diff --git a/mainwindow.ui b/mainwindow.ui index d64b61a..c7a20fe 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -159,7 +159,23 @@ + + + Affichage + + + + Interpolation + + + + + + + + + @@ -174,6 +190,36 @@ Esc + + + true + + + true + + + Textures + + + + + true + + + true + + + Phong + + + + + true + + + Gouraud + + diff --git a/src/viewer/simpleViewer.cpp b/src/viewer/simpleViewer.cpp index 649a1ff..c2be734 100644 --- a/src/viewer/simpleViewer.cpp +++ b/src/viewer/simpleViewer.cpp @@ -506,6 +506,13 @@ void Viewer::visit(SceneGroup &s) modelStack.pop(); } +void Viewer::setPhong(bool on) { + m_program->setUniformValue(m_isPhongLoc, on); + if(on) std::cout << "Phong ON\n"; + else std::cout << "Phong OFF\n"; + this->update(); +} + void Viewer::changeColor(QColor c){ if(activeCell->getChildren()->size()){ Shape* shape = dynamic_cast (activeCell->childAt(0)); diff --git a/src/viewer/simpleViewer.h b/src/viewer/simpleViewer.h index 185ce36..fc542bd 100644 --- a/src/viewer/simpleViewer.h +++ b/src/viewer/simpleViewer.h @@ -52,6 +52,7 @@ public: public slots: void cleanup(); void changeColor(QColor); + void setPhong(bool); signals: int shapeSelected(int); diff --git a/src/window/mainwindow.cpp b/src/window/mainwindow.cpp index b2fdeff..43621b5 100644 --- a/src/window/mainwindow.cpp +++ b/src/window/mainwindow.cpp @@ -2,14 +2,23 @@ #include "ui_mainwindow.h" #include #include +#include + +namespace { + Viewer* view; +} MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), - colordialog(new QColorDialog) + colordialog(new QColorDialog) { ui->setupUi(this); + lightTypeGroup = new QActionGroup(this); + lightTypeGroup->addAction(ui->actionGouraud); + lightTypeGroup->addAction(ui->actionPhong); + connect(ui->pushButton, SIGNAL(clicked(bool)), this, SLOT(onColorPickerActivate())); } @@ -24,6 +33,8 @@ void MainWindow::addViewer(Viewer* viewer) layout->addWidget(viewer); ui->frame->setLayout(layout); + // actionGouraud shouldn't need one, since they are mutual + connect(ui->actionPhong, SIGNAL(toggled(bool)), viewer, SLOT(setPhong(bool))); } void MainWindow::onColorPickerActivate(){ diff --git a/src/window/mainwindow.h b/src/window/mainwindow.h index 8ec7803..94c2cfd 100644 --- a/src/window/mainwindow.h +++ b/src/window/mainwindow.h @@ -3,6 +3,7 @@ #include #include +#include #include "src/viewer/simpleViewer.h" namespace Ui { @@ -21,10 +22,12 @@ public: public slots: void onColorPickerActivate(); + //void onTextureToggle(); private: Ui::MainWindow *ui; QColorDialog *colordialog; + QActionGroup *lightTypeGroup; }; #endif // MAINWINDOW_H