annotate src/video/bwindow/SDL_sysvideo.cc @ 1192:54aa9aa32327

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