My gaming resolution is 4:3 (1024x768). I have a png file thats the same resolution. I wish to use this image as the background for my game. Problem is that when i try to map this image onto a 4:3 polygon the polygon doesnt fit the screen (the width fits but the height is short).
When i map the image onto a 1:1 polygon (a square :-)) instead of the 4:3 rectangle, the square fits the screen perfectly (i have no idea how because the square is 1024x1024 where the monitor is 1024x768). However it stretches the background image mapped onto it (it stretches it vertically because a 4:3 image is being mapped on to a 1:1 square).
It sounds like the extents you defined were 1.0 by 1.0, or at least a multiple of 1.0s. In other words, you told OpenGL:
Yes I have a 4:3 aspect ratio, but I don’t want to think about it, so make it 1:1 for me.
A simple way of doing just that is:
glViewport(0,0,1024,768);
//…
glFrustum(0.0,1.0,0.0,1.0,//near and far planes);
// Or with glOrtho
In this instance, OpenGL knows your viewport is 1024x768 (4:3 aspect ratio), but you’re telling OpenGL that you want an aspect ratio of exactly 1:1. So it takes care of the math, leaving you with a puzzling situation.
But without seeing any code, this is all just guessing on my part.
What you fail to understand is the fact, that opengl does not work with window coordinates directly. The coordinates you send in (via Vertex etc. commands) are transformed by various matrices. This way, the coordinates (0,0) and (1, 1) may actually refer to window coordinates (0, 0) and (1023, 767). Refer to documentation.