Ok, first of all, I'm not sure if this belongs to C section. Since WinAPI is written in C, I'll post here. I'm using OpenGL with Win32 windows (not sure how to call that). I can't switch to fullscreen mode after creating the window. I'm using Windows 7 (64-bits) and VS 2008. Here's the part of the code where I switch to fullscreen mode:

DEVMODE dmScreenSettings;

// ...

  memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
  dmScreenSettings.dmSize = sizeof(dmScreenSettings);
  dmScreenSettings.dmPelsWidth = ContextPtr->ScreenWidth;
  dmScreenSettings.dmPelsHeight = ContextPtr->ScreenHeight;
  dmScreenSettings.dmBitsPerPel = ContextPtr->ScreenDepth;

  if(ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
    ContextPtr->Fullscreen = false;

I've tried copying some code from SDL (SDL_dibvideo.c), but it didn't work either. There's a similar example in some book on games development:
(the link was a bit long)

Need help :)

Recommended Answers

It seems to return a number of different values.

Perhaps you should look at/print the other values as well as just checking for DISP_CHANGE_SUCCESSFUL.

It might give you some clue as to where to start looking next.

Jump to Post

All 2 Replies

ChangeDisplaySettings returns DISP_CHANGE_BADMODE, which means that the display mode is not supported. It works with 32-bit depth, I was trying to use 24-bit depth. I guess this thread is solved now. Thank you for your help Salem.

commented: Good detective work :) +17
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.