@@ -293,21 +293,19 @@ void OpenGL::renderVertices(gpu::GPU* gpu) {
293
293
continue ;
294
294
}
295
295
296
+ bool isTextured = bitsToDepth (buffer[i].bitcount ) != ColorDepth::NONE;
296
297
if (buffer[i].flags & gpu::Vertex::SemiTransparency) {
297
298
auto semi = static_cast <Transparency>((buffer[i].flags >> 5 ) & 3 );
298
- // TODO: Refactor and batch
299
- if (semi == Transparency::Bby2plusFby2) {
300
- glBlendEquationSeparate (GL_FUNC_ADD, GL_FUNC_ADD);
301
- glBlendFuncSeparate (GL_CONSTANT_ALPHA, GL_CONSTANT_ALPHA, GL_ONE, GL_ZERO);
302
- } else if (semi == Transparency::BplusF) {
303
- glBlendEquationSeparate (GL_FUNC_ADD, GL_FUNC_ADD);
304
- glBlendFuncSeparate (GL_ONE, GL_ONE, GL_ONE, GL_ZERO);
305
- } else if (semi == Transparency::BminusF) {
306
- glBlendEquationSeparate (GL_FUNC_REVERSE_SUBTRACT, GL_FUNC_ADD);
307
- glBlendFuncSeparate (GL_ONE, GL_ONE, GL_ONE, GL_ZERO);
308
- } else if (semi == Transparency::BplusFby4) {
309
- glBlendEquationSeparate (GL_FUNC_ADD, GL_FUNC_ADD);
310
- glBlendFuncSeparate (GL_CONSTANT_COLOR, GL_ONE, GL_ONE, GL_ZERO);
299
+
300
+ glBlendEquationSeparate (semi == Transparency::BminusF ? GL_FUNC_REVERSE_SUBTRACT : GL_FUNC_ADD, GL_FUNC_ADD);
301
+ switch (semi) {
302
+ case Transparency::Bby2plusFby2:
303
+ isTextured ? glBlendFunc (GL_ONE, GL_SRC_ALPHA) : glBlendFunc (GL_CONSTANT_ALPHA, GL_CONSTANT_ALPHA); break ;
304
+ case Transparency::BplusF:
305
+ case Transparency::BminusF:
306
+ isTextured ? glBlendFunc (GL_ONE, GL_SRC_ALPHA) : glBlendFunc (GL_ONE, GL_ONE); break ;
307
+ case Transparency::BplusFby4:
308
+ isTextured ? glBlendFunc (GL_CONSTANT_COLOR, GL_SRC_ALPHA) : glBlendFunc (GL_CONSTANT_COLOR, GL_ONE); break ;
311
309
}
312
310
313
311
glEnable (GL_BLEND);
0 commit comments