summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-05-15 10:55:02 +0200
committerMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-05-15 14:01:09 +0200
commit759573b37fad51bd4f5164acd645f186ed91809d (patch)
tree010ea3d3fce0e04867424229e1ed5e98d98dbba5
parenta050856a670db629336681cdf4e5f36c4efefa57 (diff)
introduce picking mode in 3D code
Change-Id: Ifbe35a9b311bf79fa15bbad6b9fdfc5a472f516f
-rw-r--r--chart2/source/view/charttypes/GL3DBarChart.cxx27
-rw-r--r--chart2/source/view/inc/GL3DBarChart.hxx1
-rw-r--r--chart2/source/view/inc/GL3DRenderer.hxx90
-rw-r--r--chart2/source/view/main/GL3DRenderer.cxx146
-rw-r--r--vcl/source/window/openglwin.cxx1
5 files changed, 156 insertions, 109 deletions
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index d570c723b324..98f015b88fe4 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -26,6 +26,7 @@ namespace chart {
GL3DBarChart::GL3DBarChart(
const css::uno::Reference<css::chart2::XChartType>& xChartType,
OpenGLWindow& rWindow) :
+ mbPickingMode(false),
mxChartType(xChartType),
mpRenderer(new opengl3D::OpenGL3DRenderer()),
mrWindow(rWindow),
@@ -186,8 +187,34 @@ void GL3DBarChart::update()
render();
}
+namespace {
+
+class PickingModeSetter
+{
+private:
+ opengl3D::OpenGL3DRenderer* mpRenderer;
+
+public:
+ PickingModeSetter(opengl3D::OpenGL3DRenderer* pRenderer):
+ mpRenderer(pRenderer)
+ {
+ mpRenderer->SetPickingMode(true);
+ }
+
+ ~PickingModeSetter()
+ {
+ mpRenderer->SetPickingMode(false);
+ }
+};
+
+}
+
void GL3DBarChart::clickedAt(const Point& )
{
+ {
+ PickingModeSetter(mpRenderer.get());
+ render();
+ }
if (mpCamera)
mpCamera->zoom(1);
}
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index 92a3b6c514c4..81e7639a6896 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -49,6 +49,7 @@ public:
virtual void clickedAt(const Point& rPos) SAL_OVERRIDE;
private:
+ bool mbPickingMode;
css::uno::Reference<css::chart2::XChartType> mxChartType;
boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 9d5f4414d65d..c33735c08903 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -166,10 +166,11 @@ 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 SetPickingMode(bool bPickingMode);
private:
void MoveModelf(PosVecf3& trans,PosVecf3& angle,PosVecf3& scale);
- void LoadShaders();
void GetFreq();
void RenderPolygon3DObject();
void RenderLine3D(Polygon3DInfo &polygon);
@@ -206,6 +207,58 @@ private:
void CreateBMPHeader(sal_uInt8 *bmpHeader, int xsize, int ysize);
void RenderTexture(GLuint TexID);
private:
+
+ struct ShaderResources
+ {
+ // 3DProID
+ GLint m_3DProID;
+ GLuint m_3DProjectionID;
+ GLuint m_3DViewID;
+ GLuint m_3DModelID;
+ GLuint m_3DNormalMatrixID;
+ GLuint m_3DVertexID;
+ GLuint m_3DNormalID;
+
+ // TextProID
+ GLint m_TextProID;
+ GLint m_TextMatrixID;
+ GLint m_TextVertexID;
+ GLint m_TextTexCoordID;
+ GLint m_TextTexID;
+
+ // CommonProID
+ GLint m_CommonProID;
+ GLint m_2DVertexID;
+ GLint m_2DColorID;
+ GLint m_MatrixID;
+
+ // RenderProID
+ GLint m_RenderProID;
+ GLint m_RenderTexID;
+ GLint m_RenderVertexID;
+ GLint m_RenderTexCoordID;
+
+ ShaderResources():
+ m_3DProID(0),
+ m_TextProID(0),
+ m_CommonProID(0),
+ m_RenderProID(0) {}
+
+ ~ShaderResources()
+ {
+ glDeleteProgram(m_CommonProID);
+ glDeleteProgram(m_RenderProID);
+ glDeleteProgram(m_TextProID);
+ glDeleteProgram(m_3DProID);
+ }
+
+ void LoadShaders();
+ };
+
+ ShaderResources maNormalResources;
+ ShaderResources maPickingResources;
+ ShaderResources* pResources;
+
// Projection matrix : default 45 degree Field of View, 4:3 ratio, display range : 0.1 unit <-> 100 units
glm::mat4 m_Projection;
// Camera matrix
@@ -235,20 +288,6 @@ private:
glm::mat4 m_3DMVP;
- GLint m_3DProID;
-
- GLuint m_3DProjectionID;
-
- GLuint m_3DViewID;
-
- GLuint m_3DModelID;
-
- GLuint m_3DVertexID;
-
- GLuint m_3DNormalID;
-
- GLuint m_3DNormalMatrixID;
-
GLuint m_3DUBOBuffer;
#if 0
GLint m_3DLightBlockIndex;
@@ -261,8 +300,6 @@ private:
GLuint m_VertexBuffer;
- GLint m_MatrixID;
-
Extrude3DInfo m_Extrude3DInfo;
std::vector <Extrude3DInfo> m_Extrude3DList;
@@ -277,12 +314,7 @@ private:
GLuint m_BoundBoxNormal;
// add for text
std::list <TextInfo> m_TextInfoList;
- GLint m_TextProID;
- GLint m_TextMatrixID;
- GLint m_TextVertexID;
- GLint m_TextTexCoordID;
GLuint m_TextTexCoordBuf;
- GLint m_TextTexID;
int m_uiSelectFrameCounter;
@@ -294,25 +326,15 @@ private:
RoundBarMesh m_RoundBarMesh;
- GLint m_CommonProID;
- GLint m_2DVertexID;
- GLint m_2DColorID;
-
- GLint m_RenderProID;
-
GLuint m_RenderVertexBuf;
GLuint m_RenderTexCoordBuf;
- GLint m_RenderTexID;
-
- GLint m_RenderVertexID;
-
- GLint m_RenderTexCoordID;
-
float m_fViewAngle;
float m_fHeightWeight;
+
+ bool mbPickingMode;
};
}
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index abb41b094936..6645b92a8f9f 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -71,15 +71,11 @@ glm::vec4 getColorAsVector(sal_uInt32 nColor)
}
OpenGL3DRenderer::OpenGL3DRenderer():
- m_TextProID(0)
- , m_TextMatrixID(0)
- , m_TextVertexID(0)
- , m_TextTexCoordID(0)
- , m_TextTexCoordBuf(0)
- , m_TextTexID(0)
+ pResources(&maPickingResources)
, m_uiSelectFrameCounter(0)
, m_fViewAngle(30.0f)
, m_fHeightWeight(1.0f)
+ , mbPickingMode(false)
{
m_Polygon3DInfo.lineOnly = false;
m_Polygon3DInfo.twoSidesLighting = false;
@@ -96,12 +92,6 @@ OpenGL3DRenderer::OpenGL3DRenderer():
OpenGL3DRenderer::~OpenGL3DRenderer()
{
- // delete programs
- glDeleteProgram(m_CommonProID);
- glDeleteProgram(m_RenderProID);
- glDeleteProgram(m_TextProID);
- glDeleteProgram(m_3DProID);
-
// delete buffers
glDeleteBuffers(1, &m_CubeVertexBuf);
glDeleteBuffers(1, &m_CubeNormalBuf);
@@ -114,7 +104,7 @@ OpenGL3DRenderer::~OpenGL3DRenderer()
glDeleteBuffers(1, &m_3DUBOBuffer);
}
-void OpenGL3DRenderer::LoadShaders()
+void OpenGL3DRenderer::ShaderResources::LoadShaders()
{
m_3DProID = OpenGLHelper::LoadShaders("shape3DVertexShader", "shape3DFragmentShader");
m_3DProjectionID = glGetUniformLocation(m_3DProID, "P");
@@ -153,22 +143,22 @@ void OpenGL3DRenderer::RenderTexture(GLuint TexID)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glUseProgram(m_RenderProID);
+ glUseProgram(pResources->m_RenderProID);
- glEnableVertexAttribArray(m_RenderVertexID);
+ glEnableVertexAttribArray(pResources->m_RenderVertexID);
glBindBuffer(GL_ARRAY_BUFFER, m_RenderVertexBuf);
glVertexAttribPointer(
- m_RenderVertexID, // attribute. No particular reason for 0, but must match the layout in the shader.
+ pResources->m_RenderVertexID, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
- glEnableVertexAttribArray(m_RenderTexCoordID);
+ glEnableVertexAttribArray(pResources->m_RenderTexCoordID);
glBindBuffer(GL_ARRAY_BUFFER, m_RenderTexCoordBuf);
glVertexAttribPointer(
- m_RenderTexCoordID, // attribute. No particular reason for 0, but must match the layout in the shader.
+ pResources->m_RenderTexCoordID, // attribute.
2, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
@@ -176,10 +166,10 @@ void OpenGL3DRenderer::RenderTexture(GLuint TexID)
(void*)0 // array buffer offset
);
glBindTexture(GL_TEXTURE_2D, TexID);
- glUniform1i(m_RenderTexID, 0);
+ glUniform1i(pResources->m_RenderTexID, 0);
glDrawArrays(GL_QUADS, 0, 4);
- glDisableVertexAttribArray(m_RenderTexCoordID);
- glDisableVertexAttribArray(m_RenderVertexID);
+ glDisableVertexAttribArray(pResources->m_RenderTexCoordID);
+ glDisableVertexAttribArray(pResources->m_RenderVertexID);
glBindTexture(GL_TEXTURE_2D, 0);
glUseProgram(0);
}
@@ -223,7 +213,8 @@ void OpenGL3DRenderer::init()
m_fViewAngle = 60.0f;
m_3DProjection = glm::perspective(m_fViewAngle, (float)m_iWidth / (float)m_iHeight, 0.01f, 2000.0f);
- LoadShaders();
+ maNormalResources.LoadShaders();
+ maPickingResources.LoadShaders();
glGenBuffers(1, &m_TextTexCoordBuf);
glBindBuffer(GL_ARRAY_BUFFER, m_TextTexCoordBuf);
glBufferData(GL_ARRAY_BUFFER, sizeof(texCoords), texCoords, GL_STATIC_DRAW);
@@ -676,7 +667,7 @@ double OpenGL3DRenderer::GetTime()
void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
{
size_t listNum = polygon.verticesList.size();
- glUseProgram(m_CommonProID);
+ glUseProgram(pResources->m_CommonProID);
for (size_t i = 0; i < listNum; i++)
{
//move the circle to the pos, and scale using the xScale and Y scale
@@ -693,12 +684,12 @@ void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
//fill vertex buffer
glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
glBufferData(GL_ARRAY_BUFFER, pointList->size() * sizeof(glm::vec3), &pointList[0][0], GL_STATIC_DRAW);
- glUniform4fv(m_2DColorID, 1, &polygon.polygonColor[0]);
- glUniformMatrix4fv(m_MatrixID, 1, GL_FALSE, &m_3DMVP[0][0]);
+ glUniform4fv(pResources->m_2DColorID, 1, &polygon.polygonColor[0]);
+ glUniformMatrix4fv(pResources->m_MatrixID, 1, GL_FALSE, &m_3DMVP[0][0]);
// 1rst attribute buffer : vertices
- glEnableVertexAttribArray(m_2DVertexID);
+ glEnableVertexAttribArray(pResources->m_2DVertexID);
glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
- glVertexAttribPointer(m_2DVertexID, // attribute. No particular reason for 0, but must match the layout in the shader.
+ glVertexAttribPointer(pResources->m_2DVertexID, // attribute. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
@@ -708,7 +699,7 @@ void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
glLineWidth(polygon.lineWidth);
glDrawArrays(GL_LINE_STRIP, 0, pointList->size());
- glDisableVertexAttribArray(m_2DVertexID);
+ glDisableVertexAttribArray(pResources->m_2DVertexID);
glBindBuffer(GL_ARRAY_BUFFER, 0);
delete pointList;
polygon.verticesList.pop_front();
@@ -731,9 +722,9 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
glBufferSubData(GL_UNIFORM_BUFFER, m_3DActualSizeLight, sizeof(MaterialParameters), &polygon.material);
CHECK_GL_ERROR();
glBindBuffer(GL_UNIFORM_BUFFER, 0);
- glUseProgram(m_3DProID);
- glUniformMatrix4fv(m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
- glUniformMatrix4fv(m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
+ glUseProgram(pResources->m_3DProID);
+ glUniformMatrix4fv(pResources->m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
+ glUniformMatrix4fv(pResources->m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
for (size_t i = 0; i < verticesNum; i++)
{
//move the circle to the pos, and scale using the xScale and Y scale
@@ -753,13 +744,13 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
//fill normal buffer
glBindBuffer(GL_ARRAY_BUFFER, m_NormalBuffer);
glBufferData(GL_ARRAY_BUFFER, normalList->size() * sizeof(glm::vec3), &normalList[0][0], GL_STATIC_DRAW);
- glUniformMatrix4fv(m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
- glUniformMatrix3fv(m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+ glUniformMatrix4fv(pResources->m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+ glUniformMatrix3fv(pResources->m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
// 1rst attribute buffer : vertices
- glEnableVertexAttribArray(m_3DVertexID);
+ glEnableVertexAttribArray(pResources->m_3DVertexID);
glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
- glVertexAttribPointer(m_3DVertexID, // attribute. No particular reason for 0, but must match the layout in the shader.
+ glVertexAttribPointer(pResources->m_3DVertexID, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
@@ -767,9 +758,9 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
(void*)0 // array buffer offset
);
// 2nd attribute buffer : normals
- glEnableVertexAttribArray(m_3DNormalID);
+ glEnableVertexAttribArray(pResources->m_3DNormalID);
glBindBuffer(GL_ARRAY_BUFFER, m_NormalBuffer);
- glVertexAttribPointer(m_3DNormalID, // attribute. No particular reason for 0, but must match the layout in the shader.
+ glVertexAttribPointer(pResources->m_3DNormalID, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
@@ -778,8 +769,8 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
);
glDrawArrays(GL_POLYGON, 0, pointList->size());
- glDisableVertexAttribArray(m_3DVertexID);
- glDisableVertexAttribArray(m_3DNormalID);
+ glDisableVertexAttribArray(pResources->m_3DVertexID);
+ glDisableVertexAttribArray(pResources->m_3DNormalID);
glBindBuffer(GL_ARRAY_BUFFER, 0);
delete pointList;
delete normalList;
@@ -967,8 +958,8 @@ void OpenGL3DRenderer::EndAddShape3DExtrudeObject()
void OpenGL3DRenderer::Init3DUniformBlock()
{
- GLuint a3DLightBlockIndex = glGetUniformBlockIndex(m_3DProID, "GlobalLights");
- GLuint a3DMaterialBlockIndex = glGetUniformBlockIndex(m_3DProID, "GlobalMaterialParameters");
+ GLuint a3DLightBlockIndex = glGetUniformBlockIndex(pResources->m_3DProID, "GlobalLights");
+ GLuint a3DMaterialBlockIndex = glGetUniformBlockIndex(pResources->m_3DProID, "GlobalMaterialParameters");
if ((GL_INVALID_INDEX == a3DLightBlockIndex) || (GL_INVALID_INDEX == a3DMaterialBlockIndex))
{
@@ -977,8 +968,8 @@ void OpenGL3DRenderer::Init3DUniformBlock()
int nUniformBufferAlignSize = 0;
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &nUniformBufferAlignSize);
GLint nBlockDataSizeLight = 0, nBlockDataSizeMertrial = 0;
- glGetActiveUniformBlockiv(m_3DProID, a3DLightBlockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &nBlockDataSizeLight);
- glGetActiveUniformBlockiv(m_3DProID, a3DMaterialBlockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &nBlockDataSizeMertrial);
+ glGetActiveUniformBlockiv(pResources->m_3DProID, a3DLightBlockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &nBlockDataSizeLight);
+ glGetActiveUniformBlockiv(pResources->m_3DProID, a3DMaterialBlockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &nBlockDataSizeMertrial);
CHECK_GL_ERROR();
glGenBuffers(1, &m_3DUBOBuffer);
glBindBuffer(GL_UNIFORM_BUFFER, m_3DUBOBuffer);
@@ -989,10 +980,10 @@ void OpenGL3DRenderer::Init3DUniformBlock()
glBufferData(GL_UNIFORM_BUFFER, dataSize, NULL, GL_DYNAMIC_DRAW);
glBindBufferRange(GL_UNIFORM_BUFFER, 0, m_3DUBOBuffer, 0, nBlockDataSizeLight);
CHECK_GL_ERROR();
- glUniformBlockBinding(m_3DProID, a3DLightBlockIndex, 0);
+ glUniformBlockBinding(pResources->m_3DProID, a3DLightBlockIndex, 0);
glBindBufferRange(GL_UNIFORM_BUFFER, 1, m_3DUBOBuffer, ((nBlockDataSizeLight / nUniformBufferAlignSize) + std::min(nBlockDataSizeLight % nUniformBufferAlignSize, 1)) * nUniformBufferAlignSize, nBlockDataSizeMertrial);
- glUniformBlockBinding(m_3DProID, a3DMaterialBlockIndex, 1);
+ glUniformBlockBinding(pResources->m_3DProID, a3DMaterialBlockIndex, 1);
//for the light source uniform, we must calc the offset of each element
CHECK_GL_ERROR();
glBindBuffer(GL_UNIFORM_BUFFER, 0);
@@ -1023,8 +1014,8 @@ void OpenGL3DRenderer::RenderExtrudeFlatSurface(const Extrude3DInfo& extrude3D,
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]);
- glUniformMatrix3fv(m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+ glUniformMatrix4fv(pResources->m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+ glUniformMatrix3fv(pResources->m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
glDrawElements(GL_TRIANGLES, extrude3D.size[surIndex], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[surIndex]));
}
@@ -1056,8 +1047,8 @@ void OpenGL3DRenderer::RenderExtrudeBottomSurface(const Extrude3DInfo& extrude3D
}
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]);
+ glUniformMatrix4fv(pResources->m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+ glUniformMatrix3fv(pResources->m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
glDrawElements(GL_TRIANGLES, extrude3D.size[BOTTOM_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[BOTTOM_SURFACE]));
}
@@ -1091,8 +1082,8 @@ void OpenGL3DRenderer::RenderExtrudeMiddleSurface(const Extrude3DInfo& extrude3D
}
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]);
+ glUniformMatrix4fv(pResources->m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+ glUniformMatrix3fv(pResources->m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
glDrawElements(GL_TRIANGLES, extrude3D.size[MIDDLE_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[MIDDLE_SURFACE]));
}
@@ -1127,8 +1118,8 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
}
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]);
+ glUniformMatrix4fv(pResources->m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+ glUniformMatrix3fv(pResources->m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
glDrawElements(GL_TRIANGLES, extrude3D.size[TOP_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[TOP_SURFACE]));
RenderExtrudeFlatSurface(extrude3D, FLAT_BOTTOM_SURFACE);
}
@@ -1138,8 +1129,8 @@ void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D)
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]);
+ glUniformMatrix4fv(pResources->m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
+ glUniformMatrix4fv(pResources->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;
@@ -1150,15 +1141,15 @@ void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D)
}
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]);
+ glUniformMatrix4fv(pResources->m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+ glUniformMatrix3fv(pResources->m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
glDrawArrays(GL_TRIANGLES, 0, 36);
}
void OpenGL3DRenderer::RenderExtrudeSurface(const Extrude3DInfo& extrude3D)
{
- glUniformMatrix4fv(m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
- glUniformMatrix4fv(m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
+ glUniformMatrix4fv(pResources->m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
+ glUniformMatrix4fv(pResources->m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
CHECK_GL_ERROR();
RenderExtrudeMiddleSurface(extrude3D);
// check reverse flag to decide whether to render the top middle
@@ -1181,7 +1172,7 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
glCullFace(GL_BACK);
Update3DUniformBlock();
//render to fbo
- glUseProgram(m_3DProID);
+ glUseProgram(pResources->m_3DProID);
size_t extrude3DNum = m_Extrude3DList.size();
for (size_t i = 0; i < extrude3DNum; i++)
{
@@ -1189,9 +1180,9 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
GLuint vertexBuf = extrude3DInfo.rounded ? m_CubeVertexBuf : m_BoundBox;
GLuint normalBuf = extrude3DInfo.rounded ? m_CubeNormalBuf : m_BoundBoxNormal;
// 1st attribute buffer : vertices
- glEnableVertexAttribArray(m_3DVertexID);
+ glEnableVertexAttribArray(pResources->m_3DVertexID);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuf);
- glVertexAttribPointer(m_3DVertexID, // attribute. No particular reason for 0, but must match the layout in the shader.
+ glVertexAttribPointer(pResources->m_3DVertexID, // attribute. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
@@ -1199,9 +1190,9 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
(void*)0 // array buffer offset
);
// 2nd attribute buffer : normals
- glEnableVertexAttribArray(m_3DNormalID);
+ glEnableVertexAttribArray(pResources->m_3DNormalID);
glBindBuffer(GL_ARRAY_BUFFER, normalBuf);
- glVertexAttribPointer(m_3DNormalID, // attribute. No particular reason for 0, but must match the layout in the shader.
+ glVertexAttribPointer(pResources->m_3DNormalID, // attribute. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
@@ -1224,8 +1215,8 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
{
RenderNonRoundedBar(extrude3DInfo);
}
- glDisableVertexAttribArray(m_3DVertexID);
- glDisableVertexAttribArray(m_3DNormalID);
+ glDisableVertexAttribArray(pResources->m_3DVertexID);
+ glDisableVertexAttribArray(pResources->m_3DNormalID);
}
m_Extrude3DList.clear();
glUseProgram(0);
@@ -1292,15 +1283,15 @@ void OpenGL3DRenderer::RenderTextShape()
CHECK_GL_ERROR();
glBufferData(GL_ARRAY_BUFFER, sizeof(textInfo.vertex), textInfo.vertex, GL_STATIC_DRAW);
CHECK_GL_ERROR();
- glUseProgram(m_TextProID);
+ glUseProgram(pResources->m_TextProID);
CHECK_GL_ERROR();
- glUniformMatrix4fv(m_TextMatrixID, 1, GL_FALSE, &m_MVP[0][0]);
+ glUniformMatrix4fv(pResources->m_TextMatrixID, 1, GL_FALSE, &m_MVP[0][0]);
// 1rst attribute buffer : vertices
- glEnableVertexAttribArray(m_TextVertexID);
+ glEnableVertexAttribArray(pResources->m_TextVertexID);
glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
glVertexAttribPointer(
- m_TextVertexID,
+ pResources->m_TextVertexID,
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
@@ -1309,10 +1300,10 @@ void OpenGL3DRenderer::RenderTextShape()
);
//tex coord
CHECK_GL_ERROR();
- glEnableVertexAttribArray(m_TextTexCoordID);
+ glEnableVertexAttribArray(pResources->m_TextTexCoordID);
glBindBuffer(GL_ARRAY_BUFFER, m_TextTexCoordBuf);
glVertexAttribPointer(
- m_TextTexCoordID,
+ pResources->m_TextTexCoordID,
2, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
@@ -1323,14 +1314,14 @@ void OpenGL3DRenderer::RenderTextShape()
CHECK_GL_ERROR();
glBindTexture(GL_TEXTURE_2D, textInfo.texture);
CHECK_GL_ERROR();
- glUniform1i(m_TextTexID, 0);
+ glUniform1i(pResources->m_TextTexID, 0);
CHECK_GL_ERROR();
//TODO: moggi: get rid fo GL_QUADS
glDrawArrays(GL_QUADS, 0, 4);
CHECK_GL_ERROR();
- glDisableVertexAttribArray(m_TextTexCoordID);
+ glDisableVertexAttribArray(pResources->m_TextTexCoordID);
CHECK_GL_ERROR();
- glDisableVertexAttribArray(m_TextVertexID);
+ glDisableVertexAttribArray(pResources->m_TextVertexID);
CHECK_GL_ERROR();
glBindTexture(GL_TEXTURE_2D, 0);
glUseProgram(0);
@@ -1425,6 +1416,11 @@ void OpenGL3DRenderer::MoveModelf(PosVecf3& trans,PosVecf3& angle,PosVecf3& scal
m_Model = aTranslationMatrix * aRotationMatrix * aScaleMatrix;
}
+void OpenGL3DRenderer::SetPickingMode(bool bPickingMode)
+{
+ mbPickingMode = bPickingMode;
+}
+
}
}
diff --git a/vcl/source/window/openglwin.cxx b/vcl/source/window/openglwin.cxx
index 880376c726b0..d6fb9c46df9d 100644
--- a/vcl/source/window/openglwin.cxx
+++ b/vcl/source/window/openglwin.cxx
@@ -23,6 +23,7 @@ private:
OpenGLWindowImpl::OpenGLWindowImpl(SystemChildWindow* pWindow)
{
maContext.init(pWindow);
+ pWindow->SetMouseTransparent(false);
}
OpenGLContext* OpenGLWindowImpl::getContext()