More code formatting

This commit is contained in:
Maciej Suminski 2017-01-13 10:36:59 +01:00
parent 9bc2bb2651
commit 5a7604cbb4
5 changed files with 51 additions and 30 deletions

View File

@ -50,39 +50,44 @@ OPENGL_COMPOSITOR::~OPENGL_COMPOSITOR()
clean();
}
void OPENGL_COMPOSITOR::SetAntialiasingMode( OPENGL_ANTIALIASING_MODE aMode )
{
m_currentAntialiasingMode = aMode;
if(m_initialized)
if( m_initialized )
clean();
}
OPENGL_ANTIALIASING_MODE OPENGL_COMPOSITOR::GetAntialiasingMode() const
{
return m_currentAntialiasingMode;
}
void OPENGL_COMPOSITOR::Initialize()
{
if( m_initialized )
return;
switch(m_currentAntialiasingMode) {
case OPENGL_ANTIALIASING_MODE::NONE:
m_antialiasing.reset( new ANTIALIASING_NONE( this ) );
break;
case OPENGL_ANTIALIASING_MODE::SUBSAMPLE_HIGH:
m_antialiasing.reset( new ANTIALIASING_SMAA( this, SMAA_QUALITY::HIGH ) );
break;
case OPENGL_ANTIALIASING_MODE::SUBSAMPLE_ULTRA:
m_antialiasing.reset( new ANTIALIASING_SMAA( this, SMAA_QUALITY::ULTRA ) );
break;
case OPENGL_ANTIALIASING_MODE::SUPERSAMPLING_X2:
m_antialiasing.reset( new ANTIALIASING_SUPERSAMPLING( this, SUPERSAMPLING_MODE::X2 ) );
break;
case OPENGL_ANTIALIASING_MODE::SUPERSAMPLING_X4:
m_antialiasing.reset( new ANTIALIASING_SUPERSAMPLING( this, SUPERSAMPLING_MODE::X4 ) );
break;
switch( m_currentAntialiasingMode )
{
case OPENGL_ANTIALIASING_MODE::NONE:
m_antialiasing.reset( new ANTIALIASING_NONE( this ) );
break;
case OPENGL_ANTIALIASING_MODE::SUBSAMPLE_HIGH:
m_antialiasing.reset( new ANTIALIASING_SMAA( this, SMAA_QUALITY::HIGH ) );
break;
case OPENGL_ANTIALIASING_MODE::SUBSAMPLE_ULTRA:
m_antialiasing.reset( new ANTIALIASING_SMAA( this, SMAA_QUALITY::ULTRA ) );
break;
case OPENGL_ANTIALIASING_MODE::SUPERSAMPLING_X2:
m_antialiasing.reset( new ANTIALIASING_SUPERSAMPLING( this, SUPERSAMPLING_MODE::X2 ) );
break;
case OPENGL_ANTIALIASING_MODE::SUPERSAMPLING_X4:
m_antialiasing.reset( new ANTIALIASING_SUPERSAMPLING( this, SUPERSAMPLING_MODE::X4 ) );
break;
}
VECTOR2U dims = m_antialiasing->GetInternalBufferSize();
@ -117,6 +122,8 @@ void OPENGL_COMPOSITOR::Initialize()
void OPENGL_COMPOSITOR::Resize( unsigned int aWidth, unsigned int aHeight )
{
assert( aWidth > 0 && aHeight > 0 );
if( m_initialized )
clean();
@ -126,11 +133,13 @@ void OPENGL_COMPOSITOR::Resize( unsigned int aWidth, unsigned int aHeight )
m_height = aHeight;
}
unsigned int OPENGL_COMPOSITOR::CreateBuffer()
{
return m_antialiasing->CreateBuffer();
}
unsigned int OPENGL_COMPOSITOR::CreateBuffer( VECTOR2U aDimensions )
{
assert( m_initialized );
@ -241,12 +250,14 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer( VECTOR2U aDimensions )
return usedBuffers();
}
GLenum OPENGL_COMPOSITOR::GetBufferTexture( unsigned int aBufferHandle )
{
assert( aBufferHandle > 0 && aBufferHandle <= usedBuffers() );
return m_buffers[aBufferHandle - 1].textureTarget;
}
void OPENGL_COMPOSITOR::SetBuffer( unsigned int aBufferHandle )
{
assert( m_initialized );
@ -264,13 +275,14 @@ void OPENGL_COMPOSITOR::SetBuffer( unsigned int aBufferHandle )
glViewport( 0, 0,
m_buffers[m_curBuffer].dimensions.x, m_buffers[m_curBuffer].dimensions.y );
} else {
}
else
{
glViewport( 0, 0, GetScreenSize().x, GetScreenSize().y );
}
}
void OPENGL_COMPOSITOR::ClearBuffer()
{
assert( m_initialized );
@ -279,26 +291,30 @@ void OPENGL_COMPOSITOR::ClearBuffer()
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
}
VECTOR2U OPENGL_COMPOSITOR::GetScreenSize() const
{
return{ m_width, m_height };
return { m_width, m_height };
}
void OPENGL_COMPOSITOR::Begin()
{
m_antialiasing->Begin();
}
void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aBufferHandle )
{
m_antialiasing->DrawBuffer( aBufferHandle );
}
void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aSourceHandle, unsigned int aDestHandle )
{
assert( m_initialized );
assert( aSourceHandle != 0 && aSourceHandle <= usedBuffers() );
assert (aDestHandle <= usedBuffers() );
assert( aDestHandle <= usedBuffers() );
// Switch to the destination buffer and blit the scene
SetBuffer ( aDestHandle );
@ -340,12 +356,15 @@ void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aSourceHandle, unsigned int aDe
glPopMatrix();
}
void OPENGL_COMPOSITOR::Present()
{
m_antialiasing->Present();
}
void OPENGL_COMPOSITOR::bindFb( unsigned int aFb ) {
void OPENGL_COMPOSITOR::bindFb( unsigned int aFb )
{
// Currently there are only 2 valid FBOs
assert( aFb == DIRECT_RENDERING || aFb == m_mainFbo );

View File

@ -82,7 +82,8 @@ OPENGL_GAL::OPENGL_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent,
++instanceCounter;
// Check if OpenGL requirements are met
// Check if OpenGL requirements are met. The test procedure also initializes a few parts
// of the OpenGL backend (e.g. GLEW), so it is required that it is invoked before any GL calls.
runTest();
// Make VBOs use shaders
@ -192,7 +193,7 @@ OPENGL_GAL::~OPENGL_GAL()
void OPENGL_GAL::OnGalDisplayOptionsChanged( const GAL_DISPLAY_OPTIONS& aDisplayOptions )
{
if(options.gl_antialiasing_mode != compositor->GetAntialiasingMode())
if( options.gl_antialiasing_mode != compositor->GetAntialiasingMode() )
{
compositor->SetAntialiasingMode( options.gl_antialiasing_mode );
isFramebufferInitialized = false;
@ -313,7 +314,7 @@ void OPENGL_GAL::BeginDrawing()
// Something betreen BeginDrawing and EndDrawing seems to depend on
// this texture unit being active, but it does not assure it itself.
glActiveTexture(GL_TEXTURE0);
glActiveTexture( GL_TEXTURE0 );
// Unbind buffers - set compositor for direct drawing
compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING );

View File

@ -157,7 +157,7 @@ void SHADER::SetParameter( int parameterNumber, float f0, float f1, float f2, fl
}
int SHADER::GetAttribute( std::string aAttributeName ) const
int SHADER::GetAttribute( const std::string& aAttributeName ) const
{
return glGetAttribLocation( programNumber, aAttributeName.c_str() );
}
@ -209,7 +209,7 @@ std::string SHADER::ReadSource( const std::string& aShaderSourceName )
{
// Open the shader source for reading
std::ifstream inputFile( aShaderSourceName.c_str(), std::ifstream::in );
std::string shaderSource;
std::string shaderSource;
if( !inputFile )
throw std::runtime_error( "Can't read the shader source: " + aShaderSourceName );

View File

@ -90,7 +90,8 @@ public:
virtual bool IsInitialized() const override { return IsShownOnScreen(); }
///> @copydoc GAL::IsVisible()
bool IsVisible() const override {
bool IsVisible() const override
{
return IsShownOnScreen();
}

View File

@ -190,7 +190,7 @@ public:
* @param aAttributeName is the name of the attribute.
* @return the location.
*/
int GetAttribute( std::string aAttributeName ) const;
int GetAttribute( const std::string& aAttributeName ) const;
/**
* @brief Read the shader source file