///////////////////////////////////////////////////////
| 777 | |
| 778 | //////////////////////////////////////////////////////////// |
| 779 | void Shader::bind(const Shader* shader) |
| 780 | { |
| 781 | const TransientContextLock lock; |
| 782 | |
| 783 | // Make sure that we can use shaders |
| 784 | if (!isAvailable()) |
| 785 | { |
| 786 | err() << "Failed to bind or unbind shader: your system doesn't support shaders " |
| 787 | << "(you should test Shader::isAvailable() before trying to use the Shader class)" << std::endl; |
| 788 | return; |
| 789 | } |
| 790 | |
| 791 | if (shader && shader->m_shaderProgram) |
| 792 | { |
| 793 | // Enable the program |
| 794 | glCheck(GLEXT_glUseProgramObject(castToGlHandle(shader->m_shaderProgram))); |
| 795 | |
| 796 | // Bind the textures |
| 797 | shader->bindTextures(); |
| 798 | |
| 799 | // Bind the current texture |
| 800 | if (shader->m_currentTexture != -1) |
| 801 | glCheck(GLEXT_glUniform1i(shader->m_currentTexture, 0)); |
| 802 | } |
| 803 | else |
| 804 | { |
| 805 | // Bind no shader |
| 806 | glCheck(GLEXT_glUseProgramObject({})); |
| 807 | } |
| 808 | } |
| 809 | |
| 810 | |
| 811 | //////////////////////////////////////////////////////////// |
no test coverage detected