Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
1480 lines (1164 loc) · 41.2 KB

SDL_dspvideo.c

File metadata and controls

1480 lines (1164 loc) · 41.2 KB
 
Apr 26, 2001
Apr 26, 2001
1
2
/*
SDL - Simple DirectMedia Layer
Feb 1, 2006
Feb 1, 2006
3
Copyright (C) 1997-2006 Sam Lantinga
Apr 26, 2001
Apr 26, 2001
4
5
This library is free software; you can redistribute it and/or
Feb 1, 2006
Feb 1, 2006
6
modify it under the terms of the GNU Lesser General Public
Apr 26, 2001
Apr 26, 2001
7
License as published by the Free Software Foundation; either
Feb 1, 2006
Feb 1, 2006
8
version 2.1 of the License, or (at your option) any later version.
Apr 26, 2001
Apr 26, 2001
9
10
11
12
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Feb 1, 2006
Feb 1, 2006
13
Lesser General Public License for more details.
Apr 26, 2001
Apr 26, 2001
14
Feb 1, 2006
Feb 1, 2006
15
16
17
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Apr 26, 2001
Apr 26, 2001
18
19
Sam Lantinga
Dec 14, 2001
Dec 14, 2001
20
slouken@libsdl.org
Apr 26, 2001
Apr 26, 2001
21
*/
Feb 21, 2006
Feb 21, 2006
22
#include "SDL_config.h"
Apr 26, 2001
Apr 26, 2001
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
Written by Darrell Walisser <dwaliss1@purdue.edu>
Implementation notes ----------------------------------------------------------------------
A bit on GWorlds in VRAM from technote 1182:
There are two important things to note about GWorld's allocated in
VRAM. First, the base address retrieved through GetPixBaseAddr or
read directly from the PixMap structure can become invalid anytime
memory is allocated in VRAM. This can occur either by explicit
allocations, such as calls to NewGWorld, or by implicit ones, such as
those associated with the internal texture allocation of OpenGL. The
stored pixel images themselves will still be valid but may have been
moved in VRAM, thus rendering any stored base addresses invalid.
You should never store an image's base address for longer than is
necessary and especially never across calls to NewGWorld or
texture-creation routines.
Secondly, an offscreen pixel image allocated in VRAM can be
purged at system task time by the display driver. This means any
time your application yields time such by calling WaitNextEvent or
SystemTask you can lose your VRAM GWorld contents. While this
happens infrequently, usually associated with display resolution or
pixel depth changes you must code for this eventuality. This purge
can occur whether or not the GWorld is locked or not. A return value
of false from LockPixels, a NULL return value from GetPixBaseAddr
or NULL in the baseAddr field of the PixMap mean that the pixel
image has been purged. To reallocate it you can either call
UpdateGWorld or Dispose your current GWorld through
DisposeGWorld and reallocate it via NewGWorld. Either way you must
then rebuild the pixel image.
------------------------------------------------------------------------------------
Currently, I don't account for (1). In my testing, NewGWorld never invalidated
other existing GWorlds in VRAM. However, I do have protection for (2).
Namely, I am using GetOSEvent() instead of WaitNextEvent() so that there are no
context switches (the app hogs the CPU). Eventually a book-keeping system should
be coded to take care of (1) and (2).
------------------------------------------------------------------------------------
System requirements (* denotes optional):
1. DrawSprocket 1.7.3
Sep 8, 2005
Sep 8, 2005
70
2. *MacOS 9 or later (but *not* Mac OS X) for hardware accelerated blit / fill
Apr 26, 2001
Apr 26, 2001
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
3. *May also require certain graphics hardware for (2). I trust that all Apple OEM
hardware will work. Third party accelerators may work if they have QuickDraw
acceleration in the drivers and the drivers have been updated for OS 9. The current
Voodoo 3 drivers (1.0b12) do not work.
Coding suggestions:
1. Use SDL_UpdateRects !
If no QuickDraw acceleration is present, double-buffered surfaces will use a back buffer
in System memory. I recommend you use SDL_UpdateRects with double-buffered surfaces
for best performance on these cards, since the overhead is nearly zero for VRAM back buffer.
2. Load most-resident surfaces first.
If you fill up VRAM or AGP memory, there is no contingency for purging to make room for the next one.
Therefore, you should load the surfaces you plan to use the most frequently first.
Sooner or later, I will code LRU replacement to help this.
TODO:
Some kind of posterized mode for resolutions < 640x480.
Window support / fullscreen toggle.
Figure out how much VRAM is available. Put in video->info->video_mem.
Track VRAM usage.
BUGS:
I can't create a hardware surface the same size as the screen?! How to fix?
COMPILE OPTIONS:
DSP_TRY_CC_AND_AA - Define if you want to try HWA color-key and alpha blitters
HW color-key blitting gives substantial improvements,
but hw alpha is neck-and-neck with SDL's soft bitter.
DSP_NO_SYNC_VBL - Define for HWA double-buffered surfaces: don't sync
pseudo-flip to monitor redraw.
DSP_NO_SYNC_OPENGL - Define for OpenGL surfaces: don't sync buffer swap. Synching buffer
swap may result in reduced performance, but can eliminate some
tearing artifacts.
CHANGELOG:
09/17/00 Lots of little tweaks. Build modelist in reverse order so largest contexts
list first. Compared various methods with ROM methods and fixed rez switch
crashing bug in GL Tron. (Woohoo!)
*/
#define DSP_TRY_CC_AND_AA
/* #define DSP_NO_SYNC_VBL */
#define DSP_NO_SYNC_OPENGL
Sep 8, 2005
Sep 8, 2005
126
127
128
129
#if defined(__APPLE__) && defined(__MACH__)
#include <Carbon/Carbon.h>
#include <DrawSprocket/DrawSprocket.h>
#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
Apr 26, 2001
Apr 26, 2001
130
#include <Carbon.h>
Sep 8, 2005
Sep 8, 2005
131
#include <DrawSprocket.h>
Apr 26, 2001
Apr 26, 2001
132
133
134
135
136
137
#else
#include <LowMem.h>
#include <Gestalt.h>
#include <Devices.h>
#include <DiskInit.h>
#include <QDOffscreen.h>
Sep 8, 2005
Sep 8, 2005
138
#include <DrawSprocket.h>
Apr 26, 2001
Apr 26, 2001
139
140
141
142
#endif
#include "SDL_video.h"
#include "SDL_syswm.h"
Feb 16, 2006
Feb 16, 2006
143
144
145
#include "../SDL_sysvideo.h"
#include "../SDL_blit.h"
#include "../SDL_pixels_c.h"
Apr 26, 2001
Apr 26, 2001
146
#include "SDL_dspvideo.h"
Feb 24, 2006
Feb 24, 2006
147
148
149
150
#include "../maccommon/SDL_macgl_c.h"
#include "../maccommon/SDL_macwm_c.h"
#include "../maccommon/SDL_macmouse_c.h"
#include "../maccommon/SDL_macevents_c.h"
Apr 26, 2001
Apr 26, 2001
151
152
/* Initialization/Query functions */
May 29, 2006
May 29, 2006
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
static int DSp_VideoInit(_THIS, SDL_PixelFormat * vformat);
static SDL_Rect **DSp_ListModes(_THIS, SDL_PixelFormat * format,
Uint32 flags);
static SDL_Surface *DSp_SetVideoMode(_THIS, SDL_Surface * current, int width,
int height, int bpp, Uint32 flags);
static int DSp_SetColors(_THIS, int firstcolor, int ncolors,
SDL_Color * colors);
static int DSp_CreatePalette(_THIS);
static int DSp_DestroyPalette(_THIS);
static void DSp_VideoQuit(_THIS);
static int DSp_GetMainDevice(_THIS, GDHandle * device);
static void DSp_IsHWAvailable(_THIS, SDL_PixelFormat * vformat);
static void DSp_DSpUpdate(_THIS, int numrects, SDL_Rect * sdl_rects);
static void DSp_DirectUpdate(_THIS, int numrects, SDL_Rect * sdl_rects);
Apr 26, 2001
Apr 26, 2001
168
169
/* Hardware surface functions */
May 29, 2006
May 29, 2006
170
171
172
173
174
175
176
177
178
179
180
181
182
183
static int DSp_SetHWAlpha(_THIS, SDL_Surface * surface, UInt8 alpha);
static int DSp_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key);
static int DSp_NewHWSurface(_THIS, CGrafPtr * port, int depth, int width,
int height);
static int DSp_AllocHWSurface(_THIS, SDL_Surface * surface);
static int DSp_LockHWSurface(_THIS, SDL_Surface * surface);
static void DSp_UnlockHWSurface(_THIS, SDL_Surface * surface);
static void DSp_FreeHWSurface(_THIS, SDL_Surface * surface);
static int DSp_FlipHWSurface(_THIS, SDL_Surface * surface);
static int DSp_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dest);
static int DSp_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect,
SDL_Surface * dst, SDL_Rect * dstrect);
static int DSp_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect,
Uint32 color);
Apr 26, 2001
Apr 26, 2001
184
Feb 16, 2006
Feb 16, 2006
185
#if SDL_VIDEO_OPENGL
May 29, 2006
May 29, 2006
186
static void DSp_GL_SwapBuffers(_THIS);
Apr 26, 2001
Apr 26, 2001
187
188
189
190
#endif
#if ! TARGET_API_MAC_CARBON
May 28, 2006
May 28, 2006
191
192
193
194
195
#define GetPortPixRowBytes(x) ( (*(x->portPixMap))->rowBytes )
#define GetGDevPixMap(x) ((**(x)).gdPMap)
#define GetPortPixMap(x) ((*(x)).portPixMap)
#define GetPixDepth(y) ((**(y)).pixelSize)
Apr 26, 2001
Apr 26, 2001
196
197
//#define GetPixRowBytes(y) ((**(y)).rowBytes)
//#define GetPixBaseAddr(y) ((**(y)).baseAddr)
May 28, 2006
May 28, 2006
198
199
200
#define GetPixCTab(y) ((**(y)).pmTable)
#define GetPortBitMapForCopyBits(x) (&(((GrafPtr)(x))->portBits))
Apr 26, 2001
Apr 26, 2001
201
#else
May 28, 2006
May 28, 2006
202
203
#define GetPortPixRowBytes(x) (GetPixRowBytes(GetPortPixMap(x)) )
#define GetGDevPixMap(x) ((**(x)).gdPMap)
Apr 26, 2001
Apr 26, 2001
204
205
206
#endif
May 28, 2006
May 28, 2006
207
208
209
210
211
212
213
214
215
216
typedef struct private_hwdata
{
GWorldPtr offscreen; // offscreen gworld in VRAM or AGP
#ifdef DSP_TRY_CC_AND_AA
GWorldPtr mask; // transparent mask
RGBColor alpha; // alpha color
RGBColor trans; // transparent color
#endif
Apr 26, 2001
Apr 26, 2001
217
218
219
} private_hwdata;
May 28, 2006
May 28, 2006
220
typedef private_hwdata private_swdata; /* have same fields */
Apr 26, 2001
Apr 26, 2001
221
222
223
/* Macintosh toolbox driver bootstrap functions */
May 28, 2006
May 28, 2006
224
static int
May 29, 2006
May 29, 2006
225
DSp_Available(void)
Apr 26, 2001
Apr 26, 2001
226
{
May 28, 2006
May 28, 2006
227
/* Check for DrawSprocket */
Sep 8, 2005
Sep 8, 2005
228
#if ! TARGET_API_MAC_OSX
May 28, 2006
May 28, 2006
229
230
/* This check is only meaningful if you weak-link DrawSprocketLib */
return ((Ptr) DSpStartup != (Ptr) kUnresolvedCFragSymbolAddress);
Sep 8, 2005
Sep 8, 2005
231
#else
May 28, 2006
May 28, 2006
232
return 1; // DrawSprocket.framework doesn't have it all, but it's there
Sep 8, 2005
Sep 8, 2005
233
#endif
Apr 26, 2001
Apr 26, 2001
234
235
}
May 28, 2006
May 28, 2006
236
static void
May 29, 2006
May 29, 2006
237
DSp_DeleteDevice(SDL_VideoDevice * device)
Apr 26, 2001
Apr 26, 2001
238
{
May 28, 2006
May 28, 2006
239
240
241
242
243
244
/* -dw- taking no chances with null pointers */
if (device) {
if (device->hidden) {
if (device->hidden->dspinfo)
May 29, 2006
May 29, 2006
245
SDL_free(device->hidden->dspinfo);
May 28, 2006
May 28, 2006
246
May 29, 2006
May 29, 2006
247
SDL_free(device->hidden);
May 28, 2006
May 28, 2006
248
}
May 29, 2006
May 29, 2006
249
SDL_free(device);
May 28, 2006
May 28, 2006
250
}
Apr 26, 2001
Apr 26, 2001
251
252
}
May 28, 2006
May 28, 2006
253
static SDL_VideoDevice *
May 29, 2006
May 29, 2006
254
DSp_CreateDevice(int devindex)
Apr 26, 2001
Apr 26, 2001
255
{
May 28, 2006
May 28, 2006
256
257
258
SDL_VideoDevice *device;
/* Initialize all variables that we clean on shutdown */
May 29, 2006
May 29, 2006
259
device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
May 28, 2006
May 28, 2006
260
if (device) {
May 29, 2006
May 29, 2006
261
SDL_memset(device, 0, sizeof(*device));
May 28, 2006
May 28, 2006
262
device->hidden = (struct SDL_PrivateVideoData *)
May 29, 2006
May 29, 2006
263
SDL_malloc((sizeof *device->hidden));
May 28, 2006
May 28, 2006
264
if (device->hidden)
May 29, 2006
May 29, 2006
265
SDL_memset(device->hidden, 0, sizeof(*(device->hidden)));
May 28, 2006
May 28, 2006
266
267
}
if ((device == NULL) || (device->hidden == NULL)) {
May 29, 2006
May 29, 2006
268
SDL_OutOfMemory();
May 28, 2006
May 28, 2006
269
270
271
272
if (device) {
if (device->hidden)
May 29, 2006
May 29, 2006
273
SDL_free(device->hidden);
May 28, 2006
May 28, 2006
274
May 29, 2006
May 29, 2006
275
SDL_free(device);
May 28, 2006
May 28, 2006
276
277
278
279
280
281
}
return (NULL);
}
/* Allocate DrawSprocket information */
May 29, 2006
May 29, 2006
282
283
284
device->hidden->dspinfo = (struct DSpInfo *) SDL_malloc((sizeof *device->
hidden->
dspinfo));
May 28, 2006
May 28, 2006
285
if (device->hidden->dspinfo == NULL) {
May 29, 2006
May 29, 2006
286
287
288
SDL_OutOfMemory();
SDL_free(device->hidden);
SDL_free(device);
May 28, 2006
May 28, 2006
289
290
return (0);
}
May 29, 2006
May 29, 2006
291
SDL_memset(device->hidden->dspinfo, 0, (sizeof *device->hidden->dspinfo));
May 28, 2006
May 28, 2006
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
/* Set the function pointers */
device->VideoInit = DSp_VideoInit;
device->ListModes = DSp_ListModes;
device->SetVideoMode = DSp_SetVideoMode;
device->SetColors = DSp_SetColors;
device->UpdateRects = NULL;
device->VideoQuit = DSp_VideoQuit;
device->AllocHWSurface = DSp_AllocHWSurface;
device->CheckHWBlit = NULL;
device->FillHWRect = NULL;
device->SetHWColorKey = NULL;
device->SetHWAlpha = NULL;
device->LockHWSurface = DSp_LockHWSurface;
device->UnlockHWSurface = DSp_UnlockHWSurface;
device->FlipHWSurface = DSp_FlipHWSurface;
device->FreeHWSurface = DSp_FreeHWSurface;
Feb 16, 2006
Feb 16, 2006
309
#if SDL_VIDEO_OPENGL
May 28, 2006
May 28, 2006
310
311
312
313
device->GL_MakeCurrent = Mac_GL_MakeCurrent;
device->GL_SwapBuffers = DSp_GL_SwapBuffers;
device->GL_LoadLibrary = Mac_GL_LoadLibrary;
device->GL_GetProcAddress = Mac_GL_GetProcAddress;
Apr 26, 2001
Apr 26, 2001
314
#endif
May 28, 2006
May 28, 2006
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
device->SetCaption = NULL;
device->SetIcon = NULL;
device->IconifyWindow = NULL;
device->GrabInput = NULL;
device->GetWMInfo = NULL;
device->FreeWMCursor = Mac_FreeWMCursor;
device->CreateWMCursor = Mac_CreateWMCursor;
device->ShowWMCursor = Mac_ShowWMCursor;
device->WarpWMCursor = Mac_WarpWMCursor;
device->InitOSKeymap = Mac_InitOSKeymap;
device->PumpEvents = Mac_PumpEvents;
device->GrabInput = NULL;
device->CheckMouseMode = NULL;
device->free = DSp_DeleteDevice;
return device;
Apr 26, 2001
Apr 26, 2001
333
334
335
}
VideoBootStrap DSp_bootstrap = {
May 28, 2006
May 28, 2006
336
337
"DSp", "MacOS DrawSprocket",
DSp_Available, DSp_CreateDevice
Apr 26, 2001
Apr 26, 2001
338
339
340
};
/* Use DSp/Display Manager to build mode list for given screen */
May 28, 2006
May 28, 2006
341
static SDL_Rect **
May 29, 2006
May 29, 2006
342
343
DSp_BuildModeList(const GDHandle gDevice, int *displayWidth,
int *displayHeight)
Apr 26, 2001
Apr 26, 2001
344
{
May 28, 2006
May 28, 2006
345
346
347
348
349
350
351
352
353
354
355
356
357
DSpContextAttributes attributes;
DSpContextReference context;
DisplayIDType displayID;
SDL_Rect temp_list[16];
SDL_Rect **mode_list;
int width, height, i, j;
#if TARGET_API_MAC_OSX
displayID = 0;
#else
/* Ask Display Manager for integer id of screen device */
May 29, 2006
May 29, 2006
358
if (DMGetDisplayIDByGDevice(gDevice, &displayID, SDL_TRUE) != noErr) {
May 28, 2006
May 28, 2006
359
360
361
362
return NULL;
}
#endif
/* Get the first possible DSp context on this device */
May 29, 2006
May 29, 2006
363
if (DSpGetFirstContext(displayID, &context) != noErr) {
May 28, 2006
May 28, 2006
364
365
366
return NULL;
}
May 29, 2006
May 29, 2006
367
if (DSpContext_GetAttributes(context, &attributes) != noErr)
May 28, 2006
May 28, 2006
368
369
370
371
372
return NULL;
*displayWidth = attributes.displayWidth;
*displayHeight = attributes.displayHeight;
May 29, 2006
May 29, 2006
373
for (i = 0; i < SDL_arraysize(temp_list); i++) {
May 28, 2006
May 28, 2006
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
width = attributes.displayWidth;
height = attributes.displayHeight;
temp_list[i].x = 0 | attributes.displayBestDepth;
temp_list[i].y = 0;
temp_list[i].w = width;
temp_list[i].h = height;
/* DSp will report many different contexts with the same width and height. */
/* They will differ in bit depth and refresh rate. */
/* We will ignore them until we reach one with a different width/height */
/* When there are no more contexts to look at, we will quit building the list */
while (width == attributes.displayWidth
&& height == attributes.displayHeight) {
May 29, 2006
May 29, 2006
389
OSStatus err = DSpGetNextContext(context, &context);
May 28, 2006
May 28, 2006
390
391
392
393
394
395
if (err != noErr)
if (err == kDSpContextNotFoundErr)
goto done;
else
return NULL;
May 29, 2006
May 29, 2006
396
if (DSpContext_GetAttributes(context, &attributes) != noErr)
May 28, 2006
May 28, 2006
397
398
399
400
401
402
403
404
return NULL;
temp_list[i].x |= attributes.displayBestDepth;
}
}
done:
i++; /* i was not incremented before kicking out of the loop */
May 29, 2006
May 29, 2006
405
mode_list = (SDL_Rect **) SDL_malloc(sizeof(SDL_Rect *) * (i + 1));
May 28, 2006
May 28, 2006
406
407
408
409
if (mode_list) {
/* -dw- new stuff: build in reverse order so largest sizes list first */
for (j = i - 1; j >= 0; j--) {
May 29, 2006
May 29, 2006
410
mode_list[j] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect));
May 28, 2006
May 28, 2006
411
if (mode_list[j])
May 29, 2006
May 29, 2006
412
SDL_memcpy(mode_list[j], &(temp_list[j]), sizeof(SDL_Rect));
May 28, 2006
May 28, 2006
413
else {
May 29, 2006
May 29, 2006
414
SDL_OutOfMemory();
May 28, 2006
May 28, 2006
415
416
417
418
419
return NULL;
}
}
mode_list[i] = NULL; /* append null to the end */
} else {
May 29, 2006
May 29, 2006
420
SDL_OutOfMemory();
May 28, 2006
May 28, 2006
421
422
423
424
return NULL;
}
return mode_list;
Apr 26, 2001
Apr 26, 2001
425
426
}
May 28, 2006
May 28, 2006
427
static void
May 29, 2006
May 29, 2006
428
DSp_IsHWAvailable(_THIS, SDL_PixelFormat * vformat)
Apr 26, 2001
Apr 26, 2001
429
{
May 28, 2006
May 28, 2006
430
431
432
433
434
/*
VRAM GWorlds are only available on OS 9 or later.
Even with OS 9, some display drivers won't support it,
so we create a test GWorld and check for errors.
*/
Apr 26, 2001
Apr 26, 2001
435
May 28, 2006
May 28, 2006
436
437
438
439
440
long versionSystem;
dsp_vram_available = SDL_FALSE;
dsp_agp_available = SDL_FALSE;
May 29, 2006
May 29, 2006
441
Gestalt('sysv', &versionSystem);
May 28, 2006
May 28, 2006
442
443
444
445
446
447
if (0x00000860 < (versionSystem & 0x0000FFFF)) {
GWorldPtr offscreen;
OSStatus err;
Rect bounds;
May 29, 2006
May 29, 2006
448
SetRect(&bounds, 0, 0, 320, 240);
Apr 26, 2001
Apr 26, 2001
449
Sep 8, 2005
Sep 8, 2005
450
#if useDistantHdwrMem && useLocalHdwrMem
May 28, 2006
May 28, 2006
451
err =
May 29, 2006
May 29, 2006
452
453
NewGWorld(&offscreen, vformat->BitsPerPixel, &bounds, NULL,
SDL_Display, useDistantHdwrMem | noNewDevice);
May 28, 2006
May 28, 2006
454
455
if (err == noErr) {
dsp_vram_available = SDL_TRUE;
May 29, 2006
May 29, 2006
456
DisposeGWorld(offscreen);
May 28, 2006
May 28, 2006
457
458
459
}
err =
May 29, 2006
May 29, 2006
460
461
NewGWorld(&offscreen, vformat->BitsPerPixel, &bounds, NULL,
SDL_Display, useLocalHdwrMem | noNewDevice);
May 28, 2006
May 28, 2006
462
if (err == noErr) {
May 29, 2006
May 29, 2006
463
DisposeGWorld(offscreen);
May 28, 2006
May 28, 2006
464
465
dsp_agp_available = SDL_TRUE;
}
Sep 8, 2005
Sep 8, 2005
466
#endif
May 28, 2006
May 28, 2006
467
}
Apr 26, 2001
Apr 26, 2001
468
469
}
May 28, 2006
May 28, 2006
470
static int
May 29, 2006
May 29, 2006
471
DSp_GetMainDevice(_THIS, GDHandle * device)
Apr 26, 2001
Apr 26, 2001
472
{
May 28, 2006
May 28, 2006
473
Apr 26, 2001
Apr 26, 2001
474
#if TARGET_API_MAC_OSX
May 28, 2006
May 28, 2006
475
/* DSpUserSelectContext not available on OS X */
May 29, 2006
May 29, 2006
476
*device = GetMainDevice();
May 28, 2006
May 28, 2006
477
return 0;
Apr 26, 2001
Apr 26, 2001
478
479
#else
May 28, 2006
May 28, 2006
480
481
482
483
484
485
DSpContextAttributes attrib;
DSpContextReference context;
DisplayIDType display_id;
GDHandle main_device;
GDHandle device_list;
May 29, 2006
May 29, 2006
486
487
device_list = GetDeviceList();
main_device = GetMainDevice();
May 28, 2006
May 28, 2006
488
489
490
491
492
493
494
/* Quick check to avoid slower method when only one display exists */
if ((**device_list).gdNextGD == NULL) {
*device = main_device;
return 0;
}
May 29, 2006
May 29, 2006
495
SDL_memset(&attrib, 0, sizeof(DSpContextAttributes));
May 28, 2006
May 28, 2006
496
497
498
499
500
501
502
503
504
505
506
/* These attributes are hopefully supported on all devices... */
attrib.displayWidth = 640;
attrib.displayHeight = 480;
attrib.displayBestDepth = 8;
attrib.backBufferBestDepth = 8;
attrib.displayDepthMask = kDSpDepthMask_All;
attrib.backBufferDepthMask = kDSpDepthMask_All;
attrib.colorNeeds = kDSpColorNeeds_Require;
attrib.pageCount = 1;
May 29, 2006
May 29, 2006
507
if (noErr != DMGetDisplayIDByGDevice(main_device, &display_id, SDL_FALSE)) {
May 28, 2006
May 28, 2006
508
509
510
511
512
513
SDL_SetError
("Display Manager couldn't associate GDevice with a Display ID");
return (-1);
}
/* Put up dialog on main display to select which display to use */
May 29, 2006
May 29, 2006
514
515
if (noErr != DSpUserSelectContext(&attrib, display_id, NULL, &context)) {
SDL_SetError("DrawSprocket couldn't create a context");
May 28, 2006
May 28, 2006
516
517
518
return (-1);
}
May 29, 2006
May 29, 2006
519
520
if (noErr != DSpContext_GetDisplayID(context, &display_id)) {
SDL_SetError("DrawSprocket couldn't get display ID");
May 28, 2006
May 28, 2006
521
522
523
return (-1);
}
May 29, 2006
May 29, 2006
524
if (noErr != DMGetGDeviceByDisplayID(display_id, &main_device, SDL_FALSE)) {
May 28, 2006
May 28, 2006
525
526
527
528
529
530
531
SDL_SetError
("Display Manager couldn't associate Display ID with GDevice");
return (-1);
}
*device = main_device;
return (0);
Apr 26, 2001
Apr 26, 2001
532
533
534
#endif
}
May 28, 2006
May 28, 2006
535
static int
May 29, 2006
May 29, 2006
536
DSp_VideoInit(_THIS, SDL_PixelFormat * vformat)
Apr 26, 2001
Apr 26, 2001
537
{
May 28, 2006
May 28, 2006
538
539
NumVersion dsp_version = { 0x01, 0x00, 0x00, 0x00 };
Sep 8, 2005
Sep 8, 2005
540
#if UNIVERSAL_INTERFACES_VERSION > 0x0320
May 29, 2006
May 29, 2006
541
dsp_version = DSpGetVersion();
Sep 8, 2005
Sep 8, 2005
542
#endif
May 28, 2006
May 28, 2006
543
544
545
546
547
548
549
550
551
if ((dsp_version.majorRev == 1 && dsp_version.minorAndBugRev < 0x73) ||
(dsp_version.majorRev < 1)) {
/* StandardAlert (kAlertStopAlert, "\pError!",
"\pI need DrawSprocket 1.7.3 or later!\n"
"You can find a newer version at http://www.apple.com/swupdates.",
NULL, NULL);
*/
May 29, 2006
May 29, 2006
552
SDL_SetError("DrawSprocket version is too old. Need 1.7.3 or later.");
May 28, 2006
May 28, 2006
553
554
555
return (-1);
}
May 29, 2006
May 29, 2006
556
557
if (DSpStartup() != noErr) {
SDL_SetError("DrawSprocket couldn't startup");
May 28, 2006
May 28, 2006
558
559
560
561
return (-1);
}
/* Start DSpintosh events */
May 29, 2006
May 29, 2006
562
Mac_InitEvents(this);
May 28, 2006
May 28, 2006
563
564
/* Get a handle to the main monitor, or choose one on multiple monitor setups */
May 29, 2006
May 29, 2006
565
if (DSp_GetMainDevice(this, &SDL_Display) < 0)
May 28, 2006
May 28, 2006
566
567
568
return (-1);
/* Determine pixel format */
May 29, 2006
May 29, 2006
569
vformat->BitsPerPixel = GetPixDepth((**SDL_Display).gdPMap);
May 28, 2006
May 28, 2006
570
571
572
573
574
575
576
577
578
579
580
581
dsp_old_depth = vformat->BitsPerPixel;
switch (vformat->BitsPerPixel) {
case 16:
vformat->Rmask = 0x00007c00;
vformat->Gmask = 0x000003e0;
vformat->Bmask = 0x0000001f;
break;
default:
break;
}
May 29, 2006
May 29, 2006
582
583
if (DSp_CreatePalette(this) < 0) {
SDL_SetError("Could not create palette");
May 28, 2006
May 28, 2006
584
585
586
587
return (-1);
}
/* Get a list of available fullscreen modes */
May 29, 2006
May 29, 2006
588
589
590
SDL_modelist = DSp_BuildModeList(SDL_Display,
&this->info.current_w,
&this->info.current_h);
May 28, 2006
May 28, 2006
591
if (SDL_modelist == NULL) {
May 29, 2006
May 29, 2006
592
SDL_SetError("DrawSprocket could not build a mode list");
May 28, 2006
May 28, 2006
593
594
595
596
return (-1);
}
/* Check for VRAM and AGP GWorlds for HW Blitting */
May 29, 2006
May 29, 2006
597
DSp_IsHWAvailable(this, vformat);
May 28, 2006
May 28, 2006
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
this->info.wm_available = 0;
if (dsp_vram_available || dsp_agp_available) {
this->info.hw_available = SDL_TRUE;
this->CheckHWBlit = DSp_CheckHWBlit;
this->info.blit_hw = SDL_TRUE;
this->FillHWRect = DSp_FillHWRect;
this->info.blit_fill = SDL_TRUE;
#ifdef DSP_TRY_CC_AND_AA
this->SetHWColorKey = DSp_SetHWColorKey;
this->info.blit_hw_CC = SDL_TRUE;
this->SetHWAlpha = DSp_SetHWAlpha;
this->info.blit_hw_A = SDL_TRUE;
#endif
}
return (0);
Apr 26, 2001
Apr 26, 2001
622
623
}
May 28, 2006
May 28, 2006
624
static SDL_Rect **
May 29, 2006
May 29, 2006
625
DSp_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
Apr 26, 2001
Apr 26, 2001
626
{
May 28, 2006
May 28, 2006
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
static SDL_Rect *dsp_modes[16];
int i = 0, j = 0;
if (format->BitsPerPixel == 0)
return ((SDL_Rect **) NULL);
while (SDL_modelist[i] != NULL) {
if (SDL_modelist[i]->x & format->BitsPerPixel) {
dsp_modes[j] = SDL_modelist[i];
j++;
}
i++;
}
dsp_modes[j] = NULL;
return dsp_modes;
Apr 26, 2001
Apr 26, 2001
645
646
647
}
/* Various screen update functions available */
May 29, 2006
May 29, 2006
648
static void DSp_DirectUpdate(_THIS, int numrects, SDL_Rect * rects);
Apr 26, 2001
Apr 26, 2001
649
Sep 8, 2005
Sep 8, 2005
650
651
#if ! TARGET_API_MAC_OSX
Apr 26, 2001
Apr 26, 2001
652
653
static volatile unsigned int retrace_count = 0; /* -dw- need volatile because it updates asychronously */
May 28, 2006
May 28, 2006
654
Boolean
May 29, 2006
May 29, 2006
655
DSp_VBLProc(DSpContextReference context, void *ref_con)
Apr 26, 2001
Apr 26, 2001
656
{
May 28, 2006
May 28, 2006
657
658
659
retrace_count++;
return 1; /* Darrell, is this right? */
Apr 26, 2001
Apr 26, 2001
660
661
}
May 28, 2006
May 28, 2006
662
static void
May 29, 2006
May 29, 2006
663
DSp_SetHWError(OSStatus err, int is_agp)
Apr 26, 2001
Apr 26, 2001
664
{
May 28, 2006
May 28, 2006
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
char message[1024];
const char *fmt, *mem;
if (is_agp) {
mem = "AGP Memory";
} else {
mem = "VRAM";
}
switch (err) {
case memFullErr:
fmt = "Hardware surface possible but not enough %s available";
break;
case cDepthErr:
fmt = "Hardware surface possible but invalid color depth";
break;
default:
fmt = "Hardware surface could not be allocated in %s - unknown error";
break;
}
May 29, 2006
May 29, 2006
684
685
SDL_snprintf(message, SDL_arraysize(message), fmt, mem);
SDL_SetError(message);
Apr 26, 2001
Apr 26, 2001
686
}
Sep 8, 2005
Sep 8, 2005
687
#endif // TARGET_API_MAC_OSX
Apr 26, 2001
Apr 26, 2001
688
689
/* put up a dialog to verify display change */
May 28, 2006
May 28, 2006
690
static int
May 29, 2006
May 29, 2006
691
DSp_ConfirmSwitch()
May 28, 2006
May 28, 2006
692
693
694
695
696
697
698
699
700
701
702
703
704
{
/* resource id's for dialog */
const int rDialog = 1002;
const int bCancel = 1;
const int bOK = 2;
DialogPtr dialog;
OSStatus err;
SInt32 response;
DialogItemIndex item = 0;
GrafPtr savePort;
May 29, 2006
May 29, 2006
705
GetPort(&savePort);
May 28, 2006
May 28, 2006
706
May 29, 2006
May 29, 2006
707
dialog = GetNewDialog(rDialog, NULL, (WindowPtr) - 1);
May 28, 2006
May 28, 2006
708
709
if (dialog == NULL)
return (0);
Apr 26, 2001
Apr 26, 2001
710
May 17, 2006
May 17, 2006
711
#if TARGET_API_MAC_CARBON
May 29, 2006
May 29, 2006
712
SetPort(GetDialogPort(dialog));
Sep 8, 2005
Sep 8, 2005
713
#else
May 29, 2006
May 29, 2006
714
SetPort((WindowPtr) dialog);
Sep 8, 2005
Sep 8, 2005
715
#endif
Apr 26, 2001
Apr 26, 2001
716
May 29, 2006
May 29, 2006
717
718
SetDialogDefaultItem(dialog, bCancel);
SetDialogCancelItem(dialog, bCancel);
Apr 26, 2001
Apr 26, 2001
719
May 29, 2006
May 29, 2006
720
721
SetEventMask(everyEvent);
FlushEvents(everyEvent, 0);
Sep 8, 2005
Sep 8, 2005
722
May 28, 2006
May 28, 2006
723
724
725
/* On MacOS 8.5 or later, we can make the dialog go away after 15 seconds */
/* This is good since it's possible user can't even see the dialog! */
/* Requires linking to DialogsLib */
May 29, 2006
May 29, 2006
726
err = Gestalt(gestaltSystemVersion, &response);
May 28, 2006
May 28, 2006
727
if (err == noErr && response >= 0x00000850) {
May 29, 2006
May 29, 2006
728
SetDialogTimeout(dialog, bCancel, 15);
May 28, 2006
May 28, 2006
729
730
731
732
}
do {
May 29, 2006
May 29, 2006
733
ModalDialog(NULL, &item);
May 28, 2006
May 28, 2006
734
735
736
737
738
}
while (item != bCancel && item != bOK && err != noErr);
May 29, 2006
May 29, 2006
739
740
DisposeDialog(dialog);
SetPort(savePort);
May 28, 2006
May 28, 2006
741
May 29, 2006
May 29, 2006
742
743
SetEventMask(everyEvent - autoKeyMask);
FlushEvents(everyEvent, 0);
May 28, 2006
May 28, 2006
744
745
return (item - 1);
Apr 26, 2001
Apr 26, 2001
746
747
}
May 28, 2006
May 28, 2006
748
static void
May 29, 2006
May 29, 2006
749
DSp_UnsetVideoMode(_THIS, SDL_Surface * current)
Apr 26, 2001
Apr 26, 2001
750
{
May 28, 2006
May 28, 2006
751
752
753
if (current->flags & SDL_INTERNALOPENGL) {
May 29, 2006
May 29, 2006
754
Mac_GL_Quit(this);
May 28, 2006
May 28, 2006
755
756
757
758
759
}
if (dsp_context != NULL) {
GWorldPtr front;
May 29, 2006
May 29, 2006
760
DSpContext_GetFrontBuffer(dsp_context, &front);
May 28, 2006
May 28, 2006
761
762
if (front != dsp_back_buffer)
May 29, 2006
May 29, 2006
763
DisposeGWorld(dsp_back_buffer);
May 28, 2006
May 28, 2006
764
765
if (current->hwdata)
May 29, 2006
May 29, 2006
766
SDL_free(current->hwdata);
May 28, 2006
May 28, 2006
767
May 29, 2006
May 29, 2006
768
769
DSpContext_SetState(dsp_context, kDSpContextState_Inactive);
DSpContext_Release(dsp_context);
May 28, 2006
May 28, 2006
770
771
772
773
dsp_context = NULL;
}
Apr 26, 2001
Apr 26, 2001
774
if (SDL_Window != NULL) {
May 29, 2006
May 29, 2006
775
DisposeWindow(SDL_Window);
Apr 26, 2001
Apr 26, 2001
776
SDL_Window = NULL;
May 28, 2006
May 28, 2006
777
778
}
Apr 26, 2001
Apr 26, 2001
779
current->pixels = NULL;
May 28, 2006
May 28, 2006
780
current->flags = 0;
Apr 26, 2001
Apr 26, 2001
781
782
}
May 28, 2006
May 28, 2006
783
static SDL_Surface *
May 29, 2006
May 29, 2006
784
785
786
DSp_SetVideoMode(_THIS,
SDL_Surface * current, int width, int height, int bpp,
Uint32 flags)
Apr 26, 2001
Apr 26, 2001
787
{
May 28, 2006
May 28, 2006
788
Sep 8, 2005
Sep 8, 2005
789
#if !TARGET_API_MAC_OSX
May 28, 2006
May 28, 2006
790
791
DisplayIDType display_id;
Fixed freq;
Sep 8, 2005
Sep 8, 2005
792
#endif
May 28, 2006
May 28, 2006
793
794
795
796
797
798
799
800
801
DSpContextAttributes attrib;
OSStatus err;
UInt32 rmask = 0, gmask = 0, bmask = 0;
int page_count;
int double_buf;
int hw_surface;
int use_dsp_back_buffer;
May 29, 2006
May 29, 2006
802
DSp_UnsetVideoMode(this, current);
May 28, 2006
May 28, 2006
803
Apr 26, 2001
Apr 26, 2001
804
if (bpp != dsp_old_depth)
May 29, 2006
May 29, 2006
805
DSp_DestroyPalette(this);
Apr 26, 2001
Apr 26, 2001
806
May 28, 2006
May 28, 2006
807
808
809
810
811
812
813
814
815
816
817
818
819
820
double_buf = (flags & SDL_DOUBLEBUF) != 0;
hw_surface = (flags & SDL_HWSURFACE) != 0;
use_dsp_back_buffer = !dsp_vram_available || !hw_surface;
current->flags |= SDL_FULLSCREEN;
rebuild:
if (double_buf && use_dsp_back_buffer) {
page_count = 2;
} else {
page_count = 1;
}
May 29, 2006
May 29, 2006
821
SDL_memset(&attrib, 0, sizeof(DSpContextAttributes));
May 28, 2006
May 28, 2006
822
823
824
825
826
827
828
829
830
831
832
attrib.displayWidth = width;
attrib.displayHeight = height;
attrib.displayBestDepth = bpp;
attrib.backBufferBestDepth = bpp;
attrib.displayDepthMask = kDSpDepthMask_All;
attrib.backBufferDepthMask = kDSpDepthMask_All;
attrib.colorNeeds = kDSpColorNeeds_Require;
attrib.colorTable = 0;
attrib.pageCount = page_count;
#if TARGET_API_MAC_OSX || UNIVERSAL_INTERFACES_VERSION == 0x0320
May 29, 2006
May 29, 2006
833
834
if (DSpFindBestContext(&attrib, &dsp_context) != noErr) {
SDL_SetError("DrawSprocket couldn't find a context");
May 28, 2006
May 28, 2006
835
836
837
return NULL;
}
#else
May 29, 2006
May 29, 2006
838
if (noErr != DMGetDisplayIDByGDevice(SDL_Display, &display_id, SDL_FALSE)) {
May 28, 2006
May 28, 2006
839
840
841
842
SDL_SetError
("Display Manager couldn't associate GDevice with display_id");
return NULL;
}
May 29, 2006
May 29, 2006
843
if (DSpFindBestContextOnDisplayID(&attrib, &dsp_context, display_id) !=
May 28, 2006
May 28, 2006
844
845
846
847
848
849
noErr) {
SDL_SetError
("DrawSprocket couldn't find a suitable context on given display");
return NULL;
}
#endif
May 29, 2006
May 29, 2006
850
if (DSpContext_Reserve(dsp_context, &attrib) != noErr) {
May 28, 2006
May 28, 2006
851
852
853
854
855
856
SDL_SetError
("DrawSprocket couldn't get the needed resources to build the display");
return NULL;
}
if ((err =
May 29, 2006
May 29, 2006
857
DSpContext_SetState(dsp_context, kDSpContextState_Active)) != noErr)
May 28, 2006
May 28, 2006
858
859
860
861
{
if (err == kDSpConfirmSwitchWarning) {
May 29, 2006
May 29, 2006
862
if (!DSp_ConfirmSwitch()) {
May 28, 2006
May 28, 2006
863
May 29, 2006
May 29, 2006
864
DSpContext_Release(dsp_context);
May 28, 2006
May 28, 2006
865
dsp_context = NULL;
May 29, 2006
May 29, 2006
866
SDL_SetError("User cancelled display switch");
May 28, 2006
May 28, 2006
867
868
869
return NULL;
} else
/* Have to reactivate context. Why? */
May 29, 2006
May 29, 2006
870
DSpContext_SetState(dsp_context, kDSpContextState_Active);
May 28, 2006
May 28, 2006
871
872
} else {
May 29, 2006
May 29, 2006
873
SDL_SetError("DrawSprocket couldn't activate the context");
Apr 26, 2001
Apr 26, 2001
874
875
876
return NULL;
}
}
May 28, 2006
May 28, 2006
877
878
879
880
if (bpp != dsp_old_depth) {
May 29, 2006
May 29, 2006
881
DSp_CreatePalette(this);
May 28, 2006
May 28, 2006
882
883
884
885
886
887
888
889
/* update format if display depth changed */
if (bpp == 16) {
rmask = 0x00007c00;
gmask = 0x000003e0;
bmask = 0x0000001f;
}
May 29, 2006
May 29, 2006
890
if (!SDL_ReallocFormat(current, bpp, rmask, gmask, bmask, 0)) {
May 28, 2006
May 28, 2006
891
May 29, 2006
May 29, 2006
892
SDL_SetError("Could not reallocate video format.");
May 28, 2006
May 28, 2006
893
894
895
896
897
898
899
return (NULL);
}
}
if (!double_buf) {
/* single-buffer context */
May 29, 2006
May 29, 2006
900
DSpContext_GetFrontBuffer(dsp_context, &dsp_back_buffer);
May 28, 2006
May 28, 2006
901
902
current->hwdata =
May 29, 2006
May 29, 2006
903
(private_hwdata *) SDL_malloc(sizeof(private_hwdata));
May 28, 2006
May 28, 2006
904
if (current->hwdata == NULL) {
May 29, 2006
May 29, 2006
905
SDL_OutOfMemory();
May 28, 2006
May 28, 2006
906
907
908
909
910
911
912
return NULL;
}
current->hwdata->offscreen = dsp_back_buffer;
current->flags |= SDL_HWSURFACE;
this->UpdateRects = DSp_DirectUpdate;
} else if (use_dsp_back_buffer) {
May 29, 2006
May 29, 2006
913
914
DSpContext_GetBackBuffer(dsp_context, kDSpBufferKind_Normal,
&dsp_back_buffer);
May 28, 2006
May 28, 2006
915
916
917
918
919
920
921
current->flags |= SDL_DOUBLEBUF | SDL_SWSURFACE; /* only front buffer is in VRAM */
this->UpdateRects = DSp_DSpUpdate;
} else if (DSp_NewHWSurface
(this, &dsp_back_buffer, bpp, width - 1, height - 1) == 0) {
current->hwdata =
May 29, 2006
May 29, 2006
922
(private_hwdata *) SDL_malloc(sizeof(private_hwdata));
May 28, 2006
May 28, 2006
923
if (current->hwdata == NULL) {
May 29, 2006
May 29, 2006
924
SDL_OutOfMemory();
May 28, 2006
May 28, 2006
925
926
927
return NULL;
}
May 29, 2006
May 29, 2006
928
SDL_memset(current->hwdata, 0, sizeof(private_hwdata));
May 28, 2006
May 28, 2006
929
930
931
932
933
current->hwdata->offscreen = dsp_back_buffer;
current->flags |= SDL_DOUBLEBUF | SDL_HWSURFACE;
this->UpdateRects = DSp_DirectUpdate; /* hardware doesn't do update rects, must be page-flipped */
} else {
May 29, 2006
May 29, 2006
934
DSpContext_Release(dsp_context);
May 28, 2006
May 28, 2006
935
936
937
938
use_dsp_back_buffer = SDL_TRUE;
goto rebuild;
}
May 29, 2006
May 29, 2006
939
940
current->pitch = GetPortPixRowBytes(dsp_back_buffer) & 0x3FFF;
current->pixels = GetPixBaseAddr(GetPortPixMap(dsp_back_buffer));
May 28, 2006
May 28, 2006
941
942
943
944
945
946
947
948
current->w = width;
current->h = height;
#if ! TARGET_API_MAC_OSX
if (use_dsp_back_buffer) {
May 29, 2006
May 29, 2006
949
950
DSpContext_GetMonitorFrequency(dsp_context, &freq);
DSpContext_SetMaxFrameRate(dsp_context, freq >> 16);
May 28, 2006
May 28, 2006
951
952
953
954
955
}
if ((current->flags & SDL_HWSURFACE)
|| (current->flags & SDL_INTERNALOPENGL))
May 29, 2006
May 29, 2006
956
DSpContext_SetVBLProc(dsp_context, DSp_VBLProc, NULL);
May 28, 2006
May 28, 2006
957
958
959
960
961
962
963
964
965
966
967
#endif
if (bpp == 8)
current->flags |= SDL_HWPALETTE;
if (flags & SDL_INTERNALOPENGL) {
Rect rect;
RGBColor rgb = { 0.0, 0.0, 0.0 };
GrafPtr save_port;
May 29, 2006
May 29, 2006
968
SetRect(&rect, 0, 0, width, height);
May 28, 2006
May 28, 2006
969
SDL_Window =
May 29, 2006
May 29, 2006
970
971
NewCWindow(nil, &((**SDL_Display).gdRect), "\p", SDL_TRUE,
plainDBox, (WindowPtr) - 1, SDL_FALSE, 0);
May 28, 2006
May 28, 2006
972
973
974
975
976
977
978
979
980
if (SDL_Window == NULL) {
SDL_SetError
("DSp_SetVideoMode : OpenGL window could not be created.");
return NULL;
}
/* Set window color to black to avoid white flash */
May 29, 2006
May 29, 2006
981
GetPort(&save_port);
Sep 8, 2005
Sep 8, 2005
982
#if TARGET_API_MAC_CARBON
May 29, 2006
May 29, 2006
983
SetPort(GetWindowPort(SDL_Window));
Sep 8, 2005
Sep 8, 2005
984
#else
May 29, 2006
May 29, 2006
985
SetPort(SDL_Window);
Sep 8, 2005
Sep 8, 2005
986
#endif
May 29, 2006
May 29, 2006
987
988
989
RGBForeColor(&rgb);
PaintRect(&rect);
SetPort(save_port);
May 28, 2006
May 28, 2006
990
May 29, 2006
May 29, 2006
991
992
SetPortWindowPort(SDL_Window);
SelectWindow(SDL_Window);
May 28, 2006
May 28, 2006
993
May 29, 2006
May 29, 2006
994
if (Mac_GL_Init(this) < 0) {
May 28, 2006
May 28, 2006
995
996
997
998
999
1000
SDL_SetError
("DSp_SetVideoMode : could not create OpenGL context.");
return NULL;
}