2
0
Mark Sibly 8 жил өмнө
parent
commit
680dec1aef

+ 16 - 5
modules/mojo/graphics/glexts/glexts.cpp

@@ -10,7 +10,7 @@ extern "C" int SDL_GL_ExtensionSupported( const char *extension );
 
 namespace bbGLexts{
 
-	bool GL_draw_buffers;
+	bool GL_draw_buffers=true;
 	bool GL_texture_float;
 	bool GL_texture_half_float;
 	bool GL_depth_texture;
@@ -19,14 +19,25 @@ namespace bbGLexts{
 	
 	void init(){
 	
+	#if __EMSCRIPTEN__
+	
+		if( GL_draw_buffers=SDL_GL_ExtensionSupported( "GL_WEBGL_draw_buffers" ) ){
+
+			// Don't actually call this, will crash emscripten...extension is 'just there'!
+			//
+			// glDrawBuffers=(void(*)(int,const GLenum*)) SDL_GL_GetProcAddress( "glDrawBuffersWEBGL" );
+			
+			glDrawBuffers=::glDrawBuffers;
+		}
+		
+	#else
+	
 		if( GL_draw_buffers=SDL_GL_ExtensionSupported( "GL_EXT_draw_buffers" ) ){
 			
 			glDrawBuffers=(void(*)(int,const GLenum*)) SDL_GL_GetProcAddress( "glDrawBuffersEXT" );
-			
-		}else if( GL_draw_buffers=SDL_GL_ExtensionSupported( "GL_WEBGL_draw_buffers" ) ){
-		
-			glDrawBuffers=(void(*)(int,const GLenum*)) SDL_GL_GetProcAddress( "glDrawBuffersWEBGL" );
 		}
+		
+	#endif
 
 		GL_texture_float=SDL_GL_ExtensionSupported( "GL_OES_texture_float" );
 		

+ 4 - 0
modules/mojo/graphics/glexts/glexts.h

@@ -8,6 +8,10 @@
 #include <GLES2/gl2.h>
 #endif
 
+#if __EMSCRIPTEN__
+extern "C" void glDrawBuffers( int n,const GLenum *bufs );
+#endif
+
 namespace bbGLexts{
 
 	extern bool GL_draw_buffers;

+ 5 - 0
modules/mojo/graphics/glexts/glexts.monkey2

@@ -47,7 +47,11 @@ Const GL_texture_float:Bool="bbGLexts::GL_texture_float"
 Const GL_texture_half_float:bool="bbGLexts::GL_texture_half_float"
 Const GL_depth_texture:bool="bbGLexts::GL_depth_texture"
 
+#If __WEB_TARGET__
+Function glDrawBuffers( n:Int,bufs:GLenum Ptr )
+#Else
 Function glDrawBuffers( n:Int,bufs:GLenum Ptr )="bbGLexts::glDrawBuffers"
+#Endif
 
 Function InitGLexts()="bbGLexts::init"
 	
@@ -57,6 +61,7 @@ Function glDrawBuffer( mode:GLenum )
 	RuntimeError( "glDrawBuffer unsupported" )
 End
 
+
 Function glReadBuffer( mode:GLenum )
 	RuntimeError( "glReadBuffer unsupported" )
 End