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: Multiple Shaders

  1. #1
    Intern Newbie
    Join Date
    Jun 2011
    Posts
    37

    Multiple Shaders

    I need to be able to use more than one shader but I'm not entire sure how to do this.

    Code :
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glUseProgram(myshader);// "myshader" being the linked program
     
    // draw a model here using "glDrawElements"
     
    glClear(GL_DEPTH_BUFFER_BIT);
    glUseProgram(0);
     
    glEnable(GL_TRIANGLES);
     glColor3f(1, 1, 1); glVertex3f(1, 0, 0);
     glColor3f(1, 1, 1); glVertex3f(0, 1, 0);
     glColor3f(1, 1, 1); glVertex3f(0, 0, 1);
    glEnd();

    The problem with is that everything uses the default shader glUseProgram(0).

  2. #2
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Posts
    5,932

    Re: Multiple Shaders

    Of course it does; that's what you told it to do. If you want to use the other shader, then you call glUseProgram with that other shader as a parameter.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,728

    Re: Multiple Shaders

    I think these lines are the ones that the OP is referring to:
    Code :
    glUseProgram(myshader);// "myshader" being the linked program
     
    // draw a model here using "glDrawElements"
    If I've read it right, actual drawing of the model has been omitted for clarity and brevity, and the problem is that despite this glUseProgram call the default (0) shader is still being used.

    If this is the case, maybe try checking the output of your compilation to make sure that there are no errors, and also check that "myshader" doesn't have a value of 0.

  4. #4
    Intern Newbie
    Join Date
    Jun 2011
    Posts
    37

    Re: Multiple Shaders

    Already thanks guys, it turned out to be something else.

Posting Permissions

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