Nirtcpp 2.1.0
Nirtcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
ITexture.hpp
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 nirtcpp/nirtcpp.hpp
4
5#ifndef NIRT_I_TEXTURE_HPP_INCLUDED
6#define NIRT_I_TEXTURE_HPP_INCLUDED
7
8#include <nirtcpp/core/engine/IReferenceCounted.hpp>
9#include <nirtcpp/core/engine/IImage.hpp>
10#include <nirtcpp/core/engine/dimension2d.hpp>
11#include <nirtcpp/core/engine/EDriverTypes.hpp>
12#include <nirtcpp/core/engine/path.hpp>
13#include <nirtcpp/core/engine/matrix4.hpp>
14
15namespace nirt
16{
17namespace video
18{
19
20
23{
33 ETCF_ALWAYS_16_BIT = 0x00000001,
34
44 ETCF_ALWAYS_32_BIT = 0x00000002,
45
54
62
67
73
75
77
79
85
87
99
101
107
112
128
131{
132 ETLF_NONE = 0,
133
135
152
165
175
177
185class ITexture : public virtual IReferenceCounted
186{
187public:
188
190 ITexture(const io::path& name, E_TEXTURE_TYPE type) : NamedPath(name), DriverType(EDT_NULL), OriginalColorFormat(ECF_UNKNOWN),
191 ColorFormat(ECF_UNKNOWN), Pitch(0), HasMipMaps(false), IsRenderTarget(false), Source(ETS_UNKNOWN), Type(type)
192 {
193 }
194
196
218 virtual void* lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 mipmapLevel=0, u32 layer = 0, E_TEXTURE_LOCK_FLAGS lockFlags = ETLF_FLIP_Y_UP_RTT) = 0;
219
221
224 virtual void unlock() = 0;
225
227
235 virtual void regenerateMipMapLevels(void* data = 0, u32 layer = 0) = 0;
236
238
245 const core::dimension2d<u32>& getOriginalSize() const { return OriginalSize; };
246
248
249 const core::dimension2d<u32>& getSize() const { return Size; };
250
252
256 E_DRIVER_TYPE getDriverType() const { return DriverType; };
257
259
260 ECOLOR_FORMAT getColorFormat() const { return ColorFormat; };
261
263
266 ECOLOR_FORMAT getOriginalColorFormat() const { return OriginalColorFormat; };
267
269
272 u32 getPitch() const { return Pitch; };
273
275
276 bool hasMipMaps() const { return HasMipMaps; }
277
279
283 bool isRenderTarget() const { return IsRenderTarget; }
284
286 const io::SNamedPath& getName() const { return NamedPath; }
287
289 E_TEXTURE_SOURCE getSource() const { return Source; }
290
292 void updateSource(E_TEXTURE_SOURCE source) { Source = source; }
293
295 bool hasAlpha() const
296 {
297 bool status = false;
298
299 switch (ColorFormat)
300 {
301 case ECF_A8R8G8B8:
302 case ECF_A1R5G5B5:
303 case ECF_DXT1:
304 case ECF_DXT2:
305 case ECF_DXT3:
306 case ECF_DXT4:
307 case ECF_DXT5:
310 status = true;
311 break;
312 default:
313 break;
314 }
315
316 return status;
317 }
318
320 E_TEXTURE_TYPE getType() const { return Type; }
321
322protected:
323
325
339
340 io::SNamedPath NamedPath;
341 core::dimension2d<u32> OriginalSize;
343 E_DRIVER_TYPE DriverType;
344 ECOLOR_FORMAT OriginalColorFormat;
345 ECOLOR_FORMAT ColorFormat;
346 u32 Pitch;
347 bool HasMipMaps;
348 bool IsRenderTarget;
349 E_TEXTURE_SOURCE Source;
350 E_TEXTURE_TYPE Type;
351};
352
353
354} // end namespace video
355} // end namespace nirt
356
357#endif
Base class of most objects of the Nirtcpp Engine.
Definition IReferenceCounted.hpp:46
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
Used in places where we identify objects by a filename, but don't actually work with the real filenam...
Definition path.hpp:24
Interface of a Video Driver dependent Texture.
Definition ITexture.hpp:186
const io::SNamedPath & getName() const
Get name of texture (in most cases this is the filename)
Definition ITexture.hpp:286
virtual void * lock(E_TEXTURE_LOCK_MODE mode=ETLM_READ_WRITE, u32 mipmapLevel=0, u32 layer=0, E_TEXTURE_LOCK_FLAGS lockFlags=ETLF_FLIP_Y_UP_RTT)=0
Lock function.
ITexture(const io::path &name, E_TEXTURE_TYPE type)
constructor
Definition ITexture.hpp:190
E_DRIVER_TYPE getDriverType() const
Get driver type of texture.
Definition ITexture.hpp:256
bool isRenderTarget() const
Check whether the texture is a render target.
Definition ITexture.hpp:283
void updateSource(E_TEXTURE_SOURCE source)
Used internally by the engine to update Source status on IVideoDriver::getTexture calls.
Definition ITexture.hpp:292
virtual void regenerateMipMapLevels(void *data=0, u32 layer=0)=0
Regenerates the mip map levels of the texture.
bool hasMipMaps() const
Check whether the texture has MipMaps.
Definition ITexture.hpp:276
ECOLOR_FORMAT getColorFormat() const
Get the color format of texture.
Definition ITexture.hpp:260
virtual void unlock()=0
Unlock function. Must be called after a lock() to the texture.
const core::dimension2d< u32 > & getOriginalSize() const
Get original size of the texture.
Definition ITexture.hpp:245
E_TEXTURE_SOURCE getSource() const
Check where the last IVideoDriver::getTexture found this texture.
Definition ITexture.hpp:289
bool hasAlpha() const
Returns if the texture has an alpha channel.
Definition ITexture.hpp:295
E_TEXTURE_CREATION_FLAG getTextureFormatFromFlags(u32 flags)
Helper function, helps to get the desired texture creation format from the flags.
Definition ITexture.hpp:327
ECOLOR_FORMAT getOriginalColorFormat() const
Get the original color format.
Definition ITexture.hpp:266
const core::dimension2d< u32 > & getSize() const
Get dimension (=size) of the texture.
Definition ITexture.hpp:249
E_TEXTURE_TYPE getType() const
Returns the type of texture.
Definition ITexture.hpp:320
u32 getPitch() const
Get pitch of the main texture (in bytes).
Definition ITexture.hpp:272
E_TEXTURE_SOURCE
Where did the last IVideoDriver::getTexture call find this texture.
Definition ITexture.hpp:155
@ ETS_FROM_CACHE
Texture has been found in cache.
Definition ITexture.hpp:160
@ ETS_UNKNOWN
IVideoDriver::getTexture was never called (texture created otherwise)
Definition ITexture.hpp:157
@ ETS_FROM_FILE
Texture had to be loaded.
Definition ITexture.hpp:163
E_TEXTURE_LOCK_FLAGS
Additional bitflags for ITexture::lock() call.
Definition ITexture.hpp:131
@ ETLF_FLIP_Y_UP_RTT
Flip left-bottom origin rendertarget textures upside-down.
Definition ITexture.hpp:150
E_TEXTURE_LOCK_MODE
Enum for the mode for texture locking. Read-Only, write-only or read/write.
Definition ITexture.hpp:115
@ ETLM_READ_ONLY
Read only. The texture is downloaded, but not uploaded again.
Definition ITexture.hpp:121
@ ETLM_READ_WRITE
The default mode. Texture can be read and written to.
Definition ITexture.hpp:117
@ ETLM_WRITE_ONLY
Write only. The texture is not downloaded and might be uninitialized.
Definition ITexture.hpp:126
ECOLOR_FORMAT
An enum for the color format of textures used by the Nirtcpp Engine.
Definition SColor.hpp:21
@ ECF_A16B16G16R16F
64 bit format using 16 bits for the red, green, blue and alpha channels.
Definition SColor.hpp:95
@ ECF_A32B32G32R32F
128 bit format using 32 bits for the red, green, blue and alpha channels.
Definition SColor.hpp:104
@ ECF_DXT5
DXT5 color format.
Definition SColor.hpp:55
@ ECF_UNKNOWN
Unknown color format:
Definition SColor.hpp:132
@ ECF_A8R8G8B8
Definition SColor.hpp:38
@ ECF_DXT1
DXT1 color format.
Definition SColor.hpp:43
@ ECF_A1R5G5B5
16 bit color format used by the software driver.
Definition SColor.hpp:26
@ ECF_DXT4
DXT4 color format.
Definition SColor.hpp:52
@ ECF_DXT3
DXT3 color format.
Definition SColor.hpp:49
@ ECF_DXT2
DXT2 color format.
Definition SColor.hpp:46
E_DRIVER_TYPE
An enum for all types of drivers the Nirtcpp Engine supports.
Definition EDriverTypes.hpp:17
@ EDT_NULL
Null driver, useful for applications to run the engine without visualization.
Definition EDriverTypes.hpp:21
E_TEXTURE_TYPE
Enumeration describing the type of ITexture.
Definition ITexture.hpp:168
@ ETT_2D
2D texture.
Definition ITexture.hpp:170
@ ETT_CUBEMAP
Cubemap texture.
Definition ITexture.hpp:173
E_TEXTURE_CREATION_FLAG
Enumeration flags used to tell the video driver with setTextureCreationFlag in which format textures ...
Definition ITexture.hpp:23
@ ETCF_FORCE_32_BIT_DO_NOT_USE
Definition ITexture.hpp:110
@ ETCF_ALLOW_NON_POWER_2
Allow the Driver to use Non-Power-2-Textures.
Definition ITexture.hpp:76
@ ETCF_NO_ALPHA_CHANNEL
Definition ITexture.hpp:72
@ ETCF_ALLOW_MEMORY_COPY
Allow the driver to keep a copy of the texture in memory.
Definition ITexture.hpp:84
@ ETCF_OPTIMIZED_FOR_QUALITY
Definition ITexture.hpp:53
@ ETCF_AUTO_GENERATE_MIP_MAPS
Enable automatic updating mip maps when the base texture changes.
Definition ITexture.hpp:98
@ ETCF_ALWAYS_32_BIT
Definition ITexture.hpp:44
@ ETCF_CREATE_MIP_MAPS
Definition ITexture.hpp:66
@ ETCF_ALWAYS_16_BIT
Definition ITexture.hpp:33
@ ETCF_SUPPORT_VERTEXT_TEXTURE
Enable support for vertex shader texture sampling on some drivers.
Definition ITexture.hpp:106
@ ETCF_OPTIMIZED_FOR_SPEED
Definition ITexture.hpp:61
As of Nirtcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.hpp:64

Nirtcpp    @cppfx.xyz

Utxcpp    utx::print