• Advertisement


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

D3DDevice->Clear() how?

This topic is 5965 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to clear only a certain area of my window-based directx8 application I do the following to clear the area: D3DRECT *area; area->x1 =120; area->y1 =120; area->x2 =220; area->y2 =220; D3D8.D3DDevice->Clear(1, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(128, 128, 128), 1.0f, 0 ); when I do this my application crashes, and I have no idea what I do wrong...the coordinates of my window-based app are 100, 100 and the window is 320 x 320 in size so the area I clear is valid. so what am I doing wrong then?

Share this post

Link to post
Share on other sites
This ain''t good:

D3DRECT * area;
area->.. = n;

since area is an uninitialized pointer, it will cause your system to crash because you do writes into the nirvana.

whenever pointer are requested by a function, that means having the specific object on stack (or heap) and pass the adress (or heap pointer) to that function.

a valid call would look like this:

D3DRECT area;
area.x1 = area.y1 = 120;
area.x2 = area.y2 = 220;
D3D8.D3DDevice->Clear ( 1, &area, D3DCLEAR_TARGET, D3DCOLOR_XRGB(80x80,0x80,x80), 1.0f, 0 );

btw. I noticed you calling Clear() with rect count 1 and rect pointer NULL - this is another thing DX8 dislikes alot

hope that helped you out a little and make shure to grab a good
book on C/C++ - just my two cents

Share this post

Link to post
Share on other sites

  • Advertisement