here is a sketch that I believe is pretty close to a direct port of the NeHe lesson 1 opengl code.
Quote:import processing.opengl.*;
import javax.media.opengl.*;
PGraphicsOpenGL pgl;
GL gl;
void setup() {
size(400, 400, OPENGL);
pgl = (PGraphicsOpenGL)g;
gl = pgl.gl;
resizeGLScene();
initGL();
}
void draw() {
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
}
void resizeGLScene() {
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
// gl.gluPerspective(45.0, (float)width/(float)height, 0.1, 100.0);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
}
boolean initGL() {
gl.glShadeModel(GL.GL_SMOOTH);
gl.glClearColor(0.0, 0.0, 0.0, 0.0);
gl.glClearDepth(1.0);
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glDepthFunc(GL.GL_LEQUAL);
gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
return true;
}
I have some questions about this code. You'll notice gluPerspective is commented out. Apparently, there is no method by that name. If I can't set the perspective using that method then the associated glMatrixMode and glLoadIdentity are unnecessary. If you remove both of those then GL_MODELVIEW matrixmode call and the assocaited loadidentity are also unnecessary as that is the default matrixmode correct? That leaves the glViewport call which itself confuses me. The glViewport docs say "Specify the lower left corner of the viewport rectangle, in pixels. The initial value is (0,0)." Which contradicts the way processing works entirely right? The upper left pixel is 0, 0 in processing. On top of that, I don't know if I really need that call at all, as it seems like the size call sets up the viewport. I could answer some of these questions on my own (what is default and such) using glGet but it looks like that method doesn't exist.
Basically, my question is, once you start using opengl in processing, where does processing end and opengl begin? For example, I can change the perspective in processing by using the perspective method, but if I am making opengl calls inside my processing sketch what kind of impact will that call have? I'm an opengl noob (obviously) and I'm mainly trying to get started off on the right foot. Any help/ideas/advice would be appreciated. Thanks!