-
Notifications
You must be signed in to change notification settings - Fork 1
/
OTexture.h
83 lines (64 loc) · 1.72 KB
/
OTexture.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
77
78
79
80
81
82
83
#pragma once
#ifndef _OGE_TEXTURE_H_
#define _OGE_TEXTURE_H_
#include <SDL.h>
#include <SDL_image.h>
#include <string>
class OTexture
{
public:
//de/contructor
OTexture();
OTexture(SDL_Renderer* renderer);
~OTexture();
//Load image at specified path, with color key for transparency
bool loadFromFile(std::string path, SDL_Color* colorKey = NULL);
//Load editable texture at specified point
bool loadEditableFromFile(std::string path, SDL_Color* colorKey = NULL);
//Returns true if texture has been loaded
bool textureIsLoaded();
//Creates blank texture
bool createBlank(int width, int height, SDL_TextureAccess = SDL_TEXTUREACCESS_STREAMING);
//Deaccocates 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);
//Set self as render target
void setAsRenderTarget();
//Get image dimensions
int getWidth();
int getHeight();
void setWidth(int w);
void setHeight(int h);
void setRenderer(SDL_Renderer* renderer);
SDL_Renderer* getRenderer();
//Pixel Manipulators
bool lockTexture();
bool unlockTexture();
void* getPixels();
void copyPixels(void* pixels);
int getPitch();
Uint32 getPixel32(unsigned int x, unsigned int y);
bool isEditable();
protected:
//hardware texture
SDL_Texture* mTexture = NULL;
SDL_Renderer* mRenderer = NULL;
private:
//The actual hardware texture
void* mPixels;
int mPitch;
bool mEditabled;
//Image dimensions
int mHeight;
int mWidth;
};
#endif