eeschema-gal: implemented EnableDepthTest() in GAL, fixed drawing order in eeschema

This commit is contained in:
Tomasz Włostowski 2018-10-15 00:09:59 +02:00
parent 0777d11188
commit d66e0d4f7a
8 changed files with 49 additions and 9 deletions

View File

@ -49,7 +49,7 @@ GPU_MANAGER* GPU_MANAGER::MakeManager( VERTEX_CONTAINER* aContainer )
GPU_MANAGER::GPU_MANAGER( VERTEX_CONTAINER* aContainer ) : GPU_MANAGER::GPU_MANAGER( VERTEX_CONTAINER* aContainer ) :
m_isDrawing( false ), m_container( aContainer ), m_shader( NULL ), m_shaderAttrib( 0 ) m_isDrawing( false ), m_container( aContainer ), m_shader( NULL ), m_shaderAttrib( 0 ), m_enableDepthTest( true )
{ {
} }
@ -154,6 +154,11 @@ void GPU_CACHED_MANAGER::EndDrawing()
return; return;
} }
if( m_enableDepthTest )
glEnable( GL_DEPTH_TEST );
else
glDisable( GL_DEPTH_TEST );
// Prepare buffers // Prepare buffers
glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_COLOR_ARRAY ); glEnableClientState( GL_COLOR_ARRAY );
@ -254,6 +259,11 @@ void GPU_NONCACHED_MANAGER::EndDrawing()
GLfloat* coordinates = (GLfloat*) ( vertices ); GLfloat* coordinates = (GLfloat*) ( vertices );
GLubyte* colors = (GLubyte*) ( vertices ) + COLOR_OFFSET; GLubyte* colors = (GLubyte*) ( vertices ) + COLOR_OFFSET;
if( m_enableDepthTest )
glEnable( GL_DEPTH_TEST );
else
glDisable( GL_DEPTH_TEST );
// Prepare buffers // Prepare buffers
glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_COLOR_ARRAY ); glEnableClientState( GL_COLOR_ARRAY );
@ -295,3 +305,8 @@ void GPU_NONCACHED_MANAGER::EndDrawing()
wxT( "GPU_NONCACHED_MANAGER::EndDrawing(): %.1f ms" ), totalRealTime.msecs() ); wxT( "GPU_NONCACHED_MANAGER::EndDrawing(): %.1f ms" ), totalRealTime.msecs() );
#endif /* __WXDEBUG__ */ #endif /* __WXDEBUG__ */
} }
void GPU_MANAGER::EnableDepthTest( bool aEnabled )
{
m_enableDepthTest = aEnabled;
}

View File

@ -1159,6 +1159,8 @@ void OPENGL_GAL::DrawGrid()
SetTarget( TARGET_NONCACHED ); SetTarget( TARGET_NONCACHED );
compositor->SetBuffer( mainBuffer ); compositor->SetBuffer( mainBuffer );
nonCachedManager->EnableDepthTest( false );
// sub-pixel lines all render the same // sub-pixel lines all render the same
double minorLineWidth = std::max( 1.0, gridLineWidth ) * getWorldPixelSize(); double minorLineWidth = std::max( 1.0, gridLineWidth ) * getWorldPixelSize();
double majorLineWidth = minorLineWidth * 2.0; double majorLineWidth = minorLineWidth * 2.0;
@ -2072,10 +2074,7 @@ static void InitTesselatorCallbacks( GLUtesselator* aTesselator )
void OPENGL_GAL::EnableDepthTest( bool aEnabled ) void OPENGL_GAL::EnableDepthTest( bool aEnabled )
{ {
if( aEnabled ) cachedManager->EnableDepthTest( aEnabled );
glEnable( GL_DEPTH_TEST ); nonCachedManager->EnableDepthTest( aEnabled );
else overlayManager->EnableDepthTest( aEnabled );
{
glDisable( GL_DEPTH_TEST );
}
} }

View File

@ -284,3 +284,8 @@ void VERTEX_MANAGER::putVertex( VERTEX& aTarget, GLfloat aX, GLfloat aY, GLfloat
aTarget.shader[j] = m_shader[j]; aTarget.shader[j] = m_shader[j];
} }
} }
void VERTEX_MANAGER::EnableDepthTest( bool aEnabled )
{
m_gpu->EnableDepthTest( aEnabled );
}

View File

@ -1427,6 +1427,9 @@ void SCH_EDIT_FRAME::addCurrentItemToScreen( bool aRedraw )
} }
item->ClearFlags(); item->ClearFlags();
GetCanvas()->GetView()->Update( item );
screen->SetModify(); screen->SetModify();
screen->SetCurItem( NULL ); screen->SetCurItem( NULL );
m_canvas->SetMouseCapture( NULL, NULL ); m_canvas->SetMouseCapture( NULL, NULL );

View File

@ -144,8 +144,6 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer )
m_schSettings.ImportLegacyColors( nullptr ); m_schSettings.ImportLegacyColors( nullptr );
m_gal->EnableDepthTest( false );
switch( item->Type() ) switch( item->Type() )
{ {
HANDLE_ITEM(LIB_ALIAS_T, LIB_ALIAS); HANDLE_ITEM(LIB_ALIAS_T, LIB_ALIAS);
@ -1079,6 +1077,8 @@ void SCH_PAINTER::draw( SCH_COMPONENT *aComp, int aLayer )
std::vector<SCH_FIELD*> fields; std::vector<SCH_FIELD*> fields;
aComp->GetFields( fields, false ); aComp->GetFields( fields, false );
m_gal->AdvanceDepth();
for( SCH_FIELD* field : fields ) for( SCH_FIELD* field : fields )
{ {
if( field->GetId() == REFERENCE || !field->IsMoving() ) if( field->GetId() == REFERENCE || !field->IsMoving() )

View File

@ -222,6 +222,9 @@ void SCH_VIEW::Redraw()
( *i )->items->Query( rect, visitor ); ( *i )->items->Query( rect, visitor );
} }
m_gal->EnableDepthTest( false );
VIEW::Redraw(); VIEW::Redraw();
} }

View File

@ -79,6 +79,12 @@ public:
*/ */
virtual void SetShader( SHADER& aShader ); virtual void SetShader( SHADER& aShader );
/**
* Function EnableDepthTest()
* Enables/disables Z buffer depth test.
*/
void EnableDepthTest( bool aEnabled );
protected: protected:
GPU_MANAGER( VERTEX_CONTAINER* aContainer ); GPU_MANAGER( VERTEX_CONTAINER* aContainer );
@ -93,6 +99,9 @@ protected:
///> Location of shader attributes (for glVertexAttribPointer) ///> Location of shader attributes (for glVertexAttribPointer)
int m_shaderAttrib; int m_shaderAttrib;
///> true: enable Z test when drawing
bool m_enableDepthTest;
}; };

View File

@ -349,6 +349,12 @@ public:
*/ */
void EndDrawing() const; void EndDrawing() const;
/**
* Function EnableDepthTest()
* Enables/disables Z buffer depth test.
*/
void EnableDepthTest( bool aEnabled );
protected: protected:
/** /**
* Function putVertex() * Function putVertex()