PROTO::KLUDGE  0.1
Quick prototyping library for games using SDL and OpenGL.
pk::TriangleShape Class Reference

Create a drawable TriangleShape using OpenGL. Useful for basic test programs, but not very flexible - it will create only isosceles triangles. For more complex OpenGL geometry see the Mesh class. More...

#include <TriangleShape.hpp>

Inheritance diagram for pk::TriangleShape:
Inheritance graph
Collaboration diagram for pk::TriangleShape:
Collaboration graph

Public Member Functions

 TriangleShape (GLfloat width, GLfloat height)
 Construct a TriangleShape from a width and height. More...
 
virtual ~TriangleShape ()
 
void setFillColor (glm::vec4 fillColor)
 
glm::vec4 & getFillColor ()
 Get the current fill color for the TriangleShape. More...
 
void setVertexColors (GLfloat colors [16])
 Set the individual values for the vertex colors of the TriangleShape. More...
 
GLfloat * getVertexColors ()
 Get the current vertex colors for the TriangleShape. More...
 
void draw (GLStates &states)
 Draw the TriangleShape to the screen. More...
 
- Public Member Functions inherited from pk::GLDrawable
 GLDrawable ()
 
virtual ~GLDrawable ()
 
- Public Member Functions inherited from pk::GLTransformable
 GLTransformable ()
 Default constructor. More...
 
virtual ~GLTransformable ()
 
void setRect (GLRect r)
 Set the bounding rectangle for the GLTransformable object. Useful for calculating origin and size definitions. More...
 
GLRectgetRect ()
 Get the current bounding rectangle of the GLTransformable object. More...
 
void setWidth (GLfloat w)
 Convenient function for setting the width of the GLTransformable. More...
 
GLfloat & getWidth ()
 Get the width of the GLTransformable. More...
 
void setHeight (GLfloat h)
 
GLfloat & getHeight ()
 Get the height of the GLTransformable. More...
 
void setOrigin (glm::vec2 origin)
 Set the origin of the GLTransformable in screen coordinates (NOT normalized coordinates such as clip coordinates for example). More...
 
glm::vec2 & getOrigin ()
 Get the origin of the GLTransformable in screen coordinates (NOT normalized coordinates such as clip coordinates for example). More...
 
void setPosition (glm::vec2 position)
 Set the position of the GLTransformable in screen coordinates (NOT normalized coordinates such as clip coordinates for example). More...
 
const glm::vec2 & getPosition ()
 Get the position of the GLTransformable in screen coordinates (NOT normalized coordinates such as clip coordinates for example). More...
 
void move (glm::vec2 offset)
 Move the GLTransformable by a constant offset value in screen coordinates (NOT normalized coordinates such as clip coordinates for example). More...
 
void setAngle (float angle)
 Set the angle of the GLTransformable (in degrees, NOT radians). More...
 
float getAngle ()
 Get the angle of the GLTransformable (in degrees, NOT radians). More...
 
void rotate (float degrees)
 Rotate the GLTransformable by a constant value (in degrees, NOT radians). (in degrees, NOT radians). More...
 
void setScale (glm::vec2 scale)
 Set the scale of the GLTransformable. More...
 
glm::vec2 getScale ()
 Get the scale of the GLTransformable. More...
 
void scale (glm::vec2 scale)
 Scale the GLTransformable by a constant factor specified as a glm::vec2 of floats. More...
 
void clear ()
 Clear the buffers and reset the GLTransformable to an uninitialized state. More...
 

Private Member Functions

 TriangleShape ()
 Default constructor - INACCESSIBLE! More...
 
void updateNormals (GLfloat *vertices, unsigned int verticeCount, unsigned int *indices, unsigned int stride)
 
void updateGeometry ()
 Update the internal geometry of the TriangleShape. More...
 

Private Attributes

glm::vec4 m_fillColor
 Triangle fill color. More...
 
GLfloat m_vertexColors [16]
 Array of individual vertex colors. More...
 

Additional Inherited Members

- Public Attributes inherited from pk::GLTransformable
GLTransformData m_data
 Internal transform data for GLTransformable inherited classes. More...
 

Detailed Description

Create a drawable TriangleShape using OpenGL. Useful for basic test programs, but not very flexible - it will create only isosceles triangles. For more complex OpenGL geometry see the Mesh class.

Constructor & Destructor Documentation

◆ TriangleShape() [1/2]

pk::TriangleShape::TriangleShape ( )
inlineprivate

Default constructor - INACCESSIBLE!

◆ TriangleShape() [2/2]

pk::TriangleShape::TriangleShape ( GLfloat  width,
GLfloat  height 
)

Construct a TriangleShape from a width and height.

Parameters
GLfloatwidth - width specified for the TriangleShape.
GLfloatheight - height specified for the TriangleShape.

◆ ~TriangleShape()

virtual pk::TriangleShape::~TriangleShape ( )
virtual

Member Function Documentation

◆ draw()

void pk::TriangleShape::draw ( GLStates states)
virtual

Draw the TriangleShape to the screen.

Parameters
GLStates&states - reference to an OpenGl states struct.

Implements pk::GLDrawable.

◆ getFillColor()

glm::vec4 & pk::TriangleShape::getFillColor ( )
inline

Get the current fill color for the TriangleShape.

Returns
glm::vec4 - a glm::vec4 representing the vertex colors.

◆ getVertexColors()

GLfloat * pk::TriangleShape::getVertexColors ( )
inline

Get the current vertex colors for the TriangleShape.

Returns
GLfloat* - an array of GLfloat representing the vertex colors.

◆ setFillColor()

void pk::TriangleShape::setFillColor ( glm::vec4  fillColor)

◆ setVertexColors()

void pk::TriangleShape::setVertexColors ( GLfloat  colors[16])

Set the individual values for the vertex colors of the TriangleShape.

◆ updateGeometry()

void pk::TriangleShape::updateGeometry ( )
private

Update the internal geometry of the TriangleShape.

◆ updateNormals()

void pk::TriangleShape::updateNormals ( GLfloat *  vertices,
unsigned int  verticeCount,
unsigned int *  indices,
unsigned int  stride 
)
private

Member Data Documentation

◆ m_fillColor

glm::vec4 pk::TriangleShape::m_fillColor
private

Triangle fill color.

◆ m_vertexColors

GLfloat pk::TriangleShape::m_vertexColors[16]
private

Array of individual vertex colors.


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