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


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


Joined: 26 Mar 2011
Posts: 72
Updated the test to compile and run on SDL2: http://pastebin.com/Fy7560ka

It fails in the same way that I was experiencing on this topic: http://forums.libsdl.org/viewtopic.php?t=9196, 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:

/* SHADER_TEXTURE */
{ 0, 0, 0,
/* vertex shader */
"varying vec4 v_color;\n"
"varying vec2 v_texCoord;\n"
"\n"
"void main()\n"
"{\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"
"\n"
"void main()\n"
"{\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?

Regards,
Jeremy J