Go to the documentation of this file.00001 #ifndef OPENTISSUE_GPU_TEXTURE_TEXTURE_SHOW_TEXTURE2D_H
00002 #define OPENTISSUE_GPU_TEXTURE_TEXTURE_SHOW_TEXTURE2D_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/gpu/cg/cg_program.h>
00013
00014 namespace OpenTissue
00015 {
00016 namespace texture
00017 {
00018
00025 template<typename texture2D_pointer>
00026 inline void show_texture2D( texture2D_pointer texture )
00027 {
00028 static cg::Program vp;
00029 static cg::Program fp;
00030
00031 static std::string path = opentissue_path + "/OpenTissue/gpu/texture";
00032
00033 bool cull_face_enabled = glIsEnabled(GL_CULL_FACE)?true:false;
00034 bool depth_test_enabled = glIsEnabled(GL_DEPTH_TEST)?true:false;
00035 glDisable( GL_CULL_FACE );
00036 glDisable( GL_DEPTH_TEST );
00037
00038 if(!vp.is_program_loaded())
00039 vp.load_from_file(cg::Program::vertex_program,path + "/vp_show_texture2D.cg");
00040 vp.enable();
00041
00042 if(!fp.is_program_loaded())
00043 fp.load_from_file(cg::Program::fragment_program,path + "/fp_show_texture2D.cg");
00044 fp.set_input_texture("texture", texture);
00045 fp.enable();
00046
00047 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
00048 glBegin( GL_QUADS );
00049 {
00050 glTexCoord2f( 0, 0 );
00051 glVertex3f( -1, -1, 0 );
00052 glTexCoord2f( texture->width(), 0 );
00053 glVertex3f( 1, -1, 0 );
00054 glTexCoord2f( texture->width(), texture->height() );
00055 glVertex3f( 1, 1, 0 );
00056 glTexCoord2f( 0, texture->height() );
00057 glVertex3f( -1, 1, 0 );
00058 }
00059 glEnd();
00060
00061 vp.disable();
00062 fp.disable();
00063
00064 if(cull_face_enabled)
00065 glEnable(GL_CULL_FACE);
00066 if(depth_test_enabled)
00067 glEnable(GL_DEPTH_TEST);
00068 }
00069
00070 }
00071
00072 }
00073
00074
00075 #endif
00076