mirror of
https://github.com/libretro/snes9x.git
synced 2024-12-14 12:38:37 +00:00
Better Wayland OpenGL.
Still breaks with scale factors.
This commit is contained in:
parent
5b76a2b6c7
commit
daec5ccc57
@ -125,6 +125,11 @@ snes9x_gtk_SOURCES += \
|
||||
../c4emu.cpp
|
||||
endif
|
||||
|
||||
if WAYLAND
|
||||
snes9x_gtk_SOURCES += \
|
||||
src/gtk_wayland_helpers.cpp
|
||||
endif
|
||||
|
||||
# APU
|
||||
snes9x_gtk_SOURCES += \
|
||||
../apu/apu.cpp
|
||||
|
@ -223,9 +223,11 @@ if test yes = "$with_opengl" ; then
|
||||
LIBS="$LIBS $EPOXY_LIBS"
|
||||
fi
|
||||
|
||||
WAYLAND=0
|
||||
PKG_CHECK_MODULES([WAYLAND_EGL],[wayland-egl],[
|
||||
CFLAGS="$CFLAGS $WAYLAND_EGL_CFLAGS"
|
||||
LIBS="$LIBS $WAYLAND_EGL_LIBS"
|
||||
WAYLAND=yes
|
||||
],[
|
||||
echo "Not using Wayland-EGL."
|
||||
])
|
||||
@ -499,6 +501,7 @@ AM_CONDITIONAL(PULSEAUDIO, [test yes = "$PULSEAUDIO"])
|
||||
AM_CONDITIONAL(HQ2X, [test yes = "$HQ2X"])
|
||||
AM_CONDITIONAL(XBRZ, [test yes = "$XBRZ"])
|
||||
AM_CONDITIONAL(SYSTEM_ZIP, [test yes = "$SYSTEM_ZIP"])
|
||||
AM_CONDITIONAL(WAYLAND, [test yes = "$WAYLAND"])
|
||||
|
||||
AC_SUBST(NASM)
|
||||
AC_SUBST(NASM_FLAGS)
|
||||
|
@ -16,6 +16,14 @@
|
||||
|
||||
#include "shaders/shader_helpers.h"
|
||||
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
#define ON_WAYLAND(BLOCK) if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default())) \
|
||||
{ \
|
||||
BLOCK \
|
||||
}
|
||||
#else
|
||||
#define ON_WAYLAND(BLOCK) do {} while (0);
|
||||
#endif
|
||||
|
||||
static void S9xViewportCallback (int src_width, int src_height,
|
||||
int viewport_x, int viewport_y,
|
||||
@ -662,6 +670,12 @@ S9xOpenGLDisplayDriver::refresh (int width, int height)
|
||||
void
|
||||
S9xOpenGLDisplayDriver::resize_window (int width, int height)
|
||||
{
|
||||
ON_WAYLAND
|
||||
(
|
||||
wl.resize (width, height);
|
||||
wl.swap_interval (config->sync_to_vblank);
|
||||
return;
|
||||
)
|
||||
|
||||
gdk_window_destroy (gdk_window);
|
||||
create_window (width, height);
|
||||
@ -706,6 +720,20 @@ S9xOpenGLDisplayDriver::create_window (int width, int height)
|
||||
int
|
||||
S9xOpenGLDisplayDriver::init_gl (void)
|
||||
{
|
||||
ON_WAYLAND
|
||||
(
|
||||
gdk_window = gtk_widget_get_window (drawing_area);
|
||||
if (!wl.attach (gdk_window))
|
||||
return 0;
|
||||
|
||||
if (!wl.create_egl_context (256, 224))
|
||||
return 0;
|
||||
|
||||
wl.make_current ();
|
||||
|
||||
return 1;
|
||||
)
|
||||
|
||||
int glx_attribs[] = { GLX_RGBA, GLX_DOUBLEBUFFER, None };
|
||||
|
||||
display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
|
||||
@ -788,6 +816,11 @@ S9xOpenGLDisplayDriver::swap_control (int enable)
|
||||
{
|
||||
enable = enable ? 1 : 0;
|
||||
|
||||
ON_WAYLAND
|
||||
(
|
||||
wl.swap_interval (enable);
|
||||
)
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
const char *extensions = (const char *) glGetString (GL_EXTENSIONS);
|
||||
|
||||
@ -827,6 +860,19 @@ S9xOpenGLDisplayDriver::get_current_buffer (void)
|
||||
void
|
||||
S9xOpenGLDisplayDriver::gl_swap (void)
|
||||
{
|
||||
ON_WAYLAND
|
||||
(
|
||||
wl.swap_buffers ();
|
||||
|
||||
if (config->sync_every_frame)
|
||||
{
|
||||
usleep (0);
|
||||
glFinish ();
|
||||
}
|
||||
|
||||
return;
|
||||
)
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
glXSwapBuffers (display, xwindow);
|
||||
#endif
|
||||
@ -880,6 +926,11 @@ S9xOpenGLDisplayDriver::deinit (void)
|
||||
|
||||
glDeleteTextures (1, &texmap);
|
||||
|
||||
ON_WAYLAND
|
||||
(
|
||||
return;
|
||||
)
|
||||
|
||||
glXDestroyContext (display, glx_context);
|
||||
gdk_window_destroy (gdk_window);
|
||||
XFree (vi);
|
||||
@ -899,6 +950,11 @@ S9xOpenGLDisplayDriver::query_availability (void)
|
||||
{
|
||||
GdkDisplay *gdk_display = gdk_display_get_default ();
|
||||
|
||||
ON_WAYLAND
|
||||
(
|
||||
return 1;
|
||||
)
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
if (GDK_IS_X11_DISPLAY (gdk_display))
|
||||
{
|
||||
|
@ -9,6 +9,10 @@
|
||||
#include <epoxy/glx.h>
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
#include "gtk_wayland_helpers.h"
|
||||
#endif
|
||||
|
||||
#include "shaders/glsl.h"
|
||||
|
||||
#define PBO_FMT_16 0
|
||||
@ -85,6 +89,10 @@ class S9xOpenGLDisplayDriver : public S9xDisplayDriver
|
||||
XVisualInfo *vi;
|
||||
GLXContext glx_context;
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
wlgl_helper wl;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* __GTK_DISPLAY_DRIVER_OPENGL_H */
|
||||
|
Loading…
Reference in New Issue
Block a user