Hi,
I’m pretty new to OpenGL, and am trying to program a very simplistic game engine. Everything works fine, except for one problem with perspective.
My program draws a simple floor and walls made of textured quads. It’s basicly just a traditional tile engine, but projected into 3d, with walls added… (I won’t post direct code, since I am programming with a little known language called XBLite, a variation of XBasic. But the OpenGL routines should be quite universal…)
I set up the perspective with gluPerspective. The attributes should be pretty normal, as far as I understand them: 90 degrees field of view, 4/3 aspect (using a 800*600 window), 0.1 and 35.0 clipping planes… And then I set the viewpoint with gluLookAt. I track movement in the world with X and Y variables, and calculate the “camera” position a little behind and above this point, looking at it… The floor is drawn on the X/Y plane, so I use an up vector of 0,0,1. After this I draw the quads, in the ordinary manner…
So, the program works ok. But the perspective is clearly screwed up… Looking straight on, it looks almost ok, but nearer to the edges of the screen it becomes quite distorted, like stretched towards the edge or something… It’s hard to exactly describe it in words…
One interesting phenomenon is seen when the height (ie. z in this case) of the “camera” is set to the height of the wall tiles, which is 1 in this case, while the point the camera is trained on is a little lower. The tops of the walls in this situation are all horizontal on the screen! Like a horizon, but a little above the center of the screen. This looks very weird…
If anyone has any ideas of what could be the cause of this, it would be much appreciated… as I said, I’m still new to OpenGL so I may be missing something important… I just can’t figure out what…
Ben B.