diff options
Diffstat (limited to 'graphics/asymptote/GLTextures.cc')
-rw-r--r-- | graphics/asymptote/GLTextures.cc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/graphics/asymptote/GLTextures.cc b/graphics/asymptote/GLTextures.cc new file mode 100644 index 0000000000..81ab5faaee --- /dev/null +++ b/graphics/asymptote/GLTextures.cc @@ -0,0 +1,48 @@ +// +// Created by jamie on 8/23/21. +// + +#include "GLTextures.h" + +#ifdef HAVE_GL + +namespace gl +{ + +#ifdef __CYGWIN__ +#define glDeleteTextures glDeleteTexturesEXT // Missing in 32-bit CYGWIN +#endif + +AGLTexture::~AGLTexture() +{ + if (textureId != 0) + { + glDeleteTextures(1, &textureId); + } +} + +AGLTexture& AGLTexture::operator=(AGLTexture&& glTex) noexcept +{ + textureId = glTex.textureId; + textureNumber = glTex.textureNumber; + glTex.textureId = 0; + glTex.textureNumber = -1; + + return *this; +} + +AGLTexture::AGLTexture(AGLTexture&& glTex) noexcept: + textureId(glTex.textureId), textureNumber(glTex.textureNumber) +{ +} + +AGLTexture::AGLTexture(int textureNumber) : textureNumber(textureNumber) {} + +void AGLTexture::setActive() const +{ + glActiveTexture(GL_TEXTURE0+textureNumber); +} + +} // namespace gl + +#endif |