Browse Source

Implemented blend modes.

Brucey 3 years ago
parent
commit
b2be1de129
2 changed files with 21 additions and 21 deletions
  1. 21 17
      sdlrendermax2d.mod/sdlrendermax2d.bmx
  2. 0 4
      sdlsurface.mod/common.bmx

+ 21 - 17
sdlrendermax2d.mod/sdlrendermax2d.bmx

@@ -189,29 +189,17 @@ Type TSDLRenderMax2DDriver Extends TMax2DDriver
 		state_blend=blend
 		state_blend=blend
 		Select blend
 		Select blend
 		Case MASKBLEND
 		Case MASKBLEND
-			'glDisable GL_BLEND
-			'glEnable GL_ALPHA_TEST
-			'glAlphaFunc GL_GEQUAL,.5
+			renderer.SetDrawBlendMode(SDL_BLENDMODE_BLEND)
 		Case SOLIDBLEND
 		Case SOLIDBLEND
-			'glDisable GL_BLEND
-			'glDisable GL_ALPHA_TEST
+			renderer.SetDrawBlendMode(SDL_BLENDMODE_NONE)
 		Case ALPHABLEND
 		Case ALPHABLEND
 			renderer.SetDrawBlendMode(SDL_BLENDMODE_BLEND)
 			renderer.SetDrawBlendMode(SDL_BLENDMODE_BLEND)
-			'glEnable GL_BLEND
-			'glBlendFunc GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA
-			'glDisable GL_ALPHA_TEST
 		Case LIGHTBLEND
 		Case LIGHTBLEND
-			renderer.SetDrawBlendMode(BLENDMODE_LIGHTBLEND)
-			'glEnable GL_BLEND
-			'glBlendFunc GL_SRC_ALPHA,GL_ONE
-			'glDisable GL_ALPHA_TEST
+			renderer.SetDrawBlendMode(SDL_BLENDMODE_ADD)
 		Case SHADEBLEND
 		Case SHADEBLEND
-			'glEnable GL_BLEND
-			'glBlendFunc GL_DST_COLOR,GL_ZERO
-			'glDisable GL_ALPHA_TEST
+			renderer.SetDrawBlendMode(SDL_BLENDMODE_MOD)
 		Default
 		Default
-			'glDisable GL_BLEND
-			'glDisable GL_ALPHA_TEST
+			renderer.SetDrawBlendMode(SDL_BLENDMODE_NONE)
 		End Select
 		End Select
 	End Method
 	End Method
 
 
@@ -454,6 +442,22 @@ Type TSDLRenderMax2DDriver Extends TMax2DDriver
 		indices[4] = 3
 		indices[4] = 3
 		indices[5] = 2
 		indices[5] = 2
 
 
+		Select state_blend
+			Case ALPHABLEND
+				texture.SetBlendMode(SDL_BLENDMODE_BLEND)
+			Case MASKBLEND
+				texture.SetBlendMode(SDL_BLENDMODE_BLEND)
+			Case SOLIDBLEND
+				texture.SetBlendMode(SDL_BLENDMODE_NONE)
+			Case LIGHTBLEND
+				texture.SetBlendMode(SDL_BLENDMODE_ADD)
+			Case SHADEBLEND
+				texture.SetBlendMode(SDL_BLENDMODE_MOD)
+			Default
+				texture.SetBlendMode(SDL_BLENDMODE_NONE)
+		End Select
+
+
 		renderer.Geometry(texture, vertices, 4, indices, 6)
 		renderer.Geometry(texture, vertices, 4, indices, 6)
 	End Method
 	End Method
 
 

+ 0 - 4
sdlsurface.mod/common.bmx

@@ -184,7 +184,3 @@ Rem
 bbdoc: 1-dstA, 1-dstA, 1-dstA, 1-dstA
 bbdoc: 1-dstA, 1-dstA, 1-dstA, 1-dstA
 end rem
 end rem
 Const SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA:Int = $A
 Const SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA:Int = $A
-
-Const BLENDMODE_LIGHTBLEND:Int = SDL_BLENDOPERATION_ADD Shl 0 | SDL_BLENDFACTOR_SRC_COLOR Shl 4 | SDL_BLENDFACTOR_ONE Shl 8 | ..
-	SDL_BLENDOPERATION_ADD Shl 16 | SDL_BLENDFACTOR_SRC_COLOR Shl 20 | SDL_BLENDFACTOR_DST_COLOR Shl 24
-