libretro / OpenLara

Classic Tomb Raider open-source engine
BSD 2-Clause "Simplified" License
12 stars 17 forks source link

Trying to build on GLES platforms fails #14

Open vanfanel opened 5 years ago

vanfanel commented 5 years ago

@alfrix:

I was trying to get this core to build on non-Xorg, GLES-based platforms like the Raspberry Pi or any X86 PC with no Xorg server running (RetroArch is know for running on KMS/DRM+GLES) but it fails:

../../gapi_gl.h:92:24: fatal error: GL/glx.h: No such file or directory
     #include <GL/glx.h>
                        ^
compilation terminated.

I am forcing compilation by defining a non-Xorg OS on core.h like this:

#elif __KMSDRM__
    #define _OS_KMSDRM 1
    #define _GAPI_GL   1
    #define _GAPI_GLES 1

    #define DYNGEOM_NO_VBO

and also using that OS on gapi_gl.h like this on line 48:

#elif defined(_OS_RPI) || defined(_OS_CLOVER) || defined(_OS_KMSDRM)

Then I added a new platform definition on the libretro platform Makefile, like this:

else ifeq ($(platform), rpi)
   TARGET := $(TARGET_NAME)_libretro.so
   fpic := -fPIC
   SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
   CXXFLAGS += -D__KMSDRM__
   CFLAGS += -D__KMSDRM__
   LIBS += -lpthread
   GLES = 1

And then it builds on the X-less Pi as intended, but all I get on loading PSX data is a segfault... Can you please test?

alfrix commented 5 years ago

I'm sorry, but i don't have a rpi or similar platform to test this

El lun., 10 de dic. de 2018 19:02, Manuel Alfayate Corchete < notifications@github.com> escribió:

@alfrix https://github.com/alfrix:

I was trying to get this core to build on non-Xorg, GLES-based platforms like the Raspberry Pi or any X86 PC with no Xorg server running (RetroArch is know for running on KMS/DRM+GLES) but it fails:

../../gapi_gl.h:92:24: fatal error: GL/glx.h: No such file or directory

include <GL/glx.h>

                    ^

compilation terminated.

I am forcing compilation by defining a non-Xorg OS on core.h like this:

elif KMSDRM

#define _OS_KMSDRM 1
#define _GAPI_GL   1
#define _GAPI_GLES 1

#define DYNGEOM_NO_VBO

and also using that OS on gapi_gl.h like this on line 48:

elif defined(_OS_RPI) || defined(_OS_CLOVER) || defined(_OS_KMSDRM)

Then I added a new platform definition on the libretro platform Makefile, like this:

else ifeq ($(platform), rpi) TARGET := $(TARGET_NAME)_libretro.so fpic := -fPIC SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined CXXFLAGS += -DKMSDRM CFLAGS += -DKMSDRM LIBS += -lpthread GLES = 1

And then it builds on the X-less Pi as intended, but all I get on loading PSX data is a segfault... Can you please test?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/libretro/OpenLara/issues/14, or mute the thread https://github.com/notifications/unsubscribe-auth/ABMIBf6bg4e-KSQngkpYZQGbfWNUHMhcks5u3tnZgaJpZM4ZMQ8T .

vanfanel commented 5 years ago

@alfrix : Any GNU/Linux PC will do.

vanfanel commented 5 years ago

@alfrix : Trying to build a GLES version with current sources I get this:

../../gapi_gl.h:194:45: error: ‘void (* glGenerateMipmap)(GLenum)’ redeclared as different kind of symbol
         PFNGLGENERATEMIPMAPPROC             glGenerateMipmap;
                                             ^~~~~~~~~~~~~~~~
In file included from ./libretro-common/include/glsym/rglgen_headers.h:55,
                 from ./libretro-common/include/glsym/rglgen.h:32,
                 from ./libretro-common/include/glsym/glsym.h:26,
                 from main.cpp:7:
/usr/include/GLES2/gl2.h:576:29: note: previous declaration ‘void glGenerateMipmap(GLenum)’
 GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target);
                             ^~~~~~~~~~~~~~~~
In file included from ../../core.h:607,
                 from ../../game.h:4,
                 from main.cpp:11:
../../gapi_gl.h:207:45: error: ‘GLuint (* glCreateProgram)()’ redeclared as different kind of symbol
         PFNGLCREATEPROGRAMPROC              glCreateProgram;
                                             ^~~~~~~~~~~~~~~
In file included from ./libretro-common/include/glsym/rglgen_headers.h:55,
                 from ./libretro-common/include/glsym/rglgen.h:32,
                 from ./libretro-common/include/glsym/glsym.h:26,
                 from main.cpp:7:
/usr/include/GLES2/gl2.h:551:31: note: previous declaration ‘GLuint glCreateProgram()’
 GL_APICALL GLuint GL_APIENTRY glCreateProgram (void);
                               ^~~~~~~~~~~~~~~
In file included from ../../core.h:607,
                 from ../../game.h:4,
                 from main.cpp:11:

It's much longer, but you get the idea. I believe something is wrong with these redefinitions... I use MESA GLES implementation, the most common in GNU/Linux.

alfrix commented 5 years ago

you cannot just turn GLES on linux, you need to extensively modify gapi_gl to add your platform, otherwise it will assume desktop GL each time there is an defined(_OS_LINUX),

vanfanel commented 5 years ago

@alfrix : but "my platform" is libretro, as in src/platform/libretro. Asuming that Linux=DesktopGL is just plain wrong, as GLES/GLES2 is also widely used in Linux.

Is this core supposed to build on something like the Raspberry Pi?

alfrix commented 5 years ago

i have only tested fedora and ubuntu, i have never seen a x86 distro that comes with gles but not gl, i'm no expert but you can tell by looking at the code, rpi is treated differently, but again i cannot test it, if you have it, try to fix it and make a PR

vanfanel commented 5 years ago

@alfrix : Desktop GNU/Linux distros are not to be used as a reference when it comes to libretro cores, since LR/RA main point is being able to run the cores in WAY more different ways inside the Linux ecosystem, like SBCs (Pi, etc), consoles (NES/SNES/PSX Classics), etc...

I will give it a go, but I need your help. Can I meet you on IRC or any other method for a fluid comunication?

alfrix commented 5 years ago

Most LR/RA devs, including maintainers hangout on the Discord channel ask your question directly on #programming https://discord.gg/GZJKWjJ the IRC channel is much less populated http://webchat.freenode.net/?channels=%23retroarch&uio=d4 note that there is a bridge (retrobot) between IRC and discord of the channel #retroarch

vanfanel commented 5 years ago

@alfrix : I don't need general RA/LR or programming advice, but help with the OpenLara core, so I need to contact you.

alfrix commented 5 years ago

i go there regularly, you can PM me if you prefer it, once you join the channel. you can also find xproger in https://discord.gg/6mc4Jw

vanfanel commented 5 years ago

@alfrix : Does xprogger also collaborate in the libretro port?

XProger commented 5 years ago

@vanfanel I'll help all I can :)

vanfanel commented 5 years ago

@XProger : Do you use IRC? What server/channel?

XProger commented 5 years ago

@vanfanel nope, only discord and telegram

vanfanel commented 5 years ago

Can you guys send me a new invite or tell me how to join again? This discord stuff is new to me...

alfrix commented 5 years ago

TombRaider https://discord.gg/3JUqPgV https://discord.gg/3JUqPgV Libretro: https://discord.gg/GZJKWjJ https://discord.gg/GZJKWjJ

El sáb., 29 de dic. de 2018 a la(s) 14:39, Manuel Alfayate Corchete ( notifications@github.com) escribió:

Can you guys send me a new invite or tell me how to join again? This discord stuff is new to me...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/libretro/OpenLara/issues/14#issuecomment-450508413, or mute the thread https://github.com/notifications/unsubscribe-auth/ABMIBVSIv4_eeSIKqN5eFV8WV7F4RfAAks5u96jugaJpZM4ZMQ8T .

-- Alfredo Monclus

vanfanel commented 5 years ago

@alfrix @XProger

I am writting concise instructions to build OpenLara on RetroArch using GLES instead of Desktop OpenGL. It's very easy and NO Raspberry Pi is needed, any desktop GNU/Linux computer will do, because MESA has GLES implemented for desktop systems too.

1) Build RetroArch in GLES mode: ./configure --enable-opengles --disable-qt make

2) Try to build OpenLara Libretro for GLES: make GLES=1

You can easily see why it fails. It's the only core not compatible with GLES on Linux, but I am sure it's easy for you to fix it, since the core itself has GLES code already (in fact, this core is supposed to run on the Switch, which only has GLES, isn't it?).

vanfanel commented 5 years ago

@vanfanel @XProger I just fixed this. OpenLara LibRetro now works on GLES RetroArch too:

https://github.com/libretro/OpenLara/pull/20

vanfanel2 commented 5 years ago

@alfrix : GLES is broken again (it builds, but does not display anything). It's not your fault. Please merge latest upstream changes to get it working again.