White box after deleting all objects (of one type)

edited July 2012 in Help request
Hello again,

I've tried to delete all objects with this from an event handler
for(		
		ptrObject = orxOBJECT( orxStructure_GetFirst( orxSTRUCTURE_ID_OBJECT ) );
		ptrObject != orxNULL;
		ptrObject = orxOBJECT( orxStructure_GetNext( ptrObject ) ) 
		)
	{
	     orxObject_SetLifeTime(ptrObject, 0.0f);
	}

Everything gets deleted as it should, but if I try to create another object from config orx shows white emptiness instead of my graphics.
Apparently resources got freed because no one was using them anymore, but what do I do now? :silly:

Comments

  • edited July 2012
    Hi!

    Well resources will always get reloaded if needed, you can see that happening in the default playground that comes with orx where the ball objects get deleted via the LifeTime handling and get created via left click.

    If you get a white square, that means a texture has been loaded/used as if no texture were found, the object wouldn't even be sent to the renderer.

    So it's either a bug somewhere in orx or a possible misuse. :)

    Could we get more config/code details of your case?
  • edited July 2012
    Thats how the object is created
    orxVECTOR mousePosition;
    	orxMouse_GetPosition(&mousePosition);
    	orxVECTOR *ptrMouseInWorldPosition = orxRender_GetWorldPosition(&mousePosition, &mousePosition);
    	ptrMouseInWorldPosition->fZ = 0;
    	
    	//create in-world object
    	orxOBJECT *ptrObject =  orxObject_CreateFromConfig(nameOfObjThatWillBePlaced);
    	orxObject_SetPosition (ptrObject, ptrMouseInWorldPosition);
    	
    

    And thats the relevant(I hope so) config:
    [Display]
    Title                   = Harrybalt
    Decoration              = true
    FullScreen              = false
    ScreenWidth             = 640
    ScreenHeight            = 480
    ScreenDepth             = 32
    VSync                   = false
    Smoothing               = false
     
    [MainViewport]
    Camera               = MainCamera
    BackgroundColor      = (155, 0, 55)
    
     
    [MainCamera]
    FrustumWidth         = @Display.ScreenWidth
    FrustumHeight        = @Display.ScreenHeight
    FrustumFar           = 2.0                   
    FrustumNear          = 0.0                  
    Position             = (0.0, 0.0, -1.0)
    
    [Hero]
    Graphic         	= HeldIdleRight
    AnimationSet        = HeldAnimation
    Position           	= (0.0, 0.0, 0.0)
    Body                = HeroComplete
    Scale               = 2.0
    AutoScroll		= both
    DepthScale  		= true
    
    [HeroComplete]
    PartList           = HeroPart
    AllowGroundSliding = true
    AngularDamping     = 0.0
    Dynamic            = true
    FixedRotation      = true
    HighSpeed          = false
    Inertia            = 0.0
    LinearDamping      = 0.0
    
    [HeroPart]
    Type        = box
    Restitution = 0.0
    Friction    = 0.0
    SelfFlags   = 0x0001
    CheckMask   = 0xFFFF
    Solid       = true
    Density     = 1.0
    
    
    [HeroGraphics]
    Texture         	= data/opa/npc1.png
    Pivot               = center
    TextureSize 		=(21, 41, 0)
    

    There were no error messages.
    In fear this is not sufficient I've uploaded the project
    on Dropbox for you: Download

    This was created on Ubuntu 12.04 64bit.
  • edited July 2012
    Hi!

    Thanks for the details and mostly for the project, without that I wouldn't have found the bug that easily! :)

    That bug happened in a very specific use case which doesn't often happen in real game situation, hence no one ever reported it so far.

    What is happening in the display plugins is that we cache the latest used texture to prevent unnecessary texture binding. In your case you were only using one single texture, then deleting all the objects referencing that texture lead to unloading the texture (but not clearing the cached value!), then recreating an object right after that would re-load that same texture at the exact same memory address (that's the important bit and unlikely to happen in a real game/multi-texture situation) which lead the cache to think that we were still rendering the exact same texture and not triggering a rebind of it with OpenGL, thus leading to that white display.

    I've fixed all the non-deprecated plugins (latest svn version) for all supported platforms but haven't got the opportunity tested on iOS/Android. That being said I'm confident the fix was simple enough to work on those platforms too.

    Thanks for reporting that issue and let us know if you encounter any other problem! :)
Sign In or Register to comment.