OpenGL GLSL Binding Sampler for Fragment Shader

后端 未结 1 781
终归单人心
终归单人心 2021-01-22 16:09

I am hoping to implement a shader on a 2D OpenGL application. My plan is to render a scene to a framebuffer object, and then render that framebuffer object to the screen using

相关标签:
1条回答
  • 2021-01-22 17:15

    There's indeed a problem with how you set the uniform value for the sampler:

    gSampler = glGetUniformLocation(mProgramID, "gSampler");
    glUniform1i(gSampler, GL_TEXTURE0);
    

    The value you need to set for the uniform is the index of the texture unit, not the corresponding enum value. Since you are using texture unit 0 in this case, you need to replace the glUniform1i() call by:

    glUniform1i(gSampler, 0);
    
    0 讨论(0)
提交回复
热议问题