int Game_Init(void *parms, int num_parms)
{
fin.open("map1.txt", ios::in);
// first create base IDirectDraw interface
if (FAILED(DirectDrawCreate(NULL, &lpdd1, NULL)))
return(0);
// now query for IDirectDraw7
if (FAILED(lpdd1->QueryInterface(IID_IDirectDraw7,(LPVOID *)&lpdd7)))
return(0);
// set cooperation to full screen
if (FAILED(lpdd7->SetCooperativeLevel(main_window_handle,DDSCL_FULLSCREEN |
DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT)))
return(0);
// set display mode
if (FAILED(lpdd7->SetDisplayMode(WWIDTH,WHEIGHT,BPP,0,0)))
return(0);
DD_INIT_STRUCT(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.dwBackBufferCount = 1;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
//create primary surface
if (FAILED(lpdd7->CreateSurface(&ddsd, &lpddsprimary, NULL)))
return 0;
//create offscreen surface
offsurface = createsurface(WWIDTH,WHEIGHT,DDSCAPS_VIDEOMEMORY);
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
if (FAILED(lpddsprimary->GetAttachedSurface(&ddsd.ddsCaps, &lpddsback)))
return(0);
if (!loadbitmap(&bitmap,"base1.bmp"))
return(0);
offsurface->Lock(NULL,&ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT,NULL);
// get video pointer to primary surfce
UCHAR *image_buffer = (UCHAR *)ddsd.lpSurface;
for (int x=0;x<WHEIGHT;x++)
{
memcpy(ℑ_buffer[x*ddsd.lPitch],&bitmap.buffer[x*WWIDTH*2],WWIDTH*2);
}
if (FAILED(offsurface->Unlock(NULL)))
return 0;
readmap();
unloadbitmap(&bitmap);
fin.close();
return 1;
}
int Game_Main(void *parms, int num_parms)
{
// make sure this isn't executed again
if (window_closed)
return(0);
// for now test if user is hitting ESC and send WM_CLOSE
if (KEYDOWN(VK_ESCAPE))
{
PostMessage(main_window_handle,WM_CLOSE,0,0);
window_closed = 1;
} // end if
drawmap();
lpddsprimary->Flip(NULL, DDFLIP_WAIT);
return 1;
} // end Game_Main
Edited by - omegasyphon on 12/28/00 12:08:51 AM
check this code
can someone tell me what is wrong with this code:
you need to tell us what AREA you are having probelm with and EXPLAIN WTF you are trying to do before asking a question like this... gezz.. PLUS I see that it looks like code for the book programing Tips of the Gurus... by Lamothe
You have a variable problem. It seems like you want offscreen to point to an off-screen buffer. But in the GetAttachedSurface() you used lpddsback.
If you missed a great moment in history don't worry, it'll repeat itself.
what's the screen width?
whats the screen height?
how mny bits per pixel?
offsurface->Lock(NULL,&ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT,NULL);
// get video pointer to primary surfce
UCHAR *image_buffer = (UCHAR *)ddsd.lpSurface;
for (int x=0;x{
memcpy(ℑ_buffer[x*ddsd.lPitch],&bitmap.buffer[x*WWIDTH*2],WWIDTH*2);
}
if (FAILED(offsurface->Unlock(NULL)))
return 0;
there's the bug
DON'T mix up LaMothe's code with high-color modes if you are learning the basics.
Edited by - myself on December 28, 2000 1:01:03 PM
whats the screen height?
how mny bits per pixel?
offsurface->Lock(NULL,&ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT,NULL);
// get video pointer to primary surfce
UCHAR *image_buffer = (UCHAR *)ddsd.lpSurface;
for (int x=0;x{
memcpy(ℑ_buffer[x*ddsd.lPitch],&bitmap.buffer[x*WWIDTH*2],WWIDTH*2);
}
if (FAILED(offsurface->Unlock(NULL)))
return 0;
there's the bug
DON'T mix up LaMothe's code with high-color modes if you are learning the basics.
Edited by - myself on December 28, 2000 1:01:03 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement