Renamed a bunch of shader related classes in NL3D to contain the word Usr, since they are user shader related.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 11 years ago
parent 6c58856ed7
commit c6bb6ec2a9

@ -22,20 +22,20 @@
namespace NL3D namespace NL3D
{ {
class CShaderManager; class CUsrShaderManager;
class CShaderLoader class CUsrShaderLoader
{ {
public: public:
CShaderLoader(); CUsrShaderLoader();
~CShaderLoader(); ~CUsrShaderLoader();
void setManager( CShaderManager *mgr ){ manager = mgr; } void setManager( CUsrShaderManager *mgr ){ manager = mgr; }
void loadShaders( const std::string &directory ); void loadShaders( const std::string &directory );
private: private:
void loadShader( const std::string &file ); void loadShader( const std::string &file );
CShaderManager *manager; CUsrShaderManager *manager;
}; };
} }

@ -15,8 +15,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef SHADER_MANAGER_H #ifndef USR_SHADER_MANAGER_H
#define SHADER_MANAGER_H #define USR_SHADER_MANAGER_H
#include <map> #include <map>
#include <vector> #include <vector>
@ -24,25 +24,25 @@
namespace NL3D namespace NL3D
{ {
class CShaderProgram; class CUsrShaderProgram;
class IShaderVisitor; class IUsrShaderVisitor;
class CShaderManager class CUsrShaderManager
{ {
public: public:
CShaderManager(); CUsrShaderManager();
~CShaderManager(); ~CUsrShaderManager();
void clear(); void clear();
void getShaderList( std::vector< std::string > &v ); void getShaderList( std::vector< std::string > &v );
bool addShader( CShaderProgram *program ); bool addShader( CUsrShaderProgram *program );
bool removeShader( const std::string &name ); bool removeShader( const std::string &name );
bool changeShader( const std::string &name, CShaderProgram *program ); bool changeShader( const std::string &name, CUsrShaderProgram *program );
bool getShader( const std::string &name, CShaderProgram *program ); bool getShader( const std::string &name, CUsrShaderProgram *program );
void visitShaders( IShaderVisitor *visitor ); void visitShaders( IUsrShaderVisitor *visitor );
void visitShader( const std::string &name, IShaderVisitor *visitor ); void visitShader( const std::string &name, IUsrShaderVisitor *visitor );
private: private:
std::map< std::string, CShaderProgram* > programs; std::map< std::string, CUsrShaderProgram* > programs;
}; };
} }

