SparrowRenderer/src/texture.h

60 lines
1.5 KiB
C++

#ifndef TEXTURE_H
#define TEXTURE_H
#include "opengl.h"
#include <string>
class Image;
class Texture
{
private:
GLuint m_texId;
int m_texUnit;
GLenum m_target;
GLenum m_format;
GLenum m_internal_format;
int m_width;
int m_height;
GLenum m_dataType;
bool m_hasMipMaps;
void initPixels(Image* myImage, GLenum target);
public:
// creates a 2D texture from perlin noise
Texture();
// creates an empty 2D texture
Texture(GLenum format = GL_RGBA,
GLenum internal_format = GL_RGBA,
int width = 512,
int height = 512,
GLenum dataType = GL_UNSIGNED_BYTE,
GLenum texTarget = GL_TEXTURE_2D);
// creates a standard texture from an image
Texture(Image* myImage, bool makeMipMaps = true);
// creates a cubeMap from 6 images
Texture(Image* myCubemapImages[6], bool makeMipMaps = true);
// creates a texture from another
Texture(Texture* tex, bool halfDim = false);
~Texture();
void setUnit(int unit) { m_texUnit = unit; }
void bind(int unit = -1);
void unbind();
GLuint getId() {return m_texId;}
GLenum getTarget() {return m_target;}
void setWrap(GLint wrap);
void setFiltering(GLint filter);
void setParameter(GLenum parameter, GLenum value);
void createMipMaps();
bool isCubeMap() {return m_target == GL_TEXTURE_CUBE_MAP;}
bool hasMipMaps() {return m_hasMipMaps;}
int getWidth() {return m_width;}
int getHeight() {return m_height;}
Image* getData();
};
#endif // TEXTURE_H