Jump to content
  • Advertisement


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


need help with direct draw

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

I''m trying to do direct draw and I''m getting an error. I pinpointed it down to the line that''s messing up. When I comment it out the program switches into full screen mode and then resumes windows normally. When I include it in the program the program switches into full screen then goes back to windows in 640* 480 mode (I run my windows in 1024*768) then I get this error in a popup window Microsoft Development Environment An unhandled exception of type ''System.NullReferenceException'' occurred in game.exe Additional information: Object reference not set to an instance of an object. Here''s the code, I put a comment above the line that''s not working #include <ddraw.h> #include <windows.h> #include <mmsystem.h> #define INITGUID #define DDRAW_INIT_STRUCT(ddstruct) { memset(&ddstruct,0,sizeof(ddstruct)); ddstruct.dwSize=sizeof(ddstruct); } LPDIRECTDRAW7 lpdd; LPDIRECTDRAWSURFACE7 lpddsPrimary; LPDIRECTDRAWSURFACE7 lpddsBack; DDSURFACEDESC2 ddsd; LPDDSCAPS2 ddscaps; HWND hwnd; void DDInit(void); void DDClose(void); void CreateSurfaces(void); int main() { DDInit(); CreateSurfaces(); DDClose(); } void DDInit(void) { DirectDrawCreateEx(NULL, (void **)&lpdd, IID_IDirectDraw7, NULL); lpdd->SetCooperativeLevel(hwnd, DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT); lpdd->SetDisplayMode(640,480,32,0,0); } void DDClose(void) { lpdd->Release(); return; } void CreateSurfaces() { HRESULT ddrval; DDRAW_INIT_STRUCT(ddsd); memset(&ddsd,0,sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd.dwBackBufferCount = 1; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; lpdd->CreateSurface(&ddsd, &lpddsPrimary, NULL); memset(&ddsd,0,sizeof(ddsd)); ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER; // the next line is the one that I am getting problems with lpddsPrimary->GetAttachedSurface(&ddsd.ddsCaps, &lpddsBack); }

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!