Hey everybody,
currently I'm trying to mix OpenGL and SFML. Used the great OpenGL 3.3 tutorials at learnopengl.com to render a cube with two textures on it. That works without problems, even when using sf::RenderWindow().
The shaders use the texture units GL_TEXTURE0 and GL_TEXTURE1.
The problems arise if I also use a sf::RectangleShape besides the pure gl-calls.
My loop is like:
window.setActive(true);
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex1_id);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, tex2_id);
glUseProgram(shader_id);
model = glm::rotate(glm::mat4(1.0f), clock.getElapsedTime().asSeconds(), glm::vec3(0.5f, 1.0f, 0.0f));
glUniformMatrix4fv(glGetUniformLocation(shader_id, "model"), 1, GL_FALSE, &model[0][0]);
glBindVertexArray(VAO);
glDrawArrays(GL_TRIANGLES, 0, 36);
glBindVertexArray(0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 0);
glUseProgram(0);
window.setActive(false);
window.pushGLStates();
window.draw(cell_shape); // sf::RectangleShape cell_shape(sf::Vector2f(15, 15));
window.popGLStates();
window.display();
If I order the window to pushGLStates it issues:
An internal OpenGL call failed in rendertarget.cpp(381).
Expression:
glPushMatrix()
Error description:
GL_STACK_OVERFLOW
This command would cause a stack overflow.
And at popGLStates:
An internal OpenGL call failed in rendertarget.cpp(398).
Expression:
glPopMatrix()
Error description:
GL_STACK_UNDERFLOW
This command would cause a stack underflow.
This only happens if I use
both texture units. The error disappears if I don't bind GL_TEXTURE1. Only one currently bound texture seems to be no problem, two simultaneously bound textures are indeed a problem. It doesn't matter which tex units I use (GL_TEXTURE2, GL_TEXTURE3, ...), they all issue the errors.
Most disturbing is that everything is rendered correctly...
Any ideas?
I'm using SFML from repo, cloned five days ago from master, together with VS2017 and Win7-64.
Perhaps it's a problem with my graphics card; I only have the crappy Intel HD 5500. I have no other device for testing.