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,24 +50,29 @@ OPENGL_COMPOSITOR::~OPENGL_COMPOSITOR()
clean();
}
void OPENGL_COMPOSITOR::SetAntialiasingMode( OPENGL_ANTIALIASING_MODE aMode )
{
m_currentAntialiasingMode = aMode;
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) {
switch( m_currentAntialiasingMode )
{
case OPENGL_ANTIALIASING_MODE::NONE:
m_antialiasing.reset( new ANTIALIASING_NONE( this ) );
break;
@ -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,21 +291,25 @@ 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 };
}
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 );
@ -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

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() );
}

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