Solution found1. In my project, from which I came here with this issue, I was setting shader uniforms to a wrong shader, that caused error.
2. What about my example, the solution is simple:
do not use window.clear() when mixing with opengl. Seems that it internally unbinds texture (by binding texture with id 0) and this somehow causes problems in your code (at least my debugger thinks so
).
3. Also, calling window.resetGLStates() before pushing doesn't fix the problem, instead you have to reset gl objects manually:
Example:
//Application loop (while window.isOpen())
//If you start drawing your OpenGL (in my case 3d scene) before SFML, use glClear instead of window.clear
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); //or your favourite color
//Drawing your stuff
glDrawArrays(...)
glDrawElements(....);
//Switching to sfml
//Clearing objects
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
glUseProgram(0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0);
//SFML drawing
window.pushGLStates();
window.draw(...);
window.popGLStates();
Probably, I've missed something, because SFML is written and tested better than my code, but I don't know why it didn't help.
Anyway, thanks Laurent for your help.