[Libreoffice-commits] core.git: Branch 'feature/chart-3d-chart2' - chart2/source include/vcl vcl/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Wed May 21 05:29:37 PDT 2014
chart2/source/view/charttypes/GL3DBarChart.cxx | 4 +--
chart2/source/view/inc/GL3DRenderer.hxx | 4 +--
chart2/source/view/main/GL3DRenderer.cxx | 9 ++++--
include/vcl/opengl/OpenGLHelper.hxx | 4 +--
vcl/source/opengl/OpenGLHelper.cxx | 33 ++++++++++---------------
5 files changed, 26 insertions(+), 28 deletions(-)
New commits:
commit 12dd1c3999f7784aba438df38d55c5a8bd2cad3e
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Wed May 21 14:23:07 2014 +0200
fix my issues with the offscreen rendering
Change-Id: I4a2ed8a20890119220d63a6768f13365a7b5f97d
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index d36a008..5e21945 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -221,11 +221,11 @@ void GL3DBarChart::clickedAt(const Point& rPos)
{
sal_uInt32 nId = 1;
{
- PickingModeSetter(mpRenderer.get());
+ PickingModeSetter aPickingModeSetter(mpRenderer.get());
render();
nId = mpRenderer->GetPixelColorFromPoint(rPos.X(), rPos.Y());
}
- if (mpCamera)
+ if (mpCamera && nId != COL_WHITE)
mpCamera->zoom(nId);
}
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index b08e90e..c2d7b87 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -366,8 +366,8 @@ private:
SceneBox m_SenceBox;
GLuint mnPickingFbo;
- GLuint mnPickingRbo;
- GLuint mnPickingTexture;
+ GLuint mnPickingRboDepth;
+ GLuint mnPickingRboColor;
};
}
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index cf75ea6..d248016 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -112,8 +112,8 @@ OpenGL3DRenderer::~OpenGL3DRenderer()
glDeleteBuffers(1, &m_VertexBuffer);
glDeleteFramebuffers(1, &mnPickingFbo);
- glDeleteRenderbuffers(1, &mnPickingRbo);
- glDeleteTextures(1, &mnPickingTexture);
+ glDeleteRenderbuffers(1, &mnPickingRboDepth);
+ glDeleteRenderbuffers(1, &mnPickingRboColor);
}
void OpenGL3DRenderer::ShaderResources::LoadShaders()
@@ -253,7 +253,7 @@ 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);
+ OpenGLHelper::createFramebuffer(m_iWidth, m_iHeight, mnPickingFbo, mnPickingRboDepth, mnPickingRboColor);
CHECK_GL_ERROR();
Init3DUniformBlock();
@@ -1601,6 +1601,9 @@ 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]);
+ static sal_Int32 i = 0;
+ OUString aFileName = OUString("/home/moggi/Documents/work/shader") + OUString::number(i) + ".png";
+ OpenGLHelper::renderToFile(m_iWidth, m_iHeight, aFileName);
return aColor.GetColor();
}
diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx
index 70b1d2a..475bd72 100644
--- a/include/vcl/opengl/OpenGLHelper.hxx
+++ b/include/vcl/opengl/OpenGLHelper.hxx
@@ -32,10 +32,10 @@ public:
/**
* The caller is responsible for deleting the buffer objects identified by
- * nFramebufferId, nRenderbufferId and nTexturebufferId
+ * nFramebufferId, nRenderbufferDepthId and nRenderbufferColorId
*/
static void createFramebuffer(long nWidth, long nHeight,
- GLuint& nFramebufferId, GLuint& nRenderbufferId, GLuint& nTexturebufferId);
+ GLuint& nFramebufferId, GLuint& nRenderbufferTextId, GLuint& nRenderbufferColorId);
};
VCLOPENGL_DLLPUBLIC std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix);
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index ad2506d..50d5799 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -269,36 +269,31 @@ std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix)
}
void OpenGLHelper::createFramebuffer(long nWidth, long nHeight,
- GLuint& nFramebufferId, GLuint& nRenderbufferId, GLuint& nTexturebufferId)
+ GLuint& nFramebufferId, GLuint& nRenderbufferDepthId, GLuint& nRenderbufferColorId)
{
- // create a renderbuffer
- glGenRenderbuffers(1, &nRenderbufferId);
- glBindRenderbuffer(GL_RENDERBUFFER, nRenderbufferId);
+ // create a renderbuffer for depth attachment
+ glGenRenderbuffers(1, &nRenderbufferDepthId);
+ glBindRenderbuffer(GL_RENDERBUFFER, nRenderbufferDepthId);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, nWidth, nHeight);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
- // create a texture
- glGenTextures(1, &nTexturebufferId);
- glBindTexture(GL_TEXTURE_2D, nTexturebufferId);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, nWidth, nHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- glBindTexture(GL_TEXTURE_2D, 0);
+ // create a renderbuffer for color attachment
+ glGenRenderbuffers(1, &nRenderbufferColorId);
+ glBindRenderbuffer(GL_RENDERBUFFER, nRenderbufferColorId);
+ glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, nWidth, nHeight);
+ glBindRenderbuffer(GL_RENDERBUFFER, 0);
// create a framebuffer object and attach renderbuffer and texture
glGenFramebuffers(1, &nFramebufferId);
glCheckFramebufferStatus(GL_FRAMEBUFFER);
glBindFramebuffer(GL_FRAMEBUFFER, nFramebufferId);
- glBindTexture(GL_TEXTURE_2D, nTexturebufferId);
- // attach a texture to FBO color attachement point
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, nTexturebufferId, 0);
+ // attach a renderbuffer to FBO color attachement point
+ glBindRenderbuffer(GL_RENDERBUFFER, nRenderbufferColorId);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, nRenderbufferColorId);
glCheckFramebufferStatus(GL_FRAMEBUFFER);
- glBindTexture(GL_TEXTURE_2D, 0);
// attach a renderbuffer to depth attachment point
- glBindRenderbuffer(GL_RENDERBUFFER, nRenderbufferId);
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, nRenderbufferId);
+ glBindRenderbuffer(GL_RENDERBUFFER, nRenderbufferDepthId);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, nRenderbufferDepthId);
glCheckFramebufferStatus(GL_FRAMEBUFFER);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
More information about the Libreoffice-commits
mailing list