Locking the Backbuffer , HOW ?

Started by
10 comments, last by Headhunter 22 years, 5 months ago
Hi ppl ! The topic says it all : How can I lock the Backbuffer of a Direct3D8 application and write to it ? I need it for a RTS, drawing the selecting box ... I''ve tried it, but I didn''t succeed :-( Thx4help !
Greetz !
Advertisement
call:
IDirect3DDevice8::GetBackBuffer
then:
IDirect3DSurface8::LockRect
You get a pointer back along with some info about the width of the buffer etc.

But why not just use DrawPrimitive with D3DPT_LINESTRIP to make your box, its probably much faster.
Locking the back buffer is very expensive. There are MUCH better ways to draw lines.
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
You might even get away with drawing 2 trianlges with a transparent texture on them that look like a box. That depends on whether you are using 2d or 3d. If you are using 2d you might end up in a bit of trouble with the z-buffer.
quote:Original post by Anonymous Poster


But why not just use DrawPrimitive with D3DPT_LINESTRIP to make your box, its probably much faster.


Good idea, thx 4 help :-)

Greetz !

Hi !
Back to the problem of locking :
Drawing with LineStrips works fine, BUT :
There will be several players : Blue, Red, Green....
How can you lock a LPDIRECT3DTEXTURE8 and change
values there ?

I did not succeed again, though I tried hard :-(

Thx 4 help again !
Greetz !

Hi !
Back to the problem of locking :
Drawing with LineStrips works fine, BUT :
There will be several players : Blue, Red, Green....
How can you lock a LPDIRECT3DTEXTURE8 and change
values there ?

I did not succeed again, though I tried hard :-(

Thx 4 help again !
Greetz !
Again, I bet you can get the effect you''re looking for without locking the texture. Perhaps something along the lines different blending modes. Or... if there are only a couple different colors, it might be much faster to author a couple different textures rather than changing them at runtime.
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
quote:Original post by CrazedGenius
Again, I bet you can get the effect you''re looking for without locking the texture. Perhaps something along the lines different blending modes. Or... if there are only a couple different colors, it might be much faster to author a couple different textures rather than changing them at runtime.


Well, I would change them when I start the prog, NOT at runtime.
Take a look @Red Alert : There are green , red... Tanks.
I can''t imagine they''ve got 100 copys for every color ???

Blending does not work, already tested ;-)
Greetz !
Don''t texture it, just change the material color.

IDirect3DDevice8::SetMaterial

This topic is closed to new replies.

Advertisement