Mark Sibly 7 years ago
parent
commit
55b0630345

+ 30 - 25
modules/mojo/app/app.monkey2

@@ -80,15 +80,28 @@ Class AppInstance
 	Field SdlEventFilter:Void( event:SDL_Event Ptr )
 
 	#rem monkeydoc Create a new app instance.
+	
+	The following environment variables can be set prior to constructing a new AppInstance:
+	
+	MX2_MOJO_OPENGL_PROFILE : Should be set to one of "es", "compatibility" or "core". Defaults to "compatibility" on macos and linux, "es" on all other targets. Uses 'Angle' for es support on windows.
+	
+	MX2_MOJO_OPENGL_VERSION_MAJOR : defaults to "2".
+	
+	MX2_MOJO_OPENGL_VERSION_MINOR : defaults to "1".
+	
+	MX2_MOJO_COLOR_BUFFER_BITS : Minimum depth buffer bit depth. defaults to "8".
+	
+	MX2_MOJO_DEPTH_BUFFER_BITS : Minimum depth buffer bit depth. defaults to "0".
+
+	MX2_MOJO_STENCIL_BUFFER_BITS : Minimum stencil buffer bit depth. defaults to "0".
+	
+	Environment variables may be set using the [[std::std.filesystem.SetEnv|SetEnv]] function.
+	
 	#end
-	Method New( config:StringMap<String> =Null )
+	Method New()
 	
 		App=Self
 		
-		If Not config config=New StringMap<String>
-	
-		_config=config
-		
 		SDL_Init( SDL_INIT_VIDEO|SDL_INIT_JOYSTICK|SDL_INIT_GAMECONTROLLER )
 		
 		SDL_SetHint( "SDL_MOUSE_FOCUS_CLICKTHROUGH","1" )
@@ -114,7 +127,7 @@ Class AppInstance
 		'
 		Local gl_profile:Int,gl_major:Int=2,gl_minor:Int=0
 
-		Select GetConfig( "GL_context_profile","" )
+		Select GetEnv( "MX2_MOJO_OPENGL_PROFILE" )
 		Case "core"
 			gl_profile=SDL_GL_CONTEXT_PROFILE_CORE
 		Case "compatibility"
@@ -130,17 +143,18 @@ Class AppInstance
 		End
 
 		SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK,gl_profile )
-		SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION,Int( GetConfig( "GL_context_major_version",gl_major ) ) )
-		SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION,Int( GetConfig( "GL_context_minor_version",gl_minor ) ) )
-		
-		SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE,Int( GetConfig( "GL_depth_buffer_enabled",0 ) ) )
-		SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE,Int( GetConfig( "GL_stencil_buffer_enabled",0 ) ) )
+		SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION,Int( GetEnv( "MX2_MOJO_OPENGL_VERSION_MAJOR",gl_major ) ) ) 
+		SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION,Int( GetEnv( "MX2_MOJO_OPENGL_VERSION_MINOR",gl_minor ) ) )
 		
 		SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER,1 )
+		
+		Local n:=Int( GetEnv( "MX2_MOJO_COLOR_BUFFER_BITS",8 ) )
 
-		SDL_GL_SetAttribute( SDL_GL_RED_SIZE,8 )
-		SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE,8 )
-		SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE,8 )
+		SDL_GL_SetAttribute( SDL_GL_RED_SIZE,n )
+		SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE,n )
+		SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE,n )
+		SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE,Int( GetEnv( "MX2_MOJO_DEPTH_BUFFER_BITS" ) ) )
+		SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE,Int( GetEnv( "MX2_MOJO_STENCIL_BUFFER_BITS" ) ) )
 		
 #If __DESKTOP_TARGET__
 
@@ -170,9 +184,9 @@ Class AppInstance
 		
 		_theme=New Theme
 		
