Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I thought I read somewhere that one could create a 'offscreen plain surface' from an existing system memory buffer, but I cannot seem to find the reference anymore.

My use case is copying a frame from video memory to a pre-allocated buffer, and right now I perform this in two steps: copying to an 'offscreen plain surface' (GetRenderTargetData), and from that to a pre-allocated buffer. If I could create the surface from the pre-allocated buffer, it would save a copy. I am using Direct3D9Ex on Windows 7.

share|improve this question
Perhaps you were thinking of DirectDraw? DirectDraw's surface creation methods implied you could create one with pre-allocated bits (that it would probably copy), although I've never tried it and I'm not sure it would work. – Josh Petrie Jun 19 '14 at 15:55
up vote 1 down vote accepted

There are no overloads for CreateOffscreenPlainSurface that take a pre-allocated memory buffer.

D3D will generally want to own the memory its resources, for various reasons. Even methods that accept "user" data pointers, like DrawPrimitivesUP tend to guarantee that the data referred to by the user pointer has been "completely accessed" by the time the function returns, which allows for the API to copy the data if needed.

If there was such a method of creating a surface with a pointer to the surface bits, you wouldn't actually avoid the copy by using it. You'd just avoid having to write the copy yourself; D3D would do it internally.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.