Mark Sibly 8 anos atrás
pai
commit
77ae25a1d8

+ 12 - 17
modules/mojo/graphics/glexts/glexts.cpp

@@ -4,7 +4,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <EGL/egl.h>
+
+void* SDL_GL_GetProcAddress( const char *proc );
+int SDL_GL_ExtensionSupported( const char *extension );
 
 namespace bbGLexts{
 
@@ -17,28 +19,21 @@ namespace bbGLexts{
 	
 	void init(){
 	
-		const char *exts=(const char*)glGetString( GL_EXTENSIONS );
-		char *buf=(char*)malloc( strlen( exts )+3 );
-
-		buf[0]=' ';		
-		strcpy( buf+1,exts );
-		strcat( buf+1," " );
-		
-		if( GL_draw_buffers=strstr( buf," GL_EXT_draw_buffers " ) ){
+		if( GL_draw_buffers=SDL_GL_ExtensionSupported( "GL_EXT_draw_buffer" ) ){
 			
-			glDrawBuffers=(void(*)(int,const GLenum*)) eglGetProcAddress( "glDrawBuffersEXT" );
+			glDrawBuffers=(void(*)(int,const GLenum*)) SDL_GL_GetProcAddress( "glDrawBuffersEXT" );
 			
-		}else if( GL_draw_buffers=strstr( buf," WEBGL_draw_buffers " ) ){
+		}else if( GL_draw_buffers=SDL_GL_ExtensionSupported( "GL_WEBGL_draw_buffer" ) ){
 		
-			glDrawBuffers=(void(*)(int,const GLenum*)) eglGetProcAddress( "glDrawBuffersWEBGL" );
+			glDrawBuffers=(void(*)(int,const GLenum*)) SDL_GL_GetProcAddress( "glDrawBuffersWEBGL" );
 		}
+
+		GL_texture_float=SDL_GL_ExtensionSupported( "GL_OES_texture_float" );
 		
-		GL_texture_float=strstr( buf,"_texture_float" );
-		
-		GL_texture_half_float=strstr( buf,"_texture_half_float" );
+		GL_texture_half_float=SDL_GL_ExtensionSupported( "GL_OES_texture_half_float" );
 		
-		GL_depth_texture=strstr( buf,"_depth_texture" );
-			
+		GL_depth_texture=SDL_GL_ExtensionSupported( "GL_OES_depth_texture" );
+	
 		printf( "GL_draw_buffers=%i\n",int( GL_draw_buffers ) );
 		printf( "GL_texture_float=%i\n",int( GL_texture_float ) );
 		printf( "GL_texture_half_float=%i\n",int( GL_texture_half_float ) );

+ 9 - 1
modules/mojo/graphics/glexts/glexts.h

@@ -1,6 +1,12 @@
 
+#ifndef BB_GL_EXTS
+#define BB_GL_EXTS
+
+#if __APPLE__
+#include <OpenGLES/ES2/gl.h>
+#else
 #include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
+#endif
 
 namespace bbGLexts{
 
@@ -13,3 +19,5 @@ namespace bbGLexts{
 
 	void init();
 }
+
+#endif

+ 6 - 3
modules/mojo/graphics/glexts/glexts.monkey2

@@ -1,7 +1,7 @@
 
 Namespace mojo.graphics.glexts
 
-#If __TARGET__="windows" Or __TARGET__="emscripten"
+#If __TARGET__="windows" Or __MOBILE_TARGET__ or __WEB_TARGET__
 
 #Import "glexts.cpp"
 #Import "glexts.h"
@@ -29,7 +29,7 @@ Const GL_COLOR_ATTACHMENT13:Int=$8CED
 Const GL_COLOR_ATTACHMENT14:Int=$8CEE
 Const GL_COLOR_ATTACHMENT15:Int=$8CEF
 
-#If __TARGET__="windows" Or __TARGET__="emscripten"
+#If __TARGET__="windows" Or __MOBILE_TARGET__ Or __WEB_TARGET__
 
 Extern
 
@@ -42,7 +42,7 @@ Function glDrawBuffers( n:Int,bufs:GLenum Ptr )="bbGLexts::glDrawBuffers"
 
 Function InitGLexts()="bbGLexts::init"
 
-#Elseif __TARGET__="macos" or __TARGET__="linux"
+#Elseif __TARGET__="macos" Or __TARGET__="linux"
 
 Const GL_draw_buffers:Bool=True
 Const GL_texture_float:Bool=True
@@ -66,6 +66,9 @@ Const GL_texture_half_float:bool=False
 Const GL_depth_texture:bool=False
 
 Function glDrawBuffers( n:Int,bufs:GLenum Ptr )
+
+	If n=1 And (bufs[0]=GL_COLOR_ATTACHMENT0 Or bufs[0]=GL_BACK) Return
+	
 	RuntimeError( "glDrawBuffers unsupported" )
 End
 

+ 1 - 1
modules/mojo/graphics/glutil.monkey2

@@ -98,7 +98,7 @@ End
 #end
 Function glCompile:Int( type:Int,source:String )
 	
-#If __TARGET__="windows" Or __TARGET__="emscripten"
+#If __TARGET__="windows" Or __MOBILE_TARGET__ or __WEB_TARGET__
 	Const prefix:="
 #extension GL_EXT_draw_buffers : require	
 #ifdef GL_ES