DXGL r163 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r162‎ | r163 | r164 >
Date:16:46, 5 June 2012
Author:admin
Status:new
Tags:
Comment:
Add D3DTOP_ADDSMOOTH
Document shadergen.cpp
Modified paths:
  • /ddraw/glDirect3D.cpp (modified) (history)
  • /ddraw/shadergen.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirect3D.cpp
@@ -83,7 +83,8 @@
8484 8, //dwFVFCaps
8585 D3DTEXOPCAPS_SELECTARG1 | D3DTEXOPCAPS_SELECTARG2 | D3DTEXOPCAPS_MODULATE |
8686 D3DTEXOPCAPS_MODULATE2X | D3DTEXOPCAPS_MODULATE4X | D3DTEXOPCAPS_ADD |
87 - D3DTEXOPCAPS_ADDSIGNED | D3DTEXOPCAPS_ADDSIGNED2X | D3DTEXOPCAPS_SUBTRACT, //dwTextureOpCaps
 87+ D3DTEXOPCAPS_ADDSIGNED | D3DTEXOPCAPS_ADDSIGNED2X | D3DTEXOPCAPS_SUBTRACT |
 88+ D3DTEXOPCAPS_ADDSMOOTH, //dwTextureOpCaps
8889 8, //wMaxTextureBlendStages
8990 8, //wMaxSimultaneousTextures
9091 8, //dwMaxActiveLights
Index: ddraw/shadergen.cpp
@@ -90,6 +90,10 @@
9191 10=cameraspaceposition 11=cameraspacereflectionvector
9292 Bit 59: Texture image enabled
9393 */
 94+
 95+/**
 96+ * Clears the array of shaders.
 97+ */
9498 void ZeroShaderArray()
9599 {
96100 ZeroMemory(genshaders,256*sizeof(GenShader));
@@ -97,6 +101,9 @@
98102 isbuiltin = true;
99103 }
100104
 105+/**
 106+ * Deletes all shader programs in the array.
 107+ */
101108 void ClearShaders()
102109 {
103110 for(int i = 0; i < shadercount; i++)
@@ -115,6 +122,17 @@
116123 genindex = 0;
117124 }
118125
 126+/**
 127+ * Sets a shader by render state. If the shader does not exist, generates it.
 128+ * @param id
 129+ * 64-bit value containing current render states
 130+ * @param texstate
 131+ * Pointer to the texture stage state array, containing 8 64-bit state values
 132+ * @param texcoords
 133+ * Pointer to number of texture coordinates in each texture stage
 134+ * @param builtin
 135+ * If true, the id parameter is an index to a built-in shader for 2D blitting
 136+ */
119137 void SetShader(__int64 id, TEXTURESTAGE *texstate, int *texcoords, bool builtin)
120138 {
121139 int shaderindex = -1;
@@ -176,6 +194,12 @@
177195 }
178196 }
179197
 198+/**
 199+ * Retrieves the GLSL program currently in use
 200+ * @return
 201+ * Number of the current GLSL program, or if using built-in shaders, the ID of
 202+ * the shader
 203+ */
180204 GLuint GetProgram()
181205 {
182206 if(isbuiltin) return current_shader & 0xFFFFFFFF;
@@ -301,6 +325,18 @@
302326 diffuse += light.diffuse*NdotL;\n\
303327 }\n";
304328
 329+
 330+/**
 331+ * Creates an OpenGL shader program
 332+ * @param index
 333+ * Index of the shader in the array to generate
 334+ * @param id
 335+ * 64-bit value containing current render states
 336+ * @param texstate
 337+ * Pointer to the texture stage state array, containing 8 64-bit state values
 338+ * @param texcoords
 339+ * Pointer to number of texture coordinates in each texture stage
 340+ */
305341 void CreateShader(int index, __int64 id, TEXTURESTAGE *texstate, int *texcoords)
306342 {
307343 string tmp;
@@ -638,6 +674,9 @@
639675 case D3DTOP_SUBTRACT:
640676 fsrc->append("color = " + arg1 + " - " + arg2 + ";\n");
641677 break;
 678+ case D3DTOP_ADDSMOOTH:
 679+ fsrc->append("color = " + arg1 + " + " + arg2 + " - " + arg1 + " * " + arg2 + ";\n");
 680+ break;
642681 }
643682 }
644683 fsrc->append(op_colorfragout);