Removes some dead code and fixes the V-sync

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9906 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
jul..om 12 years ago
parent a5b8b48ea1
commit 3e362bd611
  1. 22
      engine/src/jogl/com/jme3/system/jogl/JoglAbstractDisplay.java
  2. 7
      engine/src/jogl/com/jme3/system/jogl/JoglContext.java

@ -49,6 +49,7 @@ import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener; import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile; import javax.media.opengl.GLProfile;
import javax.media.opengl.GLRunnable;
import javax.media.opengl.awt.GLCanvas; import javax.media.opengl.awt.GLCanvas;
public abstract class JoglAbstractDisplay extends JoglContext implements GLEventListener { public abstract class JoglAbstractDisplay extends JoglContext implements GLEventListener {
@ -76,8 +77,10 @@ public abstract class JoglAbstractDisplay extends JoglContext implements GLEvent
protected void initGLCanvas() { protected void initGLCanvas() {
device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); //FIXME use the settings to know whether to use the max programmable profile
/*caps.setHardwareAccelerated(true); //then call GLProfile.getMaxProgrammable(true);
GLCapabilities caps = new GLCapabilities(GLProfile.getMaxFixedFunc(true));
caps.setHardwareAccelerated(true);
caps.setDoubleBuffered(true); caps.setDoubleBuffered(true);
caps.setStencilBits(settings.getStencilBits()); caps.setStencilBits(settings.getStencilBits());
caps.setDepthBits(settings.getDepthBits()); caps.setDepthBits(settings.getDepthBits());
@ -85,7 +88,7 @@ public abstract class JoglAbstractDisplay extends JoglContext implements GLEvent
if (settings.getSamples() > 1) { if (settings.getSamples() > 1) {
caps.setSampleBuffers(true); caps.setSampleBuffers(true);
caps.setNumSamples(settings.getSamples()); caps.setNumSamples(settings.getSamples());
}*/ }
canvas = new GLCanvas(caps) { canvas = new GLCanvas(caps) {
@Override @Override
@ -101,14 +104,18 @@ public abstract class JoglAbstractDisplay extends JoglContext implements GLEvent
} }
}; };
if (settings.isVSync()) { if (settings.isVSync()) {
// FIXME: it is too early to get the GL instance from the canvas canvas.invoke(false, new GLRunnable() {
canvas.getGL().setSwapInterval(1);
public boolean run(GLAutoDrawable glad) {
canvas.getGL().setSwapInterval(1);
return true;
}
});
} }
canvas.setFocusable(true); canvas.setFocusable(true);
canvas.requestFocus(); canvas.requestFocus();
canvas.setSize(settings.getWidth(), settings.getHeight()); canvas.setSize(settings.getWidth(), settings.getHeight());
canvas.setIgnoreRepaint(true); canvas.setIgnoreRepaint(true);
//canvas.setAutoSwapBufferMode(false);
canvas.addGLEventListener(this); canvas.addGLEventListener(this);
@ -130,12 +137,11 @@ public abstract class JoglAbstractDisplay extends JoglContext implements GLEvent
protected void startGLCanvas() { protected void startGLCanvas() {
if (frameRate > 0) { if (frameRate > 0) {
animator = new FPSAnimator(canvas, frameRate); animator = new FPSAnimator(canvas, frameRate);
// ((FPSAnimator)animator).setRunAsFastAsPossible(true);
} }
else { else {
animator = new Animator(); animator = new Animator();
animator.add(canvas); animator.add(canvas);
//((Animator) animator).setRunAsFastAsPossible(true); ((Animator) animator).setRunAsFastAsPossible(true);
} }
animator.start(); animator.start();

@ -125,12 +125,6 @@ public abstract class JoglContext implements JmeContext {
created.set(true); created.set(true);
createdLock.notifyAll(); createdLock.notifyAll();
} }
// renderer initialization must happen in subclass.
/*if (renderable.get()){
initContextFirstTime();
}else{
assert getType() == Type.Canvas;
}*/
} }
protected void internalDestroy() { protected void internalDestroy() {
@ -142,5 +136,4 @@ public abstract class JoglContext implements JmeContext {
createdLock.notifyAll(); createdLock.notifyAll();
} }
} }
} }

Loading…
Cancel
Save