SFML community forums

Help => Graphics => Topic started by: acrin1 on May 17, 2008, 05:17:07 pm

Title: RenderWindow not showing OpenGL elements
Post 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.
Title: RenderWindow not showing OpenGL elements
Post by: acrin1 on May 17, 2008, 06:17:01 pm
I've also noticed that I get an unhandled exception if I press the Escape key in this case.
Title: RenderWindow not showing OpenGL elements
Post by: Kernelpanic on May 17, 2008, 07:50:17 pm
You could commit a pointer to the window to the function.
Title: RenderWindow not showing OpenGL elements
Post by: Laurent on May 18, 2008, 06:19:09 am
Which SFML version ? Which OS ?

If you create the window in main() (using App.Create(...)), do the problems disappear ?
Title: RenderWindow not showing OpenGL elements
Post by: acrin1 on May 18, 2008, 12:03:44 pm
Quote from: "Laurent"
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.
Title: RenderWindow not showing OpenGL elements
Post by: acrin1 on May 24, 2008, 05:39:12 pm
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.
Title: RenderWindow not showing OpenGL elements
Post by: NewbiZ on May 24, 2008, 11:19:23 pm
I suppose the raised exception is a std::bad_alloc.

It seems you defined _DEBUG ( Project -> Properties -> C++ -> Preprocessor ) and linked release libs.
Title: RenderWindow not showing OpenGL elements
Post by: acrin1 on June 04, 2008, 12:17:37 am
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.