emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.91k stars 3.32k forks source link

Porting Descent #3753

Closed jeffguy closed 5 years ago

jeffguy commented 9 years ago

I don't know if this is the right place to post. If not, where would you suggest asking this question?

I'm trying to port Descent 1 (google dxx rebirth) to the browser. I have worked through a bunch of issues, and am getting errors in the link step. In summary, my errors follow these patterns:

warning: unresolved symbol: SDL_GetRelativeMouseState
warning: unresolved symbol: glAlphaFunc
warning: Legacy GL function (glMatrixMode) called. You need to compile with -s LEGACY_GL_EMULATION=1 to enable legacy GL emulation.
warning: unresolved symbol: gluBuild2DMipmaps
warning: unresolved symbol: Mix_SetDistance
warning: unresolved symbol: inflateEnd
aborting from js compiler due to exception: unknown vector type <4 x i16> | undefined

I see references on the web that mention glAlphaFunc not being implemented, but when I look at emscripten's source (which I used to build), I see it defined.

I'd appreciate any help you can give!

My link command is:

emcc -o d1x-rebirth.html 2d/2dsline.o 2d/bitblt.o 2d/bitmap.o 2d/box.o 2d/canvas.o 2d/circle.o 2d/disc.o 2d/font.o 2d/gpixel.o 2d/line.o 2d/palette.o 2d/pcx.o 2d/pixel.o 2d/poly.o 2d/rect.o 2d/rle.o 2d/scalec.o 3d/clipper.o 3d/draw.o 3d/globvars.o 3d/instance.o 3d/interp.o 3d/matrix.o 3d/points.o 3d/rod.o 3d/setup.o arch/sdl/event.o arch/sdl/init.o arch/sdl/joy.o arch/sdl/key.o arch/sdl/mouse.o arch/sdl/rbaudio.o arch/sdl/timer.o arch/sdl/window.o arch/sdl/digi.o arch/sdl/digi_audio.o iff/iff.o main/ai.o main/aipath.o main/automap.o main/bm.o main/bmread.o main/cntrlcen.o main/collide.o main/config.o main/console.o main/controls.o main/credits.o main/custom.o main/digiobj.o main/dumpmine.o main/effects.o main/endlevel.o main/fireball.o main/fuelcen.o main/fvi.o main/game.o main/gamecntl.o main/gamefont.o main/gamemine.o main/gamerend.o main/gamesave.o main/gameseg.o main/gameseq.o main/gauges.o main/hostage.o main/hud.o main/inferno.o main/kconfig.o main/kmatrix.o main/laser.o main/lighting.o main/menu.o main/mglobal.o main/mission.o main/morph.o main/multi.o main/multibot.o main/newdemo.o main/newmenu.o main/object.o main/paging.o main/physics.o main/piggy.o main/player.o main/playsave.o main/polyobj.o main/powerup.o main/render.o main/robot.o main/scores.o main/slew.o main/snddecom.o main/songs.o main/state.o main/switch.o main/terrain.o main/texmerge.o main/text.o main/titles.o main/vclip.o main/wall.o main/weapon.o maths/fixc.o maths/rand.o maths/tables.o maths/vecmat.o mem/mem.o misc/args.o misc/dl_list.o misc/error.o misc/hash.o misc/hmp.o misc/ignorecase.o misc/physfsx.o misc/strio.o misc/strutil.o texmap/ntmap.o texmap/scanline.o arch/ogl/gr.o arch/ogl/ogl.o arch/sdl/digi_mixer.o arch/sdl/digi_mixer_music.o arch/sdl/jukebox.o main/net_udp.o main/vers_id.o ../physfs-2.0.3/build/libphysfs.bc

My full error list is:

