yabba/texture.hpp
#pragma once
#include "ogl.hpp"
#include "common.hpp"
#include <vector>
class Ppm {
private:
Ppm(GLfloat*, GLsizei, GLsizei, char*);
public:
const GLfloat* const buf;
const GLsizei w, h;
const char* const name;
static Ppm* getInst(const char*);
~Ppm();
};
class Texture {
private:
static GLuint textures[80]; // maybe use some texture pool? (with dummy texture as 0)
static unsigned tex_no;
static unsigned refcount;
static GLenum os2tex(unsigned);
public:
const int index; // for binding to this texture using glUniform1i
const GLuint& name; // texture name from glGenTextures for this index
const GLenum tex; // texture unit (as index)
const char* const file;
unsigned w, h;
Texture(const char*);
bool set(const GLfloat*, GLsizei, GLsizei, bool);
bool set(const unsigned char*, GLsizei, GLsizei);
~Texture();
static Texture* load(const char*);
static bool load(const char*, std::vector<Texture*>&);
};