Commit 8f95f651 by Alisa Jung

removed all shaders except phong

parent 00286a48
......@@ -17,44 +17,6 @@ MainWindow::MainWindow(QWidget *parent)
menuBar->addMenu(fileMenu );
//3.2.2 Shading Menu
shadingMenu = new QMenu("Shading");
shadeWireframeAction = new QAction("Wireframe",shadingMenu);
shadeFlatAction = new QAction("Flat",shadingMenu);
shadeGouraudAction = new QAction("Gouraud",shadingMenu);
shadePhongAction = new QAction("Phong",shadingMenu);
shadeWireframeAction->setShortcut(QKeySequence(tr("Ctrl+1")));
shadeFlatAction->setShortcut(QKeySequence(tr("Ctrl+2")));
shadeGouraudAction->setShortcut(QKeySequence(tr("Ctrl+3")));
shadePhongAction->setShortcut(QKeySequence(tr("Ctrl+4")));
shadeWireframeAction->setCheckable(true);
shadeFlatAction->setCheckable(true);
shadeGouraudAction->setCheckable(true);
shadePhongAction->setCheckable(true);
shadeWireframeAction->setIcon(QIcon(":/img/wireframe.png"));
shadeFlatAction->setIcon(QIcon(":/img/flat.png"));
shadeGouraudAction->setIcon(QIcon(":/img/gouraud.png"));
shadePhongAction->setIcon(QIcon(":/img/phong.png"));
shaderGroup = new QActionGroup(shadingMenu);
shaderGroup->addAction(shadeWireframeAction);
shaderGroup->addAction(shadeFlatAction);
shaderGroup->addAction(shadeGouraudAction);
shaderGroup->addAction(shadePhongAction);
shadingMenu->addAction(shadeWireframeAction);
shadingMenu->addAction(shadeFlatAction);
shadingMenu->addAction(shadeGouraudAction);
shadingMenu->addAction(shadePhongAction);
shadeFlatAction->setChecked(true);
menuBar->addMenu(shadingMenu);
setMenuBar(menuBar);
//3.2.3 About Message Box
......@@ -64,10 +26,6 @@ MainWindow::MainWindow(QWidget *parent)
//3.3 Toolbar
toolBar = new QToolBar("ToolBar",this);
toolBar->addAction(shadeWireframeAction);
toolBar->addAction(shadeFlatAction);
toolBar->addAction(shadeGouraudAction);
toolBar->addAction(shadePhongAction);
addToolBar( toolBar);
//3.4 Status Bar
......@@ -121,12 +79,6 @@ MainWindow::MainWindow(QWidget *parent)
//4.1.1 connect shading actions to slot
MyGLWidget* allWidgets[4] = {myGLWidget, viewFront, viewLeft, viewTop};
for (int i = 0; i < 4; i++){
connect(shadeWireframeAction,SIGNAL(triggered(bool)),allWidgets[i],SLOT(shadeWireframeSlot()));
connect(shadeFlatAction,SIGNAL(triggered(bool)),allWidgets[i],SLOT(shadeFlatSlot()));
connect(shadeGouraudAction,SIGNAL(triggered(bool)),allWidgets[i],SLOT(shadeGouraudSlot()));
connect(shadePhongAction,SIGNAL(triggered(bool)),allWidgets[i],SLOT(shadePhongSlot()));
}
controller->initViewWidgets(allWidgets,viewSplitter1,viewSplitter3,viewLayout);
......
......@@ -50,12 +50,6 @@ private:
QAction *aboutAction;
QAction *shadeWireframeAction;
QAction *shadeFlatAction;
QAction *shadeGouraudAction;
QAction *shadePhongAction;
QActionGroup *shaderGroup;
QAction *resetCameraAction;
QAction *modeCameraAction;
......
......@@ -124,8 +124,9 @@ void MyGLWidget::initShaderStuff(){
phongShader->addShader(frag);
phongShader->link();
glPolygonMode(GL_FRONT,GL_FILL);
phongShader->bind();
shadeFlatSlot();//set up flat shading
qDebug() << "FlatSlot setup.";
}
......@@ -309,7 +310,6 @@ QQuaternion MyGLWidget::getCameraRotation(){
return cameraRotation;
}
void MyGLWidget::resetCamera(){
camRotCenter = QVector3D(0,0,0);
cameraZoom = cameraZoomDefault;
......@@ -453,7 +453,7 @@ void MyGLWidget::drawCylinder(int tesselation){
glMaterialfv(GL_FRONT, GL_SPECULAR, specularColor);
glMaterialfv(GL_FRONT, GL_SHININESS, shininess);
GLfloat cylinderColor[] = { 0.8,0.2,0.5 };
GLfloat cylinderColor[] = { 0,0.5,0.8 };
glMaterialfv(GL_FRONT, GL_DIFFUSE, cylinderColor);
glNormal3f(0, 0, 1);
......@@ -472,12 +472,12 @@ void MyGLWidget::drawCylinder(int tesselation){
}
void MyGLWidget::drawCone(int tesselation){
GLfloat specularColor[] = { 0.3, 0.5, 0.5 };
GLfloat specularColor[] = { 0.5, 0.5, 0.5 };
GLfloat shininess[] = { 120 };//specular exponent
glMaterialfv(GL_FRONT, GL_SPECULAR, specularColor);
glMaterialfv(GL_FRONT, GL_SHININESS, shininess);
GLfloat coneColor[] = { 0.8,0.8,0 };
GLfloat coneColor[] = { 1.0,0.5,0 };
glMaterialfv(GL_FRONT, GL_DIFFUSE, coneColor);
glNormal3f(0, 0, 1);
......@@ -508,39 +508,3 @@ void MyGLWidget::drawTorus(int tesselation){
glEnd();
}
//4.1.1 slots for shading modes
void MyGLWidget::shadeWireframeSlot(){
qDebug() << "Wireframe selected";
phongShader->release();
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);//Wireframe looks way cooler with both faces on
updateGL();
}
void MyGLWidget::shadeFlatSlot(){
qDebug() << "Flat selected";
phongShader->release();
glShadeModel(GL_FLAT);
glPolygonMode(GL_FRONT,GL_FILL);
updateGL();
}
void MyGLWidget::shadeGouraudSlot(){
qDebug() << "Gouraud selected";
phongShader->release();
glShadeModel(GL_SMOOTH);
glPolygonMode(GL_FRONT,GL_FILL);
updateGL();
}
void MyGLWidget::shadePhongSlot(){
qDebug() << "Phong selected";
glPolygonMode(GL_FRONT,GL_FILL);
phongShader->bind();
updateGL();
}
......@@ -95,10 +95,6 @@ private:
void drawTorus(int tesselation);
public slots:
//4.1.1 slots for shading modes
void shadeWireframeSlot();
void shadeFlatSlot();
void shadeGouraudSlot();
void shadePhongSlot();
void resetCamera();
};
......
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