20#ifndef YOURGAME_GLTEXTURE_H
21#define YOURGAME_GLTEXTURE_H
37 TextureCoords(
int x,
int y,
int width,
int height,
int texWidth,
int texHeight,
bool cwRot)
39 if (width != 0 && height != 0 && texWidth != 0 && texHeight != 0)
41 uMin =
static_cast<float>(x) /
static_cast<float>(texWidth);
42 uMax =
static_cast<float>(x + width) /
static_cast<float>(texWidth);
43 vMin = 1.0f - (
static_cast<float>(y + height) /
static_cast<float>(texHeight));
44 vMax = 1.0f - (
static_cast<float>(y) /
static_cast<float>(texHeight));
73 const std::vector<std::pair<GLenum, GLint>> ¶meteri);
95 GLuint
handle()
const {
return m_handle; }
100 void insertCoords(std::string name,
int x,
int y,
int width,
int height,
bool cwRot);
148 std::map<int, TextureCoords> frames;
149 bool framesInvalidated;
150 std::vector<TextureCoords> framesConsec;
153 std::map<std::string, TextureCoords> m_coords;
154 std::map<std::string, Sequence> m_sequences;
static Texture * make(GLenum target, GLenum unit, const std::vector< std::pair< GLenum, GLint > > ¶meteri)
Definition texture.cpp:28
GLuint handle() const
Definition texture.h:95
GLenum getTarget() const
Definition texture.h:96
void bind() const
Definition texture.cpp:55
TextureCoords getFrameCoords(std::string sequenceName, int frame)
returns texture coordinates of subtexture which is part of a sequence
Definition texture.cpp:138
std::vector< std::string > getSequenceNames() const
returns a list of the names of all sequences
Definition texture.cpp:176
void updateData(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *data, bool generateMipmap)
Definition texture.cpp:67
TextureCoords getCoords(std::string name) const
returns texture coordinates of subtexture with name name
Definition texture.cpp:127
void unbindTarget() const
Definition texture.cpp:61
Texture & operator=(Texture const &)=delete
void insertCoords(std::string name, int x, int y, int width, int height, bool cwRot)
Definition texture.cpp:103
~Texture()
Definition texture.cpp:50
GLsizei getWidth() const
Definition texture.h:97
GLsizei getHeight() const
Definition texture.h:98
Texture(Texture const &)=delete
TextureCoords getGridCoords(int gridWidth, int gridHeight, int index) const
returns texture coordinates of grid subtexture
Definition texture.cpp:186
int getNumFrames(std::string sequenceName) const
returns the number of frames of a sequence
Definition texture.cpp:170
float uMax
Definition texture.h:56
bool cwRotated
Definition texture.h:65
int xMinPixel
Definition texture.h:59
TextureCoords(int x, int y, int width, int height, int texWidth, int texHeight, bool cwRot)
Definition texture.h:37
float aspectRatioPixelInverse
Definition texture.h:64
float vMin
Definition texture.h:57
int yMinPixel
Definition texture.h:61
float aspectRatioPixel
Definition texture.h:63
int xMaxPixel
Definition texture.h:60
float vMax
Definition texture.h:58
int yMaxPixel
Definition texture.h:62
float uMin
Definition texture.h:55
TextureCoords()
Definition texture.h:35