From cbf13dac65d642b7e1396edd0011274dfb891a59 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 28 Apr 2012 13:38:32 +0000 Subject: [PATCH] gpu: temporarily enable alpha blending in the vertex buffer code. --- src/gpu/vertexbuffer.cpp | 23 +++++++++++++++++++++-- src/video.cpp | 5 ----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/gpu/vertexbuffer.cpp b/src/gpu/vertexbuffer.cpp index 2aedde0b..8fcd17a6 100644 --- a/src/gpu/vertexbuffer.cpp +++ b/src/gpu/vertexbuffer.cpp @@ -123,6 +123,9 @@ void VertexDeclaration::Bind() void VertexDeclaration::DrawElements(MeshPrimitive type, int skip, int count) { #if defined _XBOX || defined USE_D3D9 + g_d3ddevice->SetRenderState(D3DRS_ALPHABLENDENABLE, 1); + g_d3ddevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + g_d3ddevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); if (FAILED(g_d3ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW))) Abort(); switch (type) @@ -133,6 +136,13 @@ void VertexDeclaration::DrawElements(MeshPrimitive type, int skip, int count) break; } #else +# if defined HAVE_GL_2X && !defined __APPLE__ + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GEQUAL, 0.01f); +# endif + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + switch (type) { case MeshPrimitive::Triangles: @@ -147,8 +157,10 @@ void VertexDeclaration::DrawIndexedElements(MeshPrimitive type, int vbase, int skip, int count) { #if defined _XBOX || defined USE_D3D9 - if (FAILED(g_d3ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW))) - Abort(); + g_d3ddevice->SetRenderState(D3DRS_ALPHABLENDENABLE, 1); + g_d3ddevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + g_d3ddevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + g_d3ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW); switch (type) { case MeshPrimitive::Triangles: @@ -157,6 +169,13 @@ void VertexDeclaration::DrawIndexedElements(MeshPrimitive type, int vbase, break; } #else +# if defined HAVE_GL_2X && !defined __APPLE__ + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GEQUAL, 0.01f); +# endif + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + switch (type) { case MeshPrimitive::Triangles: diff --git a/src/video.cpp b/src/video.cpp index 78ba5c93..85b07bc5 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -131,10 +131,6 @@ void Video::Setup(ivec2 size) } g_d3ddevice = VideoData::d3d_dev; - - g_d3ddevice->SetRenderState(D3DRS_ALPHABLENDENABLE, 1); - g_d3ddevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - g_d3ddevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); #else # if defined USE_GLEW && !defined __APPLE__ /* Initialise GLEW if necessary */ @@ -154,7 +150,6 @@ void Video::Setup(ivec2 size) glClearDepth(1.0); # if defined HAVE_GL_2X && !defined __APPLE__ - glShadeModel(GL_SMOOTH); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); # endif #endif