MTek-GDL 0.100.4-muffintrap
Loading...
Searching...
No Matches
Data Structures | Typedefs | Functions
mgdl-texture.h File Reference

Texture handling module header. More...

#include "mgdl-types.h"
#include "mgdl-util.h"
#include "mgdl-opengl.h"
#include "mgdl-png.h"

Go to the source code of this file.

Data Structures

struct  Texture
 Abstract class for cross platform PNG image loading. More...
 

Typedefs

typedef struct Texture Texture
 

Functions

TextureTexture_Create (void)
 
void Texture_SetGLName (Texture *img, GLuint textureName, GLsizei width, GLsizei height, ColorFormats format)
 Sets the GL name and dimenions of the image.
 
void Texture_Draw2DAligned (Texture *img, short x, short y, float scale, AlignmentModes alignX, AlignmentModes alignY)
 Draws the image using 2D vertices.
 
void Texture_Draw2DAbsolute (Texture *img, short x, short y, short x2, short y2)
 Draws the image using 2D vertices.
 
void Texture_Draw3D (Texture *img, float scale, AlignmentModes alignX, AlignmentModes alignY)
 Draws the image on the origo in 3D space.
 
void Texture_SetTint (Texture *img, float red, float green, float blue)
 Sets the tint of the image.
 
TextureTexture_LoadFile (const char *filename, TextureFilterModes filterMode)
 Loads an image from a file.
 
TextureTexture_LoadPNG (PNGFile *pngFile, TextureFilterModes filterMode)
 Loads an image from a PNG file object.
 
TextureTexture_GenerateCheckerBoard (void)
 Generates a 8x8 checkerboard image.
 

Detailed Description

Texture handling module header.

Function Documentation

◆ Texture_Draw2DAbsolute()

void Texture_Draw2DAbsolute ( Texture img,
short  x,
short  y,
short  x2,
short  y2 
)

Draws the image using 2D vertices.

This function expects the ortographic projection to be set. This function can stretch the image.

Parameters
xUpper left corner x of the image.
yUpper left corner y of the image.
x2Lower right corner x of the image.
y2Lower right corner y of the image.

◆ Texture_Draw2DAligned()

void Texture_Draw2DAligned ( Texture img,
short  x,
short  y,
float  scale,
AlignmentModes  alignX,
AlignmentModes  alignY 
)

Draws the image using 2D vertices.

This function expects the ortographic projection to be set. This function preserves the aspect ratio.

Parameters
xUpper left corner x of the image.
yUpper left corner y of the image.
scaleScaling of the image. Scale of 1.0 does not alter the size. Negative scale does not flip the image.
alignXAlignment on the X axis.
alignYAlignment on the Y axis.

◆ Texture_Draw3D()

void Texture_Draw3D ( Texture img,
float  scale,
AlignmentModes  alignX,
AlignmentModes  alignY 
)

Draws the image on the origo in 3D space.

This function expects the perspective projection to be set. This function preserves the aspect ratio.

Parameters
alignXAlignment on the X axis.
alignYAlignment on the Y axis.

◆ Texture_GenerateCheckerBoard()

Texture * Texture_GenerateCheckerBoard ( void  )

Generates a 8x8 checkerboard image.

Returns
The generated image

◆ Texture_LoadFile()

Texture * Texture_LoadFile ( const char *  filename,
TextureFilterModes  filterMode 
)

Loads an image from a file.

Parameters
filenameName of the image file.
filterModeFiltering mode to use.
Returns
True if loading was succesfull.

◆ Texture_LoadPNG()

Texture * Texture_LoadPNG ( PNGFile pngFile,
TextureFilterModes  filterMode 
)

Loads an image from a PNG file object.

Parameters
pngFilePNG file object.
filterModeFiltering mode to use.
Returns
True if loading was succesfull.

◆ Texture_SetGLName()

void Texture_SetGLName ( Texture img,
GLuint  textureName,
GLsizei  width,
GLsizei  height,
ColorFormats  format 
)

Sets the GL name and dimenions of the image.

This is used when the image data has already been loaded using OpenGL.

Parameters
textureNameGL name of the texture.
widthWidth of the image in pixels.
heightHeight of the image in pixels.
formatColor format of the image.

◆ Texture_SetTint()

void Texture_SetTint ( Texture img,
float  red,
float  green,
float  blue 
)

Sets the tint of the image.

This function sets the tint color. Each pixel is multiplied by the tint color. Default tint is white (1,1,1)

Parameters
redRed component of the tint color, [0,1].
greenRed component of the tint color, [0,1].
blueRed component of the tint color, [0,1].