Hello, I am having a VERY strange problem with openGL recently.
To get to the point, I am trying to render objects with textures, and without textures. But for some reason, whenever I render an object with no texture, it ends up appearing black, even though I am using a pixel shader that outputs a red color, for example.
Psoudo code:
Bind Program...
Bind texture...
Bind Vertex Array...
Render textured object, done!
Bind texture(texture_2d, 0) // default texture
Bind Program...
Bind Vertex Array...
Render NON-Textured Object, da fek?? Why is it black!???
It seems like whenever I still use the last texture without setting it to 0, the shader uses one of the colors from the texture to color my non-textured object, even though the shader doesn't accept a texture for input... -.-
Here's a picture of what is happening:
These are what my color shaders look like:
public string vertexColorShaderText = @"
#version 130
in vec3 in_Position;
out vec3 out_color;
uniform mat4 worldMatrix;
uniform mat4 viewMatrix;
uniform mat4 projectionMatrix;
void main(void)
{
gl_Position = worldMatrix * vec4(in_Position, 1.0f);
gl_Position = viewMatrix * gl_Position;
gl_Position = projectionMatrix * gl_Position;
}";
public string pixelColorShaderText = @"
#version 130
out vec4 last_color;
void main(void)
{
vec4 derp_color;
derp_color.r = 1.0;
derp_color.g = 0.0;
derp_color.b = 0.0;
derp_color.a = 1.0;
last_color = derp_color;
}";
I just don't understand. Is there something I am supposed to be doing here???