tavli

diff src/object.cc @ 15:b1a195c3ee16

added shaders
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 28 Jun 2015 08:34:24 +0300
parents 283eb6e9f0a3
children d6209903454b
line diff
     1.1 --- a/src/object.cc	Sun Jun 28 07:44:23 2015 +0300
     1.2 +++ b/src/object.cc	Sun Jun 28 08:34:24 2015 +0300
     1.3 @@ -24,6 +24,7 @@
     1.4  {
     1.5  	mesh = 0;
     1.6  	tex = 0;
     1.7 +	sdr = 0;
     1.8  }
     1.9  
    1.10  Object::~Object()
    1.11 @@ -66,6 +67,11 @@
    1.12  	this->tex = tex;
    1.13  }
    1.14  
    1.15 +void Object::set_shader(unsigned int sdr)
    1.16 +{
    1.17 +	this->sdr = sdr;
    1.18 +}
    1.19 +
    1.20  void Object::draw() const
    1.21  {
    1.22  	if(!mesh) return;
    1.23 @@ -73,6 +79,10 @@
    1.24  	glPushAttrib(GL_ENABLE_BIT | GL_DEPTH_BUFFER_BIT);
    1.25  	rop.setup();
    1.26  
    1.27 +	if(sdr) {
    1.28 +		glUseProgram(sdr);
    1.29 +	}
    1.30 +
    1.31  	if(tex) {
    1.32  		glBindTexture(GL_TEXTURE_2D, tex);
    1.33  		glEnable(GL_TEXTURE_2D);
    1.34 @@ -103,6 +113,10 @@
    1.35  		glPopMatrix();
    1.36  	}
    1.37  
    1.38 +	if(sdr) {
    1.39 +		glUseProgram(0);
    1.40 +	}
    1.41 +
    1.42  	glMatrixMode(GL_MODELVIEW);
    1.43  	glPopMatrix();
    1.44