PDA

View Full Version : Viewport wrong with 1280x1024



Matthias Thurau
01-11-2008, 03:40 AM
Hello,

I am writing some OpenGL Applications with SDL as WindowManager. I have a Problem with the resolution of 1280x1024. When i start the Program (Not Fullscreen) it looks fine like here:

http://data.whosme.de/denginewindow.PNG

But as soon as i move the Window by click and hold the mouse on the window title and move the whole window, then my Viewport gets moved like that: There are 16 more pixels above, that i canno reach. But my glClearColor is reaching that area as you see:

http://data.whosme.de/denginewindow2.PNG

With other Resolutions it is working. Maybe its because that 1280/1024 = 1.25 is and 1024/768 = 1.33, 640/480 = 1.33 is and so on.

Here is my Code for the Viewport:


void init(int theWidth, int theHeight) {
myWidth = cast(float) theWidth;
myHeight = cast(float) theHeight;

glClearColor(0.3f, 0.3f, 0.5f, 1.0f);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glDepthFunc(GL_LEQUAL);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glEnable(GL_TEXTURE_2D);

join3D();
};

void refresh() {
SDL_GL_SwapBuffers();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
//refresh screen
};

void uninit() {

};

void join2D() {
glMatrixMode (GL_PROJECTION);
glLoadIdentity();

glOrtho(0, myWidth, 0, myHeight,0,1);

glMatrixMode (GL_MODELVIEW);
glLoadIdentity();
};

void join3D() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.0f, myWidth / myHeight, 0.1f, 1024.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
};

-NiCo-
01-11-2008, 06:48 AM
Ehm, I don't see a glViewport call anywhere...

N.

Matthias Thurau
01-11-2008, 07:15 AM
oh... ehe :(
You re right!

I put glViewport(0, 0, theWidth, theHeight); now into my void init() function.

Its nearly the same Problem. Again just with 1280 x 1024 and just on Windowed Mode and when i move the Window. But this time the Viewport is too high. And when i move the Window its jumping down.

Thats the way it is before moving the Window:
http://data.whosme.de/denginewindow4.PNG

And after moving the Window it shows correct as on this screenshot:
http://data.whosme.de/denginewindow.PNG

greetings

Seth Hoffert
01-11-2008, 09:33 AM
Try calling glViewport whenever the window is resized. :)

Matthias Thurau
01-12-2008, 05:13 AM
But the WIndow is not getting resized. I am just moving it. Additional to that i only have that problem with that 1280x1024 resolution.