Commit dd24e81d authored by Jan Möbius's avatar Jan Möbius
Browse files

Dennis:

UI-and-support-for-pick-shaders

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5400 383ad7c9-94d9-4d36-a494-682f7c89f535
parent c5349439
......@@ -145,6 +145,16 @@ void ViewControlPlugin::updateShaderList() {
emit log( LOGWARN, "Unable to get vertex shader filename from Description file for shader " + shadersDirs[i] );
}
if ( ini.get_entry(tmp,"PickVertexShader","file") )
info.pickVertexShader = tmp;
else
info.pickVertexShader = "";
if ( ini.get_entry(tmp,"PickFragmentShader","file") )
info.pickFragmentShader = tmp;
else
info.pickFragmentShader = "";
//uniform names
std::vector<QString> uniforms;
if ( ini.get_entry(uniforms,"Info","uniforms") ) {
......@@ -601,6 +611,8 @@ void ViewControlPlugin::slotShaderClicked( QListWidgetItem * _item ){
shaderWidget_->version->setText( shaderList_[index].version );
shaderWidget_->vertexShader->setText( shaderList_[index].vertexShader );
shaderWidget_->fragmentShader->setText( shaderList_[index].fragmentShader );
shaderWidget_->pickVertexShader->setText( shaderList_[index].pickVertexShader );
shaderWidget_->pickFragmentShader->setText( shaderList_[index].pickFragmentShader );
shaderWidget_->example->setPixmap( QPixmap(shaderList_[index].example) );
//get shader paths
......@@ -737,6 +749,10 @@ void ViewControlPlugin::slotSetShader(){
OpenFlipper::Options::dirSeparator() + shaderWidget_->vertexShader->text();
QString fragmentFile = shadersDirs[ shaderWidget_->availableShaders->currentRow() ] +
OpenFlipper::Options::dirSeparator() + shaderWidget_->fragmentShader->text();
QString pickVertexFile = shadersDirs[ shaderWidget_->availableShaders->currentRow() ] +
OpenFlipper::Options::dirSeparator() + shaderWidget_->pickVertexShader->text();
QString pickFragmentFile = shadersDirs[ shaderWidget_->availableShaders->currentRow() ] +
OpenFlipper::Options::dirSeparator() + shaderWidget_->pickFragmentShader->text();
//get drawmodes
std::vector< QString > mode;
......@@ -751,7 +767,15 @@ void ViewControlPlugin::slotSetShader(){
PluginFunctions::getObject( lastObjectId_, object );
if ( object && object->shaderNode() ){
object->shaderNode()->setShader(descriptionsToDrawMode(mode), vertexFile.toStdString() , fragmentFile.toStdString());
if ( shaderWidget_->pickVertexShader->text() != "" &&
shaderWidget_->pickFragmentShader->text() != "" &&
QFile( shaderDir + pickVertexFile ).exists() &&
QFile( shaderDir + pickFragmentFile ).exists() )
object->shaderNode()->setShader(descriptionsToDrawMode(mode), vertexFile.toStdString() , fragmentFile.toStdString(),
pickVertexFile.toStdString() , pickFragmentFile.toStdString());
else
object->shaderNode()->setShader(descriptionsToDrawMode(mode), vertexFile.toStdString() , fragmentFile.toStdString());
// set uniforms if available
if (shaderList_[index].hasUniforms){
......@@ -782,7 +806,8 @@ void ViewControlPlugin::slotSetShader(){
emit updateView();
}
void ViewControlPlugin::setShader(int _id, QString _drawMode, QString _vertexShader, QString _fragmentShader ){
void ViewControlPlugin::setShader(int _id, QString _drawMode, QString _vertexShader, QString _fragmentShader,
QString _pickVertexShader, QString _pickFragmentShader){
if ( OpenFlipper::Options::nogui() )
return;
......@@ -803,10 +828,31 @@ void ViewControlPlugin::setShader(int _id, QString _drawMode, QString _vertexSha
return;
}
object->shaderNode()->setShaderDir( (vertexFile.absolutePath() + OpenFlipper::Options::dirSeparator()).toStdString() );
if (_pickVertexShader.length () && _pickFragmentShader.length ())
{
QFileInfo pickVertexFile(_pickVertexShader);
QFileInfo pickFragmentFile(_pickFragmentShader);
if (vertexFile.absolutePath() != pickVertexFile.absolutePath() ||
vertexFile.absolutePath() != pickFragmentFile.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());
object->shaderNode()->setShader(ListToDrawMode( mode ), vertexFile.fileName().toStdString(),
fragmentFile.fileName().toStdString(),
pickVertexFile.fileName().toStdString(),
pickFragmentFile.fileName().toStdString());
}
else
{
object->shaderNode()->setShaderDir( (vertexFile.absolutePath() + OpenFlipper::Options::dirSeparator()).toStdString() );
object->shaderNode()->setShader(ListToDrawMode( mode ), vertexFile.fileName().toStdString(),
fragmentFile.fileName().toStdString());
}
}
emit updateView();
......@@ -844,7 +890,9 @@ void ViewControlPlugin::setShader(int _id, QString _drawMode, QString _name ){
object->shaderNode()->setShaderDir( (shaderList_[index].directory + OpenFlipper::Options::dirSeparator()).toStdString() );
object->shaderNode()->setShader(ListToDrawMode( mode ), shaderList_[index].vertexShader.toStdString(),
shaderList_[index].fragmentShader.toStdString());
shaderList_[index].fragmentShader.toStdString(),
shaderList_[index].pickVertexShader.toStdString(),
shaderList_[index].pickFragmentShader.toStdString());
}
emit updateView();
......
......@@ -57,6 +57,9 @@ struct ShaderInfo {
QString vertexShader;
QString fragmentShader;
QString pickVertexShader;
QString pickFragmentShader;
bool hasUniforms;
QStringList uniforms;
QStringList uniformTypes;
......@@ -174,8 +177,11 @@ class ViewControlPlugin : public QObject, BaseInterface , PickingInterface, Logg
* @param _drawMode ; seperated list of drawmodes used by the shader
* @param _vertexShader File with the vertex shader code
* @param _fragmentShader File with the fragment shader code
* @param _pickVertexShader File with the picking vertex shader code
* @param _pickFragmentShader File with the picking fragment shader code
*/
void setShader(int _id, QString _drawMode, QString _vertexShader, QString _fragmentShader );
void setShader(int _id, QString _drawMode, QString _vertexShader, QString _fragmentShader,
QString _pickVertexShader = "", QString _pickFragmentShader = "");
/** Sets a Shader from the Shader directory of OpenFlipper ( Name of the one given inside the ini file )
*
......
......@@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>784</width>
<height>629</height>
<height>636</height>
</rect>
</property>
<property name="windowTitle" >
......@@ -49,106 +49,6 @@
</layout>
</widget>
</item>
<item rowspan="2" row="1" column="0" colspan="2" >
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Info</string>
</property>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Name</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<property name="spacing" >
<number>4</number>
</property>
<item>
<widget class="QLineEdit" name="name" />
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Version</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="version" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Description</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="description" />
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Details</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QTextEdit" name="details" />
</item>
<item row="3" column="0" >
<widget class="QLabel" name="label_7" >
<property name="text" >
<string>VertexShader</string>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLineEdit" name="vertexShader" />
</item>
<item row="4" column="0" >
<widget class="QLabel" name="label_8" >
<property name="text" >
<string>fragmentShader</string>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QLineEdit" name="fragmentShader" />
</item>
</layout>
<zorder>label_2</zorder>
<zorder>label</zorder>
<zorder>description</zorder>
<zorder>label_4</zorder>
<zorder>details</zorder>
<zorder>label_7</zorder>
<zorder>vertexShader</zorder>
<zorder>label_8</zorder>
<zorder>fragmentShader</zorder>
<zorder>groupBox2</zorder>
</widget>
</item>
<item row="1" column="2" >
<widget class="QGroupBox" name="groupBox2" >
<property name="minimumSize" >
......@@ -231,7 +131,122 @@
</item>
</layout>
</item>
<item rowspan="2" row="1" column="0" colspan="2" >
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Info</string>
</property>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="2" >
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<property name="spacing" >
<number>4</number>
</property>
<item>
<widget class="QLineEdit" name="name" />
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Version</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="version" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Name</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Description</string>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QLineEdit" name="description" />
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Details</string>
</property>
</widget>
</item>
<item row="2" column="2" >
<widget class="QTextEdit" name="details" />
</item>
<item row="5" column="0" >
<widget class="QLabel" name="label_8" >
<property name="text" >
<string>FragmentShader</string>
</property>
</widget>
</item>
<item row="5" column="2" >
<widget class="QLineEdit" name="fragmentShader" />
</item>
<item row="3" column="0" >
<widget class="QLabel" name="label_7" >
<property name="text" >
<string>VertexShader</string>
</property>
</widget>
</item>
<item row="3" column="2" >
<widget class="QLineEdit" name="vertexShader" />
</item>
<item row="6" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Pick Vertex Shader</string>
</property>
</widget>
</item>
<item row="7" column="0" >
<widget class="QLabel" name="label_6" >
<property name="text" >
<string>Pick FragmentShader</string>
</property>
</widget>
</item>
<item row="6" column="2" >
<widget class="QLineEdit" name="pickVertexShader" />
</item>
<item row="7" column="2" >
<widget class="QLineEdit" name="pickFragmentShader" />
</item>
</layout>
</widget>
</item>
</layout>
<zorder>groupBox_4</zorder>
<zorder>groupBox_3</zorder>
<zorder>uniformBox</zorder>
<zorder>groupBox2</zorder>
<zorder>groupBox</zorder>
</widget>
<resources/>
<connections/>
......
Markdown is supported
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