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