Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

texture.h

00001 //FILE:         texture.h
00002 //AUTHOR:       Nathan Cournia <nathan@cournia.com>
00003 
00004 #ifndef COURNIA_TEXTURE_H
00005 #define COURNIA_TEXTURE_H 1
00006 
00007 #ifdef WIN32
00008 #define WIN32_LEAN_AND_MEAN
00009 #include <windows.h>
00010 #endif
00011 
00012 #include <string>
00013 #include <GL/gl.h>
00014 #include "mathematics.h"
00015 #include "image.h"
00016 
00017 namespace gl {
00018         class texture;
00019 }
00020 
00022 
00037 class gl::texture
00038 {
00039 private:
00040         GLuint m_handle; 
00041         real_t m_aspect; 
00042 
00043 public:
00045         texture( void ): m_handle( 0 ), m_aspect( 0.0 ) { }
00046 
00048         texture( const texture& cpy ): 
00049                 m_handle( cpy.m_handle ), 
00050                 m_aspect( cpy.m_aspect )
00051                 { }
00052         
00054         inline texture& operator=( const texture& cpy ) {
00055                 m_handle = cpy.m_handle;
00056                 m_aspect = cpy.m_aspect;
00057                 return *this;
00058         }
00059 
00061         inline void set( GLuint handle, real_t aspect ) {
00062                 m_handle = handle;
00063                 m_aspect = aspect;
00064         }
00065         
00067         inline operator GLuint( void ) const {
00068                 return m_handle;
00069         }
00070 
00072         inline void erase( void ) {
00073                 glDeleteTextures( 1, &m_handle );
00074         }
00075 
00077         inline void bind( void ) const {
00078                 glBindTexture( GL_TEXTURE_2D, m_handle );
00079         }
00080 
00082         inline real_t get_aspect( void ) const {
00083                 return m_aspect;
00084         }
00085 
00087         static void set_greyscale_format( GLenum format ) {
00088                 s_greyscale_format = format;
00089         }
00090 
00092 
00098         static texture load( const std::string& filename, 
00099                 bool build_mipmaps = true, 
00100                 GLfloat min_filter = GL_LINEAR_MIPMAP_LINEAR, 
00101                 GLfloat max_filter = GL_LINEAR );
00102 
00104 
00110         static texture load( std::istream& stream,
00111                 bool build_mipmaps = true, 
00112                 GLfloat min_filter = GL_LINEAR_MIPMAP_LINEAR, 
00113                 GLfloat max_filter = GL_LINEAR );
00114 
00116 
00122         static texture load( image::image_t* img,
00123                 bool build_mipmaps = true, 
00124                 GLfloat min_filter = GL_LINEAR_MIPMAP_LINEAR, 
00125                 GLfloat max_filter = GL_LINEAR );
00126                         
00127         //inline operator bool( void ) const {
00128         //      return static_cast<bool>m_handle;
00129         //}
00130         
00131         static GLenum s_greyscale_format;
00132 };
00133 
00134 #endif

Generated on Tue Feb 11 18:49:42 2003 for uber by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002