954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problems with fullscreen mode Win32

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;

// ...

if(ContextPtr->Fullscreen)
{
  memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
  dmScreenSettings.dmSize = sizeof(dmScreenSettings);
  dmScreenSettings.dmPelsWidth = ContextPtr->ScreenWidth;
  dmScreenSettings.dmPelsHeight = ContextPtr->ScreenHeight;
  dmScreenSettings.dmBitsPerPel = ContextPtr->ScreenDepth;
  dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;

  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 :)
Thanks

venomxxl
Junior Poster in Training
72 posts since Jan 2009
Reputation Points: 34
Solved Threads: 7
 

http://msdn.microsoft.com/en-us/library/dd183411%28v=vs.85%29.aspx
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.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

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.

venomxxl
Junior Poster in Training
72 posts since Jan 2009
Reputation Points: 34
Solved Threads: 7
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: