DDBLTFX ddbltfx;
RECT dest_rect;
memset(&ddbltfx,0,sizeof(ddbltfx));
ddbltfx.dwSize = sizeof(ddbltfx);
ddbltfx.dwFillColor = RGB16(rand()%256,rand()%256,rand()%256);
unsigned short y1 = rand()%SCREEN_HEIGHT;
unsigned short y2 = rand()%SCREEN_HEIGHT;
unsigned short x1 = rand()%SCREEN_WIDTH;
unsigned short x2 = rand()%SCREEN_WIDTH;
dest_rect.bottom = y2;
dest_rect.top = y1;
dest_rect.left = x1;
dest_rect.right = x2;
lpddsprimary->Blt(&dest_rect,NULL,NULL,DDBLT_COLORFILL | DDBLT_WAIT,&ddbltfx);
ok, what it''s telling me is that there are negative values for the coordinates. The program still works without crashing but when you exit it gives you the "this program now has to close" message which is annoying . I made the variables unsigned, shouldn''t that make the negatives go away?
Direct3D9: (ERROR) :Invalid destination dimensions: Zero/Negative Heights and/or Widths not allowed
Direct3D9: (ERROR) :Erroneous dest dimensions were: (wid -285, hgt -270)
I don''t know what Direct3d is doing there.
Blt Fill Problem
Oops, didn't read it correctly. I'll get back to you if I figure it out.
[edited by - Weston on July 25, 2003 9:19:00 PM]
[edited by - Weston on July 25, 2003 9:19:00 PM]
BTW, if this affects my predicament: I''m using Tricks of the Windows Game Programming Gurus. And I believe this book uses DirectX 4? I''m using DirectX 9. I copied exactly what his code said. (Understanding it too)When I''m typing the Blt function, Visual Studio gives you the parameters while you''re typing and for some reason the prototype is:
Blt(THIST_LPRECT,LPDIRECDRAWSURFACE7)
even though the book gives a couple more parameters.
Blt(THIST_LPRECT,LPDIRECDRAWSURFACE7)
even though the book gives a couple more parameters.
If you have the first edition, you're programming in DX 6.1, and in the second edition, you're drawing with DX 7.0.
If it's giving you Blt(THIST_LPRECT,LPDIRECDRAWSURFACE7), you must have a IDirectDrawSurface7 interface pointer. DirectDraw stopped at DX 7.0, so you're getting the latest interface.
From what I remember, he writes LPDIRECTDRAWSURFACE instead of LPDIRECTDRAWSURFACE4. It'll give you the wrong pointer for the code if you do it the first way. Flip forward a couple pages and see if his interface pointers change in the example code.
Other than that, check the source code.
[edited by - Weston on July 25, 2003 9:41:41 PM]
If it's giving you Blt(THIST_LPRECT,LPDIRECDRAWSURFACE7), you must have a IDirectDrawSurface7 interface pointer. DirectDraw stopped at DX 7.0, so you're getting the latest interface.
From what I remember, he writes LPDIRECTDRAWSURFACE instead of LPDIRECTDRAWSURFACE4. It'll give you the wrong pointer for the code if you do it the first way. Flip forward a couple pages and see if his interface pointers change in the example code.
Other than that, check the source code.
[edited by - Weston on July 25, 2003 9:41:41 PM]
You see, the thing is, I chose to code with DirectX 9. I was afraid something like this might happen. But that wasn''t my original question anyways...how do i fix the negatives?
I think the problem is indicated by the error messages... negative width/height.
Take your code...
unsigned short y1 = rand()%SCREEN_HEIGHT;
unsigned short y2 = rand()%SCREEN_HEIGHT;
unsigned short x1 = rand()%SCREEN_WIDTH;
unsigned short x2 = rand()%SCREEN_WIDTH;
dest_rect.bottom = y2;
dest_rect.top = y1;
dest_rect.left = x1;
dest_rect.right = x2;
and ask yourself what if y1>y2 or x1>x2?
I''d suggest sorting your coords...
if y2>y1 then swap y1,y2 ... etc before applying them to the rect
Hope this helps
Stevie
Don''t follow me, I''m lost.
Take your code...
unsigned short y1 = rand()%SCREEN_HEIGHT;
unsigned short y2 = rand()%SCREEN_HEIGHT;
unsigned short x1 = rand()%SCREEN_WIDTH;
unsigned short x2 = rand()%SCREEN_WIDTH;
dest_rect.bottom = y2;
dest_rect.top = y1;
dest_rect.left = x1;
dest_rect.right = x2;
and ask yourself what if y1>y2 or x1>x2?
I''d suggest sorting your coords...
if y2>y1 then swap y1,y2 ... etc before applying them to the rect
Hope this helps
Stevie
Don''t follow me, I''m lost.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement