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