My Project
Loading...
Searching...
No Matches
CGenericTexture.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// Texture Filter Parameters Explained:
46//------------------------------------------------------------------------------
47/*
48 The value of parameter number three depends on whether you are setting a
49 GL_TEXTURE_MIN_FILTER variable or a GL_TEXTURE_MAG_FILTER variable.
50 Here are the possible combinations:
51
52 When the second parameter is GL_TEXTURE_MIN_FILTER, parameter three can be:
53 GL_NEAREST_MIPMAP_NEAREST
54 GL_LINEAR_MIPMAP_NEAREST
55 GL_NEAREST_MIPMAP_LINEAR
56 GL_LINEAR_MIPMAP_LINEAR
57 GL_NEAREST
58 GL_LINEAR
59
60 When the second parameter is GL_TEXTURE_MAG_FILTER, parameter three can be:
61 GL_LINEAR
62 GL_NEAREST
63
64 The filter value set for GL_TEXTURE_MIN_FILTER is used whenever a surface is
65 rendered with smaller dimensions than its corresponding texture bitmap
66 (far away objects). Whereas the filter value for GL_TEXTURE_MAG_FILTER is used in
67 the exact opposite case when a surface is bigger than the texture being applied (near objects).
68
69 There are more options for the min filter because it can potentially have mipmapping.
70 However, it wouldn't make sense to apply mipmapping to the mag filter since close-up
71 objects don't need it in the first place. Here's a list of all the possible combinations
72 and how they impact what is rendered (first constant in the left-most column is the near
73 object filter [mag]; second constant is the far object filter [min]):
74
75
76 Filter Combination Bilinear Filtering Bilinear Filtering Mipmapping
77 (MAG_FILTER/MIN_FILTER) (Near) (Far)
78 GL_NEAREST / GL_NEAREST_MIPMAP_NEAREST Off Off Standard
79 GL_NEAREST / GL_LINEAR_MIPMAP_NEAREST Off On Standard
80 GL_NEAREST / GL_NEAREST_MIPMAP_LINEAR Off Off Use trilinear filtering
81 GL_NEAREST / GL_LINEAR_MIPMAP_LINEAR Off On Use trilinear filtering
82 GL_NEAREST / GL_NEAREST Off Off None
83 GL_NEAREST / GL_LINEAR Off On None
84 GL_LINEAR / GL_NEAREST_MIPMAP_NEAREST On Off Standard
85 GL_LINEAR / GL_LINEAR_MIPMAP_NEAREST On On Standard
86 GL_LINEAR / GL_NEAREST_MIPMAP_LINEAR On Off Use trilinear filtering
87 GL_LINEAR / GL_LINEAR_MIPMAP_LINEAR On On Use trilinear filtering
88 GL_LINEAR / GL_NEAREST On Off None
89 GL_LINEAR / GL_LINEAR On On None
90*/
91//------------------------------------------------------------------------------
92
93//------------------------------------------------------------------------------
94#ifndef CGenericTextureH
95#define CGenericTextureH
96//------------------------------------------------------------------------------
97#include "graphics/CColor.h"
99#include "system/CGenericType.h"
100//------------------------------------------------------------------------------
101
102//------------------------------------------------------------------------------
103namespace chai3d {
104//------------------------------------------------------------------------------
105
106//==============================================================================
113//==============================================================================
114
115//------------------------------------------------------------------------------
116class cGenericTexture;
117typedef std::shared_ptr<cGenericTexture> cGenericTexturePtr;
118//------------------------------------------------------------------------------
119
120//==============================================================================
131//==============================================================================
133{
134 //--------------------------------------------------------------------------
135 // CONSTRUCTOR & DESTRUCTOR:
136 //--------------------------------------------------------------------------
137
138public:
139
142
144 virtual ~cGenericTexture() {};
145
147 static cGenericTexturePtr create() { return (std::make_shared<cGenericTexture>()); }
148
149
150 //-----------------------------------------------------------------------
151 // PUBLIC METHODS:
152 //--------------------------------------------------------------------------
153
154public:
155
157 virtual std::string getClassName() { return ("GenericTexture"); }
158
160 virtual bool loadFromFile(const std::string& a_fileName) { return (false); }
161
163 virtual bool saveToFile(const std::string& a_fileName) { return (false); }
164
166 virtual void renderInitialize(cRenderOptions& a_options) {}
167
169 virtual void renderFinalize(cRenderOptions& a_options) {}
170
172 virtual void markForUpdate() {}
173
175 virtual void markForDeleteAndUpdate() {}
176
178 void setEnabled(bool a_enabled) { m_enabled = a_enabled; }
179
181 bool getEnabled() const { return(m_enabled); }
182
183
184 //-----------------------------------------------------------------------
185 // PROTECTED MEMBERS:
186 //--------------------------------------------------------------------------
187
188protected:
189
192
194 std::string m_name;
195
197 std::string m_filename;
198};
199
200//------------------------------------------------------------------------------
201} // namespace chai3d
202//------------------------------------------------------------------------------
203
204//------------------------------------------------------------------------------
205#endif
206//------------------------------------------------------------------------------
Implements color properties.
Implements a general abstract type.
Implements a structure to store rendering options.
This class implements a base class for textures.
Definition CGenericTexture.h:133
bool getEnabled() const
This method returns true if the texture map is enabled, false otherwise.
Definition CGenericTexture.h:181
virtual void markForDeleteAndUpdate()
This method marks this texture for GPU deletion and reinitialization.
Definition CGenericTexture.h:175
std::string m_name
Texture name.
Definition CGenericTexture.h:194
virtual void markForUpdate()
This method marks this texture for GPU update.
Definition CGenericTexture.h:172
cGenericTexture()
Constructor of cGenericTexture.
Definition CGenericTexture.h:141
virtual void renderInitialize(cRenderOptions &a_options)
This method enables texturing and set this texture as the current texture.
Definition CGenericTexture.h:166
virtual bool saveToFile(const std::string &a_fileName)
This method saves a texture image file.
Definition CGenericTexture.h:163
std::string m_filename
Texture filename.
Definition CGenericTexture.h:197
void setEnabled(bool a_enabled)
This method enables or disables texture mapping.
Definition CGenericTexture.h:178
virtual ~cGenericTexture()
Destructor of cGenericTexture.
Definition CGenericTexture.h:144
virtual void renderFinalize(cRenderOptions &a_options)
This method disables texturing and should be called after triangles have been rendered.
Definition CGenericTexture.h:169
bool m_enabled
If true, this texture is enabled, false otherwise.
Definition CGenericTexture.h:191
virtual bool loadFromFile(const std::string &a_fileName)
This method loads a texture image file.
Definition CGenericTexture.h:160
static cGenericTexturePtr create()
Shared cGenericTexture allocator.
Definition CGenericTexture.h:147
virtual std::string getClassName()
This method returns the name of the object class.
Definition CGenericTexture.h:157
This class implements an abstract type.
Definition CGenericType.h:76
Definition CAudioBuffer.cpp:57
std::shared_ptr< cGenericTexture > cGenericTexturePtr
Definition CGenericTexture.h:117
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition CRenderOptions.h:83