34 lines
834 B
C++
34 lines
834 B
C++
|
|
#ifndef TEXTURE_CLASS_H
|
|
#define TEXTURE_CLASS_H
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <glad/glad.h>
|
|
|
|
// A loaded image and nothing else. Game elements wear one through a SurfaceTexture,
|
|
// get these from the ResourceManager.
|
|
class Texture {
|
|
public:
|
|
GLuint ID;
|
|
std::string path;
|
|
int width = 0;
|
|
int height = 0;
|
|
std::vector<unsigned char> pixels; // RGBA, row 0 is the bottom of the image
|
|
|
|
Texture(const char* filename);
|
|
Texture(const unsigned char* encoded, int size, const std::string& name); // a png, jpg or the like already in memory
|
|
Texture(int newWidth, int newHeight); // blank white
|
|
Texture(const Texture& source); // an independent copy with its own GL texture
|
|
|
|
// Sends pixels to the GPU after they've been edited
|
|
void Upload();
|
|
void Delete();
|
|
|
|
private:
|
|
void CreateGLTexture();
|
|
};
|
|
|
|
#endif
|