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
0de3f161
Commit
0de3f161
authored
Nov 23, 2015
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
grid
parent
78f61664
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
1 deletion
+112
-1
glview.cpp
A2/glview.cpp
+107
-0
glview.h
A2/glview.h
+5
-1
No files found.
A2/glview.cpp
View file @
0de3f161
...
...
@@ -7,6 +7,9 @@ GLView::GLView(Scene *scene,Camera * camera,Controler *controler )
this
->
camera
=
camera
;
this
->
scene
=
scene
;
this
->
controler
=
controler
;
gridSize
=
5
;
gridStepSize
=
1
;
isGridEnabled
=
true
;
}
QSize
GLView
::
minimumSizeHint
()
const
...
...
@@ -103,6 +106,12 @@ void GLView::paintGL ()
//draw Scene
scene
->
draw
();
if
(
isGridEnabled
){
drawGrid
();
}
if
(
isActive
){
glDisable
(
GL_DEPTH_TEST
);
glMatrixMode
(
GL_MODELVIEW
);
...
...
@@ -126,6 +135,7 @@ void GLView::paintGL ()
}
shader
->
release
();
// displayShader->bind();
// functions.glBindFramebuffer(GL_FRAMEBUFFER,fbo);
...
...
@@ -147,9 +157,106 @@ void GLView::paintGL ()
// displayShader->release();
}
void
GLView
::
drawGrid
()
{
shader
->
release
();
GLfloat
specularColor
[]
=
{
0
,
0
,
0
};
GLfloat
shininess
[]
=
{
128
};
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
specularColor
);
glMaterialfv
(
GL_FRONT
,
GL_SHININESS
,
shininess
);
GLfloat
grey
[]
=
{
1
,
0.5
,
0.5
};
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
grey
);
glNormal3f
(
0
,
1
,
0
);
glDisable
(
GL_LIGHTING
);
glEnable
(
GL_COLOR_MATERIAL
);
glLineWidth
(
1
);
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_LINES
);
glBegin
(
GL_LINES
);
float
stepSize
=
gridStepSize
;
float
x
=
stepSize
;
float
y
=
stepSize
;
if
(
stepSize
<=
0
)
stepSize
=
1
;
for
(;
x
<
gridSize
;
x
+=
stepSize
){
glVertex3f
(
x
,
0
,
-
gridSize
);
glVertex3f
(
x
,
0
,
gridSize
);
glVertex3f
(
-
x
,
0
,
-
gridSize
);
glVertex3f
(
-
x
,
0
,
gridSize
);
}
for
(;
y
<
gridSize
;
y
+=
stepSize
){
glVertex3f
(
-
gridSize
,
0
,
y
);
glVertex3f
(
gridSize
,
0
,
y
);
glVertex3f
(
-
gridSize
,
0
,
-
y
);
glVertex3f
(
gridSize
,
0
,
-
y
);
}
glEnd
();
glBegin
(
GL_LINES
);
x
=
stepSize
;
y
=
stepSize
;
if
(
stepSize
<=
0
)
stepSize
=
1
;
for
(;
x
<
gridSize
;
x
+=
stepSize
){
glVertex3f
(
0
,
x
,
-
gridSize
);
glVertex3f
(
0
,
x
,
gridSize
);
glVertex3f
(
0
,
-
x
,
-
gridSize
);
glVertex3f
(
0
,
-
x
,
gridSize
);
}
for
(;
y
<
gridSize
;
y
+=
stepSize
){
glVertex3f
(
0
,
-
gridSize
,
y
);
glVertex3f
(
0
,
gridSize
,
y
);
glVertex3f
(
0
,
-
gridSize
,
-
y
);
glVertex3f
(
0
,
gridSize
,
-
y
);
}
glEnd
();
glBegin
(
GL_LINES
);
x
=
stepSize
;
y
=
stepSize
;
if
(
stepSize
<=
0
)
stepSize
=
1
;
for
(;
x
<
gridSize
;
x
+=
stepSize
){
glVertex3f
(
x
,
-
gridSize
,
0
);
glVertex3f
(
x
,
gridSize
,
0
);
glVertex3f
(
-
x
,
-
gridSize
,
0
);
glVertex3f
(
-
x
,
gridSize
,
0
);
}
for
(;
y
<
gridSize
;
y
+=
stepSize
){
glVertex3f
(
-
gridSize
,
y
,
0
);
glVertex3f
(
gridSize
,
y
,
0
);
glVertex3f
(
-
gridSize
,
-
y
,
0
);
glVertex3f
(
gridSize
,
-
y
,
0
);
}
glEnd
();
glBegin
(
GL_LINES
);
glVertex3f
(
0
,
0
,
-
gridSize
);
glVertex3f
(
0
,
0
,
gridSize
);
glEnd
();
glBegin
(
GL_LINES
);
glVertex3f
(
-
gridSize
,
0
,
0
);
glVertex3f
(
gridSize
,
0
,
0
);
glEnd
();
glBegin
(
GL_LINES
);
glVertex3f
(
0
,
-
gridSize
,
0
);
glVertex3f
(
0
,
gridSize
,
0
);
glEnd
();
glPolygonMode
(
GL_FRONT
,
GL_FILL
);
glEnable
(
GL_LIGHTING
);
shader
->
bind
();
}
void
GLView
::
resizeGL
(
int
width
,
int
height
)
{
aspect
=
1.0
*
width
/
height
;
...
...
A2/glview.h
View file @
0de3f161
...
...
@@ -51,8 +51,12 @@ private:
GLuint
picID
;
GLuint
depth
;
void
drawGrid
();
void
initShader
();
float
gridStepSize
;
float
gridSize
;
bool
isGridEnabled
;
};
#endif // GLVIEW_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