diff src/video/win32/SDL_d3drender.c @ 1916:c773b0c0ac89

Implemented blend modes in the D3D renderer
author Sam Lantinga <slouken@libsdl.org>
date Wed, 19 Jul 2006 05:03:21 +0000
parents 83420da906a5
children 3f54b3ec5a07
line wrap: on
line diff
--- a/src/video/win32/SDL_d3drender.c	Wed Jul 19 04:24:41 2006 +0000
+++ b/src/video/win32/SDL_d3drender.c	Wed Jul 19 05:03:21 2006 +0000
@@ -359,12 +359,6 @@
     IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
                                     D3DCULL_NONE);
     IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
-    IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
-                                    TRUE);
-    IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
-                                    D3DBLEND_SRCALPHA);
-    IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
-                                    D3DBLEND_INVSRCALPHA);
 
     return renderer;
 }
@@ -627,6 +621,38 @@
     vertices[3].u = minu;
     vertices[3].v = maxv;
 
+    switch (blendMode) {
+    case SDL_TextureBlendMode_None:
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
+                                        FALSE);
+        break;
+    case SDL_TextureBlendMode_Mask:
+    case SDL_TextureBlendMode_Blend:
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
+                                        TRUE);
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
+                                        D3DBLEND_SRCALPHA);
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
+                                        D3DBLEND_INVSRCALPHA);
+        break;
+    case SDL_TextureBlendMode_Add:
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
+                                        TRUE);
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
+                                        D3DBLEND_SRCALPHA);
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
+                                        D3DBLEND_ONE);
+        break;
+    case SDL_TextureBlendMode_Mod:
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
+                                        TRUE);
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
+                                        D3DBLEND_ZERO);
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
+                                        D3DBLEND_SRCCOLOR);
+        break;
+    }
+
     result =
         IDirect3DDevice9_SetTexture(data->device, 0,
                                     (IDirect3DBaseTexture9 *) texturedata->