Added support for OpenGL ES renderer
authorHolmes Futrell <hfutrell@umail.ucsb.edu>
Tue, 02 Sep 2008 20:19:45 +0000
changeset 2745587d2b5fb805
parent 2744 1aede15771d0
child 2746 722339a7a126
Added support for OpenGL ES renderer
src/video/SDL_video.c
     1.1 --- a/src/video/SDL_video.c	Tue Sep 02 20:11:06 2008 +0000
     1.2 +++ b/src/video/SDL_video.c	Tue Sep 02 20:19:45 2008 +0000
     1.3 @@ -28,10 +28,15 @@
     1.4  #include "SDL_blit.h"
     1.5  #include "SDL_pixels_c.h"
     1.6  #include "SDL_renderer_gl.h"
     1.7 +#include "SDL_renderer_gles.h"
     1.8  #include "SDL_renderer_sw.h"
     1.9  #include "../events/SDL_sysevents.h"
    1.10  #include "../events/SDL_events_c.h"
    1.11  
    1.12 +#if SDL_VIDEO_OPENGL_ES
    1.13 +#include "SDL_opengles.h"
    1.14 +#endif				/* SDL_VIDEO_OPENGL_ES */
    1.15 +
    1.16  #if SDL_VIDEO_OPENGL
    1.17  #include "SDL_opengl.h"
    1.18  
    1.19 @@ -106,6 +111,9 @@
    1.20  #if SDL_VIDEO_DRIVER_NDS
    1.21  	&NDS_bootstrap,
    1.22  #endif
    1.23 +#if SDL_VIDEO_DRIVER_UIKIT
    1.24 +	&UIKIT_bootstrap,
    1.25 +#endif
    1.26  #if SDL_VIDEO_DRIVER_DUMMY
    1.27  	&DUMMY_bootstrap,
    1.28  #endif
    1.29 @@ -244,6 +252,7 @@
    1.30  	_this->gl_config.stereo = 0;
    1.31  	_this->gl_config.multisamplebuffers = 0;
    1.32  	_this->gl_config.multisamplesamples = 0;
    1.33 +	_this->gl_config.retained_backing = 1;
    1.34  	_this->gl_config.accelerated = -1;	/* not known, don't set */
    1.35  
    1.36  	/* Initialize the video subsystem */
    1.37 @@ -262,6 +271,10 @@
    1.38  #if SDL_VIDEO_RENDER_OGL
    1.39  		SDL_AddRenderDriver(i, &GL_RenderDriver);
    1.40  #endif
    1.41 +
    1.42 +#if SDL_VIDEO_RENDER_OGL_ES
    1.43 +		SDL_AddRenderDriver(i, &GL_ES_RenderDriver);
    1.44 +#endif
    1.45  		if (_this->displays[i].num_render_drivers > 0) {
    1.46  			SDL_AddRenderDriver(i, &SW_RenderDriver);
    1.47  		}
    1.48 @@ -2202,7 +2215,7 @@
    1.49  SDL_bool
    1.50  SDL_GL_ExtensionSupported(const char *extension)
    1.51  {
    1.52 -#if SDL_VIDEO_OPENGL
    1.53 +#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES
    1.54  	const GLubyte  *(APIENTRY * glGetStringFunc) (GLenum);
    1.55  	const char     *extensions;
    1.56  	const char     *start;
    1.57 @@ -2256,7 +2269,7 @@
    1.58  int
    1.59  SDL_GL_SetAttribute(SDL_GLattr attr, int value)
    1.60  {
    1.61 -#if SDL_VIDEO_OPENGL
    1.62 +#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES
    1.63  	int             retval;
    1.64  
    1.65  	if (!_this) {
    1.66 @@ -2313,6 +2326,9 @@
    1.67  	case SDL_GL_ACCELERATED_VISUAL:
    1.68  		_this->gl_config.accelerated = value;
    1.69  		break;
    1.70 +	case SDL_GL_RETAINED_BACKING:
    1.71 +		_this->gl_config.retained_backing = value;
    1.72 +		break;
    1.73  	default:
    1.74  		SDL_SetError("Unknown OpenGL attribute");
    1.75  		retval = -1;
    1.76 @@ -2328,7 +2344,7 @@
    1.77  int
    1.78  SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
    1.79  {
    1.80 -#if SDL_VIDEO_OPENGL
    1.81 +#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES
    1.82  	void            (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params);
    1.83  	GLenum          attrib = 0;
    1.84  
    1.85 @@ -2337,6 +2353,9 @@
    1.86  		return -1;
    1.87  	}
    1.88  	switch (attr) {
    1.89 +	case SDL_GL_RETAINED_BACKING:
    1.90 +		*value = _this->gl_config.retained_backing;
    1.91 +		return 0;
    1.92  	case SDL_GL_RED_SIZE:
    1.93  		attrib = GL_RED_BITS;
    1.94  		break;
    1.95 @@ -2350,14 +2369,24 @@
    1.96  		attrib = GL_ALPHA_BITS;
    1.97  		break;
    1.98  	case SDL_GL_DOUBLEBUFFER:
    1.99 +#ifndef SDL_VIDEO_OPENGL_ES
   1.100  		attrib = GL_DOUBLEBUFFER;
   1.101  		break;
   1.102 +#else
   1.103 +		/*
   1.104 +		 * I believe double buffering is the only option in OpenGL ES
   1.105 +		 * -- in any case, GL_DOUBLEBUFFER doesn't exist
   1.106 +		 */
   1.107 +		*value = 1;
   1.108 +		return 0;
   1.109 +#endif
   1.110  	case SDL_GL_DEPTH_SIZE:
   1.111  		attrib = GL_DEPTH_BITS;
   1.112  		break;
   1.113  	case SDL_GL_STENCIL_SIZE:
   1.114  		attrib = GL_STENCIL_BITS;
   1.115  		break;
   1.116 +#ifndef SDL_VIDEO_OPENGL_ES
   1.117  	case SDL_GL_ACCUM_RED_SIZE:
   1.118  		attrib = GL_ACCUM_RED_BITS;
   1.119  		break;
   1.120 @@ -2373,11 +2402,29 @@
   1.121  	case SDL_GL_STEREO:
   1.122  		attrib = GL_STEREO;
   1.123  		break;
   1.124 +#else
   1.125 +	case SDL_GL_ACCUM_RED_SIZE:
   1.126 +	case SDL_GL_ACCUM_GREEN_SIZE:
   1.127 +	case SDL_GL_ACCUM_BLUE_SIZE:
   1.128 +	case SDL_GL_ACCUM_ALPHA_SIZE:
   1.129 +	case SDL_GL_STEREO:
   1.130 +		/* none of these are supported in OpenGL ES */
   1.131 +		*value = 0;
   1.132 +		return 0;
   1.133 +#endif
   1.134  	case SDL_GL_MULTISAMPLEBUFFERS:
   1.135 +#ifndef SDL_VIDEO_OPENGL_ES
   1.136  		attrib = GL_SAMPLE_BUFFERS_ARB;
   1.137 +#else
   1.138 +		attrib = GL_SAMPLE_BUFFERS;
   1.139 +#endif
   1.140  		break;
   1.141  	case SDL_GL_MULTISAMPLESAMPLES:
   1.142 +#ifndef SDL_VIDEO_OPENGL_ES
   1.143  		attrib = GL_SAMPLES_ARB;
   1.144 +#else
   1.145 +		attrib = GL_SAMPLES;
   1.146 +#endif
   1.147  		break;
   1.148  	case SDL_GL_BUFFER_SIZE:
   1.149  		{