SFML community forums
Help => Graphics => Topic started by: Powereleven on May 24, 2018, 01:03:44 am
-
I am aware of
sf::Texture::bind(&texture_here);
but what if my shader requires more than 1 texture?
-
It's in the doc.
https://www.sfml-dev.org/documentation/2.5.0/classsf_1_1Shader.php#a7806a29ffbd0ee9251256a9e7265d479
-
I was aware of that setUniform stuff too. I used them before entering my game loop to set the sampler2Ds.
But when mixing with my custom OpenGL code, the doc says:
sf::Texture t1, t2;
...
sf::Texture::bind(&t1);
// draw OpenGL stuff that use t1...
sf::Texture::bind(&t2);
// draw OpenGL stuff that use t2...
sf::Texture::bind(NULL);
// draw OpenGL stuff that use no texture...
But what if my OpenGL stuff uses t1 and t2? It seems that t1 is unbinded if I bind t2.
-
Texture::bind cannot make use of multiple texture units, so yes, each call replaces the previous texture. But depending on what your OpenGL code does, this may not be a problem.
-
For example, I have 2 sampler2D and mix() them in the shader. How do I solve this? ( in sfml standard functions obviously )
-
As I said, if it's in a sf::Shader, you can use Shader::setUniform, it will correctly handle multiple texture units.