Archived

This topic is now archived and is closed to further replies.

Directdraw quits after init!

This topic is 6363 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

After I initialize directdraw with 800x600x16 if I do anything to the primary surface it quits right away. If I don''t it waits for me to press the esc key. there''s some short code at the bottom thx. //////////////////////////////////////////////////////////// int Game_Main(void *parms = NULL, int num_parms = 0) { if (KEYDOWN(VK_ESCAPE)) SendMessage(main_window_handle,WM_CLOSE,0,0); FillSurface(primsurf,_RGB16BIT565(0,255,0) return(1); } // end Game_Main //////////////////////////////////////////////////////////// int Game_Init(void *parms = NULL, int num_parms = 0) { InitDirectDraw(800,600,16); return(1); } // end Game_Init ///////////////////////////////////////////////////////////// //////////////FROM HEADER/CPP ENGINE FILE //////////////// ///////////////////////////////////////////////////////////// int InitDirectDraw(int width, int height, int bpp) // Creates DirectDraw and creates a double buffer { LPDIRECTDRAW ddraw1obj; DirectDrawCreate( NULL, &ddraw1obj, NULL); ddraw1obj->QueryInterface(IID_IDirectDraw4,(LPVOID *)&ddraw4obj); ddraw1obj->Release(); ddraw1obj = NULL; ddraw4obj->SetCooperativeLevel( main_window_handle, DDSCL_EXCLUSIVE| DDSCL_FULLSCREEN| DDSCL_ALLOWMODEX); ddraw4obj->SetDisplayMode(width, height, bpp, 0, 0); ShowCursor(FALSE); DDSURFACEDESC2 surfdesc; memset(&surfdesc,0,sizeof(surfdesc)); surfdesc.dwSize=sizeof(surfdesc); surfdesc.dwFlags= DDSD_CAPS || DDSD_BACKBUFFERCOUNT; surfdesc.dwBackBufferCount = 1; surfdesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE || DDSCAPS_COMPLEX || DDSCAPS_FLIP); if(FAILED(ddraw4obj->CreateSurface(&surfdesc,&primsurf,NULL))) return(0); surfdesc.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER; if(FAILED( primsurf->GetAttachedSurface&surfdesc.ddsCaps,&backsurf))) return(0); width = Screen_Width; height = Screen_Height; bpp = Screen_BPP; return(1); } ///////////////////////////////////////////////////////////////// int FillSurface(LPDIRECTDRAWSURFACE4 surface, int color) { //clear out ddbltfx struct memset(&bltfxstruct,0,sizeof(bltfxstruct)); bltfxstruct.dwSize=sizeof(bltfxstruct); bltfxstruct.dwFillColor = color; if(FAILED(surface->Blt(NULL,NULL,NULL,DDBLT_COLORFILL | DDBLT_WAIT, &bltfxstruct))) return(0); return(1); } /////////////////////////////////////////////////////////////////

Share this post


Link to post
Share on other sites
DDSCAPS_PRIMARYSURFACE || DDSCAPS_COMPLEX || DDSCAPS_FLIP);

You are using C++ "OR" instead of binary "OR"

Remove the || and make it one |

That will probably fix your problem

Share this post


Link to post
Share on other sites