bump product version to 6.4.0.3
[LibreOffice.git] / vcl / inc / opengl / program.hxx
blobbff248d9bfab874e3a752745c49ac3d2d1328b24
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/.
8 */
10 #ifndef INCLUDED_VCL_INC_OPENGL_PROGRAM_H
11 #define INCLUDED_VCL_INC_OPENGL_PROGRAM_H
13 #include <sal/config.h>
15 #include <vector>
17 #include <vcl/dllapi.h>
19 #include <basegfx/point/b2dpoint.hxx>
20 #include <rtl/ustring.hxx>
21 #include <opengl/texture.hxx>
23 #include <unordered_map>
25 class Color;
27 enum class TextureShaderType
29 Normal = 0,
30 Blend,
31 Masked,
32 Diff,
33 MaskedColor
36 enum class DrawShaderType
38 Normal = 0,
39 Line
42 class OpenGLProgram
44 private:
45 GLuint mnId;
46 std::unordered_map< OString, GLuint >
47 maUniformLocations;
48 sal_uInt32 mnEnabledAttribs;
49 GLuint mnPositionAttrib;
50 GLuint mnTexCoordAttrib;
51 GLuint mnAlphaCoordAttrib;
52 GLuint mnMaskCoordAttrib;
53 GLuint mnExtrusionVectorsAttrib;
54 GLuint mnVertexColorsAttrib;
56 std::vector< OpenGLTexture > maTextures;
57 bool mbBlending;
59 float mfLastWidth;
60 float mfLastHeight;
61 float mfLastPixelOffset;
64 OpenGLProgram(const OpenGLProgram &) = delete;
65 public:
66 OpenGLProgram();
67 ~OpenGLProgram();
69 GLuint Id() { return mnId; }
71 bool Load( const OUString& rVertexShader, const OUString& rFragmentShader,
72 const OString& preamble, const OString& rDigest );
73 void Use();
74 void Reuse();
75 void Clean();
77 void SetVertices( const GLvoid* pData );
78 void SetTextureCoord( const GLvoid* pData );
79 void SetAlphaCoord( const GLvoid* pData );
80 void SetMaskCoord(const GLvoid* pData);
81 void SetExtrusionVectors(const GLvoid* pData);
82 void SetVertexColors(std::vector<GLubyte>& rColorVector);
84 void SetUniform1f( const OString& rName, GLfloat v1 );
85 void SetUniform2f( const OString& rName, GLfloat v1, GLfloat v2 );
86 void SetUniform1fv( const OString& rName, GLsizei nCount, GLfloat const * aValues );
87 void SetUniform2fv( const OString& rName, GLsizei nCount, GLfloat const * aValues );
88 void SetUniform1i( const OString& rName, GLint v1 );
89 void SetColor( const OString& rName, const Color& rColor );
90 void SetColor( const OString& rName, Color nColor, sal_uInt8 nTransparency );
91 void SetColorf( const OString& rName, Color nColor, double fTransparency );
92 void SetColorWithIntensity( const OString& rName, const Color& rColor, long nFactor );
93 void SetTexture( const OString& rName, OpenGLTexture& rTexture );
94 void SetTransform( const OString& rName, const OpenGLTexture& rTexture,
95 const basegfx::B2DPoint& rNull, const basegfx::B2DPoint& rX,
96 const basegfx::B2DPoint& rY );
97 void SetIdentityTransform(const OString& rName);
98 void SetShaderType(TextureShaderType eTextureShaderType);
99 void SetShaderType(DrawShaderType eDrawShaderType);
101 void SetBlendMode( GLenum nSFactor, GLenum nDFactor );
103 void ApplyMatrix(float fWidth, float fHeight, float fPixelOffset = 0.0f);
105 void DrawTexture( const OpenGLTexture& rTexture );
107 void DrawArrays(GLenum aMode, std::vector<GLfloat>& aVertices);
108 void DrawElements(GLenum aMode, GLuint nNumberOfVertices);
110 bool EnableVertexAttrib(GLuint& rAttrib, const OString& rName);
112 void SetVertexAttrib(GLuint& rAttrib, const OString& rName, GLint nSize,
113 GLenum eType, GLboolean bNormalized, GLsizei aStride,
114 const GLvoid* pPointer);
116 private:
117 GLuint GetUniformLocation( const OString& rName );
120 #endif // INCLUDED_VCL_INC_OPENGL_PROGRAM_H
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */