aboutsummaryrefslogtreecommitdiffstats
path: root/ardor3d-jogl
diff options
context:
space:
mode:
authorJulien Gouesse <[email protected]>2013-05-07 22:30:01 +0200
committerJulien Gouesse <[email protected]>2013-05-07 22:30:01 +0200
commita5a28593b52b96c7b06017a3a519c11dba07b298 (patch)
tree45ec66a9c83e1be1a8f00bc2b1392bd02753cf4c /ardor3d-jogl
parent9df16a95aada4d6071df73e07eb9923c23de79d5 (diff)
Allows to override the capabilities utilities
Diffstat (limited to 'ardor3d-jogl')
-rw-r--r--ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/CapsUtil.java6
-rw-r--r--ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java7
-rw-r--r--ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java9
-rw-r--r--ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java7
-rw-r--r--ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java8
-rw-r--r--ardor3d-jogl/src/main/java/com/ardor3d/image/util/jogl/JoglImageLoader.java10
-rw-r--r--ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglPbufferTextureRenderer.java35
7 files changed, 54 insertions, 28 deletions
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/CapsUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/CapsUtil.java
index b74bea0..5a5fb95 100644
--- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/CapsUtil.java
+++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/CapsUtil.java
@@ -18,7 +18,7 @@ import com.ardor3d.util.Ardor3dException;
public class CapsUtil {
- public static GLProfile getProfile() {
+ public GLProfile getProfile() {
// tries to get the most capable profile, programmable or fixed, desktop or embedded, forward or backward
// compatible
GLProfile profile = GLProfile.getMaximum(true);
@@ -31,11 +31,11 @@ public class CapsUtil {
return profile;
}
- public static GLCapabilities getCapsForSettings(final DisplaySettings settings) {
+ public GLCapabilities getCapsForSettings(final DisplaySettings settings) {
return getCapsForSettings(settings, true, false, false, false);
}
- public static GLCapabilities getCapsForSettings(final DisplaySettings settings, final boolean onscreen,
+ public GLCapabilities getCapsForSettings(final DisplaySettings settings, final boolean onscreen,
final boolean bitmapRequested, final boolean pbufferRequested, final boolean fboRequested) {
// Validate window dimensions.
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java
index 6e3d140..defb510 100644
--- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java
+++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java
@@ -41,7 +41,12 @@ public class JoglAwtCanvas extends GLCanvas implements Canvas {
private final JoglInitializerRunnable _initializerRunnable;
public JoglAwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer) {
- super(CapsUtil.getCapsForSettings(settings));
+ this(settings, canvasRenderer, new CapsUtil());
+ }
+
+ public JoglAwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer,
+ final CapsUtil capsUtil) {
+ super(capsUtil.getCapsForSettings(settings));
_drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer);
_initializerRunnable = new JoglInitializerRunnable(this, settings);
_settings = settings;
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 ac5b136..1be8017 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
@@ -64,13 +64,16 @@ public class JoglCanvasRenderer implements CanvasRenderer {
*/
private boolean _debugEnabled = false;
+ protected CapsUtil _capsUtil;
+
public JoglCanvasRenderer(final Scene scene) {
- this(scene, false);
+ this(scene, false, new CapsUtil());
}
- public JoglCanvasRenderer(final Scene scene, final boolean useDebug) {
+ public JoglCanvasRenderer(final Scene scene, final boolean useDebug, final CapsUtil capsUtil) {
_scene = scene;
_useDebug = useDebug;
+ _capsUtil = capsUtil;
}
public void makeCurrentContext() throws Ardor3dException {
@@ -133,7 +136,7 @@ public class JoglCanvasRenderer implements CanvasRenderer {
public void init(final DisplaySettings settings, final boolean doSwap) {
_doSwap = doSwap;
if (_context == null) {
- _context = GLDrawableFactory.getFactory(CapsUtil.getProfile()).createExternalGLContext();
+ _context = GLDrawableFactory.getFactory(_capsUtil.getProfile()).createExternalGLContext();
}
makeCurrentContext();
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java
index 0de1c99..f633f31 100644
--- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java
+++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java
@@ -33,7 +33,12 @@ public class JoglNewtAwtCanvas extends NewtCanvasAWT implements Canvas, NewtWind
private final JoglDrawerRunnable _drawerGLRunnable;
public JoglNewtAwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer) {
- super(GLWindow.create(CapsUtil.getCapsForSettings(settings)));
+ this(settings, canvasRenderer, new CapsUtil());
+ }
+
+ public JoglNewtAwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer,
+ final CapsUtil capsUtil) {
+ super(GLWindow.create(capsUtil.getCapsForSettings(settings)));
_drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer);
getNewtWindow().setUndecorated(true);
_settings = settings;
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java
index a7cb777..9f6a710 100644
--- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java
+++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java
@@ -51,7 +51,13 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer {
public JoglNewtWindow(final JoglCanvasRenderer canvasRenderer, final DisplaySettings settings,
final boolean onscreen, final boolean bitmapRequested, final boolean pbufferRequested,
final boolean fboRequested) {
- _newtWindow = GLWindow.create(CapsUtil.getCapsForSettings(settings, onscreen, bitmapRequested,
+ this(canvasRenderer, settings, onscreen, bitmapRequested, pbufferRequested, fboRequested, new CapsUtil());
+ }
+
+ public JoglNewtWindow(final JoglCanvasRenderer canvasRenderer, final DisplaySettings settings,
+ final boolean onscreen, final boolean bitmapRequested, final boolean pbufferRequested,
+ final boolean fboRequested, final CapsUtil capsUtil) {
+ _newtWindow = GLWindow.create(capsUtil.getCapsForSettings(settings, onscreen, bitmapRequested,
pbufferRequested, fboRequested));
_drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer);
_settings = settings;
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/image/util/jogl/JoglImageLoader.java b/ardor3d-jogl/src/main/java/com/ardor3d/image/util/jogl/JoglImageLoader.java
index 145a745..d3b87a1 100644
--- a/ardor3d-jogl/src/main/java/com/ardor3d/image/util/jogl/JoglImageLoader.java
+++ b/ardor3d-jogl/src/main/java/com/ardor3d/image/util/jogl/JoglImageLoader.java
@@ -34,7 +34,9 @@ import com.jogamp.opengl.util.texture.TextureIO;
public class JoglImageLoader implements ImageLoader {
- private static boolean createOnHeap = false;
+ public static boolean createOnHeap = false;
+
+ protected CapsUtil _capsUtil;
private enum TYPE {
BYTE(ByteBuffer.class), SHORT(ShortBuffer.class), CHAR(CharBuffer.class), INT(IntBuffer.class), FLOAT(
@@ -60,11 +62,13 @@ public class JoglImageLoader implements ImageLoader {
ImageLoaderUtil.registerHandler(new JoglImageLoader(), supportedFormats);
}
- public JoglImageLoader() {}
+ public JoglImageLoader() {
+ _capsUtil = new CapsUtil();
+ }
@Override
public Image load(final InputStream is, final boolean flipped) throws IOException {
- final TextureData textureData = TextureIO.newTextureData(CapsUtil.getProfile(), is, true, null);
+ final TextureData textureData = TextureIO.newTextureData(_capsUtil.getProfile(), is, true, null);
final Buffer textureDataBuffer = textureData.getBuffer();
final Image ardorImage = new Image();
final TYPE bufferDataType = getBufferDataType(textureDataBuffer);
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 b0bacca..2b877ee 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
@@ -56,16 +56,19 @@ import com.ardor3d.util.geom.BufferUtils;
public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer {
private static final Logger logger = Logger.getLogger(JoglPbufferTextureRenderer.class.getName());
- private GLOffscreenAutoDrawable offscreenDrawable;
+ private GLOffscreenAutoDrawable _offscreenDrawable;
private GLContext _context;
+ protected CapsUtil _capsUtil;
+
// HACK: needed to get the parent context in here somehow...
public static GLContext _parentContext;
public JoglPbufferTextureRenderer(final DisplaySettings settings, final Renderer parentRenderer,
final ContextCapabilities caps) {
super(settings, parentRenderer, caps);
+ _capsUtil = new CapsUtil();
setMultipleTargets(false);
}
@@ -127,7 +130,7 @@ 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 (offscreenDrawable == null) {
+ if (_offscreenDrawable == null) {
initPbuffer();
}
@@ -196,7 +199,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 (offscreenDrawable == null) {
+ if (_offscreenDrawable == null) {
initPbuffer();
}
@@ -264,15 +267,15 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer {
private void initPbuffer() {
try {
- if (offscreenDrawable != null) {
+ if (_offscreenDrawable != null) {
_context.destroy();
- offscreenDrawable.destroy();
+ _offscreenDrawable.destroy();
giveBackContext();
- ContextManager.removeContext(offscreenDrawable.getContext());
+ ContextManager.removeContext(_offscreenDrawable.getContext());
}
// Make our GLPbuffer...
- final GLProfile profile = CapsUtil.getProfile();
+ final GLProfile profile = _capsUtil.getProfile();
final GLDrawableFactory fac = GLDrawableFactory.getFactory(profile);
final GLCapabilities caps = new GLCapabilities(profile);
caps.setHardwareAccelerated(true);
@@ -285,12 +288,12 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer {
caps.setDoubleBuffered(false);
caps.setOnscreen(false);
caps.setPBuffer(true);
- offscreenDrawable = fac.createOffscreenAutoDrawable(null, caps, null, _width, _height, _parentContext);
- _context = offscreenDrawable.getContext();
+ _offscreenDrawable = fac.createOffscreenAutoDrawable(null, caps, null, _width, _height, _parentContext);
+ _context = _offscreenDrawable.getContext();
_context.makeCurrent();
- final JoglContextCapabilities contextCaps = new JoglContextCapabilities(offscreenDrawable.getGL());
+ final JoglContextCapabilities contextCaps = new JoglContextCapabilities(_offscreenDrawable.getGL());
ContextManager.addContext(_context,
new JoglRenderContext(_context, contextCaps, ContextManager.getCurrentContext()));
@@ -312,8 +315,8 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer {
try {
activate();
- _width = offscreenDrawable.getWidth();
- _height = offscreenDrawable.getHeight();
+ _width = _offscreenDrawable.getWidth();
+ _height = _offscreenDrawable.getHeight();
deactivate();
} catch (final Exception e) {
@@ -356,17 +359,17 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer {
}
public void cleanup() {
- ContextManager.removeContext(offscreenDrawable.getContext());
- offscreenDrawable.destroy();
+ ContextManager.removeContext(_offscreenDrawable.getContext());
+ _offscreenDrawable.destroy();
}
public void setMultipleTargets(final boolean force) {
if (force) {
logger.fine("Copy Texture Pbuffer used!");
_useDirectRender = false;
- if (offscreenDrawable != null) {
+ if (_offscreenDrawable != null) {
giveBackContext();
- ContextManager.removeContext(offscreenDrawable.getContext());
+ ContextManager.removeContext(_offscreenDrawable.getContext());
}
} else {
// XXX: Is this WGL specific query right?