Ocular Engine
Ocular::Graphics::Texture2D Class Reference
Inheritance diagram for Ocular::Graphics::Texture2D:
Ocular::Graphics::Texture Ocular::Core::Resource Ocular::Graphics::D3D11Texture2D Ocular::Graphics::DepthTexture Ocular::Graphics::NoiseTexture2D Ocular::Graphics::RenderTexture Ocular::Graphics::D3D11DepthTexture Ocular::Graphics::D3D11RenderTexture

Public Member Functions

 Texture2D (TextureDescriptor const &descriptor)
 
virtual void unload ()
 
virtual void apply ()
 
virtual void refresh ()
 
Core::Color getPixel (uint32_t x, uint32_t y) const
 
bool setPixel (uint32_t x, uint32_t y, Core::Color const &color)
 
bool getPixels (std::vector< Core::Color > &pixels, uint32_t startX=0, uint32_t startY=0, uint32_t width=0, uint32_t height=0) const
 
bool setPixels (std::vector< Core::Color > const &pixels, uint32_t startX=0, uint32_t startY=0, uint32_t width=0, uint32_t height=0)
 
unsigned getWidth () const
 
void setWidth (uint32_t const &width)
 
unsigned getHeight () const
 
void setHeight (uint32_t const &height)
 
- Public Member Functions inherited from Ocular::Graphics::Texture
 Texture (TextureDescriptor const &descriptor)
 
TextureDescriptor getDescriptor () const
 
- Public Member Functions inherited from Ocular::Core::Resource
 Resource (File const &source)
 
virtual void forceLoad ()
 
File getSourceFile () const
 
void setSourceFile (File const &file)
 
void setIsInMemory (bool inMemory)
 
bool isInMemory () const
 
void setSize (uint64_t size)
 
uint64_t getSize () const
 
ResourceType getResourceType () const
 
void setName (std::string const &name)
 
std::string const & getName () const
 
std::string const & getMappingName () const
 
void setMappingName (std::string const &name)
 
ResourceMetadatagetMetadata () const
 
void setMetadata (ResourceMetadata *metadata)
 

Protected Member Functions

void getTrueDimensions (uint32_t startX, uint32_t startY, uint32_t &trueWidth, uint32_t &trueHeight) const
 

Protected Attributes

std::vector< Core::Colorm_Pixels
 
- Protected Attributes inherited from Ocular::Graphics::Texture
TextureDescriptor m_Descriptor
 
- Protected Attributes inherited from Ocular::Core::Resource
ResourceType m_Type
 
ResourceMetadatam_Metadata
 
File m_SourceFile
 
bool m_IsInMemory
 
uint64_t m_SizeInMemory
 
std::string m_Name
 
std::string m_MappingName
 

Constructor & Destructor Documentation

Ocular::Graphics::Texture2D::Texture2D ( TextureDescriptor const &  descriptor)
Parameters
[in]descriptor

Member Function Documentation

void Ocular::Graphics::Texture2D::apply ( )
virtual

Applies any manually made pixel changes of the texture to the GPU. Textures will not be updated (i.e. changes rendered) until this method is called.

Note
Texture CPU access must be set to TextureAccess::WriteOnly or TextureAccess::ReadWrite in order to modify a texture at runtime.

Implements Ocular::Graphics::Texture.

Reimplemented in Ocular::Graphics::D3D11RenderTexture, Ocular::Graphics::D3D11DepthTexture, Ocular::Graphics::DepthTexture, Ocular::Graphics::RenderTexture, and Ocular::Graphics::D3D11Texture2D.

uint32_t Ocular::Graphics::Texture2D::getHeight ( ) const
Returns
Height of the texture
Core::Color Ocular::Graphics::Texture2D::getPixel ( uint32_t  x,
uint32_t  y 
) const

Retrieves the specified pixel in the texture.

The pixel at (0,0) represents the bottom-left corner of the texture.

Parameters
[in]x
[in]y
Returns
Color of the pixel located at (x,y) in the texture.
bool Ocular::Graphics::Texture2D::getPixels ( std::vector< Core::Color > &  pixels,
uint32_t  startX = 0,
uint32_t  startY = 0,
uint32_t  width = 0,
uint32_t  height = 0 
) const

Retrieves the pixels in the specified bounds of the texture.

The pixel at (0,0) represents the bottom-left corner of the texture.

The pixels are returned in a vector that stores them in row order. So, for example, if a 3x3 square of pixels was requested starting from the origin, then the return would be:

Color(0,0), Color(1,0), Color(2,0), Color(0,1), Color(1,1), Color(2,1), Color(0,2), Color(1,2), Color(2,2)
Parameters
[out]pixels
[in]startX
[in]startY
[in]widthIf set to 0, retrieves pixels from startX to end of texture.
[in]heightIf set to 0, retrieves pixels from startY to end of texture.
uint32_t Ocular::Graphics::Texture2D::getWidth ( ) const
Returns
Width of the texture
void Ocular::Graphics::Texture2D::refresh ( )
virtual

Refreshes the CPU texture data with any data stored on the GPU. This action can overwrite pre-existing CPU data.

Note
Texture CPU access must be set to TextureAccess::ReadOnly or TextureAccess::ReadWrite in order to refresh the CPU data at runtime.

Implements Ocular::Graphics::Texture.

Reimplemented in Ocular::Graphics::D3D11RenderTexture, Ocular::Graphics::D3D11DepthTexture, Ocular::Graphics::DepthTexture, Ocular::Graphics::RenderTexture, and Ocular::Graphics::D3D11Texture2D.

void Ocular::Graphics::Texture2D::setHeight ( uint32_t const &  height)
Parameters
[in]height
Note
apply must be called after any dimension changes in order for the texture on GPU to be updated.
bool Ocular::Graphics::Texture2D::setPixel ( uint32_t  x,
uint32_t  y,
Core::Color const &  color 
)

Sets the specified pixel in the texture.

The pixel at (0,0) represents the bottom-left corner of the texture.

Parameters
[in]x
[in]y
[in]color
Note
apply must be called after any pixel setting in order for the texture on GPU to be updated.
bool Ocular::Graphics::Texture2D::setPixels ( std::vector< Core::Color > const &  pixels,
uint32_t  startX = 0,
uint32_t  startY = 0,
uint32_t  width = 0,
uint32_t  height = 0 
)

Sets the pixels in the specified bounds of the texture.

The pixel at (0,0) represents the bottom-left corner of the texture.

The provided pixel vector is expected to be in row order. So, for example, if a 3x3 square of pixels was set starting from the origin (bottom-left corner), then the pixels would be:

Color(0,0), Color(1,0), Color(2,0), Color(0,1), Color(1,1), Color(2,1), Color(0,2), Color(1,2), Color(2,2)
Parameters
[out]pixels
[in]startX
[in]startY
[in]widthIf set to 0, sets pixels from startX to end of texture.
[in]heightIf set to 0, sets pixels from startY to end of texture.
Note
apply must be called after any pixel setting in order for the texture on GPU to be updated.
void Ocular::Graphics::Texture2D::setWidth ( uint32_t const &  width)
Parameters
[in]width
Note
apply must be called after any dimension changes in order for the texture on GPU to be updated.
void Ocular::Graphics::Texture2D::unload ( )
virtual

Unloads all CPU data related to this texture.

If this is an instance of an API-specific texture implementation (such as D3D11Texture2D), then all GPU-related data will also be freed and all API-specific structures released.

Implements Ocular::Graphics::Texture.

Reimplemented in Ocular::Graphics::D3D11RenderTexture, Ocular::Graphics::D3D11DepthTexture, Ocular::Graphics::DepthTexture, Ocular::Graphics::RenderTexture, and Ocular::Graphics::D3D11Texture2D.


The documentation for this class was generated from the following files: