Commit f7ad18f9 authored by Sam Lantinga's avatar Sam Lantinga

X11 OpenGL ES minor corrections

Scott Percival 2012-01-08 04:21:22 PST

I tested the new build on my two ARM machines, and fixed a few bugs:
- if SDL_VIDEO_DRIVER_UIKIT, SDL_VIDEO_DRIVER_ANDROID or
SDL_VIDEO_DRIVER_PANDORA are specified, function pointers are grabbed from the
compile-linked library instead of through SDL_GL_GetProcAddress. (not sure if
this is the best way to go about it)
- removing "/usr/lib/" from all the library names (hey, with multiarch you
can't be too sure anymore)
- added glFinish to glesfuncs.h
- changed the eglGetProcAddress arg type to "const char *" as per the EGL spec
- filled in the stubs for X11_GLES_SetSwapInterval and X11_GLES_GetSwapInterval
parent 73b21090
......@@ -10,6 +10,7 @@ SDL_PROC(void, glDrawArrays, (GLenum, GLint, GLsizei))
SDL_PROC(void, glDrawTexiOES, (GLint, GLint, GLint, GLint, GLint))
SDL_PROC(void, glEnable, (GLenum))
SDL_PROC(void, glEnableClientState, (GLenum))
SDL_PROC(void, glFinish, (void))
SDL_PROC(void, glGenTextures, (GLsizei, GLuint *))
SDL_PROC(GLenum, glGetError, (void))
SDL_PROC(void, glGetIntegerv, (GLenum, GLint *))
......
......@@ -40,7 +40,7 @@ glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height)
/* OpenGL ES 1.1 renderer implementation, based on the OpenGL renderer */
/* Used to re-create the window with OpenGL capability */
/* Used to re-create the window with OpenGL ES capability */
extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
static const float inv255f = 1.0f / 255.0f;
......@@ -151,6 +151,14 @@ GLES_SetError(const char *prefix, GLenum result)
static int GLES_LoadFunctions(GLES_RenderData * data)
{
#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
#ifdef __SDL_NOGETPROCADDR__
#define SDL_PROC(ret,func,params) data->func=func;
#else
......@@ -318,6 +326,8 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
static void
GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
{
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
/* Rebind the context to the window area and update matrices */
SDL_CurrentContext = NULL;
......@@ -325,7 +335,7 @@ GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
if (event->event == SDL_WINDOWEVENT_MINIMIZED) {
/* According to Apple documentation, we need to finish drawing NOW! */
glFinish();
data->glFinish();
}
}
......
......@@ -27,7 +27,7 @@
#include "../SDL_sysrender.h"
#include "SDL_shaders_gles2.h"
/* Used to re-create the window with OpenGL capability */
/* Used to re-create the window with OpenGL ES capability */
extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
/*************************************************************************************************
......@@ -158,7 +158,15 @@ static SDL_GLContext SDL_CurrentContext = NULL;
static int GLES2_LoadFunctions(GLES2_DriverContext * data)
{
#ifdef __SDL_NOGETPROCADDR__
#if SDL_VIDEO_DRIVER_UIKIT
#define __SDL_NOGETPROCADDR__
#elif SDL_VIDEO_DRIVER_ANDROID
#define __SDL_NOGETPROCADDR__
#elif SDL_VIDEO_DRIVER_PANDORA
#define __SDL_NOGETPROCADDR__
#endif
#if defined __SDL_NOGETPROCADDR__
#define SDL_PROC(ret,func,params) data->func=func;
#else
#define SDL_PROC(ret,func,params) \
......
......@@ -25,10 +25,10 @@
#include "SDL_x11video.h"
#include "SDL_x11opengles.h"
#define DEFAULT_EGL "/usr/lib/libEGL.so"
#define DEFAULT_OGL_ES2 "/usr/lib/libGLESv2.so"
#define DEFAULT_OGL_ES_PVR "/usr/lib/libGLES_CM.so"
#define DEFAULT_OGL_ES "/usr/lib/libGLESv1_CM.so"
#define DEFAULT_EGL "libEGL.so"
#define DEFAULT_OGL_ES2 "libGLESv2.so"
#define DEFAULT_OGL_ES_PVR "libGLES_CM.so"
#define DEFAULT_OGL_ES "libGLESv1_CM.so"
#define LOAD_FUNC(NAME) \
*((void**)&_this->gles_data->NAME) = dlsym(handle, #NAME); \
......@@ -143,6 +143,7 @@ X11_GLES_LoadLibrary(_THIS, const char *path)
LOAD_FUNC(eglDestroySurface);
LOAD_FUNC(eglMakeCurrent);
LOAD_FUNC(eglSwapBuffers);
LOAD_FUNC(eglSwapInterval);
_this->gles_data->egl_display =
_this->gles_data->eglGetDisplay((NativeDisplayType) data->display);
......@@ -304,6 +305,7 @@ X11_GLES_CreateContext(_THIS, SDL_Window * window)
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
Display *display = data->videodata->display;
SDL_GLContext context = 1;
XSync(display, False);
......@@ -323,13 +325,14 @@ X11_GLES_CreateContext(_THIS, SDL_Window * window)
}
_this->gles_data->egl_active = 1;
_this->gles_data->egl_swapinterval = 0;
if (X11_GLES_MakeCurrent(_this, window, context) < 0) {
X11_GLES_DeleteContext(_this, context);
return NULL;
}
return (SDL_GLContext)(1);
return context;
}
int
......@@ -353,17 +356,34 @@ X11_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
return (retval);
}
static int swapinterval = -1;
int
X11_GLES_SetSwapInterval(_THIS, int interval)
{
if (_this->gles_data->egl_active != 1) {
SDL_SetError("OpenGL ES context not active");
return -1;
}
EGLBoolean status;
status = _this->gles_data->eglSwapInterval(_this->gles_data->egl_display, interval);
if (status == EGL_TRUE) {
_this->gles_data->egl_swapinterval = interval;
return 0;
}
SDL_SetError("Unable to set the EGL swap interval");
return -1;
}
int
X11_GLES_GetSwapInterval(_THIS)
{
return 0;
if (_this->gles_data->egl_active != 1) {
SDL_SetError("OpenGL ES context not active");
return -1;
}
return _this->gles_data->egl_swapinterval;
}
void
......
......@@ -37,13 +37,14 @@ typedef struct SDL_PrivateGLESData
EGLContext egl_context; /* Current GLES context */
EGLSurface egl_surface;
EGLConfig egl_config;
int egl_swapinterval;
EGLDisplay(*eglGetDisplay) (NativeDisplayType display);
EGLBoolean(*eglInitialize) (EGLDisplay dpy, EGLint * major,
EGLint * minor);
EGLBoolean(*eglTerminate) (EGLDisplay dpy);
void *(*eglGetProcAddress) (const GLubyte * procName);
void *(*eglGetProcAddress) (const char * procName);
EGLBoolean(*eglChooseConfig) (EGLDisplay dpy,
const EGLint * attrib_list,
......@@ -68,6 +69,8 @@ typedef struct SDL_PrivateGLESData
EGLBoolean(*eglSwapBuffers) (EGLDisplay dpy, EGLSurface draw);
EGLBoolean(*eglSwapInterval) (EGLDisplay dpy, EGLint interval);
const char *(*eglQueryString) (EGLDisplay dpy, EGLint name);
EGLBoolean(*eglGetConfigAttrib) (EGLDisplay dpy, EGLConfig config,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment