Hello all
I'm currently trying to learn the basics of OpenGL programing. I know what i'm trying to do can be achieved with the core processing methods but i want to try and get my head round whats happening under the hood.
So in the below code i have a display list which is attempting to draw a red rectangle on the stage (to pardon the flash term). With this code nothing happens... i get a black screen.
Code:
void draw()
{
background(0.5f);
gl.glPushMatrix();
gl.glCallList(squareList);
gl.glPopMatrix();
}
Doing a bit of digging about i find some code and change it to:
Code:
void draw()
{
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(50.0, 1.0, 3.0, 7.0);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
glu.gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
gl.glPushMatrix();
gl.glCallList(squareList);
gl.glPopMatrix();
}
..which displays my code correctly.
Now I've been through various code references and generally know what this code does. My questions are:
1) do i always need to set default matrices for GL_MODELVIEW and GL_PROJECTION and if so why?
2)do i always need to set a perspective in this way (I thought there was a default perspective set in processing)?
3) do i always need to set a gluLookAt (which i assume is some sort of camera function)?
I just want to get my head round what this exactly is and why it is needed.
Any pointer appreciated.
Cheers
James