I managed to recreate the problem with this code, it mixes pure openGL and sfml as I need to be able to use both with my app.
#include <GL/glew.h>
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
sf::RenderWindow App;
sf::Sprite backGroundSprite;
sf::Image backgroundTexture;
sf::Sprite backGroundSprite2;
sf::Image backgroundTexture2;
sf::WindowSettings Settings;
Settings.DepthBits = 24; // Request a 24 bits depth buffer
Settings.StencilBits = 8; // Request a 8 bits stencil buffer
Settings.AntialiasingLevel = 2; // Request 2 levels of antialiasing
App.Create(sf::VideoMode(800, 600, 32), "Window", sf::Style::Close ,Settings);
App.UseVerticalSync(true);
App.ShowMouseCursor(false);
App.PreserveOpenGLStates(true);
GLenum err = glewInit();
if (GLEW_OK != err)
{
/* Problem: glewInit failed, something is seriously wrong. */
std::cout << "Error: " << glewGetErrorString(err) << std::endl;
return false;
}
else
{
std::cout << "Using GLEW " << glewGetString(GLEW_VERSION) << std::endl;
}
glEnable(GL_DEPTH_TEST);
// Accept fragment if it closer to the camera than the former one
glDepthFunc(GL_LESS);
// Cull triangles which normal is not towards the camera
glEnable(GL_CULL_FACE);
backgroundTexture.LoadFromFile("./Data/MenuBackground.png");
backGroundSprite = sf::Sprite();
backGroundSprite.SetImage(backgroundTexture);
backGroundSprite.SetPosition(0.f,0.f);
sf::Vector2f scale;
scale.x = float(App.GetWidth()) / backGroundSprite.GetImage()->GetWidth();
scale.y = float(App.GetHeight()) / backGroundSprite.GetImage()->GetHeight();
backGroundSprite.SetScale(scale);
float time = 0.0f;
while(App.IsOpened())
{
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window
if (Event.Type == sf::Event::Closed)
App.Close();
// Escape key pressed
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();
if (Event.Type == sf::Event::Resized)
glViewport(0, 0, Event.Size.Width, Event.Size.Height);
}
if(!App.IsOpened()) break;
time += App.GetFrameTime();
App.SetActive();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Dark blue background
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
App.Draw(backGroundSprite);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
App.Display();
}
}