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

Author Topic: RenderWindow not showing OpenGL elements  (Read 6064 times)

0 Members and 1 Guest are viewing this topic.

acrin1

  • Newbie
  • *
  • Posts: 45
    • View Profile
    • http://www.crpgdev.com
RenderWindow not showing OpenGL elements
« 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.

acrin1

  • Newbie
  • *
  • Posts: 45
    • View Profile
    • http://www.crpgdev.com
RenderWindow not showing OpenGL elements
« Reply #1 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.

Kernelpanic

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • http://eisenholz.bplaced.net
RenderWindow not showing OpenGL elements
« Reply #2 on: May 17, 2008, 07:50:17 pm »
You could commit a pointer to the window to the function.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
RenderWindow not showing OpenGL elements
« Reply #3 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 ?
Laurent Gomila - SFML developer

acrin1

  • Newbie
  • *
  • Posts: 45
    • View Profile
    • http://www.crpgdev.com
RenderWindow not showing OpenGL elements
« Reply #4 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.

acrin1

  • Newbie
  • *
  • Posts: 45
    • View Profile
    • http://www.crpgdev.com
RenderWindow not showing OpenGL elements
« Reply #5 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.

NewbiZ

  • Newbie
  • *
  • Posts: 44
    • View Profile
RenderWindow not showing OpenGL elements
« Reply #6 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.
~ Passer pour un idiot aux yeux d'un imbécile est une volupté de fin gourmet ~

acrin1

  • Newbie
  • *
  • Posts: 45
    • View Profile
    • http://www.crpgdev.com
RenderWindow not showing OpenGL elements
« Reply #7 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.