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
227f8ace
Commit
227f8ace
authored
Jan 17, 2016
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bäh
parent
a99eeaa6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
13 deletions
+21
-13
animate.vert
A5/Animation/animate.vert
+3
-3
mainwidget.cpp
A5/Animation/mainwidget.cpp
+12
-10
mainwidget.h
A5/Animation/mainwidget.h
+6
-0
No files found.
A5/Animation/animate.vert
View file @
227f8ace
#version 330
#version 330
layout
(
location
=
0
)
in
vec
4
Position
;
layout
(
location
=
0
)
in
vec
3
Position
;
out
vec3
vPosition
;
out
vec3
vPosition
;
...
@@ -7,7 +7,7 @@ uniform mat4x4 VP;
...
@@ -7,7 +7,7 @@ uniform mat4x4 VP;
void
main
(
void
)
void
main
(
void
)
{
{
vPosition
=
Position
.
xyz
;
vPosition
=
Position
;
gl_Position
=
VP
*
Position
;
gl_Position
=
VP
*
vec4
(
Position
,
1
.
0
)
;
}
}
A5/Animation/mainwidget.cpp
View file @
227f8ace
...
@@ -30,7 +30,7 @@ void MainWidget::initializeGL(){
...
@@ -30,7 +30,7 @@ void MainWidget::initializeGL(){
animationShader
=
initShader
(
QLatin1String
(
":/animate.frag"
),
QLatin1String
(
":/animate.vert"
));
animationShader
=
initShader
(
QLatin1String
(
":/animate.frag"
),
QLatin1String
(
":/animate.vert"
));
m_view
=
QMatrix4x4
();
m_view
=
QMatrix4x4
();
m_view
.
lookAt
(
QVector3D
(
0.0
,
1.0
,
3
.0
),
QVector3D
(
0.0
,
0.0
,
0.0
),
QVector3D
(
0.0
,
1.0
,
0.0
));
m_view
.
lookAt
(
QVector3D
(
2.0
,
2.0
,
4
.0
),
QVector3D
(
0.0
,
0.0
,
0.0
),
QVector3D
(
0.0
,
1.0
,
0.0
));
//temp
//temp
static
const
GLfloat
g_vertex_buffer_data
[]
=
{
static
const
GLfloat
g_vertex_buffer_data
[]
=
{
...
@@ -72,6 +72,8 @@ void MainWidget::initializeGL(){
...
@@ -72,6 +72,8 @@ void MainWidget::initializeGL(){
1.0
f
,
-
1.0
f
,
1.0
f
1.0
f
,
-
1.0
f
,
1.0
f
};
};
glGenBuffers
(
1
,
&
vertexbuffer
);
glGenBuffers
(
1
,
&
vertexbuffer
);
glBindBuffer
(
GL_ARRAY_BUFFER
,
vertexbuffer
);
glBindBuffer
(
GL_ARRAY_BUFFER
,
vertexbuffer
);
glBufferData
(
GL_ARRAY_BUFFER
,
sizeof
(
g_vertex_buffer_data
),
g_vertex_buffer_data
,
GL_STATIC_DRAW
);
glBufferData
(
GL_ARRAY_BUFFER
,
sizeof
(
g_vertex_buffer_data
),
g_vertex_buffer_data
,
GL_STATIC_DRAW
);
...
@@ -104,25 +106,25 @@ QOpenGLShaderProgram* MainWidget::initShader(QString fragSource, QString vertSou
...
@@ -104,25 +106,25 @@ QOpenGLShaderProgram* MainWidget::initShader(QString fragSource, QString vertSou
void
MainWidget
::
paintGL
(){
void
MainWidget
::
paintGL
(){
qDebug
()
<<
"Paint"
;
glViewport
(
0
,
0
,
width
(),
height
());
glViewport
(
0
,
0
,
width
(),
height
());
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
animationShader
->
bind
();
animationShader
->
bind
();
QMatrix4x4
VP
=
m_projection
*
m_view
;
QMatrix4x4
VP
=
m_projection
*
m_view
;
// QMatrix4x4 VP = m_view*m_projection;
//QMatrix4x4 VP = m_view*m_projection;
animationShader
->
setUniformValue
(
"VP"
,
VP
);
animationShader
->
setUniformValue
(
"MVP"
,
VP
);
glEnableVertexAttribArray
(
positionIndex
);
glEnableVertexAttribArray
(
0
);
glBindBuffer
(
GL_ARRAY_BUFFER
,
vertexbuffer
);
glBindBuffer
(
GL_ARRAY_BUFFER
,
vertexbuffer
);
glVertexAttribPointer
(
0
,
3
,
GL_FLOAT
,
GL_FALSE
,
0
,(
void
*
)
0
// array buffer offset
glVertexAttribPointer
(
positionIndex
,
3
,
GL_FLOAT
,
GL_FALSE
,
0
,(
void
*
)
0
);
);
glDrawArrays
(
GL_TRIANGLES
,
0
,
12
*
3
);
// 12*3 indices starting at 0 -> 12 triangles
glDrawArrays
(
GL_TRIANGLES
,
0
,
12
*
3
);
glDisableVertexAttribArray
(
0
);
glDisableVertexAttribArray
(
positionIndex
);
animationShader
->
release
();
animationShader
->
release
();
}
}
...
@@ -131,7 +133,7 @@ void MainWidget::resizeGL(int width, int height){
...
@@ -131,7 +133,7 @@ void MainWidget::resizeGL(int width, int height){
qDebug
()
<<
"Resize"
<<
width
<<
height
;
qDebug
()
<<
"Resize"
<<
width
<<
height
;
m_projection
=
QMatrix4x4
();
m_projection
=
QMatrix4x4
();
m_projection
.
perspective
(
45.0
,
width
/
height
,
0.01
,
100.0
);
m_projection
.
perspective
(
45.0
,
1.0
*
width
/
height
,
0.01
,
100.0
);
}
}
...
...
A5/Animation/mainwidget.h
View file @
227f8ace
...
@@ -22,6 +22,12 @@ protected:
...
@@ -22,6 +22,12 @@ protected:
void
resizeGL
(
int
width
,
int
height
);
void
resizeGL
(
int
width
,
int
height
);
private
:
private
:
static
const
int
positionIndex
=
0
;
static
const
int
normalIndex
=
1
;
static
const
int
uvIndex
=
2
;
static
const
int
boneIndex
=
3
;
static
const
int
boneweightIndex
=
4
;
QOpenGLShaderProgram
*
animationShader
;
QOpenGLShaderProgram
*
animationShader
;
QMatrix4x4
m_projection
;
QMatrix4x4
m_projection
;
QMatrix4x4
m_view
;
QMatrix4x4
m_view
;
...
...
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