Skip to content

Feature request: Linux OpenGL, or fully scalable SDL, support #70

@noabody

Description

@noabody

Would you consider supporting Linux x86_64 as a build platform with the OpenGL back-end or a fully scalable SDL implementation?

The GUI works well until the scaled aspect ratio becomes greater than 4:3? At that point the menu tilts.

Here are the patches I've been using to force OpenGL. Please keep in mind that I kludged this together because I'm NOT a programmer. I really don't know how best to implement this.

The last patch is to use an SDL Hat switch on the joystick. notaz had some concerns but I don't really know if that is an issue. See 3

diff a/picodrive/Makefile b/picodrive/Makefile
index 2903a68..bad1aa5 100644
--- a/picodrive/Makefile	1969-12-31 17:00:00.000000000 -0700
+++ b/picodrive/Makefile	1969-12-31 17:00:00.000000000 -0700
@@ -164,7 +164,8 @@ OBJS += platform/libpicofe/gl_platform.o
 USE_FRONTEND = 1
 endif
 ifeq "$(PLATFORM)" "generic"
-CFLAGS += -DSDL_OVERLAY_2X -DSDL_BUFFER_3X
+CFLAGS += -DHAVE_GLES
+LDFLAGS += -ldl -lpthread -lGL -lEGL
 OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME
 ifeq "$(use_inputmap)" "1"
 OBJS += platform/common/plat_sdl.o platform/opendingux/inputmap.o
@@ -173,6 +174,7 @@ OBJS += platform/common/plat_sdl.o platform/common/inputmap_kbd.o
 endif
 OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o
 OBJS += platform/libpicofe/plat_dummy.o platform/libpicofe/linux/plat.o
+OBJS += platform/libpicofe/gl.o platform/libpicofe/gl_platform.o
 USE_FRONTEND = 1
 endif
 ifeq "$(PLATFORM)" "pandora"
diff a/picodrive/platform/libpicofe/gl.c b/picodrive/platform/libpicofe/gl.c
--- a/picodrive/platform/libpicofe/gl.c	1969-12-31 17:00:00.000000000 -0700
+++ b/picodrive/platform/libpicofe/gl.c	1969-12-31 17:00:00.000000000 -0700
@@ -2,7 +2,11 @@
 #include <stdlib.h>
 
 #include <EGL/egl.h>
-#include <GLES/gl.h>
+#if defined(__arm__)
+  #include <GLES/gl.h>
+#else
+  #include <GL/gl.h>
+#endif
 #include "gl_platform.h"
 #include "gl.h"
 
diff a/picodrive/platform/libpicofe/gl_platform.c b/picodrive/platform/libpicofe/gl_platform.c
--- a/picodrive/platform/libpicofe/gl_platform.c	1969-12-31 17:00:00.000000000 -0700
+++ b/picodrive/platform/libpicofe/gl_platform.c	1969-12-31 17:00:00.000000000 -0700
@@ -1,7 +1,11 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <EGL/egl.h>
-#include <GLES/gl.h>
+#if defined(__arm__)
+  #include <GLES/gl.h>
+#else
+  #include <GL/gl.h>
+#endif
 
 #include "gl.h"
 #include "gl_platform.h"

diff a/picodrive/platform/libpicofe/in_sdl.c  b/picodrive/platform/libpicofe/in_sdl.c
--- a/picodrive/platform/libpicofe/in_sdl.c	1969-12-31 17:00:00.000000000 -0700
+++ b/picodrive/platform/libpicofe/in_sdl.c	1969-12-31 17:00:00.000000000 -0700
@@ -300,6 +300,34 @@
 		}
 		break;
 
+	case SDL_JOYHATMOTION:
+		if (event->jhat.which != state->joy_id)
+			return -2;
+		if (event->jhat.value == SDL_HAT_CENTERED) {
+			kc = state->axis_keydown[event->jhat.hat];
+			state->axis_keydown[event->jhat.hat] = 0;
+			ret = 1;
+		}
+		else if (event->jhat.value & SDL_HAT_UP || event->jhat.value & SDL_HAT_LEFT) {
+			kc = state->axis_keydown[event->jhat.hat];
+			if (kc)
+				update_keystate(state->keystate, kc, 0);
+			kc = (event->jhat.value & SDL_HAT_UP) ? SDLK_UP : SDLK_LEFT;
+			state->axis_keydown[event->jhat.hat] = kc;
+			down = 1;
+			ret = 1;
+		}
+		else if (event->jhat.value & SDL_HAT_DOWN || event->jhat.value & SDL_HAT_RIGHT) {
+			kc = state->axis_keydown[event->jhat.hat];
+			if (kc)
+				update_keystate(state->keystate, kc, 0);
+			kc = (event->jhat.value & SDL_HAT_DOWN) ? SDLK_DOWN : SDLK_RIGHT;
+			state->axis_keydown[event->jhat.hat] = kc;
+			down = 1;
+			ret = 1;
+		}
+		break;
+
 	case SDL_JOYBUTTONDOWN:
 	case SDL_JOYBUTTONUP:
 		if (event->jbutton.which != state->joy_id)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions