Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Have our OpenGL/ES context creation be less stupid.
  • Loading branch information
Sonicadvance1 committed Dec 12, 2013
1 parent 2a0adc3 commit f9ff0bc
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 16 deletions.
5 changes: 5 additions & 0 deletions Source/Core/DolphinWX/Src/GLInterface.h
Expand Up @@ -54,6 +54,11 @@ typedef struct {
#endif
} GLWindow;

enum GLInterfaceMode {
MODE_OPENGL = 0,
MODE_OPENGLES2,
MODE_OPENGLES3,
};
extern cInterfaceBase *GLInterface;
extern GLWindow GLWin;

Expand Down
36 changes: 21 additions & 15 deletions Source/Core/DolphinWX/Src/GLInterface/EGL.cpp
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/DolphinWX/Src/GLInterface/InterfaceBase.h
Expand Up @@ -10,9 +10,12 @@ class cInterfaceBase
// 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; }
Expand Down
6 changes: 6 additions & 0 deletions Source/Core/DolphinWX/Src/GLInterface/Platform.h
Expand Up @@ -155,6 +155,12 @@ typedef struct {
#endif
} GLWindow;

enum GLInterfaceMode {
MODE_OPENGL = 0,
MODE_OPENGLES2,
MODE_OPENGLES3,
};

extern cInterfaceBase *GLInterface;
extern GLWindow GLWin;

Expand Down
4 changes: 4 additions & 0 deletions Source/Core/VideoBackends/OGL/Src/main.cpp
Expand Up @@ -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;

Expand Down
6 changes: 5 additions & 1 deletion Source/Core/VideoBackends/Software/Src/SWmain.cpp
Expand Up @@ -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");
Expand Down

0 comments on commit f9ff0bc

Please sign in to comment.