Add minimal emscripten support
This commit is contained in:
1 parent
f869bffe97
commit
f41bd37fde
4 files changed
+100
-3
No files matched your search
@@ -290,6 +290,22 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#endif
|
||||
|
||||
//================================================================== EMSCRIPTEN ===
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
|
||||
#define OS_STRING "emscripten"
|
||||
#define ID_INLINE inline
|
||||
#define PATH_SEP '/'
|
||||
|
||||
#define ARCH_STRING "wasm32"
|
||||
|
||||
#define Q3_LITTLE_ENDIAN
|
||||
|
||||
#define DLL_EXT ".wasm"
|
||||
|
||||
#endif
|
||||
|
||||
//================================================================== Q3VM ===
|
||||
|
||||
#ifdef Q3_VM
|
||||
|
||||
+16
-1
@@ -398,7 +398,7 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool
|
||||
int profileMask;
|
||||
int majorVersion;
|
||||
int minorVersion;
|
||||
} contexts[3];
|
||||
} contexts[4];
|
||||
int numContexts, type;
|
||||
const char *glstring;
|
||||
int perChannelColorBits;
|
||||
@@ -543,6 +543,14 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool
|
||||
( r_preferOpenGLES->integer == -1 && profileMask == SDL_GL_CONTEXT_PROFILE_ES ) );
|
||||
|
||||
if ( preferOpenGLES ) {
|
||||
#ifdef __EMSCRIPTEN__
|
||||
// WebGL 2.0 isn't fully backward compatible so you have to ask for it specifically
|
||||
contexts[numContexts].profileMask = SDL_GL_CONTEXT_PROFILE_ES;
|
||||
contexts[numContexts].majorVersion = 3;
|
||||
contexts[numContexts].minorVersion = 0;
|
||||
numContexts++;
|
||||
#endif
|
||||
|
||||
contexts[numContexts].profileMask = SDL_GL_CONTEXT_PROFILE_ES;
|
||||
contexts[numContexts].majorVersion = 2;
|
||||
contexts[numContexts].minorVersion = 0;
|
||||
@@ -560,6 +568,13 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool
|
||||
numContexts++;
|
||||
|
||||
if ( !preferOpenGLES ) {
|
||||
#ifdef __EMSCRIPTEN__
|
||||
contexts[numContexts].profileMask = SDL_GL_CONTEXT_PROFILE_ES;
|
||||
contexts[numContexts].majorVersion = 3;
|
||||
contexts[numContexts].minorVersion = 0;
|
||||
numContexts++;
|
||||
#endif
|
||||
|
||||
contexts[numContexts].profileMask = SDL_GL_CONTEXT_PROFILE_ES;
|
||||
contexts[numContexts].majorVersion = 2;
|
||||
contexts[numContexts].minorVersion = 0;
|
||||
|
||||
@@ -31,6 +31,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
#ifndef DEDICATED
|
||||
#ifdef USE_LOCAL_HEADERS
|
||||
# include "SDL.h"
|
||||
@@ -863,10 +867,14 @@ int main( int argc, char **argv )
|
||||
signal( SIGTERM, Sys_SigHandler );
|
||||
signal( SIGINT, Sys_SigHandler );
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop( Com_Frame, 0, 1 );
|
||||
#else
|
||||
while( 1 )
|
||||
{
|
||||
Com_Frame( );
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user