Hello everyone,
I recently started programming in OpenGL using JOGL and I am using NeHe’s tutorial as a reference.
There seems to be a problem after I reshape the Frame in which the canvas is located.
After I resize the frame, the reshape() method() is called, but the screen turns black (the background color).
the code is
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
GL gl = drawable.getGL();
GLU glu = new GLU();
gl.glViewport(x, y, width, height);
// If the height is 0 set it to 1 to avoid division by zero
if (height == 0) {
height++;
}
// Calculate the aspect ratio
float fovy = (float) width / (float) height;
// Setting the matrix mode
gl.glMatrixMode(GL.GL_PROJECTION);
// Calculate perspective
glu.gluPerspective(45.0D, fovy, 0.1D, 100D);
// Setting ModelView matrix
gl.glMatrixMode(GL.GL_MODELVIEW);
}
My question is, should I put the GLCanvas directly inside the frame? and should I use the glOrth() method for any type of aspect ratio calculations?
Thanks in advance.