I'm trying to draw a triangle with a texture mapped to it (using only a shader program, vertex buffers, a uniform buffer, etc so no immediate mode) in the gl context 3.3, but the triangle is rendered black. Though if I use the gl context 3.1, the texture draws fine.
So the first thing that I thought might be a problem was my shader code, and I was hoping someone could check if I am missing anything, shown below, so I can rule it out.
vertex shader:
#version 330layout(std140, row_major) uniform u_transform {mat4 modelViewProj;};in vec3 a_pos;in vec2 a_tex;varying vec2 v_tex;void main() { v_tex = a_tex; gl_Position = modelViewProj*vec4(a_pos,1.0);}
fragment shader:
#version 330uniform sampler2D t_colMap;varying vec2 v_tex;void main() { gl_FragColor = texture2D(t_colMap,v_tex);}
Also my context creation code is:
void initContext() { int attribs[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, 3, WGL_CONTEXT_MINOR_VERSION_ARB, 3, WGL_CONTEXT_FLAGS_ARB, 0 }; rc = wglCreateContextAttribsARB(hdc,0, attribs);}
Another issue I thought about might be is my texture loading (using the devil image lib, glTexImage2D(GL_TEXTURE_2D, ..) and glGenerateMipmap(GL_TEXTURE_2D)), but that works fine with the 3.1 context.
Thanks.