This questions is REALLY easy or REALLY hard

Started by
6 comments, last by PSioNiC 22 years, 8 months ago
If i have a IDirect3DSurface8 interface thats loaded with good data, how do i copy that surface to the back buffer? If all you have to do is just lock and memcpy, how would i get a pointer to the back buffer?
"This is stupid. I can't believe this! Ok, this time, there really IS a bug in the compiler."... 20 mins pass ..."I'M AN IDIOT!!!"
Advertisement
You can get the backbuffer surface using the GetBackBuffer function. Like this:

IDirect3DSurface8 *BackBuffer;

D3DDevice->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &BackBuffer);

Then you should use should use something like copyrects to copy the data to the backbuffer...

If you have multiple backbuffers remember to replace the first parameter with the backbuffer index you are referring - starting from 0.

However I have not done this so correct me if I am wrong.

Edited by - skallio on July 24, 2001 11:05:59 AM
I''ve seen the GetBackBuffer method, but i wasn''t sure if it copied the data from the back buffer to your supplied surface, or if it returned a pointer to the back buffer

"This is stupid. I can't believe this! Ok, this time, there really IS a bug in the compiler."... 20 mins pass ..."I'M AN IDIOT!!!"
I think it return a pointer to the backbuffer, not a copy of it.
This brought up an idea.. is it possible to use IDirect3DSurface8, GetBackBuffer and CopyRects to simulate DirectDraw... to create HUDs for example.. Wouldn''t it be easier than texturing quads?? So you would fill the HUD graphic in one surface, and then use CopyRects to copy the graphics on the surface to a surface obtained by GetBackBuffer()? Is this possible?
quote:Original post by skallio
This brought up an idea.. is it possible to use IDirect3DSurface8, GetBackBuffer and CopyRects to simulate DirectDraw... to create HUDs for example.. Wouldn''t it be easier than texturing quads?? So you would fill the HUD graphic in one surface, and then use CopyRects to copy the graphics on the surface to a surface obtained by GetBackBuffer()? Is this possible?


Yup. I have done exactly that. I use it to draw a full scene background for a 2D Fighting game I am making. I figured I would make 2 versions of my Graphics engine, one using strict Direct Draw another using D3D8. Works nicely.

-----------------------------
kevin@mayday-anime.com
http://dainteractive.mayday-anime.com
-----------------------------kevin@mayday-anime.comhttp://www.mayday-anime.com
quote:Original post by skallio
This brought up an idea.. is it possible to use IDirect3DSurface8, GetBackBuffer and CopyRects to simulate DirectDraw... to create HUDs for example.. Wouldn''t it be easier than texturing quads?? So you would fill the HUD graphic in one surface, and then use CopyRects to copy the graphics on the surface to a surface obtained by GetBackBuffer()? Is this possible?


That sounds like a good idea...one question (if this is a stupid question, forgive me, I''m new at this): would you still keep the features associated with using Direct3D over DirectDraw (like performance, special effects, etc) by emulating DirectDraw like that?

-Normie

"But time flows like a river... and history repeats."
...
So...what about beaver dams?
I am a devout follower of the"Lazy Programmer's Doctrime"(tm)...and I'm damned proud of it, too!-----"I came, I saw, I started makinggames." ... If you'll excuseme, I must resume my searchfor my long lost lobotomy stitches.
Unfortunately DirectX8 doesn''t include a directdraw interface, and as far as I know you cannot use directdraw7 with d3d8. So you have just the basic features from directdraw... Blt()(CopyRects() in d3d8), IDirect3DSurface8 and GetBackBuffer..

Hmm... no color keying supported in copyrects?
No, copy rects is just a brute copy of surface to surface. I use it of scenery or items that do not need color keying. For color-keyed surfaces, I tend to use the ID3DXSprite Interface and change the Alpha value of the color key ( D3DX_ARGB( ) ). I have been able to pretty much emulate DirectDraw with the D3DX library and functions. As for a peformance hit, I don''t know, never really tested that.

-----------------------------
kevin@mayday-anime.com
http://dainteractive.mayday-anime.com
-----------------------------kevin@mayday-anime.comhttp://www.mayday-anime.com

This topic is closed to new replies.

Advertisement