It didn't compile at start, but I downloaded glad with compatibility settings and now it works, the background and text are shown, and the cube is rotating, but it spams my console with errors:
An internal OpenGL call failed in RenderTextureImplFBO.cpp(192).
Expression:
GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, 0)
Error description:
GL_INVALID_OPERATION
The specified operation is not allowed in the current state.
Solution found
1. 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 :D ).
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.