andrew_r
YaBB Newbies
Offline
Posts: 6
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