After I do my GL calls, I display a rectangle on the screen depending upon user input. I am aware that by pressing T you will forever display the rectangle (correct functionality).
This is my code (for just the main loop):
sf::Shape Rect = sf::Shape::Rectangle(0,0,1920,1080,sf::Color::Black);
Rect.EnableFill(true);
Rect.SetPosition(0,0);
while (theVars->App.IsOpened())
{
sf::Event event;
bool draw = false;
theVars->App.Clear();
while(theVars->App.GetEvent(event)){
if (event.Type == sf::Event::MouseButtonPressed) {
const sf::Input& Input = theVars->App.GetInput();
if (event.MouseButton.Button == sf::Mouse::Left) {
selectSquares(Input.IsKeyDown(sf::Key::LShift), event.MouseButton.X, event.MouseButton.Y);
}
}
if (event.Type == sf::Event::KeyPressed) {
keyDown(event.Key.Code);
}
if (theVars->App.GetInput().IsKeyDown(sf::Key::T)) {
draw = true;
}
}
// Set the active window before using OpenGL commands
// It's useless here because active window is always the same,
// but don't forget it if you use multiple windows or controls
theVars->App.SetActive();
display();
// Finally, display rendered frame on screen
if(draw)
theVars->App.Draw(Rect);
theVars->App.Display();
}
Note:: display() is all my OpenGL stuff.
When the rectangle gets drawn the color of the box changes.
Any help?
EDIT: This is caused when you enable lighting in Open GL code. In order to use SFML drawings and display the correct color, you must first disable lighting. You can then reenable it after you draw.
Working Code:
glDisable(GL_LIGHTING);
theVars->App.Draw(Rect);
glEnable(GL_LIGHTING);