Bug 439 - GLCanvas flickers and displays its background or its scene alternately
Summary: GLCanvas flickers and displays its background or its scene alternately
Status: VERIFIED FIXED
Alias: None
Product: Jogl
Classification: JogAmp
Component: awt (show other bugs)
Version: 2
Hardware: pc_x86_32 windows
: P3 normal
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2010-11-26 05:28 CET by Cyrille
Modified: 2010-12-17 05:33 CET (History)
0 users

See Also:
Type: ---
SCM Refs:
86c164950b0a0d351fc8af3884187b10201b6237
Workaround: ---


Attachments
Runtime Version Check output, ran for all entries that appear in the test.bat script. (12.32 KB, application/octet-stream)
2010-11-26 05:28 CET, Cyrille
Details
Update Main.java to work properly (2.73 KB, text/plain)
2010-11-27 00:01 CET, Sven Gothel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Cyrille 2010-11-26 05:28:57 CET
Created attachment 180 [details]
Runtime Version Check output, ran for all entries that appear in the test.bat script.

Without animator, GLCanvas does not constantly display its OpenGL scene. It displays either its component background or the scene.

To reproduce the bug, please run the test application below. When the frame is being resized by dragging its edge over, the canvas flickers between yellow and red (resp. its background and its scene). When the resize operation ends, it randomly leaves the canvas in either configuration (yellow or red).

I only reproduced that bug on a Win32 platform but I did not try any other platform. I can't objectively assume it but it may be reproducable on every platform as well.

Sample code to reproduce the bug:
package GLSLTest;

import java.awt.Color;
import java.awt.Component;
import java.awt.Frame;

import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
import javax.swing.BoxLayout;

public class Main
{
        static CanvasListener listener = new CanvasListener();

        public static void main(String[] args)
        {
                GLProfile.initSingleton();

                GLProfile profile = GLProfile.getMaxFixedFunc();
                GLCapabilities caps = new GLCapabilities(profile);
                GLCanvas canvas = new GLCanvas(caps);
                canvas.setBackground(Color.yellow);
                canvas.addGLEventListener(listener);

                Frame topLevelFrame = new Frame();
                topLevelFrame.setLayout(new BoxLayout(topLevelFrame, BoxLayout.Y_AXIS));
                topLevelFrame.add(canvas);
                topLevelFrame.setSize(400, 300);
                topLevelFrame.setVisible(true);

                // Animator animator = new Animator(canvas);
                // animator.start();

                canvas.display();
        }
}

class CanvasListener implements GLEventListener
{
        @Override
        public void display(GLAutoDrawable arg0)
        {
                GL2 gl = arg0.getGL().getGL2();
                gl.glClearColor(1.0f, 0.0f, 0.0f, 0.5f);
                gl.glClear(GL.GL_COLOR_BUFFER_BIT);

                System.out.println("display");
        }

        @Override
        public void dispose(GLAutoDrawable arg0)
        {
        }

        @Override
        public void init(GLAutoDrawable arg0)
        {
                Component canvas = (Component) arg0;
                System.out.println(canvas.getSize().toString());
        }

        @Override
        public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4)
        {
        }
}
Comment 1 Sven Gothel 2010-11-27 00:00:27 CET
the JOGL version in your test log is
  ce3508aa66b9a40974cce2988094d0edc68b30f4
tag is v2.0-rc1 ie the signed rc.

But your code would not compile with it, since it uses a GLProfile API
before 
  774138544e1eec3330309ad682fa05154a07ab8d 
  2010-10-14 21:26:43

The GLProfile API has changed with that commit, well, I fixed that.

+++

Thanks to your report, I have revalidated the Java2D and AWT properties,
please check JOGL: 86c164950b0a0d351fc8af3884187b10201b6237,
especially the added doc:

http://jogamp.org/git/?p=jogl.git;a=blob;f=src/jogl/classes/javax/media/opengl/awt/GLCanvas.java;h=b230a2b6aa529aa69e8f5f5f47dcd6da2c585edb;hb=86c164950b0a0d351fc8af3884187b10201b6237#l79

Hope all of this helps, thank you.
Comment 2 Sven Gothel 2010-11-27 00:01:33 CET
Created attachment 183 [details]
Update Main.java to work properly
Comment 3 Cyrille 2010-11-27 02:56:07 CET
> The GLProfile API has changed with that commit, well, I fixed that.
You're right. I really tested the code against Jogl rc1 but I think I put the wrong code in my bug report. Sorry for the confusion.

> Thanks to your report, I have revalidated the Java2D and AWT properties,
> please check JOGL: 86c164950b0a0d351fc8af3884187b10201b6237,
> especially the added doc:
> 
> http://jogamp.org/git/?p=jogl.git;a=blob;f=src/jogl/classes/javax/media/opengl/awt/GLCanvas.java;h=b230a2b6aa529aa69e8f5f5f47dcd6da2c585edb;hb=86c164950b0a0d351fc8af3884187b10201b6237#l79
> 
> Hope all of this helps, thank you.

Great, thanks for this fix. I'll have a look at it as soon as I can.
Comment 4 Cyrille 2010-12-17 05:33:27 CET
At last, I could take a few minutes to test your fix. I ran the test with the autobuild of the 12/16/2010 (build 259). And... it runs perfectly!
Thanks!