mirror of https://github.com/OpenMW/openmw.git
gl4es: Delay feature detection until a context exists
gl4es feature detection does not work reliably with EGL. If a context already exists, gl4es can instead reliably detect the underlying GLES features from the context itself. This requires gl4es to be configured with: -DNOEGL=ON -DNO_LOADER=ON -DNO_INIT_CONSTRUCTOR=ON This also requires gl4es to have this fix: https://github.com/ptitSeb/gl4es/pull/271pull/3051/head
parent
28be5a259b
commit
044e784072
@ -0,0 +1,36 @@
|
||||
// EGL does not work reliably for feature detection.
|
||||
// Instead, we initialize gl4es manually.
|
||||
#ifdef OPENMW_GL4ES_MANUAL_INIT
|
||||
#include "gl4es_init.h"
|
||||
|
||||
// For glHint
|
||||
#include <GL/gl.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
#include <gl4es/gl4esinit.h>
|
||||
#include <gl4es/gl4eshint.h>
|
||||
|
||||
static SDL_Window *gWindow;
|
||||
|
||||
void openmw_gl4es_GetMainFBSize(int *width, int *height)
|
||||
{
|
||||
SDL_GetWindowSize(gWindow, width, height);
|
||||
}
|
||||
|
||||
void openmw_gl4es_init(SDL_Window *window)
|
||||
{
|
||||
gWindow = window;
|
||||
set_getprocaddress(SDL_GL_GetProcAddress);
|
||||
set_getmainfbsize(openmw_gl4es_GetMainFBSize);
|
||||
initialize_gl4es();
|
||||
|
||||
// merge glBegin/glEnd in beams and console
|
||||
glHint(GL_BEGINEND_HINT_GL4ES, 1);
|
||||
// dxt unpacked to 16-bit looks ugly
|
||||
glHint(GL_AVOID16BITS_HINT_GL4ES, 1);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
#endif // OPENMW_GL4ES_MANUAL_INIT
|
@ -0,0 +1,13 @@
|
||||
#ifndef OPENMW_COMPONENTS_SDLUTIL_GL4ES_INIT_H
|
||||
#define OPENMW_COMPONENTS_SDLUTIL_GL4ES_INIT_H
|
||||
#ifdef OPENMW_GL4ES_MANUAL_INIT
|
||||
#include <SDL_video.h>
|
||||
|
||||
// Must be called once SDL video mode has been set,
|
||||
// which creates a context.
|
||||
//
|
||||
// GL4ES can then query the context for features and extensions.
|
||||
extern "C" void openmw_gl4es_init(SDL_Window *window);
|
||||
|
||||
#endif // OPENMW_GL4ES_MANUAL_INIT
|
||||
#endif // OPENMW_COMPONENTS_SDLUTIL_GL4ES_INIT_H
|
Loading…
Reference in New Issue