TextureData.hh 4.18 KB
Newer Older
Jan Möbius's avatar
Jan Möbius committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//=============================================================================
//
//                               OpenFlipper
//        Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
//                           www.openflipper.org
//
//-----------------------------------------------------------------------------
//
//                                License
//
//  OpenFlipper is free software: you can redistribute it and/or modify
//  it under the terms of the GNU Lesser General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  OpenFlipper is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public License
//  along with OpenFlipper.  If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
//   $Revision: 5183 $
//   $Author: wilden $
//   $Date: 2009-03-03 12:51:24 +0100 (Tue, 03 Mar 2009) $
//
//=============================================================================

32
33
34
#ifndef TEXTUREDATA_HH
#define TEXTUREDATA_HH

Jan Möbius's avatar
Jan Möbius committed
35
36
37
#include <OpenFlipper/common/perObjectData.hh>

#include <QString>
38
#include <ACG/GL/gl.hh>
Jan Möbius's avatar
Jan Möbius committed
39
40
#include <vector>
#include <map>
41
42
#include <float.h>
#include <iostream>
Jan Möbius's avatar
Jan Möbius committed
43

44
enum TextureType { VERTEXBASED = 1 << 0, HALFEDGEBASED = 1 << 1};
Jan Möbius's avatar
Jan Möbius committed
45

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
class TexParameters
{
  public:
    TexParameters() :
          scale ( true ),
          clamp_min ( FLT_MIN ),
          clamp_max ( FLT_MAX ),
          clamp ( false ),
          repeat ( false ),
          center ( false ),
          abs ( false ),
          max_val ( 1.0 ) {std::cerr << "Constructor for parameters" << std::endl;};

    bool scale;

    double clamp_min;
    double clamp_max;
Jan Möbius's avatar
Jan Möbius committed
63

64
65
    bool clamp;
    bool repeat;
Jan Möbius's avatar
Jan Möbius committed
66

67
    bool center;
Jan Möbius's avatar
Jan Möbius committed
68

69
    bool abs;
Jan Möbius's avatar
Jan Möbius committed
70

71
    double max_val;
Jan Möbius's avatar
Jan Möbius committed
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
};

struct Texture {
  // Texture id
  int id;
  // glName
  GLuint glName;
  // Texture Name
  QString name;
  // Filename of the texture
  QString filename;
  // dimension
  uint dimension;
  // Status
  bool enabled;
  // does this texture need an update?
  bool dirty;
  // Texture Type
  uint type;
  // Parameters
  TexParameters parameters;
};

class TextureData : public PerObjectData
{

  public :

100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
      /// Constructor
      TextureData();
      /// Destructor
      ~TextureData();


      /// Check if a texture exists
      bool textureExists(QString _textureName);


      /// Check if a texture is enabled
      bool isEnabled(QString _textureName);


      /// Enable a given texture
      bool enableTexture(QString _textureName, bool _exclusive = false);

      /// Disable a given texture
      void disableTexture(QString _textureName);

      /// Add a Texture
      int addTexture ( QString _textureName , QString _filename , uint _dimension, GLuint _glName );

      /// Add a Texture ( Based on an existing specification )
      int addTexture ( Texture _texture, GLuint _glName );

      /*
      /// Delete a given texture
      void deleteTexture(QString _textureName);

      /// get parameters of a given texture
      TexParameters textureParameters(QString _textureName);

      /// Set Parameters for a given texture
      void setTextureParameters(QString _textureName, TexParameters _params);
      */

      /// Get the texture object
      Texture& texture(QString _textureName);

      /// Get reference to the texture vector
      std::vector< Texture >& textures();


      /// Get reference to the textureMap
      std::map< int, GLuint >* textureMap();

      /// Get reference to the propertyMap
      std::map< int, std::string >* propertyMap();

Jan Möbius's avatar
Jan Möbius committed
150
151
152
153
154
155

  private :

    std::map< int, GLuint> textureMap_;
    std::map< int, std::string> propertyMap_;

156
    // internal id for the next texture
Jan Möbius's avatar
Jan Möbius committed
157
158
    int nextInternalID_;

159

Jan Möbius's avatar
Jan Möbius committed
160
161
162
    //vector containing all textures of an object
    std::vector< Texture > textures_;

163

Jan Möbius's avatar
Jan Möbius committed
164
165
166
    // Get the index of a given texture
    int getTextureIndex(QString _textureName);

167
168
    Texture noTexture;

Jan Möbius's avatar
Jan Möbius committed
169
170
};

171
#endif //TEXTUREDATA_HH