summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
Diffstat (limited to 'chart2')
-rwxr-xr-xchart2/source/view/main/OpenGLRender.cxx141
-rwxr-xr-xchart2/source/view/main/OpenGLRender.hxx1
2 files changed, 6 insertions, 136 deletions
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 01331a04e15b..0ccb353004f9 100755
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -35,9 +35,7 @@
#include <vcl/virdev.hxx>
#include <vcl/dibtools.hxx>
-#include <osl/file.hxx>
-#include <rtl/bootstrap.hxx>
-#include <config_folders.h>
+#include <vcl/opengl/OpenGLHelper.hxx>
#include <boost/scoped_array.hpp>
@@ -96,133 +94,6 @@ static bool bGlewInit = false;
namespace {
-OUString getShaderFolder()
-{
- OUString aUrl("$BRAND_BASE_DIR/" LIBO_ETC_FOLDER);
- rtl::Bootstrap::expandMacros(aUrl);
-
- return aUrl + "/opengl/";
-}
-
-OUString maShaderFolder = getShaderFolder();
-
-OString loadShader(const OUString& rFilename)
-{
- OUString aFileURL = maShaderFolder + rFilename +".glsl";
- osl::File aFile(aFileURL);
- if(aFile.open(osl_File_OpenFlag_Read) == osl::FileBase::E_None)
- {
- sal_uInt64 nSize = 0;
- aFile.getSize(nSize);
- char* content = new char[nSize+1];
- sal_uInt64 nBytesRead = 0;
- aFile.read(content, nSize, nBytesRead);
- if(nSize != nBytesRead)
- assert(false);
-
- content[nSize] = 0;
- return OString(content);
- }
- else
- {
- SAL_WARN("chart2.opengl", "could not load the file: " << aFileURL);
- }
-
- return OString();
-}
-
-}
-
-GLint OpenGLRender::LoadShaders(const OUString& rVertexShaderName,const OUString& rFragmentShaderName)
-{
- // Create the shaders
- GLuint VertexShaderID = glCreateShader(GL_VERTEX_SHADER);
- GLuint FragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);
-
- GLint Result = GL_FALSE;
- int InfoLogLength;
-
- // Compile Vertex Shader
- OString aVertexShaderSource = loadShader(rVertexShaderName);
- char const * VertexSourcePointer = aVertexShaderSource.getStr();
- glShaderSource(VertexShaderID, 1, &VertexSourcePointer , NULL);
- glCompileShader(VertexShaderID);
-
- // Check Vertex Shader
- glGetShaderiv(VertexShaderID, GL_COMPILE_STATUS, &Result);
- if ( !Result )
- {
- glGetShaderiv(VertexShaderID, GL_INFO_LOG_LENGTH, &InfoLogLength);
- if ( InfoLogLength > 0 )
- {
- std::vector<char> VertexShaderErrorMessage(InfoLogLength+1);
- glGetShaderInfoLog(VertexShaderID, InfoLogLength, NULL, &VertexShaderErrorMessage[0]);
- VertexShaderErrorMessage.push_back('\0');
- SAL_WARN("chart2.opengl", "vertex shader compile failed : " << &VertexShaderErrorMessage[0]);
- }
- else
- SAL_WARN("chart2.opengl", "vertex shader compile failed without error log");
-
- return 0;
- }
-
- // Compile Fragment Shader
- OString aFragmentShaderSource = loadShader(rFragmentShaderName);
- char const * FragmentSourcePointer = aFragmentShaderSource.getStr();
- glShaderSource(FragmentShaderID, 1, &FragmentSourcePointer , NULL);
- glCompileShader(FragmentShaderID);
-
- // Check Fragment Shader
- glGetShaderiv(FragmentShaderID, GL_COMPILE_STATUS, &Result);
- if ( !Result )
- {
- glGetShaderiv(FragmentShaderID, GL_INFO_LOG_LENGTH, &InfoLogLength);
- if ( InfoLogLength > 0 )
- {
- std::vector<char> FragmentShaderErrorMessage(InfoLogLength+1);
- glGetShaderInfoLog(FragmentShaderID, InfoLogLength, NULL, &FragmentShaderErrorMessage[0]);
- FragmentShaderErrorMessage.push_back('\0');
- SAL_WARN("chart2.opengl", "fragment shader compile failed : " << &FragmentShaderErrorMessage[0]);
- }
- else
- SAL_WARN("chart2.opengl", "fragment shader compile failed without error log");
-
-
- return 0;
- }
-
- // Link the program
- GLint ProgramID = glCreateProgram();
- glAttachShader(ProgramID, VertexShaderID);
- glAttachShader(ProgramID, FragmentShaderID);
- glLinkProgram(ProgramID);
-
- // Check the program
- glGetProgramiv(ProgramID, GL_LINK_STATUS, &Result);
- if ( !Result )
- {
- glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, &InfoLogLength);
- if ( InfoLogLength > 0 )
- {
- std::vector<char> ProgramErrorMessage(InfoLogLength+1);
- glGetProgramInfoLog(ProgramID, InfoLogLength, NULL, &ProgramErrorMessage[0]);
- ProgramErrorMessage.push_back('\0');
- SAL_WARN("chart2.opengl", "Shader Program failed : " << &ProgramErrorMessage[0]);
- }
- else
- SAL_WARN("chart2.opengl", "shader program link failed without error log");
-
- return 0;
- }
-
- glDeleteShader(VertexShaderID);
- glDeleteShader(FragmentShaderID);
-
- return ProgramID;
-}
-
-namespace {
-
GLfloat texCoords[] = {
0.0f, 0.0f,
1.0f, 0.0f,
@@ -287,26 +158,26 @@ int OpenGLRender::InitOpenGL()
CHECK_GL_ERROR();
- m_CommonProID = LoadShaders("commonVertexShader", "commonFragmentShader");
+ m_CommonProID = OpenGLHelper::LoadShaders("commonVertexShader", "commonFragmentShader");
m_MatrixID = glGetUniformLocation(m_CommonProID, "MVP");
m_2DVertexID = glGetAttribLocation(m_CommonProID, "vPosition");
m_2DColorID = glGetUniformLocation(m_CommonProID, "vColor");
CHECK_GL_ERROR();
#if DEBUG_POSITIONING
- m_DebugProID = LoadShaders("debugVertexShader", "debugFragmentShader");
+ m_DebugProID = OpenGLHelper::LoadShaders("debugVertexShader", "debugFragmentShader");
m_DebugVertexID = glGetAttribLocation(m_DebugProID, "vPosition");
CHECK_GL_ERROR();
#endif
- m_BackgroundProID = LoadShaders("backgroundVertexShader", "backgroundFragmentShader");
+ m_BackgroundProID = OpenGLHelper::LoadShaders("backgroundVertexShader", "backgroundFragmentShader");
m_BackgroundMatrixID = glGetUniformLocation(m_BackgroundProID, "MVP");
m_BackgroundVertexID = glGetAttribLocation(m_BackgroundProID, "vPosition");
m_BackgroundColorID = glGetAttribLocation(m_BackgroundProID, "vColor");
CHECK_GL_ERROR();
- m_SymbolProID = LoadShaders("symbolVertexShader", "symbolFragmentShader");
+ m_SymbolProID = OpenGLHelper::LoadShaders("symbolVertexShader", "symbolFragmentShader");
m_SymbolVertexID = glGetAttribLocation(m_SymbolProID, "vPosition");
m_SymbolMatrixID = glGetUniformLocation(m_SymbolProID, "MVP");
m_SymbolColorID = glGetUniformLocation(m_SymbolProID, "vColor");
@@ -314,7 +185,7 @@ int OpenGLRender::InitOpenGL()
CHECK_GL_ERROR();
- m_TextProID = LoadShaders("textVertexShader", "textFragmentShader");
+ m_TextProID = OpenGLHelper::LoadShaders("textVertexShader", "textFragmentShader");
m_TextMatrixID = glGetUniformLocation(m_TextProID, "MVP");
m_TextVertexID = glGetAttribLocation(m_TextProID, "vPosition");
m_TextTexCoordID = glGetAttribLocation(m_TextProID, "texCoord");
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index d0121ad9b4cc..2f79e1c35fb0 100755
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -108,7 +108,6 @@ public:
void SetBackGroundColor(sal_uInt32 color1, sal_uInt32 color2, sal_uInt8 nAlpha);
private:
- GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName);
int CreateTextureObj(int width, int height);
int CreateRenderObj(int width, int height);
int CreateFrameBufferObj();