displaying a bitmap color problem
my problem is when i display my bitmap the colors are all screwed up and i dont know why? also do i need to implement a back buffer or will the flip call be suffice in game main?
im using msvc5++ and win98
// WINX GAME PROGRAMMING CONSOLE FUNCTIONS ////////////////
int Game_Init(void *parms, int num_parms)
{
LPDIRECTDRAW lpdd1;
// first create base IDirectDraw interface
if (FAILED(DirectDrawCreate(NULL, &lpdd1, NULL)))
return(0);
// now query for IDirectDraw4
if (FAILED(lpdd1->QueryInterface(IID_IDirectDraw4,
(LPVOID *)&lpdd)))
return(0);
// set cooperation to full screen
if (FAILED(lpdd->SetCooperativeLevel(main_window_handle,
DDSCL_FULLSCREEN / DDSCL_ALLOWMODEX /
DDSCL_EXCLUSIVE / DDSCL_ALLOWREBOOT)))
return(0);
// set display mode
if (FAILED(lpdd->SetDisplayMode(WWIDTH,WHEIGHT,BPP,0,0)))
return(0);
DDRAW_INIT_STRUCT(ddsd);
// enable valid fields
ddsd.dwFlags = DDSD_CAPS / DDSD_BACKBUFFERCOUNT;
ddsd.dwBackBufferCount =1;
// request primary surface
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE / DDSCAPS_COMPLEX / DDSCAPS_FLIP;
// create the primary surface
if (FAILED(lpdd->CreateSurface(&ddsd, &lpddsprimary, NULL)))
return(0);
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
if (FAILED(lpddsprimary->GetAttachedSurface(&ddsd.ddsCaps,&lpddsback)))
return 0;
// load the 24-bit image
if (!loadbitmap(ℑ,"brick.bmp"))
return(0);
createbob(&bsprite,64,64,DDSCAPS_SYSTEMMEMORY);
loadbob(&bsprite,ℑ,0,0,0);
bsprite.x=100;
bsprite.y=100;
// unload the bitmap file, we no longer need it
unloadbitmap(ℑ);
return 1;
} // end Game_Init
///////////////////////////////////////////////////////////
int Game_Shutdown(void *parms, int num_parms)
{
destroybob(&bsprite);
if (lpddsprimary)
{
lpddsprimary->Release();
lpddsprimary = NULL;
} // end if
// release the directdraw object
if (lpdd!=NULL)
lpdd->Release();
return 1;
} // end Game_Shutdown
///////////////////////////////////////////////////////////
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
drawbob(&bsprite,lpddsback);
return 1;
} // end Game_Main
Im sorry, but that code doesn''t help us. The reason things are wrong is probably because you''re not loading the pallete associated with the bitmap. We need to see this phantom LoadBitmap function .
=======================================
A man with no head is still a man.
A head with no man is plain freaky.
=======================================
A man with no head is still a man.
A head with no man is plain freaky.
Zipster is right, bitmaps will almost never load with the correct colors, you must always use a pallette with your graphics.
I wonder though, is this pallette problem the same with file types such as jpeg & gif?
I wonder though, is this pallette problem the same with file types such as jpeg & gif?
well ive been reading the book and do i still need to load a pallete if im using 16bpp? if so how do u load a 16bit palette?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement