Mercurial > sdl-ios-xcode
annotate src/video/quartz/SDL_QuartzGL.m @ 770:ac44ddb84f6f
*** empty log message ***
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 04 Jan 2004 17:04:54 +0000 |
parents | c5b2b6d2d1fe |
children | ce05e92d909b |
rev | line source |
---|---|
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2003 Sam Lantinga |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Library General Public |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2 of the License, or (at your option) any later version. |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Library General Public License for more details. |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Library General Public |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 #include "SDL_QuartzVideo.h" |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 @implementation NSOpenGLContext (CGLContextAccess) |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 - (CGLContextObj) cglContext; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 return _contextAuxiliary; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 @end |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 /* OpenGL helper functions (used internally) */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 int QZ_SetupOpenGL (_THIS, int bpp, Uint32 flags) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 NSOpenGLPixelFormatAttribute attr[32]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 NSOpenGLPixelFormat *fmt; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 int i = 0; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 int colorBits = bpp; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 if ( flags & SDL_FULLSCREEN ) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 attr[i++] = NSOpenGLPFAFullScreen; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 /* In windowed mode, the OpenGL pixel depth must match device pixel depth */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 else if ( colorBits != device_bpp ) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 colorBits = device_bpp; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 attr[i++] = NSOpenGLPFAColorSize; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 attr[i++] = colorBits; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 attr[i++] = NSOpenGLPFADepthSize; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 attr[i++] = this->gl_config.depth_size; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 if ( this->gl_config.double_buffer ) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 attr[i++] = NSOpenGLPFADoubleBuffer; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 if ( this->gl_config.stereo ) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 attr[i++] = NSOpenGLPFAStereo; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 if ( this->gl_config.stencil_size != 0 ) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 attr[i++] = NSOpenGLPFAStencilSize; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 attr[i++] = this->gl_config.stencil_size; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 #if NSOPENGL_CURRENT_VERSION > 1 /* What version should this be? */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 if ( this->gl_config.multisamplebuffers != 0 ) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 attr[i++] = NSOpenGLPFASampleBuffers; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 attr[i++] = this->gl_config.multisamplebuffers; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 if ( this->gl_config.multisamplesamples != 0 ) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 attr[i++] = NSOpenGLPFASamples; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 attr[i++] = this->gl_config.multisamplesamples; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 #endif |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 attr[i++] = NSOpenGLPFAScreenMask; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 attr[i++] = CGDisplayIDToOpenGLDisplayMask (display_id); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 attr[i] = 0; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 fmt = [ [ NSOpenGLPixelFormat alloc ] initWithAttributes:attr ]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 if (fmt == nil) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 SDL_SetError ("Failed creating OpenGL pixel format"); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 return 0; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 gl_context = [ [ NSOpenGLContext alloc ] initWithFormat:fmt |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 shareContext:nil]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 if (gl_context == nil) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 SDL_SetError ("Failed creating OpenGL context"); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 return 0; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 /* |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 * Wisdom from Apple engineer in reference to UT2003's OpenGL performance: |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 * "You are blowing a couple of the internal OpenGL function caches. This |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 * appears to be happening in the VAO case. You can tell OpenGL to up |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 * the cache size by issuing the following calls right after you create |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 * the OpenGL context. The default cache size is 16." --ryan. |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 #ifndef GLI_ARRAY_FUNC_CACHE_MAX |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 #define GLI_ARRAY_FUNC_CACHE_MAX 284 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 #endif |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 #ifndef GLI_SUBMIT_FUNC_CACHE_MAX |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 #define GLI_SUBMIT_FUNC_CACHE_MAX 280 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 #endif |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 long cache_max = 64; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 CGLContextObj ctx = [ gl_context cglContext ]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 CGLSetParameter (ctx, GLI_SUBMIT_FUNC_CACHE_MAX, &cache_max); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 CGLSetParameter (ctx, GLI_ARRAY_FUNC_CACHE_MAX, &cache_max); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 /* End Wisdom from Apple Engineer section. --ryan. */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 /* Convince SDL that the GL "driver" is loaded */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 this->gl_config.driver_loaded = 1; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 [ fmt release ]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 return 1; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 void QZ_TearDownOpenGL (_THIS) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 [ NSOpenGLContext clearCurrentContext ]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 [ gl_context clearDrawable ]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 [ gl_context release ]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 /* SDL OpenGL functions */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 int QZ_GL_LoadLibrary (_THIS, const char *location) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 this->gl_config.driver_loaded = 1; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 return 1; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 void* QZ_GL_GetProcAddress (_THIS, const char *proc) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 /* We may want to cache the bundleRef at some point */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 CFBundleRef bundle; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 CFURLRef bundleURL = CFURLCreateWithFileSystemPath (kCFAllocatorDefault, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 CFSTR("/System/Library/Frameworks/OpenGL.framework"), kCFURLPOSIXPathStyle, true); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 CFStringRef functionName = CFStringCreateWithCString |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 (kCFAllocatorDefault, proc, kCFStringEncodingASCII); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 void *function; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 bundle = CFBundleCreate (kCFAllocatorDefault, bundleURL); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 assert (bundle != NULL); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 function = CFBundleGetFunctionPointerForName (bundle, functionName); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 CFRelease ( bundleURL ); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 CFRelease ( functionName ); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 CFRelease ( bundle ); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 return function; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 int QZ_GL_GetAttribute (_THIS, SDL_GLattr attrib, int* value) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 GLenum attr = 0; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 QZ_GL_MakeCurrent (this); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 switch (attrib) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 case SDL_GL_RED_SIZE: attr = GL_RED_BITS; break; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 case SDL_GL_BLUE_SIZE: attr = GL_BLUE_BITS; break; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 case SDL_GL_GREEN_SIZE: attr = GL_GREEN_BITS; break; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 case SDL_GL_ALPHA_SIZE: attr = GL_ALPHA_BITS; break; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 case SDL_GL_DOUBLEBUFFER: attr = GL_DOUBLEBUFFER; break; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 case SDL_GL_DEPTH_SIZE: attr = GL_DEPTH_BITS; break; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 case SDL_GL_STENCIL_SIZE: attr = GL_STENCIL_BITS; break; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 case SDL_GL_ACCUM_RED_SIZE: attr = GL_ACCUM_RED_BITS; break; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 case SDL_GL_ACCUM_GREEN_SIZE: attr = GL_ACCUM_GREEN_BITS; break; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 case SDL_GL_ACCUM_BLUE_SIZE: attr = GL_ACCUM_BLUE_BITS; break; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 case SDL_GL_ACCUM_ALPHA_SIZE: attr = GL_ACCUM_ALPHA_BITS; break; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 case SDL_GL_STEREO: attr = GL_STEREO; break; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 case SDL_GL_MULTISAMPLEBUFFERS: attr = GL_SAMPLE_BUFFERS_ARB; break; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 case SDL_GL_MULTISAMPLESAMPLES: attr = GL_SAMPLES_ARB; break; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 case SDL_GL_BUFFER_SIZE: |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 GLint bits = 0; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 GLint component; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 /* there doesn't seem to be a single flag in OpenGL for this! */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 glGetIntegerv (GL_RED_BITS, &component); bits += component; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 glGetIntegerv (GL_GREEN_BITS,&component); bits += component; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 glGetIntegerv (GL_BLUE_BITS, &component); bits += component; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 glGetIntegerv (GL_ALPHA_BITS, &component); bits += component; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 *value = bits; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 return 0; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 glGetIntegerv (attr, (GLint *)value); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 return 0; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 int QZ_GL_MakeCurrent (_THIS) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 [ gl_context makeCurrentContext ]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 return 0; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 void QZ_GL_SwapBuffers (_THIS) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 [ gl_context flushBuffer ]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 } |