-
Notifications
You must be signed in to change notification settings - Fork 5
/
texturetools.h
39 lines (30 loc) · 1.56 KB
/
texturetools.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef TEXTURETOOLS_H
#define TEXTURETOOLS_H
#include "gl.h"
//Throws if allocation failed
TEXTURE* newTexture(const unsigned int w, const unsigned int h, const COLOR fill = 0, const bool transparent = true, const COLOR transparent_color = 0);
void deleteTexture(TEXTURE *tex);
//Textures have to have the same resolution
void copyTexture(const TEXTURE &src, TEXTURE &dest);
//Returns nullptr if loading failed
TEXTURE *loadTextureFromFile(const char* filename);
bool saveTextureToFile(const TEXTURE &texture, const char* filename);
//Normal blitting
void drawTexture(const TEXTURE &src, TEXTURE &dest,
uint16_t src_x, uint16_t src_y, uint16_t src_w, uint16_t src_h,
uint16_t dest_x, uint16_t dest_y, uint16_t dest_w, uint16_t dest_h);
//50% opacity
void drawTextureOverlay(const TEXTURE &src, const unsigned int src_x, const unsigned int src_y, TEXTURE &dest, const unsigned int dest_x, const unsigned int dest_y, unsigned int w, unsigned int h);
//Allocates memory for new texture, deleteTexture must be called
TEXTURE* resizeTexture(const TEXTURE &src, const unsigned int w, const unsigned int h);
//Makes the texture greyscale
void greyscaleTexture(TEXTURE &tex);
//Draw outlines of rectangle (x/y)(x+w/y+h)
void drawRectangle(TEXTURE &tex, const unsigned int x, const unsigned int y, unsigned int w, unsigned int h, const COLOR c);
struct TextureAtlasEntry
{
unsigned int left, right; //U
unsigned int top, bottom; //V
};
TextureAtlasEntry textureArea(const unsigned int x, const unsigned int y, const unsigned int w, const unsigned int h);
#endif // TEXTURETOOLS_H