NAP
Image Class Reference

#include <image.h>

Public Member Functions

BitmapgetBitmap ()
 
void update ()
 
BitmapgetData ()
 
void startGetData ()
 
BitmapendGetData ()
 
void update (const Bitmap &bitmap)
 
void update (const void *data, int pitch=0)
 
void getData (Bitmap &bitmap)
 
void endGetData (Bitmap &bitmap)
 
- Public Member Functions inherited from Texture2D
void initTexture (const opengl::Texture2DSettings &settings)
 
bool initFromBitmap (const Bitmap &bitmap, bool compressed, utility::ErrorState &errorState)
 
const nap::TextureParametersgeParameters () const
 
const glm::vec2 getSize () const
 
int getWidth () const
 
int getHeight () const
 
void update (const Bitmap &bitmap)
 
void update (const void *data, int pitch=0)
 
void getData (Bitmap &bitmap)
 
nap::uint getHandle () const
 
void startGetData ()
 
void endGetData (Bitmap &bitmap)
 
void bind ()
 
void unbind ()
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual bool init (utility::ErrorState &errorState)
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 
- Public Attributes inherited from Texture2D
nap::TextureParameters mParameters
 Property: 'Parameters' GPU parameters associated with this texture. More...
 
opengl::ETextureUsage mUsage = opengl::ETextureUsage::Static
 Property: 'Usage' How this texture is used, ie: updated on the GPU. More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 
- Protected Member Functions inherited from Texture2D
opengl::Texture2DgetTexture ()
 
const opengl::Texture2DgetTexture () const
 

Detailed Description

Represents both CPU and GPU data for a texture. The CPU data is stored internally as a bitmap and is optional GPU textures can be read back to CPU using the getData functions. This will fill the internal bitmap with the data read-back from the GPU. A texture can be modified in two ways:

  • By modifying the internal bitmap (retrieved through getBitmap()) and calling update(). This is the most common way of updating the texture. When updating the texture in this way, the formats & size of the CPU and GPU textures are guaranteed to match.
  • By calling update directly with a custom data buffer. This is useful if you already have data available and don't want the extra overhead of copying to the internal bitmap first. When updating the texture in this way, you are responsible for making sure that the data buffer you pass in matches the format & size of the GPU texture.
Inheritance diagram for Image:
[legend]
Collaboration diagram for Image:
[legend]

Member Function Documentation

◆ endGetData() [1/2]

void endGetData

Finishes a transfer of texture data from GPU to CPU that was started with startGetData. See comment in startGetData for proper use. When the internal bitmap is empty it will be initialized based on the settings associated with this texture. This call asserts if the bitmap can't be initialized or, when initialized, the bitmap settings don't match.

Returns
reference to the internal bitmap that is filled with the GPU data of this texture.

◆ endGetData() [2/2]

Bitmap& endGetData ( )

Finishes a transfer of texture data from GPU to CPU that was started with startGetData. See comment in startGetData for proper use. When the internal bitmap is empty it will be initialized based on the settings associated with this texture. This call asserts if the bitmap can't be initialized or, when initialized, the bitmap settings don't match.

Returns
reference to the internal bitmap that is filled with the GPU data of this texture.

◆ getBitmap()

Bitmap& getBitmap ( )
Returns
CPU data for this texture in the form of a Bitmap. The Bitmap can be empty if this is a GPU-only texture.

◆ getData() [1/2]

void getData

Blocking call to retrieve GPU texture data that is stored in this texture When the internal bitmap is empty it will be initialized based on the settings associated with this texture This call asserts if the bitmap can't be initialized or, when initialized, the bitmap settings don't match.

Returns
reference to the internal bitmap that is filled with the GPU data of this texture.

◆ getData() [2/2]

Bitmap& getData ( )

Blocking call to retrieve GPU texture data that is stored in this texture When the internal bitmap is empty it will be initialized based on the settings associated with this texture This call asserts if the bitmap can't be initialized or, when initialized, the bitmap settings don't match.

Returns
reference to the internal bitmap that is filled with the GPU data of this texture.

◆ startGetData()

void startGetData ( )

Starts a transfer of texture data from GPU to CPU. This is a non blocking call. For performance, it is important to start a transfer as soon as possible after the texture is rendered.

◆ update() [1/3]

void update

Converts the CPU data that is passed in to the GPU. The internal Bitmap remains untouched.

Parameters
dataPointer to the CPU data.
pitchLength of a row of bytes in the input data.

◆ update() [2/3]

void update

Converts the CPU data from the Bitmap that is passed in to the GPU. The internal Bitmap remains untouched. The bitmap should contain valid data and not be empty.

Parameters
bitmapCPU data to convert to GPU.

◆ update() [3/3]

void update ( )

Converts the CPU data in the internal Bitmap to the GPU. The bitmap should contain valid data and not be empty.