Kaydet (Commit) 1a4ce718 authored tarafından Emmanuel Gil Peyrot's avatar Emmanuel Gil Peyrot Kaydeden (comit) Tomaž Vajngerl

slideshow: Remove extraneous checks for the program object.

Change-Id: Ice61bfbd75aafd4197584c34ef7fbed80c20c184
(cherry picked from commit 129b8b85)
üst c319cb00
...@@ -143,67 +143,65 @@ bool OGLTransitionImpl::prepare( sal_Int32 glLeavingSlideTex, sal_Int32 glEnteri ...@@ -143,67 +143,65 @@ bool OGLTransitionImpl::prepare( sal_Int32 glLeavingSlideTex, sal_Int32 glEnteri
if (!m_nProgramObject) if (!m_nProgramObject)
return false; return false;
CHECK_GL_ERROR();
glUseProgram( m_nProgramObject );
CHECK_GL_ERROR();
const SceneObjects_t& rSceneObjects(maScene.getSceneObjects()); const SceneObjects_t& rSceneObjects(maScene.getSceneObjects());
for(size_t i(0); i != rSceneObjects.size(); ++i) { for(size_t i(0); i != rSceneObjects.size(); ++i) {
rSceneObjects[i]->prepare(m_nProgramObject); rSceneObjects[i]->prepare(m_nProgramObject);
} }
CHECK_GL_ERROR(); GLint location = glGetUniformLocation( m_nProgramObject, "leavingSlideTexture" );
if( m_nProgramObject ) { if( location != -1 ) {
glUseProgram( m_nProgramObject ); glUniform1i( location, 0 ); // texture unit 0
CHECK_GL_ERROR(); CHECK_GL_ERROR();
}
GLint location = glGetUniformLocation( m_nProgramObject, "leavingSlideTexture" ); location = glGetUniformLocation( m_nProgramObject, "enteringSlideTexture" );
if( location != -1 ) { if( location != -1 ) {
glUniform1i( location, 0 ); // texture unit 0 glUniform1i( location, 2 ); // texture unit 2
CHECK_GL_ERROR(); CHECK_GL_ERROR();
} }
location = glGetUniformLocation( m_nProgramObject, "enteringSlideTexture" );
if( location != -1 ) {
glUniform1i( location, 2 ); // texture unit 2
CHECK_GL_ERROR();
}
uploadModelViewProjectionMatrices();
m_nPrimitiveTransformLocation = glGetUniformLocation( m_nProgramObject, "u_primitiveTransformMatrix" ); uploadModelViewProjectionMatrices();
m_nSceneTransformLocation = glGetUniformLocation( m_nProgramObject, "u_sceneTransformMatrix" );
m_nOperationsTransformLocation = glGetUniformLocation( m_nProgramObject, "u_operationsTransformMatrix" );
glGenVertexArrays(1, &m_nVertexArrayObject); m_nPrimitiveTransformLocation = glGetUniformLocation( m_nProgramObject, "u_primitiveTransformMatrix" );
glBindVertexArray(m_nVertexArrayObject); m_nSceneTransformLocation = glGetUniformLocation( m_nProgramObject, "u_sceneTransformMatrix" );
m_nOperationsTransformLocation = glGetUniformLocation( m_nProgramObject, "u_operationsTransformMatrix" );
glGenBuffers(1, &m_nVertexBufferObject); glGenVertexArrays(1, &m_nVertexArrayObject);
glBindBuffer(GL_ARRAY_BUFFER, m_nVertexBufferObject); glBindVertexArray(m_nVertexArrayObject);
// In practice both leaving and entering slides share the same primitives. glGenBuffers(1, &m_nVertexBufferObject);
m_nFirstIndices = uploadPrimitives(getScene().getLeavingSlide()); glBindBuffer(GL_ARRAY_BUFFER, m_nVertexBufferObject);
// Attribute bindings // In practice both leaving and entering slides share the same primitives.
m_nPositionLocation = glGetAttribLocation(m_nProgramObject, "a_position"); m_nFirstIndices = uploadPrimitives(getScene().getLeavingSlide());
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"); // Attribute bindings
if (m_nNormalLocation != -1) { m_nPositionLocation = glGetAttribLocation(m_nProgramObject, "a_position");
glEnableVertexAttribArray(m_nNormalLocation); if (m_nPositionLocation != -1) {
glVertexAttribPointer( m_nNormalLocation, 3, GL_FLOAT, false, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, normal)) ); glEnableVertexAttribArray(m_nPositionLocation);
CHECK_GL_ERROR(); glVertexAttribPointer( m_nPositionLocation, 3, GL_FLOAT, false, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, position)) );
} CHECK_GL_ERROR();
}
m_nTexCoordLocation = glGetAttribLocation(m_nProgramObject, "a_texCoord"); m_nNormalLocation = glGetAttribLocation(m_nProgramObject, "a_normal");
if (m_nTexCoordLocation != -1) { if (m_nNormalLocation != -1) {
glEnableVertexAttribArray(m_nTexCoordLocation); glEnableVertexAttribArray(m_nNormalLocation);
glVertexAttribPointer( m_nTexCoordLocation, 2, GL_FLOAT, false, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, texcoord)) ); glVertexAttribPointer( m_nNormalLocation, 3, GL_FLOAT, false, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, normal)) );
CHECK_GL_ERROR(); CHECK_GL_ERROR();
} }
glBindBuffer(GL_ARRAY_BUFFER, 0); 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();
} }
glBindBuffer(GL_ARRAY_BUFFER, 0);
CHECK_GL_ERROR(); CHECK_GL_ERROR();
prepareTransition( glLeavingSlideTex, glEnteringSlideTex ); prepareTransition( glLeavingSlideTex, glEnteringSlideTex );
...@@ -252,12 +250,9 @@ void OGLTransitionImpl::displaySlides_( double nTime, sal_Int32 glLeavingSlideTe ...@@ -252,12 +250,9 @@ void OGLTransitionImpl::displaySlides_( double nTime, sal_Int32 glLeavingSlideTe
CHECK_GL_ERROR(); CHECK_GL_ERROR();
applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale ); applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale );
if( m_nProgramObject ) { GLint location = glGetUniformLocation( m_nProgramObject, "time" );
GLint location = glGetUniformLocation( m_nProgramObject, "time" ); if( location != -1 )
if( location != -1 ) { glUniform1f( location, nTime );
glUniform1f( location, nTime );
}
}
glActiveTexture( GL_TEXTURE2 ); glActiveTexture( GL_TEXTURE2 );
glBindTexture( GL_TEXTURE_2D, glEnteringSlideTex ); glBindTexture( GL_TEXTURE_2D, glEnteringSlideTex );
...@@ -1418,20 +1413,18 @@ static void initPermTexture(GLuint *texID) ...@@ -1418,20 +1413,18 @@ static void initPermTexture(GLuint *texID)
void PermTextureTransition::prepareTransition( sal_Int32, sal_Int32 ) void PermTextureTransition::prepareTransition( sal_Int32, sal_Int32 )
{ {
CHECK_GL_ERROR(); CHECK_GL_ERROR();
if( m_nProgramObject ) { GLint location = glGetUniformLocation( m_nProgramObject, "permTexture" );
GLint location = glGetUniformLocation( m_nProgramObject, "permTexture" ); if( location != -1 ) {
if( location != -1 ) { glActiveTexture(GL_TEXTURE1);
glActiveTexture(GL_TEXTURE1); CHECK_GL_ERROR();
CHECK_GL_ERROR(); if( !m_nHelperTexture )
if( !m_nHelperTexture ) initPermTexture( &m_nHelperTexture );
initPermTexture( &m_nHelperTexture );
glActiveTexture(GL_TEXTURE0);
glActiveTexture(GL_TEXTURE0); CHECK_GL_ERROR();
CHECK_GL_ERROR();
glUniform1i( location, 1 ); // texture unit 1
glUniform1i( location, 1 ); // texture unit 1 CHECK_GL_ERROR();
CHECK_GL_ERROR();
}
} }
CHECK_GL_ERROR(); CHECK_GL_ERROR();
} }
...@@ -1601,20 +1594,14 @@ void VortexTransition::prepareTransition( sal_Int32 glLeavingSlideTex, sal_Int32 ...@@ -1601,20 +1594,14 @@ void VortexTransition::prepareTransition( sal_Int32 glLeavingSlideTex, sal_Int32
PermTextureTransition::prepareTransition( glLeavingSlideTex, glEnteringSlideTex ); PermTextureTransition::prepareTransition( glLeavingSlideTex, glEnteringSlideTex );
CHECK_GL_ERROR(); CHECK_GL_ERROR();
if (m_nProgramObject) mnTileInfoLocation = glGetAttribLocation(m_nProgramObject, "tileInfo");
{ CHECK_GL_ERROR();
mnTileInfoLocation = glGetAttribLocation(m_nProgramObject, "tileInfo");
CHECK_GL_ERROR();
glUseProgram(m_nProgramObject);
CHECK_GL_ERROR();
GLint nNumTilesLocation = glGetUniformLocation(m_nProgramObject, "numTiles"); GLint nNumTilesLocation = glGetUniformLocation(m_nProgramObject, "numTiles");
CHECK_GL_ERROR(); CHECK_GL_ERROR();
glUniform2iv(nNumTilesLocation, 1, glm::value_ptr(maNumTiles)); glUniform2iv(nNumTilesLocation, 1, glm::value_ptr(maNumTiles));
CHECK_GL_ERROR(); CHECK_GL_ERROR();
}
glGenBuffers(1, &mnTileInfoBuffer); glGenBuffers(1, &mnTileInfoBuffer);
CHECK_GL_ERROR(); CHECK_GL_ERROR();
...@@ -1712,17 +1699,11 @@ GLuint RippleTransition::makeShader() const ...@@ -1712,17 +1699,11 @@ GLuint RippleTransition::makeShader() const
void RippleTransition::prepareTransition( sal_Int32, sal_Int32 ) void RippleTransition::prepareTransition( sal_Int32, sal_Int32 )
{ {
if (m_nProgramObject) GLint nCenterLocation = glGetUniformLocation(m_nProgramObject, "center");
{ CHECK_GL_ERROR();
glUseProgram(m_nProgramObject);
CHECK_GL_ERROR();
GLint nCenterLocation = glGetUniformLocation(m_nProgramObject, "center");
CHECK_GL_ERROR();
glUniform2fv(nCenterLocation, 1, glm::value_ptr(maCenter)); glUniform2fv(nCenterLocation, 1, glm::value_ptr(maCenter));
CHECK_GL_ERROR(); CHECK_GL_ERROR();
}
} }
std::shared_ptr<OGLTransitionImpl> std::shared_ptr<OGLTransitionImpl>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment