diff options
Diffstat (limited to 'src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java')
-rw-r--r-- | src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java index 70068ce63..5e2662b47 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java @@ -4,16 +4,20 @@ import net.java.games.jogl.*; import net.java.games.jogl.impl.*; public class MacOSXPbufferGLContext extends MacOSXGLContext { + private static final boolean DEBUG = false; + + // see MacOSXWindowSystemInterface.m createPBuffer + private static final boolean USE_GL_TEXTURE_RECTANGLE_EXT = true; - private int initWidth; - private int initHeight; + protected int initWidth; + protected int initHeight; private long pBuffer; private int pBufferTextureName; - private int width; - private int height; + protected int width; + protected int height; // FIXME: kept around because we create the OpenGL context lazily to // better integrate with the MacOSXGLContext framework @@ -23,10 +27,6 @@ public class MacOSXPbufferGLContext extends MacOSXGLContext { super(null, capabilities, null, null); this.initWidth = initialWidth; this.initHeight = initialHeight; - if (initWidth <= 0 || initHeight <= 0) { - throw new GLException("Initial width and height of pbuffer must be positive (were (" + - initWidth + ", " + initHeight + "))"); - } } public boolean canCreatePbufferContext() { @@ -61,14 +61,35 @@ public class MacOSXPbufferGLContext extends MacOSXGLContext { nsContextOfParent = parentContext; - width = getNextPowerOf2(initWidth); - height = getNextPowerOf2(initHeight); - + if (USE_GL_TEXTURE_RECTANGLE_EXT) + { + // GL_TEXTURE_RECTANGLE_EXT + width = initWidth; + height = initHeight; + } + else + { + // GL_TEXTURE_2D + width = getNextPowerOf2(initWidth); + height = getNextPowerOf2(initHeight); + } + if (DEBUG) { System.err.println("Created pbuffer " + width + " x " + height); } } + public void destroyPBuffer() { + if (this.pBuffer != 0) { + CGL.destroyPBuffer(nsContext, pBuffer); + } + this.pBuffer = 0; + + if (DEBUG) { + System.err.println("Destroyed pbuffer " + width + " x " + height); + } + } + public void handleModeSwitch(long parentView, long parentContext) { throw new GLException("Not yet implemented"); } @@ -79,18 +100,6 @@ public class MacOSXPbufferGLContext extends MacOSXGLContext { return false; } - public int getOffscreenContextBufferedImageType() { - throw new GLException("Should not call this"); - } - - public int getOffscreenContextReadBuffer() { - throw new GLException("Should not call this"); - } - - public boolean offscreenImageNeedsVerticalFlip() { - throw new GLException("Should not call this"); - } - protected void swapBuffers() throws GLException { // FIXME: do we need to do anything if the pbuffer is double-buffered? } |