Skip to content

Commit

Permalink
Linux Port (GTK/GTK2): Remove the requirement for libGLX.so when requ…
Browse files Browse the repository at this point in the history
…esting a GLX context since libGL.so is all we need here.

- Also do some minor code cleanup in glx_3Demu.cpp
  • Loading branch information
rogerman committed Aug 2, 2024
1 parent 4427b86 commit 9aa2ddf
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 19 deletions.
2 changes: 0 additions & 2 deletions desmume/src/frontend/posix/codeblocks/desmume.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<Add option="`pkg-config --libs gtk+-2.0`" />
<Add library="/usr/lib/x86_64-linux-gnu/libGL.so" />
<Add library="/usr/lib/x86_64-linux-gnu/libGLESv2.so" />
<Add library="/usr/lib/x86_64-linux-gnu/libGLX.so" />
<Add library="/usr/lib/x86_64-linux-gnu/libOSMesa.so" />
<Add library="/usr/lib/x86_64-linux-gnu/libEGL.so" />
</Linker>
Expand Down Expand Up @@ -72,7 +71,6 @@
<Add option="`pkg-config --libs gtk+-3.0`" />
<Add library="/usr/lib/x86_64-linux-gnu/libGL.so" />
<Add library="/usr/lib/x86_64-linux-gnu/libGLESv2.so" />
<Add library="/usr/lib/x86_64-linux-gnu/libGLX.so" />
<Add library="/usr/lib/x86_64-linux-gnu/libOSMesa.so" />
<Add library="/usr/lib/x86_64-linux-gnu/libEGL.so" />
</Linker>
Expand Down
6 changes: 0 additions & 6 deletions desmume/src/frontend/posix/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,12 @@ if test "x$glx" = "xyes" ; then
AC_CHECK_HEADERS([GL/glx.h], [have_glx=yes], [have_glx=no])
if test "have_glx" = "no" ; then
AC_MSG_WARN([Cannot use GLX -- headers not found.])
else
AC_CHECK_LIB(dl, main)
AC_CHECK_LIB(GL, main)
AC_CHECK_LIB(GLX, main)
fi
fi

if test "$have_glx" = "yes" ; then
if test "$have_opengl" = "yes" ; then
AC_DEFINE(ENABLE_GLX)
GLX_LIBS="-lGLX"
AC_SUBST(GLX_LIBS)
else
have_glx=no
if test "$have_opengles" = "yes" ; then
Expand Down
1 change: 0 additions & 1 deletion desmume/src/frontend/posix/gtk/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ endif
endif

if ENABLE_GLX
desmume_LDADD += $(GLX_LIBS)
desmume_SOURCES += ../shared/glx_3Demu.h ../shared/glx_3Demu.cpp
else
if ENABLE_OSMESA
Expand Down
2 changes: 1 addition & 1 deletion desmume/src/frontend/posix/gtk/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ desmume_src = [
gresource,
]

if get_option('glx') and dep_glx.found()
if get_option('glx') and dep_gl.found()
desmume_src += [
'../shared/glx_3Demu.cpp',
]
Expand Down
1 change: 0 additions & 1 deletion desmume/src/frontend/posix/gtk2/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ endif
endif

if ENABLE_GLX
desmume_LDADD += $(GLX_LIBS)
desmume_SOURCES += ../shared/glx_3Demu.h ../shared/glx_3Demu.cpp
else
if ENABLE_OSMESA
Expand Down
2 changes: 1 addition & 1 deletion desmume/src/frontend/posix/gtk2/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ desmume_src = [
'main.cpp',
]

if get_option('glx') and dep_glx.found()
if get_option('glx') and dep_gl.found()
desmume_src += [
'../shared/glx_3Demu.cpp',
]
Expand Down
8 changes: 3 additions & 5 deletions desmume/src/frontend/posix/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ dep_alsa = dependency('alsa', required: false)
dep_soundtouch = dependency('soundtouch', required: false)
dep_agg = dependency('libagg', required: false)
dep_fontconfig = dependency('fontconfig', required: false)
dep_glx = dependency('glx', required: false)
dep_osmesa = dependency('osmesa', required: false)
dep_egl = dependency('egl', required: false)

Expand Down Expand Up @@ -198,17 +197,16 @@ elif get_option('opengl')
endif

if get_option('glx')
if dep_glx.found()
if get_option('opengl') and dep_gl.found()
if dep_gl.found()
if get_option('opengl')
add_global_arguments('-DENABLE_GLX', language: ['c', 'cpp'])
dependencies += dep_glx
elif get_option('opengles')
message('GLX contexts are incompatible with OpenGL ES -- cancelling the use of GLX.')
else
message('GLX contexts are only compatible with standard OpenGL -- cancelling the use of GLX.')
endif
else
message('Cannot use GLX -- glx library not found.')
message('Cannot use GLX -- gl library not found.')
endif
elif get_option('osmesa')
if dep_osmesa.found()
Expand Down
4 changes: 2 additions & 2 deletions desmume/src/frontend/posix/shared/glx_3Demu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static bool __glx_initOpenGL(const int requestedProfile, const int requestedVers
const char *extensionSet = glXQueryExtensionsString(currDisplay, currScreen);

const char *foundString = strstr(extensionSet, "GLX_ARB_create_context_profile");
glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddressARB( (const GLubyte *) "glXCreateContextAttribsARB");
glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress( (const GLubyte *) "glXCreateContextAttribsARB");

if ( (foundString == NULL) || (glXCreateContextAttribsARB == NULL) )
{
Expand Down Expand Up @@ -273,7 +273,7 @@ bool glx_beginOpenGL()
prevReadDrawable = glXGetCurrentReadDrawable();
prevContext = glXGetCurrentContext();

if (pendingDrawable != NULL)
if (pendingDrawable != 0)
{
bool previousIsCurrent = (prevDrawDrawable == currDrawable);

Expand Down

0 comments on commit 9aa2ddf

Please sign in to comment.