annotate src/video/quartz/SDL_QuartzVideo.m @ 252:e8157fcb3114

Updated the source with the correct e-mail address
author Sam Lantinga <slouken@libsdl.org>
date Fri, 14 Dec 2001 12:38:15 +0000
parents ef78524e5f59
children d1447a846d80
rev   line source
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
3 Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
13 Library General Public License for more details.
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
16 License along with this library; if not, write to the Free
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
19 Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 197
diff changeset
20 slouken@libsdl.org
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
22
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23 #include "SDL_QuartzVideo.h"
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25 /* Some variables to share among files, put in device structure eventually */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26 static SDL_GrabMode currentGrabMode = SDL_GRAB_OFF;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27 static BOOL inForeground = YES;
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
28 static char QZ_Error[255]; /* Global error buffer to temporarily store more informative error messages */
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30 /* Include files into one compile unit...break apart eventually */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31 #include "SDL_QuartzWM.m"
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
32 #include "SDL_QuartzEvents.m"
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33 #include "SDL_QuartzWindow.m"
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
35 /* Bootstrap binding, enables entry point into the driver */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
36 VideoBootStrap QZ_bootstrap = {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
37 "Quartz", "MacOS X CoreGraphics", QZ_Available, QZ_CreateDevice
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
38 };
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40 /* Bootstrap functions */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41 static int QZ_Available () {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
42 return 1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
43 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
44
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45 static SDL_VideoDevice* QZ_CreateDevice (int device_index) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
46
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
47 #pragma unused (device_index)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
48
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
49 SDL_VideoDevice *device;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
50 SDL_PrivateVideoData *hidden;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
51
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
52 device = (SDL_VideoDevice*) malloc (sizeof (*device) );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
53 hidden = (SDL_PrivateVideoData*) malloc (sizeof (*hidden) );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
54
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
55 if (device == NULL || hidden == NULL)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
56 SDL_OutOfMemory ();
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
57
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
58 memset (device, 0, sizeof (*device) );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
59 memset (hidden, 0, sizeof (*hidden) );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
60
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
61 device->hidden = hidden;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
62
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
63 device->VideoInit = QZ_VideoInit;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
64 device->ListModes = QZ_ListModes;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
65 device->SetVideoMode = QZ_SetVideoMode;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
66 device->ToggleFullScreen = QZ_ToggleFullScreen;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
67 device->SetColors = QZ_SetColors;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
68 /* device->UpdateRects = QZ_UpdateRects; this is determined by SetVideoMode() */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
69 device->VideoQuit = QZ_VideoQuit;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
70
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
71 device->LockHWSurface = QZ_LockHWSurface;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
72 device->UnlockHWSurface = QZ_UnlockHWSurface;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
73 device->FreeHWSurface = QZ_FreeHWSurface;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
74 /* device->FlipHWSurface = QZ_FlipHWSurface */;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
75
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
76 device->SetGamma = QZ_SetGamma;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
77 device->GetGamma = QZ_GetGamma;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
78 device->SetGammaRamp = QZ_SetGammaRamp;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
79 device->GetGammaRamp = QZ_GetGammaRamp;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
80
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
81 device->GL_GetProcAddress = QZ_GL_GetProcAddress;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
82 device->GL_GetAttribute = QZ_GL_GetAttribute;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
83 device->GL_MakeCurrent = QZ_GL_MakeCurrent;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
84 device->GL_SwapBuffers = QZ_GL_SwapBuffers;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
85 device->GL_LoadLibrary = QZ_GL_LoadLibrary;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
86
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
87 device->FreeWMCursor = QZ_FreeWMCursor;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
88 device->CreateWMCursor = QZ_CreateWMCursor;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
89 device->ShowWMCursor = QZ_ShowWMCursor;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
90 device->WarpWMCursor = QZ_WarpWMCursor;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
91 device->MoveWMCursor = QZ_MoveWMCursor;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
92 device->CheckMouseMode = QZ_CheckMouseMode;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
93 device->InitOSKeymap = QZ_InitOSKeymap;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
94 device->PumpEvents = QZ_PumpEvents;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
95
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
96 device->SetCaption = QZ_SetCaption;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
97 device->SetIcon = QZ_SetIcon;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
98 device->IconifyWindow = QZ_IconifyWindow;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
99 /*device->GetWMInfo = QZ_GetWMInfo;*/
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
100 device->GrabInput = QZ_GrabInput;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
101
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
102 device->free = QZ_DeleteDevice;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
103
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
104 return device;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
105 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
106
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
107 static void QZ_DeleteDevice (SDL_VideoDevice *device) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
108
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
109 free (device->hidden);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
110 free (device);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
111 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
112
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
113 static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
114
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
115 /* Initialize the video settings; this data persists between mode switches */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
116 display_id = kCGDirectMainDisplay;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
117 save_mode = CGDisplayCurrentMode (display_id);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
118 mode_list = CGDisplayAvailableModes (display_id);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
119 palette = CGPaletteCreateDefaultColorPalette ();
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
120
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121 /* Gather some information that is useful to know about the display */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
122 CFNumberGetValue (CFDictionaryGetValue (save_mode, kCGDisplayBitsPerPixel),
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
123 kCFNumberSInt32Type, &device_bpp);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
124
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
125 CFNumberGetValue (CFDictionaryGetValue (save_mode, kCGDisplayWidth),
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
126 kCFNumberSInt32Type, &device_width);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
127
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
128 CFNumberGetValue (CFDictionaryGetValue (save_mode, kCGDisplayHeight),
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
129 kCFNumberSInt32Type, &device_height);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
130
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
131 video_format->BitsPerPixel = device_bpp;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
132
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
133 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
134 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
135
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
136 static SDL_Rect** QZ_ListModes (_THIS, SDL_PixelFormat *format, Uint32 flags) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
137
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
138 CFIndex num_modes = CFArrayGetCount (mode_list);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
139 CFIndex i;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
140
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
141 static SDL_Rect **list = NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
142 int list_size = 0;
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
143
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
144 /* Any windowed mode is acceptable */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
145 if ( (flags & SDL_FULLSCREEN) == 0 )
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
146 return (SDL_Rect**)-1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
147
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
148 /* Free memory from previous call, if any */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
149 if ( list != NULL ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
150
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
151 int i;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
152
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
153 for (i = 0; list[i] != NULL; i++)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
154 free (list[i]);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
155
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
156 free (list);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
157 list = NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
158 }
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
159
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
160 /* Build list of modes with the requested bpp */
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
161 for (i = 0; i < num_modes; i++) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
162
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
163 CFDictionaryRef onemode;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
164 CFNumberRef number;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
165 int bpp;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
166
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
167 onemode = CFArrayGetValueAtIndex (mode_list, i);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
168 number = CFDictionaryGetValue (onemode, kCGDisplayBitsPerPixel);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
169 CFNumberGetValue (number, kCFNumberSInt32Type, &bpp);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
170
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
171 if (bpp == format->BitsPerPixel) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
172
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
173 int intvalue;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
174 int hasMode;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
175 int width, height;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
176
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
177 number = CFDictionaryGetValue (onemode, kCGDisplayWidth);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
178 CFNumberGetValue (number, kCFNumberSInt32Type, &intvalue);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
179 width = (Uint16) intvalue;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
180
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
181 number = CFDictionaryGetValue (onemode, kCGDisplayHeight);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
182 CFNumberGetValue (number, kCFNumberSInt32Type, &intvalue);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
183 height = (Uint16) intvalue;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
184
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
185 /* Check if mode is already in the list */
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
186 {
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
187 int i;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
188 hasMode = SDL_FALSE;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
189 for (i = 0; i < list_size; i++) {
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
190 if (list[i]->w == width && list[i]->h == height) {
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
191 hasMode = SDL_TRUE;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
192 break;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
193 }
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
194 }
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
195 }
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
196
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
197 /* Grow the list and add mode to the list */
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
198 if ( ! hasMode ) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
199
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
200 SDL_Rect *rect;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
201
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
202 list_size++;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
203
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
204 if ( list == NULL)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
205 list = (SDL_Rect**) malloc (sizeof(*list) * list_size+1);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
206 else
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
207 list = (SDL_Rect**) realloc (list, sizeof(*list) * list_size+1);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
208
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
209 rect = (SDL_Rect*) malloc (sizeof(**list));
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
210
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
211 if (list == NULL || rect == NULL)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
212 SDL_OutOfMemory ();
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
213
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
214 rect->w = width;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
215 rect->h = height;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
216
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
217 list[list_size-1] = rect;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
218 list[list_size] = NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
219 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
220 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
221 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
222
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
223 /* Sort list largest to smallest (by area) */
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
224 {
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
225 int i, j;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
226 for (i = 0; i < list_size; i++) {
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
227 for (j = 0; j < list_size-1; j++) {
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
228
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
229 int area1, area2;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
230 area1 = list[j]->w * list[j]->h;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
231 area2 = list[j+1]->w * list[j+1]->h;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
232
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
233 if (area1 < area2) {
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
234 SDL_Rect *tmp = list[j];
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
235 list[j] = list[j+1];
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
236 list[j+1] = tmp;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
237 }
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
238 }
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
239 }
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
240 }
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
241 return list;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
242 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
243
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
244 static void QZ_UnsetVideoMode (_THIS) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
245
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
246 /* Reset values that may change between switches */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
247 this->info.blit_fill = 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
248 this->FillHWRect = NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
249 this->UpdateRects = NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
250
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
251 /* Restore gamma settings */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
252 CGDisplayRestoreColorSyncSettings ();
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
253
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
254 /* Restore original screen resolution */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
255 if ( mode_flags & SDL_FULLSCREEN ) {
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
256 if (mode_flags & SDL_OPENGL)
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
257 CGLSetFullScreen(NULL);
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
258
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
259 CGDisplaySwitchToMode (display_id, save_mode);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
260 CGDisplayRelease (display_id);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
261 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
262 /* Release window mode data structures */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
263 else {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
264 if ( (mode_flags & SDL_OPENGL) == 0 ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
265 UnlockPortBits ( [ windowView qdPort ] );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
266 [ windowView release ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
267 }
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
268 [ qz_window setContentView:nil ];
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
269 [ qz_window setDelegate:nil ];
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
270 [ qz_window close ];
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
271 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
272
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
273 /* Set pixels to null (so other code doesn't try to free it) */
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
274 if (this->screen != NULL)
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
275 this->screen->pixels = NULL;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
276
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
277 /* Release the OpenGL context */
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
278 if ( mode_flags & SDL_OPENGL )
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
279 QZ_TearDownOpenGL (this);
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
280
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
281 /* Ensure the cursor will be visible and working when we quit */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
282 CGDisplayShowCursor (display_id);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
283 CGAssociateMouseAndMouseCursorPosition (1);
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
284
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
285 /* Signal successful teardown */
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
286 video_set = SDL_FALSE;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
287 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
288
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
289 static SDL_Surface* QZ_SetVideoFullScreen (_THIS, SDL_Surface *current, int width,
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
290 int height, int bpp, Uint32 flags) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
291 int exact_match;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
292
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
293 /* See if requested mode exists */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
294 mode = CGDisplayBestModeForParameters (display_id, bpp, width,
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
295 height, &exact_match);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
296
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
297 /* Require an exact match to the requested mode */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
298 if ( ! exact_match ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
299 sprintf (QZ_Error, "Failed to find display resolution: %dx%dx%d", width, height, bpp);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
300 SDL_SetError (QZ_Error);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
301 goto ERR_NO_MATCH;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
302 }
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
303
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
304 /* Put up the blanking window (a window above all other windows) */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
305 if ( CGDisplayNoErr != CGDisplayCapture (display_id) ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
306 SDL_SetError ("Failed capturing display");
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
307 goto ERR_NO_CAPTURE;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
308 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
309
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
310 /* Do the physical switch */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
311 if ( CGDisplayNoErr != CGDisplaySwitchToMode (display_id, mode) ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
312 SDL_SetError ("Failed switching display resolution");
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
313 goto ERR_NO_SWITCH;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
314 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
315
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
316 /* None of these methods seem to fix the fullscreen artifacts bug(s) */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
317 #if USE_GDHANDLE
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
318 SetGDevice(GetMainDevice());
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
319 current->pitch = (**(** GetMainDevice() ).gdPMap).rowBytes & 0x3FFF;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
320 current->pixels = (**(** GetMainDevice() ).gdPMap).baseAddr;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
321 #elif USE_CREATEPORT
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
322 device_port = CreateNewPortForCGDisplayID((Uint32*)display_id);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
323 SetPort (device_port);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
324 LockPortBits ( device_port );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
325 current->pixels = GetPixBaseAddr ( GetPortPixMap ( device_port ) );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
326 current->pitch = GetPixRowBytes ( GetPortPixMap ( device_port ) );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
327 UnlockPortBits ( device_port );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
328 #else
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
329 current->pixels = (Uint32*) CGDisplayBaseAddress (display_id);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
330 current->pitch = CGDisplayBytesPerRow (display_id);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
331 #endif
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
332
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
333 current->flags = 0;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
334 current->w = width;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
335 current->h = height;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
336 current->flags |= SDL_FULLSCREEN;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
337 current->flags |= SDL_HWSURFACE;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
338
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
339 this->UpdateRects = QZ_DirectUpdate;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
340
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
341 /* Setup some mode-dependant info */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
342 if ( CGSDisplayCanHWFill (display_id) ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
343 this->info.blit_fill = 1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
344 this->FillHWRect = QZ_FillHWRect;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
345 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
346
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
347 if ( CGDisplayCanSetPalette (display_id) )
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
348 current->flags |= SDL_HWPALETTE;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
349
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
350 /* Setup OpenGL for a fullscreen context */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
351 if (flags & SDL_OPENGL) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
352
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
353 CGLError err;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
354 CGLContextObj ctx;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
355
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
356 if ( ! QZ_SetupOpenGL (this, bpp, flags) ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
357 return NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
358 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
359
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
360 ctx = [ gl_context cglContext ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
361 err = CGLSetFullScreen (ctx);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
362
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
363 if (err) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
364 sprintf (QZ_Error, "Error setting OpenGL fullscreen: %s", CGLErrorString(err));
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
365 SDL_SetError (QZ_Error);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
366 goto ERR_NO_GL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
367 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
368
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
369 [ gl_context makeCurrentContext];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
370
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
371 current->flags |= SDL_OPENGL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
372 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
373
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
374 /* If we don't hide menu bar, it will get events and interrupt the program */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
375 HideMenuBar ();
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
376
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
377 /* Save the flags to ensure correct tear-down */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
378 mode_flags = current->flags;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
379
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
380 return current;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
381
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
382 /* Since the blanking window covers *all* windows (even force quit) correct recovery is crutial */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
383 ERR_NO_GL: CGDisplaySwitchToMode (display_id, save_mode);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
384 ERR_NO_SWITCH: CGDisplayRelease (display_id);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
385 ERR_NO_CAPTURE:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
386 ERR_NO_MATCH: return NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
387 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
388
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
389 static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width,
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
390 int height, int bpp, Uint32 flags) {
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
391 unsigned int style;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
392 NSRect rect;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
393 rect = NSMakeRect (0, 0, width, height);
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
394
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
395 #if 1 // FIXME - the resize button doesn't show? Also need resize events...
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
396 flags &= ~SDL_RESIZABLE;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
397 #endif
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
398 /* Set the window style based on input flags */
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
399 if ( flags & SDL_NOFRAME ) {
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
400 style = NSBorderlessWindowMask;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
401 } else {
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
402 style = NSTitledWindowMask;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
403 style |= (NSMiniaturizableWindowMask | NSClosableWindowMask);
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
404 if ( flags & SDL_RESIZABLE )
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
405 style |= NSResizableWindowMask;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
406 }
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
407
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
408 /* Manually create a window, avoids having a nib file resource */
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
409 qz_window = [ [ SDL_QuartzWindow alloc ] initWithContentRect:rect
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
410 styleMask:style backing:NSBackingStoreBuffered defer:NO ];
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
411 if (qz_window == nil) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
412 SDL_SetError ("Could not create the Cocoa window");
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
413 return NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
414 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
415
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
416 current->flags = 0;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
417 current->w = width;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
418 current->h = height;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
419
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
420 [ qz_window setReleasedWhenClosed:YES ];
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
421 QZ_SetCaption(this, this->wm_title, this->wm_icon);
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
422 [ qz_window setAcceptsMouseMovedEvents:YES ];
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
423 [ qz_window setViewsNeedDisplay:NO ];
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
424 [ qz_window center ];
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
425 [ qz_window setDelegate:
56
ce9cd2cf0d0d Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
426 [ [ [ SDL_QuartzWindowDelegate alloc ] init ] autorelease ] ];
ce9cd2cf0d0d Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
427
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
428 /* For OpenGL, we set the content view to a NSOpenGLView */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
429 if ( flags & SDL_OPENGL ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
430
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
431 if ( ! QZ_SetupOpenGL (this, bpp, flags) ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
432 return NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
433 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
434
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
435 [ gl_context setView: [ qz_window contentView ] ];
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
436 [ gl_context makeCurrentContext];
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
437 [ qz_window makeKeyAndOrderFront:nil ];
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
438 current->flags |= SDL_OPENGL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
439 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
440 /* For 2D, we set the content view to a NSQuickDrawView */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
441 else {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
442
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
443 windowView = [ [ NSQuickDrawView alloc ] init ];
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
444 [ qz_window setContentView:windowView ];
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
445 [ qz_window makeKeyAndOrderFront:nil ];
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
446
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
447 LockPortBits ( [ windowView qdPort ] );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
448 current->pixels = GetPixBaseAddr ( GetPortPixMap ( [ windowView qdPort ] ) );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
449 current->pitch = GetPixRowBytes ( GetPortPixMap ( [ windowView qdPort ] ) );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
450
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
451 current->flags |= SDL_SWSURFACE;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
452 current->flags |= SDL_PREALLOC;
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
453 if ( flags & SDL_NOFRAME )
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
454 current->flags |= SDL_NOFRAME;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
455 if ( flags & SDL_RESIZABLE )
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
456 current->flags |= SDL_RESIZABLE;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
457
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
458 /* Offset 22 pixels down to fill the full content region */
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
459 if ( ! (current->flags & SDL_NOFRAME) ) {
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
460 current->pixels += 22 * current->pitch;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
461 }
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
462
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
463 this->UpdateRects = QZ_UpdateRects;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
464 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
465 return current;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
466 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
467
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
468 static SDL_Surface* QZ_SetVideoMode (_THIS, SDL_Surface *current, int width,
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
469 int height, int bpp, Uint32 flags) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
470
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
471 if (video_set == SDL_TRUE)
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
472 QZ_UnsetVideoMode (this);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
473
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
474 current->flags = 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
475
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
476 /* Setup full screen video */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
477 if ( flags & SDL_FULLSCREEN ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
478 current = QZ_SetVideoFullScreen (this, current, width, height, bpp, flags );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
479 if (current == NULL)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
480 return NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
481 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
482 /* Setup windowed video */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
483 else {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
484 /* Force bpp to the device's bpp */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
485 bpp = current->format->BitsPerPixel;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
486 current = QZ_SetVideoWindowed (this, current, width, height, bpp, flags);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
487 if (current == NULL)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
488 return NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
489 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
490
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
491 /* Setup the new pixel format */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
492 {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
493 int amask = 0,
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
494 rmask = 0,
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
495 gmask = 0,
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
496 bmask = 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
497
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
498 switch (bpp) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
499 case 16: /* (1)-5-5-5 RGB */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
500 amask = 0;
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
501 rmask = 0x7C00;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
502 gmask = 0x03E0;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
503 bmask = 0x001F;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
504 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
505 case 24:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
506 SDL_SetError ("24bpp is not available");
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
507 return NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
508 case 32: /* (8)-8-8-8 ARGB */
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
509 amask = 0x00000000;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
510 rmask = 0x00FF0000;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
511 gmask = 0x0000FF00;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
512 bmask = 0x000000FF;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
513 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
514 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
515
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
516 if ( ! SDL_ReallocFormat (current, bpp,
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
517 rmask, gmask, bmask, amask ) ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
518 SDL_SetError ("Couldn't reallocate pixel format");
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
519 return NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
520 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
521 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
522
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
523 /* Warp mouse to origin in order to get passive mouse motion events started correctly */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
524 QZ_PrivateWarpCursor (this, current->flags & SDL_FULLSCREEN, height, 0, 0);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
525
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
526 /* Signal successful completion */
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
527 video_set = SDL_TRUE;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
528
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
529 return current;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
530 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
531
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
532 static int QZ_ToggleFullScreen (_THIS, int on) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
533 return -1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
534 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
535
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
536 static int QZ_SetColors (_THIS, int first_color, int num_colors,
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
537 SDL_Color *colors) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
538
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
539 CGTableCount index;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
540 CGDeviceColor color;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
541
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
542 for (index = first_color; index < first_color+num_colors; index++) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
543
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
544 /* Clamp colors between 0.0 and 1.0 */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
545 color.red = colors->r / 255.0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
546 color.blue = colors->b / 255.0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
547 color.green = colors->g / 255.0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
548
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
549 colors++;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
550
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
551 CGPaletteSetColorAtIndex (palette, color, index);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
552 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
553
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
554 if ( CGDisplayNoErr != CGDisplaySetPalette (display_id, palette) )
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
555 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
556
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
557 return 1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
558 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
559
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
560 static void QZ_DirectUpdate (_THIS, int num_rects, SDL_Rect *rects) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
561 #pragma unused(this,num_rects,rects)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
562 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
563
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
564 static void QZ_UpdateRects (_THIS, int numRects, SDL_Rect *rects) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
565
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
566 if (SDL_VideoSurface->flags & SDL_OPENGLBLIT) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
567 QZ_GL_SwapBuffers (this);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
568 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
569 else {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
570 int i;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
571 RgnHandle dirty = NewRgn ();
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
572 RgnHandle temp = NewRgn ();
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
573
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
574 SetEmptyRgn (dirty);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
575
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
576 /* Build the region of dirty rectangles */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
577 for (i = 0; i < numRects; i++) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
578
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
579 MacSetRectRgn (temp, rects[i].x, rects[i].y,
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
580 rects[i].x + rects[i].w, rects[i].y + rects[i].h);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
581 MacUnionRgn (dirty, temp, dirty);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
582 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
583
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
584 /* Flush the dirty region */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
585 QDFlushPortBuffer ( [ windowView qdPort ], dirty );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
586 DisposeRgn (dirty);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
587 DisposeRgn (temp);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
588 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
589 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
590
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
591 static void QZ_VideoQuit (_THIS) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
592
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
593 QZ_UnsetVideoMode (this);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
594 CGPaletteRelease (palette);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
595 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
596
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
597 static int QZ_FillHWRect (_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
598
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
599 CGSDisplayHWFill (display_id, rect->x, rect->y, rect->w, rect->h, color);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
600 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
601 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
602
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
603 static int QZ_LockHWSurface(_THIS, SDL_Surface *surface) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
604
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
605 return 1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
606 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
607
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
608 static void QZ_UnlockHWSurface(_THIS, SDL_Surface *surface) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
609 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
610
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
611 static void QZ_FreeHWSurface (_THIS, SDL_Surface *surface) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
612 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
613
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
614 /*
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
615 int QZ_FlipHWSurface (_THIS, SDL_Surface *surface) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
616 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
617 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
618 */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
619
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
620 /* Gamma functions */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
621 static int QZ_SetGamma (_THIS, float red, float green, float blue) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
622
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
623 const CGGammaValue min = 0.0, max = 1.0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
624
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
625 if ( CGDisplayNoErr != CGSetDisplayTransferByFormula
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
626 (display_id, min, max, red, min, max, green, min, max, blue) )
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
627 return -1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
628
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
629 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
630 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
631
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
632 static int QZ_GetGamma (_THIS, float *red, float *green, float *blue) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
633
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
634 CGGammaValue dummy;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
635 if ( CGDisplayNoErr != CGGetDisplayTransferByFormula
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
636 (display_id, &dummy, &dummy, red,
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
637 &dummy, &dummy, green, &dummy, &dummy, blue) )
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
638
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
639 return -1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
640
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
641 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
642 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
643
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
644 static int QZ_SetGammaRamp (_THIS, Uint16 *ramp) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
645
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
646 const CGTableCount tableSize = 255;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
647 CGGammaValue redTable[tableSize];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
648 CGGammaValue greenTable[tableSize];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
649 CGGammaValue blueTable[tableSize];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
650
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
651 int i;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
652
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
653 /* Extract gamma values into separate tables, convert to floats between 0.0 and 1.0 */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
654 for (i = 0; i < 256; i++)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
655 redTable[i % 256] = ramp[i] / 65535.0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
656
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
657 for (i=256; i < 512; i++)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
658 greenTable[i % 256] = ramp[i] / 65535.0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
659
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
660 for (i=512; i < 768; i++)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
661 blueTable[i % 256] = ramp[i] / 65535.0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
662
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
663 if ( CGDisplayNoErr != CGSetDisplayTransferByTable
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
664 (display_id, tableSize, redTable, greenTable, blueTable) )
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
665 return -1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
666
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
667 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
668 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
669
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
670 static int QZ_GetGammaRamp (_THIS, Uint16 *ramp) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
671
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
672 const CGTableCount tableSize = 255;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
673 CGGammaValue redTable[tableSize];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
674 CGGammaValue greenTable[tableSize];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
675 CGGammaValue blueTable[tableSize];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
676 CGTableCount actual;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
677 int i;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
678
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
679 if ( CGDisplayNoErr != CGGetDisplayTransferByTable
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
680 (display_id, tableSize, redTable, greenTable, blueTable, &actual) ||
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
681 actual != tableSize)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
682
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
683 return -1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
684
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
685 /* Pack tables into one array, with values from 0 to 65535 */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
686 for (i = 0; i < 256; i++)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
687 ramp[i] = redTable[i % 256] * 65535.0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
688
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
689 for (i=256; i < 512; i++)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
690 ramp[i] = greenTable[i % 256] * 65535.0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
691
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
692 for (i=512; i < 768; i++)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
693 ramp[i] = blueTable[i % 256] * 65535.0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
694
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
695 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
696 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
697
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
698 /* OpenGL helper functions */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
699 static int QZ_SetupOpenGL (_THIS, int bpp, Uint32 flags) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
700
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
701 NSOpenGLPixelFormatAttribute attr[32];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
702 NSOpenGLPixelFormat *fmt;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
703 int i = 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
704 int colorBits = bpp;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
705
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
706 if ( flags & SDL_FULLSCREEN ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
707
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
708 attr[i++] = NSOpenGLPFAFullScreen;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
709 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
710 /* In windowed mode, the OpenGL pixel depth must match device pixel depth */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
711 else if ( colorBits != device_bpp ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
712
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
713 colorBits = device_bpp;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
714 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
715
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
716 attr[i++] = NSOpenGLPFAColorSize;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
717 attr[i++] = colorBits;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
718
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
719 attr[i++] = NSOpenGLPFADepthSize;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
720 attr[i++] = this->gl_config.depth_size;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
721
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
722 if ( this->gl_config.double_buffer ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
723 attr[i++] = NSOpenGLPFADoubleBuffer;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
724 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
725
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
726 if ( this->gl_config.stencil_size != 0 ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
727 attr[i++] = NSOpenGLPFAStencilSize;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
728 attr[i++] = this->gl_config.stencil_size;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
729 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
730
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
731 attr[i++] = NSOpenGLPFAScreenMask;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
732 attr[i++] = CGDisplayIDToOpenGLDisplayMask (display_id);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
733 attr[i] = 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
734
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
735 fmt = [ [ NSOpenGLPixelFormat alloc ] initWithAttributes:attr ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
736 if (fmt == nil) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
737 SDL_SetError ("Failed creating OpenGL pixel format");
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
738 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
739 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
740
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
741 gl_context = [ [ NSOpenGLContext alloc ] initWithFormat:fmt
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
742 shareContext:nil];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
743
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
744 if (gl_context == nil) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
745 SDL_SetError ("Failed creating OpenGL context");
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
746 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
747 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
748
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
749 /* Convince SDL that the GL "driver" is loaded */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
750 this->gl_config.driver_loaded = 1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
751
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
752 [ fmt release ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
753
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
754 return 1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
755 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
756
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
757 static void QZ_TearDownOpenGL (_THIS) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
758
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
759 [ NSOpenGLContext clearCurrentContext ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
760 [ gl_context clearDrawable ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
761 [ gl_context release ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
762 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
763
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
764 /* SDL OpenGL functions */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
765
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
766 static int QZ_GL_LoadLibrary (_THIS, const char *location) {
197
ef78524e5f59 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 172
diff changeset
767 this->gl_config.driver_loaded = 1;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
768 return 1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
769 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
770
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
771 static void* QZ_GL_GetProcAddress (_THIS, const char *proc) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
772
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
773 /* We may want to cache the bundleRef at some point */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
774 CFBundleRef bundle;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
775 CFURLRef bundleURL = CFURLCreateWithFileSystemPath (kCFAllocatorDefault,
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
776 CFSTR("/System/Library/Frameworks/OpenGL.framework"), kCFURLPOSIXPathStyle, true);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
777
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
778 CFStringRef functionName = CFStringCreateWithCString
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
779 (kCFAllocatorDefault, proc, kCFStringEncodingASCII);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
780
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
781 void *function;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
782
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
783 bundle = CFBundleCreate (kCFAllocatorDefault, bundleURL);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
784 assert (bundle != NULL);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
785
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
786 function = CFBundleGetFunctionPointerForName (bundle, functionName);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
787
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
788 CFRelease ( bundleURL );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
789 CFRelease ( functionName );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
790 CFRelease ( bundle );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
791
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
792 return function;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
793 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
794
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
795 static int QZ_GL_GetAttribute (_THIS, SDL_GLattr attrib, int* value) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
796
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
797 /*
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
798 CGLContextRef ctx = [ gl_context cglContext ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
799 CGLContextParameter param;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
800
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
801 switch (attrib) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
802 case SDL_GL_RED_SIZE: param = CGLContextParameter break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
803
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
804 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
805
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
806 CGLGetParameter (ctx, param, (long*)value);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
807 */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
808 *value = -1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
809 return -1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
810 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
811
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
812 static int QZ_GL_MakeCurrent (_THIS) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
813 [ gl_context makeCurrentContext ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
814 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
815 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
816
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
817 static void QZ_GL_SwapBuffers (_THIS) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
818 [ gl_context flushBuffer ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
819 }