annotate src/video/quartz/SDL_QuartzVideo.m @ 435:140798e1e7a6

Darrell's fix for Quartz mouse motion
author Sam Lantinga <slouken@libsdl.org>
date Mon, 12 Aug 2002 22:43:58 +0000
parents 19e73568a75c
children 8a43e0cbf02f
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
297
f6ffac90895c Updated copyright information for 2002
Sam Lantinga <slouken@libsdl.org>
parents: 272
diff changeset
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
47
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 = {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
37 "Quartz", "Mac OS X CoreGraphics", QZ_Available, QZ_CreateDevice
47
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
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
47 #pragma unused (device_index)
47
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) );
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
60
47
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;
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
70
47
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;
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
86
47
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;
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
101
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
102 device->CreateYUVOverlay = QZ_CreateYUVOverlay;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
103
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
104 device->free = QZ_DeleteDevice;
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
105
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
106 return device;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
107 }
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 static void QZ_DeleteDevice (SDL_VideoDevice *device) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
110
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
111 free (device->hidden);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
112 free (device);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
113 }
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 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
116
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
117 /* Initialize the video settings; this data persists between mode switches */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
118 display_id = kCGDirectMainDisplay;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
119 save_mode = CGDisplayCurrentMode (display_id);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
120 mode_list = CGDisplayAvailableModes (display_id);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
121 palette = CGPaletteCreateDefaultColorPalette ();
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
122
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
123 /* Gather some information that is useful to know about the display */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
124 CFNumberGetValue (CFDictionaryGetValue (save_mode, kCGDisplayBitsPerPixel),
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
125 kCFNumberSInt32Type, &device_bpp);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
126
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
127 CFNumberGetValue (CFDictionaryGetValue (save_mode, kCGDisplayWidth),
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
128 kCFNumberSInt32Type, &device_width);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
129
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
130 CFNumberGetValue (CFDictionaryGetValue (save_mode, kCGDisplayHeight),
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
131 kCFNumberSInt32Type, &device_height);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
132
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
133 video_format->BitsPerPixel = device_bpp;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
134
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
135 return 0;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
136 }
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 static SDL_Rect** QZ_ListModes (_THIS, SDL_PixelFormat *format, Uint32 flags) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
139
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
140 CFIndex num_modes;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
141 CFIndex i;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
142
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
143 static SDL_Rect **list = NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
144 int list_size = 0;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
145
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
146 /* Any windowed mode is acceptable */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
147 if ( (flags & SDL_FULLSCREEN) == 0 )
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
148 return (SDL_Rect**)-1;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
149
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
150 /* Free memory from previous call, if any */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
151 if ( list != NULL ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
152
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
153 int i;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
154
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
155 for (i = 0; list[i] != NULL; i++)
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
156 free (list[i]);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
157
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
158 free (list);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
159 list = NULL;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
160 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
161
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
162 num_modes = CFArrayGetCount (mode_list);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
163
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
164 /* 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
165 for (i = 0; i < num_modes; i++) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
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 CFDictionaryRef onemode;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
168 CFNumberRef number;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
169 int bpp;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
170
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
171 onemode = CFArrayGetValueAtIndex (mode_list, i);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
172 number = CFDictionaryGetValue (onemode, kCGDisplayBitsPerPixel);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
173 CFNumberGetValue (number, kCFNumberSInt32Type, &bpp);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
174
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
175 if (bpp == format->BitsPerPixel) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
176
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
177 int intvalue;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
178 int hasMode;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
179 int width, height;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
180
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
181 number = CFDictionaryGetValue (onemode, kCGDisplayWidth);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
182 CFNumberGetValue (number, kCFNumberSInt32Type, &intvalue);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
183 width = (Uint16) intvalue;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
184
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
185 number = CFDictionaryGetValue (onemode, kCGDisplayHeight);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
186 CFNumberGetValue (number, kCFNumberSInt32Type, &intvalue);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
187 height = (Uint16) intvalue;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
188
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
189 /* Check if mode is already in the list */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
190 {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
191 int i;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
192 hasMode = SDL_FALSE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
193 for (i = 0; i < list_size; i++) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
194 if (list[i]->w == width && list[i]->h == height) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
195 hasMode = SDL_TRUE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
196 break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
197 }
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
198 }
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
199 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
200
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
201 /* Grow the list and add mode to the list */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
202 if ( ! hasMode ) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
203
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
204 SDL_Rect *rect;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
205
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
206 list_size++;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
207
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
208 if (list == NULL)
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
209 list = (SDL_Rect**) malloc (sizeof(*list) * (list_size+1) );
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
210 else
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
211 list = (SDL_Rect**) realloc (list, sizeof(*list) * (list_size+1));
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
212
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
213 rect = (SDL_Rect*) malloc (sizeof(**list));
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
214
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
215 if (list == NULL || rect == NULL) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
216 SDL_OutOfMemory ();
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
217 return NULL;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
218 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
219
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
220 rect->w = width;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
221 rect->h = height;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
222
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
223 list[list_size-1] = rect;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
224 list[list_size] = NULL;
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
225 }
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
226 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
227 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
228
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
229 /* 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
230 {
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
231 int i, j;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
232 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
233 for (j = 0; j < list_size-1; j++) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
234
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
235 int area1, area2;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
236 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
237 area2 = list[j+1]->w * list[j+1]->h;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
238
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
239 if (area1 < area2) {
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
240 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
241 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
242 list[j+1] = tmp;
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
243 }
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
244 }
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
245 }
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
246 }
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
247 return list;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
248 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
249
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
250 /* Gamma functions to try to hide the flash from a rez switch */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
251 /* Fade the display from normal to black */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
252 /* Save gamma tables for fade back to normal */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
253 static UInt32 QZ_FadeGammaOut (_THIS, SDL_QuartzGammaTable *table) {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
254
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
255 CGGammaValue redTable[QZ_GAMMA_TABLE_SIZE],
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
256 greenTable[QZ_GAMMA_TABLE_SIZE],
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
257 blueTable[QZ_GAMMA_TABLE_SIZE];
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
258
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
259 float percent;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
260 int j;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
261 int actual;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
262
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
263 if ( (CGDisplayNoErr != CGGetDisplayTransferByTable
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
264 (display_id, QZ_GAMMA_TABLE_SIZE,
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
265 table->red, table->green, table->blue, &actual)) ||
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
266 actual != QZ_GAMMA_TABLE_SIZE) {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
267
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
268 return 1;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
269 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
270
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
271 memcpy (redTable, table->red, sizeof(redTable));
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
272 memcpy (greenTable, table->green, sizeof(greenTable));
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
273 memcpy (blueTable, table->blue, sizeof(greenTable));
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
274
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
275 for (percent = 1.0; percent >= 0.0; percent -= 0.01) {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
276
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
277 for (j = 0; j < QZ_GAMMA_TABLE_SIZE; j++) {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
278
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
279 redTable[j] = redTable[j] * percent;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
280 greenTable[j] = greenTable[j] * percent;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
281 blueTable[j] = blueTable[j] * percent;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
282 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
283
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
284 if (CGDisplayNoErr != CGSetDisplayTransferByTable
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
285 (display_id, QZ_GAMMA_TABLE_SIZE,
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
286 redTable, greenTable, blueTable)) {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
287
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
288 CGDisplayRestoreColorSyncSettings();
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
289 return 1;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
290 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
291
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
292 SDL_Delay (10);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
293 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
294
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
295 return 0;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
296 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
297
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
298 /* Fade the display from black to normal */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
299 /* Restore previously saved gamma values */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
300 static UInt32 QZ_FadeGammaIn (_THIS, SDL_QuartzGammaTable *table) {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
301
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
302 CGGammaValue redTable[QZ_GAMMA_TABLE_SIZE],
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
303 greenTable[QZ_GAMMA_TABLE_SIZE],
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
304 blueTable[QZ_GAMMA_TABLE_SIZE];
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
305
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
306 float percent;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
307 int j;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
308
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
309 memset (redTable, 0, sizeof(redTable));
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
310 memset (greenTable, 0, sizeof(greenTable));
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
311 memset (blueTable, 0, sizeof(greenTable));
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
312
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
313 for (percent = 0.0; percent <= 1.0; percent += 0.01) {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
314
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
315 for (j = 0; j < QZ_GAMMA_TABLE_SIZE; j++) {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
316
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
317 redTable[j] = table->red[j] * percent;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
318 greenTable[j] = table->green[j] * percent;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
319 blueTable[j] = table->blue[j] * percent;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
320 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
321
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
322 if (CGDisplayNoErr != CGSetDisplayTransferByTable
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
323 (display_id, QZ_GAMMA_TABLE_SIZE,
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
324 redTable, greenTable, blueTable)) {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
325
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
326 CGDisplayRestoreColorSyncSettings();
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
327 return 1;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
328 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
329
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
330 SDL_Delay (10);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
331 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
332
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
333 return 0;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
334 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
335
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
336 static void QZ_UnsetVideoMode (_THIS) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
337
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
338 /* Reset values that may change between switches */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
339 this->info.blit_fill = 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
340 this->FillHWRect = NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
341 this->UpdateRects = NULL;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
342
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
343 /* Release fullscreen resources */
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
344 if ( mode_flags & SDL_FULLSCREEN ) {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
345
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
346 SDL_QuartzGammaTable gamma_table;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
347 int gamma_error;
435
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
348 NSRect screen_rect;
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
349
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
350 gamma_error = QZ_FadeGammaOut (this, &gamma_table);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
351
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
352 /* Release the OpenGL context */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
353 /* Do this first to avoid trash on the display before fade */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
354 if ( mode_flags & SDL_OPENGL )
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
355 QZ_TearDownOpenGL (this);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
356
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
357 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
358 CGLSetFullScreen(NULL);
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
359
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
360 /* Restore original screen resolution/bpp */
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
361 CGDisplaySwitchToMode (display_id, save_mode);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
362 CGDisplayRelease (display_id);
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
363 ShowMenuBar ();
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
364
435
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
365 /*
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
366 reset the main screen's rectangle, see comment
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
367 in QZ_SetVideoFullscreen
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
368 */
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
369 screen_rect = NSMakeRect(0,0,device_width,device_height);
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
370 [ [ NSScreen mainScreen ] setFrame:screen_rect ];
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
371
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
372 if (! gamma_error)
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
373 QZ_FadeGammaIn (this, &gamma_table);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
374 }
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
375 /* Release window mode resources */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
376 else {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
377 if ( (mode_flags & SDL_OPENGL) == 0 ) {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
378 UnlockPortBits ( [ window_view qdPort ] );
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
379 [ window_view release ];
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
380 }
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
381 [ qz_window setContentView:nil ];
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
382 [ qz_window setDelegate:nil ];
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
383 [ qz_window close ];
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
384 [ qz_window release ];
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
385 qz_window = nil;
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
386
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
387 /* Release the OpenGL context */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
388 if ( mode_flags & SDL_OPENGL )
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
389 QZ_TearDownOpenGL (this);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
390 }
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
391
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
392 /* Restore gamma settings */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
393 CGDisplayRestoreColorSyncSettings ();
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
394
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
395 /* 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
396 if (this->screen != NULL)
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
397 this->screen->pixels = NULL;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
398
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
399 /* 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
400 CGDisplayShowCursor (display_id);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
401 CGAssociateMouseAndMouseCursorPosition (1);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
402
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
403 /* Signal successful teardown */
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
404 video_set = SDL_FALSE;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
405 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
406
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
407 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
408 int height, int bpp, Uint32 flags) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
409 int exact_match;
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
410 int gamma_error;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
411 SDL_QuartzGammaTable gamma_table;
435
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
412 NSRect screen_rect;
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
413
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
414 /* See if requested mode exists */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
415 mode = CGDisplayBestModeForParameters (display_id, bpp, width,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
416 height, &exact_match);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
417
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
418 /* 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
419 if ( ! exact_match ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
420 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
421 SDL_SetError (QZ_Error);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
422 goto ERR_NO_MATCH;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
423 }
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
424
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
425 /* Fade display to zero gamma */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
426 gamma_error = QZ_FadeGammaOut (this, &gamma_table);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
427
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
428 /* 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
429 if ( CGDisplayNoErr != CGDisplayCapture (display_id) ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
430 SDL_SetError ("Failed capturing display");
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
431 goto ERR_NO_CAPTURE;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
432 }
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
433
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
434
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
435 /* Do the physical switch */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
436 if ( CGDisplayNoErr != CGDisplaySwitchToMode (display_id, mode) ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
437 SDL_SetError ("Failed switching display resolution");
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
438 goto ERR_NO_SWITCH;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
439 }
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
440
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
441 current->pixels = (Uint32*) CGDisplayBaseAddress (display_id);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
442 current->pitch = CGDisplayBytesPerRow (display_id);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
443
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
444 current->flags = 0;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
445 current->w = width;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
446 current->h = height;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
447 current->flags |= SDL_FULLSCREEN;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
448 current->flags |= SDL_HWSURFACE;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
449
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
450 this->UpdateRects = QZ_DirectUpdate;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
451
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
452 /* Setup some mode-dependant info */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
453 if ( CGSDisplayCanHWFill (display_id) ) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
454 this->info.blit_fill = 1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
455 this->FillHWRect = QZ_FillHWRect;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
456 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
457
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
458 if ( CGDisplayCanSetPalette (display_id) )
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
459 current->flags |= SDL_HWPALETTE;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
460
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
461 /* Setup OpenGL for a fullscreen context */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
462 if (flags & SDL_OPENGL) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
463
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
464 CGLError err;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
465 CGLContextObj ctx;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
466
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
467 if ( ! QZ_SetupOpenGL (this, bpp, flags) ) {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
468 goto ERR_NO_GL;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
469 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
470
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
471 ctx = [ gl_context cglContext ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
472 err = CGLSetFullScreen (ctx);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
473
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
474 if (err) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
475 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
476 SDL_SetError (QZ_Error);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
477 goto ERR_NO_GL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
478 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
479
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
480 [ gl_context makeCurrentContext];
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
481
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
482 glClear (GL_COLOR_BUFFER_BIT);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
483
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
484 [ gl_context flushBuffer ];
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
485
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
486 current->flags |= SDL_OPENGL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
487 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
488
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
489 /* 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
490 HideMenuBar ();
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
491
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
492 /* Fade the display to original gamma */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
493 if (! gamma_error )
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
494 QZ_FadeGammaIn (this, &gamma_table);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
495
435
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
496 /*
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
497 There is a bug in Cocoa where NSScreen doesn't synchronize
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
498 with CGDirectDisplay, so the main screen's frame is wrong.
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
499 As a result, coordinate translation produces wrong results.
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
500 We can hack around this bug by setting the screen rect
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
501 ourselves. This hack should be removed if/when the bug is fixed.
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
502 */
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
503 screen_rect = NSMakeRect(0,0,width,height);
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
504 [ [ NSScreen mainScreen ] setFrame:screen_rect ];
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
505
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
506 /* 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
507 mode_flags = current->flags;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
508
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
509 return current;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
510
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
511 /* Since the blanking window covers *all* windows (even force quit) correct recovery is crucial */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
512 ERR_NO_GL: CGDisplaySwitchToMode (display_id, save_mode);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
513 ERR_NO_SWITCH: CGDisplayRelease (display_id);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
514 ERR_NO_CAPTURE: if (!gamma_error) { QZ_FadeGammaIn (this, &gamma_table); }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
515 ERR_NO_MATCH: return NULL;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
516 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
517
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
518 static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width,
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
519 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
520 unsigned int style;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
521 NSRect rect;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
522 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
523
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
524 #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
525 flags &= ~SDL_RESIZABLE;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
526 #endif
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
527 /* 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
528 if ( flags & SDL_NOFRAME ) {
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
529 style = NSBorderlessWindowMask;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
530 } else {
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
531 style = NSTitledWindowMask;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
532 style |= (NSMiniaturizableWindowMask | NSClosableWindowMask);
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
533 if ( flags & SDL_RESIZABLE )
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
534 style |= NSResizableWindowMask;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
535 }
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
536
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
537 /* Manually create a window, avoids having a nib file resource */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
538 qz_window = [ [ SDL_QuartzWindow alloc ] initWithContentRect:rect
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
539 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
540 if (qz_window == nil) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
541 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
542 return NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
543 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
544
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
545 current->flags = 0;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
546 current->w = width;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
547 current->h = height;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
548
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
549 [ qz_window setReleasedWhenClosed:YES ];
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
550 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
551 [ qz_window setAcceptsMouseMovedEvents:YES ];
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
552 [ qz_window setViewsNeedDisplay:NO ];
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
553 [ qz_window center ];
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
554 [ qz_window setDelegate:
56
ce9cd2cf0d0d Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
555 [ [ [ SDL_QuartzWindowDelegate alloc ] init ] autorelease ] ];
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
556
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
557 /* 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
558 if ( flags & SDL_OPENGL ) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
559
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
560 if ( ! QZ_SetupOpenGL (this, bpp, flags) ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
561 return NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
562 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
563
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
564 [ gl_context setView: [ qz_window contentView ] ];
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
565 [ gl_context makeCurrentContext];
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
566 [ qz_window makeKeyAndOrderFront:nil ];
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
567 current->flags |= SDL_OPENGL;
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 /* 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
570 else {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
571
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
572 window_view = [ [ SDL_QuartzWindowView alloc ] init ];
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
573 [ qz_window setContentView:window_view ];
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
574 [ qz_window makeKeyAndOrderFront:nil ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
575
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
576 LockPortBits ( [ window_view qdPort ] );
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
577 current->pixels = GetPixBaseAddr ( GetPortPixMap ( [ window_view qdPort ] ) );
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
578 current->pitch = GetPixRowBytes ( GetPortPixMap ( [ window_view qdPort ] ) );
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
579
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
580 current->flags |= SDL_SWSURFACE;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
581 current->flags |= SDL_PREALLOC;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
582
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
583 if ( flags & SDL_NOFRAME )
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
584 current->flags |= SDL_NOFRAME;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
585 if ( flags & SDL_RESIZABLE )
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
586 current->flags |= SDL_RESIZABLE;
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
587
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
588 /* Offset 22 pixels down to fill the full content region */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
589 if ( ! (current->flags & SDL_NOFRAME) ) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
590 current->pixels += 22 * current->pitch;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
591 }
47
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 this->UpdateRects = QZ_UpdateRects;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
594 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
595
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
596 /* Save flags to ensure correct teardown */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
597 mode_flags = current->flags;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
598
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
599 return current;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
600 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
601
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
602 static SDL_Surface* QZ_SetVideoMode (_THIS, SDL_Surface *current, int width,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
603 int height, int bpp, Uint32 flags) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
604
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
605 if (video_set == SDL_TRUE)
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
606 QZ_UnsetVideoMode (this);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
607
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
608 current->flags = 0;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
609
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
610 /* Setup full screen video */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
611 if ( flags & SDL_FULLSCREEN ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
612 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
613 if (current == NULL)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
614 return NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
615 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
616 /* Setup windowed video */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
617 else {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
618 /* Force bpp to the device's bpp */
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
619 bpp = device_bpp;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
620 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
621 if (current == NULL)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
622 return NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
623 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
624
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
625 /* Setup the new pixel format */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
626 {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
627 int amask = 0,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
628 rmask = 0,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
629 gmask = 0,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
630 bmask = 0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
631
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
632 switch (bpp) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
633 case 16: /* (1)-5-5-5 RGB */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
634 amask = 0;
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
635 rmask = 0x7C00;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
636 gmask = 0x03E0;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 56
diff changeset
637 bmask = 0x001F;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
638 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
639 case 24:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
640 SDL_SetError ("24bpp is not available");
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
641 return NULL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
642 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
643 amask = 0x00000000;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
644 rmask = 0x00FF0000;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
645 gmask = 0x0000FF00;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
646 bmask = 0x000000FF;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
647 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
648 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
649
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
650 if ( ! SDL_ReallocFormat (current, bpp,
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
651 rmask, gmask, bmask, amask ) ) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
652 SDL_SetError ("Couldn't reallocate pixel format");
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
653 return NULL;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
654 }
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
655 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
656
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
657 /* Signal successful completion (used internally) */
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
658 video_set = SDL_TRUE;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
659
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
660 return current;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
661 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
662
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
663 static int QZ_ToggleFullScreen (_THIS, int on) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
664 return -1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
665 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
666
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
667 static int QZ_SetColors (_THIS, int first_color, int num_colors,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
668 SDL_Color *colors) {
47
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 CGTableCount index;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
671 CGDeviceColor color;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
672
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
673 for (index = first_color; index < first_color+num_colors; index++) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
674
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
675 /* 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
676 color.red = colors->r / 255.0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
677 color.blue = colors->b / 255.0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
678 color.green = colors->g / 255.0;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
679
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
680 colors++;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
681
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
682 CGPaletteSetColorAtIndex (palette, color, index);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
683 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
684
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
685 if ( CGDisplayNoErr != CGDisplaySetPalette (display_id, palette) )
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
686 return 0;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
687
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
688 return 1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
689 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
690
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
691 static void QZ_DirectUpdate (_THIS, int num_rects, SDL_Rect *rects) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
692 #pragma unused(this,num_rects,rects)
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
693 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
694
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
695 /**
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
696 * The obscured code is based on work by Matt Slot fprefect@ambrosiasw.com,
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
697 * who supplied sample code for Carbon.
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
698 **/
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
699 static int QZ_IsWindowObscured (NSWindow *window) {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
700
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
701 //#define TEST_OBSCURED 1
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
702
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
703 #if TEST_OBSCURED
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
704
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
705 /* In order to determine if a direct copy to the screen is possible,
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
706 we must figure out if there are any windows covering ours (including shadows).
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
707 This can be done by querying the window server about the on screen
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
708 windows for their screen rectangle and window level.
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
709 The procedure used below is puts accuracy before speed; however, it aims to call
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
710 the window server the fewest number of times possible to keep things reasonable.
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
711 In my testing on a 300mhz G3, this routine typically takes < 2 ms. -DW
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
712
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
713 Notes:
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
714 -Calls into the Window Server involve IPC which is slow.
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
715 -Getting a rectangle seems slower than getting the window level
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
716 -The window list we get back is in sorted order, top to bottom
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
717 -On average, I suspect, most windows above ours are dock icon windows (hence optimization)
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
718 -Some windows above ours are always there, and cannot move or obscure us (menu bar)
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
719
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
720 Bugs:
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
721 -no way (yet) to deactivate direct drawing when a window is dragged,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
722 or suddenly obscured, so drawing continues and can produce garbage
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
723 We need some kind of locking mechanism on window movement to prevent this
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
724
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
725 -deactivated normal windows use activated normal
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
726 window shadows (slight inaccuraccy)
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
727 */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
728
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
729 /* Cache the connection to the window server */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
730 static CGSConnectionID cgsConnection = (CGSConnectionID) -1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
731
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
732 /* Cache the dock icon windows */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
733 static CGSWindowID dockIcons[kMaxWindows];
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
734 static int numCachedDockIcons = 0;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
735
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
736 CGSWindowID windows[kMaxWindows];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
737 CGSWindowCount i, count;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
738 CGSWindowLevel winLevel;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
739 CGSRect winRect;
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
740
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
741 CGSRect contentRect;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
742 int windowNumber;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
743 //int isMainWindow;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
744 int firstDockIcon;
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
745 int dockIconCacheMiss;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
746 int windowContentOffset;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
747
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
748 int obscured = SDL_TRUE;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
749
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
750 if ( [ window isVisible ] ) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
751
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
752 /* walk the window list looking for windows over top of
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
753 (or casting a shadow on) ours */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
754
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
755 /* Get a connection to the window server */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
756 /* Should probably be moved out into SetVideoMode() or InitVideo() */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
757 if (cgsConnection == (CGSConnectionID) -1) {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
758 cgsConnection = (CGSConnectionID) 0;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
759 cgsConnection = _CGSDefaultConnection ();
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
760 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
761
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
762 if (cgsConnection) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
763
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
764 if ( ! [ window styleMask ] & NSBorderlessWindowMask )
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
765 windowContentOffset = 22;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
766 else
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
767 windowContentOffset = 0;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
768
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
769 windowNumber = [ window windowNumber ];
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
770 //isMainWindow = [ window isMainWindow ];
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
771
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
772 /* The window list is sorted according to order on the screen */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
773 count = 0;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
774 CGSGetOnScreenWindowList (cgsConnection, 0, kMaxWindows, windows, &count);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
775 CGSGetScreenRectForWindow (cgsConnection, windowNumber, &contentRect);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
776
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
777 /* adjust rect for window title bar (if present) */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
778 contentRect.origin.y += windowContentOffset;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
779 contentRect.size.height -= windowContentOffset;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
780
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
781 firstDockIcon = -1;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
782 dockIconCacheMiss = SDL_FALSE;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
783
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
784 /* The first window is always an empty window with level kCGSWindowLevelTop
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
785 so start at index 1 */
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
786 for (i = 1; i < count; i++) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
787
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
788 /* If we reach our window in the list, it cannot be obscured */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
789 if (windows[i] == windowNumber) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
790
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
791 obscured = SDL_FALSE;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
792 break;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
793 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
794 else {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
795
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
796 float shadowSide;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
797 float shadowTop;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
798 float shadowBottom;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
799
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
800 CGSGetWindowLevel (cgsConnection, windows[i], &winLevel);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
801
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
802 if (winLevel == kCGSWindowLevelDockIcon) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
803
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
804 int j;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
805
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
806 if (firstDockIcon < 0) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
807
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
808 firstDockIcon = i;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
809
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
810 if (numCachedDockIcons > 0) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
811
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
812 for (j = 0; j < numCachedDockIcons; j++) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
813
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
814 if (windows[i] == dockIcons[j])
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
815 i++;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
816 else
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
817 break;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
818 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
819
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
820 if (j != 0) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
821
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
822 i--;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
823
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
824 if (j < numCachedDockIcons) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
825
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
826 dockIconCacheMiss = SDL_TRUE;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
827 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
828 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
829
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
830 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
831 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
832
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
833 continue;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
834 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
835 else if (winLevel == kCGSWindowLevelMenuIgnore
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
836 /* winLevel == kCGSWindowLevelTop */) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
837
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
838 continue; /* cannot obscure window */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
839 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
840 else if (winLevel == kCGSWindowLevelDockMenu ||
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
841 winLevel == kCGSWindowLevelMenu) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
842
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
843 shadowSide = 18;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
844 shadowTop = 4;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
845 shadowBottom = 22;
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
846 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
847 else if (winLevel == kCGSWindowLevelUtility) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
848
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
849 shadowSide = 8;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
850 shadowTop = 4;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
851 shadowBottom = 12;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
852 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
853 else if (winLevel == kCGSWindowLevelNormal) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
854
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
855 /* These numbers are for foreground windows,
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
856 they are too big (but will work) for background windows */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
857 shadowSide = 20;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
858 shadowTop = 10;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
859 shadowBottom = 24;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
860 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
861 else if (winLevel == kCGSWindowLevelDock) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
862
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
863 /* Create dock icon cache */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
864 if (numCachedDockIcons != (i-firstDockIcon) ||
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
865 dockIconCacheMiss) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
866
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
867 numCachedDockIcons = i - firstDockIcon;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
868 memcpy (dockIcons, &(windows[firstDockIcon]),
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
869 numCachedDockIcons * sizeof(*windows));
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
870 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
871
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
872 /* no shadow */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
873 shadowSide = 0;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
874 shadowTop = 0;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
875 shadowBottom = 0;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
876 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
877 else {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
878
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
879 /* kCGSWindowLevelDockLabel,
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
880 kCGSWindowLevelDock,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
881 kOther??? */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
882
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
883 /* no shadow */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
884 shadowSide = 0;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
885 shadowTop = 0;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
886 shadowBottom = 0;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
887 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
888
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
889 CGSGetScreenRectForWindow (cgsConnection, windows[i], &winRect);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
890
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
891 winRect.origin.x -= shadowSide;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
892 winRect.origin.y -= shadowTop;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
893 winRect.size.width += shadowSide;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
894 winRect.size.height += shadowBottom;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
895
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
896 if (NSIntersectsRect (contentRect, winRect)) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
897
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
898 obscured = SDL_TRUE;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
899 break;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
900 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
901
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
902 } /* window was not our window */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
903
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
904 } /* iterate over windows */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
905
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
906 } /* get cgsConnection */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
907
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
908 } /* window is visible */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
909
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
910 return obscured;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
911 #else
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
912 return SDL_TRUE;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
913 #endif
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
914 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
915
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
916 static void QZ_UpdateRects (_THIS, int numRects, SDL_Rect *rects) {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
917
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
918 if (SDL_VideoSurface->flags & SDL_OPENGLBLIT) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
919 QZ_GL_SwapBuffers (this);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
920 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
921 else if ( [ qz_window isMiniaturized ] &&
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
922 ! (SDL_VideoSurface->flags & SDL_OPENGL)) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
923
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
924 /**
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
925 * Set port alpha opaque so deminiaturize looks right
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
926 * This isn't so nice, but there is no
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
927 * initial deminatureize notification (before demini starts)
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
928 **/
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
929 QZ_SetPortAlphaOpaque ([ [ qz_window contentView ] qdPort],
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
930 [ qz_window styleMask ] & NSBorderlessWindowMask);
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
931 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
932 else if ( ! QZ_IsWindowObscured (qz_window) ) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
933
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
934 /* Use direct copy to flush contents to the display */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
935 CGrafPtr savePort;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
936 CGrafPtr dstPort, srcPort;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
937 const BitMap *dstBits, *srcBits;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
938 Rect dstRect, srcRect;
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
939 Point offset;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
940 int i;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
941
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
942 GetPort (&savePort);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
943
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
944 dstPort = CreateNewPortForCGDisplayID ((UInt32)display_id);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
945 srcPort = [ window_view qdPort ];
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
946
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
947 offset.h = 0;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
948 offset.v = 0;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
949 SetPort (srcPort);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
950 LocalToGlobal (&offset);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
951
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
952 SetPort (dstPort);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
953
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
954 LockPortBits (dstPort);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
955 LockPortBits (srcPort);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
956
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
957 dstBits = GetPortBitMapForCopyBits (dstPort);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
958 srcBits = GetPortBitMapForCopyBits (srcPort);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
959
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
960 for (i = 0; i < numRects; i++) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
961
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
962 SetRect (&srcRect, rects[i].x, rects[i].y,
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
963 rects[i].x + rects[i].w,
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
964 rects[i].y + rects[i].h);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
965
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
966 SetRect (&dstRect,
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
967 rects[i].x + offset.h,
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
968 rects[i].y + offset.v,
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
969 rects[i].x + rects[i].w + offset.h,
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
970 rects[i].y + rects[i].h + offset.v);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
971
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
972 CopyBits (srcBits, dstBits,
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
973 &srcRect, &dstRect, srcCopy, NULL);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
974
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
975 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
976
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
977 SetPort (savePort);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
978 }
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
979 else {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
980
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
981 /* Use QDFlushPortBuffer() to flush content to display */
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
982 int i;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
983 RgnHandle dirty = NewRgn ();
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
984 RgnHandle temp = NewRgn ();
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
985
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
986 SetEmptyRgn (dirty);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
987
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
988 /* Build the region of dirty rectangles */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
989 for (i = 0; i < numRects; i++) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
990
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
991 MacSetRectRgn (temp, rects[i].x, rects[i].y,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
992 rects[i].x + rects[i].w, rects[i].y + rects[i].h);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
993 MacUnionRgn (dirty, temp, dirty);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
994 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
995
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
996 /* Flush the dirty region */
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
997 QDFlushPortBuffer ( [ window_view qdPort ], dirty );
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
998 DisposeRgn (dirty);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
999 DisposeRgn (temp);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1000 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1001 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1002
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1003 static void QZ_VideoQuit (_THIS) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1004
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1005 QZ_UnsetVideoMode (this);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1006 CGPaletteRelease (palette);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1007 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1008
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1009 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
1010
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1011 CGSDisplayHWFill (display_id, rect->x, rect->y, rect->w, rect->h, color);
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1012
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1013 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1014 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1015
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1016 static int QZ_LockHWSurface(_THIS, SDL_Surface *surface) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1017
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1018 return 1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1019 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1020
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1021 static void QZ_UnlockHWSurface(_THIS, SDL_Surface *surface) {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1022
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1023 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1024
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1025 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
1026 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1027
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1028 /*
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1029 int QZ_FlipHWSurface (_THIS, SDL_Surface *surface) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1030 return 0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1031 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1032 */
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1033
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1034 /* Gamma functions */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1035 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
1036
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1037 const CGGammaValue min = 0.0, max = 1.0;
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1038
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1039 if (red == 0.0)
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1040 red = FLT_MAX;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1041 else
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1042 red = 1.0 / red;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1043
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1044 if (green == 0.0)
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1045 green = FLT_MAX;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1046 else
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1047 green = 1.0 / green;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1048
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1049 if (blue == 0.0)
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1050 blue = FLT_MAX;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1051 else
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1052 blue = 1.0 / blue;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1053
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1054 if ( CGDisplayNoErr == CGSetDisplayTransferByFormula
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1055 (display_id, min, max, red, min, max, green, min, max, blue) ) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1056
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1057 return 0;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1058 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1059 else {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1060
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1061 return -1;
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1062 }
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1063 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1064
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1065 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
1066
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1067 CGGammaValue dummy;
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1068 if ( CGDisplayNoErr == CGGetDisplayTransferByFormula
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1069 (display_id, &dummy, &dummy, red,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1070 &dummy, &dummy, green, &dummy, &dummy, blue) )
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1071
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1072 return 0;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1073 else
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1074 return -1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1075 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1076
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1077 static int QZ_SetGammaRamp (_THIS, Uint16 *ramp) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1078
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1079 const CGTableCount tableSize = 255;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1080 CGGammaValue redTable[tableSize];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1081 CGGammaValue greenTable[tableSize];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1082 CGGammaValue blueTable[tableSize];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1083
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1084 int i;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1085
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1086 /* Extract gamma values into separate tables, convert to floats between 0.0 and 1.0 */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1087 for (i = 0; i < 256; i++)
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1088 redTable[i % 256] = ramp[i] / 65535.0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1089
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1090 for (i=256; i < 512; i++)
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1091 greenTable[i % 256] = ramp[i] / 65535.0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1092
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1093 for (i=512; i < 768; i++)
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1094 blueTable[i % 256] = ramp[i] / 65535.0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1095
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1096 if ( CGDisplayNoErr == CGSetDisplayTransferByTable
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1097 (display_id, tableSize, redTable, greenTable, blueTable) )
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1098 return 0;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1099 else
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1100 return -1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1101 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1102
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1103 static int QZ_GetGammaRamp (_THIS, Uint16 *ramp) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1104
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1105 const CGTableCount tableSize = 255;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1106 CGGammaValue redTable[tableSize];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1107 CGGammaValue greenTable[tableSize];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1108 CGGammaValue blueTable[tableSize];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1109 CGTableCount actual;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1110 int i;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1111
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1112 if ( CGDisplayNoErr != CGGetDisplayTransferByTable
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1113 (display_id, tableSize, redTable, greenTable, blueTable, &actual) ||
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1114 actual != tableSize)
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1115
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1116 return -1;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1117
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1118 /* 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
1119 for (i = 0; i < 256; i++)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1120 ramp[i] = redTable[i % 256] * 65535.0;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1121
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1122 for (i=256; i < 512; i++)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1123 ramp[i] = greenTable[i % 256] * 65535.0;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1124
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1125 for (i=512; i < 768; i++)
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1126 ramp[i] = blueTable[i % 256] * 65535.0;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1127
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1128 return 0;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1129 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1130
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1131 /* OpenGL helper functions (used internally) */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1132
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1133 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
1134
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1135 NSOpenGLPixelFormatAttribute attr[32];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1136 NSOpenGLPixelFormat *fmt;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1137 int i = 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1138 int colorBits = bpp;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1139
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1140 if ( flags & SDL_FULLSCREEN ) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1141
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1142 attr[i++] = NSOpenGLPFAFullScreen;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1143 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1144 /* In windowed mode, the OpenGL pixel depth must match device pixel depth */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1145 else if ( colorBits != device_bpp ) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1146
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1147 colorBits = device_bpp;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1148 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1149
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1150 attr[i++] = NSOpenGLPFAColorSize;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1151 attr[i++] = colorBits;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1152
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1153 attr[i++] = NSOpenGLPFADepthSize;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1154 attr[i++] = this->gl_config.depth_size;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1155
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1156 if ( this->gl_config.double_buffer ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1157 attr[i++] = NSOpenGLPFADoubleBuffer;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1158 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1159
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1160 if ( this->gl_config.stencil_size != 0 ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1161 attr[i++] = NSOpenGLPFAStencilSize;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1162 attr[i++] = this->gl_config.stencil_size;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1163 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1164
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1165 attr[i++] = NSOpenGLPFAScreenMask;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1166 attr[i++] = CGDisplayIDToOpenGLDisplayMask (display_id);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1167 attr[i] = 0;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1168
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1169 fmt = [ [ NSOpenGLPixelFormat alloc ] initWithAttributes:attr ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1170 if (fmt == nil) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1171 SDL_SetError ("Failed creating OpenGL pixel format");
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1172 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1173 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1174
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1175 gl_context = [ [ NSOpenGLContext alloc ] initWithFormat:fmt
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1176 shareContext:nil];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1177
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1178 if (gl_context == nil) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1179 SDL_SetError ("Failed creating OpenGL context");
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1180 return 0;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1181 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1182
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1183 /* 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
1184 this->gl_config.driver_loaded = 1;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1185
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1186 [ fmt release ];
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1187
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1188 return 1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1189 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1190
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1191 static void QZ_TearDownOpenGL (_THIS) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1192
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1193 [ NSOpenGLContext clearCurrentContext ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1194 [ gl_context clearDrawable ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1195 [ gl_context release ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1196 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1197
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1198
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1199 /* SDL OpenGL functions */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1200
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1201 static int QZ_GL_LoadLibrary (_THIS, const char *location) {
197
ef78524e5f59 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 172
diff changeset
1202 this->gl_config.driver_loaded = 1;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1203 return 1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1204 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1205
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1206 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
1207
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1208 /* 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
1209 CFBundleRef bundle;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1210 CFURLRef bundleURL = CFURLCreateWithFileSystemPath (kCFAllocatorDefault,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1211 CFSTR("/System/Library/Frameworks/OpenGL.framework"), kCFURLPOSIXPathStyle, true);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1212
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1213 CFStringRef functionName = CFStringCreateWithCString
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1214 (kCFAllocatorDefault, proc, kCFStringEncodingASCII);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1215
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1216 void *function;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1217
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1218 bundle = CFBundleCreate (kCFAllocatorDefault, bundleURL);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1219 assert (bundle != NULL);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1220
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1221 function = CFBundleGetFunctionPointerForName (bundle, functionName);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1222
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1223 CFRelease ( bundleURL );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1224 CFRelease ( functionName );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1225 CFRelease ( bundle );
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1226
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1227 return function;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1228 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1229
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1230 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
1231
347
1b89c9ca9246 Fixed build warning
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
1232 GLenum attr = 0;
308
ee32ed29a507 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1233
ee32ed29a507 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1234 QZ_GL_MakeCurrent (this);
ee32ed29a507 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1235
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1236 switch (attrib) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1237 case SDL_GL_RED_SIZE: attr = GL_RED_BITS; break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1238 case SDL_GL_BLUE_SIZE: attr = GL_BLUE_BITS; break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1239 case SDL_GL_GREEN_SIZE: attr = GL_GREEN_BITS; break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1240 case SDL_GL_ALPHA_SIZE: attr = GL_ALPHA_BITS; break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1241 case SDL_GL_DOUBLEBUFFER: attr = GL_DOUBLEBUFFER; break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1242 case SDL_GL_DEPTH_SIZE: attr = GL_DEPTH_BITS; break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1243 case SDL_GL_STENCIL_SIZE: attr = GL_STENCIL_BITS; break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1244 case SDL_GL_ACCUM_RED_SIZE: attr = GL_ACCUM_RED_BITS; break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1245 case SDL_GL_ACCUM_GREEN_SIZE: attr = GL_ACCUM_GREEN_BITS; break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1246 case SDL_GL_ACCUM_BLUE_SIZE: attr = GL_ACCUM_BLUE_BITS; break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1247 case SDL_GL_ACCUM_ALPHA_SIZE: attr = GL_ACCUM_ALPHA_BITS; break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1248 case SDL_GL_BUFFER_SIZE:
308
ee32ed29a507 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1249 {
ee32ed29a507 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1250 GLint bits = 0;
ee32ed29a507 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1251 GLint component;
ee32ed29a507 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1252
ee32ed29a507 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1253 /* there doesn't seem to be a single flag in OpenGL for this! */
ee32ed29a507 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1254 glGetIntegerv (GL_RED_BITS, &component); bits += component;
ee32ed29a507 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1255 glGetIntegerv (GL_GREEN_BITS,&component); bits += component;
ee32ed29a507 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1256 glGetIntegerv (GL_BLUE_BITS, &component); bits += component;
ee32ed29a507 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1257 glGetIntegerv (GL_ALPHA_BITS, &component); bits += component;
ee32ed29a507 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1258
ee32ed29a507 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1259 *value = bits;
ee32ed29a507 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1260 }
ee32ed29a507 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1261 return 0;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1262 }
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1263
324
f25f666d609a *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 308
diff changeset
1264 glGetIntegerv (attr, (GLint *)value);
308
ee32ed29a507 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1265 return 0;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1266 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1267
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1268 static int QZ_GL_MakeCurrent (_THIS) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1269 [ gl_context makeCurrentContext ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1270 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1271 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1272
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1273 static void QZ_GL_SwapBuffers (_THIS) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1274 [ gl_context flushBuffer ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1275 }
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1276
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1277 static int QZ_LockYUV (_THIS, SDL_Overlay *overlay) {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
1278
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1279 return 0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1280 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1281
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1282 static void QZ_UnlockYUV (_THIS, SDL_Overlay *overlay) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1283
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1284 ;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1285 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1286
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1287 static int QZ_DisplayYUV (_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1288
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1289 OSErr err;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1290 CodecFlags flags;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1291
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1292 if (dstrect->x != 0 || dstrect->y != 0) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1293
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1294 SDL_SetError ("Need a dstrect at (0,0)");
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1295 return -1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1296 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1297
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1298 if (dstrect->w != yuv_width || dstrect->h != yuv_height) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1299
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1300 Fixed scale_x, scale_y;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1301
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1302 scale_x = FixDiv ( Long2Fix (dstrect->w), Long2Fix (overlay->w) );
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1303 scale_y = FixDiv ( Long2Fix (dstrect->h), Long2Fix (overlay->h) );
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1304
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1305 SetIdentityMatrix (yuv_matrix);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1306 ScaleMatrix (yuv_matrix, scale_x, scale_y, Long2Fix (0), Long2Fix (0));
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1307
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1308 SetDSequenceMatrix (yuv_seq, yuv_matrix);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1309
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1310 yuv_width = dstrect->w;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1311 yuv_height = dstrect->h;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1312 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1313
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1314 if( ( err = DecompressSequenceFrameS(
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1315 yuv_seq,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1316 (void*)yuv_pixmap,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1317 sizeof (PlanarPixmapInfoYUV420),
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1318 codecFlagUseImageBuffer, &flags, nil ) != noErr ) )
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1319 {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1320 SDL_SetError ("DecompressSequenceFrameS failed");
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1321 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1322
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1323 return err == noErr;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1324 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1325
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1326 static void QZ_FreeHWYUV (_THIS, SDL_Overlay *overlay) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1327
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1328 CDSequenceEnd (yuv_seq);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1329 ExitMovies();
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1330
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1331 free (overlay->hwfuncs);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1332 free (overlay->pitches);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1333 free (overlay->pixels);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1334
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1335 if (SDL_VideoSurface->flags & SDL_FULLSCREEN) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1336 [ qz_window close ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1337 qz_window = nil;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1338 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1339
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1340 free (yuv_matrix);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1341 DisposeHandle ((Handle)yuv_idh);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1342 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1343
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1344 #include "SDL_yuvfuncs.h"
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1345
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1346 /**
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1347 * check for 16 byte alignment, bail otherwise
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1348 **/
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1349 #define CHECK_ALIGN(x) do { if ((Uint32)x & 15) { SDL_SetError("Alignment error"); return NULL; } } while(0)
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1350
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1351 /**
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1352 * align a byte offset, return how much to add to make it
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1353 * a multiple of 16
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1354 **/
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1355 #define ALIGN(x) ((16 - (x & 15)) & 15)
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1356
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1357 static SDL_Overlay* QZ_CreateYUVOverlay (_THIS, int width, int height,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1358 Uint32 format, SDL_Surface *display) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1359
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1360 Uint32 codec;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1361 OSStatus err;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1362 CGrafPtr port;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1363 SDL_Overlay *overlay;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1364
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1365 if (format == SDL_YV12_OVERLAY ||
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1366 format == SDL_IYUV_OVERLAY) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1367
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1368 codec = kYUV420CodecType;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1369 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1370 else {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1371 SDL_SetError ("Hardware: unsupported video format");
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1372 return NULL;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1373 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1374
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1375 yuv_idh = (ImageDescriptionHandle) NewHandleClear (sizeof(ImageDescription));
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1376 if (yuv_idh == NULL) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1377 SDL_OutOfMemory();
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1378 return NULL;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1379 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1380
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1381 yuv_matrix = (MatrixRecordPtr) malloc (sizeof(MatrixRecord));
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1382 if (yuv_matrix == NULL) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1383 SDL_OutOfMemory();
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1384 return NULL;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1385 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1386
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1387 if ( EnterMovies() != noErr ) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1388 SDL_SetError ("Could not init QuickTime for YUV playback");
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1389 return NULL;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1390 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1391
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1392 err = FindCodec (codec, bestSpeedCodec, nil, &yuv_codec);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1393 if (err != noErr) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1394 SDL_SetError ("Could not find QuickTime codec for format");
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1395 return NULL;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1396 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1397
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1398 if (SDL_VideoSurface->flags & SDL_FULLSCREEN) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1399
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1400 /**
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1401 * Good acceleration requires a window to be present.
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1402 * A CGrafPtr that points to the screen isn't good enough
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1403 **/
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1404 NSRect content = NSMakeRect (0, 0, SDL_VideoSurface->w, SDL_VideoSurface->h);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1405
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1406 qz_window = [ [ SDL_QuartzWindow alloc ]
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1407 initWithContentRect:content
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1408 styleMask:NSBorderlessWindowMask
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1409 backing:NSBackingStoreBuffered defer:NO ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1410
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1411 if (qz_window == nil) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1412 SDL_SetError ("Could not create the Cocoa window");
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1413 return NULL;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1414 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1415
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1416 [ qz_window setContentView:[ [ SDL_QuartzWindowView alloc ] init ] ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1417 [ qz_window setReleasedWhenClosed:YES ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1418 [ qz_window center ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1419 [ qz_window setAcceptsMouseMovedEvents:YES ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1420 [ qz_window setLevel:CGShieldingWindowLevel() ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1421 [ qz_window makeKeyAndOrderFront:nil ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1422
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1423 port = [ [ qz_window contentView ] qdPort ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1424 SetPort (port);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1425 // BUG: would like to remove white flash when window kicks in
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1426 //{
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1427 // Rect r;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1428 // SetRect (&r, 0, 0, SDL_VideoSurface->w, SDL_VideoSurface->h);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1429 // PaintRect (&r);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1430 // QDFlushPortBuffer (port, nil);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1431 //}
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1432
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1433 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1434 else {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1435 port = [ [ qz_window contentView ] qdPort ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1436 SetPort (port);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1437 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1438
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1439 SetIdentityMatrix (yuv_matrix);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1440
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1441 HLock ((Handle)yuv_idh);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1442
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1443 (**yuv_idh).idSize = sizeof(ImageDescription);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1444 (**yuv_idh).cType = codec;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1445 (**yuv_idh).version = 1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1446 (**yuv_idh).revisionLevel = 0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1447 (**yuv_idh).width = width;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1448 (**yuv_idh).height = height;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1449 (**yuv_idh).hRes = Long2Fix(72);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1450 (**yuv_idh).vRes = Long2Fix(72);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1451 (**yuv_idh).spatialQuality = codecLosslessQuality;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1452 (**yuv_idh).frameCount = 1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1453 (**yuv_idh).clutID = -1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1454 (**yuv_idh).dataSize = 0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1455 (**yuv_idh).depth = 12;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1456
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1457 HUnlock ((Handle)yuv_idh);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1458
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1459 err = DecompressSequenceBeginS (
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1460 &yuv_seq,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1461 yuv_idh,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1462 NULL,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1463 0,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1464 port,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1465 NULL,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1466 NULL,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1467 yuv_matrix,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1468 0,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1469 NULL,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1470 codecFlagUseImageBuffer,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1471 codecLosslessQuality,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1472 yuv_codec);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1473
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1474 if (err != noErr) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1475 SDL_SetError ("Error trying to start YUV codec.");
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1476 return NULL;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1477 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1478
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1479 overlay = (SDL_Overlay*) malloc (sizeof(*overlay));
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1480 if (overlay == NULL) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1481 SDL_OutOfMemory();
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1482 return NULL;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1483 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1484
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1485 overlay->format = format;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1486 overlay->w = width;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1487 overlay->h = height;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1488 overlay->planes = 3;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1489 overlay->hw_overlay = 1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1490 {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1491 int offset;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1492 Uint8 **pixels;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1493 Uint16 *pitches;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1494 int plane2, plane3;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1495
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1496 if (format == SDL_IYUV_OVERLAY) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1497
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1498 plane2 = 1; /* Native codec format */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1499 plane3 = 2;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1500 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1501 else if (format == SDL_YV12_OVERLAY) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1502
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1503 /* switch the U and V planes */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1504 plane2 = 2; /* U plane maps to plane 3 */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1505 plane3 = 1; /* V plane maps to plane 2 */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1506 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1507 else {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1508 SDL_SetError("Unsupported YUV format");
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1509 return NULL;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1510 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1511
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1512 pixels = (Uint8**) malloc (sizeof(*pixels) * 3);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1513 pitches = (Uint16*) malloc (sizeof(*pitches) * 3);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1514 if (pixels == NULL || pitches == NULL) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1515 SDL_OutOfMemory();
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1516 return NULL;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1517 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1518
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1519 yuv_pixmap = (PlanarPixmapInfoYUV420*)
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1520 malloc (sizeof(PlanarPixmapInfoYUV420) +
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1521 (width * height * 2));
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1522 if (yuv_pixmap == NULL) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1523 SDL_OutOfMemory ();
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1524 return NULL;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1525 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1526
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1527 //CHECK_ALIGN(yuv_pixmap);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1528 offset = sizeof(PlanarPixmapInfoYUV420);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1529 //offset += ALIGN(offset);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1530 //CHECK_ALIGN(offset);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1531
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1532 pixels[0] = (Uint8*)yuv_pixmap + offset;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1533 //CHECK_ALIGN(pixels[0]);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1534
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1535 pitches[0] = width;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1536 yuv_pixmap->componentInfoY.offset = offset;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1537 yuv_pixmap->componentInfoY.rowBytes = width;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1538
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1539 offset += width * height;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1540 pixels[plane2] = (Uint8*)yuv_pixmap + offset;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1541 pitches[plane2] = width / 2;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1542 yuv_pixmap->componentInfoCb.offset = offset;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1543 yuv_pixmap->componentInfoCb.rowBytes = width / 2;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1544
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1545 offset += (width * height / 4);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1546 pixels[plane3] = (Uint8*)yuv_pixmap + offset;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1547 pitches[plane3] = width / 2;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1548 yuv_pixmap->componentInfoCr.offset = offset;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1549 yuv_pixmap->componentInfoCr.rowBytes = width / 2;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1550
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1551 overlay->pixels = pixels;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1552 overlay->pitches = pitches;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1553 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1554
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1555 overlay->hwfuncs = malloc (sizeof(*overlay->hwfuncs));
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1556 if (overlay->hwfuncs == NULL) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1557 SDL_OutOfMemory();
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1558 return NULL;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1559 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1560
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1561 overlay->hwfuncs->Lock = QZ_LockYUV;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1562 overlay->hwfuncs->Unlock = QZ_UnlockYUV;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1563 overlay->hwfuncs->Display = QZ_DisplayYUV;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1564 overlay->hwfuncs->FreeHW = QZ_FreeHWYUV;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1565
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1566 yuv_width = overlay->w;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1567 yuv_height = overlay->h;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1568
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1569 return overlay;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1570 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 359
diff changeset
1571