-
Notifications
You must be signed in to change notification settings - Fork 0
/
texture.h
76 lines (55 loc) · 1.61 KB
/
texture.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef TEXTURE_H
#define TEXTURE_H
#include "SDL.h"
#include <SDL_ttf.h>
#include "string"
//#include "string.h"
#include "stdio.h"
#include "sstream"
#include "SDL_image.h"
#include <cmath>
#include <stddef.h>
#include <iostream>
//#include <istream>
#include <assert.h>
#include <vector>
#include "cstdlib"
const int SCREEN_WIDTH = 800;
const int SCREEN_HEIGHT = 600;
class Texture
{
public:
//Initializes variables
Texture();
//Deallocates memory
~Texture();
//Loads individual image as texture
SDL_Texture* loadTexture( std::string path,SDL_Renderer* renderer);
bool initTexture(int SCREEN_WIDTH,int SCREEN_HEIGHT, SDL_Window* window,SDL_Renderer* renderer);
//Loads image at specified path
bool loadFromFile( std::string path, SDL_Renderer* renderer);
#if defined(SDL_TTF_MAJOR_VERSION)
//Creates image from font string
bool loadFromRenderedText( std::string textureText, SDL_Color textColor,TTF_Font* font,SDL_Renderer* renderer );
#endif
//Deallocates texture
void free();
//Set color modulation
void setColor( Uint8 red, Uint8 green, Uint8 blue );
//Set blending
void setBlendMode( SDL_BlendMode blending );
//Set alpha modulation
void setAlpha( Uint8 alpha );
//Renders texture at given point
void render( int x, int y, SDL_Rect* clip = NULL, double angle = 0.0, SDL_Point* center = NULL, SDL_RendererFlip flip = SDL_FLIP_NONE,SDL_Renderer* renderer=NULL );
//Gets image dimensions
int getWidth();
int getHeight();
private:
//The actual hardware texture
SDL_Texture* texture;
//Image dimensions
int width;
int height;
};
#endif // TEXTURE_H