Texture.h

Go to the documentation of this file.
00001 
00005 /* Copyright © 2009, 2010 James Legg.
00006     This program is free software: you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation, either version 3 of the License, or
00009     (at your option) any later version.
00010 */
00011 
00012 #ifndef LIBTRACK_TEXTURE_H_
00013 #define LIBTRACK_TEXTURE_H_
00014 
00015 #include <string>
00016 #include <istream>
00017 #include <boost/shared_ptr.hpp>
00018 #include <GL/gl.h>
00019 
00020 namespace Track
00021 {
00022 
00026 class Texture
00027 {
00028 public:
00030     Texture(std::istream & source);
00032     Texture(std::string filename);
00033     Texture();
00034     virtual ~Texture();
00036     const std::string & get_filename() const;
00037     
00039     virtual void bind() const;
00040     
00046     void make_cache() const;
00047 protected:
00049     std::string m_filename;
00050     
00051     /* There are several mutable things.
00052      * These are used when loading the image the first time.
00053      * However, they should not affect the the way the object behaves,
00054      * only prevent disk access and loading the second time around.
00055      */
00056     
00058     mutable GLuint m_texture_name;
00059     
00065     mutable boost::shared_ptr<GLuint> m_texture_name_ref;
00066     
00068     mutable GLenum m_target;
00069     
00071     mutable unsigned int m_width;
00073     mutable unsigned int m_height;
00075     mutable bool m_has_alpha;
00076     
00081     static void delete_gl_texture(GLuint * texture);
00082     
00087     GLuint * load_gl_texture() const;
00088     
00090     virtual void load_from_file() const;
00091 };
00092 
00093 }
00094 
00095 #endif /*LIBTRACK_TEXTURE_H_*/

Get Racer at SourceForge.net. Fast, secure and Free Open Source software downloads

Generated at Mon Sep 6 00:41:12 2010 by Doxygen version 1.4.7 for Racer version svn335.