hamletbon
YaBB Newbies
Offline
Posts: 16
Full openGL control?
Sep 19th , 2006, 7:11pm
I have tried to use different method to create an opengl object in processing, but it seems I can't really port those opengl code directly. Here's the code import javax.media.opengl.*; import processing.opengl.*; GL gl; void draw() { background(0); // 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(); //drawSquareCentric3d(100.0, 100.0, 0.0, 20.0, 20.0, 255, 0, 0, 255, 1); //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(p); gl.glCallList(q); buildquad(); } 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(); } void drawSquareCentric3d(float x, float y, float z, float sqSizex, float sqSizey, int colorR, int colorG, int colorB, int opac, int filling) { if (colorR>255) {colorR = 255;} if (colorG>255) {colorG = 255;} if (colorB>255) {colorB = 255;} if (filling==1) {gl.glBegin(gl.GL_QUADS); gl.glColor4f(colorR/255.0, colorG/255.0, colorB/255.0, opac/255.0); // GLfloat_materialKd[]={float(colorR)/255, float(colorG)/255, float(colorB)/255}; gl.glVertex3f(x-sqSizex/2, y-sqSizey/2, z); gl.glVertex3f(x+sqSizex/2, y-sqSizey/2, z); gl.glVertex3f(x+sqSizex/2, y+sqSizey/2, z); gl.glVertex3f(x-sqSizex/2, y+sqSizey/2, z); gl.glEnd(); } if (filling==0) {gl.glBegin(gl.GL_LINE_LOOP); gl.glColor4f(colorR/255.0, colorG/255.0, colorB/255.0, opac/255.0); gl.glVertex3f(x-sqSizex/2, y-sqSizey/2, z); gl.glVertex3f(x+sqSizex/2, y-sqSizey/2, z); gl.glVertex3f(x+sqSizex/2, y+sqSizey/2, z); gl.glVertex3f(x-sqSizex/2, y+sqSizey/2, z); gl.glEnd(); } } So basically the function "drawSquareCentric3d" doesn't draw anything. Do I have to use syntax like "beginShape(QUADS);" instead of "gl.glBegin(gl.GL_QUADS);" in order to draw in processing enviornemnt?