help with copying a directx surface.

Started by
8 comments, last by CJWR 18 years, 8 months ago
i have the following two directx surfaces: LPDIRECTDRAWSURFACE4 lpddsprimary; //dd primary surface LPDIRECTDRAWSURFACE4 lpddsback; //dd back surface i want to copy lpddsback to lpddsprimary, while leaving lpddsback the same. (ie, not page flipping) how can i do this? thanks. [Edited by - CJWR on July 29, 2005 6:20:47 AM]
Charles Reed, CEO of CJWR Software LLC
Advertisement
wow, i thought is would have been an easier question to get answered. just writing lpddsprimary = lpddsback; doesn't work by the way, i tried that.
Charles Reed, CEO of CJWR Software LLC
come on? how hard can this be?
Charles Reed, CEO of CJWR Software LLC
You could just set the second surface as render target (its SetRenderTarget) and then render a quad that fills the entire screen with a texture containing the data from surface 1. Textures (in mdx at least) have a member function called GetSurfaceLevel which retrieves the textures surface.
Maybe theres an easier way but this works.

-CProgrammer
D3DXLoadSurfaceFromSurface()?
i'm using direct draw, i don't think 3d stuff will work. why isn't there a copy function for these things?
Charles Reed, CEO of CJWR Software LLC
How about:

memcpy( lpddsprimary, lpddsback, sizeof( *lpddsback ) );

I'm assuming here that they are the same size...
Quote:Original post by Simian Man
How about:

memcpy( lpddsprimary, lpddsback, sizeof( *lpddsback ) );

I'm assuming here that they are the same size...


yes, they are the same size. i page flip them every frame. this is just a special case for talking to npcs.
Charles Reed, CEO of CJWR Software LLC
Well then memcpy should work. It is defined as follows:

memcpy( void* dest, void* source, size_t size );

It copies "size" bites from "source" to "dest".

The only possible pitfall is if DirectX puts the fact that one is the backbuffer hardcoded in the structure. I don't know anything about DirectX, it may have other stuff in the header that you don't want to copy.

Did it work?
Quote:Original post by Simian Man
Well then memcpy should work. It is defined as follows:

memcpy( void* dest, void* source, size_t size );

It copies "size" bites from "source" to "dest".

The only possible pitfall is if DirectX puts the fact that one is the backbuffer hardcoded in the structure. I don't know anything about DirectX, it may have other stuff in the header that you don't want to copy.

Did it work?


no, it didn't.
Charles Reed, CEO of CJWR Software LLC

This topic is closed to new replies.

Advertisement