Mercurial > sdl-ios-xcode
annotate src/video/quartz/SDL_QuartzVideo.m @ 555:2536446a92de
From: Darrell Walisser
Subject: Re: [SDL] OS X and power save
Here ya go. This works just fine. One might complain that it doesn't
generate the event until after wake as completed (there is about 5
seconds between the screen coming up and the expose event), but I think
that's OK.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 07 Dec 2002 06:48:49 +0000 |
parents | 74262d2647ca |
children | 37c31c12eb70 |
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 /* 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
|
26 #include "SDL_QuartzWM.m" |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
27 #include "SDL_QuartzEvents.m" |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
28 #include "SDL_QuartzWindow.m" |
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 /* 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
|
31 VideoBootStrap QZ_bootstrap = { |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
32 "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
|
33 }; |
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 functions */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
36 static int QZ_Available () { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
37 return 1; |
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 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
|
41 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
42 #pragma unused (device_index) |
47
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 SDL_VideoDevice *device; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
45 SDL_PrivateVideoData *hidden; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
46 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
47 device = (SDL_VideoDevice*) malloc (sizeof (*device) ); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
48 hidden = (SDL_PrivateVideoData*) malloc (sizeof (*hidden) ); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
49 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
50 if (device == NULL || hidden == NULL) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
51 SDL_OutOfMemory (); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
52 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
53 memset (device, 0, sizeof (*device) ); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
54 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
|
55 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
56 device->hidden = hidden; |
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 device->VideoInit = QZ_VideoInit; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
59 device->ListModes = QZ_ListModes; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
60 device->SetVideoMode = QZ_SetVideoMode; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
61 device->ToggleFullScreen = QZ_ToggleFullScreen; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
62 device->SetColors = QZ_SetColors; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
63 /* 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
|
64 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
|
65 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
66 device->LockHWSurface = QZ_LockHWSurface; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
67 device->UnlockHWSurface = QZ_UnlockHWSurface; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
68 device->FreeHWSurface = QZ_FreeHWSurface; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
69 /* device->FlipHWSurface = QZ_FlipHWSurface */; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
70 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
71 device->SetGamma = QZ_SetGamma; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
72 device->GetGamma = QZ_GetGamma; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
73 device->SetGammaRamp = QZ_SetGammaRamp; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
74 device->GetGammaRamp = QZ_GetGammaRamp; |
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->GL_GetProcAddress = QZ_GL_GetProcAddress; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
77 device->GL_GetAttribute = QZ_GL_GetAttribute; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
78 device->GL_MakeCurrent = QZ_GL_MakeCurrent; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
79 device->GL_SwapBuffers = QZ_GL_SwapBuffers; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
80 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
|
81 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
82 device->FreeWMCursor = QZ_FreeWMCursor; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
83 device->CreateWMCursor = QZ_CreateWMCursor; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
84 device->ShowWMCursor = QZ_ShowWMCursor; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
85 device->WarpWMCursor = QZ_WarpWMCursor; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
86 device->MoveWMCursor = QZ_MoveWMCursor; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
87 device->CheckMouseMode = QZ_CheckMouseMode; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
88 device->InitOSKeymap = QZ_InitOSKeymap; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
89 device->PumpEvents = QZ_PumpEvents; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
90 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
91 device->SetCaption = QZ_SetCaption; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
92 device->SetIcon = QZ_SetIcon; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
93 device->IconifyWindow = QZ_IconifyWindow; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
94 /*device->GetWMInfo = QZ_GetWMInfo;*/ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
95 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
|
96 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
97 device->CreateYUVOverlay = QZ_CreateYUVOverlay; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
98 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
99 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
|
100 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
101 return device; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
102 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
103 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
104 static void QZ_DeleteDevice (SDL_VideoDevice *device) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
105 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
106 free (device->hidden); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
107 free (device); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
108 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
109 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
110 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
|
111 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
112 /* 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
|
113 display_id = kCGDirectMainDisplay; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
114 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
|
115 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
|
116 palette = CGPaletteCreateDefaultColorPalette (); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
117 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
118 /* 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
|
119 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
|
120 kCFNumberSInt32Type, &device_bpp); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
121 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
122 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
|
123 kCFNumberSInt32Type, &device_width); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
124 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
125 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
|
126 kCFNumberSInt32Type, &device_height); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
127 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
128 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
|
129 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
130 /* Set misc globals */ |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
131 current_grab_mode = SDL_GRAB_OFF; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
132 in_foreground = YES; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
133 |
555 | 134 /* register for sleep notifications so wake from sleep generates SDL_VIDEOEXPOSE */ |
135 QZ_RegisterForSleepNotifications (this); | |
136 | |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
137 return 0; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
138 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
139 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
140 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
|
141 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
142 CFIndex num_modes; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
143 CFIndex i; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
144 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
145 int list_size = 0; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
146 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
147 /* Any windowed mode is acceptable */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
148 if ( (flags & SDL_FULLSCREEN) == 0 ) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
149 return (SDL_Rect**)-1; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
150 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
151 /* Free memory from previous call, if any */ |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
152 if ( client_mode_list != NULL ) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
153 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
154 int i; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
155 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
156 for (i = 0; client_mode_list[i] != NULL; i++) |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
157 free (client_mode_list[i]); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
158 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
159 free (client_mode_list); |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
160 client_mode_list = NULL; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
161 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
162 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
163 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
|
164 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
165 /* 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
|
166 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
|
167 |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
168 CFDictionaryRef onemode; |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
169 CFNumberRef number; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
170 int bpp; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
171 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
172 onemode = CFArrayGetValueAtIndex (mode_list, i); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
173 number = CFDictionaryGetValue (onemode, kCGDisplayBitsPerPixel); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
174 CFNumberGetValue (number, kCFNumberSInt32Type, &bpp); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
175 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
176 if (bpp == format->BitsPerPixel) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
177 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
178 int intvalue; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
179 int hasMode; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
180 int width, height; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
181 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
182 number = CFDictionaryGetValue (onemode, kCGDisplayWidth); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
183 CFNumberGetValue (number, kCFNumberSInt32Type, &intvalue); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
184 width = (Uint16) intvalue; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
185 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
186 number = CFDictionaryGetValue (onemode, kCGDisplayHeight); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
187 CFNumberGetValue (number, kCFNumberSInt32Type, &intvalue); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
188 height = (Uint16) intvalue; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
189 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
190 /* 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
|
191 { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
192 int i; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
193 hasMode = SDL_FALSE; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
194 for (i = 0; i < list_size; i++) { |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
195 if (client_mode_list[i]->w == width && |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
196 client_mode_list[i]->h == height) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
197 hasMode = SDL_TRUE; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
198 break; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
199 } |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
200 } |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
201 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
202 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
203 /* 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
|
204 if ( ! hasMode ) { |
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 SDL_Rect *rect; |
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 list_size++; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
209 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
210 if (client_mode_list == NULL) |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
211 client_mode_list = (SDL_Rect**) |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
212 malloc (sizeof(*client_mode_list) * (list_size+1) ); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
213 else |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
214 client_mode_list = (SDL_Rect**) |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
215 realloc (client_mode_list, sizeof(*client_mode_list) * (list_size+1)); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
216 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
217 rect = (SDL_Rect*) malloc (sizeof(**client_mode_list)); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
218 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
219 if (client_mode_list == NULL || rect == NULL) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
220 SDL_OutOfMemory (); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
221 return NULL; |
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 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
224 rect->w = width; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
225 rect->h = height; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
226 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
227 client_mode_list[list_size-1] = rect; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
228 client_mode_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
|
229 } |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
230 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
231 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
232 |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
233 /* 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
|
234 { |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
235 int i, j; |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
236 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
|
237 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
|
238 |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
239 int area1, area2; |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
240 area1 = client_mode_list[j]->w * client_mode_list[j]->h; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
241 area2 = client_mode_list[j+1]->w * client_mode_list[j+1]->h; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
242 |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
243 if (area1 < area2) { |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
244 SDL_Rect *tmp = client_mode_list[j]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
245 client_mode_list[j] = client_mode_list[j+1]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
246 client_mode_list[j+1] = tmp; |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
247 } |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
248 } |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
249 } |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
250 } |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
251 return client_mode_list; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
252 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
253 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
254 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
255 Gamma functions to try to hide the flash from a rez switch |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
256 Fade the display from normal to black |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
257 Save gamma tables for fade back to normal |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
258 */ |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
259 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
|
260 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
261 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
|
262 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
|
263 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
|
264 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
265 float percent; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
266 int j; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
267 int actual; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
268 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
269 if ( (CGDisplayNoErr != CGGetDisplayTransferByTable |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
270 (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
|
271 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
|
272 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
|
273 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
274 return 1; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
275 } |
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 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
|
278 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
|
279 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
|
280 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
281 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
|
282 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
283 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
|
284 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
285 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
|
286 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
|
287 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
|
288 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
289 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
290 if (CGDisplayNoErr != CGSetDisplayTransferByTable |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
291 (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
|
292 redTable, greenTable, blueTable)) { |
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 CGDisplayRestoreColorSyncSettings(); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
295 return 1; |
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 SDL_Delay (10); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
299 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
300 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
301 return 0; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
302 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
303 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
304 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
305 Fade the display from black to normal |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
306 Restore previously saved gamma values |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
307 */ |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
308 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
|
309 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
310 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
|
311 greenTable[QZ_GAMMA_TABLE_SIZE], |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
312 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
|
313 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
314 float percent; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
315 int 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 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
|
318 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
|
319 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
|
320 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
321 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
|
322 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
323 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
|
324 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
325 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
|
326 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
|
327 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
|
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 if (CGDisplayNoErr != CGSetDisplayTransferByTable |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
331 (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
|
332 redTable, greenTable, blueTable)) { |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
333 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
334 CGDisplayRestoreColorSyncSettings(); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
335 return 1; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
336 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
337 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
338 SDL_Delay (10); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
339 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
340 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
341 return 0; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
342 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
343 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
344 static void QZ_UnsetVideoMode (_THIS) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
345 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
346 /* Reset values that may change between switches */ |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
347 this->info.blit_fill = 0; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
348 this->FillHWRect = NULL; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
349 this->UpdateRects = NULL; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
350 this->LockHWSurface = NULL; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
351 this->UnlockHWSurface = NULL; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
352 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
353 /* Release fullscreen resources */ |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
354 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
|
355 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
356 SDL_QuartzGammaTable gamma_table; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
357 int gamma_error; |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
358 NSRect screen_rect; |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
359 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
360 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
|
361 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
362 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
363 Release the OpenGL context |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
364 Do this first to avoid trash on the display before fade |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
365 */ |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
366 if ( mode_flags & SDL_OPENGL ) { |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
367 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
368 QZ_TearDownOpenGL (this); |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
369 CGLSetFullScreen (NULL); |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
370 } |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
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 /* Restore original screen resolution/bpp */ |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
373 CGDisplaySwitchToMode (display_id, save_mode); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
374 CGDisplayRelease (display_id); |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
375 ShowMenuBar (); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
376 |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
377 /* |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
378 Reset the main screen's rectangle |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
379 See comment in QZ_SetVideoFullscreen for why we do this |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
380 */ |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
381 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
|
382 [ [ NSScreen mainScreen ] setFrame:screen_rect ]; |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
383 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
384 if (! gamma_error) |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
385 QZ_FadeGammaIn (this, &gamma_table); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
386 } |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
387 /* Release window mode resources */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
388 else { |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
389 |
158
4382c38dfbee
Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
155
diff
changeset
|
390 [ qz_window close ]; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
391 [ qz_window release ]; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
392 qz_window = nil; |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
393 window_view = nil; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
394 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
395 /* Release the OpenGL context */ |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
396 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
|
397 QZ_TearDownOpenGL (this); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
398 } |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
399 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
400 /* Restore gamma settings */ |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
401 CGDisplayRestoreColorSyncSettings (); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
402 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
403 /* 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
|
404 CGDisplayShowCursor (display_id); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
405 CGAssociateMouseAndMouseCursorPosition (1); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
406 |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
407 /* Signal successful teardown */ |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
408 video_set = SDL_FALSE; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
409 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
410 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
411 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
|
412 int height, int bpp, Uint32 flags) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
413 int exact_match; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
414 int gamma_error; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
415 SDL_QuartzGammaTable gamma_table; |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
416 NSRect screen_rect; |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
417 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
418 /* Destroy any previous mode */ |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
419 if (video_set == SDL_TRUE) |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
420 QZ_UnsetVideoMode (this); |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
421 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
422 /* 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
|
423 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
|
424 height, &exact_match); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
425 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
426 /* 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
|
427 if ( ! exact_match ) { |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
428 SDL_SetError ("Failed to find display resolution: %dx%dx%d", width, height, bpp); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
429 goto ERR_NO_MATCH; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
430 } |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
431 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
432 /* 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
|
433 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
|
434 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
435 /* 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
|
436 if ( CGDisplayNoErr != CGDisplayCapture (display_id) ) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
437 SDL_SetError ("Failed capturing display"); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
438 goto ERR_NO_CAPTURE; |
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 /* Do the physical switch */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
442 if ( CGDisplayNoErr != CGDisplaySwitchToMode (display_id, mode) ) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
443 SDL_SetError ("Failed switching display resolution"); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
444 goto ERR_NO_SWITCH; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
445 } |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
446 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
447 current->pixels = (Uint32*) CGDisplayBaseAddress (display_id); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
448 current->pitch = CGDisplayBytesPerRow (display_id); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
449 |
58
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
56
diff
changeset
|
450 current->flags = 0; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
451 current->w = width; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
452 current->h = height; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
453 current->flags |= SDL_FULLSCREEN; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
454 current->flags |= SDL_HWSURFACE; |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
455 current->flags |= SDL_PREALLOC; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
456 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
457 this->UpdateRects = QZ_DirectUpdate; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
458 this->LockHWSurface = QZ_LockHWSurface; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
459 this->UnlockHWSurface = QZ_UnlockHWSurface; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
460 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
461 /* Setup some mode-dependant info */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
462 if ( CGSDisplayCanHWFill (display_id) ) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
463 this->info.blit_fill = 1; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
464 this->FillHWRect = QZ_FillHWRect; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
465 } |
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 ( CGDisplayCanSetPalette (display_id) ) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
468 current->flags |= SDL_HWPALETTE; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
469 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
470 /* Setup OpenGL for a fullscreen context */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
471 if (flags & SDL_OPENGL) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
472 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
473 CGLError err; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
474 CGLContextObj ctx; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
475 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
476 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
|
477 goto ERR_NO_GL; |
47
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 ctx = [ gl_context cglContext ]; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
481 err = CGLSetFullScreen (ctx); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
482 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
483 if (err) { |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
484 SDL_SetError ("Error setting OpenGL fullscreen: %s", CGLErrorString(err)); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
485 goto ERR_NO_GL; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
486 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
487 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
488 [ gl_context makeCurrentContext]; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
489 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
490 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
|
491 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
492 [ gl_context flushBuffer ]; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
493 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
494 current->flags |= SDL_OPENGL; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
495 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
496 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
497 /* 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
|
498 HideMenuBar (); |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
499 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
500 /* 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
|
501 if (! gamma_error ) |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
502 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
|
503 |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
504 /* |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
505 There is a bug in Cocoa where NSScreen doesn't synchronize |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
506 with CGDirectDisplay, so the main screen's frame is wrong. |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
507 As a result, coordinate translation produces incorrect results. |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
508 We can hack around this bug by setting the screen rect |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
509 ourselves. This hack should be removed if/when the bug is fixed. |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
510 */ |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
511 screen_rect = NSMakeRect(0,0,width,height); |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
512 [ [ NSScreen mainScreen ] setFrame:screen_rect ]; |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
513 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
514 /* 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
|
515 mode_flags = current->flags; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
516 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
517 return current; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
518 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
519 /* 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
|
520 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
|
521 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
|
522 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
|
523 ERR_NO_MATCH: return NULL; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
524 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
525 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
526 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
|
527 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
|
528 unsigned int style; |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
529 NSRect contentRect; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
530 |
58
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
56
diff
changeset
|
531 current->flags = 0; |
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
56
diff
changeset
|
532 current->w = width; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
533 current->h = height; |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
534 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
535 contentRect = NSMakeRect (0, 0, width, height); |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
536 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
537 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
538 Check if we should completely destroy the previous mode |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
539 - If it is fullscreen |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
540 - If it has different noframe or resizable attribute |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
541 - If it is OpenGL (since gl attributes could be different) |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
542 - If new mode is OpenGL, but previous mode wasn't |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
543 */ |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
544 if (video_set == SDL_TRUE) |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
545 if ( (mode_flags & SDL_FULLSCREEN) || |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
546 ((mode_flags ^ flags) & (SDL_NOFRAME|SDL_RESIZABLE)) || |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
547 (mode_flags & SDL_OPENGL) || |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
548 (flags & SDL_OPENGL) ) |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
549 QZ_UnsetVideoMode (this); |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
550 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
551 /* Check if we should recreate the window */ |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
552 if (qz_window == nil) { |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
553 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
554 /* Set the window style based on input flags */ |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
555 if ( flags & SDL_NOFRAME ) { |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
556 style = NSBorderlessWindowMask; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
557 current->flags |= SDL_NOFRAME; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
558 } else { |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
559 style = NSTitledWindowMask; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
560 style |= (NSMiniaturizableWindowMask | NSClosableWindowMask); |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
561 if ( flags & SDL_RESIZABLE ) { |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
562 style |= NSResizableWindowMask; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
563 current->flags |= SDL_RESIZABLE; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
564 } |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
565 } |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
566 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
567 /* Manually create a window, avoids having a nib file resource */ |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
568 qz_window = [ [ SDL_QuartzWindow alloc ] |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
569 initWithContentRect:contentRect |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
570 styleMask:style |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
571 backing:NSBackingStoreBuffered |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
572 defer:NO ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
573 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
574 if (qz_window == nil) { |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
575 SDL_SetError ("Could not create the Cocoa window"); |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
576 return NULL; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
577 } |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
578 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
579 [ qz_window setReleasedWhenClosed:YES ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
580 QZ_SetCaption(this, this->wm_title, this->wm_icon); |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
581 [ qz_window setAcceptsMouseMovedEvents:YES ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
582 [ qz_window setViewsNeedDisplay:NO ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
583 [ qz_window center ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
584 [ qz_window setDelegate: |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
585 [ [ [ SDL_QuartzWindowDelegate alloc ] init ] autorelease ] ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
586 } |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
587 /* We already have a window, just change its size */ |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
588 else { |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
589 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
590 [ qz_window setContentSize:contentRect.size ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
591 current->flags |= (SDL_NOFRAME|SDL_RESIZABLE) & mode_flags; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
592 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
593 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
594 /* For OpenGL, we bind the context to a subview */ |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
595 if ( flags & SDL_OPENGL ) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
596 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
597 if ( ! QZ_SetupOpenGL (this, bpp, flags) ) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
598 return NULL; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
599 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
600 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
601 window_view = [ [ NSView alloc ] initWithFrame:contentRect ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
602 [ window_view setAutoresizingMask: NSViewMinYMargin ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
603 [ [ qz_window contentView ] addSubview:window_view ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
604 [ gl_context setView: window_view ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
605 [ window_view release ]; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
606 [ gl_context makeCurrentContext]; |
158
4382c38dfbee
Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
155
diff
changeset
|
607 [ qz_window makeKeyAndOrderFront:nil ]; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
608 current->flags |= SDL_OPENGL; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
609 } |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
610 /* For 2D, we set the subview to an NSQuickDrawView */ |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
611 else { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
612 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
613 /* Only recreate the view if it doesn't already exist */ |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
614 if (window_view == nil) { |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
615 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
616 window_view = [ [ SDL_QuartzWindowView alloc ] initWithFrame:contentRect ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
617 [ window_view setAutoresizingMask: NSViewMinYMargin ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
618 [ [ qz_window contentView ] addSubview:window_view ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
619 [ window_view release ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
620 [ qz_window makeKeyAndOrderFront:nil ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
621 } |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
622 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
623 LockPortBits ( [ window_view qdPort ] ); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
624 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
|
625 current->pitch = GetPixRowBytes ( GetPortPixMap ( [ window_view qdPort ] ) ); |
498
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
626 UnlockPortBits ( [ window_view qdPort ] ); |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
627 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
628 current->flags |= SDL_SWSURFACE; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
629 current->flags |= SDL_PREALLOC; |
498
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
630 current->flags |= SDL_ASYNCBLIT; |
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
631 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
632 /* Offset below the title bar to fill the full content region */ |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
633 current->pixels += ((int)([ qz_window frame ].size.height) - height) * current->pitch; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
634 |
498
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
635 this->UpdateRects = QZ_UpdateRects; |
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
636 this->LockHWSurface = QZ_LockWindow; |
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
637 this->UnlockHWSurface = QZ_UnlockWindow; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
638 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
639 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
640 /* 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
|
641 mode_flags = current->flags; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
642 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
643 return current; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
644 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
645 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
646 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
|
647 int height, int bpp, Uint32 flags) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
648 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
649 current->flags = 0; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
650 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
651 /* Setup full screen video */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
652 if ( flags & SDL_FULLSCREEN ) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
653 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
|
654 if (current == NULL) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
655 return NULL; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
656 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
657 /* Setup windowed video */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
658 else { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
659 /* 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
|
660 bpp = device_bpp; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
661 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
|
662 if (current == NULL) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
663 return NULL; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
664 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
665 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
666 /* Setup the new pixel format */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
667 { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
668 int amask = 0, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
669 rmask = 0, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
670 gmask = 0, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
671 bmask = 0; |
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 switch (bpp) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
674 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
|
675 amask = 0; |
58
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
56
diff
changeset
|
676 rmask = 0x7C00; |
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
56
diff
changeset
|
677 gmask = 0x03E0; |
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
56
diff
changeset
|
678 bmask = 0x001F; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
679 break; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
680 case 24: |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
681 SDL_SetError ("24bpp is not available"); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
682 return NULL; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
683 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
|
684 amask = 0x00000000; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
685 rmask = 0x00FF0000; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
686 gmask = 0x0000FF00; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
687 bmask = 0x000000FF; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
688 break; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
689 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
690 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
691 if ( ! SDL_ReallocFormat (current, bpp, |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
692 rmask, gmask, bmask, amask ) ) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
693 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
|
694 return NULL; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
695 } |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
696 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
697 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
698 /* 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
|
699 video_set = SDL_TRUE; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
700 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
701 return current; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
702 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
703 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
704 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
|
705 return -1; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
706 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
707 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
708 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
|
709 SDL_Color *colors) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
710 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
711 CGTableCount index; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
712 CGDeviceColor color; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
713 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
714 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
|
715 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
716 /* 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
|
717 color.red = colors->r / 255.0; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
718 color.blue = colors->b / 255.0; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
719 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
|
720 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
721 colors++; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
722 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
723 CGPaletteSetColorAtIndex (palette, color, index); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
724 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
725 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
726 if ( CGDisplayNoErr != CGDisplaySetPalette (display_id, palette) ) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
727 return 0; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
728 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
729 return 1; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
730 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
731 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
732 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
|
733 #pragma unused(this,num_rects,rects) |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
734 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
735 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
736 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
737 The obscured code is based on work by Matt Slot fprefect@ambrosiasw.com, |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
738 who supplied sample code for Carbon. |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
739 */ |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
740 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
|
741 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
742 //#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
|
743 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
744 #if TEST_OBSCURED |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
745 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
746 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
747 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
|
748 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
|
749 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
|
750 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
|
751 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
|
752 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
|
753 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
|
754 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
755 Notes: |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
756 -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
|
757 -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
|
758 -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
|
759 -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
|
760 -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
|
761 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
762 Bugs: |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
763 -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
|
764 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
|
765 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
|
766 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
767 -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
|
768 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
|
769 */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
770 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
771 /* 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
|
772 static CGSConnectionID cgsConnection = (CGSConnectionID) -1; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
773 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
774 /* 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
|
775 static CGSWindowID dockIcons[kMaxWindows]; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
776 static int numCachedDockIcons = 0; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
777 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
778 CGSWindowID windows[kMaxWindows]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
779 CGSWindowCount i, count; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
780 CGSWindowLevel winLevel; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
781 CGSRect winRect; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
782 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
783 CGSRect contentRect; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
784 int windowNumber; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
785 //int isMainWindow; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
786 int firstDockIcon; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
787 int dockIconCacheMiss; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
788 int windowContentOffset; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
789 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
790 int obscured = SDL_TRUE; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
791 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
792 if ( [ window isVisible ] ) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
793 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
794 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
795 walk the window list looking for windows over top of |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
796 (or casting a shadow on) ours |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
797 */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
798 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
799 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
800 Get a connection to the window server |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
801 Should probably be moved out into SetVideoMode() or InitVideo() |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
802 */ |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
803 if (cgsConnection == (CGSConnectionID) -1) { |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
804 cgsConnection = (CGSConnectionID) 0; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
805 cgsConnection = _CGSDefaultConnection (); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
806 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
807 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
808 if (cgsConnection) { |
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 ( ! [ window styleMask ] & NSBorderlessWindowMask ) |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
811 windowContentOffset = 22; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
812 else |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
813 windowContentOffset = 0; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
814 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
815 windowNumber = [ window windowNumber ]; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
816 //isMainWindow = [ window isMainWindow ]; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
817 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
818 /* 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
|
819 count = 0; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
820 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
|
821 CGSGetScreenRectForWindow (cgsConnection, windowNumber, &contentRect); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
822 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
823 /* 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
|
824 contentRect.origin.y += windowContentOffset; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
825 contentRect.size.height -= windowContentOffset; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
826 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
827 firstDockIcon = -1; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
828 dockIconCacheMiss = SDL_FALSE; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
829 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
830 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
831 The first window is always an empty window with level kCGSWindowLevelTop |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
832 so start at index 1 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
833 */ |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
834 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
|
835 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
836 /* 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
|
837 if (windows[i] == windowNumber) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
838 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
839 obscured = SDL_FALSE; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
840 break; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
841 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
842 else { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
843 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
844 float shadowSide; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
845 float shadowTop; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
846 float shadowBottom; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
847 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
848 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
|
849 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
850 if (winLevel == kCGSWindowLevelDockIcon) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
851 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
852 int j; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
853 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
854 if (firstDockIcon < 0) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
855 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
856 firstDockIcon = i; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
857 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
858 if (numCachedDockIcons > 0) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
859 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
860 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
|
861 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
862 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
|
863 i++; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
864 else |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
865 break; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
866 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
867 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
868 if (j != 0) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
869 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
870 i--; |
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 if (j < numCachedDockIcons) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
873 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
874 dockIconCacheMiss = SDL_TRUE; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
875 } |
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 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
878 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
879 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
880 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
881 continue; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
882 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
883 else if (winLevel == kCGSWindowLevelMenuIgnore |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
884 /* winLevel == kCGSWindowLevelTop */) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
885 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
886 continue; /* cannot obscure window */ |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
887 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
888 else if (winLevel == kCGSWindowLevelDockMenu || |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
889 winLevel == kCGSWindowLevelMenu) { |
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 shadowSide = 18; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
892 shadowTop = 4; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
893 shadowBottom = 22; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
894 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
895 else if (winLevel == kCGSWindowLevelUtility) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
896 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
897 shadowSide = 8; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
898 shadowTop = 4; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
899 shadowBottom = 12; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
900 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
901 else if (winLevel == kCGSWindowLevelNormal) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
902 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
903 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
904 These numbers are for foreground windows, |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
905 they are too big (but will work) for background windows |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
906 */ |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
907 shadowSide = 20; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
908 shadowTop = 10; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
909 shadowBottom = 24; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
910 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
911 else if (winLevel == kCGSWindowLevelDock) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
912 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
913 /* Create dock icon cache */ |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
914 if (numCachedDockIcons != (i-firstDockIcon) || |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
915 dockIconCacheMiss) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
916 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
917 numCachedDockIcons = i - firstDockIcon; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
918 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
|
919 numCachedDockIcons * sizeof(*windows)); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
920 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
921 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
922 /* no shadow */ |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
923 shadowSide = 0; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
924 shadowTop = 0; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
925 shadowBottom = 0; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
926 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
927 else { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
928 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
929 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
930 kCGSWindowLevelDockLabel, |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
931 kCGSWindowLevelDock, |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
932 kOther??? |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
933 */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
934 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
935 /* no shadow */ |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
936 shadowSide = 0; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
937 shadowTop = 0; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
938 shadowBottom = 0; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
939 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
940 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
941 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
|
942 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
943 winRect.origin.x -= shadowSide; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
944 winRect.origin.y -= shadowTop; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
945 winRect.size.width += shadowSide; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
946 winRect.size.height += shadowBottom; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
947 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
948 if (NSIntersectsRect (contentRect, winRect)) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
949 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
950 obscured = SDL_TRUE; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
951 break; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
952 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
953 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
954 } /* window was not our window */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
955 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
956 } /* iterate over windows */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
957 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
958 } /* get cgsConnection */ |
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 } /* window is visible */ |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
961 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
962 return obscured; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
963 #else |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
964 return SDL_TRUE; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
965 #endif |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
966 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
967 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
968 |
498
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
969 /* Locking functions for the software window buffer */ |
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
970 static int QZ_LockWindow (_THIS, SDL_Surface *surface) { |
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
971 |
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
972 return LockPortBits ( [ window_view qdPort ] ); |
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
973 } |
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
974 |
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
975 static void QZ_UnlockWindow (_THIS, SDL_Surface *surface) { |
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
976 |
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
977 UnlockPortBits ( [ window_view qdPort ] ); |
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
978 } |
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
979 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
980 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
|
981 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
982 if (SDL_VideoSurface->flags & SDL_OPENGLBLIT) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
983 QZ_GL_SwapBuffers (this); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
984 } |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
985 else if ( [ qz_window isMiniaturized ] ) { |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
986 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
987 /* Do nothing if miniaturized */ |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
988 } |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
989 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
990 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
|
991 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
992 /* 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
|
993 CGrafPtr savePort; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
994 CGrafPtr dstPort, srcPort; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
995 const BitMap *dstBits, *srcBits; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
996 Rect dstRect, srcRect; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
997 Point offset; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
998 int i; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
999 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1000 GetPort (&savePort); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1001 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1002 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
|
1003 srcPort = [ window_view qdPort ]; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1004 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1005 offset.h = 0; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1006 offset.v = 0; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1007 SetPort (srcPort); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1008 LocalToGlobal (&offset); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1009 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1010 SetPort (dstPort); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1011 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1012 LockPortBits (dstPort); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1013 LockPortBits (srcPort); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1014 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1015 dstBits = GetPortBitMapForCopyBits (dstPort); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1016 srcBits = GetPortBitMapForCopyBits (srcPort); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1017 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1018 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
|
1019 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1020 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
|
1021 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
|
1022 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
|
1023 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1024 SetRect (&dstRect, |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1025 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
|
1026 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
|
1027 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
|
1028 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
|
1029 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1030 CopyBits (srcBits, dstBits, |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1031 &srcRect, &dstRect, srcCopy, NULL); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1032 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1033 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1034 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1035 SetPort (savePort); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1036 } |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1037 else { |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1038 /* 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
|
1039 int i; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1040 RgnHandle dirty = NewRgn (); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1041 RgnHandle temp = NewRgn (); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1042 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1043 SetEmptyRgn (dirty); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1044 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1045 /* Build the region of dirty rectangles */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1046 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
|
1047 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1048 MacSetRectRgn (temp, rects[i].x, rects[i].y, |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1049 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
|
1050 MacUnionRgn (dirty, temp, dirty); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1051 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1052 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1053 QZ_DrawResizeIcon (this, dirty); |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1054 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1055 /* 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
|
1056 QDFlushPortBuffer ( [ window_view qdPort ], dirty ); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1057 DisposeRgn (dirty); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1058 DisposeRgn (temp); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1059 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1060 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1061 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1062 static void QZ_VideoQuit (_THIS) { |
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 QZ_UnsetVideoMode (this); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1065 CGPaletteRelease (palette); |
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 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1068 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
|
1069 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1070 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
|
1071 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1072 return 0; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1073 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1074 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1075 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
|
1076 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1077 return 1; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1078 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1079 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1080 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
|
1081 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1082 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1083 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1084 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
|
1085 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1086 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1087 /* |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1088 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
|
1089 return 0; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1090 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1091 */ |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1092 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1093 /* Gamma functions */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1094 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
|
1095 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1096 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
|
1097 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1098 if (red == 0.0) |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1099 red = FLT_MAX; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1100 else |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1101 red = 1.0 / red; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1102 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1103 if (green == 0.0) |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1104 green = FLT_MAX; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1105 else |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1106 green = 1.0 / green; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1107 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1108 if (blue == 0.0) |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1109 blue = FLT_MAX; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1110 else |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1111 blue = 1.0 / blue; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1112 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1113 if ( CGDisplayNoErr == CGSetDisplayTransferByFormula |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1114 (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
|
1115 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1116 return 0; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1117 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1118 else { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1119 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1120 return -1; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1121 } |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1122 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1123 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1124 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
|
1125 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1126 CGGammaValue dummy; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1127 if ( CGDisplayNoErr == CGGetDisplayTransferByFormula |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1128 (display_id, &dummy, &dummy, red, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1129 &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
|
1130 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1131 return 0; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1132 else |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1133 return -1; |
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 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1136 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
|
1137 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1138 const CGTableCount tableSize = 255; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1139 CGGammaValue redTable[tableSize]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1140 CGGammaValue greenTable[tableSize]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1141 CGGammaValue blueTable[tableSize]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1142 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1143 int i; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1144 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1145 /* 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
|
1146 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
|
1147 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
|
1148 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1149 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
|
1150 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
|
1151 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1152 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
|
1153 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
|
1154 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1155 if ( CGDisplayNoErr == CGSetDisplayTransferByTable |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1156 (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
|
1157 return 0; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1158 else |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1159 return -1; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1160 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1161 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1162 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
|
1163 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1164 const CGTableCount tableSize = 255; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1165 CGGammaValue redTable[tableSize]; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1166 CGGammaValue greenTable[tableSize]; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1167 CGGammaValue blueTable[tableSize]; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1168 CGTableCount actual; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1169 int i; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1170 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1171 if ( CGDisplayNoErr != CGGetDisplayTransferByTable |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1172 (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
|
1173 actual != tableSize) |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1174 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1175 return -1; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1176 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1177 /* 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
|
1178 for (i = 0; i < 256; i++) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1179 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
|
1180 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1181 for (i=256; i < 512; i++) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1182 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
|
1183 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1184 for (i=512; i < 768; i++) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1185 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
|
1186 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1187 return 0; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1188 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1189 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1190 /* 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
|
1191 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1192 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
|
1193 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1194 NSOpenGLPixelFormatAttribute attr[32]; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1195 NSOpenGLPixelFormat *fmt; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1196 int i = 0; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1197 int colorBits = bpp; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1198 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1199 if ( flags & SDL_FULLSCREEN ) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1200 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1201 attr[i++] = NSOpenGLPFAFullScreen; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1202 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1203 /* 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
|
1204 else if ( colorBits != device_bpp ) { |
47
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 colorBits = device_bpp; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1207 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1208 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1209 attr[i++] = NSOpenGLPFAColorSize; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1210 attr[i++] = colorBits; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1211 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1212 attr[i++] = NSOpenGLPFADepthSize; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1213 attr[i++] = this->gl_config.depth_size; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1214 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1215 if ( this->gl_config.double_buffer ) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1216 attr[i++] = NSOpenGLPFADoubleBuffer; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1217 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1218 |
450
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
435
diff
changeset
|
1219 if ( this->gl_config.stereo ) { |
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
435
diff
changeset
|
1220 attr[i++] = NSOpenGLPFAStereo; |
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
435
diff
changeset
|
1221 } |
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
435
diff
changeset
|
1222 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1223 if ( this->gl_config.stencil_size != 0 ) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1224 attr[i++] = NSOpenGLPFAStencilSize; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1225 attr[i++] = this->gl_config.stencil_size; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1226 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1227 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1228 attr[i++] = NSOpenGLPFAScreenMask; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1229 attr[i++] = CGDisplayIDToOpenGLDisplayMask (display_id); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1230 attr[i] = 0; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1231 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1232 fmt = [ [ NSOpenGLPixelFormat alloc ] initWithAttributes:attr ]; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1233 if (fmt == nil) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1234 SDL_SetError ("Failed creating OpenGL pixel format"); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1235 return 0; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1236 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1237 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1238 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
|
1239 shareContext:nil]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1240 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1241 if (gl_context == nil) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1242 SDL_SetError ("Failed creating OpenGL context"); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1243 return 0; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1244 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1245 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1246 /* 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
|
1247 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
|
1248 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1249 [ fmt release ]; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1250 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1251 return 1; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1252 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1253 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1254 static void QZ_TearDownOpenGL (_THIS) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1255 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1256 [ NSOpenGLContext clearCurrentContext ]; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1257 [ gl_context clearDrawable ]; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1258 [ gl_context release ]; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1259 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1260 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1261 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1262 /* SDL OpenGL functions */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1263 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1264 static int QZ_GL_LoadLibrary (_THIS, const char *location) { |
197
ef78524e5f59
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
172
diff
changeset
|
1265 this->gl_config.driver_loaded = 1; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1266 return 1; |
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 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1269 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
|
1270 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1271 /* 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
|
1272 CFBundleRef bundle; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1273 CFURLRef bundleURL = CFURLCreateWithFileSystemPath (kCFAllocatorDefault, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1274 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
|
1275 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1276 CFStringRef functionName = CFStringCreateWithCString |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1277 (kCFAllocatorDefault, proc, kCFStringEncodingASCII); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1278 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1279 void *function; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1280 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1281 bundle = CFBundleCreate (kCFAllocatorDefault, bundleURL); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1282 assert (bundle != NULL); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1283 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1284 function = CFBundleGetFunctionPointerForName (bundle, functionName); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1285 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1286 CFRelease ( bundleURL ); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1287 CFRelease ( functionName ); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1288 CFRelease ( bundle ); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1289 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1290 return function; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1291 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1292 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1293 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
|
1294 |
347 | 1295 GLenum attr = 0; |
308
ee32ed29a507
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1296 |
ee32ed29a507
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1297 QZ_GL_MakeCurrent (this); |
ee32ed29a507
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1298 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1299 switch (attrib) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1300 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
|
1301 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
|
1302 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
|
1303 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
|
1304 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
|
1305 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
|
1306 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
|
1307 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
|
1308 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
|
1309 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
|
1310 case SDL_GL_ACCUM_ALPHA_SIZE: attr = GL_ACCUM_ALPHA_BITS; break; |
450
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
435
diff
changeset
|
1311 case SDL_GL_STEREO: attr = GL_STEREO; break; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1312 case SDL_GL_BUFFER_SIZE: |
308
ee32ed29a507
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1313 { |
ee32ed29a507
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1314 GLint bits = 0; |
ee32ed29a507
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1315 GLint component; |
ee32ed29a507
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1316 |
ee32ed29a507
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1317 /* 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
|
1318 glGetIntegerv (GL_RED_BITS, &component); bits += component; |
ee32ed29a507
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1319 glGetIntegerv (GL_GREEN_BITS,&component); bits += component; |
ee32ed29a507
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1320 glGetIntegerv (GL_BLUE_BITS, &component); bits += component; |
ee32ed29a507
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1321 glGetIntegerv (GL_ALPHA_BITS, &component); bits += component; |
ee32ed29a507
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1322 |
ee32ed29a507
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1323 *value = bits; |
ee32ed29a507
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1324 } |
ee32ed29a507
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1325 return 0; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1326 } |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1327 |
324
f25f666d609a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
308
diff
changeset
|
1328 glGetIntegerv (attr, (GLint *)value); |
308
ee32ed29a507
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1329 return 0; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1330 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1331 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1332 static int QZ_GL_MakeCurrent (_THIS) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1333 [ gl_context makeCurrentContext ]; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1334 return 0; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1335 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1336 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1337 static void QZ_GL_SwapBuffers (_THIS) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1338 [ gl_context flushBuffer ]; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1339 } |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1340 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1341 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
|
1342 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1343 return 0; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1344 } |
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 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
|
1347 |
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 } |
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 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
|
1352 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1353 OSErr err; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1354 CodecFlags flags; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1355 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1356 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
|
1357 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1358 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
|
1359 return -1; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1360 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1361 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1362 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
|
1363 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1364 Fixed scale_x, scale_y; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1365 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1366 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
|
1367 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
|
1368 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1369 SetIdentityMatrix (yuv_matrix); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1370 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
|
1371 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1372 SetDSequenceMatrix (yuv_seq, yuv_matrix); |
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 yuv_width = dstrect->w; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1375 yuv_height = dstrect->h; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1376 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1377 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1378 if( ( err = DecompressSequenceFrameS( |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1379 yuv_seq, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1380 (void*)yuv_pixmap, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1381 sizeof (PlanarPixmapInfoYUV420), |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1382 codecFlagUseImageBuffer, &flags, nil ) != noErr ) ) |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1383 { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1384 SDL_SetError ("DecompressSequenceFrameS failed"); |
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 return err == noErr; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1388 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1389 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1390 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
|
1391 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1392 CDSequenceEnd (yuv_seq); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1393 ExitMovies(); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1394 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1395 free (overlay->hwfuncs); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1396 free (overlay->pitches); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1397 free (overlay->pixels); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1398 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1399 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
|
1400 [ qz_window close ]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1401 qz_window = nil; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1402 } |
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 free (yuv_matrix); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1405 DisposeHandle ((Handle)yuv_idh); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1406 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1407 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1408 #include "SDL_yuvfuncs.h" |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1409 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1410 /* check for 16 byte alignment, bail otherwise */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1411 #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
|
1412 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1413 /* align a byte offset, return how much to add to make it a multiple of 16 */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1414 #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
|
1415 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1416 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
|
1417 Uint32 format, SDL_Surface *display) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1418 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1419 Uint32 codec; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1420 OSStatus err; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1421 CGrafPtr port; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1422 SDL_Overlay *overlay; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1423 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1424 if (format == SDL_YV12_OVERLAY || |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1425 format == SDL_IYUV_OVERLAY) { |
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 codec = kYUV420CodecType; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1428 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1429 else { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1430 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
|
1431 return NULL; |
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 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
|
1435 if (yuv_idh == NULL) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1436 SDL_OutOfMemory(); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1437 return NULL; |
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 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1440 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
|
1441 if (yuv_matrix == NULL) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1442 SDL_OutOfMemory(); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1443 return NULL; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1444 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1445 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1446 if ( EnterMovies() != noErr ) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1447 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
|
1448 return NULL; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1449 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1450 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1451 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
|
1452 if (err != noErr) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1453 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
|
1454 return NULL; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1455 } |
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 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
|
1458 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1459 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1460 Acceleration requires a window to be present. |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1461 A CGrafPtr that points to the screen isn't good enough |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1462 */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1463 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
|
1464 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1465 qz_window = [ [ SDL_QuartzWindow alloc ] |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1466 initWithContentRect:content |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1467 styleMask:NSBorderlessWindowMask |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1468 backing:NSBackingStoreBuffered defer:NO ]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1469 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1470 if (qz_window == nil) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1471 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
|
1472 return NULL; |
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 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1475 [ 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
|
1476 [ qz_window setReleasedWhenClosed:YES ]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1477 [ qz_window center ]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1478 [ qz_window setAcceptsMouseMovedEvents:YES ]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1479 [ qz_window setLevel:CGShieldingWindowLevel() ]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1480 [ qz_window makeKeyAndOrderFront:nil ]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1481 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1482 port = [ [ qz_window contentView ] qdPort ]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1483 SetPort (port); |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1484 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1485 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1486 BUG: would like to remove white flash when window kicks in |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1487 { |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1488 Rect r; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1489 SetRect (&r, 0, 0, SDL_VideoSurface->w, SDL_VideoSurface->h); |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1490 PaintRect (&r); |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1491 QDFlushPortBuffer (port, nil); |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1492 } |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1493 */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1494 |
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 else { |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1497 port = [ window_view qdPort ]; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1498 SetPort (port); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1499 } |
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 SetIdentityMatrix (yuv_matrix); |
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 HLock ((Handle)yuv_idh); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1504 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1505 (**yuv_idh).idSize = sizeof(ImageDescription); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1506 (**yuv_idh).cType = codec; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1507 (**yuv_idh).version = 1; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1508 (**yuv_idh).revisionLevel = 0; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1509 (**yuv_idh).width = width; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1510 (**yuv_idh).height = height; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1511 (**yuv_idh).hRes = Long2Fix(72); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1512 (**yuv_idh).vRes = Long2Fix(72); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1513 (**yuv_idh).spatialQuality = codecLosslessQuality; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1514 (**yuv_idh).frameCount = 1; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1515 (**yuv_idh).clutID = -1; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1516 (**yuv_idh).dataSize = 0; |
500
c335456c421d
Fixed YUV overlay code for Quicktime 6
Sam Lantinga <slouken@libsdl.org>
parents:
498
diff
changeset
|
1517 (**yuv_idh).depth = 24; |
390
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 HUnlock ((Handle)yuv_idh); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1520 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1521 err = DecompressSequenceBeginS ( |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1522 &yuv_seq, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1523 yuv_idh, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1524 NULL, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1525 0, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1526 port, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1527 NULL, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1528 NULL, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1529 yuv_matrix, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1530 0, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1531 NULL, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1532 codecFlagUseImageBuffer, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1533 codecLosslessQuality, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1534 yuv_codec); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1535 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1536 if (err != noErr) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1537 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
|
1538 return NULL; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1539 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1540 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1541 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
|
1542 if (overlay == NULL) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1543 SDL_OutOfMemory(); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1544 return NULL; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1545 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1546 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1547 overlay->format = format; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1548 overlay->w = width; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1549 overlay->h = height; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1550 overlay->planes = 3; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1551 overlay->hw_overlay = 1; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1552 { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1553 int offset; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1554 Uint8 **pixels; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1555 Uint16 *pitches; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1556 int plane2, plane3; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1557 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1558 if (format == SDL_IYUV_OVERLAY) { |
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 plane2 = 1; /* Native codec format */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1561 plane3 = 2; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1562 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1563 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
|
1564 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1565 /* 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
|
1566 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
|
1567 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
|
1568 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1569 else { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1570 SDL_SetError("Unsupported YUV format"); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1571 return NULL; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1572 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1573 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1574 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
|
1575 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
|
1576 if (pixels == NULL || pitches == NULL) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1577 SDL_OutOfMemory(); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1578 return NULL; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1579 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1580 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1581 yuv_pixmap = (PlanarPixmapInfoYUV420*) |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1582 malloc (sizeof(PlanarPixmapInfoYUV420) + |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1583 (width * height * 2)); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1584 if (yuv_pixmap == NULL) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1585 SDL_OutOfMemory (); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1586 return NULL; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1587 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1588 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1589 /* CHECK_ALIGN(yuv_pixmap); */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1590 offset = sizeof(PlanarPixmapInfoYUV420); |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1591 /* offset += ALIGN(offset); */ |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1592 /* CHECK_ALIGN(offset); */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1593 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1594 pixels[0] = (Uint8*)yuv_pixmap + offset; |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1595 /* CHECK_ALIGN(pixels[0]); */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1596 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1597 pitches[0] = width; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1598 yuv_pixmap->componentInfoY.offset = offset; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1599 yuv_pixmap->componentInfoY.rowBytes = width; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1600 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1601 offset += width * height; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1602 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
|
1603 pitches[plane2] = width / 2; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1604 yuv_pixmap->componentInfoCb.offset = offset; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1605 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
|
1606 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1607 offset += (width * height / 4); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1608 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
|
1609 pitches[plane3] = width / 2; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1610 yuv_pixmap->componentInfoCr.offset = offset; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1611 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
|
1612 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1613 overlay->pixels = pixels; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1614 overlay->pitches = pitches; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1615 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1616 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1617 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
|
1618 if (overlay->hwfuncs == NULL) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1619 SDL_OutOfMemory(); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1620 return NULL; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1621 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1622 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1623 overlay->hwfuncs->Lock = QZ_LockYUV; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1624 overlay->hwfuncs->Unlock = QZ_UnlockYUV; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1625 overlay->hwfuncs->Display = QZ_DisplayYUV; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1626 overlay->hwfuncs->FreeHW = QZ_FreeHWYUV; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1627 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1628 yuv_width = overlay->w; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1629 yuv_height = overlay->h; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1630 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1631 return overlay; |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1632 } |