warning: unresolved symbol: SDL_GetRelativeMouseState
warning: unresolved symbol: glAlphaFunc
warning: unresolved symbol: glReadBuffer
warning: Legacy GL function (glMatrixMode) called. You need to compile with -s LEGACY_GL_EMULATION=1 to enable legacy GL emulation.
warning: Legacy GL function (glLoadIdentity) called. You need to compile with -s LEGACY_GL_EMULATION=1 to enable legacy GL emulation.
warning: unresolved symbol: glOrtho
warning: unresolved symbol: glPointSize
warning: unresolved symbol: glEnableClientState
warning: Legacy GL function (glVertexPointer) called. You need to compile with -s LEGACY_GL_EMULATION=1 to enable legacy GL emulation.
warning: unresolved symbol: glColorPointer
warning: unresolved symbol: glDisableClientState
warning: unresolved symbol: glPushMatrix
warning: unresolved symbol: glTranslatef
warning: unresolved symbol: glScalef
warning: unresolved symbol: glPopMatrix
warning: unresolved symbol: glColor4f
warning: unresolved symbol: glTexCoordPointer
warning: unresolved symbol: glShadeModel
warning: unresolved symbol: glGetTexLevelParameteriv
warning: unresolved symbol: glPrioritizeTextures
warning: unresolved symbol: glTexEnvi
warning: unresolved symbol: gluBuild2DMipmaps
warning: unresolved symbol: SDL_BuildAudioCVT
warning: unresolved symbol: SDL_ConvertAudio
warning: unresolved symbol: Mix_SetDistance
warning: unresolved symbol: inflateEnd
warning: unresolved symbol: inflateInit2_
warning: unresolved symbol: inflate
aborting from js compiler due to exception: unknown vector type <4 x i16> | undefined
Stack: Error
    at assertTrue (eval at globalEval (/usr/share/emscripten/src/compiler.js:105:8), <anonymous>:59:26)
    at eval (eval at globalEval (/usr/share/emscripten/src/compiler.js:105:8), <anonymous>:932:13)
    at Array.forEach (native)
    at eval (eval at globalEval (/usr/share/emscripten/src/compiler.js:105:8), <anonymous>:296:21)
    at Array.forEach (native)
    at legalizer (eval at globalEval (/usr/share/emscripten/src/compiler.js:105:8), <anonymous>:291:22)
    at analyzer (eval at globalEval (/usr/share/emscripten/src/compiler.js:105:8), <anonymous>:1768:3)
    at JSify (eval at globalEval (/usr/share/emscripten/src/compiler.js:105:8), <anonymous>:112:13)
    at runPhase (/usr/share/emscripten/src/compiler.js:281:5)
    at compile (/usr/share/emscripten/src/compiler.js:301:5)
