From ad503c41557606d15b0420c824369456f6d20a8f Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Thu, 1 Apr 2010 11:01:31 -0700 Subject: apple: Initial import of libGL for OSX from AppleSGLX svn repository. Signed-off-by: Jeremy Huddleston --- src/glx/apple/apple_visual.c | 144 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 src/glx/apple/apple_visual.c (limited to 'src/glx/apple/apple_visual.c') diff --git a/src/glx/apple/apple_visual.c b/src/glx/apple/apple_visual.c new file mode 100644 index 0000000000..e80914741e --- /dev/null +++ b/src/glx/apple/apple_visual.c @@ -0,0 +1,144 @@ +/* + Copyright (c) 2008, 2009 Apple Inc. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT + HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + Except as contained in this notice, the name(s) of the above + copyright holders shall not be used in advertising or otherwise to + promote the sale, use or other dealings in this Software without + prior written authorization. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "apple_cgl.h" +#include "apple_visual.h" +#include "apple_glx.h" +#include "glcontextmodes.h" + +enum +{ + MAX_ATTR = 60 +}; + +/*mode is a __GlcontextModes*/ +void +apple_visual_create_pfobj(CGLPixelFormatObj * pfobj, const void *mode, + bool * double_buffered, bool * uses_stereo, + bool offscreen) +{ + CGLPixelFormatAttribute attr[MAX_ATTR]; + const __GLcontextModes *c = mode; + int numattr = 0; + GLint vsref = 0; + CGLError error = 0; + + if (offscreen) { + apple_glx_diagnostic + ("offscreen rendering enabled. Using kCGLPFAOffScreen\n"); + + attr[numattr++] = kCGLPFAOffScreen; + attr[numattr++] = kCGLPFAColorSize; + attr[numattr++] = 32; + } + else if (getenv("LIBGL_ALWAYS_SOFTWARE") != NULL) { + apple_glx_diagnostic + ("Software rendering requested. Using kCGLRendererGenericFloatID.\n"); + attr[numattr++] = kCGLPFARendererID; + attr[numattr++] = kCGLRendererGenericFloatID; + } + else if (getenv("LIBGL_ALLOW_SOFTWARE") != NULL) { + apple_glx_diagnostic + ("Software rendering is not being excluded. Not using kCGLPFAAccelerated.\n"); + } + else { + attr[numattr++] = kCGLPFAAccelerated; + } + + /* + * The program chose a config based on the fbconfigs or visuals. + * Those are based on the attributes from CGL, so we probably + * do want the closest match for the color, depth, and accum. + */ + attr[numattr++] = kCGLPFAClosestPolicy; + + if (c->stereoMode) { + attr[numattr++] = kCGLPFAStereo; + *uses_stereo = true; + } + else { + *uses_stereo = false; + } + + if (c->doubleBufferMode) { + attr[numattr++] = kCGLPFADoubleBuffer; + *double_buffered = true; + } + else { + *double_buffered = false; + } + + attr[numattr++] = kCGLPFAColorSize; + attr[numattr++] = c->redBits + c->greenBits + c->blueBits; + attr[numattr++] = kCGLPFAAlphaSize; + attr[numattr++] = c->alphaBits; + + if ((c->accumRedBits + c->accumGreenBits + c->accumBlueBits) > 0) { + attr[numattr++] = kCGLPFAAccumSize; + attr[numattr++] = c->accumRedBits + c->accumGreenBits + + c->accumBlueBits + c->accumAlphaBits; + } + + if (c->depthBits > 0) { + attr[numattr++] = kCGLPFADepthSize; + attr[numattr++] = c->depthBits; + } + + if (c->stencilBits > 0) { + attr[numattr++] = kCGLPFAStencilSize; + attr[numattr++] = c->stencilBits; + } + + if (c->sampleBuffers > 0) { + attr[numattr++] = kCGLPFAMultisample; + attr[numattr++] = kCGLPFASampleBuffers; + attr[numattr++] = c->sampleBuffers; + attr[numattr++] = kCGLPFASamples; + attr[numattr++] = c->samples; + } + + attr[numattr++] = 0; + + assert(numattr < MAX_ATTR); + + error = apple_cgl.choose_pixel_format(attr, pfobj, &vsref); + + if (error) { + fprintf(stderr, "error: %s\n", apple_cgl.error_string(error)); + abort(); + } +} -- cgit v1.2.3 From a1cb3babbef2af222b839a058694acc82a7074f1 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Mon, 12 Apr 2010 18:37:47 -0700 Subject: Buildfixes to work around issues in OpenGL.framework Signed-off-by: Jeremy Huddleston --- src/glx/apple/apple_glx.h | 2 +- src/glx/apple/apple_glx_context.h | 12 +++++++-- src/glx/apple/apple_glx_drawable.h | 6 ++++- src/glx/apple/apple_glx_pbuffer.c | 23 ++++++++++++++--- src/glx/apple/apple_visual.c | 9 +++++++ src/glx/apple/apple_xgl_api_read.c | 5 ++-- src/glx/apple/apple_xgl_api_read.h | 47 ---------------------------------- src/glx/apple/apple_xgl_api_stereo.c | 13 ++++++++-- src/glx/apple/apple_xgl_api_stereo.h | 39 ---------------------------- src/glx/apple/apple_xgl_api_viewport.c | 3 ++- src/glx/apple/apple_xgl_api_viewport.h | 36 -------------------------- 11 files changed, 60 insertions(+), 135 deletions(-) delete mode 100644 src/glx/apple/apple_xgl_api_read.h delete mode 100644 src/glx/apple/apple_xgl_api_stereo.h delete mode 100644 src/glx/apple/apple_xgl_api_viewport.h (limited to 'src/glx/apple/apple_visual.c') diff --git a/src/glx/apple/apple_glx.h b/src/glx/apple/apple_glx.h index 3ee54aa6cf..9b3643bf15 100644 --- a/src/glx/apple/apple_glx.h +++ b/src/glx/apple/apple_glx.h @@ -31,10 +31,10 @@ #define APPLE_GLX_H #include -#include #include #include #include + #define XP_NO_X_HEADERS #include diff --git a/src/glx/apple/apple_glx_context.h b/src/glx/apple/apple_glx_context.h index 7e2394f2bb..c2a3e3fcf6 100644 --- a/src/glx/apple/apple_glx_context.h +++ b/src/glx/apple/apple_glx_context.h @@ -29,11 +29,19 @@ #ifndef APPLE_GLX_CONTEXT_H #define APPLE_GLX_CONTEXT_H +/* */ +#define glTexImage1D glTexImage1D_OSX +#define glTexImage2D glTexImage2D_OSX +#define glTexImage3D glTexImage3D_OSX +#include +#include +#undef glTexImage1D +#undef glTexImage2D +#undef glTexImage3D + #include #include #include -#include -#include #define XP_NO_X_HEADERS #include #undef XP_NO_X_HEADERS diff --git a/src/glx/apple/apple_glx_drawable.h b/src/glx/apple/apple_glx_drawable.h index a15858963d..e49eae355e 100644 --- a/src/glx/apple/apple_glx_drawable.h +++ b/src/glx/apple/apple_glx_drawable.h @@ -29,6 +29,11 @@ #ifndef APPLE_GLX_DRAWABLE_H #define APPLE_GLX_DRAWABLE_H +/* Must be first for: + * + */ +#include "apple_glx_context.h" + #include #include #include @@ -36,7 +41,6 @@ #define XP_NO_X_HEADERS #include #undef XP_NO_X_HEADERS -#include "apple_glx_context.h" enum { diff --git a/src/glx/apple/apple_glx_pbuffer.c b/src/glx/apple/apple_glx_pbuffer.c index fb56b7512e..1466fea487 100644 --- a/src/glx/apple/apple_glx_pbuffer.c +++ b/src/glx/apple/apple_glx_pbuffer.c @@ -27,16 +27,33 @@ prior written authorization. */ +/* Must be before OpenGL.framework is included. Remove once fixed: + * + */ +#include +#include +#define __gltypes_h_ 1 + +/* Must be first for: + * + */ +#include "apple_glx_context.h" +#include "apple_glx_drawable.h" + #include #include #include -#include #include "apple_glx.h" #include "glcontextmodes.h" -#include "apple_glx_context.h" -#include "apple_glx_drawable.h" #include "apple_cgl.h" +/* mesa defines in glew.h, Apple in glext.h. + * Due to namespace nightmares, just do it here. + */ +#ifndef GL_TEXTURE_RECTANGLE_EXT +#define GL_TEXTURE_RECTANGLE_EXT 0x84F5 +#endif + static bool pbuffer_make_current(struct apple_glx_context *ac, struct apple_glx_drawable *d); diff --git a/src/glx/apple/apple_visual.c b/src/glx/apple/apple_visual.c index e80914741e..da5aa05fd5 100644 --- a/src/glx/apple/apple_visual.c +++ b/src/glx/apple/apple_visual.c @@ -32,9 +32,18 @@ #include #include #include + +/* */ +#define glTexImage1D glTexImage1D_OSX +#define glTexImage2D glTexImage2D_OSX +#define glTexImage3D glTexImage3D_OSX #include #include #include +#undef glTexImage1D +#undef glTexImage2D +#undef glTexImage3D + #include "apple_cgl.h" #include "apple_visual.h" #include "apple_glx.h" diff --git a/src/glx/apple/apple_xgl_api_read.c b/src/glx/apple/apple_xgl_api_read.c index 36357c7fc2..0798f45bbf 100644 --- a/src/glx/apple/apple_xgl_api_read.c +++ b/src/glx/apple/apple_xgl_api_read.c @@ -34,10 +34,9 @@ * drawable if they are different. */ #include -#include "apple_xgl_api_read.h" -#include "apple_xgl_api.h" -#include "apple_cgl.h" +#include "glxclient.h" #include "apple_glx_context.h" +#include "apple_xgl_api.h" extern struct apple_xgl_api __gl_api; diff --git a/src/glx/apple/apple_xgl_api_read.h b/src/glx/apple/apple_xgl_api_read.h deleted file mode 100644 index ffeb32afb8..0000000000 --- a/src/glx/apple/apple_xgl_api_read.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (c) 2008, 2009 Apple Inc. - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation files - (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT - HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - - Except as contained in this notice, the name(s) of the above - copyright holders shall not be used in advertising or otherwise to - promote the sale, use or other dealings in this Software without - prior written authorization. -*/ - -/* - * This file works with the glXMakeContextCurrent readable drawable. - */ -#ifndef APPLE_XGL_API_READ_H -#define APPLE_XGL_API_READ_H - -#include "glxclient.h" - -extern void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, void *pixels); - -extern void glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, - GLenum type); - -extern void glCopyColorTable(GLenum target, GLenum internalformat, GLint x, - GLint y, GLsizei width); - -#endif diff --git a/src/glx/apple/apple_xgl_api_stereo.c b/src/glx/apple/apple_xgl_api_stereo.c index 7dd946f764..64a15f7486 100644 --- a/src/glx/apple/apple_xgl_api_stereo.c +++ b/src/glx/apple/apple_xgl_api_stereo.c @@ -27,10 +27,19 @@ prior written authorization. */ +/* This should be removed once stereo hardware bugs are fixed + * + */ + #include -#include "apple_xgl_api_stereo.h" -#include "apple_xgl_api.h" + +#define GL_GLEXT_PROTOTYPES +#include +#include + +#include "glxclient.h" #include "apple_glx_context.h" +#include "apple_xgl_api.h" extern struct apple_xgl_api __gl_api; /* diff --git a/src/glx/apple/apple_xgl_api_stereo.h b/src/glx/apple/apple_xgl_api_stereo.h deleted file mode 100644 index c285363f6f..0000000000 --- a/src/glx/apple/apple_xgl_api_stereo.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - Copyright (c) 2009 Apple Inc. - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation files - (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT - HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - - Except as contained in this notice, the name(s) of the above - copyright holders shall not be used in advertising or otherwise to - promote the sale, use or other dealings in this Software without - prior written authorization. -*/ - -#include "glxclient.h" - -#ifndef APPLE_XGL_API_STEREO_H -#define APPLE_XGL_API_STEREO_H - -extern void glDrawBuffer(GLenum mode); -extern void glDrawBuffers(GLsizei n, const GLenum * bufs); -extern void glDrawBuffersARB(GLsizei n, const GLenum * bufs); - -#endif diff --git a/src/glx/apple/apple_xgl_api_viewport.c b/src/glx/apple/apple_xgl_api_viewport.c index f556eefa22..e39ab15223 100644 --- a/src/glx/apple/apple_xgl_api_viewport.c +++ b/src/glx/apple/apple_xgl_api_viewport.c @@ -26,9 +26,10 @@ promote the sale, use or other dealings in this Software without prior written authorization. */ + +#include "glxclient.h" #include "apple_glx_context.h" #include "apple_xgl_api.h" -#include "apple_xgl_api_viewport.h" extern struct apple_xgl_api __gl_api; diff --git a/src/glx/apple/apple_xgl_api_viewport.h b/src/glx/apple/apple_xgl_api_viewport.h deleted file mode 100644 index 6c89ca7998..0000000000 --- a/src/glx/apple/apple_xgl_api_viewport.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright (c) 2009 Apple Inc. - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation files - (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT - HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - - Except as contained in this notice, the name(s) of the above - copyright holders shall not be used in advertising or otherwise to - promote the sale, use or other dealings in this Software without - prior written authorization. -*/ -#ifndef APPLE_XGL_API_VIEWPORT_H -#define APPLE_XGL_API_VIEWPORT_H - -#include "glxclient.h" - -void glViewport(GLint x, GLint y, GLsizei width, GLsizei height); - -#endif -- cgit v1.2.3