DXGL r289 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r288‎ | r289 | r290 >
Date:23:03, 15 December 2012
Author:admin
Status:new
Tags:
Comment:
Add color key transparency to texture stages.
Modified paths:
  • /ddraw/common.h (modified) (history)
  • /ddraw/glExtensions.cpp (modified) (history)
  • /ddraw/glExtensions.h (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/shadergen.cpp (modified) (history)

Diff [purge]

Index: ddraw/common.h
@@ -90,6 +90,14 @@
9191 out[3] = (GLfloat)((in>>24) & 0xff) / 255.0f;
9292 }
9393
 94+static inline void dwordto4int(DWORD in, GLint *out)
 95+{
 96+ out[0] = (GLint)((in>>16) & 0xff);
 97+ out[1] = (GLint)((in>>8) & 0xff);
 98+ out[2] = (GLint)(in& 0xff);
 99+ out[3] = (GLint)((in>>24) & 0xff);
 100+}
 101+
94102 #ifdef _M_X64
95103 #define NextMultipleOfWord NextMultipleOf8
96104 #else
Index: ddraw/glExtensions.cpp
@@ -59,6 +59,7 @@
6060 void (APIENTRY *glUniform2i) (GLint location, GLint v0, GLint v1) = NULL;
6161 void (APIENTRY *glUniform3i) (GLint location, GLint v0, GLint v1, GLint v2) = NULL;
6262 void (APIENTRY *glUniform4i) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3) = NULL;
 63+void (APIENTRY *glUniform4iv) (GLint location, GLsizei count, const GLint* value) = NULL;
6364 void (APIENTRY *glUniform1f) (GLint location, GLfloat v0) = NULL;
6465 void (APIENTRY *glUniform2f) (GLint location, GLfloat v0, GLfloat v1) = NULL;
6566 void (APIENTRY *glUniform3f) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2) = NULL;
@@ -136,6 +137,7 @@
137138 glUniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i");
138139 glUniform3i = (PFNGLUNIFORM3IPROC)wglGetProcAddress("glUniform3i");
139140 glUniform4i = (PFNGLUNIFORM4IPROC)wglGetProcAddress("glUniform4i");
 141+ glUniform4iv = (PFNGLUNIFORM4IVPROC)wglGetProcAddress("glUniform4iv");
140142 glUniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f");
141143 glUniform2f = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f");
142144 glUniform3f = (PFNGLUNIFORM3FPROC)wglGetProcAddress("glUniform3f");
Index: ddraw/glExtensions.h
@@ -87,6 +87,7 @@
8888 GLAPI void (APIENTRY *glUniform2i) (GLint location, GLint v0, GLint v1);
8989 GLAPI void (APIENTRY *glUniform3i) (GLint location, GLint v0, GLint v1, GLint v2);
9090 GLAPI void (APIENTRY *glUniform4i) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
 91+GLAPI void (APIENTRY *glUniform4iv) (GLint location, GLsizei count, const GLint* value);
9192 GLAPI void (APIENTRY *glUniform1f) (GLint location, GLfloat v0);
9293 GLAPI void (APIENTRY *glUniform2f) (GLint location, GLfloat v0, GLfloat v1);
9394 GLAPI void (APIENTRY *glUniform3f) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
Index: ddraw/glRenderer.cpp
@@ -1517,7 +1517,7 @@
15181518 if(prog.uniforms[136] != -1)
15191519 glUniform4f(prog.uniforms[136],RGBA_GETRED(ambient),RGBA_GETGREEN(ambient),
15201520 RGBA_GETBLUE(ambient),RGBA_GETALPHA(ambient));
1521 -
 1521+ GLint keycolor[4];
15221522 for(i = 0; i < 8; i++)
15231523 {
15241524 if(device->texstages[i].colorop == D3DTOP_DISABLE) break;
@@ -1541,6 +1541,14 @@
15421542 }
15431543 else SetTexture(i,0);
15441544 glUniform1i(prog.uniforms[128+i],i);
 1545+ if(device->renderstate[D3DRENDERSTATE_COLORKEYENABLE] && device->texstages[i].texture && (prog.uniforms[140+i] != -1))
 1546+ {
 1547+ if(device->texstages[i].texture->ddsd.dwFlags & DDSD_CKSRCBLT)
 1548+ {
 1549+ dwordto4int(device->texstages[i].texture->colorkey[0].key.dwColorSpaceLowValue,keycolor);
 1550+ glUniform4iv(prog.uniforms[140+i],1,keycolor);
 1551+ }
 1552+ }
15451553 }
15461554 if(prog.uniforms[137]!= -1) glUniform1f(prog.uniforms[137],device->glDDS7->fakex);
15471555 if(prog.uniforms[138]!= -1) glUniform1f(prog.uniforms[138],device->glDDS7->fakey);
Index: ddraw/shadergen.cpp
@@ -636,6 +636,18 @@
637637 tmp.replace(21,1,_itoa(i,idstring,10));
638638 fsrc->append(tmp);
639639 }
 640+ if((id>>13)&1)
 641+ {
 642+ for(i = 0; i < 8; i++)
 643+ {
 644+ if((texstate[i].shaderid>>60)&1)
 645+ {
 646+ tmp = unif_key;
 647+ tmp.replace(17,1,_itoa(i,idstring,10));
 648+ fsrc->append(tmp);
 649+ }
 650+ }
 651+ }
640652 if((id>>2)&1) fsrc->append(unif_alpharef);
641653 // Variables
642654 fsrc->append(var_color);