annotate src/video/quartz/SDL_QuartzGL.m @ 4249:429c8dd3175d SDL-1.2

Fixed bug #713 Don't clamp the mouse coordinates to the video surface size, instead clamp them to the last known window size. This allows users to get the correct mouse coordinates even if they don't call SDL_SetVideoMode() in response to an SDL_VIDEORESIZE event (used as a hack to retain the OpenGL context on Windows and Linux after a window resize)
author Sam Lantinga <slouken@libsdl.org>
date Sun, 27 Sep 2009 05:18:43 +0000
parents 976bc19f8f6b
children 8d67936e32ec
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
4159
a1b03ba2fcd0 Updated copyright date
Sam Lantinga <slouken@libsdl.org>
parents: 1738
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
761
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 *
4188
9701c96e2cbb Updated some URLs in the comments.
Ryan C. Gordon <icculus@icculus.org>
parents: 4159
diff changeset
29 * http://developer.apple.com/graphicsimaging/opengl/extensions.html#GL_ARB_multisample
857
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 *
4188
9701c96e2cbb Updated some URLs in the comments.
Ryan C. Gordon <icculus@icculus.org>
parents: 4159
diff changeset
33 * http://lists.libsdl.org/pipermail/sdl-libsdl.org/2003-December/039794.html
857
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
4204
976bc19f8f6b 1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents: 4188
diff changeset
44 #ifdef __powerpc__ /* we lost this in 10.6, which has no PPC support. */
761
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
4204
976bc19f8f6b 1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents: 4188
diff changeset
51 CGLContextObj QZ_GetCGLContextObj(NSOpenGLContext *nsctx)
976bc19f8f6b 1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents: 4188
diff changeset
52 {
976bc19f8f6b 1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents: 4188
diff changeset
53 return [nsctx cglContext];
976bc19f8f6b 1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents: 4188
diff changeset
54 }
976bc19f8f6b 1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents: 4188
diff changeset
55 #else
976bc19f8f6b 1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents: 4188
diff changeset
56 CGLContextObj QZ_GetCGLContextObj(NSOpenGLContext *nsctx)
976bc19f8f6b 1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents: 4188
diff changeset
57 {
976bc19f8f6b 1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents: 4188
diff changeset
58 return (CGLContextObj) [nsctx CGLContextObj];
976bc19f8f6b 1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents: 4188
diff changeset
59 }
976bc19f8f6b 1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents: 4188
diff changeset
60 #endif
976bc19f8f6b 1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents: 4188
diff changeset
61
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 /* OpenGL helper functions (used internally) */
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 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
66
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 NSOpenGLPixelFormatAttribute attr[32];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 NSOpenGLPixelFormat *fmt;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 int i = 0;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 int colorBits = bpp;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71
1195
bb6791b0a268 Fixed OpenGL usage in Quartz target when SDL_SetVideoMode() is called without
Ryan C. Gordon <icculus@icculus.org>
parents: 1189
diff changeset
72 /* 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
73 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
74 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
75 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
76 }
bb6791b0a268 Fixed OpenGL usage in Quartz target when SDL_SetVideoMode() is called without
Ryan C. Gordon <icculus@icculus.org>
parents: 1189
diff changeset
77
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 if ( flags & SDL_FULLSCREEN ) {
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++] = NSOpenGLPFAFullScreen;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 /* 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
83 else if ( colorBits != device_bpp ) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 colorBits = device_bpp;
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
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 attr[i++] = NSOpenGLPFAColorSize;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 attr[i++] = colorBits;
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 attr[i++] = NSOpenGLPFADepthSize;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 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
93
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 if ( this->gl_config.double_buffer ) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 attr[i++] = NSOpenGLPFADoubleBuffer;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 if ( this->gl_config.stereo ) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 attr[i++] = NSOpenGLPFAStereo;
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.stencil_size != 0 ) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 attr[i++] = NSOpenGLPFAStencilSize;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 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
105 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106
890
416158ec61a0 Date: Sat, 10 Apr 2004 10:05:46 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 857
diff changeset
107 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
108 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
109 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
110 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
111 attr[i++] = NSOpenGLPFAAccumSize;
416158ec61a0 Date: Sat, 10 Apr 2004 10:05:46 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 857
diff changeset
112 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
113 }
416158ec61a0 Date: Sat, 10 Apr 2004 10:05:46 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 857
diff changeset
114
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 if ( this->gl_config.multisamplebuffers != 0 ) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 attr[i++] = NSOpenGLPFASampleBuffers;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 attr[i++] = this->gl_config.multisamplebuffers;
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
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 if ( this->gl_config.multisamplesamples != 0 ) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 attr[i++] = NSOpenGLPFASamples;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 attr[i++] = this->gl_config.multisamplesamples;
900
c3c8739f7844 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 890
diff changeset
123 attr[i++] = NSOpenGLPFANoRecovery;
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
126 if ( this->gl_config.accelerated > 0 ) {
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
127 attr[i++] = NSOpenGLPFAAccelerated;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
128 }
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
129
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 attr[i++] = NSOpenGLPFAScreenMask;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 attr[i++] = CGDisplayIDToOpenGLDisplayMask (display_id);
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 attr[i] = 0;
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 fmt = [ [ NSOpenGLPixelFormat alloc ] initWithAttributes:attr ];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 if (fmt == nil) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 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
137 return 0;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 }
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 gl_context = [ [ NSOpenGLContext alloc ] initWithFormat:fmt
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 shareContext:nil];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142
1160
72c6c3e5bb85 Closed a memory leak caused when quitting video subsystem on Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents: 900
diff changeset
143 [ 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
144
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 if (gl_context == nil) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 SDL_SetError ("Failed creating OpenGL context");
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 return 0;
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
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
150 /* Synchronize QZ_GL_SwapBuffers() to vertical retrace.
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
151 * (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
152 * exactly does, IMHO - for a detailed explanation see
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
153 * 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
154 */
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
155 if ( this->gl_config.swap_control >= 0 ) {
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
156 long value;
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
157 value = this->gl_config.swap_control;
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
158 [ gl_context setValues: &value forParameter: NSOpenGLCPSwapInterval ];
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
159 }
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
160
761
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 * 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
163 * "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
164 * 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
165 * 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
166 * 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
167 */
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 #ifndef GLI_ARRAY_FUNC_CACHE_MAX
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 #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
171 #endif
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 #ifndef GLI_SUBMIT_FUNC_CACHE_MAX
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 #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
175 #endif
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 long cache_max = 64;
4204
976bc19f8f6b 1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents: 4188
diff changeset
179 CGLContextObj ctx = QZ_GetCGLContextObj(gl_context);
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 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
181 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
182 }
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 /* 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
185
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 return 1;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 void QZ_TearDownOpenGL (_THIS) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 [ NSOpenGLContext clearCurrentContext ];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 [ gl_context clearDrawable ];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 [ gl_context release ];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 }
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
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 /* SDL OpenGL functions */
1189
c96b326b90ba Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1181
diff changeset
198 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
199 "/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
200
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 int QZ_GL_LoadLibrary (_THIS, const char *location) {
1181
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
202 if ( gl_context != NULL ) {
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
203 SDL_SetError("OpenGL context already created");
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
204 return -1;
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
205 }
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
206
1189
c96b326b90ba Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1181
diff changeset
207 if (opengl_library != NULL)
c96b326b90ba Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1181
diff changeset
208 SDL_UnloadObject(opengl_library);
1181
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
209
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
210 if (location == NULL)
1189
c96b326b90ba Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1181
diff changeset
211 location = DEFAULT_OPENGL_LIB_NAME;
1181
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
212
1189
c96b326b90ba Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1181
diff changeset
213 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
214 if (opengl_library != NULL) {
1181
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
215 this->gl_config.driver_loaded = 1;
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
216 return 0;
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
217 }
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
218
1189
c96b326b90ba Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1181
diff changeset
219 this->gl_config.driver_loaded = 0;
1181
49d3efec6651 Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents: 1177
diff changeset
220 return -1;
761
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
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 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
224 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
225 }
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 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
228
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 GLenum attr = 0;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 QZ_GL_MakeCurrent (this);
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 switch (attrib) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 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
235 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
236 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
237 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
238 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
239 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
240 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
241 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
242 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
243 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
244 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
245 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
246 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
247 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
248 case SDL_GL_BUFFER_SIZE:
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 GLint bits = 0;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 GLint component;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 /* 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
254 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
255 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
256 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
257 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
258
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 *value = bits;
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
260 return 0;
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 }
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
262 case SDL_GL_ACCELERATED_VISUAL:
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
263 {
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
264 long val;
1738
acfd00fbff5c Fixed compile errors on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents: 1737
diff changeset
265 /* FIXME: How do we get this information here?
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
266 [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
267 */
acfd00fbff5c Fixed compile errors on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents: 1737
diff changeset
268 val = (this->gl_config.accelerated != 0);;
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
269 *value = val;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
270 return 0;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
271 }
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
272 case SDL_GL_SWAP_CONTROL:
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
273 {
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
274 long val;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
275 [ gl_context getValues: &val forParameter: NSOpenGLCPSwapInterval ];
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
276 *value = val;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
277 return 0;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
278 }
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 glGetIntegerv (attr, (GLint *)value);
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 return 0;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 int QZ_GL_MakeCurrent (_THIS) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 [ gl_context makeCurrentContext ];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 return 0;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290 void QZ_GL_SwapBuffers (_THIS) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 [ gl_context flushBuffer ];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 }