Saga3D API Documentation  1.0-RC4
ITexture.h
Go to the documentation of this file.
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 __I_TEXTURE_H_INCLUDED__
6 #define __I_TEXTURE_H_INCLUDED__
7 
8 #include "EDriverTypes.h"
9 #include <string>
10 
11 namespace saga
12 {
13 namespace video
14 {
15 
17 
25 class ITexture
26 {
27 public:
28 
30  ITexture(const std::string& name, E_TEXTURE_TYPE type)
31  : NamedPath(name), DriverType(E_DRIVER_TYPE::NULL_DRIVER),
34  HasMipMaps(false), IsRenderTarget(false),
35  Source(E_TEXTURE_SOURCE::UNKNOWN), Type(type)
36  {
37  }
38 
40 
58  virtual void* lock(E_TEXTURE_LOCK_MODE mode = E_TEXTURE_LOCK_MODE::READ_WRITE, std::uint32_t layer = 0) = 0;
59 
61 
63  virtual void unlock() = 0;
64 
66 
74  virtual void regenerateMipMapLevels(void* data = 0, std::uint32_t layer = 0) = 0;
75 
77 
84  const glm::uvec2& getOriginalSize() const { return OriginalSize; };
85 
87 
88  const glm::uvec2& getSize() const { return Size; };
89 
91 
95  E_DRIVER_TYPE getDriverType() const { return DriverType; };
96 
98 
100 
102 
105  std::uint32_t getPitch() const { return Pitch; };
106 
108 
109  bool hasMipMaps() const { return HasMipMaps; }
110 
112 
116  bool isRenderTarget() const { return IsRenderTarget; }
117 
119  const std::string& getName() const { return NamedPath; }
120 
122  E_TEXTURE_SOURCE getSource() const { return Source; }
123 
125  void updateSource(E_TEXTURE_SOURCE source) { Source = source; }
126 
128  bool hasAlpha() const
129  {
130  bool status = false;
131 
132  switch (ColorFormat)
133  {
136  case E_PIXEL_FORMAT::DXT2:
138  case E_PIXEL_FORMAT::DXT4:
140  case E_PIXEL_FORMAT::A16B16G16R16F:
141  case E_PIXEL_FORMAT::A32B32G32R32F:
142  status = true;
143  break;
144  default:
145  break;
146  }
147 
148  return status;
149  }
150 
152  E_TEXTURE_TYPE getType() const { return Type; }
153 
154 protected:
155  std::string NamedPath;
156  glm::uvec2 OriginalSize;
157  glm::uvec2 Size;
161  std::uint32_t Pitch;
164  E_TEXTURE_SOURCE Source;
166 };
167 
168 
169 } // namespace video
170 } // namespace saga
171 
172 #endif
173 
saga::video::ITexture::isRenderTarget
bool isRenderTarget() const
Check whether the texture is a render target.
Definition: ITexture.h:116
saga::video::E_DRIVER_TYPE
E_DRIVER_TYPE
An enum class for all types of drivers Saga3D supports.
Definition: EDriverTypes.h:9
saga::video::E_TEXTURE_TYPE
E_TEXTURE_TYPE
Enumeration for all primitive types there are.
Definition: ETextureTypes.h:10
saga::video::ITexture::ITexture
ITexture(const std::string &name, E_TEXTURE_TYPE type)
constructor
Definition: ITexture.h:30
saga::video::ITexture::Type
E_TEXTURE_TYPE Type
Definition: ITexture.h:165
saga::video::ITexture::NamedPath
std::string NamedPath
Definition: ITexture.h:155
saga::video::ITexture::getDriverType
E_DRIVER_TYPE getDriverType() const
Get driver type of texture.
Definition: ITexture.h:95
saga::video::E_PIXEL_FORMAT::DXT3
@ DXT3
saga::video::E_PIXEL_FORMAT::DXT1
@ DXT1
saga::video::ITexture::OriginalColorFormat
E_PIXEL_FORMAT OriginalColorFormat
Definition: ITexture.h:159
saga::video::ITexture::Source
E_TEXTURE_SOURCE Source
Definition: ITexture.h:164
saga::video::ITexture::hasMipMaps
bool hasMipMaps() const
Check whether the texture has MipMaps.
Definition: ITexture.h:109
saga::video::ITexture::getOriginalSize
const glm::uvec2 & getOriginalSize() const
Get original size of the texture.
Definition: ITexture.h:84
saga::video::ITexture::getColorFormat
E_PIXEL_FORMAT getColorFormat() const
Get the color format of texture.
Definition: ITexture.h:99
saga::video::ITexture::HasMipMaps
bool HasMipMaps
Definition: ITexture.h:162
saga::video::ITexture::IsRenderTarget
bool IsRenderTarget
Definition: ITexture.h:163
saga::video::ITexture::unlock
virtual void unlock()=0
Unlock function. Must be called after a lock() to the texture.
saga::video::E_PIXEL_FORMAT::RGBA8
@ RGBA8
Vulkan swapchain format.
saga::video::ITexture::lock
virtual void * lock(E_TEXTURE_LOCK_MODE mode=E_TEXTURE_LOCK_MODE::READ_WRITE, std::uint32_t layer=0)=0
Lock function.
saga::video::ITexture::updateSource
void updateSource(E_TEXTURE_SOURCE source)
Used internally by the engine to update Source status on IVideoDriver::getTexture calls.
Definition: ITexture.h:125
saga::video::ITexture::Size
glm::uvec2 Size
Definition: ITexture.h:157
saga::video::ITexture::OriginalSize
glm::uvec2 OriginalSize
Definition: ITexture.h:156
saga::video::E_PIXEL_FORMAT::DXT5
@ DXT5
saga::video::ITexture::getSource
E_TEXTURE_SOURCE getSource() const
Check where the last IVideoDriver::getTexture found this texture.
Definition: ITexture.h:122
saga::video::ITexture::Pitch
std::uint32_t Pitch
Definition: ITexture.h:161
saga::video::ITexture
Interface of a Video Driver dependent Texture.
Definition: ITexture.h:25
saga::video::ITexture::ColorFormat
E_PIXEL_FORMAT ColorFormat
Definition: ITexture.h:160
saga::video::ITexture::DriverType
E_DRIVER_TYPE DriverType
Definition: ITexture.h:158
saga::video::ITexture::getName
const std::string & getName() const
Get name of texture (in most cases this is the filename)
Definition: ITexture.h:119
saga::video::ITexture::regenerateMipMapLevels
virtual void regenerateMipMapLevels(void *data=0, std::uint32_t layer=0)=0
Regenerates the mip map levels of the texture.
saga::video::ITexture::getType
E_TEXTURE_TYPE getType() const
Returns the type of texture.
Definition: ITexture.h:152
saga::video::E_PIXEL_FORMAT
E_PIXEL_FORMAT
Enumeration for all primitive types there are.
Definition: EPixelFormat.h:10
saga::video::ITexture::hasAlpha
bool hasAlpha() const
Returns if the texture has an alpha channel.
Definition: ITexture.h:128
saga::video::E_PIXEL_FORMAT::UNKNOWN
@ UNKNOWN
saga::video::ITexture::getSize
const glm::uvec2 & getSize() const
Get dimension (=size) of the texture.
Definition: ITexture.h:88
saga::video::ITexture::getPitch
std::uint32_t getPitch() const
Get pitch of the main texture (in bytes).
Definition: ITexture.h:105
saga
Definition: aabbox3d.h:11
EDriverTypes.h