mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-16 06:57:04 +02:00
Remove dead class from oglplus helpers
This commit is contained in:
parent
c7551a2207
commit
f28962af12
2 changed files with 0 additions and 108 deletions
|
@ -480,84 +480,3 @@ ShapeWrapperPtr loadLaser(const ProgramPtr& program) {
|
|||
return std::make_shared<shapes::ShapeWrapper>(shapes::ShapeWrapper("Position", shapes::Laser(), *program));
|
||||
}
|
||||
|
||||
void TextureRecycler::setSize(const uvec2& size) {
|
||||
if (size == _size) {
|
||||
return;
|
||||
}
|
||||
_size = size;
|
||||
while (!_readyTextures.empty()) {
|
||||
_readyTextures.pop();
|
||||
}
|
||||
std::set<Map::key_type> toDelete;
|
||||
std::for_each(_allTextures.begin(), _allTextures.end(), [&](Map::const_reference item) {
|
||||
if (!item.second._active && item.second._size != _size) {
|
||||
toDelete.insert(item.first);
|
||||
}
|
||||
});
|
||||
std::for_each(toDelete.begin(), toDelete.end(), [&](Map::key_type key) {
|
||||
_allTextures.erase(key);
|
||||
});
|
||||
}
|
||||
|
||||
void TextureRecycler::clear() {
|
||||
while (!_readyTextures.empty()) {
|
||||
_readyTextures.pop();
|
||||
}
|
||||
_allTextures.clear();
|
||||
}
|
||||
|
||||
TexturePtr TextureRecycler::getNextTexture() {
|
||||
using namespace oglplus;
|
||||
if (_readyTextures.empty()) {
|
||||
TexturePtr newTexture(new Texture());
|
||||
|
||||
if (_useMipmaps) {
|
||||
Context::Bound(oglplus::Texture::Target::_2D, *newTexture)
|
||||
.MinFilter(TextureMinFilter::LinearMipmapLinear)
|
||||
.MagFilter(TextureMagFilter::Linear)
|
||||
.WrapS(TextureWrap::ClampToEdge)
|
||||
.WrapT(TextureWrap::ClampToEdge)
|
||||
.Anisotropy(8.0f)
|
||||
.LODBias(-0.2f)
|
||||
.Image2D(0, PixelDataInternalFormat::RGBA8,
|
||||
_size.x, _size.y,
|
||||
0, PixelDataFormat::RGB, PixelDataType::UnsignedByte, nullptr);
|
||||
} else {
|
||||
Context::Bound(oglplus::Texture::Target::_2D, *newTexture)
|
||||
.MinFilter(TextureMinFilter::Linear)
|
||||
.MagFilter(TextureMagFilter::Linear)
|
||||
.WrapS(TextureWrap::ClampToEdge)
|
||||
.WrapT(TextureWrap::ClampToEdge)
|
||||
.Image2D(0, PixelDataInternalFormat::RGBA8,
|
||||
_size.x, _size.y,
|
||||
0, PixelDataFormat::RGB, PixelDataType::UnsignedByte, nullptr);
|
||||
}
|
||||
GLuint texId = GetName(*newTexture);
|
||||
_allTextures[texId] = TexInfo{ newTexture, _size };
|
||||
_readyTextures.push(newTexture);
|
||||
}
|
||||
|
||||
TexturePtr result = _readyTextures.front();
|
||||
_readyTextures.pop();
|
||||
|
||||
GLuint texId = GetName(*result);
|
||||
auto& item = _allTextures[texId];
|
||||
item._active = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void TextureRecycler::recycleTexture(GLuint texture) {
|
||||
Q_ASSERT(_allTextures.count(texture));
|
||||
auto& item = _allTextures[texture];
|
||||
Q_ASSERT(item._active);
|
||||
item._active = false;
|
||||
if (item._size != _size) {
|
||||
// Buh-bye
|
||||
_allTextures.erase(texture);
|
||||
return;
|
||||
}
|
||||
|
||||
_readyTextures.push(item._tex);
|
||||
}
|
||||
|
||||
|
|
|
@ -188,30 +188,3 @@ protected:
|
|||
|
||||
using BasicFramebufferWrapperPtr = std::shared_ptr<BasicFramebufferWrapper>;
|
||||
|
||||
class TextureRecycler {
|
||||
public:
|
||||
TextureRecycler(bool useMipmaps) : _useMipmaps(useMipmaps) {}
|
||||
void setSize(const uvec2& size);
|
||||
void clear();
|
||||
TexturePtr getNextTexture();
|
||||
void recycleTexture(GLuint texture);
|
||||
|
||||
private:
|
||||
|
||||
struct TexInfo {
|
||||
TexturePtr _tex;
|
||||
uvec2 _size;
|
||||
bool _active{ false };
|
||||
|
||||
TexInfo() {}
|
||||
TexInfo(TexturePtr tex, const uvec2& size) : _tex(tex), _size(size) {}
|
||||
};
|
||||
|
||||
using Map = std::map<GLuint, TexInfo>;
|
||||
using Queue = std::queue<TexturePtr>;
|
||||
|
||||
Map _allTextures;
|
||||
Queue _readyTextures;
|
||||
uvec2 _size{ 1920, 1080 };
|
||||
bool _useMipmaps;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue