EgtGraphics 1.6b3 :
- aggiunta gestione flag di edge per non disegnare in wireframe/hiddenline (per poligoni).
This commit is contained in:
+16
-9
@@ -21,10 +21,13 @@
|
||||
#include "/EgtDev/Include/EGKTriangle3d.h"
|
||||
|
||||
|
||||
//--------------------------- Macro ------------------------------------------
|
||||
//--------------------------- Macro e Costanti -------------------------------
|
||||
// Per funzioni glew dipendenti dal context
|
||||
#define glewGetContext() (( m_pScene != nullptr) ? m_pScene->glewGetContext() : nullptr)
|
||||
|
||||
// Dimensioni flag per edge di triangoli
|
||||
const size_t SIZEFLAG = sizeof( unsigned char) ;
|
||||
// Dimensioni record del buffer ( vertice + normale + flag)
|
||||
const size_t SIZEVNF = ( 2 * SIZEV3F + SIZEFLAG) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ObjNewGraphics::~ObjNewGraphics( void)
|
||||
@@ -215,8 +218,8 @@ ObjNewGraphics::StartTriangles( int nNum, bool bAux)
|
||||
return false ;
|
||||
}
|
||||
glBindBuffer( GL_ARRAY_BUFFER, nVboId) ;
|
||||
// 3 float per le coordinate e 3 per la normale
|
||||
glBufferData( GL_ARRAY_BUFFER, 6 * nNum * SIZEV3F, NULL, GL_STATIC_DRAW) ;
|
||||
// NumTria * 3 * dimensione( vertice+normale+flag)
|
||||
glBufferData( GL_ARRAY_BUFFER, nNum * 3 * SIZEVNF, NULL, GL_STATIC_DRAW) ;
|
||||
// aggiungo i dati in lista
|
||||
AddVerts( GL_TRIANGLES, 0, nVaoId, nVboId, bAux) ;
|
||||
// dichiaro modo triangoli
|
||||
@@ -226,7 +229,7 @@ ObjNewGraphics::StartTriangles( int nNum, bool bAux)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjNewGraphics::AddTriangle( const Triangle3d& Tria, const TriNormals3d& TNrms)
|
||||
ObjNewGraphics::AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, const TriNormals3d& TNrms)
|
||||
{
|
||||
if ( m_pScene == nullptr || ! m_pScene->MakeCurrent())
|
||||
return false ;
|
||||
@@ -238,9 +241,11 @@ ObjNewGraphics::AddTriangle( const Triangle3d& Tria, const TriNormals3d& TNrms)
|
||||
// emetto i vertici e le normali del triangolo
|
||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||
Vert3f v3V( Tria.GetP( i)) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, 2 * nCount * SIZEV3F, SIZEV3F, &v3V) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, nCount * SIZEVNF, SIZEV3F, &v3V) ;
|
||||
Vert3f v3N( TNrms.vtN[i]) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, ( 2 * nCount + 1) * SIZEV3F, SIZEV3F, &v3N) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, nCount * SIZEVNF + SIZEV3F, SIZEV3F, &v3N) ;
|
||||
unsigned char cFlag = ( TFlags.bFlag[i] ? 1 : 0) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, nCount * SIZEVNF + 2 * SIZEV3F, SIZEFLAG, &cFlag) ;
|
||||
++ nCount ;
|
||||
}
|
||||
// aggiorno il conteggio
|
||||
@@ -258,10 +263,12 @@ ObjNewGraphics::EndTriangles( void)
|
||||
if ( m_nCurrMode != GL_TRIANGLES)
|
||||
return false ;
|
||||
// termino il modo triangoli
|
||||
glVertexPointer( 3, GL_FLOAT, 2 * SIZEV3F, ((void*)(0))) ;
|
||||
glVertexPointer( 3, GL_FLOAT, SIZEVNF, ((void*)(0))) ;
|
||||
glEnableClientState( GL_VERTEX_ARRAY) ;
|
||||
glNormalPointer( GL_FLOAT, 2 * SIZEV3F, ((void*)( 1 * SIZEV3F))) ;
|
||||
glNormalPointer( GL_FLOAT, SIZEVNF, ((void*)( 1 * SIZEV3F))) ;
|
||||
glEnableClientState( GL_NORMAL_ARRAY) ;
|
||||
glEdgeFlagPointer( SIZEVNF, ((void*)( 2 * SIZEV3F))) ;
|
||||
glEnableClientState( GL_EDGE_FLAG_ARRAY) ;
|
||||
glBindVertexArray( 0) ;
|
||||
// dichiaro modalità standard
|
||||
m_nCurrMode = GL_NONE ;
|
||||
|
||||
Reference in New Issue
Block a user