-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextureImage.hpp
60 lines (45 loc) · 1.19 KB
/
TextureImage.hpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once
// System
#include <iostream>
#include <string>
#include <stdio.h>
#include <SDL2/SDL.h>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
//Texture wrapper class
class TextureImage
{
public:
//Initializes variables
TextureImage();
//Deallocates memory
~TextureImage();
//Loads image at specified path
bool loadFromFile(SDL_Renderer* gRenderer, SDL_Window* gWindow, std::string path );
// Creates a blank texture
bool createBlank( SDL_Renderer* gRenderer, SDL_Window* gWindow, int width, int height);
//Deallocates texture
void free();
//Set color modulation
void setColor( Uint8 red, Uint8 green, Uint8 blue );
//Renders texture at given point
void render(SDL_Renderer* gRenderer, int x, int y, SDL_Rect* clip = NULL );
//Gets image dimensions
int getWidth();
int getHeight();
//Pixel manipulators
bool lockTexture();
bool unlockTexture();
void* getPixels();
int getPitch();
private:
//The actual hardware texture
SDL_Texture* mTexture;
//Image dimensions
int width_;
int height_;
//Pixels
void* pixels_;
int pitch_;
};