aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Slack <[email protected]>2013-04-26 15:56:44 -0700
committerJoshua Slack <[email protected]>2013-04-26 15:56:44 -0700
commita2661ab409439eb014fcb13183874ab41da7a0b6 (patch)
treeafa152020d709294a42e642b4a5fe0e54b0a3f79
parent980b453284e1dcc0796bf2360bddccb5a1a2e859 (diff)
parent27ee15947fe711815fdf29a1933e5c1c7549bad9 (diff)
Merge pull request #45 from gouessej/master
Switches to JOGL 2.0.2 RC 20130425 and allows to control the creation of the renderer in the canvas renderer
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/framework/CanvasRenderer.java7
-rw-r--r--ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java7
-rw-r--r--ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglPbufferTextureRenderer.java55
-rw-r--r--ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglCanvasRenderer.java13
-rw-r--r--pom.xml2
5 files changed, 56 insertions, 28 deletions
diff --git a/ardor3d-core/src/main/java/com/ardor3d/framework/CanvasRenderer.java b/ardor3d-core/src/main/java/com/ardor3d/framework/CanvasRenderer.java
index e6790df..8ec45a9 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/framework/CanvasRenderer.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/framework/CanvasRenderer.java
@@ -60,6 +60,13 @@ public interface CanvasRenderer {
void setScene(Scene scene);
/**
+ * Creates a new renderer for this canvas renderer
+ *
+ * @return a new renderer
+ */
+ Renderer createRenderer();
+
+ /**
* Returns the renderer being used by this canvas renderer.
*
* @return the renderer used by this canvas renderer
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java
index da235c7..ac5b136 100644
--- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java
+++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java
@@ -124,6 +124,11 @@ public class JoglCanvasRenderer implements CanvasRenderer {
return new JoglContextCapabilities(_context.getGL());
}
+ @Override
+ public JoglRenderer createRenderer() {
+ return new JoglRenderer();
+ }
+
@MainThread
public void init(final DisplaySettings settings, final boolean doSwap) {
_doSwap = doSwap;
@@ -148,7 +153,7 @@ public class JoglCanvasRenderer implements CanvasRenderer {
ContextManager.addContext(_context, _currentContext);
ContextManager.switchContext(_context);
- _renderer = new JoglRenderer();
+ _renderer = createRenderer();
if (settings.getSamples() != 0 && caps.isMultisampleSupported()) {
final GL gl = GLContext.getCurrentGL();
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglPbufferTextureRenderer.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglPbufferTextureRenderer.java
index cbdb2a3..b0bacca 100644
--- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglPbufferTextureRenderer.java
+++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglPbufferTextureRenderer.java
@@ -19,7 +19,7 @@ import javax.media.opengl.GL;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
-import javax.media.opengl.GLPbuffer;
+import javax.media.opengl.GLOffscreenAutoDrawable;
import javax.media.opengl.GLProfile;
import com.ardor3d.framework.DisplaySettings;
@@ -48,15 +48,15 @@ import com.ardor3d.util.geom.BufferUtils;
* This class is used by Ardor3D's JOGL implementation to render textures. Users should <b>not </b> create this class
* directly.
* </p>
+ * N.B: This class can't work without a complete implementation of GLOffscreenAutoDrawable.PBuffer, which is currently
+ * missing from JOGL
*
* @see TextureRendererFactory
*/
public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer {
private static final Logger logger = Logger.getLogger(JoglPbufferTextureRenderer.class.getName());
- /* Pbuffer instance */
- // TODO use javax.media.opengl.GLOffscreenAutoDrawable
- private GLPbuffer _pbuffer;
+ private GLOffscreenAutoDrawable offscreenDrawable;
private GLContext _context;
@@ -127,13 +127,13 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer {
private void render(final List<? extends Spatial> toDrawA, final Spatial toDrawB, final Scene toDrawC,
final Texture tex, final int clear) {
try {
- if (_pbuffer == null) {
+ if (offscreenDrawable == null) {
initPbuffer();
}
if (_useDirectRender && !tex.getTextureStoreFormat().isDepthFormat()) {
// setup and render directly to a 2d texture.
- _pbuffer.releaseTexture();
+ releaseTexture();
activate();
switchCameraIn(clear);
@@ -146,7 +146,7 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer {
deactivate();
switchCameraOut();
JoglTextureStateUtil.doTextureBind(tex, 0, true);
- _pbuffer.bindTexture();
+ bindTexture();
} else {
// render and copy to a texture
activate();
@@ -172,6 +172,15 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer {
}
}
+ private void bindTexture() {
+ // FIXME The class PBuffer is going to be removed from JOGL very soon and GLOffscreenAutoDrawable.PBuffer is not
+ // yet ready
+ }
+
+ private void releaseTexture() {
+ // FIXME
+ }
+
public void render(final Spatial spat, final List<Texture> texs, final int clear) {
render(null, spat, null, texs, clear);
}
@@ -187,7 +196,7 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer {
private void render(final List<? extends Spatial> toDrawA, final Spatial toDrawB, final Scene toDrawC,
final List<Texture> texs, final int clear) {
try {
- if (_pbuffer == null) {
+ if (offscreenDrawable == null) {
initPbuffer();
}
@@ -196,7 +205,7 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer {
JoglTextureStateUtil.doTextureBind(texs.get(0), 0, true);
activate();
switchCameraIn(clear);
- _pbuffer.releaseTexture();
+ releaseTexture();
if (toDrawA != null) {
doDraw(toDrawA);
@@ -209,7 +218,7 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer {
switchCameraOut();
deactivate();
- _pbuffer.bindTexture();
+ bindTexture();
} else {
// render and copy to a texture
activate();
@@ -255,11 +264,11 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer {
private void initPbuffer() {
try {
- if (_pbuffer != null) {
+ if (offscreenDrawable != null) {
_context.destroy();
- _pbuffer.destroy();
+ offscreenDrawable.destroy();
giveBackContext();
- ContextManager.removeContext(_pbuffer);
+ ContextManager.removeContext(offscreenDrawable.getContext());
}
// Make our GLPbuffer...
@@ -274,12 +283,14 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer {
caps.setSampleBuffers(_settings.getSamples() != 0);
caps.setStencilBits(_settings.getStencilBits());
caps.setDoubleBuffered(false);
- _pbuffer = fac.createGLPbuffer(null, caps, null, _width, _height, _parentContext);
- _context = _pbuffer.getContext();
+ caps.setOnscreen(false);
+ caps.setPBuffer(true);
+ offscreenDrawable = fac.createOffscreenAutoDrawable(null, caps, null, _width, _height, _parentContext);
+ _context = offscreenDrawable.getContext();
_context.makeCurrent();
- final JoglContextCapabilities contextCaps = new JoglContextCapabilities(_pbuffer.getGL());
+ final JoglContextCapabilities contextCaps = new JoglContextCapabilities(offscreenDrawable.getGL());
ContextManager.addContext(_context,
new JoglRenderContext(_context, contextCaps, ContextManager.getCurrentContext()));
@@ -301,8 +312,8 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer {
try {
activate();
- _width = _pbuffer.getWidth();
- _height = _pbuffer.getHeight();
+ _width = offscreenDrawable.getWidth();
+ _height = offscreenDrawable.getHeight();
deactivate();
} catch (final Exception e) {
@@ -345,17 +356,17 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer {
}
public void cleanup() {
- ContextManager.removeContext(_pbuffer);
- _pbuffer.destroy();
+ ContextManager.removeContext(offscreenDrawable.getContext());
+ offscreenDrawable.destroy();
}
public void setMultipleTargets(final boolean force) {
if (force) {
logger.fine("Copy Texture Pbuffer used!");
_useDirectRender = false;
- if (_pbuffer != null) {
+ if (offscreenDrawable != null) {
giveBackContext();
- ContextManager.removeContext(_pbuffer);
+ ContextManager.removeContext(offscreenDrawable.getContext());
}
} else {
// XXX: Is this WGL specific query right?
diff --git a/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglCanvasRenderer.java b/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglCanvasRenderer.java
index 51f579d..9bcc2ee 100644
--- a/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglCanvasRenderer.java
+++ b/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglCanvasRenderer.java
@@ -22,11 +22,11 @@ import com.ardor3d.framework.Scene;
import com.ardor3d.math.ColorRGBA;
import com.ardor3d.math.Vector3;
import com.ardor3d.renderer.Camera;
+import com.ardor3d.renderer.Camera.ProjectionMode;
import com.ardor3d.renderer.ContextCapabilities;
import com.ardor3d.renderer.ContextManager;
import com.ardor3d.renderer.RenderContext;
import com.ardor3d.renderer.Renderer;
-import com.ardor3d.renderer.Camera.ProjectionMode;
import com.ardor3d.renderer.lwjgl.LwjglContextCapabilities;
import com.ardor3d.renderer.lwjgl.LwjglRenderer;
import com.ardor3d.util.Ardor3dException;
@@ -67,6 +67,11 @@ public class LwjglCanvasRenderer implements CanvasRenderer {
return new LwjglContextCapabilities(GLContext.getCapabilities());
}
+ @Override
+ public LwjglRenderer createRenderer() {
+ return new LwjglRenderer();
+ }
+
@MainThread
public void init(final DisplaySettings settings, final boolean doSwap) {
_doSwap = doSwap;
@@ -93,7 +98,7 @@ public class LwjglCanvasRenderer implements CanvasRenderer {
ContextManager.addContext(this, _currentContext);
ContextManager.switchContext(this);
- _renderer = new LwjglRenderer();
+ _renderer = createRenderer();
if (settings.getSamples() != 0 && caps.isMultisampleSupported()) {
GL11.glEnable(ARBMultisample.GL_MULTISAMPLE_ARB);
@@ -116,8 +121,8 @@ public class LwjglCanvasRenderer implements CanvasRenderer {
} else {
// use new width and height to set ratio.
_camera.setFrustumPerspective(_camera.getFovY(),
- (float) settings.getWidth() / (float) settings.getHeight(), _camera.getFrustumNear(), _camera
- .getFrustumFar());
+ (float) settings.getWidth() / (float) settings.getHeight(), _camera.getFrustumNear(),
+ _camera.getFrustumFar());
}
}
diff --git a/pom.xml b/pom.xml
index 919c8bb..4f07136 100644
--- a/pom.xml
+++ b/pom.xml
@@ -169,7 +169,7 @@
<!-- these properties help simplify specifying some commonly occurring variables -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <jogamp.version>2.0.2-rc20130404</jogamp.version>
+ <jogamp.version>2.0.2-rc-20130425</jogamp.version>
<lwjgl.version>2.8.4</lwjgl.version>
<swt.version>3650</swt.version>
<osgi.project.version>0.9_SNAPSHOT</osgi.project.version>