Results 1 to 5 of 5

Thread: Error on exit

  1. #1
    Serf
    Join Date
    Apr 2007
    Posts
    3

    Default Error on exit

    All my ClanLib programs compile and run fine, but when I hit escape to exit the window closes and windows gives one of those "This program needs to be terminated" errors. I've done some tracing and found that it doesn't happen until the return 0 in the main function.

    What's wrong?

  2. #2
    Lesser Knight
    Join Date
    Sep 2006
    Posts
    41

    Default

    Something isn't deinitializing correctly.

    Can you reduce the code to a minimal skeleton that still causes the error?

  3. #3
    Serf
    Join Date
    Apr 2007
    Posts
    3

    Default

    Modelled after the examples on the site...

    Code:
    #include "BlankDriver.h"
    #include "BlankGame.h"
    
    BlankDriver applicationInstance;
    
    BlankDriver::BlankDriver(){}
    BlankDriver::~BlankDriver(){}
    
    int BlankDriver::main(int, char **)
    {
    	CL_ConsoleWindow console("Blank Console");
    	console.redirect_stdio();
    
    	try {
    		CL_SetupCore::init();
    		CL_SetupDisplay::init();
    		CL_SetupGL::init();
    
    		CL_DisplayWindow window("Blank", 640, 400);
    		BlankGame rg;
    		rg.run();
    		CL_SetupGL::deinit();
    		CL_SetupDisplay::deinit();
    		CL_SetupCore::deinit();
    	} catch (CL_Error err) {
    		std::cout << "Exception caught: " << err.message.c_str() << std::endl;
    		console.display_close_message();
    	}
    
    	return 0;
    }
    and

    Code:
    #include "BlankGame.h"
    
    BlankGame::BlankGame()
    {
    
    	loadGraphics();
    }
    
    BlankGame::~BlankGame() {}
    
    void BlankGame::run()
    {
    	bool alive=true;
    	while (alive && !CL_Keyboard::get_keycode(CL_KEY_ESCAPE))
    	{
    		paint();
    		CL_Display::flip();
    		CL_System::keep_alive();
    	}
    }
    
    void BlankGame::paint()
    {
    	CL_Display::clear(CL_Color(0, 0, 0, 255));
    }
    
    void BlankGame::loadGraphics()
    {
    
    }
    The header files are just what you'd expect.

  4. #4
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    If you replace the init code (CL_SetupCore::init();, CL_SetupDisplay::init();CL_SetupGL::init() with the suggested way in the INSTALL files:

    try
    {
    // Initialize ClanLib base components
    CL_SetupCore setup_core;

    // Initialize the ClanLib display component
    CL_SetupDisplay setup_display;

    // Initialize the ClanLib GL component
    CL_SetupGL setup_gl;

    // Create a display window
    CL_DisplayWindow window("ClanLib application", 640, 480);

    ....

    Does that help?

  5. #5
    Serf
    Join Date
    Apr 2007
    Posts
    3

    Default

    Yeah, that worked, thanks. I guess something changed in the newer versions of ClanLib that made that way not work anymore.

Similar Threads

  1. Help! linking error
    By thfai2000 in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 10-30-2008, 04:30 AM
  2. encountered compile error 0.9 svn 146
    By voudras in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 01-11-2007, 06:57 AM
  3. error compiling 0.9 svn
    By voudras in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 01-11-2007, 06:47 AM
  4. Error at startup
    By in forum Other RTsoft Games
    Replies: 3
    Last Post: 06-28-2006, 09:27 AM
  5. Customized error message
    By File Sponge in forum Funeral Quest
    Replies: 2
    Last Post: 08-13-2004, 12:33 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •