dungeon_crawler

diff prototype/src/light.cc @ 33:0357994effe2

ha! fixed deferred
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 28 Aug 2012 03:18:47 +0300
parents 2fc004802739
children 862461b686f4
line diff
     1.1 --- a/prototype/src/light.cc	Tue Aug 28 02:18:19 2012 +0300
     1.2 +++ b/prototype/src/light.cc	Tue Aug 28 03:18:47 2012 +0300
     1.3 @@ -1,5 +1,6 @@
     1.4  #include "opengl.h"
     1.5  #include "light.h"
     1.6 +#include "renderer.h"
     1.7  
     1.8  Light::Light(const Color &col)
     1.9  	: color(col)
    1.10 @@ -58,6 +59,7 @@
    1.11  
    1.12  
    1.13  PointLight::PointLight()
    1.14 +	: Light(Color(1.0, 1.0, 1.0))
    1.15  {
    1.16  	atten[0] = 1.0f;
    1.17  	atten[1] = 0.0f;
    1.18 @@ -108,6 +110,17 @@
    1.19  
    1.20  void PointLight::draw() const
    1.21  {
    1.22 +	unsigned int sdr = get_deferred_shader();
    1.23 +	if(sdr) {
    1.24 +		int loc;
    1.25 +		if((loc = glGetUniformLocation(sdr, "light_radius")) != -1) {
    1.26 +			glUniform1f(loc, radius);
    1.27 +		}
    1.28 +		if((loc = glGetUniformLocation(sdr, "light_color")) != -1) {
    1.29 +			glUniform3f(loc, color.x, color.y, color.z);
    1.30 +		}
    1.31 +	}
    1.32 +
    1.33  	glMatrixMode(GL_MODELVIEW);
    1.34  	glPushMatrix();
    1.35  	glTranslatef(pos.x, pos.y, pos.z);