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
3b08f256
Commit
3b08f256
authored
Oct 22, 2015
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a Cube
parent
c3e1e5e8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
8 deletions
+83
-8
.gitignore
.gitignore
+2
-0
cubewidget.cpp
A1/hellocube/cubewidget.cpp
+78
-8
cubewidget.h
A1/hellocube/cubewidget.h
+3
-0
No files found.
.gitignore
0 → 100644
View file @
3b08f256
/A1/build-hellocube-Desktop_Qt_5_4_2_MSVC2013_OpenGL_64bit-Debug
/A1/hellocube/*.user
A1/hellocube/cubewidget.cpp
View file @
3b08f256
...
@@ -20,22 +20,92 @@ QSize CubeWidget::sizeHint() const
...
@@ -20,22 +20,92 @@ QSize CubeWidget::sizeHint() const
void
CubeWidget
::
initializeGL
()
void
CubeWidget
::
initializeGL
()
{
{
glClearColor
(
0.0
,
0.0
,
0.0
,
0.0
);
glEnable
(
GL_DEPTH_TEST
);
glEnable
(
GL_DEPTH_TEST
);
/* glEnable(GL_CULL_FACE);
glEnable
(
GL_CULL_FACE
);
glShadeModel(GL_SMOOTH);
glEnable(GL_MULTISAMPLE);
glEnable(GL_LIGHTING);
// enable default shading
glShadeModel
(
GL_FLAT
);
// glEnable(GL_LIGHTING);
glEnable
(
GL_LIGHT0
);
glEnable
(
GL_LIGHT0
);
static
GLfloat
lightPosition
[
4
]
=
{
0.5
,
0.0
,
2.0
,
1.0
};
static
GLfloat
lightPosition
[
4
]
=
{
0.5
,
0.0
,
2.0
,
1.0
};
glLightfv
(
GL_LIGHT0
,
GL_POSITION
,
lightPosition
);
glLightfv
(
GL_LIGHT0
,
GL_POSITION
,
lightPosition
);
*/
}
void
CubeWidget
::
paintGL
(
)
{
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glLoadIdentity
();
glTranslatef
(
0.0
f
,
0.0
f
,
-
3.0
f
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
glEnd
();
}
}
void
CubeWidget
::
resizeGL
(
int
width
,
int
height
)
{
glMatrixMode
(
GL_PROJECTION
);
glViewport
(
0
,
0
,
width
,
height
);
glLoadIdentity
();
perspective
(
45.0
,
1.0
*
width
/
height
,
0.01
,
5.0
);
glMatrixMode
(
GL_MODELVIEW
);
}
void
CubeWidget
::
perspective
(
GLdouble
fovy
,
GLdouble
aspect
,
GLdouble
zNear
,
GLdouble
zFar
)
{
GLdouble
xmin
,
xmax
,
ymin
,
ymax
;
ymax
=
zNear
*
tan
(
fovy
*
M_PI
/
360.0
);
ymin
=
-
ymax
;
xmin
=
ymin
*
aspect
;
xmax
=
ymax
*
aspect
;
glFrustum
(
xmin
,
xmax
,
ymin
,
ymax
,
zNear
,
zFar
);
}
void
CubeWidget
::
paintGL
(
)
{}
void
CubeWidget
::
resizeGL
(
int
width
,
int
height
)
{}
void
CubeWidget
::
mousePressEvent
(
QMouseEvent
*
event
)
{}
void
CubeWidget
::
mousePressEvent
(
QMouseEvent
*
event
)
{}
void
CubeWidget
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{}
void
CubeWidget
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{}
void
CubeWidget
::
wheelEvent
(
QWheelEvent
*
event
)
{}
void
CubeWidget
::
wheelEvent
(
QWheelEvent
*
event
)
{}
A1/hellocube/cubewidget.h
View file @
3b08f256
...
@@ -22,6 +22,9 @@ public:
...
@@ -22,6 +22,9 @@ public:
QSize
minimumSizeHint
()
const
;
QSize
minimumSizeHint
()
const
;
QSize
sizeHint
()
const
;
QSize
sizeHint
()
const
;
private
:
void
perspective
(
GLdouble
fovy
,
GLdouble
aspect
,
GLdouble
zNear
,
GLdouble
zFar
);
};
};
#endif // CUBEWIDGET_H
#endif // CUBEWIDGET_H
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