zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_uikitvideo.m
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "SDL_config.h"
22 
23 #if SDL_VIDEO_DRIVER_UIKIT
24 
25 #import <UIKit/UIKit.h>
26 
27 #include "SDL_video.h"
28 #include "SDL_mouse.h"
29 #include "../SDL_sysvideo.h"
30 #include "../SDL_pixels_c.h"
31 #include "../../events/SDL_events_c.h"
32 
33 #include "SDL_uikitvideo.h"
34 #include "SDL_uikitevents.h"
35 #include "SDL_uikitmodes.h"
36 #include "SDL_uikitwindow.h"
37 #include "SDL_uikitopengles.h"
38 
39 #define UIKITVID_DRIVER_NAME "uikit"
40 
41 /* Initialization/Query functions */
42 static int UIKit_VideoInit(_THIS);
43 static void UIKit_VideoQuit(_THIS);
44 
45 /* DUMMY driver bootstrap functions */
46 
47 static int
48 UIKit_Available(void)
49 {
50  return 1;
51 }
52 
53 static void UIKit_DeleteDevice(SDL_VideoDevice * device)
54 {
55  SDL_free(device);
56 }
57 
58 static SDL_VideoDevice *
59 UIKit_CreateDevice(int devindex)
60 {
61  SDL_VideoDevice *device;
62 
63  /* Initialize all variables that we clean on shutdown */
64  device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
65  if (!device) {
66  SDL_free(device);
68  return (0);
69  }
70 
71  /* Set the function pointers */
72  device->VideoInit = UIKit_VideoInit;
73  device->VideoQuit = UIKit_VideoQuit;
76  device->PumpEvents = UIKit_PumpEvents;
78  device->ShowWindow = UIKit_ShowWindow;
79  device->HideWindow = UIKit_HideWindow;
84 
85  /* !!! FIXME: implement SetWindowBordered */
86 
87 #if SDL_IPHONE_KEYBOARD
88  device->HasScreenKeyboardSupport = UIKit_HasScreenKeyboardSupport;
89  device->ShowScreenKeyboard = UIKit_ShowScreenKeyboard;
90  device->HideScreenKeyboard = UIKit_HideScreenKeyboard;
91  device->IsScreenKeyboardShown = UIKit_IsScreenKeyboardShown;
92 #endif
93 
94  /* OpenGL (ES) functions */
101  device->free = UIKit_DeleteDevice;
102 
103  device->gl_config.accelerated = 1;
104 
105  return device;
106 }
107 
108 VideoBootStrap UIKIT_bootstrap = {
109  UIKITVID_DRIVER_NAME, "SDL UIKit video driver",
110  UIKit_Available, UIKit_CreateDevice
111 };
112 
113 
114 int
115 UIKit_VideoInit(_THIS)
116 {
118 
119  if (UIKit_InitModes(_this) < 0) {
120  return -1;
121  }
122  return 0;
123 }
124 
125 void
126 UIKit_VideoQuit(_THIS)
127 {
129 }
130 
131 /*
132  * iOS log support.
133  *
134  * This doesn't really have aything to do with the interfaces of the SDL video
135  * subsystem, but we need to stuff this into an Objective-C source code file.
136  */
137 
138 void SDL_NSLog(const char *text)
139 {
140  NSLog(@"%s", text);
141 }
142 
143 #endif /* SDL_VIDEO_DRIVER_UIKIT */
144 
145 /* vi: set ts=4 sw=4 expandtab: */
void(* GetDisplayModes)(_THIS, SDL_VideoDisplay *display)
Definition: SDL_sysvideo.h:169
int UIKit_InitModes(_THIS)
void UIKit_QuitModes(_THIS)
SDL_bool(* GetWindowWMInfo)(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
Definition: SDL_sysvideo.h:215
SDL_bool(* IsScreenKeyboardShown)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:251
void(* RaiseWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:193
void UIKit_PumpEvents(_THIS)
SDL_bool UIKit_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
int UIKit_CreateWindow(_THIS, SDL_Window *window)
DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size)
void UIKit_DestroyWindow(_THIS, SDL_Window *window)
void(* HideWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:192
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
Definition: SDL_sysvideo.h:226
void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context)
DECLSPEC void SDLCALL SDL_free(void *mem)
void UIKit_RaiseWindow(_THIS, SDL_Window *window)
SDL_bool(* HasScreenKeyboardSupport)(_THIS)
Definition: SDL_sysvideo.h:248
void UIKit_HideWindow(_THIS, SDL_Window *window)
int UIKit_GL_LoadLibrary(_THIS, const char *path)
void UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
void(* HideScreenKeyboard)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:250
void(* free)(_THIS)
Definition: SDL_sysvideo.h:327
static SDL_VideoDevice * _this
Definition: SDL_video.c:92
int(* CreateWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:183
void UIKit_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
int(* VideoInit)(_THIS)
Definition: SDL_sysvideo.h:148
#define _THIS
void(* PumpEvents)(_THIS)
Definition: SDL_sysvideo.h:237
void UIKit_GL_SwapWindow(_THIS, SDL_Window *window)
SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window *window)
void * UIKit_GL_GetProcAddress(_THIS, const char *proc)
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
Definition: SDL_sysvideo.h:231
void(* DestroyWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:202
int(* SetDisplayMode)(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
Definition: SDL_sysvideo.h:177
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:225
int(* GL_LoadLibrary)(_THIS, const char *path)
Definition: SDL_sysvideo.h:222
void(* GL_SwapWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:230
void(* VideoQuit)(_THIS)
Definition: SDL_sysvideo.h:154
void(* ShowWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:191
void(* SetWindowFullscreen)(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
Definition: SDL_sysvideo.h:198
void UIKit_ShowWindow(_THIS, SDL_Window *window)
struct SDL_VideoDevice::@87 gl_config
void *(* GL_GetProcAddress)(_THIS, const char *proc)
Definition: SDL_sysvideo.h:223
int UIKit_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
void(* ShowScreenKeyboard)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:249
int UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)