Archived

This topic is now archived and is closed to further replies.

Headhunter

Locking the Backbuffer , HOW ?

Recommended Posts

Headhunter    122
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 !

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Moe    1256
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.

Share this post


Link to post
Share on other sites
Headhunter    122
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 :-)

Share this post


Link to post
Share on other sites
Headhunter    122

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 !

Share this post


Link to post
Share on other sites
Headhunter    122

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 !

Share this post


Link to post
Share on other sites
CrazedGenius    156
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.

Share this post


Link to post
Share on other sites
Headhunter    122
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 ;-)

Share this post


Link to post
Share on other sites
invective    118
Oh you mean change the texture for the units, not the boxes you are drawing... well then you might want to pre compute textures, as locking EVERY texture every frame is way to slow. You can also blend with the material color, but i don''t think that will give you quite the effect you want... it depends on your model too though. You could have some untextured polys in the model, and just draw these with the material set. this would let you change the color of only certain polys in the model.

Share this post


Link to post
Share on other sites
Possibility    122
In order to lock the back buffer, you have to set a flag to lockable when creating the backbuffer. I do not know the specific code for it off hand right now but look up in the sdk for creating the primary and backbuffer swap change, there is a flag that has to be set to something like lockable in order to lock the backbuffer later on.

While we are on this subject, does anyone know how to create a copy of the backbuffer that resides in system memory?

Possibility

Share this post


Link to post
Share on other sites