summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-05-21 14:23:07 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-05-21 14:24:09 +0200
commit2bbcf97eb35b98da33f3aaba67cd7abc1a265c69 (patch)
tree2a58d363ed4db9a3eda10cb6dca75d479c3dcead
parentb8e8c9c471ba6974886dd624630144ef2edccb2c (diff)
fix my issues with the offscreen rendering
Change-Id: I4a2ed8a20890119220d63a6768f13365a7b5f97d
-rw-r--r--chart2/source/view/charttypes/GL3DBarChart.cxx4
-rw-r--r--chart2/source/view/inc/GL3DRenderer.hxx4
-rw-r--r--chart2/source/view/main/GL3DRenderer.cxx9
-rw-r--r--include/vcl/opengl/OpenGLHelper.hxx4
-rw-r--r--vcl/source/opengl/OpenGLHelper.cxx33
5 files changed, 26 insertions, 28 deletions
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index d36a00869cd8..5e21945e63dc 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 b08e90e22ae6..c2d7b87c648a 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 cf75ea63e188..d2480163b931 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 70b1d2aa637a..475bd720c082 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 ad2506d9166e..50d5799d7797 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);