Skip to content

Commit

Permalink
GLInterface: Fix VideoSW on linux + OSX
Browse files Browse the repository at this point in the history
Our Video Software backend isn't OpenGL Core compatible, so we need a flag to alloc a compatible one.
  • Loading branch information
degasus committed Sep 17, 2015
1 parent 52de4cc commit 550e902
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Source/Core/VideoBackends/OGL/GLInterface/AGL.cpp
Expand Up @@ -15,7 +15,7 @@ void cInterfaceAGL::Swap()

// Create rendering window.
// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
bool cInterfaceAGL::Create(void *window_handle)
bool cInterfaceAGL::Create(void *window_handle, bool core)
{
cocoaWin = reinterpret_cast<NSView*>(window_handle);
NSSize size = [cocoaWin frame].size;
Expand All @@ -33,7 +33,7 @@ bool cInterfaceAGL::Create(void *window_handle)
s_backbuffer_width = size.width;
s_backbuffer_height = size.height;

NSOpenGLPixelFormatAttribute attr[] = { NSOpenGLPFADoubleBuffer, NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core, NSOpenGLPFAAccelerated, 0 };
NSOpenGLPixelFormatAttribute attr[] = { NSOpenGLPFADoubleBuffer, NSOpenGLPFAOpenGLProfile, NSOpenGLPFAAccelerated, core ? NSOpenGLProfileVersion3_2Core : 0, 0 };
NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc]
initWithAttributes: attr];
if (fmt == nil)
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/OGL/GLInterface/AGL.h
Expand Up @@ -17,7 +17,7 @@ class cInterfaceAGL : public cInterfaceBase
NSOpenGLContext *cocoaCtx;
public:
void Swap();
bool Create(void *window_handle);
bool Create(void *window_handle, bool core);
bool MakeCurrent();
bool ClearCurrent();
void Shutdown();
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/OGL/GLInterface/EGL.cpp
Expand Up @@ -96,7 +96,7 @@ void cInterfaceEGL::DetectMode()

// Create rendering window.
// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
bool cInterfaceEGL::Create(void *window_handle)
bool cInterfaceEGL::Create(void *window_handle, bool core)
{
const char *s;
EGLint egl_major, egl_minor;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/OGL/GLInterface/EGL.h
Expand Up @@ -26,7 +26,7 @@ class cInterfaceEGL : public cInterfaceBase
void Swap();
void SetMode(u32 mode) { s_opengl_mode = mode; }
void* GetFuncAddress(const std::string& name);
bool Create(void *window_handle);
bool Create(void *window_handle, bool core);
bool MakeCurrent();
bool ClearCurrent();
void Shutdown();
Expand Down
12 changes: 8 additions & 4 deletions Source/Core/VideoBackends/OGL/GLInterface/GLX.cpp
Expand Up @@ -44,7 +44,7 @@ void cInterfaceGLX::Swap()

// Create rendering window.
// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
bool cInterfaceGLX::Create(void *window_handle)
bool cInterfaceGLX::Create(void *window_handle, bool core)
{
dpy = XOpenDisplay(nullptr);
int screen = DefaultScreen(dpy);
Expand Down Expand Up @@ -107,9 +107,13 @@ bool cInterfaceGLX::Create(void *window_handle)
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
None
};
ctx = glXCreateContextAttribs(dpy, fbconfig, 0, True, context_attribs);
XSync(dpy, False);
if (!ctx || s_glxError)
ctx = nullptr;
if (core)
{
ctx = glXCreateContextAttribs(dpy, fbconfig, 0, True, context_attribs);
XSync(dpy, False);
}
if (core && (!ctx || s_glxError))
{
int context_attribs_33[] =
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/OGL/GLInterface/GLX.h
Expand Up @@ -23,7 +23,7 @@ class cInterfaceGLX : public cInterfaceBase
void SwapInterval(int Interval) override;
void Swap() override;
void* GetFuncAddress(const std::string& name) override;
bool Create(void *window_handle) override;
bool Create(void *window_handle, bool core) override;
bool MakeCurrent() override;
bool ClearCurrent() override;
void Shutdown() override;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/OGL/GLInterface/WGL.cpp
Expand Up @@ -57,7 +57,7 @@ bool cInterfaceWGL::PeekMessages()

// Create rendering window.
// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
bool cInterfaceWGL::Create(void *window_handle)
bool cInterfaceWGL::Create(void *window_handle, bool core)
{
if (window_handle == nullptr)
return false;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/OGL/GLInterface/WGL.h
Expand Up @@ -13,7 +13,7 @@ class cInterfaceWGL : public cInterfaceBase
void SwapInterval(int Interval);
void Swap();
void* GetFuncAddress(const std::string& name);
bool Create(void *window_handle);
bool Create(void *window_handle, bool core);
bool MakeCurrent();
bool ClearCurrent();
void Shutdown();
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/OGL/GLInterfaceBase.h
Expand Up @@ -29,7 +29,7 @@ class cInterfaceBase
virtual void SetMode(u32 mode) { s_opengl_mode = GLInterfaceMode::MODE_OPENGL; }
virtual u32 GetMode() { return s_opengl_mode; }
virtual void* GetFuncAddress(const std::string& name) { return nullptr; }
virtual bool Create(void *window_handle) { return true; }
virtual bool Create(void *window_handle, bool core = true) { return true; }
virtual bool MakeCurrent() { return true; }
virtual bool ClearCurrent() { return true; }
virtual void Shutdown() {}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/Software/SWmain.cpp
Expand Up @@ -78,7 +78,7 @@ bool VideoSoftware::Initialize(void *window_handle)

InitInterface();
GLInterface->SetMode(GLInterfaceMode::MODE_DETECT);
if (!GLInterface->Create(window_handle))
if (!GLInterface->Create(window_handle, false))
{
INFO_LOG(VIDEO, "GLInterface::Create failed.");
return false;
Expand Down

0 comments on commit 550e902

Please sign in to comment.