zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_pspgl.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 #include <stdlib.h>
23 #include <string.h>
24 
25 #include "SDL_error.h"
26 #include "SDL_pspvideo.h"
27 #include "SDL_pspgl_c.h"
28 
29 /*****************************************************************************/
30 /* SDL OpenGL/OpenGL ES functions */
31 /*****************************************************************************/
32 #define EGLCHK(stmt) \
33  do { \
34  EGLint err; \
35  \
36  stmt; \
37  err = eglGetError(); \
38  if (err != EGL_SUCCESS) { \
39  SDL_SetError("EGL error %d", err); \
40  return 0; \
41  } \
42  } while (0)
43 
44 int
46 {
49  }
50 
51  return 0;
52 }
53 
54 /* pspgl doesn't provide this call, so stub it out since SDL requires it.
55 #define GLSTUB(func,params) void func params {}
56 
57 GLSTUB(glOrtho,(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
58  GLdouble zNear, GLdouble zFar))
59 */
60 void *
61 PSP_GL_GetProcAddress(_THIS, const char *proc)
62 {
63  return eglGetProcAddress(proc);
64 }
65 
66 void
68 {
70 }
71 
72 static EGLint width = 480;
73 static EGLint height = 272;
74 
77 {
78 
79  SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
80 
81  EGLint attribs[32];
86  EGLint num_configs;
87  int i;
88 
89 
90  /* EGL init taken from glutCreateWindow() in PSPGL's glut.c. */
93  wdata->uses_gles = SDL_TRUE;
94  window->flags |= SDL_WINDOW_FULLSCREEN;
95 
96  /* Setup the config based on SDL's current values. */
97  i = 0;
98  attribs[i++] = EGL_RED_SIZE;
100  attribs[i++] = EGL_GREEN_SIZE;
102  attribs[i++] = EGL_BLUE_SIZE;
104  attribs[i++] = EGL_DEPTH_SIZE;
106 
108  {
109  attribs[i++] = EGL_ALPHA_SIZE;
111  }
113  {
116  }
117 
118  attribs[i++] = EGL_NONE;
119 
120  EGLCHK(eglChooseConfig(display, attribs, &config, 1, &num_configs));
121 
122  if (num_configs == 0)
123  {
124  SDL_SetError("No valid EGL configs for requested mode");
125  return 0;
126  }
127 
130 
134 
138 
139 
140  return context;
141 }
142 
143 int
145 {
148  {
149  return SDL_SetError("Unable to make EGL context current");
150  }
151  return 0;
152 }
153 
154 int
156 {
157  EGLBoolean status;
158  status = eglSwapInterval(_this->gl_data->display, interval);
159  if (status == EGL_TRUE) {
160  /* Return success to upper level */
161  _this->gl_data->swapinterval = interval;
162  return 0;
163  }
164  /* Failed to set swap interval */
165  return SDL_SetError("Unable to set the EGL swap interval");
166 }
167 
168 int
170 {
171  return _this->gl_data->swapinterval;
172 }
173 
174 void
176 {
178 }
179 
180 void
182 {
184  EGLBoolean status;
185 
186  if (phdata->egl_initialized != SDL_TRUE) {
187  SDL_SetError("PSP: GLES initialization failed, no OpenGL ES support");
188  return;
189  }
190 
191  /* Check if OpenGL ES connection has been initialized */
192  if (_this->gl_data->display != EGL_NO_DISPLAY) {
193  if (context != EGL_NO_CONTEXT) {
194  status = eglDestroyContext(_this->gl_data->display, context);
195  if (status != EGL_TRUE) {
196  /* Error during OpenGL ES context destroying */
197  SDL_SetError("PSP: OpenGL ES context destroy error");
198  return;
199  }
200  }
201  }
202 
203  return;
204 }
205 
EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy)
uint32_t swapinterval
Definition: SDL_pspgl_c.h:36
#define EGL_RED_SIZE
Definition: egl.h:100
EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
void * EGLConfig
Definition: egl.h:46
#define EGLCHK(stmt)
Definition: SDL_pspgl.c:32
#define NULL
Definition: ftobjs.h:61
EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
void PSP_GL_UnloadLibrary(_THIS)
Definition: SDL_pspgl.c:67
EGLSurface surface
Definition: eglext.h:74
void PSP_GL_DeleteContext(_THIS, SDL_GLContext context)
Definition: SDL_pspgl.c:181
#define EGL_ALPHA_SIZE
Definition: egl.h:97
void PSP_GL_SwapWindow(_THIS, SDL_Window *window)
Definition: SDL_pspgl.c:175
#define EGL_NONE
Definition: egl.h:119
EGLSurface EGLint EGLint EGLint EGLint height
Definition: eglext.h:293
void * SDL_GLContext
An opaque handle to an OpenGL context.
Definition: SDL_video.h:161
EGLSurface surface
Definition: SDL_pspgl_c.h:35
khronos_int32_t EGLint
Definition: eglplatform.h:127
EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress(const char *procname)
void * EGLDisplay
Definition: egl.h:48
#define EGL_HEIGHT
Definition: egl.h:167
char * display
Definition: visualinfo.c:85
if(!yyg->yy_init)
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
const GLint * attribs
Definition: glew.h:13064
EGLDisplay display
Definition: SDL_pspgl_c.h:33
int PSP_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
Definition: SDL_pspgl.c:144
GLsizei const GLchar *const * path
Definition: glew.h:5828
#define EGL_TRUE
Definition: egl.h:65
#define EGL_NO_DISPLAY
Definition: egl.h:70
#define EGL_BLUE_SIZE
Definition: egl.h:98
struct SDL_GLDriverData * gl_data
Definition: SDL_sysvideo.h:315
void * EGLSurface
Definition: egl.h:49
unsigned int EGLBoolean
Definition: egl.h:44
EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
static SDL_VideoDevice * _this
Definition: SDL_video.c:92
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
void * EGLContext
Definition: egl.h:47
#define EGL_NO_CONTEXT
Definition: egl.h:69
EGLSurface EGLint EGLint EGLint width
Definition: eglext.h:293
#define _THIS
SDL_bool uses_gles
Definition: SDL_pandora.h:48
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
Definition: SDL_error.c:53
int PSP_GL_LoadLibrary(_THIS, const char *path)
Definition: SDL_pspgl.c:45
#define EGL_DEPTH_SIZE
Definition: egl.h:101
void * PSP_GL_GetProcAddress(_THIS, const char *proc)
Definition: SDL_pspgl.c:61
SDL_GLContext PSP_GL_CreateContext(_THIS, SDL_Window *window)
Definition: SDL_pspgl.c:76
EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id)
EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
EGLConfig config
Definition: eglext.h:257
#define EGL_GREEN_SIZE
Definition: egl.h:99
SDL_bool egl_initialized
Definition: SDL_pandora.h:32
EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval)
#define EGL_STENCIL_SIZE
Definition: egl.h:102
int PSP_GL_SetSwapInterval(_THIS, int interval)
Definition: SDL_pspgl.c:155
void * driverdata
Definition: SDL_sysvideo.h:99
EGLContext context
Definition: SDL_pspgl_c.h:34
TParseContext * context
int i
Definition: pngrutil.c:1377
Uint32 flags
Definition: SDL_sysvideo.h:81
EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list)
struct SDL_VideoDevice::@87 gl_config
int PSP_GL_GetSwapInterval(_THIS)
Definition: SDL_pspgl.c:169
#define EGL_WIDTH
Definition: egl.h:168
EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)