diff options
author | Kenneth Russel <[email protected]> | 2005-05-20 19:21:02 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2005-05-20 19:21:02 +0000 |
commit | bea9f9567ca5892813b308bf92eab96166248afe (patch) | |
tree | da37b659a3dc5028ac54f4a1852d3aae52d6b118 | |
parent | a6655b13e61b28e5e2c38c7b53c6d26db93b0cbb (diff) |
Added first-cut support for floating-point pbuffers on Mac OS X
(untested)
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@276 232f8b59-042b-4e1e-8c03-345bb8c30851
-rw-r--r-- | make/cgl-macosx.cfg | 2 | ||||
-rw-r--r-- | make/stub_includes/macosx/window-system.c | 2 | ||||
-rw-r--r-- | src/native/jogl/MacOSXWindowSystemInterface.m | 6 | ||||
-rw-r--r-- | src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java | 14 |
4 files changed, 18 insertions, 6 deletions
diff --git a/make/cgl-macosx.cfg b/make/cgl-macosx.cfg index e4fad5a5f..ac91c252c 100644 --- a/make/cgl-macosx.cfg +++ b/make/cgl-macosx.cfg @@ -39,7 +39,7 @@ CustomCCode extern void updateContext(void* nsContext, void* nsView); CustomCCode extern void* updateContextRegister(void* nsContext, void* nsView); CustomCCode extern void updateContextUnregister(void* nsContext, void* nsView, void* updater); -CustomCCode extern void* createPBuffer(int renderTarget, int width, int height); +CustomCCode extern void* createPBuffer(int renderTarget, int internalFormat, int width, int height); CustomCCode extern Bool destroyPBuffer(void* nsContext, void* pBuffer); CustomCCode extern void setContextPBuffer(void* nsContext, void* pBuffer); CustomCCode extern void setContextTextureImageToPBuffer(void* nsContext, void* pBuffer, int colorBuffer); diff --git a/make/stub_includes/macosx/window-system.c b/make/stub_includes/macosx/window-system.c index 8ce6120a3..d15406263 100644 --- a/make/stub_includes/macosx/window-system.c +++ b/make/stub_includes/macosx/window-system.c @@ -27,7 +27,7 @@ void updateContext(void* nsContext, void* nsView); void* updateContextRegister(void* nsContext, void* nsView); void updateContextUnregister(void* nsContext, void* nsView, void* updater); -void* createPBuffer(int renderTarget, int width, int height); +void* createPBuffer(int renderTarget, int internalFormat, int width, int height); Bool destroyPBuffer(void* nsContext, void* pBuffer); void setContextPBuffer(void* nsContext, void* pBuffer); void setContextTextureImageToPBuffer(void* nsContext, void* pBuffer, int colorBuffer); diff --git a/src/native/jogl/MacOSXWindowSystemInterface.m b/src/native/jogl/MacOSXWindowSystemInterface.m index 46c50ceb7..f77c6f2c1 100644 --- a/src/native/jogl/MacOSXWindowSystemInterface.m +++ b/src/native/jogl/MacOSXWindowSystemInterface.m @@ -161,11 +161,11 @@ void updateContextUnregister(void* context, void* view, void* updater) [contextUpdater release]; } -void* createPBuffer(int renderTarget, int width, int height) +void* createPBuffer(int renderTarget, int internalFormat, int width, int height) { - // fprintf(stderr, "createPBuffer renderTarget=%d width=%d height=%d\n", renderTarget, width, height); + // fprintf(stderr, "createPBuffer renderTarget=%d internalFormat=%d width=%d height=%d\n", renderTarget, internalFormat, width, height); - NSOpenGLPixelBuffer* pBuffer = [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:renderTarget textureInternalFormat:GL_RGBA textureMaxMipMapLevel:0 pixelsWide:width pixelsHigh:height]; + NSOpenGLPixelBuffer* pBuffer = [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:renderTarget textureInternalFormat:internalFormat textureMaxMipMapLevel:0 pixelsWide:width pixelsHigh:height]; return pBuffer; } diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java index bc046bcc1..d374230d9 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java @@ -64,8 +64,20 @@ public class MacOSXPbufferGLContext extends MacOSXGLContext { height = getNextPowerOf2(initHeight); renderTarget = GL.GL_TEXTURE_2D; } + + int internalFormat = GL.GL_RGBA; + if (capabilities.getOffscreenFloatingPointBuffers()) { + if (!gl.isExtensionAvailable("GL_APPLE_float_pixels")) { + throw new GLException("Floating-point support (GL_APPLE_float_pixels) not available"); + } + switch (capabilities.getRedBits()) { + case 16: internalFormat = GL.GL_RGBA_FLOAT16_APPLE; break; + case 32: internalFormat = GL.GL_RGBA_FLOAT32_APPLE; break; + default: throw new GLException("Invalid floating-point bit depth (only 16 and 32 supported)"); + } + } - pBuffer = CGL.createPBuffer(renderTarget, width, height); + pBuffer = CGL.createPBuffer(renderTarget, internalFormat, width, height); if (pBuffer == 0) { throw new GLException("pbuffer creation error: CGL.createPBuffer() failed"); } |