2008-09-02 00:37:04 +00:00
|
|
|
/*
|
2011-04-08 13:03:26 -07:00
|
|
|
Simple DirectMedia Layer
|
2016-01-02 10:10:34 -08:00
|
|
|
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
2008-09-02 00:37:04 +00: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.
|
2008-09-02 00:37:04 +00: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:
|
2008-09-02 00:37:04 +00: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.
|
2008-09-02 00:37:04 +00:00
|
|
|
*/
|
2013-11-24 23:56:17 -05:00
|
|
|
#include "../../SDL_internal.h"
|
2008-09-02 00:37:04 +00:00
|
|
|
|
2011-02-08 10:04:09 -08:00
|
|
|
#if SDL_VIDEO_RENDER_OGL_ES && !SDL_RENDER_DISABLED
|
2008-09-02 00:37:04 +00:00
|
|
|
|
2011-03-13 11:18:35 -07:00
|
|
|
#include "SDL_hints.h"
|
2008-09-02 00:37:04 +00:00
|
|
|
#include "SDL_opengles.h"
|
2011-02-02 14:34:54 -08:00
|
|
|
#include "../SDL_sysrender.h"
|
2008-09-02 00:37:04 +00:00
|
|
|
|
2014-02-27 20:21:46 -03:00
|
|
|
/* To prevent unnecessary window recreation,
|
|
|
|
* these should match the defaults selected in SDL_GL_ResetAttributes
|
|
|
|
*/
|
|
|
|
|
2014-02-25 17:42:34 -03:00
|
|
|
#define RENDERER_CONTEXT_MAJOR 1
|
|
|
|
#define RENDERER_CONTEXT_MINOR 1
|
|
|
|
|
2011-02-01 21:40:03 -08:00
|
|
|
#if defined(SDL_VIDEO_DRIVER_PANDORA)
|
2009-06-05 07:30:51 +00:00
|
|
|
|
|
|
|
/* Empty function stub to get OpenGL ES 1.x support without */
|
|
|
|
/* OpenGL ES extension GL_OES_draw_texture supported */
|
2009-05-31 11:53:12 +00:00
|
|
|
GL_API void GL_APIENTRY
|
|
|
|
glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2009-06-05 07:30:51 +00:00
|
|
|
|
2015-06-05 19:41:18 +02:00
|
|
|
#endif /* SDL_VIDEO_DRIVER_PANDORA */
|
2009-05-31 11:53:12 +00:00
|
|
|
|
2008-09-02 00:37:04 +00:00
|
|
|
/* OpenGL ES 1.1 renderer implementation, based on the OpenGL renderer */
|
|
|
|
|
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);
|
|
|
|
|
2008-09-02 00:37:04 +00:00
|
|
|
static const float inv255f = 1.0f / 255.0f;
|
|
|
|
|
|
|
|
static SDL_Renderer *GLES_CreateRenderer(SDL_Window * window, Uint32 flags);
|
2011-02-01 19:19:43 -08:00
|
|
|
static void GLES_WindowEvent(SDL_Renderer * renderer,
|
|
|
|
const SDL_WindowEvent *event);
|
2014-12-01 07:31:22 -04:00
|
|
|
static int GLES_GetOutputSize(SDL_Renderer * renderer, int *w, int *h);
|
2008-09-02 00:37:04 +00:00
|
|
|
static int GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
|
|
|
|
static int GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
2008-09-15 04:32:36 +00:00
|
|
|
const SDL_Rect * rect, const void *pixels,
|
|
|
|
int pitch);
|
2008-09-02 00:37:04 +00:00
|
|
|
static int GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
2011-02-03 00:19:40 -08:00
|
|
|
const SDL_Rect * rect, void **pixels, int *pitch);
|
2008-09-15 04:32:36 +00:00
|
|
|
static void GLES_UnlockTexture(SDL_Renderer * renderer,
|
|
|
|
SDL_Texture * texture);
|
2012-01-22 01:26:28 -05:00
|
|
|
static int GLES_SetRenderTarget(SDL_Renderer * renderer,
|
2012-01-21 22:22:30 -05:00
|
|
|
SDL_Texture * texture);
|
2011-02-15 13:59:59 -08:00
|
|
|
static int GLES_UpdateViewport(SDL_Renderer * renderer);
|
2013-05-04 04:46:00 -07:00
|
|
|
static int GLES_UpdateClipRect(SDL_Renderer * renderer);
|
2011-02-17 02:23:48 -08:00
|
|
|
static int GLES_RenderClear(SDL_Renderer * renderer);
|
2010-01-13 04:58:31 +00:00
|
|
|
static int GLES_RenderDrawPoints(SDL_Renderer * renderer,
|
2012-10-01 20:59:33 -07:00
|
|
|
const SDL_FPoint * points, int count);
|
2010-01-13 04:58:31 +00:00
|
|
|
static int GLES_RenderDrawLines(SDL_Renderer * renderer,
|
2012-10-01 20:59:33 -07:00
|
|
|
const SDL_FPoint * points, int count);
|
2010-01-13 04:58:31 +00:00
|
|
|
static int GLES_RenderFillRects(SDL_Renderer * renderer,
|
2012-10-01 20:59:33 -07:00
|
|
|
const SDL_FRect * rects, int count);
|
2008-09-02 00:37:04 +00:00
|
|
|
static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
2008-09-15 04:32:36 +00:00
|
|
|
const SDL_Rect * srcrect,
|
2012-10-01 20:59:33 -07:00
|
|
|
const SDL_FRect * dstrect);
|
|
|
|
static int GLES_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
|
|
|
const SDL_Rect * srcrect, const SDL_FRect * dstrect,
|
|
|
|
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip);
|
2011-10-31 03:06:32 -04:00
|
|
|
static int GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|
|
|
Uint32 pixel_format, void * pixels, int pitch);
|
2008-09-02 00:37:04 +00:00
|
|
|
static void GLES_RenderPresent(SDL_Renderer * renderer);
|
2008-09-15 04:32:36 +00:00
|
|
|
static void GLES_DestroyTexture(SDL_Renderer * renderer,
|
|
|
|
SDL_Texture * texture);
|
2008-09-02 00:37:04 +00:00
|
|
|
static void GLES_DestroyRenderer(SDL_Renderer * renderer);
|
2012-09-03 11:16:12 -03:00
|
|
|
static int GLES_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh);
|
|
|
|
static int GLES_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture);
|
2012-01-18 22:45:49 -05:00
|
|
|
|
|
|
|
typedef struct GLES_FBOList GLES_FBOList;
|
|
|
|
|
|
|
|
struct GLES_FBOList
|
|
|
|
{
|
|
|
|
Uint32 w, h;
|
|
|
|
GLuint FBO;
|
|
|
|
GLES_FBOList *next;
|
|
|
|
};
|
2008-09-02 00:37:04 +00:00
|
|
|
|
|
|
|
|
2011-02-06 00:00:13 -08:00
|
|
|
SDL_RenderDriver GLES_RenderDriver = {
|
2008-09-02 00:37:04 +00:00
|
|
|
GLES_CreateRenderer,
|
|
|
|
{
|
2011-02-06 00:48:41 -08:00
|
|
|
"opengles",
|
2014-03-09 22:48:38 -07:00
|
|
|
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
|
2011-02-03 00:19:40 -08:00
|
|
|
1,
|
|
|
|
{SDL_PIXELFORMAT_ABGR8888},
|
2008-09-15 04:32:36 +00:00
|
|
|
0,
|
2008-09-02 00:37:04 +00:00
|
|
|
0}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
SDL_GLContext context;
|
2011-02-19 21:51:21 -08:00
|
|
|
struct {
|
|
|
|
Uint32 color;
|
|
|
|
int blendMode;
|
|
|
|
SDL_bool tex_coords;
|
|
|
|
} current;
|
2008-09-15 04:32:36 +00: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
|
|
|
#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
|
2013-08-16 13:37:27 -03:00
|
|
|
#define SDL_PROC_OES SDL_PROC
|
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
|
|
|
#include "SDL_glesfuncs.h"
|
|
|
|
#undef SDL_PROC
|
2013-08-16 13:37:27 -03:00
|
|
|
#undef SDL_PROC_OES
|
2012-01-18 22:45:49 -05:00
|
|
|
SDL_bool GL_OES_framebuffer_object_supported;
|
|
|
|
GLES_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
|
|
|
|
2013-07-23 08:06:49 -07:00
|
|
|
SDL_bool GL_OES_blend_func_separate_supported;
|
2008-09-02 00:37:04 +00:00
|
|
|
} GLES_RenderData;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GLuint texture;
|
|
|
|
GLenum type;
|
|
|
|
GLfloat texw;
|
|
|
|
GLfloat texh;
|
|
|
|
GLenum format;
|
|
|
|
GLenum formattype;
|
|
|
|
void *pixels;
|
|
|
|
int pitch;
|
2012-01-18 22:45:49 -05:00
|
|
|
GLES_FBOList *fbo;
|
2008-09-02 00:37:04 +00:00
|
|
|
} GLES_TextureData;
|
|
|
|
|
2013-03-31 12:48:50 -04:00
|
|
|
static int
|
2008-09-02 00:37:04 +00:00
|
|
|
GLES_SetError(const char *prefix, GLenum result)
|
|
|
|
{
|
|
|
|
const char *error;
|
|
|
|
|
|
|
|
switch (result) {
|
|
|
|
case GL_NO_ERROR:
|
|
|
|
error = "GL_NO_ERROR";
|
|
|
|
break;
|
|
|
|
case GL_INVALID_ENUM:
|
|
|
|
error = "GL_INVALID_ENUM";
|
|
|
|
break;
|
|
|
|
case GL_INVALID_VALUE:
|
|
|
|
error = "GL_INVALID_VALUE";
|
|
|
|
break;
|
|
|
|
case GL_INVALID_OPERATION:
|
|
|
|
error = "GL_INVALID_OPERATION";
|
|
|
|
break;
|
|
|
|
case GL_STACK_OVERFLOW:
|
|
|
|
error = "GL_STACK_OVERFLOW";
|
|
|
|
break;
|
|
|
|
case GL_STACK_UNDERFLOW:
|
|
|
|
error = "GL_STACK_UNDERFLOW";
|
|
|
|
break;
|
|
|
|
case GL_OUT_OF_MEMORY:
|
|
|
|
error = "GL_OUT_OF_MEMORY";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = "UNKNOWN";
|
|
|
|
break;
|
|
|
|
}
|
2013-03-31 12:48:50 -04:00
|
|
|
return SDL_SetError("%s: %s", prefix, error);
|
2008-09-02 00:37:04 +00: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
|
|
|
static int GLES_LoadFunctions(GLES_RenderData * 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
|
|
|
|
|
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
|
|
|
#ifdef __SDL_NOGETPROCADDR__
|
|
|
|
#define SDL_PROC(ret,func,params) data->func=func;
|
2013-08-16 12:51:29 -04:00
|
|
|
#define SDL_PROC_OES(ret,func,params) data->func=func;
|
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
|
|
|
#else
|
|
|
|
#define SDL_PROC(ret,func,params) \
|
|
|
|
do { \
|
|
|
|
data->func = SDL_GL_GetProcAddress(#func); \
|
|
|
|
if ( ! data->func ) { \
|
2013-03-31 12:48:50 -04:00
|
|
|
return SDL_SetError("Couldn't load GLES function %s: %s\n", #func, SDL_GetError()); \
|
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
|
|
|
} \
|
2013-05-18 14:17:52 -07:00
|
|
|
} while ( 0 );
|
2013-08-16 13:37:27 -03:00
|
|
|
#define SDL_PROC_OES(ret,func,params) \
|
|
|
|
do { \
|
|
|
|
data->func = SDL_GL_GetProcAddress(#func); \
|
|
|
|
} while ( 0 );
|
2015-06-05 19:41:18 +02:00
|
|
|
#endif /* __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
|
|
|
|
|
|
|
#include "SDL_glesfuncs.h"
|
|
|
|
#undef SDL_PROC
|
2013-08-16 13:37:27 -03:00
|
|
|
#undef SDL_PROC_OES
|
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
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-15 13:59:59 -08:00
|
|
|
static SDL_GLContext SDL_CurrentContext = NULL;
|
|
|
|
|
2012-01-18 22:45:49 -05:00
|
|
|
GLES_FBOList *
|
|
|
|
GLES_GetFBO(GLES_RenderData *data, Uint32 w, Uint32 h)
|
|
|
|
{
|
|
|
|
GLES_FBOList *result = data->framebuffers;
|
2015-05-16 17:35:36 -03:00
|
|
|
while ((result) && ((result->w != w) || (result->h != h)) ) {
|
2012-01-18 22:45:49 -05:00
|
|
|
result = result->next;
|
|
|
|
}
|
2015-05-16 17:35:36 -03:00
|
|
|
if (result == NULL) {
|
2012-01-18 22:45:49 -05:00
|
|
|
result = SDL_malloc(sizeof(GLES_FBOList));
|
|
|
|
result->w = w;
|
|
|
|
result->h = h;
|
2012-01-28 14:53:23 -05:00
|
|
|
data->glGenFramebuffersOES(1, &result->FBO);
|
2012-01-18 22:45:49 -05:00
|
|
|
result->next = data->framebuffers;
|
|
|
|
data->framebuffers = result;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-15 13:59:59 -08:00
|
|
|
static int
|
|
|
|
GLES_ActivateRenderer(SDL_Renderer * renderer)
|
|
|
|
{
|
|
|
|
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
|
|
|
|
|
|
|
if (SDL_CurrentContext != data->context) {
|
|
|
|
if (SDL_GL_MakeCurrent(renderer->window, data->context) < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
SDL_CurrentContext = data->context;
|
|
|
|
|
|
|
|
GLES_UpdateViewport(renderer);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-19 21:51:21 -08:00
|
|
|
/* This is called if we need to invalidate all of the SDL OpenGL state */
|
|
|
|
static void
|
|
|
|
GLES_ResetState(SDL_Renderer *renderer)
|
|
|
|
{
|
|
|
|
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
|
|
|
|
|
|
|
if (SDL_CurrentContext == data->context) {
|
|
|
|
GLES_UpdateViewport(renderer);
|
|
|
|
} else {
|
|
|
|
GLES_ActivateRenderer(renderer);
|
|
|
|
}
|
|
|
|
|
|
|
|
data->current.color = 0;
|
|
|
|
data->current.blendMode = -1;
|
|
|
|
data->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
|
|
|
data->glDisable(GL_DEPTH_TEST);
|
|
|
|
data->glDisable(GL_CULL_FACE);
|
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
|
|
|
data->glMatrixMode(GL_MODELVIEW);
|
|
|
|
data->glLoadIdentity();
|
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
|
|
|
data->glEnableClientState(GL_VERTEX_ARRAY);
|
|
|
|
data->glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
2011-02-19 21:51:21 -08:00
|
|
|
}
|
|
|
|
|
2008-09-02 00:37:04 +00:00
|
|
|
SDL_Renderer *
|
|
|
|
GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|
|
|
{
|
2008-09-15 04:32:36 +00:00
|
|
|
|
2008-09-02 00:37:04 +00:00
|
|
|
SDL_Renderer *renderer;
|
|
|
|
GLES_RenderData *data;
|
|
|
|
GLint value;
|
2014-06-22 02:48:43 -07:00
|
|
|
Uint32 window_flags;
|
2015-12-10 20:25:34 -04:00
|
|
|
int profile_mask = 0, major = 0, minor = 0;
|
2014-06-22 02:48:43 -07:00
|
|
|
SDL_bool changed_window = SDL_FALSE;
|
2013-12-19 06:01:18 +09:00
|
|
|
|
2014-02-25 17:42:34 -03:00
|
|
|
SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask);
|
|
|
|
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major);
|
|
|
|
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minor);
|
2013-05-18 14:17:52 -07:00
|
|
|
|
2014-06-22 02:48:43 -07:00
|
|
|
window_flags = SDL_GetWindowFlags(window);
|
|
|
|
if (!(window_flags & SDL_WINDOW_OPENGL) ||
|
2014-02-25 17:42:34 -03:00
|
|
|
profile_mask != SDL_GL_CONTEXT_PROFILE_ES || major != RENDERER_CONTEXT_MAJOR || minor != RENDERER_CONTEXT_MINOR) {
|
2014-02-27 20:21:46 -03:00
|
|
|
|
2014-06-22 02:48:43 -07:00
|
|
|
changed_window = SDL_TRUE;
|
2014-02-27 20:21:46 -03:00
|
|
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, RENDERER_CONTEXT_MAJOR);
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, RENDERER_CONTEXT_MINOR);
|
|
|
|
|
2014-06-22 02:48:43 -07:00
|
|
|
if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) {
|
|
|
|
goto error;
|
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
|
|
|
}
|
|
|
|
}
|
2008-09-02 00:37:04 +00:00
|
|
|
|
|
|
|
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
|
|
|
if (!renderer) {
|
|
|
|
SDL_OutOfMemory();
|
2014-06-22 02:48:43 -07:00
|
|
|
goto error;
|
2008-09-02 00:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
data = (GLES_RenderData *) SDL_calloc(1, sizeof(*data));
|
|
|
|
if (!data) {
|
|
|
|
GLES_DestroyRenderer(renderer);
|
|
|
|
SDL_OutOfMemory();
|
2014-06-22 02:48:43 -07:00
|
|
|
goto error;
|
2008-09-02 00:37:04 +00:00
|
|
|
}
|
|
|
|
|
2011-02-01 19:19:43 -08:00
|
|
|
renderer->WindowEvent = GLES_WindowEvent;
|
2014-12-01 07:31:22 -04:00
|
|
|
renderer->GetOutputSize = GLES_GetOutputSize;
|
2008-09-02 00:37:04 +00:00
|
|
|
renderer->CreateTexture = GLES_CreateTexture;
|
|
|
|
renderer->UpdateTexture = GLES_UpdateTexture;
|
|
|
|
renderer->LockTexture = GLES_LockTexture;
|
|
|
|
renderer->UnlockTexture = GLES_UnlockTexture;
|
2012-01-22 01:26:28 -05:00
|
|
|
renderer->SetRenderTarget = GLES_SetRenderTarget;
|
2011-02-15 13:59:59 -08:00
|
|
|
renderer->UpdateViewport = GLES_UpdateViewport;
|
2013-05-04 04:46:00 -07:00
|
|
|
renderer->UpdateClipRect = GLES_UpdateClipRect;
|
2011-02-17 02:23:48 -08:00
|
|
|
renderer->RenderClear = GLES_RenderClear;
|
2010-01-13 04:58:31 +00:00
|
|
|
renderer->RenderDrawPoints = GLES_RenderDrawPoints;
|
|
|
|
renderer->RenderDrawLines = GLES_RenderDrawLines;
|
|
|
|
renderer->RenderFillRects = GLES_RenderFillRects;
|
2008-09-02 00:37:04 +00:00
|
|
|
renderer->RenderCopy = GLES_RenderCopy;
|
2012-06-01 19:51:08 -03:00
|
|
|
renderer->RenderCopyEx = GLES_RenderCopyEx;
|
2012-10-01 20:59:33 -07:00
|
|
|
renderer->RenderReadPixels = GLES_RenderReadPixels;
|
2008-09-02 00:37:04 +00:00
|
|
|
renderer->RenderPresent = GLES_RenderPresent;
|
|
|
|
renderer->DestroyTexture = GLES_DestroyTexture;
|
|
|
|
renderer->DestroyRenderer = GLES_DestroyRenderer;
|
2012-09-03 11:16:12 -03:00
|
|
|
renderer->GL_BindTexture = GLES_BindTexture;
|
|
|
|
renderer->GL_UnbindTexture = GLES_UnbindTexture;
|
2011-02-06 00:00:13 -08:00
|
|
|
renderer->info = GLES_RenderDriver.info;
|
2012-01-21 22:22:30 -05:00
|
|
|
renderer->info.flags = SDL_RENDERER_ACCELERATED;
|
2011-02-15 13:59:59 -08:00
|
|
|
renderer->driverdata = data;
|
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;
|
2008-09-02 00:37:04 +00:00
|
|
|
|
2010-01-21 07:28:01 +00:00
|
|
|
data->context = SDL_GL_CreateContext(window);
|
2008-09-02 00:37:04 +00:00
|
|
|
if (!data->context) {
|
|
|
|
GLES_DestroyRenderer(renderer);
|
2014-06-22 02:48:43 -07:00
|
|
|
goto error;
|
2008-09-02 00:37:04 +00:00
|
|
|
}
|
2010-01-21 07:28:01 +00:00
|
|
|
if (SDL_GL_MakeCurrent(window, data->context) < 0) {
|
2008-09-02 00:37:04 +00:00
|
|
|
GLES_DestroyRenderer(renderer);
|
2014-06-22 02:48:43 -07:00
|
|
|
goto error;
|
2008-09-02 00:37:04 +00: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 (GLES_LoadFunctions(data) < 0) {
|
|
|
|
GLES_DestroyRenderer(renderer);
|
2014-06-22 02:48:43 -07:00
|
|
|
goto error;
|
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
|
|
|
}
|
|
|
|
|
2008-09-02 00:37:04 +00: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;
|
|
|
|
}
|
|
|
|
|
2012-01-31 21:03:35 -05:00
|
|
|
value = 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
|
|
|
data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
|
2008-09-02 00:37:04 +00:00
|
|
|
renderer->info.max_texture_width = value;
|
2012-01-31 21:03:35 -05:00
|
|
|
value = 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
|
|
|
data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
|
2008-09-02 00:37:04 +00:00
|
|
|
renderer->info.max_texture_height = value;
|
|
|
|
|
2013-08-16 14:38:04 -03:00
|
|
|
/* Android does not report GL_OES_framebuffer_object but the functionality seems to be there anyway */
|
|
|
|
if (SDL_GL_ExtensionSupported("GL_OES_framebuffer_object") || data->glGenFramebuffersOES) {
|
2012-01-18 22:45:49 -05:00
|
|
|
data->GL_OES_framebuffer_object_supported = SDL_TRUE;
|
2012-01-21 22:22:30 -05:00
|
|
|
renderer->info.flags |= SDL_RENDERER_TARGETTEXTURE;
|
2012-01-30 20:56:25 -05:00
|
|
|
|
2012-01-31 21:03:35 -05:00
|
|
|
value = 0;
|
2012-01-30 20:56:25 -05:00
|
|
|
data->glGetIntegerv(GL_FRAMEBUFFER_BINDING_OES, &value);
|
|
|
|
data->window_framebuffer = (GLuint)value;
|
2012-01-18 22:45:49 -05:00
|
|
|
}
|
|
|
|
data->framebuffers = NULL;
|
|
|
|
|
2013-07-23 08:06:49 -07:00
|
|
|
if (SDL_GL_ExtensionSupported("GL_OES_blend_func_separate")) {
|
|
|
|
data->GL_OES_blend_func_separate_supported = SDL_TRUE;
|
|
|
|
}
|
|
|
|
|
2008-09-02 00:37:04 +00:00
|
|
|
/* Set up parameters for rendering */
|
2011-02-19 21:51:21 -08:00
|
|
|
GLES_ResetState(renderer);
|
2008-09-02 00:37:04 +00:00
|
|
|
|
|
|
|
return renderer;
|
2014-06-22 02:48:43 -07:00
|
|
|
|
|
|
|
error:
|
|
|
|
if (changed_window) {
|
|
|
|
/* Uh oh, better try to put it back... */
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profile_mask);
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major);
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor);
|
|
|
|
SDL_RecreateWindow(window, window_flags);
|
|
|
|
}
|
|
|
|
return NULL;
|
2008-09-02 00:37:04 +00:00
|
|
|
}
|
|
|
|
|
2011-02-01 19:19:43 -08:00
|
|
|
static void
|
|
|
|
GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
|
2008-09-02 00:37:04 +00:00
|
|
|
{
|
2012-01-08 13:31:22 -05:00
|
|
|
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
2013-05-18 14:17:52 -07: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-01 19:19:43 -08:00
|
|
|
/* Rebind the context to the window area and update matrices */
|
|
|
|
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! */
|
2012-01-18 22:45:49 -05:00
|
|
|
data->glFinish();
|
2011-11-07 23:07:00 -05:00
|
|
|
}
|
2008-09-02 00:37:04 +00:00
|
|
|
}
|
|
|
|
|
2014-12-01 07:31:22 -04:00
|
|
|
static int
|
|
|
|
GLES_GetOutputSize(SDL_Renderer * renderer, int *w, int *h)
|
|
|
|
{
|
|
|
|
SDL_GL_GetDrawableSize(renderer->window, w, h);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-10-20 21:56:15 -07:00
|
|
|
static SDL_INLINE int
|
2008-09-02 00:37:04 +00:00
|
|
|
power_of_2(int input)
|
|
|
|
{
|
|
|
|
int value = 1;
|
|
|
|
|
|
|
|
while (value < input) {
|
|
|
|
value <<= 1;
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-02 00:37:04 +00:00
|
|
|
static int
|
2009-05-23 22:41:08 +00:00
|
|
|
GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
2008-09-02 00:37:04 +00: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
|
|
|
GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
|
2008-09-02 00:37:04 +00:00
|
|
|
GLES_TextureData *data;
|
|
|
|
GLint internalFormat;
|
|
|
|
GLenum format, type;
|
|
|
|
int texture_w, texture_h;
|
2011-03-21 17:15:49 -07:00
|
|
|
GLenum scaleMode;
|
2008-09-02 00:37:04 +00:00
|
|
|
GLenum result;
|
Date: Mon, 23 Mar 2009 09:17:24 +0200
From: "Mike Gorchak"
Subject: New QNX patches
Please apply patch qnx4.diff, which is attached. What has been done:
1)Added back OpenGL ES renderer for QNX target. Added few corrections to
OpenGL ES renderer to let it work under QNX. OpenGL ES renderer do not
support textures under QNX, so I think some additional work must be done.
2) Added GL_OES_query_matrix extension to SDL_opengles.h header file, which
required by OpenGL ES 1.1 specification.
3) Added attribute clearing at the entrance of function
SDL_GL_GetAttribure(). Added error checking into the function
SDL_GL_GetAttribure(), because some attributes can't be obtained in OpenGL
ES 1.0.
4) Porting testdyngles to OpenGL ES 1.0 (1.1 has glColor4ub() and
glColor4f() functions, but 1.0 has glColor4f() only).
5) Added error checking after obtaining attributes using
SDL_GL_GetAttribute() function to the testgl2 and testgles.
6) Small correction to testmultiaudio with printing errors.
7) Added software and accelerated OpenGL ES 1.0 support into the QNX GF
driver.
Please remove ./src/audio/nto directory - it will not be used anymore.
Please create ./src/audio/qsa directory and add content of the archive
qsa.tar.gz into this directory. I rewrote some sound code, added support for
multiple audio cards, enumeration, etc. Added initial support for capture.
As far as I can understand SDL 1.3 is not supporting audio capture right now
? Sam, Am I right ? Or audio capture must be supported through the
PlayDevice routine ?
And last, please put file SDL_gf_opengles.c to the ./src/video/qnxgf
directory. It is OpenGL ES 1.1 emulation layer for some functions, which are
not supported by OpenGL ES 1.0.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403566
2009-03-24 10:33:12 +00:00
|
|
|
|
2011-02-01 19:19:43 -08:00
|
|
|
GLES_ActivateRenderer(renderer);
|
|
|
|
|
2008-09-15 04:32:36 +00:00
|
|
|
switch (texture->format) {
|
|
|
|
case SDL_PIXELFORMAT_ABGR8888:
|
2009-05-23 22:41:08 +00:00
|
|
|
internalFormat = GL_RGBA;
|
|
|
|
format = GL_RGBA;
|
|
|
|
type = GL_UNSIGNED_BYTE;
|
|
|
|
break;
|
2008-09-15 04:32:36 +00:00
|
|
|
default:
|
2013-03-31 12:48:50 -04:00
|
|
|
return SDL_SetError("Texture format not supported");
|
2008-09-15 04:32:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
data = (GLES_TextureData *) SDL_calloc(1, sizeof(*data));
|
2008-09-02 00:37:04 +00:00
|
|
|
if (!data) {
|
2013-03-31 12:48:50 -04:00
|
|
|
return SDL_OutOfMemory();
|
2008-09-02 00:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
|
|
|
|
data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
|
2011-02-26 21:39:34 -08:00
|
|
|
data->pixels = SDL_calloc(1, texture->h * data->pitch);
|
2008-09-02 00:37:04 +00:00
|
|
|
if (!data->pixels) {
|
|
|
|
SDL_free(data);
|
2013-03-31 12:48:50 -04:00
|
|
|
return SDL_OutOfMemory();
|
2008-09-02 00:37:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-16 13:37:27 -03:00
|
|
|
|
2012-01-18 22:45:49 -05:00
|
|
|
if (texture->access == SDL_TEXTUREACCESS_TARGET) {
|
2013-08-16 13:37:27 -03:00
|
|
|
if (!renderdata->GL_OES_framebuffer_object_supported) {
|
|
|
|
SDL_free(data);
|
|
|
|
return SDL_SetError("GL_OES_framebuffer_object not supported");
|
|
|
|
}
|
|
|
|
data->fbo = GLES_GetFBO(renderer->driverdata, texture->w, texture->h);
|
2012-01-18 22:45:49 -05:00
|
|
|
} else {
|
2013-08-16 13:37:27 -03:00
|
|
|
data->fbo = NULL;
|
2012-01-18 22:45:49 -05:00
|
|
|
}
|
2013-08-16 13:37:27 -03:00
|
|
|
|
2008-09-02 00:37:04 +00: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
|
|
|
renderdata->glGetError();
|
|
|
|
renderdata->glEnable(GL_TEXTURE_2D);
|
|
|
|
renderdata->glGenTextures(1, &data->texture);
|
2013-08-10 10:49:26 -07:00
|
|
|
result = renderdata->glGetError();
|
|
|
|
if (result != GL_NO_ERROR) {
|
|
|
|
SDL_free(data);
|
|
|
|
return GLES_SetError("glGenTextures()", result);
|
|
|
|
}
|
2008-09-15 04:32:36 +00:00
|
|
|
|
|
|
|
data->type = GL_TEXTURE_2D;
|
|
|
|
/* no NPOV textures allowed in OpenGL ES (yet) */
|
|
|
|
texture_w = power_of_2(texture->w);
|
|
|
|
texture_h = power_of_2(texture->h);
|
|
|
|
data->texw = (GLfloat) texture->w / texture_w;
|
|
|
|
data->texh = (GLfloat) texture->h / texture_h;
|
|
|
|
|
2008-09-02 00:37:04 +00:00
|
|
|
data->format = format;
|
|
|
|
data->formattype = type;
|
2011-03-21 17:15:49 -07:00
|
|
|
scaleMode = GetScaleQuality();
|
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
|
|
|
renderdata->glBindTexture(data->type, data->texture);
|
|
|
|
renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, scaleMode);
|
|
|
|
renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, scaleMode);
|
|
|
|
renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
|
|
renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
2008-09-15 04:32:36 +00: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
|
|
|
renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w,
|
2008-09-15 04:32:36 +00:00
|
|
|
texture_h, 0, format, type, 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
|
|
|
renderdata->glDisable(GL_TEXTURE_2D);
|
2008-09-02 00:37:04 +00: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
|
|
|
result = renderdata->glGetError();
|
2008-09-02 00:37:04 +00:00
|
|
|
if (result != GL_NO_ERROR) {
|
2013-08-16 13:37:27 -03:00
|
|
|
SDL_free(data);
|
2013-03-31 12:48:50 -04:00
|
|
|
return GLES_SetError("glTexImage2D()", result);
|
2008-09-02 00:37:04 +00:00
|
|
|
}
|
2013-08-16 13:37:27 -03:00
|
|
|
|
|
|
|
texture->driverdata = data;
|
2008-09-02 00:37:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-05-23 22:41:08 +00:00
|
|
|
GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|
|
|
const SDL_Rect * rect, const void *pixels, int pitch)
|
2008-09-02 00:37:04 +00: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
|
|
|
GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
|
2008-09-02 00:37:04 +00:00
|
|
|
GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
|
2011-02-08 10:38:12 -08:00
|
|
|
Uint8 *blob = NULL;
|
|
|
|
Uint8 *src;
|
|
|
|
int srcPitch;
|
|
|
|
int y;
|
2008-09-02 00:37:04 +00:00
|
|
|
|
2011-02-01 19:19:43 -08:00
|
|
|
GLES_ActivateRenderer(renderer);
|
|
|
|
|
2011-02-08 10:38:12 -08:00
|
|
|
/* Bail out if we're supposed to update an empty rectangle */
|
2015-05-16 17:35:36 -03:00
|
|
|
if (rect->w <= 0 || rect->h <= 0) {
|
2011-02-08 10:38:12 -08:00
|
|
|
return 0;
|
2015-05-16 17:35:36 -03:00
|
|
|
}
|
2011-01-19 23:47:50 -08:00
|
|
|
|
2011-02-08 10:38:12 -08:00
|
|
|
/* Reformat the texture data into a tightly packed array */
|
|
|
|
srcPitch = rect->w * SDL_BYTESPERPIXEL(texture->format);
|
|
|
|
src = (Uint8 *)pixels;
|
2013-03-31 12:48:50 -04:00
|
|
|
if (pitch != srcPitch) {
|
2011-02-08 10:38:12 -08:00
|
|
|
blob = (Uint8 *)SDL_malloc(srcPitch * rect->h);
|
2013-03-31 12:48:50 -04:00
|
|
|
if (!blob) {
|
|
|
|
return SDL_OutOfMemory();
|
2011-02-08 10:38:12 -08:00
|
|
|
}
|
|
|
|
src = blob;
|
2013-03-31 12:48:50 -04:00
|
|
|
for (y = 0; y < rect->h; ++y) {
|
2011-02-08 10:38:12 -08:00
|
|
|
SDL_memcpy(src, pixels, srcPitch);
|
|
|
|
src += srcPitch;
|
|
|
|
pixels = (Uint8 *)pixels + pitch;
|
|
|
|
}
|
|
|
|
src = blob;
|
2011-01-19 23:47:50 -08:00
|
|
|
}
|
|
|
|
|
2011-02-08 10:38:12 -08:00
|
|
|
/* 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
|
|
|
renderdata->glGetError();
|
|
|
|
renderdata->glEnable(data->type);
|
|
|
|
renderdata->glBindTexture(data->type, data->texture);
|
|
|
|
renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
|
|
|
renderdata->glTexSubImage2D(data->type,
|
2011-02-08 10:38:12 -08:00
|
|
|
0,
|
|
|
|
rect->x,
|
|
|
|
rect->y,
|
|
|
|
rect->w,
|
|
|
|
rect->h,
|
|
|
|
data->format,
|
|
|
|
data->formattype,
|
|
|
|
src);
|
2013-08-29 08:29:21 -07:00
|
|
|
SDL_free(blob);
|
2011-01-19 23:47:50 -08:00
|
|
|
|
2015-05-16 17:35:36 -03:00
|
|
|
if (renderdata->glGetError() != GL_NO_ERROR) {
|
2013-03-31 12:48:50 -04:00
|
|
|
return SDL_SetError("Failed to update texture");
|
2008-09-02 00:37:04 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
2011-02-03 00:19:40 -08:00
|
|
|
const SDL_Rect * rect, void **pixels, int *pitch)
|
2008-09-02 00:37:04 +00:00
|
|
|
{
|
|
|
|
GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
|
|
|
|
|
|
|
|
*pixels =
|
|
|
|
(void *) ((Uint8 *) data->pixels + rect->y * data->pitch +
|
|
|
|
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
|
|
|
*pitch = data->pitch;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
GLES_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|
|
|
{
|
|
|
|
GLES_TextureData *data = (GLES_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;
|
|
|
|
GLES_UpdateTexture(renderer, texture, &rect, data->pixels, data->pitch);
|
2008-09-02 00:37:04 +00:00
|
|
|
}
|
|
|
|
|
2012-01-21 22:22:30 -05:00
|
|
|
static int
|
2012-01-22 01:26:28 -05:00
|
|
|
GLES_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
2012-01-21 22:22:30 -05:00
|
|
|
{
|
|
|
|
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
|
|
|
GLES_TextureData *texturedata = NULL;
|
|
|
|
GLenum status;
|
|
|
|
|
|
|
|
GLES_ActivateRenderer(renderer);
|
2015-05-16 17:35:36 -03:00
|
|
|
|
2013-08-16 13:37:27 -03:00
|
|
|
if (!data->GL_OES_framebuffer_object_supported) {
|
|
|
|
return SDL_SetError("Can't enable render target support in this renderer");
|
|
|
|
}
|
2012-01-21 22:22:30 -05:00
|
|
|
|
|
|
|
if (texture == NULL) {
|
2012-01-30 20:56:25 -05:00
|
|
|
data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, data->window_framebuffer);
|
2012-01-21 22:22:30 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
texturedata = (GLES_TextureData *) texture->driverdata;
|
|
|
|
data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, texturedata->fbo->FBO);
|
|
|
|
/* TODO: check if texture pixel format allows this operation */
|
|
|
|
data->glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, texturedata->type, texturedata->texture, 0);
|
|
|
|
/* Check FBO status */
|
|
|
|
status = data->glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
|
|
|
|
if (status != GL_FRAMEBUFFER_COMPLETE_OES) {
|
2013-03-31 12:48:50 -04:00
|
|
|
return SDL_SetError("glFramebufferTexture2DOES() failed");
|
2012-01-21 22:22:30 -05:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-15 13:59:59 -08:00
|
|
|
static int
|
|
|
|
GLES_UpdateViewport(SDL_Renderer * renderer)
|
2011-02-07 20:06:26 -08:00
|
|
|
{
|
2011-02-15 13:59:59 -08:00
|
|
|
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
2011-02-07 20:06:26 -08:00
|
|
|
|
2011-02-15 13:59:59 -08:00
|
|
|
if (SDL_CurrentContext != data->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
|
|
|
|
2015-05-28 18:57:10 -07:00
|
|
|
if (renderer->target) {
|
|
|
|
data->glViewport(renderer->viewport.x, renderer->viewport.y,
|
|
|
|
renderer->viewport.w, renderer->viewport.h);
|
|
|
|
} else {
|
|
|
|
int w, h;
|
|
|
|
|
|
|
|
SDL_GetRendererOutputSize(renderer, &w, &h);
|
|
|
|
data->glViewport(renderer->viewport.x, (h - renderer->viewport.y - renderer->viewport.h),
|
|
|
|
renderer->viewport.w, renderer->viewport.h);
|
|
|
|
}
|
2011-02-15 13:59:59 -08:00
|
|
|
|
2013-05-29 03:07:55 -07:00
|
|
|
if (renderer->viewport.w && renderer->viewport.h) {
|
|
|
|
data->glMatrixMode(GL_PROJECTION);
|
|
|
|
data->glLoadIdentity();
|
|
|
|
data->glOrthof((GLfloat) 0,
|
|
|
|
(GLfloat) renderer->viewport.w,
|
|
|
|
(GLfloat) renderer->viewport.h,
|
|
|
|
(GLfloat) 0, 0.0, 1.0);
|
|
|
|
}
|
2011-02-15 13:59:59 -08:00
|
|
|
return 0;
|
2011-02-07 20:06:26 -08:00
|
|
|
}
|
|
|
|
|
2013-05-04 04:46:00 -07:00
|
|
|
static int
|
|
|
|
GLES_UpdateClipRect(SDL_Renderer * renderer)
|
|
|
|
{
|
2013-05-10 10:31:01 -03:00
|
|
|
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
2013-05-04 04:46:00 -07:00
|
|
|
|
2013-05-10 10:31:01 -03:00
|
|
|
if (SDL_CurrentContext != data->context) {
|
|
|
|
/* We'll update the clip rect after we rebind the context */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-04-19 13:15:41 -07:00
|
|
|
if (renderer->clipping_enabled) {
|
|
|
|
const SDL_Rect *rect = &renderer->clip_rect;
|
2013-05-10 10:31:01 -03:00
|
|
|
data->glEnable(GL_SCISSOR_TEST);
|
2015-05-28 18:57:10 -07:00
|
|
|
if (renderer->target) {
|
|
|
|
data->glScissor(renderer->viewport.x + rect->x, renderer->viewport.y + rect->y, rect->w, rect->h);
|
|
|
|
} else {
|
|
|
|
int w, h;
|
|
|
|
|
|
|
|
SDL_GetRendererOutputSize(renderer, &w, &h);
|
2015-12-28 15:15:58 -05:00
|
|
|
data->glScissor(renderer->viewport.x + rect->x, h - renderer->viewport.y - rect->y - rect->h, rect->w, rect->h);
|
2015-05-28 18:57:10 -07:00
|
|
|
}
|
2013-05-04 04:46:00 -07:00
|
|
|
} else {
|
2013-05-10 10:31:01 -03:00
|
|
|
data->glDisable(GL_SCISSOR_TEST);
|
2013-05-04 04:46:00 -07:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-19 21:51:21 -08:00
|
|
|
static void
|
|
|
|
GLES_SetColor(GLES_RenderData * data, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
2011-02-17 02:23:48 -08:00
|
|
|
{
|
2011-02-19 21:51:21 -08:00
|
|
|
Uint32 color = ((a << 24) | (r << 16) | (g << 8) | b);
|
|
|
|
|
|
|
|
if (color != data->current.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
|
|
|
data->glColor4f((GLfloat) r * inv255f,
|
2011-02-19 21:51:21 -08:00
|
|
|
(GLfloat) g * inv255f,
|
|
|
|
(GLfloat) b * inv255f,
|
|
|
|
(GLfloat) a * inv255f);
|
|
|
|
data->current.color = color;
|
|
|
|
}
|
2011-02-17 02:23:48 -08:00
|
|
|
}
|
|
|
|
|
2008-12-31 07:56:56 +00:00
|
|
|
static void
|
2011-01-31 23:23:57 -08:00
|
|
|
GLES_SetBlendMode(GLES_RenderData * data, int blendMode)
|
2008-12-31 07:56:56 +00:00
|
|
|
{
|
2011-02-19 21:51:21 -08:00
|
|
|
if (blendMode != data->current.blendMode) {
|
2008-12-31 07:56:56 +00:00
|
|
|
switch (blendMode) {
|
|
|
|
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
|
|
|
data->glDisable(GL_BLEND);
|
2008-12-31 07:56:56 +00: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
|
|
|
data->glEnable(GL_BLEND);
|
2013-07-23 08:06:49 -07:00
|
|
|
if (data->GL_OES_blend_func_separate_supported) {
|
|
|
|
data->glBlendFuncSeparateOES(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
} else {
|
|
|
|
data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
}
|
2008-12-31 07:56:56 +00: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
|
|
|
data->glEnable(GL_BLEND);
|
2013-07-23 08:06:49 -07:00
|
|
|
if (data->GL_OES_blend_func_separate_supported) {
|
|
|
|
data->glBlendFuncSeparateOES(GL_SRC_ALPHA, GL_ONE, GL_ZERO, GL_ONE);
|
|
|
|
} else {
|
|
|
|
data->glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
|
|
|
}
|
2008-12-31 07:56:56 +00:00
|
|
|
break;
|
2011-02-04 19:50:56 -08:00
|
|
|
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
|
|
|
data->glEnable(GL_BLEND);
|
2013-07-23 08:06:49 -07:00
|
|
|
if (data->GL_OES_blend_func_separate_supported) {
|
|
|
|
data->glBlendFuncSeparateOES(GL_ZERO, GL_SRC_COLOR, GL_ZERO, GL_ONE);
|
|
|
|
} else {
|
|
|
|
data->glBlendFunc(GL_ZERO, GL_SRC_COLOR);
|
|
|
|
}
|
2011-02-04 19:50:56 -08:00
|
|
|
break;
|
2008-12-31 07:56:56 +00:00
|
|
|
}
|
2011-02-19 21:51:21 -08:00
|
|
|
data->current.blendMode = blendMode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
GLES_SetTexCoords(GLES_RenderData * data, SDL_bool enabled)
|
|
|
|
{
|
|
|
|
if (enabled != data->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
|
|
|
data->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
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
|
|
|
data->glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
2011-02-19 21:51:21 -08:00
|
|
|
}
|
|
|
|
data->current.tex_coords = enabled;
|
2008-12-31 07:56:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-19 21:51:21 -08:00
|
|
|
static void
|
|
|
|
GLES_SetDrawingState(SDL_Renderer * renderer)
|
|
|
|
{
|
|
|
|
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
|
|
|
|
|
|
|
GLES_ActivateRenderer(renderer);
|
|
|
|
|
|
|
|
GLES_SetColor(data, (GLfloat) renderer->r,
|
|
|
|
(GLfloat) renderer->g,
|
|
|
|
(GLfloat) renderer->b,
|
|
|
|
(GLfloat) renderer->a);
|
|
|
|
|
|
|
|
GLES_SetBlendMode(data, renderer->blendMode);
|
|
|
|
|
|
|
|
GLES_SetTexCoords(data, SDL_FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
GLES_RenderClear(SDL_Renderer * renderer)
|
|
|
|
{
|
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
|
|
|
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
|
|
|
|
2011-02-19 21:51:21 -08:00
|
|
|
GLES_ActivateRenderer(renderer);
|
|
|
|
|
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
|
|
|
data->glClearColor((GLfloat) renderer->r * inv255f,
|
2011-02-19 21:51:21 -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
|
|
|
data->glClear(GL_COLOR_BUFFER_BIT);
|
2011-02-19 21:51:21 -08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-09-02 00:37:04 +00:00
|
|
|
static int
|
2012-10-01 20:59:33 -07:00
|
|
|
GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points,
|
2010-01-13 04:58:31 +00:00
|
|
|
int count)
|
2008-09-02 00:37:04 +00: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
|
|
|
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
Fixed bug 2421 - SDL_RenderCopyEx off by one when rotating by 90 and -90
chasesan
When using SDL_RenderCopyEx, I get a problem on some platforms where the output is offset by +/-1 on other platforms and not on others. I tried it with a center of both 0,0 (and offsetting by width/height) and NULL (for centered).
The rotation involved is 90, and/or -90 rotation. The rotation was a constant, no arithmetic was involved when inputting it into SDL_RenderCopyEx.
This occurred with 32x32, 24x24, and 16x16 texture sizes. I apologize that I don't have more precise information, as I received the information as a bug report myself. But I have tracked the problem down to here.
My program requires pixel perfect alignment on several different platforms, so this is something of a showstopper for me.
--
Sylvain
It appears the RenderCopyEx is done as expected,
this is the red rectangle which is not correctly positionned !
So, here's patch with a 0.5 float increment, like for opengles2, for DrawLines, and also Draw Points.
2014-07-07 23:26:34 -07:00
|
|
|
GLfloat *vertices;
|
|
|
|
int idx;
|
2008-12-31 07:56:56 +00:00
|
|
|
|
2011-02-19 21:51:21 -08:00
|
|
|
GLES_SetDrawingState(renderer);
|
2008-12-31 07:56:56 +00:00
|
|
|
|
Fixed bug 2421 - SDL_RenderCopyEx off by one when rotating by 90 and -90
chasesan
When using SDL_RenderCopyEx, I get a problem on some platforms where the output is offset by +/-1 on other platforms and not on others. I tried it with a center of both 0,0 (and offsetting by width/height) and NULL (for centered).
The rotation involved is 90, and/or -90 rotation. The rotation was a constant, no arithmetic was involved when inputting it into SDL_RenderCopyEx.
This occurred with 32x32, 24x24, and 16x16 texture sizes. I apologize that I don't have more precise information, as I received the information as a bug report myself. But I have tracked the problem down to here.
My program requires pixel perfect alignment on several different platforms, so this is something of a showstopper for me.
--
Sylvain
It appears the RenderCopyEx is done as expected,
this is the red rectangle which is not correctly positionned !
So, here's patch with a 0.5 float increment, like for opengles2, for DrawLines, and also Draw Points.
2014-07-07 23:26:34 -07:00
|
|
|
/* Emit the specified vertices as points */
|
|
|
|
vertices = SDL_stack_alloc(GLfloat, count * 2);
|
|
|
|
for (idx = 0; idx < count; ++idx) {
|
|
|
|
GLfloat x = points[idx].x + 0.5f;
|
|
|
|
GLfloat y = points[idx].y + 0.5f;
|
|
|
|
|
|
|
|
vertices[idx * 2] = x;
|
|
|
|
vertices[(idx * 2) + 1] = y;
|
|
|
|
}
|
2009-01-02 16:03:37 +00:00
|
|
|
|
Fixed bug 2421 - SDL_RenderCopyEx off by one when rotating by 90 and -90
chasesan
When using SDL_RenderCopyEx, I get a problem on some platforms where the output is offset by +/-1 on other platforms and not on others. I tried it with a center of both 0,0 (and offsetting by width/height) and NULL (for centered).
The rotation involved is 90, and/or -90 rotation. The rotation was a constant, no arithmetic was involved when inputting it into SDL_RenderCopyEx.
This occurred with 32x32, 24x24, and 16x16 texture sizes. I apologize that I don't have more precise information, as I received the information as a bug report myself. But I have tracked the problem down to here.
My program requires pixel perfect alignment on several different platforms, so this is something of a showstopper for me.
--
Sylvain
It appears the RenderCopyEx is done as expected,
this is the red rectangle which is not correctly positionned !
So, here's patch with a 0.5 float increment, like for opengles2, for DrawLines, and also Draw Points.
2014-07-07 23:26:34 -07:00
|
|
|
data->glVertexPointer(2, GL_FLOAT, 0, vertices);
|
|
|
|
data->glDrawArrays(GL_POINTS, 0, count);
|
|
|
|
SDL_stack_free(vertices);
|
2008-12-31 07:56:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2008-09-15 04:32:36 +00:00
|
|
|
|
2008-12-31 07:56:56 +00:00
|
|
|
static int
|
2012-10-01 20:59:33 -07:00
|
|
|
GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points,
|
2010-01-13 04:58:31 +00:00
|
|
|
int count)
|
2008-12-31 07:56:56 +00: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
|
|
|
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
Fixed bug 2421 - SDL_RenderCopyEx off by one when rotating by 90 and -90
chasesan
When using SDL_RenderCopyEx, I get a problem on some platforms where the output is offset by +/-1 on other platforms and not on others. I tried it with a center of both 0,0 (and offsetting by width/height) and NULL (for centered).
The rotation involved is 90, and/or -90 rotation. The rotation was a constant, no arithmetic was involved when inputting it into SDL_RenderCopyEx.
This occurred with 32x32, 24x24, and 16x16 texture sizes. I apologize that I don't have more precise information, as I received the information as a bug report myself. But I have tracked the problem down to here.
My program requires pixel perfect alignment on several different platforms, so this is something of a showstopper for me.
--
Sylvain
It appears the RenderCopyEx is done as expected,
this is the red rectangle which is not correctly positionned !
So, here's patch with a 0.5 float increment, like for opengles2, for DrawLines, and also Draw Points.
2014-07-07 23:26:34 -07:00
|
|
|
GLfloat *vertices;
|
|
|
|
int idx;
|
2008-09-15 04:32:36 +00:00
|
|
|
|
2011-02-19 21:51:21 -08:00
|
|
|
GLES_SetDrawingState(renderer);
|
2008-12-31 07:56:56 +00:00
|
|
|
|
Fixed bug 2421 - SDL_RenderCopyEx off by one when rotating by 90 and -90
chasesan
When using SDL_RenderCopyEx, I get a problem on some platforms where the output is offset by +/-1 on other platforms and not on others. I tried it with a center of both 0,0 (and offsetting by width/height) and NULL (for centered).
The rotation involved is 90, and/or -90 rotation. The rotation was a constant, no arithmetic was involved when inputting it into SDL_RenderCopyEx.
This occurred with 32x32, 24x24, and 16x16 texture sizes. I apologize that I don't have more precise information, as I received the information as a bug report myself. But I have tracked the problem down to here.
My program requires pixel perfect alignment on several different platforms, so this is something of a showstopper for me.
--
Sylvain
It appears the RenderCopyEx is done as expected,
this is the red rectangle which is not correctly positionned !
So, here's patch with a 0.5 float increment, like for opengles2, for DrawLines, and also Draw Points.
2014-07-07 23:26:34 -07:00
|
|
|
/* Emit a line strip including the specified vertices */
|
|
|
|
vertices = SDL_stack_alloc(GLfloat, count * 2);
|
|
|
|
for (idx = 0; idx < count; ++idx) {
|
|
|
|
GLfloat x = points[idx].x + 0.5f;
|
|
|
|
GLfloat y = points[idx].y + 0.5f;
|
|
|
|
|
|
|
|
vertices[idx * 2] = x;
|
|
|
|
vertices[(idx * 2) + 1] = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
data->glVertexPointer(2, GL_FLOAT, 0, vertices);
|
2013-05-18 14:17:52 -07:00
|
|
|
if (count > 2 &&
|
2009-12-09 15:56:56 +00:00
|
|
|
points[0].x == points[count-1].x && points[0].y == points[count-1].y) {
|
|
|
|
/* GL_LINE_LOOP takes care of the final segment */
|
|
|
|
--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
|
|
|
data->glDrawArrays(GL_LINE_LOOP, 0, count);
|
2009-12-09 15:56:56 +00: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
|
|
|
data->glDrawArrays(GL_LINE_STRIP, 0, count);
|
2011-11-10 00:22:44 -05:00
|
|
|
/* We need to close the endpoint of the line */
|
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
|
|
|
data->glDrawArrays(GL_POINTS, count-1, 1);
|
2009-12-09 15:56:56 +00:00
|
|
|
}
|
Fixed bug 2421 - SDL_RenderCopyEx off by one when rotating by 90 and -90
chasesan
When using SDL_RenderCopyEx, I get a problem on some platforms where the output is offset by +/-1 on other platforms and not on others. I tried it with a center of both 0,0 (and offsetting by width/height) and NULL (for centered).
The rotation involved is 90, and/or -90 rotation. The rotation was a constant, no arithmetic was involved when inputting it into SDL_RenderCopyEx.
This occurred with 32x32, 24x24, and 16x16 texture sizes. I apologize that I don't have more precise information, as I received the information as a bug report myself. But I have tracked the problem down to here.
My program requires pixel perfect alignment on several different platforms, so this is something of a showstopper for me.
--
Sylvain
It appears the RenderCopyEx is done as expected,
this is the red rectangle which is not correctly positionned !
So, here's patch with a 0.5 float increment, like for opengles2, for DrawLines, and also Draw Points.
2014-07-07 23:26:34 -07:00
|
|
|
SDL_stack_free(vertices);
|
2009-01-01 23:47:33 +00:00
|
|
|
|
2008-12-31 07:56:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2008-09-15 04:32:36 +00:00
|
|
|
|
2010-01-13 04:58:31 +00:00
|
|
|
static int
|
2012-10-01 20:59:33 -07:00
|
|
|
GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects,
|
2010-01-13 04:58:31 +00:00
|
|
|
int count)
|
2008-12-31 07:56:56 +00: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
|
|
|
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
2009-12-09 15:56:56 +00:00
|
|
|
int i;
|
2008-09-15 04:32:36 +00:00
|
|
|
|
2011-02-19 21:51:21 -08:00
|
|
|
GLES_SetDrawingState(renderer);
|
2008-09-15 04:32:36 +00:00
|
|
|
|
2009-12-09 15:56:56 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
2012-10-01 20:59:33 -07:00
|
|
|
const SDL_FRect *rect = &rects[i];
|
|
|
|
GLfloat minx = rect->x;
|
|
|
|
GLfloat maxx = rect->x + rect->w;
|
|
|
|
GLfloat miny = rect->y;
|
|
|
|
GLfloat maxy = rect->y + rect->h;
|
|
|
|
GLfloat vertices[8];
|
2009-12-09 15:56:56 +00:00
|
|
|
vertices[0] = minx;
|
|
|
|
vertices[1] = miny;
|
|
|
|
vertices[2] = maxx;
|
|
|
|
vertices[3] = miny;
|
|
|
|
vertices[4] = minx;
|
|
|
|
vertices[5] = maxy;
|
|
|
|
vertices[6] = maxx;
|
|
|
|
vertices[7] = maxy;
|
|
|
|
|
2012-10-01 20:59:33 -07:00
|
|
|
data->glVertexPointer(2, GL_FLOAT, 0, 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
|
|
|
data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
2009-12-09 15:56:56 +00:00
|
|
|
}
|
2009-01-01 23:47:33 +00:00
|
|
|
|
2008-09-15 04:32:36 +00:00
|
|
|
return 0;
|
2008-09-02 00:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
2012-10-01 20:59:33 -07:00
|
|
|
const SDL_Rect * srcrect, const SDL_FRect * dstrect)
|
2008-09-02 00:37:04 +00:00
|
|
|
{
|
|
|
|
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
|
|
|
GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
|
2012-10-01 20:59:33 -07:00
|
|
|
GLfloat minx, miny, maxx, maxy;
|
2008-09-02 00:37:04 +00:00
|
|
|
GLfloat minu, maxu, minv, maxv;
|
2013-08-21 10:12:16 -03:00
|
|
|
GLfloat vertices[8];
|
|
|
|
GLfloat texCoords[8];
|
2008-09-15 04:32:36 +00:00
|
|
|
|
2011-02-01 19:19:43 -08:00
|
|
|
GLES_ActivateRenderer(renderer);
|
|
|
|
|
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
|
|
|
data->glEnable(GL_TEXTURE_2D);
|
2009-05-14 10:54:34 +00: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
|
|
|
data->glBindTexture(texturedata->type, texturedata->texture);
|
2008-09-15 04:32:36 +00:00
|
|
|
|
2008-09-02 00:37:04 +00:00
|
|
|
if (texture->modMode) {
|
2011-02-19 21:51:21 -08:00
|
|
|
GLES_SetColor(data, texture->r, texture->g, texture->b, texture->a);
|
2008-09-02 00:37:04 +00:00
|
|
|
} else {
|
2011-02-19 21:51:21 -08:00
|
|
|
GLES_SetColor(data, 255, 255, 255, 255);
|
2008-09-02 00:37:04 +00:00
|
|
|
}
|
|
|
|
|
2011-01-31 23:23:57 -08:00
|
|
|
GLES_SetBlendMode(data, texture->blendMode);
|
2008-09-02 00:37:04 +00:00
|
|
|
|
2011-02-19 21:51:21 -08:00
|
|
|
GLES_SetTexCoords(data, SDL_TRUE);
|
|
|
|
|
2016-10-01 10:43:01 -07:00
|
|
|
minx = dstrect->x;
|
|
|
|
miny = dstrect->y;
|
|
|
|
maxx = dstrect->x + dstrect->w;
|
|
|
|
maxy = dstrect->y + dstrect->h;
|
|
|
|
|
|
|
|
minu = (GLfloat) srcrect->x / texture->w;
|
|
|
|
minu *= texturedata->texw;
|
|
|
|
maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
|
|
|
|
maxu *= texturedata->texw;
|
|
|
|
minv = (GLfloat) srcrect->y / texture->h;
|
|
|
|
minv *= texturedata->texh;
|
|
|
|
maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
|
|
|
|
maxv *= texturedata->texh;
|
|
|
|
|
|
|
|
vertices[0] = minx;
|
|
|
|
vertices[1] = miny;
|
|
|
|
vertices[2] = maxx;
|
|
|
|
vertices[3] = miny;
|
|
|
|
vertices[4] = minx;
|
|
|
|
vertices[5] = maxy;
|
|
|
|
vertices[6] = maxx;
|
|
|
|
vertices[7] = maxy;
|
|
|
|
|
|
|
|
texCoords[0] = minu;
|
|
|
|
texCoords[1] = minv;
|
|
|
|
texCoords[2] = maxu;
|
|
|
|
texCoords[3] = minv;
|
|
|
|
texCoords[4] = minu;
|
|
|
|
texCoords[5] = maxv;
|
|
|
|
texCoords[6] = maxu;
|
|
|
|
texCoords[7] = maxv;
|
2008-09-15 04:32:36 +00:00
|
|
|
|
2016-10-01 10:43:01 -07:00
|
|
|
data->glVertexPointer(2, GL_FLOAT, 0, vertices);
|
|
|
|
data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
|
|
|
|
data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
2008-09-15 04:32:36 +00: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
|
|
|
data->glDisable(GL_TEXTURE_2D);
|
2009-05-14 10:54:34 +00:00
|
|
|
|
2008-09-02 00:37:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-06-01 19:51:08 -03:00
|
|
|
static int
|
|
|
|
GLES_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
2012-10-01 20:59:33 -07:00
|
|
|
const SDL_Rect * srcrect, const SDL_FRect * dstrect,
|
|
|
|
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
|
2012-06-01 19:51:08 -03:00
|
|
|
{
|
|
|
|
|
|
|
|
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
|
|
|
GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
|
2012-10-01 20:59:33 -07:00
|
|
|
GLfloat minx, miny, maxx, maxy;
|
2012-06-01 19:51:08 -03:00
|
|
|
GLfloat minu, maxu, minv, maxv;
|
|
|
|
GLfloat centerx, centery;
|
2013-08-21 10:12:16 -03:00
|
|
|
GLfloat vertices[8];
|
|
|
|
GLfloat texCoords[8];
|
|
|
|
|
2013-05-18 14:17:52 -07:00
|
|
|
|
2012-06-01 19:51:08 -03:00
|
|
|
GLES_ActivateRenderer(renderer);
|
|
|
|
|
|
|
|
data->glEnable(GL_TEXTURE_2D);
|
|
|
|
|
|
|
|
data->glBindTexture(texturedata->type, texturedata->texture);
|
|
|
|
|
|
|
|
if (texture->modMode) {
|
|
|
|
GLES_SetColor(data, texture->r, texture->g, texture->b, texture->a);
|
|
|
|
} else {
|
|
|
|
GLES_SetColor(data, 255, 255, 255, 255);
|
|
|
|
}
|
|
|
|
|
|
|
|
GLES_SetBlendMode(data, texture->blendMode);
|
|
|
|
|
|
|
|
GLES_SetTexCoords(data, SDL_TRUE);
|
|
|
|
|
2012-10-01 20:59:33 -07:00
|
|
|
centerx = center->x;
|
|
|
|
centery = center->y;
|
2012-06-01 19:51:08 -03:00
|
|
|
|
2013-05-18 14:17:52 -07:00
|
|
|
/* Rotate and translate */
|
2012-06-01 19:51:08 -03:00
|
|
|
data->glPushMatrix();
|
2012-10-01 20:59:33 -07:00
|
|
|
data->glTranslatef(dstrect->x + centerx, dstrect->y + centery, 0.0f);
|
|
|
|
data->glRotatef((GLfloat)angle, 0.0f, 0.0f, 1.0f);
|
2012-06-01 19:51:08 -03:00
|
|
|
|
|
|
|
if (flip & SDL_FLIP_HORIZONTAL) {
|
2012-10-01 20:59:33 -07:00
|
|
|
minx = dstrect->w - centerx;
|
2012-06-01 19:51:08 -03:00
|
|
|
maxx = -centerx;
|
2012-10-01 20:59:33 -07:00
|
|
|
} else {
|
2012-06-01 19:51:08 -03:00
|
|
|
minx = -centerx;
|
|
|
|
maxx = dstrect->w - centerx;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flip & SDL_FLIP_VERTICAL) {
|
|
|
|
miny = dstrect->h - centery;
|
|
|
|
maxy = -centery;
|
2012-10-01 20:59:33 -07:00
|
|
|
} else {
|
2012-06-01 19:51:08 -03:00
|
|
|
miny = -centery;
|
|
|
|
maxy = dstrect->h - centery;
|
|
|
|
}
|
|
|
|
|
|
|
|
minu = (GLfloat) srcrect->x / texture->w;
|
|
|
|
minu *= texturedata->texw;
|
|
|
|
maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
|
|
|
|
maxu *= texturedata->texw;
|
|
|
|
minv = (GLfloat) srcrect->y / texture->h;
|
|
|
|
minv *= texturedata->texh;
|
|
|
|
maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
|
|
|
|
maxv *= texturedata->texh;
|
|
|
|
|
|
|
|
vertices[0] = minx;
|
|
|
|
vertices[1] = miny;
|
|
|
|
vertices[2] = maxx;
|
|
|
|
vertices[3] = miny;
|
|
|
|
vertices[4] = minx;
|
|
|
|
vertices[5] = maxy;
|
|
|
|
vertices[6] = maxx;
|
|
|
|
vertices[7] = maxy;
|
|
|
|
|
|
|
|
texCoords[0] = minu;
|
|
|
|
texCoords[1] = minv;
|
|
|
|
texCoords[2] = maxu;
|
|
|
|
texCoords[3] = minv;
|
|
|
|
texCoords[4] = minu;
|
|
|
|
texCoords[5] = maxv;
|
|
|
|
texCoords[6] = maxu;
|
|
|
|
texCoords[7] = maxv;
|
2012-10-01 20:59:33 -07:00
|
|
|
data->glVertexPointer(2, GL_FLOAT, 0, vertices);
|
2012-06-01 19:51:08 -03:00
|
|
|
data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
|
|
|
|
data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
|
|
data->glPopMatrix();
|
|
|
|
data->glDisable(GL_TEXTURE_2D);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-01 20:59:33 -07:00
|
|
|
static int
|
|
|
|
GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|
|
|
Uint32 pixel_format, void * pixels, int pitch)
|
|
|
|
{
|
|
|
|
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
|
|
|
Uint32 temp_format = SDL_PIXELFORMAT_ABGR8888;
|
|
|
|
void *temp_pixels;
|
|
|
|
int temp_pitch;
|
|
|
|
Uint8 *src, *dst, *tmp;
|
|
|
|
int w, h, length, rows;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
GLES_ActivateRenderer(renderer);
|
|
|
|
|
|
|
|
temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
|
|
|
temp_pixels = SDL_malloc(rect->h * temp_pitch);
|
|
|
|
if (!temp_pixels) {
|
2013-03-31 12:48:50 -04:00
|
|
|
return SDL_OutOfMemory();
|
2012-10-01 20:59:33 -07:00
|
|
|
}
|
|
|
|
|
2013-07-12 00:55:04 -07:00
|
|
|
SDL_GetRendererOutputSize(renderer, &w, &h);
|
2012-10-01 20:59:33 -07:00
|
|
|
|
|
|
|
data->glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
|
|
|
|
|
|
|
data->glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h,
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2008-09-02 00:37:04 +00:00
|
|
|
static void
|
2009-05-23 22:41:08 +00:00
|
|
|
GLES_RenderPresent(SDL_Renderer * renderer)
|
2008-09-02 00:37:04 +00:00
|
|
|
{
|
2011-02-01 19:19:43 -08:00
|
|
|
GLES_ActivateRenderer(renderer);
|
|
|
|
|
2008-09-02 00:37:04 +00:00
|
|
|
SDL_GL_SwapWindow(renderer->window);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
GLES_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
|
|
|
GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
|
|
|
|
|
2008-09-02 00:37:04 +00:00
|
|
|
GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
|
|
|
|
|
2011-02-01 19:19:43 -08:00
|
|
|
GLES_ActivateRenderer(renderer);
|
|
|
|
|
2008-09-02 00:37:04 +00:00
|
|
|
if (!data) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (data->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
|
|
|
renderdata->glDeleteTextures(1, &data->texture);
|
2008-09-02 00:37:04 +00:00
|
|
|
}
|
2013-08-29 08:29:21 -07:00
|
|
|
SDL_free(data->pixels);
|
2008-09-02 00:37:04 +00:00
|
|
|
SDL_free(data);
|
|
|
|
texture->driverdata = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
GLES_DestroyRenderer(SDL_Renderer * renderer)
|
|
|
|
{
|
|
|
|
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
if (data->context) {
|
2012-01-18 22:45:49 -05:00
|
|
|
while (data->framebuffers) {
|
|
|
|
GLES_FBOList *nextnode = data->framebuffers->next;
|
|
|
|
data->glDeleteFramebuffersOES(1, &data->framebuffers->FBO);
|
|
|
|
SDL_free(data->framebuffers);
|
|
|
|
data->framebuffers = nextnode;
|
|
|
|
}
|
2008-09-02 00:37:04 +00:00
|
|
|
SDL_GL_DeleteContext(data->context);
|
|
|
|
}
|
|
|
|
SDL_free(data);
|
|
|
|
}
|
|
|
|
SDL_free(renderer);
|
|
|
|
}
|
|
|
|
|
2013-03-03 11:25:09 -08:00
|
|
|
static int GLES_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh)
|
|
|
|
{
|
2012-09-03 11:16:12 -03:00
|
|
|
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
|
|
|
GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
|
|
|
|
GLES_ActivateRenderer(renderer);
|
|
|
|
|
|
|
|
data->glEnable(GL_TEXTURE_2D);
|
|
|
|
data->glBindTexture(texturedata->type, texturedata->texture);
|
|
|
|
|
2015-05-16 17:35:36 -03:00
|
|
|
if (texw) {
|
|
|
|
*texw = (float)texturedata->texw;
|
|
|
|
}
|
|
|
|
if (texh) {
|
|
|
|
*texh = (float)texturedata->texh;
|
|
|
|
}
|
2012-09-03 11:16:12 -03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-03 11:25:09 -08:00
|
|
|
static int GLES_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture)
|
|
|
|
{
|
2012-09-03 11:16:12 -03:00
|
|
|
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
|
|
|
GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
|
|
|
|
GLES_ActivateRenderer(renderer);
|
|
|
|
data->glDisable(texturedata->type);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-08 10:04:09 -08:00
|
|
|
#endif /* SDL_VIDEO_RENDER_OGL_ES && !SDL_RENDER_DISABLED */
|
2008-09-02 00:37:04 +00:00
|
|
|
|
|
|
|
/* vi: set ts=4 sw=4 expandtab: */
|