OpenGL viewport issue

I’ve got a weird issue. If I create a window with a height of 768 (which
happens to be my desktop resolution) or something close to it (like >
760) the viewport isn’t quite right. For example, I have a FPS counter
in the upper left corner of the screen, but when the game starts up the
counter is too high, like the top portion of it is underneath the
titlebar. The higher I set the window height the higher the counter is,
until it isn’t visible anymore. BUT as soon as I move the window and
release the mouse button the viewport “pops” to what it should be. I
don’t have this issue in fullscreen mode, or lower window sizes, like
800x600.

This is on Windows with SDL 1.2.13. Any ideas what could be wrong?

Make sure you call SDL_SetVideoMode() AND glViewport() together whenever
you resize the screen.

Eddy

Brad wrote:> I’ve got a weird issue. If I create a window with a height of 768 (which

happens to be my desktop resolution) or something close to it (like >
760) the viewport isn’t quite right. For example, I have a FPS counter
in the upper left corner of the screen, but when the game starts up the
counter is too high, like the top portion of it is underneath the
titlebar. The higher I set the window height the higher the counter is,
until it isn’t visible anymore. BUT as soon as I move the window and
release the mouse button the viewport “pops” to what it should be. I
don’t have this issue in fullscreen mode, or lower window sizes, like
800x600.

This is on Windows with SDL 1.2.13. Any ideas what could be wrong?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I’m calling glViewport() shortly after calling SDL_SetVideoMode() when I
create the window. The window isn’t resizable, so screen creation should be
the only time I need to call those functions.

Edward Cullen wrote:>

Make sure you call SDL_SetVideoMode() AND glViewport() together whenever
you resize the screen.

Eddy

Brad wrote:

I’ve got a weird issue. If I create a window with a height of 768 (which
happens to be my desktop resolution) or something close to it (like >
760) the viewport isn’t quite right. For example, I have a FPS counter
in the upper left corner of the screen, but when the game starts up the
counter is too high, like the top portion of it is underneath the
titlebar. The higher I set the window height the higher the counter is,
until it isn’t visible anymore. BUT as soon as I move the window and
release the mouse button the viewport “pops” to what it should be. I
don’t have this issue in fullscreen mode, or lower window sizes, like
800x600.

This is on Windows with SDL 1.2.13. Any ideas what could be wrong?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


View this message in context: http://www.nabble.com/OpenGL-viewport-issue-tp17495823p17502623.html
Sent from the SDL mailing list archive at Nabble.com.

You need to be aware that under Windows, the “window size” you set up the window with is the size of the entire window, including the frame and title bar. You need to work with the “client size”, which is the size of the actual area enclosed by the frame. Is your code compensating for this?> ----- Original Message -----

From: braddabug@comcast.net (Brad)
To: sdl at lists.libsdl.org
Sent: Tuesday, May 27, 2008 4:54:26 PM
Subject: Re: [SDL] OpenGL viewport issue

I’m calling glViewport() shortly after calling SDL_SetVideoMode() when I
create the window. The window isn’t resizable, so screen creation should be
the only time I need to call those functions.

I added a call to GetClientRect(), and it looks like you’re right- when I
request a window that’s 768 pixels high GetClientRect() reports the client
area is 755 pixels high. But what I don’t understand is when I create a
window that’s 600 pixels high the client area is also 600 pixels high.

If I use the results of GetClientRect() to call glViewport() then everything
works fine until I move the window and I get the opposite problem,
everything on the screen is several pixels too low, and there’s a bar going
across the screen the color of the background.

Hey, I just tried something. I set my desktop resolution height to 600 and
created a 1024 pixel high window, and the client height is reported as 755,
and when I move the window I see a HUGE bar across the top of the screen,
probably 269 pixels high, if I had to guess. It really seems like this has
more to do with the height of the window vs the desktop resolution rather
than the titlebar and frame around the window. What’s going on?

masonwheeler wrote:>

You need to be aware that under Windows, the “window size” you set up the
window with is the size of the entire window, including the frame and
title bar. You need to work with the “client size”, which is the size of
the actual area enclosed by the frame. Is your code compensating for this?

----- Original Message ----
From: BradDaBug <@Brad>
To: sdl at lists.libsdl.org
Sent: Tuesday, May 27, 2008 4:54:26 PM
Subject: Re: [SDL] OpenGL viewport issue

I’m calling glViewport() shortly after calling SDL_SetVideoMode() when I
create the window. The window isn’t resizable, so screen creation should
be

the only time I need to call those functions.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


View this message in context: http://www.nabble.com/OpenGL-viewport-issue-tp17495823p17503721.html
Sent from the SDL mailing list archive at Nabble.com.