cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

SDL_bvideo.cc (5195B)


      1/*
      2  Simple DirectMedia Layer
      3  Copyright (C) 1997-2014 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
     27extern "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
     49static SDL_VideoDevice *
     50BE_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->CreateWindow = BE_CreateWindow;
     72    device->CreateWindowFrom = 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->SetWindowFullscreen = BE_SetWindowFullscreen;
     85    device->SetWindowGammaRamp = BE_SetWindowGammaRamp;
     86    device->GetWindowGammaRamp = BE_GetWindowGammaRamp;
     87    device->SetWindowGrab = BE_SetWindowGrab;
     88    device->DestroyWindow = BE_DestroyWindow;
     89    device->GetWindowWMInfo = BE_GetWindowWMInfo;
     90    device->CreateWindowFramebuffer = BE_CreateWindowFramebuffer;
     91    device->UpdateWindowFramebuffer = BE_UpdateWindowFramebuffer;
     92    device->DestroyWindowFramebuffer = BE_DestroyWindowFramebuffer;
     93    
     94    device->shape_driver.CreateShaper = NULL;
     95    device->shape_driver.SetWindowShape = NULL;
     96    device->shape_driver.ResizeWindowShape = NULL;
     97
     98
     99    device->GL_LoadLibrary = BE_GL_LoadLibrary;
    100    device->GL_GetProcAddress = BE_GL_GetProcAddress;
    101    device->GL_UnloadLibrary = BE_GL_UnloadLibrary;
    102    device->GL_CreateContext = BE_GL_CreateContext;
    103    device->GL_MakeCurrent = BE_GL_MakeCurrent;
    104    device->GL_SetSwapInterval = BE_GL_SetSwapInterval;
    105    device->GL_GetSwapInterval = BE_GL_GetSwapInterval;
    106    device->GL_SwapWindow = BE_GL_SwapWindow;
    107    device->GL_DeleteContext = BE_GL_DeleteContext;
    108
    109    device->StartTextInput = BE_StartTextInput;
    110    device->StopTextInput = BE_StopTextInput;
    111    device->SetTextInputRect = BE_SetTextInputRect;
    112
    113    device->SetClipboardText = BE_SetClipboardText;
    114    device->GetClipboardText = BE_GetClipboardText;
    115    device->HasClipboardText = BE_HasClipboardText;
    116
    117    device->free = BE_DeleteDevice;
    118
    119    return device;
    120}
    121
    122VideoBootStrap HAIKU_bootstrap = {
    123	"haiku", "Haiku graphics",
    124	BE_Available, BE_CreateDevice
    125};
    126
    127void BE_DeleteDevice(SDL_VideoDevice * device)
    128{
    129	SDL_free(device->driverdata);
    130	SDL_free(device);
    131}
    132
    133int BE_VideoInit(_THIS)
    134{
    135	/* Initialize the Be Application for appserver interaction */
    136	if (SDL_InitBeApp() < 0) {
    137		return -1;
    138	}
    139	
    140	/* Initialize video modes */
    141	BE_InitModes(_this);
    142
    143	/* Init the keymap */
    144	BE_InitOSKeymap();
    145	
    146	
    147#if SDL_VIDEO_OPENGL
    148        /* testgl application doesn't load library, just tries to load symbols */
    149        /* is it correct? if so we have to load library here */
    150    BE_GL_LoadLibrary(_this, NULL);
    151#endif
    152
    153        /* We're done! */
    154    return (0);
    155}
    156
    157int BE_Available(void)
    158{
    159    return (1);
    160}
    161
    162void BE_VideoQuit(_THIS)
    163{
    164
    165    BE_QuitModes(_this);
    166
    167    SDL_QuitBeApp();
    168}
    169
    170#ifdef __cplusplus
    171}
    172#endif
    173
    174#endif /* SDL_VIDEO_DRIVER_HAIKU */