Archived

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

changing screen/colour resolution

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

Using openGL, I find the best resoultion to use is 800x600 with 16 bit colours. The problem is that I don''t know how to change the screen/colour resolution from within a C++ or Win32 program. At the moment all I can do is ''measure'' the width of the screen using GetSystemMetrics(...) and displaying a MessageBox("For best results change resolution to 800x600") This is especially important because, for instance, if someone has set their colours to 256 colours or their screen size to 1024x.... their computers might not handle it and the program will look rubbish or even crash. Is it because I use Borland C++ 4.50 which maybe is too old nowadays? (OK, so the link between this question and openGL is at best tenuous.)

Share this post


Link to post
Share on other sites

      
#include <windows.h>

// You'll need this on some compilers:

#ifndef CDS_FULLSCREEN

#define CDS_FULLSCREEN 0x4

#endif

void SetFullscreenMode(bool fullscreen,int w,int h,int bpp,int refresh)
{
if(fullscreen)
{
DEVMODE devmode;
devmode.dmSize = sizeof(devmode);
devmode.dmBitsPerPel = bpp;
devmode.dmPelsWidth = w;
devmode.dmPelsHeight = h;
devmode.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;

ChangeDisplaySettings(&devmode,CDS_FULLSCREEN);
}
else
ChangeDisplaySettings(NULL,0);

}


Should do it. However, in some cases you can't change the bpp of the screen and you do actually have to use the desktop bpp.


[edited by - JuNC on March 24, 2003 12:19:10 PM]

Share this post


Link to post
Share on other sites