-		Local themePath:=GetConfig( "initialTheme","default" )
+		Local themePath:=GetEnv( "MX2_MOJO_INITIAL_THEME","default" )
 		
-		Local themeScale:=Float( GetConfig( "initialThemeScale",1 ) )
+		Local themeScale:=Float( GetEnv( "MX2_MOJO_INITIAL_THEME_SCALE",1 ) )
 		
 		_theme.Load( themePath,New Vec2f( themeScale ) )
 		
@@ -389,13 +403,6 @@ Class AppInstance
 	
 #Endif
 	
-	#rem monkeydoc @hidden
-	#end
-	Method GetConfig:String( name:String,defValue:String )
-		If _config.Contains( name ) Return _config[name]
-		Return defValue
-	End
-
 	#rem monkeydoc @hidden
 	#end
 	Method GetDisplayModes:DisplayMode[]()
@@ -607,8 +614,6 @@ Class AppInstance
 
 	Private
 	
-	Field _config:StringMap<String>
-
 	Field _touchMouse:Bool=False		'Whether mouse is really touch
 	Field _captureMouse:Bool=False		'Whether to use SDL_CaptureMouse
 	

+ 1 - 1
modules/mojo/app/window.monkey2

@@ -520,7 +520,7 @@ Class Window Extends View
 		Endif
 		SDL_GL_MakeCurrent( _sdlWindow,_sdlGLContext )
 		
-		InitGLexts()
+		bbglInit()
 		
 		_allWindows.Push( Self )
 		_windowsByID[SDL_GetWindowID( _sdlWindow )]=Self

+ 43 - 10
modules/mojo/graphics/glutil.monkey2

@@ -7,6 +7,40 @@ Global bindings:=New IntStack
 
 Public
 
+Function glShaderSourceEx:Void( shader:GLuint,source:String )
+
+	Local n:=source.Length
+	Local buf:=Cast<Byte Ptr>( libc.malloc( n+1 ) )
+	For Local i:=0 Until n
+		buf[i]=source[i]
+	Next
+	buf[n]=0
+	
+	Local p:=Cast<GLcchar Ptr>( buf )
+	
+	glShaderSource( shader,1,Varptr p,Null )
+	
+	libc.free( buf )
+End
+
+Function glGetShaderInfoLogEx:String( shader:GLuint )
+
+	Local buf:=New Byte[1024],length:GLsizei
+	
+	glGetShaderInfoLog( shader,buf.Length,Varptr length,Cast<GLchar Ptr>( Varptr buf[0] ) )
+	
+	Return String.FromCString( Varptr buf[0] )
+End
+
+Function glGetProgramInfoLogEx:String( program:GLuint )
+
+	Local buf:=New Byte[1024],length:GLsizei
+	
+	glGetProgramInfoLog( program,buf.Length,Varptr length,Cast<GLchar Ptr>( Varptr buf[0] ) )
+	
+	Return String.FromCString( Varptr buf[0] )
+End
+
 #rem monkeydoc @hidden
 #end
 Global glDebug:Bool=False
@@ -26,6 +60,7 @@ Global glRetroSeq:Int=1
 #rem monkeydoc @hidden
 #end
 Function glInvalidateGraphics()
+	
 	glGraphicsSeq+=1
 End
 
@@ -136,9 +171,9 @@ End
 #end
 Function glCompile:Int( type:Int,source:String )
 	
-#If __TARGET__="windows" Or __MOBILE_TARGET__ Or __WEB_TARGET__
-
-		Const prefix:="
+	If BBGL_ES
+	
+		Local prefix:="
 #ifdef GL_ES
 #ifdef GL_FRAGMENT_PRECISION_HIGH
 precision highp float;
@@ -149,18 +184,16 @@ precision mediump float;
 "
 		source=prefix+source
 		
-		If glexts.GL_draw_buffers source="#extension GL_EXT_draw_buffers : require~n"+source
+		If BBGL_draw_buffers source="#extension GL_EXT_draw_buffers : require~n"+source
 			
-		If glexts.GL_standard_derivatives source="#extension GL_OES_standard_derivatives : require~n"+source
+'		If glexts.GL_standard_derivatives source="#extension GL_OES_standard_derivatives : require~n"+source
+	Else
 			
-#ElseIf __TARGET__="macos" or __TARGET__="linux"
-	
-		Const prefix:="
+		Local prefix:="
 #version 120
 "
 		source=prefix+source
-		 
-#EndIf
+	Endif
 	
 	Local shader:=glCreateShader( type )
 	glShaderSourceEx( shader,source )

+ 15 - 14
modules/mojo/graphics/graphicsdevice.monkey2

@@ -255,7 +255,7 @@ Class GraphicsDevice
 	
 	Method BindUniformBlock( ublock:UniformBlock )
 	
-		_ublocks[ublock.Name]=ublock
+		_ublocks[ublock.BlockId]=ublock
 	End
 	
 	Method GetUniformBlock:UniformBlock( block:Int )
@@ -290,7 +290,7 @@ Class GraphicsDevice
 		Endif
 		
 		If _depthMask
-			glClearDepthf( depth )
+			glClearDepth( depth )
 			mask|=GL_DEPTH_BUFFER_BIT
 		Endif
 		
@@ -432,15 +432,15 @@ Class GraphicsDevice
 		
 		glGetIntegerv( GL_FRAMEBUFFER_BINDING,Varptr _defaultFbo )
 		
-		If GL_draw_buffer glGetIntegerv( GL_DRAW_BUFFER,Varptr _defaultDrawBuf )
-		If GL_read_buffer glGetIntegerv( GL_READ_BUFFER,Varptr _defaultReadBuf )
-			
-		if GL_seamless_cube_map glEnable( GL_TEXTURE_CUBE_MAP_SEAMLESS )
+		If BBGL_seamless_cube_map glEnable( GL_TEXTURE_CUBE_MAP_SEAMLESS )
 		
-#If __TARGET__="macos" or __TARGET__="linux"
-		glEnable( $8861 )	'GL_POINT_SPRITE
-		glEnable( $8642 )	'GL_PROGRAM_POINT_SIZE
-#Endif
+		If Not BBGL_ES
+			glGetIntegerv( GL_DRAW_BUFFER,Varptr _defaultDrawBuf )
+			glGetIntegerv( GL_READ_BUFFER,Varptr _defaultReadBuf )
+			glEnable( GL_POINT_SPRITE )
+			glEnable( GL_VERTEX_PROGRAM_POINT_SIZE )
+			glEnable( GL_TEXTURE_CUBE_MAP_SEAMLESS )
+		Endif
 			
 		glCheck()
 	End
@@ -482,12 +482,13 @@ Class GraphicsDevice
 				_rtarget.Bind()
 			Else
 				glBindFramebuffer( GL_FRAMEBUFFER,_defaultFbo )
-
-				If GL_draw_buffer glDrawBuffer( _defaultDrawBuf )
-				If GL_read_buffer glReadBuffer( _defaultReadBuf )
+				
+				If Not BBGL_ES
+					glDrawBuffer( _defaultDrawBuf )
+					glReadBuffer( _defaultReadBuf )
+				Endif
 				
 			Endif
-			
 
 		Endif
 	

+ 5 - 5
modules/mojo/graphics/rendertarget.monkey2

@@ -69,12 +69,12 @@ Class RenderTarget Extends Resource
 	Method Bind()
 	
 		glBindFramebuffer( GL_FRAMEBUFFER,ValidateGLFramebuffer() )
-
-		If glexts.GL_draw_buffers 
+		
+		If BBGL_draw_buffers
 			glDrawBuffers( _glDrawBufs.Length,_glDrawBufs.Data )
 		Endif
-
-		If glexts.GL_read_buffer
+		
+		If Not BBGL_ES
 			glReadBuffer( _glDrawBufs ? _glDrawBufs[0] Else GL_NONE )
 		Endif
 
@@ -127,7 +127,7 @@ Class RenderTarget Extends Resource
 	
 	Method CheckStatus()
 		
-		Local status:=gles20.glCheckFramebufferStatus( GL_FRAMEBUFFER )
+		Local status:=glCheckFramebufferStatus( GL_FRAMEBUFFER )
 		
 		If status=GL_FRAMEBUFFER_COMPLETE Return
 		

+ 13 - 6
modules/mojo/graphics/texture.monkey2

@@ -21,7 +21,7 @@ Function glInternalFormat:GLenum( format:PixelFormat )
 	Case PixelFormat.IA8 Return GL_LUMINANCE_ALPHA
 	Case PixelFormat.RGB8 Return GL_RGB
 	Case PixelFormat.RGBA8 Return GL_RGBA
-	Case PixelFormat.RGBA16F Return GL_RGBA
+'	Case PixelFormat.RGBA16F Return GL_RGBA
 	Case PixelFormat.RGBA32F Return GL_RGBA
 	Case PixelFormat.Depth32 Return GL_DEPTH_COMPONENT
 	End
@@ -36,7 +36,7 @@ Function glFormat:GLenum( format:PixelFormat )
 	Case PixelFormat.IA8 Return GL_LUMINANCE_ALPHA
 	Case PixelFormat.RGB8 Return GL_RGB
 	Case PixelFormat.RGBA8 Return GL_RGBA
-	Case PixelFormat.RGBA16F Return GL_RGBA
+'	Case PixelFormat.RGBA16F Return GL_RGBA
 	Case PixelFormat.RGBA32F Return GL_RGBA
 	Case PixelFormat.Depth32 Return GL_DEPTH_COMPONENT
 	End
@@ -51,7 +51,7 @@ Function glType:GLenum( format:PixelFormat )
 	Case PixelFormat.IA8 Return GL_UNSIGNED_BYTE
 	Case PixelFormat.RGB8 Return GL_UNSIGNED_BYTE
 	Case PixelFormat.RGBA8 Return GL_UNSIGNED_BYTE
-	Case PixelFormat.RGBA16F Return GL_HALF_FLOAT
+'	Case PixelFormat.RGBA16F Return GL_HALF_FLOAT
 	Case PixelFormat.RGBA32F Return GL_FLOAT
 	Case PixelFormat.Depth32 Return GL_UNSIGNED_INT
 	End
@@ -99,6 +99,13 @@ Enum CubeFace
 End
 
 #Rem monkeydoc The Texture class.
+
+The environment variable "MX2_MOJO_TEXTURE_MAX_ANISOTROPY" can be used to control texture max anisotropy.
+
+If this env variable is not set, texture max anisotropy is set to the max level.
+	
+Environment variables may be set using the [[std::std.filesystem.SetEnv|SetEnv]] function.
+	
 #end
 Class Texture Extends Resource
 	
@@ -438,12 +445,12 @@ Class Texture Extends Resource
 				Endif
 				
 				If _flags & TextureFlags.Mipmap And Not (_flags & TextureFlags.Cubemap)
-					If glexts.GL_texture_filter_anisotropic
+'					If glexts.GL_texture_filter_anisotropic
 						Local max:Int=0
 						glGetIntegerv( GL_MAX_TEXTURE_MAX_ANISOTROPY,Varptr max )
-						Local n:=Min( Int(App.GetConfig( "GL_texture_max_anisotropy",max )),max )
+						Local n:=Min( Int(GetEnv( "MX2_MOJO_TEXTURE_MAX_ANISOTROPY",max )),max )
 						glTexParameteri( _glTarget,GL_TEXTURE_MAX_ANISOTROPY,n )
-					Endif
+'					Endif
 				Endif
 								
 			Endif

