Browse Source

Cleanups.

Mark Sibly 8 years ago
parent
commit
f012bda0f8

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

@@ -1,7 +1,7 @@
 
 
 Namespace mojo.graphics.glexts
 Namespace mojo.graphics.glexts
 
 
-#If __TARGET__="windows" Or __MOBILE_TARGET__ or __WEB_TARGET__
+#If __TARGET__="windows" Or __WEB_TARGET__
 
 
 #Import "glexts.cpp"
 #Import "glexts.cpp"
 #Import "glexts.h"
 #Import "glexts.h"
@@ -29,7 +29,7 @@ Const GL_COLOR_ATTACHMENT13:Int=$8CED
 Const GL_COLOR_ATTACHMENT14:Int=$8CEE
 Const GL_COLOR_ATTACHMENT14:Int=$8CEE
 Const GL_COLOR_ATTACHMENT15:Int=$8CEF
 Const GL_COLOR_ATTACHMENT15:Int=$8CEF
 
 
-#If __TARGET__="windows" Or __MOBILE_TARGET__ Or __WEB_TARGET__
+#If __TARGET__="windows" Or __WEB_TARGET__
 
 
 Extern
 Extern
 
 
@@ -66,9 +66,6 @@ Const GL_texture_half_float:bool=False
 Const GL_depth_texture:bool=False
 Const GL_depth_texture:bool=False
 
 
 Function glDrawBuffers( n:Int,bufs:GLenum Ptr )
 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" )
 	RuntimeError( "glDrawBuffers unsupported" )
 End
 End
 
 

+ 4 - 17
modules/mojo/graphics/glutil.monkey2

@@ -98,9 +98,7 @@ End
 #end
 #end
 Function glCompile:Int( type:Int,source:String )
 Function glCompile:Int( type:Int,source:String )
 	
 	
-#If __TARGET__="windows" Or __MOBILE_TARGET__ or __WEB_TARGET__
 	Const prefix:="
 	Const prefix:="
-#extension GL_EXT_draw_buffers : require	
 #ifdef GL_ES
 #ifdef GL_ES
 #ifdef GL_FRAGMENT_PRECISION_HIGH
 #ifdef GL_FRAGMENT_PRECISION_HIGH
 precision highp float;
 precision highp float;
@@ -109,23 +107,12 @@ precision mediump float;
 #endif
 #endif
 #endif
 #endif
 "
 "
-#Else if __TARGET__="linux"
-	Const prefix:="
-#ifdef GL_ES
-#ifdef GL_FRAGMENT_PRECISION_HIGH
-precision highp float;
-#else
-precision mediump float;
-#endif
-#endif
-"
-#Else
-	Const prefix:="
-"
-#Endif
-
 	source=prefix+source
 	source=prefix+source
 	
 	
+	#If __TARGET__="windows" Or __MOBILE_TARGET__ Or __WEB_TARGET__
+		If glexts.GL_draw_buffers source="#extension GL_EXT_draw_buffers : require~n"+source
+	#endif
+	
 	Local shader:=glCreateShader( type )
 	Local shader:=glCreateShader( type )
 	glShaderSourceEx( shader,source )
 	glShaderSourceEx( shader,source )
 	glCompileShader( shader )
 	glCompileShader( shader )

+ 6 - 4
modules/mojo/graphics/rendertarget.monkey2

@@ -5,6 +5,8 @@ Class RenderTarget Extends Resource
 	
 	
 	Method New( colorTextures:Texture[],depthTexture:Texture )
 	Method New( colorTextures:Texture[],depthTexture:Texture )
 		
 		
+		Assert( colorTextures.Length<2 Or glexts.GL_draw_buffers,"Multiple render targets not supported" )
+		
 		_colorTextures=colorTextures.Slice( 0 )
 		_colorTextures=colorTextures.Slice( 0 )
 		
 		
 		_depthTexture=depthTexture
 		_depthTexture=depthTexture
@@ -27,9 +29,9 @@ Class RenderTarget Extends Resource
 		
 		
 		glBindFramebuffer( GL_FRAMEBUFFER,ValidateGLFramebuffer() )
 		glBindFramebuffer( GL_FRAMEBUFFER,ValidateGLFramebuffer() )
 		
 		
-		glDrawBuffers( _drawBufs.Length,_drawBufs.Data )
-		
-'		glReadBuffer( GL_NONE )
+		If glexts.GL_draw_buffers 
+			glDrawBuffers( _drawBufs.Length,_drawBufs.Data )
+		Endif
 	End
 	End
 	
 	
 	Private
 	Private
@@ -54,7 +56,7 @@ Class RenderTarget Extends Resource
 			
 			
 			Local texture:=_colorTextures[i]
 			Local texture:=_colorTextures[i]
 			
 			
-			glFramebufferTexture2D( GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0+i,GL_TEXTURE_2D,texture.ValidateGLTexture(),0 )
+			If texture glFramebufferTexture2D( GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0+i,GL_TEXTURE_2D,texture.ValidateGLTexture(),0 )
 			
 			
 		Next
 		Next