I've been arming my engine with error checking code. I'll try to describe this situation to my best abilities. Whenever i load a shader and there's an error (file doesn't exist, compilation error, anything that could go wrong) i delete the shader and set the pointer to 0 (can't think of annother way to make sure i don't try to attach or delete trash by accident). I don't want to stop the program if this happens, because somebody might delete or modify a single file by accident in the game folder and don't want to render the whole game unusable because of that.
Now the thing is, is there a default behavior in the situation where i attach shaders to a program that have the pointer equal to 0?
In my program, if i attach a vertex shader equal 0 and a fragment shader equal 0, then OpenGL will use the default program (will display everything white):
This is a rotated cube that's dimensions are in clip space already, rendered without perspective projection or depth checking. It's loaded from an .obj file.
Now, if i attach a proper fragment shader, but the vertex shader will be 0, i get this:
Which is what i would expect, all the fragment shader does is outputs a vec4(1.0, 0.3, 0.7, 1.0), there's no vertex shader so OpenGL uses the default one (is this a correct assumption?).
Now, however, if i attach a correct vertex shader, but i attach a fragment shader equal to 0 (or i won't attach a fragment shader at all) i'll get this mess:
Something you can't see is that this model is contantly being painted different colors, so on my screen it looks like an acid trip with black horizontal lines going through.
I'm confused a bit, because i would expect the cube to just be white. I'd like to point out that my shader code is bare bones, i'm not exchanging any variables between vertex and fragment shaders. Checking if the pointer is not equal to 0 doesn't change anything, the linked program acts the same as if i gave it a pointer equal to 0. The weirdest thing to me is that it's always nicely shaded, it's not just trash.
EDIT: Maybe the default fragment shader expects a gl_ value from the vertex that i'm ommiting to set? That would kind of explain why the surface is nicely shaded, the fragment shader expects a smooth in, but that value is just trash, because i didnt' set it.
Now is this an "undefined behavior" or is this how it's suppoused to work?