-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadableTexture.h
More file actions
41 lines (34 loc) · 970 Bytes
/
ReadableTexture.h
File metadata and controls
41 lines (34 loc) · 970 Bytes
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
#pragma once
#include <SDL.h>
#include <SDL_image.h>
#include <stdio.h>
#include <string>
//Texture wrapper class
class ReadableTexture {
public:
ReadableTexture();
ReadableTexture(std::string path, SDL_Window* curWindow, SDL_Renderer* curRenderer);
//Gets image dimensions
int getWidth();
int getHeight();
//Pixel manipulators
Uint32* getPixels();
int getPitch();
SDL_PixelFormat* getMappingFormat();
SDL_Texture* getTexture();
/// <summary>
/// Finds the first pixel, reading left to right, that matches the colour given.
/// </summary>
/// <returns>The x and y position of a matching pixel, or -1, -1 for pixel not found.</returns>
SDL_Point findMatchingPixel(Uint32 targetColour);
SDL_Point findMatchingPixel(Uint32 targetColour, SDL_Rect* region);
private:
//The actual hardware texture
SDL_Surface* baseSurface;
SDL_Texture* baseTexture;
int mPitch;
SDL_PixelFormat* mappingFormat;
//Image dimensions
int mWidth;
int mHeight;
};