Go to the documentation of this file.00001 #ifndef OPENTISSUE_UTILITY_GL_GL_DRAW_IMAGE_H
00002 #define OPENTISSUE_UTILITY_GL_GL_DRAW_IMAGE_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/utility/gl/gl_util.h>
00013 #include <OpenTissue/gpu/texture/texture_texture2D.h>
00014
00015 namespace OpenTissue
00016 {
00017
00018 namespace gl
00019 {
00020
00021 template<typename image_type>
00022 inline void DrawImage(image_type const & image )
00023 {
00024 gl_check_errors("DrawImage() - start");
00025 bool rectangular = image.width()==image.height();
00026 OpenTissue::texture::texture2D_pointer texture = image.create_texture(GL_RGBA,rectangular);
00027 texture->bind();
00028 if(rectangular)
00029 {
00030 glBegin(GL_POLYGON);
00031 glTexCoord2f(0,0);
00032 glVertex3d(0,0,0);
00033 glTexCoord2f(image.width(),0);
00034 glVertex3d(image.width(),0,0);
00035 glTexCoord2f(image.width(),image.height());
00036 glVertex3d(image.width(),image.height(),0);
00037 glTexCoord2f(0,image.height());
00038 glVertex3d(0,image.height(),0);
00039 glEnd();
00040 }
00041 else
00042 {
00043 glBegin(GL_POLYGON);
00044 glTexCoord2f(0,0);
00045 glVertex3d(0,0,0);
00046 glTexCoord2f(1,0);
00047 glVertex3d(image.width(),0,0);
00048 glTexCoord2f(1,1);
00049 glVertex3d(image.width(),image.height(),0);
00050 glTexCoord2f(0,1);
00051 glVertex3d(0,image.height(),0);
00052 glEnd();
00053 }
00054 gl_check_errors("DrawImage() - done");
00055 }
00056
00057 }
00058
00059 }
00060
00061
00062 #endif