Go to the documentation of this file.00001 #ifndef OPENTISSUE_OPENTISSUE_GL_GL_DRAW_TRIANGLE_H
00002 #define OPENTISSUE_OPENTISSUE_GL_GL_DRAW_TRIANGLE_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/utility/gl/gl.h>
00013
00014 namespace OpenTissue
00015 {
00016
00017 namespace gl
00018 {
00019
00026 template<typename triangle_type>
00027 inline void DrawTriangle(triangle_type const & triangle, bool wireframe = false)
00028 {
00029 typedef typename triangle_type::vector3_type vector3_type;
00030
00031 vector3_type const & p0 = triangle.p0();
00032 vector3_type const & p1 = triangle.p1();
00033 vector3_type const & p2 = triangle.p2();
00034
00035 vector3_type n,v,u;
00036 v = p1 - p0;
00037 u = p2 - p1;
00038 n = unit( v % u);
00039 glBegin(wireframe?GL_LINE_LOOP:GL_POLYGON);
00040 glNormal3f((GLfloat)n[0],(GLfloat)n[1],(GLfloat)n[2]);
00041 glVertex3f((GLfloat)p0[0],(GLfloat)p0[1],(GLfloat)p0[2]);
00042 glNormal3f((GLfloat)n[0],(GLfloat)n[1],(GLfloat)n[2]);
00043 glVertex3f((GLfloat)p1[0],(GLfloat)p1[1],(GLfloat)p1[2]);
00044 glNormal3f((GLfloat)n[0],(GLfloat)n[1],(GLfloat)n[2]);
00045 glVertex3f((GLfloat)p2[0],(GLfloat)p2[1],(GLfloat)p2[2]);
00046 glEnd();
00047 }
00048
00049 }
00050
00051 }
00052
00053
00054 #endif