libretro / desmume

DeSmuME is a Nintendo DS emulator
http://desmume.org
GNU General Public License v2.0
35 stars 33 forks source link

Compilation error (OGL, emscripten) #84

Open BinBashBanana opened 3 years ago

BinBashBanana commented 3 years ago

Hello, I am trying to build desmume for emscripten, and I want to use desmume gl. After modifiying wifi.cpp to support emscripten, I edited the emscripten section of Makefile.libretro to look like this:

# Emscripten
else ifeq ($(platform), emscripten)
   TARGET := $(TARGET_NAME)_libretro_$(platform).bc
   LIBS := -lpthread -lpcap -lGL
   CXXFLAGS += -DHAVE_OPENGL
   DESMUME_OPENGL = 1
   STATIC_LINKING = 1

I also edited OGLRender.h to include my system glx.h because for some reason the current one wasn't working.

The inital build works fine, but when I try to link it in the RetroArch repository, it fails with messages like this one:

LD desmume_libretro.js
wasm-ld: error: symbol type mismatch: glDeleteBuffers
>>> defined as WASM_SYMBOL_TYPE_FUNCTION in obj-emscripten/gfx/drivers/gl.o
>>> defined as WASM_SYMBOL_TYPE_DATA in libretro_emscripten.bc(OGLRender.o)

Is this easily fixable, or is this not supported yet?

BinBashBanana commented 3 years ago

I tried adding these to makefile.emscripten, which changed the error, but it still doesn't work.

HAVE_OPENGLES = 0
HAVE_GL_CONTEXT = 1
HAVE_GL_MODERN = 1
HAVE_OPENGL = 1

New error:

LD desmume_libretro.js
warning: undefined symbol: _Z21OGLCreateRenderer_3_2PP14OpenGLRenderer (referenced by top-level compiled C/C++ code)
warning: undefined symbol: _Z22OGLLoadEntryPoints_3_2v (referenced by top-level compiled C/C++ code)
warning: undefined symbol: glActiveTextureARB (referenced by top-level compiled C/C++ code)
warning: undefined symbol: glAlphaFunc (referenced by top-level compiled C/C++ code)
warning: undefined symbol: glColorPointer (referenced by top-level compiled C/C++ code)
warning: undefined symbol: glDisableClientState (referenced by top-level compiled C/C++ code)
warning: undefined symbol: glDrawBuffer (referenced by top-level compiled C/C++ code)
warning: undefined symbol: glEnableClientState (referenced by top-level compiled C/C++ code)
warning: undefined symbol: glReadBuffer (referenced by top-level compiled C/C++ code)
warning: undefined symbol: glScalef (referenced by top-level compiled C/C++ code)
warning: undefined symbol: glTexCoordPointer (referenced by top-level compiled C/C++ code)
warning: undefined symbol: glTexEnvi (referenced by top-level compiled C/C++ code)
warning: undefined symbol: glTexImage1D (referenced by top-level compiled C/C++ code)
warning: undefined symbol: glTexSubImage1D (referenced by top-level compiled C/C++ code)
warning: undefined symbol: glXGetProcAddress (referenced by top-level compiled C/C++ code)
warning: undefined symbol: pthread_attr_setschedpolicy (referenced by top-level compiled C/C++ code)
bearoso commented 3 years ago

emscripten can't work with OpenGL like that. You'd have to create a port to WebGL or WebGPU. Also, wifi won't work either, and compiling with pthread is bad, too.

Basically, you're trying to do something that requires much, much bigger changes.

BinBashBanana commented 3 years ago

I got it down to only these 2 errors:

LD desmume_libretro.js
error: undefined symbol: _Z21OGLCreateRenderer_3_2PP14OpenGLRenderer (referenced by top-level compiled C/C++ code)
error: undefined symbol: _Z22OGLLoadEntryPoints_3_2v (referenced by top-level compiled C/C++ code)

Do you know how to fix them? Or were you saying that even if they were fixed, it wouldn't work?

bearoso commented 3 years ago

It won't work if you're trying to use the GLX path. Desmume does context creation manually for only a few platform contexts. emscripten most likely won't wrap that code automatically.

BinBashBanana commented 3 years ago

I'm using EGL, where is the code for context creation so I can add it?

BinBashBanana commented 3 years ago

Oh... it might be a better idea to use GLES, is there a way to do that?

kurai021 commented 2 years ago

@BinBashBanana have you had any luck with this? it's a pity there is no working port for Emscripten.

BinBashBanana commented 2 years ago

No... though I now better understand how some of the GL stuff works... a little. Sorry.

kurai021 commented 2 years ago

don't worry hopefully one day it will work