Results 1 to 3 of 3

Thread: Deleting sprites (ClanLib 0.9)

  1. #1
    Serf
    Join Date
    May 2008
    Posts
    3

    Default Deleting sprites (ClanLib 0.9)

    I have code like this:

    Code:
    CL_ResourceManager *resources;
    CL_Sprite *spr;
    
    resources = new CL_ResourceManager("resources.xml");
    spr = new CL_Sprite("SpriteFromResource", resources, gc);
    Then I try to delete the sprite in application's destructor:

    Code:
    CL_Game::~CL_Game()
    {
    	if(spr)
    		delete spr;
    
    	if(resources)
    		delete resources;
    }
    This results unhandled exception in mutex.cpp line 89 (EnterCriticalSection(&critical_section)). This also happens if I put "delete spr" in try block. This seems to happen only when I load sprite from resource file, not if I load sprite from image file.

    Is this wrong way to delete sprites? What's the right way?

  2. #2
    Serf
    Join Date
    May 2008
    Posts
    3

    Default

    It seems this is caused because CL_GraphicContext is already deleted when the program reaches application's destructor. I guess I should delete sprites somewhere before the destructor.

  3. #3
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Yes, that is correct.

    I ran into the same problem myself.

    Sprites uses CL_Texture's, so that the sprite can be stored on the graphics card memory. If the display is destroyed, the CL_Texture will be invalid, thus it will not deallocate correctly

Similar Threads

  1. Sprites and more...
    By Ledorax in forum Novashell Game Creation System
    Replies: 8
    Last Post: 09-28-2009, 04:47 PM
  2. Problem: Using sprites after a gui.run
    By nokturn in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 05-16-2007, 06:44 PM
  3. Sprites
    By lixopmstp in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 01-21-2007, 02:36 AM
  4. Sprites and Surfaces
    By ART_Adventures in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 09-22-2006, 10:03 AM
  5. sprites
    By seyah3 in forum Dink Smallwood HD
    Replies: 0
    Last Post: 02-03-2006, 03:05 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
  •