Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
C-Fu
OpenGL
Commits
9c12598b
Commit
9c12598b
authored
Nov 03, 2016
by
Anakin
Browse files
trying to give MVP via buffer,
nothing displayed -.-
parent
3af88645
Changes
5
Show whitespace changes
Inline
Side-by-side
MshViewer/Shader/FragmentColorShader.mv2shdr
deleted
100644 → 0
View file @
3af88645
#version 450 core
// Input
in vec3 fragmentColor;
// Ouput data
out vec3 color;
void main()
{
color = fragmentColor;
}
\ No newline at end of file
MshViewer/Shader/
Fragment
TextureShader.
mv2shdr
→
MshViewer/Shader/TextureShader.
frag
View file @
9c12598b
File moved
MshViewer/Shader/
Vertex
TextureShader.
mv2shdr
→
MshViewer/Shader/TextureShader.
vert
View file @
9c12598b
...
...
@@ -3,18 +3,21 @@
// Input vertex data, different for all executions of this shader.
layout
(
location
=
0
)
in
vec3
vertexPosition_modelspace
;
layout
(
location
=
1
)
in
vec2
vertexUV
;
//layout(location = 2) in mat4 mvp;
layout
(
location
=
2
)
in
mat4
mvp
;
//layout(location = 3) in mat4 mvp;
//layout(location = 4) in mat4 mvp;
//layout(location = 5) in mat4 mvp;
// Output
out
vec2
UV
;
// Values that stay constant for the whole mesh.
uniform mat4 MVP;
//
uniform mat4 MVP;
void
main
(){
// Output position of the vertex, in clip space : MVP * position
gl_Position =
MVP
* vec4(vertexPosition_modelspace, 1);
gl_Position
=
mvp
*
vec4
(
vertexPosition_modelspace
,
1
);
UV
=
vertexUV
;
...
...
MshViewer/Shader/VertexColorShader.mv2shdr
deleted
100644 → 0
View file @
3af88645
#version 450 core
// Input vertex data, different for all executions of this shader.
layout(location = 0) in vec3 vertexPosition_modelspace;
layout(location = 1) in vec3 vertexColor;
// Output
out vec3 fragmentColor;
// Values that stay constant for the whole mesh.
uniform mat4 MVP;
void main(){
// Output position of the vertex, in clip space : MVP * position
gl_Position = MVP * vec4(vertexPosition_modelspace,1);
fragmentColor = vertexColor;
}
MshViewer/Source/OpenGlController.cpp
View file @
9c12598b
...
...
@@ -9,8 +9,8 @@
#include "Texture.h"
#include <iostream>
#define VERTEX_SHADER "Shader/
Vertex
TextureShader.
mv2shdr
"
#define FRAGMENT_SHADER "Shader/
Fragment
TextureShader.
mv2shdr
"
#define VERTEX_SHADER "Shader/TextureShader.
vert
"
#define FRAGMENT_SHADER "Shader/TextureShader.
frag
"
/////////////////////////////////////////////////////////////////////////
...
...
@@ -91,6 +91,13 @@ void OpenGLController::processInit()
glVertexAttribPointer
(
VERTEX_INDEX_UV
,
VERTEX_COMPONENTS_UV
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
Vertex
),
(
void
*
)
VERTEX_OFFSET_UV
);
glBindBuffer
(
GL_ARRAY_BUFFER
,
0
);
glBindBuffer
(
GL_ARRAY_BUFFER
,
gluiInstanceBufferID
);
glVertexAttribPointer
(
2
,
4
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
glm
::
mat4
),
(
void
*
)(
sizeof
(
GL_FLOAT
)
*
0
));
glVertexAttribPointer
(
3
,
4
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
glm
::
mat4
),
(
void
*
)(
sizeof
(
GL_FLOAT
)
*
4
));
glVertexAttribPointer
(
4
,
4
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
glm
::
mat4
),
(
void
*
)(
sizeof
(
GL_FLOAT
)
*
8
));
glVertexAttribPointer
(
5
,
4
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
glm
::
mat4
),
(
void
*
)(
sizeof
(
GL_FLOAT
)
*
12
));
glBindBuffer
(
GL_ARRAY_BUFFER
,
0
);
glEnableVertexAttribArray
(
0
);
glEnableVertexAttribArray
(
1
);
...
...
@@ -245,7 +252,10 @@ void OpenGLController::updateScene()
glUseProgram
(
gluiShaderPrgmID
);
// tell shader transformation
glUniformMatrix4fv
(
gluiMatrixID
,
1
,
GL_FALSE
,
&
getMVPMatrix
()[
0
][
0
]);
//glUniformMatrix4fv(gluiMatrixID, 1, GL_FALSE, &getMVPMatrix()[0][0]);
glBindBuffer
(
GL_UNIFORM_BUFFER
,
gluiInstanceBufferID
);
glBufferData
(
GL_UNIFORM_BUFFER
,
sizeof
(
glm
::
mat4
)
*
1
,
NULL
,
GL_STREAM_DRAW
);
glBindBuffer
(
GL_UNIFORM_BUFFER
,
0
);
// bind texture in texture unit 0
glActiveTexture
(
GL_TEXTURE0
);
...
...
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