Title states it pretty well. Basically, I have a bit of code that automatically applies a given shader to the whole screen (Assuming the shader pointer is not null), and when I re open the windows it crashes. It would be easier to explain this with a
gif. (Sorry, can't embed imgur gifs because they technically aren't gifs)
Anyway, here is the exact code where it crashes. (I know it says "Code: C" but this is actually C++)
if (vScreenShader != nullptr && !vSkipFrameShader && vGameWindow->hasFocus()) {
// Check that the screen texture is the same size as the screen
if (vScreen.tex.getSize().x != vWindowWidth || vScreen.tex.getSize().y != vWindowHeight) {
vScreen.tex.create(vWindowWidth, vWindowHeight);
vScreen.spr.setTexture(vScreen.tex);
}
vScreen.tex.update(*vGameWindow);
vScreen.spr.setTexture(vScreen.tex);
// Account for current shader and view
sf::View currentView = vGameWindow->getView();
sf::Shader* currentShader = (sf::Shader*)vRenderState.shader;
vRenderState.shader = vScreenShader;
vGameWindow->setView(vGameWindow->getDefaultView());
vGameWindow->draw(vScreen.spr, vRenderState);
vRenderState.shader = currentShader;
vGameWindow->setView(currentView);
}
It crashes at line 8 when I try to update the texture with the window. The window used to crash when I minimized it, but when I added the "&& vGameWindow->hasFocus()" to line 1, it fixed that problem. I don't know what I'm doing wrong, I've tried looking for another function to stop this block of code like "if window is opening" or "is minimized," but nothing. I don't know if this is important, but this code works when the window is open. (The gif shows off a sick scanline shader) How do I stop it from updating when the window is regaining focus?
thanks in advance