If GL4 renderer is not supported, fall back to default. Fix SDL GL init.
This commit is contained in:
parent
0260b00c00
commit
b8ae998252
|
@ -76,6 +76,7 @@ u32 VertexCount=0;
|
|||
u32 FrameCount=1;
|
||||
|
||||
Renderer* renderer;
|
||||
Renderer* fallback_renderer;
|
||||
bool renderer_enabled = true; // Signals the renderer thread to exit
|
||||
|
||||
#if !defined(TARGET_NO_THREADS)
|
||||
|
@ -286,6 +287,17 @@ bool rend_single_frame()
|
|||
return do_swp;
|
||||
}
|
||||
|
||||
static void rend_init_renderer()
|
||||
{
|
||||
if (!renderer->Init())
|
||||
{
|
||||
if (fallback_renderer == NULL || !fallback_renderer->Init())
|
||||
die("Renderer initialization failed\n");
|
||||
printf("Selected renderer initialization failed. Falling back to default renderer.\n");
|
||||
renderer = fallback_renderer;
|
||||
}
|
||||
}
|
||||
|
||||
void* rend_thread(void* p)
|
||||
{
|
||||
#if FEAT_HAS_NIXPROF
|
||||
|
@ -319,9 +331,7 @@ void* rend_thread(void* p)
|
|||
#endif
|
||||
|
||||
|
||||
|
||||
if (!renderer->Init())
|
||||
die("rend->init() failed\n");
|
||||
rend_init_renderer();
|
||||
|
||||
//we don't know if this is true, so let's not speculate here
|
||||
//renderer->Resize(640, 480);
|
||||
|
@ -513,6 +523,7 @@ bool rend_init()
|
|||
#if !defined(GLES) && HOST_OS != OS_DARWIN
|
||||
case 3:
|
||||
renderer = rend_GL4();
|
||||
fallback_renderer = rend_GLES2();
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
@ -523,7 +534,7 @@ bool rend_init()
|
|||
#if !defined(TARGET_NO_THREADS)
|
||||
rthd.Start();
|
||||
#else
|
||||
if (!renderer->Init()) die("rend->init() failed\n");
|
||||
rend_init_renderer();
|
||||
|
||||
renderer->Resize(640, 480);
|
||||
#endif
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include "oslib/oslib.h"
|
||||
#include "rend/rend.h"
|
||||
#include "hw/pvr/Renderer_if.h"
|
||||
|
||||
//Fragment and vertex shaders code
|
||||
|
||||
|
@ -579,6 +578,16 @@ static bool gles_init()
|
|||
(void*)libPvr_GetRenderSurface()))
|
||||
return false;
|
||||
|
||||
int major = 0;
|
||||
int minor = 0;
|
||||
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
||||
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
||||
if (major < 4 || (major == 4 && minor < 3))
|
||||
{
|
||||
printf("Warning: OpenGL version doesn't support per-pixel sorting.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!gl_create_resources())
|
||||
return false;
|
||||
|
||||
|
|
|
@ -63,7 +63,6 @@ Tile clip
|
|||
|
||||
#include "oslib/oslib.h"
|
||||
#include "rend/rend.h"
|
||||
#include "hw/pvr/Renderer_if.h"
|
||||
|
||||
float fb_scale_x,fb_scale_y;
|
||||
float scale_x, scale_y;
|
||||
|
@ -454,34 +453,34 @@ GLuint fogTextureId;
|
|||
|
||||
printf("Info: EGL version %d.%d\n",maj,min);
|
||||
|
||||
|
||||
|
||||
EGLint pi32ConfigAttribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT , EGL_DEPTH_SIZE, 24, EGL_STENCIL_SIZE, 8, EGL_NONE };
|
||||
EGLint pi32ContextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2 , EGL_NONE };
|
||||
|
||||
int num_config;
|
||||
|
||||
EGLConfig config;
|
||||
if (!eglChooseConfig(gl.setup.display, pi32ConfigAttribs, &config, 1, &num_config) || (num_config != 1))
|
||||
if (gl.setup.surface == 0)
|
||||
{
|
||||
printf("EGL Error: eglChooseConfig failed\n");
|
||||
return false;
|
||||
EGLint pi32ConfigAttribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT , EGL_DEPTH_SIZE, 24, EGL_STENCIL_SIZE, 8, EGL_NONE };
|
||||
EGLint pi32ContextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2 , EGL_NONE };
|
||||
|
||||
int num_config;
|
||||
|
||||
EGLConfig config;
|
||||
if (!eglChooseConfig(gl.setup.display, pi32ConfigAttribs, &config, 1, &num_config) || (num_config != 1))
|
||||
{
|
||||
printf("EGL Error: eglChooseConfig failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
gl.setup.surface = eglCreateWindowSurface(gl.setup.display, config, (EGLNativeWindowType)wind, NULL);
|
||||
|
||||
if (eglCheck())
|
||||
return false;
|
||||
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
if (eglCheck())
|
||||
return false;
|
||||
|
||||
gl.setup.context = eglCreateContext(gl.setup.display, config, NULL, pi32ContextAttribs);
|
||||
|
||||
if (eglCheck())
|
||||
return false;
|
||||
}
|
||||
|
||||
gl.setup.surface = eglCreateWindowSurface(gl.setup.display, config, (EGLNativeWindowType)wind, NULL);
|
||||
|
||||
if (eglCheck())
|
||||
return false;
|
||||
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
if (eglCheck())
|
||||
return false;
|
||||
|
||||
gl.setup.context = eglCreateContext(gl.setup.display, config, NULL, pi32ContextAttribs);
|
||||
|
||||
if (eglCheck())
|
||||
return false;
|
||||
|
||||
#endif
|
||||
|
||||
eglMakeCurrent(gl.setup.display, gl.setup.surface, gl.setup.surface, gl.setup.context);
|
||||
|
@ -589,6 +588,10 @@ GLuint fogTextureId;
|
|||
HDC ourWindowHandleToDeviceContext;
|
||||
bool gl_init(void* hwnd, void* hdc)
|
||||
{
|
||||
if (ourWindowHandleToDeviceContext)
|
||||
// Already initialized
|
||||
return true;
|
||||
|
||||
PIXELFORMATDESCRIPTOR pfd =
|
||||
{
|
||||
sizeof(PIXELFORMATDESCRIPTOR),
|
||||
|
|
|
@ -430,8 +430,8 @@ void sdl_window_create()
|
|||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||
#else
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
|
||||
#endif
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
||||
|
|
Loading…
Reference in New Issue