From 6489c103b5005a5d0b8e701105f07a1cd3dec576 Mon Sep 17 00:00:00 2001 From: Gerard Ziemski Date: Wed, 18 Jan 2006 00:40:29 +0000 Subject: clamp the passed in values to their max if necessary - fixes InfiniteShadowVolumes demo git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@547 232f8b59-042b-4e1e-8c03-345bb8c30851 --- src/native/jogl/MacOSXWindowSystemInterface.m | 122 +++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/native/jogl/MacOSXWindowSystemInterface.m b/src/native/jogl/MacOSXWindowSystemInterface.m index 73027bbee..42d3d8e5d 100644 --- a/src/native/jogl/MacOSXWindowSystemInterface.m +++ b/src/native/jogl/MacOSXWindowSystemInterface.m @@ -13,8 +13,108 @@ #endif #endif +// kCGLPFAColorFloat is equivalent to NSOpenGLPFAColorFloat, but the +// latter is only available on 10.4 and we need to compile under +// 10.3 +#ifndef NSOpenGLPFAColorFloat + #define NSOpenGLPFAColorFloat kCGLPFAColorFloat +#endif + + typedef int Bool; +static Bool rendererInfoInitialized = false; +static int bufferDepthsLength = 17; +static int bufferDepths[] = {kCGL128Bit, kCGL96Bit, kCGL64Bit, kCGL48Bit, kCGL32Bit, kCGL24Bit, kCGL16Bit, kCGL12Bit, kCGL10Bit, kCGL8Bit, kCGL6Bit, kCGL5Bit, kCGL4Bit, kCGL3Bit, kCGL2Bit, kCGL1Bit, kCGL0Bit}; +static int bufferDepthsBits[] = {128, 96, 64, 48, 32, 24, 16, 12, 10, 8, 6, 5, 4, 3, 2, 1, 0}; +static int accRenderID = 0; // the ID of the accelerated renderer +static int maxColorSize = kCGL128Bit; // max depth of color buffer +static int maxDepthSize = kCGL128Bit; // max depth of depth buffer +static int maxAccumSize = kCGL128Bit; // max depth of accum buffer +static int maxStencilSize = kCGL128Bit; // max depth of stencil buffer +void getRendererInfo() +{ + if (rendererInfoInitialized == false) + { + rendererInfoInitialized = true; + + CGLRendererInfoObj info; + long numRenderers = 0; + CGLError err = CGLQueryRendererInfo(CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay), &info, &numRenderers); + if (err == kCGLNoError) + { + CGLDescribeRenderer(info, 0, kCGLRPRendererCount, &numRenderers); + long j; + for (j=0; j maxColorSize) { + colorSize = maxColorSize; + } + int accumSize = accumRedBits + accumGreenBits + accumBlueBits; + if (accumSize > maxAccumSize) { + accumSize = maxAccumSize; + } + + if (depthBits > maxDepthSize) { + depthBits = maxDepthSize; + } + + if (stencilBits > maxStencilSize) { + stencilBits = maxStencilSize; + } NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -69,10 +186,7 @@ void* createContext(void* shareContext, void* view, NSOpenGLPixelFormatAttribute attribs[256]; int idx = 0; if (pbuffer) attribs[idx++] = NSOpenGLPFAPixelBuffer; - // kCGLPFAColorFloat is equivalent to NSOpenGLPFAColorFloat, but the - // latter is only available on 10.4 and we need to compile under - // 10.3 - if (floatingPoint) attribs[idx++] = kCGLPFAColorFloat; + if (floatingPoint) attribs[idx++] = NSOpenGLPFAColorFloat; if (doubleBuffer) attribs[idx++] = NSOpenGLPFADoubleBuffer; if (stereo) attribs[idx++] = NSOpenGLPFAStereo; attribs[idx++] = NSOpenGLPFAColorSize; attribs[idx++] = colorSize; -- cgit v1.2.3