Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
grapa_alisa
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Alisa Jung
grapa_alisa
Commits
8f95f651
Commit
8f95f651
authored
Nov 23, 2015
by
Alisa Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed all shaders except phong
parent
00286a48
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
99 deletions
+5
-99
mainwindow.cpp
helloqube/mainwindow.cpp
+0
-48
mainwindow.h
helloqube/mainwindow.h
+0
-6
myglwidget.cpp
helloqube/myglwidget.cpp
+5
-41
myglwidget.h
helloqube/myglwidget.h
+0
-4
No files found.
helloqube/mainwindow.cpp
View file @
8f95f651
...
@@ -17,44 +17,6 @@ MainWindow::MainWindow(QWidget *parent)
...
@@ -17,44 +17,6 @@ MainWindow::MainWindow(QWidget *parent)
menuBar
->
addMenu
(
fileMenu
);
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
);
setMenuBar
(
menuBar
);
//3.2.3 About Message Box
//3.2.3 About Message Box
...
@@ -64,10 +26,6 @@ MainWindow::MainWindow(QWidget *parent)
...
@@ -64,10 +26,6 @@ MainWindow::MainWindow(QWidget *parent)
//3.3 Toolbar
//3.3 Toolbar
toolBar
=
new
QToolBar
(
"ToolBar"
,
this
);
toolBar
=
new
QToolBar
(
"ToolBar"
,
this
);
toolBar
->
addAction
(
shadeWireframeAction
);
toolBar
->
addAction
(
shadeFlatAction
);
toolBar
->
addAction
(
shadeGouraudAction
);
toolBar
->
addAction
(
shadePhongAction
);
addToolBar
(
toolBar
);
addToolBar
(
toolBar
);
//3.4 Status Bar
//3.4 Status Bar
...
@@ -121,12 +79,6 @@ MainWindow::MainWindow(QWidget *parent)
...
@@ -121,12 +79,6 @@ MainWindow::MainWindow(QWidget *parent)
//4.1.1 connect shading actions to slot
//4.1.1 connect shading actions to slot
MyGLWidget
*
allWidgets
[
4
]
=
{
myGLWidget
,
viewFront
,
viewLeft
,
viewTop
};
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
);
controller
->
initViewWidgets
(
allWidgets
,
viewSplitter1
,
viewSplitter3
,
viewLayout
);
...
...
helloqube/mainwindow.h
View file @
8f95f651
...
@@ -50,12 +50,6 @@ private:
...
@@ -50,12 +50,6 @@ private:
QAction
*
aboutAction
;
QAction
*
aboutAction
;
QAction
*
shadeWireframeAction
;
QAction
*
shadeFlatAction
;
QAction
*
shadeGouraudAction
;
QAction
*
shadePhongAction
;
QActionGroup
*
shaderGroup
;
QAction
*
resetCameraAction
;
QAction
*
resetCameraAction
;
QAction
*
modeCameraAction
;
QAction
*
modeCameraAction
;
...
...
helloqube/myglwidget.cpp
View file @
8f95f651
...
@@ -124,8 +124,9 @@ void MyGLWidget::initShaderStuff(){
...
@@ -124,8 +124,9 @@ void MyGLWidget::initShaderStuff(){
phongShader
->
addShader
(
frag
);
phongShader
->
addShader
(
frag
);
phongShader
->
link
();
phongShader
->
link
();
glPolygonMode
(
GL_FRONT
,
GL_FILL
);
phongShader
->
bind
();
shadeFlatSlot
();
//set up flat shading
qDebug
()
<<
"FlatSlot setup."
;
qDebug
()
<<
"FlatSlot setup."
;
}
}
...
@@ -309,7 +310,6 @@ QQuaternion MyGLWidget::getCameraRotation(){
...
@@ -309,7 +310,6 @@ QQuaternion MyGLWidget::getCameraRotation(){
return
cameraRotation
;
return
cameraRotation
;
}
}
void
MyGLWidget
::
resetCamera
(){
void
MyGLWidget
::
resetCamera
(){
camRotCenter
=
QVector3D
(
0
,
0
,
0
);
camRotCenter
=
QVector3D
(
0
,
0
,
0
);
cameraZoom
=
cameraZoomDefault
;
cameraZoom
=
cameraZoomDefault
;
...
@@ -453,7 +453,7 @@ void MyGLWidget::drawCylinder(int tesselation){
...
@@ -453,7 +453,7 @@ void MyGLWidget::drawCylinder(int tesselation){
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
specularColor
);
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
specularColor
);
glMaterialfv
(
GL_FRONT
,
GL_SHININESS
,
shininess
);
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
);
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
cylinderColor
);
glNormal3f
(
0
,
0
,
1
);
glNormal3f
(
0
,
0
,
1
);
...
@@ -472,12 +472,12 @@ void MyGLWidget::drawCylinder(int tesselation){
...
@@ -472,12 +472,12 @@ void MyGLWidget::drawCylinder(int tesselation){
}
}
void
MyGLWidget
::
drawCone
(
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
GLfloat
shininess
[]
=
{
120
};
//specular exponent
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
specularColor
);
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
specularColor
);
glMaterialfv
(
GL_FRONT
,
GL_SHININESS
,
shininess
);
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
);
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
coneColor
);
glNormal3f
(
0
,
0
,
1
);
glNormal3f
(
0
,
0
,
1
);
...
@@ -508,39 +508,3 @@ void MyGLWidget::drawTorus(int tesselation){
...
@@ -508,39 +508,3 @@ void MyGLWidget::drawTorus(int tesselation){
glEnd
();
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
();
}
helloqube/myglwidget.h
View file @
8f95f651
...
@@ -95,10 +95,6 @@ private:
...
@@ -95,10 +95,6 @@ private:
void
drawTorus
(
int
tesselation
);
void
drawTorus
(
int
tesselation
);
public
slots
:
public
slots
:
//4.1.1 slots for shading modes
//4.1.1 slots for shading modes
void
shadeWireframeSlot
();
void
shadeFlatSlot
();
void
shadeGouraudSlot
();
void
shadePhongSlot
();
void
resetCamera
();
void
resetCamera
();
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment