Skip to content

Commit e9d10a9

Browse files
Linux+OpenGL: Implement GUI vsync setting (#477)
1 parent 2842615 commit e9d10a9

File tree

6 files changed

+391
-19
lines changed

6 files changed

+391
-19
lines changed

src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp

+10-15
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
#define STRINGIFY(X) STRINGIFY2(X)
2626

2727
#define GLFUNC(__type, __name) __type __name;
28+
#define EGLFUNC(__type, __name) __type __name;
2829
#include "Common/GLInclude/glFunctions.h"
2930
#undef GLFUNC
31+
#undef EGLFUNC
3032

3133
#include "config/ActiveSettings.h"
3234
#include "config/LaunchSettings.h"
@@ -229,9 +231,17 @@ void LoadOpenGLImports()
229231
_glXGetProcAddress = (PFNGLXGETPROCADDRESSPROC)dlsym(libGL, "glXGetProcAddressARB");
230232
}
231233

234+
void* libEGL = dlopen("libEGL.so.1", RTLD_NOW | RTLD_GLOBAL);
235+
if(!libEGL)
236+
{
237+
libGL = dlopen("libEGL.so", RTLD_NOW | RTLD_GLOBAL);
238+
}
239+
232240
#define GLFUNC(__type, __name) __name = (__type)_GetOpenGLFunction(libGL, _glXGetProcAddress, STRINGIFY(__name));
241+
#define EGLFUNC(__type, __name) __name = (__type)dlsym(libEGL, STRINGIFY(__name));
233242
#include "Common/GLInclude/glFunctions.h"
234243
#undef GLFUNC
244+
#undef EGLFUNC
235245
}
236246
#elif BOOST_OS_MACOS
237247
void LoadOpenGLImports()
@@ -352,20 +362,6 @@ void OpenGLRenderer::NotifyLatteCommandProcessorIdle()
352362
glFlush();
353363
}
354364

355-
void OpenGLRenderer::UpdateVSyncState()
356-
{
357-
int configValue = GetConfig().vsync.GetValue();
358-
if(m_activeVSyncState != configValue)
359-
{
360-
#if BOOST_OS_WINDOWS
361-
if(wglSwapIntervalEXT)
362-
wglSwapIntervalEXT(configValue); // 1 = enabled, 0 = disabled
363-
#else
364-
cemuLog_log(LogType::Force, "OpenGL vsync not implemented");
365-
#endif
366-
m_activeVSyncState = configValue;
367-
}
368-
}
369365

370366
bool IsRunningInWine();
371367

@@ -443,7 +439,6 @@ void OpenGLRenderer::EnableDebugMode()
443439
void OpenGLRenderer::SwapBuffers(bool swapTV, bool swapDRC)
444440
{
445441
GLCanvas_SwapBuffers(swapTV, swapDRC);
446-
UpdateVSyncState();
447442

448443
if (swapTV)
449444
cleanupAfterFrame();

src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h

-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ class OpenGLRenderer : public Renderer
168168
GLuint m_defaultFramebufferId;
169169
GLuint m_pipeline = 0;
170170

171-
int m_activeVSyncState{};
172171
bool m_isPadViewContext{};
173172

174173
// rendertarget viewport

src/Common/GLInclude/GLInclude.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ typedef XID GLXFBConfigID;
2424
typedef struct __GLXcontextRec *GLXContext;
2525
typedef struct __GLXFBConfigRec *GLXFBConfig;
2626

27+
#define EGL_EGL_PROTOTYPES 0
28+
#include "egl.h"
29+
#undef EGL_EGL_PROTOTYPES
2730
#include "glxext.h"
2831

2932
#undef Bool
@@ -34,9 +37,11 @@ typedef struct __GLXFBConfigRec *GLXFBConfig;
3437
#endif
3538

3639
#define GLFUNC(__type, __name) extern __type __name;
40+
#define EGLFUNC(__type, __name) extern __type __name;
3741
#include "glFunctions.h"
3842
#undef GLFUNC
43+
#undef EGLFUNC
3944

4045
// this prevents Windows GL.h from being included:
4146
#define __gl_h_
42-
#define __GL_H__
47+
#define __GL_H__

0 commit comments

Comments
 (0)