aborting from js compiler due to exception: Assertion failed: Could not legalize illegal line: 965,// {
//   "tokens": null,
//   "indent": 2,
//   "lineNum": 965,
//   "assignTo": "$broadcast_splatinsert9",
//   "intertype": "insertelement",
//   "type": "<2 x i16>",
//   "ident": "0",
//   "value": {
//     "intertype": "value",
//     "ident": "$66",
//     "type": "i16"
//   },
//   "index": {
//     "intertype": "value",
//     "ident": "0",
//     "type": "i32"
//   }
// } | undefined
aborting from js compiler due to exception: unknown vector type <2 x i16> | undefined
aborting from js compiler due to exception: unknown vector type i32 | undefined
warning: Casting a function pointer type to a potentially incompatible one (use -s VERBOSE=1 to see more)
warning: See https://github.com/kripken/emscripten/wiki/CodeGuidelinesAndLimitations#function-pointer-issues for more information on dangerous function pointer casts
aborting from js compiler due to exception: unknown vector type <4 x i8> | undefined
Traceback (most recent call last):
  File "/usr/share/emscripten/emscripten.py", line 1352, in <module>
    _main(environ=os.environ)
  File "/usr/share/emscripten/emscripten.py", line 1340, in _main
    temp_files.run_and_clean(lambda: main(
  File "/usr/share/emscripten/tools/tempfiles.py", line 39, in run_and_clean
    return func()
  File "/usr/share/emscripten/emscripten.py", line 1348, in <lambda>
    DEBUG_CACHE=DEBUG_CACHE,
  File "/usr/share/emscripten/emscripten.py", line 1235, in main
    jcache=jcache, temp_files=temp_files, DEBUG=DEBUG, DEBUG_CACHE=DEBUG_CACHE)
  File "/usr/share/emscripten/emscripten.py", line 292, in emscript
    assert len(output) == 2, 'Did not receive forwarded data in an output - process failed? We only got: ' + output[0][-3000:]
AssertionError: Did not receive forwarded data in an output - process failed? We only got: ($110)+(1))|0)]<<8)|(HEAPU8[((($110)+(2))|0)]<<16)|(HEAPU8[((($110)+(3))|0)]<<24))|0));
 var $171=$170;
 var $172=(($111+$171)|0);
 tempBigInt=$172;HEAP8[($110)]=tempBigInt&0xff;tempBigInt = tempBigInt>>8;HEAP8[((($110)+(1))|0)]=tempBigInt&0xff;tempBigInt = tempBigInt>>8;HEAP8[((($110)+(2))|0)]=tempBigInt&0xff;tempBigInt = tempBigInt>>8;HEAP8[((($110)+(3))|0)]=tempBigInt&0xff;
 label=44;break;
 case 44: 
 var $174=$166&1;
 var $175=(($174<<16)>>16)==0;
 if($175){label=46;break;}else{label=45;break;}
 case 45: 
 var $177=(($palette)|0);
 var $178$0=_PHYSFS_read($14,$177,3,256);
 var $178$1=tempRet0;
 var $179=(($colormap)|0);
 var $180=(($freq)|0);
 _build_colormap_good($177,$179,$180);
 var $181=(($colormap+255)|0);
 HEAP8[($181)]=-1;
 var $182=((((HEAPU8[($84)])|(HEAPU8[((($84)+(1))|0)]<<8)|(HEAPU8[((($84)+(2))|0)]<<16)|(HEAPU8[((($84)+(3))|0)]<<24))|0));
 var $183=$ptr_2;
 var $184=$182;
 var $185=((($183)-($184))|0);
 _decode_data($182,$185,$179,$180);
 label=46;break;
 case 46: 
 var $187=_PHYSFS_close($14);
 var $188=HEAP32[((2346416)>>2)];
 var $189=(($188+56)|0);
 HEAP32[(($189)>>2)]=$31;
 var $190=HEAP32[((2346416)>>2)];
 var $191=(($190+60)|0);
 HEAP16[(($191)>>1)]=0;
 var $192=HEAP32[((2346416)>>2)];
 var $193=(($192+62)|0);
 HEAP16[(($193)>>1)]=0;
 _ogl_init_font($31);
 var $_0=$31;label=47;break;
 case 47: 
 var $_0;
 STACKTOP=sp;return $_0;
  default: assert(0, "bad label: " + label);
 }

}

function _gr_set_curfont($new){
 var label=0;

 var $1=HEAP32[((2346416)>>2)];
 var $2=(($1+56)|0);
 HEAP32[(($2)>>2)]=$new;
 return;
}

function _gr_set_fontcolor($fg_color,$bg_color){
 var label=0;

 var $1=(($fg_color)&65535);
 var $2=HEAP32[((2346416)>>2)];
 var $3=(($2+60)|0);
 HEAP16[(($3)>>1)]=$1;
 var $4=(($bg_color)&65535);
 var $5=HEAP32[((2346416)>>2)];
 var $6=(($5+62)|0);
 HEAP16[(($6)>>1)]=$4;
 return;
}

