SDL_uikitvideo.m is the main file for the UIKit video driver. It has the UIKit video bootstrap, initialization, device creation, etc. gsoc2008_iphone
authorHolmes Futrell <hfutrell@umail.ucsb.edu>
Thu, 17 Jul 2008 22:38:29 +0000
branchgsoc2008_iphone
changeset 23521ecbeff9eb4c
parent 2351 d2a519d2cc57
child 2353 07acabba25d9
SDL_uikitvideo.m is the main file for the UIKit video driver. It has the UIKit video bootstrap, initialization, device creation, etc.
src/video/uikit/SDL_uikitvideo.h
src/video/uikit/SDL_uikitvideo.m
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/video/uikit/SDL_uikitvideo.h	Thu Jul 17 22:38:29 2008 +0000
     1.3 @@ -0,0 +1,31 @@
     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 +#ifndef _SDL_uikitvideo_h
    1.28 +#define _SDL_uikitvideo_h
    1.29 +
    1.30 +#include "../SDL_sysvideo.h"
    1.31 +
    1.32 +#endif /* _SDL_uikitvideo_h */
    1.33 +
    1.34 +/* vi: set ts=4 sw=4 expandtab: */
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/video/uikit/SDL_uikitvideo.m	Thu Jul 17 22:38:29 2008 +0000
     2.3 @@ -0,0 +1,163 @@
     2.4 +/*
     2.5 +    SDL - Simple DirectMedia Layer
     2.6 +    Copyright (C) 1997-2006 Sam Lantinga
     2.7 +
     2.8 +    This library is free software; you can redistribute it and/or
     2.9 +    modify it under the terms of the GNU Lesser General Public
    2.10 +    License as published by the Free Software Foundation; either
    2.11 +    version 2.1 of the License, or (at your option) any later version.
    2.12 +
    2.13 +    This library is distributed in the hope that it will be useful,
    2.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    2.16 +    Lesser General Public License for more details.
    2.17 +
    2.18 +    You should have received a copy of the GNU Lesser General Public
    2.19 +    License along with this library; if not, write to the Free Software
    2.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    2.21 +
    2.22 +    Sam Lantinga
    2.23 +    slouken@libsdl.org
    2.24 +*/
    2.25 +#include "SDL_config.h"
    2.26 +
    2.27 +/* Dummy SDL video driver implementation; this is just enough to make an
    2.28 + *  SDL-based application THINK it's got a working video driver, for
    2.29 + *  applications that call SDL_Init(SDL_INIT_VIDEO) when they don't need it,
    2.30 + *  and also for use as a collection of stubs when porting SDL to a new
    2.31 + *  platform for which you haven't yet written a valid video driver.
    2.32 + *
    2.33 + * This is also a great way to determine bottlenecks: if you think that SDL
    2.34 + *  is a performance problem for a given platform, enable this driver, and
    2.35 + *  then see if your application runs faster without video overhead.
    2.36 + *
    2.37 + * Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion
    2.38 + *  of this was cut-and-pasted from Stephane Peter's work in the AAlib
    2.39 + *  SDL video driver.  Renamed to "DUMMY" by Sam Lantinga.
    2.40 + */
    2.41 +
    2.42 +#include "SDL_video.h"
    2.43 +#include "SDL_mouse.h"
    2.44 +#include "../SDL_sysvideo.h"
    2.45 +#include "../SDL_pixels_c.h"
    2.46 +#include "../../events/SDL_events_c.h"
    2.47 +
    2.48 +#include "SDL_uikitvideo.h"
    2.49 +#include "SDL_uikitevents.h"
    2.50 +#include "SDL_uikitwindow.h"
    2.51 +#include "SDL_uikitopengles.h"
    2.52 +
    2.53 +#include "SDL_renderer_sw.h"
    2.54 +#include "SDL_renderer_gles.h"
    2.55 +
    2.56 +#define UIKITVID_DRIVER_NAME "uikit"
    2.57 +
    2.58 +/* Initialization/Query functions */
    2.59 +static int UIKit_VideoInit(_THIS);
    2.60 +static int UIKit_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
    2.61 +static void UIKit_VideoQuit(_THIS);
    2.62 +
    2.63 +/* DUMMY driver bootstrap functions */
    2.64 +
    2.65 +static int
    2.66 +UIKit_Available(void)
    2.67 +{
    2.68 +	return (1);
    2.69 +}
    2.70 +
    2.71 +static void UIKit_DeleteDevice(SDL_VideoDevice * device)
    2.72 +{
    2.73 +    SDL_free(device);
    2.74 +}
    2.75 +
    2.76 +static SDL_VideoDevice *
    2.77 +UIKit_CreateDevice(int devindex)
    2.78 +{
    2.79 +    SDL_VideoDevice *device;
    2.80 +
    2.81 +    /* Initialize all variables that we clean on shutdown */
    2.82 +    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
    2.83 +    if (!device) {
    2.84 +        SDL_OutOfMemory();
    2.85 +        if (device) {
    2.86 +            SDL_free(device);
    2.87 +        }
    2.88 +        return (0);
    2.89 +    }
    2.90 +
    2.91 +    /* Set the function pointers */
    2.92 +    device->VideoInit = UIKit_VideoInit;
    2.93 +    device->VideoQuit = UIKit_VideoQuit;
    2.94 +    device->SetDisplayMode = UIKit_SetDisplayMode;
    2.95 +    device->PumpEvents = UIKit_PumpEvents;
    2.96 +	device->CreateWindow = UIKit_CreateWindow;
    2.97 +	device->DestroyWindow = UIKit_DestroyWindow;
    2.98 +	
    2.99 +	
   2.100 +	/* OpenGL (ES) functions */
   2.101 +	device->GL_MakeCurrent		= UIKit_GL_MakeCurrent;
   2.102 +	device->GL_SwapWindow		= UIKit_GL_SwapWindow;
   2.103 +	device->GL_CreateContext	= UIKit_GL_CreateContext;
   2.104 +	device->GL_DeleteContext    = UIKit_GL_DeleteContext;
   2.105 +	device->GL_GetProcAddress   = UIKit_GL_GetProcAddress;
   2.106 +	device->GL_LoadLibrary	    = UIKit_GL_LoadLibrary;
   2.107 +	device->free = UIKit_DeleteDevice;
   2.108 +
   2.109 +	device->gl_config.accelerated = 1;
   2.110 +	
   2.111 +    return device;
   2.112 +}
   2.113 +
   2.114 +VideoBootStrap UIKIT_bootstrap = {
   2.115 +    UIKITVID_DRIVER_NAME, "SDL UIKit video driver",
   2.116 +    UIKit_Available, UIKit_CreateDevice
   2.117 +};
   2.118 +
   2.119 +
   2.120 +int
   2.121 +UIKit_VideoInit(_THIS)
   2.122 +{
   2.123 +    SDL_DisplayMode mode;
   2.124 +
   2.125 +	printf("UIKit Video init!");
   2.126 +		
   2.127 +	_this->gl_config.driver_loaded = 1;
   2.128 +
   2.129 +	SDL_VideoDisplay display;
   2.130 +	SDL_zero(display);
   2.131 +
   2.132 +    /* Use a 32-bpp desktop mode */
   2.133 +    SDL_zero(mode);
   2.134 +	mode.format = SDL_PIXELFORMAT_ABGR8888;
   2.135 +    mode.w = 320;
   2.136 +    mode.h = 480;
   2.137 +    mode.refresh_rate = 0;
   2.138 +    mode.driverdata = NULL;
   2.139 +		
   2.140 +	display.num_display_modes = 1;
   2.141 +	display.max_display_modes = 1;
   2.142 +	display.display_modes = (SDL_DisplayMode *)SDL_malloc(display.max_display_modes * sizeof(SDL_DisplayMode));
   2.143 +	
   2.144 +	display.display_modes[0] = mode;
   2.145 +	display.desktop_mode = mode;
   2.146 +	display.fullscreen_mode = mode;
   2.147 +	display.current_mode = mode;
   2.148 +		
   2.149 +	SDL_AddVideoDisplay(&display);
   2.150 +
   2.151 +    /* We're done! */
   2.152 +    return 0;
   2.153 +}
   2.154 +
   2.155 +static int
   2.156 +UIKit_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
   2.157 +{
   2.158 +    return 0;
   2.159 +}
   2.160 +
   2.161 +void
   2.162 +UIKit_VideoQuit(_THIS)
   2.163 +{
   2.164 +}
   2.165 +
   2.166 +/* vi: set ts=4 sw=4 expandtab: */