Mercurial > sdl-ios-xcode
annotate src/video/quartz/SDL_QuartzVideo.m @ 4230:2bb68bacdc54 SDL-1.2
Max correctly pointed out that this will cause unexpected change in application
behavior and conflict with binding ctrl-click in some existing applications.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 22 Sep 2009 02:25:59 +0000 |
parents | 976bc19f8f6b |
children | 1fc8c8a5ff00 |
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 |
4159 | 3 Copyright (C) 1997-2009 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 */ |
1403
376665398b25
Catch the C++ and Objective C sources too...
Sam Lantinga <slouken@libsdl.org>
parents:
1340
diff
changeset
|
22 #include "SDL_config.h" |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
23 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
24 #include "SDL_QuartzVideo.h" |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
25 #include "SDL_QuartzWindow.h" |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
26 |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
27 #ifdef __powerpc__ /* I'm gambling they fixed this by 10.4. --ryan. */ |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
28 /* |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
29 Add methods to get at private members of NSScreen. |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
30 Since there is a bug in Apple's screen switching code |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
31 that does not update this variable when switching |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
32 to fullscreen, we'll set it manually (but only for the |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
33 main screen). |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
34 */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
35 @interface NSScreen (NSScreenAccess) |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
36 - (void) setFrame:(NSRect)frame; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
37 @end |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
38 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
39 @implementation NSScreen (NSScreenAccess) |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
40 - (void) setFrame:(NSRect)frame; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
41 { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
42 _frame = frame; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
43 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
44 @end |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
45 static inline void QZ_SetFrame(NSScreen *nsscreen, NSRect frame) |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
46 { |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
47 [nsscreen setFrame:frame]; |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
48 } |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
49 #else |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
50 static inline void QZ_SetFrame(NSScreen *nsscreen, NSRect frame) |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
51 { |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
52 } |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
53 #endif |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
54 |
4123
9d90d7765fa7
Guillaume Borios fixed bug #508
Sam Lantinga <slouken@libsdl.org>
parents:
4090
diff
changeset
|
55 @interface SDLTranslatorResponder : NSTextView |
9d90d7765fa7
Guillaume Borios fixed bug #508
Sam Lantinga <slouken@libsdl.org>
parents:
4090
diff
changeset
|
56 { |
9d90d7765fa7
Guillaume Borios fixed bug #508
Sam Lantinga <slouken@libsdl.org>
parents:
4090
diff
changeset
|
57 } |
9d90d7765fa7
Guillaume Borios fixed bug #508
Sam Lantinga <slouken@libsdl.org>
parents:
4090
diff
changeset
|
58 - (void) doCommandBySelector:(SEL)myselector; |
9d90d7765fa7
Guillaume Borios fixed bug #508
Sam Lantinga <slouken@libsdl.org>
parents:
4090
diff
changeset
|
59 @end |
9d90d7765fa7
Guillaume Borios fixed bug #508
Sam Lantinga <slouken@libsdl.org>
parents:
4090
diff
changeset
|
60 |
9d90d7765fa7
Guillaume Borios fixed bug #508
Sam Lantinga <slouken@libsdl.org>
parents:
4090
diff
changeset
|
61 @implementation SDLTranslatorResponder |
9d90d7765fa7
Guillaume Borios fixed bug #508
Sam Lantinga <slouken@libsdl.org>
parents:
4090
diff
changeset
|
62 - (void) doCommandBySelector:(SEL) myselector {} |
9d90d7765fa7
Guillaume Borios fixed bug #508
Sam Lantinga <slouken@libsdl.org>
parents:
4090
diff
changeset
|
63 @end |
9d90d7765fa7
Guillaume Borios fixed bug #508
Sam Lantinga <slouken@libsdl.org>
parents:
4090
diff
changeset
|
64 |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
65 /* absent in 10.3.9. */ |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
66 CG_EXTERN CGImageRef CGBitmapContextCreateImage (CGContextRef); |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
67 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
68 /* Bootstrap functions */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
69 static int QZ_Available (); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
70 static SDL_VideoDevice* QZ_CreateDevice (int device_index); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
71 static void QZ_DeleteDevice (SDL_VideoDevice *device); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
72 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
73 /* Initialization, Query, Setup, and Redrawing functions */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
74 static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
75 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
76 static SDL_Rect** QZ_ListModes (_THIS, SDL_PixelFormat *format, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
77 Uint32 flags); |
1340
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
78 static void QZ_UnsetVideoMode (_THIS, BOOL to_desktop); |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
79 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
80 static SDL_Surface* QZ_SetVideoMode (_THIS, SDL_Surface *current, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
81 int width, int height, int bpp, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
82 Uint32 flags); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
83 static int QZ_ToggleFullScreen (_THIS, int on); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
84 static int QZ_SetColors (_THIS, int first_color, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
85 int num_colors, SDL_Color *colors); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
86 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
87 static int QZ_LockDoubleBuffer (_THIS, SDL_Surface *surface); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
88 static void QZ_UnlockDoubleBuffer (_THIS, SDL_Surface *surface); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
89 static int QZ_ThreadFlip (_THIS); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
90 static int QZ_FlipDoubleBuffer (_THIS, SDL_Surface *surface); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
91 static void QZ_DoubleBufferUpdate (_THIS, int num_rects, SDL_Rect *rects); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
92 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
93 static void QZ_DirectUpdate (_THIS, int num_rects, SDL_Rect *rects); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
94 static void QZ_UpdateRects (_THIS, int num_rects, SDL_Rect *rects); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
95 static void QZ_VideoQuit (_THIS); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
96 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
97 /* Hardware surface functions (for fullscreen mode only) */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
98 #if 0 /* Not used (apparently, it's really slow) */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
99 static int QZ_FillHWRect (_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
100 #endif |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
101 static int QZ_LockHWSurface(_THIS, SDL_Surface *surface); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
102 static void QZ_UnlockHWSurface(_THIS, SDL_Surface *surface); |
1120
8e1fde455471
Patch by me to fix crash described below.
Ryan C. Gordon <icculus@icculus.org>
parents:
1119
diff
changeset
|
103 static int QZ_AllocHWSurface(_THIS, SDL_Surface *surface); |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
104 static void QZ_FreeHWSurface (_THIS, SDL_Surface *surface); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
105 /* static int QZ_FlipHWSurface (_THIS, SDL_Surface *surface); */ |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
106 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
107 /* 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
|
108 VideoBootStrap QZ_bootstrap = { |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
109 "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
|
110 }; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
111 |
588
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
112 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
113 /* Bootstrap functions */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
114 static int QZ_Available () { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
115 return 1; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
116 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
117 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
118 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
|
119 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
120 #pragma unused (device_index) |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
121 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
122 SDL_VideoDevice *device; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
123 SDL_PrivateVideoData *hidden; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
124 |
1756
eed7a3f396ce
Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
125 device = (SDL_VideoDevice*) SDL_malloc (sizeof (*device) ); |
eed7a3f396ce
Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
126 hidden = (SDL_PrivateVideoData*) SDL_malloc (sizeof (*hidden) ); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
127 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
128 if (device == NULL || hidden == NULL) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
129 SDL_OutOfMemory (); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
130 |
1756
eed7a3f396ce
Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
131 SDL_memset (device, 0, sizeof (*device) ); |
eed7a3f396ce
Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
132 SDL_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
|
133 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
134 device->hidden = hidden; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
135 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
136 device->VideoInit = QZ_VideoInit; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
137 device->ListModes = QZ_ListModes; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
138 device->SetVideoMode = QZ_SetVideoMode; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
139 device->ToggleFullScreen = QZ_ToggleFullScreen; |
1212 | 140 device->UpdateMouse = QZ_UpdateMouse; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
141 device->SetColors = QZ_SetColors; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
142 /* 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
|
143 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
|
144 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
145 device->LockHWSurface = QZ_LockHWSurface; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
146 device->UnlockHWSurface = QZ_UnlockHWSurface; |
1120
8e1fde455471
Patch by me to fix crash described below.
Ryan C. Gordon <icculus@icculus.org>
parents:
1119
diff
changeset
|
147 device->AllocHWSurface = QZ_AllocHWSurface; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
148 device->FreeHWSurface = QZ_FreeHWSurface; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
149 /* device->FlipHWSurface = QZ_FlipHWSurface */; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
150 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
151 device->SetGamma = QZ_SetGamma; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
152 device->GetGamma = QZ_GetGamma; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
153 device->SetGammaRamp = QZ_SetGammaRamp; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
154 device->GetGammaRamp = QZ_GetGammaRamp; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
155 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
156 device->GL_GetProcAddress = QZ_GL_GetProcAddress; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
157 device->GL_GetAttribute = QZ_GL_GetAttribute; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
158 device->GL_MakeCurrent = QZ_GL_MakeCurrent; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
159 device->GL_SwapBuffers = QZ_GL_SwapBuffers; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
160 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
|
161 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
162 device->FreeWMCursor = QZ_FreeWMCursor; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
163 device->CreateWMCursor = QZ_CreateWMCursor; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
164 device->ShowWMCursor = QZ_ShowWMCursor; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
165 device->WarpWMCursor = QZ_WarpWMCursor; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
166 device->MoveWMCursor = QZ_MoveWMCursor; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
167 device->CheckMouseMode = QZ_CheckMouseMode; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
168 device->InitOSKeymap = QZ_InitOSKeymap; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
169 device->PumpEvents = QZ_PumpEvents; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
170 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
171 device->SetCaption = QZ_SetCaption; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
172 device->SetIcon = QZ_SetIcon; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
173 device->IconifyWindow = QZ_IconifyWindow; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
174 /*device->GetWMInfo = QZ_GetWMInfo;*/ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
175 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
|
176 |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
177 /* |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
178 * This is a big hassle, needing QuickDraw and QuickTime on older |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
179 * systems, and god knows what on 10.6, so we immediately fail here, |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
180 * which causes SDL to make an RGB surface and manage the YUV overlay |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
181 * in software. Sorry. Use SDL 1.3 if you want YUV rendering in a pixel |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
182 * shader. :) |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
183 */ |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
184 /*device->CreateYUVOverlay = QZ_CreateYUVOverlay;*/ |
390
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 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
|
187 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
188 return device; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
189 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
190 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
191 static void QZ_DeleteDevice (SDL_VideoDevice *device) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
192 |
1756
eed7a3f396ce
Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
193 SDL_free (device->hidden); |
eed7a3f396ce
Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
194 SDL_free (device); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
195 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
196 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
197 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
|
198 |
4049
60f677630282
Added key composition support, courtesy of Kuon
Sam Lantinga <slouken@libsdl.org>
parents:
3936
diff
changeset
|
199 NSRect r = NSMakeRect(0.0, 0.0, 0.0, 0.0); |
3936
c5c3c772f5aa
Let app set SDL_VIDEO_ALLOW_SCREENSAVER environment variable to override SDL's
Ryan C. Gordon <icculus@icculus.org>
parents:
3877
diff
changeset
|
200 const char *env = NULL; |
c5c3c772f5aa
Let app set SDL_VIDEO_ALLOW_SCREENSAVER environment variable to override SDL's
Ryan C. Gordon <icculus@icculus.org>
parents:
3877
diff
changeset
|
201 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
202 /* 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
|
203 display_id = kCGDirectMainDisplay; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
204 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
|
205 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
|
206 palette = CGPaletteCreateDefaultColorPalette (); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
207 |
4139
568c9b3c0167
* Added configure option --enable-screensaver, to allow enabling the screensaver by default.
Sam Lantinga <slouken@libsdl.org>
parents:
4123
diff
changeset
|
208 /* Allow environment override of screensaver disable. */ |
3936
c5c3c772f5aa
Let app set SDL_VIDEO_ALLOW_SCREENSAVER environment variable to override SDL's
Ryan C. Gordon <icculus@icculus.org>
parents:
3877
diff
changeset
|
209 env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER"); |
4139
568c9b3c0167
* Added configure option --enable-screensaver, to allow enabling the screensaver by default.
Sam Lantinga <slouken@libsdl.org>
parents:
4123
diff
changeset
|
210 if ( env ) { |
568c9b3c0167
* Added configure option --enable-screensaver, to allow enabling the screensaver by default.
Sam Lantinga <slouken@libsdl.org>
parents:
4123
diff
changeset
|
211 allow_screensaver = SDL_atoi(env); |
568c9b3c0167
* Added configure option --enable-screensaver, to allow enabling the screensaver by default.
Sam Lantinga <slouken@libsdl.org>
parents:
4123
diff
changeset
|
212 } else { |
568c9b3c0167
* Added configure option --enable-screensaver, to allow enabling the screensaver by default.
Sam Lantinga <slouken@libsdl.org>
parents:
4123
diff
changeset
|
213 #ifdef SDL_VIDEO_DISABLE_SCREENSAVER |
568c9b3c0167
* Added configure option --enable-screensaver, to allow enabling the screensaver by default.
Sam Lantinga <slouken@libsdl.org>
parents:
4123
diff
changeset
|
214 allow_screensaver = 0; |
568c9b3c0167
* Added configure option --enable-screensaver, to allow enabling the screensaver by default.
Sam Lantinga <slouken@libsdl.org>
parents:
4123
diff
changeset
|
215 #else |
568c9b3c0167
* Added configure option --enable-screensaver, to allow enabling the screensaver by default.
Sam Lantinga <slouken@libsdl.org>
parents:
4123
diff
changeset
|
216 allow_screensaver = 1; |
568c9b3c0167
* Added configure option --enable-screensaver, to allow enabling the screensaver by default.
Sam Lantinga <slouken@libsdl.org>
parents:
4123
diff
changeset
|
217 #endif |
568c9b3c0167
* Added configure option --enable-screensaver, to allow enabling the screensaver by default.
Sam Lantinga <slouken@libsdl.org>
parents:
4123
diff
changeset
|
218 } |
3936
c5c3c772f5aa
Let app set SDL_VIDEO_ALLOW_SCREENSAVER environment variable to override SDL's
Ryan C. Gordon <icculus@icculus.org>
parents:
3877
diff
changeset
|
219 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
220 /* 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
|
221 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
|
222 kCFNumberSInt32Type, &device_bpp); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
223 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
224 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
|
225 kCFNumberSInt32Type, &device_width); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
226 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
227 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
|
228 kCFNumberSInt32Type, &device_height); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
229 |
1545
8d9bb0cf2c2a
Added current_w and current_h to the SDL_VideoInfo structure, which is set to the desktop resolution during video intialization, and then set to the current resolution when a video mode is set.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
230 /* Determine the current screen size */ |
8d9bb0cf2c2a
Added current_w and current_h to the SDL_VideoInfo structure, which is set to the desktop resolution during video intialization, and then set to the current resolution when a video mode is set.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
231 this->info.current_w = device_width; |
8d9bb0cf2c2a
Added current_w and current_h to the SDL_VideoInfo structure, which is set to the desktop resolution during video intialization, and then set to the current resolution when a video mode is set.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
232 this->info.current_h = device_height; |
8d9bb0cf2c2a
Added current_w and current_h to the SDL_VideoInfo structure, which is set to the desktop resolution during video intialization, and then set to the current resolution when a video mode is set.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
233 |
8d9bb0cf2c2a
Added current_w and current_h to the SDL_VideoInfo structure, which is set to the desktop resolution during video intialization, and then set to the current resolution when a video mode is set.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
234 /* Determine the default screen depth */ |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
235 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
|
236 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
237 /* 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
|
238 current_grab_mode = SDL_GRAB_OFF; |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
239 cursor_should_be_visible = YES; |
779
68c8da837fc0
Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
768
diff
changeset
|
240 cursor_visible = YES; |
823
d67e76f25874
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
816
diff
changeset
|
241 current_mods = 0; |
4123
9d90d7765fa7
Guillaume Borios fixed bug #508
Sam Lantinga <slouken@libsdl.org>
parents:
4090
diff
changeset
|
242 field_edit = [[SDLTranslatorResponder alloc] initWithFrame:r]; |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
243 |
876
9e84d106ec19
(Said Max Horn on the SDL mailing list...)
Ryan C. Gordon <icculus@icculus.org>
parents:
852
diff
changeset
|
244 if ( Gestalt(gestaltSystemVersion, &system_version) != noErr ) |
9e84d106ec19
(Said Max Horn on the SDL mailing list...)
Ryan C. Gordon <icculus@icculus.org>
parents:
852
diff
changeset
|
245 system_version = 0; |
934
af585d6efec8
Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents:
876
diff
changeset
|
246 |
555 | 247 /* register for sleep notifications so wake from sleep generates SDL_VIDEOEXPOSE */ |
248 QZ_RegisterForSleepNotifications (this); | |
249 | |
1271
092722dbc766
Whoops! (hope this compiles...)
Sam Lantinga <slouken@libsdl.org>
parents:
1220
diff
changeset
|
250 /* Fill in some window manager capabilities */ |
092722dbc766
Whoops! (hope this compiles...)
Sam Lantinga <slouken@libsdl.org>
parents:
1220
diff
changeset
|
251 this->info.wm_available = 1; |
092722dbc766
Whoops! (hope this compiles...)
Sam Lantinga <slouken@libsdl.org>
parents:
1220
diff
changeset
|
252 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
253 return 0; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
254 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
255 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
256 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
|
257 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
258 CFIndex num_modes; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
259 CFIndex i; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
260 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
261 int list_size = 0; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
262 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
263 /* Any windowed mode is acceptable */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
264 if ( (flags & SDL_FULLSCREEN) == 0 ) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
265 return (SDL_Rect**)-1; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
266 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
267 /* 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
|
268 if ( client_mode_list != NULL ) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
269 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
270 int i; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
271 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
272 for (i = 0; client_mode_list[i] != NULL; i++) |
1756
eed7a3f396ce
Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
273 SDL_free (client_mode_list[i]); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
274 |
1756
eed7a3f396ce
Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
275 SDL_free (client_mode_list); |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
276 client_mode_list = NULL; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
277 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
278 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
279 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
|
280 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
281 /* 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
|
282 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
|
283 |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
284 CFDictionaryRef onemode; |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
285 CFNumberRef number; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
286 int bpp; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
287 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
288 onemode = CFArrayGetValueAtIndex (mode_list, i); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
289 number = CFDictionaryGetValue (onemode, kCGDisplayBitsPerPixel); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
290 CFNumberGetValue (number, kCFNumberSInt32Type, &bpp); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
291 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
292 if (bpp == format->BitsPerPixel) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
293 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
294 int intvalue; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
295 int hasMode; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
296 int width, height; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
297 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
298 number = CFDictionaryGetValue (onemode, kCGDisplayWidth); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
299 CFNumberGetValue (number, kCFNumberSInt32Type, &intvalue); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
300 width = (Uint16) intvalue; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
301 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
302 number = CFDictionaryGetValue (onemode, kCGDisplayHeight); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
303 CFNumberGetValue (number, kCFNumberSInt32Type, &intvalue); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
304 height = (Uint16) intvalue; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
305 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
306 /* 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
|
307 { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
308 int i; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
309 hasMode = SDL_FALSE; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
310 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
|
311 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
|
312 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
|
313 hasMode = SDL_TRUE; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
314 break; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
315 } |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
316 } |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
317 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
318 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
319 /* 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
|
320 if ( ! hasMode ) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
321 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
322 SDL_Rect *rect; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
323 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
324 list_size++; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
325 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
326 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
|
327 client_mode_list = (SDL_Rect**) |
1756
eed7a3f396ce
Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
328 SDL_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
|
329 else |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
330 client_mode_list = (SDL_Rect**) |
1756
eed7a3f396ce
Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
331 SDL_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
|
332 |
1756
eed7a3f396ce
Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
333 rect = (SDL_Rect*) SDL_malloc (sizeof(**client_mode_list)); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
334 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
335 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
|
336 SDL_OutOfMemory (); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
337 return NULL; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
338 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
339 |
1218
057d313e36a2
Quartz target: set x and y field of mode list to 0 in SDL_ListMode call.
Ryan C. Gordon <icculus@icculus.org>
parents:
1212
diff
changeset
|
340 rect->x = rect->y = 0; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
341 rect->w = width; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
342 rect->h = height; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
343 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
344 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
|
345 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
|
346 } |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
347 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
348 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
349 |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
350 /* 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
|
351 { |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
352 int i, j; |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
353 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
|
354 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
|
355 |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
356 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
|
357 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
|
358 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
|
359 |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
360 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
|
361 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
|
362 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
|
363 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
|
364 } |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
365 } |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
366 } |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
367 } |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
368 return client_mode_list; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
369 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
370 |
657
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
371 static SDL_bool QZ_WindowPosition(_THIS, int *x, int *y) |
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
372 { |
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
373 const char *window = getenv("SDL_VIDEO_WINDOW_POS"); |
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
374 if ( window ) { |
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
375 if ( sscanf(window, "%d,%d", x, y) == 2 ) { |
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
376 return SDL_TRUE; |
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
377 } |
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
378 } |
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
379 return SDL_FALSE; |
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
380 } |
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
381 |
1340
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
382 static void QZ_UnsetVideoMode (_THIS, BOOL to_desktop) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
383 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
384 /* 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
|
385 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
|
386 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
|
387 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
|
388 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
|
389 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
|
390 |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
391 if (cg_context) { |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
392 CGContextFlush (cg_context); |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
393 CGContextRelease (cg_context); |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
394 cg_context = nil; |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
395 } |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
396 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
397 /* Release fullscreen resources */ |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
398 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
|
399 |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
400 NSRect screen_rect; |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
401 |
588
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
402 /* Release double buffer stuff */ |
1144
509295d5a023
Date: Sun, 11 Sep 2005 14:41:07 +0300 (EEST)
Ryan C. Gordon <icculus@icculus.org>
parents:
1120
diff
changeset
|
403 if ( mode_flags & SDL_DOUBLEBUF) { |
588
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
404 quit_thread = YES; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
405 SDL_SemPost (sem1); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
406 SDL_WaitThread (thread, NULL); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
407 SDL_DestroySemaphore (sem1); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
408 SDL_DestroySemaphore (sem2); |
1756
eed7a3f396ce
Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
409 SDL_free (sw_buffers[0]); |
588
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
410 } |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
411 |
4065 | 412 /* If we still have a valid window, close it. */ |
413 if ( qz_window ) { | |
4090 | 414 NSCAssert([ qz_window delegate ] == nil, @"full screen window shouldn't have a delegate"); /* if that should ever change, we'd have to release it here */ |
415 [ qz_window close ]; /* includes release because [qz_window isReleasedWhenClosed] */ | |
4065 | 416 qz_window = nil; |
417 window_view = nil; | |
418 } | |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
419 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
420 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
|
421 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
|
422 */ |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
423 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
|
424 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
425 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
|
426 CGLSetFullScreen (NULL); |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
427 } |
1340
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
428 if (to_desktop) { |
3877 | 429 ShowMenuBar (); |
1340
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
430 /* Restore original screen resolution/bpp */ |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
431 CGDisplaySwitchToMode (display_id, save_mode); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
432 CGReleaseAllDisplays (); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
433 /* |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
434 Reset the main screen's rectangle |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
435 See comment in QZ_SetVideoFullscreen for why we do this |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
436 */ |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
437 screen_rect = NSMakeRect(0,0,device_width,device_height); |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
438 QZ_SetFrame([ NSScreen mainScreen ], screen_rect); |
1340
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
439 } |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
440 } |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
441 /* Release window mode resources */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
442 else { |
4090 | 443 id delegate = [ qz_window delegate ]; |
444 [ qz_window close ]; /* includes release because [qz_window isReleasedWhenClosed] */ | |
445 if (delegate != nil) [ delegate release ]; | |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
446 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
|
447 window_view = nil; |
1160
72c6c3e5bb85
Closed a memory leak caused when quitting video subsystem on Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1144
diff
changeset
|
448 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
449 /* Release the OpenGL context */ |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
450 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
|
451 QZ_TearDownOpenGL (this); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
452 } |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
453 |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
454 /* Signal successful teardown */ |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
455 video_set = SDL_FALSE; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
456 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
457 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
458 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
|
459 int height, int bpp, Uint32 flags) { |
1220
ca2f0da7b708
Quartz driver: Make sure we pass a pointer to the right type.
Ryan C. Gordon <icculus@icculus.org>
parents:
1219
diff
changeset
|
460 boolean_t exact_match = 0; |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
461 NSRect screen_rect; |
588
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
462 CGError error; |
4065 | 463 NSRect contentRect; |
464 BOOL isCustom = NO; | |
1340
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
465 CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken; |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
466 |
1340
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
467 /* Fade to black to hide resolution-switching flicker (and garbage |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
468 that is displayed by a destroyed OpenGL context, if applicable) */ |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
469 if ( CGAcquireDisplayFadeReservation (5, &fade_token) == kCGErrorSuccess ) { |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
470 CGDisplayFade (fade_token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, TRUE); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
471 } |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
472 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
473 /* 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
|
474 if (video_set == SDL_TRUE) |
1340
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
475 QZ_UnsetVideoMode (this, FALSE); |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
476 |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
477 /* Sorry, QuickDraw was ripped out. */ |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
478 if (getenv("SDL_NSWindowPointer") || getenv("SDL_NSQuickDrawViewPointer")) { |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
479 SDL_SetError ("Embedded QuickDraw windows are no longer supported"); |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
480 goto ERR_NO_MATCH; |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
481 } |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
482 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
483 /* 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
|
484 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
|
485 height, &exact_match); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
486 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
487 /* 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
|
488 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
|
489 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
|
490 goto ERR_NO_MATCH; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
491 } |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
117
diff
changeset
|
492 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
493 /* Put up the blanking window (a window above all other windows) */ |
588
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
494 if (getenv ("SDL_SINGLEDISPLAY")) |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
495 error = CGDisplayCapture (display_id); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
496 else |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
497 error = CGCaptureAllDisplays (); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
498 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
499 if ( CGDisplayNoErr != error ) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
500 SDL_SetError ("Failed capturing display"); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
501 goto ERR_NO_CAPTURE; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
502 } |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
503 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
504 /* Do the physical switch */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
505 if ( CGDisplayNoErr != CGDisplaySwitchToMode (display_id, mode) ) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
506 SDL_SetError ("Failed switching display resolution"); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
507 goto ERR_NO_SWITCH; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
508 } |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
509 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
510 current->pixels = (Uint32*) CGDisplayBaseAddress (display_id); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
511 current->pitch = CGDisplayBytesPerRow (display_id); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
512 |
58
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
56
diff
changeset
|
513 current->flags = 0; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
514 current->w = width; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
515 current->h = height; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
516 current->flags |= SDL_FULLSCREEN; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
517 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
|
518 current->flags |= SDL_PREALLOC; |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
519 /* current->hwdata = (void *) CGDisplayGetDrawingContext (display_id); */ |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
520 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
521 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
|
522 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
|
523 this->UnlockHWSurface = QZ_UnlockHWSurface; |
588
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
524 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
525 /* Setup double-buffer emulation */ |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
526 if ( flags & SDL_DOUBLEBUF ) { |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
527 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
528 /* |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
529 Setup a software backing store for reasonable results when |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
530 double buffering is requested (since a single-buffered hardware |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
531 surface looks hideous). |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
532 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
533 The actual screen blit occurs in a separate thread to allow |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
534 other blitting while waiting on the VBL (and hence results in higher framerates). |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
535 */ |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
536 this->LockHWSurface = NULL; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
537 this->UnlockHWSurface = NULL; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
538 this->UpdateRects = NULL; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
539 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
540 current->flags |= (SDL_HWSURFACE|SDL_DOUBLEBUF); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
541 this->UpdateRects = QZ_DoubleBufferUpdate; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
542 this->LockHWSurface = QZ_LockDoubleBuffer; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
543 this->UnlockHWSurface = QZ_UnlockDoubleBuffer; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
544 this->FlipHWSurface = QZ_FlipDoubleBuffer; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
545 |
1756
eed7a3f396ce
Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
546 current->pixels = SDL_malloc (current->pitch * current->h * 2); |
588
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
547 if (current->pixels == NULL) { |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
548 SDL_OutOfMemory (); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
549 goto ERR_DOUBLEBUF; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
550 } |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
551 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
552 sw_buffers[0] = current->pixels; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
553 sw_buffers[1] = (Uint8*)current->pixels + current->pitch * current->h; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
554 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
555 quit_thread = NO; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
556 sem1 = SDL_CreateSemaphore (0); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
557 sem2 = SDL_CreateSemaphore (1); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
558 thread = SDL_CreateThread ((int (*)(void *))QZ_ThreadFlip, this); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
559 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
560 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
561 if ( CGDisplayCanSetPalette (display_id) ) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
562 current->flags |= SDL_HWPALETTE; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
563 |
4065 | 564 /* Check if we should recreate the window */ |
565 if (qz_window == nil) { | |
566 /* Manually create a window, avoids having a nib file resource */ | |
567 qz_window = [ [ SDL_QuartzWindow alloc ] | |
568 initWithContentRect:contentRect | |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
569 styleMask:0 |
4065 | 570 backing:NSBackingStoreBuffered |
571 defer:NO ]; | |
572 | |
573 if (qz_window != nil) { | |
574 [ qz_window setAcceptsMouseMovedEvents:YES ]; | |
575 [ qz_window setViewsNeedDisplay:NO ]; | |
576 } | |
577 } | |
578 /* We already have a window, just change its size */ | |
579 else { | |
580 if (!isCustom) { | |
581 [ qz_window setContentSize:contentRect.size ]; | |
582 current->flags |= (SDL_NOFRAME|SDL_RESIZABLE) & mode_flags; | |
583 [ window_view setFrameSize:contentRect.size ]; | |
584 } | |
585 } | |
586 | |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
587 /* Setup OpenGL for a fullscreen context */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
588 if (flags & SDL_OPENGL) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
589 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
590 CGLError err; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
591 CGLContextObj ctx; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
592 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
593 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
|
594 goto ERR_NO_GL; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
595 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
596 |
4065 | 597 /* Initialize the NSView and add it to our window. The presence of a valid window and |
598 view allow the cursor to be changed whilst in fullscreen.*/ | |
599 window_view = [ [ NSView alloc ] initWithFrame:contentRect ]; | |
600 [ [ qz_window contentView ] addSubview:window_view ]; | |
601 [ window_view release ]; | |
602 | |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
603 ctx = QZ_GetCGLContextObj (gl_context); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
604 err = CGLSetFullScreen (ctx); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
605 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
606 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
|
607 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
|
608 goto ERR_NO_GL; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
609 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
610 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
611 [ gl_context makeCurrentContext]; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
612 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
613 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
|
614 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
615 [ gl_context flushBuffer ]; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
616 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
617 current->flags |= SDL_OPENGL; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
618 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
619 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
620 /* 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
|
621 HideMenuBar (); |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
622 |
1340
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
623 /* Fade in again (asynchronously) */ |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
624 if ( fade_token != kCGDisplayFadeReservationInvalidToken ) { |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
625 CGDisplayFade (fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
626 CGReleaseDisplayFadeReservation(fade_token); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
627 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
628 |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
629 /* |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
630 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
|
631 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
|
632 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
|
633 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
|
634 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
|
635 */ |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
636 screen_rect = NSMakeRect(0,0,width,height); |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
637 QZ_SetFrame([ NSScreen mainScreen ], screen_rect); |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
638 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
639 /* 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
|
640 mode_flags = current->flags; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
641 |
1629 | 642 /* Set app state, hide cursor if necessary, ... */ |
643 QZ_DoActivate(this); | |
1119
430d8d701f69
SDL_GetAppState() correction when toggling fullscreen on OSX.
Ryan C. Gordon <icculus@icculus.org>
parents:
967
diff
changeset
|
644 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
645 return current; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
646 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
647 /* Since the blanking window covers *all* windows (even force quit) correct recovery is crucial */ |
588
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
648 ERR_NO_GL: |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
649 ERR_DOUBLEBUF: CGDisplaySwitchToMode (display_id, save_mode); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
650 ERR_NO_SWITCH: CGReleaseAllDisplays (); |
1340
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
651 ERR_NO_CAPTURE: |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
652 ERR_NO_MATCH: if ( fade_token != kCGDisplayFadeReservationInvalidToken ) { |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
653 CGDisplayFade (fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
654 CGReleaseDisplayFadeReservation (fade_token); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
655 } |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
656 return NULL; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
657 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
658 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
659 static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width, |
1183
634d85aefc8c
Fixed bug reported here:
Ryan C. Gordon <icculus@icculus.org>
parents:
1181
diff
changeset
|
660 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
|
661 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
|
662 NSRect contentRect; |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
674
diff
changeset
|
663 BOOL isCustom = NO; |
657
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
664 int center_window = 1; |
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
665 int origin_x, origin_y; |
1340
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
666 CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
667 |
58
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
56
diff
changeset
|
668 current->flags = 0; |
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
56
diff
changeset
|
669 current->w = width; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
670 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
|
671 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
672 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
|
673 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
674 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
675 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
|
676 - 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
|
677 - 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
|
678 - 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
|
679 - 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
|
680 */ |
1340
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
681 if (video_set == SDL_TRUE) { |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
682 if (mode_flags & SDL_FULLSCREEN) { |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
683 /* Fade to black to hide resolution-switching flicker (and garbage |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
684 that is displayed by a destroyed OpenGL context, if applicable) */ |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
685 if (CGAcquireDisplayFadeReservation (5, &fade_token) == kCGErrorSuccess) { |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
686 CGDisplayFade (fade_token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, TRUE); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
687 } |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
688 QZ_UnsetVideoMode (this, TRUE); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
689 } |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
690 else if ( ((mode_flags ^ flags) & (SDL_NOFRAME|SDL_RESIZABLE)) || |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
691 (mode_flags & SDL_OPENGL) || |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
692 (flags & SDL_OPENGL) ) { |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
693 QZ_UnsetVideoMode (this, TRUE); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
694 } |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
695 } |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
674
diff
changeset
|
696 |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
697 /* Sorry, QuickDraw was ripped out. */ |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
698 if (getenv("SDL_NSWindowPointer") || getenv("SDL_NSQuickDrawViewPointer")) { |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
699 SDL_SetError ("Embedded QuickDraw windows are no longer supported"); |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
700 if (fade_token != kCGDisplayFadeReservationInvalidToken) { |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
701 CGDisplayFade (fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE); |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
702 CGReleaseDisplayFadeReservation (fade_token); |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
674
diff
changeset
|
703 } |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
704 return NULL; |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
674
diff
changeset
|
705 } |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
706 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
707 /* 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
|
708 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
|
709 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
710 /* 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
|
711 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
|
712 style = NSBorderlessWindowMask; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
713 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
|
714 } else { |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
715 style = NSTitledWindowMask; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
716 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
|
717 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
|
718 style |= NSResizableWindowMask; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
719 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
|
720 } |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
721 } |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
722 |
657
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
723 if ( QZ_WindowPosition(this, &origin_x, &origin_y) ) { |
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
724 center_window = 0; |
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
725 contentRect.origin.x = (float)origin_x; |
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
726 contentRect.origin.y = (float)origin_y; |
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
727 } |
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
728 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
729 /* 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
|
730 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
|
731 initWithContentRect:contentRect |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
732 styleMask:style |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
733 backing:NSBackingStoreBuffered |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
734 defer:NO ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
735 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
736 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
|
737 SDL_SetError ("Could not create the Cocoa window"); |
1340
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
738 if (fade_token != kCGDisplayFadeReservationInvalidToken) { |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
739 CGDisplayFade (fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
740 CGReleaseDisplayFadeReservation (fade_token); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
741 } |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
742 return NULL; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
743 } |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
744 |
4090 | 745 /*[ qz_window setReleasedWhenClosed:YES ];*/ /* no need to set this as it's the default for NSWindows */ |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
746 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
|
747 [ 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
|
748 [ qz_window setViewsNeedDisplay:NO ]; |
657
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
749 if ( center_window ) { |
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
750 [ qz_window center ]; |
714053f573e7
Date: Thu, 24 Jul 2003 01:40:17 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
751 } |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
752 [ qz_window setDelegate: |
4090 | 753 [ [ SDL_QuartzWindowDelegate alloc ] init ] ]; |
4070
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4065
diff
changeset
|
754 [ qz_window setContentView: [ [ [ SDL_QuartzView alloc ] init ] autorelease ] ]; |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
755 } |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
756 /* 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
|
757 else { |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
758 |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
674
diff
changeset
|
759 if (!isCustom) { |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
674
diff
changeset
|
760 [ qz_window setContentSize:contentRect.size ]; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
674
diff
changeset
|
761 current->flags |= (SDL_NOFRAME|SDL_RESIZABLE) & mode_flags; |
832
f003714db2f4
Date: Mon, 16 Feb 2004 19:21:51 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
823
diff
changeset
|
762 [ window_view setFrameSize:contentRect.size ]; |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
674
diff
changeset
|
763 } |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
764 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
765 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
766 /* 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
|
767 if ( flags & SDL_OPENGL ) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
768 |
1183
634d85aefc8c
Fixed bug reported here:
Ryan C. Gordon <icculus@icculus.org>
parents:
1181
diff
changeset
|
769 if ( ! QZ_SetupOpenGL (this, *bpp, flags) ) { |
1340
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
770 if (fade_token != kCGDisplayFadeReservationInvalidToken) { |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
771 CGDisplayFade (fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
772 CGReleaseDisplayFadeReservation (fade_token); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
773 } |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
774 return NULL; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
775 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
776 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
777 window_view = [ [ NSView alloc ] initWithFrame:contentRect ]; |
832
f003714db2f4
Date: Mon, 16 Feb 2004 19:21:51 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
823
diff
changeset
|
778 [ window_view setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable ]; |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
779 [ [ 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
|
780 [ 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
|
781 [ window_view release ]; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
782 [ gl_context makeCurrentContext]; |
158
4382c38dfbee
Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
155
diff
changeset
|
783 [ qz_window makeKeyAndOrderFront:nil ]; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
784 current->flags |= SDL_OPENGL; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
785 } |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
786 /* For 2D, we build a CGBitmapContext */ |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
787 else { |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
788 CGColorSpaceRef cgColorspace; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
789 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
790 /* 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
|
791 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
|
792 |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
793 window_view = [ [ NSView alloc ] initWithFrame:contentRect ]; |
832
f003714db2f4
Date: Mon, 16 Feb 2004 19:21:51 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
823
diff
changeset
|
794 [ window_view setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable ]; |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
795 [ [ 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
|
796 [ 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
|
797 [ 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
|
798 } |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
799 |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
800 cgColorspace = CGColorSpaceCreateDeviceRGB(); |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
801 current->pitch = 4 * current->w; |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
802 current->pixels = SDL_malloc (current->h * current->pitch); |
498
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
803 |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
804 cg_context = CGBitmapContextCreate (current->pixels, current->w, current->h, |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
805 8, current->pitch, cgColorspace, |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
806 kCGImageAlphaNoneSkipFirst); |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
807 CGColorSpaceRelease (cgColorspace); |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
808 |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
809 current->flags |= SDL_SWSURFACE; |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
810 current->flags |= SDL_ASYNCBLIT; |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
811 current->hwdata = (void *) cg_context; |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
812 |
498
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
813 this->UpdateRects = QZ_UpdateRects; |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
814 this->LockHWSurface = QZ_LockHWSurface; |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
815 this->UnlockHWSurface = QZ_UnlockHWSurface; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
816 } |
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 /* 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
|
819 mode_flags = current->flags; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
820 |
1340
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
821 /* Fade in again (asynchronously) if we came from a fullscreen mode and faded to black */ |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
822 if (fade_token != kCGDisplayFadeReservationInvalidToken) { |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
823 CGDisplayFade (fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
824 CGReleaseDisplayFadeReservation (fade_token); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
825 } |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
826 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
827 return current; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
828 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
829 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
830 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
|
831 int height, int bpp, Uint32 flags) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
832 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
833 current->flags = 0; |
852 | 834 current->pixels = NULL; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
835 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
836 /* Setup full screen video */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
837 if ( flags & SDL_FULLSCREEN ) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
838 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
|
839 if (current == NULL) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
840 return NULL; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
841 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
842 /* Setup windowed video */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
843 else { |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
844 /* Force bpp to 32 */ |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
845 bpp = 32; |
1183
634d85aefc8c
Fixed bug reported here:
Ryan C. Gordon <icculus@icculus.org>
parents:
1181
diff
changeset
|
846 current = QZ_SetVideoWindowed (this, current, width, height, &bpp, flags); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
847 if (current == NULL) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
848 return NULL; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
849 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
850 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
851 /* Setup the new pixel format */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
852 { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
853 int amask = 0, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
854 rmask = 0, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
855 gmask = 0, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
856 bmask = 0; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
857 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
858 switch (bpp) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
859 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
|
860 amask = 0; |
58
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
56
diff
changeset
|
861 rmask = 0x7C00; |
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
56
diff
changeset
|
862 gmask = 0x03E0; |
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
56
diff
changeset
|
863 bmask = 0x001F; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
864 break; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
865 case 24: |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
866 SDL_SetError ("24bpp is not available"); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
867 return NULL; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
868 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
|
869 amask = 0x00000000; |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
870 #ifdef __LITTLE_ENDIAN__ |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
871 rmask = 0x0000FF00; |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
872 gmask = 0x00FF0000; |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
873 bmask = 0xFF000000; |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
874 #else |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
875 rmask = 0x00FF0000; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
876 gmask = 0x0000FF00; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
877 bmask = 0x000000FF; |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
878 #endif |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
879 break; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
880 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
881 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
882 if ( ! SDL_ReallocFormat (current, bpp, |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
883 rmask, gmask, bmask, amask ) ) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
884 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
|
885 return NULL; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
886 } |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
887 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
888 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
889 /* 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
|
890 video_set = SDL_TRUE; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
891 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
892 return current; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
893 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
894 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
895 static int QZ_ToggleFullScreen (_THIS, int on) { |
576
cd41dca47fff
Fixed QZ_ToggleFullScreen() return value (thanks Max!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
896 return 0; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
897 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
898 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
899 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
|
900 SDL_Color *colors) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
901 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
902 CGTableCount index; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
903 CGDeviceColor color; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
904 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
905 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
|
906 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
907 /* 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
|
908 color.red = colors->r / 255.0; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
909 color.blue = colors->b / 255.0; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
910 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
|
911 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
912 colors++; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
913 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
914 CGPaletteSetColorAtIndex (palette, color, index); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
915 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
916 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
917 if ( CGDisplayNoErr != CGDisplaySetPalette (display_id, palette) ) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
918 return 0; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
919 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
920 return 1; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
921 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
922 |
588
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
923 static int QZ_LockDoubleBuffer (_THIS, SDL_Surface *surface) { |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
924 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
925 return 1; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
926 } |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
927 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
928 static void QZ_UnlockDoubleBuffer (_THIS, SDL_Surface *surface) { |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
929 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
930 } |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
931 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
932 /* The VBL delay is based on code by Ian R Ollmann's RezLib <iano@cco.caltech.edu> */ |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
933 static AbsoluteTime QZ_SecondsToAbsolute ( double seconds ) { |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
934 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
935 union |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
936 { |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
937 UInt64 i; |
588
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
938 Nanoseconds ns; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
939 } temp; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
940 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
941 temp.i = seconds * 1000000000.0; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
942 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
943 return NanosecondsToAbsolute ( temp.ns ); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
944 } |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
945 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
946 static int QZ_ThreadFlip (_THIS) { |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
947 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
948 Uint8 *src, *dst; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
949 int skip, len, h; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
950 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
951 /* |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
952 Give this thread the highest scheduling priority possible, |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
953 in the hopes that it will immediately run after the VBL delay |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
954 */ |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
955 { |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
956 pthread_t current_thread; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
957 int policy; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
958 struct sched_param param; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
959 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
960 current_thread = pthread_self (); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
961 pthread_getschedparam (current_thread, &policy, ¶m); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
962 policy = SCHED_RR; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
963 param.sched_priority = sched_get_priority_max (policy); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
964 pthread_setschedparam (current_thread, policy, ¶m); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
965 } |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
966 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
967 while (1) { |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
968 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
969 SDL_SemWait (sem1); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
970 if (quit_thread) |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
971 return 0; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
972 |
1219
9a7a016d5a71
Quartz driver: Correctly handle SDL_DOUBLEBUF|SDL_FULLSCREEN when the
Ryan C. Gordon <icculus@icculus.org>
parents:
1218
diff
changeset
|
973 /* |
9a7a016d5a71
Quartz driver: Correctly handle SDL_DOUBLEBUF|SDL_FULLSCREEN when the
Ryan C. Gordon <icculus@icculus.org>
parents:
1218
diff
changeset
|
974 * We have to add SDL_VideoSurface->offset here, since we might be a |
9a7a016d5a71
Quartz driver: Correctly handle SDL_DOUBLEBUF|SDL_FULLSCREEN when the
Ryan C. Gordon <icculus@icculus.org>
parents:
1218
diff
changeset
|
975 * smaller surface in the center of the framebuffer (you asked for |
9a7a016d5a71
Quartz driver: Correctly handle SDL_DOUBLEBUF|SDL_FULLSCREEN when the
Ryan C. Gordon <icculus@icculus.org>
parents:
1218
diff
changeset
|
976 * a fullscreen resolution smaller than the hardware could supply |
9a7a016d5a71
Quartz driver: Correctly handle SDL_DOUBLEBUF|SDL_FULLSCREEN when the
Ryan C. Gordon <icculus@icculus.org>
parents:
1218
diff
changeset
|
977 * so SDL is centering it in a bigger resolution)... |
9a7a016d5a71
Quartz driver: Correctly handle SDL_DOUBLEBUF|SDL_FULLSCREEN when the
Ryan C. Gordon <icculus@icculus.org>
parents:
1218
diff
changeset
|
978 */ |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1403
diff
changeset
|
979 dst = (Uint8 *)CGDisplayBaseAddress (display_id) + SDL_VideoSurface->offset; |
1219
9a7a016d5a71
Quartz driver: Correctly handle SDL_DOUBLEBUF|SDL_FULLSCREEN when the
Ryan C. Gordon <icculus@icculus.org>
parents:
1218
diff
changeset
|
980 src = current_buffer + SDL_VideoSurface->offset; |
588
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
981 len = SDL_VideoSurface->w * SDL_VideoSurface->format->BytesPerPixel; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
982 h = SDL_VideoSurface->h; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
983 skip = SDL_VideoSurface->pitch; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
984 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
985 /* Wait for the VBL to occur (estimated since we don't have a hardware interrupt) */ |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
986 { |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
987 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
988 /* The VBL delay is based on Ian Ollmann's RezLib <iano@cco.caltech.edu> */ |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
989 double refreshRate; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
990 double linesPerSecond; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
991 double target; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
992 double position; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
993 double adjustment; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
994 AbsoluteTime nextTime; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
995 CFNumberRef refreshRateCFNumber; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
996 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
997 refreshRateCFNumber = CFDictionaryGetValue (mode, kCGDisplayRefreshRate); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
998 if ( NULL == refreshRateCFNumber ) { |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
999 SDL_SetError ("Mode has no refresh rate"); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1000 goto ERROR; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1001 } |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1002 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1003 if ( 0 == CFNumberGetValue (refreshRateCFNumber, kCFNumberDoubleType, &refreshRate) ) { |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1004 SDL_SetError ("Error getting refresh rate"); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1005 goto ERROR; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1006 } |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1007 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1008 if ( 0 == refreshRate ) { |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1009 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1010 SDL_SetError ("Display has no refresh rate, using 60hz"); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1011 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1012 /* ok, for LCD's we'll emulate a 60hz refresh, which may or may not look right */ |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1013 refreshRate = 60.0; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1014 } |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1015 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1016 linesPerSecond = refreshRate * h; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1017 target = h; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1018 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1019 /* Figure out the first delay so we start off about right */ |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1020 position = CGDisplayBeamPosition (display_id); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1021 if (position > target) |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1022 position = 0; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1023 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1024 adjustment = (target - position) / linesPerSecond; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1025 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1026 nextTime = AddAbsoluteToAbsolute (UpTime (), QZ_SecondsToAbsolute (adjustment)); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1027 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1028 MPDelayUntil (&nextTime); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1029 } |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1030 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1031 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1032 /* On error, skip VBL delay */ |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1033 ERROR: |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1034 |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1035 /* TODO: use CGContextDrawImage here too! Create two CGContextRefs the same way we |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1036 create two buffers, replace current_buffer with current_context and set it |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1037 appropriately in QZ_FlipDoubleBuffer. */ |
588
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1038 while ( h-- ) { |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1039 |
1756
eed7a3f396ce
Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
1040 SDL_memcpy (dst, src, len); |
588
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1041 src += skip; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1042 dst += skip; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1043 } |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1044 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1045 /* signal flip completion */ |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1046 SDL_SemPost (sem2); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1047 } |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1048 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1049 return 0; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1050 } |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1051 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1052 static int QZ_FlipDoubleBuffer (_THIS, SDL_Surface *surface) { |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1053 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1054 /* wait for previous flip to complete */ |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1055 SDL_SemWait (sem2); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1056 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1057 current_buffer = surface->pixels; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1058 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1059 if (surface->pixels == sw_buffers[0]) |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1060 surface->pixels = sw_buffers[1]; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1061 else |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1062 surface->pixels = sw_buffers[0]; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1063 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1064 /* signal worker thread to do the flip */ |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1065 SDL_SemPost (sem1); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1066 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1067 return 0; |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1068 } |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1069 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1070 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1071 static void QZ_DoubleBufferUpdate (_THIS, int num_rects, SDL_Rect *rects) { |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1072 |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1073 /* perform a flip if someone calls updaterects on a doublebuferred surface */ |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1074 this->FlipHWSurface (this, SDL_VideoSurface); |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1075 } |
2c6510c0a304
Darrell added support for emulated SDL_DOUBLEBUF on MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
576
diff
changeset
|
1076 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1077 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
|
1078 #pragma unused(this,num_rects,rects) |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1079 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1080 |
498
4b8ff8ac2c07
Fixed window update problems on MacOS X 10.2 (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
1081 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1082 /* Resize icon, BMP format */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1083 static const unsigned char QZ_ResizeIcon[] = { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1084 0x42,0x4d,0x31,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1085 0x00,0x00,0x0d,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x01,0x00,0x18,0x00,0x00,0x00, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1086 0x00,0x00,0xfb,0x01,0x00,0x00,0x13,0x0b,0x00,0x00,0x13,0x0b,0x00,0x00,0x00,0x00, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1087 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1088 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1089 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0b,0xff,0xff, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1090 0xff,0xda,0xda,0xda,0x87,0x87,0x87,0xe8,0xe8,0xe8,0xff,0xff,0xff,0xda,0xda,0xda, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1091 0x87,0x87,0x87,0xe8,0xe8,0xe8,0xff,0xff,0xff,0xda,0xda,0xda,0x87,0x87,0x87,0xe8, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1092 0xe8,0xe8,0xff,0xff,0xff,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xda,0xda,0xda,0x87, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1093 0x87,0x87,0xe8,0xe8,0xe8,0xff,0xff,0xff,0xda,0xda,0xda,0x87,0x87,0x87,0xe8,0xe8, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1094 0xe8,0xff,0xff,0xff,0xda,0xda,0xda,0x87,0x87,0x87,0xff,0xff,0xff,0x0b,0xff,0xff, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1095 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd5,0xd5,0xd5,0x87,0x87,0x87,0xe8,0xe8,0xe8, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1096 0xff,0xff,0xff,0xda,0xda,0xda,0x87,0x87,0x87,0xe8,0xe8,0xe8,0xff,0xff,0xff,0xda, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1097 0xda,0xda,0xff,0xff,0xff,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1098 0xff,0xff,0xd7,0xd7,0xd7,0x87,0x87,0x87,0xe8,0xe8,0xe8,0xff,0xff,0xff,0xda,0xda, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1099 0xda,0x87,0x87,0x87,0xe8,0xe8,0xe8,0xff,0xff,0xff,0xff,0xff,0xff,0x0b,0xff,0xff, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1100 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd7,0xd7,0xd7, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1101 0x87,0x87,0x87,0xe8,0xe8,0xe8,0xff,0xff,0xff,0xda,0xda,0xda,0x87,0x87,0x87,0xe8, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1102 0xe8,0xe8,0xff,0xff,0xff,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1103 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd7,0xd7,0xd7,0x87,0x87,0x87,0xe8,0xe8, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1104 0xe8,0xff,0xff,0xff,0xdc,0xdc,0xdc,0x87,0x87,0x87,0xff,0xff,0xff,0x0b,0xff,0xff, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1105 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1106 0xff,0xff,0xff,0xd9,0xd9,0xd9,0x87,0x87,0x87,0xe8,0xe8,0xe8,0xff,0xff,0xff,0xdc, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1107 0xdc,0xdc,0xff,0xff,0xff,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1108 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xdb,0xdb, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1109 0xdb,0x87,0x87,0x87,0xe8,0xe8,0xe8,0xff,0xff,0xff,0xff,0xff,0xff,0x0b,0xff,0xff, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1110 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1111 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xdb,0xdb,0xdb,0x87,0x87,0x87,0xe8, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1112 0xe8,0xe8,0xff,0xff,0xff,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1113 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1114 0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0x87,0x87,0x87,0xff,0xff,0xff,0x0b,0xff,0xff, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1115 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1116 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xdc, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1117 0xdc,0xdc,0xff,0xff,0xff,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1118 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1119 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0b |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1120 }; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1121 |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1122 static void QZ_DrawResizeIcon (_THIS) { |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1123 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1124 /* Check if we should draw the resize icon */ |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1125 if (SDL_VideoSurface->flags & SDL_RESIZABLE) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1126 |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1127 SDL_Rect icon_rect; |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1128 |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1129 /* Create the icon image */ |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1130 if (resize_icon == NULL) { |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1131 |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1132 SDL_RWops *rw; |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1133 SDL_Surface *tmp; |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1134 |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1135 rw = SDL_RWFromConstMem (QZ_ResizeIcon, sizeof(QZ_ResizeIcon)); |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1136 tmp = SDL_LoadBMP_RW (rw, SDL_TRUE); |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1137 |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1138 resize_icon = SDL_ConvertSurface (tmp, SDL_VideoSurface->format, SDL_SRCCOLORKEY); |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1139 SDL_SetColorKey (resize_icon, SDL_SRCCOLORKEY, 0xFFFFFF); |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1140 |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1141 SDL_FreeSurface (tmp); |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1142 } |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1143 |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1144 icon_rect.x = SDL_VideoSurface->w - 13; |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1145 icon_rect.y = SDL_VideoSurface->h - 13; |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1146 icon_rect.w = 13; |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1147 icon_rect.h = 13; |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1148 |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1149 SDL_BlitSurface (resize_icon, NULL, SDL_VideoSurface, &icon_rect); |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1150 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1151 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1152 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1153 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
|
1154 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1155 if (SDL_VideoSurface->flags & SDL_OPENGLBLIT) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1156 QZ_GL_SwapBuffers (this); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1157 } |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1158 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
|
1159 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1160 /* 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
|
1161 } |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1162 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1163 else { |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1164 CGContextRef cgc = (CGContextRef) |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1165 [[NSGraphicsContext graphicsContextWithWindow: qz_window] |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1166 graphicsPort]; |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1167 QZ_DrawResizeIcon (this); |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1168 CGContextFlush (cg_context); |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1169 CGImageRef image = CGBitmapContextCreateImage (cg_context); |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1170 CGRect rectangle = CGRectMake (0,0,[window_view frame].size.width,[window_view frame].size.height); |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
500
diff
changeset
|
1171 |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1172 CGContextDrawImage (cgc, rectangle, image); |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1173 CGImageRelease(image); |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1174 CGContextFlush (cgc); |
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
1175 CGContextRelease (cgc); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1176 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1177 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1178 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1179 static void QZ_VideoQuit (_THIS) { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1180 |
1340
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
1181 CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken; |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
1182 |
560
37c31c12eb70
Moved some cleanup stuff to QZ_VideoQuit() from QZ_UnsetVideoMode()...fixes
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1183 /* Restore gamma settings */ |
37c31c12eb70
Moved some cleanup stuff to QZ_VideoQuit() from QZ_UnsetVideoMode()...fixes
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1184 CGDisplayRestoreColorSyncSettings (); |
37c31c12eb70
Moved some cleanup stuff to QZ_VideoQuit() from QZ_UnsetVideoMode()...fixes
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1185 |
37c31c12eb70
Moved some cleanup stuff to QZ_VideoQuit() from QZ_UnsetVideoMode()...fixes
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1186 /* Ensure the cursor will be visible and working when we quit */ |
37c31c12eb70
Moved some cleanup stuff to QZ_VideoQuit() from QZ_UnsetVideoMode()...fixes
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1187 CGDisplayShowCursor (display_id); |
37c31c12eb70
Moved some cleanup stuff to QZ_VideoQuit() from QZ_UnsetVideoMode()...fixes
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1188 CGAssociateMouseAndMouseCursorPosition (1); |
37c31c12eb70
Moved some cleanup stuff to QZ_VideoQuit() from QZ_UnsetVideoMode()...fixes
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1189 |
1340
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
1190 if (mode_flags & SDL_FULLSCREEN) { |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
1191 /* Fade to black to hide resolution-switching flicker (and garbage |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
1192 that is displayed by a destroyed OpenGL context, if applicable) */ |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
1193 if (CGAcquireDisplayFadeReservation (5, &fade_token) == kCGErrorSuccess) { |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
1194 CGDisplayFade (fade_token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, TRUE); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
1195 } |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
1196 QZ_UnsetVideoMode (this, TRUE); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
1197 if (fade_token != kCGDisplayFadeReservationInvalidToken) { |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
1198 CGDisplayFade (fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
1199 CGReleaseDisplayFadeReservation (fade_token); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
1200 } |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
1201 } |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
1202 else |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
1203 QZ_UnsetVideoMode (this, TRUE); |
58b114ef50e7
Faster fades when changing to/from/between fullscreen modes on Mac OS X. Also,
Ryan C. Gordon <icculus@icculus.org>
parents:
1271
diff
changeset
|
1204 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1205 CGPaletteRelease (palette); |
1181
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1160
diff
changeset
|
1206 |
1189
c96b326b90ba
Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1183
diff
changeset
|
1207 if (opengl_library) { |
c96b326b90ba
Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1183
diff
changeset
|
1208 SDL_UnloadObject(opengl_library); |
c96b326b90ba
Moved Quartz SDL_GL_LoadLibrary() to SDL_loadso interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1183
diff
changeset
|
1209 opengl_library = NULL; |
1181
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1160
diff
changeset
|
1210 } |
49d3efec6651
Quartz driver OpenGL updates:
Ryan C. Gordon <icculus@icculus.org>
parents:
1160
diff
changeset
|
1211 this->gl_config.driver_loaded = 0; |
4049
60f677630282
Added key composition support, courtesy of Kuon
Sam Lantinga <slouken@libsdl.org>
parents:
3936
diff
changeset
|
1212 |
60f677630282
Added key composition support, courtesy of Kuon
Sam Lantinga <slouken@libsdl.org>
parents:
3936
diff
changeset
|
1213 if (field_edit) { |
60f677630282
Added key composition support, courtesy of Kuon
Sam Lantinga <slouken@libsdl.org>
parents:
3936
diff
changeset
|
1214 [field_edit release]; |
60f677630282
Added key composition support, courtesy of Kuon
Sam Lantinga <slouken@libsdl.org>
parents:
3936
diff
changeset
|
1215 field_edit = NULL; |
60f677630282
Added key composition support, courtesy of Kuon
Sam Lantinga <slouken@libsdl.org>
parents:
3936
diff
changeset
|
1216 } |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1217 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1218 |
674
be597a247e20
Fix compilation on MacOS 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
668
diff
changeset
|
1219 #if 0 /* Not used (apparently, it's really slow) */ |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1220 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
|
1221 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1222 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
|
1223 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1224 return 0; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1225 } |
674
be597a247e20
Fix compilation on MacOS 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
668
diff
changeset
|
1226 #endif |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1227 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1228 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
|
1229 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1230 return 1; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1231 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1232 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1233 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
|
1234 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1235 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1236 |
1120
8e1fde455471
Patch by me to fix crash described below.
Ryan C. Gordon <icculus@icculus.org>
parents:
1119
diff
changeset
|
1237 static int QZ_AllocHWSurface(_THIS, SDL_Surface *surface) { |
8e1fde455471
Patch by me to fix crash described below.
Ryan C. Gordon <icculus@icculus.org>
parents:
1119
diff
changeset
|
1238 return(-1); /* unallowed (no HWSURFACE support here). */ |
8e1fde455471
Patch by me to fix crash described below.
Ryan C. Gordon <icculus@icculus.org>
parents:
1119
diff
changeset
|
1239 } |
8e1fde455471
Patch by me to fix crash described below.
Ryan C. Gordon <icculus@icculus.org>
parents:
1119
diff
changeset
|
1240 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1241 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
|
1242 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1243 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1244 /* |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1245 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
|
1246 return 0; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1247 } |
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 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1250 /* Gamma functions */ |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1251 int QZ_SetGamma (_THIS, float red, float green, float blue) { |
47
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 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
|
1254 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1255 if (red == 0.0) |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1256 red = FLT_MAX; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1257 else |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1258 red = 1.0 / red; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1259 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1260 if (green == 0.0) |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1261 green = FLT_MAX; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1262 else |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1263 green = 1.0 / green; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1264 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1265 if (blue == 0.0) |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1266 blue = FLT_MAX; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1267 else |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1268 blue = 1.0 / blue; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1269 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1270 if ( CGDisplayNoErr == CGSetDisplayTransferByFormula |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1271 (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
|
1272 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1273 return 0; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1274 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1275 else { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1276 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1277 return -1; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1278 } |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1279 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1280 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1281 int QZ_GetGamma (_THIS, float *red, float *green, float *blue) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1282 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1283 CGGammaValue dummy; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1284 if ( CGDisplayNoErr == CGGetDisplayTransferByFormula |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1285 (display_id, &dummy, &dummy, red, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1286 &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
|
1287 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1288 return 0; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1289 else |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1290 return -1; |
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 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1293 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
|
1294 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1295 const CGTableCount tableSize = 255; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1296 CGGammaValue redTable[tableSize]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1297 CGGammaValue greenTable[tableSize]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1298 CGGammaValue blueTable[tableSize]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1299 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1300 int i; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1301 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1302 /* 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
|
1303 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
|
1304 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
|
1305 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1306 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
|
1307 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
|
1308 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1309 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
|
1310 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
|
1311 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1312 if ( CGDisplayNoErr == CGSetDisplayTransferByTable |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1313 (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
|
1314 return 0; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1315 else |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1316 return -1; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1317 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1318 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1319 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
|
1320 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1321 const CGTableCount tableSize = 255; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1322 CGGammaValue redTable[tableSize]; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1323 CGGammaValue greenTable[tableSize]; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1324 CGGammaValue blueTable[tableSize]; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1325 CGTableCount actual; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1326 int i; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1327 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1328 if ( CGDisplayNoErr != CGGetDisplayTransferByTable |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1329 (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
|
1330 actual != tableSize) |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1331 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1332 return -1; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1333 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1334 /* 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
|
1335 for (i = 0; i < 256; i++) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1336 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
|
1337 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1338 for (i=256; i < 512; i++) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1339 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
|
1340 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1341 for (i=512; i < 768; i++) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1342 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
|
1343 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
359
diff
changeset
|
1344 return 0; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1345 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1346 |