From 3e362bd611e1799ec2f1d632666bb9b6876e457d Mon Sep 17 00:00:00 2001 From: "jul..om" Date: Fri, 26 Oct 2012 17:45:59 +0000 Subject: [PATCH] Removes some dead code and fixes the V-sync git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9906 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../jme3/system/jogl/JoglAbstractDisplay.java | 24 ++++++++++++------- .../com/jme3/system/jogl/JoglContext.java | 7 ------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/engine/src/jogl/com/jme3/system/jogl/JoglAbstractDisplay.java b/engine/src/jogl/com/jme3/system/jogl/JoglAbstractDisplay.java index ce2346939..0801c1687 100644 --- a/engine/src/jogl/com/jme3/system/jogl/JoglAbstractDisplay.java +++ b/engine/src/jogl/com/jme3/system/jogl/JoglAbstractDisplay.java @@ -49,6 +49,7 @@ import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; +import javax.media.opengl.GLRunnable; import javax.media.opengl.awt.GLCanvas; public abstract class JoglAbstractDisplay extends JoglContext implements GLEventListener { @@ -75,9 +76,11 @@ public abstract class JoglAbstractDisplay extends JoglContext implements GLEvent protected void initGLCanvas() { device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); - - GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); - /*caps.setHardwareAccelerated(true); + + //FIXME use the settings to know whether to use the max programmable profile + //then call GLProfile.getMaxProgrammable(true); + GLCapabilities caps = new GLCapabilities(GLProfile.getMaxFixedFunc(true)); + caps.setHardwareAccelerated(true); caps.setDoubleBuffered(true); caps.setStencilBits(settings.getStencilBits()); caps.setDepthBits(settings.getDepthBits()); @@ -85,7 +88,7 @@ public abstract class JoglAbstractDisplay extends JoglContext implements GLEvent if (settings.getSamples() > 1) { caps.setSampleBuffers(true); caps.setNumSamples(settings.getSamples()); - }*/ + } canvas = new GLCanvas(caps) { @Override @@ -101,14 +104,18 @@ public abstract class JoglAbstractDisplay extends JoglContext implements GLEvent } }; if (settings.isVSync()) { - // FIXME: it is too early to get the GL instance from the canvas - canvas.getGL().setSwapInterval(1); + canvas.invoke(false, new GLRunnable() { + + public boolean run(GLAutoDrawable glad) { + canvas.getGL().setSwapInterval(1); + return true; + } + }); } canvas.setFocusable(true); canvas.requestFocus(); canvas.setSize(settings.getWidth(), settings.getHeight()); canvas.setIgnoreRepaint(true); - //canvas.setAutoSwapBufferMode(false); canvas.addGLEventListener(this); @@ -130,12 +137,11 @@ public abstract class JoglAbstractDisplay extends JoglContext implements GLEvent protected void startGLCanvas() { if (frameRate > 0) { animator = new FPSAnimator(canvas, frameRate); - // ((FPSAnimator)animator).setRunAsFastAsPossible(true); } else { animator = new Animator(); animator.add(canvas); - //((Animator) animator).setRunAsFastAsPossible(true); + ((Animator) animator).setRunAsFastAsPossible(true); } animator.start(); diff --git a/engine/src/jogl/com/jme3/system/jogl/JoglContext.java b/engine/src/jogl/com/jme3/system/jogl/JoglContext.java index ae43213c7..f6abcbde8 100644 --- a/engine/src/jogl/com/jme3/system/jogl/JoglContext.java +++ b/engine/src/jogl/com/jme3/system/jogl/JoglContext.java @@ -125,12 +125,6 @@ public abstract class JoglContext implements JmeContext { created.set(true); createdLock.notifyAll(); } - // renderer initialization must happen in subclass. - /*if (renderable.get()){ - initContextFirstTime(); - }else{ - assert getType() == Type.Canvas; - }*/ } protected void internalDestroy() { @@ -142,5 +136,4 @@ public abstract class JoglContext implements JmeContext { createdLock.notifyAll(); } } - }