tavli

diff src/object.cc @ 14:283eb6e9f0a3

scenery
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 28 Jun 2015 07:44:23 +0300
parents a8e26f163f99
children b1a195c3ee16
line diff
     1.1 --- a/src/object.cc	Sat Jun 27 22:33:27 2015 +0300
     1.2 +++ b/src/object.cc	Sun Jun 28 07:44:23 2015 +0300
     1.3 @@ -1,15 +1,29 @@
     1.4  #include "object.h"
     1.5  #include "opengl.h"
     1.6  
     1.7 +Material::Material()
     1.8 +	: diffuse(1, 1, 1), specular(0, 0, 0)
     1.9 +{
    1.10 +	shininess = 60.0;
    1.11 +	alpha = 1.0;
    1.12 +}
    1.13 +
    1.14 +RenderOps::RenderOps()
    1.15 +{
    1.16 +	zwrite = true;
    1.17 +}
    1.18 +
    1.19 +void RenderOps::setup() const
    1.20 +{
    1.21 +	if(!zwrite) {
    1.22 +		glDepthMask(0);
    1.23 +	}
    1.24 +}
    1.25 +
    1.26  Object::Object()
    1.27  {
    1.28  	mesh = 0;
    1.29  	tex = 0;
    1.30 -
    1.31 -	mtl.diffuse = Vector3(1, 1, 1);
    1.32 -	mtl.specular = Vector3(0, 0, 0);
    1.33 -	mtl.shininess = 60.0;
    1.34 -	mtl.alpha = 1.0;
    1.35  }
    1.36  
    1.37  Object::~Object()
    1.38 @@ -56,6 +70,9 @@
    1.39  {
    1.40  	if(!mesh) return;
    1.41  
    1.42 +	glPushAttrib(GL_ENABLE_BIT | GL_DEPTH_BUFFER_BIT);
    1.43 +	rop.setup();
    1.44 +
    1.45  	if(tex) {
    1.46  		glBindTexture(GL_TEXTURE_2D, tex);
    1.47  		glEnable(GL_TEXTURE_2D);
    1.48 @@ -88,6 +105,8 @@
    1.49  
    1.50  	glMatrixMode(GL_MODELVIEW);
    1.51  	glPopMatrix();
    1.52 +
    1.53 +	glPopAttrib();
    1.54  }
    1.55  
    1.56  void Object::draw_wire(const Vector4 &col) const