Removed the debug triangle from the material editor plugin.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 11 years ago
parent eabc209303
commit 14aea7acc9

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

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

@ -447,144 +447,6 @@ namespace MaterialEditor
return loadShape( "primitives/teapot.shape" );
}
const char *vs =
"#version 330\n"
"\n"
"layout ( location = 0 ) in vec4 vertex;\n"
"layout ( location = 3 ) in vec4 color;\n"
"out vec4 vColor;\n"
"\n"
"void main( void )\n"
"{\n"
"gl_Position = vertex;\n"
"vColor = color;\n"
"}\n";
const char *ps =
"#version 330\n"
"\n"
"in vec4 vColor;\n"
"out vec4 color;\n"
"\n"
"uniform float redShift;"
"\n"
"void main( void )\n"
"{\n"
"vec4 finalColor = vColor.rgba;\n"
"finalColor.r = redShift;\n"
"color = finalColor;\n"
"}\n";
void CNel3DInterface::drawTriangle()
{
NL3D::CDriverUser *d = dynamic_cast< NL3D::CDriverUser* >( driver );
if( d != NULL )
{
NL3D::IDriver *id = d->getDriver();
NL3D::CVertexBuffer vb;
vb.setVertexFormat( NL3D::CVertexBuffer::PositionFlag | NL3D::CVertexBuffer::PrimaryColorFlag );
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.setColor( 0, NLMISC::CRGBA::Red );
rw.setVertexCoord( 1, 1.0f, -1.0f, 0.0f );
rw.setColor( 1, NLMISC::CRGBA::Green );
rw.setVertexCoord( 2, 0.0f, 1.0f, 0.0f );
rw.setColor( 2, NLMISC::CRGBA::Blue );
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();
NL3D::CMaterial mat;
NL3D::IProgramObject *po = id->createProgramObject();
NL3D::IProgram *vp = id->createVertexProgram();
NL3D::IProgram *pp = id->createPixelProgram();
vp->shaderSource( vs );
pp->shaderSource( ps );
std::string log;
bool ok = false;
ok = vp->compile( log );
if( !ok )
{
delete po;
delete vp;
delete pp;
return;
}
ok = pp->compile( log );
if( !ok )
{
delete po;
delete vp;
delete pp;
return;
}
ok = po->attachVertexProgram( vp );
if( !ok )
{
delete po;
return;
}
ok = po->attachPixelProgram( pp );
if( !ok )
{
delete po;
return;
}
ok = po->link( log );
if( !ok )
{
delete po;
return;
}
ok = id->activeProgramObject( po );
if( !ok )
{
delete po;
return;
}
int opacityLocation = id->getUniformLocation( "redShift" );
if( opacityLocation != -1 )
id->setUniform1f( opacityLocation, 0.25f );
id->activeVertexBuffer( vb );
id->activeIndexBuffer( ib );
driver->clearBuffers( NLMISC::CRGBA::Black );
NLMISC::CMatrix f;
f.identity();
driver->setFrustumMatrix( f );
id->renderRawTriangles2( mat, 0, 1 );
driver->swapBuffers();
id->activeProgramObject( NULL );
delete po;
}
}
bool CNel3DInterface::loadShape( const std::string &fileName )
{
NLMISC::CPath::addSearchPath( NLMISC::CFile::getPath( fileName ), false, false );

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

Loading…
Cancel
Save