<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://pandorawiki.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Lonewolf9383</id>
	<title>Pandora Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://pandorawiki.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Lonewolf9383"/>
	<link rel="alternate" type="text/html" href="https://pandorawiki.org/Special:Contributions/Lonewolf9383"/>
	<updated>2026-05-05T09:05:50Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.32.0-alpha</generator>
	<entry>
		<id>https://pandorawiki.org/index.php?title=Combining_OpenGL_ES_1.1_and_SDL_to_create_a_window_on_the_Pandora&amp;diff=3468</id>
		<title>Combining OpenGL ES 1.1 and SDL to create a window on the Pandora</title>
		<link rel="alternate" type="text/html" href="https://pandorawiki.org/index.php?title=Combining_OpenGL_ES_1.1_and_SDL_to_create_a_window_on_the_Pandora&amp;diff=3468"/>
		<updated>2010-08-31T15:15:36Z</updated>

		<summary type="html">&lt;p&gt;Lonewolf9383: /* 2: Use EGL Directly (with SDL 1.2) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are two options for combining GLES and SDL:&lt;br /&gt;
&lt;br /&gt;
= 1: Grab the modified version of SDL =&lt;br /&gt;
&lt;br /&gt;
There is a special SDL source code for pandora with OpenGL ES capability &lt;br /&gt;
available here : http://github.com/Cpasjuste&lt;br /&gt;
&lt;br /&gt;
The screen initialisation is now easy as this : SDL_SetVideoMode(800, 480, 16, SDL_OPENGLES)&lt;br /&gt;
&lt;br /&gt;
An SDL/GLES exemple is also available on the git repository.&lt;br /&gt;
&lt;br /&gt;
= 2: Use EGL Directly (with SDL 1.2) =&lt;br /&gt;
&lt;br /&gt;
Sometimes its not best to use the modified version of SDl (when working on cross platform games). Instead you can use EGL to create the GLES graphics context for you.&lt;br /&gt;
The following functions do just that.&lt;br /&gt;
&lt;br /&gt;
Steps:&lt;br /&gt;
# Make sure you call InitOpenGL() straight after creating the window (SDL_SetVideoMode()).&lt;br /&gt;
# When using EGL you should not pass in the SDL_OPENGL flag to SDL_SetVideoMode(). SDL_HWSurface and SDL_SWSurface should do.&lt;br /&gt;
# You will notice '#ifdef GLES1' around much of the EGL code. Simply define GLES1 in your preprocessor (-DGLES1 on the command line of gcc if i recall correctly?) to use GLES. Without the define SDL will be set up for standard OpenGL (I left it in as its useful for cross platform dev).&lt;br /&gt;
# Once you have finished with the window and just before terminating it call TerminateOpenGL() to clean up.&lt;br /&gt;
&lt;br /&gt;
NOTE - If you call SDL_SetVideoMode more than once you will probably need to terminate and reset the context (TerminateOpenGL(); SDL_SetVideoMode(); InitOpenGL();)&lt;br /&gt;
&lt;br /&gt;
// OpenGLInit.c&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	#include &amp;lt;EGL/egl.h&amp;gt;&lt;br /&gt;
	#include &amp;lt;GLES/gl.h&amp;gt;&lt;br /&gt;
	#include &amp;lt;SDL/SDL_syswm.h&amp;gt;&lt;br /&gt;
#else&lt;br /&gt;
	#include &amp;lt;GL/gl.h&amp;gt;&lt;br /&gt;
	#include &amp;lt;SDL/SDL.h&amp;gt;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;OpenGLInit.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	EGLDisplay g_eglDisplay = 0;&lt;br /&gt;
	EGLConfig g_eglConfig = 0;&lt;br /&gt;
	EGLContext g_eglContext = 0;&lt;br /&gt;
	EGLSurface g_eglSurface = 0;&lt;br /&gt;
        Display *g_x11Display = NULL;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
// consts&lt;br /&gt;
#define COLOURDEPTH_RED_SIZE  		5&lt;br /&gt;
#define COLOURDEPTH_GREEN_SIZE 		6&lt;br /&gt;
#define COLOURDEPTH_BLUE_SIZE 		5&lt;br /&gt;
#define COLOURDEPTH_DEPTH_SIZE		16&lt;br /&gt;
&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
static const EGLint g_configAttribs[] ={&lt;br /&gt;
										  EGL_RED_SIZE,      	    COLOURDEPTH_RED_SIZE,&lt;br /&gt;
										  EGL_GREEN_SIZE,    	    COLOURDEPTH_GREEN_SIZE,&lt;br /&gt;
										  EGL_BLUE_SIZE,     	    COLOURDEPTH_BLUE_SIZE,&lt;br /&gt;
										  EGL_DEPTH_SIZE,	    COLOURDEPTH_DEPTH_SIZE,&lt;br /&gt;
										  EGL_SURFACE_TYPE,         EGL_WINDOW_BIT,&lt;br /&gt;
										  EGL_RENDERABLE_TYPE,      EGL_OPENGL_ES_BIT,&lt;br /&gt;
										  EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE,&lt;br /&gt;
										  EGL_NONE&lt;br /&gt;
									   };&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
/*===========================================================&lt;br /&gt;
Initialise opengl settings. Call straight after SDL_SetVideoMode()&lt;br /&gt;
===========================================================*/&lt;br /&gt;
&lt;br /&gt;
int InitOpenGL()&lt;br /&gt;
{&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	// use EGL to initialise GLES&lt;br /&gt;
	g_x11Display = XOpenDisplay(NULL);&lt;br /&gt;
&lt;br /&gt;
	if (!g_x11Display)&lt;br /&gt;
	{&lt;br /&gt;
		fprintf(stderr, &amp;quot;ERROR: unable to get display!n&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	g_eglDisplay = eglGetDisplay((EGLNativeDisplayType)g_x11Display);&lt;br /&gt;
	if (g_eglDisplay == EGL_NO_DISPLAY)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to initialise EGL display.&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Initialise egl&lt;br /&gt;
	if (!eglInitialize(g_eglDisplay, NULL, NULL))&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to initialise EGL display.&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Find a matching config&lt;br /&gt;
	EGLint numConfigsOut = 0;&lt;br /&gt;
	if (eglChooseConfig(g_eglDisplay, g_configAttribs, &amp;amp;g_eglConfig, 1, &amp;amp;numConfigsOut) != EGL_TRUE || numConfigsOut == 0)&lt;br /&gt;
	{&lt;br /&gt;
		fprintf(stderr, &amp;quot;Unable to find appropriate EGL config.&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Get the SDL window handle&lt;br /&gt;
	SDL_SysWMinfo sysInfo; //Will hold our Window information&lt;br /&gt;
	SDL_VERSION(&amp;amp;sysInfo.version); //Set SDL version&lt;br /&gt;
	if(SDL_GetWMInfo(&amp;amp;sysInfo) &amp;lt;= 0) &lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to get window handle&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	g_eglSurface = eglCreateWindowSurface(g_eglDisplay, g_eglConfig, (EGLNativeWindowType)sysInfo.info.x11.window, 0);&lt;br /&gt;
	if ( g_eglSurface == EGL_NO_SURFACE)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to create EGL surface!&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Bind GLES and create the context&lt;br /&gt;
	eglBindAPI(EGL_OPENGL_ES_API);&lt;br /&gt;
	EGLint contextParams[] = {EGL_CONTEXT_CLIENT_VERSION, 1, EGL_NONE};		// Use GLES version 1.x&lt;br /&gt;
	g_eglContext = eglCreateContext(g_eglDisplay, g_eglConfig, NULL, NULL);&lt;br /&gt;
	if (g_eglContext == EGL_NO_CONTEXT)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to create GLES context!&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	if (eglMakeCurrent(g_eglDisplay,  g_eglSurface,  g_eglSurface, g_eglContext) == EGL_FALSE)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to make GLES context current&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
#else&lt;br /&gt;
	&lt;br /&gt;
	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, COLOURDEPTH_RED_SIZE);&lt;br /&gt;
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, COLOURDEPTH_GREEN_SIZE);&lt;br /&gt;
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, COLOURDEPTH_BLUE_SIZE);&lt;br /&gt;
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, COLOURDEPTH_DEPTH_SIZE);&lt;br /&gt;
	&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
	return 1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*======================================================&lt;br /&gt;
 * Kill off any opengl specific details&lt;br /&gt;
  ====================================================*/&lt;br /&gt;
void TerminateOpenGL()&lt;br /&gt;
{&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	eglMakeCurrent(g_eglDisplay, NULL, NULL, EGL_NO_CONTEXT);&lt;br /&gt;
	eglDestroySurface(g_eglDisplay, g_eglSurface);&lt;br /&gt;
	eglDestroyContext(g_eglDisplay, g_eglContext);&lt;br /&gt;
	g_eglSurface = 0;&lt;br /&gt;
	g_eglContext = 0;&lt;br /&gt;
	g_eglConfig = 0;&lt;br /&gt;
	eglTerminate(g_eglDisplay);&lt;br /&gt;
	g_eglDisplay = 0;&lt;br /&gt;
        XCloseDisplay(g_x11Display);&lt;br /&gt;
        g_x11Display = NULL;&lt;br /&gt;
#endif&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int SwapBuffers()&lt;br /&gt;
{&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	eglSwapBuffers(g_eglDisplay, g_eglSurface);&lt;br /&gt;
#else&lt;br /&gt;
	SDL_GL_SwapBuffers();&lt;br /&gt;
#endif&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Lonewolf9383</name></author>
		
	</entry>
	<entry>
		<id>https://pandorawiki.org/index.php?title=Combining_OpenGL_ES_1.1_and_SDL_to_create_a_window_on_the_Pandora&amp;diff=3202</id>
		<title>Combining OpenGL ES 1.1 and SDL to create a window on the Pandora</title>
		<link rel="alternate" type="text/html" href="https://pandorawiki.org/index.php?title=Combining_OpenGL_ES_1.1_and_SDL_to_create_a_window_on_the_Pandora&amp;diff=3202"/>
		<updated>2010-07-21T22:19:40Z</updated>

		<summary type="html">&lt;p&gt;Lonewolf9383: /* 2: Use EGL Directly */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are two options for combining GLES and SDL:&lt;br /&gt;
&lt;br /&gt;
= 1: Grab the modified version of SDL =&lt;br /&gt;
&lt;br /&gt;
There is a special SDL source code for pandora with OpenGL ES capability &lt;br /&gt;
available here : http://github.com/Cpasjuste&lt;br /&gt;
&lt;br /&gt;
The screen initialisation is now easy as this : SDL_SetVideoMode(800, 480, 16, SDL_OPENGLES)&lt;br /&gt;
&lt;br /&gt;
An SDL/GLES exemple is also available on the git repository.&lt;br /&gt;
&lt;br /&gt;
= 2: Use EGL Directly (with SDL 1.2) =&lt;br /&gt;
&lt;br /&gt;
Sometimes its not best to use the modified version of SDl (when working on cross platform games). Instead you can use EGL to create the GLES graphics context for you.&lt;br /&gt;
The following functions do just that.&lt;br /&gt;
&lt;br /&gt;
Steps:&lt;br /&gt;
# Make sure you call InitOpenGL() straight after creating the window (SDL_SetVideoMode()).&lt;br /&gt;
# When using EGL you should not pass in the SDL_OPENGL flag to SDL_SetVideoMode(). SDL_HWSurface and SDL_SWSurface should do.&lt;br /&gt;
# You will notice '#ifdef GLES1' around much of the EGL code. Simply define GLES1 in your preprocessor (-DGLES1 on the command line of gcc if i recall correctly?) to use GLES. Without the define SDL will be set up for standard OpenGL (I left it in as its useful for cross platform dev).&lt;br /&gt;
# Once you have finished with the window and just before terminating it call TerminateOpenGL() to clean up.&lt;br /&gt;
&lt;br /&gt;
NOTE - If you call SDL_SetVideoMode more than once you will probably need to terminate and reset the context (TerminateOpenGL(); SDL_SetVideoMode(); InitOpenGL();)&lt;br /&gt;
&lt;br /&gt;
// OpenGLInit.c&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	#include &amp;lt;EGL/egl.h&amp;gt;&lt;br /&gt;
	#include &amp;lt;GLES/gl.h&amp;gt;&lt;br /&gt;
	#include &amp;lt;SDL/SDL_syswm.h&amp;gt;&lt;br /&gt;
#else&lt;br /&gt;
	#include &amp;lt;GL/gl.h&amp;gt;&lt;br /&gt;
	#include &amp;lt;SDL/SDL.h&amp;gt;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;OpenGLInit.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	EGLDisplay g_eglDisplay = 0;&lt;br /&gt;
	EGLConfig g_eglConfig = 0;&lt;br /&gt;
	EGLContext g_eglContext = 0;&lt;br /&gt;
	EGLSurface g_eglSurface = 0;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
// consts&lt;br /&gt;
#define COLOURDEPTH_RED_SIZE  		5&lt;br /&gt;
#define COLOURDEPTH_GREEN_SIZE 		6&lt;br /&gt;
#define COLOURDEPTH_BLUE_SIZE 		5&lt;br /&gt;
#define COLOURDEPTH_DEPTH_SIZE		16&lt;br /&gt;
&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
static const EGLint g_configAttribs[] ={&lt;br /&gt;
										  EGL_RED_SIZE,      	    COLOURDEPTH_RED_SIZE,&lt;br /&gt;
										  EGL_GREEN_SIZE,    	    COLOURDEPTH_GREEN_SIZE,&lt;br /&gt;
										  EGL_BLUE_SIZE,     	    COLOURDEPTH_BLUE_SIZE,&lt;br /&gt;
										  EGL_DEPTH_SIZE,	    COLOURDEPTH_DEPTH_SIZE,&lt;br /&gt;
										  EGL_SURFACE_TYPE,         EGL_WINDOW_BIT,&lt;br /&gt;
										  EGL_RENDERABLE_TYPE,      EGL_OPENGL_ES_BIT,&lt;br /&gt;
										  EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE,&lt;br /&gt;
										  EGL_NONE&lt;br /&gt;
									   };&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
/*===========================================================&lt;br /&gt;
Initialise opengl settings. Call straight after SDL_SetVideoMode()&lt;br /&gt;
===========================================================*/&lt;br /&gt;
&lt;br /&gt;
int InitOpenGL()&lt;br /&gt;
{&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	// use EGL to initialise GLES&lt;br /&gt;
	g_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);&lt;br /&gt;
	if (g_eglDisplay == EGL_NO_DISPLAY)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to initialise EGL display.&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Initialise egl&lt;br /&gt;
	if (!eglInitialize(g_eglDisplay, NULL, NULL))&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to initialise EGL display.&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Find a matching config&lt;br /&gt;
	EGLint numConfigsOut = 0;&lt;br /&gt;
	if (eglChooseConfig(g_eglDisplay, g_configAttribs, &amp;amp;g_eglConfig, 1, &amp;amp;numConfigsOut) != EGL_TRUE || numConfigsOut == 0)&lt;br /&gt;
	{&lt;br /&gt;
		fprintf(stderr, &amp;quot;Unable to find appropriate EGL config.&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Get the SDL window handle&lt;br /&gt;
	SDL_SysWMinfo sysInfo; //Will hold our Window information&lt;br /&gt;
	SDL_VERSION(&amp;amp;sysInfo.version); //Set SDL version&lt;br /&gt;
	if(SDL_GetWMInfo(&amp;amp;sysInfo) &amp;lt;= 0) &lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to get window handle&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	g_eglSurface = eglCreateWindowSurface(g_eglDisplay, g_eglConfig, (EGLNativeWindowType)sysInfo.info.x11.window, 0);&lt;br /&gt;
	if ( g_eglSurface == EGL_NO_SURFACE)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to create EGL surface!&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Bind GLES and create the context&lt;br /&gt;
	eglBindAPI(EGL_OPENGL_ES_API);&lt;br /&gt;
	EGLint contextParams[] = {EGL_CONTEXT_CLIENT_VERSION, 1, EGL_NONE};		// Use GLES version 1.x&lt;br /&gt;
	g_eglContext = eglCreateContext(g_eglDisplay, g_eglConfig, NULL, NULL);&lt;br /&gt;
	if (g_eglContext == EGL_NO_CONTEXT)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to create GLES context!&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	if (eglMakeCurrent(g_eglDisplay,  g_eglSurface,  g_eglSurface, g_eglContext) == EGL_FALSE)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to make GLES context current&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
#else&lt;br /&gt;
	&lt;br /&gt;
	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, COLOURDEPTH_RED_SIZE);&lt;br /&gt;
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, COLOURDEPTH_GREEN_SIZE);&lt;br /&gt;
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, COLOURDEPTH_BLUE_SIZE);&lt;br /&gt;
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, COLOURDEPTH_DEPTH_SIZE);&lt;br /&gt;
	&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
	return 1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*======================================================&lt;br /&gt;
 * Kill off any opengl specific details&lt;br /&gt;
  ====================================================*/&lt;br /&gt;
void TerminateOpenGL()&lt;br /&gt;
{&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	eglMakeCurrent(g_eglDisplay, NULL, NULL, EGL_NO_CONTEXT);&lt;br /&gt;
	eglDestroySurface(g_eglDisplay, g_eglSurface);&lt;br /&gt;
	eglDestroyContext(g_eglDisplay, g_eglContext);&lt;br /&gt;
	g_eglSurface = 0;&lt;br /&gt;
	g_eglContext = 0;&lt;br /&gt;
	g_eglConfig = 0;&lt;br /&gt;
	eglTerminate(g_eglDisplay);&lt;br /&gt;
	g_eglDisplay = 0;&lt;br /&gt;
#endif&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int SwapBuffers()&lt;br /&gt;
{&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	eglSwapBuffers(g_eglDisplay, g_eglSurface);&lt;br /&gt;
#else&lt;br /&gt;
	SDL_GL_SwapBuffers();&lt;br /&gt;
#endif&lt;br /&gt;
}&lt;br /&gt;
[/source]&lt;br /&gt;
&lt;br /&gt;
~~~&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Lonewolf9383</name></author>
		
	</entry>
	<entry>
		<id>https://pandorawiki.org/index.php?title=Combining_OpenGL_ES_1.1_and_SDL_to_create_a_window_on_the_Pandora&amp;diff=3201</id>
		<title>Combining OpenGL ES 1.1 and SDL to create a window on the Pandora</title>
		<link rel="alternate" type="text/html" href="https://pandorawiki.org/index.php?title=Combining_OpenGL_ES_1.1_and_SDL_to_create_a_window_on_the_Pandora&amp;diff=3201"/>
		<updated>2010-07-21T22:13:30Z</updated>

		<summary type="html">&lt;p&gt;Lonewolf9383: /* 2: Use EGL */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are two options for combining GLES and SDL:&lt;br /&gt;
&lt;br /&gt;
= 1: Grab the modified version of SDL =&lt;br /&gt;
&lt;br /&gt;
There is a special SDL source code for pandora with OpenGL ES capability &lt;br /&gt;
available here : http://github.com/Cpasjuste&lt;br /&gt;
&lt;br /&gt;
The screen initialisation is now easy as this : SDL_SetVideoMode(800, 480, 16, SDL_OPENGLES)&lt;br /&gt;
&lt;br /&gt;
An SDL/GLES exemple is also available on the git repository.&lt;br /&gt;
&lt;br /&gt;
= 2: Use EGL Directly =&lt;br /&gt;
&lt;br /&gt;
Sometimes its not best to use the modified version of SDl (when working on cross platform games). Instead you can use EGL to create the GLES graphics context for you.&lt;br /&gt;
The following functions do just that.&lt;br /&gt;
&lt;br /&gt;
Steps:&lt;br /&gt;
# Make sure you call InitOpenGL() straight after creating the window (SDL_SetVideoMode()).&lt;br /&gt;
# When using EGL you should not pass in the SDL_OPENGL flag to SDL_SetVideoMode(). SDL_HWSurface and SDL_SWSurface should do.&lt;br /&gt;
# You will notice '#ifdef GLES1' around much of the EGL code. Simply define GLES1 in your preprocessor (-DGLES1 on the command line of gcc if i recall correctly?) to use GLES. Without the define SDL will be set up for standard OpenGL (I left it in as its useful for cross platform dev).&lt;br /&gt;
# Once you have finished with the window and just before terminating it call TerminateOpenGL() to clean up.&lt;br /&gt;
&lt;br /&gt;
NOTE - If you call SDL_SetVideoMode more than once you will probably need to terminate and reset the context (TerminateOpenGL(); SDL_SetVideoMode(); InitOpenGL();)&lt;br /&gt;
&lt;br /&gt;
// OpenGLInit.c&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	#include &amp;lt;EGL/egl.h&amp;gt;&lt;br /&gt;
	#include &amp;lt;GLES/gl.h&amp;gt;&lt;br /&gt;
	#include &amp;lt;SDL/SDL_syswm.h&amp;gt;&lt;br /&gt;
#else&lt;br /&gt;
	#include &amp;lt;GL/gl.h&amp;gt;&lt;br /&gt;
	#include &amp;lt;SDL/SDL.h&amp;gt;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;OpenGLInit.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	EGLDisplay g_eglDisplay = 0;&lt;br /&gt;
	EGLConfig g_eglConfig = 0;&lt;br /&gt;
	EGLContext g_eglContext = 0;&lt;br /&gt;
	EGLSurface g_eglSurface = 0;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
// consts&lt;br /&gt;
#define COLOURDEPTH_RED_SIZE  		5&lt;br /&gt;
#define COLOURDEPTH_GREEN_SIZE 		6&lt;br /&gt;
#define COLOURDEPTH_BLUE_SIZE 		5&lt;br /&gt;
#define COLOURDEPTH_DEPTH_SIZE		16&lt;br /&gt;
&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
static const EGLint g_configAttribs[] ={&lt;br /&gt;
										  EGL_RED_SIZE,      	    COLOURDEPTH_RED_SIZE,&lt;br /&gt;
										  EGL_GREEN_SIZE,    	    COLOURDEPTH_GREEN_SIZE,&lt;br /&gt;
										  EGL_BLUE_SIZE,     	    COLOURDEPTH_BLUE_SIZE,&lt;br /&gt;
										  EGL_DEPTH_SIZE,	    COLOURDEPTH_DEPTH_SIZE,&lt;br /&gt;
										  EGL_SURFACE_TYPE,         EGL_WINDOW_BIT,&lt;br /&gt;
										  EGL_RENDERABLE_TYPE,      EGL_OPENGL_ES_BIT,&lt;br /&gt;
										  EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE,&lt;br /&gt;
										  EGL_NONE&lt;br /&gt;
									   };&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
/*===========================================================&lt;br /&gt;
Initialise opengl settings. Call straight after SDL_SetVideoMode()&lt;br /&gt;
===========================================================*/&lt;br /&gt;
&lt;br /&gt;
int InitOpenGL()&lt;br /&gt;
{&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	// use EGL to initialise GLES&lt;br /&gt;
	g_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);&lt;br /&gt;
	if (g_eglDisplay == EGL_NO_DISPLAY)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to initialise EGL display.&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Initialise egl&lt;br /&gt;
	if (!eglInitialize(g_eglDisplay, NULL, NULL))&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to initialise EGL display.&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Find a matching config&lt;br /&gt;
	EGLint numConfigsOut = 0;&lt;br /&gt;
	if (eglChooseConfig(g_eglDisplay, g_configAttribs, &amp;amp;g_eglConfig, 1, &amp;amp;numConfigsOut) != EGL_TRUE || numConfigsOut == 0)&lt;br /&gt;
	{&lt;br /&gt;
		fprintf(stderr, &amp;quot;Unable to find appropriate EGL config.&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Get the SDL window handle&lt;br /&gt;
	SDL_SysWMinfo sysInfo; //Will hold our Window information&lt;br /&gt;
	SDL_VERSION(&amp;amp;sysInfo.version); //Set SDL version&lt;br /&gt;
	if(SDL_GetWMInfo(&amp;amp;sysInfo) &amp;lt;= 0) &lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to get window handle&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	g_eglSurface = eglCreateWindowSurface(g_eglDisplay, g_eglConfig, (EGLNativeWindowType)sysInfo.info.x11.window, 0);&lt;br /&gt;
	if ( g_eglSurface == EGL_NO_SURFACE)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to create EGL surface!&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Bind GLES and create the context&lt;br /&gt;
	eglBindAPI(EGL_OPENGL_ES_API);&lt;br /&gt;
	EGLint contextParams[] = {EGL_CONTEXT_CLIENT_VERSION, 1, EGL_NONE};		// Use GLES version 1.x&lt;br /&gt;
	g_eglContext = eglCreateContext(g_eglDisplay, g_eglConfig, NULL, NULL);&lt;br /&gt;
	if (g_eglContext == EGL_NO_CONTEXT)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to create GLES context!&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	if (eglMakeCurrent(g_eglDisplay,  g_eglSurface,  g_eglSurface, g_eglContext) == EGL_FALSE)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to make GLES context current&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
#else&lt;br /&gt;
	&lt;br /&gt;
	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, COLOURDEPTH_RED_SIZE);&lt;br /&gt;
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, COLOURDEPTH_GREEN_SIZE);&lt;br /&gt;
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, COLOURDEPTH_BLUE_SIZE);&lt;br /&gt;
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, COLOURDEPTH_DEPTH_SIZE);&lt;br /&gt;
	&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
	return 1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*======================================================&lt;br /&gt;
 * Kill off any opengl specific details&lt;br /&gt;
  ====================================================*/&lt;br /&gt;