+ 99 - 55
modules/mojo/graphics/uniformblock.monkey2

@@ -5,16 +5,16 @@ Namespace mojo.graphics
 #end
 Class UniformBlock Extends Resource
 
-	Method New( name:Int,linearColors:Bool=False )
+	Method New( blockid:Int,linearColors:Bool=False )
 	
-		_name=name
+		_blockid=blockid
 		
 		_linearColors=linearColors
 	End
 	
 	Method New( uniforms:UniformBlock )
 	
-		_name=uniforms._name
+		_blockid=uniforms._blockid
 		_linearColors=uniforms._linearColors
 		_defaultTexture=uniforms._defaultTexture
 		_ntextures=uniforms._ntextures
@@ -24,11 +24,6 @@ Class UniformBlock Extends Resource
 		Next
 	End
 	
-	Property Name:Int()
-	
-		Return _name
-	End
-	
 	Property LinearColors:Bool()
 	
 		Return _linearColors
@@ -38,30 +33,6 @@ Class UniformBlock Extends Resource
 		_linearColors=linearColors
 	End
 	
-	Function GetUniformId:Int( name:String,block:Int )
-		Local ids:=_ids[block]
-		If Not ids
-			ids=New StringMap<Int>
-			_ids[block]=ids
-		Endif
-		Local id:=ids[name]
-		If Not id
-			id=ids.Count()+1
-			ids[name]=id
-		Endif
-		Return id
-	End
-	
-	Method GetUniformId:Int( name:String )
-		Return GetUniformId( name,_name )
-	End
-	
-	Method GetUniformId:Int( name:String,type:Type )
-		Local id:=GetUniformId( name,_name )
-		DebugAssert( _uniforms[id].type=type,"Invalid uniform type" )
-		Return id
-	End
-
 	'***** Int *****
 	'	
 	Method SetInt( uniform:String,value:Int )
@@ -200,22 +171,31 @@ Class UniformBlock Extends Resource
 
 	'***** Mat4f array *****
 	'
-	Method SetMat4fArray( uniform:String,value:Mat4f[] )
-		Local id:=GetUniformId( uniform )
+	Method SetMat4fArray( name:String,value:Mat4f[] )
+		
+		Local id:=GetUniformId( name )
 		_uniforms[id].arrayData=value
 		_uniforms[id].type=Type.Mat4fArray
 		_seq=_gseq
 		_gseq+=1
 	End
 	
-	Method GetMat4fArray:Mat4f[]( uniform:String )
-		Local id:=GetUniformId( uniform )
-		DebugAssert( _uniforms[id].type=Type.Mat4fArray,"Invalidate uniform type" )
+	Method GetMat4fArray:Mat4f[]( name:String )
+		
+		Local id:=GetUniformId( name,Type.Mat4fArray )
+		
 		Return _uniforms[id].arrayData
 	End
 
 	Method GetMat4fArray:Mat4f[]( id:Int )
-		DebugAssert( _uniforms[id].type=Type.Mat4fArray,"Invalidate uniform type" )
+		
+	#If __DEBUG__
+		Local type:=Type.Mat4fArray
+		Assert( id,"Uniform '"+GetUniformName( id )+"' not found" )
+		Assert( _uniforms[id].type,"Uniform '"+GetUniformName( id )+"' not found in UniformBlock" )
+		Assert( _uniforms[id].type=type,"Uniform '"+GetUniformName( id )+"' has incorrect type '"+_typenames[_uniforms[id].type]="', expecting type '"+_typenames[type]+"'" )
+	#endif
+	
 		Return _uniforms[id].arrayData
 	End
 
@@ -235,11 +215,14 @@ Class UniformBlock Extends Resource
 		_defaultTexture=texture
 	End
 	
