trying to give MVP via buffer,

nothing displayed -.-
This commit is contained in:
Anakin 2016-11-03 19:46:36 +01:00
parent 3af886450f
commit 9c12598bf5
5 changed files with 19 additions and 38 deletions

View File

@ -1,12 +0,0 @@
#version 450 core
// Input
in vec3 fragmentColor;
// Ouput data
out vec3 color;
void main()
{
color = fragmentColor;
}

View File

@ -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;

View File

@ -1,20 +0,0 @@
#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;
}

View File

@ -9,8 +9,8 @@
#include "Texture.h"
#include <iostream>
#define VERTEX_SHADER "Shader/VertexTextureShader.mv2shdr"
#define FRAGMENT_SHADER "Shader/FragmentTextureShader.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);