I'm going nuts over this, but I'm studying OpenGL, and this book I have isn't doing a good job explaining this to me.
All I need actually is verification, I know how to do this mapping, but I just need to know what actually happens!
Little definition first;
(this is a 2D scenario)
World = Everything in the game, based on X,Y cartesian axes.
World-Window = What part of the World is being displayed from P1=(x1,y1) through P2=(x2,y2).
Viewport = Defines how the World-Window is displayed.
Everything in the world-window gets stretched to fit whatever size viewport is defined as.
I made a image:
(http://www.private.is/arni/viewport.gif)
Am I correct about this?
Kevglass verified to me that I am correct.
But, I'm trying to accomplish this in lwjgl.
What I'm doing is;
drawing a polygon (rectangle) that is 10x10, and has the origin point 0,0.
I have defined:
GL11.glOrtho(0, 10, 0, 10, -1, 1);
GL11.glViewport(0,640,0,480);
Shouldn't that polygon fill the window? (the window is 640x480).
Nothing happens :\
my code is here: http://www.private.is/arni/OpenGL.java
One thing you might try, is to do GL_QUADS or GL_TRIANGLES instead of GL_POLYGON.
Also its possible that the polygon you are drawing is getting culled (not drawn because its facing the wrong way). Try drawing the polygon in the reverse order. I can't remember if OpenGL defaults to clockwise or counter-clockwise front face.
Kevglass gave me the solution;
GL11.glViewport(0,0,640,480);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(0, 10, 10, 0, -1, 1);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();