Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
GraPa
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kai Westerkamp
GraPa
Commits
60a1e7e0
Commit
60a1e7e0
authored
Oct 22, 2015
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Material
Tesselation Slot
parent
a110ad01
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
13 deletions
+45
-13
cubewidget.cpp
A1/hellocube/cubewidget.cpp
+34
-13
cubewidget.h
A1/hellocube/cubewidget.h
+1
-0
mainwindow.cpp
A1/hellocube/mainwindow.cpp
+8
-0
mainwindow.h
A1/hellocube/mainwindow.h
+2
-0
No files found.
A1/hellocube/cubewidget.cpp
View file @
60a1e7e0
...
...
@@ -20,18 +20,23 @@ void CubeWidget::initializeGL ()
{
glClearColor
(
0.0
,
0.0
,
0.0
,
0.0
);
glEnable
(
GL_DEPTH_TEST
);
glEnable
(
GL_CULL_FACE
);
// enable default shading
showFlat
();
//
glEnable(GL_LIGHTING);
glEnable
(
GL_LIGHTING
);
glEnable
(
GL_LIGHT0
);
static
GLfloat
lightPosition
[
4
]
=
{
0.5
,
0.0
,
2.0
,
1.0
};
glLightfv
(
GL_LIGHT0
,
GL_POSITION
,
lightPosition
);
}
void
CubeWidget
::
setMaterial
(
GLfloat
*
color
)
{
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
color
);
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
color
);
glMaterialfv
(
GL_FRONT
,
GL_SHININESS
,
color
);
}
void
CubeWidget
::
paintGL
(
)
{
...
...
@@ -41,38 +46,46 @@ void CubeWidget::paintGL ( )
glRotated
(
45
,
1
,
0
,
0
);
glRotated
(
45
,
0
,
1
,
0
);
glBegin
(
GL_QUADS
);
// Draw A Quad
glColor3f
(
0.0
f
,
1.0
f
,
0.0
f
);
GLfloat
red
[]
=
{
1.0
,
0.0
,
0.0
};
GLfloat
green
[]
=
{
0.0
,
1.0
,
0.0
};
GLfloat
blue
[]
=
{
0.0
,
0.0
,
1.0
};
GLfloat
cyan
[]
=
{
0.0
,
1.0
,
1.0
};
GLfloat
magenta
[]
=
{
1.0
,
0.0
,
1.0
};
GLfloat
yellow
[]
=
{
1.0
,
1.0
,
0.0
};
glBegin
(
GL_QUADS
);
setMaterial
(
red
);
glVertex3f
(
0.5
f
,
0.5
f
,
-
0.5
f
);
glVertex3f
(
-
0.5
f
,
0.5
f
,
-
0.5
f
);
glVertex3f
(
-
0.5
f
,
0.5
f
,
0.5
f
);
glVertex3f
(
0.5
f
,
0.5
f
,
0.5
f
);
glColor3f
(
0.0
f
,
1.0
f
,
1.0
f
);
setMaterial
(
magenta
);
glVertex3f
(
0.5
f
,
-
0.5
f
,
0.5
f
);
glVertex3f
(
-
0.5
f
,
-
0.5
f
,
0.5
f
);
glVertex3f
(
-
0.5
f
,
-
0.5
f
,
-
0.5
f
);
glVertex3f
(
0.5
f
,
-
0.5
f
,
-
0.5
f
);
glColor3f
(
1.0
f
,
0.0
f
,
0.0
f
);
setMaterial
(
green
);
glVertex3f
(
0.5
f
,
0.5
f
,
0.5
f
);
glVertex3f
(
-
0.5
f
,
0.5
f
,
0.5
f
);
glVertex3f
(
-
0.5
f
,
-
0.5
f
,
0.5
f
);
glVertex3f
(
0.5
f
,
-
0.5
f
,
0.5
f
);
glColor3f
(
1.0
f
,
0.0
f
,
1.0
f
);
setMaterial
(
yellow
);
glVertex3f
(
0.5
f
,
-
0.5
f
,
-
0.5
f
);
glVertex3f
(
-
0.5
f
,
-
0.5
f
,
-
0.5
f
);
glVertex3f
(
-
0.5
f
,
0.5
f
,
-
0.5
f
);
glVertex3f
(
0.5
f
,
0.5
f
,
-
0.5
f
);
glColor3f
(
0.0
f
,
0.0
f
,
1.0
f
);
setMaterial
(
blue
);
glVertex3f
(
-
0.5
f
,
0.5
f
,
0.5
f
);
glVertex3f
(
-
0.5
f
,
0.5
f
,
-
0.5
f
);
glVertex3f
(
-
0.5
f
,
-
0.5
f
,
-
0.5
f
);
glVertex3f
(
-
0.5
f
,
-
0.5
f
,
0.5
f
);
glColor3f
(
1.0
f
,
1.0
f
,
0.0
f
);
setMaterial
(
cyan
);
glVertex3f
(
0.5
f
,
0.5
f
,
-
0.5
f
);
glVertex3f
(
0.5
f
,
0.5
f
,
0.5
f
);
glVertex3f
(
0.5
f
,
-
0.5
f
,
0.5
f
);
...
...
@@ -107,23 +120,31 @@ void CubeWidget::perspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLd
void
CubeWidget
::
showWireframe
()
{
qDebug
(
"show Wireframe"
);
glShadeModel
(
GL_FLAT
);
glPolygoneMode
(
GL_FRONT
,
GL_LINE
);
glDisable
(
GL_CULL_FACE
);
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_LINE
);
repaint
();
}
void
CubeWidget
::
showFlat
()
{
qDebug
(
"show Flat"
);
glShadeModel
(
GL_FLAT
);
glPolygoneMode
(
GL_FRONT
,
GL_FILL
);
glEnable
(
GL_CULL_FACE
);
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
);
repaint
();
}
void
CubeWidget
::
showGouraut
()
{
qDebug
(
"show Gouraut"
);
glShadeModel
(
GL_SMOOTH
);
glPolygoneMode
(
GL_FRONT
,
GL_FILL
);
glEnable
(
GL_CULL_FACE
);
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
);
repaint
();
}
void
CubeWidget
::
showPhong
()
...
...
@@ -135,7 +156,7 @@ void CubeWidget::showPhong()
void
CubeWidget
::
setTessellation
(
int
t
)
{
qDebug
()
<<
"Tesselation"
<<
t
;
}
void
CubeWidget
::
mousePressEvent
(
QMouseEvent
*
event
)
{}
...
...
A1/hellocube/cubewidget.h
View file @
60a1e7e0
...
...
@@ -35,6 +35,7 @@ public slots:
private
:
void
perspective
(
GLdouble
fovy
,
GLdouble
aspect
,
GLdouble
zNear
,
GLdouble
zFar
);
void
setMaterial
(
GLfloat
*
color
);
};
#endif // CUBEWIDGET_H
A1/hellocube/mainwindow.cpp
View file @
60a1e7e0
...
...
@@ -61,6 +61,13 @@ MainWindow::MainWindow(QWidget *parent)
camHome
=
new
QAction
(
QIcon
(
":/img/cam_home.png"
),
"Cam Home"
,
toolBar
);
slider
=
new
QSlider
(
Qt
::
Horizontal
,
toolBar
);
slider
->
setMinimum
(
0
);
slider
->
setMaximum
(
4
);
slider
->
setValue
(
0
);
connect
(
slider
,
SIGNAL
(
valueChanged
(
int
)),
mainWidget
,
SLOT
(
setTessellation
(
int
)));
// slider->setSizePolicy();
// Assemble Menus
fileMenu
->
addAction
(
exitAction
);
menuBar
->
addMenu
(
fileMenu
);
...
...
@@ -80,6 +87,7 @@ MainWindow::MainWindow(QWidget *parent)
toolBar
->
addAction
(
flatAction
);
toolBar
->
addAction
(
gouraudAction
);
toolBar
->
addAction
(
phongAction
);
toolBar
->
addWidget
(
slider
);
toolBar
->
addAction
(
camHome
);
addToolBar
(
toolBar
);
...
...
A1/hellocube/mainwindow.h
View file @
60a1e7e0
...
...
@@ -10,6 +10,7 @@
#include <QMessageBox>
#include <QToolBar>
#include <QStatusBar>
#include <QSlider>
#include <cubewidget.h>
...
...
@@ -37,6 +38,7 @@ private:
QToolBar
*
toolBar
;
QStatusBar
*
statusBar
;
QSlider
*
slider
;
CubeWidget
*
mainWidget
;
...
...
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