src/video/bwindow/SDL_bvideo.cc
author Nathan Heisey <nathanheisey@gmail.com>
Wed, 20 Jul 2011 19:25:38 +0000
changeset 5921 4cec9ba57dfb
parent 5918 2063df37190b
child 5926 d9d57de9fb4e
permissions -rw-r--r--
Framebuffer support in progress.
nathanheisey@5918
     1
/*
nathanheisey@5918
     2
  Simple DirectMedia Layer
nathanheisey@5918
     3
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
nathanheisey@5918
     4
nathanheisey@5918
     5
  This software is provided 'as-is', without any express or implied
nathanheisey@5918
     6
  warranty.  In no event will the authors be held liable for any damages
nathanheisey@5918
     7
  arising from the use of this software.
nathanheisey@5918
     8
nathanheisey@5918
     9
  Permission is granted to anyone to use this software for any purpose,
nathanheisey@5918
    10
  including commercial applications, and to alter it and redistribute it
nathanheisey@5918
    11
  freely, subject to the following restrictions:
nathanheisey@5918
    12
nathanheisey@5918
    13
  1. The origin of this software must not be misrepresented; you must not
nathanheisey@5918
    14
     claim that you wrote the original software. If you use this software
nathanheisey@5918
    15
     in a product, an acknowledgment in the product documentation would be
nathanheisey@5918
    16
     appreciated but is not required.
nathanheisey@5918
    17
  2. Altered source versions must be plainly marked as such, and must not be
nathanheisey@5918
    18
     misrepresented as being the original software.
nathanheisey@5918
    19
  3. This notice may not be removed or altered from any source distribution.
nathanheisey@5918
    20
*/
nathanheisey@5918
    21
nathanheisey@5918
    22
nathanheisey@5921
    23
nathanheisey@5921
    24
nathanheisey@5921
    25
#ifdef __cplusplus
nathanheisey@5921
    26
extern "C" {
nathanheisey@5921
    27
#endif
nathanheisey@5921
    28
nathanheisey@5918
    29
#include "SDL_bwindow.h"
nathanheisey@5918
    30
#include "SDL_bclipboard.h"
nathanheisey@5918
    31
#include "SDL_bvideo.h"
nathanheisey@5918
    32
#include "SDL_bopengl.h"
nathanheisey@5918
    33
#include "SDL_bmodes.h"
nathanheisey@5921
    34
#include "SDL_bevents.h"
nathanheisey@5918
    35
nathanheisey@5918
    36
/* FIXME: Undefined functions */
nathanheisey@5921
    37
//    #define BE_PumpEvents NULL
nathanheisey@5918
    38
    
nathanheisey@5918
    39
#if SDL_VIDEO_OPENGL_WGL	/* FIXME: Replace with BeOs's SDL OPENGL stuff */
nathanheisey@5918
    40
//    #define BE_GL_LoadLibrary NULL
nathanheisey@5918
    41
//    #define BE_GL_GetProcAddress NULL
nathanheisey@5918
    42
    #define BE_GL_UnloadLibrary NULL
nathanheisey@5918
    43
    #define BE_GL_CreateContext NULL
nathanheisey@5918
    44
//    #define BE_GL_MakeCurrent NULL
nathanheisey@5918
    45
    #define BE_GL_SetSwapInterval NULL
nathanheisey@5918
    46
    #define BE_GL_GetSwapInterval NULL
nathanheisey@5918
    47
    #define BE_GL_SwapWindow NULL
nathanheisey@5918
    48
    #define BE_GL_DeleteContext NULL
nathanheisey@5918
    49
#endif
nathanheisey@5918
    50
    #define BE_StartTextInput NULL
nathanheisey@5918
    51
    #define BE_StopTextInput NULL
nathanheisey@5918
    52
    #define BE_SetTextInputRect NULL
nathanheisey@5918
    53
nathanheisey@5918
    54
//    #define BE_DeleteDevice NULL
nathanheisey@5918
    55
nathanheisey@5918
    56
/* End undefined functions */
nathanheisey@5918
    57
nathanheisey@5918
    58
static SDL_VideoDevice *
nathanheisey@5918
    59
BE_CreateDevice(int devindex)
nathanheisey@5918
    60
{
nathanheisey@5918
    61
    SDL_VideoDevice *device;
nathanheisey@5918
    62
    SDL_VideoData *data;
nathanheisey@5918
    63
nathanheisey@5918
    64
    /* Initialize all variables that we clean on shutdown */
nathanheisey@5918
    65
    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
nathanheisey@5918
    66
    if (device) {
nathanheisey@5918
    67
        data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
nathanheisey@5918
    68
    } else {
nathanheisey@5918
    69
        data = NULL;
nathanheisey@5918
    70
    }
nathanheisey@5918
    71
    if (!data) {
nathanheisey@5918
    72
        SDL_OutOfMemory();
nathanheisey@5918
    73
        if (device) {
nathanheisey@5918
    74
            SDL_free(device);
nathanheisey@5918
    75
        }
nathanheisey@5918
    76
        return NULL;
nathanheisey@5918
    77
    }
nathanheisey@5918
    78
    device->driverdata = data;
nathanheisey@5918
    79
nathanheisey@5918
    80
/* TODO: Figure out what sort of initialization needs to go here */
nathanheisey@5918
    81
nathanheisey@5918
    82
    /* Set the function pointers */
nathanheisey@5918
    83
    device->VideoInit = BE_VideoInit;
nathanheisey@5918
    84
    device->VideoQuit = BE_VideoQuit;
nathanheisey@5918
    85
    device->GetDisplayBounds = BE_GetDisplayBounds;
nathanheisey@5918
    86
    device->GetDisplayModes = BE_GetDisplayModes;
nathanheisey@5918
    87
    device->SetDisplayMode = BE_SetDisplayMode;
nathanheisey@5918
    88
    device->PumpEvents = BE_PumpEvents;
nathanheisey@5918
    89
nathanheisey@5918
    90
    device->CreateWindow = BE_CreateWindow;
nathanheisey@5918
    91
    device->CreateWindowFrom = BE_CreateWindowFrom;
nathanheisey@5918
    92
    device->SetWindowTitle = BE_SetWindowTitle;
nathanheisey@5918
    93
    device->SetWindowIcon = BE_SetWindowIcon;
nathanheisey@5918
    94
    device->SetWindowPosition = BE_SetWindowPosition;
nathanheisey@5918
    95
    device->SetWindowSize = BE_SetWindowSize;
nathanheisey@5918
    96
    device->ShowWindow = BE_ShowWindow;
nathanheisey@5918
    97
    device->HideWindow = BE_HideWindow;
nathanheisey@5918
    98
    device->RaiseWindow = BE_RaiseWindow;
nathanheisey@5918
    99
    device->MaximizeWindow = BE_MaximizeWindow;
nathanheisey@5918
   100
    device->MinimizeWindow = BE_MinimizeWindow;
nathanheisey@5918
   101
    device->RestoreWindow = BE_RestoreWindow;
nathanheisey@5918
   102
    device->SetWindowFullscreen = BE_SetWindowFullscreen;
nathanheisey@5918
   103
    device->SetWindowGammaRamp = BE_SetWindowGammaRamp;
nathanheisey@5918
   104
    device->GetWindowGammaRamp = BE_GetWindowGammaRamp;
nathanheisey@5918
   105
    device->SetWindowGrab = BE_SetWindowGrab;
nathanheisey@5918
   106
    device->DestroyWindow = BE_DestroyWindow;
nathanheisey@5918
   107
    device->GetWindowWMInfo = BE_GetWindowWMInfo;
nathanheisey@5918
   108
    device->CreateWindowFramebuffer = BE_CreateWindowFramebuffer;
nathanheisey@5918
   109
    device->UpdateWindowFramebuffer = BE_UpdateWindowFramebuffer;
nathanheisey@5918
   110
    device->DestroyWindowFramebuffer = BE_DestroyWindowFramebuffer;
nathanheisey@5918
   111
    
nathanheisey@5918
   112
    device->shape_driver.CreateShaper = NULL;
nathanheisey@5918
   113
    device->shape_driver.SetWindowShape = NULL;
nathanheisey@5918
   114
    device->shape_driver.ResizeWindowShape = NULL;
nathanheisey@5918
   115
    
nathanheisey@5918
   116
#if SDL_VIDEO_OPENGL_WGL	/* FIXME: Replace with BeOs's SDL OPENGL stuff */
nathanheisey@5918
   117
    device->GL_LoadLibrary = BE_GL_LoadLibrary;
nathanheisey@5918
   118
    device->GL_GetProcAddress = BE_GL_GetProcAddress;
nathanheisey@5918
   119
    device->GL_UnloadLibrary = BE_GL_UnloadLibrary;
nathanheisey@5918
   120
    device->GL_CreateContext = BE_GL_CreateContext;
nathanheisey@5918
   121
    device->GL_MakeCurrent = BE_GL_MakeCurrent;
nathanheisey@5918
   122
    device->GL_SetSwapInterval = BE_GL_SetSwapInterval;
nathanheisey@5918
   123
    device->GL_GetSwapInterval = BE_GL_GetSwapInterval;
nathanheisey@5918
   124
    device->GL_SwapWindow = BE_GL_SwapWindow;
nathanheisey@5918
   125
    device->GL_DeleteContext = BE_GL_DeleteContext;
nathanheisey@5918
   126
#endif
nathanheisey@5918
   127
    device->StartTextInput = BE_StartTextInput;
nathanheisey@5918
   128
    device->StopTextInput = BE_StopTextInput;
nathanheisey@5918
   129
    device->SetTextInputRect = BE_SetTextInputRect;
nathanheisey@5918
   130
nathanheisey@5918
   131
    device->SetClipboardText = BE_SetClipboardText;
nathanheisey@5918
   132
    device->GetClipboardText = BE_GetClipboardText;
nathanheisey@5918
   133
    device->HasClipboardText = BE_HasClipboardText;
nathanheisey@5918
   134
nathanheisey@5918
   135
    device->free = BE_DeleteDevice;
nathanheisey@5918
   136
nathanheisey@5918
   137
    return device;
nathanheisey@5918
   138
}
nathanheisey@5918
   139
nathanheisey@5921
   140
VideoBootStrap BWINDOW_bootstrap = {
nathanheisey@5921
   141
	"bwindow", "BDirectWindow graphics",
nathanheisey@5921
   142
	BE_Available, BE_CreateDevice
nathanheisey@5921
   143
};
nathanheisey@5921
   144
nathanheisey@5918
   145
static void BE_DeleteDevice(SDL_VideoDevice * device)
nathanheisey@5918
   146
{
nathanheisey@5918
   147
	SDL_free(device->driverdata);
nathanheisey@5918
   148
	SDL_free(device);
nathanheisey@5918
   149
}
nathanheisey@5918
   150
nathanheisey@5918
   151
/* FIXME: This is the 1.2 function at the moment.  Read through it and
nathanheisey@5918
   152
  o understand what it does. */
nathanheisey@5918
   153
int BE_VideoInit(_THIS)
nathanheisey@5918
   154
{
nathanheisey@5918
   155
	/* Initialize the Be Application for appserver interaction */
nathanheisey@5918
   156
	if (SDL_InitBeApp() < 0) {
nathanheisey@5918
   157
		return -1;
nathanheisey@5918
   158
	}
nathanheisey@5918
   159
	
nathanheisey@5918
   160
	BE_InitModes(_this);
nathanheisey@5918
   161
nathanheisey@5918
   162
#if SDL_VIDEO_OPENGL
nathanheisey@5918
   163
        /* testgl application doesn't load library, just tries to load symbols */
nathanheisey@5918
   164
        /* is it correct? if so we have to load library here */
nathanheisey@5918
   165
    BE_GL_LoadLibrary(_this, NULL);
nathanheisey@5918
   166
#endif
nathanheisey@5918
   167
nathanheisey@5918
   168
        /* Fill in some window manager capabilities */
nathanheisey@5918
   169
//    _this->info.wm_available = 1;
nathanheisey@5918
   170
nathanheisey@5918
   171
        /* We're done! */
nathanheisey@5918
   172
    return (0);
nathanheisey@5918
   173
}
nathanheisey@5918
   174
nathanheisey@5918
   175
static int BE_Available(void)
nathanheisey@5918
   176
{
nathanheisey@5918
   177
    return (1);
nathanheisey@5918
   178
}
nathanheisey@5918
   179
nathanheisey@5918
   180
void BE_VideoQuit(_THIS)
nathanheisey@5918
   181
{
nathanheisey@5918
   182
nathanheisey@5918
   183
#if 0
nathanheisey@5918
   184
        SDL_Win->Quit();
nathanheisey@5918
   185
        SDL_Win = NULL;
nathanheisey@5918
   186
#endif
nathanheisey@5918
   187
#if 0
nathanheisey@5918
   188
        if (SDL_BlankCursor != NULL) {
nathanheisey@5918
   189
            BE_FreeWMCursor(_this, SDL_BlankCursor);
nathanheisey@5918
   190
            SDL_BlankCursor = NULL;
nathanheisey@5918
   191
        }
nathanheisey@5918
   192
#endif
nathanheisey@5918
   193
nathanheisey@5918
   194
    BE_QuitModes(_this);
nathanheisey@5918
   195
nathanheisey@5918
   196
#if SDL_VIDEO_OPENGL
nathanheisey@5918
   197
//    if (_this->gl_config.dll_handle != NULL)
nathanheisey@5918
   198
//        unload_add_on((image_id) _this->gl_config.dll_handle);
nathanheisey@5918
   199
#endif
nathanheisey@5918
   200
nathanheisey@5918
   201
    SDL_QuitBeApp();
nathanheisey@5918
   202
}
nathanheisey@5918
   203
nathanheisey@5918
   204
#ifdef __cplusplus
nathanheisey@5918
   205
}
nathanheisey@5918
   206
#endif