-	Method SetTexture( uniform:String,value:Texture )
-		Local id:=GetUniformId( uniform )
+	Method SetTexture( name:String,value:Texture )
+		
+		Local id:=GetUniformId( name )
+		
 		If (value<>Null)<>(_uniforms[id].texture<>Null)
 			If value _ntextures+=1 Else _ntextures-=1
 		End
+		
 		_uniforms[id].texture=value
 		_uniforms[id].type=Type.Texture
 		_seq=_gseq
@@ -247,15 +230,21 @@ Class UniformBlock Extends Resource
 	End
 
 	Method GetTexture:Texture( uniform:String )
-		Local id:=GetUniformId( uniform )
-		DebugAssert( _uniforms[id].type=Type.Texture,"Invalid uniform type" )
+		
+		Local id:=GetUniformId( uniform,Type.Texture )
 		Return _uniforms[id].texture
 	End
 	
 	Method GetTexture:Texture( id:Int )
-		DebugAssert( _uniforms[id].type=Type.Texture,"Invalid uniform type" )
-		Local texture:=_uniforms[id].texture
-		Return texture ? texture Else _defaultTexture
+		
+	#If __DEBUG__
+		Local type:=Type.Texture
+		Assert( id,"Uniform '"+GetUniformName( id )+"' not found" )
+		Assert( _uniforms[id].type,"Uniform '"+GetUniformName( id )+"' not found in UniformBlock" )
+		Assert( _uniforms[id].type=type,"Uniform '"+GetUniformName( id )+"' has incorrect type '"+_typenames[_uniforms[id].type]="', expecting type '"+_typenames[type]+"'" )
+	#endif
+		
+		Return _uniforms[id].texture ?Else _defaultTexture
 	End
 	
 	#rem monkeydoc @hidden
@@ -273,10 +262,60 @@ Class UniformBlock Extends Resource
 		_uniforms=Null
 	End
 	
+	Internal
+
+	Property BlockId:Int()
+	
+		Return _blockid
+	End
+	
+	Function GetUniformId:Int( name:String,blockid:Int )
+		
+		Local ids:=_ids[blockid]
+		If Not ids
+			ids=New StringMap<Int>
+			_ids[blockid]=ids
+			_names[blockid]=New IntMap<String>
+		Endif
+		Local id:=ids[name]
+		If Not id
+			id=ids.Count()+1
+			ids[name]=id
+			_names[blockid][id]=name
+		Endif
+		Return id
+	End
+	
+	Method GetUniformId:Int( name:String )
+		
+		Return GetUniformId( name,_blockid )
+	End
+	
+	Method GetUniformId:Int( name:String,type:Type )
+		
+		Local id:=_ids[_blockid][name]
+
+#If __DEBUG__		
+		Assert( id,"Uniform '"+name+"' not found" )
+		Assert( _uniforms[id].type,"Uniform '"+name+"' does not found in UniformBlock" )
+		Assert( _uniforms[id].type=type,"Uniform '"+name+"' has incorrect type '"+_typenames[_uniforms[id].type]="', expecting type '"+_typenames[type]+"'" )
+#endif
+		Return id
+	End
+	
+	Method GetUniformName:String( id:Int )
+		
+		Local names:=_names[_blockid]
+		Local name:=names ? names[id] Else ""
+		Return name ?Else "<unknown>"
+	End
+		
 	Private
 	
 	Global _gseq:Int=1
 	Global _ids:=New StringMap<Int>[8]
+	Global _names:=New IntMap<String>[8]
+	Global _typenames:=New String[]( "Void","Float","Vec2f","Vec3f","Vec4f","Mat3f","Mat4f","Mat4f[]","Int" )
 	
 	Enum Type
 		None=0
@@ -298,7 +337,7 @@ Class UniformBlock Extends Resource
 		Field floatData:Mat4f
 	End
 
-	Field _name:Int
+	Field _blockid:Int
 	Field _linearColors:bool
 	Field _defaultTexture:Texture
 	Field _ntextures:Int