@ -23,14 +23,14 @@
namespace NL3D namespace NL3D
{ {
class CShaderProgram : public NLMISC::IStreamable class CUsrShaderProgram : public NLMISC::IStreamable
{ {
public: public:
CShaderProgram(); CUsrShaderProgram();
~CShaderProgram(); ~CUsrShaderProgram();
std::string getClassName(){ return "CShaderProgram"; } std::string getClassName(){ return "CUsrShaderProgram"; }
void serial( NLMISC::IStream &f ); void serial( NLMISC::IStream &f );

@ -15,32 +15,32 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef SHADER_SAVER_H #ifndef USR_SHADER_SAVER_H
#define SHADER_SAVER_H #define USR_SHADER_SAVER_H
#include "nel/3d/shader_visitor.h" #include "nel/3d/usr_shader_visitor.h"
#include <string> #include <string>
namespace NL3D namespace NL3D
{ {
class CShaderProgram; class CUsrShaderProgram;
class CShaderManager; class CUsrShaderManager;
class CShaderSaver : public IShaderVisitor class CUsrShaderSaver : public IUsrShaderVisitor
{ {
public: public:
CShaderSaver(); CUsrShaderSaver();
~CShaderSaver(); ~CUsrShaderSaver();
void setManager( CShaderManager *mgr ){ manager = mgr; } void setManager( CUsrShaderManager *mgr ){ manager = mgr; }
void visit( CShaderProgram *program ); void visit( CUsrShaderProgram *program );
void saveShaders( const std::string &directory ); void saveShaders( const std::string &directory );
void saveShader( const std::string &directory, const std::string &name ); void saveShader( const std::string &directory, const std::string &name );
private: private:
CShaderManager *manager; CUsrShaderManager *manager;
std::string outputDir; std::string outputDir;
}; };
} }

@ -15,20 +15,20 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef SHADER_VISITOR_H #ifndef USR_SHADER_VISITOR_H
#define SHADER_VISITOR_H #define USR_SHADER_VISITOR_H
namespace NL3D namespace NL3D
{ {
class CShaderProgram; class CUsrShaderProgram;
class IShaderVisitor class IUsrShaderVisitor
{ {
public: public:
IShaderVisitor(){} IUsrShaderVisitor(){}
~IShaderVisitor(){} ~IUsrShaderVisitor(){}
virtual void visit( CShaderProgram *program ) = 0; virtual void visit( CUsrShaderProgram *program ) = 0;
}; };

@ -15,25 +15,25 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/3d/shader_loader.h" #include "nel/3d/usr_shader_loader.h"
#include "nel/3d/shader_manager.h" #include "nel/3d/usr_shader_manager.h"
#include "nel/3d/shader_program.h" #include "nel/3d/usr_shader_program.h"
#include "nel/misc/file.h" #include "nel/misc/file.h"
#include "nel/misc/path.h" #include "nel/misc/path.h"
#include "nel/misc/i_xml.h" #include "nel/misc/i_xml.h"
namespace NL3D namespace NL3D
{ {
CShaderLoader::CShaderLoader() CUsrShaderLoader::CUsrShaderLoader()
{ {
manager = NULL; manager = NULL;
} }
CShaderLoader::~CShaderLoader() CUsrShaderLoader::~CUsrShaderLoader()
{ {
} }
void CShaderLoader::loadShaders( const std::string &directory ) void CUsrShaderLoader::loadShaders( const std::string &directory )
{ {
if( manager == NULL ) if( manager == NULL )
return; return;
@ -54,7 +54,7 @@ namespace NL3D
} }
} }
void CShaderLoader::loadShader( const std::string &file ) void CUsrShaderLoader::loadShader( const std::string &file )
{ {
NLMISC::CIFile f; NLMISC::CIFile f;
if( !f.open( file, true ) ) if( !f.open( file, true ) )
@ -64,7 +64,7 @@ namespace NL3D
if( !xml.init( f ) ) if( !xml.init( f ) )
return; return;
CShaderProgram *p = new CShaderProgram(); CUsrShaderProgram *p = new CUsrShaderProgram();
p->serial( xml ); p->serial( xml );
manager->addShader( p ); manager->addShader( p );

@ -15,25 +15,25 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/3d/shader_manager.h" #include "nel/3d/usr_shader_manager.h"
#include "nel/3d/shader_program.h" #include "nel/3d/usr_shader_program.h"
#include "nel/3d/shader_visitor.h" #include "nel/3d/usr_shader_visitor.h"
namespace NL3D namespace NL3D
{ {
CShaderManager::CShaderManager() CUsrShaderManager::CUsrShaderManager()
{ {
} }
CShaderManager::~CShaderManager() CUsrShaderManager::~CUsrShaderManager()
{ {
clear(); clear();
} }
void CShaderManager::clear() void CUsrShaderManager::clear()
{ {
std::map< std::string, CShaderProgram* >::iterator itr = programs.begin(); std::map< std::string, CUsrShaderProgram* >::iterator itr = programs.begin();
while( itr != programs.end() ) while( itr != programs.end() )
{ {
delete itr->second; delete itr->second;
@ -42,12 +42,12 @@ namespace NL3D
programs.clear(); programs.clear();
} }
void CShaderManager::getShaderList( std::vector< std::string > &v ) void CUsrShaderManager::getShaderList( std::vector< std::string > &v )
{ {
v.clear(); v.clear();
std::string n; std::string n;
std::map< std::string, CShaderProgram* >::iterator itr = programs.begin(); std::map< std::string, CUsrShaderProgram* >::iterator itr = programs.begin();
while( itr != programs.end() ) while( itr != programs.end() )
{ {
itr->second->getName( n ); itr->second->getName( n );
@ -56,12 +56,12 @@ namespace NL3D
} }
} }
bool CShaderManager::addShader( CShaderProgram *program ) bool CUsrShaderManager::addShader( CUsrShaderProgram *program )
{ {
std::string n; std::string n;
program->getName( n ); program->getName( n );
std::map< std::string, CShaderProgram* >::iterator itr std::map< std::string, CUsrShaderProgram* >::iterator itr
= programs.find( n ); = programs.find( n );
if( itr != programs.end() ) if( itr != programs.end() )
return false; return false;
@ -70,9 +70,9 @@ namespace NL3D
return true; return true;
} }
bool CShaderManager::removeShader( const std::string &name ) bool CUsrShaderManager::removeShader( const std::string &name )
{ {
std::map< std::string, CShaderProgram* >::iterator itr std::map< std::string, CUsrShaderProgram* >::iterator itr
= programs.find( name ); = programs.find( name );
if( itr == programs.end() ) if( itr == programs.end() )
return false; return false;
@ -84,14 +84,14 @@ namespace NL3D
return true; return true;
} }
bool CShaderManager::changeShader( const std::string &name, CShaderProgram *program ) bool CUsrShaderManager::changeShader( const std::string &name, CUsrShaderProgram *program )
{ {
std::map< std::string, CShaderProgram* >::iterator itr std::map< std::string, CUsrShaderProgram* >::iterator itr
= programs.find( name ); = programs.find( name );
if( itr == programs.end() ) if( itr == programs.end() )
return false; return false;
CShaderProgram *p = itr->second; CUsrShaderProgram *p = itr->second;
std::string s; std::string s;
program->getName( s ); program->getName( s );
@ -109,14 +109,14 @@ namespace NL3D
return true; return true;
} }
bool CShaderManager::getShader( const std::string &name, CShaderProgram *program ) bool CUsrShaderManager::getShader( const std::string &name, CUsrShaderProgram *program )
{ {
std::map< std::string, CShaderProgram* >::iterator itr std::map< std::string, CUsrShaderProgram* >::iterator itr
= programs.find( name ); = programs.find( name );
if( itr == programs.end() ) if( itr == programs.end() )
return false; return false;
CShaderProgram *p = itr->second; CUsrShaderProgram *p = itr->second;
std::string s; std::string s;
program->setName( name ); program->setName( name );
@ -133,9 +133,9 @@ namespace NL3D
return true; return true;
} }
void CShaderManager::visitShaders( IShaderVisitor *visitor ) void CUsrShaderManager::visitShaders( IUsrShaderVisitor *visitor )
{ {
std::map< std::string, CShaderProgram* >::iterator itr = programs.begin(); std::map< std::string, CUsrShaderProgram* >::iterator itr = programs.begin();
while( itr != programs.end() ) while( itr != programs.end() )
{ {
visitor->visit( itr->second ); visitor->visit( itr->second );
@ -143,9 +143,9 @@ namespace NL3D
} }
} }
void CShaderManager::visitShader( const std::string &name, IShaderVisitor *visitor ) void CUsrShaderManager::visitShader( const std::string &name, IUsrShaderVisitor *visitor )
{ {
std::map< std::string, CShaderProgram* >::iterator itr = std::map< std::string, CUsrShaderProgram* >::iterator itr =
programs.find( name ); programs.find( name );
if( itr == programs.end() ) if( itr == programs.end() )
return; return;

@ -15,22 +15,22 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/3d/shader_program.h" #include "nel/3d/usr_shader_program.h"
namespace NL3D namespace NL3D
{ {
CShaderProgram::CShaderProgram() CUsrShaderProgram::CUsrShaderProgram()
{ {
vpId = 0; vpId = 0;
fpId = 0; fpId = 0;
pId = 0; pId = 0;
} }
CShaderProgram::~CShaderProgram() CUsrShaderProgram::~CUsrShaderProgram()
{ {
} }
void CShaderProgram::serial( NLMISC::IStream &f ) void CUsrShaderProgram::serial( NLMISC::IStream &f )
{ {
f.xmlPush( "ShaderProgram" ); f.xmlPush( "ShaderProgram" );

@ -15,24 +15,24 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/3d/shader_saver.h" #include "nel/3d/usr_shader_saver.h"
#include "nel/3d/shader_manager.h" #include "nel/3d/usr_shader_manager.h"
#include "nel/3d/shader_program.h" #include "nel/3d/usr_shader_program.h"
#include "nel/misc/file.h" #include "nel/misc/file.h"
#include "nel/misc/o_xml.h" #include "nel/misc/o_xml.h"
namespace NL3D namespace NL3D
{ {
CShaderSaver::CShaderSaver() CUsrShaderSaver::CUsrShaderSaver()
{ {
manager = NULL; manager = NULL;
} }
CShaderSaver::~CShaderSaver() CUsrShaderSaver::~CUsrShaderSaver()
{ {
} }
void CShaderSaver::visit( CShaderProgram *program ) void CUsrShaderSaver::visit( CUsrShaderProgram *program )
{ {
std::string fn; std::string fn;
program->getName( fn ); program->getName( fn );
@ -55,13 +55,13 @@ namespace NL3D
} }
void CShaderSaver::saveShaders( const std::string &directory ) void CUsrShaderSaver::saveShaders( const std::string &directory )
{ {
outputDir = directory; outputDir = directory;
manager->visitShaders( this ); manager->visitShaders( this );
} }
void CShaderSaver::saveShader( const std::string &directory, const std::string &name ) void CUsrShaderSaver::saveShader( const std::string &directory, const std::string &name )
{ {
outputDir = directory; outputDir = directory;
manager->visitShader( name, this ); manager->visitShader( name, this );

@ -16,10 +16,10 @@
#include "nel3d_interface.h" #include "nel3d_interface.h"
#include "nel/3d/dynamic_material.h" #include "nel/3d/dynamic_material.h"
#include "nel/3d/shader_manager.h" #include "nel/3d/usr_shader_manager.h"
#include "nel/3d/shader_program.h" #include "nel/3d/usr_shader_program.h"
#include "nel/3d/shader_loader.h" #include "nel/3d/usr_shader_loader.h"
#include "nel/3d/shader_saver.h" #include "nel/3d/usr_shader_saver.h"
#include "nel/3d/driver_user.h" #include "nel/3d/driver_user.h"
#include "nel/3d/scene_user.h" #include "nel/3d/scene_user.h"
#include "nel/3d/u_camera.h" #include "nel/3d/u_camera.h"
@ -231,7 +231,7 @@ namespace MaterialEditor
CNel3DInterface::CNel3DInterface() CNel3DInterface::CNel3DInterface()
{ {
shaderManager = new NL3D::CShaderManager(); shaderManager = new NL3D::CUsrShaderManager();
driver = NULL; driver = NULL;
scene = NULL; scene = NULL;
mouseListener = NULL; mouseListener = NULL;
@ -324,7 +324,7 @@ namespace MaterialEditor
bool CNel3DInterface::getShaderInfo( const std::string &name, SShaderInfo &info ) bool CNel3DInterface::getShaderInfo( const std::string &name, SShaderInfo &info )
{ {
NL3D::CShaderProgram program; NL3D::CUsrShaderProgram program;
bool ok = shaderManager->getShader( name, &program ); bool ok = shaderManager->getShader( name, &program );
if( !ok ) if( !ok )
return false; return false;
@ -346,7 +346,7 @@ namespace MaterialEditor
bool CNel3DInterface::updateShaderInfo( const SShaderInfo &info ) bool CNel3DInterface::updateShaderInfo( const SShaderInfo &info )
{ {
NL3D::CShaderProgram program; NL3D::CUsrShaderProgram program;
program.setName( info.name ); program.setName( info.name );
program.setDescription( info.description ); program.setDescription( info.description );
program.setVP( info.vp ); program.setVP( info.vp );
@ -357,7 +357,7 @@ namespace MaterialEditor
bool CNel3DInterface::addShader( const SShaderInfo &info ) bool CNel3DInterface::addShader( const SShaderInfo &info )
{ {
NL3D::CShaderProgram *program = new NL3D::CShaderProgram(); NL3D::CUsrShaderProgram *program = new NL3D::CUsrShaderProgram();
program->setName( info.name ); program->setName( info.name );
program->setDescription( info.description ); program->setDescription( info.description );
@ -381,14 +381,14 @@ namespace MaterialEditor
void CNel3DInterface::loadShaders() void CNel3DInterface::loadShaders()
{ {
NL3D::CShaderLoader loader; NL3D::CUsrShaderLoader loader;
loader.setManager( shaderManager ); loader.setManager( shaderManager );
loader.loadShaders( "./shaders" ); loader.loadShaders( "./shaders" );
} }
void CNel3DInterface::saveShader( const std::string &name ) void CNel3DInterface::saveShader( const std::string &name )
{ {
NL3D::CShaderSaver saver; NL3D::CUsrShaderSaver saver;
saver.setManager( shaderManager ); saver.setManager( shaderManager );
saver.saveShader( "./shaders", name ); saver.saveShader( "./shaders", name );
} }

@ -25,7 +25,7 @@ namespace NL3D
{ {
class CDynMaterial; class CDynMaterial;
struct SRenderPass; struct SRenderPass;
class CShaderManager; class CUsrShaderManager;
class UDriver; class UDriver;
class UScene; class UScene;
class U3dMouseListener; class U3dMouseListener;
@ -174,7 +174,7 @@ namespace MaterialEditor
unsigned long subMatId; unsigned long subMatId;
NL3D::CShaderManager *shaderManager; NL3D::CUsrShaderManager *shaderManager;
NL3D::UDriver *driver; NL3D::UDriver *driver;
NL3D::UScene *scene; NL3D::UScene *scene;
NL3D::U3dMouseListener *mouseListener; NL3D::U3dMouseListener *mouseListener;

Loading…
Cancel
Save