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 › OpenGL: low quality 2D graphics
Page Index Toggle Pages: 1
OpenGL: low quality 2D graphics (Read 1047 times)
OpenGL: low quality 2D graphics
Jan 13th, 2006, 11:17am
 
Hi,

As designer exploring the potential of Processing  I so  have a sketchy knowledge of some of the technical concepts (so be gentle) .  

I have been drawing simple lines which have worked OK, but when I add the OpenGL library the quality of the graphics becomes noticeably worse. Why is this happening: is there something I am missing, misunderstanding or misusing?

A simple example of this (below).

import processing.opengl.*;

float x ;
float y;
float angle;
float radius;
float w ;
float inc;

int timer = 0;
void setup () {
 size (500, 500, OPENGL);
 rectMode (CENTER);
 smooth();
 stroke (256, 256, 256);
 strokeWeight (2.5);
 noStroke ();
 fill (0,0,0);
 background (0, 50, 0);
 reset ();
}

void draw () {
 framerate (25);
 scale (0.5);
 if (timer % 5 == 0 ) {
   fill (0, 50, 0, 10);
   rect (250, 250, 500, 500);
 }
 fill (256,256,256);
 translate (200, 0);
 if (timer % 1 == 0) {
   lineDraw (x, y, angle, radius);
 }

 if (w < 2 ) {
   reset ();
 }

 timer ++;
}
void reset () {
 x = 0;
 y = 0;
 angle = 60;
 radius = 10;
 w = 20;
 inc = 1;
}
// input x and y into lineDraw and return the values as well
void lineDraw (float xpos, float ypos, float ang, float r) {
 translate (xpos, ypos);
 xpos = cos (radians (ang)) * r;
 ypos = sin (radians (ang)) * r;
 pushMatrix ();
 rotate (radians (ang));
 rect (0, 0, 8, w);
 popMatrix ();
 // x and y are the values fed into this function
 // these values are used in the translate to be reset at 0, 0
 // these values are increased each time.
 x += xpos;
 y += ypos;
 angle += inc;
 w -= 0.4;
 // randomize the increment to randomize the direction of the line
 inc+= random (-1, 1);

}

The sketch is much smoother when the OpenGL is not used .... why?

Thanks

Andrew
Re: OpenGL: low quality 2D graphics
Reply #1 - Jan 13th, 2006, 7:32pm
 
Hi there

nice applet!

I made a small modifications in order to allow the fading to affect the whole frame.

Code:

import processing.opengl.*;

float x ;
float y;
float angle;
float radius;
float w ;
float inc;

int timer = 0;
void setup () {
size (500, 500, OPENGL);
rectMode (CENTER);
smooth();
stroke (255, 255, 255);
strokeWeight (2.5);
noStroke ();
fill (0,0,0);
background (0, 50, 0);
reset ();
}

void draw () {
framerate (25);

// Small modification here to enable the fading to affect all the frame
// Scale afterwards

if (timer % 5 == 0 ) {
fill (0, 50, 0, 10);
rect (width/2, height/2, width, height);
}

scale (0.5);

fill (255,255,255);
translate (200, 0);
if (timer % 1 == 0) {
lineDraw (x, y, angle, radius);
}

if (w < 2 ) {
reset ();
}

timer ++;
}
void reset () {
x = 0;
y = 0;
angle = 60;
radius = 10;
w = 20;
inc = 1;
}
// input x and y into lineDraw and return the values as well
void lineDraw (float xpos, float ypos, float ang, float r) {
translate (xpos, ypos);
xpos = cos (radians (ang)) * r;
ypos = sin (radians (ang)) * r;
pushMatrix ();
rotate (radians (ang));
rect (0, 0, 8, w);
popMatrix ();
// x and y are the values fed into this function
// these values are used in the translate to be reset at 0, 0
// these values are increased each time.
x += xpos;
y += ypos;
angle += inc;
w -= 0.4;
// randomize the increment to randomize the direction of the line
inc+= random (-1, 1);

}



I agree that the OPENGL renderer works a little bit worse, this is filed as a bug:

http://dev.processing.org/bugs/show_bug.cgi?id=200

Is this what you meant
Re: OpenGL: low quality 2D graphics
Reply #2 - Jan 14th, 2006, 12:38am
 
I'm running the same applet by ART+COM and I have the same problem when openGL as graphic engine. But I'not sure this linked to the bug you are talking about. I mean, I moved other applet to openGL and I never got this result (poor quality).

They have another applet (named Garden) that runs better with openGL: smoother and better quality.
But I don't see the difference between the former one and Garden.

their URL:
http://www.artcom.de/process/



Page Index Toggle Pages: 1