DXGL r186 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r185‎ | r186 | r187 >
Date:15:16, 29 June 2012
Author:admin
Status:new
Tags:
Comment:
Support transformed vertices
Modified paths:
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/shadergen.cpp (modified) (history)

Diff [purge]

Index: ddraw/glRenderer.cpp
@@ -1473,7 +1473,8 @@
14741474 else SetTexture(i,0);
14751475 glUniform1i(prog.uniforms[128+i],i);
14761476 }
1477 -
 1477+ if(prog.uniforms[137]!= -1) glUniform1f(prog.uniforms[137],device->glDDS7->fakex);
 1478+ if(prog.uniforms[138]!= -1) glUniform1f(prog.uniforms[138],device->glDDS7->fakey);
14781479 if(device->glDDS7->zbuffer) SetFBO(device->glDDS7->texture,device->glDDS7->zbuffer->texture,device->glDDS7->zbuffer->hasstencil);
14791480 else SetFBO(device->glDDS7->texture,0,false);
14801481 glViewport(device->viewport.dwX,device->viewport.dwY,device->viewport.dwWidth,device->viewport.dwHeight);
Index: ddraw/shadergen.cpp
@@ -264,6 +264,8 @@
265265 static const char unif_light[] = "uniform Light lightX;\n";
266266 static const char unif_ambient[] = "uniform vec4 ambientcolor;\n";
267267 static const char unif_tex[] = "uniform sampler2D texX;\n";
 268+static const char unif_size[] = "uniform float width;\n\
 269+uniform float height;\n";
268270 // Variables
269271 static const char var_common[] = "vec4 diffuse;\n\
270272 vec4 specular;\n\
@@ -278,7 +280,7 @@
279281 gl_Position = vec4(pos.x,-pos.y,pos.z,pos.w);\n";
280282 static const char op_normalize[] = "N = normalize(normalmat*nxyz);\n";
281283 static const char op_normalpassthru[] = "N = normalmat*nxyz;\n";
282 -static const char op_passthru[] = "gl_Position = vec4(xyz/640.0,1.0/rhw);\n";
 284+static const char op_passthru[] = "gl_Position = vec4((xyz.x/(width/2.0))-1.0,(xyz.y/(height/2.0))-1.0,xyz.z,1.0/rhw);\n";
283285 static const char op_resetcolor[] = "diffuse = specular = vec4(0.0);\n\
284286 ambient = ambientcolor / 255.0;\n";
285287 static const char op_dirlight[] = "DirLight(lightX);\n";
@@ -447,6 +449,7 @@
448450 vsrc->append(unif_matrices); // Material
449451 vsrc->append(unif_material);
450452 vsrc->append(unif_ambient);
 453+ if((id>>50)&1) vsrc->append(unif_size);
451454 numlights = (id>>18)&7;
452455 if(numlights) // Lighting
453456 {
@@ -934,4 +937,6 @@
935938 genshaders[index].shader.uniforms[128+i] = glGetUniformLocation(genshaders[index].shader.prog,uniftex);
936939 }
937940 genshaders[index].shader.uniforms[136] = glGetUniformLocation(genshaders[index].shader.prog,"ambientcolor");
 941+ genshaders[index].shader.uniforms[137] = glGetUniformLocation(genshaders[index].shader.prog,"width");
 942+ genshaders[index].shader.uniforms[138] = glGetUniformLocation(genshaders[index].shader.prog,"height");
938943 }