annotate src/video/quartz/SDL_QuartzGL.m @ 1807:f173f8fe1fc6

(none)
author Sam Lantinga <slouken@libsdl.org>
date Wed, 10 May 2006 15:00:30 +0000
parents acfd00fbff5c
children c121d94672cb a1b03ba2fcd0
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 */
1403
376665398b25 Catch the C++ and Objective C sources too...
Sam Lantinga <slouken@libsdl.org>
parents: 1400
diff changeset
22 #include "SDL_config.h"
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #include "SDL_QuartzVideo.h"
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25
857
ce05e92d909b Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents: 770
diff changeset
26 /*
ce05e92d909b Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents: 770
diff changeset
27 * 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
28 *
ce05e92d909b Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents: 770
diff changeset
29 * 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
30 *
ce05e92d909b Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents: 770
diff changeset
31 * ...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
32 *
ce05e92d909b Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents: 770
diff changeset
33 * 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
34 *
ce05e92d909b Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents: 770
diff changeset
35 * 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
36 *
ce05e92d909b Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents: 770
diff changeset
37 * --ryan.
ce05e92d909b Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents: 770
diff changeset
38 */
ce05e92d909b Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents: 770
diff changeset
39 #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
40 #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
41 #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
42 #endif
ce05e92d909b Attempt to get FSAA compiling on all versions of MacOS X.
Ryan C. Gordon <icculus@icculus.org>
parents: 770
diff changeset
43
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 @implementation NSOpenGLContext (CGLContextAccess)
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 - (CGLContextObj) cglContext;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 return _contextAuxiliary;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 @end
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 /* OpenGL helper functions (used internally) */
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 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
55
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 NSOpenGLPixelFormatAttribute attr[32];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 NSOpenGLPixelFormat *fmt;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 int i = 0;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 int colorBits = bpp;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60
1195
bb6791b0a268 Fixed OpenGL usage in Quartz target when SDL_SetVideoMode() is called without
Ryan C. Gordon <icculus@icculus.org>
parents: 1189
diff changeset
61 /* if a GL library hasn't been loaded at this point, load the default. */
bb6791b0a268 Fixed OpenGL usage in Quartz target when SDL_SetVideoMode() is called without
Ryan C. Gordon <icculus@icculus.org>
parents: 1189
diff changeset
62 if (!this->gl_config.driver_loaded) {
bb6791b0a268 Fixed OpenGL usage in Quartz target when SDL_SetVideoMode() is called without
Ryan C. Gordon <icculus@icculus.org>
parents: 1189
diff changeset
63 if (QZ_GL_LoadLibrary(this, NULL) == -1)
bb6791b0a268 Fixed OpenGL usage in Quartz target when SDL_SetVideoMode() is called without
Ryan C. Gordon <icculus@icculus.org>
parents: 1189
diff changeset
64 return 0;
bb6791b0a268 Fixed OpenGL usage in Quartz target when SDL_SetVideoMode() is called without
Ryan C. Gordon <icculus@icculus.org>
parents: 1189
diff changeset
65 }
bb6791b0a268 Fixed OpenGL usage in Quartz target when SDL_SetVideoMode() is called without
Ryan C. Gordon <icculus@icculus.org>
parents: 1189
diff changeset
66
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 if ( flags & SDL_FULLSCREEN ) {
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 attr[i++] = NSOpenGLPFAFullScreen;
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 /* 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
72 else if ( colorBits != device_bpp ) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 colorBits = device_bpp;
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 attr[i++] = NSOpenGLPFAColorSize;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 attr[i++] = colorBits;
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 attr[i++] = NSOpenGLPFADepthSize;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 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
82
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 if ( this->gl_config.double_buffer ) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 attr[i++] = NSOpenGLPFADoubleBuffer;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 }
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 if ( this->gl_config.stereo ) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 attr[i++] = NSOpenGLPFAStereo;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 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
92 attr[i++] = NSOpenGLPFAStencilSize;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 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
94 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95
890
416158ec61a0 Date: Sat, 10 Apr 2004 10:05:46 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 857
diff changeset
96 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
97 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
98 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
99 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
100 attr[i++] = NSOpenGLPFAAccumSize;
416158ec61a0 Date: Sat, 10 Apr 2004 10:05:46 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 857
diff changeset
101 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
102 }
416158ec61a0 Date: Sat, 10 Apr 2004 10:05:46 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 857
diff changeset
103
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 if ( this->gl_config.multisamplebuffers != 0 ) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 attr[i++] = NSOpenGLPFASampleBuffers;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 attr[i++] = this->gl_config.multisamplebuffers;
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 if ( this->gl_config.multisamplesamples != 0 ) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 attr[i++] = NSOpenGLPFASamples;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 attr[i++] = this->gl_config.multisamplesamples;
900
c3c8739f7844 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 890
diff changeset
112 attr[i++] = NSOpenGLPFANoRecovery;
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
115 if ( this->gl_config.accelerated > 0 ) {
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
116 attr[i++] = NSOpenGLPFAAccelerated;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
117 }
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
118
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 attr[i++] = NSOpenGLPFAScreenMask;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 attr[i++] = CGDisplayIDToOpenGLDisplayMask (display_id);
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 attr[i] = 0;
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 fmt = [ [ NSOpenGLPixelFormat alloc ] initWithAttributes:attr ];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 if (fmt == 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 pixel format");
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 gl_context = [ [ NSOpenGLContext alloc ] initWithFormat:fmt
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 shareContext:nil];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131
1160
72c6c3e5bb85 Closed a memory leak caused when quitting video subsystem on Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents: 900
diff changeset
132 [ 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
133
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 if (gl_context == nil) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 SDL_SetError ("Failed creating OpenGL context");
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 return 0;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
139 /* Synchronize QZ_GL_SwapBuffers() to vertical retrace.
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
140 * (Apple's documentation is not completely clear about what this setting
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
141 * exactly does, IMHO - for a detailed explanation see
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
142 * http://lists.apple.com/archives/mac-opengl/2006/Jan/msg00080.html )
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
143 */
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
144 if ( this->gl_config.swap_control >= 0 ) {
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
145 long value;
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
146 value = this->gl_config.swap_control;
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
147 [ gl_context setValues: &value forParameter: NSOpenGLCPSwapInterval ];
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
148 }
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
149
761
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 * 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
152 * "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
153 * 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
154 * 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
155 * 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
156 */
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 #ifndef GLI_ARRAY_FUNC_CACHE_MAX
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 #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
160 #endif
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 #ifndef GLI_SUBMIT_FUNC_CACHE_MAX
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 #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
164 #endif
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 long cache_max = 64;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 CGLContextObj ctx = [ gl_context cglContext ];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 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
170 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
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 /* 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
174
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 return 1;
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
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 void QZ_TearDownOpenGL (_THIS) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 [ NSOpenGLContext clearCurrentContext ];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 [ gl_context clearDrawable ];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 [ gl_context release ];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 /* SDL OpenGL functions */
1189
c96b326b90ba Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1181
diff changeset
187 static const char *DEFAULT_OPENGL_LIB_NAME =
c96b326b90ba Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1181
diff changeset
188 "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib";
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 int QZ_GL_LoadLibrary (_THIS, const char *location) {
1181
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
191 if ( gl_context != NULL ) {
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
192 SDL_SetError("OpenGL context already created");
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
193 return -1;
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
1189
c96b326b90ba Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1181
diff changeset
196 if (opengl_library != NULL)
c96b326b90ba Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1181
diff changeset
197 SDL_UnloadObject(opengl_library);
1181
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
198
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
199 if (location == NULL)
1189
c96b326b90ba Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1181
diff changeset
200 location = DEFAULT_OPENGL_LIB_NAME;
1181
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
201
1189
c96b326b90ba Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1181
diff changeset
202 opengl_library = SDL_LoadObject(location);
c96b326b90ba Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1181
diff changeset
203 if (opengl_library != NULL) {
1181
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
204 this->gl_config.driver_loaded = 1;
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
205 return 0;
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
1189
c96b326b90ba Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1181
diff changeset
208 this->gl_config.driver_loaded = 0;
1181
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
209 return -1;
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 void* QZ_GL_GetProcAddress (_THIS, const char *proc) {
1189
c96b326b90ba Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1181
diff changeset
213 return SDL_LoadFunction(opengl_library, proc);
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 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
217
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 GLenum attr = 0;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 QZ_GL_MakeCurrent (this);
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 switch (attrib) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 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
224 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
225 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
226 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
227 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
228 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
229 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
230 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
231 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
232 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
233 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
234 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
235 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
236 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
237 case SDL_GL_BUFFER_SIZE:
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 GLint bits = 0;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 GLint component;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 /* 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
243 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
244 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
245 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
246 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
247
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 *value = bits;
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
249 return 0;
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 }
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
251 case SDL_GL_ACCELERATED_VISUAL:
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
252 {
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
253 long val;
1738
acfd00fbff5c Fixed compile errors on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents: 1737
diff changeset
254 /* FIXME: How do we get this information here?
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
255 [fmt getValues: &val forAttribute: NSOpenGLPFAAccelerated attr forVirtualScreen: 0];
1738
acfd00fbff5c Fixed compile errors on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents: 1737
diff changeset
256 */
acfd00fbff5c Fixed compile errors on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents: 1737
diff changeset
257 val = (this->gl_config.accelerated != 0);;
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
258 *value = val;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
259 return 0;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
260 }
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
261 case SDL_GL_SWAP_CONTROL:
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
262 {
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
263 long val;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
264 [ gl_context getValues: &val forParameter: NSOpenGLCPSwapInterval ];
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
265 *value = val;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
266 return 0;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
267 }
761
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
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 glGetIntegerv (attr, (GLint *)value);
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 int QZ_GL_MakeCurrent (_THIS) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 [ gl_context makeCurrentContext ];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 return 0;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 void QZ_GL_SwapBuffers (_THIS) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 [ gl_context flushBuffer ];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 }