1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
11 #ifndef INCLUDED_VCL_INC_OPENGL_TEXTURE_STATE_H
12 #define INCLUDED_VCL_INC_OPENGL_TEXTURE_STATE_H
14 #include <vcl/opengl/OpenGLHelper.hxx>
19 GLuint mnCurrentTextureUnit
;
20 std::vector
<GLuint
> maBoundTextures
;
24 : mnCurrentTextureUnit(0)
25 , maBoundTextures(4, 0)
28 static void generate(GLuint
& nTexture
)
30 glGenTextures(1, &nTexture
);
34 void active(GLuint nTextureUnit
)
36 if (mnCurrentTextureUnit
!= nTextureUnit
)
38 glActiveTexture(GL_TEXTURE0
+ nTextureUnit
);
40 mnCurrentTextureUnit
= nTextureUnit
;
45 void bind(GLuint nTexture
)
47 if (maBoundTextures
[mnCurrentTextureUnit
] != nTexture
)
49 glBindTexture(GL_TEXTURE_2D
, nTexture
);
51 maBoundTextures
[mnCurrentTextureUnit
] = nTexture
;
55 void unbindAndDelete(GLuint 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: */