comparison src/video/uikit/SDL_uikitopengles.m @ 2350:eb828d6c3efb gsoc2008_iphone

SDL_uikitopengles is responsible for OpenGLES related functions in the UIKit video driver. The main thing to note is UIKit_GL_CreateContext which creates an instance of the SDL_uikitopenglview class, an OpenGL ES View. Most the real functionality is in SDL_uikitopenglview.
author Holmes Futrell <hfutrell@umail.ucsb.edu>
date Thu, 17 Jul 2008 22:32:16 +0000
parents
children 1fe89198aba5
comparison
equal deleted inserted replaced
2349:0381047f2210 2350:eb828d6c3efb
1 /*
2 * SDL_uikitopengles.c
3 * iPodSDL
4 *
5 * Created by Holmes Futrell on 5/29/08.
6 * Copyright 2008 __MyCompanyName__. All rights reserved.
7 *
8 */
9
10 #include "SDL_uikitopengles.h"
11 #include "SDL_uikitopenglview.h"
12 #include "jump.h"
13 #include "SDL_sysvideo.h"
14 #include "SDL_loadso.h"
15 #include <dlfcn.h>
16
17 extern SDL_uikitopenglview *uikitEAGLView;
18 extern UIWindow *uikitWindow;
19
20 static int UIKit_GL_Initialize(_THIS);
21
22 void *
23 UIKit_GL_GetProcAddress(_THIS, const char *proc)
24 {
25 /* Look through all SO's for the proc symbol. Here's why:
26 -Looking for the path to the OpenGL Library seems not to work in the iPhone Simulator.
27 -We don't know that the path won't change in the future.
28 */
29 return SDL_LoadFunction(RTLD_DEFAULT, proc);
30 }
31
32 int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
33 {
34 [uikitEAGLView setCurrentContext];
35 return 0;
36 }
37
38 int
39 UIKit_GL_LoadLibrary(_THIS, const char *path)
40 {
41 /* shouldn't be passing a path into this function */
42 if (path != NULL) {
43 SDL_SetError("iPhone GL Load Library just here for compatibility");
44 return -1;
45 }
46 return 0;
47 }
48
49
50 void UIKit_GL_SwapWindow(_THIS, SDL_Window * window)
51 {
52
53 [uikitEAGLView swapBuffers];
54
55 /* since now we've got something to draw
56 make the window visible */
57 [uikitWindow makeKeyAndVisible];
58
59 /* we need to let the event cycle run, or the OS won't update the OpenGL view! */
60 SDL_PumpEvents();
61
62 }
63
64 SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
65 {
66
67 uikitEAGLView = [[SDL_uikitopenglview alloc] initWithFrame: [[UIScreen mainScreen] applicationFrame] \
68 retainBacking: _this->gl_config.retained_backing \
69 rBits: _this->gl_config.red_size \
70 gBits: _this->gl_config.green_size \
71 bBits: _this->gl_config.blue_size \
72 aBits: _this->gl_config.alpha_size \
73 depthBits: _this->gl_config.depth_size];
74
75 [uikitWindow addSubview: [uikitEAGLView autorelease]];
76 uikitEAGLView.multipleTouchEnabled = YES;
77
78 if ( UIKit_GL_MakeCurrent(_this, window, NULL) < 0 ) {
79 //Cocoa_GL_DeleteContext(_this, context);
80 return NULL;
81 }
82
83 return [uikitEAGLView context];
84 }
85
86 void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context)
87 {
88
89 return;
90 }
91
92