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.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › firt opening processing, first problem with openGL
Page Index Toggle Pages: 1
firt opening processing, first problem with openGL (Read 656 times)
firt opening processing, first problem with openGL
May 19th, 2008, 11:30am
 
Hi!
sorry for my poor knowledge.

i'm opening exemple Array2D
in processing 0135
with intel iMac os x 10.4.11 with aty radeonX1600

i changed only size(200, 200, OPENGL); and importing lib.
everything all not chaged.
result: black stage.

other exeples with opengl run correctly.
why?
thanks
alberto

Code:

import processing.opengl.*;

float[][] distances;
float maxDistance;

size(200, 200) ;//, OPENGL);
background(0);
maxDistance = dist(width/2, height/2, width, height);
distances = new float[width][height];
for(int i=0; i<height; i++) {
for(int j=0; j<width; j++) {
float dist = dist(width/2, height/2, j, i);
distances[j][i] = dist/maxDistance * 255;
}
}

for(int i=0; i<height; i+=2) {
for(int j=0; j<width; j+=2) {
stroke(distances[j][i]);
point(j, i);
}
}
Re: firt opening processing, first problem with op
Reply #1 - May 19th, 2008, 12:27pm
 
Seems like point() has an issue with OPENGL renderer.

Quote:
import processing.opengl.*;
 
float[][] distances;
float maxDistance;

size(200, 200, OPENGL);
background(0);
maxDistance = dist(width/2, height/2, width, height);
distances = new float[width][height];
for(int i=0; i<height; i++) {
 for(int j=0; j<width; j++) {
   float dist = dist(width/2, height/2, j, i);
   distances[j][i] = dist/maxDistance * 255;  
 }
}

for(int i=0; i<height; i+=2) {
 for(int j=0; j<width; j+=2) {
   stroke(distances[j][i]);
   rect(j, i,1,1);
 }
}
Re: firt opening processing, first problem with op
Reply #2 - May 19th, 2008, 12:54pm
 
ok
thanks man!
so with openGL point() don't work correctly.
(why? bug? or normal differences in core processing drawing api?)

actually.. for having same result WITHOUT OPENGL i have to use:
rect(i,j, 0,0) ==== point(i,j)

but with rect(i,j, 0,0) WITH OPENGL make same result that using point..

seems to be a problem in using opengl
with single point/pixel?

but rect() is slowler then using point method. also with opengl..

how can i find some profiler or something with i can misure
a method computational time in processing.org ide?
Re: firt opening processing, first problem with op
Reply #3 - May 20th, 2008, 12:56am
 
This is what i've got so far

Code:

import javax.media.opengl.*;
import processing.opengl.*;

float[][] distances;  
float maxDistance;  

void setup() {
  size(200, 200, OPENGL);
maxDistance = dist(width/2, height/2, width, height);  
distances = new float[width][height];  
for(int i=0; i<height; i++) {  
 for(int j=0; j<width; j++) {  
   float dist = dist(width/2, height/2, j, i);  
   distances[j][i] = dist/maxDistance * 255;  
   }  
 }
}
 
void draw(){
background(200,100,100);

PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;  
GL gl = pgl.beginGL();  
//gl.glEnable(GL.GL_POINT_SMOOTH);
gl.glBegin(gl.GL_POINTS);
gl.glColor3f(0,0,0);  
for(int i=0; i<height; i+=2) {  
 for(int j=0; j<width; j+=2) {  
gl.glVertex3f(j, i,0);
   }  
 }
 gl.glEnd();
 pgl.endGL();  
}




You can also check this thread

http://processing.org/discourse/yabb_beta/YaBB.cgi?board=OpenGL;action=display;num=1181926021;start=1#1


Re: firt opening processing, first problem with op
Reply #4 - May 21st, 2008, 3:17pm
 
thanks!
it runs perfectly
Page Index Toggle Pages: 1