src/video/uikit/SDL_uikitvideo.m
author Sam Lantinga
Wed, 13 Jan 2010 05:21:30 +0000
changeset 3643 41253c0fa9b3
parent 3547 8b18669c2663
child 4443 c598e440c87c
permissions -rw-r--r--
Fixed function prototype
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2009 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 #include "SDL_video.h"
    25 #include "SDL_mouse.h"
    26 #include "../SDL_sysvideo.h"
    27 #include "../SDL_pixels_c.h"
    28 #include "../../events/SDL_events_c.h"
    29 
    30 #include "SDL_uikitvideo.h"
    31 #include "SDL_uikitevents.h"
    32 #include "SDL_uikitwindow.h"
    33 #include "SDL_uikitopengles.h"
    34 
    35 #include "SDL_renderer_sw.h"
    36 #include "SDL_renderer_gles.h"
    37 
    38 #define UIKITVID_DRIVER_NAME "uikit"
    39 
    40 /* Initialization/Query functions */
    41 static int UIKit_VideoInit(_THIS);
    42 static int UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay * display,
    43                                 SDL_DisplayMode * mode);
    44 static void UIKit_VideoQuit(_THIS);
    45 
    46 /* DUMMY driver bootstrap functions */
    47 
    48 static int
    49 UIKit_Available(void)
    50 {
    51 	return (1);
    52 }
    53 
    54 static void UIKit_DeleteDevice(SDL_VideoDevice * device)
    55 {
    56     SDL_free(device);
    57 }
    58 
    59 static SDL_VideoDevice *
    60 UIKit_CreateDevice(int devindex)
    61 {
    62     SDL_VideoDevice *device;
    63 
    64     /* Initialize all variables that we clean on shutdown */
    65     device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
    66     if (!device) {
    67         SDL_OutOfMemory();
    68         if (device) {
    69             SDL_free(device);
    70         }
    71         return (0);
    72     }
    73 
    74     /* Set the function pointers */
    75     device->VideoInit = UIKit_VideoInit;
    76     device->VideoQuit = UIKit_VideoQuit;
    77     device->SetDisplayMode = UIKit_SetDisplayMode;
    78     device->PumpEvents = UIKit_PumpEvents;
    79 	device->CreateWindow = UIKit_CreateWindow;
    80 	device->DestroyWindow = UIKit_DestroyWindow;
    81 	
    82 	
    83 	/* OpenGL (ES) functions */
    84 	device->GL_MakeCurrent		= UIKit_GL_MakeCurrent;
    85 	device->GL_SwapWindow		= UIKit_GL_SwapWindow;
    86 	device->GL_CreateContext	= UIKit_GL_CreateContext;
    87 	device->GL_DeleteContext    = UIKit_GL_DeleteContext;
    88 	device->GL_GetProcAddress   = UIKit_GL_GetProcAddress;
    89 	device->GL_LoadLibrary	    = UIKit_GL_LoadLibrary;
    90 	device->free = UIKit_DeleteDevice;
    91 
    92 	device->gl_config.accelerated = 1;
    93 	
    94     return device;
    95 }
    96 
    97 VideoBootStrap UIKIT_bootstrap = {
    98     UIKITVID_DRIVER_NAME, "SDL UIKit video driver",
    99     UIKit_Available, UIKit_CreateDevice
   100 };
   101 
   102 
   103 int
   104 UIKit_VideoInit(_THIS)
   105 {
   106     SDL_DisplayMode mode;
   107 		
   108 	_this->gl_config.driver_loaded = 1;
   109 
   110 	SDL_VideoDisplay display;
   111 	SDL_zero(display);
   112 
   113     /* Use a 32-bpp desktop mode */
   114     SDL_zero(mode);
   115 	mode.format = SDL_PIXELFORMAT_ABGR8888;
   116     mode.w = 320;
   117     mode.h = 480;
   118     mode.refresh_rate = 0;
   119     mode.driverdata = NULL;
   120 		
   121 	display.num_display_modes = 1;
   122 	display.max_display_modes = 1;
   123 	display.display_modes = (SDL_DisplayMode *)SDL_malloc(display.max_display_modes * sizeof(SDL_DisplayMode));
   124 	
   125 	display.display_modes[0] = mode;
   126 	display.desktop_mode = mode;
   127 	display.current_mode = mode;
   128 		
   129 	SDL_AddVideoDisplay(&display);
   130 
   131     /* We're done! */
   132     return 0;
   133 }
   134 
   135 static int
   136 UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
   137 {
   138     return 0;
   139 }
   140 
   141 void
   142 UIKit_VideoQuit(_THIS)
   143 {
   144 }
   145 
   146 /* vi: set ts=4 sw=4 expandtab: */