I have been trying to tackle the blank screen problem in OpenGL.I decided to debug with render doc.
here is source.cpp section…
{
glm::mat4 proj=glm::perspective<float>(45.0f,1024.0f/786.0f,0.0f,10.0f);
glm::mat4 view=glm::lookAt(glm::vec3(-0.3,0.0,5.0),glm::vec3(0.0,0.0,0.0),glm::vec3(0.0,1.0,0.0));
glm::mat4 translate=glm::make_mat4x4(translation);
glm::translate(translate, glm::vec3(glm::sin(glfwGetTime()), 0.0, glm::abs(glm::sin(glfwGetTime()))));
box.shader.setUniformat4x4("projection_matrix",glm::value_ptr(proj));
box.shader.setUniformat4x4("view_matrix",glm::value_ptr(view));
box.shader.setUniformat4x4("translate",glm::value_ptr(translate));
static Timer t;
t.startTimer();
box.shader.setUniform1f("time",t.getTicks());
box.render();
glm::vec4 p1(0.2, 0.2, -2.0, 1.0),p2(-0.2, 0.2, 0.0,1.0),p3(0.00,-0.2,0.0,1.0);
p1 = proj * p1;
p2 = proj * p2;
p3 = proj * p3;
/*
glBegin(GL_TRIANGLES);
glColor3f(1.0, 1.0, 1.0);
glVertex3f(p1.x,p1.y,p1.z);
glVertex3f(p2.x, p2.y, p2.z);
glVertex3f(p3.x, p3.y, p3.z);
glEnd();
*/
//glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glFlush();
}
And the vertex shader…
#version 330 core
layout(location=0) in vec3 pos1;
uniform mat4 translate;
uniform mat4 projection_matrix;
uniform mat4 view_matrix;
uniform float time;
out float t;
out vec4 vertex;
void main()
{
projection_matrix;
view_matrix;
translate;
//if(pos1.x<0)
//vertex=projection_matrix*pos1;
//else
vec4 p=vec4(pos1.x,pos1.y,pos1.z,1.0);
gl_Position=projection_matrix*p;
t=time;
}
Here when I don’t apply projection multiplication with p;everything works fine.
But with above mentioned shader RenderDoc shows this
empty VS output gl_position.Why!
what is wrong here.
here is projection matrix
mat4x4((1.853097, 0.000000, 0.000000, 0.000000), (0.000000, 2.414213, 0.000000, 0.000000), (0.000000, 0.000000, -1.000000, -1.000000), (0.000000, 0.000000, -0.000000, 0.000000))