I add jogl to EditorPart , but find some bug at refresh area, help me please.
Posted by yymusic on Nov 02, 2015; 3:12am
URL: https://forum.jogamp.org/I-add-jogl-to-EditorPart-but-find-some-bug-at-refresh-area-help-me-please-tp4035693.html
I add joal 2.1 to eclipse, add to a EditorPart control, When I run it, I seed the 3D graphic.
Then I open other program, the window of other program will cover the part of 3D window. When I minimized the other program window, I will see the 3D graphic again, but only the area that covered by other windows before can rendering now. other area are frozen.
sample code as follow, thanks.
canvas.addListener(SWT.Resize, new Listener() {
@Override
public void handleEvent(Event event) {
Rectangle bounds = canvas.getBounds();
float fAspect = (float) bounds.width / (float) bounds.height;
canvas.setCurrent();
context.makeCurrent();
GL2 gl = context.getGL().getGL2();
gl.glViewport(0, 0, bounds.width, bounds.height);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
GLU glu = new GLU();
glu.gluPerspective(45.0f, fAspect, 0.5f, 400.0f);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
context.release();
}
});
canvas.addPaintListener(new PaintListener()
{
int rot = 1;
public void paintControl(PaintEvent e)
{
if (!canvas.isDisposed()) {
canvas.setCurrent();
context.makeCurrent();
GL2 gl = context.getGL().getGL2();
gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
gl.glClearColor(.3f, .5f, .8f, 1.0f);
gl.glLoadIdentity();
gl.glTranslatef(0.0f, 0.0f, -10.0f);
float frot = rot;
gl.glRotatef(0.15f * rot, 2.0f * frot, 10.0f * frot, 1.0f);
gl.glRotatef(0.3f * rot, 3.0f * frot, 1.0f * frot, 1.0f);
//rot++;
gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE);
gl.glColor3f(0.9f, 0.9f, 0.9f);
drawTorus(gl, 1, 1.9f + ((float) Math.sin((0.004f * frot))), 15, 15);
canvas.swapBuffers();
context.release();
//display.asyncExec(this);
}
}
});
context.makeCurrent();
GL2 gl = context.getGL().getGL2();
gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
gl.glColor3f(1.0f, 0.0f, 0.0f);
gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST);
gl.glClearDepth(1.0);
gl.glLineWidth(2);
gl.glEnable(GL2.GL_DEPTH_TEST);
context.release();