nss: upgrade to release 3.73
[LibreOffice.git] / vcl / inc / opengl / TextureState.hxx
blobe285cd7704fa76230829de95db26669089ef384e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #ifndef INCLUDED_VCL_INC_OPENGL_TEXTURE_STATE_H
12 #define INCLUDED_VCL_INC_OPENGL_TEXTURE_STATE_H
14 #include <vcl/opengl/OpenGLHelper.hxx>
16 class TextureState
18 private:
19 GLuint mnCurrentTextureUnit;
20 std::vector<GLuint> maBoundTextures;
22 public:
23 TextureState()
24 : mnCurrentTextureUnit(0)
25 , maBoundTextures(4, 0)
29 static void generate(GLuint& nTexture)
31 glGenTextures(1, &nTexture);
32 CHECK_GL_ERROR();
35 void active(GLuint nTextureUnit)
37 if (mnCurrentTextureUnit != nTextureUnit)
39 glActiveTexture(GL_TEXTURE0 + nTextureUnit);
40 CHECK_GL_ERROR();
41 mnCurrentTextureUnit = nTextureUnit;
45 void bind(GLuint nTexture)
47 if (maBoundTextures[mnCurrentTextureUnit] != nTexture)
49 glBindTexture(GL_TEXTURE_2D, nTexture);
50 CHECK_GL_ERROR();
51 maBoundTextures[mnCurrentTextureUnit] = nTexture;
55 void unbindAndDelete(GLuint nTexture)
57 unbind(nTexture);
58 glDeleteTextures(1, &nTexture);
61 void unbind(GLuint nTexture)
63 for (size_t i = 0; i < maBoundTextures.size(); i++)
65 if (nTexture == maBoundTextures[i])
66 maBoundTextures[i] = 0;
71 #endif // INCLUDED_VCL_INC_OPENGL_TEXTURE_STATE_H
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */