Commit 9c12598b authored by Anakin's avatar Anakin
Browse files

trying to give MVP via buffer,

nothing displayed -.-
parent 3af88645
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
#version 450 core

// Input
in vec3 fragmentColor;

// Ouput data
out vec3 color;

void main()
{
	color = fragmentColor;
}
 No newline at end of file
+6 −3
Original line number Diff line number Diff line
@@ -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;

+0 −20
Original line number Diff line number Diff line
#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;

}
+13 −3
Original line number Diff line number Diff line
@@ -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);