The SDL forums have moved to
This is just a read-only archive of the previous forums, to keep old links working.

SDL Forum Index
Simple Directmedia Layer Forums
testshader.c Updated for SDL2, some shaders not working

Joined: 26 Mar 2011
Posts: 72
Updated the test to compile and run on SDL2:

It fails in the same way that I was experiencing on this topic:, ie. the shader that tries to sample a texture ends up full black everytime. Here is the unmodified code pulled from testshader.c, presumably it worked at some point:

{ 0, 0, 0,
/* vertex shader */
"varying vec4 v_color;\n"
"varying vec2 v_texCoord;\n"
"void main()\n"
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
" v_color = gl_Color;\n"
" v_texCoord = vec2(gl_MultiTexCoord0);\n"
/* fragment shader */
"varying vec4 v_color;\n"
"varying vec2 v_texCoord;\n"
"uniform sampler2D tex0;\n"
"void main()\n"
" gl_FragColor = texture2D(tex0, v_texCoord) * v_color;\n"

Can anyone with GL experience figure out why the shaders run, but the sampler doesn't seem to have access to texture data? Can anyone make testshader.c run as expected under SDL2?

Jeremy J