Original Post
I'm using Win32 and a bastardized mix of C and C++ (wait! hold flame!). I'm using GetDeviceCaps to determined whether the screen is 16 or 32 bpp and then make my video buffer WORD* or DWORD*, respectively.
void Game_Main()
{
DWORD *video_buffer = NULL; // here
long lPitch;
int x, y;
DDSURFACEDESC ddsd;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
G.lpDDSBack->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WAIT, NULL);
//DRAWING HERE
video_buffer = (DWORD*)ddsd.lpSurface; //here
lPitch = ddsd.lPitch >> 2;
for (y = 0; y < G.SCREEN_HEIGHT; ++y)
{
for (x = 0; x < G.SCREEN_WIDTH; ++x)
{
video_buffer[x + y*lPitch] = RGB32COLOR(15,63,15);
}
}
G.lpDDSBack->Unlock(NULL);
while(G.lpDDSPrimary->Flip(NULL, DDFLIP_WAIT) != DD_OK);
Sleep(66); Now I'm not sure how to go about this. I can't see how to use template but I have the feeling a switch statement and void* is going to show up somewhere in my solution. Is there a more "elegant" way to solve this? Am I clear as mud? [smile]