So I constructed my engine with OpenGL 1.1+. I did this to make it a little easier for me to get my matrices straight. Now that I think I have, I’m working on the OpenGL 3.0+ implementation, but apparantly my scene remains black (background color). I want to know what’s wrong with my code. First, lets take a look at my vertex and fragment shaders:
I’m passing the color white to the fragment shader because I want to implement the textures a little later, for now, I just want to be able to load models.
So model_matrix is the matrix that positions every model to be drawn and view_matrix positions the ‘camera’. In my OpenGL 1.1 implementation, I would:
[ul][li] Push the view matrix[*] For each model:[/li] [LIST][li] Push the model matrix[/li] [li] Pop the model matrix[/li] [/ul][li] Pop the view matrix[/LIST][/li]I hope I’m getting the same effect with what I’m doing right now in my vertex shader.
Fragment:
#version 130
in vec4 color_input;
out vec4 color_output;
void main()
{
color_output = color_input;
}
There are now compile errors and I’m convinced I don’t do anything else that should fail because I don’t get any access violations (segmentation fault).
I think you should write the variable gl_Position in the vertex shader with a value that is transformed to homogeneous coordinates( using projection and view matrices?), and in the fragment shader you should write the colour to gl_FragColor.
Also, the varyings you declare are wrong. It should be
There are now compile errors and I’m convinced I don’t do anything else that should fail because I don’t get any access violations (segmentation fault).
Yomboprime’s correct as to your error, which is why you generally shouldn’t put words like “output” or “input” in your interface variable names, since what is an output on one side must have the same name as the input on the other.
However, OpenGL shouldn’t crash. Unless you pass OpenGL a bad pointer, OpenGL isn’t supposed to crash, ever. OpenGL shows errors by, well, providing errors. A GLSL compiler error should not crash; it should give a compiler error log. That log should explain the problem, and possibly even the line number on which it happened.