Kaydet (Commit) 61b2ae31 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

use FBO for the picking

Change-Id: Ibab6daa1f76300d159ccd4cfbca061c8d8c1951f
üst 8c39739a
......@@ -217,14 +217,16 @@ public:
}
void GL3DBarChart::clickedAt(const Point& )
void GL3DBarChart::clickedAt(const Point& rPos)
{
sal_uInt32 nId = 1;
{
PickingModeSetter(mpRenderer.get());
render();
nId = mpRenderer->GetPixelColorFromPoint(rPos.X(), rPos.Y());
}
if (mpCamera)
mpCamera->zoom(1);
mpCamera->zoom(nId);
}
}
......
......@@ -179,6 +179,8 @@ public:
void ProcessUnrenderedShape();
void SetPickingMode(bool bPickingMode);
sal_uInt32 GetPixelColorFromPoint(long nX, long nY);
private:
void MoveModelf(PosVecf3& trans,PosVecf3& angle,PosVecf3& scale);
......@@ -362,6 +364,10 @@ private:
bool mbPickingMode;
SceneBox m_SenceBox;
GLuint mnPickingFbo;
GLuint mnPickingRbo;
GLuint mnPickingTexture;
};
}
......
......@@ -249,6 +249,8 @@ void OpenGL3DRenderer::init()
glBufferData(GL_ARRAY_BUFFER, sizeof(squareVertices), squareVertices, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
OpenGLHelper::createFramebuffer(m_iWidth, m_iHeight, mnPickingFbo, mnPickingRbo, mnPickingTexture);
CHECK_GL_ERROR();
Init3DUniformBlock();
......@@ -1580,6 +1582,22 @@ void OpenGL3DRenderer::MoveModelf(PosVecf3& trans,PosVecf3& angle,PosVecf3& scal
void OpenGL3DRenderer::SetPickingMode(bool bPickingMode)
{
mbPickingMode = bPickingMode;
if(mbPickingMode)
{
glBindFramebuffer(GL_FRAMEBUFFER, mnPickingFbo);
}
else
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
}
sal_uInt32 OpenGL3DRenderer::GetPixelColorFromPoint(long nX, long nY)
{
boost::scoped_array<sal_uInt8> buf(new sal_uInt8[4]);
glReadPixels(nX, nY, 1, 1, GL_BGRA, GL_UNSIGNED_BYTE, buf.get());
Color aColor(buf[3], buf[2], buf[1], buf[0]);
return aColor.GetColor();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment