We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Full openGL control? (Read 703 times)
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?
Re: Full openGL control?
Reply #1 - Sep 19th, 2006, 8:38pm
 
please read the opengl section of the faq:
http://processing.org/faq/bugs.html#opengl

"Note, however, that this is not supported, in the sense that if you get weird problems with a GL-based sketch that uses this method, you're on your own. Processing is not intended as a nice wrapper on top of OpenGL. Instead, we're using OpenGL graphics for one implementation of the Processing Core API.
Because most of the work in drawing is handled by Processing, most OpenGL calls will not work, because the model and perspective matrices won't be set up properly. Therefore, using the GL object will mostly only be useful for tweaking obscure OpenGL parameters."
Re: Full openGL control?
Reply #2 - Sep 19th, 2006, 8:42pm
 
I've read the FAQ, just want to see if someone would have any idea on this. Anyway, thank you.
Page Index Toggle Pages: 1