DXGL r127 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r126‎ | r127 | r128 >
Date:01:29, 15 March 2012
Author:admin
Status:new
Tags:
Comment:
Fix shader generation rollover crash
Modified paths:
  • /ddraw/shadergen.cpp (modified) (history)

Diff [purge]

Index: ddraw/shadergen.cpp
@@ -157,17 +157,17 @@
158158 if(genshaders[genindex].shader.prog)
159159 {
160160 glUseProgram(0);
161 - glDeleteProgram(genshaders[shaderindex].shader.prog);
162 - glDeleteShader(genshaders[shaderindex].shader.vs);
163 - glDeleteShader(genshaders[shaderindex].shader.fs);
164 - delete genshaders[shaderindex].shader.vsrc;
165 - delete genshaders[shaderindex].shader.fsrc;
166 - ZeroMemory(&genshaders[shaderindex],sizeof(GenShader));
 161+ glDeleteProgram(genshaders[genindex].shader.prog);
 162+ glDeleteShader(genshaders[genindex].shader.vs);
 163+ glDeleteShader(genshaders[genindex].shader.fs);
 164+ delete genshaders[genindex].shader.vsrc;
 165+ delete genshaders[genindex].shader.fsrc;
 166+ ZeroMemory(&genshaders[genindex],sizeof(GenShader));
167167 }
168168 CreateShader(genindex,id,texstate,texcoords);
169169 shaderindex = genindex;
170170 genindex++;
171 - if(genindex == 256) genindex = 0;
 171+ if(genindex >= 256) genindex = 0;
172172 }
173173 genshaders[shaderindex].id = id;
174174 glUseProgram(genshaders[shaderindex].shader.prog);
@@ -255,7 +255,7 @@
256256 (material.specular * specular) + material.emissive;\n\
257257 gl_FrontColor = color;\n";
258258 static const char op_colorfragout[] = "gl_FragColor = color;\n";
259 -static const char op_fragpassthru[] = "color = gl_Color;\n";
 259+static const char op_colorfragin[] = "color = gl_Color;\n";
260260
261261 // Functions
262262 static const char func_dirlight[] = "void DirLight(in Light light)\n\
@@ -412,7 +412,6 @@
413413 idstring[21] = 0;
414414 fsrc->append(idheader);
415415 fsrc->append(idstring);
416 - // Attributs
417416 // Uniforms
418417 // Variables
419418 fsrc->append(var_color);
@@ -419,7 +418,11 @@
420419 // Functions
421420 // Main
422421 fsrc->append(mainstart);
423 - fsrc->append(op_fragpassthru);
 422+ fsrc->append(op_colorfragin);
 423+ for(int i = 0; i < 8; i++)
 424+ {
 425+
 426+ }
424427 fsrc->append(op_colorfragout);
425428 fsrc->append(mainend);
426429 #ifdef _DEBUG