2011-02-06 00:00:13 -08:00
|
|
|
/*
|
2011-04-08 13:03:26 -07:00
|
|
|
Simple DirectMedia Layer
|
2011-12-31 09:28:07 -05:00
|
|
|
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
2011-02-06 00:00:13 -08:00
|
|
|
|
2011-04-08 13:03:26 -07:00
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
arising from the use of this software.
|
2011-02-11 19:11:27 -08:00
|
|
|
|
2011-04-08 13:03:26 -07:00
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
freely, subject to the following restrictions:
|
2011-02-06 00:00:13 -08:00
|
|
|
|
2011-04-08 13:03:26 -07:00
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
appreciated but is not required.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
2011-02-11 19:11:27 -08:00
|
|
|
*/
|
2011-02-06 00:00:13 -08:00
|
|
|
#include "SDL_config.h"
|
|
|
|
|
2011-02-08 10:04:09 -08:00
|
|
|
#if SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED
|
2011-02-06 00:00:13 -08:00
|
|
|
|
2011-03-13 11:18:35 -07:00
|
|
|
#include "SDL_hints.h"
|
2011-02-06 02:35:14 -08:00
|
|
|
#include "SDL_opengles2.h"
|
2011-02-06 00:00:13 -08:00
|
|
|
#include "../SDL_sysrender.h"
|
|
|
|
#include "SDL_shaders_gles2.h"
|
|
|
|
|
2012-01-08 13:31:22 -05:00
|
|
|
/* Used to re-create the window with OpenGL ES capability */
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
|
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
/*************************************************************************************************
|
|
|
|
* Bootstrap data *
|
|
|
|
*************************************************************************************************/
|
|
|
|
|
|
|
|
static SDL_Renderer *GLES2_CreateRenderer(SDL_Window *window, Uint32 flags);
|
|
|
|
|
|
|
|
SDL_RenderDriver GLES2_RenderDriver = {
|
|
|
|
GLES2_CreateRenderer,
|
|
|
|
{
|
|
|
|
"opengles2",
|
2012-01-19 21:06:47 -05:00
|
|
|
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
|
2011-12-29 05:11:33 -05:00
|
|
|
4,
|
|
|
|
{SDL_PIXELFORMAT_ABGR8888,
|
|
|
|
SDL_PIXELFORMAT_ARGB8888,
|
|
|
|
SDL_PIXELFORMAT_RGB888,
|
|
|
|
SDL_PIXELFORMAT_BGR888},
|
2011-02-06 00:00:13 -08:00
|
|
|
0,
|
|
|
|
0
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*************************************************************************************************
|
|
|
|
* Context structures *
|
|
|
|
*************************************************************************************************/
|
|
|
|
|
2012-01-18 22:45:49 -05:00
|
|
|
typedef struct GLES2_FBOList GLES2_FBOList;
|
|
|
|
|
|
|
|
struct GLES2_FBOList
|
|
|
|
{
|
|
|
|
Uint32 w, h;
|
|
|
|
GLuint FBO;
|
|
|
|
GLES2_FBOList *next;
|
|
|
|
};
|
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
typedef struct GLES2_TextureData
|
|
|
|
{
|
|
|
|
GLenum texture;
|
|
|
|
GLenum texture_type;
|
|
|
|
GLenum pixel_format;
|
|
|
|
GLenum pixel_type;
|
|
|
|
void *pixel_data;
|
|
|
|
size_t pitch;
|
2012-01-18 22:45:49 -05:00
|
|
|
GLES2_FBOList *fbo;
|
2011-02-06 00:00:13 -08:00
|
|
|
} GLES2_TextureData;
|
|
|
|
|
|
|
|
typedef struct GLES2_ShaderCacheEntry
|
|
|
|
{
|
|
|
|
GLuint id;
|
|
|
|
GLES2_ShaderType type;
|
|
|
|
const GLES2_ShaderInstance *instance;
|
|
|
|
int references;
|
|
|
|
struct GLES2_ShaderCacheEntry *prev;
|
|
|
|
struct GLES2_ShaderCacheEntry *next;
|
|
|
|
} GLES2_ShaderCacheEntry;
|
|
|
|
|
|
|
|
typedef struct GLES2_ShaderCache
|
|
|
|
{
|
|
|
|
int count;
|
|
|
|
GLES2_ShaderCacheEntry *head;
|
|
|
|
} GLES2_ShaderCache;
|
|
|
|
|
|
|
|
typedef struct GLES2_ProgramCacheEntry
|
|
|
|
{
|
|
|
|
GLuint id;
|
|
|
|
SDL_BlendMode blend_mode;
|
|
|
|
GLES2_ShaderCacheEntry *vertex_shader;
|
|
|
|
GLES2_ShaderCacheEntry *fragment_shader;
|
|
|
|
GLuint uniform_locations[16];
|
|
|
|
struct GLES2_ProgramCacheEntry *prev;
|
|
|
|
struct GLES2_ProgramCacheEntry *next;
|
|
|
|
} GLES2_ProgramCacheEntry;
|
|
|
|
|
|
|
|
typedef struct GLES2_ProgramCache
|
|
|
|
{
|
|
|
|
int count;
|
|
|
|
GLES2_ProgramCacheEntry *head;
|
|
|
|
GLES2_ProgramCacheEntry *tail;
|
|
|
|
} GLES2_ProgramCache;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GLES2_ATTRIBUTE_POSITION = 0,
|
2012-06-01 19:51:08 -03:00
|
|
|
GLES2_ATTRIBUTE_TEXCOORD = 1,
|
|
|
|
GLES2_ATTRIBUTE_ANGLE = 2,
|
|
|
|
GLES2_ATTRIBUTE_CENTER = 3,
|
2011-02-06 00:00:13 -08:00
|
|
|
} GLES2_Attribute;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GLES2_UNIFORM_PROJECTION,
|
|
|
|
GLES2_UNIFORM_TEXTURE,
|
|
|
|
GLES2_UNIFORM_MODULATION,
|
|
|
|
GLES2_UNIFORM_COLOR,
|
|
|
|
GLES2_UNIFORM_COLORTABLE
|
|
|
|
} GLES2_Uniform;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GLES2_IMAGESOURCE_SOLID,
|
2011-12-29 05:11:33 -05:00
|
|
|
GLES2_IMAGESOURCE_TEXTURE_ABGR,
|
|
|
|
GLES2_IMAGESOURCE_TEXTURE_ARGB,
|
|
|
|
GLES2_IMAGESOURCE_TEXTURE_RGB,
|
|
|
|
GLES2_IMAGESOURCE_TEXTURE_BGR
|
2011-02-06 00:00:13 -08:00
|
|
|
} GLES2_ImageSource;
|
|
|
|
|
|
|
|
typedef struct GLES2_DriverContext
|
|
|
|
{
|
|
|
|
SDL_GLContext *context;
|
2011-02-19 21:51:21 -08:00
|
|
|
struct {
|
|
|
|
int blendMode;
|
|
|
|
SDL_bool tex_coords;
|
|
|
|
} current;
|
|
|
|
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
|
|
|
|
#include "SDL_gles2funcs.h"
|
|
|
|
#undef SDL_PROC
|
2012-01-18 22:45:49 -05:00
|
|
|
GLES2_FBOList *framebuffers;
|
2012-01-30 20:56:25 -05:00
|
|
|
GLuint window_framebuffer;
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
int shader_format_count;
|
|
|
|
GLenum *shader_formats;
|
|
|
|
GLES2_ShaderCache shader_cache;
|
|
|
|
GLES2_ProgramCache program_cache;
|
|
|
|
GLES2_ProgramCacheEntry *current_program;
|
|
|
|
} GLES2_DriverContext;
|
|
|
|
|
|
|
|
#define GLES2_MAX_CACHED_PROGRAMS 8
|
|
|
|
|
|
|
|
/*************************************************************************************************
|
|
|
|
* Renderer state APIs *
|
|
|
|
*************************************************************************************************/
|
|
|
|
|
2011-02-07 20:06:26 -08:00
|
|
|
static int GLES2_ActivateRenderer(SDL_Renderer *renderer);
|
2011-02-06 00:00:13 -08:00
|
|
|
static void GLES2_WindowEvent(SDL_Renderer * renderer,
|
|
|
|
const SDL_WindowEvent *event);
|
2011-02-15 13:59:59 -08:00
|
|
|
static int GLES2_UpdateViewport(SDL_Renderer * renderer);
|
2011-02-06 00:00:13 -08:00
|
|
|
static void GLES2_DestroyRenderer(SDL_Renderer *renderer);
|
2012-01-21 22:22:30 -05:00
|
|
|
static int GLES2_SetOrthographicProjection(SDL_Renderer *renderer);
|
2011-02-06 00:00:13 -08:00
|
|
|
|
2012-01-18 22:45:49 -05:00
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
static SDL_GLContext SDL_CurrentContext = NULL;
|
|
|
|
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
static int GLES2_LoadFunctions(GLES2_DriverContext * data)
|
|
|
|
{
|
2012-01-08 13:31:22 -05:00
|
|
|
#if SDL_VIDEO_DRIVER_UIKIT
|
|
|
|
#define __SDL_NOGETPROCADDR__
|
|
|
|
#elif SDL_VIDEO_DRIVER_ANDROID
|
|
|
|
#define __SDL_NOGETPROCADDR__
|
|
|
|
#elif SDL_VIDEO_DRIVER_PANDORA
|
|
|
|
#define __SDL_NOGETPROCADDR__
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined __SDL_NOGETPROCADDR__
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
#define SDL_PROC(ret,func,params) data->func=func;
|
|
|
|
#else
|
|
|
|
#define SDL_PROC(ret,func,params) \
|
|
|
|
do { \
|
|
|
|
data->func = SDL_GL_GetProcAddress(#func); \
|
|
|
|
if ( ! data->func ) { \
|
|
|
|
SDL_SetError("Couldn't load GLES2 function %s: %s\n", #func, SDL_GetError()); \
|
|
|
|
return -1; \
|
|
|
|
} \
|
2012-01-18 22:45:49 -05:00
|
|
|
} while ( 0 );
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
#endif /* _SDL_NOGETPROCADDR_ */
|
|
|
|
|
|
|
|
#include "SDL_gles2funcs.h"
|
|
|
|
#undef SDL_PROC
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-18 22:45:49 -05:00
|
|
|
GLES2_FBOList *
|
|
|
|
GLES2_GetFBO(GLES2_DriverContext *data, Uint32 w, Uint32 h)
|
|
|
|
{
|
|
|
|
GLES2_FBOList *result = data->framebuffers;
|
|
|
|
while ((result) && ((result->w != w) || (result->h != h)) )
|
|
|
|
{
|
|
|
|
result = result->next;
|
|
|
|
}
|
|
|
|
if (result == NULL)
|
|
|
|
{
|
|
|
|
result = SDL_malloc(sizeof(GLES2_FBOList));
|
|
|
|
result->w = w;
|
|
|
|
result->h = h;
|
2012-01-28 14:53:23 -05:00
|
|
|
data->glGenFramebuffers(1, &result->FBO);
|
2012-01-18 22:45:49 -05:00
|
|
|
result->next = data->framebuffers;
|
|
|
|
data->framebuffers = result;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
static int
|
|
|
|
GLES2_ActivateRenderer(SDL_Renderer * renderer)
|
|
|
|
{
|
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
|
|
|
|
|
|
|
if (SDL_CurrentContext != rdata->context) {
|
|
|
|
/* Null out the current program to ensure we set it again */
|
|
|
|
rdata->current_program = NULL;
|
|
|
|
|
2011-02-15 13:59:59 -08:00
|
|
|
if (SDL_GL_MakeCurrent(renderer->window, rdata->context) < 0) {
|
2011-02-06 00:00:13 -08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
SDL_CurrentContext = rdata->context;
|
|
|
|
|
2011-02-15 13:59:59 -08:00
|
|
|
GLES2_UpdateViewport(renderer);
|
2011-02-06 00:00:13 -08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
GLES2_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
|
|
|
|
{
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
2012-01-18 22:45:49 -05:00
|
|
|
|
2012-01-22 21:46:06 -05:00
|
|
|
if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED ||
|
|
|
|
event->event == SDL_WINDOWEVENT_SHOWN ||
|
|
|
|
event->event == SDL_WINDOWEVENT_HIDDEN) {
|
2011-02-06 00:00:13 -08:00
|
|
|
/* Rebind the context to the window area */
|
|
|
|
SDL_CurrentContext = NULL;
|
|
|
|
}
|
2011-11-07 23:07:00 -05:00
|
|
|
|
|
|
|
if (event->event == SDL_WINDOWEVENT_MINIMIZED) {
|
|
|
|
/* According to Apple documentation, we need to finish drawing NOW! */
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glFinish();
|
2011-11-07 23:07:00 -05:00
|
|
|
}
|
2011-02-06 00:00:13 -08:00
|
|
|
}
|
|
|
|
|
2011-02-15 13:59:59 -08:00
|
|
|
static int
|
|
|
|
GLES2_UpdateViewport(SDL_Renderer * renderer)
|
2011-02-07 20:06:26 -08:00
|
|
|
{
|
2011-02-15 13:59:59 -08:00
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
2011-02-07 20:06:26 -08:00
|
|
|
|
2011-02-15 13:59:59 -08:00
|
|
|
if (SDL_CurrentContext != rdata->context) {
|
|
|
|
/* We'll update the viewport after we rebind the context */
|
|
|
|
return 0;
|
2011-02-07 20:06:26 -08:00
|
|
|
}
|
2011-02-15 13:59:59 -08:00
|
|
|
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glViewport(renderer->viewport.x, renderer->viewport.y,
|
2011-02-15 13:59:59 -08:00
|
|
|
renderer->viewport.w, renderer->viewport.h);
|
2012-01-28 14:05:48 -05:00
|
|
|
|
|
|
|
if (rdata->current_program) {
|
|
|
|
GLES2_SetOrthographicProjection(renderer);
|
|
|
|
}
|
2011-02-15 13:59:59 -08:00
|
|
|
return 0;
|
2011-02-07 20:06:26 -08:00
|
|
|
}
|
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
static void
|
|
|
|
GLES2_DestroyRenderer(SDL_Renderer *renderer)
|
|
|
|
{
|
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
|
|
|
|
|
|
|
/* Deallocate everything */
|
2011-02-06 10:22:25 -08:00
|
|
|
if (rdata) {
|
|
|
|
GLES2_ActivateRenderer(renderer);
|
|
|
|
|
2012-01-07 22:33:58 -05:00
|
|
|
{
|
|
|
|
GLES2_ShaderCacheEntry *entry;
|
|
|
|
GLES2_ShaderCacheEntry *next;
|
|
|
|
entry = rdata->shader_cache.head;
|
|
|
|
while (entry)
|
|
|
|
{
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glDeleteShader(entry->id);
|
2011-11-07 00:45:13 -05:00
|
|
|
next = entry->next;
|
|
|
|
SDL_free(entry);
|
|
|
|
entry = next;
|
2012-01-07 22:33:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
GLES2_ProgramCacheEntry *entry;
|
|
|
|
GLES2_ProgramCacheEntry *next;
|
2011-11-07 00:45:13 -05:00
|
|
|
entry = rdata->program_cache.head;
|
|
|
|
while (entry) {
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glDeleteProgram(entry->id);
|
2011-11-07 00:45:13 -05:00
|
|
|
next = entry->next;
|
|
|
|
SDL_free(entry);
|
|
|
|
entry = next;
|
|
|
|
}
|
2012-01-07 22:33:58 -05:00
|
|
|
}
|
2011-02-06 10:22:25 -08:00
|
|
|
if (rdata->context) {
|
2012-01-18 22:45:49 -05:00
|
|
|
while (rdata->framebuffers) {
|
|
|
|
GLES2_FBOList *nextnode = rdata->framebuffers->next;
|
|
|
|
rdata->glDeleteFramebuffers(1, &rdata->framebuffers->FBO);
|
|
|
|
SDL_free(rdata->framebuffers);
|
|
|
|
rdata->framebuffers = nextnode;
|
|
|
|
}
|
2011-02-06 10:22:25 -08:00
|
|
|
SDL_GL_DeleteContext(rdata->context);
|
|
|
|
}
|
|
|
|
if (rdata->shader_formats) {
|
|
|
|
SDL_free(rdata->shader_formats);
|
|
|
|
}
|
|
|
|
SDL_free(rdata);
|
2011-02-06 00:00:13 -08:00
|
|
|
}
|
|
|
|
SDL_free(renderer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************************************
|
|
|
|
* Texture APIs *
|
|
|
|
*************************************************************************************************/
|
|
|
|
|
|
|
|
static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture);
|
|
|
|
static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture);
|
|
|
|
static int GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
|
|
|
|
void **pixels, int *pitch);
|
|
|
|
static void GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture);
|
|
|
|
static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
|
|
|
|
const void *pixels, int pitch);
|
2012-01-22 01:26:28 -05:00
|
|
|
static int GLES2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture);
|
2011-02-06 00:00:13 -08:00
|
|
|
|
2011-03-13 11:18:35 -07:00
|
|
|
static GLenum
|
|
|
|
GetScaleQuality(void)
|
|
|
|
{
|
|
|
|
const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY);
|
|
|
|
|
|
|
|
if (!hint || *hint == '0' || SDL_strcasecmp(hint, "nearest") == 0) {
|
|
|
|
return GL_NEAREST;
|
|
|
|
} else {
|
|
|
|
return GL_LINEAR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
static int
|
|
|
|
GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|
|
|
{
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
2011-02-06 00:00:13 -08:00
|
|
|
GLES2_TextureData *tdata;
|
|
|
|
GLenum format;
|
|
|
|
GLenum type;
|
2011-03-21 17:15:49 -07:00
|
|
|
GLenum scaleMode;
|
2011-02-06 00:00:13 -08:00
|
|
|
|
|
|
|
GLES2_ActivateRenderer(renderer);
|
|
|
|
|
|
|
|
/* Determine the corresponding GLES texture format params */
|
|
|
|
switch (texture->format)
|
|
|
|
{
|
|
|
|
case SDL_PIXELFORMAT_ABGR8888:
|
2011-12-29 05:11:33 -05:00
|
|
|
case SDL_PIXELFORMAT_ARGB8888:
|
|
|
|
case SDL_PIXELFORMAT_BGR888:
|
|
|
|
case SDL_PIXELFORMAT_RGB888:
|
2011-02-06 00:00:13 -08:00
|
|
|
format = GL_RGBA;
|
|
|
|
type = GL_UNSIGNED_BYTE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SDL_SetError("Texture format not supported");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate a texture struct */
|
|
|
|
tdata = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData));
|
|
|
|
if (!tdata)
|
|
|
|
{
|
|
|
|
SDL_OutOfMemory();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
tdata->texture = 0;
|
|
|
|
tdata->texture_type = GL_TEXTURE_2D;
|
|
|
|
tdata->pixel_format = format;
|
|
|
|
tdata->pixel_type = type;
|
2011-03-21 17:15:49 -07:00
|
|
|
scaleMode = GetScaleQuality();
|
2011-02-06 00:00:13 -08:00
|
|
|
|
|
|
|
/* Allocate a blob for image data */
|
|
|
|
if (texture->access == SDL_TEXTUREACCESS_STREAMING)
|
|
|
|
{
|
|
|
|
tdata->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
|
2011-02-26 21:39:34 -08:00
|
|
|
tdata->pixel_data = SDL_calloc(1, tdata->pitch * texture->h);
|
2011-02-06 00:00:13 -08:00
|
|
|
if (!tdata->pixel_data)
|
|
|
|
{
|
|
|
|
SDL_OutOfMemory();
|
|
|
|
SDL_free(tdata);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate the texture */
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetError();
|
|
|
|
rdata->glGenTextures(1, &tdata->texture);
|
|
|
|
rdata->glActiveTexture(GL_TEXTURE0);
|
|
|
|
rdata->glBindTexture(tdata->texture_type, tdata->texture);
|
|
|
|
rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode);
|
|
|
|
rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode);
|
|
|
|
rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
|
|
rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
|
|
rdata->glTexImage2D(tdata->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL);
|
|
|
|
if (rdata->glGetError() != GL_NO_ERROR)
|
2011-02-06 00:00:13 -08:00
|
|
|
{
|
|
|
|
SDL_SetError("Texture creation failed");
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glDeleteTextures(1, &tdata->texture);
|
2011-02-06 00:00:13 -08:00
|
|
|
SDL_free(tdata);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
texture->driverdata = tdata;
|
2012-01-18 22:45:49 -05:00
|
|
|
|
|
|
|
if (texture->access == SDL_TEXTUREACCESS_TARGET) {
|
|
|
|
tdata->fbo = GLES2_GetFBO(renderer->driverdata, texture->w, texture->h);
|
|
|
|
} else {
|
|
|
|
tdata->fbo = NULL;
|
|
|
|
}
|
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|
|
|
{
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
2011-02-06 00:00:13 -08:00
|
|
|
GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata;
|
|
|
|
|
|
|
|
GLES2_ActivateRenderer(renderer);
|
|
|
|
|
|
|
|
/* Destroy the texture */
|
|
|
|
if (tdata)
|
|
|
|
{
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glDeleteTextures(1, &tdata->texture);
|
2011-02-06 00:00:13 -08:00
|
|
|
SDL_free(tdata->pixel_data);
|
|
|
|
SDL_free(tdata);
|
|
|
|
texture->driverdata = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
|
|
|
|
void **pixels, int *pitch)
|
|
|
|
{
|
|
|
|
GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata;
|
|
|
|
|
|
|
|
/* Retrieve the buffer/pitch for the specified region */
|
|
|
|
*pixels = (Uint8 *)tdata->pixel_data +
|
|
|
|
(tdata->pitch * rect->y) +
|
|
|
|
(rect->x * SDL_BYTESPERPIXEL(texture->format));
|
|
|
|
*pitch = tdata->pitch;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|
|
|
{
|
|
|
|
GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata;
|
2011-02-08 10:38:12 -08:00
|
|
|
SDL_Rect rect;
|
|
|
|
|
|
|
|
/* We do whole texture updates, at least for now */
|
|
|
|
rect.x = 0;
|
|
|
|
rect.y = 0;
|
|
|
|
rect.w = texture->w;
|
|
|
|
rect.h = texture->h;
|
|
|
|
GLES2_UpdateTexture(renderer, texture, &rect, tdata->pixel_data, tdata->pitch);
|
2011-02-06 00:00:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
|
|
|
|
const void *pixels, int pitch)
|
|
|
|
{
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
2011-02-06 00:00:13 -08:00
|
|
|
GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata;
|
|
|
|
Uint8 *blob = NULL;
|
|
|
|
Uint8 *src;
|
|
|
|
int srcPitch;
|
|
|
|
int y;
|
|
|
|
|
|
|
|
GLES2_ActivateRenderer(renderer);
|
2012-01-18 22:45:49 -05:00
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
/* Bail out if we're supposed to update an empty rectangle */
|
|
|
|
if (rect->w <= 0 || rect->h <= 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Reformat the texture data into a tightly packed array */
|
|
|
|
srcPitch = rect->w * SDL_BYTESPERPIXEL(texture->format);
|
|
|
|
src = (Uint8 *)pixels;
|
|
|
|
if (pitch != srcPitch)
|
|
|
|
{
|
|
|
|
blob = (Uint8 *)SDL_malloc(srcPitch * rect->h);
|
|
|
|
if (!blob)
|
|
|
|
{
|
|
|
|
SDL_OutOfMemory();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
src = blob;
|
|
|
|
for (y = 0; y < rect->h; ++y)
|
|
|
|
{
|
|
|
|
SDL_memcpy(src, pixels, srcPitch);
|
|
|
|
src += srcPitch;
|
|
|
|
pixels = (Uint8 *)pixels + pitch;
|
|
|
|
}
|
|
|
|
src = blob;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create a texture subimage with the supplied data */
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetError();
|
|
|
|
rdata->glActiveTexture(GL_TEXTURE0);
|
|
|
|
rdata->glBindTexture(tdata->texture_type, tdata->texture);
|
|
|
|
rdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
|
|
|
rdata->glTexSubImage2D(tdata->texture_type,
|
2011-02-06 00:00:13 -08:00
|
|
|
0,
|
|
|
|
rect->x,
|
|
|
|
rect->y,
|
|
|
|
rect->w,
|
|
|
|
rect->h,
|
|
|
|
tdata->pixel_format,
|
|
|
|
tdata->pixel_type,
|
|
|
|
src);
|
2011-02-08 10:38:12 -08:00
|
|
|
if (blob) {
|
|
|
|
SDL_free(blob);
|
|
|
|
}
|
2011-02-06 20:56:21 -08:00
|
|
|
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
if (rdata->glGetError() != GL_NO_ERROR)
|
2011-02-06 00:00:13 -08:00
|
|
|
{
|
|
|
|
SDL_SetError("Failed to update texture");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-21 22:22:30 -05:00
|
|
|
static int
|
2012-01-22 01:26:28 -05:00
|
|
|
GLES2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
2012-01-21 22:22:30 -05:00
|
|
|
{
|
|
|
|
GLES2_DriverContext *data = (GLES2_DriverContext *) renderer->driverdata;
|
|
|
|
GLES2_TextureData *texturedata = NULL;
|
|
|
|
GLenum status;
|
|
|
|
|
|
|
|
if (texture == NULL) {
|
2012-01-30 20:56:25 -05:00
|
|
|
data->glBindFramebuffer(GL_FRAMEBUFFER, data->window_framebuffer);
|
2012-01-21 22:22:30 -05:00
|
|
|
} else {
|
|
|
|
texturedata = (GLES2_TextureData *) texture->driverdata;
|
|
|
|
data->glBindFramebuffer(GL_FRAMEBUFFER, texturedata->fbo->FBO);
|
|
|
|
/* TODO: check if texture pixel format allows this operation */
|
|
|
|
data->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texturedata->texture_type, texturedata->texture, 0);
|
|
|
|
/* Check FBO status */
|
|
|
|
status = data->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
|
|
|
if (status != GL_FRAMEBUFFER_COMPLETE) {
|
|
|
|
SDL_SetError("glFramebufferTexture2D() failed");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
/*************************************************************************************************
|
|
|
|
* Shader management functions *
|
|
|
|
*************************************************************************************************/
|
|
|
|
|
|
|
|
static GLES2_ShaderCacheEntry *GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type,
|
|
|
|
SDL_BlendMode blendMode);
|
|
|
|
static void GLES2_EvictShader(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *entry);
|
|
|
|
static GLES2_ProgramCacheEntry *GLES2_CacheProgram(SDL_Renderer *renderer,
|
|
|
|
GLES2_ShaderCacheEntry *vertex,
|
|
|
|
GLES2_ShaderCacheEntry *fragment,
|
|
|
|
SDL_BlendMode blendMode);
|
|
|
|
static int GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source,
|
|
|
|
SDL_BlendMode blendMode);
|
|
|
|
|
|
|
|
static GLES2_ProgramCacheEntry *
|
|
|
|
GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex,
|
|
|
|
GLES2_ShaderCacheEntry *fragment, SDL_BlendMode blendMode)
|
|
|
|
{
|
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
|
|
|
GLES2_ProgramCacheEntry *entry;
|
|
|
|
GLES2_ShaderCacheEntry *shaderEntry;
|
|
|
|
GLint linkSuccessful;
|
|
|
|
|
|
|
|
/* Check if we've already cached this program */
|
|
|
|
entry = rdata->program_cache.head;
|
|
|
|
while (entry)
|
|
|
|
{
|
|
|
|
if (entry->vertex_shader == vertex && entry->fragment_shader == fragment)
|
|
|
|
break;
|
|
|
|
entry = entry->next;
|
|
|
|
}
|
|
|
|
if (entry)
|
|
|
|
{
|
2011-11-07 23:10:49 -05:00
|
|
|
if (rdata->program_cache.head != entry)
|
2011-02-06 00:00:13 -08:00
|
|
|
{
|
|
|
|
if (entry->next)
|
|
|
|
entry->next->prev = entry->prev;
|
|
|
|
if (entry->prev)
|
|
|
|
entry->prev->next = entry->next;
|
|
|
|
entry->prev = NULL;
|
|
|
|
entry->next = rdata->program_cache.head;
|
|
|
|
rdata->program_cache.head->prev = entry;
|
|
|
|
rdata->program_cache.head = entry;
|
|
|
|
}
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create a program cache entry */
|
|
|
|
entry = (GLES2_ProgramCacheEntry *)SDL_calloc(1, sizeof(GLES2_ProgramCacheEntry));
|
|
|
|
if (!entry)
|
|
|
|
{
|
|
|
|
SDL_OutOfMemory();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
entry->vertex_shader = vertex;
|
|
|
|
entry->fragment_shader = fragment;
|
|
|
|
entry->blend_mode = blendMode;
|
2012-01-18 22:45:49 -05:00
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
/* Create the program and link it */
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetError();
|
|
|
|
entry->id = rdata->glCreateProgram();
|
|
|
|
rdata->glAttachShader(entry->id, vertex->id);
|
|
|
|
rdata->glAttachShader(entry->id, fragment->id);
|
|
|
|
rdata->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_POSITION, "a_position");
|
|
|
|
rdata->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_TEXCOORD, "a_texCoord");
|
2012-06-01 19:51:08 -03:00
|
|
|
rdata->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_ANGLE, "a_angle");
|
|
|
|
rdata->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_CENTER, "a_center");
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glLinkProgram(entry->id);
|
|
|
|
rdata->glGetProgramiv(entry->id, GL_LINK_STATUS, &linkSuccessful);
|
|
|
|
if (rdata->glGetError() != GL_NO_ERROR || !linkSuccessful)
|
2011-02-06 00:00:13 -08:00
|
|
|
{
|
|
|
|
SDL_SetError("Failed to link shader program");
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glDeleteProgram(entry->id);
|
2011-02-06 00:00:13 -08:00
|
|
|
SDL_free(entry);
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-01-18 22:45:49 -05:00
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
/* Predetermine locations of uniform variables */
|
|
|
|
entry->uniform_locations[GLES2_UNIFORM_PROJECTION] =
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetUniformLocation(entry->id, "u_projection");
|
2011-02-06 00:00:13 -08:00
|
|
|
entry->uniform_locations[GLES2_UNIFORM_TEXTURE] =
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetUniformLocation(entry->id, "u_texture");
|
2011-02-06 00:00:13 -08:00
|
|
|
entry->uniform_locations[GLES2_UNIFORM_MODULATION] =
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetUniformLocation(entry->id, "u_modulation");
|
2011-02-06 00:00:13 -08:00
|
|
|
entry->uniform_locations[GLES2_UNIFORM_COLOR] =
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetUniformLocation(entry->id, "u_color");
|
2011-02-06 00:00:13 -08:00
|
|
|
entry->uniform_locations[GLES2_UNIFORM_COLORTABLE] =
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetUniformLocation(entry->id, "u_colorTable");
|
2011-02-06 00:00:13 -08:00
|
|
|
|
|
|
|
/* Cache the linked program */
|
|
|
|
if (rdata->program_cache.head)
|
|
|
|
{
|
|
|
|
entry->next = rdata->program_cache.head;
|
|
|
|
rdata->program_cache.head->prev = entry;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rdata->program_cache.tail = entry;
|
|
|
|
}
|
|
|
|
rdata->program_cache.head = entry;
|
|
|
|
++rdata->program_cache.count;
|
|
|
|
|
|
|
|
/* Increment the refcount of the shaders we're using */
|
|
|
|
++vertex->references;
|
|
|
|
++fragment->references;
|
|
|
|
|
|
|
|
/* Evict the last entry from the cache if we exceed the limit */
|
|
|
|
if (rdata->program_cache.count > GLES2_MAX_CACHED_PROGRAMS)
|
|
|
|
{
|
|
|
|
shaderEntry = rdata->program_cache.tail->vertex_shader;
|
|
|
|
if (--shaderEntry->references <= 0)
|
|
|
|
GLES2_EvictShader(renderer, shaderEntry);
|
|
|
|
shaderEntry = rdata->program_cache.tail->fragment_shader;
|
|
|
|
if (--shaderEntry->references <= 0)
|
|
|
|
GLES2_EvictShader(renderer, shaderEntry);
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glDeleteProgram(rdata->program_cache.tail->id);
|
2011-02-06 00:00:13 -08:00
|
|
|
rdata->program_cache.tail = rdata->program_cache.tail->prev;
|
|
|
|
SDL_free(rdata->program_cache.tail->next);
|
|
|
|
rdata->program_cache.tail->next = NULL;
|
|
|
|
--rdata->program_cache.count;
|
|
|
|
}
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GLES2_ShaderCacheEntry *
|
|
|
|
GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode blendMode)
|
|
|
|
{
|
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
|
|
|
const GLES2_Shader *shader;
|
|
|
|
const GLES2_ShaderInstance *instance = NULL;
|
|
|
|
GLES2_ShaderCacheEntry *entry = NULL;
|
|
|
|
GLint compileSuccessful = GL_FALSE;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
/* Find the corresponding shader */
|
|
|
|
shader = GLES2_GetShader(type, blendMode);
|
|
|
|
if (!shader)
|
|
|
|
{
|
|
|
|
SDL_SetError("No shader matching the requested characteristics was found");
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-01-18 22:45:49 -05:00
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
/* Find a matching shader instance that's supported on this hardware */
|
2011-02-06 08:46:48 -08:00
|
|
|
for (i = 0; i < shader->instance_count && !instance; ++i)
|
2011-02-06 00:00:13 -08:00
|
|
|
{
|
2011-02-06 08:46:48 -08:00
|
|
|
for (j = 0; j < rdata->shader_format_count && !instance; ++j)
|
2011-02-06 00:00:13 -08:00
|
|
|
{
|
|
|
|
if (!shader->instances)
|
|
|
|
continue;
|
2011-02-06 08:46:48 -08:00
|
|
|
if (!shader->instances[i])
|
|
|
|
continue;
|
2011-02-06 00:00:13 -08:00
|
|
|
if (shader->instances[i]->format != rdata->shader_formats[j])
|
|
|
|
continue;
|
|
|
|
instance = shader->instances[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!instance)
|
|
|
|
{
|
|
|
|
SDL_SetError("The specified shader cannot be loaded on the current platform");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if we've already cached this shader */
|
|
|
|
entry = rdata->shader_cache.head;
|
|
|
|
while (entry)
|
|
|
|
{
|
|
|
|
if (entry->instance == instance)
|
|
|
|
break;
|
|
|
|
entry = entry->next;
|
|
|
|
}
|
|
|
|
if (entry)
|
|
|
|
return entry;
|
|
|
|
|
|
|
|
/* Create a shader cache entry */
|
|
|
|
entry = (GLES2_ShaderCacheEntry *)SDL_calloc(1, sizeof(GLES2_ShaderCacheEntry));
|
|
|
|
if (!entry)
|
|
|
|
{
|
|
|
|
SDL_OutOfMemory();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
entry->type = type;
|
|
|
|
entry->instance = instance;
|
|
|
|
|
|
|
|
/* Compile or load the selected shader instance */
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetError();
|
|
|
|
entry->id = rdata->glCreateShader(instance->type);
|
2011-02-06 00:00:13 -08:00
|
|
|
if (instance->format == (GLenum)-1)
|
|
|
|
{
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glShaderSource(entry->id, 1, (const char **)&instance->data, NULL);
|
|
|
|
rdata->glCompileShader(entry->id);
|
|
|
|
rdata->glGetShaderiv(entry->id, GL_COMPILE_STATUS, &compileSuccessful);
|
2011-02-06 00:00:13 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glShaderBinary(1, &entry->id, instance->format, instance->data, instance->length);
|
2011-02-06 00:00:13 -08:00
|
|
|
compileSuccessful = GL_TRUE;
|
|
|
|
}
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
if (rdata->glGetError() != GL_NO_ERROR || !compileSuccessful)
|
2011-02-06 00:00:13 -08:00
|
|
|
{
|
2011-02-06 10:59:37 -08:00
|
|
|
char *info = NULL;
|
2011-12-29 05:11:33 -05:00
|
|
|
int length = 0;
|
2011-02-06 10:59:37 -08:00
|
|
|
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetShaderiv(entry->id, GL_INFO_LOG_LENGTH, &length);
|
2011-02-06 10:59:37 -08:00
|
|
|
if (length > 0) {
|
|
|
|
info = SDL_stack_alloc(char, length);
|
|
|
|
if (info) {
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetShaderInfoLog(entry->id, length, &length, info);
|
2011-02-06 10:59:37 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (info) {
|
|
|
|
SDL_SetError("Failed to load the shader: %s", info);
|
|
|
|
SDL_stack_free(info);
|
|
|
|
} else {
|
|
|
|
SDL_SetError("Failed to load the shader");
|
|
|
|
}
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glDeleteShader(entry->id);
|
2011-02-06 00:00:13 -08:00
|
|
|
SDL_free(entry);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Link the shader entry in at the front of the cache */
|
|
|
|
if (rdata->shader_cache.head)
|
|
|
|
{
|
|
|
|
entry->next = rdata->shader_cache.head;
|
|
|
|
rdata->shader_cache.head->prev = entry;
|
|
|
|
}
|
|
|
|
rdata->shader_cache.head = entry;
|
|
|
|
++rdata->shader_cache.count;
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
GLES2_EvictShader(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *entry)
|
|
|
|
{
|
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
|
|
|
|
|
|
|
/* Unlink the shader from the cache */
|
|
|
|
if (entry->next)
|
|
|
|
entry->next->prev = entry->prev;
|
|
|
|
if (entry->prev)
|
|
|
|
entry->prev->next = entry->next;
|
|
|
|
if (rdata->shader_cache.head == entry)
|
|
|
|
rdata->shader_cache.head = entry->next;
|
|
|
|
--rdata->shader_cache.count;
|
|
|
|
|
|
|
|
/* Deallocate the shader */
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glDeleteShader(entry->id);
|
2011-02-06 00:00:13 -08:00
|
|
|
SDL_free(entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, SDL_BlendMode blendMode)
|
|
|
|
{
|
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
|
|
|
GLES2_ShaderCacheEntry *vertex = NULL;
|
|
|
|
GLES2_ShaderCacheEntry *fragment = NULL;
|
|
|
|
GLES2_ShaderType vtype, ftype;
|
|
|
|
GLES2_ProgramCacheEntry *program;
|
|
|
|
|
|
|
|
/* Select an appropriate shader pair for the specified modes */
|
|
|
|
vtype = GLES2_SHADER_VERTEX_DEFAULT;
|
|
|
|
switch (source)
|
|
|
|
{
|
|
|
|
case GLES2_IMAGESOURCE_SOLID:
|
|
|
|
ftype = GLES2_SHADER_FRAGMENT_SOLID_SRC;
|
|
|
|
break;
|
2011-12-29 05:11:33 -05:00
|
|
|
case GLES2_IMAGESOURCE_TEXTURE_ABGR:
|
|
|
|
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC;
|
2012-06-22 11:38:49 -04:00
|
|
|
break;
|
2011-12-29 05:11:33 -05:00
|
|
|
case GLES2_IMAGESOURCE_TEXTURE_ARGB:
|
|
|
|
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC;
|
|
|
|
break;
|
|
|
|
case GLES2_IMAGESOURCE_TEXTURE_RGB:
|
|
|
|
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC;
|
|
|
|
break;
|
|
|
|
case GLES2_IMAGESOURCE_TEXTURE_BGR:
|
|
|
|
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC;
|
2011-02-06 00:00:13 -08:00
|
|
|
break;
|
2011-12-29 05:11:33 -05:00
|
|
|
default:
|
|
|
|
goto fault;
|
2011-02-06 00:00:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Load the requested shaders */
|
|
|
|
vertex = GLES2_CacheShader(renderer, vtype, blendMode);
|
|
|
|
if (!vertex)
|
|
|
|
goto fault;
|
|
|
|
fragment = GLES2_CacheShader(renderer, ftype, blendMode);
|
|
|
|
if (!fragment)
|
|
|
|
goto fault;
|
|
|
|
|
|
|
|
/* Check if we need to change programs at all */
|
|
|
|
if (rdata->current_program &&
|
|
|
|
rdata->current_program->vertex_shader == vertex &&
|
|
|
|
rdata->current_program->fragment_shader == fragment)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Generate a matching program */
|
|
|
|
program = GLES2_CacheProgram(renderer, vertex, fragment, blendMode);
|
|
|
|
if (!program)
|
|
|
|
goto fault;
|
|
|
|
|
|
|
|
/* Select that program in OpenGL */
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetError();
|
|
|
|
rdata->glUseProgram(program->id);
|
|
|
|
if (rdata->glGetError() != GL_NO_ERROR)
|
2011-02-06 00:00:13 -08:00
|
|
|
{
|
|
|
|
SDL_SetError("Failed to select program");
|
|
|
|
goto fault;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the current program */
|
|
|
|
rdata->current_program = program;
|
|
|
|
|
|
|
|
/* Activate an orthographic projection */
|
|
|
|
if (GLES2_SetOrthographicProjection(renderer) < 0)
|
|
|
|
goto fault;
|
|
|
|
|
|
|
|
/* Clean up and return */
|
|
|
|
return 0;
|
|
|
|
fault:
|
|
|
|
if (vertex && vertex->references <= 0)
|
|
|
|
GLES2_EvictShader(renderer, vertex);
|
|
|
|
if (fragment && fragment->references <= 0)
|
|
|
|
GLES2_EvictShader(renderer, fragment);
|
|
|
|
rdata->current_program = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
GLES2_SetOrthographicProjection(SDL_Renderer *renderer)
|
|
|
|
{
|
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
|
|
|
GLfloat projection[4][4];
|
|
|
|
GLuint locProjection;
|
|
|
|
|
|
|
|
/* Prepare an orthographic projection */
|
2011-02-15 13:59:59 -08:00
|
|
|
projection[0][0] = 2.0f / renderer->viewport.w;
|
2011-02-06 00:00:13 -08:00
|
|
|
projection[0][1] = 0.0f;
|
|
|
|
projection[0][2] = 0.0f;
|
|
|
|
projection[0][3] = 0.0f;
|
|
|
|
projection[1][0] = 0.0f;
|
2012-06-22 11:38:49 -04:00
|
|
|
if (renderer->target) {
|
|
|
|
projection[1][1] = 2.0f / renderer->viewport.h;
|
|
|
|
} else {
|
|
|
|
projection[1][1] = -2.0f / renderer->viewport.h;
|
|
|
|
}
|
2011-02-06 00:00:13 -08:00
|
|
|
projection[1][2] = 0.0f;
|
|
|
|
projection[1][3] = 0.0f;
|
|
|
|
projection[2][0] = 0.0f;
|
|
|
|
projection[2][1] = 0.0f;
|
2012-06-22 11:38:49 -04:00
|
|
|
projection[2][2] = 0.0f;
|
2011-02-06 00:00:13 -08:00
|
|
|
projection[2][3] = 0.0f;
|
|
|
|
projection[3][0] = -1.0f;
|
2012-06-22 11:38:49 -04:00
|
|
|
if (renderer->target) {
|
|
|
|
projection[3][1] = -1.0f;
|
|
|
|
} else {
|
|
|
|
projection[3][1] = 1.0f;
|
|
|
|
}
|
2011-02-06 00:00:13 -08:00
|
|
|
projection[3][2] = 0.0f;
|
|
|
|
projection[3][3] = 1.0f;
|
|
|
|
|
|
|
|
/* Set the projection matrix */
|
|
|
|
locProjection = rdata->current_program->uniform_locations[GLES2_UNIFORM_PROJECTION];
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetError();
|
|
|
|
rdata->glUniformMatrix4fv(locProjection, 1, GL_FALSE, (GLfloat *)projection);
|
|
|
|
if (rdata->glGetError() != GL_NO_ERROR)
|
2011-02-06 00:00:13 -08:00
|
|
|
{
|
|
|
|
SDL_SetError("Failed to set orthographic projection");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************************************
|
|
|
|
* Rendering functions *
|
|
|
|
*************************************************************************************************/
|
|
|
|
|
2011-02-07 20:06:26 -08:00
|
|
|
static const float inv255f = 1.0f / 255.0f;
|
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
static int GLES2_RenderClear(SDL_Renderer *renderer);
|
|
|
|
static int GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_Point *points, int count);
|
|
|
|
static int GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_Point *points, int count);
|
2011-02-15 13:59:59 -08:00
|
|
|
static int GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_Rect *rects, int count);
|
2011-02-06 00:00:13 -08:00
|
|
|
static int GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect,
|
|
|
|
const SDL_Rect *dstrect);
|
2011-10-31 02:55:21 -04:00
|
|
|
static int GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|
|
|
Uint32 pixel_format, void * pixels, int pitch);
|
2012-06-01 19:51:08 -03:00
|
|
|
static int GLES2_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
|
|
|
const SDL_Rect * srcrect, const SDL_Rect * dstrect,
|
|
|
|
const double angle, const SDL_Point *center, const SDL_RendererFlip flip);
|
2011-02-06 00:00:13 -08:00
|
|
|
static void GLES2_RenderPresent(SDL_Renderer *renderer);
|
|
|
|
|
2011-02-17 02:23:48 -08:00
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
static int
|
2011-02-17 02:23:48 -08:00
|
|
|
GLES2_RenderClear(SDL_Renderer * renderer)
|
2011-02-06 00:00:13 -08:00
|
|
|
{
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
2011-02-06 00:00:13 -08:00
|
|
|
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
GLES2_ActivateRenderer(renderer);
|
2012-01-18 22:45:49 -05:00
|
|
|
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glClearColor((GLfloat) renderer->r * inv255f,
|
2011-02-17 02:23:48 -08:00
|
|
|
(GLfloat) renderer->g * inv255f,
|
|
|
|
(GLfloat) renderer->b * inv255f,
|
|
|
|
(GLfloat) renderer->a * inv255f);
|
|
|
|
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glClear(GL_COLOR_BUFFER_BIT);
|
2011-02-17 02:23:48 -08:00
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-02-19 21:51:21 -08:00
|
|
|
GLES2_SetBlendMode(GLES2_DriverContext *rdata, int blendMode)
|
2011-02-06 00:00:13 -08:00
|
|
|
{
|
2011-02-19 21:51:21 -08:00
|
|
|
if (blendMode != rdata->current.blendMode) {
|
|
|
|
switch (blendMode) {
|
|
|
|
default:
|
|
|
|
case SDL_BLENDMODE_NONE:
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glDisable(GL_BLEND);
|
2011-02-19 21:51:21 -08:00
|
|
|
break;
|
|
|
|
case SDL_BLENDMODE_BLEND:
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glEnable(GL_BLEND);
|
|
|
|
rdata->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
2011-02-19 21:51:21 -08:00
|
|
|
break;
|
|
|
|
case SDL_BLENDMODE_ADD:
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glEnable(GL_BLEND);
|
|
|
|
rdata->glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
2011-02-19 21:51:21 -08:00
|
|
|
break;
|
|
|
|
case SDL_BLENDMODE_MOD:
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glEnable(GL_BLEND);
|
|
|
|
rdata->glBlendFunc(GL_ZERO, GL_SRC_COLOR);
|
2011-02-19 21:51:21 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
rdata->current.blendMode = blendMode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
GLES2_SetTexCoords(GLES2_DriverContext * rdata, SDL_bool enabled)
|
|
|
|
{
|
|
|
|
if (enabled != rdata->current.tex_coords) {
|
|
|
|
if (enabled) {
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glEnableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD);
|
2011-02-19 21:51:21 -08:00
|
|
|
} else {
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD);
|
2011-02-19 21:51:21 -08:00
|
|
|
}
|
|
|
|
rdata->current.tex_coords = enabled;
|
2011-02-06 00:00:13 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2011-02-19 21:51:21 -08:00
|
|
|
GLES2_SetDrawingState(SDL_Renderer * renderer)
|
2011-02-06 00:00:13 -08:00
|
|
|
{
|
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
2011-02-19 21:51:21 -08:00
|
|
|
int blendMode = renderer->blendMode;
|
2011-02-06 00:00:13 -08:00
|
|
|
GLuint locColor;
|
2011-02-19 21:51:21 -08:00
|
|
|
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetError();
|
2011-02-06 00:00:13 -08:00
|
|
|
|
|
|
|
GLES2_ActivateRenderer(renderer);
|
|
|
|
|
2011-02-19 21:51:21 -08:00
|
|
|
GLES2_SetBlendMode(rdata, blendMode);
|
|
|
|
|
|
|
|
GLES2_SetTexCoords(rdata, SDL_FALSE);
|
2011-02-06 00:00:13 -08:00
|
|
|
|
|
|
|
/* Activate an appropriate shader and set the projection matrix */
|
|
|
|
if (GLES2_SelectProgram(renderer, GLES2_IMAGESOURCE_SOLID, blendMode) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* Select the color to draw with */
|
|
|
|
locColor = rdata->current_program->uniform_locations[GLES2_UNIFORM_COLOR];
|
2012-06-22 11:38:49 -04:00
|
|
|
if (renderer->target &&
|
|
|
|
(renderer->target->format == SDL_PIXELFORMAT_ARGB8888 ||
|
|
|
|
renderer->target->format == SDL_PIXELFORMAT_RGB888)) {
|
|
|
|
rdata->glUniform4f(locColor,
|
|
|
|
renderer->b * inv255f,
|
|
|
|
renderer->g * inv255f,
|
|
|
|
renderer->r * inv255f,
|
|
|
|
renderer->a * inv255f);
|
|
|
|
} else {
|
|
|
|
rdata->glUniform4f(locColor,
|
|
|
|
renderer->r * inv255f,
|
|
|
|
renderer->g * inv255f,
|
|
|
|
renderer->b * inv255f,
|
|
|
|
renderer->a * inv255f);
|
|
|
|
}
|
2011-02-19 21:51:21 -08:00
|
|
|
return 0;
|
|
|
|
}
|
2011-02-06 00:00:13 -08:00
|
|
|
|
2011-02-19 21:51:21 -08:00
|
|
|
static int
|
|
|
|
GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_Point *points, int count)
|
|
|
|
{
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
2011-02-19 21:51:21 -08:00
|
|
|
GLfloat *vertices;
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
if (GLES2_SetDrawingState(renderer) < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
2011-02-06 00:00:13 -08:00
|
|
|
|
|
|
|
/* Emit the specified vertices as points */
|
|
|
|
vertices = SDL_stack_alloc(GLfloat, count * 2);
|
|
|
|
for (idx = 0; idx < count; ++idx)
|
|
|
|
{
|
|
|
|
GLfloat x = (GLfloat)points[idx].x + 0.5f;
|
|
|
|
GLfloat y = (GLfloat)points[idx].y + 0.5f;
|
|
|
|
|
|
|
|
vertices[idx * 2] = x;
|
|
|
|
vertices[(idx * 2) + 1] = y;
|
|
|
|
}
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetError();
|
|
|
|
rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
|
|
|
rdata->glDrawArrays(GL_POINTS, 0, count);
|
2011-02-06 00:00:13 -08:00
|
|
|
SDL_stack_free(vertices);
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
if (rdata->glGetError() != GL_NO_ERROR)
|
2011-02-06 00:00:13 -08:00
|
|
|
{
|
|
|
|
SDL_SetError("Failed to render lines");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_Point *points, int count)
|
|
|
|
{
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
2011-02-06 00:00:13 -08:00
|
|
|
GLfloat *vertices;
|
|
|
|
int idx;
|
|
|
|
|
2011-02-19 21:51:21 -08:00
|
|
|
if (GLES2_SetDrawingState(renderer) < 0) {
|
2011-02-06 00:00:13 -08:00
|
|
|
return -1;
|
2011-02-19 21:51:21 -08:00
|
|
|
}
|
2011-02-06 00:00:13 -08:00
|
|
|
|
|
|
|
/* Emit a line strip including the specified vertices */
|
|
|
|
vertices = SDL_stack_alloc(GLfloat, count * 2);
|
|
|
|
for (idx = 0; idx < count; ++idx)
|
|
|
|
{
|
|
|
|
GLfloat x = (GLfloat)points[idx].x + 0.5f;
|
|
|
|
GLfloat y = (GLfloat)points[idx].y + 0.5f;
|
|
|
|
|
|
|
|
vertices[idx * 2] = x;
|
|
|
|
vertices[(idx * 2) + 1] = y;
|
|
|
|
}
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetError();
|
|
|
|
rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
|
|
|
rdata->glDrawArrays(GL_LINE_STRIP, 0, count);
|
2011-11-10 00:22:44 -05:00
|
|
|
|
|
|
|
/* We need to close the endpoint of the line */
|
|
|
|
if (count == 2 ||
|
|
|
|
points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glDrawArrays(GL_POINTS, count-1, 1);
|
2011-11-10 00:22:44 -05:00
|
|
|
}
|
2011-02-06 00:00:13 -08:00
|
|
|
SDL_stack_free(vertices);
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
if (rdata->glGetError() != GL_NO_ERROR)
|
2011-02-06 00:00:13 -08:00
|
|
|
{
|
|
|
|
SDL_SetError("Failed to render lines");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2011-02-15 13:59:59 -08:00
|
|
|
GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_Rect *rects, int count)
|
2011-02-06 00:00:13 -08:00
|
|
|
{
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
2011-02-06 00:00:13 -08:00
|
|
|
GLfloat vertices[8];
|
|
|
|
int idx;
|
|
|
|
|
2011-02-19 21:51:21 -08:00
|
|
|
if (GLES2_SetDrawingState(renderer) < 0) {
|
2011-02-06 00:00:13 -08:00
|
|
|
return -1;
|
2011-02-19 21:51:21 -08:00
|
|
|
}
|
2011-02-06 00:00:13 -08:00
|
|
|
|
|
|
|
/* Emit a line loop for each rectangle */
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetError();
|
2011-02-15 13:59:59 -08:00
|
|
|
for (idx = 0; idx < count; ++idx) {
|
|
|
|
const SDL_Rect *rect = &rects[idx];
|
|
|
|
|
|
|
|
GLfloat xMin = (GLfloat)rect->x;
|
|
|
|
GLfloat xMax = (GLfloat)(rect->x + rect->w);
|
|
|
|
GLfloat yMin = (GLfloat)rect->y;
|
|
|
|
GLfloat yMax = (GLfloat)(rect->y + rect->h);
|
2011-02-06 00:00:13 -08:00
|
|
|
|
|
|
|
vertices[0] = xMin;
|
|
|
|
vertices[1] = yMin;
|
|
|
|
vertices[2] = xMax;
|
|
|
|
vertices[3] = yMin;
|
|
|
|
vertices[4] = xMin;
|
|
|
|
vertices[5] = yMax;
|
|
|
|
vertices[6] = xMax;
|
|
|
|
vertices[7] = yMax;
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
|
|
|
rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
2011-02-06 00:00:13 -08:00
|
|
|
}
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
if (rdata->glGetError() != GL_NO_ERROR)
|
2011-02-06 00:00:13 -08:00
|
|
|
{
|
|
|
|
SDL_SetError("Failed to render lines");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect,
|
|
|
|
const SDL_Rect *dstrect)
|
|
|
|
{
|
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
|
|
|
GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata;
|
|
|
|
GLES2_ImageSource sourceType;
|
|
|
|
SDL_BlendMode blendMode;
|
|
|
|
GLfloat vertices[8];
|
|
|
|
GLfloat texCoords[8];
|
|
|
|
GLuint locTexture;
|
|
|
|
GLuint locModulation;
|
|
|
|
|
|
|
|
GLES2_ActivateRenderer(renderer);
|
|
|
|
|
2012-06-01 19:51:08 -03:00
|
|
|
/* Activate an appropriate shader and set the projection matrix */
|
|
|
|
blendMode = texture->blendMode;
|
|
|
|
if (renderer->target) {
|
|
|
|
/* Check if we need to do color mapping between the source and render target textures */
|
|
|
|
if (renderer->target->format != texture->format) {
|
|
|
|
switch (texture->format)
|
|
|
|
{
|
|
|
|
case SDL_PIXELFORMAT_ABGR8888:
|
|
|
|
switch (renderer->target->format)
|
|
|
|
{
|
|
|
|
case SDL_PIXELFORMAT_ARGB8888:
|
|
|
|
case SDL_PIXELFORMAT_RGB888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_BGR888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_ARGB8888:
|
|
|
|
switch (renderer->target->format)
|
|
|
|
{
|
|
|
|
case SDL_PIXELFORMAT_ABGR8888:
|
|
|
|
case SDL_PIXELFORMAT_BGR888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_RGB888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_BGR888:
|
|
|
|
switch (renderer->target->format)
|
|
|
|
{
|
|
|
|
case SDL_PIXELFORMAT_ABGR8888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_ARGB8888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_RGB888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_RGB888:
|
|
|
|
switch (renderer->target->format)
|
|
|
|
{
|
|
|
|
case SDL_PIXELFORMAT_ABGR8888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_ARGB8888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_BGR888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; // Texture formats match, use the non color mapping shader (even if the formats are not ABGR)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switch (texture->format)
|
|
|
|
{
|
|
|
|
case SDL_PIXELFORMAT_ABGR8888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_ARGB8888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_BGR888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_RGB888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (GLES2_SelectProgram(renderer, sourceType, blendMode) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* Select the target texture */
|
|
|
|
locTexture = rdata->current_program->uniform_locations[GLES2_UNIFORM_TEXTURE];
|
|
|
|
rdata->glGetError();
|
2012-06-22 11:38:49 -04:00
|
|
|
rdata->glActiveTexture(GL_TEXTURE0);
|
2012-06-01 19:51:08 -03:00
|
|
|
rdata->glBindTexture(tdata->texture_type, tdata->texture);
|
|
|
|
rdata->glUniform1i(locTexture, 0);
|
|
|
|
|
|
|
|
/* Configure color modulation */
|
|
|
|
locModulation = rdata->current_program->uniform_locations[GLES2_UNIFORM_MODULATION];
|
2012-06-22 11:38:49 -04:00
|
|
|
if (renderer->target &&
|
|
|
|
(renderer->target->format == SDL_PIXELFORMAT_ARGB8888 ||
|
|
|
|
renderer->target->format == SDL_PIXELFORMAT_RGB888)) {
|
|
|
|
rdata->glUniform4f(locModulation,
|
|
|
|
texture->b * inv255f,
|
|
|
|
texture->g * inv255f,
|
|
|
|
texture->r * inv255f,
|
|
|
|
texture->a * inv255f);
|
|
|
|
} else {
|
|
|
|
rdata->glUniform4f(locModulation,
|
|
|
|
texture->r * inv255f,
|
|
|
|
texture->g * inv255f,
|
|
|
|
texture->b * inv255f,
|
|
|
|
texture->a * inv255f);
|
|
|
|
}
|
2012-06-01 19:51:08 -03:00
|
|
|
|
|
|
|
/* Configure texture blending */
|
|
|
|
GLES2_SetBlendMode(rdata, blendMode);
|
|
|
|
|
|
|
|
GLES2_SetTexCoords(rdata, SDL_TRUE);
|
|
|
|
|
|
|
|
/* Emit the textured quad */
|
2012-06-22 11:38:49 -04:00
|
|
|
vertices[0] = (GLfloat)dstrect->x;
|
|
|
|
vertices[1] = (GLfloat)dstrect->y;
|
|
|
|
vertices[2] = (GLfloat)(dstrect->x + dstrect->w);
|
|
|
|
vertices[3] = (GLfloat)dstrect->y;
|
|
|
|
vertices[4] = (GLfloat)dstrect->x;
|
|
|
|
vertices[5] = (GLfloat)(dstrect->y + dstrect->h);
|
|
|
|
vertices[6] = (GLfloat)(dstrect->x + dstrect->w);
|
|
|
|
vertices[7] = (GLfloat)(dstrect->y + dstrect->h);
|
2012-06-01 19:51:08 -03:00
|
|
|
rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
|
|
|
texCoords[0] = srcrect->x / (GLfloat)texture->w;
|
|
|
|
texCoords[1] = srcrect->y / (GLfloat)texture->h;
|
|
|
|
texCoords[2] = (srcrect->x + srcrect->w) / (GLfloat)texture->w;
|
|
|
|
texCoords[3] = srcrect->y / (GLfloat)texture->h;
|
|
|
|
texCoords[4] = srcrect->x / (GLfloat)texture->w;
|
|
|
|
texCoords[5] = (srcrect->y + srcrect->h) / (GLfloat)texture->h;
|
|
|
|
texCoords[6] = (srcrect->x + srcrect->w) / (GLfloat)texture->w;
|
|
|
|
texCoords[7] = (srcrect->y + srcrect->h) / (GLfloat)texture->h;
|
|
|
|
rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords);
|
|
|
|
rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
|
|
if (rdata->glGetError() != GL_NO_ERROR)
|
|
|
|
{
|
|
|
|
SDL_SetError("Failed to render texture");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect,
|
|
|
|
const SDL_Rect *dstrect, const double angle, const SDL_Point *center, const SDL_RendererFlip flip)
|
|
|
|
{
|
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
|
|
|
GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata;
|
|
|
|
GLES2_ImageSource sourceType;
|
|
|
|
SDL_BlendMode blendMode;
|
|
|
|
GLfloat vertices[8];
|
|
|
|
GLfloat texCoords[8];
|
|
|
|
GLuint locTexture;
|
|
|
|
GLuint locModulation;
|
|
|
|
GLfloat translate[8];
|
|
|
|
GLfloat fAngle[4];
|
|
|
|
GLfloat tmp;
|
|
|
|
|
|
|
|
GLES2_ActivateRenderer(renderer);
|
|
|
|
|
|
|
|
rdata->glEnableVertexAttribArray(GLES2_ATTRIBUTE_CENTER);
|
|
|
|
rdata->glEnableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE);
|
|
|
|
fAngle[0] = fAngle[1] = fAngle[2] = fAngle[3] = (GLfloat)angle;
|
|
|
|
/* Calculate the center of rotation */
|
|
|
|
translate[0] = translate[2] = translate[4] = translate[6] = (GLfloat)(center->x + dstrect->x);
|
|
|
|
translate[1] = translate[3] = translate[5] = translate[7] = (GLfloat)(center->y + dstrect->y);
|
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
/* Activate an appropriate shader and set the projection matrix */
|
|
|
|
blendMode = texture->blendMode;
|
2012-01-21 22:22:30 -05:00
|
|
|
if (renderer->target) {
|
2012-01-18 22:45:49 -05:00
|
|
|
/* Check if we need to do color mapping between the source and render target textures */
|
2012-01-21 22:22:30 -05:00
|
|
|
if (renderer->target->format != texture->format) {
|
2012-01-18 22:45:49 -05:00
|
|
|
switch (texture->format)
|
|
|
|
{
|
|
|
|
case SDL_PIXELFORMAT_ABGR8888:
|
2012-01-21 22:22:30 -05:00
|
|
|
switch (renderer->target->format)
|
2012-01-18 22:45:49 -05:00
|
|
|
{
|
|
|
|
case SDL_PIXELFORMAT_ARGB8888:
|
|
|
|
case SDL_PIXELFORMAT_RGB888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_BGR888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_ARGB8888:
|
2012-01-21 22:22:30 -05:00
|
|
|
switch (renderer->target->format)
|
2012-01-18 22:45:49 -05:00
|
|
|
{
|
|
|
|
case SDL_PIXELFORMAT_ABGR8888:
|
|
|
|
case SDL_PIXELFORMAT_BGR888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_RGB888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_BGR888:
|
2012-01-21 22:22:30 -05:00
|
|
|
switch (renderer->target->format)
|
2012-01-18 22:45:49 -05:00
|
|
|
{
|
|
|
|
case SDL_PIXELFORMAT_ABGR8888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_ARGB8888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_RGB888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_RGB888:
|
2012-01-21 22:22:30 -05:00
|
|
|
switch (renderer->target->format)
|
2012-01-18 22:45:49 -05:00
|
|
|
{
|
|
|
|
case SDL_PIXELFORMAT_ABGR8888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_ARGB8888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_BGR888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; // Texture formats match, use the non color mapping shader (even if the formats are not ABGR)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switch (texture->format)
|
|
|
|
{
|
|
|
|
case SDL_PIXELFORMAT_ABGR8888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_ARGB8888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_BGR888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
|
|
|
|
break;
|
|
|
|
case SDL_PIXELFORMAT_RGB888:
|
|
|
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
|
|
|
|
break;
|
|
|
|
}
|
2011-12-29 05:11:33 -05:00
|
|
|
}
|
2011-02-06 00:00:13 -08:00
|
|
|
if (GLES2_SelectProgram(renderer, sourceType, blendMode) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* Select the target texture */
|
|
|
|
locTexture = rdata->current_program->uniform_locations[GLES2_UNIFORM_TEXTURE];
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetError();
|
|
|
|
rdata->glActiveTexture(GL_TEXTURE0);
|
|
|
|
rdata->glBindTexture(tdata->texture_type, tdata->texture);
|
|
|
|
rdata->glUniform1i(locTexture, 0);
|
2011-02-06 00:00:13 -08:00
|
|
|
|
|
|
|
/* Configure color modulation */
|
|
|
|
locModulation = rdata->current_program->uniform_locations[GLES2_UNIFORM_MODULATION];
|
2012-06-22 11:38:49 -04:00
|
|
|
if (renderer->target &&
|
|
|
|
(renderer->target->format == SDL_PIXELFORMAT_ARGB8888 ||
|
|
|
|
renderer->target->format == SDL_PIXELFORMAT_RGB888)) {
|
|
|
|
rdata->glUniform4f(locModulation,
|
|
|
|
texture->b * inv255f,
|
|
|
|
texture->g * inv255f,
|
|
|
|
texture->r * inv255f,
|
|
|
|
texture->a * inv255f);
|
|
|
|
} else {
|
|
|
|
rdata->glUniform4f(locModulation,
|
|
|
|
texture->r * inv255f,
|
|
|
|
texture->g * inv255f,
|
|
|
|
texture->b * inv255f,
|
|
|
|
texture->a * inv255f);
|
|
|
|
}
|
2011-02-19 21:51:21 -08:00
|
|
|
|
|
|
|
/* Configure texture blending */
|
|
|
|
GLES2_SetBlendMode(rdata, blendMode);
|
|
|
|
|
|
|
|
GLES2_SetTexCoords(rdata, SDL_TRUE);
|
2011-02-06 00:00:13 -08:00
|
|
|
|
|
|
|
/* Emit the textured quad */
|
2012-06-22 11:38:49 -04:00
|
|
|
vertices[0] = (GLfloat)dstrect->x;
|
|
|
|
vertices[1] = (GLfloat)dstrect->y;
|
|
|
|
vertices[2] = (GLfloat)(dstrect->x + dstrect->w);
|
|
|
|
vertices[3] = (GLfloat)dstrect->y;
|
|
|
|
vertices[4] = (GLfloat)dstrect->x;
|
|
|
|
vertices[5] = (GLfloat)(dstrect->y + dstrect->h);
|
|
|
|
vertices[6] = (GLfloat)(dstrect->x + dstrect->w);
|
|
|
|
vertices[7] = (GLfloat)(dstrect->y + dstrect->h);
|
2012-06-01 19:51:08 -03:00
|
|
|
if (flip & SDL_FLIP_HORIZONTAL) {
|
|
|
|
tmp = vertices[0];
|
|
|
|
vertices[0] = vertices[4] = vertices[2];
|
|
|
|
vertices[2] = vertices[6] = tmp;
|
|
|
|
}
|
|
|
|
if (flip & SDL_FLIP_VERTICAL) {
|
|
|
|
tmp = vertices[1];
|
|
|
|
vertices[1] = vertices[3] = vertices[5];
|
|
|
|
vertices[5] = vertices[7] = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_ANGLE, 1, GL_FLOAT, GL_FALSE, 0, &fAngle);
|
|
|
|
rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_CENTER, 2, GL_FLOAT, GL_FALSE, 0, translate);
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
2012-01-18 22:45:49 -05:00
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
texCoords[0] = srcrect->x / (GLfloat)texture->w;
|
|
|
|
texCoords[1] = srcrect->y / (GLfloat)texture->h;
|
|
|
|
texCoords[2] = (srcrect->x + srcrect->w) / (GLfloat)texture->w;
|
|
|
|
texCoords[3] = srcrect->y / (GLfloat)texture->h;
|
|
|
|
texCoords[4] = srcrect->x / (GLfloat)texture->w;
|
|
|
|
texCoords[5] = (srcrect->y + srcrect->h) / (GLfloat)texture->h;
|
|
|
|
texCoords[6] = (srcrect->x + srcrect->w) / (GLfloat)texture->w;
|
|
|
|
texCoords[7] = (srcrect->y + srcrect->h) / (GLfloat)texture->h;
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords);
|
|
|
|
rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
2012-06-01 19:51:08 -03:00
|
|
|
rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_CENTER);
|
|
|
|
rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE);
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
if (rdata->glGetError() != GL_NO_ERROR)
|
2011-02-06 00:00:13 -08:00
|
|
|
{
|
|
|
|
SDL_SetError("Failed to render texture");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-10-31 02:55:21 -04:00
|
|
|
static int
|
|
|
|
GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|
|
|
Uint32 pixel_format, void * pixels, int pitch)
|
|
|
|
{
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
|
2011-10-31 02:55:21 -04:00
|
|
|
SDL_Window *window = renderer->window;
|
|
|
|
Uint32 temp_format = SDL_PIXELFORMAT_ABGR8888;
|
|
|
|
void *temp_pixels;
|
|
|
|
int temp_pitch;
|
|
|
|
Uint8 *src, *dst, *tmp;
|
|
|
|
int w, h, length, rows;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
GLES2_ActivateRenderer(renderer);
|
|
|
|
|
|
|
|
temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
|
|
|
temp_pixels = SDL_malloc(rect->h * temp_pitch);
|
|
|
|
if (!temp_pixels) {
|
|
|
|
SDL_OutOfMemory();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_GetWindowSize(window, &w, &h);
|
|
|
|
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
2011-10-31 02:55:21 -04:00
|
|
|
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h,
|
2011-10-31 02:55:21 -04:00
|
|
|
GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels);
|
|
|
|
|
|
|
|
/* Flip the rows to be top-down */
|
|
|
|
length = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
|
|
|
src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch;
|
|
|
|
dst = (Uint8*)temp_pixels;
|
|
|
|
tmp = SDL_stack_alloc(Uint8, length);
|
|
|
|
rows = rect->h / 2;
|
|
|
|
while (rows--) {
|
|
|
|
SDL_memcpy(tmp, dst, length);
|
|
|
|
SDL_memcpy(dst, src, length);
|
|
|
|
SDL_memcpy(src, tmp, length);
|
|
|
|
dst += temp_pitch;
|
|
|
|
src -= temp_pitch;
|
|
|
|
}
|
|
|
|
SDL_stack_free(tmp);
|
|
|
|
|
|
|
|
status = SDL_ConvertPixels(rect->w, rect->h,
|
|
|
|
temp_format, temp_pixels, temp_pitch,
|
|
|
|
pixel_format, pixels, pitch);
|
|
|
|
SDL_free(temp_pixels);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
static void
|
|
|
|
GLES2_RenderPresent(SDL_Renderer *renderer)
|
|
|
|
{
|
|
|
|
GLES2_ActivateRenderer(renderer);
|
|
|
|
|
|
|
|
/* Tell the video driver to swap buffers */
|
|
|
|
SDL_GL_SwapWindow(renderer->window);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************************************
|
|
|
|
* Renderer instantiation *
|
|
|
|
*************************************************************************************************/
|
|
|
|
|
|
|
|
#define GL_NVIDIA_PLATFORM_BINARY_NV 0x890B
|
|
|
|
|
2011-02-19 21:51:21 -08:00
|
|
|
static void
|
|
|
|
GLES2_ResetState(SDL_Renderer *renderer)
|
|
|
|
{
|
|
|
|
GLES2_DriverContext *rdata = (GLES2_DriverContext *) renderer->driverdata;
|
|
|
|
|
|
|
|
if (SDL_CurrentContext == rdata->context) {
|
|
|
|
GLES2_UpdateViewport(renderer);
|
|
|
|
} else {
|
|
|
|
GLES2_ActivateRenderer(renderer);
|
|
|
|
}
|
|
|
|
|
|
|
|
rdata->current.blendMode = -1;
|
|
|
|
rdata->current.tex_coords = SDL_FALSE;
|
|
|
|
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glEnableVertexAttribArray(GLES2_ATTRIBUTE_POSITION);
|
|
|
|
rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD);
|
2011-02-19 21:51:21 -08:00
|
|
|
}
|
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
static SDL_Renderer *
|
|
|
|
GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
|
|
|
{
|
|
|
|
SDL_Renderer *renderer;
|
|
|
|
GLES2_DriverContext *rdata;
|
|
|
|
GLint nFormats;
|
|
|
|
#ifndef ZUNE_HD
|
|
|
|
GLboolean hasCompiler;
|
|
|
|
#endif
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
Uint32 windowFlags;
|
2012-01-30 20:56:25 -05:00
|
|
|
GLint window_framebuffer;
|
2012-01-18 22:45:49 -05:00
|
|
|
|
2012-07-18 15:20:32 -07:00
|
|
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_EGL, 1);
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
2012-01-18 22:45:49 -05:00
|
|
|
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
windowFlags = SDL_GetWindowFlags(window);
|
|
|
|
if (!(windowFlags & SDL_WINDOW_OPENGL)) {
|
|
|
|
if (SDL_RecreateWindow(window, windowFlags | SDL_WINDOW_OPENGL) < 0) {
|
|
|
|
/* Uh oh, better try to put it back... */
|
|
|
|
SDL_RecreateWindow(window, windowFlags);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2011-02-06 00:00:13 -08:00
|
|
|
|
|
|
|
/* Create the renderer struct */
|
|
|
|
renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(SDL_Renderer));
|
2011-02-06 10:22:25 -08:00
|
|
|
if (!renderer) {
|
|
|
|
SDL_OutOfMemory();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
rdata = (GLES2_DriverContext *)SDL_calloc(1, sizeof(GLES2_DriverContext));
|
2011-02-06 10:22:25 -08:00
|
|
|
if (!rdata) {
|
|
|
|
GLES2_DestroyRenderer(renderer);
|
2011-02-06 00:00:13 -08:00
|
|
|
SDL_OutOfMemory();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
renderer->info = GLES2_RenderDriver.info;
|
2012-01-19 21:06:47 -05:00
|
|
|
renderer->info.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
|
2011-02-15 13:59:59 -08:00
|
|
|
renderer->driverdata = rdata;
|
Fixed bug 1256 - Invalid window warning in GL_CreateRenderer
Martin Gerhardy 2011-07-27 02:26:06 PDT
the window reference is lost in the GL_CreateRenderer function. The attached
patch should fix this error.
#0 SDLSystem_LogOutputFunction (userdata=0x63b010, category=1,
priority=SDL_LOG_PRIORITY_ERROR, message=0x7fffffffcd00 "Invalid window") at
src/system/sdl/SDLSystem.cpp:8
#1 0x00007ffff7b1ddb3 in SDL_LogMessageV (category=1,
priority=SDL_LOG_PRIORITY_ERROR, fmt=<value optimized out>, ap=<value optimized
out>) at src/SDL_log.c:275
#2 0x00007ffff7b1df7c in SDL_LogError (category=<value optimized out>,
fmt=<value optimized out>) at src/SDL_log.c:212
#3 0x00007ffff7b1d582 in SDL_SetError (fmt=0x7ffff7baaff0 "") at
src/SDL_error.c:111
#4 0x00007ffff7b96f9e in SDL_GL_MakeCurrent (window=0x0, ctx=0xa62ce0) at
src/video/SDL_video.c:2484
#5 0x00007ffff7b4ba0c in GL_ActivateRenderer (renderer=0xa8f680) at
src/render/opengl/SDL_render_gl.c:195
#6 0x00007ffff7b4c59a in GL_ResetState (window=0x918010, flags=<value
optimized out>) at src/render/opengl/SDL_render_gl.c:214
#7 GL_CreateRenderer (window=0x918010, flags=<value optimized out>) at
src/render/opengl/SDL_render_gl.c:343
#8 0x00007ffff7b48053 in SDL_CreateRenderer (window=0x918010, index=<value
optimized out>, flags=2) at src/render/SDL_render.c:166
2012-01-07 02:32:08 -05:00
|
|
|
renderer->window = window;
|
2011-02-06 02:35:14 -08:00
|
|
|
|
2011-02-06 10:22:25 -08:00
|
|
|
/* Create an OpenGL ES 2.0 context */
|
2011-02-06 00:00:13 -08:00
|
|
|
rdata->context = SDL_GL_CreateContext(window);
|
|
|
|
if (!rdata->context)
|
|
|
|
{
|
2011-02-06 10:22:25 -08:00
|
|
|
GLES2_DestroyRenderer(renderer);
|
2011-02-06 00:00:13 -08:00
|
|
|
return NULL;
|
|
|
|
}
|
2011-02-06 00:48:16 -08:00
|
|
|
if (SDL_GL_MakeCurrent(window, rdata->context) < 0) {
|
2011-02-06 10:22:25 -08:00
|
|
|
GLES2_DestroyRenderer(renderer);
|
2011-02-06 00:48:16 -08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
if (GLES2_LoadFunctions(rdata) < 0) {
|
|
|
|
GLES2_DestroyRenderer(renderer);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-02-06 00:48:16 -08:00
|
|
|
if (flags & SDL_RENDERER_PRESENTVSYNC) {
|
|
|
|
SDL_GL_SetSwapInterval(1);
|
|
|
|
} else {
|
|
|
|
SDL_GL_SetSwapInterval(0);
|
|
|
|
}
|
|
|
|
if (SDL_GL_GetSwapInterval() > 0) {
|
|
|
|
renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
|
|
|
|
}
|
2011-02-06 00:00:13 -08:00
|
|
|
|
|
|
|
/* Determine supported shader formats */
|
|
|
|
/* HACK: glGetInteger is broken on the Zune HD's compositor, so we just hardcode this */
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetError();
|
2011-02-06 00:00:13 -08:00
|
|
|
#ifdef ZUNE_HD
|
|
|
|
nFormats = 1;
|
|
|
|
#else /* !ZUNE_HD */
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &nFormats);
|
|
|
|
rdata->glGetBooleanv(GL_SHADER_COMPILER, &hasCompiler);
|
2011-02-06 00:00:13 -08:00
|
|
|
if (hasCompiler)
|
|
|
|
++nFormats;
|
|
|
|
#endif /* ZUNE_HD */
|
|
|
|
rdata->shader_formats = (GLenum *)SDL_calloc(nFormats, sizeof(GLenum));
|
|
|
|
if (!rdata->shader_formats)
|
|
|
|
{
|
2011-02-06 10:22:25 -08:00
|
|
|
GLES2_DestroyRenderer(renderer);
|
2011-02-06 00:00:13 -08:00
|
|
|
SDL_OutOfMemory();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
rdata->shader_format_count = nFormats;
|
|
|
|
#ifdef ZUNE_HD
|
|
|
|
rdata->shader_formats[0] = GL_NVIDIA_PLATFORM_BINARY_NV;
|
|
|
|
#else /* !ZUNE_HD */
|
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT
This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.
The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION
So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.
The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.
I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
|
|
|
rdata->glGetIntegerv(GL_SHADER_BINARY_FORMATS, (GLint *)rdata->shader_formats);
|
|
|
|
if (rdata->glGetError() != GL_NO_ERROR)
|
2011-02-06 00:00:13 -08:00
|
|
|
{
|
2011-02-06 10:22:25 -08:00
|
|
|
GLES2_DestroyRenderer(renderer);
|
2011-02-06 00:00:13 -08:00
|
|
|
SDL_SetError("Failed to query supported shader formats");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (hasCompiler)
|
|
|
|
rdata->shader_formats[nFormats - 1] = (GLenum)-1;
|
|
|
|
#endif /* ZUNE_HD */
|
|
|
|
|
2012-01-18 22:45:49 -05:00
|
|
|
rdata->framebuffers = NULL;
|
2012-01-30 20:56:25 -05:00
|
|
|
rdata->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &window_framebuffer);
|
|
|
|
rdata->window_framebuffer = (GLuint)window_framebuffer;
|
2012-01-18 22:45:49 -05:00
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
/* Populate the function pointers for the module */
|
|
|
|
renderer->WindowEvent = &GLES2_WindowEvent;
|
|
|
|
renderer->CreateTexture = &GLES2_CreateTexture;
|
|
|
|
renderer->UpdateTexture = &GLES2_UpdateTexture;
|
|
|
|
renderer->LockTexture = &GLES2_LockTexture;
|
|
|
|
renderer->UnlockTexture = &GLES2_UnlockTexture;
|
2012-01-22 01:26:28 -05:00
|
|
|
renderer->SetRenderTarget = &GLES2_SetRenderTarget;
|
2011-02-15 13:59:59 -08:00
|
|
|
renderer->UpdateViewport = &GLES2_UpdateViewport;
|
2011-02-06 00:00:13 -08:00
|
|
|
renderer->RenderClear = &GLES2_RenderClear;
|
|
|
|
renderer->RenderDrawPoints = &GLES2_RenderDrawPoints;
|
|
|
|
renderer->RenderDrawLines = &GLES2_RenderDrawLines;
|
|
|
|
renderer->RenderFillRects = &GLES2_RenderFillRects;
|
|
|
|
renderer->RenderCopy = &GLES2_RenderCopy;
|
2011-10-31 02:55:21 -04:00
|
|
|
renderer->RenderReadPixels = &GLES2_RenderReadPixels;
|
2012-06-01 19:51:08 -03:00
|
|
|
renderer->RenderCopyEx = &GLES2_RenderCopyEx;
|
2011-02-06 00:00:13 -08:00
|
|
|
renderer->RenderPresent = &GLES2_RenderPresent;
|
|
|
|
renderer->DestroyTexture = &GLES2_DestroyTexture;
|
|
|
|
renderer->DestroyRenderer = &GLES2_DestroyRenderer;
|
2011-02-19 21:51:21 -08:00
|
|
|
|
|
|
|
GLES2_ResetState(renderer);
|
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
return renderer;
|
|
|
|
}
|
|
|
|
|
2011-02-08 10:04:09 -08:00
|
|
|
#endif /* SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED */
|
2011-02-06 00:00:13 -08:00
|
|
|
|
|
|
|
/* vi: set ts=4 sw=4 expandtab: */
|