src/video/uikit/SDL_uikitvideo.m
changeset 2765 f55c87ae336b
child 2859 99210400e8b9
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/video/uikit/SDL_uikitvideo.m	Sat Oct 04 06:46:59 2008 +0000
     1.3 @@ -0,0 +1,146 @@
     1.4 +/*
     1.5 +    SDL - Simple DirectMedia Layer
     1.6 +    Copyright (C) 1997-2006 Sam Lantinga
     1.7 +
     1.8 +    This library is free software; you can redistribute it and/or
     1.9 +    modify it under the terms of the GNU Lesser General Public
    1.10 +    License as published by the Free Software Foundation; either
    1.11 +    version 2.1 of the License, or (at your option) any later version.
    1.12 +
    1.13 +    This library is distributed in the hope that it will be useful,
    1.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 +    Lesser General Public License for more details.
    1.17 +
    1.18 +    You should have received a copy of the GNU Lesser General Public
    1.19 +    License along with this library; if not, write to the Free Software
    1.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1.21 +
    1.22 +    Sam Lantinga
    1.23 +    slouken@libsdl.org
    1.24 +*/
    1.25 +#include "SDL_config.h"
    1.26 +
    1.27 +#include "SDL_video.h"
    1.28 +#include "SDL_mouse.h"
    1.29 +#include "../SDL_sysvideo.h"
    1.30 +#include "../SDL_pixels_c.h"
    1.31 +#include "../../events/SDL_events_c.h"
    1.32 +
    1.33 +#include "SDL_uikitvideo.h"
    1.34 +#include "SDL_uikitevents.h"
    1.35 +#include "SDL_uikitwindow.h"
    1.36 +#include "SDL_uikitopengles.h"
    1.37 +
    1.38 +#include "SDL_renderer_sw.h"
    1.39 +#include "SDL_renderer_gles.h"
    1.40 +
    1.41 +#define UIKITVID_DRIVER_NAME "uikit"
    1.42 +
    1.43 +/* Initialization/Query functions */
    1.44 +static int UIKit_VideoInit(_THIS);
    1.45 +static int UIKit_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
    1.46 +static void UIKit_VideoQuit(_THIS);
    1.47 +
    1.48 +/* DUMMY driver bootstrap functions */
    1.49 +
    1.50 +static int
    1.51 +UIKit_Available(void)
    1.52 +{
    1.53 +	return (1);
    1.54 +}
    1.55 +
    1.56 +static void UIKit_DeleteDevice(SDL_VideoDevice * device)
    1.57 +{
    1.58 +    SDL_free(device);
    1.59 +}
    1.60 +
    1.61 +static SDL_VideoDevice *
    1.62 +UIKit_CreateDevice(int devindex)
    1.63 +{
    1.64 +    SDL_VideoDevice *device;
    1.65 +
    1.66 +    /* Initialize all variables that we clean on shutdown */
    1.67 +    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
    1.68 +    if (!device) {
    1.69 +        SDL_OutOfMemory();
    1.70 +        if (device) {
    1.71 +            SDL_free(device);
    1.72 +        }
    1.73 +        return (0);
    1.74 +    }
    1.75 +
    1.76 +    /* Set the function pointers */
    1.77 +    device->VideoInit = UIKit_VideoInit;
    1.78 +    device->VideoQuit = UIKit_VideoQuit;
    1.79 +    device->SetDisplayMode = UIKit_SetDisplayMode;
    1.80 +    device->PumpEvents = UIKit_PumpEvents;
    1.81 +	device->CreateWindow = UIKit_CreateWindow;
    1.82 +	device->DestroyWindow = UIKit_DestroyWindow;
    1.83 +	
    1.84 +	
    1.85 +	/* OpenGL (ES) functions */
    1.86 +	device->GL_MakeCurrent		= UIKit_GL_MakeCurrent;
    1.87 +	device->GL_SwapWindow		= UIKit_GL_SwapWindow;
    1.88 +	device->GL_CreateContext	= UIKit_GL_CreateContext;
    1.89 +	device->GL_DeleteContext    = UIKit_GL_DeleteContext;
    1.90 +	device->GL_GetProcAddress   = UIKit_GL_GetProcAddress;
    1.91 +	device->GL_LoadLibrary	    = UIKit_GL_LoadLibrary;
    1.92 +	device->free = UIKit_DeleteDevice;
    1.93 +
    1.94 +	device->gl_config.accelerated = 1;
    1.95 +	
    1.96 +    return device;
    1.97 +}
    1.98 +
    1.99 +VideoBootStrap UIKIT_bootstrap = {
   1.100 +    UIKITVID_DRIVER_NAME, "SDL UIKit video driver",
   1.101 +    UIKit_Available, UIKit_CreateDevice
   1.102 +};
   1.103 +
   1.104 +
   1.105 +int
   1.106 +UIKit_VideoInit(_THIS)
   1.107 +{
   1.108 +    SDL_DisplayMode mode;
   1.109 +		
   1.110 +	_this->gl_config.driver_loaded = 1;
   1.111 +
   1.112 +	SDL_VideoDisplay display;
   1.113 +	SDL_zero(display);
   1.114 +
   1.115 +    /* Use a 32-bpp desktop mode */
   1.116 +    SDL_zero(mode);
   1.117 +	mode.format = SDL_PIXELFORMAT_ABGR8888;
   1.118 +    mode.w = 320;
   1.119 +    mode.h = 480;
   1.120 +    mode.refresh_rate = 0;
   1.121 +    mode.driverdata = NULL;
   1.122 +		
   1.123 +	display.num_display_modes = 1;
   1.124 +	display.max_display_modes = 1;
   1.125 +	display.display_modes = (SDL_DisplayMode *)SDL_malloc(display.max_display_modes * sizeof(SDL_DisplayMode));
   1.126 +	
   1.127 +	display.display_modes[0] = mode;
   1.128 +	display.desktop_mode = mode;
   1.129 +	display.fullscreen_mode = mode;
   1.130 +	display.current_mode = mode;
   1.131 +		
   1.132 +	SDL_AddVideoDisplay(&display);
   1.133 +
   1.134 +    /* We're done! */
   1.135 +    return 0;
   1.136 +}
   1.137 +
   1.138 +static int
   1.139 +UIKit_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
   1.140 +{
   1.141 +    return 0;
   1.142 +}
   1.143 +
   1.144 +void
   1.145 +UIKit_VideoQuit(_THIS)
   1.146 +{
   1.147 +}
   1.148 +
   1.149 +/* vi: set ts=4 sw=4 expandtab: */