@@ -306,28 +345,33 @@ Class UniformBlock Extends Resource
 	Field _uniforms:=New Uniform[64]
 	Field _seq:Int
 	
-	Method SetData<T>( uniform:String,data:T,type:Type )
-		Local id:=GetUniformId( uniform )
+	Method SetData<T>( name:String,data:T,type:Type )
+		Local id:=GetUniformId( name )
 		Cast<T Ptr>( Varptr _uniforms[id].floatData )[0]=data
 		_uniforms[id].type=type
 		_seq=_gseq
 		_gseq+=1
 	End
 	
-	Method GetData<T>:T( uniform:String,type:Type )
-		Local id:=GetUniformId( uniform )
-		DebugAssert( _uniforms[id].type=type,"Invalid uniform type" )
+	Method GetData<T>:T( name:String,type:Type )
+		Local id:=GetUniformId( name,type )
+'		DebugAssert( _uniforms[id].type=type,"Invalid uniform type" )
 		Return Cast<T Ptr>( Varptr _uniforms[id].floatData )[0]
 	End
 
-	Method GetDataPtr<T>:T Ptr( uniform:String,type:Type )
-		Local id:=GetUniformId( uniform )
-		DebugAssert( _uniforms[id].type=type,"Invalid uniform type" )
+	Method GetDataPtr<T>:T Ptr( name:String,type:Type )
+		Local id:=GetUniformId( name,type )
+'		DebugAssert( _uniforms[id].type=type,"Invalid uniform type" )
 		Return Cast<T Ptr>( Varptr _uniforms[id].floatData )
 	End
 	
 	Method GetFloatPtr:Float Ptr( id:Int,type:Type )
-		DebugAssert( _uniforms[id].type=type,"Invalid uniform type "+Int(_uniforms[id].type)+" expecting "+Int(type) )
+		
+#If __DEBUG__
+		Assert( id,"Uniform '"+GetUniformName( id )+"' not found" )
+		Assert( _uniforms[id].type,"Uniform '"+GetUniformName( id )+"' not found in UniformBlock" )
+		Assert( _uniforms[id].type=type,"Uniform '"+GetUniformName( id )+"' has incorrect type '"+_typenames[_uniforms[id].type]="', expecting type '"+_typenames[type]+"'" )
+#endif
 		Return Cast<Float Ptr>( Varptr _uniforms[id].floatData )
 	End
 	

+ 1 - 1
modules/mojo/module.json

@@ -4,5 +4,5 @@
 	"author":"Mark Sibly",
 	"version":"1.0.0",
 	"support":"http://monkeycoder.co.nz",
-	"depends":["freetype","emscripten","std","sdl2","gles20","openal"]
+	"depends":["freetype","emscripten","std","sdl2","opengl","openal"]
 }

+ 9 - 9
modules/mojo/mojo.monkey2

@@ -6,10 +6,17 @@ Namespace mojo
 #Import "<emscripten>"
 #Import "<std>"
 #Import "<sdl2>"
-#Import "<gles20>"
+#Import "<opengl>"
 #Import "<openal>"
 #Import "<freetype>"
 
+Using emscripten..
+Using std..
+Using sdl2..
+Using opengl..
+Using openal..
+Using mojo..
+
 #Import "app/app"
 #Import "app/event"
 #Import "app/skin"
@@ -21,7 +28,7 @@ Namespace mojo
 #Import "app/glwindow"
 
 'core graphics stuff
-#Import "graphics/glexts/glexts"
+'#Import "graphics/glexts/glexts"
 #Import "graphics/glutil"
 #Import "graphics/graphicsdevice"
 #Import "graphics/uniformblock"
@@ -49,13 +56,6 @@ Namespace mojo
 
 #Import "audio/audio"
 
-Using emscripten..
-Using std..
-Using sdl2..
-Using gles20..
-Using openal..
-Using mojo..
-
 Private
 
 Function Use( type:TypeInfo )