Hi, I’ve been using opengl on and off for a couple of years now as a hobbyist and as I have no real maths background I’ve come to rely on the glMatrix stack for all my transforming needs. As this is all getting stripped out of the spec I was wondering if there’s anyway to start getting use to using my own matrix class for transforms using my current setup, as my card doesn’t support opengl 3.0.
Say for example my old glinit and render loop functions looked something like this:
glinit()
{
glClearColor(0.6, 0.6, 0.6, 1);
glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(FOV, WIDTH/HEIGHT, 0.0f, 100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
renderLoop()
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
{
glTranslatef(z, y, z);
make some glVertex3f calls();
}
glPopMatrix();
}
What I’d like to do now is something like this I think:
glinit()
{
glClearColor(0.6, 0.6, 0.6, 1);
glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
myProjection.setProjection(FOV, WIDTH/HEIGHT, 0.0f, 100.0f);
myTransform.transform(0, 0, -50);
myModel.transform( myProjection * myTransform);
}
renderLoop()
{
glClear(GL_COLOR_BUFFER_BIT);
myModel.draw();
}
But when using the above method I can’t seem to see anything as, I think, this has to do with the default clipping planes setup? However if I do as in the below example all appears how I expect it to, but obviously this uses the deprecated functions:
glinit()
{
glClearColor(0.6, 0.6, 0.6, 1);
glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
myProjection.setProjection(FOV, WIDTH/HEIGHT, 0.0f, 100.0f);
myTransform.transform(0, 0, -50);
myModel.transform( myTransform);
}
renderLoop()
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glLoadMatrixf(myProjection);
myModel.draw();
glPopMatrix();
}
So if anyone knows how I can get this working so I’m able to view my transformed model without the use of the fixed function matrix stack it would be a huge help to me, and I’m sure many others in my boat. Just like to point out at this stage myModel.draw is still making glVertex3f calls but this is ok for testing purposes only I hope?
Cheers.