Original Post
Ok im new to directdraw and am creating a simple program which uses double buffering techniques (or so i think: i tend to mix up double buffering and page flipping!
).
Ok what i am trying to do is:
I am working in 640x480x32 mode.
I have two surfaces -the primary and the backbuffer.
The backbuffer is 100x100 big.
I have completely filled the back buffer to green.
Then I have copied the back buffer to the primary surface.
But instead of displaying a 100x100 rectangle of green in the top left corner, my program outputs the whole screen as green!
I set my backbuffer as 100x100, not 640x480!
Heres some of the relevant code from Game_Init() and Game_Main():
I bet this is some simple problem, so remember that im new to directx! Thanks for your time
//FROM GAME_INIT()
//Create primary surface
INIT_DXSTRUCT(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if (FAILED(lpdd->CreateSurface(&ddsd,&lpddsPrimary,NULL)))
{
return (0);
}
//Create back buffer
INIT_DXSTRUCT(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = 100;
ddsd.dwHeight = 100;
if (FAILED(lpdd->CreateSurface(&ddsd,&lpddsBack,NULL)))
{
return (0);
}
//THIS IS THE WHOLE OF GAME_MAIN()
void Game_Main(HWND hwnd)
{
//Create colour struct
DDBLTFX fx;
INIT_DXSTRUCT(fx);
fx.dwFillColor = RGB32(0,0,0,0);
//Now clear back buffer
if (FAILED(lpddsBack->Blt(NULL,NULL,NULL,
DDBLT_COLORFILL |
DDBLT_WAIT,&fx)))
{
//Error
}
//Now set back buffer all green
INIT_DXSTRUCT(fx);
fx.dwFillColor = RGB32(0,0,255,0);
lpddsBack->Blt(NULL,NULL,NULL,DDBLT_COLORFILL |
DDBLT_WAIT,&fx);
//Now copy back buffer to primary surface
lpddsPrimary->Blt(NULL,lpddsBack,NULL,DDBLT_WAIT,NULL);
Sleep(1000);
} //End Game_Main