EgtGraphics 1.5d1 :
- gestione visualizzazione triangoli per Stm.
This commit is contained in:
+79
-4
@@ -18,6 +18,7 @@
|
||||
#include "GraphObjs.h"
|
||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||
#include "/EgtDev/Include/EGkGdbConst.h"
|
||||
#include "/EgtDev/Include/EGKTriangle3d.h"
|
||||
|
||||
|
||||
//--------------------------- Macro ------------------------------------------
|
||||
@@ -36,6 +37,7 @@ void
|
||||
ObjNewGraphics::Reset( void)
|
||||
{
|
||||
m_bValid = false ;
|
||||
m_nCurrMode = GL_NONE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -45,6 +47,7 @@ ObjNewGraphics::Clear( void)
|
||||
DeleteVaoVbo() ;
|
||||
m_ngaList.clear() ;
|
||||
m_bValid = false ;
|
||||
m_nCurrMode = GL_NONE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -60,7 +63,6 @@ ObjNewGraphics::AddPoint( const Point3d& ptP)
|
||||
{
|
||||
if ( m_pScene == nullptr || ! m_pScene->MakeCurrent())
|
||||
return false ;
|
||||
|
||||
// definisco i buffer per la scheda grafica e vi inserisco i nuovi vertici
|
||||
unsigned int nVaoId ;
|
||||
glGenVertexArrays( 1, &nVaoId) ;
|
||||
@@ -76,7 +78,7 @@ ObjNewGraphics::AddPoint( const Point3d& ptP)
|
||||
}
|
||||
glBindBuffer( GL_ARRAY_BUFFER, nVboId) ;
|
||||
glBufferData( GL_ARRAY_BUFFER, 1 * SIZEV3F, NULL, GL_STATIC_DRAW) ;
|
||||
Vert3f v3V( ptP.x, ptP.y, ptP.z) ;
|
||||
Vert3f v3V( ptP) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, 0, SIZEV3F, &v3V) ;
|
||||
int nCount = 1 ;
|
||||
glVertexPointer( 3, GL_FLOAT, 0, ((void*)(0))) ;
|
||||
@@ -96,7 +98,6 @@ ObjNewGraphics::AddPolyLine( const PolyLine& PL)
|
||||
{
|
||||
if ( m_pScene == nullptr || ! m_pScene->MakeCurrent())
|
||||
return false ;
|
||||
|
||||
// definisco i buffer per la scheda grafica e vi inserisco i nuovi vertici
|
||||
unsigned int nVaoId ;
|
||||
glGenVertexArrays( 1, &nVaoId) ;
|
||||
@@ -116,7 +117,7 @@ ObjNewGraphics::AddPolyLine( const PolyLine& PL)
|
||||
Vert3f v3V ;
|
||||
int nCount = 0 ;
|
||||
for ( bool bFound = PL.GetFirstPoint( ptP) ; bFound ; bFound = PL.GetNextPoint( ptP)) {
|
||||
v3V.Set( ptP.x, ptP.y, ptP.z) ;
|
||||
v3V.Set( ptP) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, nCount * SIZEV3F, SIZEV3F, &v3V) ;
|
||||
++ nCount ;
|
||||
}
|
||||
@@ -131,6 +132,80 @@ ObjNewGraphics::AddPolyLine( const PolyLine& PL)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjNewGraphics::StartTriangles( int nNum)
|
||||
{
|
||||
if ( m_pScene == nullptr || ! m_pScene->MakeCurrent())
|
||||
return false ;
|
||||
// modo corrente deve essere nullo
|
||||
if ( m_nCurrMode != GL_NONE)
|
||||
return false ;
|
||||
// inizializzo emissione triangoli
|
||||
unsigned int nVaoId ;
|
||||
glGenVertexArrays( 1, &nVaoId) ;
|
||||
if ( nVaoId == 0)
|
||||
return false ;
|
||||
glBindVertexArray( nVaoId) ;
|
||||
unsigned int nVboId ;
|
||||
glGenBuffers( 1, &nVboId) ;
|
||||
if ( nVboId == 0) {
|
||||
glBindVertexArray( 0) ;
|
||||
glDeleteVertexArrays( 1, &nVaoId) ;
|
||||
return false ;
|
||||
}
|
||||
glBindBuffer( GL_ARRAY_BUFFER, nVboId) ;
|
||||
glBufferData( GL_ARRAY_BUFFER, 3 * nNum * SIZEV3F, NULL, GL_STATIC_DRAW) ;
|
||||
// aggiungo i dati in lista
|
||||
AddVerts( GL_TRIANGLES, 0, nVaoId, nVboId) ;
|
||||
// dichiaro modo triangoli
|
||||
m_nCurrMode = GL_TRIANGLES ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjNewGraphics::AddTriangle( const Triangle3d& Tria)
|
||||
{
|
||||
if ( m_pScene == nullptr || ! m_pScene->MakeCurrent())
|
||||
return false ;
|
||||
// modo corrente deve essere triangoli
|
||||
if ( m_nCurrMode != GL_TRIANGLES)
|
||||
return false ;
|
||||
// recupero il conteggio dei vertici
|
||||
int nCount = m_ngaList.back().m_nCount ;
|
||||
// emetto i vertici del triangolo
|
||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||
Vert3f v3V( Tria.GetP( i)) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, nCount * SIZEV3F, SIZEV3F, &v3V) ;
|
||||
++ nCount ;
|
||||
}
|
||||
// aggiorno il conteggio
|
||||
m_ngaList.back().m_nCount = nCount ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjNewGraphics::EndTriangles( void)
|
||||
{
|
||||
if ( m_pScene == nullptr || ! m_pScene->MakeCurrent())
|
||||
return false ;
|
||||
// modo corrente deve essere triangoli
|
||||
if ( m_nCurrMode != GL_TRIANGLES)
|
||||
return false ;
|
||||
// termino il modo triangoli
|
||||
glVertexPointer( 3, GL_FLOAT, 0, ((void*)(0))) ;
|
||||
glEnableClientState( GL_VERTEX_ARRAY) ;
|
||||
glBindVertexArray( 0) ;
|
||||
// dichiaro modalità standard
|
||||
m_nCurrMode = GL_NONE ;
|
||||
// dichiaro valida la grafica
|
||||
m_bValid = true ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjNewGraphics::Draw( int nStat, int nMark)
|
||||
|
||||
Reference in New Issue
Block a user