canvas/source/opengl/ogl_canvascustomsprite.cxx | 7 ++++- canvas/source/opengl/ogl_canvashelper.cxx | 32 ++++------------------- canvas/source/opengl/ogl_canvastools.cxx | 33 +++++++++++++++++------- canvas/source/opengl/ogl_canvastools.hxx | 5 ++- canvas/source/opengl/ogl_renderHelper.cxx | 13 +++++---- canvas/source/opengl/ogl_spritedevicehelper.cxx | 4 -- vcl/source/opengl/OpenGLHelper.cxx | 19 +++++++------ 7 files changed, 57 insertions(+), 56 deletions(-)
New commits: commit 293a54dd59928330baf1873e23f4cb61c73e33e0 Author: Michael Jaumann <meta_...@yahoo.com> Date: Wed Nov 19 08:20:59 2014 +0000 unbind buffers, remove GlewInit() Change-Id: I9304fa6ae3b02812d53c91dde0470d09b4cc3668 diff --git a/canvas/source/opengl/ogl_renderHelper.cxx b/canvas/source/opengl/ogl_renderHelper.cxx index 7bf6a94..1d1379b 100644 --- a/canvas/source/opengl/ogl_renderHelper.cxx +++ b/canvas/source/opengl/ogl_renderHelper.cxx @@ -11,7 +11,6 @@ namespace oglcanvas } void RenderHelper::InitOpenGL() { - GLenum err = glewInit(); //Load Shaders // m_texManProgID = OpenGLHelper::LoadShaders("textManipulatingVertexShader", "textFragmentShader"); m_simpleProgID = OpenGLHelper::LoadShaders("simpleVertexShader", "textFragmentShader"); @@ -37,7 +36,7 @@ namespace oglcanvas m_simplePosAttrb = glGetAttribLocation(m_simpleProgID ,"vPosition"); m_texPosAttrb = glGetAttribLocation(m_texProgID ,"vPosition"); - //glViewport(0, 0, m_iWidth, m_iHeight); + glViewport(0, 0, m_iWidth, m_iHeight); } //Todo figgure out, which parameters i should use :) void RenderHelper::SetVP(int width, int height) @@ -77,8 +76,8 @@ namespace oglcanvas glDrawArrays(mode, 0, sizeof(vertices) / sizeof(vertices[0]) /2); glDisableVertexAttribArray(m_texPosAttrb); - glUseProgram(0); glBindBuffer(GL_ARRAY_BUFFER, 0); + glUseProgram(0); } //Renders a TriangleStrip, Texture has to be stored in TextureUnit0 @@ -122,6 +121,7 @@ namespace oglcanvas glDisableVertexAttribArray(m_simplePosAttrb); glDisableVertexAttribArray(m_simpleUvAttrb); + glBindBuffer(GL_ARRAY_BUFFER, 0); glUseProgram(0); } @@ -164,6 +164,7 @@ namespace oglcanvas glDrawArrays(mode, 0, sizeof(vertices) / sizeof(vertices[0]) /2); glDisableVertexAttribArray(m_manPosAttrb); + glBindBuffer(GL_ARRAY_BUFFER, 0); glUseProgram(0); } } \ No newline at end of file commit 2dee7ecb904e956542a3d74cf28e8a52e2b1af60 Author: Michael Jaumann <meta_...@yahoo.com> Date: Wed Nov 19 08:15:07 2014 +0000 assign lcl_drawPolyPolygon to maFunction Change-Id: I58b465938e64fd44e1dd27b71c248a540dd3abbe diff --git a/canvas/source/opengl/ogl_canvashelper.cxx b/canvas/source/opengl/ogl_canvashelper.cxx index 33d5814..cd9823d 100644 --- a/canvas/source/opengl/ogl_canvashelper.cxx +++ b/canvas/source/opengl/ogl_canvashelper.cxx @@ -500,7 +500,7 @@ namespace oglcanvas ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon)); rAct.maPolyPolys.back().makeUnique(); // own copy, for thread safety - // rAct.maFunction = &lcl_drawPolyPolygon; + rAct.maFunction = &lcl_drawPolyPolygon; } // TODO(P1): Provide caching here. commit 0f8b4f8b9827cb726aa9c8eb604f95beda527cf4 Author: Michael Jaumann <meta_...@yahoo.com> Date: Wed Nov 19 08:13:17 2014 +0000 renderOSD with renderHelper Change-Id: I1acff597434f870504d58e699cb55c76080db15d diff --git a/canvas/source/opengl/ogl_canvascustomsprite.cxx b/canvas/source/opengl/ogl_canvascustomsprite.cxx index 58b2561..6073e5a 100644 --- a/canvas/source/opengl/ogl_canvascustomsprite.cxx +++ b/canvas/source/opengl/ogl_canvascustomsprite.cxx @@ -127,6 +127,7 @@ namespace oglcanvas bool CanvasCustomSprite::renderSprite() { + if( ::basegfx::fTools::equalZero( mfAlpha ) ) return true; @@ -152,6 +153,7 @@ namespace oglcanvas const glm::mat4 translate = glm::translate(glm::vec3(maPosition.getX(), maPosition.getY(), 0)); if( pBufferContext ) { + const glm::mat4 aGLTransform = glm::mat4( maTransformation.m00, maTransformation.m10, 0, 0, maTransformation.m01, maTransformation.m11, 0, 0, @@ -225,7 +227,9 @@ namespace oglcanvas } glBindTexture(GL_TEXTURE_2D, 0); + } + // translate sprite to output position pRenderHelper->SetModelAndMVP(translate); GLfloat vertices[] = {-2, -2, @@ -241,7 +245,8 @@ namespace oglcanvas aVec.push_back(mfAlpha); aVec.push_back(mfPriority); aVec.push_back(maCanvasHelper.getRecordedActionCount()); - renderOSD( aVec, 10 ); + + renderOSD( aVec, 10, pRenderHelper); return true; } diff --git a/canvas/source/opengl/ogl_canvashelper.cxx b/canvas/source/opengl/ogl_canvashelper.cxx index 60216ec..33d5814 100644 --- a/canvas/source/opengl/ogl_canvashelper.cxx +++ b/canvas/source/opengl/ogl_canvashelper.cxx @@ -149,29 +149,7 @@ namespace oglcanvas const ::basegfx::B2DPolyPolygonVector::const_iterator aEnd=rPolyPolygons.end(); while( aCurr != aEnd ) { - // renderPolyPolygon(*aCurr++); - const ::basegfx::B2DPolyPolygon& rPolyPoly= *aCurr++; - ::basegfx::B2DPolyPolygon aPolyPoly(rPolyPoly); - if( aPolyPoly.areControlPointsUsed() ) - aPolyPoly = rPolyPoly.getDefaultAdaptiveSubdivision(); - - for( sal_uInt32 i=0; i<aPolyPoly.count(); i++ ) - { - - - const ::basegfx::B2DPolygon& rPolygon( aPolyPoly.getB2DPolygon(i) ); - - const sal_uInt32 nPts=rPolygon.count(); - const sal_uInt32 nExtPts=nPts + int(rPolygon.isClosed()); - GLfloat vertices[nExtPts*2]; - for( sal_uInt32 j=0; j<nExtPts; j++ ) - { - const ::basegfx::B2DPoint& rPt( rPolygon.getB2DPoint( j % nPts ) ); - vertices[j*2] = rPt.getX(); - vertices[j*2+1] = rPt.getY(); - } - pRenderHelper->renderVertexConstColor(vertices, color, GL_LINE_STRIP); - } + renderPolyPolygon(*aCurr++, pRenderHelper, color); } return true; @@ -299,6 +277,7 @@ namespace oglcanvas sal_uInt32 nPixelCrc32) { + RenderHelper* pRenderHelper = rHelper.getDeviceHelper()->getRenderHelper(); pRenderHelper->SetModelAndMVP(setupState(rTransform, eSrcBlend, eDstBlend)); @@ -319,7 +298,6 @@ namespace oglcanvas // blend against fixed vertex color; texture alpha is multiplied in glm::vec4 color = glm::vec4(1, 1, 1, 1); - GLfloat vertices[] = {0, 0, 0, (float) rPixelSize.Height, (float) rPixelSize.Width, 0, @@ -328,7 +306,7 @@ namespace oglcanvas 0, 1, 1, 0, 1, 1 }; - pRenderHelper->renderVertexUVTex(vertices, uvCoordinates, color, GL_TRIANGLE_STRIP ); + pRenderHelper->renderVertexUVTex(vertices, uvCoordinates, color, GL_TRIANGLE_STRIP ); glBindTexture(GL_TEXTURE_2D, 0); @@ -863,6 +841,7 @@ namespace oglcanvas CanvasBitmap* pOwnBitmap=dynamic_cast<CanvasBitmap*>(xBitmap.get()); if( pOwnBitmap ) { + // insert as transformed copy of bitmap action vector - // during rendering, this gets rendered into a temporary // buffer, and then composited to the front @@ -873,6 +852,7 @@ namespace oglcanvas rAct.maFunction = ::boost::bind(&lcl_drawOwnBitmap, _1,_2,_3,_4,_5, *pOwnBitmap); + } else { diff --git a/canvas/source/opengl/ogl_canvastools.cxx b/canvas/source/opengl/ogl_canvastools.cxx index 0022905..dc751b9 100644 --- a/canvas/source/opengl/ogl_canvastools.cxx +++ b/canvas/source/opengl/ogl_canvastools.cxx @@ -23,6 +23,7 @@ #include <GL/glew.h> #include <glm/gtc/type_ptr.hpp> + using namespace ::com::sun::star; namespace oglcanvas @@ -53,16 +54,28 @@ namespace oglcanvas better not leave triangulation to OpenGL. also, ignores texturing */ - //move to canvashelper, or take renderHelper as parameter? - void renderPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly ) + void renderPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly, RenderHelper *renderHelper, glm::vec4 color) { ::basegfx::B2DPolyPolygon aPolyPoly(rPolyPoly); if( aPolyPoly.areControlPointsUsed() ) aPolyPoly = rPolyPoly.getDefaultAdaptiveSubdivision(); - - for( sal_uInt32 i=0; i<aPolyPoly.count(); i++ ) + for(sal_uInt32 i=0; i<aPolyPoly.count(); i++ ) { + + const ::basegfx::B2DPolygon& rPolygon( aPolyPoly.getB2DPolygon(i) ); + + const sal_uInt32 nPts=rPolygon.count(); + const sal_uInt32 nExtPts=nPts + int(rPolygon.isClosed()); + GLfloat vertices[nExtPts*2]; + for( sal_uInt32 j=0; j<nExtPts; j++ ) + { + const ::basegfx::B2DPoint& rPt( rPolygon.getB2DPoint( j % nPts ) ); + vertices[j*2] = rPt.getX(); + vertices[j*2+1] = rPt.getY(); + } + renderHelper->renderVertexConstColor(vertices, color, GL_LINE_STRIP); + /* glBegin(GL_LINE_STRIP); const ::basegfx::B2DPolygon& rPolygon( aPolyPoly.getB2DPolygon(i) ); @@ -76,9 +89,12 @@ namespace oglcanvas } glEnd(); + */ + } + } - //makes it sence to enable evrytime glBlend glBlendfunc...? + glm::mat4 setupState( const ::basegfx::B2DHomMatrix& rTransform, GLenum eSrcBlend, GLenum eDstBlend) @@ -96,8 +112,7 @@ namespace oglcanvas return glm::make_mat4(aGLTransform); } - //What does it make, - void renderOSD( const std::vector<double>& rNumbers, double scale ) + void renderOSD( const std::vector<double>& rNumbers, double scale, RenderHelper *renderHelper) { double y=4.0; basegfx::B2DHomMatrix aTmp; @@ -116,9 +131,9 @@ namespace oglcanvas aTmp=aTmp*aScaleShear; aPoly.transform(aTmp); - glColor4f(0,1,0,1); - renderPolyPolygon(aPoly); + glm::vec4 color = glm::vec4(1, 0, 0, 1); + renderPolyPolygon(aPoly, renderHelper, color); } } } diff --git a/canvas/source/opengl/ogl_canvastools.hxx b/canvas/source/opengl/ogl_canvastools.hxx index 4ce9819..1f6679d 100644 --- a/canvas/source/opengl/ogl_canvastools.hxx +++ b/canvas/source/opengl/ogl_canvastools.hxx @@ -13,6 +13,7 @@ #include <sal/config.h> #include <vector> #include <glm/glm.hpp> +#include "ogl_renderHelper.hxx" namespace com { namespace sun { namespace star { namespace rendering { struct ARGBColor; @@ -25,12 +26,12 @@ namespace basegfx { namespace oglcanvas { void renderComplexPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly ); - void renderPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly ); + void renderPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly, RenderHelper *renderHelper, glm::vec4 color ); glm::mat4 setupState( const ::basegfx::B2DHomMatrix& rTransform, unsigned int eSrcBlend, unsigned int eDstBlend ); - void renderOSD( const std::vector<double>& rNumbers, double scale ); + void renderOSD( const std::vector<double>& rNumbers, double scale, RenderHelper *helper); } diff --git a/canvas/source/opengl/ogl_spritedevicehelper.cxx b/canvas/source/opengl/ogl_spritedevicehelper.cxx index 92820ce..a2576c3 100644 --- a/canvas/source/opengl/ogl_spritedevicehelper.cxx +++ b/canvas/source/opengl/ogl_spritedevicehelper.cxx @@ -59,7 +59,6 @@ static void initTransformation(const ::Size& rSize, bool bMirror=false) glViewport( 0,0, (GLsizei)rSize.Width(), (GLsizei)rSize.Height() ); - // model coordinate system is already in device pixel glMatrixMode(GL_MODELVIEW); glLoadIdentity(); @@ -310,7 +309,6 @@ namespace oglcanvas SystemChildWindow* pChildWindow = maContext.getChildWindow(); const ::Size& rOutputSize = pChildWindow->GetSizePixel(); initTransformation(rOutputSize); - // render the actual spritecanvas content mpSpriteCanvas->renderRecordedActions(); @@ -345,7 +343,7 @@ namespace oglcanvas aVec.push_back(mpTextureCache->getCacheSize()); aVec.push_back(mpTextureCache->getCacheMissCount()); aVec.push_back(mpTextureCache->getCacheHitCount()); - renderOSD( aVec, 20 ); + renderOSD( aVec, 20 , getRenderHelper()); /* * TODO: moggi: fix it! commit 554ae9abaf3561f940b4da888703b811c14b849b Author: Michael Jaumann <meta_...@yahoo.com> Date: Wed Nov 19 07:43:06 2014 +0000 create framebuffer color attachment properly Change-Id: Ia374e16d7215f9c50445d3da770b3eb31906cb06 diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx index c3bf509..31fe315 100644 --- a/vcl/source/opengl/OpenGLHelper.cxx +++ b/vcl/source/opengl/OpenGLHelper.cxx @@ -282,38 +282,39 @@ void OpenGLHelper::createFramebuffer(long nWidth, long nHeight, GLuint& nFramebu glBindRenderbuffer(GL_RENDERBUFFER, nRenderbufferDepthId); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, nWidth, nHeight); glBindRenderbuffer(GL_RENDERBUFFER, 0); - + // create a framebuffer object + glGenFramebuffers(1, &nFramebufferId); + glCheckFramebufferStatus(GL_FRAMEBUFFER); + glBindFramebuffer(GL_FRAMEBUFFER, nFramebufferId); if(bRenderbuffer) { // create a renderbuffer for color attachment glGenRenderbuffers(1, &nRenderbufferColorId); glBindRenderbuffer(GL_RENDERBUFFER, nRenderbufferColorId); glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, nWidth, nHeight); + // attach a renderbuffer to FBO color attachement point + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, nRenderbufferColorId); glBindRenderbuffer(GL_RENDERBUFFER, 0); } else { + // create a texture for rendering glGenTextures(1, &nRenderbufferColorId); glBindTexture(GL_TEXTURE_2D, nRenderbufferColorId); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, nWidth, nHeight, 0, - GL_RGBA, GL_UNSIGNED_BYTE, 0); + GL_BGRA, GL_UNSIGNED_BYTE, 0); + glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, nRenderbufferColorId, 0); } - // create a framebuffer object and attach renderbuffer - glGenFramebuffers(1, &nFramebufferId); - glCheckFramebufferStatus(GL_FRAMEBUFFER); - glBindFramebuffer(GL_FRAMEBUFFER, nFramebufferId); - // attach a renderbuffer to FBO color attachement point - glBindRenderbuffer(GL_RENDERBUFFER, nRenderbufferColorId); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, nRenderbufferColorId); glCheckFramebufferStatus(GL_FRAMEBUFFER); // attach a renderbuffer to depth attachment point glBindRenderbuffer(GL_RENDERBUFFER, nRenderbufferDepthId); commit eafa2bf94de3bd42e1f2af23874595f68c4dd560 Author: Michael Jaumann <meta_...@yahoo.com> Date: Thu Nov 13 08:20:02 2014 +0000 vertex color uniform now correct Change-Id: I31d5bd3b308275364a139819c01226e7f2ae8525 diff --git a/canvas/source/opengl/ogl_renderHelper.cxx b/canvas/source/opengl/ogl_renderHelper.cxx index c6b127a..7bf6a94 100644 --- a/canvas/source/opengl/ogl_renderHelper.cxx +++ b/canvas/source/opengl/ogl_renderHelper.cxx @@ -61,7 +61,7 @@ namespace oglcanvas glUseProgram(m_texProgID); - glUniform4fv(m_texColorUnf, 4, glm::value_ptr(color)); + glUniform4fv(m_texColorUnf, 1, glm::value_ptr(color)); glEnableVertexAttribArray(m_texPosAttrb); //vertices glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer); @@ -93,7 +93,7 @@ namespace oglcanvas glUseProgram(m_simpleProgID); glUniform1i(m_simpleTexUnf, 0); //Use texture Unit 0 - glUniform4fv(m_simpleColorUnf, 4, glm::value_ptr(color)); + glUniform4fv(m_simpleColorUnf, 1, glm::value_ptr(color)); glUniformMatrix4fv(m_simpleMVPUnf, 1, GL_FALSE, &m_MVP[0][0]); glEnableVertexAttribArray(m_simplePosAttrb); @@ -147,7 +147,7 @@ namespace oglcanvas //Set Uniforms glUniform1i(m_manTexUnf, 0); glUniform2f(m_manCordUnf,fWidth,fHeight); - glUniform4fv(m_manColorUnf, 4, glm::value_ptr(color)); + glUniform4fv(m_manColorUnf, 1, glm::value_ptr(color)); glUniformMatrix4fv(m_manMVPUnf, 1, GL_FALSE, &m_MVP[0][0]); glEnableVertexAttribArray(m_manPosAttrb); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits