Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: applying texture to the application surface

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2016

    applying texture to the application surface

    how to change the color of the application surface, using the texture??

    my fragment shader start in this way:

    Code :
    varying vec2 v_vTexcoord;
    varying vec4 v_vColour;
    void main()
        gl_FragColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );


  2. #2
    Member Regular Contributor
    Join Date
    May 2016
    i think you are missing the texture sampler:
    Code :
    uniform sampler2D gm_BaseTexture;

    if you want to use multiple textures, you have to explicitly assign a value to "gm_BaseTexture":
    Code :
    unsigned int textureunit = ..anynumber..;
    // get sampler location:
    int location = getUniformLocation(shader, "gm_BaseTexture");
    // send texture location to the sampler:
    glProgramUniform1i(shader, location, textureunit);
    // bind texture to texture unit
    glActiveTexture(GL_TEXTURE0 + textureunit);
    glBindTexture(GL_TEXTURE_2D, texture);

  3. #3
    Member Regular Contributor
    Join Date
    Jul 2012
    If I understood you well, you should better search in this direction.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts