Shaders are now loaded/saved/deleted from the disk.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 12 years ago
parent 00b47d6a50
commit 1f2ff5721e

@ -45,7 +45,7 @@ namespace NL3D
std::vector< std::string >::iterator itr = files.begin();
while( itr != files.end() )
{
if( NLMISC::CFile::getExtension( *itr ) == ".nelshdr" )
if( NLMISC::CFile::getExtension( *itr ) == "nlshdr" )
{
loadShader( *itr );
}

@ -38,7 +38,7 @@ namespace NL3D
program->getName( fn );
fn += ".nlshdr";
fn = outputDir + fn;
fn = outputDir + "/" + fn;
NLMISC::COFile of;
if( !of.open( fn, false, true ) )

@ -32,8 +32,7 @@
#include <QDockWidget>
#include <QFileDialog>
#include <QMessageBox>
#include "3rdparty/qtpropertybrowser/qttreepropertybrowser.h"
#include <QTimer>
namespace MaterialEditor
{
@ -55,6 +54,8 @@ namespace MaterialEditor
createMenus();
createDockWidgets();
QTimer::singleShot( 1, this, SLOT( onStartup() ) );
}
MaterialEditorWindow::~MaterialEditorWindow()
@ -149,6 +150,11 @@ namespace MaterialEditor
passesWidget->show();
}
void MaterialEditorWindow::onStartup()
{
nl3dIface->loadShaders();
}
void MaterialEditorWindow::createMenus()
{
Core::MenuManager *mm = Core::ICore::instance()->menuManager();

@ -42,6 +42,7 @@ private Q_SLOTS:
void onSaveMaterialClicked();
void onShadersClicked();
void onPassesClicked();
void onStartup();
private:
void createMenus();

@ -18,9 +18,12 @@
#include "nel/3d/dynamic_material.h"
#include "nel/3d/shader_manager.h"
#include "nel/3d/shader_program.h"
#include "nel/3d/shader_loader.h"
#include "nel/3d/shader_saver.h"
#include "nel/misc/i_xml.h"
#include "nel/misc/o_xml.h"
#include "nel/misc/file.h"
#include "nel/misc/path.h"
namespace MaterialEditor
{
@ -300,5 +303,24 @@ namespace MaterialEditor
{
return shaderManager->removeShader( name );
}
void CNel3DInterface::loadShaders()
{
NL3D::CShaderLoader loader;
loader.setManager( shaderManager );
loader.loadShaders( "./shaders" );
}
void CNel3DInterface::saveShader( const std::string &name )
{
NL3D::CShaderSaver saver;
saver.setManager( shaderManager );
saver.saveShader( "./shaders", name );
}
void CNel3DInterface::deleteShader( const std::string &name )
{
NLMISC::CFile::deleteFile( "./shaders/" + name + ".nlshdr" );
}
}

@ -135,6 +135,10 @@ namespace MaterialEditor
bool addShader( const SShaderInfo &info );
bool removeShader( const std::string &name );
void loadShaders();
void saveShader( const std::string &name );
void deleteShader( const std::string &name );
private:
NL3D::CDynMaterial *mat;
NL3D::CShaderManager *shaderManager;

@ -121,6 +121,7 @@ namespace MaterialEditor
SShaderInfo info;
info.name = name.toUtf8().data();
bool ok = nl3dIface->addShader( info );
nl3dIface->saveShader( info.name );
if( !ok )
{
QMessageBox::critical(
@ -155,7 +156,12 @@ namespace MaterialEditor
QListWidgetItem *item = shaderList->takeItem( i );
std::string n = item->text().toUtf8().data();
delete item;
nl3dIface->removeShader( n );
nl3dIface->deleteShader( n );
if( shaderList->count() == 0 )
description->setPlainText( "" );
}
}
@ -214,6 +220,9 @@ namespace MaterialEditor
tr( "There was an error while trying to save shader data!" )
);
}
nl3dIface->saveShader( info.name );
description->setPlainText( info.description.c_str() );
}
void ShaderWidget::onRowChanged( int i )

Loading…
Cancel
Save