Skylicht Engine
Loading...
Searching...
No Matches
SMaterialLayer.h
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#ifndef __S_MATERIAL_LAYER_H_INCLUDED__
6#define __S_MATERIAL_LAYER_H_INCLUDED__
7
8#include "matrix4.h"
9#include "irrAllocator.h"
10
11namespace irr
12{
13namespace video
14{
15 class ITexture;
16
37 static const char* const aTextureClampNames[] = {
38 "texture_clamp_repeat",
39 "texture_clamp_clamp",
40 "texture_clamp_clamp_to_edge",
41 "texture_clamp_clamp_to_border",
42 "texture_clamp_mirror",
43 "texture_clamp_mirror_clamp",
44 "texture_clamp_mirror_clamp_to_edge",
45 "texture_clamp_mirror_clamp_to_border", 0};
46
49 {
50 public:
53 : Texture(0),
55 TextureWrapV(ETC_REPEAT),
56 BilinearFilter(true),
57 TrilinearFilter(false),
59 LODBias(0),
60 TextureMatrix(0)
61 {}
62
64
66 {
67 // This pointer is checked during assignment
68 TextureMatrix = 0;
69 *this = other;
70 }
71
74 {
75 MatrixAllocator.destruct(TextureMatrix);
76 MatrixAllocator.deallocate(TextureMatrix);
77 }
78
80
83 {
84 // Check for self-assignment!
85 if (this == &other)
86 return *this;
87
88 Texture = other.Texture;
89 if (TextureMatrix)
90 {
91 if (other.TextureMatrix)
92 *TextureMatrix = *other.TextureMatrix;
93 else
94 {
95 MatrixAllocator.destruct(TextureMatrix);
96 MatrixAllocator.deallocate(TextureMatrix);
97 TextureMatrix = 0;
98 }
99 }
100 else
101 {
102 if (other.TextureMatrix)
103 {
104 TextureMatrix = MatrixAllocator.allocate(1);
105 MatrixAllocator.construct(TextureMatrix,*other.TextureMatrix);
106 }
107 else
108 TextureMatrix = 0;
109 }
111 TextureWrapV = other.TextureWrapV;
115 LODBias = other.LODBias;
116 BorderColor = other.BorderColor;
117
118 return *this;
119 }
120
122
124 {
125 if (!TextureMatrix)
126 {
127 TextureMatrix = MatrixAllocator.allocate(1);
128 MatrixAllocator.construct(TextureMatrix,core::IdentityMatrix);
129 }
130 return *TextureMatrix;
131 }
132
134
136 {
137 if (TextureMatrix)
138 return *TextureMatrix;
139 else
141 }
142
144
146 {
147 if (!TextureMatrix)
148 {
149 TextureMatrix = MatrixAllocator.allocate(1);
150 MatrixAllocator.construct(TextureMatrix,mat);
151 }
152 else
153 *TextureMatrix = mat;
154 }
155
157
159 inline bool operator!=(const SMaterialLayer& b) const
160 {
161 bool different =
162 Texture != b.Texture ||
164 TextureWrapV != b.TextureWrapV ||
168 LODBias != b.LODBias;
169 if (different)
170 return true;
171 else
172 different |= (TextureMatrix != b.TextureMatrix) &&
173 TextureMatrix && b.TextureMatrix &&
174 (*TextureMatrix != *(b.TextureMatrix));
175 return different;
176 }
177
179
181 inline bool operator==(const SMaterialLayer& b) const
182 { return !(b!=*this); }
183
186
188
190 u8 TextureWrapV:4;
191
194
196
199
201
208
210
215
216 SColorf BorderColor;
217
218 private:
219 friend class SMaterial;
221
223
225 core::matrix4* TextureMatrix;
226 };
227
228} // end namespace video
229} // end namespace irr
230
231#endif // __S_MATERIAL_LAYER_H_INCLUDED__
Very simple allocator implementation, containers using it can be used across dll boundaries.
Definition irrAllocator.h:26
Interface of a Video Driver dependent Texture.
Definition ITexture.h:119
Class representing a color with four floats.
Definition SColor.h:542
bool operator==(const SMaterialLayer &b) const
Equality operator.
Definition SMaterialLayer.h:181
void setTextureMatrix(const core::matrix4 &mat)
Sets the texture transformation matrix to mat.
Definition SMaterialLayer.h:145
bool operator!=(const SMaterialLayer &b) const
Inequality operator.
Definition SMaterialLayer.h:159
~SMaterialLayer()
Destructor.
Definition SMaterialLayer.h:73
s8 LODBias
Bias for the mipmap choosing decision.
Definition SMaterialLayer.h:214
const core::matrix4 & getTextureMatrix() const
Gets the immutable texture transformation matrix.
Definition SMaterialLayer.h:135
SMaterialLayer & operator=(const SMaterialLayer &other)
Assignment operator.
Definition SMaterialLayer.h:82
bool BilinearFilter
Is bilinear filtering enabled? Default: true.
Definition SMaterialLayer.h:193
SMaterialLayer()
Default constructor.
Definition SMaterialLayer.h:52
core::matrix4 & getTextureMatrix()
Gets the texture transformation matrix.
Definition SMaterialLayer.h:123
bool TrilinearFilter
Is trilinear filtering enabled? Default: false.
Definition SMaterialLayer.h:198
u8 AnisotropicFilter
Is anisotropic filtering enabled? Default: 0, disabled.
Definition SMaterialLayer.h:207
ITexture * Texture
Texture.
Definition SMaterialLayer.h:185
u8 TextureWrapU
Texture Clamp Mode.
Definition SMaterialLayer.h:189
SMaterialLayer(const SMaterialLayer &other)
Copy constructor.
Definition SMaterialLayer.h:65
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition matrix4.h:2241
IRRLICHT_API const matrix4 IdentityMatrix
global const identity matrix
The video namespace contains classes for accessing the video driver. All 2d and 3d rendering is done ...
Definition EDriverFeatures.h:11
E_TEXTURE_CLAMP
Texture coord clamp mode outside [0.0, 1.0].
Definition SMaterialLayer.h:19
@ ETC_REPEAT
Texture repeats.
Definition SMaterialLayer.h:21
@ ETC_CLAMP
Texture is clamped to the last pixel.
Definition SMaterialLayer.h:23
@ ETC_CLAMP_TO_BORDER
Texture is clamped to the border pixel (if exists).
Definition SMaterialLayer.h:27
@ ETC_MIRROR_CLAMP_TO_BORDER
Texture is mirrored once and then clamped to border.
Definition SMaterialLayer.h:35
@ ETC_MIRROR
Texture is alternatingly mirrored (0..1..0..1..0..).
Definition SMaterialLayer.h:29
@ ETC_MIRROR_CLAMP_TO_EDGE
Texture is mirrored once and then clamped to edge.
Definition SMaterialLayer.h:33
@ ETC_MIRROR_CLAMP
Texture is mirrored once and then clamped (0..1..0).
Definition SMaterialLayer.h:31
@ ETC_CLAMP_TO_EDGE
Texture is clamped to the edge pixel.
Definition SMaterialLayer.h:25
Everything in the Irrlicht Engine can be found in this namespace.
Definition Skylicht.h:33
unsigned char u8
8 bit unsigned variable.
Definition irrTypes.h:18
signed char s8
8 bit signed variable.
Definition irrTypes.h:26