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. gsoc2008_iphone
authorHolmes Futrell <hfutrell@umail.ucsb.edu>
Thu, 17 Jul 2008 22:32:16 +0000
branchgsoc2008_iphone
changeset 2350eb828d6c3efb
parent 2349 0381047f2210
child 2351 d2a519d2cc57
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.
src/video/uikit/SDL_uikitopengles.h
src/video/uikit/SDL_uikitopengles.m
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/video/uikit/SDL_uikitopengles.h	Thu Jul 17 22:32:16 2008 +0000
     1.3 @@ -0,0 +1,23 @@
     1.4 +/*
     1.5 + *  SDL_uikitopengles.h
     1.6 + *  iPodSDL
     1.7 + *
     1.8 + *  Created by Holmes Futrell on 5/29/08.
     1.9 + *  Copyright 2008 __MyCompanyName__. All rights reserved.
    1.10 + *
    1.11 + */
    1.12 +
    1.13 +#include "SDL_config.h"
    1.14 +
    1.15 +#ifndef _SDL_uikitopengles
    1.16 +#define _SDL_uikitopengles
    1.17 +
    1.18 +#include "SDL_uikitvideo.h"
    1.19 +
    1.20 +extern int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
    1.21 +extern void UIKit_GL_SwapWindow(_THIS, SDL_Window * window);
    1.22 +extern SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window);
    1.23 +extern void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context);
    1.24 +extern void *UIKit_GL_GetProcAddress(_THIS, const char *proc);
    1.25 +extern int UIKit_GL_LoadLibrary(_THIS, const char *path);
    1.26 +#endif
    1.27 \ No newline at end of file
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/video/uikit/SDL_uikitopengles.m	Thu Jul 17 22:32:16 2008 +0000
     2.3 @@ -0,0 +1,92 @@
     2.4 +/*
     2.5 + *  SDL_uikitopengles.c
     2.6 + *  iPodSDL
     2.7 + *
     2.8 + *  Created by Holmes Futrell on 5/29/08.
     2.9 + *  Copyright 2008 __MyCompanyName__. All rights reserved.
    2.10 + *
    2.11 + */
    2.12 +
    2.13 +#include "SDL_uikitopengles.h"
    2.14 +#include "SDL_uikitopenglview.h"
    2.15 +#include "jump.h"
    2.16 +#include "SDL_sysvideo.h"
    2.17 +#include "SDL_loadso.h"
    2.18 +#include <dlfcn.h>
    2.19 +
    2.20 +extern SDL_uikitopenglview *uikitEAGLView;
    2.21 +extern UIWindow *uikitWindow;
    2.22 +
    2.23 +static int UIKit_GL_Initialize(_THIS);
    2.24 +
    2.25 +void *
    2.26 +UIKit_GL_GetProcAddress(_THIS, const char *proc)
    2.27 +{	
    2.28 +	/* Look through all SO's for the proc symbol.  Here's why:
    2.29 +	   -Looking for the path to the OpenGL Library seems not to work in the iPhone Simulator.
    2.30 +	   -We don't know that the path won't change in the future.
    2.31 +	*/
    2.32 +    return SDL_LoadFunction(RTLD_DEFAULT, proc);
    2.33 +}
    2.34 +
    2.35 +int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
    2.36 +{
    2.37 +	[uikitEAGLView setCurrentContext];
    2.38 +    return 0;
    2.39 +}
    2.40 +
    2.41 +int
    2.42 +UIKit_GL_LoadLibrary(_THIS, const char *path)
    2.43 +{
    2.44 +	/* shouldn't be passing a path into this function */
    2.45 +    if (path != NULL) {
    2.46 +		SDL_SetError("iPhone GL Load Library just here for compatibility");
    2.47 +		return -1;
    2.48 +    }
    2.49 +    return 0;
    2.50 +}
    2.51 +
    2.52 +
    2.53 +void UIKit_GL_SwapWindow(_THIS, SDL_Window * window)
    2.54 +{
    2.55 +
    2.56 +	[uikitEAGLView swapBuffers];
    2.57 +	
    2.58 +	/* since now we've got something to draw
    2.59 +	   make the window visible */
    2.60 +	[uikitWindow makeKeyAndVisible];
    2.61 +
    2.62 +	/* we need to let the event cycle run, or the OS won't update the OpenGL view! */
    2.63 +	SDL_PumpEvents();
    2.64 +	
    2.65 +}
    2.66 +
    2.67 +SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
    2.68 +{
    2.69 +	
    2.70 +	uikitEAGLView = [[SDL_uikitopenglview alloc] initWithFrame: [[UIScreen mainScreen] applicationFrame] \
    2.71 +						retainBacking: _this->gl_config.retained_backing \
    2.72 +						rBits: _this->gl_config.red_size \
    2.73 +						gBits: _this->gl_config.green_size \
    2.74 +						bBits: _this->gl_config.blue_size \
    2.75 +						aBits: _this->gl_config.alpha_size \
    2.76 +						depthBits: _this->gl_config.depth_size];
    2.77 +
    2.78 +	[uikitWindow addSubview: [uikitEAGLView autorelease]];
    2.79 +	uikitEAGLView.multipleTouchEnabled = YES;
    2.80 +	
    2.81 +	if ( UIKit_GL_MakeCurrent(_this, window, NULL) < 0 ) {
    2.82 +        //Cocoa_GL_DeleteContext(_this, context);
    2.83 +        return NULL;
    2.84 +    }
    2.85 +		
    2.86 +	return [uikitEAGLView context];
    2.87 +}
    2.88 +
    2.89 +void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context)
    2.90 +{
    2.91 +	
    2.92 +	return;
    2.93 +}
    2.94 +
    2.95 +