Hi,
I have read through the search hits to this problem and found no solution, so I take the liberty of posting a new question after roughly an hour of debug to no avail.
I have an app that uses native rendering beside SFML text render, and I have a problem when I resize my window. Infact the entire screen turns black.
Every frame when I render my things, I issue glUseProgam() to enable using my shaders, and when redering text, I use push/popGLStates to save my state of the statemachine, and to revert it back. I have found that push states does not save the program being used, that's why I lazily issue it every time before render. However, when I handle events at the begininng of the guiLoop(), I have to update my viewMatrix inside the shader. For that I need glUseProgram so the application knows which shader should have it's matrix updated. Here is the code:
// Set view matrix upon window resize
if (event.type == sf::Event::Resized)
{
m_matProj = glm::perspective( 45.0f, ((float)event.size.width)/event.size.height, 0.01f, 100.0f);
OpenGL.lock();
mainWindow->setActive();
mainWindow->setView(sf::View(sf::FloatRect(0, 0, (float)event.size.width, (float)event.size.height)));
glViewport(0, 0, event.size.width, event.size.height); auxRuntime->checkErr(glGetError(), cl::ERR, "glViewPort()");
// glUseProgram(glProgram); auxRuntime->checkErr(glGetError(), cl::ERR, "glUseProgram(glProgram)");
std::cout << glProgram << " " << projectionMatrixLocation << "\n";
glUniformMatrix4fv(projectionMatrixLocation, 1, GL_FALSE, &m_matProj[0][0]);
auxRuntime->checkErr(glGetError(), cl::ERR, "glUniformMatrix4fv(projectionMatrix)");
mainWindow->setActive(false);
OpenGL.unlock();
}
Funny thing is, having glUseProgram uncommented, things only distort, but when I actually try to update the matrix, the screen turns black. It is the very same routine I used to initialize the matrix in the first place.
What am I doing wrong?