• Advertisement
Sign in to follow this  

FIXED ! urgent! simple shader multi text problem

This topic is 3983 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've got to do this by lunchtime (uk time) ! I can't get the second texture parameter to be read at all. Can anyone see what is wrong at all ? The shader is so simple it's untrue:
uniform samplerRect in0;
uniform samplerRect in1;
void main (void)
vec4  outTex0 = vec4(textureRect(in0, gl_TexCoord[0].st));
vec4  outTex1 = vec4(textureRect(in1, gl_TexCoord[1].st));
gl_FragData[0] = outTex0;
gl_FragData[1] = outTex1;

the texture written to by gl_FragData[1] always has the data from outTex0 (read from 'in0' texture). I've swapped textures over, used new textures etc and still I can't get the output outTex1 to have anything but outTex0. I also tried the below
In this case the data output is as expected, 1.2 in the first tex and 2.3 in the second tex.
gl_FragData[0] = vec4(1.2);
gl_FragData[1] = vec4(2.3);

So it must be the the multi tex call but it looks ok to me
For one texture input I use:
    glTexCoord2f(xoffset, yoffset);
    glVertex2i(0, 0);

    glTexCoord2f(width, yoffset);
    glVertex2i((GLuint)width, 0);

    glTexCoord2f(width, height);
    glVertex2i((GLuint)width, (GLuint)height);

    glTexCoord2f(xoffset, height);
    glVertex2i(0, (GLuint)height);


for two tex's I use:


    fglMultiTexCoord2f(GL_TEXTURE0, xoffset, yoffset);
    fglMultiTexCoord2f(GL_TEXTURE1, xoffset, yoffset);
    glVertex2i(0, 0);

    fglMultiTexCoord2f(GL_TEXTURE0, width, yoffset);
    fglMultiTexCoord2f(GL_TEXTURE1, width, yoffset);
    glVertex2i((GLuint)width, 0);

    fglMultiTexCoord2f(GL_TEXTURE0, width, height);
    fglMultiTexCoord2f(GL_TEXTURE1, width, height);
    glVertex2i((GLuint)width, (GLuint)height);

    fglMultiTexCoord2f(GL_TEXTURE0, xoffset, height);
    fglMultiTexCoord2f(GL_TEXTURE1, xoffset, height);
    glVertex2i(0, (GLuint)height);


THE FIX WAS: GLint location = fglGetUniformLocation(m_shaders[shaderHandle].program, parameterName); fglUniform1i(location, tex); tex wants 0,1,2,3, and NOT the texture id [Edited by - ade-the-heat on May 25, 2007 5:24:09 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement