bump product version to 6.4.0.3
[LibreOffice.git] / vcl / inc / opengl / TextureState.hxx
blobfbf2b9cee548f2ec599ee5b9edc8564544fc7499
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)
28 static void generate(GLuint& nTexture)
30 glGenTextures(1, &nTexture);
31 CHECK_GL_ERROR();
34 void active(GLuint nTextureUnit)
36 if (mnCurrentTextureUnit != nTextureUnit)
38 glActiveTexture(GL_TEXTURE0 + nTextureUnit);
39 CHECK_GL_ERROR();
40 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;
74 #endif // INCLUDED_VCL_INC_OPENGL_TEXTURE_STATE_H
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */