///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int Game_Main(void *parms = NULL, int num_parms = 0)
{
// test if user is hitting ESC and send WM_CLOSE
if (KEYDOWN(VK_ESCAPE))
SendMessage(main_window_handle,WM_CLOSE,0,0);
FillSurface(backsurf,_RGB16BIT565(32,64,32));
Draw_Text_GDI("HI",0,0,_RGB16BIT565(255,255,0),backsurf);
FlipSurfaces();
return(1);
} // end Game_Main
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int InitDirectDraw(int width, int height, int bpp)
// Creates DirectDraw and creates a double buffer
{
LPDIRECTDRAW ddraw1obj; //ddraw 1.0
DirectDrawCreate( NULL, &ddraw1obj, NULL); //create the object
ddraw1obj->QueryInterface(IID_IDirectDraw4,(LPVOID *)&ddraw4obj); //get the ddraw 4.0 with 1.0
ddraw1obj->Release(); //dump ddraw 1.0 obj, we using 4.0 now
ddraw1obj = NULL; //set it to null just for the hell of it
//from now on we can always use ddraw 4.0, which is really directx 6.0
ddraw4obj->SetCooperativeLevel( main_window_handle, //windows stuff
DDSCL_EXCLUSIVE| //don''t let anything interrupt ddraw
DDSCL_FULLSCREEN| //fullscreen is nice
DDSCL_ALLOWMODEX); //modex is some vga thing
ddraw4obj->SetDisplayMode(width, height, bpp, 0, 0); //simply set the display,bpp is bits per pixel
ShowCursor(FALSE); //don''t want to see windows cursor
memset(&surfdesc,0,sizeof(surfdesc)); //zero out and set size
surfdesc.dwSize=sizeof(surfdesc);
surfdesc.dwFlags= DDSD_CAPS | DDSD_BACKBUFFERCOUNT; //setting these enable dwCaps and dwBackBufferCount
surfdesc.dwBackBufferCount = 1; //set backbuffercount to 1, double buffer including primary surface
surfdesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; //ddsCaps is just required to get to dwCaps
//the settings above are required if you want to make a double buffer
if(FAILED(ddraw4obj->CreateSurface(&surfdesc,&primsurf,NULL))) //create the primary surface from the ddraw4 object
return(0);
surfdesc.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER; // set the description to backbuffer
if(FAILED(primsurf->GetAttachedSurface(&surfdesc.ddsCaps,&backsurf))) //now using the description(set to back buffer) we attach the backsurf(declared at top) to primsurf
return(0);
//make the following global so we can use em in main program
width = Screen_Width;
height = Screen_Height;
bpp = Screen_BPP;
return(1);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int Draw_Text_GDI(char *text,
int x,
int y,
COLORREF color,
LPDIRECTDRAWSURFACE4 surface)
{
HDC devicecontext;
surface->GetDC(&devicecontext);
SetTextColor(devicecontext,color);
SetBkMode(devicecontext,TRANSPARENT);
TextOut(devicecontext,x,y,text,strlen(text));
surface->ReleaseDC(devicecontext);
return(1);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
surface coords not correct WHY!?
Under the game main below I drawtext to the backsurface, when I do that and then flip the location is not at 0,0. it''s like 40 pixels to the right. and 20 pixels down. It''s not just drawing text, when I blit bitmaps it''s the same thing. It''s like the whole surface is rigged or something. Below I have the game main(which draws the text) initdirectdraw(which creates primary surface etc) and the drawtextfunction itself. Any ideas on what''s causing this?
THX!
Perhaps the problem is that the monitor settings are changed?
If there is a black edge above and to the left of your surfce that might be the problem.
See what happens if you play with your monitor a bit.
If you move the screen up a bit and you see more of the surface coming up at the bottom then that is your problem.
I don''t know how to fix it.
If there is a black edge above and to the left of your surfce that might be the problem.
See what happens if you play with your monitor a bit.
If you move the screen up a bit and you see more of the surface coming up at the bottom then that is your problem.
I don''t know how to fix it.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement