summaryrefslogtreecommitdiff
path: root/vcl/opengl/gdiimpl.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-09-13 13:24:01 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2016-09-21 13:33:10 +0200
commit7ac5ccde2d7332b926df509d840f775a65d0c9dd (patch)
treeafaa81006a7622796bc7820e512666a97f5714d0 /vcl/opengl/gdiimpl.cxx
parentca3c8526efc57eb90dcb238dd740cfe41df13b31 (diff)
SceneGraph experiment
Change-Id: I1e88559034a2a2787c70bdb4bcf4f7c61fc328e1
Diffstat (limited to 'vcl/opengl/gdiimpl.cxx')
-rw-r--r--vcl/opengl/gdiimpl.cxx64
1 files changed, 61 insertions, 3 deletions
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 5fd46b6465f6..4301b1c9d447 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -45,6 +45,9 @@
#include <stdlib.h>
+#include "SceneGraphNodes.hxx"
+#include "opengl/SceneGraphRenderer.hxx"
+
class OpenGLFlushIdle : public Idle
{
OpenGLSalGraphicsImpl *m_pImpl;
@@ -1309,12 +1312,13 @@ void OpenGLSalGraphicsImpl::DeferredTextDraw(OpenGLTexture& rTexture, SalColor a
PostBatchDraw();
}
-bool OpenGLSalGraphicsImpl::FlushLinesOrTriangles(DrawShaderType eType, RenderParameters& rParameters)
+bool OpenGLSalGraphicsImpl::FlushLinesOrTriangles(DrawShaderType eType, glm::mat4 aMatrix, RenderParameters& rParameters)
{
if (!UseProgram("combinedVertexShader", "combinedFragmentShader", "#define USE_VERTEX_COLORS"))
return false;
mpProgram->SetShaderType(eType);
+ mpProgram->SetTransform("transform", aMatrix);
mpProgram->SetBlendMode(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
ApplyProgramMatrices(0.5f);
@@ -1361,13 +1365,13 @@ void OpenGLSalGraphicsImpl::FlushDeferredDrawing()
{
RenderParameters& rParameters = rRenderEntry.maTriangleParameters;
VCL_GL_INFO("Flush Triangles: " << rParameters.maVertices.size());
- FlushLinesOrTriangles(DrawShaderType::Normal, rParameters);
+ FlushLinesOrTriangles(DrawShaderType::Normal, rRenderEntry.maMatrix, rParameters);
}
if (rRenderEntry.hasLines())
{
RenderParameters& rParameters = rRenderEntry.maLineParameters;
VCL_GL_INFO("Flush Lines: " << rParameters.maVertices.size());
- FlushLinesOrTriangles(DrawShaderType::Line, rParameters);
+ FlushLinesOrTriangles(DrawShaderType::Line, rRenderEntry.maMatrix, rParameters);
}
if (rRenderEntry.hasTextures() && UseProgram("combinedTextureVertexShader", "combinedTextureFragmentShader", "#define USE_VERTEX_COLORS"))
{
@@ -1389,6 +1393,51 @@ void OpenGLSalGraphicsImpl::FlushDeferredDrawing()
}
mpProgram->Clean();
}
+ if (rRenderEntry.hasNewTextures() && UseProgram("combinedTextureVertexShader", "combinedTextureFragmentShader", "#define USE_VERTEX_COLORS"))
+ {
+ mpProgram->SetShaderType(TextureShaderType::Normal);
+ mpProgram->SetTransform("transform", rRenderEntry.maMatrix);
+ mpProgram->SetBlendMode(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ for (auto& rPair : rRenderEntry.maTextureMap)
+ {
+ TextureParameters& rParameters = rPair.second;
+ mpProgram->SetTexture("texture", rParameters.maTexture);
+ ApplyProgramMatrices();
+
+ vcl::VertexBufferObject<TextureVertex> vbo;
+ vbo.upload(rParameters.maVertices);
+
+ GLuint positionAttrib = SAL_MAX_UINT32;
+ GLuint texCoordAttrib = SAL_MAX_UINT32;
+ GLuint maskCoordAttrib = SAL_MAX_UINT32;
+ GLuint alphaCoordAttrib = SAL_MAX_UINT32;
+ GLuint colorAttrib = SAL_MAX_UINT32;
+
+ mpProgram->SetVertexAttrib(positionAttrib, "position", 2, GL_FLOAT, GL_FALSE,
+ sizeof(TextureVertex), reinterpret_cast<void*>(offsetof(TextureVertex, position)));
+
+ mpProgram->SetVertexAttrib(texCoordAttrib, "tex_coord_in", 2, GL_FLOAT, GL_FALSE,
+ sizeof(TextureVertex), reinterpret_cast<void*>(offsetof(TextureVertex, texCoords)));
+
+ mpProgram->SetVertexAttrib(maskCoordAttrib, "mask_coord_in", 2, GL_FLOAT, GL_FALSE,
+ sizeof(TextureVertex), reinterpret_cast<void*>(offsetof(TextureVertex, maskCoords)));
+
+ mpProgram->SetVertexAttrib(alphaCoordAttrib, "alpha_coord_in", 2, GL_FLOAT, GL_FALSE,
+ sizeof(TextureVertex), reinterpret_cast<void*>(offsetof(TextureVertex, alphaCoords)));
+
+ mpProgram->SetVertexAttrib(colorAttrib, "vertex_color_in", 4, GL_FLOAT, GL_FALSE,
+ sizeof(TextureVertex), reinterpret_cast<void*>(offsetof(TextureVertex, color)));
+
+ vcl::IndexBufferObject ibo;
+ ibo.upload(rParameters.maIndices);
+ ibo.bind();
+
+ mpProgram->DrawElements(GL_TRIANGLES, rParameters.maIndices.size());
+ CHECK_GL_ERROR();
+ }
+ mpProgram->Clean();
+ }
}
mpRenderList->clear();
@@ -2159,4 +2208,13 @@ void OpenGLSalGraphicsImpl::doFlush()
VCL_GL_INFO( "doFlush - end." );
}
+bool OpenGLSalGraphicsImpl::renderSceneGraph(vcl::sg::RootNode& rRootNode)
+{
+ SceneGraphRenderer aSceneGraphRenderer(rRootNode, *mpRenderList);
+ aSceneGraphRenderer.render(GetWidth(), GetHeight());
+
+ FlushDeferredDrawing();
+ return true;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */