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