function _gr_gpixel($bitmap,$x,$y){
 var label=0;

 label = 1; 
 while(1)switch(label){
 case 1: 
 var $1=$y|$x;
 var $2=($1|0)<0;
 if($2){var $_0=0;label=7;break;}else{label=2;break;}
 case 2: 
 var $4=(($bitmap+4)|0);
 var $5=HEAP16[(($4)>>1)];
 var $6=(($5<<16)>>16);
 var $7=($6|0)>($x|0);
 if($7){label=3;break;}else{var $_0=0;label=7;break;}
 case 3: 
 var $9=(($bitmap+6)|0);
 var $10=HEAP16[(($9)>>1)];
 var $11=(($10<<16)>>16);
 var $12=($11|0)>($y|0);
 if($12){label=4;break;}else{var $_0=0;label=7;break;}
 case 4: 
 var $14=(($bitmap+8)|0);
 var $15=HEAP8[($14)];
 var $16=(($15<<24)>>24);
 if(($16|0)==0){ label=5;break;}else if(($16|0)==5){ label=6;break;}else{var $_0=0;label=7;break;}
 case 5: 
 var $18=(($bitmap+10)|0);
 var $19=HEAP16[(($18)>>1)];
 var $20=(($19<<16)>>16);
 var $21=(Math_imul($20,$y)|0);
 var $22=((($21)+($x))|0);
 var $23=(($bitmap+12)|0);
 var $24=HEAP32[(($23)>>2)];
 var $25=(($24+$22)|0);
 var $26=HEAP8[($25)];
 var $_0=$26;label=7;break;
 case 6: 
 var $28=_ogl_ugpixel($bitmap,$x,$y);
 var $_0=$28;label=7;break;
 case 7: 
 var $_0;
 return $_0;
  default: assert(0, "bad label: " + label);
 }

}

Traceback (most recent call last):
  File "/usr/bin/emcc", line 1864, in <module>
    final = shared.Building.emscripten(final, append_ext=False, extra_args=extra_args)
  File "/usr/share/emscripten/tools/shared.py", line 1276, in emscripten
    assert os.path.exists(filename + '.o.js') and len(open(filename + '.o.js', 'r').read()) > 0, 'Emscripten failed to generate .js: ' + str(compiler_output)
AssertionError: Emscripten failed to generate .js: 
kripken commented 9 years ago

Emscripten has partial support for emulating various GL methods not in ES2. As mentioned in that output, you need to compile with -s LEGACY_GL_EMULATION=1 to enable that. That should get rid of most of those errors.

I would also strongly recommend using a new version of emscripten, based on the output that one looks quite old.

jeffguy commented 9 years ago

Good catch. I'm using emscripten 1.10, which is the version in the Ubuntu 14.04 repo. I'm trying to get llvm-3.7 to build so I can use emscripten 1.34. Then I'll give it another shot.

kripken commented 9 years ago

Just to be sure, you need not stock llvm 3.7, but emscripten's fork of llvm, or get the sdk.

jeffguy commented 9 years ago

Oh! I was going down the wrong path. I'll look at that tonight. Thanks!

On Tue, Sep 8, 2015 at 2:30 PM, Alon Zakai notifications@github.com wrote:

Just to be sure, you need not stock llvm 3.7, but emscripten's fork of llvm http://kripken.github.io/emscripten-site/docs/building_from_source/building_fastcomp_manually_from_source.html, or get the sdk.

— Reply to this email directly or view it on GitHub https://github.com/kripken/emscripten/issues/3753#issuecomment-138661946 .

jeffguy commented 9 years ago

Summary: I got further, but am having trouble with getting emcc to recognize "-s LEGACY_GL_EMULATION=1". Where should I put this flag? Thanks!

