Commit 6e1eb7c1 authored by Dirk Wilden's avatar Dirk Wilden
Browse files

set shader from scripting

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4953 383ad7c9-94d9-4d36-a494-682f7c89f535
parent b93d89b5
......@@ -761,17 +761,33 @@ void ViewControlPlugin::slotSetShader(){
}
void ViewControlPlugin::setShader(int _id, QString _drawMode, QString _vertexShader, QString _fragmentShader ){
std::cerr << "Todo : Scripting to set Shader" << std::endl;
// if ( OpenFlipper::Options::nogui() )
// return;
//
// BaseObjectData* object = 0;
// PluginFunctions::getObject( _id, object );
//
// if ( object && object->shaderNode() ){
// object->shaderNode()->setShader( descriptionsToDrawMode(_drawMode), _vertexShader.toStdString() , _fragmentShader.toStdString());
// }
if ( OpenFlipper::Options::nogui() )
return;
BaseObjectData* object = 0;
PluginFunctions::getObject( _id, object );
std::vector< QString > mode;
mode.push_back( _drawMode );
if ( object && object->shaderNode() ){
QFileInfo vertexFile(_vertexShader);
QFileInfo fragmentFile(_fragmentShader);
if (vertexFile.absolutePath() != fragmentFile.absolutePath()){
emit log(LOGERR, "Cannot set shader. Currently shader files have to be in the same folder.");
return;
}
object->shaderNode()->setShaderDir( (vertexFile.absolutePath() + OpenFlipper::Options::dirSeparator()).toStdString() );
object->shaderNode()->setShader(ListToDrawMode( mode ), vertexFile.fileName().toStdString(),
fragmentFile.fileName().toStdString());
}
emit updateView();
}
void ViewControlPlugin::setShader(int _id, QString _drawMode, QString _name ){
......@@ -779,6 +795,8 @@ void ViewControlPlugin::setShader(int _id, QString _drawMode, QString _name ){
if ( OpenFlipper::Options::nogui() )
return;
updateShaderList();
//get current shader index
int index = -1;
for ( int i = 0 ; i < (int)shaderList_.size(); ++i) {
......@@ -796,10 +814,18 @@ void ViewControlPlugin::setShader(int _id, QString _drawMode, QString _name ){
BaseObjectData* object = 0;
PluginFunctions::getObject( _id, object );
std::vector< QString > mode;
mode.push_back( _drawMode );
if ( object && object->shaderNode() ){
std::cerr << "TODO : Get right shader from list, set uniforms as stored in the list" << std::endl;
object->shaderNode()->setShaderDir( (shaderList_[index].directory + OpenFlipper::Options::dirSeparator()).toStdString() );
object->shaderNode()->setShader(ListToDrawMode( mode ), shaderList_[index].vertexShader.toStdString(),
shaderList_[index].fragmentShader.toStdString());
}
emit updateView();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment