Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Texture2DPool.hh
1 /*
2  This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4  Copyright (C) 2008, 2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10  BIAS is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation; either version 2.1 of the License, or
13  (at your option) any later version.
14 
15  BIAS is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with BIAS; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  */
24 
25 #ifndef __Texture2DPool_hh__
26 #define __Texture2DPool_hh__
27 
28 #include <OpenGLFramework/Base/glfTexture2D.hh>
29 #include <map>
30 
31 #include <bias_config.h>
32 
33 namespace BIAS
34 {
35 
36  /** Convenience container for managing 2D textures.
37  * \ingroup g_openglframework
38  * \author bartczak 03/2009
39  **/
40  class BIASOpenGLFramework_EXPORT Texture2DPool
41  {
42  public:
43 
44  /** Terminates the lifecycle of all textures created in the pool! **/
45  ~Texture2DPool();
47  {
48  }
49 
50  /** Returns NULL if name is not found.
51  **/
53  operator[](const std::string& name);
54 
55  /** Allocates an empty texture **/
57  Create(const std::string& name, int width, int height,
58  GLenum internalFormat, GLenum minFilter = GL_NEAREST, GLenum magFilter =
59  GL_NEAREST, GLenum wrapS = GL_CLAMP, GLenum wrapT = GL_CLAMP,
60  int mipmap = 0);
61 
62  /** Uploads BIAS image to texture space **/
64  Create(const std::string& name, const BIAS::ImageBase& img,
65  GLenum minFilter = GL_NEAREST, GLenum magFilter = GL_NEAREST,
66  GLenum wrapS = GL_CLAMP, GLenum wrapT = GL_CLAMP,
67  GLenum internalFormat = 0, int mipmap = 0);
68 
70  Create(const std::string& name, int width, int height,
71  ImageBase::EStorageType storageType, ImageBase::EColorModel colorModel,
72  GLenum minFilter = GL_NEAREST, GLenum magFilter = GL_NEAREST,
73  GLenum wrapS = GL_CLAMP, GLenum wrapT = GL_CLAMP, int mipmap = 0);
74 
76  UploadImage(const std::string& name, const BIAS::ImageBase& img,
77  GLenum minFilter = GL_NEAREST, GLenum magFilter = GL_NEAREST,
78  GLenum wrapS = GL_CLAMP, GLenum wrapT = GL_CLAMP,
79  GLenum internalFormat = 0, int mipmap = 0);
80 
81  void
82  ClearAll();
83  void
84  Clear(const std::string& name);
85 
86  std::map<std::string, BIAS::glfTexture2D*> GetTextureMap() { return texturePool_; }
87 
88  private:
89 
90  std::map<std::string, BIAS::glfTexture2D*> texturePool_;
91 
93  operator=(const Texture2DPool&)
94  {
95  return (*this);
96  }
97  Texture2DPool(const Texture2DPool&)
98  {
99  }
100 
101  };
102 
103 }
104 
105 #endif
EColorModel
These are the most often used color models.
Definition: ImageBase.hh:127
A 2D texture.
Definition: glfTexture2D.hh:40
std::map< std::string, BIAS::glfTexture2D * > GetTextureMap()
Convenience container for managing 2D textures.
This is the base class for images in BIAS.
Definition: ImageBase.hh:102