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