src/video/uikit/SDL_uikitvideo.m
branchgsoc2008_iphone
changeset 2352 1ecbeff9eb4c
child 2425 491958a6c881
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/video/uikit/SDL_uikitvideo.m	Thu Jul 17 22:38:29 2008 +0000
     1.3 @@ -0,0 +1,163 @@
     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 +/* Dummy SDL video driver implementation; this is just enough to make an
    1.28 + *  SDL-based application THINK it's got a working video driver, for
    1.29 + *  applications that call SDL_Init(SDL_INIT_VIDEO) when they don't need it,
    1.30 + *  and also for use as a collection of stubs when porting SDL to a new
    1.31 + *  platform for which you haven't yet written a valid video driver.
    1.32 + *
    1.33 + * This is also a great way to determine bottlenecks: if you think that SDL
    1.34 + *  is a performance problem for a given platform, enable this driver, and
    1.35 + *  then see if your application runs faster without video overhead.
    1.36 + *
    1.37 + * Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion
    1.38 + *  of this was cut-and-pasted from Stephane Peter's work in the AAlib
    1.39 + *  SDL video driver.  Renamed to "DUMMY" by Sam Lantinga.
    1.40 + */
    1.41 +
    1.42 +#include "SDL_video.h"
    1.43 +#include "SDL_mouse.h"
    1.44 +#include "../SDL_sysvideo.h"
    1.45 +#include "../SDL_pixels_c.h"
    1.46 +#include "../../events/SDL_events_c.h"
    1.47 +
    1.48 +#include "SDL_uikitvideo.h"
    1.49 +#include "SDL_uikitevents.h"
    1.50 +#include "SDL_uikitwindow.h"
    1.51 +#include "SDL_uikitopengles.h"
    1.52 +
    1.53 +#include "SDL_renderer_sw.h"
    1.54 +#include "SDL_renderer_gles.h"
    1.55 +
    1.56 +#define UIKITVID_DRIVER_NAME "uikit"
    1.57 +
    1.58 +/* Initialization/Query functions */
    1.59 +static int UIKit_VideoInit(_THIS);
    1.60 +static int UIKit_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
    1.61 +static void UIKit_VideoQuit(_THIS);
    1.62 +
    1.63 +/* DUMMY driver bootstrap functions */
    1.64 +
    1.65 +static int
    1.66 +UIKit_Available(void)
    1.67 +{
    1.68 +	return (1);
    1.69 +}
    1.70 +
    1.71 +static void UIKit_DeleteDevice(SDL_VideoDevice * device)
    1.72 +{
    1.73 +    SDL_free(device);
    1.74 +}
    1.75 +
    1.76 +static SDL_VideoDevice *
    1.77 +UIKit_CreateDevice(int devindex)
    1.78 +{
    1.79 +    SDL_VideoDevice *device;
    1.80 +
    1.81 +    /* Initialize all variables that we clean on shutdown */
    1.82 +    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
    1.83 +    if (!device) {
    1.84 +        SDL_OutOfMemory();
    1.85 +        if (device) {
    1.86 +            SDL_free(device);
    1.87 +        }
    1.88 +        return (0);
    1.89 +    }
    1.90 +
    1.91 +    /* Set the function pointers */
    1.92 +    device->VideoInit = UIKit_VideoInit;
    1.93 +    device->VideoQuit = UIKit_VideoQuit;
    1.94 +    device->SetDisplayMode = UIKit_SetDisplayMode;
    1.95 +    device->PumpEvents = UIKit_PumpEvents;
    1.96 +	device->CreateWindow = UIKit_CreateWindow;
    1.97 +	device->DestroyWindow = UIKit_DestroyWindow;
    1.98 +	
    1.99 +	
   1.100 +	/* OpenGL (ES) functions */
   1.101 +	device->GL_MakeCurrent		= UIKit_GL_MakeCurrent;
   1.102 +	device->GL_SwapWindow		= UIKit_GL_SwapWindow;
   1.103 +	device->GL_CreateContext	= UIKit_GL_CreateContext;
   1.104 +	device->GL_DeleteContext    = UIKit_GL_DeleteContext;
   1.105 +	device->GL_GetProcAddress   = UIKit_GL_GetProcAddress;
   1.106 +	device->GL_LoadLibrary	    = UIKit_GL_LoadLibrary;
   1.107 +	device->free = UIKit_DeleteDevice;
   1.108 +
   1.109 +	device->gl_config.accelerated = 1;
   1.110 +	
   1.111 +    return device;
   1.112 +}
   1.113 +
   1.114 +VideoBootStrap UIKIT_bootstrap = {
   1.115 +    UIKITVID_DRIVER_NAME, "SDL UIKit video driver",
   1.116 +    UIKit_Available, UIKit_CreateDevice
   1.117 +};
   1.118 +
   1.119 +
   1.120 +int
   1.121 +UIKit_VideoInit(_THIS)
   1.122 +{
   1.123 +    SDL_DisplayMode mode;
   1.124 +
   1.125 +	printf("UIKit Video init!");
   1.126 +		
   1.127 +	_this->gl_config.driver_loaded = 1;
   1.128 +
   1.129 +	SDL_VideoDisplay display;
   1.130 +	SDL_zero(display);
   1.131 +
   1.132 +    /* Use a 32-bpp desktop mode */
   1.133 +    SDL_zero(mode);
   1.134 +	mode.format = SDL_PIXELFORMAT_ABGR8888;
   1.135 +    mode.w = 320;
   1.136 +    mode.h = 480;
   1.137 +    mode.refresh_rate = 0;
   1.138 +    mode.driverdata = NULL;
   1.139 +		
   1.140 +	display.num_display_modes = 1;
   1.141 +	display.max_display_modes = 1;
   1.142 +	display.display_modes = (SDL_DisplayMode *)SDL_malloc(display.max_display_modes * sizeof(SDL_DisplayMode));
   1.143 +	
   1.144 +	display.display_modes[0] = mode;
   1.145 +	display.desktop_mode = mode;
   1.146 +	display.fullscreen_mode = mode;
   1.147 +	display.current_mode = mode;
   1.148 +		
   1.149 +	SDL_AddVideoDisplay(&display);
   1.150 +
   1.151 +    /* We're done! */
   1.152 +    return 0;
   1.153 +}
   1.154 +
   1.155 +static int
   1.156 +UIKit_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
   1.157 +{
   1.158 +    return 0;
   1.159 +}
   1.160 +
   1.161 +void
   1.162 +UIKit_VideoQuit(_THIS)
   1.163 +{
   1.164 +}
   1.165 +
   1.166 +/* vi: set ts=4 sw=4 expandtab: */