Mercurial > sdl-ios-xcode
annotate src/video/bwindow/SDL_sysvideo.cc @ 1367:e440d5c488c1
Fixes for BeOS and Solaris builds
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 17 Feb 2006 08:43:23 +0000 |
parents | 19418e4422cb |
children | 376665398b25 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
206
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 /* BWindow based framebuffer implementation */ | |
24 | |
25 #include <unistd.h> | |
26 | |
27 #include "SDL_BWin.h" | |
28 #include "SDL_timer.h" | |
29 | |
30 extern "C" { | |
31 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
32 #include "../SDL_sysvideo.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
33 #include "../../events/SDL_events_c.h" |
1367
e440d5c488c1
Fixes for BeOS and Solaris builds
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
34 #include "SDL_sysevents_c.h" |
0 | 35 #include "SDL_sysmouse_c.h" |
36 #include "SDL_syswm_c.h" | |
37 #include "SDL_lowvideo.h" | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
38 #include "../SDL_yuvfuncs.h" |
756
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
39 #include "SDL_sysyuv.h" |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
40 #include "../blank_cursor.h" |
0 | 41 |
42 #define BEOS_HIDDEN_SIZE 32 /* starting hidden window size */ | |
43 | |
44 /* Initialization/Query functions */ | |
45 static int BE_VideoInit(_THIS, SDL_PixelFormat *vformat); | |
46 static SDL_Rect **BE_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); | |
47 static SDL_Surface *BE_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); | |
48 static void BE_UpdateMouse(_THIS); | |
49 static int BE_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); | |
50 static void BE_VideoQuit(_THIS); | |
51 | |
52 /* Hardware surface functions */ | |
53 static int BE_AllocHWSurface(_THIS, SDL_Surface *surface); | |
54 static int BE_LockHWSurface(_THIS, SDL_Surface *surface); | |
55 static void BE_UnlockHWSurface(_THIS, SDL_Surface *surface); | |
56 static void BE_FreeHWSurface(_THIS, SDL_Surface *surface); | |
57 | |
58 static int BE_ToggleFullScreen(_THIS, int fullscreen); | |
756
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
59 static SDL_Overlay *BE_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display); |
0 | 60 |
61 /* OpenGL functions */ | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
62 #if SDL_VIDEO_OPENGL |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
63 static int BE_GL_LoadLibrary(_THIS, const char *path); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
64 static void* BE_GL_GetProcAddress(_THIS, const char *proc); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
65 static int BE_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
66 static int BE_GL_MakeCurrent(_THIS); |
0 | 67 static void BE_GL_SwapBuffers(_THIS); |
68 #endif | |
69 | |
70 /* FB driver bootstrap functions */ | |
71 | |
72 static int BE_Available(void) | |
73 { | |
74 return(1); | |
75 } | |
76 | |
77 static void BE_DeleteDevice(SDL_VideoDevice *device) | |
78 { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
79 SDL_free(device->hidden); |
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
80 SDL_free(device); |
0 | 81 } |
82 | |
83 static SDL_VideoDevice *BE_CreateDevice(int devindex) | |
84 { | |
85 SDL_VideoDevice *device; | |
86 | |
87 /* Initialize all variables that we clean on shutdown */ | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
88 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); |
0 | 89 if ( device ) { |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
90 SDL_memset(device, 0, (sizeof *device)); |
0 | 91 device->hidden = (struct SDL_PrivateVideoData *) |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
92 SDL_malloc((sizeof *device->hidden)); |
0 | 93 } |
94 if ( (device == NULL) || (device->hidden == NULL) ) { | |
95 SDL_OutOfMemory(); | |
96 if ( device ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
97 SDL_free(device); |
0 | 98 } |
99 return(0); | |
100 } | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
101 SDL_memset(device->hidden, 0, (sizeof *device->hidden)); |
0 | 102 |
103 /* Set the function pointers */ | |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
104 /* Initialization/Query functions */ |
0 | 105 device->VideoInit = BE_VideoInit; |
106 device->ListModes = BE_ListModes; | |
107 device->SetVideoMode = BE_SetVideoMode; | |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
108 device->ToggleFullScreen = BE_ToggleFullScreen; |
0 | 109 device->UpdateMouse = BE_UpdateMouse; |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
110 device->CreateYUVOverlay = BE_CreateYUVOverlay; |
0 | 111 device->SetColors = BE_SetColors; |
112 device->UpdateRects = NULL; | |
113 device->VideoQuit = BE_VideoQuit; | |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
114 /* Hardware acceleration functions */ |
0 | 115 device->AllocHWSurface = BE_AllocHWSurface; |
116 device->CheckHWBlit = NULL; | |
117 device->FillHWRect = NULL; | |
118 device->SetHWColorKey = NULL; | |
119 device->SetHWAlpha = NULL; | |
120 device->LockHWSurface = BE_LockHWSurface; | |
121 device->UnlockHWSurface = BE_UnlockHWSurface; | |
122 device->FlipHWSurface = NULL; | |
123 device->FreeHWSurface = BE_FreeHWSurface; | |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
124 /* Gamma support */ |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
125 #if SDL_VIDEO_OPENGL |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
126 /* OpenGL support */ |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
127 device->GL_LoadLibrary = BE_GL_LoadLibrary; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
128 device->GL_GetProcAddress = BE_GL_GetProcAddress; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
129 device->GL_GetAttribute = BE_GL_GetAttribute; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
130 device->GL_MakeCurrent = BE_GL_MakeCurrent; |
0 | 131 device->GL_SwapBuffers = BE_GL_SwapBuffers; |
132 #endif | |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
133 /* Window manager functions */ |
0 | 134 device->SetCaption = BE_SetWMCaption; |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
135 device->SetIcon = NULL; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
136 device->IconifyWindow = BE_IconifyWindow; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
137 device->GrabInput = NULL; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
138 device->GetWMInfo = BE_GetWMInfo; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
139 /* Cursor manager functions */ |
0 | 140 device->FreeWMCursor = BE_FreeWMCursor; |
141 device->CreateWMCursor = BE_CreateWMCursor; | |
142 device->ShowWMCursor = BE_ShowWMCursor; | |
143 device->WarpWMCursor = BE_WarpWMCursor; | |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
144 device->MoveWMCursor = NULL; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
145 device->CheckMouseMode = NULL; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
146 /* Event manager functions */ |
0 | 147 device->InitOSKeymap = BE_InitOSKeymap; |
148 device->PumpEvents = BE_PumpEvents; | |
149 | |
150 device->free = BE_DeleteDevice; | |
151 | |
152 /* Set the driver flags */ | |
153 device->handles_any_size = 1; | |
154 | |
155 return device; | |
156 } | |
157 | |
158 VideoBootStrap BWINDOW_bootstrap = { | |
159 "bwindow", "BDirectWindow graphics", | |
160 BE_Available, BE_CreateDevice | |
161 }; | |
162 | |
163 static inline int ColorSpaceToBitsPerPixel(uint32 colorspace) | |
164 { | |
165 int bitsperpixel; | |
166 | |
167 bitsperpixel = 0; | |
168 switch (colorspace) { | |
169 case B_CMAP8: | |
170 bitsperpixel = 8; | |
171 break; | |
172 case B_RGB15: | |
173 case B_RGBA15: | |
174 case B_RGB15_BIG: | |
175 case B_RGBA15_BIG: | |
176 bitsperpixel = 15; | |
177 break; | |
178 case B_RGB16: | |
179 case B_RGB16_BIG: | |
180 bitsperpixel = 16; | |
181 break; | |
182 case B_RGB32: | |
183 case B_RGBA32: | |
184 case B_RGB32_BIG: | |
185 case B_RGBA32_BIG: | |
186 bitsperpixel = 32; | |
187 break; | |
188 default: | |
189 break; | |
190 } | |
191 return(bitsperpixel); | |
192 } | |
193 | |
194 /* Function to sort the display_list in bscreen */ | |
195 static int CompareModes(const void *A, const void *B) | |
196 { | |
197 const display_mode *a = (display_mode *)A; | |
198 const display_mode *b = (display_mode *)B; | |
199 | |
200 if ( a->space == b->space ) { | |
201 return((b->virtual_width*b->virtual_height)- | |
202 (a->virtual_width*a->virtual_height)); | |
203 } else { | |
204 return(ColorSpaceToBitsPerPixel(b->space)- | |
205 ColorSpaceToBitsPerPixel(a->space)); | |
206 } | |
207 } | |
208 | |
209 /* Yes, this isn't the fastest it could be, but it works nicely */ | |
210 static int BE_AddMode(_THIS, int index, unsigned int w, unsigned int h) | |
211 { | |
212 SDL_Rect *mode; | |
213 int i; | |
214 int next_mode; | |
215 | |
216 /* Check to see if we already have this mode */ | |
217 if ( SDL_nummodes[index] > 0 ) { | |
218 for ( i=SDL_nummodes[index]-1; i >= 0; --i ) { | |
219 mode = SDL_modelist[index][i]; | |
220 if ( (mode->w == w) && (mode->h == h) ) { | |
221 #ifdef BWINDOW_DEBUG | |
222 fprintf(stderr, "We already have mode %dx%d at %d bytes per pixel\n", w, h, index+1); | |
223 #endif | |
224 return(0); | |
225 } | |
226 } | |
227 } | |
228 | |
229 /* Set up the new video mode rectangle */ | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
230 mode = (SDL_Rect *)SDL_malloc(sizeof *mode); |
0 | 231 if ( mode == NULL ) { |
232 SDL_OutOfMemory(); | |
233 return(-1); | |
234 } | |
235 mode->x = 0; | |
236 mode->y = 0; | |
237 mode->w = w; | |
238 mode->h = h; | |
239 #ifdef BWINDOW_DEBUG | |
240 fprintf(stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h, index+1); | |
241 #endif | |
242 | |
243 /* Allocate the new list of modes, and fill in the new mode */ | |
244 next_mode = SDL_nummodes[index]; | |
245 SDL_modelist[index] = (SDL_Rect **) | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
246 SDL_realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); |
0 | 247 if ( SDL_modelist[index] == NULL ) { |
248 SDL_OutOfMemory(); | |
249 SDL_nummodes[index] = 0; | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
250 SDL_free(mode); |
0 | 251 return(-1); |
252 } | |
253 SDL_modelist[index][next_mode] = mode; | |
254 SDL_modelist[index][next_mode+1] = NULL; | |
255 SDL_nummodes[index]++; | |
256 | |
257 return(0); | |
258 } | |
259 | |
260 int BE_VideoInit(_THIS, SDL_PixelFormat *vformat) | |
261 { | |
262 display_mode *modes; | |
263 uint32 i, nmodes; | |
264 int bpp; | |
265 BRect bounds; | |
266 | |
267 /* Initialize the Be Application for appserver interaction */ | |
268 if ( SDL_InitBeApp() < 0 ) { | |
269 return(-1); | |
270 } | |
271 | |
272 /* It is important that this be created after SDL_InitBeApp() */ | |
273 BScreen bscreen; | |
274 | |
275 /* Save the current display mode */ | |
276 bscreen.GetMode(&saved_mode); | |
277 | |
278 /* Determine the screen depth */ | |
279 vformat->BitsPerPixel = ColorSpaceToBitsPerPixel(bscreen.ColorSpace()); | |
280 if ( vformat->BitsPerPixel == 0 ) { | |
281 SDL_SetError("Unknown BScreen colorspace: 0x%x", | |
282 bscreen.ColorSpace()); | |
283 return(-1); | |
284 } | |
285 | |
286 /* Get the video modes we can switch to in fullscreen mode */ | |
287 bscreen.GetModeList(&modes, &nmodes); | |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
288 SDL_qsort(modes, nmodes, sizeof *modes, CompareModes); |
0 | 289 for ( i=0; i<nmodes; ++i ) { |
290 bpp = ColorSpaceToBitsPerPixel(modes[i].space); | |
291 //if ( bpp != 0 ) { // There are bugs in changing colorspace | |
292 if ( modes[i].space == saved_mode.space ) { | |
293 BE_AddMode(_this, ((bpp+7)/8)-1, | |
294 modes[i].virtual_width, | |
295 modes[i].virtual_height); | |
296 } | |
297 } | |
298 | |
299 /* Create the window and view */ | |
300 bounds.top = 0; bounds.left = 0; | |
301 bounds.right = BEOS_HIDDEN_SIZE; | |
302 bounds.bottom = BEOS_HIDDEN_SIZE; | |
303 SDL_Win = new SDL_BWin(bounds); | |
304 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
305 #if SDL_VIDEO_OPENGL |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
306 /* testgl application doesn't load library, just tries to load symbols */ |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
307 /* is it correct? if so we have to load library here */ |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
308 BE_GL_LoadLibrary(_this, NULL); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
309 #endif |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
310 |
0 | 311 /* Create the clear cursor */ |
312 SDL_BlankCursor = BE_CreateWMCursor(_this, blank_cdata, blank_cmask, | |
313 BLANK_CWIDTH, BLANK_CHEIGHT, BLANK_CHOTX, BLANK_CHOTY); | |
314 | |
315 /* Fill in some window manager capabilities */ | |
316 _this->info.wm_available = 1; | |
317 | |
318 /* We're done! */ | |
319 return(0); | |
320 } | |
321 | |
322 /* We support any dimension at our bit-depth */ | |
323 SDL_Rect **BE_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | |
324 { | |
325 SDL_Rect **modes; | |
326 | |
327 modes = ((SDL_Rect **)0); | |
328 if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | |
329 modes = SDL_modelist[((format->BitsPerPixel+7)/8)-1]; | |
330 } else { | |
331 if ( format->BitsPerPixel == | |
332 _this->screen->format->BitsPerPixel ) { | |
333 modes = ((SDL_Rect **)-1); | |
334 } | |
335 } | |
336 return(modes); | |
337 } | |
338 | |
339 /* Various screen update functions available */ | |
340 static void BE_NormalUpdate(_THIS, int numrects, SDL_Rect *rects); | |
341 | |
342 | |
343 /* Find the closest display mode for fullscreen */ | |
344 static bool BE_FindClosestFSMode(_THIS, int width, int height, int bpp, | |
345 display_mode *mode) | |
346 { | |
347 BScreen bscreen; | |
348 uint32 i, nmodes; | |
349 SDL_Rect **modes; | |
350 display_mode *dmodes; | |
756
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
351 display_mode current; |
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
352 float current_refresh; |
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
353 bscreen.GetMode(¤t); |
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
354 current_refresh = (1000 * current.timing.pixel_clock) / |
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
355 (current.timing.h_total * current.timing.v_total); |
0 | 356 |
357 modes = SDL_modelist[((bpp+7)/8)-1]; | |
358 for ( i=0; modes[i] && (modes[i]->w > width) && | |
359 (modes[i]->h > height); ++i ) { | |
360 /* still looking */ | |
361 } | |
362 if ( ! modes[i] || (modes[i]->w < width) || (modes[i]->h < width) ) { | |
363 --i; /* We went too far */ | |
364 } | |
365 width = modes[i]->w; | |
366 height = modes[i]->h; | |
367 bscreen.GetModeList(&dmodes, &nmodes); | |
368 for ( i = 0; i < nmodes; ++i ) { | |
369 if ( (bpp == ColorSpaceToBitsPerPixel(dmodes[i].space)) && | |
370 (width == dmodes[i].virtual_width) && | |
371 (height == dmodes[i].virtual_height) ) { | |
372 break; | |
373 } | |
374 } | |
375 if ( i != nmodes ) { | |
376 *mode = dmodes[i]; | |
756
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
377 if ((mode->virtual_width <= current.virtual_width) && |
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
378 (mode->virtual_height <= current.virtual_height)) { |
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
379 float new_refresh = (1000 * mode->timing.pixel_clock) / |
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
380 (mode->timing.h_total * mode->timing.v_total); |
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
381 if (new_refresh < current_refresh) { |
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
382 mode->timing.pixel_clock = (uint32)((mode->timing.h_total * mode->timing.v_total) |
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
383 * current_refresh / 1000); |
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
384 } |
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
385 } |
0 | 386 return true; |
387 } else { | |
388 return false; | |
389 } | |
390 } | |
391 | |
114
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
392 static int BE_SetFullScreen(_THIS, SDL_Surface *screen, int fullscreen) |
0 | 393 { |
114
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
394 int was_fullscreen; |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
395 bool needs_unlock; |
0 | 396 BScreen bscreen; |
397 BRect bounds; | |
398 display_mode mode; | |
399 int width, height, bpp; | |
400 | |
114
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
401 /* Set the fullscreen mode */ |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
402 was_fullscreen = SDL_Win->IsFullScreen(); |
0 | 403 SDL_Win->SetFullScreen(fullscreen); |
114
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
404 fullscreen = SDL_Win->IsFullScreen(); |
0 | 405 |
114
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
406 width = screen->w; |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
407 height = screen->h; |
0 | 408 |
409 /* Set the appropriate video mode */ | |
410 if ( fullscreen ) { | |
114
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
411 bpp = screen->format->BitsPerPixel; |
0 | 412 bscreen.GetMode(&mode); |
413 if ( (bpp != ColorSpaceToBitsPerPixel(mode.space)) || | |
414 (width != mode.virtual_width) || | |
415 (height != mode.virtual_height)) { | |
416 if(BE_FindClosestFSMode(_this, width, height, bpp, &mode)) { | |
417 bscreen.SetMode(&mode); | |
418 /* This simply stops the next resize event from being | |
419 * sent to the SDL handler. | |
420 */ | |
421 SDL_Win->InhibitResize(); | |
422 } else { | |
114
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
423 fullscreen = 0; |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
424 SDL_Win->SetFullScreen(fullscreen); |
0 | 425 } |
426 } | |
114
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
427 } |
206
b69bb2a368a0
Fixed flashing the screen when creating a window on BeOS
Sam Lantinga <slouken@libsdl.org>
parents:
115
diff
changeset
|
428 if ( was_fullscreen && ! fullscreen ) { |
0 | 429 bscreen.SetMode(&saved_mode); |
430 } | |
114
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
431 |
0 | 432 if ( SDL_Win->Lock() ) { |
433 int xoff, yoff; | |
434 if ( SDL_Win->Shown() ) { | |
435 needs_unlock = 1; | |
436 SDL_Win->Hide(); | |
437 } else { | |
438 needs_unlock = 0; | |
439 } | |
114
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
440 /* This resizes the window and view area, but inhibits resizing |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
441 * of the BBitmap due to the InhibitResize call above. Thus the |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
442 * bitmap (pixel data) never changes. |
0 | 443 */ |
444 SDL_Win->ResizeTo(width, height); | |
445 bounds = bscreen.Frame(); | |
114
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
446 /* Calculate offsets - used either to center window |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
447 * (windowed mode) or to set drawing offsets (fullscreen mode) |
0 | 448 */ |
114
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
449 xoff = (bounds.IntegerWidth() - width)/2; |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
450 yoff = (bounds.IntegerHeight() - height)/2; |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
451 if ( fullscreen ) { |
0 | 452 /* Set offset for drawing */ |
453 SDL_Win->SetXYOffset(xoff, yoff); | |
454 } else { | |
455 /* Center window and reset the drawing offset */ | |
456 SDL_Win->SetXYOffset(0, 0); | |
457 } | |
114
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
458 if ( ! needs_unlock || was_fullscreen ) { |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
459 /* Center the window the first time */ |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
460 SDL_Win->MoveTo(xoff > 0 ? (float)xoff : 0.0f, |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
461 yoff > 0 ? (float)yoff : 0.0f); |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
462 } |
0 | 463 SDL_Win->Show(); |
464 | |
465 /* Unlock the window manually after the first Show() */ | |
114
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
466 if ( needs_unlock ) { |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
467 SDL_Win->Unlock(); |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
468 } |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
469 } |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
470 |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
471 /* Set the fullscreen flag in the screen surface */ |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
472 if ( fullscreen ) { |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
473 screen->flags |= SDL_FULLSCREEN; |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
474 } else { |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
475 screen->flags &= ~SDL_FULLSCREEN; |
0 | 476 } |
477 return(1); | |
478 } | |
479 | |
114
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
480 static int BE_ToggleFullScreen(_THIS, int fullscreen) |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
481 { |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
482 return BE_SetFullScreen(_this, _this->screen, fullscreen); |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
483 } |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
484 |
0 | 485 /* FIXME: check return values and cleanup here */ |
486 SDL_Surface *BE_SetVideoMode(_THIS, SDL_Surface *current, | |
487 int width, int height, int bpp, Uint32 flags) | |
488 { | |
489 BScreen bscreen; | |
490 BBitmap *bbitmap; | |
491 BRect bounds; | |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
492 Uint32 gl_flags = 0; |
0 | 493 |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
494 /* Only RGB works on r5 currently */ |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
495 gl_flags = BGL_RGB; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
496 if (_this->gl_config.double_buffer) |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
497 gl_flags |= BGL_DOUBLE; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
498 else |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
499 gl_flags |= BGL_SINGLE; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
500 if (_this->gl_config.alpha_size > 0 || bpp == 32) |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
501 gl_flags |= BGL_ALPHA; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
502 if (_this->gl_config.depth_size > 0) |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
503 gl_flags |= BGL_DEPTH; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
504 if (_this->gl_config.stencil_size > 0) |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
505 gl_flags |= BGL_STENCIL; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
506 if (_this->gl_config.accum_red_size > 0 |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
507 || _this->gl_config.accum_green_size > 0 |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
508 || _this->gl_config.accum_blue_size > 0 |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
509 || _this->gl_config.accum_alpha_size > 0) |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
510 gl_flags |= BGL_ACCUM; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
511 |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
512 /* Create the view for this window, using found flags */ |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
513 if ( SDL_Win->CreateView(flags, gl_flags) < 0 ) { |
0 | 514 return(NULL); |
515 } | |
516 | |
517 current->flags = 0; /* Clear flags */ | |
518 current->w = width; | |
519 current->h = height; | |
520 SDL_Win->SetType(B_TITLED_WINDOW); | |
521 if ( flags & SDL_NOFRAME ) { | |
522 current->flags |= SDL_NOFRAME; | |
523 SDL_Win->SetLook(B_NO_BORDER_WINDOW_LOOK); | |
524 } else { | |
525 if ( (flags & SDL_RESIZABLE) && !(flags & SDL_OPENGL) ) { | |
526 current->flags |= SDL_RESIZABLE; | |
527 /* We don't want opaque resizing (TM). :-) */ | |
528 SDL_Win->SetFlags(B_OUTLINE_RESIZE); | |
529 } else { | |
530 SDL_Win->SetFlags(B_NOT_RESIZABLE|B_NOT_ZOOMABLE); | |
531 } | |
532 } | |
533 | |
534 if ( flags & SDL_OPENGL ) { | |
535 current->flags |= SDL_OPENGL; | |
536 current->pitch = 0; | |
537 current->pixels = NULL; | |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
538 _this->UpdateRects = NULL; |
0 | 539 } else { |
540 /* Create the BBitmap framebuffer */ | |
541 bounds.top = 0; bounds.left = 0; | |
542 bounds.right = width-1; | |
543 bounds.bottom = height-1; | |
544 bbitmap = new BBitmap(bounds, bscreen.ColorSpace()); | |
545 if ( ! bbitmap->IsValid() ) { | |
546 SDL_SetError("Couldn't create screen bitmap"); | |
547 delete bbitmap; | |
548 return(NULL); | |
549 } | |
550 current->pitch = bbitmap->BytesPerRow(); | |
551 current->pixels = (void *)bbitmap->Bits(); | |
552 SDL_Win->SetBitmap(bbitmap); | |
553 _this->UpdateRects = BE_NormalUpdate; | |
554 } | |
555 | |
114
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
556 /* Set the correct fullscreen mode */ |
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
557 BE_SetFullScreen(_this, current, flags & SDL_FULLSCREEN ? 1 : 0); |
0 | 558 |
559 /* We're done */ | |
560 return(current); | |
561 } | |
562 | |
563 /* Update the current mouse state and position */ | |
564 void BE_UpdateMouse(_THIS) | |
565 { | |
566 BPoint point; | |
567 uint32 buttons; | |
568 | |
569 if ( SDL_Win->Lock() ) { | |
570 /* Get new input state, if still active */ | |
571 if ( SDL_Win->IsActive() ) { | |
572 (SDL_Win->View())->GetMouse(&point, &buttons, true); | |
573 } else { | |
574 point.x = -1; | |
575 point.y = -1; | |
576 } | |
577 SDL_Win->Unlock(); | |
578 | |
579 if ( (point.x >= 0) && (point.x < SDL_VideoSurface->w) && | |
580 (point.y >= 0) && (point.y < SDL_VideoSurface->h) ) { | |
581 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); | |
582 SDL_PrivateMouseMotion(0, 0, | |
583 (Sint16)point.x, (Sint16)point.y); | |
584 } else { | |
585 SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); | |
586 } | |
587 } | |
588 } | |
589 | |
590 /* We don't actually allow hardware surfaces other than the main one */ | |
591 static int BE_AllocHWSurface(_THIS, SDL_Surface *surface) | |
592 { | |
593 return(-1); | |
594 } | |
595 static void BE_FreeHWSurface(_THIS, SDL_Surface *surface) | |
596 { | |
597 return; | |
598 } | |
599 static int BE_LockHWSurface(_THIS, SDL_Surface *surface) | |
600 { | |
601 return(0); | |
602 } | |
603 static void BE_UnlockHWSurface(_THIS, SDL_Surface *surface) | |
604 { | |
605 return; | |
606 } | |
607 | |
608 static void BE_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) | |
609 { | |
610 if ( SDL_Win->BeginDraw() ) { | |
611 int i; | |
612 | |
613 for ( i=0; i<numrects; ++i ) { | |
614 BRect rect; | |
615 | |
616 rect.top = rects[i].y; | |
617 rect.left = rects[i].x; | |
618 rect.bottom = rect.top+rects[i].h-1; | |
619 rect.right = rect.left+rects[i].w-1; | |
620 SDL_Win->DrawAsync(rect); | |
621 } | |
622 SDL_Win->EndDraw(); | |
623 } | |
624 } | |
625 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
626 #if SDL_VIDEO_OPENGL |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
627 /* Passing a NULL path means load pointers from the application */ |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
628 int BE_GL_LoadLibrary(_THIS, const char *path) |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
629 { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
630 if (path == NULL) { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
631 if (_this->gl_config.dll_handle == NULL) { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
632 image_info info; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
633 int32 cookie = 0; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
634 while (get_next_image_info(0,&cookie,&info) == B_OK) { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
635 void *location = NULL; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
636 if (get_image_symbol((image_id)cookie,"glBegin",B_SYMBOL_TYPE_ANY,&location) == B_OK) { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
637 _this->gl_config.dll_handle = (void*)cookie; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
638 _this->gl_config.driver_loaded = 1; |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
639 SDL_strncpy(_this->gl_config.driver_path, "libGL.so", sizeof(_this->gl_config.driver_path)-1); |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
640 } |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
641 } |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
642 } |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
643 } else { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
644 /* |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
645 FIXME None of BeOS libGL.so implementations have exported functions |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
646 to load BGLView, which should be reloaded from new lib. |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
647 So for now just "load" linked libGL.so :( |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
648 */ |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
649 if (_this->gl_config.dll_handle == NULL) { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
650 return BE_GL_LoadLibrary(_this, NULL); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
651 } |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
652 |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
653 /* Unload old first */ |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
654 /*if (_this->gl_config.dll_handle != NULL) {*/ |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
655 /* Do not try to unload application itself (if LoadLibrary was called before with NULL ;) */ |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
656 /* image_info info; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
657 if (get_image_info((image_id)_this->gl_config.dll_handle, &info) == B_OK) { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
658 if (info.type != B_APP_IMAGE) { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
659 unload_add_on((image_id)_this->gl_config.dll_handle); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
660 } |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
661 } |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
662 |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
663 } |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
664 |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
665 if ((_this->gl_config.dll_handle = (void*)load_add_on(path)) != (void*)B_ERROR) { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
666 _this->gl_config.driver_loaded = 1; |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
667 SDL_strncpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path)-1); |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
668 }*/ |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
669 } |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
670 |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
671 if (_this->gl_config.dll_handle != NULL) { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
672 return 0; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
673 } else { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
674 _this->gl_config.dll_handle = NULL; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
675 _this->gl_config.driver_loaded = 0; |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
676 SDL_strcpy(_this->gl_config.driver_path, ""); |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
677 return -1; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
678 } |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
679 } |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
680 |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
681 void* BE_GL_GetProcAddress(_THIS, const char *proc) |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
682 { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
683 if (_this->gl_config.dll_handle != NULL) { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
684 void *location = NULL; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
685 status_t err; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
686 if ((err = get_image_symbol((image_id)_this->gl_config.dll_handle, proc, B_SYMBOL_TYPE_ANY, &location)) == B_OK) { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
687 return location; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
688 } else { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
689 SDL_SetError("Couldn't find OpenGL symbol"); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
690 return NULL; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
691 } |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
692 } else { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
693 SDL_SetError("OpenGL library not loaded"); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
694 return NULL; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
695 } |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
696 } |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
697 |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
698 int BE_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
699 { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
700 /* |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
701 FIXME? Right now BE_GL_GetAttribute shouldn't be called between glBegin() and glEnd() - it doesn't use "cached" values |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
702 */ |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
703 switch (attrib) |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
704 { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
705 case SDL_GL_RED_SIZE: |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
706 glGetIntegerv(GL_RED_BITS, (GLint*)value); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
707 break; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
708 case SDL_GL_GREEN_SIZE: |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
709 glGetIntegerv(GL_GREEN_BITS, (GLint*)value); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
710 break; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
711 case SDL_GL_BLUE_SIZE: |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
712 glGetIntegerv(GL_BLUE_BITS, (GLint*)value); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
713 break; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
714 case SDL_GL_ALPHA_SIZE: |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
715 glGetIntegerv(GL_ALPHA_BITS, (GLint*)value); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
716 break; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
717 case SDL_GL_DOUBLEBUFFER: |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
718 glGetBooleanv(GL_DOUBLEBUFFER, (GLboolean*)value); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
719 break; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
720 case SDL_GL_BUFFER_SIZE: |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
721 int v; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
722 glGetIntegerv(GL_RED_BITS, (GLint*)&v); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
723 *value = v; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
724 glGetIntegerv(GL_GREEN_BITS, (GLint*)&v); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
725 *value += v; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
726 glGetIntegerv(GL_BLUE_BITS, (GLint*)&v); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
727 *value += v; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
728 glGetIntegerv(GL_ALPHA_BITS, (GLint*)&v); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
729 *value += v; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
730 break; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
731 case SDL_GL_DEPTH_SIZE: |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
732 glGetIntegerv(GL_DEPTH_BITS, (GLint*)value); /* Mesa creates 16 only? r5 always 32 */ |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
733 break; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
734 case SDL_GL_STENCIL_SIZE: |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
735 glGetIntegerv(GL_STENCIL_BITS, (GLint*)value); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
736 break; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
737 case SDL_GL_ACCUM_RED_SIZE: |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
738 glGetIntegerv(GL_ACCUM_RED_BITS, (GLint*)value); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
739 break; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
740 case SDL_GL_ACCUM_GREEN_SIZE: |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
741 glGetIntegerv(GL_ACCUM_GREEN_BITS, (GLint*)value); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
742 break; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
743 case SDL_GL_ACCUM_BLUE_SIZE: |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
744 glGetIntegerv(GL_ACCUM_BLUE_BITS, (GLint*)value); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
745 break; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
746 case SDL_GL_ACCUM_ALPHA_SIZE: |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
747 glGetIntegerv(GL_ACCUM_ALPHA_BITS, (GLint*)value); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
748 break; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
749 case SDL_GL_STEREO: |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
750 case SDL_GL_MULTISAMPLEBUFFERS: |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
751 case SDL_GL_MULTISAMPLESAMPLES: |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
752 default: |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
753 *value=0; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
754 return(-1); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
755 } |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
756 return 0; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
757 } |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
758 |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
759 int BE_GL_MakeCurrent(_THIS) |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
760 { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
761 /* FIXME: should we glview->unlock and then glview->lock()? */ |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
762 return 0; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
763 } |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
764 |
0 | 765 void BE_GL_SwapBuffers(_THIS) |
766 { | |
767 SDL_Win->SwapBuffers(); | |
768 } | |
769 #endif | |
770 | |
771 /* Is the system palette settable? */ | |
772 int BE_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | |
773 { | |
774 int i; | |
775 SDL_Palette *palette; | |
776 const color_map *cmap = BScreen().ColorMap(); | |
777 | |
778 /* Get the screen colormap */ | |
779 palette = _this->screen->format->palette; | |
780 for ( i=0; i<256; ++i ) { | |
781 palette->colors[i].r = cmap->color_list[i].red; | |
782 palette->colors[i].g = cmap->color_list[i].green; | |
783 palette->colors[i].b = cmap->color_list[i].blue; | |
784 } | |
785 return(0); | |
786 } | |
787 | |
788 void BE_VideoQuit(_THIS) | |
789 { | |
790 int i, j; | |
791 | |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
792 SDL_Win->Quit(); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
793 SDL_Win = NULL; |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
794 |
0 | 795 if ( SDL_BlankCursor != NULL ) { |
796 BE_FreeWMCursor(_this, SDL_BlankCursor); | |
797 SDL_BlankCursor = NULL; | |
798 } | |
799 for ( i=0; i<NUM_MODELISTS; ++i ) { | |
800 if ( SDL_modelist[i] ) { | |
801 for ( j=0; SDL_modelist[i][j]; ++j ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
802 SDL_free(SDL_modelist[i][j]); |
0 | 803 } |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
804 SDL_free(SDL_modelist[i]); |
0 | 805 SDL_modelist[i] = NULL; |
806 } | |
807 } | |
808 /* Restore the original video mode */ | |
809 if ( _this->screen ) { | |
810 if ( (_this->screen->flags&SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | |
811 BScreen bscreen; | |
812 bscreen.SetMode(&saved_mode); | |
813 } | |
814 _this->screen->pixels = NULL; | |
815 } | |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
816 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
817 #if SDL_VIDEO_OPENGL |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
818 if (_this->gl_config.dll_handle != NULL) |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
819 unload_add_on((image_id)_this->gl_config.dll_handle); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
820 #endif |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
821 |
0 | 822 SDL_QuitBeApp(); |
823 } | |
824 | |
825 }; /* Extern C */ |