[Libreoffice-commits] core.git: 41 commits - chart2/source include/vcl vcl/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Sun May 11 18:04:30 PDT 2014
chart2/source/view/charttypes/GL3DBarChart.cxx | 24 -
chart2/source/view/inc/GL3DRenderer.hxx | 113 +-----
chart2/source/view/inc/StaticGeometry.h | 9
chart2/source/view/main/3DChartObjects.cxx | 13
chart2/source/view/main/GL3DRenderer.cxx | 412 +++----------------------
include/vcl/opengl/OpenGLHelper.hxx | 6
include/vcl/openglwin.hxx | 3
vcl/source/opengl/OpenGLContext.cxx | 20 -
vcl/source/opengl/OpenGLHelper.cxx | 22 +
vcl/source/window/openglwin.cxx | 9
10 files changed, 152 insertions(+), 479 deletions(-)
New commits:
commit 46351c13e9057bbb27bb490f166d8002f86a6025
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Mon May 12 02:57:51 2014 +0200
Revert "separate rounded corner bar and normal bar rendering"
This reverts commit 51d5062642189ff5a4330903253c012e83e5ef1f.
Conflicts:
chart2/source/view/main/GL3DRenderer.cxx
Change-Id: Id21e59d2cc605f0d7d637fb889725f0e91fa6cb3
diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx
index f8138aa..8571fd8 100644
--- a/chart2/source/view/inc/3DChartObjects.hxx
+++ b/chart2/source/view/inc/3DChartObjects.hxx
@@ -37,7 +37,7 @@ protected:
class Bar : public Renderable3DObject
{
public:
- Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 nColor, sal_uInt32 nId);
+ Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_Int32 nColor, sal_uInt32 nId);
virtual void render() SAL_OVERRIDE;
private:
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 7840a02..5337384 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -90,6 +90,7 @@ struct Polygon3DInfo
struct Extrude3DInfo
{
+ bool rounded;
bool twoSidesLighting;
glm::vec4 extrudeColor;
float xScale;
@@ -156,7 +157,7 @@ public:
void EndAddPolygon3DObjectNormalPoint();
void AddPolygon3DObjectPoint(float x, float y, float z);
void EndAddPolygon3DObjectPoint();
- void AddShape3DExtrudeObject(sal_Int32 color, sal_Int32 specular, glm::mat4 modelMatrix);
+ void AddShape3DExtrudeObject(bool roundedCorner, sal_Int32 color, sal_Int32 specular, glm::mat4 modelMatrix);
void EndAddShape3DExtrudeObject();
double GetTime();
void SetFPS(float fps);
@@ -165,8 +166,6 @@ public:
void SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up);
void CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft);
void ProcessUnrenderedShape();
- void RenderNonRoundedBar(const glm::mat4& rModelMatrix, sal_uInt32 nColor);
-
private:
void MoveModelf(PosVecf3& trans,PosVecf3& angle,PosVecf3& scale);
@@ -190,6 +189,7 @@ private:
void AddVertexData(GLuint vertexBuf);
void AddNormalData(GLuint normalBuf);
void AddIndexData(GLuint indexBuf);
+ void RenderNonRoundedBar(const Extrude3DInfo& extrude3D);
bool GetSimilarVertexIndex(PackedVertex & packed,
std::map<PackedVertex,unsigned short> & VertexToOutIndex,
unsigned short & result
diff --git a/chart2/source/view/inc/StaticGeometry.h b/chart2/source/view/inc/StaticGeometry.h
index d3d5926..bdc8fe7 100644
--- a/chart2/source/view/inc/StaticGeometry.h
+++ b/chart2/source/view/inc/StaticGeometry.h
@@ -130,45 +130,6 @@ static GLfloat squareVertices[] = {
-1.0f, 1.0f, -1.0
};
-static const GLfloat cubeVertices[] = {
- -1.0f,-1.0f,-1.0f,
- -1.0f,-1.0f, 1.0f,
- -1.0f, 1.0f, 1.0f,
- 1.0f, 1.0f,-1.0f,
- -1.0f,-1.0f,-1.0f,
- -1.0f, 1.0f,-1.0f,
- 1.0f,-1.0f, 1.0f,
- -1.0f,-1.0f,-1.0f,
- 1.0f,-1.0f,-1.0f,
- 1.0f, 1.0f,-1.0f,
- 1.0f,-1.0f,-1.0f,
- -1.0f,-1.0f,-1.0f,
- -1.0f,-1.0f,-1.0f,
- -1.0f, 1.0f, 1.0f,
- -1.0f, 1.0f,-1.0f,
- 1.0f,-1.0f, 1.0f,
- -1.0f,-1.0f, 1.0f,
- -1.0f,-1.0f,-1.0f,
- -1.0f, 1.0f, 1.0f,
- -1.0f,-1.0f, 1.0f,
- 1.0f,-1.0f, 1.0f,
- 1.0f, 1.0f, 1.0f,
- 1.0f,-1.0f,-1.0f,
- 1.0f, 1.0f,-1.0f,
- 1.0f,-1.0f,-1.0f,
- 1.0f, 1.0f, 1.0f,
- 1.0f,-1.0f, 1.0f,
- 1.0f, 1.0f, 1.0f,
- 1.0f, 1.0f,-1.0f,
- -1.0f, 1.0f,-1.0f,
- 1.0f, 1.0f, 1.0f,
- -1.0f, 1.0f,-1.0f,
- -1.0f, 1.0f, 1.0f,
- 1.0f, 1.0f, 1.0f,
- -1.0f, 1.0f, 1.0f,
- 1.0f,-1.0f, 1.0f
-};
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index aa5d3bc..1c46509 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -28,7 +28,7 @@ void Renderable3DObject::render()
(void) mnUniqueId;
}
-Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 aColor, sal_uInt32 nId)
+Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_Int32 aColor, sal_uInt32 nId)
: Renderable3DObject(pRenderer, nId)
, mbRoundedCorners(true)
, maPos(rPosition)
@@ -39,15 +39,8 @@ Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 aCo
void Bar::render()
{
- if(mbRoundedCorners)
- {
- mpRenderer->AddShape3DExtrudeObject((sal_Int32)maColor.GetColor(), 0xFFFFFF, maPos);
- mpRenderer->EndAddShape3DExtrudeObject();
- }
- else
- {
- mpRenderer->RenderNonRoundedBar(maPos, maColor.GetColor());
- }
+ mpRenderer->AddShape3DExtrudeObject(mbRoundedCorners, (sal_Int32)maColor.GetColor(), 0xFFFFFF, maPos);
+ mpRenderer->EndAddShape3DExtrudeObject();
}
Line::Line(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index e8a5f04..d60d64f 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -919,7 +919,7 @@ void OpenGL3DRenderer::EndAddPolygon3DObjectPoint()
m_Polygon3DInfo.vertices = NULL;
}
-void OpenGL3DRenderer::AddShape3DExtrudeObject(sal_Int32 color,sal_Int32 specular, glm::mat4 modelMatrix)
+void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_Int32 color,sal_Int32 specular, glm::mat4 modelMatrix)
{
glm::vec4 tranform = modelMatrix * glm::vec4(0.0, 0.0, 0.0, 1.0);
glm::vec4 DirX = modelMatrix * glm::vec4(1.0, 0.0, 0.0, 0.0);
@@ -954,7 +954,8 @@ void OpenGL3DRenderer::AddShape3DExtrudeObject(sal_Int32 color,sal_Int32 specula
m_Extrude3DInfo.yTransform = tranform.y;
m_Extrude3DInfo.zTransform = tranform.z;
// m_Extrude3DInfo.zTransform = 0;
- if (m_RoundBarMesh.iMeshSizes == 0)
+ m_Extrude3DInfo.rounded = roundedCorner;
+ if (m_Extrude3DInfo.rounded && (m_RoundBarMesh.iMeshSizes == 0))
{
CreateActualRoundedCube(0.1f, 30, 30, 1.0f, 1.2f, m_Extrude3DInfo.zScale / m_Extrude3DInfo.xScale);
AddVertexData(m_CubeVertexBuf);
@@ -1144,54 +1145,26 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
RenderExtrudeFlatSurface(extrude3D, FLAT_BOTTOM_SURFACE);
}
-namespace {
-
-glm::vec4 getColorAsVector(sal_uInt32 nColor)
+void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D)
{
- sal_uInt8 nRed = sal_uInt8((nColor & 0xFF0000) >> 16);
- sal_uInt8 nGreen = sal_uInt8((nColor & 0xFF00) >> 8);
- sal_uInt8 nBlue = sal_uInt8((nColor & 0xFF));
- sal_uInt8 nAlpha = sal_uInt8((nColor & 0xFF000000) >> 24);
- return glm::vec4(nRed/255.0, nGreen/255.0, nBlue/255.0, nAlpha/255.0);
-}
-
-}
-
-void OpenGL3DRenderer::RenderNonRoundedBar(const glm::mat4& modelMatrix, sal_uInt32 nColor)
-{
- glm::mat4 aMVP = m_3DProjection * m_3DView * modelMatrix;
- SAL_INFO("chart2.3dopengl", "render new bar");
- SAL_INFO("chart2.3dopengl", aMVP);
-
- for(size_t i = 0; i < SAL_N_ELEMENTS(cubeVertices); i += 3)
+ float xScale = extrude3D.xScale;
+ float yScale = extrude3D.yScale;
+ float zScale = extrude3D.zScale;
+ glUniformMatrix4fv(m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
+ glUniformMatrix4fv(m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
+ glm::mat4 transformMatrix = glm::translate(glm::vec3(extrude3D.xTransform, -extrude3D.yTransform, extrude3D.zTransform));
+ glm::mat4 scaleMatrix = glm::scale(xScale, yScale, zScale);
+ m_Model = transformMatrix * extrude3D.rotation * scaleMatrix;
+ if (extrude3D.reverse)
{
- glm::vec4 aPos(cubeVertices[i*3], cubeVertices[i*3+1], cubeVertices[i*3+2], 1.0);
- glm::vec4 aNewPos = aMVP * aPos;
- SAL_INFO("chart2.3dopengl", aNewPos);
+ glm::mat4 reverseMatrix = glm::translate(glm::vec3(0.0, -1.0, 0.0));
+ m_Model = m_Model * reverseMatrix;
}
-
- glm::vec4 aColor = getColorAsVector(nColor);
- glUseProgram(m_CommonProID);
- //fill vertex buffer
- glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
- glBufferData(GL_ARRAY_BUFFER, sizeof(cubeVertices), cubeVertices, GL_STATIC_DRAW);
- glUniform4fv(m_2DColorID, 1, &aColor[0]);
- glUniformMatrix4fv(m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
- // 1rst attribute buffer : vertices
- glEnableVertexAttribArray(m_2DVertexID);
- glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
- glVertexAttribPointer(m_2DVertexID,
- 3, // size
- GL_FLOAT, // type
- GL_FALSE, // normalized?
- 0, // stride
- (void*)0 // array buffer offset
- );
-
+ glm::mat3 normalMatrix(m_Model);
+ glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
+ glUniformMatrix4fv(m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+ glUniformMatrix3fv(m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
glDrawArrays(GL_TRIANGLES, 0, 36);
- glDisableVertexAttribArray(m_2DVertexID);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
- glUseProgram(0);
}
void OpenGL3DRenderer::RenderExtrudeSurface(const Extrude3DInfo& extrude3D)
@@ -1225,8 +1198,8 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
for (size_t i = 0; i < extrude3DNum; i++)
{
Extrude3DInfo extrude3DInfo = m_Extrude3DList[i];
- GLuint vertexBuf = m_CubeVertexBuf;
- GLuint normalBuf = m_CubeNormalBuf;
+ GLuint vertexBuf = extrude3DInfo.rounded ? m_CubeVertexBuf : m_BoundBox;
+ GLuint normalBuf = extrude3DInfo.rounded ? m_CubeNormalBuf : m_BoundBoxNormal;
// 1st attribute buffer : vertices
glEnableVertexAttribArray(m_3DVertexID);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuf);
@@ -1254,8 +1227,15 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
CHECK_GL_ERROR();
glBindBuffer(GL_UNIFORM_BUFFER, 0);
extrude3DInfo.reverse = 0;
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_CubeElementBuf);
- RenderExtrudeSurface(extrude3DInfo);
+ if (extrude3DInfo.rounded)
+ {
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_CubeElementBuf);
+ RenderExtrudeSurface(extrude3DInfo);
+ }
+ else
+ {
+ RenderNonRoundedBar(extrude3DInfo);
+ }
glDisableVertexAttribArray(m_3DVertexID);
glDisableVertexAttribArray(m_3DNormalID);
}
commit 2124f55b5371c421c3c1793fc740921adda3dfac
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Mon May 12 02:55:06 2014 +0200
Revert "fix alpha calculation"
This reverts commit 204efb6a1723f98ff53a61ed249dbff8cb391bb3.
Change-Id: I1756c399adbf0dd3371e8aab1d8021931203c49e
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 58e5e20..e8a5f04 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -327,12 +327,10 @@ void OpenGL3DRenderer::CreateActualRoundedCube(float fRadius, int iSubDivY, int
m_RoundBarMesh.topThreshold = topThreshold;
m_RoundBarMesh.bottomThreshold = bottomThreshold;
m_RoundBarMesh.iMeshStartIndices = m_Vertices.size();
-
for (int k = 0; k < 5; k++)
{
m_RoundBarMesh.iElementStartIndices[k] = indeices[k].size();
}
-
for (size_t i = 0; i < vertices.size(); i += 3)
{
for (int k = 0; k < 3; k++)
@@ -409,12 +407,9 @@ int OpenGL3DRenderer::GenerateRoundCornerBar(std::vector<glm::vec3> &vertices, s
{
fNextAngleY = 360.0f;
}
- float fSineY = sin(fCurAngleY/180.0f*PI);
- float fCosY = cos(fCurAngleY/180.0f*PI);
- float fNextSineY = sin(fNextAngleY/180.0f*PI);
- float fNextCosY = cos(fNextAngleY/180.0f*PI);
- glm::vec3 vDirY(fCosY, 0.0f, -fSineY);
- glm::vec3 vNextDirY(fNextCosY, 0.0f, -fNextSineY);
+ float fSineY = sin(fCurAngleY/180.0f*PI), fCosY = cos(fCurAngleY/180.0f*PI);
+ float fNextSineY = sin(fNextAngleY/180.0f*PI), fNextCosY = cos(fNextAngleY/180.0f*PI);
+ glm::vec3 vDirY(fCosY, 0.0f, -fSineY), vNextDirY(fNextCosY, 0.0f, -fNextSineY);
float fCurAngleZ = 0.0f;
int iStepsZ = 1;
int xzIndex = 0;
@@ -434,7 +429,6 @@ int OpenGL3DRenderer::GenerateRoundCornerBar(std::vector<glm::vec3> &vertices, s
{
xzIndex = 3;
}
-
while(iStepsZ <= iSubDivZ)
{
int yIndex = 0;
@@ -481,7 +475,6 @@ int OpenGL3DRenderer::GenerateRoundCornerBar(std::vector<glm::vec3> &vertices, s
glm::normalize(vQuadPoints[2]),
glm::normalize(vQuadPoints[3])
};
-
for (int i = 0; i < 6; i++)
{
int index = iIndices[i];
@@ -1159,7 +1152,7 @@ glm::vec4 getColorAsVector(sal_uInt32 nColor)
sal_uInt8 nGreen = sal_uInt8((nColor & 0xFF00) >> 8);
sal_uInt8 nBlue = sal_uInt8((nColor & 0xFF));
sal_uInt8 nAlpha = sal_uInt8((nColor & 0xFF000000) >> 24);
- return glm::vec4(nRed/255.0, nGreen/255.0, nBlue/255.0, (0xFF - nAlpha)/255.0);
+ return glm::vec4(nRed/255.0, nGreen/255.0, nBlue/255.0, nAlpha/255.0);
}
}
@@ -1172,16 +1165,12 @@ void OpenGL3DRenderer::RenderNonRoundedBar(const glm::mat4& modelMatrix, sal_uIn
for(size_t i = 0; i < SAL_N_ELEMENTS(cubeVertices); i += 3)
{
- glm::vec4 aPos(cubeVertices[i], cubeVertices[i+1], cubeVertices[i+2], 1.0);
- SAL_INFO("chart2.3dopengl", aPos);
- glm::vec4 aWorldPos = modelMatrix * aPos;
- SAL_INFO("chart2.3dopengl", aWorldPos);
+ glm::vec4 aPos(cubeVertices[i*3], cubeVertices[i*3+1], cubeVertices[i*3+2], 1.0);
glm::vec4 aNewPos = aMVP * aPos;
SAL_INFO("chart2.3dopengl", aNewPos);
}
glm::vec4 aColor = getColorAsVector(nColor);
- SAL_INFO("chart2.3dopengl", "Color: " << aColor);
glUseProgram(m_CommonProID);
//fill vertex buffer
glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
commit 5b7dfb07e3b167e8b6626f5d872abb8d3c8b5dd2
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sun May 11 18:04:01 2014 +0200
move glm operator<< for debugging to OpenGLHelper
Change-Id: Ia529badffe08507d593f494230d2e504b68ff477
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index 202eb97..aa5d3bc 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -11,31 +11,12 @@
#include <vcl/virdev.hxx>
#include <vcl/svapp.hxx>
-#include <ostream>
+#include <vcl/opengl/OpenGLHelper.hxx>
namespace chart {
namespace opengl3D {
-namespace {
-
-std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix)
-{
- for(int i = 0; i < 4; ++i)
- {
- rStrm << "( ";
- for(int j = 0; j < 4; ++j)
- {
- rStrm << rMatrix[j][i];
- rStrm << " ";
- }
- rStrm << ")\n";
- }
- return rStrm;
-}
-
-}
-
Renderable3DObject::Renderable3DObject(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
mpRenderer(pRenderer),
mnUniqueId(nId)
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 56a421e..58e5e20 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1162,27 +1162,6 @@ glm::vec4 getColorAsVector(sal_uInt32 nColor)
return glm::vec4(nRed/255.0, nGreen/255.0, nBlue/255.0, (0xFF - nAlpha)/255.0);
}
-std::ostream& operator<<(std::ostream& rStrm, const glm::vec4& rPos)
-{
- rStrm << "( " << rPos[0] << ", " << rPos[1] << ", " << rPos[2] << ", " << rPos[3] << ")";
- return rStrm;
-}
-
-std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix)
-{
- for(int i = 0; i < 4; ++i)
- {
- rStrm << "\n( ";
- for(int j = 0; j < 4; ++j)
- {
- rStrm << rMatrix[j][i];
- rStrm << " ";
- }
- rStrm << ")\n";
- }
- return rStrm;
-}
-
}
void OpenGL3DRenderer::RenderNonRoundedBar(const glm::mat4& modelMatrix, sal_uInt32 nColor)
diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx
index 4afeae4..3cb482b 100644
--- a/include/vcl/opengl/OpenGLHelper.hxx
+++ b/include/vcl/opengl/OpenGLHelper.hxx
@@ -11,11 +11,14 @@
#define INCLUDED_VCL_OPENGL_OPENGLHELPER_HXX
#include <GL/glew.h>
+#include "glm/glm.hpp"
#include <vcl/vclopengl_dllapi.hxx>
#include <vcl/bitmapex.hxx>
#include <rtl/ustring.hxx>
+#include <ostream>
+
class VCLOPENGL_DLLPUBLIC OpenGLHelper
{
public:
@@ -28,6 +31,9 @@ public:
static const char* GLErrorString(GLenum errorCode);
};
+VCLOPENGL_DLLPUBLIC std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix);
+VCLOPENGL_DLLPUBLIC std::ostream& operator<<(std::ostream& rStrm, const glm::vec4& rPos);
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 4ef2ce0..0e9d710 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -247,4 +247,26 @@ const char* OpenGLHelper::GLErrorString(GLenum errorCode)
return NULL;
}
+std::ostream& operator<<(std::ostream& rStrm, const glm::vec4& rPos)
+{
+ rStrm << "( " << rPos[0] << ", " << rPos[1] << ", " << rPos[2] << ", " << rPos[3] << ")";
+ return rStrm;
+}
+
+std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix)
+{
+ for(int i = 0; i < 4; ++i)
+ {
+ rStrm << "\n( ";
+ for(int j = 0; j < 4; ++j)
+ {
+ rStrm << rMatrix[j][i];
+ rStrm << " ";
+ }
+ rStrm << ")\n";
+ }
+ return rStrm;
+}
+
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit ca4c75ae7c0326c86e79532649a6a8c1bcbd5ce4
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sun May 11 17:57:54 2014 +0200
fix alpha calculation
Change-Id: Ic0734ef9a079196d9a0a523dac7726937ed2155f
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 9afd1b7..56a421e 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1159,7 +1159,7 @@ glm::vec4 getColorAsVector(sal_uInt32 nColor)
sal_uInt8 nGreen = sal_uInt8((nColor & 0xFF00) >> 8);
sal_uInt8 nBlue = sal_uInt8((nColor & 0xFF));
sal_uInt8 nAlpha = sal_uInt8((nColor & 0xFF000000) >> 24);
- return glm::vec4(nRed/255.0, nGreen/255.0, nBlue/255.0, nAlpha/255.0);
+ return glm::vec4(nRed/255.0, nGreen/255.0, nBlue/255.0, (0xFF - nAlpha)/255.0);
}
std::ostream& operator<<(std::ostream& rStrm, const glm::vec4& rPos)
commit 5cad8bbc9988ab059eea09dd35ba87e7e7525431
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sun May 11 17:56:12 2014 +0200
a few debug statements and cosmetic clean-up
Change-Id: I78cc73cc792f1182abcac0b81e97b948206a11d8
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 636b015..9afd1b7 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -327,10 +327,12 @@ void OpenGL3DRenderer::CreateActualRoundedCube(float fRadius, int iSubDivY, int
m_RoundBarMesh.topThreshold = topThreshold;
m_RoundBarMesh.bottomThreshold = bottomThreshold;
m_RoundBarMesh.iMeshStartIndices = m_Vertices.size();
+
for (int k = 0; k < 5; k++)
{
m_RoundBarMesh.iElementStartIndices[k] = indeices[k].size();
}
+
for (size_t i = 0; i < vertices.size(); i += 3)
{
for (int k = 0; k < 3; k++)
@@ -407,9 +409,12 @@ int OpenGL3DRenderer::GenerateRoundCornerBar(std::vector<glm::vec3> &vertices, s
{
fNextAngleY = 360.0f;
}
- float fSineY = sin(fCurAngleY/180.0f*PI), fCosY = cos(fCurAngleY/180.0f*PI);
- float fNextSineY = sin(fNextAngleY/180.0f*PI), fNextCosY = cos(fNextAngleY/180.0f*PI);
- glm::vec3 vDirY(fCosY, 0.0f, -fSineY), vNextDirY(fNextCosY, 0.0f, -fNextSineY);
+ float fSineY = sin(fCurAngleY/180.0f*PI);
+ float fCosY = cos(fCurAngleY/180.0f*PI);
+ float fNextSineY = sin(fNextAngleY/180.0f*PI);
+ float fNextCosY = cos(fNextAngleY/180.0f*PI);
+ glm::vec3 vDirY(fCosY, 0.0f, -fSineY);
+ glm::vec3 vNextDirY(fNextCosY, 0.0f, -fNextSineY);
float fCurAngleZ = 0.0f;
int iStepsZ = 1;
int xzIndex = 0;
@@ -429,6 +434,7 @@ int OpenGL3DRenderer::GenerateRoundCornerBar(std::vector<glm::vec3> &vertices, s
{
xzIndex = 3;
}
+
while(iStepsZ <= iSubDivZ)
{
int yIndex = 0;
@@ -475,6 +481,7 @@ int OpenGL3DRenderer::GenerateRoundCornerBar(std::vector<glm::vec3> &vertices, s
glm::normalize(vQuadPoints[2]),
glm::normalize(vQuadPoints[3])
};
+
for (int i = 0; i < 6; i++)
{
int index = iIndices[i];
@@ -930,7 +937,7 @@ void OpenGL3DRenderer::AddShape3DExtrudeObject(sal_Int32 color,sal_Int32 specula
m_Extrude3DInfo.zScale = glm::length(DirY);
glm::mat4 transformMatrixInverse = glm::inverse(glm::translate(glm::vec3(tranform)));
glm::mat4 scaleMatrixInverse = glm::inverse(glm::scale(m_Extrude3DInfo.xScale, m_Extrude3DInfo.zScale, m_Extrude3DInfo.yScale));
- //m_Extrude3DInfo.rotation = transformMatrixInverse * modelMatrix * scaleMatrixInverse;
+ m_Extrude3DInfo.rotation = transformMatrixInverse * modelMatrix * scaleMatrixInverse;
//color
m_Extrude3DInfo.extrudeColor = glm::vec4((float)(((color) & 0x00FF0000) >> 16) / 255.0f,
@@ -1165,7 +1172,7 @@ std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix)
{
for(int i = 0; i < 4; ++i)
{
- rStrm << "( ";
+ rStrm << "\n( ";
for(int j = 0; j < 4; ++j)
{
rStrm << rMatrix[j][i];
@@ -1186,12 +1193,16 @@ void OpenGL3DRenderer::RenderNonRoundedBar(const glm::mat4& modelMatrix, sal_uIn
for(size_t i = 0; i < SAL_N_ELEMENTS(cubeVertices); i += 3)
{
- glm::vec4 aPos(cubeVertices[i*3], cubeVertices[i*3+1], cubeVertices[i*3+2], 1.0);
+ glm::vec4 aPos(cubeVertices[i], cubeVertices[i+1], cubeVertices[i+2], 1.0);
+ SAL_INFO("chart2.3dopengl", aPos);
+ glm::vec4 aWorldPos = modelMatrix * aPos;
+ SAL_INFO("chart2.3dopengl", aWorldPos);
glm::vec4 aNewPos = aMVP * aPos;
SAL_INFO("chart2.3dopengl", aNewPos);
}
glm::vec4 aColor = getColorAsVector(nColor);
+ SAL_INFO("chart2.3dopengl", "Color: " << aColor);
glUseProgram(m_CommonProID);
//fill vertex buffer
glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
commit bc9d2f80c373e0ed22ba643964fe1b13c3169b40
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sun May 11 17:55:16 2014 +0200
a few changes to camera position and bar positioning
Change-Id: I256e6855735bea050507c894f91ed895da0e13ba
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index eabc36a..a5d4a36 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -68,7 +68,7 @@ void GL3DBarChart::create3DShapes()
for (boost::ptr_vector<VDataSeries>::const_iterator itr = maDataSeries.begin(),
itrEnd = maDataSeries.end(); itr != itrEnd; ++itr)
{
- nYPos = nSeriesIndex * (nBarSizeY + nBarDistanceY);
+ nYPos = nSeriesIndex * (nBarSizeY + nBarDistanceY) + nBarSizeY;
const VDataSeries& rDataSeries = *itr;
sal_Int32 nPointCount = rDataSeries.getTotalPointCount();
@@ -93,11 +93,11 @@ void GL3DBarChart::create3DShapes()
for(sal_Int32 nIndex = 0; nIndex < nPointCount; ++nIndex)
{
float nVal = rDataSeries.getYValue(nIndex);
- float nXPos = nIndex * (nBarSizeX + nBarDistanceX);
+ float nXPos = nIndex * (nBarSizeX + nBarDistanceX) + nBarSizeX;
glm::mat4 aScaleMatrix = glm::scale(nBarSizeX, nBarSizeY, nVal);
- glm::mat4 aTranslationMatrix = glm::translate(nXPos, nYPos, nVal/2);
+ glm::mat4 aTranslationMatrix = glm::translate(nXPos, nYPos, nVal);
glm::mat4 aBarPosition = aTranslationMatrix * aScaleMatrix;
maShapes.push_back(new opengl3D::Bar(mpRenderer.get(), aBarPosition, nColor, nId++));
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index 0aeec40..202eb97 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -49,7 +49,7 @@ void Renderable3DObject::render()
Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 aColor, sal_uInt32 nId)
: Renderable3DObject(pRenderer, nId)
- , mbRoundedCorners(false)
+ , mbRoundedCorners(true)
, maPos(rPosition)
, maColor(aColor)
{
@@ -185,7 +185,7 @@ Camera::Camera(OpenGL3DRenderer* pRenderer):
Renderable3DObject(pRenderer, 0),
maPos(10,-50,20),
maUp(0, 0, 1),
- maDirection(glm::vec3(0,1,-0.5))
+ maDirection(glm::vec3(0,0,0))
{
}
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index c92d878..636b015 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -136,7 +136,7 @@ void OpenGL3DRenderer::LoadShaders()
void OpenGL3DRenderer::SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up)
{
m_CameraInfo.cameraPos = pos;
- m_CameraInfo.cameraOrg = pos + direction;
+ m_CameraInfo.cameraOrg = direction;
m_CameraInfo.cameraUp = up;
}
@@ -212,7 +212,7 @@ void OpenGL3DRenderer::init()
glBufferData(GL_ARRAY_BUFFER, sizeof(boundBoxNormal), boundBoxNormal, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
- m_fViewAngle = 30.0f;
+ m_fViewAngle = 60.0f;
m_3DProjection = glm::perspective(m_fViewAngle, (float)m_iWidth / (float)m_iHeight, 0.01f, 2000.0f);
LoadShaders();
glGenBuffers(1, &m_TextTexCoordBuf);
@@ -930,7 +930,8 @@ void OpenGL3DRenderer::AddShape3DExtrudeObject(sal_Int32 color,sal_Int32 specula
m_Extrude3DInfo.zScale = glm::length(DirY);
glm::mat4 transformMatrixInverse = glm::inverse(glm::translate(glm::vec3(tranform)));
glm::mat4 scaleMatrixInverse = glm::inverse(glm::scale(m_Extrude3DInfo.xScale, m_Extrude3DInfo.zScale, m_Extrude3DInfo.yScale));
- m_Extrude3DInfo.rotation = transformMatrixInverse * modelMatrix * scaleMatrixInverse;
+ //m_Extrude3DInfo.rotation = transformMatrixInverse * modelMatrix * scaleMatrixInverse;
+
//color
m_Extrude3DInfo.extrudeColor = glm::vec4((float)(((color) & 0x00FF0000) >> 16) / 255.0f,
(float)(((color) & 0x0000FF00) >> 8) / 255.0f,
@@ -1443,10 +1444,9 @@ void OpenGL3DRenderer::RenderClickPos(Point aMPos)
void OpenGL3DRenderer::CreateSceneBoxView()
{
- m_3DView = glm::lookAt(m_CameraInfo.cameraPos, // Camera is at (0,0,3), in World Space
- m_CameraInfo.cameraOrg, // and looks at the origin
- m_CameraInfo.cameraUp // Head is up (set to 0,-1,0 to look upside-down)
- );
+ m_3DView = glm::lookAt(m_CameraInfo.cameraPos,
+ m_CameraInfo.cameraOrg,
+ m_CameraInfo.cameraUp);
}
void OpenGL3DRenderer::ProcessUnrenderedShape()
commit 5c799db571e4bb911a32e0e3a9b4bb244015b53b
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sun May 11 06:11:01 2014 +0200
separate rounded corner bar and normal bar rendering
This makes it much easier to debug problems.
Change-Id: I0ba10f6d24cca54be724639074bfd3fac59d37e5
diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx
index 8571fd8..f8138aa 100644
--- a/chart2/source/view/inc/3DChartObjects.hxx
+++ b/chart2/source/view/inc/3DChartObjects.hxx
@@ -37,7 +37,7 @@ protected:
class Bar : public Renderable3DObject
{
public:
- Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_Int32 nColor, sal_uInt32 nId);
+ Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 nColor, sal_uInt32 nId);
virtual void render() SAL_OVERRIDE;
private:
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 5337384..7840a02 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -90,7 +90,6 @@ struct Polygon3DInfo
struct Extrude3DInfo
{
- bool rounded;
bool twoSidesLighting;
glm::vec4 extrudeColor;
float xScale;
@@ -157,7 +156,7 @@ public:
void EndAddPolygon3DObjectNormalPoint();
void AddPolygon3DObjectPoint(float x, float y, float z);
void EndAddPolygon3DObjectPoint();
- void AddShape3DExtrudeObject(bool roundedCorner, sal_Int32 color, sal_Int32 specular, glm::mat4 modelMatrix);
+ void AddShape3DExtrudeObject(sal_Int32 color, sal_Int32 specular, glm::mat4 modelMatrix);
void EndAddShape3DExtrudeObject();
double GetTime();
void SetFPS(float fps);
@@ -166,6 +165,8 @@ public:
void SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up);
void CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft);
void ProcessUnrenderedShape();
+ void RenderNonRoundedBar(const glm::mat4& rModelMatrix, sal_uInt32 nColor);
+
private:
void MoveModelf(PosVecf3& trans,PosVecf3& angle,PosVecf3& scale);
@@ -189,7 +190,6 @@ private:
void AddVertexData(GLuint vertexBuf);
void AddNormalData(GLuint normalBuf);
void AddIndexData(GLuint indexBuf);
- void RenderNonRoundedBar(const Extrude3DInfo& extrude3D);
bool GetSimilarVertexIndex(PackedVertex & packed,
std::map<PackedVertex,unsigned short> & VertexToOutIndex,
unsigned short & result
diff --git a/chart2/source/view/inc/StaticGeometry.h b/chart2/source/view/inc/StaticGeometry.h
index bdc8fe7..d3d5926 100644
--- a/chart2/source/view/inc/StaticGeometry.h
+++ b/chart2/source/view/inc/StaticGeometry.h
@@ -130,6 +130,45 @@ static GLfloat squareVertices[] = {
-1.0f, 1.0f, -1.0
};
+static const GLfloat cubeVertices[] = {
+ -1.0f,-1.0f,-1.0f,
+ -1.0f,-1.0f, 1.0f,
+ -1.0f, 1.0f, 1.0f,
+ 1.0f, 1.0f,-1.0f,
+ -1.0f,-1.0f,-1.0f,
+ -1.0f, 1.0f,-1.0f,
+ 1.0f,-1.0f, 1.0f,
+ -1.0f,-1.0f,-1.0f,
+ 1.0f,-1.0f,-1.0f,
+ 1.0f, 1.0f,-1.0f,
+ 1.0f,-1.0f,-1.0f,
+ -1.0f,-1.0f,-1.0f,
+ -1.0f,-1.0f,-1.0f,
+ -1.0f, 1.0f, 1.0f,
+ -1.0f, 1.0f,-1.0f,
+ 1.0f,-1.0f, 1.0f,
+ -1.0f,-1.0f, 1.0f,
+ -1.0f,-1.0f,-1.0f,
+ -1.0f, 1.0f, 1.0f,
+ -1.0f,-1.0f, 1.0f,
+ 1.0f,-1.0f, 1.0f,
+ 1.0f, 1.0f, 1.0f,
+ 1.0f,-1.0f,-1.0f,
+ 1.0f, 1.0f,-1.0f,
+ 1.0f,-1.0f,-1.0f,
+ 1.0f, 1.0f, 1.0f,
+ 1.0f,-1.0f, 1.0f,
+ 1.0f, 1.0f, 1.0f,
+ 1.0f, 1.0f,-1.0f,
+ -1.0f, 1.0f,-1.0f,
+ 1.0f, 1.0f, 1.0f,
+ -1.0f, 1.0f,-1.0f,
+ -1.0f, 1.0f, 1.0f,
+ 1.0f, 1.0f, 1.0f,
+ -1.0f, 1.0f, 1.0f,
+ 1.0f,-1.0f, 1.0f
+};
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index f46933e..0aeec40 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -47,9 +47,9 @@ void Renderable3DObject::render()
(void) mnUniqueId;
}
-Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_Int32 aColor, sal_uInt32 nId)
+Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 aColor, sal_uInt32 nId)
: Renderable3DObject(pRenderer, nId)
- , mbRoundedCorners(true)
+ , mbRoundedCorners(false)
, maPos(rPosition)
, maColor(aColor)
{
@@ -58,8 +58,15 @@ Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_Int32 aCol
void Bar::render()
{
- mpRenderer->AddShape3DExtrudeObject(mbRoundedCorners, (sal_Int32)maColor.GetColor(), 0xFFFFFF, maPos);
- mpRenderer->EndAddShape3DExtrudeObject();
+ if(mbRoundedCorners)
+ {
+ mpRenderer->AddShape3DExtrudeObject((sal_Int32)maColor.GetColor(), 0xFFFFFF, maPos);
+ mpRenderer->EndAddShape3DExtrudeObject();
+ }
+ else
+ {
+ mpRenderer->RenderNonRoundedBar(maPos, maColor.GetColor());
+ }
}
Line::Line(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index e8de12b..c92d878 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -919,7 +919,7 @@ void OpenGL3DRenderer::EndAddPolygon3DObjectPoint()
m_Polygon3DInfo.vertices = NULL;
}
-void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_Int32 color,sal_Int32 specular, glm::mat4 modelMatrix)
+void OpenGL3DRenderer::AddShape3DExtrudeObject(sal_Int32 color,sal_Int32 specular, glm::mat4 modelMatrix)
{
glm::vec4 tranform = modelMatrix * glm::vec4(0.0, 0.0, 0.0, 1.0);
glm::vec4 DirX = modelMatrix * glm::vec4(1.0, 0.0, 0.0, 0.0);
@@ -953,8 +953,7 @@ void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_Int32 col
m_Extrude3DInfo.yTransform = tranform.y;
m_Extrude3DInfo.zTransform = tranform.z;
// m_Extrude3DInfo.zTransform = 0;
- m_Extrude3DInfo.rounded = roundedCorner;
- if (m_Extrude3DInfo.rounded && (m_RoundBarMesh.iMeshSizes == 0))
+ if (m_RoundBarMesh.iMeshSizes == 0)
{
CreateActualRoundedCube(0.1f, 30, 30, 1.0f, 1.2f, m_Extrude3DInfo.zScale / m_Extrude3DInfo.xScale);
AddVertexData(m_CubeVertexBuf);
@@ -1144,26 +1143,75 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
RenderExtrudeFlatSurface(extrude3D, FLAT_BOTTOM_SURFACE);
}
-void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D)
+namespace {
+
+glm::vec4 getColorAsVector(sal_uInt32 nColor)
{
- float xScale = extrude3D.xScale;
- float yScale = extrude3D.yScale;
- float zScale = extrude3D.zScale;
- glUniformMatrix4fv(m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
- glUniformMatrix4fv(m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
- glm::mat4 transformMatrix = glm::translate(glm::vec3(extrude3D.xTransform, -extrude3D.yTransform, extrude3D.zTransform));
- glm::mat4 scaleMatrix = glm::scale(xScale, yScale, zScale);
- m_Model = transformMatrix * extrude3D.rotation * scaleMatrix;
- if (extrude3D.reverse)
+ sal_uInt8 nRed = sal_uInt8((nColor & 0xFF0000) >> 16);
+ sal_uInt8 nGreen = sal_uInt8((nColor & 0xFF00) >> 8);
+ sal_uInt8 nBlue = sal_uInt8((nColor & 0xFF));
+ sal_uInt8 nAlpha = sal_uInt8((nColor & 0xFF000000) >> 24);
+ return glm::vec4(nRed/255.0, nGreen/255.0, nBlue/255.0, nAlpha/255.0);
+}
+
+std::ostream& operator<<(std::ostream& rStrm, const glm::vec4& rPos)
+{
+ rStrm << "( " << rPos[0] << ", " << rPos[1] << ", " << rPos[2] << ", " << rPos[3] << ")";
+ return rStrm;
+}
+
+std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix)
+{
+ for(int i = 0; i < 4; ++i)
{
- glm::mat4 reverseMatrix = glm::translate(glm::vec3(0.0, -1.0, 0.0));
- m_Model = m_Model * reverseMatrix;
+ rStrm << "( ";
+ for(int j = 0; j < 4; ++j)
+ {
+ rStrm << rMatrix[j][i];
+ rStrm << " ";
+ }
+ rStrm << ")\n";
}
- glm::mat3 normalMatrix(m_Model);
- glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
- glUniformMatrix4fv(m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
- glUniformMatrix3fv(m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+ return rStrm;
+}
+
+}
+
+void OpenGL3DRenderer::RenderNonRoundedBar(const glm::mat4& modelMatrix, sal_uInt32 nColor)
+{
+ glm::mat4 aMVP = m_3DProjection * m_3DView * modelMatrix;
+ SAL_INFO("chart2.3dopengl", "render new bar");
+ SAL_INFO("chart2.3dopengl", aMVP);
+
+ for(size_t i = 0; i < SAL_N_ELEMENTS(cubeVertices); i += 3)
+ {
+ glm::vec4 aPos(cubeVertices[i*3], cubeVertices[i*3+1], cubeVertices[i*3+2], 1.0);
+ glm::vec4 aNewPos = aMVP * aPos;
+ SAL_INFO("chart2.3dopengl", aNewPos);
+ }
+
+ glm::vec4 aColor = getColorAsVector(nColor);
+ glUseProgram(m_CommonProID);
+ //fill vertex buffer
+ glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(cubeVertices), cubeVertices, GL_STATIC_DRAW);
+ glUniform4fv(m_2DColorID, 1, &aColor[0]);
+ glUniformMatrix4fv(m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
+ // 1rst attribute buffer : vertices
+ glEnableVertexAttribArray(m_2DVertexID);
+ glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
+ glVertexAttribPointer(m_2DVertexID,
+ 3, // size
+ GL_FLOAT, // type
+ GL_FALSE, // normalized?
+ 0, // stride
+ (void*)0 // array buffer offset
+ );
+
glDrawArrays(GL_TRIANGLES, 0, 36);
+ glDisableVertexAttribArray(m_2DVertexID);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ glUseProgram(0);
}
void OpenGL3DRenderer::RenderExtrudeSurface(const Extrude3DInfo& extrude3D)
@@ -1197,8 +1245,8 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
for (size_t i = 0; i < extrude3DNum; i++)
{
Extrude3DInfo extrude3DInfo = m_Extrude3DList[i];
- GLuint vertexBuf = extrude3DInfo.rounded ? m_CubeVertexBuf : m_BoundBox;
- GLuint normalBuf = extrude3DInfo.rounded ? m_CubeNormalBuf : m_BoundBoxNormal;
+ GLuint vertexBuf = m_CubeVertexBuf;
+ GLuint normalBuf = m_CubeNormalBuf;
// 1st attribute buffer : vertices
glEnableVertexAttribArray(m_3DVertexID);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuf);
@@ -1226,15 +1274,8 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
CHECK_GL_ERROR();
glBindBuffer(GL_UNIFORM_BUFFER, 0);
extrude3DInfo.reverse = 0;
- if (extrude3DInfo.rounded)
- {
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_CubeElementBuf);
- RenderExtrudeSurface(extrude3DInfo);
- }
- else
- {
- RenderNonRoundedBar(extrude3DInfo);
- }
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_CubeElementBuf);
+ RenderExtrudeSurface(extrude3DInfo);
glDisableVertexAttribArray(m_3DVertexID);
glDisableVertexAttribArray(m_3DNormalID);
}
commit 906672eb43fcef95a53a0a825628018752ff2c00
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sun May 11 05:26:02 2014 +0200
this does not need to be a member variable
Change-Id: I9be286f8e10d43c8c5ce89bb6b52ebddce48bb6b
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 242cb52..5337384 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -235,8 +235,6 @@ private:
glm::mat4 m_3DMVP;
- glm::mat4 m_TranslationMatrix;
-
GLint m_3DProID;
GLuint m_3DProjectionID;
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 87248d0..e8de12b 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -62,8 +62,7 @@ GLfloat texCoords[] = {
}
OpenGL3DRenderer::OpenGL3DRenderer():
- m_TranslationMatrix(glm::translate(m_Model, glm::vec3(0.0f, 0.0f, 0.0f)))
- , m_TextProID(0)
+ m_TextProID(0)
, m_TextMatrixID(0)
, m_TextVertexID(0)
, m_TextTexCoordID(0)
@@ -1030,9 +1029,9 @@ void OpenGL3DRenderer::RenderExtrudeFlatSurface(const Extrude3DInfo& extrude3D,
PosVecf3 trans = {extrude3D.xTransform,//m_Extrude3DInfo.xTransform + 140,
-extrude3D.yTransform,
extrude3D.zTransform};
- m_TranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
+ glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
glm::mat4 flatScale = glm::scale(xzScale, xzScale, xzScale);
- m_Model = m_TranslationMatrix * extrude3D.rotation * flatScale;
+ m_Model = aTranslationMatrix * extrude3D.rotation * flatScale;
glm::mat3 normalMatrix(m_Model);
glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
glUniformMatrix4fv(m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
@@ -1063,8 +1062,8 @@ void OpenGL3DRenderer::RenderExtrudeBottomSurface(const Extrude3DInfo& extrude3D
{
glm::mat4 topTrans = glm::translate(glm::vec3(0.0, -actualYTrans, 0.0));
glm::mat4 topScale = glm::scale(xzScale, xzScale, xzScale);
- m_TranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
- m_Model = m_TranslationMatrix * extrude3D.rotation * topTrans * topScale;
+ glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
+ m_Model = aTranslationMatrix * extrude3D.rotation * topTrans * topScale;
}
glm::mat3 normalMatrix(m_Model);
glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
@@ -1092,8 +1091,8 @@ void OpenGL3DRenderer::RenderExtrudeMiddleSurface(const Extrude3DInfo& extrude3D
else
{
glm::mat4 scale = glm::scale(xzScale, actualYScale, xzScale);
- m_TranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
- m_Model = m_TranslationMatrix * extrude3D.rotation * scale;
+ glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
+ m_Model = aTranslationMatrix * extrude3D.rotation * scale;
}
if (extrude3D.reverse)
@@ -1125,8 +1124,8 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
glm::mat4 orgTrans = glm::translate(glm::vec3(0.0, -1.0, 0.0));
glm::mat4 scale = glm::scale(xzScale, yScale, xzScale);
//MoveModelf(trans, angle, scale);
- m_TranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
- m_Model = m_TranslationMatrix * extrude3D.rotation * scale * orgTrans;
+ glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
+ m_Model = aTranslationMatrix * extrude3D.rotation * scale * orgTrans;
}
else
{
@@ -1134,8 +1133,8 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
glm::mat4 orgTrans = glm::translate(glm::vec3(0.0, -1.0, 0.0));
glm::mat4 topTrans = glm::translate(glm::vec3(0.0, actualYTrans, 0.0));
glm::mat4 topScale = glm::scale(xzScale, xzScale, xzScale);
- m_TranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
- m_Model = m_TranslationMatrix * extrude3D.rotation * topTrans * topScale * orgTrans;
+ glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
+ m_Model = aTranslationMatrix * extrude3D.rotation * topTrans * topScale * orgTrans;
}
glm::mat3 normalMatrix(m_Model);
glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
commit 3b367b5453b24949374154ecbb1f13276df469f6
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sun May 11 05:14:02 2014 +0200
remove unused methods
Change-Id: Id518c6a253f72cf062754fe6ff65c5041e41cc27
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 8ceae53..242cb52 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -117,15 +117,6 @@ struct CameraInfo
cameraUp(glm::vec3(0, 0, 1)) {}
};
-struct CoordinateAxisInfo
-{
- int pickingFlg;
- int reverse;
- glm::vec4 color;
- PosVecf3 trans;
- PosVecf3 scale;
-};
-
struct RoundBarMesh
{
float topThreshold;
@@ -195,9 +186,6 @@ private:
void RenderExtrudeMiddleSurface(const Extrude3DInfo& extrude3D);
void RenderExtrudeBottomSurface(const Extrude3DInfo& extrude3D);
void RenderExtrudeFlatSurface(const Extrude3DInfo& extrude3D, int surIndex);
- glm::vec4 GetColorByIndex(int index);
- sal_uInt32 GetIndexByColor(sal_uInt32 r, sal_uInt32 g, sal_uInt32 b);
- void RenderCoordinateAxis();
void AddVertexData(GLuint vertexBuf);
void AddNormalData(GLuint normalBuf);
void AddIndexData(GLuint indexBuf);
@@ -226,16 +214,11 @@ private:
glm::mat4 m_Model;
// Our ModelViewProjection : multiplication of our 3 matrices
glm::mat4 m_MVP;
-#if 0
- double m_dFreq;
-#endif
sal_Int32 m_iWidth;
sal_Int32 m_iHeight;
- float m_fZmax;
-
GlobalLights m_LightsInfo;
CameraInfo m_CameraInfo;
@@ -292,12 +275,6 @@ private:
GLuint m_CubeNormalBuf;
- bool m_bCameraUpdated;
-
- float m_fFPS;
-
- Point m_aMPos;
-
GLuint m_BoundBox;
GLuint m_BoundBoxNormal;
// add for text
@@ -309,12 +286,8 @@ private:
GLuint m_TextTexCoordBuf;
GLint m_TextTexID;
- GLuint m_CoordinateBuf;
-
int m_uiSelectFrameCounter;
- CoordinateAxisInfo m_coordinateAxisinfo;
-
std::vector<glm::vec3> m_Vertices;
std::vector<glm::vec3> m_Normals;
diff --git a/chart2/source/view/inc/StaticGeometry.h b/chart2/source/view/inc/StaticGeometry.h
index e734ade..bdc8fe7 100644
--- a/chart2/source/view/inc/StaticGeometry.h
+++ b/chart2/source/view/inc/StaticGeometry.h
@@ -116,15 +116,6 @@ static const GLfloat boundBoxNormal[] = {
1.0f, 0.0f, 0.0f//12
};
-static GLfloat coordinateAxis[] = {
- -1.0, 0.0, 0.0,
- 1.0, 0.0, 0.0,//x
- 0.0, 0.0, -1.0,
- 0.0, 0.0, 1.0,//z
- 0.0, 0.0, 0.0,
- 0.0, 1.0, 0.0//y
-};
-
static GLfloat coordReverseVertices[] = {
0.0f, 1.0f,
1.0f, 1.0f,
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index be34aee..87248d0 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -100,7 +100,6 @@ OpenGL3DRenderer::~OpenGL3DRenderer()
glDeleteBuffers(1, &m_CubeElementBuf);
glDeleteBuffers(1, &m_BoundBox);
glDeleteBuffers(1, &m_BoundBoxNormal);
- glDeleteBuffers(1, &m_CoordinateBuf);
glDeleteBuffers(1, &m_TextTexCoordBuf);
glDeleteBuffers(1, &m_RenderTexCoordBuf);
glDeleteBuffers(1, &m_RenderVertexBuf);
@@ -214,10 +213,6 @@ void OpenGL3DRenderer::init()
glBufferData(GL_ARRAY_BUFFER, sizeof(boundBoxNormal), boundBoxNormal, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
- glGenBuffers(1, &m_CoordinateBuf);
- glBindBuffer(GL_ARRAY_BUFFER, m_CoordinateBuf);
- glBufferData(GL_ARRAY_BUFFER, sizeof(coordinateAxis), coordinateAxis, GL_STATIC_DRAW);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
m_fViewAngle = 30.0f;
m_3DProjection = glm::perspective(m_fViewAngle, (float)m_iWidth / (float)m_iHeight, 0.01f, 2000.0f);
LoadShaders();
@@ -1250,11 +1245,6 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
glDisable(GL_CULL_FACE);
}
-void OpenGL3DRenderer::SetFPS(float fps)
-{
- m_fFPS = fps;
-}
-
void OpenGL3DRenderer::CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft)
{
long bmpWidth = rBitmapEx.GetSizePixel().Width();
@@ -1433,8 +1423,6 @@ void OpenGL3DRenderer::ProcessUnrenderedShape()
RenderExtrude3DObject();
//render text
RenderTextShape();
- //render the axis
- RenderCoordinateAxis();
glViewport(0, 0, m_iWidth, m_iHeight);
#if DEBUG_FBO
OUString aFileName = OUString("D://shaderout_") + OUString::number(m_iWidth) + "_" + OUString::number(m_iHeight) + ".png";
@@ -1443,47 +1431,6 @@ void OpenGL3DRenderer::ProcessUnrenderedShape()
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
-glm::vec4 OpenGL3DRenderer::GetColorByIndex(int index)
-{
- sal_uInt8 r = index & 0xFF;
- sal_uInt8 g = (index >> 8) & 0xFF;
- sal_uInt8 b = (index >> 16) & 0xFF;
- return glm::vec4(((float)r) / 255.0, ((float)g) / 255.0, ((float)b) / 255.0, 1.0);
-}
-
-sal_uInt32 OpenGL3DRenderer::GetIndexByColor(sal_uInt32 r, sal_uInt32 g, sal_uInt32 b)
-{
- return r | (g << 8) | (b << 16);
-}
-
-void OpenGL3DRenderer::RenderCoordinateAxis()
-{
- PosVecf3 angle = {0.0f, 0.0f, 0.0f};
- MoveModelf(m_coordinateAxisinfo.trans, angle, m_coordinateAxisinfo.scale);
- glm::mat4 reverseMatrix = glm::scale(glm::vec3(1.0, m_coordinateAxisinfo.reverse, 1.0));
- glm::mat4 axisMVP = m_3DProjection * m_3DView * m_Model * reverseMatrix;
- glUseProgram(m_CommonProID);
- glLineWidth(3.0);
- glEnable(GL_POLYGON_OFFSET_FILL);
- glPolygonOffset(2.0, 2.0);
- // 1rst attribute buffer : vertices
- glEnableVertexAttribArray(m_2DVertexID);
- glBindBuffer(GL_ARRAY_BUFFER, m_CoordinateBuf);
- glVertexAttribPointer(m_2DVertexID, // attribute. No particular reason for 0, but must match the layout in the shader.
- 3, // size
- GL_FLOAT, // type
- GL_FALSE, // normalized?
- 0, // stride
- (void*)0 // array buffer offset
- );
- glUniform4fv(m_2DColorID, 1, &m_coordinateAxisinfo.color[0]);
- glUniformMatrix4fv(m_MatrixID, 1, GL_FALSE, &axisMVP[0][0]);
- glDrawArrays(GL_LINES, 0, sizeof(coordinateAxis) / sizeof(GLfloat) / 3);
- glDisableVertexAttribArray(m_2DVertexID);
- glDisable(GL_POLYGON_OFFSET_FILL);
- glUseProgram(0);
-}
-
void OpenGL3DRenderer::MoveModelf(PosVecf3& trans,PosVecf3& angle,PosVecf3& scale)
{
glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
commit df640feea6f4cee78eddd3b6b99c1809dbf23b36
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sun May 11 05:07:54 2014 +0200
remove unused variables
Change-Id: Ia2dfa357d0fb7c2a19511ec0957deac38b85c09f
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 1a969b4..8ceae53 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -91,11 +91,8 @@ struct Polygon3DInfo
struct Extrude3DInfo
{
bool rounded;
- bool lineOnly;
- float lineWidth;
bool twoSidesLighting;
glm::vec4 extrudeColor;
- long fillStyle;
float xScale;
float yScale;
float zScale;
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 030e968..be34aee 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -80,9 +80,7 @@ OpenGL3DRenderer::OpenGL3DRenderer():
m_Polygon3DInfo.normals = NULL;
m_Polygon3DInfo.lineWidth = 0.001f;
- m_Extrude3DInfo.lineOnly = false;
m_Extrude3DInfo.twoSidesLighting = false;
- m_Extrude3DInfo.lineWidth = 0.001f;
GetFreq();
m_RoundBarMesh.iMeshSizes = 0;
commit e799cd81b830ea8037c282c1950d49605db2867a
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 23:36:11 2014 +0200
better colors for now
Change-Id: I0d236d48d02faf65da2dfc9d3ce8fbdc1ad759ef
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 5fc1914..eabc36a 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -120,7 +120,7 @@ void GL3DBarChart::create3DShapes()
glm::vec3 aEnd = aBegin;
aEnd.x = nXEnd;
pAxis->setPosition(aBegin, aEnd);
- pAxis->setLineColor(COL_WHITE);
+ pAxis->setLineColor(COL_BLUE);
// Y axis
maShapes.push_back(new opengl3D::Line(mpRenderer.get(), nId++));
@@ -129,7 +129,7 @@ void GL3DBarChart::create3DShapes()
aEnd = aBegin;
aEnd.y = nYPos;
pAxis->setPosition(aBegin, aEnd);
- pAxis->setLineColor(COL_WHITE);
+ pAxis->setLineColor(COL_BLUE);
// Chart background.
maShapes.push_back(new opengl3D::Rectangle(mpRenderer.get(), nId++));
@@ -141,7 +141,7 @@ void GL3DBarChart::create3DShapes()
aBottomRight.y = nYPos;
pRect->setPosition(aTopLeft, aTopRight, aBottomRight);
pRect->setFillColor(COL_BLACK);
- pRect->setLineColor(COL_WHITE);
+ pRect->setLineColor(COL_BLUE);
// Create category texts along X-axis at the bottom.
uno::Sequence<OUString> aCats = mrCatProvider.getSimpleCategories();
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 24e00cc..030e968 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1427,7 +1427,7 @@ void OpenGL3DRenderer::ProcessUnrenderedShape()
glViewport(0, 0, m_iWidth, m_iHeight);
glClearDepth(1.0f);
glViewport(0, 0, m_iWidth, m_iHeight);
- glClearColor(0.0, 0.0, 1.0, 1.0);
+ glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//Polygon
RenderPolygon3DObject();
commit 2b5590f2c891da02009fc921ff1be81ae2ccf6dc
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 23:36:02 2014 +0200
use rounded corners by default
Change-Id: Id8cd44f98319c2064d10dcbcb1009a8a29fef484
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index 4f3f9ff..f46933e 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -49,7 +49,7 @@ void Renderable3DObject::render()
Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_Int32 aColor, sal_uInt32 nId)
: Renderable3DObject(pRenderer, nId)
- , mbRoundedCorners(false)
+ , mbRoundedCorners(true)
, maPos(rPosition)
, maColor(aColor)
{
commit fae9fa2bef1090e19eb403024cd13746e992d725
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 23:35:37 2014 +0200
better camera position
Change-Id: I63c7751c273b8ae46c4990561cf5a7084157121a
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index 08dab34..4f3f9ff 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -176,9 +176,9 @@ void Rectangle::setLineColor(const Color& rColor)
Camera::Camera(OpenGL3DRenderer* pRenderer):
Renderable3DObject(pRenderer, 0),
- maPos(10,-50,10),
+ maPos(10,-50,20),
maUp(0, 0, 1),
- maDirection(glm::vec3(0,1,-0.2))
+ maDirection(glm::vec3(0,1,-0.5))
{
}
commit db9c2f0d06e26607fff3fe9cd95ec1b6c2dcb890
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 23:17:19 2014 +0200
whitespace cleanup
Change-Id: Ib971ed2055974f6f11a69a81c28035c84c29b504
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 6886713..24e00cc 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -829,6 +829,7 @@ void OpenGL3DRenderer::SetLightInfo(bool lightOn, sal_Int32 color, const glm::ve
{
return;
}
+
if (lightOn)
{
m_LightsInfo.light[m_LightsInfo.lightNum].lightColor = glm::vec4((float)(((color) & 0x00FF0000) >> 16) / 255.0f,
@@ -866,7 +867,7 @@ void OpenGL3DRenderer::AddShapePolygon3DObject(sal_Int32 color,bool lineOnly,sal
//material specular;
- m_Polygon3DInfo.material.specular = glm::vec4((float)(((specular) & 0x00FF0000) >> 16) / 255.0f,
+ m_Polygon3DInfo.material.specular = glm::vec4((float)(((specular) & 0x00FF0000) >> 16) / 255.0f,
(float)(((specular) & 0x0000FF00) >> 8) / 255.0f,
(float)(((specular) & 0x000000FF)) / 255.0f,
1.0);
commit 383dccc094f8c8c07b4298ce0b7406d18cd61cee
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 23:06:07 2014 +0200
enable MSAA
Change-Id: I38c29c2fd9ddbf6fc42fd1d94f9e34c561aab76d
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 5185d07..6886713 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -196,6 +196,8 @@ void OpenGL3DRenderer::init()
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_MULTISAMPLE);
+
glClearColor (1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glClearDepth(1.0f);
commit 87e10bc6d15cb259d16611667c32c6842044e616
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 22:59:01 2014 +0200
no need to call clear before destryozing a vector
Change-Id: Ic5013c100520e8949d687ce6b34b83405bdfaf0a
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index db1a9b8..5185d07 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -707,7 +707,6 @@ void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
glDrawArrays(GL_LINE_STRIP, 0, pointList->size());
glDisableVertexAttribArray(m_2DVertexID);
glBindBuffer(GL_ARRAY_BUFFER, 0);
- pointList->clear();
delete pointList;
polygon.verticesList.pop_front();
}
@@ -779,9 +778,7 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
glDisableVertexAttribArray(m_3DVertexID);
glDisableVertexAttribArray(m_3DNormalID);
glBindBuffer(GL_ARRAY_BUFFER, 0);
- pointList->clear();
delete pointList;
- normalList->clear();
delete normalList;
polygon.verticesList.pop_front();
polygon.normalsList.pop_front();
@@ -884,6 +881,7 @@ void OpenGL3DRenderer::EndAddShapePolygon3DObject()
m_Polygon3DInfoList.push_back(m_Polygon3DInfo);
m_Polygon3DInfo.normals = NULL;
m_Polygon3DInfo.vertices = NULL;
+ // TODO: moggi: memory leak???
m_Polygon3DInfo.verticesList.clear();
m_Polygon3DInfo.normalsList.clear();
}
commit ed506c3763da099053d847dcf73d02b61cd99527
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 22:55:02 2014 +0200
remove unused variable
Change-Id: Ic6455f080fae211d7919d9f6ea35cdbda3ca3757
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 8f2caa0..1a969b4 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -253,8 +253,6 @@ private:
glm::mat4 m_3DView;
- glm::mat4 m_3DViewBack;
-
glm::mat4 m_3DMVP;
glm::mat4 m_TranslationMatrix;
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 89792a2..db1a9b8 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1418,7 +1418,6 @@ void OpenGL3DRenderer::CreateSceneBoxView()
m_CameraInfo.cameraOrg, // and looks at the origin
m_CameraInfo.cameraUp // Head is up (set to 0,-1,0 to look upside-down)
);
- m_3DViewBack = m_3DView;
}
void OpenGL3DRenderer::ProcessUnrenderedShape()
commit be7fd499ca8c0b2b71b1f1067ea4f59a4fb480f5
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 22:54:12 2014 +0200
remove unneccessary flag
Change-Id: I88c7abe0fa428ea6d9b396e77b510088eda09289
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index ab86007..89792a2 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -63,7 +63,6 @@ GLfloat texCoords[] = {
OpenGL3DRenderer::OpenGL3DRenderer():
m_TranslationMatrix(glm::translate(m_Model, glm::vec3(0.0f, 0.0f, 0.0f)))
- , m_bCameraUpdated(false)
, m_TextProID(0)
, m_TextMatrixID(0)
, m_TextVertexID(0)
@@ -792,10 +791,6 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
void OpenGL3DRenderer::RenderPolygon3DObject()
{
- if (!m_bCameraUpdated)
- {
- return;
- }
glDepthMask(GL_FALSE);
size_t polygonNum = m_Polygon3DInfoList.size();
for (size_t i = 0; i < polygonNum; i++)
@@ -1424,7 +1419,6 @@ void OpenGL3DRenderer::CreateSceneBoxView()
m_CameraInfo.cameraUp // Head is up (set to 0,-1,0 to look upside-down)
);
m_3DViewBack = m_3DView;
- m_bCameraUpdated = true;
}
void OpenGL3DRenderer::ProcessUnrenderedShape()
commit 1b10b86f5b6ee125e08080a31e0487084837f3a5
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 22:53:24 2014 +0200
remove unimplemented methods from class
Change-Id: Ib050c0c0c699964cad91b184fcc4b3387b171235
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index bc0b8de..8f2caa0 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -159,10 +159,6 @@ public:
OpenGL3DRenderer();
~OpenGL3DRenderer();
- void CreateFrameBufferObj();
- void CreateTextureObj(int,int);
- void CreateRenderObj(int, int);
- void LoadShaders();
void init();
void Set3DSenceInfo(sal_Int32 color = 255, bool twoSidesLighting = true);
void SetLightInfo(bool lightOn, sal_Int32 color, const glm::vec4& direction);
@@ -185,6 +181,7 @@ public:
private:
void MoveModelf(PosVecf3& trans,PosVecf3& angle,PosVecf3& scale);
+ void LoadShaders();
void GetFreq();
void RenderPolygon3DObject();
void RenderLine3D(Polygon3DInfo &polygon);
commit 5e454794127f86988028325f56e7787cba6379ae
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 22:51:43 2014 +0200
remove unused pickingFlg
Change-Id: I27b4559a5d2f4a003d31be9cce4d74dfb7b5326c
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 89e9f18..bc0b8de 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -90,7 +90,6 @@ struct Polygon3DInfo
struct Extrude3DInfo
{
- int pickingFlg;
bool rounded;
bool lineOnly;
float lineWidth;
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 343f174..ab86007 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -985,7 +985,6 @@ void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_Int32 col
void OpenGL3DRenderer::EndAddShape3DExtrudeObject()
{
- m_Extrude3DInfo.pickingFlg = 0;
m_Extrude3DList.push_back(m_Extrude3DInfo);
}
@@ -1467,11 +1466,6 @@ sal_uInt32 OpenGL3DRenderer::GetIndexByColor(sal_uInt32 r, sal_uInt32 g, sal_uIn
void OpenGL3DRenderer::RenderCoordinateAxis()
{
- if (!m_coordinateAxisinfo.pickingFlg)
- {
- return;
- }
-
PosVecf3 angle = {0.0f, 0.0f, 0.0f};
MoveModelf(m_coordinateAxisinfo.trans, angle, m_coordinateAxisinfo.scale);
glm::mat4 reverseMatrix = glm::scale(glm::vec3(1.0, m_coordinateAxisinfo.reverse, 1.0));
commit a29e1c5cfd734bdff66fac5f0a324665f8c321d7
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 22:51:32 2014 +0200
remove unused methods
Change-Id: Id9e35e171d4235d863a09f6d1d8083d7dbab59c6
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 7e407db..89e9f18 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -204,8 +204,6 @@ private:
void RenderExtrudeFlatSurface(const Extrude3DInfo& extrude3D, int surIndex);
glm::vec4 GetColorByIndex(int index);
sal_uInt32 GetIndexByColor(sal_uInt32 r, sal_uInt32 g, sal_uInt32 b);
- void ProcessPickingBox();
- int ProcessExtrude3DPickingBox();
void RenderCoordinateAxis();
void AddVertexData(GLuint vertexBuf);
void AddNormalData(GLuint normalBuf);
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index e581d23..343f174 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -20,8 +20,6 @@
#include <StaticGeometry.h>
#include "glm/gtc/matrix_inverse.hpp"
-#define RGB_WHITE (0xFF | (0xFF << 8) | (0xFF << 16))
-
#define DEBUG_FBO 0
using namespace com::sun::star;
@@ -1467,109 +1465,6 @@ sal_uInt32 OpenGL3DRenderer::GetIndexByColor(sal_uInt32 r, sal_uInt32 g, sal_uIn
return r | (g << 8) | (b << 16);
}
-void OpenGL3DRenderer::ProcessPickingBox()
-{
- glViewport(0, 0, m_iWidth, m_iHeight);
- glClearDepth(1.0f);
- glClearColor(1.0, 1.0, 1.0, 1.0);
- if(ProcessExtrude3DPickingBox() == 1)
- {
- //the picked object has been processed, return
- return ;
- }
-}
-
-int OpenGL3DRenderer::ProcessExtrude3DPickingBox()
-{
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- //render the bounding box
- Extrude3DInfo extrude3DInfo;
- glUseProgram(m_CommonProID);
-
- // 1rst attribute buffer : vertices
- glEnableVertexAttribArray(m_2DVertexID);
- glBindBuffer(GL_ARRAY_BUFFER, m_BoundBox);
- glVertexAttribPointer(m_2DVertexID, // attribute. No particular reason for 0, but must match the layout in the shader.
- 3, // size
- GL_FLOAT, // type
- GL_FALSE, // normalized?
- 0, // stride
- (void*)0 // array buffer offset
- );
- for (unsigned int i = 0; i < m_Extrude3DList.size(); i++)
- {
- extrude3DInfo = m_Extrude3DList[i];
- extrude3DInfo.yTransform *= m_fHeightWeight;
- extrude3DInfo.yScale *= m_fHeightWeight;
- PosVecf3 trans = {extrude3DInfo.xTransform,//m_Extrude3DInfo.xTransform + 140,
- -extrude3DInfo.yTransform,
- extrude3DInfo.zTransform};
- PosVecf3 angle = {0.0f, 0.0f, 0.0f};
- PosVecf3 scale = {extrude3DInfo.xScale,
- extrude3DInfo.yScale,
- extrude3DInfo.xScale};
- MoveModelf(trans, angle, scale);
- glm::mat4 boundMVP = m_3DProjection * m_3DView * m_Model;
- glm::vec4 boundColor = GetColorByIndex(i);
- int reverse = 1;
- if (reverse < 0)
- {
- glm::mat4 reverseMatrix = glm::translate(glm::vec3(0.0, -1.0, 0.0));
- boundMVP = boundMVP * reverseMatrix;
- }
- glUniform4fv(m_2DColorID, 1, &boundColor[0]);
- glUniformMatrix4fv(m_MatrixID, 1, GL_FALSE, &boundMVP[0][0]);
-
- glDrawArrays(GL_TRIANGLES, 0, sizeof(boundBox) / sizeof(GLfloat) / 3);
- }
- glDisableVertexAttribArray(m_2DVertexID);
- glUseProgram(0);
- //read pixel to get the index
- Point select = Point(m_aMPos.X(), m_aMPos.Y());
- sal_uInt8 selectColor[4] = {0};
-
- glReadPixels(select.X(), select.Y(), 1, 1, GL_RGB, GL_UNSIGNED_BYTE, selectColor);
- int selectID = GetIndexByColor(selectColor[0], selectColor[1], selectColor[2]);
-
- if (selectID == RGB_WHITE)
- {
- if (m_uiSelectFrameCounter <= 0)
- {
- m_3DView = m_3DViewBack;
- m_uiSelectFrameCounter = 0;
- m_coordinateAxisinfo.pickingFlg = 0;
- }
- else
- {
- m_uiSelectFrameCounter--;
- }
- return 0;
- }
-
- extrude3DInfo = m_Extrude3DList[selectID];
- extrude3DInfo.yTransform *= m_fHeightWeight;
- extrude3DInfo.yScale *= m_fHeightWeight;
- int reverse = 1;
- m_3DView = glm::lookAt(m_CameraInfo.cameraPos, // Camera is at (0,0,3), in World Space
- m_CameraInfo.cameraOrg, // and looks at the origin
- m_CameraInfo.cameraUp // Head is up (set to 0,-1,0 to look upside-down)
- );
- m_uiSelectFrameCounter = 5;
-
- m_coordinateAxisinfo.pickingFlg = 1;
- m_coordinateAxisinfo.reverse = reverse;
- m_coordinateAxisinfo.trans.x = extrude3DInfo.xTransform + extrude3DInfo.xScale / 2;
- m_coordinateAxisinfo.trans.y = -extrude3DInfo.yTransform + (extrude3DInfo.yScale + 1.5) * reverse;
- m_coordinateAxisinfo.trans.z = extrude3DInfo.zTransform + extrude3DInfo.xScale / 2;
-
- m_coordinateAxisinfo.scale.x = 4 * extrude3DInfo.xScale;
- m_coordinateAxisinfo.scale.y = 4 * extrude3DInfo.xScale;
- m_coordinateAxisinfo.scale.z = 4 * extrude3DInfo.xScale;
- m_coordinateAxisinfo.color = glm::vec4(0.5, 1.0, 0.8, 1.0);
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
- return 1;
-}
-
void OpenGL3DRenderer::RenderCoordinateAxis()
{
if (!m_coordinateAxisinfo.pickingFlg)
commit 3729f6ca6abe83b8f6b2a712b286e7ba57442302
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 22:45:30 2014 +0200
remove scene box that should not be in the renderer
Change-Id: I3ec69042782aaac2fa2b583dd5a667b91dcdbb88
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 9eb21b2..7e407db 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -154,26 +154,6 @@ struct TextInfo
float vertex[12];
};
-
-struct SceneBox
-{
- float maxXCoord;
- float minXCoord;
- float maxYCoord;
- float minYCoord;
- float maxZCoord;
- float minZCoord;
-
- SceneBox():
- maxXCoord(-1*FLT_MAX),
- minXCoord(FLT_MAX),
- maxYCoord(-1*FLT_MAX),
- minYCoord(FLT_MAX),
- maxZCoord(-1*FLT_MAX),
- minZCoord(FLT_MAX) {}
-};
-
-
class OpenGL3DRenderer
{
public:
@@ -198,7 +178,6 @@ public:
void EndAddShape3DExtrudeObject();
double GetTime();
void SetFPS(float fps);
- void SetClickPos(Point aMPos);
void RenderClickPos(Point aMPos);
void SetSize(const Size& rSize);
void SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up);
@@ -370,13 +349,6 @@ private:
GLint m_RenderVertexID;
GLint m_RenderTexCoordID;
- //TODO: moggi: kill the following parts
- // don't add anything below or I will remove it
-#if 0
- size_t m_iPointNum;
-#endif
-
- SceneBox m_SenceBox;
float m_fViewAngle;
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 412d401..e581d23 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -924,17 +924,7 @@ void OpenGL3DRenderer::AddPolygon3DObjectPoint(float x, float y, float z)
float actualX = x;
float actualY = y;
float actualZ = z;
- float maxCoord = std::max(actualX, std::max(actualY, actualZ));
- m_fZmax = std::max(maxCoord, m_fZmax);
m_Polygon3DInfo.vertices->push_back(glm::vec3(actualX, actualY, actualZ));
- m_SenceBox.maxXCoord = std::max(m_SenceBox.maxXCoord, actualX);
- m_SenceBox.minXCoord = std::min(m_SenceBox.minXCoord, actualX);
-
- m_SenceBox.maxYCoord = std::max(m_SenceBox.maxYCoord, actualY);
- m_SenceBox.minYCoord = std::min(m_SenceBox.minYCoord, actualY);
-
- m_SenceBox.maxZCoord = std::max(m_SenceBox.maxZCoord, actualZ);
- m_SenceBox.minZCoord = std::min(m_SenceBox.minZCoord, actualZ);
}
void OpenGL3DRenderer::EndAddPolygon3DObjectPoint()
@@ -993,15 +983,6 @@ void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_Int32 col
m_Vertices.clear();
m_Normals.clear();
m_Indeices.clear();
- m_SenceBox.maxXCoord = std::max(m_SenceBox.maxXCoord, m_Extrude3DInfo.xTransform + m_Extrude3DInfo.xScale);
- m_SenceBox.minXCoord = std::min(m_SenceBox.minXCoord, m_Extrude3DInfo.xTransform);
-
- m_SenceBox.maxYCoord = std::max(m_SenceBox.maxYCoord, m_Extrude3DInfo.yTransform + m_Extrude3DInfo.yScale);
- m_SenceBox.minYCoord = std::min(m_SenceBox.minYCoord, m_Extrude3DInfo.yTransform );
-
- m_SenceBox.maxZCoord = std::max(m_SenceBox.maxZCoord, m_Extrude3DInfo.zTransform + m_Extrude3DInfo.zScale);
- m_SenceBox.minZCoord = std::min(m_SenceBox.minZCoord, m_Extrude3DInfo.zTransform);
-
}
void OpenGL3DRenderer::EndAddShape3DExtrudeObject()
@@ -1283,11 +1264,6 @@ void OpenGL3DRenderer::SetFPS(float fps)
m_fFPS = fps;
}
-void OpenGL3DRenderer::SetClickPos(Point aMPos)
-{
- m_aMPos = aMPos;
-}
-
void OpenGL3DRenderer::CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft)
{
long bmpWidth = rBitmapEx.GetSizePixel().Width();
commit c4a490eb0b6cc19e2aab39f639ae251af511cc62
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 22:35:37 2014 +0200
no framebuffer support needed anymore
Change-Id: I5e6830bbd87eb9465aeb87d7e5074c9192caa47e
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 1c38333..412d401 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -184,12 +184,6 @@ void OpenGL3DRenderer::RenderTexture(GLuint TexID)
void OpenGL3DRenderer::init()
{
- if (glewIsSupported("framebuffer_object") != GLEW_OK)
- {
- SAL_WARN("chart2.opengl", "GL stack has no framebuffer support");
- return;
- }
-
glEnable(GL_TEXTURE_2D);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
commit b53e1acde5130cab54ca064963c17683b69e8916
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 22:35:04 2014 +0200
keep camera calculations out of the rendering code
Change-Id: I7a26ce1881958a7465692174dd8ea793b593efad
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 8c57412..9eb21b2 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -113,14 +113,12 @@ struct Extrude3DInfo
struct CameraInfo
{
- bool useDefault;
glm::vec3 cameraPos;
glm::vec3 cameraOrg;
glm::vec3 cameraUp;
CameraInfo():
- useDefault(true),
- cameraUp(glm::vec3(0, 1, 0)) {}
+ cameraUp(glm::vec3(0, 0, 1)) {}
};
struct CoordinateAxisInfo
@@ -203,7 +201,7 @@ public:
void SetClickPos(Point aMPos);
void RenderClickPos(Point aMPos);
void SetSize(const Size& rSize);
- void SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up, bool useDefalut);
+ void SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up);
void CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft);
void ProcessUnrenderedShape();
private:
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index a1fc5ee..08dab34 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -184,7 +184,7 @@ Camera::Camera(OpenGL3DRenderer* pRenderer):
void Camera::render()
{
- mpRenderer->SetCameraInfo(maPos, maDirection, maUp, false);
+ mpRenderer->SetCameraInfo(maPos, maDirection, maUp);
}
void Camera::zoom(sal_uInt32 /*nId*/)
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 4875241..1c38333 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -20,7 +20,6 @@
#include <StaticGeometry.h>
#include "glm/gtc/matrix_inverse.hpp"
-#define GL_PI 3.14159f
#define RGB_WHITE (0xFF | (0xFF << 8) | (0xFF << 16))
#define DEBUG_FBO 0
@@ -141,13 +140,8 @@ void OpenGL3DRenderer::LoadShaders()
CHECK_GL_ERROR();
}
-void OpenGL3DRenderer::SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up, bool useDefalut)
+void OpenGL3DRenderer::SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up)
{
- m_CameraInfo.useDefault = useDefalut;
- if (m_CameraInfo.useDefault)
- {
- return;
- }
m_CameraInfo.cameraPos = pos;
m_CameraInfo.cameraOrg = pos + direction;
m_CameraInfo.cameraUp = up;
@@ -1458,26 +1452,6 @@ void OpenGL3DRenderer::RenderClickPos(Point aMPos)
void OpenGL3DRenderer::CreateSceneBoxView()
{
- if (m_CameraInfo.useDefault)
- {
- float senceBoxWidth = m_SenceBox.maxXCoord - m_SenceBox.minXCoord;
- float senceBoxHeight = m_SenceBox.maxYCoord - m_SenceBox.minYCoord;
- float senceBoxDepth = m_SenceBox.maxZCoord - m_SenceBox.minZCoord;
- float distanceZ = m_SenceBox.maxZCoord + senceBoxWidth / 2 / tan(m_fViewAngle / 2 * GL_PI / 180.0f);
- float veriticalAngle = atan((float)m_iHeight / (float)m_iWidth);
- float distance = distanceZ / cos(veriticalAngle);
- float horizontalAngle = 0;
- m_fHeightWeight = senceBoxWidth * (float)m_iHeight / (float)m_iWidth / senceBoxHeight;
- m_SenceBox.maxYCoord *= m_fHeightWeight;
- m_SenceBox.minYCoord *= m_fHeightWeight;
- m_CameraInfo.cameraOrg = glm::vec3(m_SenceBox.minXCoord + senceBoxWidth / 2,
- m_SenceBox.minYCoord + senceBoxHeight * m_fHeightWeight/ 2,
- m_SenceBox.minZCoord + senceBoxDepth * 2);
- //update the camera position and org
- m_CameraInfo.cameraPos.x = m_CameraInfo.cameraOrg.x + distance * cos(veriticalAngle) * sin(horizontalAngle);
- m_CameraInfo.cameraPos.z = m_CameraInfo.cameraOrg.z + distance * cos(veriticalAngle) * cos(horizontalAngle);
- m_CameraInfo.cameraPos.y = m_CameraInfo.cameraOrg.y + distance * sin(veriticalAngle);
- }
m_3DView = glm::lookAt(m_CameraInfo.cameraPos, // Camera is at (0,0,3), in World Space
m_CameraInfo.cameraOrg, // and looks at the origin
m_CameraInfo.cameraUp // Head is up (set to 0,-1,0 to look upside-down)
@@ -1601,25 +1575,11 @@ int OpenGL3DRenderer::ProcessExtrude3DPickingBox()
}
return 0;
}
- //reset the camera by index
- //update the camera position and org
- float distance = 500;
- float veriticalAngle = GL_PI / 3.25f;
- float horizontalAngle = GL_PI / 6.0f;
+
extrude3DInfo = m_Extrude3DList[selectID];
extrude3DInfo.yTransform *= m_fHeightWeight;
extrude3DInfo.yScale *= m_fHeightWeight;
int reverse = 1;
- if (m_CameraInfo.useDefault)
- {
- m_CameraInfo.cameraOrg = glm::vec3(extrude3DInfo.xTransform + extrude3DInfo.xScale / 2,
- -extrude3DInfo.yTransform + extrude3DInfo.yScale *reverse,
- extrude3DInfo.zTransform + extrude3DInfo.xScale / 2);
-
- m_CameraInfo.cameraPos.x = m_CameraInfo.cameraOrg.x - distance * cos(veriticalAngle) * sin(horizontalAngle);
- m_CameraInfo.cameraPos.z = m_CameraInfo.cameraOrg.z + distance * cos(veriticalAngle) * cos(horizontalAngle);
- m_CameraInfo.cameraPos.y = m_CameraInfo.cameraOrg.y + distance * sin(horizontalAngle) * reverse;
- }
m_3DView = glm::lookAt(m_CameraInfo.cameraPos, // Camera is at (0,0,3), in World Space
m_CameraInfo.cameraOrg, // and looks at the origin
m_CameraInfo.cameraUp // Head is up (set to 0,-1,0 to look upside-down)
commit 28e7d53826fd2eae8048173c46bdc4b33f7e7ba4
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 22:29:59 2014 +0200
add some debug code
Change-Id: I279e25f902e4bd8d19d61ddd6b9c290a120a39a9
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index 35d116f..a1fc5ee 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -11,10 +11,31 @@
#include <vcl/virdev.hxx>
#include <vcl/svapp.hxx>
+#include <ostream>
+
namespace chart {
namespace opengl3D {
+namespace {
+
+std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix)
+{
+ for(int i = 0; i < 4; ++i)
+ {
+ rStrm << "( ";
+ for(int j = 0; j < 4; ++j)
+ {
+ rStrm << rMatrix[j][i];
+ rStrm << " ";
+ }
+ rStrm << ")\n";
+ }
+ return rStrm;
+}
+
+}
+
Renderable3DObject::Renderable3DObject(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
mpRenderer(pRenderer),
mnUniqueId(nId)
@@ -32,6 +53,7 @@ Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_Int32 aCol
, maPos(rPosition)
, maColor(aColor)
{
+ SAL_INFO("chart2.3dopengl", rPosition);
}
void Bar::render()
commit 9ec2a09c007685cc78db8ca80778eb8f3930a6ab
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 22:29:06 2014 +0200
fix camera position
Change-Id: Ie3acc0a82e86fe7fbc565783ac09c2f9b6721fbf
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index 6cad265..35d116f 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -154,15 +154,15 @@ void Rectangle::setLineColor(const Color& rColor)
Camera::Camera(OpenGL3DRenderer* pRenderer):
Renderable3DObject(pRenderer, 0),
- maPos(10,10,-10),
- maUp(0, 1, 0),
- maDirection(glm::vec3(0,0,0)-maPos)
+ maPos(10,-50,10),
+ maUp(0, 0, 1),
+ maDirection(glm::vec3(0,1,-0.2))
{
}
void Camera::render()
{
- mpRenderer->SetCameraInfo(maPos, maDirection, maUp, true);
+ mpRenderer->SetCameraInfo(maPos, maDirection, maUp, false);
}
void Camera::zoom(sal_uInt32 /*nId*/)
commit 4a833ab441a1bcc972f3c52e75fb5d913260c7bb
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 22:28:11 2014 +0200
fix bar positioning
Change-Id: I91bcaaef42df82495d06d46a85c115396720e247
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index f300989..5fc1914 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -96,9 +96,9 @@ void GL3DBarChart::create3DShapes()
float nXPos = nIndex * (nBarSizeX + nBarDistanceX);
- glm::mat4 aBarPosition;
- aBarPosition = glm::scale(aBarPosition, nBarSizeX, nBarSizeY, nVal);
- aBarPosition = glm::translate(aBarPosition, nXPos, nYPos, nVal/2);
+ glm::mat4 aScaleMatrix = glm::scale(nBarSizeX, nBarSizeY, nVal);
+ glm::mat4 aTranslationMatrix = glm::translate(nXPos, nYPos, nVal/2);
+ glm::mat4 aBarPosition = aTranslationMatrix * aScaleMatrix;
maShapes.push_back(new opengl3D::Bar(mpRenderer.get(), aBarPosition, nColor, nId++));
}
commit 8c6ec8e4c22814736c85e9ce29c63dd3044a35bc
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 08:24:54 2014 +0200
some work into intercepting mouse events in OpenGL window
Change-Id: I46dcfed7d5398d994c68ed7cfe4408f9f5719bf1
diff --git a/include/vcl/openglwin.hxx b/include/vcl/openglwin.hxx
index f78c530..b766f05 100644
--- a/include/vcl/openglwin.hxx
+++ b/include/vcl/openglwin.hxx
@@ -27,6 +27,7 @@ public:
OpenGLContext* getContext();
virtual void Paint(const Rectangle&) SAL_OVERRIDE {}
+ virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
private:
boost::scoped_ptr<OpenGLWindowImpl> mpImpl;
diff --git a/vcl/source/window/openglwin.cxx b/vcl/source/window/openglwin.cxx
index 3065718..77ab2d9 100644
--- a/vcl/source/window/openglwin.cxx
+++ b/vcl/source/window/openglwin.cxx
@@ -9,6 +9,7 @@
#include <vcl/openglwin.hxx>
#include <vcl/opengl/OpenGLContext.hxx>
+#include <vcl/event.hxx>
class OpenGLWindowImpl
{
@@ -44,4 +45,12 @@ OpenGLContext* OpenGLWindow::getContext()
return mpImpl->getContext();
}
+void OpenGLWindow::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ Point aPoint = rMEvt.GetPosPixel();
+
+ Color aColor = GetPixel(aPoint);
+ SAL_WARN("vcl.opengl", aColor.GetColor());
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 01e04598ce1f512084676bf62f75626d1cd38614
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 08:23:00 2014 +0200
remove printf statements
Change-Id: I82de8e5e3c028103f1d2b006124593293f9fe365
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index f9f5e10..4875241 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -138,7 +138,6 @@ void OpenGL3DRenderer::LoadShaders()
m_RenderVertexID = glGetAttribLocation(m_RenderProID, "vPosition");
m_RenderTexCoordID = glGetAttribLocation(m_RenderProID, "texCoord");
m_RenderTexID = glGetUniformLocation(m_RenderProID, "RenderTex");
- printf("m_RenderProID = %d, m_RenderVertexID = %d\n", m_RenderProID, m_RenderVertexID);
CHECK_GL_ERROR();
}
@@ -1587,7 +1586,6 @@ int OpenGL3DRenderer::ProcessExtrude3DPickingBox()
glReadPixels(select.X(), select.Y(), 1, 1, GL_RGB, GL_UNSIGNED_BYTE, selectColor);
int selectID = GetIndexByColor(selectColor[0], selectColor[1], selectColor[2]);
-// printf("selectColor[0] = %d, selectColor[1] = %d, selectColor[2] = %d, selectID = %d\n", selectColor[0], selectColor[1], selectColor[2], selectID);
if (selectID == RGB_WHITE)
{
commit df7cef1c387398957c893f28194b2a15f22cb6b5
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 08:22:28 2014 +0200
give each series an own color
Change-Id: Ia74eda050349d34d23e07b8e700aaae97e43d903
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 3775d04..f300989 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -58,6 +58,10 @@ void GL3DBarChart::create3DShapes()
float nXEnd = 0.0;
float nYPos = 0.0;
+ const Color aSeriesColor[] = {
+ COL_RED, COL_GREEN, COL_YELLOW, COL_BROWN, COL_GRAY
+ };
+
maShapes.clear();
maShapes.push_back(new opengl3D::Camera(mpRenderer.get()));
sal_Int32 nSeriesIndex = 0;
@@ -85,12 +89,12 @@ void GL3DBarChart::create3DShapes()
aBottomRight.y += aTextSize.getHeight();
p->setPosition(aTopLeft, aTopRight, aBottomRight);
+ sal_Int32 nColor = aSeriesColor[nSeriesIndex % SAL_N_ELEMENTS(aSeriesColor)].GetColor();
for(sal_Int32 nIndex = 0; nIndex < nPointCount; ++nIndex)
{
float nVal = rDataSeries.getYValue(nIndex);
float nXPos = nIndex * (nBarSizeX + nBarDistanceX);
- sal_Int32 nColor = COL_RED;
glm::mat4 aBarPosition;
aBarPosition = glm::scale(aBarPosition, nBarSizeX, nBarSizeY, nVal);
commit 27340aeb1975ef93c6acfb1ebe2f79d9dc0f48bc
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 04:31:07 2014 +0200
we need to call OpenGL3DRenderer::init
Change-Id: I9bcdc7d033835bf3cdb6f9d4770aaee284f7eaf7
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index b38e1ee..3775d04 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -162,6 +162,7 @@ void GL3DBarChart::render()
{
mrWindow.getContext()->makeCurrent();
Size aSize = mrWindow.GetSizePixel();
+ mpRenderer->init();
mpRenderer->SetSize(aSize);
mrWindow.getContext()->setWinSize(aSize);
for(boost::ptr_vector<opengl3D::Renderable3DObject>::iterator itr = maShapes.begin(),
commit 57c681d8ee2923a7592f1b8f6edc3cfa39384cf6
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 04:30:46 2014 +0200
change the color of the bars as the ackground is blue as well
Change-Id: Ib16ef3548368e5b07dd9411a4515d5e6abe3acaf
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 8f443d1..b38e1ee 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -90,7 +90,7 @@ void GL3DBarChart::create3DShapes()
float nVal = rDataSeries.getYValue(nIndex);
float nXPos = nIndex * (nBarSizeX + nBarDistanceX);
- sal_Int32 nColor = COL_BLUE;
+ sal_Int32 nColor = COL_RED;
glm::mat4 aBarPosition;
aBarPosition = glm::scale(aBarPosition, nBarSizeX, nBarSizeY, nVal);
commit c5e34d2dcbf000aab7e299268133ea84ea89ccbf
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 10 04:29:20 2014 +0200
remove more unnecessary typedefs
Change-Id: I62968f11220da31febdbdff2d057607696ea6271
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index c49370a..8c57412 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -42,7 +42,7 @@ typedef std::vector <glm::vec3> Vertices3D;
typedef std::vector <glm::vec2> UVs3D;
typedef std::vector <glm::vec3> Normals3D;
-typedef struct MaterialParameters
+struct MaterialParameters
{
glm::vec4 ambient;
glm::vec4 diffuse;
@@ -53,9 +53,9 @@ typedef struct MaterialParameters
float shininess;
float pad;
float pad1;
-}Material;
+};
-typedef struct LightSource
+struct LightSource
{
glm::vec4 lightColor;
glm::vec4 positionWorldspace;
@@ -63,16 +63,16 @@ typedef struct LightSource
float pad1;
float pad2;
float pad3;
-}LightSource;
+};
-typedef struct GlobalLights
+struct GlobalLights
{
int lightNum;
glm::vec4 ambient;
LightSource light[MAX_LIGHT_NUM];
-}Lights;
+};
-typedef struct Polygon3DInfo
+struct Polygon3DInfo
{
bool lineOnly;
float lineWidth;
@@ -85,10 +85,10 @@ typedef struct Polygon3DInfo
std::list <Vertices3D *> verticesList;
std::list <UVs3D *> uvsList;
std::list <Normals3D *> normalsList;
- Material material;
-}Polygon3DInfo;
+ MaterialParameters material;
+};
-typedef struct Extrude3DInfo
+struct Extrude3DInfo
{
int pickingFlg;
bool rounded;
@@ -104,11 +104,11 @@ typedef struct Extrude3DInfo
float yTransform;
float zTransform;
glm::mat4 rotation;
- Material material;
+ MaterialParameters material;
int startIndex[5];
int size[5];
int reverse;
-}Extrude3DInfo;
+};
struct CameraInfo
@@ -268,7 +268,7 @@ private:
float m_fZmax;
- Lights m_LightsInfo;
+ GlobalLights m_LightsInfo;
CameraInfo m_CameraInfo;
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index b3a9c53..f9f5e10 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -742,7 +742,7 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
//update ubo
Update3DUniformBlock();
glBindBuffer(GL_UNIFORM_BUFFER, m_3DUBOBuffer);
- glBufferSubData(GL_UNIFORM_BUFFER, m_3DActualSizeLight, sizeof(Material), &polygon.material);
+ glBufferSubData(GL_UNIFORM_BUFFER, m_3DActualSizeLight, sizeof(MaterialParameters), &polygon.material);
CHECK_GL_ERROR();
glBindBuffer(GL_UNIFORM_BUFFER, 0);
glUseProgram(m_3DProID);
@@ -1269,7 +1269,7 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
extrude3DInfo.yTransform *= m_fHeightWeight;
extrude3DInfo.yScale *= m_fHeightWeight;
glBindBuffer(GL_UNIFORM_BUFFER, m_3DUBOBuffer);
- glBufferSubData(GL_UNIFORM_BUFFER, m_3DActualSizeLight, sizeof(Material), &extrude3DInfo.material);
+ glBufferSubData(GL_UNIFORM_BUFFER, m_3DActualSizeLight, sizeof(MaterialParameters), &extrude3DInfo.material);
CHECK_GL_ERROR();
glBindBuffer(GL_UNIFORM_BUFFER, 0);
extrude3DInfo.reverse = 0;
commit 720f38787c2cb6724fdb5594739563ae4489d91f
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri May 9 05:34:34 2014 +0200
initialize variables in initializer list
Change-Id: I1526d40c28a33cd29074adcc8c8d182f92996914
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 6c00422..c49370a 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -117,6 +117,10 @@ struct CameraInfo
glm::vec3 cameraPos;
glm::vec3 cameraOrg;
glm::vec3 cameraUp;
+
+ CameraInfo():
+ useDefault(true),
+ cameraUp(glm::vec3(0, 1, 0)) {}
};
struct CoordinateAxisInfo
@@ -161,6 +165,14 @@ struct SceneBox
float minYCoord;
float maxZCoord;
float minZCoord;
+
+ SceneBox():
+ maxXCoord(-1*FLT_MAX),
+ minXCoord(FLT_MAX),
+ maxYCoord(-1*FLT_MAX),
+ minYCoord(FLT_MAX),
+ maxZCoord(-1*FLT_MAX),
+ minZCoord(FLT_MAX) {}
};
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 277b78b..b3a9c53 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -66,12 +66,16 @@ GLfloat texCoords[] = {
OpenGL3DRenderer::OpenGL3DRenderer():
m_TranslationMatrix(glm::translate(m_Model, glm::vec3(0.0f, 0.0f, 0.0f)))
+ , m_bCameraUpdated(false)
, m_TextProID(0)
, m_TextMatrixID(0)
, m_TextVertexID(0)
, m_TextTexCoordID(0)
, m_TextTexCoordBuf(0)
, m_TextTexID(0)
+ , m_uiSelectFrameCounter(0)
+ , m_fViewAngle(30.0f)
+ , m_fHeightWeight(1.0f)
{
m_Polygon3DInfo.lineOnly = false;
m_Polygon3DInfo.twoSidesLighting = false;
@@ -84,19 +88,7 @@ OpenGL3DRenderer::OpenGL3DRenderer():
m_Extrude3DInfo.twoSidesLighting = false;
m_Extrude3DInfo.lineWidth = 0.001f;
- m_bCameraUpdated = false;
GetFreq();
- m_fViewAngle = 30.0f;
- m_SenceBox.maxXCoord = -1.0 * FLT_MAX;
- m_SenceBox.minXCoord = FLT_MAX;
- m_SenceBox.maxYCoord = -1.0 * FLT_MAX;
- m_SenceBox.minYCoord = FLT_MAX;
- m_SenceBox.maxZCoord = -1.0 * FLT_MAX;
- m_SenceBox.minZCoord = FLT_MAX;
- m_uiSelectFrameCounter = 0;
- m_fHeightWeight = 1.0f;
- m_CameraInfo.useDefault = true;
- m_CameraInfo.cameraUp = glm::vec3(0, 1, 0);
m_RoundBarMesh.iMeshSizes = 0;
}
commit 93268d379ebca4bc2bd3fa7bedf8f3aadf0c3d78
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri May 9 05:31:42 2014 +0200
avoid temporary copy
Change-Id: Ica949141c58d7ebb85f246dee4109c39ee8f889e
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 339114e..6c00422 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -141,7 +141,7 @@ struct RoundBarMesh
struct PackedVertex{
glm::vec3 position;
glm::vec3 normal;
- bool operator<(const PackedVertex that) const{
+ bool operator<(const PackedVertex& that) const{
return memcmp((void*)this, (void*)&that, sizeof(PackedVertex))>0;
};
};
commit 832f44c80fb829604bd32f5fc573989e463bbd08
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri May 9 05:30:46 2014 +0200
remove these unnecessary typedefs
Change-Id: Iae2dc2d9bcc40bf7b45cd319a8be46b040d9ec23
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index a67c625..339114e 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -111,24 +111,24 @@ typedef struct Extrude3DInfo
}Extrude3DInfo;
-typedef struct CameraInfo
+struct CameraInfo
{
bool useDefault;
glm::vec3 cameraPos;
glm::vec3 cameraOrg;
glm::vec3 cameraUp;
-}CameraInfo;
+};
-typedef struct CoordinateAxisInfo
+struct CoordinateAxisInfo
{
int pickingFlg;
int reverse;
glm::vec4 color;
PosVecf3 trans;
PosVecf3 scale;
-}CoordinateAxisInfo;
+};
-typedef struct RoundBarMesh
+struct RoundBarMesh
{
float topThreshold;
float bottomThreshold;
@@ -136,7 +136,7 @@ typedef struct RoundBarMesh
int iMeshSizes;
int iElementStartIndices[5];
int iElementSizes[5];
-}RoundBarMesh;
+};
struct PackedVertex{
glm::vec3 position;
@@ -146,14 +146,14 @@ struct PackedVertex{
};
};
-typedef struct TextInfo
+struct TextInfo
{
GLuint texture;
float vertex[12];
-}TextInfo;
+};
-typedef struct SceneBox
+struct SceneBox
{
float maxXCoord;
float minXCoord;
@@ -161,7 +161,7 @@ typedef struct SceneBox
float minYCoord;
float maxZCoord;
float minZCoord;
-}SceneBox;
+};
class OpenGL3DRenderer
commit 21130eaef91bcc471e7c265623a078e82c13b15d
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri May 9 05:23:12 2014 +0200
we need glew initalized before testing through it for features
Change-Id: I4999de29b2a12888129ab291344b239b8def373c
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 8ad2d7a..58202fb 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -509,16 +509,6 @@ bool OpenGLContext::ImplInit()
//rGLRender.InitOpenGL(m_aGLWin);
-#ifdef DBG_UTIL
- // only enable debug output in dbgutil build
- if( GLEW_ARB_debug_output )
- {
- glEnable(GL_DEBUG_OUTPUT);
- glDebugMessageCallback(&debug_callback, NULL);
- }
-
-#endif
-
static bool bGlewInit = false;
if(!bGlewInit)
{
@@ -533,6 +523,16 @@ bool OpenGLContext::ImplInit()
bGlewInit = true;
}
+#ifdef DBG_UTIL
+ // only enable debug output in dbgutil build
+ if( GLEW_ARB_debug_output )
+ {
+ glEnable(GL_DEBUG_OUTPUT);
+ glDebugMessageCallback(&debug_callback, NULL);
+ }
+
+#endif
+
SAL_INFO("vcl.opengl", "OpenGLContext::ImplInit----end");
mbInitialized = true;
return true;
commit 0515a9fca1a0db34fbad4c5c6fd4c881b743a870
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri May 9 05:19:32 2014 +0200
let us at least try to render the shapes
Change-Id: I8753c6a9397117137d4da25f76db1f9cae23f90e
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index adce1ee..8f443d1 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -169,6 +169,7 @@ void GL3DBarChart::render()
{
itr->render();
}
+ mpRenderer->ProcessUnrenderedShape();
mrWindow.getContext()->swapBuffers();
}
commit 7c1bf9e53b8dafcdcd418e5b378411e7742d67e8
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri May 9 04:10:19 2014 +0200
delete OpenGL resources in the destructor
Change-Id: Ibfeb836d23d48e4ad9fd9b111394b8349ba7c8a3
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list