After getting some clarification on NeHe lesson 1 I have moved on to lesson 2 and have run into more strange issues.
Quote:import processing.opengl.*;
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
void setup() {
size(400, 400, OPENGL);
PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;
GL gl = pgl.gl;
GLU glu = pgl.glu;
resizeGLScene(gl, glu);
initGL(gl);
}
void draw() {
working();
// broken();
}
void working() {
PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;
GL gl = pgl.beginGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glBegin(GL.GL_TRIANGLES);
gl.glVertex3f(0, 100, 0);
gl.glVertex3f(-100, -100, 0);
gl.glVertex3f(100, -100, 0);
gl.glEnd();
pgl.endGL();
}
void broken() {
PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;
GL gl = pgl.gl;
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glTranslatef(-1.5, 0.0, -6.0);
gl.glBegin(GL.GL_TRIANGLES);
gl.glVertex3f(0, 1, 0);
gl.glVertex3f(-1, -1, 0);
gl.glVertex3f(1, -1, 0);
gl.glEnd();
}
void resizeGLScene(GL gl, GLU glu) {
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(45, (float)width/(float)height, 0.1, 100);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
}
boolean initGL(GL gl) {
gl.glShadeModel(GL.GL_SMOOTH);
gl.glClearColor(0, 0, 0, 0);
gl.glClearDepth(1);
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glDepthFunc(GL.GL_LEQUAL);
gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
return true;
}
The problem lies in the working and broken methods. broken is the direct NeHe lesson 2 implementation. Running that method in draw produces no output. That actually doesn't surprise me because I'm not quite sure how a triangle that is 1 pixel big would show up. In any case the differences between the two methods are as follows:
working uses beginGL/endGL and does not use glLoadIdentity or glTranslate. It also creates a triangle that is 100 pixels big.
Now, I've combed through forum posts, done much reading on google and understand I have a TON to learn. Most responses to people on this forum asking "how do I learn opengl" point them towards these NeHe tutorials and the JOGL ports. It seems like I am missing some crucial bit of documentation here because I have no idea how a 1x1x1 triangle would ever be visible. Are there any "opengl for processing" tutorials that explain the differences between the two? I can't seem to find any. As always, any help on figuring out lesson 2 or just general help and/or resources would be greatly appreciated. Thanks!