Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML 2 - Bug when exit  (Read 2281 times)

0 Members and 1 Guest are viewing this topic.

prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
SFML 2 - Bug when exit
« on: November 27, 2010, 10:30:16 pm »
Hi,

I get an error when i click CLOSE button of window of my game.

Line of code that get error (WglContext):

Code: [Select]
   
// Destroy the window if we own it
    if (myWindow && myOwnsWindow)
        DestroyWindow(myWindow);


Main file:

Code: [Select]

#include <SFML/System.hpp>
#include <iostream>

#include "Planet.h"
#include "GameObjects.h"

int main()
{
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Solo Defender");

sf::Clock Clock;
   
Planet *planet = new Planet();

while (App.IsOpened())
{
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

App.Clear();

App.Draw(planet->sprite);

        App.Display();
    }

    return EXIT_SUCCESS;
}




What can be?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
SFML 2 - Bug when exit
« Reply #1 on: November 28, 2010, 04:49:42 am »
What error do you get?

Can you minimize your example so that only the code related to your problem remains?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
SFML 2 - Bug when exit
« Reply #2 on: November 28, 2010, 06:04:46 am »
The code of my basic test is:

Code: [Select]

#include <stdlib.h>
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>


int main(int argc, char** argv)
{
sf::RenderWindow Game(sf::VideoMode(800, 600, 32), "Teste");
   
while (Game.IsOpened())
{

sf::Event event;
        while (Game.GetEvent(event)) {

            if (event.Type == sf::Event::Closed)
                Game.Close();
            if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::Escape))
                Game.Close();
        }

Game.Display();
        Game.Clear();

}

    return EXIT_SUCCESS;
}



Is only you create a new project with VS 2008 and SFML 2.

Project type: Console

Put this code on main.cpp.

Compile and run.

Press ESC or close the window.

You will get the error on IDE:



You will get the error executing out of IDE:



Its all details.