DXGL r311 - Code Review
For
DXGL
(
recent comments
|
status changes
|
tags
|
authors
|
states
|
release notes
|
statistics
)
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 @@
1494
1494
{
1495
1495
if(device->gllights[i] != -1)
1496
1496
{
1497
+ if(prog.uniforms[0] != -1) glUniformMatrix4fv(prog.uniforms[0],1,false,device->matWorld);
1497
1498
if(prog.uniforms[20+(i*12)] != -1)
1498
1499
glUniform4fv(prog.uniforms[20+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvDiffuse);
1499
1500
if(prog.uniforms[21+(i*12)] != -1)
Index: ddraw/shadergen.cpp
—
—
@@ -264,6 +264,7 @@
265
265
uniform float height;\n";
266
266
static const char unif_alpharef[] = "uniform int alpharef;\n";
267
267
static const char unif_key[] = "uniform ivec4 keyX;\n";
268
+static const char unif_world[] = "uniform mat4 matWorld;\n";
268
269
// Variables
269
270
static const char var_common[] = "vec4 diffuse;\n\
270
271
vec4 specular;\n\
—
—
@@ -338,7 +339,7 @@
339
340
}\n";
340
341
static const char func_pointlight[] = "void PointLight(in Light light)\n\
341
342
{\n\
342
-vec4 pos = gl_ModelViewMatrix*xyzw;\n\
343
+vec4 pos = matWorld*xyzw;\n\
343
344
vec3 pos3 = pos.xyz / pos.w;\n\
344
345
vec3 V = light.position - pos3;\n\
345
346
float d = length(V);\n\
—
—
@@ -478,6 +479,7 @@
479
480
if(numlights) // Lighting
480
481
{
481
482
vsrc->append(lightstruct);
483
+ vsrc->append(unif_world);
482
484
tmp = unif_light;
483
485
for(i = 0; i < numlights; i++)
484
486
{
—
—
@@ -1094,6 +1096,7 @@
1095
1097
attrSTRQ[4] = i + '0';
1096
1098
genshaders[index].shader.attribs[i+34] = glGetAttribLocation(genshaders[index].shader.prog,attrSTRQ);
1097
1099
}
1100
+ genshaders[index].shader.uniforms[0] = glGetUniformLocation(genshaders[index].shader.prog,"matWorld");
1098
1101
// Uniforms
1099
1102
// TODO: 4-14 world1-3 and texture0-7
1100
1103
char uniflight[] = "lightX. ";
Navigation menu
Personal tools
Log in
Namespaces
Special page
English
expanded
collapsed
Views
More
expanded
collapsed
Search
Navigation
Home
Main page
Recent changes
Random page
MediaWiki help
Introduction
Progress
Downloads
Source code
Build from source
AppDB
Bug reports
Forums
Tools
Special pages
Printable version