int GameMain()
{
int r,g,b;
if (KEYDOWN(VK_ESCAPE))
SendMessage(main_window_handle,WM_CLOSE,0,0);
r=rand()%32;
g=rand()%64;
b=rand()%32;
RECT dest_rect;
ddbltfx.dwFillColor=RGB16(r,g,b);
dest_rect.left=0;
dest_rect.top=0;
dest_rect.right=800;
dest_rect.bottom=600;
lpddsback->Blt(&dest_rect,NULL,NULL,DDBLT_COLORFILL|DDBLT_WAIT,&ddbltfx);
while(FAILED(lpddsprimary->Flip(NULL,DDFLIP_WAIT)));
return(1);
}
[/source]
and my RGB16 function defanition looks like this
[source]
#define RGB16(r,g,b) ((b%32)+((g%64)<<6)+((r%32)<<11))
Please help
help with blitting
Im trying to blit to the back buffer a fullscreen box and each time the screen flips I want the color to change randomly. Can someone tell me what Im doing wrong?
memsert(&ddbltfx, 0, sizeof(ddbltfx));
ddbltfx.dwSize = sizeof(ddbltfx);
stick that somewhere in your loop
ddbltfx.dwSize = sizeof(ddbltfx);
stick that somewhere in your loop
It´s very hard to say what you have done wrong. Dx crashes if Struct example DDBLTFX isn´t initialized.
Blit function first parameter could be NULL.Then it will blit to whole surface.
Post more in depth information about your problem.
Have you done basic Dx7 program which draws nothing.
As a last resort.If your program is in fullscreen and you don´t want to use Breakpoints write a result of Dx function call to a text file.
Blit function first parameter could be NULL.Then it will blit to whole surface.
Post more in depth information about your problem.
Have you done basic Dx7 program which draws nothing.
As a last resort.If your program is in fullscreen and you don´t want to use Breakpoints write a result of Dx function call to a text file.
One more thing: your macro is incorrect. Shift the value for green by 5 bits, not 6.
-Ironblayde
Aeon Software
-Ironblayde
Aeon Software
"Your superior intellect is no match for our puny weapons!"
quote: Original post by Ironblayde
One more thing: your macro is incorrect. Shift the value for green by 5 bits, not 6.
-Ironblayde
Aeon Software
Doesn''t that depend on 555 and 565?
No it doesnt. In either 565 or 555, the number of Blue bits is 5. So you must shift the green bits by 5.
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
If it were 555 mode, then the modulus following green would be 32 instead of 64, and red would be shifted by 10 bits, not 11. Actually, there's one more problem with that macro. ALWAYS enclose the parameters to a macro in parenthesis, like this:
#define RGB16(r,g,b) (((b)%32)+(((g)%64)<<5)+(((r)%32)<<11))
Otherwise, passing an expression as a parameter rather than a constant would yield an erroneous result. For example, you might pass 25+x as the red value, thinking it would evaluate to (25+x)%32, but in fact the value would be 25+(x%32).
-Ironblayde
Aeon Software
Edited by - Ironblayde on October 14, 2000 2:34:48 PM
#define RGB16(r,g,b) (((b)%32)+(((g)%64)<<5)+(((r)%32)<<11))
Otherwise, passing an expression as a parameter rather than a constant would yield an erroneous result. For example, you might pass 25+x as the red value, thinking it would evaluate to (25+x)%32, but in fact the value would be 25+(x%32).
-Ironblayde
Aeon Software
Edited by - Ironblayde on October 14, 2000 2:34:48 PM
"Your superior intellect is no match for our puny weapons!"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement