From 2234f91c38476f90a632ec8158501b6044706799 Mon Sep 17 00:00:00 2001 From: yohimik Date: Tue, 3 Jun 2025 20:10:33 +0400 Subject: [PATCH] ref: gl: add stubs for WebGL --- ref/gl/gl2_shim/gl2_shim.c | 64 ++++++++++++++++++++++++++++++++++++++ wscript | 9 +++++- 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/ref/gl/gl2_shim/gl2_shim.c b/ref/gl/gl2_shim/gl2_shim.c index b2ab0e9d..34269812 100644 --- a/ref/gl/gl2_shim/gl2_shim.c +++ b/ref/gl/gl2_shim/gl2_shim.c @@ -1714,6 +1714,56 @@ static void APIENTRY stub( void ) *((void **)&pgl ## name) = (void *)stub; \ } +#if XASH_EMSCRIPTEN +static void GL2_PolygonMode( GLenum face, GLenum mode ) +{ +} + +static void GL2_PolygonOffset( GLfloat factor, GLfloat units ) +{ +} + +static void GL2_ShadeModel( GLenum mode ) +{ +} + +static void GL2_PointSize( GLfloat size ) +{ +} + +static void GL2_Normal3fv( const GLfloat *v ) +{ +} + +static void GL2_Hint( GLenum target, GLenum mode ) +{ +} + +static void GL2_Scalef( GLfloat x, GLfloat y, GLfloat z ) +{ +} + +static void GL2_Translatef( GLfloat x, GLfloat y, GLfloat z ) +{ +} + +static void GL2_TexEnvi( GLenum target, GLenum pname, GLint param ) +{ +} + +static void GL2_TexEnvf( GLenum target, GLenum pname, GLfloat param ) +{ +} + +static void GL2_Fogi( GLenum pname, GLint param ) +{ +} + +static void GL2_DrawBuffer( GLenum mode ) +{ +} +#endif // XASH_EMSCRIPTEN + void GL2_ShimInstall( void ) { GL2_OVERRIDE_PTR( Vertex2f ) @@ -1758,6 +1808,20 @@ void GL2_ShimInstall( void ) GL2_OVERRIDE_PTR_B( TexImage2D ) GL2_OVERRIDE_PTR_B( TexParameteri ) } +#if XASH_EMSCRIPTEN + GL2_OVERRIDE_PTR( Normal3fv ) + GL2_OVERRIDE_PTR( Hint ) + GL2_OVERRIDE_PTR( Scalef ) + GL2_OVERRIDE_PTR( Translatef ) + GL2_OVERRIDE_PTR( TexEnvi ) + GL2_OVERRIDE_PTR( TexEnvf ) + GL2_OVERRIDE_PTR( Fogi ) + GL2_OVERRIDE_PTR( ShadeModel ) + GL2_OVERRIDE_PTR( PolygonMode ) + GL2_OVERRIDE_PTR( PointSize ) + GL2_OVERRIDE_PTR( PolygonOffset ) + GL2_OVERRIDE_PTR( DrawBuffer ) +#endif // XASH_EMSCRIPTEN GL2_OVERRIDE_PTR_B( IsEnabled ) GL2_OVERRIDE_PTR_B( DrawRangeElements ) GL2_OVERRIDE_PTR_B( DrawElements ) diff --git a/wscript b/wscript index 4b84bd6e..52226427 100644 --- a/wscript +++ b/wscript @@ -123,7 +123,7 @@ REFDLLS = [ RefDll('gles1', False, 'NANOGL'), RefDll('gles2', False, 'GLWES'), RefDll('gl4es', False), - RefDll('gles3compat', False), + RefDll('gles3compat', False, 'GLES3COMPAT'), RefDll('null', False), ] @@ -191,6 +191,9 @@ def options(opt): grp.add_option('--enable-fuzzer', action = 'store_true', dest = 'ENABLE_FUZZER', default = False, help = 'enable building libFuzzer runner [default: %(default)s]' ) + grp.add_option('--enable-emscripten', action = 'store_true', dest = 'ENABLE_EMSCRIPTEN', default = False, + help = 'enable emscripten support [default: %(default)s]' ) + for i in SUBDIRS: if not i.is_exists(opt): continue @@ -252,6 +255,10 @@ def configure(conf): conf.options.GLES3COMPAT = True conf.options.GL = False + if conf.options.ENABLE_EMSCRIPTEN: + conf.options.GLES3COMPAT = True + conf.options.GL = False + # psvita needs -fPIC set manually and static builds are incompatible with -fPIC enforce_pic = conf.env.DEST_OS != 'psvita' and not conf.env.STATIC_LINKING conf.check_pic(enforce_pic)