Hi everyone,
I am struggling with shaders right now. Below are my shaders.
#version 440 core
void main(void)
{
const vec4 vertices[3]=vec43;
gl_Position=vertices[gl_VertexID];
}
#version 440 core
out vec4 color;
void main(void)
{
color=vec4(1.0f,0.0f,0.0f,1.0f);
}
In render function, I used glDrawArrays(GL_TRIANGLES,0,3). They draw nothing. The problem is I dont know even where to start troubleshooting. They are compiled, linked and even validated successfully. All I get is a blank scene. Several issues, I believe, are also related to how I get the text into the shader source in the first place. So the code below is how load it.
ifstream input(****.txt);
string line, content;
while(!input.eof())
{
getline(input,line);
content. append(line+"
");
}
const GLchar *shader_source=content.c_str();
glShaderSource(vertex_shader,1,&shader_source,NULL);
Fragment shader is similar to the above one. If I print shader_source, I get whatever is in my text. So no problem there. If everything is fine here, then I need to examine the code elsewhere.