// Globals
LPDIRECT3DSURFACE8 lpd3ds;
int *iBuffer;
D3DLOCKED_RECT LockRect;
// COnstants
#define _RGB32BIT(a,r,g,b) ((b) + ((g) << 8) + ((r) << 16) + ((a) << 24))
//In my init code
lp3dd->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &lpd3ds);
LockRect.Pitch = 3200;
LockRect.pBits = &iBuffer
//In my Render loop
lpd3ds->LockRect(&LockRect, NULL, NULL);
iBuffer[x+(y*LockRect.Pitch >> 3)] = _RGB32BIT(255, 255, 100, 255);
lpd3ds->UnlockRect();
I suspect that my problem is the pitch. How do you get the pitch of the backbuffer? I just guessed that it was 3200, because I''m using 800X600X32
Am I on the completely wrong track?
-Forcas
"Elvis is alive. He is Barney the purple dinosaur. He is the pied piper that leads our children into the wages of sin and eternal damnation."
Direct Access to Backbuffer in D3D8
Hi! Lately I''ve been trying to get direct access to the backbuffer, and it hasn''t been working. Here''s how I tried it:
Whoa, don''t know how you got that pitch, but that probably is your problem. The pitch should be 800 * 600 * 4 (32-bit equals 4 bytes) which equals 1920000.
Hope that helps
Hope that helps
Whoa.... I guess that''d be the problem. I thought the pitch just described one line, so I did 800X4. I''ll try it out. Thanks.
-Forcas
"Elvis is alive. He is Barney the purple dinosaur. He is the pied piper that leads our children into the wages of sin and eternal damnation."
-Forcas
"Elvis is alive. He is Barney the purple dinosaur. He is the pied piper that leads our children into the wages of sin and eternal damnation."
Ummm.... nope. Still doesn''t work.
-Forcas
"Elvis is alive. He is Barney the purple dinosaur. He is the pied piper that leads our children into the wages of sin and eternal damnation."
-Forcas
"Elvis is alive. He is Barney the purple dinosaur. He is the pied piper that leads our children into the wages of sin and eternal damnation."
You should link the buffer to LockRect.pBits after locking the surface, not before it.
After locking the surface, the pitch will be filled to LockRect.Pitch automatically, so don''t worry about it.
GetBackBuffer( ...... );
lpd3ds->LockRect( &LockRect, NULL, 0 );
DWORD* dwBuffer = (DWORD*)LockRect.pBits;
dwBuffer[x+(y*LockRect.Pitch>>3)] = _RGB32BIT(255,255,100,255);
lpd3ds->UnlockRect();
hope this piece of code helps
After locking the surface, the pitch will be filled to LockRect.Pitch automatically, so don''t worry about it.
GetBackBuffer( ...... );
lpd3ds->LockRect( &LockRect, NULL, 0 );
DWORD* dwBuffer = (DWORD*)LockRect.pBits;
dwBuffer[x+(y*LockRect.Pitch>>3)] = _RGB32BIT(255,255,100,255);
lpd3ds->UnlockRect();
hope this piece of code helps
The program still won''t run. It shuts down as soon as it gets to this line:
dwBuffer[x+(y*LockRect.Pitch>>3)] = _RGB32BIT(255,255,100,255);
What could be wrong? I''ve tried putting it inside beginscene and endscene, and outside(that''s where I think it''s supposed to go).
Well... either way, it doesn''t work. Any idea what could be wrong?
-Forcas
"Elvis is alive. He is Barney the purple dinosaur. He is the pied piper that leads our children into the wages of sin and eternal damnation."
dwBuffer[x+(y*LockRect.Pitch>>3)] = _RGB32BIT(255,255,100,255);
What could be wrong? I''ve tried putting it inside beginscene and endscene, and outside(that''s where I think it''s supposed to go).
Well... either way, it doesn''t work. Any idea what could be wrong?
-Forcas
"Elvis is alive. He is Barney the purple dinosaur. He is the pied piper that leads our children into the wages of sin and eternal damnation."
How are you initializing your D3DPRESENTPARAMETERS ?
Make sure you have the D16_LOCKABLE or whatever that is....or else yuo can''t have access to the back buffer....
dankydoo
Make sure you have the D16_LOCKABLE or whatever that is....or else yuo can''t have access to the back buffer....
dankydoo
I wonder about your line
As one Pixel is 4 Bytes your index "x+(y*LockRect.Pitch>>3)" doesn''t seem logical to me. To get the correct line you should imo use y*LockRect.Pitch and to get the right x-value you should use 4*x. So after all I would write:
Could you tell me why you were using your version of that line, as I can''t figure out for what reason you wrote (y*LockRect.Pitch>>3), especially the >>3
Don''t hang me, it''s just a guess
dwBuffer[x+(y*LockRect.Pitch>>3)] = _RGB32BIT(255,255,100,255);
As one Pixel is 4 Bytes your index "x+(y*LockRect.Pitch>>3)" doesn''t seem logical to me. To get the correct line you should imo use y*LockRect.Pitch and to get the right x-value you should use 4*x. So after all I would write:
dwBuffer[4*x+y*LockRect.Pitch] = _RGB32BIT(255,255,100,255);
Could you tell me why you were using your version of that line, as I can''t figure out for what reason you wrote (y*LockRect.Pitch>>3), especially the >>3
Don''t hang me, it''s just a guess
The pitch is equal to the number of bytes in one line. BinaryMagus is wrong.
But generally you can''t just assume the pitch is equal to 800x4, you have to query the surface for it''s pitch, as the card manufacturer may make the pitch something else.
For example, on my card, the pitch of an 800x600x32bit surface is 3584, not 3200. That is 3584 bytes per line.
Awroight! I got it workin''! Thanks to everyone who replied... especially yangwaiwai and dankydoo! Your posts were the keys. Right after I set the present parameters flag member, evrything fell in to place. Thanks.
-Forcas
"Elvis is alive. He is Barney the purple dinosaur. He is the pied piper that leads our children into the wages of sin and eternal damnation."
-Forcas
"Elvis is alive. He is Barney the purple dinosaur. He is the pied piper that leads our children into the wages of sin and eternal damnation."
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement