Perception Tool Kit (PTK) API Guide
ptk::Image Class Reference
Inheritance diagram for ptk::Image:
Inheritance graph
Collaboration diagram for ptk::Image:
Collaboration graph

Public Types

enum  FitType {
  STRETCH, FIT_X, FIT_Y, FIT,
  NATURAL
}
 

Public Member Functions

 Image (Renderer *r, GLuint texture, bool invert, FitType fit)
 
 Image (Renderer *r, GLuint texture, bool invert)
 
 Image (Renderer *r, GLuint texture, FitType fit)
 
 Image (Renderer *r, GLuint texture)
 
virtual ~Image ()
 
virtual Imageshow ()
 
virtual Imagehide ()
 
ImagesetTexture (GLuint tex)
 
virtual void render (uint64_t delta, Dimensions d)
 
virtual void windowResize ()
 
void update ()
 
float getScale () const
 
float getXOffset () const
 
float getYOffset () const
 
void setRenderer (Renderer *r)
 
void setVirtualCamera (PTK_VirtualCamera *camera)
 
PTK_VirtualCameragetVirtualCamera () const
 
void setQuadUV (uint16_t quad, float minU, float maxU, float minV, float maxV)
 
void setQuadUV (uint16_t quad, GLushort minU, GLushort maxU, GLushort minV, GLushort maxV)
 
void setQuadAlpha (uint16_t quad, float alpha)
 
void setQuadAlpha (uint16_t quad, GLushort alpha)
 
bool render (glm::u16vec3 *vCoords, glm::u16vec3 *tCoords, int offset, bool force)
 
bool render (glm::u16vec3 *vCoords, uint16_t offset, bool force)
 
void setTextureId (uint16_t quad, GLuint tId)
 
GLuint getTextureId (uint16_t quad) const
 
void setQuadsZ (GLshort z)
 
void setQuadXY (uint16_t quad, float x, float y, float w, float h)
 
void setQuadXY (uint16_t quad, GLshort x, GLshort y, GLshort w, GLshort h)
 
void setQuadZ (uint16_t quad, GLshort z)
 
void setQuadPosition (uint16_t quad, const glm::u16vec3 &coords, GLshort w, GLshort h)
 
uint16_t getQuadCount (void) const
 
bool isVisible (void) const
 

Protected Member Functions

void _show (void)
 
void _hide (void)
 

Protected Attributes

Renderer_r
 
PTK_VirtualCamera_viewCamera
 
uint16_t _count
 
uint16_t _prevOffset
 Count of quads rendered. More...
 
glm::u16vec3 * _vCoords
 Have the vertex or color data been modified? More...
 
bool _visible
 

Static Protected Attributes

static PTK_VirtualCamera_defaultCamera
 

Private Attributes

Dimensions _lastDimensions
 
bool _modified
 
bool _invert
 
FitType _fit
 
int _texWidth
 
int _texHeight
 
float _scale
 
float _xOffset
 
float _yOffset
 

Member Enumeration Documentation

◆ FitType

enum ptk::Image::FitType
Enumerator
STRETCH 

Reshape to full dimensions given.

FIT_X 

Keep aspect ratio, match x (may overflow y)

FIT_Y 

Keep aspect ratio, match y (may overflow x)

FIT 

Keep aspect ratio, match largest dimension (no overflows)

NATURAL 

Do not resize, may overflow (not recommended)

Constructor & Destructor Documentation

◆ Image() [1/4]

ptk::Image::Image ( Renderer r,
GLuint  texture,
bool  invert,
FitType  fit 
)

◆ Image() [2/4]

ptk::Image::Image ( Renderer r,
GLuint  texture,
bool  invert 
)

◆ Image() [3/4]

ptk::Image::Image ( Renderer r,
GLuint  texture,
FitType  fit 
)

◆ Image() [4/4]

ptk::Image::Image ( Renderer r,
GLuint  texture 
)

◆ ~Image()

virtual ptk::Image::~Image ( )
virtual

Member Function Documentation

◆ show()

virtual Image* ptk::Image::show ( void  )
virtual

Default show implementation merely calls the concrete function

Reimplemented from ptk::Visible< Image >.

◆ hide()

virtual Image* ptk::Image::hide ( void  )
virtual

Default hide implementation merely calls the concrete function

Reimplemented from ptk::Visible< Image >.

◆ setTexture()

Image* ptk::Image::setTexture ( GLuint  tex)

◆ render() [1/3]

virtual void ptk::Image::render ( uint64_t  tick,
Dimensions  dimensions 
)
virtual

Render this object, including a time delta in microseconds since it was last rendered and the size of the region being renderered to. For 3D objects, glViewport will hand dimensions and it is informative. For 2D objects with a separate aggregate pipeline, the dimensions should be used to check and update position information, so that all positions can be specified relative to the "container" and allow boxes to be nested and repositioned easily

Parameters
[in]tickThe number of microseconds that have passed since this object was last rendered
[in]dimensionsThe dimensions of the region this renders to of the entire screen

Implements ptk::Renderable.

◆ windowResize()

virtual void ptk::Image::windowResize ( )
inlinevirtual

Called when the window is resized by the Renderer

Implements ptk::TexturedQuadRenderable.

◆ update()

void ptk::Image::update ( )

◆ getScale()

float ptk::Image::getScale ( ) const
inline

◆ getXOffset()

float ptk::Image::getXOffset ( ) const
inline

◆ getYOffset()

float ptk::Image::getYOffset ( ) const
inline

◆ setRenderer()

void ptk::Renderable::setRenderer ( Renderer r)
inlineinherited

Save a pointer to the renderer this is attached to, which may be needed later for some global state access

Parameters
[in]rThe renderer that is being used to visualize this renderable

◆ setVirtualCamera()

void ptk::Renderable::setVirtualCamera ( PTK_VirtualCamera camera)
inlineinherited

Save a pointer to the given virtual camera to use when visualizing this object

Parameters
[in]cameraPointer to virtual camera to use

◆ getVirtualCamera()

PTK_VirtualCamera* ptk::Renderable::getVirtualCamera ( ) const
inlineinherited

◆ setQuadUV() [1/2]

void ptk::TexturedQuadRenderable::setQuadUV ( uint16_t  quad,
float  minU,
float  maxU,
float  minV,
float  maxV 
)
inherited

◆ setQuadUV() [2/2]

void ptk::TexturedQuadRenderable::setQuadUV ( uint16_t  quad,
GLushort  minU,
GLushort  maxU,
GLushort  minV,
GLushort  maxV 
)
inherited

◆ setQuadAlpha() [1/2]

void ptk::TexturedQuadRenderable::setQuadAlpha ( uint16_t  quad,
float  alpha 
)
inherited

◆ setQuadAlpha() [2/2]

void ptk::TexturedQuadRenderable::setQuadAlpha ( uint16_t  quad,
GLushort  alpha 
)
inherited

◆ render() [2/3]

bool ptk::TexturedQuadRenderable::render ( glm::u16vec3 *  vCoords,
glm::u16vec3 *  tCoords,
int  offset,
bool  force 
)
inherited

◆ render() [3/3]

bool ptk::QuadRenderable::render ( glm::u16vec3 *  vCoords,
uint16_t  offset,
bool  force 
)
inherited

◆ setTextureId()

void ptk::TexturedQuadRenderable::setTextureId ( uint16_t  quad,
GLuint  tId 
)
inlineinherited

Set the texture ID that should be used during rendering

Parameters
quadWhich quad to set the texture for
tIdthe new opengl texture id to use

◆ getTextureId()

GLuint ptk::TexturedQuadRenderable::getTextureId ( uint16_t  quad) const
inlineinherited

Retrieves the texture ID for a specific quad, useful during rendering

Returns
The opengl id for a specific quad's texture

◆ setQuadsZ()

void ptk::QuadRenderable::setQuadsZ ( GLshort  z)
inherited

◆ setQuadXY() [1/2]

void ptk::QuadRenderable::setQuadXY ( uint16_t  quad,
float  x,
float  y,
float  w,
float  h 
)
inherited

◆ setQuadXY() [2/2]

void ptk::QuadRenderable::setQuadXY ( uint16_t  quad,
GLshort  x,
GLshort  y,
GLshort  w,
GLshort  h 
)
inherited

◆ setQuadZ()

void ptk::QuadRenderable::setQuadZ ( uint16_t  quad,
GLshort  z 
)
inherited

◆ setQuadPosition()

void ptk::QuadRenderable::setQuadPosition ( uint16_t  quad,
const glm::u16vec3 &  coords,
GLshort  w,
GLshort  h 
)
inherited

◆ getQuadCount()

uint16_t ptk::QuadRenderable::getQuadCount ( void  ) const
inlineinherited
Returns
Number of quads this Renderable expects

◆ _show()

void ptk::Visible< Image >::_show ( void  )
inlineprotectedinherited

Show implementation that adjusts our flag

◆ _hide()

void ptk::Visible< Image >::_hide ( void  )
inlineprotectedinherited

Hide implementation that adjusts our flag

◆ isVisible()

bool ptk::Visible< Image >::isVisible ( void  ) const
inlineinherited

Determine if this is currently visible or not

Returns
true if visible, false otherwise

Field Documentation

◆ _lastDimensions

Dimensions ptk::Image::_lastDimensions
private

◆ _modified

bool ptk::Image::_modified
private

◆ _invert

bool ptk::Image::_invert
private

◆ _fit

FitType ptk::Image::_fit
private

◆ _texWidth

int ptk::Image::_texWidth
private

◆ _texHeight

int ptk::Image::_texHeight
private

◆ _scale

float ptk::Image::_scale
private

◆ _xOffset

float ptk::Image::_xOffset
private

◆ _yOffset

float ptk::Image::_yOffset
private

◆ _r

Renderer* ptk::Renderable::_r
protectedinherited

◆ _viewCamera

PTK_VirtualCamera* ptk::Renderable::_viewCamera
protectedinherited

◆ _defaultCamera

PTK_VirtualCamera* ptk::Renderable::_defaultCamera
staticprotectedinherited

◆ _count

uint16_t ptk::QuadRenderable::_count
protectedinherited

◆ _prevOffset

uint16_t ptk::QuadRenderable::_prevOffset
protectedinherited

Count of quads rendered.

◆ _vCoords

glm::u16vec3* ptk::QuadRenderable::_vCoords
protectedinherited

Have the vertex or color data been modified?

◆ _visible

bool ptk::Visible< Image >::_visible
protectedinherited