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
450e6140
Commit
450e6140
authored
Oct 23, 2015
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tesselation
naja
parent
60a1e7e0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
24 deletions
+60
-24
cubewidget.cpp
A1/hellocube/cubewidget.cpp
+58
-24
cubewidget.h
A1/hellocube/cubewidget.h
+2
-0
No files found.
A1/hellocube/cubewidget.cpp
View file @
450e6140
...
...
@@ -21,7 +21,7 @@ void CubeWidget::initializeGL ()
glClearColor
(
0.0
,
0.0
,
0.0
,
0.0
);
glEnable
(
GL_DEPTH_TEST
);
tesselation
=
0
;
// enable default shading
showFlat
();
...
...
@@ -55,41 +55,73 @@ void CubeWidget::paintGL ( )
GLfloat
yellow
[]
=
{
1.0
,
1.0
,
0.0
};
glBegin
(
GL_QUADS
);
float
increment
=
1.0
/
(
pow
(
2
,
tesselation
));
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
);
for
(
float
x
=
-
0.5
;
x
<
0.5
;
x
+=
increment
)
{
for
(
float
y
=
-
0.5
;
y
<
0.5
;
y
+=
increment
)
{
glVertex3f
(
x
+
increment
,
0.5
f
,
y
);
glVertex3f
(
x
,
0.5
f
,
y
);
glVertex3f
(
x
,
0.5
f
,
y
+
increment
);
glVertex3f
(
x
+
increment
,
0.5
f
,
y
+
increment
);
}
}
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
);
for
(
float
x
=
-
0.5
;
x
<
0.5
;
x
+=
increment
)
{
for
(
float
y
=
-
0.5
;
y
<
0.5
;
y
+=
increment
)
{
glVertex3f
(
x
+
increment
,
-
0.5
f
,
y
+
increment
);
glVertex3f
(
x
,
-
0.5
f
,
y
+
increment
);
glVertex3f
(
x
,
-
0.5
f
,
y
);
glVertex3f
(
x
+
increment
,
-
0.5
f
,
y
);
}
}
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
);
for
(
float
x
=
-
0.5
;
x
<
0.5
;
x
+=
increment
)
{
for
(
float
y
=
-
0.5
;
y
<
0.5
;
y
+=
increment
)
{
glVertex3f
(
x
+
increment
,
y
+
increment
,
0.5
f
);
glVertex3f
(
x
,
y
+
increment
,
0.5
f
);
glVertex3f
(
x
,
y
,
0.5
f
);
glVertex3f
(
x
+
increment
,
y
,
0.5
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
);
for
(
float
x
=
-
0.5
;
x
<
0.5
;
x
+=
increment
)
{
for
(
float
y
=
-
0.5
;
y
<
0.5
;
y
+=
increment
)
{
glVertex3f
(
x
+
increment
,
y
,
-
0.5
f
);
glVertex3f
(
x
,
y
,
-
0.5
f
);
glVertex3f
(
x
,
y
+
increment
,
-
0.5
f
);
glVertex3f
(
x
+
increment
,
y
+
increment
,
-
0.5
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
);
for
(
float
x
=
-
0.5
;
x
<
0.5
;
x
+=
increment
)
{
for
(
float
y
=
-
0.5
;
y
<
0.5
;
y
+=
increment
)
{
glVertex3f
(
-
0.5
f
,
x
+
increment
,
y
+
increment
);
glVertex3f
(
-
0.5
f
,
x
+
increment
,
y
);
glVertex3f
(
-
0.5
f
,
x
,
y
);
glVertex3f
(
-
0.5
f
,
x
,
y
+
increment
);
}
}
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
);
glVertex3f
(
0.5
f
,
-
0.5
f
,
-
0.5
f
);
for
(
float
x
=
-
0.5
;
x
<
0.5
;
x
+=
increment
)
{
for
(
float
y
=
-
0.5
;
y
<
0.5
;
y
+=
increment
)
{
glVertex3f
(
0.5
f
,
x
+
increment
,
y
);
glVertex3f
(
0.5
f
,
x
+
increment
,
y
+
increment
);
glVertex3f
(
0.5
f
,
x
,
y
+
increment
);
glVertex3f
(
0.5
f
,
x
,
y
);
}
}
glEnd
();
}
...
...
@@ -126,7 +158,7 @@ void CubeWidget::showWireframe()
glDisable
(
GL_CULL_FACE
);
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_LINE
);
repaint
();
updateGL
();
}
void
CubeWidget
::
showFlat
()
...
...
@@ -135,7 +167,7 @@ void CubeWidget::showFlat()
glShadeModel
(
GL_FLAT
);
glEnable
(
GL_CULL_FACE
);
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
);
repaint
();
updateGL
();
}
void
CubeWidget
::
showGouraut
()
...
...
@@ -144,7 +176,7 @@ void CubeWidget::showGouraut()
glShadeModel
(
GL_SMOOTH
);
glEnable
(
GL_CULL_FACE
);
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
);
repaint
();
updateGL
();
}
void
CubeWidget
::
showPhong
()
...
...
@@ -156,6 +188,8 @@ void CubeWidget::showPhong()
void
CubeWidget
::
setTessellation
(
int
t
)
{
tesselation
=
t
;
updateGL
();
qDebug
()
<<
"Tesselation"
<<
t
;
}
...
...
A1/hellocube/cubewidget.h
View file @
450e6140
...
...
@@ -5,6 +5,7 @@
#include <QtOpenGL>
#include <QGLFunctions>
#include <QOpenGLFunctions>
#include <math.h>
...
...
@@ -34,6 +35,7 @@ public slots:
void
setTessellation
(
int
t
);
private
:
int
tesselation
;
void
perspective
(
GLdouble
fovy
,
GLdouble
aspect
,
GLdouble
zNear
,
GLdouble
zFar
);
void
setMaterial
(
GLfloat
*
color
);
};
...
...
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