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/.
10 #ifndef INCLUDED_VCL_INC_OPENGL_PROGRAM_H
11 #define INCLUDED_VCL_INC_OPENGL_PROGRAM_H
13 #include <sal/config.h>
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>
27 enum class TextureShaderType
36 enum class DrawShaderType
46 std::unordered_map
< OString
, GLuint
>
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
;
61 float mfLastPixelOffset
;
64 OpenGLProgram(const OpenGLProgram
&) = delete;
69 GLuint
Id() { return mnId
; }
71 bool Load( const OUString
& rVertexShader
, const OUString
& rFragmentShader
,
72 const OString
& preamble
, const OString
& rDigest
);
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
);
117 GLuint
GetUniformLocation( const OString
& rName
);
120 #endif // INCLUDED_VCL_INC_OPENGL_PROGRAM_H
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */