desmume icon indicating copy to clipboard operation
desmume copied to clipboard

Compilation error (OGL, emscripten)

Open BinBashBanana opened this issue 3 years ago • 10 comments

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 avatar Mar 25 '21 02:03 BinBashBanana

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)

BinBashBanana avatar Mar 28 '21 17:03 BinBashBanana

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.

bearoso avatar Mar 28 '21 18:03 bearoso

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?

BinBashBanana avatar Mar 29 '21 18:03 BinBashBanana

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.

bearoso avatar Mar 29 '21 23:03 bearoso

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

BinBashBanana avatar Mar 29 '21 23:03 BinBashBanana

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

BinBashBanana avatar Apr 04 '21 02:04 BinBashBanana

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

kurai021 avatar Oct 19 '21 13:10 kurai021

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

BinBashBanana avatar Oct 19 '21 14:10 BinBashBanana

don't worry hopefully one day it will work

kurai021 avatar Oct 20 '21 01:10 kurai021

It seems that ever since, the build for emscripten has been fixed, but I still can't get it working.

@BinBashBanana , I did successfully build it, even using your suggestions from your webretro repository, but unfortunately it still doesn't work.

I can get stdio logs of desmume running, but the canvas would not show anything, it just stays black.

Did you have any luck with it so far?

arleypadua avatar Aug 28 '24 14:08 arleypadua