Hello;
I’m pretty much a newbie with openGL and wonderring few things about glFrustum() usage.
I tried using it in my program:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// I kinda messed with the values until I get something correct.
glFrustum(-15.0f, 15.0f, -60.0f, -35.0f, 50.0f, 400.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
And noticed few things:
For some reason, after using glFrustum(), glTranslatef() on Y axis, seems to provoke a rotation instead of a translation ? Why ? o:
X, and Y axes are still fine.
I then don’t know if I’m kinda going crazy, but I truely feel like that both my X and Y axis are inverted.
When applying a translation with a negative X value, the scene is moving to the right and vice versa…
Is it because objects are rendered with a negative Z value ?
I then call glTranslatef():
// (Position.x and Position.z are 2 floats set at 0.0f by default)
glTranslatef(0.0f + position.x, -110.0f, 0.0f + position.z);
Here is what I get:
Which point a last problem, since glTranslatef() provokes a rotation (which fits what I want here), the Cubes are being slightly distorted.
Is there any way to deal with this ? How ?
This is the current way I’m drawing my cubes (using VBO)
void Cube::Draw()
{
glPushMatrix();
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_MODELVIEW);
glTranslatef(position.x, position.y, position.z);
Texture_->bind();
glBindBuffer(GL_ARRAY_BUFFER, CubeBuffers[0]);
glVertexPointer(3, GL_FLOAT, 5 * sizeof(float), 0);
glTexCoordPointer(2, GL_FLOAT, 5 * sizeof(float), (GLvoid*)(sizeof(float)*3));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, CubeBuffers[1]);
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glDrawElements(GL_TRIANGLE_STRIP, 36, GL_UNSIGNED_INT, 0);
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
glDisable(GL_DEPTH_TEST);
glDisable(GL_TEXTURE_2D);
glPopMatrix();
}
In case it’d eventually come from it
Also a last question: I plan on trying to integrated the Frustum Culling, would the rotation provokated by glTranslatef() have an impact on that ?
And if I was rotating before calling glFrustum() ?
Sorry for asking so many questions, but i need to clear my mind
Also sorry for any grammar / spelling mistake, english is not my main language ;o
Thanks a lot for your help !