summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2015-01-20 14:48:48 +0100
committerLuboš Luňák <l.lunak@collabora.com>2015-01-27 18:42:48 +0100
commitdf290c63451723ae05833cf5f13342d4c93f94cc (patch)
treecd0deacf8103562dd94f6fa14607ce2f8f585e4b /include
parentd3ac5c2d68fe6affc03e200ff985b4da1d4cf2d0 (diff)
make it possible to easily have variants of glsl programs
Now it's possible to add a preamble to the compiled program, so there can be just one program with #ifdef's inside and the small variants can be selected using #define in the preamble instead of having several almost identical programs. Change-Id: I6c5112313b91b6269ebdecdfc896e0f96209ea2b
Diffstat (limited to 'include')
-rw-r--r--include/vcl/opengl/OpenGLContext.hxx14
-rw-r--r--include/vcl/opengl/OpenGLHelper.hxx2
2 files changed, 11 insertions, 5 deletions
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 0178e21ebcd0..6f665875e256 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -161,8 +161,6 @@ struct GLWindow
~GLWindow();
};
-typedef std::pair<OUString, OUString> ProgramKey;
-
class VCLOPENGL_DLLPUBLIC OpenGLContext
{
public:
@@ -203,8 +201,8 @@ public:
void ReleaseFramebuffers();
// retrieve a program from the cache or compile/link it
- OpenGLProgram* GetProgram( const OUString& rVertexShader, const OUString& rFragmentShader );
- OpenGLProgram* UseProgram( const OUString& rVertexShader, const OUString& rFragmentShader );
+ OpenGLProgram* GetProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble = "" );
+ OpenGLProgram* UseProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble = "" );
bool isCurrent();
static void clearCurrent();
@@ -266,6 +264,14 @@ private:
OpenGLFramebuffer* mpFirstFramebuffer;
OpenGLFramebuffer* mpLastFramebuffer;
+ struct ProgramKey
+ {
+ ProgramKey( const OUString& vertexShader, const OUString& fragmentShader, const OString& preamble );
+ bool operator< ( const ProgramKey& other ) const;
+ OUString vertexShader;
+ OUString fragmentShader;
+ OString preamble;
+ };
boost::ptr_map<ProgramKey, OpenGLProgram> maPrograms;
OpenGLProgram* mpCurrentProgram;
#ifdef DBG_UTIL
diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx
index 243051519dac..4e11bf8306ef 100644
--- a/include/vcl/opengl/OpenGLHelper.hxx
+++ b/include/vcl/opengl/OpenGLHelper.hxx
@@ -25,7 +25,7 @@
class VCLOPENGL_DLLPUBLIC OpenGLHelper
{
public:
- static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName);
+ static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, const OString& preamble = "" );
/**
* The caller is responsible for allocate the memory for the RGBA buffer, before call