Josh Nimoy
YaBB Newbies
Offline
Posts: 3
Re: Using OpenGL directly
Reply #3 - Dec 14th , 2005, 6:32am
ya, anywayz, here's a nice function for you that fixes your code. It's called "beginRawGL()" and it makes the other 2 squares draw, but breaks the P engine til the end of the draw call. So make sure you do all your P-ing before you go raw. Someone please write a function to get back out from this mode. -JT ---------------- import processing.opengl.*; import net.java.games.jogl.*; GL gl; int p,q; void beginRawGL(){ /* * escape Fry's matrix to make raw jogl calls work * til the end of the draw function. * special thanks to Flux for showing me this thread. * love always, your pal Josh Nimoy */ gl.glViewport(0,0,width,height); gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(-1,1,0); gl.glScalef(2.0/width,-2.0/height,0); } void setup() { size(300,300,OPENGL); gl=((PGraphicsGL)g).gl; buildquad(); } void draw() { background(0); //top right beginShape(QUADS); fill(255); vertex(200,0,0); vertex(300,0,0); vertex(300,100,0); vertex(200,100,0); endShape(); gl.glCallList(q); beginRawOpenGL(); // top left square gl.glBegin(GL.GL_QUADS); gl.glColor4f(1.0,1.0,1.0,1.0); gl.glVertex3f(0.0,0.0,0.0); gl.glVertex3f(100.0,0.0,0.0); gl.glVertex3f(100.0,100.0,0.0); gl.glVertex3f(0.0,100.0,0.0); gl.glEnd(); gl.glCallList(p); } void buildquad() { p=gl.glGenLists(1); gl.glNewList(p,GL.GL_COMPILE); // bottom left gl.glBegin(GL.GL_QUADS); gl.glColor4f(1.0,1.0,1.0,1.0); gl.glVertex3f(0.0,200.0,0.0); gl.glVertex3f(100.0,200.0,0.0); gl.glVertex3f(100.0,300.0,0.0); gl.glVertex3f(0.0,300.0,0.0); gl.glEnd(); gl.glEndList(); q=gl.glGenLists(1); gl.glNewList(q,GL.GL_COMPILE); //bottom right beginShape(QUADS); vertex(200,200,0); vertex(300,200,0); vertex(300,300,0); vertex(200,300,0); endShape(); gl.glEndList(); }