mirror of
https://github.com/encounter/SDL.git
synced 2025-12-13 23:26:18 +00:00
Separate vita piglet renderer. Add proper render initialization and window re-creation.
This commit is contained in:
committed by
Sam Lantinga
parent
d75ea51ac0
commit
dbb730d395
@@ -26,6 +26,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_log.h"
|
||||
#include "SDL_vitavideo.h"
|
||||
#include "SDL_vitagl_c.h"
|
||||
|
||||
@@ -47,20 +48,20 @@
|
||||
int
|
||||
VITA_GL_LoadLibrary(_THIS, const char *path)
|
||||
{
|
||||
pibInit(PIB_SHACCCG);
|
||||
pibInit(PIB_SHACCCG | PIB_GET_PROC_ADDR_CORE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *
|
||||
VITA_GL_GetProcAddress(_THIS, const char *proc)
|
||||
{
|
||||
return eglGetProcAddress(proc);
|
||||
return eglGetProcAddress(proc);
|
||||
}
|
||||
|
||||
void
|
||||
VITA_GL_UnloadLibrary(_THIS)
|
||||
{
|
||||
eglTerminate(_this->gl_data->display);
|
||||
eglTerminate(_this->gl_data->display);
|
||||
}
|
||||
|
||||
static EGLint width = 960;
|
||||
@@ -72,80 +73,72 @@ VITA_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
|
||||
SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
EGLint attribs[32];
|
||||
EGLDisplay display;
|
||||
EGLContext context;
|
||||
EGLSurface surface;
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
int i;
|
||||
EGLint attribs[32];
|
||||
EGLDisplay display;
|
||||
EGLContext context;
|
||||
EGLSurface surface;
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
int i;
|
||||
|
||||
EGLCHK(display = eglGetDisplay(0));
|
||||
|
||||
/* EGL init taken from glutCreateWindow() in VITAGL's glut.c. */
|
||||
EGLCHK(display = eglGetDisplay(0));
|
||||
EGLCHK(eglInitialize(display, NULL, NULL));
|
||||
wdata->uses_gles = SDL_TRUE;
|
||||
window->flags |= SDL_WINDOW_FULLSCREEN;
|
||||
|
||||
EGLCHK(eglInitialize(display, NULL, NULL));
|
||||
wdata->uses_gles = SDL_TRUE;
|
||||
window->flags |= SDL_WINDOW_FULLSCREEN;
|
||||
EGLCHK(eglBindAPI(EGL_OPENGL_ES_API));
|
||||
|
||||
EGLCHK(eglBindAPI(EGL_OPENGL_ES_API));
|
||||
i = 0;
|
||||
attribs[i++] = EGL_RED_SIZE;
|
||||
attribs[i++] = 8;
|
||||
attribs[i++] = EGL_GREEN_SIZE;
|
||||
attribs[i++] = 8;
|
||||
attribs[i++] = EGL_BLUE_SIZE;
|
||||
attribs[i++] = 8;
|
||||
attribs[i++] = EGL_DEPTH_SIZE;
|
||||
attribs[i++] = 0;
|
||||
attribs[i++] = EGL_ALPHA_SIZE;
|
||||
attribs[i++] = 8;
|
||||
attribs[i++] = EGL_STENCIL_SIZE;
|
||||
attribs[i++] = 0;;
|
||||
|
||||
/* Setup the config based on SDL's current values. */
|
||||
i = 0;
|
||||
attribs[i++] = EGL_RED_SIZE;
|
||||
attribs[i++] = 8;//_this->gl_config.red_size;
|
||||
attribs[i++] = EGL_GREEN_SIZE;
|
||||
attribs[i++] = 8;//_this->gl_config.green_size;
|
||||
attribs[i++] = EGL_BLUE_SIZE;
|
||||
attribs[i++] = 8;//_this->gl_config.blue_size;
|
||||
attribs[i++] = EGL_DEPTH_SIZE;
|
||||
attribs[i++] = 32;//_this->gl_config.depth_size;
|
||||
attribs[i++] = EGL_SURFACE_TYPE;
|
||||
attribs[i++] = 5;
|
||||
|
||||
// if (_this->gl_config.alpha_size)
|
||||
{
|
||||
attribs[i++] = EGL_ALPHA_SIZE;
|
||||
attribs[i++] = 8;//_this->gl_config.alpha_size;
|
||||
}
|
||||
if (_this->gl_config.stencil_size)
|
||||
{
|
||||
attribs[i++] = EGL_STENCIL_SIZE;
|
||||
attribs[i++] = _this->gl_config.stencil_size;
|
||||
}
|
||||
attribs[i++] = EGL_RENDERABLE_TYPE;
|
||||
attribs[i++] = EGL_OPENGL_ES2_BIT;
|
||||
|
||||
attribs[i++] = EGL_SURFACE_TYPE;
|
||||
attribs[i++] = 5;
|
||||
attribs[i++] = EGL_CONFORMANT;
|
||||
attribs[i++] = EGL_OPENGL_ES2_BIT;
|
||||
|
||||
attribs[i++] = EGL_RENDERABLE_TYPE;
|
||||
attribs[i++] = EGL_OPENGL_ES2_BIT;
|
||||
attribs[i++] = EGL_NONE;
|
||||
|
||||
attribs[i++] = EGL_NONE;
|
||||
EGLCHK(eglChooseConfig(display, attribs, &config, 1, &num_configs));
|
||||
|
||||
EGLCHK(eglChooseConfig(display, attribs, &config, 1, &num_configs));
|
||||
if (num_configs == 0)
|
||||
{
|
||||
SDL_SetError("No valid EGL configs for requested mode");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (num_configs == 0)
|
||||
{
|
||||
SDL_SetError("No valid EGL configs for requested mode");
|
||||
return 0;
|
||||
}
|
||||
const EGLint contextAttribs[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
const EGLint contextAttribs[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
EGL_NONE
|
||||
};
|
||||
EGLCHK(surface = eglCreateWindowSurface(display, config, VITA_WINDOW_960X544, NULL));
|
||||
|
||||
EGLCHK(surface = eglCreateWindowSurface(display, config, VITA_WINDOW_960X544, NULL));
|
||||
EGLCHK(context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs));
|
||||
|
||||
EGLCHK(context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs));
|
||||
EGLCHK(eglMakeCurrent(display, surface, surface, context));
|
||||
|
||||
EGLCHK(eglMakeCurrent(display, surface, surface, context));
|
||||
|
||||
EGLCHK(eglQuerySurface(display, surface, EGL_WIDTH, &width));
|
||||
EGLCHK(eglQuerySurface(display, surface, EGL_HEIGHT, &height));
|
||||
|
||||
_this->gl_data->display = display;
|
||||
_this->gl_data->context = context;
|
||||
_this->gl_data->surface = surface;
|
||||
EGLCHK(eglQuerySurface(display, surface, EGL_WIDTH, &width));
|
||||
EGLCHK(eglQuerySurface(display, surface, EGL_HEIGHT, &height));
|
||||
|
||||
_this->gl_data->display = display;
|
||||
_this->gl_data->context = context;
|
||||
_this->gl_data->surface = surface;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
@@ -41,9 +41,6 @@
|
||||
|
||||
SDL_Window *Vita_Window;
|
||||
|
||||
/* unused
|
||||
static SDL_bool VITA_initialized = SDL_FALSE;
|
||||
*/
|
||||
static int
|
||||
VITA_Available(void)
|
||||
{
|
||||
@@ -67,15 +64,6 @@ VITA_Create()
|
||||
SDL_VideoData *phdata;
|
||||
SDL_GLDriverData *gldata;
|
||||
|
||||
int status;
|
||||
|
||||
/* Check if VITA could be initialized */
|
||||
status = VITA_Available();
|
||||
if (status == 0) {
|
||||
/* VITA could not be used */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Initialize SDL_VideoDevice structure */
|
||||
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
|
||||
if (device == NULL) {
|
||||
@@ -225,8 +213,8 @@ VITA_CreateWindow(_THIS, SDL_Window * window)
|
||||
// Vita can only have one window
|
||||
if (Vita_Window != NULL)
|
||||
{
|
||||
// Replace this with something else
|
||||
return SDL_OutOfMemory();
|
||||
SDL_SetError("Only one window supported");
|
||||
return -1;
|
||||
}
|
||||
|
||||
Vita_Window = window;
|
||||
@@ -292,6 +280,17 @@ VITA_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||
void
|
||||
VITA_DestroyWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
SDL_WindowData *data;
|
||||
|
||||
data = window->driverdata;
|
||||
if (data) {
|
||||
// TODO: should we destroy egl context? No one sane should recreate ogl window as non-ogl
|
||||
SDL_free(data);
|
||||
}
|
||||
|
||||
window->driverdata = NULL;
|
||||
Vita_Window = NULL;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user