DXGL r311 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r310‎ | r311 | r312 >
Date:20:33, 13 January 2013
Author:admin
Status:new
Tags:
Comment:
Point lights in world space.
Modified paths:
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/shadergen.cpp (modified) (history)

Diff [purge]

Index: ddraw/glRenderer.cpp
@@ -1493,6 +1493,7 @@
14941494 {
14951495 if(device->gllights[i] != -1)
14961496 {
 1497+ if(prog.uniforms[0] != -1) glUniformMatrix4fv(prog.uniforms[0],1,false,device->matWorld);
14971498 if(prog.uniforms[20+(i*12)] != -1)
14981499 glUniform4fv(prog.uniforms[20+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvDiffuse);
14991500 if(prog.uniforms[21+(i*12)] != -1)
Index: ddraw/shadergen.cpp
@@ -264,6 +264,7 @@
265265 uniform float height;\n";
266266 static const char unif_alpharef[] = "uniform int alpharef;\n";
267267 static const char unif_key[] = "uniform ivec4 keyX;\n";
 268+static const char unif_world[] = "uniform mat4 matWorld;\n";
268269 // Variables
269270 static const char var_common[] = "vec4 diffuse;\n\
270271 vec4 specular;\n\
@@ -338,7 +339,7 @@
339340 }\n";
340341 static const char func_pointlight[] = "void PointLight(in Light light)\n\
341342 {\n\
342 -vec4 pos = gl_ModelViewMatrix*xyzw;\n\
 343+vec4 pos = matWorld*xyzw;\n\
343344 vec3 pos3 = pos.xyz / pos.w;\n\
344345 vec3 V = light.position - pos3;\n\
345346 float d = length(V);\n\
@@ -478,6 +479,7 @@
479480 if(numlights) // Lighting
480481 {
481482 vsrc->append(lightstruct);
 483+ vsrc->append(unif_world);
482484 tmp = unif_light;
483485 for(i = 0; i < numlights; i++)
484486 {
@@ -1094,6 +1096,7 @@
10951097 attrSTRQ[4] = i + '0';
10961098 genshaders[index].shader.attribs[i+34] = glGetAttribLocation(genshaders[index].shader.prog,attrSTRQ);
10971099 }
 1100+ genshaders[index].shader.uniforms[0] = glGetUniformLocation(genshaders[index].shader.prog,"matWorld");
10981101 // Uniforms
10991102 // TODO: 4-14 world1-3 and texture0-7
11001103 char uniflight[] = "lightX. ";