canvas/opengl/simpleVertexShader.glsl | 5 - canvas/opengl/texVertexShader.glsl | 5 - canvas/opengl/textManipulatingVertexShader.glsl | 3 canvas/source/opengl/ogl_canvascustomsprite.cxx | 48 +++++++------ canvas/source/opengl/ogl_canvashelper.cxx | 85 ++++++++++++------------ canvas/source/opengl/ogl_canvastools.cxx | 39 +++-------- canvas/source/opengl/ogl_canvastools.hxx | 2 canvas/source/opengl/ogl_renderHelper.cxx | 66 ++++++++++-------- canvas/source/opengl/ogl_renderHelper.hxx | 29 +++++--- canvas/source/opengl/ogl_spritedevicehelper.cxx | 67 +++++++++--------- canvas/source/opengl/ogl_spritedevicehelper.hxx | 3 11 files changed, 182 insertions(+), 170 deletions(-)
New commits: commit de9b174dede3bcb0575d42f134f6f112d507abc7 Author: Michael Jaumann <meta_...@yahoo.com> Date: Tue Nov 25 14:45:08 2014 +0000 compute gl_position in one line instead of two Change-Id: Id250c0092d533bf23de867ef7dfc51666fa4c1fd diff --git a/canvas/opengl/simpleVertexShader.glsl b/canvas/opengl/simpleVertexShader.glsl index 0aa110f..af3e9cc 100644 --- a/canvas/opengl/simpleVertexShader.glsl +++ b/canvas/opengl/simpleVertexShader.glsl @@ -12,9 +12,8 @@ varying vec2 textCoords; uniform mat4 MVP; void main(void) -{ - vec4 v = vec4(vPosition,1,1); - gl_Position = MVP * v; +{ + gl_Position = MVP * vec4(vPosition,1,1); textCoords = UV; } diff --git a/canvas/opengl/texVertexShader.glsl b/canvas/opengl/texVertexShader.glsl index aadf0de..cce2420 100644 --- a/canvas/opengl/texVertexShader.glsl +++ b/canvas/opengl/texVertexShader.glsl @@ -8,14 +8,13 @@ */ #version 120 - + attribute vec2 vPosition; uniform mat4 MVP; void main(void) { - vec4 v = vec4(vPosition,1,1); - gl_Position = MVP * v; + gl_Position = MVP * vec4(vPosition,1,1); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/canvas/opengl/textManipulatingVertexShader.glsl b/canvas/opengl/textManipulatingVertexShader.glsl index 172fc18..1637ff7 100644 --- a/canvas/opengl/textManipulatingVertexShader.glsl +++ b/canvas/opengl/textManipulatingVertexShader.glsl @@ -16,8 +16,7 @@ uniform mat4 MVP; void main(void) { - vec4 v = vec4(vPosition,1,1); - gl_Position = MVP * v; + gl_Position = MVP * vec4(vPosition,1,1); textCoords = vPosition/texCord; } commit 0513a38ad267a57fee69fcef7a8099e23e9b3894 Author: Michael Jaumann <meta_...@yahoo.com> Date: Tue Nov 25 14:11:29 2014 +0000 use const refs and vectors instead of arrays Change-Id: Ie853e719528ef7f6f72935c8749a5cb8e97c3153 diff --git a/canvas/source/opengl/ogl_canvascustomsprite.cxx b/canvas/source/opengl/ogl_canvascustomsprite.cxx index 6073e5a..9962eb4 100644 --- a/canvas/source/opengl/ogl_canvascustomsprite.cxx +++ b/canvas/source/opengl/ogl_canvascustomsprite.cxx @@ -161,7 +161,8 @@ namespace oglcanvas maTransformation.m02, maTransformation.m12, 0, 1 ); - pRenderHelper->SetModelAndMVP(translate * aGLTransform); + //pRenderHelper->SetModelAndMVP(translate * aGLTransform); + pRenderHelper->SetModelAndMVP( aGLTransform); // content ended up in background buffer - compose to // screen now. Calls below switches us back to window // context, and binds to generated, dynamic texture @@ -200,12 +201,12 @@ namespace oglcanvas aSpriteSizePixel.x, aSpriteSizePixel.y))); - GLfloat vertices[rTriangulatedPolygon.count()*2]; + std::vector<glm::vec2> vertices; + vertices.reserve(rTriangulatedPolygon.count()); for( sal_uInt32 i=0; i<rTriangulatedPolygon.count(); i++ ) { const ::basegfx::B2DPoint& rPt( rTriangulatedPolygon.getB2DPoint(i) ); - vertices[i*2]= rPt.getX(); - vertices[i*2+1]= rPt.getY(); + vertices.push_back(glm::vec2(rPt.getX(), rPt.getY())); } pRenderHelper->renderVertexTex( vertices, fWidth, fHeight, color, GL_TRIANGLES); } @@ -214,14 +215,19 @@ namespace oglcanvas const double fWidth=maSize.Width/aSpriteSizePixel.x; const double fHeight=maSize.Height/aSpriteSizePixel.y; - GLfloat vertices[] = {0, 0, - 0, (float) aSpriteSizePixel.y, - (float) aSpriteSizePixel.x, 0, - (float) aSpriteSizePixel.x, (float) aSpriteSizePixel.y }; - GLfloat uvCoordinates[] = {0, 0, - 0, (float) fHeight, - (float) fWidth, 0, - (float) fWidth, (float) fHeight }; + std::vector<glm::vec2> vertices; + vertices.reserve(4); + vertices.push_back(glm::vec2(0, 0)); + vertices.push_back(glm::vec2(0, (float) aSpriteSizePixel.y)); + vertices.push_back(glm::vec2((float) aSpriteSizePixel.x, 0)); + vertices.push_back(glm::vec2((float) aSpriteSizePixel.x, (float) aSpriteSizePixel.y)); + + std::vector<glm::vec2> uvCoordinates; + uvCoordinates.reserve(4); + uvCoordinates.push_back(glm::vec2(0, 0)); + uvCoordinates.push_back(glm::vec2(0, (float) fHeight)); + uvCoordinates.push_back(glm::vec2((float) fWidth, 0)); + uvCoordinates.push_back(glm::vec2((float) fWidth, (float) fHeight)); pRenderHelper->renderVertexUVTex(vertices, uvCoordinates, color, GL_TRIANGLE_STRIP ); } @@ -230,23 +236,25 @@ namespace oglcanvas } - // translate sprite to output position - pRenderHelper->SetModelAndMVP(translate); - GLfloat vertices[] = {-2, -2, - -2, (float) maSize.Height+4, - (float) maSize.Width+4, (float) maSize.Height+4, - (float) maSize.Width+4, -2, - -2, -2, - (float) maSize.Width+4, (float) maSize.Height+4 }; + std::vector<glm::vec2> vertices; + vertices.reserve(6); + vertices.push_back(glm::vec2(-2, -2)); + vertices.push_back(glm::vec2(-2, (float) maSize.Height+4)); + vertices.push_back(glm::vec2((float) maSize.Width+4, (float) maSize.Height+4)); + vertices.push_back(glm::vec2((float) maSize.Width+4, -2)); + vertices.push_back(glm::vec2(-2, -2)); + vertices.push_back(glm::vec2((float) maSize.Width+4, (float) maSize.Height+4)); pRenderHelper->renderVertexConstColor(vertices, glm::vec4(1, 0, 0, 1), GL_LINE_STRIP); +#ifdef DEBUG_RENDERING std::vector<double> aVec; aVec.push_back(mfAlpha); aVec.push_back(mfPriority); aVec.push_back(maCanvasHelper.getRecordedActionCount()); renderOSD( aVec, 10, pRenderHelper); +#endif return true; } diff --git a/canvas/source/opengl/ogl_canvashelper.cxx b/canvas/source/opengl/ogl_canvashelper.cxx index 74e2ee8..7d25491 100644 --- a/canvas/source/opengl/ogl_canvashelper.cxx +++ b/canvas/source/opengl/ogl_canvashelper.cxx @@ -101,12 +101,14 @@ namespace oglcanvas const geometry::RealPoint2D& rPoint) { RenderHelper* pRenderHelper = rHelper.getDeviceHelper()->getRenderHelper(); - pRenderHelper->SetModelAndMVP(setupState(rTransform, eSrcBlend, eDstBlend)); + setupState(rTransform, eSrcBlend, eDstBlend); glm::vec4 color = glm::vec4( (float) rColor.Red, (float) rColor.Green, (float) rColor.Blue, (float) rColor.Alpha); - GLfloat vertices[] = {(float) rPoint.X, (float) rPoint.Y}; + std::vector<glm::vec2> vertices; + vertices.reserve(1); + vertices.push_back(glm::vec2((float) rPoint.X, (float) rPoint.Y)); pRenderHelper->renderVertexConstColor(vertices, color, GL_POINTS); return true; } @@ -120,13 +122,16 @@ namespace oglcanvas const geometry::RealPoint2D& rEndPoint) { RenderHelper* pRenderHelper = rHelper.getDeviceHelper()->getRenderHelper(); - pRenderHelper->SetModelAndMVP(setupState(rTransform, eSrcBlend, eDstBlend)); + setupState(rTransform, eSrcBlend, eDstBlend); glm::vec4 color = glm::vec4( (float) rColor.Red, (float) rColor.Green, (float) rColor.Blue, (float) rColor.Alpha); - GLfloat vertices[] = {(float) rStartPoint.X, (float) rStartPoint.Y, - (float) rEndPoint.X, (float) rEndPoint.Y }; + + std::vector<glm::vec2> vertices; + vertices.reserve(2); + vertices.push_back(glm::vec2((float) rStartPoint.X, (float) rStartPoint.Y)); + vertices.push_back(glm::vec2((float) rEndPoint.X, (float) rEndPoint.Y)); pRenderHelper->renderVertexConstColor(vertices, color, GL_LINES); return true; } @@ -139,7 +144,7 @@ namespace oglcanvas const ::basegfx::B2DPolyPolygonVector& rPolyPolygons) { RenderHelper* pRenderHelper = rHelper.getDeviceHelper()->getRenderHelper(); - pRenderHelper->SetModelAndMVP(setupState(rTransform, eSrcBlend, eDstBlend)); + setupState(rTransform, eSrcBlend, eDstBlend); glm::vec4 color = glm::vec4( (float) rColor.Red, (float) rColor.Green, (float) rColor.Blue, @@ -278,7 +283,7 @@ namespace oglcanvas { RenderHelper* pRenderHelper = rHelper.getDeviceHelper()->getRenderHelper(); - pRenderHelper->SetModelAndMVP(setupState(rTransform, eSrcBlend, eDstBlend)); + setupState(rTransform, eSrcBlend, eDstBlend); const unsigned int nTexId=rHelper.getDeviceHelper()->getTextureCache().getTexture( rPixelSize, rPixelData.getConstArray(), nPixelCrc32); @@ -297,14 +302,20 @@ 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, - (float) rPixelSize.Width, (float) rPixelSize.Height }; - GLfloat uvCoordinates[] = {0, 0, - 0, 1, - 1, 0, - 1, 1 }; + + std::vector<glm::vec2> vertices; + vertices.reserve(4); + vertices.push_back(glm::vec2(0, 0)); + vertices.push_back(glm::vec2(0, (float) rPixelSize.Height)); + vertices.push_back(glm::vec2((float) rPixelSize.Width, 0)); + vertices.push_back(glm::vec2((float) rPixelSize.Width, (float) rPixelSize.Height)); + + std::vector<glm::vec2> uvCoordinates; + uvCoordinates.reserve(4); + uvCoordinates.push_back(glm::vec2(0, 0)); + uvCoordinates.push_back(glm::vec2(0, 1)); + uvCoordinates.push_back(glm::vec2(1, 0)); + uvCoordinates.push_back(glm::vec2(1, 1)); pRenderHelper->renderVertexUVTex(vertices, uvCoordinates, color, GL_TRIANGLE_STRIP ); glBindTexture(GL_TEXTURE_2D, 0); diff --git a/canvas/source/opengl/ogl_renderHelper.cxx b/canvas/source/opengl/ogl_renderHelper.cxx index acd0a17..70f1769 100644 --- a/canvas/source/opengl/ogl_renderHelper.cxx +++ b/canvas/source/opengl/ogl_renderHelper.cxx @@ -10,13 +10,13 @@ #include <GL/glew.h> #include "ogl_renderHelper.hxx" #include <vcl/opengl/OpenGLHelper.hxx> +#include <vcl/opengl/GLMHelper.hxx> namespace oglcanvas { - RenderHelper::RenderHelper() - : m_iWidth(1600) //Why this dimensions? - , m_iHeight(900) //Whole window, see spritedevicehelper - , m_Model(glm::mat4(1.0f)) + RenderHelper::RenderHelper(): + m_Model(glm::mat4(1.0f)) { + } void RenderHelper::InitOpenGL() { @@ -29,7 +29,7 @@ namespace oglcanvas m_simpleTexUnf = glGetUniformLocation(m_simpleProgID, "TextTex"); m_manCordUnf = glGetUniformLocation(m_texManProgID, "texCord"); - m_texColorUnf = glGetUniformLocation(m_texProgID, "constColor"); + m_texColorUnf = glGetUniformLocation(m_texProgID, "constantColor"); m_manColorUnf = glGetUniformLocation(m_texManProgID,"colorTex"); m_simpleColorUnf = glGetUniformLocation(m_simpleProgID,"colorTex"); @@ -45,29 +45,24 @@ namespace oglcanvas m_simplePosAttrb = glGetAttribLocation(m_simpleProgID ,"vPosition"); m_texPosAttrb = glGetAttribLocation(m_texProgID ,"vPosition"); - //glViewport(0, 0, m_iWidth, m_iHeight); } - //Todo figgure out, which parameters i should use :) - void RenderHelper::SetVP(int width, int height) + + void RenderHelper::SetVP(const float width, const float height) { - m_Projection = glm::ortho(0.f, float(m_iWidth), 0.f, float(m_iHeight), -4.f, 3.f); - m_Projection = m_Projection * glm::scale(glm::vec3((float)width / m_iWidth, -(float)height / m_iHeight, 1.0f)); + m_VP = glm::ortho(0.0f, width, 0.0f, height); - m_View = glm::lookAt(glm::vec3(0,m_iHeight,1), - glm::vec3(0,m_iHeight,0), - glm::vec3(0,1,0) ); } - void RenderHelper::SetModelAndMVP(glm::mat4 mat) + + void RenderHelper::SetModelAndMVP(const glm::mat4& mat) { m_Model = mat; - m_MVP = m_Projection * m_View * m_Model; + m_MVP = m_Model * m_VP; } - - void RenderHelper::renderVertexConstColor(GLfloat vertices[], glm::vec4 color, GLenum mode) const + void RenderHelper::renderVertexConstColor(const std::vector<glm::vec2>& rVertices, glm::vec4 color, GLenum mode) const { glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer); - glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, rVertices.size()*2, &rVertices[0].x, GL_STATIC_DRAW); glUseProgram(m_texProgID); @@ -85,7 +80,7 @@ namespace oglcanvas (void*)0 // array buffer offset ); - glDrawArrays(mode, 0, sizeof(vertices) / 2); + glDrawArrays(mode, 0, rVertices.size()); glDisableVertexAttribArray(m_texPosAttrb); glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -93,13 +88,13 @@ namespace oglcanvas } //Renders a TriangleStrip, Texture has to be stored in TextureUnit0 - void RenderHelper::renderVertexUVTex(GLfloat vertices[], GLfloat uvCoordinates[], glm::vec4 color, GLenum mode) const + void RenderHelper::renderVertexUVTex(const std::vector<glm::vec2>& rVertices, const std::vector<glm::vec2>& rUVcoords, glm::vec4 color, GLenum mode) const { glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer); - glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, rVertices.size()*2, &rVertices[0].x, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, m_uvBuffer); - glBufferData(GL_ARRAY_BUFFER, sizeof(uvCoordinates), uvCoordinates, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, rUVcoords.size()*2, &rUVcoords[0].x, GL_STATIC_DRAW); glUseProgram(m_simpleProgID); @@ -130,7 +125,7 @@ namespace oglcanvas (void*)0 // array buffer offset ); - glDrawArrays(mode, 0, sizeof(vertices) / 2); + glDrawArrays(mode, 0, rVertices.size()); glDisableVertexAttribArray(m_simplePosAttrb); glDisableVertexAttribArray(m_simpleUvAttrb); @@ -150,10 +145,10 @@ namespace oglcanvas // Renders a Polygon, Texture has to be stored in TextureUnit0 // Uses fWidth,fHeight to generate texture coordinates in vertex-shader. - void RenderHelper::renderVertexTex(GLfloat vertices[], GLfloat fWidth, GLfloat fHeight, glm::vec4 color, GLenum mode) const + void RenderHelper::renderVertexTex(const std::vector<glm::vec2>& rVertices, GLfloat fWidth, GLfloat fHeight, glm::vec4 color, GLenum mode) const { glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer); - glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, rVertices.size()*2, &rVertices[0].x, GL_STATIC_DRAW); glUseProgram(m_texManProgID); @@ -174,7 +169,7 @@ namespace oglcanvas (void*)0 // array buffer offset ); - glDrawArrays(mode, 0, sizeof(vertices) / 2); + glDrawArrays(mode, 0, rVertices.size()); glDisableVertexAttribArray(m_manPosAttrb); glBindBuffer(GL_ARRAY_BUFFER, 0); diff --git a/canvas/source/opengl/ogl_renderHelper.hxx b/canvas/source/opengl/ogl_renderHelper.hxx index 803e198..504df4f 100644 --- a/canvas/source/opengl/ogl_renderHelper.hxx +++ b/canvas/source/opengl/ogl_renderHelper.hxx @@ -12,20 +12,21 @@ #include <GL/glew.h> #include <glm/glm.hpp> #include "glm/gtx/transform.hpp" +#include <vector> namespace oglcanvas { class RenderHelper { public: - void renderVertexConstColor(GLfloat vertices[], glm::vec4 color, GLenum mode) const; - void renderVertexUVTex(GLfloat vertices[], GLfloat uvCoordinates[], glm::vec4 color, GLenum mode) const; - void renderVertexTex(GLfloat vertices[], GLfloat, GLfloat, glm::vec4 color, GLenum mode) const; + void renderVertexConstColor(const std::vector<glm::vec2>& rVertices, glm::vec4 color, GLenum mode) const; + void renderVertexUVTex(const std::vector<glm::vec2>& rVertices, const std::vector<glm::vec2>& rUVcoords, glm::vec4 color, GLenum mode) const; + void renderVertexTex(const std::vector<glm::vec2>& rVertices, GLfloat, GLfloat, glm::vec4 color, GLenum mode) const; RenderHelper(); - void SetVP(int width, int height); - void SetModelAndMVP(glm::mat4 mat); + void SetVP(const float width, const float height); + void SetModelAndMVP(const glm::mat4& mat); void dispose(); void InitOpenGL(); @@ -59,10 +60,7 @@ namespace oglcanvas int m_iWidth; int m_iHeight; - // Projection matrix : default 45 degree Field of View, 4:3 ratio, display range : 0.1 unit <-> 100 units - glm::mat4 m_Projection; - // Camera matrix - glm::mat4 m_View; + glm::mat4 m_VP; // Model matrix : an identity matrix (model will be at the origin glm::mat4 m_Model; // Our ModelViewProjection : multiplication of our 3 matrices diff --git a/canvas/source/opengl/ogl_spritedevicehelper.cxx b/canvas/source/opengl/ogl_spritedevicehelper.cxx index 63eeef3..0d171d6 100644 --- a/canvas/source/opengl/ogl_spritedevicehelper.cxx +++ b/canvas/source/opengl/ogl_spritedevicehelper.cxx @@ -300,6 +300,17 @@ namespace oglcanvas SystemChildWindow* pChildWindow = mpContext->getChildWindow(); const ::Size& rOutputSize = pChildWindow->GetSizePixel(); initTransformation(rOutputSize); + + glm::mat4 ViewTranslate = glm::translate( + glm::mat4(1.0f), + glm::vec3(-1.0, 1.0, 0.0)); + glm::mat4 ViewScaled = glm::scale( + ViewTranslate, + glm::vec3(2.0 / rOutputSize.Width(), + -2.0/ rOutputSize.Height(), + 1.0 )); + mRenderHelper.SetModelAndMVP(ViewScaled); + // render the actual spritecanvas content mpSpriteCanvas->renderRecordedActions(); @@ -318,33 +329,21 @@ namespace oglcanvas // frame counter, other info - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslated(-1.0, 1.0, 0.0); - glScaled( 2.0 / rOutputSize.Width(), - -2.0 / rOutputSize.Height(), - 1.0 ); - const double denominator( maLastUpdate.getElapsedTime() ); maLastUpdate.reset(); const double fps(denominator == 0.0 ? 100.0 : 1.0/denominator); + + mRenderHelper.SetModelAndMVP(ViewScaled); + +#ifdef RENDER_DEBUG std::vector<double> aVec; aVec.push_back(fps); aVec.push_back(maActiveSprites.size()); aVec.push_back(mpTextureCache->getCacheSize()); aVec.push_back(mpTextureCache->getCacheMissCount()); aVec.push_back(mpTextureCache->getCacheHitCount()); - - glm::mat4 ViewTranslate = glm::translate( - glm::mat4(1.0f), - glm::vec3(-1.0,1.0,0.0)); - glm::mat4 ViewScaled = glm::scale( - ViewTranslate, - glm::vec3(2.0 / rOutputSize.Width(), - -2.0 / rOutputSize.Height(), - 1.0 )); - mRenderHelper.SetModelAndMVP(ViewScaled); renderOSD( aVec, 20 , getRenderHelper()); +#endif /* * TODO: moggi: fix it! @@ -404,6 +403,7 @@ namespace oglcanvas SystemChildWindow* pChildWindow = mpContext->getChildWindow(); pChildWindow->setPosSizePixel( 0,0,rBounds.Width,rBounds.Height); + mRenderHelper.SetVP(rBounds.Width, rBounds.Height); } } commit 958574962ee8e575d5d6a95cb328545d12bfda3d Author: Michael Jaumann <meta_...@yahoo.com> Date: Mon Nov 24 13:40:08 2014 +0000 renderComplexPolyPolygon -> openGl 2.1 Change-Id: If173ab655526c86069ce770a725faa54f6856b31 diff --git a/canvas/source/opengl/ogl_canvashelper.cxx b/canvas/source/opengl/ogl_canvashelper.cxx index 6c30e90..74e2ee8 100644 --- a/canvas/source/opengl/ogl_canvashelper.cxx +++ b/canvas/source/opengl/ogl_canvashelper.cxx @@ -165,14 +165,16 @@ namespace oglcanvas //no texture bind ? RenderHelper* pRenderHelper = rHelper.getDeviceHelper()->getRenderHelper(); setupState(rTransform, eSrcBlend, eDstBlend); + glm::vec4 color = glm::vec4( (float) rColor.Red, + (float) rColor.Green, + (float) rColor.Blue, + (float) rColor.Alpha); ::basegfx::B2DPolyPolygonVector::const_iterator aCurr=rPolyPolygons.begin(); const ::basegfx::B2DPolyPolygonVector::const_iterator aEnd=rPolyPolygons.end(); while( aCurr != aEnd ) { - glBegin(GL_TRIANGLES); - renderComplexPolyPolygon(*aCurr++); - glEnd(); + renderPolyPolygon(*aCurr++, pRenderHelper, color); } return true; @@ -188,6 +190,10 @@ namespace oglcanvas { RenderHelper* pRenderHelper = rHelper.getDeviceHelper()->getRenderHelper(); setupState(rTransform, eSrcBlend, eDstBlend); + glm::vec4 color = glm::vec4( (float) rendering::ARGBColor().Red, + (float) rendering::ARGBColor().Green, + (float) rendering::ARGBColor().Blue, + (float) rendering::ARGBColor().Alpha); // convert to weird canvas textur coordinate system (not // [0,1]^2, but path coordinate system) @@ -240,14 +246,10 @@ namespace oglcanvas aCurr=rPolyPolygons.begin(); while( aCurr != aEnd ) { - glBegin(GL_TRIANGLES); - renderComplexPolyPolygon(*aCurr++); - glEnd(); + renderComplexPolyPolygon(*aCurr++, pRenderHelper, color); } glUseProgram(0); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); return true; } @@ -321,7 +323,12 @@ namespace oglcanvas const ::basegfx::B2DPolyPolygonVector& rPolyPolygons ) { // setupState(rTransform, eSrcBlend, eDstBlend, rendering::ARGBColor()); + RenderHelper* pRenderHelper = rHelper.getDeviceHelper()->getRenderHelper(); setupState(rTransform, eSrcBlend, eDstBlend); + glm::vec4 color = glm::vec4( (float) rendering::ARGBColor().Red, + (float) rendering::ARGBColor().Green, + (float) rendering::ARGBColor().Blue, + (float) rendering::ARGBColor().Alpha); const unsigned int nTexId=rHelper.getDeviceHelper()->getTextureCache().getTexture( rPixelSize, rPixelData.getConstArray(), nPixelCrc32); @@ -363,9 +370,7 @@ namespace oglcanvas aCurr=rPolyPolygons.begin(); while( aCurr != aEnd ) { - glBegin(GL_TRIANGLES); - renderComplexPolyPolygon(*aCurr++); - glEnd(); + renderComplexPolyPolygon(*aCurr++, pRenderHelper, color); } diff --git a/canvas/source/opengl/ogl_canvastools.cxx b/canvas/source/opengl/ogl_canvastools.cxx index dc751b9..833c9eb 100644 --- a/canvas/source/opengl/ogl_canvastools.cxx +++ b/canvas/source/opengl/ogl_canvastools.cxx @@ -17,7 +17,7 @@ #include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/polygon/b2dpolygontriangulator.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> - +#include <vector> #include <com/sun/star/rendering/ARGBColor.hpp> #include <GL/glew.h> @@ -30,7 +30,7 @@ namespace oglcanvas { /// triangulates polygon before //move to canvashelper, or take renderHelper as parameter? - void renderComplexPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly ) + void renderComplexPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly, RenderHelper *renderHelper, glm::vec4 color ) { ::basegfx::B2DPolyPolygon aPolyPoly(rPolyPoly); if( aPolyPoly.areControlPointsUsed() ) @@ -40,14 +40,14 @@ namespace oglcanvas const double nHeight=rBounds.getHeight(); const ::basegfx::B2DPolygon& rTriangulatedPolygon( ::basegfx::triangulator::triangulate(aPolyPoly)); - + std::vector<glm::vec2> vertices; + vertices.reserve(rTriangulatedPolygon.count()); for( sal_uInt32 i=0; i<rTriangulatedPolygon.count(); i++ ) { const ::basegfx::B2DPoint& rPt( rTriangulatedPolygon.getB2DPoint(i) ); - const double s(rPt.getX()/nWidth); - const double t(rPt.getY()/nHeight); - glTexCoord2f(s,t); glVertex2d(rPt.getX(), rPt.getY()); + vertices.push_back(glm::vec2(rPt.getX(),rPt.getY())); } + renderHelper->renderVertexTex( vertices, nWidth, nHeight, color, GL_TRIANGLES); } /** only use this for line polygons. @@ -67,30 +67,14 @@ namespace oglcanvas const sal_uInt32 nPts=rPolygon.count(); const sal_uInt32 nExtPts=nPts + int(rPolygon.isClosed()); - GLfloat vertices[nExtPts*2]; + std::vector<glm::vec2> vertices; + vertices.reserve(nExtPts); 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(); + vertices.push_back(glm::vec2(rPt.getX(),rPt.getY())); } renderHelper->renderVertexConstColor(vertices, color, GL_LINE_STRIP); - /* - glBegin(GL_LINE_STRIP); - - const ::basegfx::B2DPolygon& rPolygon( aPolyPoly.getB2DPolygon(i) ); - - const sal_uInt32 nPts=rPolygon.count(); - const sal_uInt32 nExtPts=nPts + int(rPolygon.isClosed()); - for( sal_uInt32 j=0; j<nExtPts; j++ ) - { - const ::basegfx::B2DPoint& rPt( rPolygon.getB2DPoint( j % nPts ) ); - glVertex2d(rPt.getX(), rPt.getY()); - } - - glEnd(); - */ - } } @@ -106,7 +90,6 @@ namespace oglcanvas 0, 0, 1, 0, (float) rTransform.get(0,2), (float) rTransform.get(1,2), 0, 1 }; - glEnable(GL_BLEND); glBlendFunc(eSrcBlend, eDstBlend); return glm::make_mat4(aGLTransform); @@ -131,8 +114,8 @@ namespace oglcanvas aTmp=aTmp*aScaleShear; aPoly.transform(aTmp); - glColor4f(0,1,0,1); - glm::vec4 color = glm::vec4(1, 0, 0, 1); + // glColor4f(0,1,0,1); + glm::vec4 color = glm::vec4(0.5, 0, 0, 0.5); renderPolyPolygon(aPoly, renderHelper, color); } } diff --git a/canvas/source/opengl/ogl_canvastools.hxx b/canvas/source/opengl/ogl_canvastools.hxx index 1f6679d..904b7f6 100644 --- a/canvas/source/opengl/ogl_canvastools.hxx +++ b/canvas/source/opengl/ogl_canvastools.hxx @@ -25,7 +25,7 @@ namespace basegfx { namespace oglcanvas { - void renderComplexPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly ); + void renderComplexPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly, RenderHelper *renderHelper, glm::vec4 color); void renderPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly, RenderHelper *renderHelper, glm::vec4 color ); glm::mat4 setupState( const ::basegfx::B2DHomMatrix& rTransform, unsigned int eSrcBlend, commit cb680e9f37ff03e34fc4473414308f22c7ea02b3 Author: Michael Jaumann <meta_...@yahoo.com> Date: Mon Nov 24 13:15:30 2014 +0000 remove glMatrixStack from ogl_canvas Change-Id: I00fc5ab54fea444d03e5050e0c80b51180028ee4 diff --git a/canvas/source/opengl/ogl_canvashelper.cxx b/canvas/source/opengl/ogl_canvashelper.cxx index cd9823d..6c30e90 100644 --- a/canvas/source/opengl/ogl_canvashelper.cxx +++ b/canvas/source/opengl/ogl_canvashelper.cxx @@ -155,7 +155,7 @@ namespace oglcanvas return true; } - bool lcl_fillPolyPolygon( const CanvasHelper& /*rHelper*/, + bool lcl_fillPolyPolygon( const CanvasHelper& rHelper, const ::basegfx::B2DHomMatrix& rTransform, GLenum eSrcBlend, GLenum eDstBlend, @@ -163,7 +163,7 @@ namespace oglcanvas const ::basegfx::B2DPolyPolygonVector& rPolyPolygons ) { //no texture bind ? - TransformationPreserver aPreserver; + RenderHelper* pRenderHelper = rHelper.getDeviceHelper()->getRenderHelper(); setupState(rTransform, eSrcBlend, eDstBlend); ::basegfx::B2DPolyPolygonVector::const_iterator aCurr=rPolyPolygons.begin(); @@ -186,9 +186,7 @@ namespace oglcanvas const rendering::Texture& rTexture, const ::basegfx::B2DPolyPolygonVector& rPolyPolygons ) { - //not complete - TransformationPreserver aPreserver; - // setupState(rTransform, eSrcBlend, eDstBlend, rendering::ARGBColor()); + RenderHelper* pRenderHelper = rHelper.getDeviceHelper()->getRenderHelper(); setupState(rTransform, eSrcBlend, eDstBlend); // convert to weird canvas textur coordinate system (not @@ -261,7 +259,6 @@ namespace oglcanvas const rendering::ARGBColor& rColor, const CanvasBitmap& rBitmap ) { - TransformationPreserver aPreserver; setupState(rTransform, eSrcBlend, eDstBlend); return rBitmap.renderRecordedActions(); @@ -323,7 +320,6 @@ namespace oglcanvas sal_uInt32 nPixelCrc32, const ::basegfx::B2DPolyPolygonVector& rPolyPolygons ) { - TransformationPreserver aPreserver; // setupState(rTransform, eSrcBlend, eDstBlend, rendering::ARGBColor()); setupState(rTransform, eSrcBlend, eDstBlend); @@ -356,7 +352,6 @@ namespace oglcanvas aTextureTransform.scale(1/aBounds.getWidth(), 1/aBounds.getHeight()); aTextureTransform.invert(); - glMatrixMode(GL_TEXTURE); double aTexTransform[] = { aTextureTransform.get(0,0), aTextureTransform.get(1,0), 0, 0, @@ -364,10 +359,6 @@ namespace oglcanvas 0, 0, 1, 0, aTextureTransform.get(0,2), aTextureTransform.get(1,2), 0, 1 }; - glLoadMatrixd(aTexTransform); - - // blend against fixed vertex color; texture alpha is multiplied in - glColor4f(1,1,1,rTexture.Alpha); aCurr=rPolyPolygons.begin(); while( aCurr != aEnd ) @@ -377,8 +368,6 @@ namespace oglcanvas glEnd(); } - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); diff --git a/canvas/source/opengl/ogl_spritedevicehelper.cxx b/canvas/source/opengl/ogl_spritedevicehelper.cxx index 9fe8380..63eeef3 100644 --- a/canvas/source/opengl/ogl_spritedevicehelper.cxx +++ b/canvas/source/opengl/ogl_spritedevicehelper.cxx @@ -39,9 +39,6 @@ static void initContext() // need the backside for mirror effects glDisable(GL_CULL_FACE); - // no perspective, we're 2D - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); // misc preferences glEnable(GL_POINT_SMOOTH); @@ -60,13 +57,6 @@ static void initTransformation(const ::Size& rSize, bool bMirror=false) (GLsizei)rSize.Width(), (GLsizei)rSize.Height() ); // model coordinate system is already in device pixel - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslated(-1.0, (bMirror ? -1.0 : 1.0), 0.0); - glScaled( 2.0 / rSize.Width(), - (bMirror ? 2.0 : -2.0) / rSize.Height(), - 1.0 ); - // clear to black glClearColor(0,0,0,0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -109,7 +99,6 @@ namespace oglcanvas // init window context initContext(); mRenderHelper.InitOpenGL(); - mRenderHelper.SetVP(1200, 600);//is this right? mnLinearMultiColorGradientProgram = OpenGLHelper::LoadShaders("dummyVertexShader", "linearMultiColorGradientFragmentShader"); commit ce48b22c93163e54df01cc68e2fa966c36df1ed0 Author: Michael Jaumann <meta_...@yahoo.com> Date: Fri Nov 21 19:41:28 2014 +0000 cleanup oglContext use a scopedpointer to avoid undelet oglContext Childwindow. Change-Id: I850346ce3d9649038d678e37cf75ead72c4c6c7e diff --git a/canvas/source/opengl/ogl_spritedevicehelper.cxx b/canvas/source/opengl/ogl_spritedevicehelper.cxx index a2576c3..9fe8380 100644 --- a/canvas/source/opengl/ogl_spritedevicehelper.cxx +++ b/canvas/source/opengl/ogl_spritedevicehelper.cxx @@ -103,8 +103,9 @@ namespace oglcanvas VCLUnoHelper::GetInterface(&rWindow), uno::UNO_QUERY_THROW) ); - maContext.requestLegacyContext(); - maContext.init(&rWindow); + mpContext.reset(new OpenGLContext); + mpContext->requestLegacyContext(); + mpContext->init(&rWindow); // init window context initContext(); mRenderHelper.InitOpenGL(); @@ -128,7 +129,7 @@ namespace oglcanvas mnRectangularTwoColorGradientProgram = OpenGLHelper::LoadShaders("dummyVertexShader", "rectangularTwoColorGradientFragmentShader"); - maContext.makeCurrent(); + mpContext->makeCurrent(); notifySizeUpdate(rViewArea); // TODO(E3): check for GL_ARB_imaging extension @@ -141,7 +142,7 @@ namespace oglcanvas mpDevice = NULL; mpTextureCache.reset(); - if( maContext.isInitialized() ) + if( mpContext->isInitialized() ) { glDeleteProgram( mnRectangularTwoColorGradientProgram ); glDeleteProgram( mnRectangularMultiColorGradientProgram ); @@ -150,16 +151,17 @@ namespace oglcanvas glDeleteProgram( mnLinearTwoColorGradientProgram ); glDeleteProgram( mnLinearMultiColorGradientProgram ); } + mpContext.reset(); mRenderHelper.dispose(); } geometry::RealSize2D SpriteDeviceHelper::getPhysicalResolution() { - if( !maContext.isInitialized() ) + if( !mpContext->isInitialized() ) return ::canvas::tools::createInfiniteSize2D(); // we're disposed // Map a one-by-one millimeter box to pixel - SystemChildWindow* pChildWindow = maContext.getChildWindow(); + SystemChildWindow* pChildWindow = mpContext->getChildWindow(); const MapMode aOldMapMode( pChildWindow->GetMapMode() ); pChildWindow->SetMapMode( MapMode(MAP_MM) ); const Size aPixelSize( pChildWindow->LogicToPixel(Size(1,1)) ); @@ -170,11 +172,11 @@ namespace oglcanvas geometry::RealSize2D SpriteDeviceHelper::getPhysicalSize() { - if( !maContext.isInitialized() ) + if( !mpContext->isInitialized() ) return ::canvas::tools::createInfiniteSize2D(); // we're disposed // Map the pixel dimensions of the output window to millimeter - SystemChildWindow* pChildWindow = maContext.getChildWindow(); + SystemChildWindow* pChildWindow = mpContext->getChildWindow(); const MapMode aOldMapMode( pChildWindow->GetMapMode() ); pChildWindow->SetMapMode( MapMode(MAP_MM) ); const Size aLogSize( pChildWindow->PixelToLogic(pChildWindow->GetOutputSizePixel()) ); @@ -300,13 +302,13 @@ namespace oglcanvas bool SpriteDeviceHelper::showBuffer( bool bIsVisible, bool /*bUpdateAll*/ ) { // hidden or disposed? - if( !bIsVisible || !maContext.isInitialized() || !mpSpriteCanvas ) + if( !bIsVisible || !mpContext->isInitialized() || !mpSpriteCanvas ) return false; if( !activateWindowContext() ) return false; - SystemChildWindow* pChildWindow = maContext.getChildWindow(); + SystemChildWindow* pChildWindow = mpContext->getChildWindow(); const ::Size& rOutputSize = pChildWindow->GetSizePixel(); initTransformation(rOutputSize); // render the actual spritecanvas content @@ -343,6 +345,16 @@ namespace oglcanvas aVec.push_back(mpTextureCache->getCacheSize()); aVec.push_back(mpTextureCache->getCacheMissCount()); aVec.push_back(mpTextureCache->getCacheHitCount()); + + glm::mat4 ViewTranslate = glm::translate( + glm::mat4(1.0f), + glm::vec3(-1.0,1.0,0.0)); + glm::mat4 ViewScaled = glm::scale( + ViewTranslate, + glm::vec3(2.0 / rOutputSize.Width(), + -2.0 / rOutputSize.Height(), + 1.0 )); + mRenderHelper.SetModelAndMVP(ViewScaled); renderOSD( aVec, 20 , getRenderHelper()); /* @@ -355,7 +367,7 @@ namespace oglcanvas unx::glXWaitGL(); XSync( reinterpret_cast<unx::Display*>(mpDisplay), false ); */ - maContext.swapBuffers(); + mpContext->swapBuffers(); // flush texture cache, such that it does not build up // indefinitely. @@ -379,7 +391,7 @@ namespace oglcanvas uno::Any SpriteDeviceHelper::getDeviceHandle() const { - const SystemChildWindow* pChildWindow = maContext.getChildWindow(); + const SystemChildWindow* pChildWindow = mpContext->getChildWindow(); return uno::makeAny( reinterpret_cast< sal_Int64 >(pChildWindow) ); } @@ -398,9 +410,9 @@ namespace oglcanvas void SpriteDeviceHelper::notifySizeUpdate( const awt::Rectangle& rBounds ) { - if( maContext.isInitialized() ) + if( mpContext->isInitialized() ) { - SystemChildWindow* pChildWindow = maContext.getChildWindow(); + SystemChildWindow* pChildWindow = mpContext->getChildWindow(); pChildWindow->setPosSizePixel( 0,0,rBounds.Width,rBounds.Height); } @@ -535,7 +547,7 @@ namespace oglcanvas bool SpriteDeviceHelper::activateWindowContext() { - maContext.makeCurrent(); + mpContext->makeCurrent(); return true; } diff --git a/canvas/source/opengl/ogl_spritedevicehelper.hxx b/canvas/source/opengl/ogl_spritedevicehelper.hxx index 8bda43b..5e2cbca 100644 --- a/canvas/source/opengl/ogl_spritedevicehelper.hxx +++ b/canvas/source/opengl/ogl_spritedevicehelper.hxx @@ -17,6 +17,7 @@ #include <com/sun/star/rendering/XGraphicDevice.hpp> #include <boost/utility.hpp> #include <boost/shared_ptr.hpp> +#include <boost/scoped_ptr.hpp> #include "ogl_buffercontext.hxx" #include "ogl_renderHelper.hxx" @@ -152,7 +153,7 @@ namespace oglcanvas unsigned int mnRectangularTwoColorGradientProgram; unsigned int mnRectangularMultiColorGradientProgram; - OpenGLContext maContext; + boost::scoped_ptr<OpenGLContext> mpContext; RenderHelper mRenderHelper; }; } commit 79070b14731990b65d3d248f62b590b4891e922e Author: Michael Jaumann <meta_...@yahoo.com> Date: Thu Nov 20 15:11:19 2014 +0000 feed glDrawArrays with right vertexcount Change-Id: I8aa835cc1b2f0f41d5c1051ae2a005928d625746 diff --git a/canvas/source/opengl/ogl_renderHelper.cxx b/canvas/source/opengl/ogl_renderHelper.cxx index b192df2..acd0a17 100644 --- a/canvas/source/opengl/ogl_renderHelper.cxx +++ b/canvas/source/opengl/ogl_renderHelper.cxx @@ -29,7 +29,7 @@ namespace oglcanvas m_simpleTexUnf = glGetUniformLocation(m_simpleProgID, "TextTex"); m_manCordUnf = glGetUniformLocation(m_texManProgID, "texCord"); - m_texColorUnf = glGetUniformLocation(m_texProgID, "constantColor"); + m_texColorUnf = glGetUniformLocation(m_texProgID, "constColor"); m_manColorUnf = glGetUniformLocation(m_texManProgID,"colorTex"); m_simpleColorUnf = glGetUniformLocation(m_simpleProgID,"colorTex"); @@ -45,7 +45,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) @@ -62,6 +62,8 @@ namespace oglcanvas m_Model = mat; m_MVP = m_Projection * m_View * m_Model; } + + void RenderHelper::renderVertexConstColor(GLfloat vertices[], glm::vec4 color, GLenum mode) const { glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer); @@ -69,7 +71,7 @@ namespace oglcanvas glUseProgram(m_texProgID); - glUniform4fv(m_texColorUnf, 1, glm::value_ptr(color)); + glUniform4fv(m_texColorUnf, 1, &color[0]); glUniformMatrix4fv(m_texMVPUnf, 1, GL_FALSE, &m_MVP[0][0]); glEnableVertexAttribArray(m_texPosAttrb); //vertices @@ -83,7 +85,7 @@ namespace oglcanvas (void*)0 // array buffer offset ); - glDrawArrays(mode, 0, sizeof(vertices) / sizeof(vertices[0]) /2); + glDrawArrays(mode, 0, sizeof(vertices) / 2); glDisableVertexAttribArray(m_texPosAttrb); glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -102,7 +104,8 @@ namespace oglcanvas glUseProgram(m_simpleProgID); glUniform1i(m_simpleTexUnf, 0); //Use texture Unit 0 - glUniform4fv(m_simpleColorUnf, 1, glm::value_ptr(color)); + + glUniform4fv(m_simpleColorUnf, 1, &color[0]); glUniformMatrix4fv(m_simpleMVPUnf, 1, GL_FALSE, &m_MVP[0][0]); glEnableVertexAttribArray(m_simplePosAttrb); @@ -127,7 +130,7 @@ namespace oglcanvas (void*)0 // array buffer offset ); - glDrawArrays(mode, 0, sizeof(vertices) / sizeof(vertices[0]) /2); + glDrawArrays(mode, 0, sizeof(vertices) / 2); glDisableVertexAttribArray(m_simplePosAttrb); glDisableVertexAttribArray(m_simpleUvAttrb); @@ -157,7 +160,7 @@ namespace oglcanvas //Set Uniforms glUniform1i(m_manTexUnf, 0); glUniform2f(m_manCordUnf,fWidth,fHeight); - glUniform4fv(m_manColorUnf, 1, glm::value_ptr(color)); + glUniform4fv(m_manColorUnf, 1, &color[0]); glUniformMatrix4fv(m_manMVPUnf, 1, GL_FALSE, &m_MVP[0][0]); glEnableVertexAttribArray(m_manPosAttrb); @@ -171,7 +174,7 @@ namespace oglcanvas (void*)0 // array buffer offset ); - glDrawArrays(mode, 0, sizeof(vertices) / sizeof(vertices[0]) /2); + glDrawArrays(mode, 0, sizeof(vertices) / 2); glDisableVertexAttribArray(m_manPosAttrb); glBindBuffer(GL_ARRAY_BUFFER, 0); diff --git a/canvas/source/opengl/ogl_renderHelper.hxx b/canvas/source/opengl/ogl_renderHelper.hxx index 66d4e5e..803e198 100644 --- a/canvas/source/opengl/ogl_renderHelper.hxx +++ b/canvas/source/opengl/ogl_renderHelper.hxx @@ -12,7 +12,6 @@ #include <GL/glew.h> #include <glm/glm.hpp> #include "glm/gtx/transform.hpp" -#include <glm/gtc/type_ptr.hpp> namespace oglcanvas { class RenderHelper commit 07cafcd76c532dd0214da94294631ee86fe82634 Author: Michael Jaumann <meta_...@yahoo.com> Date: Wed Nov 19 13:17:21 2014 +0000 added licence statement, vim modeline Change-Id: Ibc9dd608b9b49df17a13513f2c0b2ed2076b4b6c diff --git a/canvas/source/opengl/ogl_renderHelper.cxx b/canvas/source/opengl/ogl_renderHelper.cxx index 2c4fe6c..b192df2 100644 --- a/canvas/source/opengl/ogl_renderHelper.cxx +++ b/canvas/source/opengl/ogl_renderHelper.cxx @@ -1,3 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + #include <GL/glew.h> #include "ogl_renderHelper.hxx" #include <vcl/opengl/OpenGLHelper.hxx> @@ -168,4 +177,6 @@ namespace oglcanvas glBindBuffer(GL_ARRAY_BUFFER, 0); glUseProgram(0); } -} \ No newline at end of file +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/canvas/source/opengl/ogl_renderHelper.hxx b/canvas/source/opengl/ogl_renderHelper.hxx index 7c717a6..66d4e5e 100644 --- a/canvas/source/opengl/ogl_renderHelper.hxx +++ b/canvas/source/opengl/ogl_renderHelper.hxx @@ -1,3 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + #ifndef RENDER_HELPER #define RENDER_HELPER #include <GL/glew.h> @@ -63,5 +72,6 @@ namespace oglcanvas }; } +#endif /* RENDER_HELPER */ -#endif /* RENDER_HELPER */ \ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 2744af98407f0419d0b4a0da6237c206bf5a2a2d Author: Michael Jaumann <meta_...@yahoo.com> Date: Wed Nov 19 10:30:43 2014 +0000 renderVertexConstCol uses now MVP matrix Change-Id: I6f145984596c8d1b739a7dd561d1bffb35bb2957 diff --git a/canvas/source/opengl/ogl_renderHelper.cxx b/canvas/source/opengl/ogl_renderHelper.cxx index 1d1379b..2c4fe6c 100644 --- a/canvas/source/opengl/ogl_renderHelper.cxx +++ b/canvas/source/opengl/ogl_renderHelper.cxx @@ -61,6 +61,7 @@ namespace oglcanvas glUseProgram(m_texProgID); glUniform4fv(m_texColorUnf, 1, glm::value_ptr(color)); + glUniformMatrix4fv(m_texMVPUnf, 1, GL_FALSE, &m_MVP[0][0]); glEnableVertexAttribArray(m_texPosAttrb); //vertices glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits