CHAI3D  3.0.0
CTexture1d.h
Go to the documentation of this file.
1 //==============================================================================
2 /*
3  Software License Agreement (BSD License)
4  Copyright (c) 2003-2015, CHAI3D.
5  (www.chai3d.org)
6 
7  All rights reserved.
8 
9  Redistribution and use in source and binary forms, with or without
10  modification, are permitted provided that the following conditions
11  are met:
12 
13  * Redistributions of source code must retain the above copyright
14  notice, this list of conditions and the following disclaimer.
15 
16  * Redistributions in binary form must reproduce the above
17  copyright notice, this list of conditions and the following
18  disclaimer in the documentation and/or other materials provided
19  with the distribution.
20 
21  * Neither the name of CHAI3D nor the names of its contributors may
22  be used to endorse or promote products derived from this software
23  without specific prior written permission.
24 
25  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  POSSIBILITY OF SUCH DAMAGE.
37 
38  \author <http://www.chai3d.org>
39  \author Francois Conti
40  \version 3.0.0 $Rev: 1648 $
41 */
42 //==============================================================================
43 
44 //------------------------------------------------------------------------------
45 #ifndef CTexture1dH
46 #define CTexture1dH
47 //------------------------------------------------------------------------------
48 #include "graphics/CColor.h"
49 #include "graphics/CImage.h"
51 //------------------------------------------------------------------------------
52 
53 //------------------------------------------------------------------------------
54 namespace chai3d {
55 //------------------------------------------------------------------------------
56 
57 //==============================================================================
64 //==============================================================================
65 
66 //------------------------------------------------------------------------------
67 class cTexture1d;
68 typedef std::shared_ptr<cTexture1d> cTexture1dPtr;
69 //------------------------------------------------------------------------------
70 
71 //==============================================================================
82 //==============================================================================
84 {
85  //--------------------------------------------------------------------------
86  // CONSTRUCTOR & DESTRUCTOR:
87  //--------------------------------------------------------------------------
88 
89 public:
90 
92  cTexture1d();
93 
95  virtual ~cTexture1d();
96 
98  static cTexture1dPtr create() { return (std::make_shared<cTexture1d>()); }
99 
100 
101  //--------------------------------------------------------------------------
102  // PUBLIC METHODS:
103  //--------------------------------------------------------------------------
104 
105 public:
106 
108  inline void setTextureUnit(const GLenum a_textureUnit) { m_textureUnit = a_textureUnit; }
109 
111  inline GLenum getTextureUnit() const { return (m_textureUnit); }
112 
114  void setTextureId(const GLuint a_textureId,
115  const int a_displayContext = 0) { m_textureID[a_displayContext] = a_textureId; }
116 
118  GLuint getTextureId(const int a_displayContext = 0) { return(m_textureID[a_displayContext]); }
119 
121  cTexture1dPtr copy();
122 
124  virtual bool loadFromFile(const std::string& a_fileName);
125 
127  virtual bool saveToFile(const std::string& a_fileName);
128 
130  virtual void renderInitialize(cRenderOptions& a_options);
131 
133  virtual void renderFinalize(cRenderOptions& a_options);
134 
136  virtual void markForUpdate();
137 
139  virtual void markForDeleteAndUpdate();
140 
142  void setEnvironmentMode(const GLint& a_environmentMode) { m_environmentMode = a_environmentMode; }
143 
145  GLint getEnvironmentMode() { return (m_environmentMode); }
146 
148  virtual void setWrapModeS(const GLint& a_wrapModeS);
149 
151  GLint getWrapModeS() const { return (m_wrapModeS); }
152 
154  void setMagFunction(const GLint a_magFunction);
155 
157  GLint getMagFunction() const { return (m_magFunction); }
158 
160  void setMinFunction(const GLint a_minFunction);
161 
163  GLint getMinFunction() const { return (m_minFunction); }
164 
166  void setSphericalMappingEnabled(const bool a_enabled) { m_useSphericalMapping = a_enabled; }
167 
170 
172  void setUseMipmaps(bool a_useMipmaps);
173 
175  bool getUseMipmaps() { return (m_useMipmaps); }
176 
178  bool setImage (cImagePtr a_image);
179 
180 
181  //--------------------------------------------------------------------------
182  // PUBLIC METHODS:
183  //--------------------------------------------------------------------------
184 
185 public:
186 
189 
192 
193 
194  //--------------------------------------------------------------------------
195  // PROTECTED METHODS:
196  //--------------------------------------------------------------------------
197 
198 protected:
199 
201  virtual void reset();
202 
204  virtual void update(cRenderOptions& a_options);
205 
206 
207  //--------------------------------------------------------------------------
208  // PROTECTED MEMBERS:
209  //--------------------------------------------------------------------------
210 
211 protected:
212 
214  bool m_deleteTextureFlag[C_MAX_DISPLAY_CONTEXTS];
215 
217  bool m_updateTextureFlag[C_MAX_DISPLAY_CONTEXTS];
218 
220  GLuint m_textureID[C_MAX_DISPLAY_CONTEXTS];
221 
223  GLint m_wrapModeS;
224 
227 
230 
233 
236 
239 
242 
245 
248 
251 
254 };
255 
256 //------------------------------------------------------------------------------
257 } // namespace chai3d
258 //------------------------------------------------------------------------------
259 
260 //------------------------------------------------------------------------------
261 #endif
262 //------------------------------------------------------------------------------
virtual ~cTexture1d()
Destructor of cTexture1d.
Definition: CTexture1d.cpp:77
Implements a base class for textures.
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition: CRenderOptions.h:82
void setEnvironmentMode(const GLint &a_environmentMode)
This method sets the environment mode (GL_MODULATE, GL_DECAL, GL_BLEND, GL_REPLACE).
Definition: CTexture1d.h:142
virtual void reset()
This method resets all internal variables. This function should be called only by constructors...
Definition: CTexture1d.cpp:125
void setTextureUnit(const GLenum a_textureUnit)
This method set the texture unit where a_textureUnit is GL_TEXTUREi_ARB, where 0i
Definition: CTexture1d.h:108
GLuint getTextureId(const int a_displayContext=0)
This method returns the texture ID.
Definition: CTexture1d.h:118
virtual void markForDeleteAndUpdate()
This method marks this texture for GPU deletion and reinitialization.
Definition: CTexture1d.cpp:337
GLint getMinFunction() const
This method returns the current minification function value.
Definition: CTexture1d.h:163
virtual void markForUpdate()
This method marks this texture for GPU update.
Definition: CTexture1d.cpp:322
This class implements a base class for textures.
Definition: CGenericTexture.h:131
void setUseMipmaps(bool a_useMipmaps)
This method enables or disables the use of mipmaps.
Definition: CTexture1d.cpp:519
static cTexture1dPtr create()
Shared cTexture1d allocator.
Definition: CTexture1d.h:98
GLint m_minFunctionMipmapsON
Texture minification function when mipmapping is ON.
Definition: CTexture1d.h:253
virtual void renderFinalize(cRenderOptions &a_options)
This method disables texture rendering. This method should be called after triangles have been render...
Definition: CTexture1d.cpp:275
bool m_useSphericalMapping
If true, spherical mapping is enable.
Definition: CTexture1d.h:235
GLuint m_textureID[C_MAX_DISPLAY_CONTEXTS]
OpenGL texture ID number.
Definition: CTexture1d.h:220
GLenum getTextureUnit() const
This method returns the texture unit value.
Definition: CTexture1d.h:111
GLint m_magFunctionMipmapsOFF
Texture magnification function when mipmapping is OFF.
Definition: CTexture1d.h:244
bool setImage(cImagePtr a_image)
This method assigns an image to this texture.
Definition: CTexture1d.cpp:545
std::shared_ptr< cTexture1d > cTexture1dPtr
Definition: CTexture1d.h:67
GLint m_wrapModeS
Texture wrap parameter along s (GL_REPEAT or GL_CLAMP).
Definition: CTexture1d.h:223
virtual void setWrapModeS(const GLint &a_wrapModeS)
This method set the texture wrap mode of s.
Definition: CTexture1d.cpp:440
GLint getEnvironmentMode()
This method returns the environment mode status.
Definition: CTexture1d.h:145
void setMinFunction(const GLint a_minFunction)
This method sets the minification function value.
Definition: CTexture1d.cpp:495
This class implements a 1D texture map.
Definition: CTexture1d.h:83
virtual bool saveToFile(const std::string &a_fileName)
This method save a texture image to a file.
Definition: CTexture1d.cpp:309
bool getSphericalMappingEnabled() const
This method returns thestatus of the spherical mapping mode.
Definition: CTexture1d.h:169
GLint m_magFunction
Texture magnification function value. (GL_NEAREST or GL_LINEAR).
Definition: CTexture1d.h:226
void setTextureId(const GLuint a_textureId, const int a_displayContext=0)
This method sets the texture ID.
Definition: CTexture1d.h:114
GLenum m_textureUnit
Texture unit number.
Definition: CTexture1d.h:241
cTexture1dPtr copy()
This method creates a copy of itself.
Definition: CTexture1d.cpp:97
bool m_deleteTextureFlag[C_MAX_DISPLAY_CONTEXTS]
If true, texture bitmap needs to be deleted from GPU memory.
Definition: CTexture1d.h:214
GLint m_minFunctionMipmapsOFF
Texture minification function when mipmapping is OFF.
Definition: CTexture1d.h:247
GLint getMagFunction() const
This method returns the current magnification function value.
Definition: CTexture1d.h:157
GLint m_minFunction
Texture minification function value. (GL_NEAREST or GL_LINEAR).
Definition: CTexture1d.h:229
This class defines a color using a GLfloat representation for each component.
Definition: CColor.h:138
Implements color properties.
GLint m_environmentMode
OpenGL texture mode (GL_MODULATE, GL_DECAL, GL_BLEND, or GL_REPLACE).
Definition: CTexture1d.h:238
virtual bool loadFromFile(const std::string &a_fileName)
This method load a texture image from a file.
Definition: CTexture1d.cpp:296
std::shared_ptr< cImage > cImagePtr
Definition: CImage.h:63
bool m_updateTextureFlag[C_MAX_DISPLAY_CONTEXTS]
If true, texture bitmap needs to be updated to GPU memory.
Definition: CTexture1d.h:217
bool m_useMipmaps
If true, mipmaps are enabled.
Definition: CTexture1d.h:232
void setMagFunction(const GLint a_magFunction)
This method sets the magnification function value.
Definition: CTexture1d.cpp:457
virtual void renderInitialize(cRenderOptions &a_options)
This method enables texturing and sets this texture as the current texture.
Definition: CTexture1d.cpp:173
Definition: CAudioBuffer.cpp:56
cImagePtr m_image
Image object associated with texture (use this to get data about the texture itself).
Definition: CTexture1d.h:188
GLint getWrapModeS() const
This method returns the texture wrap mode of s.
Definition: CTexture1d.h:151
bool getUseMipmaps()
This returns the the status of mipmaps.
Definition: CTexture1d.h:175
GLint m_magFunctionMipmapsON
Texture magnification function when mipmapping is ON.
Definition: CTexture1d.h:250
Implements a 2D image data structure.
cColorf m_color
Environmental color.
Definition: CTexture1d.h:191
virtual void update(cRenderOptions &a_options)
This method update the OpenGL texture to GPU.
Definition: CTexture1d.cpp:354
cTexture1d()
Constructor of cTexture1d.
Definition: CTexture1d.cpp:59
void setSphericalMappingEnabled(const bool a_enabled)
This method enables of disables the spherical mapping mode.
Definition: CTexture1d.h:166

CHAI3D 3.0.0 documentation
Please address any questions to support@chai3d.org
(C) 2003-2015 - CHAI3D
All Rights Reserved.