cscg22-gearboy

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

SDL_uikitvideo.m (4106B)


      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_UIKIT
     24
     25#import <UIKit/UIKit.h>
     26
     27#include "SDL_video.h"
     28#include "SDL_mouse.h"
     29#include "../SDL_sysvideo.h"
     30#include "../SDL_pixels_c.h"
     31#include "../../events/SDL_events_c.h"
     32
     33#include "SDL_uikitvideo.h"
     34#include "SDL_uikitevents.h"
     35#include "SDL_uikitmodes.h"
     36#include "SDL_uikitwindow.h"
     37#include "SDL_uikitopengles.h"
     38
     39#define UIKITVID_DRIVER_NAME "uikit"
     40
     41/* Initialization/Query functions */
     42static int UIKit_VideoInit(_THIS);
     43static void UIKit_VideoQuit(_THIS);
     44
     45/* DUMMY driver bootstrap functions */
     46
     47static int
     48UIKit_Available(void)
     49{
     50    return 1;
     51}
     52
     53static void UIKit_DeleteDevice(SDL_VideoDevice * device)
     54{
     55    SDL_free(device);
     56}
     57
     58static SDL_VideoDevice *
     59UIKit_CreateDevice(int devindex)
     60{
     61    SDL_VideoDevice *device;
     62
     63    /* Initialize all variables that we clean on shutdown */
     64    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
     65    if (!device) {
     66        SDL_free(device);
     67        SDL_OutOfMemory();
     68        return (0);
     69    }
     70
     71    /* Set the function pointers */
     72    device->VideoInit = UIKit_VideoInit;
     73    device->VideoQuit = UIKit_VideoQuit;
     74    device->GetDisplayModes = UIKit_GetDisplayModes;
     75    device->SetDisplayMode = UIKit_SetDisplayMode;
     76    device->PumpEvents = UIKit_PumpEvents;
     77    device->CreateWindow = UIKit_CreateWindow;
     78    device->ShowWindow = UIKit_ShowWindow;
     79    device->HideWindow = UIKit_HideWindow;
     80    device->RaiseWindow = UIKit_RaiseWindow;
     81    device->SetWindowFullscreen = UIKit_SetWindowFullscreen;
     82    device->DestroyWindow = UIKit_DestroyWindow;
     83    device->GetWindowWMInfo = UIKit_GetWindowWMInfo;
     84
     85    /* !!! FIXME: implement SetWindowBordered */
     86
     87#if SDL_IPHONE_KEYBOARD
     88    device->HasScreenKeyboardSupport = UIKit_HasScreenKeyboardSupport;
     89    device->ShowScreenKeyboard = UIKit_ShowScreenKeyboard;
     90    device->HideScreenKeyboard = UIKit_HideScreenKeyboard;
     91    device->IsScreenKeyboardShown = UIKit_IsScreenKeyboardShown;
     92    device->SetTextInputRect = UIKit_SetTextInputRect;
     93#endif
     94
     95    /* OpenGL (ES) functions */
     96    device->GL_MakeCurrent        = UIKit_GL_MakeCurrent;
     97    device->GL_SwapWindow        = UIKit_GL_SwapWindow;
     98    device->GL_CreateContext    = UIKit_GL_CreateContext;
     99    device->GL_DeleteContext    = UIKit_GL_DeleteContext;
    100    device->GL_GetProcAddress   = UIKit_GL_GetProcAddress;
    101    device->GL_LoadLibrary        = UIKit_GL_LoadLibrary;
    102    device->free = UIKit_DeleteDevice;
    103
    104    device->gl_config.accelerated = 1;
    105
    106    return device;
    107}
    108
    109VideoBootStrap UIKIT_bootstrap = {
    110    UIKITVID_DRIVER_NAME, "SDL UIKit video driver",
    111    UIKit_Available, UIKit_CreateDevice
    112};
    113
    114
    115int
    116UIKit_VideoInit(_THIS)
    117{
    118    _this->gl_config.driver_loaded = 1;
    119
    120    if (UIKit_InitModes(_this) < 0) {
    121        return -1;
    122    }
    123    return 0;
    124}
    125
    126void
    127UIKit_VideoQuit(_THIS)
    128{
    129    UIKit_QuitModes(_this);
    130}
    131
    132/*
    133 * iOS log support.
    134 *
    135 * This doesn't really have aything to do with the interfaces of the SDL video
    136 *  subsystem, but we need to stuff this into an Objective-C source code file.
    137 */
    138
    139void SDL_NSLog(const char *text)
    140{
    141    NSLog(@"%s", text);
    142}
    143
    144#endif /* SDL_VIDEO_DRIVER_UIKIT */
    145
    146/* vi: set ts=4 sw=4 expandtab: */