Mercurial > sdl-ios-xcode
annotate src/video/quartz/SDL_QuartzGL.m @ 1183:634d85aefc8c
Fixed bug reported here:
http://www.devolution.com/pipermail/sdl/2005-October/070998.html
--ryan.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 22 Nov 2005 09:59:42 +0000 |
parents | 49d3efec6651 |
children | c96b326b90ba |
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 |
857
ce05e92d909b
Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
770
diff
changeset
|
25 /* |
ce05e92d909b
Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
770
diff
changeset
|
26 * GL_ARB_Multisample is supposed to be available in 10.1, according to Apple: |
ce05e92d909b
Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
770
diff
changeset
|
27 * |
ce05e92d909b
Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
770
diff
changeset
|
28 * http://developer.apple.com/opengl/extensions.html#GL_ARB_multisample |
ce05e92d909b
Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
770
diff
changeset
|
29 * |
ce05e92d909b
Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
770
diff
changeset
|
30 * ...but it isn't in the system headers, according to Sam: |
ce05e92d909b
Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
770
diff
changeset
|
31 * |
ce05e92d909b
Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
770
diff
changeset
|
32 * http://www.libsdl.org/pipermail/sdl/2003-December/058335.html |
ce05e92d909b
Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
770
diff
changeset
|
33 * |
ce05e92d909b
Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
770
diff
changeset
|
34 * These are normally enums and not #defines in the system headers. |
ce05e92d909b
Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
770
diff
changeset
|
35 * |
ce05e92d909b
Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
770
diff
changeset
|
36 * --ryan. |
ce05e92d909b
Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
770
diff
changeset
|
37 */ |
ce05e92d909b
Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
770
diff
changeset
|
38 #if (MAC_OS_X_VERSION_MAX_ALLOWED < 1020) |
ce05e92d909b
Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
770
diff
changeset
|
39 #define NSOpenGLPFASampleBuffers ((NSOpenGLPixelFormatAttribute) 55) |
ce05e92d909b
Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
770
diff
changeset
|
40 #define NSOpenGLPFASamples ((NSOpenGLPixelFormatAttribute) 56) |
ce05e92d909b
Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
770
diff
changeset
|
41 #endif |
ce05e92d909b
Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
770
diff
changeset
|
42 |
761
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 @implementation NSOpenGLContext (CGLContextAccess) |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 - (CGLContextObj) cglContext; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 return _contextAuxiliary; |
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 @end |
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 /* OpenGL helper functions (used internally) */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 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
|
54 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 NSOpenGLPixelFormatAttribute attr[32]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 NSOpenGLPixelFormat *fmt; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 int i = 0; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 int colorBits = bpp; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 if ( flags & SDL_FULLSCREEN ) { |
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 attr[i++] = NSOpenGLPFAFullScreen; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 /* 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
|
65 else if ( colorBits != device_bpp ) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 colorBits = device_bpp; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 } |
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 attr[i++] = NSOpenGLPFAColorSize; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 attr[i++] = colorBits; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 attr[i++] = NSOpenGLPFADepthSize; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 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
|
75 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 if ( this->gl_config.double_buffer ) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 attr[i++] = NSOpenGLPFADoubleBuffer; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 if ( this->gl_config.stereo ) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 attr[i++] = NSOpenGLPFAStereo; |
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 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 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
|
85 attr[i++] = NSOpenGLPFAStencilSize; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 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
|
87 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 |
890
416158ec61a0
Date: Sat, 10 Apr 2004 10:05:46 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
857
diff
changeset
|
89 if ( (this->gl_config.accum_red_size + |
416158ec61a0
Date: Sat, 10 Apr 2004 10:05:46 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
857
diff
changeset
|
90 this->gl_config.accum_green_size + |
416158ec61a0
Date: Sat, 10 Apr 2004 10:05:46 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
857
diff
changeset
|
91 this->gl_config.accum_blue_size + |
416158ec61a0
Date: Sat, 10 Apr 2004 10:05:46 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
857
diff
changeset
|
92 this->gl_config.accum_alpha_size) > 0 ) { |
416158ec61a0
Date: Sat, 10 Apr 2004 10:05:46 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
857
diff
changeset
|
93 attr[i++] = NSOpenGLPFAAccumSize; |
416158ec61a0
Date: Sat, 10 Apr 2004 10:05:46 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
857
diff
changeset
|
94 attr[i++] = this->gl_config.accum_red_size + this->gl_config.accum_green_size + this->gl_config.accum_blue_size + this->gl_config.accum_alpha_size; |
416158ec61a0
Date: Sat, 10 Apr 2004 10:05:46 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
857
diff
changeset
|
95 } |
416158ec61a0
Date: Sat, 10 Apr 2004 10:05:46 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
857
diff
changeset
|
96 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 if ( this->gl_config.multisamplebuffers != 0 ) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 attr[i++] = NSOpenGLPFASampleBuffers; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 attr[i++] = this->gl_config.multisamplebuffers; |
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 if ( this->gl_config.multisamplesamples != 0 ) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 attr[i++] = NSOpenGLPFASamples; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 attr[i++] = this->gl_config.multisamplesamples; |
900
c3c8739f7844
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
890
diff
changeset
|
105 attr[i++] = NSOpenGLPFANoRecovery; |
c3c8739f7844
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
890
diff
changeset
|
106 attr[i++] = (NSOpenGLPixelFormatAttribute)nil; |
761
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 attr[i++] = NSOpenGLPFAScreenMask; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 attr[i++] = CGDisplayIDToOpenGLDisplayMask (display_id); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 attr[i] = 0; |
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 fmt = [ [ NSOpenGLPixelFormat alloc ] initWithAttributes:attr ]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 if (fmt == nil) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 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
|
116 return 0; |
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 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 gl_context = [ [ NSOpenGLContext alloc ] initWithFormat:fmt |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 shareContext:nil]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 |
1160
72c6c3e5bb85
Closed a memory leak caused when quitting video subsystem on Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
900
diff
changeset
|
122 [ fmt release ]; |
72c6c3e5bb85
Closed a memory leak caused when quitting video subsystem on Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
900
diff
changeset
|
123 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 if (gl_context == nil) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 SDL_SetError ("Failed creating OpenGL context"); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 return 0; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 } |
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 /* |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 * 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
|
131 * "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
|
132 * 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
|
133 * 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
|
134 * 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
|
135 */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 #ifndef GLI_ARRAY_FUNC_CACHE_MAX |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 #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
|
139 #endif |
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 #ifndef GLI_SUBMIT_FUNC_CACHE_MAX |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 #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
|
143 #endif |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 long cache_max = 64; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 CGLContextObj ctx = [ gl_context cglContext ]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 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
|
149 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
|
150 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 /* 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
|
153 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 /* 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
|
155 this->gl_config.driver_loaded = 1; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 return 1; |
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 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 void QZ_TearDownOpenGL (_THIS) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 [ NSOpenGLContext clearCurrentContext ]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 [ gl_context clearDrawable ]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 [ gl_context release ]; |
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 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 /* SDL OpenGL functions */ |
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 int QZ_GL_LoadLibrary (_THIS, const char *location) { |
1181
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
171 CFURLRef bundleURL; |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
172 CFStringRef cfstr; |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
173 |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
174 if ( gl_context != NULL ) { |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
175 SDL_SetError("OpenGL context already created"); |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
176 return -1; |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
177 } |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
178 |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
179 if (opengl_bundle != NULL) |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
180 CFRelease(opengl_bundle); |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
181 |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
182 opengl_bundle = NULL; |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
183 this->gl_config.driver_loaded = 0; |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
184 |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
185 if (location == NULL) |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
186 location = "/System/Library/Frameworks/OpenGL.framework"; |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
187 |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
188 cfstr = CFStringCreateWithCString(kCFAllocatorDefault, location, |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
189 kCFStringEncodingUTF8); |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
190 if (cfstr == NULL) { |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
191 SDL_OutOfMemory(); |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
192 return -1; |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
193 } |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
194 |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
195 bundleURL = CFURLCreateWithFileSystemPath (kCFAllocatorDefault, |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
196 cfstr, kCFURLPOSIXPathStyle, true); |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
197 |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
198 CFRelease(cfstr); |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
199 |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
200 if (bundleURL == NULL) { |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
201 SDL_OutOfMemory(); |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
202 return -1; |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
203 } |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
204 |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
205 opengl_bundle = CFBundleCreate (kCFAllocatorDefault, bundleURL); |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
206 |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
207 CFRelease(bundleURL); |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
208 |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
209 if (opengl_bundle != NULL) { |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
210 this->gl_config.driver_loaded = 1; |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
211 return 0; |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
212 } |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
213 |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
214 /* not exactly descriptive, but okay... */ |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
215 SDL_SetError("Could not load OpenGL library"); |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
216 return -1; |
761
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_GetProcAddress (_THIS, const char *proc) { |
1181
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
220 CFStringRef funcName = CFStringCreateWithCString |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 (kCFAllocatorDefault, proc, kCFStringEncodingASCII); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 |
1181
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
223 void *func = CFBundleGetFunctionPointerForName(opengl_bundle, funcName); |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
224 CFRelease (funcName); |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1177
diff
changeset
|
225 return func; |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 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
|
229 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 GLenum attr = 0; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 QZ_GL_MakeCurrent (this); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 switch (attrib) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 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
|
236 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
|
237 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
|
238 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
|
239 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
|
240 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
|
241 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
|
242 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
|
243 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
|
244 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
|
245 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
|
246 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
|
247 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
|
248 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
|
249 case SDL_GL_BUFFER_SIZE: |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 GLint bits = 0; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 GLint component; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 /* 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
|
255 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
|
256 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
|
257 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
|
258 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
|
259 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 *value = bits; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 return 0; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 glGetIntegerv (attr, (GLint *)value); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 return 0; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 int QZ_GL_MakeCurrent (_THIS) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 [ gl_context makeCurrentContext ]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 return 0; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 void QZ_GL_SwapBuffers (_THIS) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 [ gl_context flushBuffer ]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 } |