diff options
author | Julien Gouesse <[email protected]> | 2013-04-06 13:48:19 +0200 |
---|---|---|
committer | Julien Gouesse <[email protected]> | 2013-04-06 13:48:19 +0200 |
commit | 4a0370758d4023ca095054c3c8d8583b89dfb465 (patch) | |
tree | 0613ccc2f8506f59ecbe4d3e8e4389c7591c0086 /ardor3d-jogl | |
parent | 742f72f5288e399627940818b25cc22585fc4596 (diff) |
Uses a single dedicated method to get the GLProfile
Diffstat (limited to 'ardor3d-jogl')
4 files changed, 29 insertions, 15 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 8d4eca8..2102ac3 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,6 +18,10 @@ import com.ardor3d.util.Ardor3dException; public class CapsUtil { + public static GLProfile getProfile() { + return GLProfile.getMaximum(true); + } + public static GLCapabilities getCapsForSettings(final DisplaySettings settings) { return getCapsForSettings(settings, true, false, false, false); } @@ -36,7 +40,7 @@ public class CapsUtil { throw new Ardor3dException("Invalid pixel depth: " + settings.getColorDepth()); } - final GLCapabilities caps = new GLCapabilities(GLProfile.getMaximum(true)); + final GLCapabilities caps = new GLCapabilities(getProfile()); caps.setHardwareAccelerated(true); caps.setDoubleBuffered(true); caps.setAlphaBits(settings.getAlphaBits()); 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 7137ab6..da235c7 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 @@ -23,7 +23,6 @@ import javax.media.opengl.GL; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; -import javax.media.opengl.GLProfile; import com.ardor3d.annotation.MainThread; import com.ardor3d.framework.CanvasRenderer; @@ -129,7 +128,7 @@ public class JoglCanvasRenderer implements CanvasRenderer { public void init(final DisplaySettings settings, final boolean doSwap) { _doSwap = doSwap; if (_context == null) { - _context = GLDrawableFactory.getFactory(GLProfile.getMaximum(true)).createExternalGLContext(); + _context = GLDrawableFactory.getFactory(CapsUtil.getProfile()).createExternalGLContext(); } makeCurrentContext(); 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 08e0367..c53e1e3 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 @@ -20,8 +20,7 @@ import java.nio.IntBuffer; import java.nio.LongBuffer; import java.nio.ShortBuffer; -import javax.media.opengl.GLProfile; - +import com.ardor3d.framework.jogl.CapsUtil; import com.ardor3d.image.Image; import com.ardor3d.image.PixelDataType; import com.ardor3d.image.util.ImageLoader; @@ -55,30 +54,32 @@ public class JoglImageLoader implements ImageLoader { @Override public Image load(final InputStream is, final boolean flipped) throws IOException { - final TextureData textureData = TextureIO.newTextureData(GLProfile.getMaximum(true), is, true, null); + final TextureData textureData = TextureIO.newTextureData(CapsUtil.getProfile(), is, true, null); final Buffer textureDataBuffer = textureData.getBuffer(); final Image ardorImage = new Image(); - - int dataSize = textureDataBuffer.capacity(); + final int elementSize; if (textureDataBuffer instanceof ShortBuffer) { - dataSize *= Buffers.SIZEOF_SHORT; + elementSize = Buffers.SIZEOF_SHORT; } else { if (textureDataBuffer instanceof IntBuffer) { - dataSize *= Buffers.SIZEOF_INT; + elementSize = Buffers.SIZEOF_INT; } else { if (textureDataBuffer instanceof LongBuffer) { - dataSize *= Buffers.SIZEOF_LONG; + elementSize = Buffers.SIZEOF_LONG; } else { if (textureDataBuffer instanceof FloatBuffer) { - dataSize *= Buffers.SIZEOF_FLOAT; + elementSize = Buffers.SIZEOF_FLOAT; } else { if (textureDataBuffer instanceof DoubleBuffer) { - dataSize *= Buffers.SIZEOF_DOUBLE; + elementSize = Buffers.SIZEOF_DOUBLE; + } else { + elementSize = 1; } } } } } + final int dataSize = textureDataBuffer.capacity() * elementSize; final ByteBuffer scratch = createOnHeap ? BufferUtils.createByteBufferOnHeap(dataSize) : Buffers .newDirectByteBuffer(dataSize); if (textureDataBuffer instanceof ShortBuffer) { @@ -122,7 +123,16 @@ public class JoglImageLoader implements ImageLoader { scratch.rewind(); textureDataBuffer.rewind(); if (flipped) { - + // FIXME + /* + * final int width = textureData.getWidth(); final int height = textureData.getHeight(); final int + * dataLineSize = elementSize * width; final byte[] buf0 = new byte[dataLineSize], buf1 = new + * byte[dataLineSize]; for (int lineIndex = 0; lineIndex < height / 2; lineIndex++) { final int + * line0DataIndex = lineIndex * dataLineSize; final int line1DataIndex = (height - lineIndex - 1) * + * dataLineSize; scratch.position(line0DataIndex); scratch.get(buf0); scratch.position(line1DataIndex); + * scratch.get(buf1); scratch.position(line0DataIndex); scratch.put(buf1); scratch.position(line1DataIndex); + * scratch.put(buf0); } scratch.rewind(); + */ } ardorImage.setWidth(textureData.getWidth()); ardorImage.setHeight(textureData.getHeight()); 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 8cce557..cbdb2a3 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 @@ -24,6 +24,7 @@ import javax.media.opengl.GLProfile; import com.ardor3d.framework.DisplaySettings; import com.ardor3d.framework.Scene; +import com.ardor3d.framework.jogl.CapsUtil; import com.ardor3d.image.Texture; import com.ardor3d.image.Texture.Type; import com.ardor3d.renderer.AbstractPbufferTextureRenderer; @@ -262,7 +263,7 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer { } // Make our GLPbuffer... - final GLProfile profile = GLProfile.getMaximum(true); + final GLProfile profile = CapsUtil.getProfile(); final GLDrawableFactory fac = GLDrawableFactory.getFactory(profile); final GLCapabilities caps = new GLCapabilities(profile); caps.setHardwareAccelerated(true); |