Have our OpenGL/ES context creation be less stupid.
This commit is contained in:
parent
2a0adc3972
commit
f9ff0bc55d
|
@ -54,6 +54,11 @@ typedef struct {
|
|||
#endif
|
||||
} GLWindow;
|
||||
|
||||
enum GLInterfaceMode {
|
||||
MODE_OPENGL = 0,
|
||||
MODE_OPENGLES2,
|
||||
MODE_OPENGLES3,
|
||||
};
|
||||
extern cInterfaceBase *GLInterface;
|
||||
extern GLWindow GLWin;
|
||||
|
||||
|
|
|
@ -47,31 +47,37 @@ bool cInterfaceEGL::Create(void *&window_handle)
|
|||
// attributes for a visual in RGBA format with at least
|
||||
// 8 bits per color
|
||||
int attribs[] = {
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
#ifdef USE_GLES
|
||||
#ifdef USE_GLES3
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
|
||||
// OpenGL ES 3 bit is disabled for now, until we have a way to select it from runtime
|
||||
// Qualcomm drivers don't even care if it is ES2 or ES3 bit set.
|
||||
// Intel drivers /might/ not care, but that code path is untested
|
||||
// EGL_RENDERABLE_TYPE, (1 << 6) /* EGL_OPENGL_ES3_BIT */,
|
||||
#else
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
#endif
|
||||
#else
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
#endif
|
||||
EGL_NONE };
|
||||
|
||||
static const EGLint ctx_attribs[] = {
|
||||
#ifdef USE_GLES
|
||||
EGLint ctx_attribs[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
#endif
|
||||
EGL_NONE
|
||||
};
|
||||
switch(s_opengl_mode)
|
||||
{
|
||||
case MODE_OPENGL:
|
||||
attribs[1] = EGL_OPENGL_BIT;
|
||||
ctx_attribs[0] = EGL_NONE;
|
||||
break;
|
||||
case MODE_OPENGLES2:
|
||||
attribs[1] = EGL_OPENGL_ES2_BIT;
|
||||
ctx_attribs[1] = 2;
|
||||
break;
|
||||
case MODE_OPENGLES3:
|
||||
attribs[1] = (1 << 6); /* EGL_OPENGL_ES3_BIT_KHR */
|
||||
ctx_attribs[1] = 3;
|
||||
break;
|
||||
default:
|
||||
ERROR_LOG(VIDEO, "Unknown opengl mode set\n");
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!Platform.SelectDisplay())
|
||||
return false;
|
||||
|
|
|
@ -10,9 +10,12 @@ protected:
|
|||
// Window dimensions.
|
||||
u32 s_backbuffer_width;
|
||||
u32 s_backbuffer_height;
|
||||
|
||||
u32 s_opengl_mode;
|
||||
public:
|
||||
virtual void Swap() {}
|
||||
virtual void UpdateFPSDisplay(const char *Text) {}
|
||||
virtual void SetMode(u32 mode) { s_opengl_mode = mode; }
|
||||
virtual bool Create(void *&window_handle) { return true; }
|
||||
virtual bool MakeCurrent() { return true; }
|
||||
virtual bool ClearCurrent() { return true; }
|
||||
|
|
|
@ -155,6 +155,12 @@ typedef struct {
|
|||
#endif
|
||||
} GLWindow;
|
||||
|
||||
enum GLInterfaceMode {
|
||||
MODE_OPENGL = 0,
|
||||
MODE_OPENGLES2,
|
||||
MODE_OPENGLES3,
|
||||
};
|
||||
|
||||
extern cInterfaceBase *GLInterface;
|
||||
extern GLWindow GLWin;
|
||||
|
||||
|
|
|
@ -179,6 +179,10 @@ bool VideoBackend::Initialize(void *&window_handle)
|
|||
UpdateActiveConfig();
|
||||
|
||||
InitInterface();
|
||||
GLInterface->SetMode(GLInterfaceMode::MODE_OPENGL);
|
||||
#ifdef USE_GLES3
|
||||
GLInterface->SetMode(GLInterfaceMode::MODE_OPENGLES3);
|
||||
#endif
|
||||
if (!GLInterface->Create(window_handle))
|
||||
return false;
|
||||
|
||||
|
|
|
@ -61,8 +61,12 @@ void VideoSoftware::ShowConfig(void *_hParent)
|
|||
bool VideoSoftware::Initialize(void *&window_handle)
|
||||
{
|
||||
g_SWVideoConfig.Load((File::GetUserPath(D_CONFIG_IDX) + "gfx_software.ini").c_str());
|
||||
InitInterface();
|
||||
|
||||
InitInterface();
|
||||
GLInterface->SetMode(GLInterfaceMode::MODE_OPENGL);
|
||||
#ifdef USE_GLES
|
||||
GLInterface->SetMode(GLInterfaceMode::MODE_OPENGLES2);
|
||||
#endif
|
||||
if (!GLInterface->Create(window_handle))
|
||||
{
|
||||
INFO_LOG(VIDEO, "%s", "SWRenderer::Create failed\n");
|
||||
|
|
Loading…
Reference in New Issue