OpenGL resolution settings?

Started by
5 comments, last by Unimatrix_001 21 years, 10 months ago
How can I make OpenGL run with certain resolution settings? If I need to get them from windows settings how can I temporarily change them to a certain setting? I think I''ve sorta made myself clear... Thanks Uni
Advertisement
You''re probably looking for glViewport() if you want to get OpenGL to run with a specific resolution. You can change it if you want (for render to texture or whatever). You should probably have the window dimensions left over from when you created the window. Hope that helps.
How can I use that to get me the resolution settings?

[edited by - Unimatrix_001 on June 5, 2002 4:22:32 PM]
All the glViewport seems to do is to specify the width and height of the window but not the resolution...

Uni
Actually, the solution to this suprised me, since I was initally working with Direct3D, which has separate initialisation for full-screen mode.

In OpenGL, you just make a popup-style window (i.e. with no borders) and place it in the top-left corner of the screen (0,0).

Then you have to change the windows desktop resolution to fit the window:


  // Example for 640x480x32 modeDEVMODE dmScreenSettings;memset(&dmScreenSettings,0,sizeof(dmScreenSettings));dmScreenSettings.dmSize=sizeof(dmScreenSettings);dmScreenSettings.dmPelsWidth	= 640;dmScreenSettings.dmPelsHeight	= 480;dmScreenSettings.dmBitsPerPel	= 32;dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);  


CDS_FULLSCREEN is to hide the status bar at the bottom

And when you want to get out of full-screen mode, just do:


  ChangeDisplaySettings(NULL, 0);  


After Direct3D, this is soooooo much easier eh

------------------------
CRAZY_DUSIK* pCrazyDuSiK = new CRAZY_DUSIK;
pCrazyDuSiK->EatMicroshaft(MS_MUNCH_BILL_GATES | MS_CHEW_BILL_GATES);
------------------------CRAZY_DUSIK* pCrazyDuSiK = new CRAZY_DUSIK;pCrazyDuSiK->EatMicroshaft(MS_MUNCH_BILL_GATES | MS_CHEW_BILL_GATES);pCrazyDuSiK->WebSiteURL = "http://www.geocities.com/dusik2000";
Summit is still up...when I increase the resolution i.e. make

dmScreenSettings.dmPelsWidth
dmScreenSettings.dmPelsHeight

higher values isn't the image (in this case a triangle) meant to decrease in size due to more pixels being on screen? Mine ain't it just stays the same size.

here's the code if it helps:

RECT windowRect;

int width = 800;
int height = 600;
int bits = 32;

windowRect.left=(long)0; // Set Left Value To 0
windowRect.right=(long)width; // Set Right Value To Requested Width
windowRect.top=(long)0; // Set Top Value To 0
windowRect.bottom=(long)height; // Set Bottom Value To Requested Height

if(fsval == true)
{
DEVMODE dmScreenSettings; // device mode
memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = width; // screen width
dmScreenSettings.dmPelsHeight = height; // screen height
dmScreenSettings.dmBitsPerPel = bits; // bits per pixel
dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;


I think that is the code that is needed.

Uni

[edited by - Unimatrix_001 on June 5, 2002 6:22:34 PM]
The triangle should appear to be the same size. Images are placed on the screen as fractions of the screen width. Higher resolution just gives more detail.

This topic is closed to new replies.

Advertisement