SFML community forums
Help => Graphics => Topic started by: acrin1 on May 17, 2008, 05:17:07 pm
-
#include <SFML/Graphics.hpp>
#include "display.h"
sf::RenderWindow App(sf::VideoMode(800, 600), "SFML OpenGL");
void mainLoop()
{
...my code...
Defining my RenderWindow outside my functions as above is causing me a problem - only my 2D SFML drawing is working (fonts, images). My OpenGL stuff doesn't show up. I'm wanting to be able to refer to App from numerous different functions.
Am I doing something wrong?
Thanks.
-
I've also noticed that I get an unhandled exception if I press the Escape key in this case.
-
You could commit a pointer to the window to the function.
-
Which SFML version ? Which OS ?
If you create the window in main() (using App.Create(...)), do the problems disappear ?
-
Which SFML version ? Which OS ?
If you create the window in main() (using App.Create(...)), do the problems disappear ?
I'm using SFML 1.2, with Visual Studio 2005 and Windows XP.
I still seem to get the same issues with App.Create within main() and if I define sf::RenderWindow App; outside my main().
I'll try simlifying my code as it's spread across a number of source files just now.
Thanks.
-
I simplified some of my code and found some additional references to RenderWindow in my code which was causing the OpenGL elements to not show up.
So everything is working ok now except that I still get an unhandled exception error when I press Escape if I define my window as follows:
#include <SFML/Graphics.hpp>
sf::RenderWindow App;
int main()
{
// Create main window
App.Create(sf::VideoMode(640, 480, 32), "SFML");
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed) Running = false;
// Escape key : exit
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape)) Running = false;
Closing the window doesn't generate any errors. The VS2005 debugger points at:
////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////
RenderWindow::~RenderWindow()
{
// Nothing to do...
}
Can anybody suggest what I'm doing wrong here?
Many thanks.
-
I suppose the raised exception is a std::bad_alloc.
It seems you defined _DEBUG ( Project -> Properties -> C++ -> Preprocessor ) and linked release libs.
-
Upgrading to the latest SVN yesterday seems to have got rid of the unhandled exception I was getting when pressing a key to end the program.