Hi,
Trying to create an isometric engine in GL. Things went smoothly until I tried to use a larger map and move the camera around.
Here is how I set up GL every frame:
glMatrixMode(gl_PROJECTION)
glLoadIdentity()
glOrtho(-5, 5, -5, 5, -10, 20.0)
glMatrixMode(gl_MODELVIEW)
glLoadIdentity()
'ExtractFrustum() ' Should this be here or below?
' Place camera
glTranslatef( camx,0,camz ) ' Just moves the clipping planes and cuts of the graphics
'glTranslatef( camx,camz,0 ) ' Moves the camera up and down, after a while clipped quads are visible
' Isometric view
glRotatef( 35.264, 1.0, 0.0, 0.0)
glRotatef( -45.0, 0.0, 1.0, 0.0)
glScalef( 1.0, 1.0, -1.0)
ExtractFrustum() ' Does it matter if it's here or above?
Ok, to explain it a bit. ExtractFrustum() does just that. It is a codesnippet I found here: http://www.crownandcutlass.com/features/technicaldetails/frustum.html
I use it in an attempt to figure out what parts of the map to draw. And I'm not entirely sure where to put it. :P
Not sure if it works since the problem is with clipping.
As you can see above I use glTranslatef to move the camera around.
If i put camz as the second argument the camera is moving up and down, but the clipping planes, or what they are called, doesn't follow. After moving up a bit the map is cut off.
If I put camz as the third argument the camera isn't moving at all, but the clipping planes do.
So, naturally I tried to put camz as both the second and third argument, but it did not work as expected. :P
So I believe I'm on the wrong track here. How can I make the camera and clipping planes to work together?
Any help appreciated. :)
Trying to create an isometric engine in GL. Things went smoothly until I tried to use a larger map and move the camera around.
Here is how I set up GL every frame:
glMatrixMode(gl_PROJECTION)
glLoadIdentity()
glOrtho(-5, 5, -5, 5, -10, 20.0)
glMatrixMode(gl_MODELVIEW)
glLoadIdentity()
'ExtractFrustum() ' Should this be here or below?
' Place camera
glTranslatef( camx,0,camz ) ' Just moves the clipping planes and cuts of the graphics
'glTranslatef( camx,camz,0 ) ' Moves the camera up and down, after a while clipped quads are visible
' Isometric view
glRotatef( 35.264, 1.0, 0.0, 0.0)
glRotatef( -45.0, 0.0, 1.0, 0.0)
glScalef( 1.0, 1.0, -1.0)
ExtractFrustum() ' Does it matter if it's here or above?
Ok, to explain it a bit. ExtractFrustum() does just that. It is a codesnippet I found here: http://www.crownandcutlass.com/features/technicaldetails/frustum.html
I use it in an attempt to figure out what parts of the map to draw. And I'm not entirely sure where to put it. :P
Not sure if it works since the problem is with clipping.
As you can see above I use glTranslatef to move the camera around.
If i put camz as the second argument the camera is moving up and down, but the clipping planes, or what they are called, doesn't follow. After moving up a bit the map is cut off.
If I put camz as the third argument the camera isn't moving at all, but the clipping planes do.
So, naturally I tried to put camz as both the second and third argument, but it did not work as expected. :P
So I believe I'm on the wrong track here. How can I make the camera and clipping planes to work together?
Any help appreciated. :)