void TerminateOpenGL()&lt;br /&gt;
{&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	eglMakeCurrent(g_eglDisplay, NULL, NULL, EGL_NO_CONTEXT);&lt;br /&gt;
	eglDestroySurface(g_eglDisplay, g_eglSurface);&lt;br /&gt;
	eglDestroyContext(g_eglDisplay, g_eglContext);&lt;br /&gt;
	g_eglSurface = 0;&lt;br /&gt;
	g_eglContext = 0;&lt;br /&gt;
	g_eglConfig = 0;&lt;br /&gt;
	eglTerminate(g_eglDisplay);&lt;br /&gt;
	g_eglDisplay = 0;&lt;br /&gt;
#endif&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int SwapBuffers()&lt;br /&gt;
{&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	eglSwapBuffers(g_eglDisplay, g_eglSurface);&lt;br /&gt;
#else&lt;br /&gt;
	SDL_GL_SwapBuffers();&lt;br /&gt;
#endif&lt;br /&gt;
}&lt;br /&gt;
[/source]&lt;br /&gt;
&lt;br /&gt;
~~~&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Lonewolf9383</name></author>
		
	</entry>
	<entry>
		<id>https://pandorawiki.org/index.php?title=Combining_OpenGL_ES_1.1_and_SDL_to_create_a_window_on_the_Pandora&amp;diff=3200</id>
		<title>Combining OpenGL ES 1.1 and SDL to create a window on the Pandora</title>
		<link rel="alternate" type="text/html" href="https://pandorawiki.org/index.php?title=Combining_OpenGL_ES_1.1_and_SDL_to_create_a_window_on_the_Pandora&amp;diff=3200"/>
		<updated>2010-07-21T22:05:51Z</updated>

		<summary type="html">&lt;p&gt;Lonewolf9383: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are two options for combining GLES and SDL:&lt;br /&gt;
&lt;br /&gt;
= 1: Grab the modified version of SDL =&lt;br /&gt;
&lt;br /&gt;
There is a special SDL source code for pandora with OpenGL ES capability &lt;br /&gt;
available here : http://github.com/Cpasjuste&lt;br /&gt;
&lt;br /&gt;
The screen initialisation is now easy as this : SDL_SetVideoMode(800, 480, 16, SDL_OPENGLES)&lt;br /&gt;
&lt;br /&gt;
An SDL/GLES exemple is also available on the git repository.&lt;br /&gt;
&lt;br /&gt;
= 2: Use EGL =&lt;br /&gt;
&lt;br /&gt;
Sometimes its not best to use the modified version of SDl (when working on cross platform games). Instead you can use EGL to create the GLES graphics context for you.&lt;br /&gt;
The following functions do just that.&lt;br /&gt;
&lt;br /&gt;
Steps:&lt;br /&gt;
#1- Make sure you call InitOpenGL() straight after creating the window (SDL_SetVideoMode()).&lt;br /&gt;
#2- When using EGL you should not pass in the SDL_OPENGL flag to SDL_SetVideoMode(). SDL_HWSurface and SDL_SWSurface should do.&lt;br /&gt;
#3- You will notice '#ifdef GLES1' around much of the EGL code. Simply define GLES1 in your preprocessor (-DGLES1 on the command line of gcc if i recall correctly?) to use GLES. Without the define SDL will be set up for standard OpenGL (I left it in as its useful for cross platform dev).&lt;br /&gt;
#4 - Once you have finished with the window and just before terminating it call TerminateOpenGL() to clean up.&lt;br /&gt;
&lt;br /&gt;
NOTE - If you call SDL_SetVideoMode more than once you will probably need to terminate and reset the context (TerminateOpenGL(); SDL_SetVideoMode(); InitOpenGL();)&lt;br /&gt;
&lt;br /&gt;
// OpenGLInit.c&lt;br /&gt;
[code]&lt;br /&gt;
&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	#include &amp;lt;EGL/egl.h&amp;gt;&lt;br /&gt;
	#include &amp;lt;GLES/gl.h&amp;gt;&lt;br /&gt;
	#include &amp;lt;SDL/SDL_syswm.h&amp;gt;&lt;br /&gt;
#else&lt;br /&gt;
	#include &amp;lt;GL/gl.h&amp;gt;&lt;br /&gt;
	#include &amp;lt;SDL/SDL.h&amp;gt;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;OpenGLInit.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	EGLDisplay g_eglDisplay = 0;&lt;br /&gt;
	EGLConfig g_eglConfig = 0;&lt;br /&gt;
	EGLContext g_eglContext = 0;&lt;br /&gt;
	EGLSurface g_eglSurface = 0;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
// consts&lt;br /&gt;
#define COLOURDEPTH_RED_SIZE  		5&lt;br /&gt;
#define COLOURDEPTH_GREEN_SIZE 		6&lt;br /&gt;
#define COLOURDEPTH_BLUE_SIZE 		5&lt;br /&gt;
#define COLOURDEPTH_DEPTH_SIZE		16&lt;br /&gt;
&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
static const EGLint g_configAttribs[] ={&lt;br /&gt;
										  EGL_RED_SIZE,      		COLOURDEPTH_RED_SIZE,&lt;br /&gt;
										  EGL_GREEN_SIZE,    		COLOURDEPTH_GREEN_SIZE,&lt;br /&gt;
										  EGL_BLUE_SIZE,     		COLOURDEPTH_BLUE_SIZE,&lt;br /&gt;
										  EGL_DEPTH_SIZE,	 		COLOURDEPTH_DEPTH_SIZE,&lt;br /&gt;
										  EGL_SURFACE_TYPE,         EGL_WINDOW_BIT,&lt;br /&gt;
										  EGL_RENDERABLE_TYPE,      EGL_OPENGL_ES_BIT,&lt;br /&gt;
										  EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE,&lt;br /&gt;
										  EGL_NONE&lt;br /&gt;
									   };&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
/*===========================================================&lt;br /&gt;
Initialise opengl settings. Call straight after SDL_SetVideoMode()&lt;br /&gt;
===========================================================*/&lt;br /&gt;
&lt;br /&gt;
int InitOpenGL()&lt;br /&gt;
{&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	// use EGL to initialise GLES&lt;br /&gt;
	g_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);&lt;br /&gt;
	if (g_eglDisplay == EGL_NO_DISPLAY)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to initialise EGL display.&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Initialise egl&lt;br /&gt;
	if (!eglInitialize(g_eglDisplay, NULL, NULL))&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to initialise EGL display.&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Find a matching config&lt;br /&gt;
	EGLint numConfigsOut = 0;&lt;br /&gt;
	if (eglChooseConfig(g_eglDisplay, g_configAttribs, &amp;amp;g_eglConfig, 1, &amp;amp;numConfigsOut) != EGL_TRUE || numConfigsOut == 0)&lt;br /&gt;
	{&lt;br /&gt;
		fprintf(stderr, &amp;quot;Unable to find appropriate EGL config.&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Get the SDL window handle&lt;br /&gt;
	SDL_SysWMinfo sysInfo; //Will hold our Window information&lt;br /&gt;
	SDL_VERSION(&amp;amp;sysInfo.version); //Set SDL version&lt;br /&gt;
	if(SDL_GetWMInfo(&amp;amp;sysInfo) &amp;lt;= 0) &lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to get window handle&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	g_eglSurface = eglCreateWindowSurface(g_eglDisplay, g_eglConfig, (EGLNativeWindowType)sysInfo.info.x11.window, 0);&lt;br /&gt;
	if ( g_eglSurface == EGL_NO_SURFACE)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to create EGL surface!&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Bind GLES and create the context&lt;br /&gt;
	eglBindAPI(EGL_OPENGL_ES_API);&lt;br /&gt;
	EGLint contextParams[] = {EGL_CONTEXT_CLIENT_VERSION, 1, EGL_NONE};		// Use GLES version 1.x&lt;br /&gt;
	g_eglContext = eglCreateContext(g_eglDisplay, g_eglConfig, NULL, NULL);&lt;br /&gt;
	if (g_eglContext == EGL_NO_CONTEXT)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to create GLES context!&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	if (eglMakeCurrent(g_eglDisplay,  g_eglSurface,  g_eglSurface, g_eglContext) == EGL_FALSE)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Unable to make GLES context current&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
#else&lt;br /&gt;
	&lt;br /&gt;
	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, COLOURDEPTH_RED_SIZE);&lt;br /&gt;
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, COLOURDEPTH_GREEN_SIZE);&lt;br /&gt;
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, COLOURDEPTH_BLUE_SIZE);&lt;br /&gt;
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, COLOURDEPTH_DEPTH_SIZE);&lt;br /&gt;
	&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
	return 1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*======================================================&lt;br /&gt;
 * Kill off any opengl specific details&lt;br /&gt;
  ====================================================*/&lt;br /&gt;
void TerminateOpenGL()&lt;br /&gt;
{&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	eglMakeCurrent(g_eglDisplay, NULL, NULL, EGL_NO_CONTEXT);&lt;br /&gt;
	eglDestroySurface(g_eglDisplay, g_eglSurface);&lt;br /&gt;
	eglDestroyContext(g_eglDisplay, g_eglContext);&lt;br /&gt;
	g_eglSurface = 0;&lt;br /&gt;
	g_eglContext = 0;&lt;br /&gt;
	g_eglConfig = 0;&lt;br /&gt;
	eglTerminate(g_eglDisplay);&lt;br /&gt;
	g_eglDisplay = 0;&lt;br /&gt;
#endif&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int SwapBuffers()&lt;br /&gt;
{&lt;br /&gt;
#ifdef GLES1&lt;br /&gt;
	eglSwapBuffers(g_eglDisplay, g_eglSurface);&lt;br /&gt;
#else&lt;br /&gt;
	SDL_GL_SwapBuffers();&lt;br /&gt;
#endif&lt;br /&gt;
}&lt;br /&gt;
[/code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Lonewolf9383</name></author>
		
	</entry>
</feed>