1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 19:32:49 +01:00
openrw/rwengine/include/render/TextureAtlas.hpp

57 lines
1.1 KiB
C++
Raw Normal View History

2013-09-11 13:10:42 +02:00
#pragma once
#ifndef _TEXTURE_ATLAS_HPP_
#define _TEXTURE_ATLAS_HPP_
2013-09-11 20:23:31 +02:00
#include <GL/glew.h>
2013-09-11 13:10:42 +02:00
class TextureAtlas
{
/**
* @brief width Width of the backing texture.
*/
size_t width;
/**
* @brief height Height of the backing texture.
*/
size_t height;
GLuint textureName;
size_t X; // X edge of latest texture.
size_t Y; // Y of current row.
size_t rowHeight; // Maximum texture height for the current row.
2013-09-11 20:23:31 +02:00
size_t textureCount;
bool finalized;
2013-09-11 13:10:42 +02:00
public:
TextureAtlas(size_t w, size_t h);
~TextureAtlas();
2013-09-11 20:23:31 +02:00
void packTexture(void* data, size_t w, size_t h, float& s, float& t, float& sX, float& sY);
void packTextureFormat(void* data, GLenum format, GLenum type, size_t w, size_t h, float& s, float& t, float& sX, float& sY);
2013-09-11 13:10:42 +02:00
/**
* @brief canPack Returns true if enough space remains in the atlas
* for the given texture sizes to be packed.
* @param w
* @param h
* @param n
* @return True on success, false on failure.
*/
bool canPack(size_t* w, size_t* h, size_t n) const;
2013-09-11 20:23:31 +02:00
size_t getTextureCount() const;
GLint getName() const;
bool isFinalized() const;
void finalize();
2013-09-11 13:10:42 +02:00
};
#endif