Go to the documentation of this file.00001 #ifndef OPENTISSUE_UTILITY_GL_GL_DRAW_TEXTURE2D_H
00002 #define OPENTISSUE_UTILITY_GL_GL_DRAW_TEXTURE2D_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/utility/gl/gl_util.h>
00013
00014 namespace OpenTissue
00015 {
00016
00017 namespace gl
00018 {
00019
00028 template<typename texture_type>
00029 inline void DrawTexture2D(texture_type const & texture )
00030 {
00031 gl::gl_check_errors("DrawTexture2D() - start");
00032 bool rectangular = texture.width()!=texture.height();
00033 texture.bind();
00034 gl::gl_check_errors("DrawTexture2D() - bind");
00035 if(rectangular)
00036 {
00037 glBegin(GL_POLYGON);
00038 glTexCoord2f(0,0);
00039 glVertex3d(0,0,0);
00040 glTexCoord2f(texture.width(),0);
00041 glVertex3d(texture.width(),0,0);
00042 glTexCoord2f(texture.width(),texture.height());
00043 glVertex3d(texture.width(),texture.height(),0);
00044 glTexCoord2f(0,texture.height());
00045 glVertex3d(0,texture.height(),0);
00046 glEnd();
00047 gl::gl_check_errors("DrawTexture2D() - draw rectangle");
00048 }
00049 else
00050 {
00051 glBegin(GL_POLYGON);
00052 glTexCoord2f(0,0);
00053 glVertex3d(0,0,0);
00054 glTexCoord2f(1,0);
00055 glVertex3d(texture.width(),0,0);
00056 glTexCoord2f(1,1);
00057 glVertex3d(texture.width(),texture.height(),0);
00058 glTexCoord2f(0,1);
00059 glVertex3d(0,texture.height(),0);
00060 glEnd();
00061 gl::gl_check_errors("DrawTexture2D() - draw");
00062 }
00063
00064 gl::gl_check_errors("DrawTexture2D() - done");
00065 }
00066
00067 }
00068
00069
00070 }
00071
00072
00073 #endif