[Libreoffice-commits] core.git: Branch 'private/moggi/opengl-3D-bar-rendering' - 3 commits - chart2/Library_chartcore.mk chart2/source include/vcl vcl/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Mon Apr 7 16:34:04 PDT 2014
chart2/Library_chartcore.mk | 2 ++
chart2/source/view/charttypes/3DBarChart.cxx | 9 ++++++---
chart2/source/view/inc/3DBarChart.hxx | 9 ++++++++-
chart2/source/view/inc/3DChartObjects.hxx | 17 +++++++++++++++++
chart2/source/view/main/3DChartObjects.cxx | 14 ++++++++++++++
include/vcl/OpenGLContext.hxx | 4 ++--
vcl/source/opengl/OpenGLContext.cxx | 13 +++++++++++++
7 files changed, 62 insertions(+), 6 deletions(-)
New commits:
commit 0e9cbea7bdbbd2e66c72cd337d2c9919989d4b84
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Tue Apr 8 01:17:16 2014 +0200
improve the code for temporary OpenGl context
Change-Id: Ia66bf54539e67066a56bb50fb606e50e581bee73
diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk
index 55aa610..e4b0051 100644
--- a/chart2/Library_chartcore.mk
+++ b/chart2/Library_chartcore.mk
@@ -29,6 +29,7 @@ $(eval $(call gb_Library_use_externals,chartcore,\
boost_headers \
mdds_headers \
glm_headers \
+ glew \
))
$(eval $(call gb_Library_use_custom_headers,chartcore,\
@@ -56,6 +57,7 @@ $(eval $(call gb_Library_use_libraries,chartcore,\
ucbhelper \
utl \
vcl \
+ vclopengl \
$(gb_UWINAPI) \
))
diff --git a/chart2/source/view/charttypes/3DBarChart.cxx b/chart2/source/view/charttypes/3DBarChart.cxx
index 79c02a6..3a13059 100644
--- a/chart2/source/view/charttypes/3DBarChart.cxx
+++ b/chart2/source/view/charttypes/3DBarChart.cxx
@@ -9,15 +9,16 @@
#include "3DBarChart.hxx"
-#include "3DChartObjects.hxx"
-
#include <glm/glm.hpp>
#include <glm/gtx/transform.hpp>
+#include "3DChartObjects.hxx"
+
namespace chart {
Bar3DChart::Bar3DChart(const std::vector<VDataSeries*>& rDataSeries):
- maDataSeries(rDataSeries)
+ maDataSeries(rDataSeries),
+ mxContext(new opengl3D::temporary::TemporaryContext())
{
}
@@ -57,12 +58,13 @@ void Bar3DChart::create3DShapes()
void Bar3DChart::render()
{
- maContext.init();
+ mxContext->init();
for(boost::ptr_vector<opengl3D::Renderable3DObject>::iterator itr = maShapes.begin(),
itrEnd = maShapes.end(); itr != itrEnd; ++itr)
{
itr->render();
}
+ mxContext->render();
}
}
diff --git a/chart2/source/view/inc/3DBarChart.hxx b/chart2/source/view/inc/3DBarChart.hxx
index 0cc5831..2f10ce2 100644
--- a/chart2/source/view/inc/3DBarChart.hxx
+++ b/chart2/source/view/inc/3DBarChart.hxx
@@ -19,7 +19,11 @@ namespace opengl3D {
class Renderable3DObject;
-}
+namespace temporary {
+
+class TemporaryContext;
+
+} }
class Bar3DChart
{
@@ -36,7 +40,7 @@ private:
std::vector<VDataSeries*> maDataSeries;
boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
- OpenGLContext maContext;
+ boost::scoped_ptr<opengl3D::temporary::TemporaryContext> mxContext;
};
}
diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx
index ec56ad8..f7eed23 100644
--- a/chart2/source/view/inc/3DChartObjects.hxx
+++ b/chart2/source/view/inc/3DChartObjects.hxx
@@ -12,6 +12,8 @@
#include <tools/color.hxx>
#include <vcl/bitmapex.hxx>
+#include <vcl/OpenGLContext.hxx>
+
namespace chart {
namespace opengl3D {
@@ -64,6 +66,21 @@ private:
Color maLineColor; // RGBA line color
};
+namespace temporary {
+
+class TemporaryContext
+{
+public:
+
+ void init();
+ void render();
+
+private:
+ OpenGLContext maContext;
+};
+
+}
+
}
}
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index 0a0696a..3c5a5b8 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -18,6 +18,20 @@ Bar::Bar(const glm::mat4& rPosition):
{
}
+namespace temporary {
+
+void TemporaryContext::init()
+{
+ maContext.init();
+}
+
+void TemporaryContext::render()
+{
+
+}
+
+}
+
}
}
diff --git a/include/vcl/OpenGLContext.hxx b/include/vcl/OpenGLContext.hxx
index e84e8fc..8c7eb55 100644
--- a/include/vcl/OpenGLContext.hxx
+++ b/include/vcl/OpenGLContext.hxx
@@ -10,6 +10,8 @@
#ifndef VCL_OPENGL_CONTEXT_HXX
#define VCL_OPENGL_CONTEXT_HXX
+#include <GL/glew.h>
+
#if defined( MACOSX )
#elif defined( UNX )
# include <prex.h>
@@ -21,8 +23,6 @@
# include "postwin.h"
#endif
-#include <GL/glew.h>
-
#if defined( _WIN32 )
#include <GL/glext.h>
#include <GL/wglext.h>
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index e3feb70..985018b 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -7,7 +7,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <GL/glew.h>
#include <vcl/OpenGLContext.hxx>
#include <vcl/syschild.hxx>
#include <vcl/sysdata.hxx>
commit 3c6327950a6d2039af80f4ed3af84ccaae8facde
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Tue Apr 8 00:34:29 2014 +0200
call glewInit in vcl's OpenGLContext just once
Change-Id: I9f9b50615e588e659c7fcdd016cf9ceb8407b974
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index b9b9125..e3feb70 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -7,6 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <GL/glew.h>
#include <vcl/OpenGLContext.hxx>
#include <vcl/syschild.hxx>
#include <vcl/sysdata.hxx>
@@ -447,6 +448,19 @@ bool OpenGLContext::init( Window* pParent )
#endif
+ static bool bGlewInit = false;
+ if(!bGlewInit)
+ {
+ glewExperimental = GL_TRUE;
+ if (glewInit() != GLEW_OK)
+ {
+ SAL_WARN("vcl.opengl", "Failed to initialize GLEW");
+ return false;
+ }
+ else
+ bGlewInit = true;
+ }
+
SAL_INFO("vcl.opengl", "OpenGLContext::init----end");
mbInitialized = true;
return true;
commit 9bfaa3c3bc14dbfabf3dbfe00426aa2abd416373
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Tue Apr 8 00:30:23 2014 +0200
e temporarily a local OpenGL context
Change-Id: I086d826456d77bf978c3877ed6da92850878ad97
diff --git a/chart2/source/view/charttypes/3DBarChart.cxx b/chart2/source/view/charttypes/3DBarChart.cxx
index 2da54aa..79c02a6 100644
--- a/chart2/source/view/charttypes/3DBarChart.cxx
+++ b/chart2/source/view/charttypes/3DBarChart.cxx
@@ -57,6 +57,7 @@ void Bar3DChart::create3DShapes()
void Bar3DChart::render()
{
+ maContext.init();
for(boost::ptr_vector<opengl3D::Renderable3DObject>::iterator itr = maShapes.begin(),
itrEnd = maShapes.end(); itr != itrEnd; ++itr)
{
diff --git a/chart2/source/view/inc/3DBarChart.hxx b/chart2/source/view/inc/3DBarChart.hxx
index 6eeea5b..0cc5831 100644
--- a/chart2/source/view/inc/3DBarChart.hxx
+++ b/chart2/source/view/inc/3DBarChart.hxx
@@ -11,6 +11,8 @@
#include <boost/ptr_container/ptr_vector.hpp>
#include "VDataSeries.hxx"
+#include <vcl/OpenGLContext.hxx>
+
namespace chart {
namespace opengl3D {
@@ -34,6 +36,7 @@ private:
std::vector<VDataSeries*> maDataSeries;
boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
+ OpenGLContext maContext;
};
}
More information about the Libreoffice-commits
mailing list