fix my issues with the offscreen rendering
Change-Id: I4a2ed8a20890119220d63a6768f13365a7b5f97d
This commit is contained in:
parent
b8e8c9c471
commit
2bbcf97eb3
@ -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);
|
||||
}
|
||||
|
||||
|
@ -366,8 +366,8 @@ private:
|
||||
SceneBox m_SenceBox;
|
||||
|
||||
GLuint mnPickingFbo;
|
||||
GLuint mnPickingRbo;
|
||||
GLuint mnPickingTexture;
|
||||
GLuint mnPickingRboDepth;
|
||||
GLuint mnPickingRboColor;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user