src/video/haiku/SDL_bvideo.cc
author Sam Lantinga <slouken@libsdl.org>
Wed, 03 Jan 2018 10:03:25 -0800
changeset 11811 5d94cb6b24d3
parent 11383 6cafb5954aaf
child 12082 09999a0e8f9a
permissions -rw-r--r--
Updated copyright for 2018
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
     4 
     5   This software is provided 'as-is', without any express or implied
     6   warranty.  In no event will the authors be held liable for any damages
     7   arising from the use of this software.
     8 
     9   Permission is granted to anyone to use this software for any purpose,
    10   including commercial applications, and to alter it and redistribute it
    11   freely, subject to the following restrictions:
    12 
    13   1. The origin of this software must not be misrepresented; you must not
    14      claim that you wrote the original software. If you use this software
    15      in a product, an acknowledgment in the product documentation would be
    16      appreciated but is not required.
    17   2. Altered source versions must be plainly marked as such, and must not be
    18      misrepresented as being the original software.
    19   3. This notice may not be removed or altered from any source distribution.
    20 */
    21 #include "../../SDL_internal.h"
    22 
    23 #if SDL_VIDEO_DRIVER_HAIKU
    24 
    25 
    26 #ifdef __cplusplus
    27 extern "C" {
    28 #endif
    29 
    30 #include "SDL_bkeyboard.h"
    31 #include "SDL_bwindow.h"
    32 #include "SDL_bclipboard.h"
    33 #include "SDL_bvideo.h"
    34 #include "SDL_bopengl.h"
    35 #include "SDL_bmodes.h"
    36 #include "SDL_bframebuffer.h"
    37 #include "SDL_bevents.h"
    38 
    39 /* FIXME: Undefined functions */
    40 //    #define BE_PumpEvents NULL
    41     #define BE_StartTextInput NULL
    42     #define BE_StopTextInput NULL
    43     #define BE_SetTextInputRect NULL
    44 
    45 //    #define BE_DeleteDevice NULL
    46 
    47 /* End undefined functions */
    48 
    49 static SDL_VideoDevice *
    50 BE_CreateDevice(int devindex)
    51 {
    52     SDL_VideoDevice *device;
    53     /*SDL_VideoData *data;*/
    54 
    55     /* Initialize all variables that we clean on shutdown */
    56     device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
    57 
    58     device->driverdata = NULL; /* FIXME: Is this the cause of some of the
    59     							  SDL_Quit() errors? */
    60 
    61 /* TODO: Figure out if any initialization needs to go here */
    62 
    63     /* Set the function pointers */
    64     device->VideoInit = BE_VideoInit;
    65     device->VideoQuit = BE_VideoQuit;
    66     device->GetDisplayBounds = BE_GetDisplayBounds;
    67     device->GetDisplayModes = BE_GetDisplayModes;
    68     device->SetDisplayMode = BE_SetDisplayMode;
    69     device->PumpEvents = BE_PumpEvents;
    70 
    71     device->CreateSDLWindow = BE_CreateWindow;
    72     device->CreateSDLWindowFrom = BE_CreateWindowFrom;
    73     device->SetWindowTitle = BE_SetWindowTitle;
    74     device->SetWindowIcon = BE_SetWindowIcon;
    75     device->SetWindowPosition = BE_SetWindowPosition;
    76     device->SetWindowSize = BE_SetWindowSize;
    77     device->ShowWindow = BE_ShowWindow;
    78     device->HideWindow = BE_HideWindow;
    79     device->RaiseWindow = BE_RaiseWindow;
    80     device->MaximizeWindow = BE_MaximizeWindow;
    81     device->MinimizeWindow = BE_MinimizeWindow;
    82     device->RestoreWindow = BE_RestoreWindow;
    83     device->SetWindowBordered = BE_SetWindowBordered;
    84     device->SetWindowResizable = BE_SetWindowResizable;
    85     device->SetWindowFullscreen = BE_SetWindowFullscreen;
    86     device->SetWindowGammaRamp = BE_SetWindowGammaRamp;
    87     device->GetWindowGammaRamp = BE_GetWindowGammaRamp;
    88     device->SetWindowGrab = BE_SetWindowGrab;
    89     device->DestroyWindow = BE_DestroyWindow;
    90     device->GetWindowWMInfo = BE_GetWindowWMInfo;
    91     device->CreateWindowFramebuffer = BE_CreateWindowFramebuffer;
    92     device->UpdateWindowFramebuffer = BE_UpdateWindowFramebuffer;
    93     device->DestroyWindowFramebuffer = BE_DestroyWindowFramebuffer;
    94     
    95     device->shape_driver.CreateShaper = NULL;
    96     device->shape_driver.SetWindowShape = NULL;
    97     device->shape_driver.ResizeWindowShape = NULL;
    98 
    99 #if SDL_VIDEO_OPENGL
   100     device->GL_LoadLibrary = BE_GL_LoadLibrary;
   101     device->GL_GetProcAddress = BE_GL_GetProcAddress;
   102     device->GL_UnloadLibrary = BE_GL_UnloadLibrary;
   103     device->GL_CreateContext = BE_GL_CreateContext;
   104     device->GL_MakeCurrent = BE_GL_MakeCurrent;
   105     device->GL_SetSwapInterval = BE_GL_SetSwapInterval;
   106     device->GL_GetSwapInterval = BE_GL_GetSwapInterval;
   107     device->GL_SwapWindow = BE_GL_SwapWindow;
   108     device->GL_DeleteContext = BE_GL_DeleteContext;
   109 #endif
   110 
   111     device->StartTextInput = BE_StartTextInput;
   112     device->StopTextInput = BE_StopTextInput;
   113     device->SetTextInputRect = BE_SetTextInputRect;
   114 
   115     device->SetClipboardText = BE_SetClipboardText;
   116     device->GetClipboardText = BE_GetClipboardText;
   117     device->HasClipboardText = BE_HasClipboardText;
   118 
   119     device->free = BE_DeleteDevice;
   120 
   121     return device;
   122 }
   123 
   124 VideoBootStrap HAIKU_bootstrap = {
   125 	"haiku", "Haiku graphics",
   126 	BE_Available, BE_CreateDevice
   127 };
   128 
   129 void BE_DeleteDevice(SDL_VideoDevice * device)
   130 {
   131 	SDL_free(device->driverdata);
   132 	SDL_free(device);
   133 }
   134 
   135 int BE_VideoInit(_THIS)
   136 {
   137 	/* Initialize the Be Application for appserver interaction */
   138 	if (SDL_InitBeApp() < 0) {
   139 		return -1;
   140 	}
   141 	
   142 	/* Initialize video modes */
   143 	BE_InitModes(_this);
   144 
   145 	/* Init the keymap */
   146 	BE_InitOSKeymap();
   147 	
   148 	
   149 #if SDL_VIDEO_OPENGL
   150         /* testgl application doesn't load library, just tries to load symbols */
   151         /* is it correct? if so we have to load library here */
   152     BE_GL_LoadLibrary(_this, NULL);
   153 #endif
   154 
   155         /* We're done! */
   156     return (0);
   157 }
   158 
   159 int BE_Available(void)
   160 {
   161     return (1);
   162 }
   163 
   164 void BE_VideoQuit(_THIS)
   165 {
   166 
   167     BE_QuitModes(_this);
   168 
   169     SDL_QuitBeApp();
   170 }
   171 
   172 #ifdef __cplusplus
   173 }
   174 #endif
   175 
   176 #endif /* SDL_VIDEO_DRIVER_HAIKU */
   177 
   178 /* vi: set ts=4 sw=4 expandtab: */