SFML community forums
Help => Window => Topic started by: prchakal 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):
// Destroy the window if we own it
if (myWindow && myOwnsWindow)
DestroyWindow(myWindow);
Main file:
#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?
-
What error do you get?
Can you minimize your example so that only the code related to your problem remains?
-
The code of my basic test is:
#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:
(http://www.prsolucoes.com/downloads/sfml_1.png)
You will get the error executing out of IDE:
(http://www.prsolucoes.com/downloads/sfml_2.png)
Its all details.