summaryrefslogtreecommitdiffstats
path: root/vcl/inc/opengl/program.hxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /vcl/inc/opengl/program.hxx
parentInitial commit. (diff)
downloadlibreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz
libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--vcl/inc/opengl/program.hxx122
1 files changed, 122 insertions, 0 deletions
diff --git a/vcl/inc/opengl/program.hxx b/vcl/inc/opengl/program.hxx
new file mode 100644
index 000000000..bff248d9b
--- /dev/null
+++ b/vcl/inc/opengl/program.hxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_VCL_INC_OPENGL_PROGRAM_H
+#define INCLUDED_VCL_INC_OPENGL_PROGRAM_H
+
+#include <sal/config.h>
+
+#include <vector>
+
+#include <vcl/dllapi.h>
+
+#include <basegfx/point/b2dpoint.hxx>
+#include <rtl/ustring.hxx>
+#include <opengl/texture.hxx>
+
+#include <unordered_map>
+
+class Color;
+
+enum class TextureShaderType
+{
+ Normal = 0,
+ Blend,
+ Masked,
+ Diff,
+ MaskedColor
+};
+
+enum class DrawShaderType
+{
+ Normal = 0,
+ Line
+};
+
+class OpenGLProgram
+{
+private:
+ GLuint mnId;
+ std::unordered_map< OString, GLuint >
+ maUniformLocations;
+ sal_uInt32 mnEnabledAttribs;
+ GLuint mnPositionAttrib;
+ GLuint mnTexCoordAttrib;
+ GLuint mnAlphaCoordAttrib;
+ GLuint mnMaskCoordAttrib;
+ GLuint mnExtrusionVectorsAttrib;
+ GLuint mnVertexColorsAttrib;
+
+ std::vector< OpenGLTexture > maTextures;
+ bool mbBlending;
+
+ float mfLastWidth;
+ float mfLastHeight;
+ float mfLastPixelOffset;
+
+
+ OpenGLProgram(const OpenGLProgram &) = delete;
+public:
+ OpenGLProgram();
+ ~OpenGLProgram();
+
+ GLuint Id() { return mnId; }
+
+ bool Load( const OUString& rVertexShader, const OUString& rFragmentShader,
+ const OString& preamble, const OString& rDigest );
+ void Use();
+ void Reuse();
+ void Clean();
+
+ void SetVertices( const GLvoid* pData );
+ void SetTextureCoord( const GLvoid* pData );
+ void SetAlphaCoord( const GLvoid* pData );
+ void SetMaskCoord(const GLvoid* pData);
+ void SetExtrusionVectors(const GLvoid* pData);
+ void SetVertexColors(std::vector<GLubyte>& rColorVector);
+
+ void SetUniform1f( const OString& rName, GLfloat v1 );
+ void SetUniform2f( const OString& rName, GLfloat v1, GLfloat v2 );
+ void SetUniform1fv( const OString& rName, GLsizei nCount, GLfloat const * aValues );
+ void SetUniform2fv( const OString& rName, GLsizei nCount, GLfloat const * aValues );
+ void SetUniform1i( const OString& rName, GLint v1 );
+ void SetColor( const OString& rName, const Color& rColor );
+ void SetColor( const OString& rName, Color nColor, sal_uInt8 nTransparency );
+ void SetColorf( const OString& rName, Color nColor, double fTransparency );
+ void SetColorWithIntensity( const OString& rName, const Color& rColor, long nFactor );
+ void SetTexture( const OString& rName, OpenGLTexture& rTexture );
+ void SetTransform( const OString& rName, const OpenGLTexture& rTexture,
+ const basegfx::B2DPoint& rNull, const basegfx::B2DPoint& rX,
+ const basegfx::B2DPoint& rY );
+ void SetIdentityTransform(const OString& rName);
+ void SetShaderType(TextureShaderType eTextureShaderType);
+ void SetShaderType(DrawShaderType eDrawShaderType);
+
+ void SetBlendMode( GLenum nSFactor, GLenum nDFactor );
+
+ void ApplyMatrix(float fWidth, float fHeight, float fPixelOffset = 0.0f);
+
+ void DrawTexture( const OpenGLTexture& rTexture );
+
+ void DrawArrays(GLenum aMode, std::vector<GLfloat>& aVertices);
+ void DrawElements(GLenum aMode, GLuint nNumberOfVertices);
+
+ bool EnableVertexAttrib(GLuint& rAttrib, const OString& rName);
+
+ void SetVertexAttrib(GLuint& rAttrib, const OString& rName, GLint nSize,
+ GLenum eType, GLboolean bNormalized, GLsizei aStride,
+ const GLvoid* pPointer);
+
+private:
+ GLuint GetUniformLocation( const OString& rName );
+};
+
+#endif // INCLUDED_VCL_INC_OPENGL_PROGRAM_H
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */