Login  Register

Re: display() called repeatedly, yet screen not updated?

Posted by jerron on May 25, 2011; 3:52pm
URL: https://forum.jogamp.org/display-called-repeatedly-yet-screen-not-updated-tp2979558p2984801.html

I'm now using the latest build from git and have come up with a cut down version of the above that demonstrates a strange timing issue:

--

package com.io7m.javagl1;

import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;

import com.jogamp.newt.event.WindowAdapter;
import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.util.FPSAnimator;

public final class JavaGL1 implements GLEventListener
{
  static {
    GLProfile.initSingleton(true);
  }

  private static void initGL()
  {
    final GLProfile profile = GLProfile.getDefault();
    final GLCapabilities capabilities = new GLCapabilities(profile);
    final GLWindow window = GLWindow.create(capabilities);

    window.setSize(300, 300);
    window.setVisible(true);
    window.setTitle("NEWT Window Test");
    window.addWindowListener(new WindowAdapter() {
      @Override public void windowDestroyNotify(final WindowEvent arg0)
      {
        System.exit(0);
      }
    });

    final JavaGL1 test0 = new JavaGL1();
    window.addGLEventListener(test0);

    final FPSAnimator animator = new FPSAnimator(window, 1);
    animator.add(window);
    animator.start();
  }

  public static void main(final String[] args)
  {
    JavaGL1.initGL();
  }

  @Override public void dispose(final GLAutoDrawable drawable)
  {
    System.out.println("info: dispose");
  }

  @Override public void init(final GLAutoDrawable drawable)
  {
    System.out.println("info: init - autoswap(" + drawable.getAutoSwapBufferMode() + ")");
  }

  @Override public void display(final GLAutoDrawable drawable)
  {
    System.out.println("info: display " + System.currentTimeMillis());
  }

  @Override public void reshape(final GLAutoDrawable drawable,
                                final int x,
                                final int y,
                                final int width,
                                final int height)
  {
    System.out.println("info: resize " + x + "," + y + "+" + width + "x" + height);
  }
}

--

The output of the program is:

Info: XInitThreads() called for concurrent Thread support
Detected screen size 2880x900
info: init - autoswap(true)
info: resize 0,0+1438x438
info: display 1306338624188
info: display 1306338624193
info: display 1306338625187
info: display 1306338625192
info: display 1306338626189
info: display 1306338626196
info: display 1306338627190
info: display 1306338627195
info: display 1306338628191
info: display 1306338628196
info: display 1306338629192
info: display 1306338629197
info: display 1306338630193
info: display 1306338630198
info: display 1306338631195
info: display 1306338631200
info: display 1306338632196
info: display 1306338632201
info: display 1306338633197
info: display 1306338633202
info: display 1306338634198
info: display 1306338634203
info: display 1306338635198
info: display 1306338635203
info: display 1306338636200
info: display 1306338636205
info: display 1306338637202
info: display 1306338637209
info: dispose
Warning: EDT about (2) to stop, having remaining tasks: 1 - Thread[main-Display-X11_:0.0-1-EDT-1,5,main]

Note that given the 'new FPSAnimator(window, 1);', display should be called once per second, but it's
being called twice in quick succession, milliseconds apart, each second. I believe this could be the cause of the screen update issues but I don't know how to fix it.