File: Triangle.cpp

package info (click to toggle)
structure-synth 1.0.0-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,072 kB
  • ctags: 1,176
  • sloc: cpp: 7,070; python: 167; makefile: 66; lisp: 25
file content (46 lines) | stat: -rw-r--r-- 957 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "Triangle.h"

#include "SyntopiaCore/Math/Vector3.h"

using namespace SyntopiaCore::Math;

namespace SyntopiaCore {
	namespace GLEngine {


		Triangle::Triangle(SyntopiaCore::Math::Vector3f p1 , 
				 SyntopiaCore::Math::Vector3f p2, 
				 SyntopiaCore::Math::Vector3f p3) : p1(p1), p2(p2), p3(p3) 
		{
			/// Bounding box (very approximate :-) )
			from = p1;
			to = p3;
		};

		Triangle::~Triangle() { };

		void Triangle::draw() const {
			glPushMatrix();
			
			glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, primaryColor );
			glPolygonMode(GL_FRONT, GL_FILL);
				
			glEnable(GL_CULL_FACE);
			glEnable (GL_LIGHTING);

			glEnable (GL_BLEND);
			glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
			
			glMateriali(GL_FRONT, GL_SPECULAR, 30);
			glMateriali(GL_FRONT, GL_SHININESS, 127);
			
			glBegin(GL_TRIANGLES);
			vertex3n(p1,p2,p3);
			glEnd();	
			
			glPopMatrix();			
		};

	}
}