Details: Thanks for your help! I was able to download and build emscripten and dependencies from emsdk_portable. libphysfs needed a minor modification to point at emsdk_portable/emscripten/tag-1.34.7/tests/zlib/zlib.h. emcc --version says: emcc (Emscripten gcc/clang-like replacement) 1.34.7 () Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt) This is free and open source software under the MIT license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Then i tried compiling descent, one step was: $ emcc -o arch/ogl/ogl.o -c -std=gnu99 -Wall -funsigned-char -Werror=implicit-int -Werror=implicit-function-declaration -pthread -O2 -DLINUX -DHAVE_STRUCT_TIMESPEC -DHAVE_STRUCT_TIMEVAL -D_GNU_SOURCE=1 -D_REENTRANT -DNETWORK -DDXX_VERSION_MAJORi=0 -DDXX_VERSION_MINORi=58 -DDXX_VERSION_MICROi=1 -DOGL -DNO_ASM -DUSE_SDLMIXER -DNDEBUG -DRELEASE -DUSE_UDP -DUSE_TRACKER -DSHAREPATH=\"/usr/local/share/games/d1x-rebirth/\" -I../physfs-2.0.3 -Iarch/linux/include -Iinclude -Imain -Iarch/include arch/ogl/ogl.c In file included from arch/ogl/ogl.c:53: In file included from main/playsave.h:24: In file included from main/kconfig.h:26: arch/include/key.h:190:2: error: unknown type name 'SDLKey' SDLKey sym; ^ 1 error generated. ERROR root: compiler frontend failed to generate LLVM bitcode, halting

I remember you mentioning LEGACY_GL_EMULATION=1, and I ran $ grep -R SDLKey emsdk_portable emsdk_portable/emscripten/tag-1.34.7/system/include/SDL/SDL_compat.h:#define SDLKey SDL_Keycode

That seems to confirm that I want legacy gl emulation, so I tried: $ emcc -s LEGACY_GL_EMULATION=1 -o arch/ogl/ogl.o -c -std=gnu99 -Wall -funsigned-char -Werror=implicit-int -Werror=implicit-function-declaration -pthread -O2 -DLINUX -DHAVE_STRUCT_TIMESPEC -DHAVE_STRUCT_TIMEVAL -D_GNU_SOURCE=1 -D_REENTRANT -DNETWORK -DDXX_VERSION_MAJORi=0 -DDXX_VERSION_MINORi=58 -DDXX_VERSION_MICROi=1 -DOGL -DNO_ASM -DUSE_SDLMIXER -DNDEBUG -DRELEASE -DUSE_UDP -DUSE_TRACKER -DSHAREPATH=\"/usr/local/share/games/d1x-rebirth/\" -I../physfs-2.0.3 -Iarch/linux/include -Iinclude -Imain -Iarch/include arch/ogl/ogl.c In file included from arch/ogl/ogl.c:53: In file included from main/playsave.h:24: In file included from main/kconfig.h:26: arch/include/key.h:190:2: error: unknown type name 'SDLKey' SDLKey sym; ^ 1 error generated. ERROR root: compiler frontend failed to generate LLVM bitcode, halting

This looks rather the same, as though I'm not successfully enabling LEGACY_GL_EMULATION. Where should I put the -s flag?

Thanks again for all your help!

On Tue, Sep 8, 2015 at 2:30 PM, Alon Zakai notifications@github.com wrote:

Just to be sure, you need not stock llvm 3.7, but emscripten's fork of llvm http://kripken.github.io/emscripten-site/docs/building_from_source/building_fastcomp_manually_from_source.html, or get the sdk.

— Reply to this email directly or view it on GitHub https://github.com/kripken/emscripten/issues/3753#issuecomment-138661946 .

kripken commented 9 years ago

SDL and GL emulation are not related. I'm not sure what that SDLKey problem is - is sdl1 or 2 being used? And is it using the sdl headers from emscripten, or something in the local system (which would be bad)?

emcc -s LEGACY_GL_EMULATION=1 should be done for GL emulation, when compiling bitcode to JS, in the "link" stage. It has no effect when building to bitcode (with commands like -o arch/ogl/ogl.o, .o files contain bitcode).

jeffguy commented 9 years ago

Thanks for making that distinction. SDLKey is only referenced in two files. I think I should be able to patch that out. I'll try tomorrow, after some good sleep.

jeffguy commented 9 years ago

I've made much progress, thanks to the IRC folks. I think I've commented out all the code related to audio, and the game loads far enough to create a black rectangle that looks like it will be used to render the screen. Then it crashes, saying, "missing function: glPrioritizeTextures". Is this something emscripten should support, or do I need to find a way to work around this function call?

When I compiled Descent in C, I used these options: "opengl=1 opengles=0 sdlmixer=0" (which was a guess at what would work best with emscripten).

I'm running emcc with "-s SAFE_HEAP=1 -s LEGACY_GL_EMULATION=1 -s TOTAL_MEMORY=33554432 -s GL_UNSAFE_OPTS=0".

Also, in case it's relevant, emscripten prints "WARNING: using emscripten GL emulation. This is a collection of limited workarounds, do not expect it to work." and "WARNING: using emscripten GL immediate mode emulation. This is very limited in what it supports" on the console.

kripken commented 9 years ago

glPrioritizeTextures is not present in WebGL, and I'm not sure how we could emulate it. It's best to avoid calling it if possible.

Does the codebase have an OpenGL ES2 rendering option? That would be much easier than relying on emulation. Emscripten's GL emulation is basically good enough to render Cube 2, it's very likely in a non-trivial rendering engine you'd find plenty that we don't support. See http://kripken.github.io/emscripten-site/docs/porting/multimedia_and_graphics/OpenGL-support.html

jeffguy commented 9 years ago

I don't know much about OpenGL, but these two things make me doubt it supports ES 2.0.

===== D1X-Rebirth v0.58.1 =====
    'opengl=[0/1]'        build with OpenGL support [default: 1]
    'opengles=[0/1]'      build with OpenGL ES support [default: 0]
    'sdlmixer=[0/1]'      build with SDL_Mixer support for sound and music (includes external music support) [default: 1]
    'asm=[0/1]'           build with ASSEMBLER code (only with opengl=0, requires NASM and x86) [default: 0]
    'debug=[0/1]'         build DEBUG binary which includes asserts, debugging output, cheats and more output [default: 0]
    'use_tracker=[0/1]'   enable Tracker support (requires udp) [default :1]
    'verbosebuild=[0/1]'  print out all compiler/linker messages during building [default: 0]

Do you agree with my assessment? If so, how different are ES 1.0 and ES 2.0? Perhaps I could port Descent in less than 16 man hours? Or are there other c++ -> browser converters I should consider? Or am I maybe biting off more than I can chew? Thanks for your help!

kripken commented 9 years ago

OpenGL ES1 is quite different from ES2, but much closer to it than normal OpenGL. Probably worth trying that path. There's a higher chance we support the necessary emulation for that.

If that happens to use emulation features we support, it might just work. If not, we could look into adding the missing pieces, but it could potentially be very hard.

In that case, an option is to use Regal, which emulates legacy GL. Last I checked it was very close to working on Emscripten, and if it did, GL like this should no longer be a problem.

jeffguy commented 9 years ago

I eventually got Descent to compile with GL ES 1. It didn't link successfully (missing a library), but I figure that shouldn't matter for emcc, since emcc provides its own libraries.

Descent calls glViewport several times. Emscripten implements as "function _glViewport(x0, x1, x2, x3) { GLctx.viewport(x0, x1, x2, x3) }", and firefox complains "GLctx is undefined".

Some googling suggests GL ES 2 still uses glViewport, so I'm surprised this didn't work. Any idea what I've done wrong? Thanks agoin for your help!!

Here are the relevant glViewport lines: include/internal.h:#define OGL_VIEWPORT(x,y,w,h){if (w!=last_width || h!=last_height){glViewport(x,grd_curscreen->sc_canvas.cv_bitmap.bm_h-y-h,w,h);last_width=w;last_height=h;}} arch/ogl/ogl.c: OGL_VIEWPORT(grd_curcanv->cv_bitmap.bm_x,grd_curcanv->cv_bitmap.bm_y,Canvas_width,Canvas_height); arch/ogl/ogl.c: OGL_VIEWPORT(0,0,grd_curscreen->sc_w,grd_curscreen->sc_h); arch/ogl/gr.c: OGL_VIEWPORT(0,0,w,h);

On Sun, Sep 13, 2015 at 12:34 AM, Alon Zakai notifications@github.com wrote:

OpenGL ES1 is quite different from ES2, but much closer to it than normal OpenGL. Probably worth trying that path. There's a higher chance we support the necessary emulation for that.

If that happens to use emulation features we support, it might just work. If not, we could look into adding the missing pieces, but it could potentially be very hard.

In that case, an option is to use Regal https://github.com/p3/regal, which emulates legacy GL. Last I checked it was very close to working on Emscripten, and if it did, GL like this should no longer be a problem.

— Reply to this email directly or view it on GitHub https://github.com/kripken/emscripten/issues/3753#issuecomment-139843997 .

jeffguy commented 9 years ago

clb helped me figure out that: eglCreateContext() calls to glutCreateWindow(), which calls to Browser.createContext(Module['canvas'], true, true, contextAttributes);, which calls to GL.makeContextCurrent(contextHandle);, which should set GLctx = non-null;

Indeed, I'm calling eglCreateContext before glViewport, but I hadn't noticed my eglCreateContext is tripping over if (glesContextVersion != 2) {EGL.setErrorCode(0x3005 /* EGL_BAD_CONFIG */);

I'll see if I can figure out a way to hard code glesContextVersion==2

On Mon, Sep 14, 2015 at 4:35 PM, Jeff Guy jeffguy@gmail.com wrote:

I eventually got Descent to compile with GL ES 1. It didn't link successfully (missing a library), but I figure that shouldn't matter for emcc, since emcc provides its own libraries.

Descent calls glViewport several times. Emscripten implements as "function _glViewport(x0, x1, x2, x3) { GLctx.viewport(x0, x1, x2, x3) }", and firefox complains "GLctx is undefined".

Some googling suggests GL ES 2 still uses glViewport, so I'm surprised this didn't work. Any idea what I've done wrong? Thanks agoin for your help!!

Here are the relevant glViewport lines: include/internal.h:#define OGL_VIEWPORT(x,y,w,h){if (w!=last_width || h!=last_height){glViewport(x,grd_curscreen->sc_canvas.cv_bitmap.bm_h-y-h,w,h);last_width=w;last_height=h;}} arch/ogl/ogl.c: OGL_VIEWPORT(grd_curcanv->cv_bitmap.bm_x,grd_curcanv->cv_bitmap.bm_y,Canvas_width,Canvas_height); arch/ogl/ogl.c: OGL_VIEWPORT(0,0,grd_curscreen->sc_w,grd_curscreen->sc_h); arch/ogl/gr.c: OGL_VIEWPORT(0,0,w,h);

On Sun, Sep 13, 2015 at 12:34 AM, Alon Zakai notifications@github.com wrote:

OpenGL ES1 is quite different from ES2, but much closer to it than normal OpenGL. Probably worth trying that path. There's a higher chance we support the necessary emulation for that.

If that happens to use emulation features we support, it might just work. If not, we could look into adding the missing pieces, but it could potentially be very hard.

In that case, an option is to use Regal https://github.com/p3/regal, which emulates legacy GL. Last I checked it was very close to working on Emscripten, and if it did, GL like this should no longer be a problem.

— Reply to this email directly or view it on GitHub https://github.com/kripken/emscripten/issues/3753#issuecomment-139843997 .

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because there has been no activity in the past 2 years. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.

midzer commented 4 months ago

@jeffguy I've ported Descent 1 in my fork https://github.com/midzer/dxx-rebirth/tree/emscripten

jeffguy commented 4 months ago

Thanks, @midzer! I appreciate your hard work :)

sbc100 commented 3 months ago

@midzer can we try it online somewhere? I loved that game back in the day!

midzer commented 3 months ago

@sbc100 Sure -> https://midzer.de/games#descent-i

Probably gonna update the port soon as upstream repo has many new changes.

sbc100 commented 3 months ago

Wow, amazing! I did run into a Uncaught RuntimeError: memory access out of bounds eventually.. but so great to see that game again.