mirror of
https://github.com/ConjureETS/LOG750-LAB2.git
synced 2026-03-24 03:21:19 +00:00
Phong Toggle
This commit is contained in:
parent
e7c2dc3e63
commit
d1ed0a00dd
@ -159,7 +159,23 @@
|
||||
</property>
|
||||
<addaction name="action_Quit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuAffichage">
|
||||
<property name="title">
|
||||
<string>Affichage</string>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuInterpolation">
|
||||
<property name="title">
|
||||
<string>Interpolation</string>
|
||||
</property>
|
||||
<addaction name="actionPhong"/>
|
||||
<addaction name="actionGouraud"/>
|
||||
</widget>
|
||||
<addaction name="actionTextures"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="menuInterpolation"/>
|
||||
</widget>
|
||||
<addaction name="menu_File"/>
|
||||
<addaction name="menuAffichage"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar">
|
||||
<property name="enabled">
|
||||
@ -174,6 +190,36 @@
|
||||
<string>Esc</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionTextures">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Textures</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPhong">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Phong</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionGouraud">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Gouraud</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
|
||||
@ -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<Shape*> (activeCell->childAt(0));
|
||||
|
||||
@ -52,6 +52,7 @@ public:
|
||||
public slots:
|
||||
void cleanup();
|
||||
void changeColor(QColor);
|
||||
void setPhong(bool);
|
||||
|
||||
signals:
|
||||
int shapeSelected(int);
|
||||
|
||||
@ -2,14 +2,23 @@
|
||||
#include "ui_mainwindow.h"
|
||||
#include <QBoxLayout>
|
||||
#include <QColorDialog>
|
||||
#include <QActionGroup>
|
||||
|
||||
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(){
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QColorDialog>
|
||||
#include <QActionGroup>
|
||||
#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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user