hey!
i’m writing a fullscreen-library for the processing programming language and one of the users pointed out to me that on his mac in fullscreen-exclusive mode he can only achieve 30fps.
it turns out this bug only appears on nvidia cards.
so i’ve tested on different versions of jogl to confirm this behavior.
with the jogl-jsr231-2.0 library from
in window mode i get ~900fps, while i only get a constant 30fps in fullscreen-exclusive mode.
so honestly i’m feeling lost and don’t know where to start searching for this problem.
sorry for this vague question, but if you have any advice or guess i’d be happy.
best,
hansi.
p.s.
I don’t think it matters much, but here’s the code i used:
package test;
import java.awt.GraphicsDevice;
import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.awt.GLCanvas;
import javax.media.opengl.glu.GLU;
import javax.swing.JFrame;
import com.sun.opengl.util.FPSAnimator;
import com.sun.opengl.util.gl2.GLUT;
public class Test extends JFrame implements GLEventListener{
// When is the last time we measured?
long lastMeasure = 0;
int frameCounter = 0;
float fps = 0;
GLUT glut = new GLUT();
public static void main(String[] args) {
new Test();
}
public Test(){
super( "hey ho!" );
setSize( 300, 300 );
setDefaultCloseOperation( EXIT_ON_CLOSE );
setUndecorated( true );
//enable/disable the next two lines for fullscreen-excl. mode
//GraphicsDevice device = getGraphicsConfiguration().getDevice();
//device.setFullScreenWindow( this );
final GLCanvas canvas = new GLCanvas();
canvas.addGLEventListener( this );
getContentPane().add( canvas );
setVisible( true );
}
@Override
public void display( GLAutoDrawable drawable ){
frameCounter ++;
if( System.currentTimeMillis() - lastMeasure > 1000 ){
fps = frameCounter * 1000f / ( System.currentTimeMillis() - lastMeasure );
lastMeasure = System.currentTimeMillis();
frameCounter = 0;
System.out.println( fps );
}
GL2 gl = drawable.getGL().getGL2();
gl.glLoadIdentity();
gl.glClearColor( 0, 0, 0, 1 );
gl.glClear( GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
gl.setSwapInterval( 0 );
gl.glColor3f( 1, 1, 1 );
gl.glRasterPos2i( 0, 0 );
glut.glutBitmapString( GLUT.BITMAP_8_BY_13, fps + " fps" );
}
// All the code from here on is just annoying boilerplate.
@Override
public void init( final GLAutoDrawable drawable ){
System.out.println( "Init!" );
GL2 gl = drawable.getGL().getGL2();
gl.glShadeModel( GL2.GL_SMOOTH );
gl.glClearDepth( 1.0 );
gl.glDepthFunc( GL.GL_LEQUAL );
gl.glEnable( GL.GL_DEPTH_TEST );
gl.glHint( GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST );
gl.setSwapInterval( 0 );
FPSAnimator animator = new FPSAnimator( drawable, 1000 );
animator.start();
// Also doesn't work:
// Animator animator2 = new Animator( drawable );
// animator2.setRunAsFastAsPossible( true );
// animator2.start();
}
@Override
public void reshape( GLAutoDrawable drawable, int x, int y, int width, int height ){
GL2 gl = drawable.getGL().getGL2();
GLU glu = new GLU();
gl.glViewport( 0, 0, width, height );
gl.glMatrixMode( GL2.GL_PROJECTION );
gl.glLoadIdentity();
glu.gluPerspective( 45.0f, 0, 0.1f, 1000.0f);
gl.glMatrixMode( GL2.GL_MODELVIEW );
gl.glLoadIdentity();
gl.setSwapInterval( 0 );
}
@Override
public void dispose(GLAutoDrawable arg0) {
// TODO Auto-generated method stub
}
}