Bug 1360 : (1.0.8+) opengl + resize window => window content garbled
Last modified: 2009-10-23 06:54




Status:
RESOLVED
Resolution:
INVALID -
Priority:
P2
Severity:
normal

 

Reporter:
mots
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2009-10-22 23:45
Hello,


while using the openGL mode, and setting the window resizable, if you
resize the window, its content becomes garbled.

1.0.6 on XP sp3 = ok
1.0.6 on OSX 10.6 : ok
1.0.8 on OSX 10.6 : not ok
1.0.8 XP sp3 : not ok.
1.0.9 XP sp3 : not ok.
1.0.9 on OSX 10.6 : not ok

some more details and screenshot here :
http://processing.org/discourse/yabb2/YaBB.pl?num=1255971129/

here is an example of program that does not work as expected below)

import javax.media.opengl.GL;
import processing.opengl.PGraphicsOpenGL;
import com.sun.opengl.util.GLUT;



// OPENGL
private PGraphicsOpenGL pgl;
private GL gl;
private GLUT glut;

void init() {
frame.setResizable(true);
super.init();
}

public void setup() {
//OPENGL
size(320, 200, OPENGL);
pgl = (PGraphicsOpenGL) g;
}

public void draw() {
gl = pgl.beginGL();
//draw some random shapes
float[][] points = new float[10][];
for(int i=0;i<10;i++){
points[i]=new
float[]{(float)Math.random()*320,(float)Math.random()*200};
}
shape(points);
pgl.endGL();
gl.glFlush();
}

private void shape( float[][] points){
float ratio=0;
gl.glBegin(GL.GL_POLYGON);
for(int i=0;i<points.length;i++){
gl.glColor4f(
0.5+(float)Math.random()*0.2f,
0.8+(float)Math.random()*0.2f,
0.1+(float)Math.random()*0.2f,
(float)Math.random()*0.5f);
gl.glVertex2f(points[i][0],points[i][1]);
}
gl.glEnd();
}
Additional Comment #1 From fry 2009-10-23 06:33
call background(). otherwise, opengl is never clearing the pixel buffers
properly so you're just writing into mangled memory. processing can't do it
for you because 1) it can't know what the bg color is and 2) whether you're
even using a bg color or image or whatever.
Additional Comment #2 From mots 2009-10-23 06:54
Hi,

sorry my mistake, i just wrote the code be removing all the unncessary code
from my project so that the bug report was concise enough.
Here is the same code with updated background.

resize the window. it does not work any more. the greenish shape is not
showing anymore in 1.0.8 or 1.0.9. it work just as expected in 1.0.6.
i just re tested it at the minute on XP sp3.


import javax.media.opengl.GL;
import processing.opengl.PGraphicsOpenGL;
import com.sun.opengl.util.GLUT;

// OPENGL
private PGraphicsOpenGL pgl;
private GL gl;
private GLUT glut;
float[][] points;

void init() {
frame.setResizable(true);
super.init();
}

public void setup() {
//OPENGL
size(320, 200, OPENGL);
pgl = (PGraphicsOpenGL) g;

points = new float[10][];
for(int i=0;i<10;i++){
points[i]=new
float[]{
(float)Math.random()*320,(float)Math.random()*200};
}

}

public void draw() {
gl = pgl.beginGL();
//draw some random shapes
shape(points);
pgl.endGL();
gl.glFlush();
}

private void shape( float[][] points){
background((float)Math.random()*124f);
float ratio=0;
gl.glBegin(GL.GL_POLYGON);
for(int i=0;i<points.length;i++){
gl.glColor4f(
0.5+(float)Math.random()*0.2f,
0.8+(float)Math.random()*0.2f,
0.1+(float)Math.random()*0.2f,
(float)Math.random()*0.5f
);
gl.glVertex2f(points[i][0],points[i][1]);
}
gl.glEnd();
}