Commit 5512c5ff authored by Frédéric Larue's avatar Frédéric Larue
Browse files

During the creation of a SelectionManagerMeshFaces, the way the VBO must be...

During the creation of a SelectionManagerMeshFaces, the way the VBO must be drawn can now be specified (by array or by element).
parent b28d041a
......@@ -135,10 +135,12 @@ const char* SelectionManagerMeshFaces::s_SelectionShaderFSH =
SelectionManagerMeshFaces::SelectionManagerMeshFaces( GPU::VBO &meshVBO,
const std::string& posAttribName ) :
const std::string& posAttribName,
bool useIndices) :
FaceSelectionManager(),
m_MeshVBO( meshVBO ),
m_PosAttribName( posAttribName )
m_PosAttribName( posAttribName ),
m_UseIndices( useIndices )
{
GPU::CreateShaderFromSources(
m_DisplayShader,
......@@ -147,7 +149,7 @@ SelectionManagerMeshFaces::SelectionManagerMeshFaces( GPU::VBO &meshVBO,
s_DisplayShaderFSH
);
if( m_MeshVBO.Indices() )
if( m_MeshVBO.Indices() && useIndices )
m_NFaces = m_MeshVBO.Indices()->BufferSize() / 3;
else
m_NFaces = m_MeshVBO.Attrib(posAttribName)->BufferSize() / 3;
......@@ -207,7 +209,10 @@ void SelectionManagerMeshFaces::onUpdatingSelection( SelectionTool *tool )
//m_IsNormalLoaded? m_VBO.Normal.Enable() : m_VBO.Normal.Disable();
glPointSize( 1.0f );
m_MeshVBO.DrawArrays( GL_TRIANGLES );
if( m_MeshVBO.Indices() && m_UseIndices )
m_MeshVBO.DrawElements( GL_TRIANGLES );
else
m_MeshVBO.DrawArrays( GL_TRIANGLES );
glFlush();
m_SelectionOutBuffer.Unbind();
......@@ -243,7 +248,11 @@ void SelectionManagerMeshFaces::onDisplay( GLViewer *viewer,
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glPolygonMode( GL_FRONT, GL_FILL );
m_MeshVBO.DrawArrays( GL_TRIANGLES );
if( m_MeshVBO.Indices() && m_UseIndices )
m_MeshVBO.DrawElements( GL_TRIANGLES );
else
m_MeshVBO.DrawArrays( GL_TRIANGLES );
glDisable( GL_BLEND );
}
......
......@@ -29,9 +29,12 @@ class SelectionManagerMeshFaces : public FaceSelectionManager
unsigned int m_FrameBufferWidth;
unsigned int m_FrameBufferHeight;
bool m_UseIndices;
public:
SelectionManagerMeshFaces( GPU::VBO &meshVBO,
const std::string& posAttribName );
const std::string& posAttribName,
bool useIndices );
void onRecompilingSelectionShader( SelectionTool *tool );
void onUpdatingSelection( SelectionTool *tool );
......
Supports Markdown
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