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
Opengl syntax (Read 1805 times)
Opengl syntax
May 27th, 2010, 7:41am
 
Can someone post the processing syntax for the following opengl ?

 glClearColor (0.0, 0.0, 0.0, 0.0);
  glClear (GL_COLOR_BUFFER_BIT);
  glColor3f (1.0, 1.0, 1.0);
  glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
  glBegin(GL_POLYGON);
     glVertex3f (0.25, 0.25, 0.0);
     glVertex3f (0.75, 0.25, 0.0);
     glVertex3f (0.75, 0.75, 0.0);
     glVertex3f (0.25, 0.75, 0.0);
  glEnd();
  glFlush();
Re: Opengl syntax
Reply #1 - May 27th, 2010, 8:46am
 
andrewowaun wrote on May 27th, 2010, 7:41am:
Can someone post the processing syntax for the following opengl


I feel like this should work, but for some reason it just gives an empty black window:
Code:
void setup() {
size(300, 300, P3D);
colorMode(RGB, 1.0);
}

void draw() {
ortho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);

background(0.0, 0.0, 0.0);

stroke(1.0, 1.0, 1.0);
fill(1.0, 1.0, 1.0);
beginShape();
vertex(0.25, 0.25, 0.0);
vertex(0.75, 0.25, 0.0);
vertex(0.75, 0.75, 0.0);
vertex(0.25, 0.75, 0.0);
endShape(CLOSE);

}
Re: Opengl syntax
Reply #2 - May 27th, 2010, 8:58am
 
Also, the reference page for ortho() shows an example.  I can't tell why that example works but the sketch I posted doesn't, but maybe it'll help you.
Re: Opengl syntax
Reply #3 - May 27th, 2010, 9:46am
 
Well the vertex coordinates are pretty close together.  Making them further apart, using the default parameters for ortho() and translating (as per the example) at least gets something to render onscreen:

Code:
void setup() {
size(300, 300, P3D);
colorMode(RGB, 1.0);
}

void draw() {
//ortho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
ortho();
background(0.0, 0.0, 0.0);

stroke(1.0, 1.0, 1.0);
fill(1.0, 1.0, 1.0);
translate(300,300);
beginShape();
vertex(25, 25, 0.0);
vertex(75, 25, 0.0);
vertex(75, 75, 0.0);
vertex(25, 75, 0.0);
endShape(CLOSE);

}
Re: Opengl syntax
Reply #4 - May 27th, 2010, 2:15pm
 
http://processing.org/discourse/yabb2/num_1274971310.html#1

> Well the vertex coordinates are pretty close together.

that depends on where the camera is.
Re: Opengl syntax
Reply #5 - May 27th, 2010, 2:25pm
 
I probably have my stupid hat on today...
Page Index Toggle Pages: 1