src/video/haiku/SDL_bvideo.cc
author Sam Lantinga <slouken@libsdl.org>
Fri, 04 Jan 2019 22:01:14 -0800
changeset 12503 806492103856
parent 12201 8bdc4d340419
permissions -rw-r--r--
Updated copyright for 2019
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2019 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 HAIKU_PumpEvents NULL
    41     #define HAIKU_StartTextInput NULL
    42     #define HAIKU_StopTextInput NULL
    43     #define HAIKU_SetTextInputRect NULL
    44 
    45 //    #define HAIKU_DeleteDevice NULL
    46 
    47 /* End undefined functions */
    48 
    49 static SDL_VideoDevice *
    50 HAIKU_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 = HAIKU_VideoInit;
    65     device->VideoQuit = HAIKU_VideoQuit;
    66     device->GetDisplayBounds = HAIKU_GetDisplayBounds;
    67     device->GetDisplayModes = HAIKU_GetDisplayModes;
    68     device->SetDisplayMode = HAIKU_SetDisplayMode;
    69     device->PumpEvents = HAIKU_PumpEvents;
    70 
    71     device->CreateSDLWindow = HAIKU_CreateWindow;
    72     device->CreateSDLWindowFrom = HAIKU_CreateWindowFrom;
    73     device->SetWindowTitle = HAIKU_SetWindowTitle;
    74     device->SetWindowIcon = HAIKU_SetWindowIcon;
    75     device->SetWindowPosition = HAIKU_SetWindowPosition;
    76     device->SetWindowSize = HAIKU_SetWindowSize;
    77     device->ShowWindow = HAIKU_ShowWindow;
    78     device->HideWindow = HAIKU_HideWindow;
    79     device->RaiseWindow = HAIKU_RaiseWindow;
    80     device->MaximizeWindow = HAIKU_MaximizeWindow;
    81     device->MinimizeWindow = HAIKU_MinimizeWindow;
    82     device->RestoreWindow = HAIKU_RestoreWindow;
    83     device->SetWindowBordered = HAIKU_SetWindowBordered;
    84     device->SetWindowResizable = HAIKU_SetWindowResizable;
    85     device->SetWindowFullscreen = HAIKU_SetWindowFullscreen;
    86     device->SetWindowGammaRamp = HAIKU_SetWindowGammaRamp;
    87     device->GetWindowGammaRamp = HAIKU_GetWindowGammaRamp;
    88     device->SetWindowGrab = HAIKU_SetWindowGrab;
    89     device->DestroyWindow = HAIKU_DestroyWindow;
    90     device->GetWindowWMInfo = HAIKU_GetWindowWMInfo;
    91     device->CreateWindowFramebuffer = HAIKU_CreateWindowFramebuffer;
    92     device->UpdateWindowFramebuffer = HAIKU_UpdateWindowFramebuffer;
    93     device->DestroyWindowFramebuffer = HAIKU_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 = HAIKU_GL_LoadLibrary;
   101     device->GL_GetProcAddress = HAIKU_GL_GetProcAddress;
   102     device->GL_UnloadLibrary = HAIKU_GL_UnloadLibrary;
   103     device->GL_CreateContext = HAIKU_GL_CreateContext;
   104     device->GL_MakeCurrent = HAIKU_GL_MakeCurrent;
   105     device->GL_SetSwapInterval = HAIKU_GL_SetSwapInterval;
   106     device->GL_GetSwapInterval = HAIKU_GL_GetSwapInterval;
   107     device->GL_SwapWindow = HAIKU_GL_SwapWindow;
   108     device->GL_DeleteContext = HAIKU_GL_DeleteContext;
   109 #endif
   110 
   111     device->StartTextInput = HAIKU_StartTextInput;
   112     device->StopTextInput = HAIKU_StopTextInput;
   113     device->SetTextInputRect = HAIKU_SetTextInputRect;
   114 
   115     device->SetClipboardText = HAIKU_SetClipboardText;
   116     device->GetClipboardText = HAIKU_GetClipboardText;
   117     device->HasClipboardText = HAIKU_HasClipboardText;
   118 
   119     device->free = HAIKU_DeleteDevice;
   120 
   121     return device;
   122 }
   123 
   124 VideoBootStrap HAIKU_bootstrap = {
   125     "haiku", "Haiku graphics",
   126     HAIKU_Available, HAIKU_CreateDevice
   127 };
   128 
   129 void HAIKU_DeleteDevice(SDL_VideoDevice * device)
   130 {
   131     SDL_free(device->driverdata);
   132     SDL_free(device);
   133 }
   134 
   135 int HAIKU_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     HAIKU_InitModes(_this);
   144 
   145     /* Init the keymap */
   146     HAIKU_InitOSKeymap();
   147 
   148 #if SDL_VIDEO_OPENGL
   149         /* testgl application doesn't load library, just tries to load symbols */
   150         /* is it correct? if so we have to load library here */
   151     HAIKU_GL_LoadLibrary(_this, NULL);
   152 #endif
   153 
   154     /* We're done! */
   155     return (0);
   156 }
   157 
   158 int HAIKU_Available(void)
   159 {
   160     return (1);
   161 }
   162 
   163 void HAIKU_VideoQuit(_THIS)
   164 {
   165 
   166     HAIKU_QuitModes(_this);
   167 
   168     SDL_QuitBeApp();
   169 }
   170 
   171 #ifdef __cplusplus
   172 }
   173 #endif
   174 
   175 #endif /* SDL_VIDEO_DRIVER_HAIKU */
   176 
   177 /* vi: set ts=4 sw=4 expandtab: */