Jump to content
  • Advertisement


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


Directdraw quits after init!

This topic is 6668 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

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!