Sign in to follow this  
energydrink

[SOLVED] issue with glViewport and going into fullscreen

Recommended Posts

energydrink    100
This is my function for setting up my ortho.
GLvoid DrawEngine::setOrtho2D( GLint width, GLint height ) {
	glViewport( 0, 0, ( GLsizei )width, ( GLsizei )height );
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();
	gluOrtho2D( 0, ( GLdouble )width, ( GLdouble )height, 0 );
}


The resolution I want is 256x224. Going into fullscreen the "drawing" only occurs on about 1/4 of the screen. Using the same code but switching the resolution to 800x600, everything is fine. Removing glViewport() and using 256x224, everything works fine aswell. Whats going on here really? [Edited by - energydrink on April 25, 2010 9:54:11 PM]

Share this post


Link to post
Share on other sites
jyk    2094
Are you trying to create a fullscreen window with a resolution of 256x224?

Also, what API are you using to create the window?

Share this post


Link to post
Share on other sites
energydrink    100
I am using SDL. The following command.
1. SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_OPENGL | SDL_FULLSCREEN )

2. setOrtho2D( SCREEN_WIDTH, SCREEN_HEIGHT );

So yes, I want to create a fullscreen window for 256x224. To clarify what happen is, basically I get a window 1/4 of the size of my monitor where the drawing takes place. Like if I take my 256x224 in window mode and drag it to the lowerleft part of my screen.

But the strange part is that everything works as intended if the resolution has minimum of 800x600.

Share this post


Link to post
Share on other sites
jyk    2094
Generally speaking, before switching to a fullscreen video mode, you need to make sure that that mode is supported by your hardware. (This applies regardless of what API you're using to create the window, more or less.)

With SDL, there's a couple of ways to do this, one of which is to get a list of supported resolutions using the 'list modes' function, and then check to see if the desired resolution is included in the list. In your case, you'll need to check to see if a fullscreen resolution of 256x224 is supported (I would be a little surprised if it were).

Share this post


Link to post
Share on other sites
jyk    2094
Quote:
Original post by energydrink
Alright I will look into it, but what is the deal if I don't include the glViewport() the 256x224 resolution will work as intended.
Not really sure, but I'm guessing that when you request a resolution of 256x224, SDL punts and uses some other resolution instead. If you then leave out the glViewport() call, the viewport is simply set to the entire screen, and rendering appears to work correctly (although it's not actually at the resolution that you intend).

Share this post


Link to post
Share on other sites
energydrink    100
Quote:
Original post by jyk
Quote:
Original post by energydrink
Alright I will look into it, but what is the deal if I don't include the glViewport() the 256x224 resolution will work as intended.
Not really sure, but I'm guessing that when you request a resolution of 256x224, SDL punts and uses some other resolution instead. If you then leave out the glViewport() call, the viewport is simply set to the entire screen, and rendering appears to work correctly (although it's not actually at the resolution that you intend).


Great info!

I used SDL_ListModes and you were right.
Max: 1920x1200
Min: 640x480

So my claim that 800x600 was minimum was wrong. I did the test with 640x480 which worked aswell. Thank you, this is solved.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this