Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: applying texture to the application surface

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2016
    Posts
    13

    applying texture to the application surface

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

    https://en.wikipedia.org/wiki/List_o...dware_palettes

    https://en.wikipedia.org/wiki/List_o...test_chart.png

    https://upload.wikimedia.org/wikiped...test_chart.png

    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 );
    }

    thanks

  2. #2
    Member Regular Contributor
    Join Date
    May 2016
    Posts
    443
    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":
    c-code:
    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
    Posts
    425
    If I understood you well, you should better search in this direction.

  4. #4
    Newbie Newbie
    Join Date
    Sep 2016
    Posts
    3
    Quote Originally Posted by Silence View Post
    If I understood you well, you should better search in this direction.
    nice link.. it is detailed.. got it ifirmative

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
  •