Beatmup
Beatmup::NNets::Storage::TextureHandler Class Reference

TextureHandler representation of a pack of 4 channels from a non-empty View. More...

#include <storage.h>

Inheritance diagram for Beatmup::NNets::Storage::TextureHandler:
Beatmup::GL::TextureHandler Beatmup::Object

Public Member Functions

 TextureHandler (const View &, int channel)
 
 ~TextureHandler ()
 
const int getWidth () const
 Width of the texture in pixels. More...
 
const int getHeight () const
 Height of the texture in pixels. More...
 
const int getDepth () const
 Depth of the texture in pixels. More...
 
const GL::TextureHandler::TextureFormat getTextureFormat () const
 Returns the texture format specifying how the shader must interpret the data. More...
 
- Public Member Functions inherited from Beatmup::GL::TextureHandler
 ~TextureHandler ()
 
float getAspectRatio () const
 Aspect ratio of the texture. More...
 
float getInvAspectRatio () const
 Inverse of the aspect ratio of the texture. More...
 
const bool isFloatingPoint () const
 
const int getNumberOfChannels () const
 Returns number of channels containing in the texture. More...
 
bool hasValidHandle () const
 Returns true if the texture handle points to a valid texture. More...
 
- Public Member Functions inherited from Beatmup::Object
virtual ~Object ()
 

Private Member Functions

void prepare (GraphicPipeline &gpu)
 Prepares (eventually uploads) texture data on GPU. More...
 

Private Attributes

const int width
 
const int height
 

Additional Inherited Members

- Public Types inherited from Beatmup::GL::TextureHandler
enum  TextureFormat {
  Rx8 , RGBx8 , RGBAx8 , Rx32f ,
  RGBx32f , RGBAx32f , OES_Ext
}
 Texture format, specifies how the texture should be interpreted on the shader side. More...
 
- Static Public Member Functions inherited from Beatmup::GL::TextureHandler
static const char * textureFormatToString (const TextureFormat &)
 
- Static Public Attributes inherited from Beatmup::GL::TextureHandler
static const int TEXTURE_FORMAT_BYTES_PER_PIXEL []
 size of a texel in bytes for different texture formats More...
 
- Protected Member Functions inherited from Beatmup::GL::TextureHandler
 TextureHandler ()
 
void invalidate (RecycleBin &)
 Forces disposing the texture data, e.g. More...
 
- Protected Attributes inherited from Beatmup::GL::TextureHandler
handle_t textureHandle
 

Detailed Description

TextureHandler representation of a pack of 4 channels from a non-empty View.

Does not copy any data, only stores a reference to an existing texture.

Definition at line 403 of file storage.h.

Constructor & Destructor Documentation

◆ TextureHandler()

Storage::TextureHandler::TextureHandler ( const View view,
int  channel 
)

Definition at line 519 of file storage.cpp.

519  :
520  width(view.getStorage().getTextureWidth()), height(view.getStorage().getTextureHeight())
521 {
522 #ifdef BEATMUP_DEBUG
524  OutOfRange::check(channel, 0, view.getDepth() - 1, "Channel index out of range: %d");
525 #endif
526  const int storageChannel = view.channels[ channel/4 ].channelIdx;
527  const int storageTexture = view.storage->getChannelTextureNumber(storageChannel);
528  GL::TextureHandler::textureHandle = view.storage->textures[storageTexture].handle;
529 }
static void checkChannelNumber(int channel)
Checks whether a channel number points to the first channel in a texture.
Definition: storage.h:290
static void check(const datatype value, const datatype min, const datatype max, const char *message)
Definition: exception.h:86

◆ ~TextureHandler()

Storage::TextureHandler::~TextureHandler ( )

Definition at line 532 of file storage.cpp.

532  {
534  // dropping the texture handle; the texture is not owned and is managed by the Storage
535 }

Member Function Documentation

◆ prepare()

void Storage::TextureHandler::prepare ( GraphicPipeline gpu)
privatevirtual

Prepares (eventually uploads) texture data on GPU.

Called only by the context managing thread.

Parameters
[in]gpuGraphic pipeline instance

Reimplemented from Beatmup::GL::TextureHandler.

Definition at line 538 of file storage.cpp.

538  {
539  glBindTexture(GL_TEXTURE_2D, GL::TextureHandler::textureHandle);
540 }

◆ getWidth()

const int Beatmup::NNets::Storage::TextureHandler::getWidth ( ) const
inlinevirtual

Width of the texture in pixels.

Implements Beatmup::GL::TextureHandler.

Definition at line 410 of file storage.h.

410 { return width; }

◆ getHeight()

const int Beatmup::NNets::Storage::TextureHandler::getHeight ( ) const
inlinevirtual

Height of the texture in pixels.

Implements Beatmup::GL::TextureHandler.

Definition at line 411 of file storage.h.

411 { return height; }

◆ getDepth()

const int Beatmup::NNets::Storage::TextureHandler::getDepth ( ) const
inlinevirtual

Depth of the texture in pixels.

Implements Beatmup::GL::TextureHandler.

Definition at line 412 of file storage.h.

412 { return 1; }

◆ getTextureFormat()

const GL::TextureHandler::TextureFormat Beatmup::NNets::Storage::TextureHandler::getTextureFormat ( ) const
inlinevirtual

Returns the texture format specifying how the shader must interpret the data.

Implements Beatmup::GL::TextureHandler.

Definition at line 413 of file storage.h.

413 { return GL::TextureHandler::TextureFormat::RGBAx8; }

Member Data Documentation

◆ width

const int Beatmup::NNets::Storage::TextureHandler::width
private

Definition at line 405 of file storage.h.

◆ height

const int Beatmup::NNets::Storage::TextureHandler::height
private

Definition at line 405 of file storage.h.


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