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