usata-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Usata-commits] Changes to usata2/src/texture.hpp


From: David Lau
Subject: [Usata-commits] Changes to usata2/src/texture.hpp
Date: Wed, 19 Jan 2005 20:15:12 -0500

Index: usata2/src/texture.hpp
diff -u usata2/src/texture.hpp:1.7 usata2/src/texture.hpp:1.8
--- usata2/src/texture.hpp:1.7  Wed Jan 19 06:28:47 2005
+++ usata2/src/texture.hpp      Thu Jan 20 01:15:09 2005
@@ -1,7 +1,7 @@
 // -*- mode: C++; tab-width: 4; indent-tabs-mode: t; -*- vim:ts=4:sw=4
 //
-// Copyright (C) 2004  David Lau (skunix)
-//                     Chong Kai Xiong (descender)
+// Copyright (C) 2004-2005  David Lau (skunix)
+//                          Chong Kai Xiong (descender)
 //
 // This file is part of The Plains of Usata.
 //
@@ -10,66 +10,86 @@
 // included in the software distribution, or visit
 // http://www.fsf.org/licenses/gpl.html.
 //
-// $Id: texture.hpp,v 1.7 2005/01/19 06:28:47 skunix Exp $
+// $Id: texture.hpp,v 1.8 2005/01/20 01:15:09 skunix Exp $
 
 #ifndef USATA_TEXTURE_HPP
 #define USATA_TEXTURE_HPP
 
-#include <GL/glew.h>
 #include <string>
 #include <memory>
+
 #include <boost/filesystem/path.hpp>
 #include <boost/shared_ptr.hpp>
+
+#include <GL/glew.h>
+
 #include "texture-meta.hpp"
 #include "resource-manager.hpp"
+
 namespace usata
 {
 
-       struct TextureManagerImpl;      
+//     struct TextureManagerImpl;
 
-       class TextureMeta;      
-       // move texture meta int another header
-
-       class Texture
+       class TextureMeta;
+       
+       class Pixmap;
+       
+       //! Texture map resource class
+       class TextureMap
        {
                private:
                        GLuint          tex_id;
                        GLuint          tex_gl_format;
+                       GLenum          m_gl_texture_type;
+                       std::auto_ptr<Pixmap> m_pixmap;
+                       //! uses glGenTextures to allocate its id
                        void            allocate_gltex (void);
+                       void            finish_load_1d(GLint);
+                       void            finish_load_2d(GLint);
+       
+                       //! gets the texture map data to GL
+                       void            finish_load();
+               
                public:
-                       Texture(const TextureMeta*);
-                       Texture(const TextureMeta&);
-                       bool reload(const TextureMeta*);
-                       GLuint get_tex() { return tex_id; }
-                       ~Texture();
+                       TextureMap(const TextureMeta&);
+
+                       bool reload();
+                       /**
+                               \note only to be called from the drawing 
thread!!!,
+                                       since it will call openGL functions the 
first time its
+                                       used.
+                       */
+                       GLuint get_tex() 
+                       { 
+                               if (m_pixmap.get()!=0)
+                                       finish_load();
+                                       return tex_id; 
+                       }
+                       //! retrieve the type of the texture (like 
GL_TEXTURE_2D)
+                       GLenum texture_type(){ return m_gl_texture_type;}
+                       ~TextureMap();
        };
 
+       typedef TextureMap Texture;
+
        typedef boost::shared_ptr<Texture> Texture_sp;
 
-       class TextureMapManager : public ResourceManager<Texture, TextureMeta, 
std::string>
+       class TextureMapManager 
+       :       public ResourceManager<TextureMap, TextureMeta, std::string>
        {
-               typedef resource Image_sp;
                public:
-                       Image_sp get(const std::string& name);
-                       bool    get(const std::string& name, Image_sp&);
-                       void meta_add(const TextureMeta*);
-                       void load_path(const boost::filesystem::path&);
+                       typedef resource TextureMap_sp;
+                       TextureMap_sp 
+                                       get(const std::string& name);
+                       //! failable retrieval
+                       bool    get(const std::string& name, TextureMap_sp&);
+                       void    meta_add(const TextureMeta*);
+                       void    load_path(const boost::filesystem::path&);
        };
 
-/*
-       class TextureManager
-       {
-                       std::auto_ptr<TextureManagerImpl> impl;
-               public:
-                       TextureManager();
-                       ~TextureManager();
-                       void load_path(const boost::filesystem::path&);
-                       void add_meta(const TextureMeta*m);
-       
-                       Texture_sp get(const std::string&texAlias);             
        
+       typedef TextureMapManager::TextureMap_sp TextureMap_sp;
 
-       };
-*/
 }
 #endif  
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]