My Project
Loading...
Searching...
No Matches
CTexture1d.h
Go to the documentation of this file.
1//==============================================================================
2/*
3 Software License Agreement (BSD License)
4 Copyright (c) 2003-2024, 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.3.0
41*/
42//==============================================================================
43
44//------------------------------------------------------------------------------
45#ifndef CTexture1dH
46#define CTexture1dH
47//------------------------------------------------------------------------------
48#include "graphics/CColor.h"
49#include "graphics/CImage.h"
51//------------------------------------------------------------------------------
52
53//------------------------------------------------------------------------------
54namespace chai3d {
55//------------------------------------------------------------------------------
56
57//==============================================================================
64//==============================================================================
65
66//------------------------------------------------------------------------------
67class cTexture1d;
68typedef std::shared_ptr<cTexture1d> cTexture1dPtr;
69//------------------------------------------------------------------------------
70
71//==============================================================================
82//==============================================================================
84{
85 //--------------------------------------------------------------------------
86 // CONSTRUCTOR & DESTRUCTOR:
87 //--------------------------------------------------------------------------
88
89public:
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
105public:
106
108 virtual std::string getClassName() { return ("Texture1d"); }
109
111 inline void setTextureUnit(const GLenum a_textureUnit) { m_textureUnit = a_textureUnit; }
112
114 inline GLenum getTextureUnit() const { return (m_textureUnit); }
115
117 void setTextureId(const GLuint a_textureId) { m_textureID = a_textureId; }
118
120 GLuint getTextureId() { return(m_textureID); }
121
124
126 virtual bool loadFromFile(const std::string& a_fileName);
127
129 virtual bool saveToFile(const std::string& a_fileName);
130
132 virtual void renderInitialize(cRenderOptions& a_options);
133
135 virtual void renderFinalize(cRenderOptions& a_options);
136
138 virtual void markForUpdate();
139
141 virtual void markForDeleteAndUpdate();
142
144 void setEnvironmentMode(const GLint& a_environmentMode) { m_environmentMode = a_environmentMode; }
145
148
150 virtual void setWrapModeS(const GLint& a_wrapModeS);
151
153 GLint getWrapModeS() const { return (m_wrapModeS); }
154
156 void setMagFunction(const GLint a_magFunction);
157
159 GLint getMagFunction() const { return (m_magFunction); }
160
162 void setMinFunction(const GLint a_minFunction);
163
165 GLint getMinFunction() const { return (m_minFunction); }
166
168 void setSphericalMappingEnabled(const bool a_enabled) { m_useSphericalMapping = a_enabled; }
169
172
174 void setUseMipmaps(bool a_useMipmaps);
175
177 bool getUseMipmaps() { return (m_useMipmaps); }
178
180 bool setImage (cImagePtr a_image);
181
182
183 //--------------------------------------------------------------------------
184 // PUBLIC METHODS:
185 //--------------------------------------------------------------------------
186
187public:
188
191
194
195
196 //--------------------------------------------------------------------------
197 // PROTECTED METHODS:
198 //--------------------------------------------------------------------------
199
200protected:
201
203 virtual void reset();
204
206 virtual void update(cRenderOptions& a_options);
207
208
209 //--------------------------------------------------------------------------
210 // PROTECTED MEMBERS:
211 //--------------------------------------------------------------------------
212
213protected:
214
217
220
223
226
229
232
235
238
241
244
247
250
253
256};
257
258//------------------------------------------------------------------------------
259} // namespace chai3d
260//------------------------------------------------------------------------------
261
262//------------------------------------------------------------------------------
263#endif
264//------------------------------------------------------------------------------
Implements color properties.
Implements a base class for textures.
Implements a 2D image data structure.
This class implements a base class for textures.
Definition CGenericTexture.h:133
This class implements a 1D texture map.
Definition CTexture1d.h:84
GLuint getTextureId()
This method returns the texture ID.
Definition CTexture1d.h:120
GLint m_environmentMode
OpenGL texture mode (GL_MODULATE, GL_DECAL, GL_BLEND, or GL_REPLACE).
Definition CTexture1d.h:240
GLint m_minFunctionMipmapsON
Texture minification function when mipmapping is ON.
Definition CTexture1d.h:255
bool m_useMipmaps
If true, mipmaps are enabled.
Definition CTexture1d.h:234
void setTextureId(const GLuint a_textureId)
This method sets the texture ID.
Definition CTexture1d.h:117
cTexture1dPtr copy()
This method creates a copy of itself.
Definition CTexture1d.cpp:97
virtual void markForDeleteAndUpdate()
This method marks this texture for GPU deletion and reinitialization.
Definition CTexture1d.cpp:332
virtual ~cTexture1d()
Destructor of cTexture1d.
Definition CTexture1d.cpp:77
cTexture1d()
Constructor of cTexture1d.
Definition CTexture1d.cpp:59
GLint getEnvironmentMode()
This method returns the environment mode status.
Definition CTexture1d.h:147
GLint getWrapModeS() const
This method returns the texture wrap mode of s.
Definition CTexture1d.h:153
virtual void reset()
This method resets all internal variables. This function should be called only by constructors.
Definition CTexture1d.cpp:125
GLint m_minFunctionMipmapsOFF
Texture minification function when mipmapping is OFF.
Definition CTexture1d.h:249
GLint getMagFunction() const
This method returns the current magnification function value.
Definition CTexture1d.h:159
bool getUseMipmaps()
This returns the the status of mipmaps.
Definition CTexture1d.h:177
virtual void markForUpdate()
This method marks this texture for GPU update.
Definition CTexture1d.cpp:320
bool m_updateTextureFlag
If true, texture bitmap needs to be updated to GPU memory.
Definition CTexture1d.h:219
void setMagFunction(const GLint a_magFunction)
This method sets the magnification function value.
Definition CTexture1d.cpp:449
cColorf m_color
Environmental color.
Definition CTexture1d.h:193
void setUseMipmaps(bool a_useMipmaps)
This method enables or disables the use of mipmaps.
Definition CTexture1d.cpp:511
static cTexture1dPtr create()
Shared cTexture1d allocator.
Definition CTexture1d.h:98
bool m_useSphericalMapping
If true, spherical mapping is enable.
Definition CTexture1d.h:237
bool m_deleteTextureFlag
If true, texture bitmap needs to be deleted from GPU memory.
Definition CTexture1d.h:216
GLint m_minFunction
Texture minification function value. (GL_NEAREST or GL_LINEAR).
Definition CTexture1d.h:231
virtual void renderInitialize(cRenderOptions &a_options)
This method enables texturing and sets this texture as the current texture.
Definition CTexture1d.cpp:171
virtual bool saveToFile(const std::string &a_fileName)
This method save a texture image to a file.
Definition CTexture1d.cpp:307
void setMinFunction(const GLint a_minFunction)
This method sets the minification function value.
Definition CTexture1d.cpp:487
void setTextureUnit(const GLenum a_textureUnit)
This method set the texture unit where a_textureUnit is GL_TEXTUREi_ARB, where 0i<GL_MAX_TEXTURE_UNIT...
Definition CTexture1d.h:111
GLint m_magFunction
Texture magnification function value. (GL_NEAREST or GL_LINEAR).
Definition CTexture1d.h:228
GLint m_magFunctionMipmapsON
Texture magnification function when mipmapping is ON.
Definition CTexture1d.h:252
GLuint m_textureID
OpenGL texture ID number.
Definition CTexture1d.h:222
bool getSphericalMappingEnabled() const
This method returns thestatus of the spherical mapping mode.
Definition CTexture1d.h:171
GLint getMinFunction() const
This method returns the current minification function value.
Definition CTexture1d.h:165
virtual void renderFinalize(cRenderOptions &a_options)
This method disables texture rendering. This method should be called after triangles have been render...
Definition CTexture1d.cpp:273
virtual void update(cRenderOptions &a_options)
This method update the OpenGL texture to GPU.
Definition CTexture1d.cpp:346
bool setImage(cImagePtr a_image)
This method assigns an image to this texture.
Definition CTexture1d.cpp:537
virtual bool loadFromFile(const std::string &a_fileName)
This method load a texture image from a file.
Definition CTexture1d.cpp:294
GLint m_magFunctionMipmapsOFF
Texture magnification function when mipmapping is OFF.
Definition CTexture1d.h:246
virtual void setWrapModeS(const GLint &a_wrapModeS)
This method set the texture wrap mode of s.
Definition CTexture1d.cpp:432
virtual std::string getClassName()
This method returns the name of the object class.
Definition CTexture1d.h:108
GLint m_wrapModeS
Texture wrap parameter along s (GL_REPEAT or GL_CLAMP).
Definition CTexture1d.h:225
GLenum m_textureUnit
Texture unit number.
Definition CTexture1d.h:243
GLenum getTextureUnit() const
This method returns the texture unit value.
Definition CTexture1d.h:114
void setEnvironmentMode(const GLint &a_environmentMode)
This method sets the environment mode (GL_MODULATE, GL_DECAL, GL_BLEND, GL_REPLACE).
Definition CTexture1d.h:144
cImagePtr m_image
Image object associated with texture (use this to get data about the texture itself).
Definition CTexture1d.h:190
void setSphericalMappingEnabled(const bool a_enabled)
This method enables of disables the spherical mapping mode.
Definition CTexture1d.h:168
Definition CAudioBuffer.cpp:57
std::shared_ptr< cImage > cImagePtr
Definition CImage.h:64
std::shared_ptr< cTexture1d > cTexture1dPtr
Definition CTexture1d.h:68
This class defines a color using a GLfloat representation for each component.
Definition CColor.h:139
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition CRenderOptions.h:83