0 Favourites

multiple objects sharing texture handles crash

This forum is currently in read-only mode.
  • i construct each instance of the same sprite uses the same texturehandle. in the current plug I'm developing, if I have more than one object getting it's texture from the same handle, it crashes? any idea why? I'll try looking through the runtime code to figure out how sprite pulls it off, but any help would be appreciated.

    I can't see why, but I'm fairly certain it's the problem. basically I have a line of code that copies the texture to a new handle each time a new object will use it. if i remove that code and make them both refer to the same handle it crashes

    also, if it helps with the answer, the objects need to load an unknown amount of new textures off of disk at runtime, and share them amongst eachother

  • At what point does it crash? TextureHandles are reference counted, which is taken care of for you when creating a new textureHandle. But when manually setting a texture to an existing textureHandle it appears that you need to manually increment the reference.

    http://www.google.com/codesearch#ri7jKR5oU44/Runtime/RenderLayer.cpp&q=AddTextureReference%20package:construct&type=cs&l=79

  • thank you rojo

    just recently changed something I can't seem to undo that made the problem worse. but when I debug.

    it seems to set the textures fine one time, for a new object,

    this is basically a modified sprite object that has localTex used for rendering instead of info.currenttexture

    also I just added the line at the top to increment reference. Not sure if that's how it's supposed to be done

    but it crashes on the highlighted line:

    pastebin.com/Hmqgzz3K

  • ok

    update. if I remove the line from the previous post it doesn't crash. but I really need to be able to generate a collision mask.

    while I wait for a reply, I'll try to search for some releasecollision mask or increment of that. thanks for your help so far though

    I'll post back if I figure it out before you do

    edit: also removed the increment texture thing and works the same, no crash unless I try to generate a collision mask:

    localTex = (TextureHandle)param;

    info.w=localTex->image_widthf;

    info.h=localTex->image_heightf;

    pRuntime->UpdateBoundingBox(this);

    this works fine with no crashes

  • There was a bug with GenerateCollisionMaskFromTexture() locking a texture region and not unlocking it. Is now in the SVN revision 283.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • thanks again. I pm'd you back about the updated runtimes. Also, if you could phrase what you did in a changelog friendly way I'll add it to the cc changelog

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)