diff options
author | Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com> | 2015-12-09 21:39:25 +0000 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2015-12-11 15:28:59 +0100 |
commit | a74e8ab7841a67ae353c537d449d27a931ba67d8 (patch) | |
tree | 9d1e2aa5f46be3758c08de772a71919906a2b8df /slideshow | |
parent | 7d1c123a55d222868e27673685c25d62b1e96cd5 (diff) |
slideshow: Remove the last legacy uniforms
Change-Id: If5f7368bf53dd59e66e990e4f2c57b6ee2cba44b
Diffstat (limited to 'slideshow')
4 files changed, 49 insertions, 36 deletions
diff --git a/slideshow/opengl/basicVertexShader.glsl b/slideshow/opengl/basicVertexShader.glsl index ebd5dbcc6585..cd68b16a161c 100644 --- a/slideshow/opengl/basicVertexShader.glsl +++ b/slideshow/opengl/basicVertexShader.glsl @@ -28,6 +28,10 @@ #version 120 +attribute vec3 a_position; +attribute vec3 a_normal; +attribute vec2 a_texCoord; + uniform mat4 u_projectionMatrix; uniform mat4 u_modelViewMatrix; uniform mat4 u_sceneTransformMatrix; @@ -41,9 +45,9 @@ void main( void ) { mat4 modelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix; mat3 normalMatrix = mat3(transpose(inverse(modelViewMatrix))); - gl_Position = u_projectionMatrix * modelViewMatrix * gl_Vertex; - v_texturePosition = gl_MultiTexCoord0.xy; - v_normal = normalize(normalMatrix * gl_Normal); + gl_Position = u_projectionMatrix * modelViewMatrix * vec4(a_position, 1.0); + v_texturePosition = a_texCoord; + v_normal = normalize(normalMatrix * a_normal); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/slideshow/opengl/reflectionVertexShader.glsl b/slideshow/opengl/reflectionVertexShader.glsl index 566eafa7590b..96748887c308 100644 --- a/slideshow/opengl/reflectionVertexShader.glsl +++ b/slideshow/opengl/reflectionVertexShader.glsl @@ -28,6 +28,10 @@ #version 130 +attribute vec3 a_position; +attribute vec3 a_normal; +attribute vec2 a_texCoord; + uniform mat4 u_projectionMatrix; uniform mat4 u_modelViewMatrix; uniform mat4 u_sceneTransformMatrix; @@ -42,9 +46,9 @@ void main( void ) { mat4 modelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix; mat3 normalMatrix = mat3(transpose(inverse(modelViewMatrix))); - gl_Position = u_projectionMatrix * modelViewMatrix * gl_Vertex; - v_texturePosition = gl_MultiTexCoord0.xy; - v_normal = normalize(normalMatrix * gl_Normal); + gl_Position = u_projectionMatrix * modelViewMatrix * vec4(a_position, 1.0); + v_texturePosition = a_texCoord; + v_normal = normalize(normalMatrix * a_normal); v_isShadow = float(gl_VertexID >= 6); } diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx index 025c9805672f..09ccc6d31b7e 100644 --- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx +++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx @@ -142,6 +142,31 @@ void OGLTransitionImpl::prepare( sal_Int32 glLeavingSlideTex, sal_Int32 glEnteri m_nPrimitiveTransformLocation = glGetUniformLocation( m_nProgramObject, "u_primitiveTransformMatrix" ); m_nSceneTransformLocation = glGetUniformLocation( m_nProgramObject, "u_sceneTransformMatrix" ); m_nOperationsTransformLocation = glGetUniformLocation( m_nProgramObject, "u_operationsTransformMatrix" ); + + glGenBuffers(1, &m_nVertexBufferObject); + glBindBuffer(GL_ARRAY_BUFFER, m_nVertexBufferObject); + + // Attribute bindings + m_nPositionLocation = glGetAttribLocation(m_nProgramObject, "a_position"); + if (m_nPositionLocation != -1) { + glEnableVertexAttribArray(m_nPositionLocation); + glVertexAttribPointer( m_nPositionLocation, 3, GL_FLOAT, false, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, position)) ); + CHECK_GL_ERROR(); + } + + m_nNormalLocation = glGetAttribLocation(m_nProgramObject, "a_normal"); + if (m_nNormalLocation != -1) { + glEnableVertexAttribArray(m_nNormalLocation); + glVertexAttribPointer( m_nNormalLocation, 3, GL_FLOAT, false, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, normal)) ); + CHECK_GL_ERROR(); + } + + m_nTexCoordLocation = glGetAttribLocation(m_nProgramObject, "a_texCoord"); + if (m_nTexCoordLocation != -1) { + glEnableVertexAttribArray(m_nTexCoordLocation); + glVertexAttribPointer( m_nTexCoordLocation, 2, GL_FLOAT, false, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, texcoord)) ); + CHECK_GL_ERROR(); + } } CHECK_GL_ERROR(); @@ -159,6 +184,8 @@ void OGLTransitionImpl::finish() CHECK_GL_ERROR(); if( m_nProgramObject ) { + glDeleteBuffers(1, &m_nVertexBufferObject); + m_nVertexBufferObject = 0; glDeleteProgram( m_nProgramObject ); m_nProgramObject = 0; } @@ -231,12 +258,6 @@ void OGLTransitionImpl::applyOverallOperations( double nTime, double SlideWidthS static void display_primitives(const Primitives_t& primitives, GLint primitiveTransformLocation, double nTime, double WidthScale, double HeightScale) { - CHECK_GL_ERROR(); - GLuint buffer; - glGenBuffers(1, &buffer); - CHECK_GL_ERROR(); - glBindBuffer(GL_ARRAY_BUFFER, buffer); - int size = 0; for (const Primitive& primitive: primitives) size += primitive.getVerticesSize(); @@ -259,26 +280,8 @@ static void display_primitives(const Primitives_t& primitives, GLint primitiveTr CHECK_GL_ERROR(); glUnmapBuffer(GL_ARRAY_BUFFER); - // State initialization - // TODO: move that elsewhere. - CHECK_GL_ERROR(); - glEnableClientState( GL_VERTEX_ARRAY ); - CHECK_GL_ERROR(); - glVertexPointer( 3, GL_FLOAT, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, position)) ); - CHECK_GL_ERROR(); - glEnableClientState( GL_NORMAL_ARRAY ); - CHECK_GL_ERROR(); - glNormalPointer( GL_FLOAT , sizeof(Vertex) , reinterpret_cast<void*>(offsetof(Vertex, normal)) ); - CHECK_GL_ERROR(); - glEnableClientState( GL_TEXTURE_COORD_ARRAY ); - CHECK_GL_ERROR(); - glTexCoordPointer( 2, GL_FLOAT, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, texcoord)) ); - for (const Primitive& primitive: primitives) primitive.display(primitiveTransformLocation, nTime, WidthScale, HeightScale, *first++); - - CHECK_GL_ERROR(); - glDeleteBuffers(1, &buffer); } void diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.hxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.hxx index c972ff37f587..0bd15d61ce88 100644 --- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.hxx +++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.hxx @@ -216,17 +216,19 @@ private: */ void uploadModelViewProjectionMatrices(); - /** Uniform location for primitive transform + /** Uniform locations for transform matrices */ GLint m_nPrimitiveTransformLocation = -1; - - /** Uniform location for scene transform - */ GLint m_nSceneTransformLocation = -1; + GLint m_nOperationsTransformLocation = -1; - /** Uniform location for operations transform + /** Per-vertex attribute locations */ - GLint m_nOperationsTransformLocation = -1; + GLint m_nPositionLocation = -1; + GLint m_nNormalLocation = -1; + GLint m_nTexCoordLocation = -1; + + GLuint m_nVertexBufferObject = -1; protected: /** GLSL program object |