void Application::Resize(int width, int height)
{
Application::height = height;
Application::width = width;
Application::halfHeight = height/2;
Application::halfWidth = width/2;
if(height == 0)
{
height = 1;
halfHeight = 1;
}
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f,width,height,0,-1.0f,1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void Application::Render() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glBegin(GL_POINTS);
glVertex2d(10.0, 10.0);
glEnd();
glFlush();
}
stupid ortho problem
I'm trying to setup a ortho projection. The problem is that with the code below when I resize the y component of the window a point drawn at 10,10 moves in the opposite direction of the resize. the x resizes have no effect on the raster position of 10,10 in world coords. I'll post all the resize and drawing code here:
the initial window setup works fine until the y component of the window is changed, then the point is no longer at 10,10 pixels from the top left.
The window coordinates in OpenGL have origin in "bottom-left" not in "top-left".
So change the parameters to 'glOrtho()' as follows
glOrtho(0.0f,width,0,height,-1.0f,1.0f);
So change the parameters to 'glOrtho()' as follows
glOrtho(0.0f,width,0,height,-1.0f,1.0f);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement