Added triangle drawing for debug purposes.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 11 years ago
parent c7e8ebcf05
commit f387256984

@ -260,6 +260,13 @@ namespace MaterialEditor
viewPort->stopTimedUpdates(); viewPort->stopTimedUpdates();
} }
void MaterialEditorWindow::onTriangleClicked()
{
nl3dIface->clearScene();
materialSplitter->onSceneCleared();
nl3dIface->drawTriangle();
}
void MaterialEditorWindow::createMenus() void MaterialEditorWindow::createMenus()
{ {
Core::MenuManager *mm = Core::ICore::instance()->menuManager(); Core::MenuManager *mm = Core::ICore::instance()->menuManager();
@ -305,6 +312,13 @@ namespace MaterialEditor
a = new QAction( tr( "Clear scene" ), NULL ); a = new QAction( tr( "Clear scene" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onClearSceneClicked() ) ); connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onClearSceneClicked() ) );
mm->addAction( a ); mm->addAction( a );
QMenu *mmmm = mm->addMenu( tr( "Debug" ) );
{
a = new QAction( tr( "Triangle" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onTriangleClicked() ) );
mmmm->addAction( a );
}
} }
a = new QAction( tr( "Shaders" ), NULL ); a = new QAction( tr( "Shaders" ), NULL );

@ -51,6 +51,7 @@ private Q_SLOTS:
void onAddTeaPotClicked(); void onAddTeaPotClicked();
void onClearSceneClicked(); void onClearSceneClicked();
void onTriangleClicked();
private: private:
void createMenus(); void createMenus();

@ -445,6 +445,53 @@ namespace MaterialEditor
return loadShape( "primitives/teapot.shape" ); return loadShape( "primitives/teapot.shape" );
} }
void CNel3DInterface::drawTriangle()
{
driver->clearBuffers( NLMISC::CRGBA::Black );
NLMISC::CMatrix f;
f.identity();
driver->setFrustumMatrix( f );
NL3D::CDriverUser *d = dynamic_cast< NL3D::CDriverUser* >( driver );
if( d != NULL )
{
NL3D::IDriver *id = d->getDriver();
NL3D::CVertexBuffer vb;
vb.setVertexFormat( NL3D::CVertexBuffer::PositionFlag );
vb.setNumVertices( 3 );
vb.setPreferredMemory( NL3D::CVertexBuffer::StaticPreferred, false );
NL3D::CVertexBufferReadWrite rw;
vb.lock( rw );
rw.setVertexCoord( 0, -1.0f, -1.0f, 0.0f );
rw.setVertexCoord( 1, 1.0f, -1.0f, 0.0f );
rw.setVertexCoord( 2, 0.0f, 1.0f, 0.0f );
rw.unlock();
NL3D::CIndexBuffer ib;
ib.setNumIndexes( 3 );
ib.setFormat( NL3D::CIndexBuffer::Indices32 );
ib.setPreferredMemory( NL3D::CIndexBuffer::StaticPreferred, false );
NL3D::CIndexBufferReadWrite iw;
ib.lock( iw );
iw.setTri( 0, 0, 1, 2 );
iw.unlock();
id->activeVertexBuffer( vb );
id->activeIndexBuffer( ib );
NL3D::CMaterial mat;
mat.setColor( NLMISC::CRGBA::White );
id->renderRawTriangles( mat, 0, 1 );
}
driver->swapBuffers();
}
bool CNel3DInterface::loadShape( const std::string &fileName ) bool CNel3DInterface::loadShape( const std::string &fileName )
{ {
NLMISC::CPath::addSearchPath( NLMISC::CFile::getPath( fileName ), false, false ); NLMISC::CPath::addSearchPath( NLMISC::CFile::getPath( fileName ), false, false );

@ -161,6 +161,7 @@ namespace MaterialEditor
bool addSphere(); bool addSphere();
bool addCylinder(); bool addCylinder();
bool addTeaPot(); bool addTeaPot();
void drawTriangle();
bool loadShape( const std::string &fileName ); bool loadShape( const std::string &fileName );
void clearScene(); void clearScene();

Loading…
Cancel
Save