Results 1 to 5 of 5

Thread: SetupAnimEntity for texture mapping

  1. #1

    Default SetupAnimEntity for texture mapping

    Entity* TmpE1 = CreateOverlayEntity(GetParent(), "testE1", TmpC, 64.0f, 64.0f);
    SetupAnimEntity(TmpE1, 4, 4, 0, 0);

    Entity* TmpE2 = CreateOverlayEntity(GetParent(), "testE2", TmpC, 0.0f, 0.0f);
    SetupAnimEntity(TmpE2, 2, 2, 0, 0);

    When I use this code first entity is mapped like second. I do not know whether the function is designed for such use. Maybe I need to share images on the parts?

  2. #2
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,343

    Default

    Hmm, TmpE2 should show a larger chunk of the image (1 of four squares instead of 1 of eight squared).

    This isn't happening? Can you show a screenshot of the bug, and also the original source image?
    Seth A. Robinson
    Robinson Technologies

  3. #3

    Default

    Ok, this is my sample graphic:



    Entity* TmpE1 = CreateOverlayEntity(GetParent(), "testE1", "interface/numbers.rttex", 0,0);
    SetupAnimEntity(TmpE1 , 4, 4, 0, 0);
    Entity* TmpE2 = CreateOverlayEntity(GetParent(), "testE2", "interface/numbers.rttex", 256,256);
    SetupAnimEntity(TmpE2 , 2, 2, 0, 0);

    When i use this code mapped entities look like this:


    When i change image in second entitiy first is mapped properly.
    Last edited by Yogi; 07-21-2011 at 12:54 PM.

  4. #4
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,343

    Default

    Thanks for the detailed bug report, very helpful.

    The problem is that Proton handles surfaces like this:

    • All surfaces with the same file name are shared internally with the same SurfaceAnim
    • Grid settings for how a surface is cut-up for an anim is saved in the SurfaceAnim, and not send it for the blit, like frameXY is.
    • Changing the grid settings breaks any previous grid settings set by other people sharing the Surface/SurfaceAnim


    I'll have to give this some thought on the best way to fix it. Possibly I'll just change it so OverlayComponents set the grid size every frame.

    For now, here is a work around - create a new surface for the second piece. This does waste extra texture memory for no reason though.

    Code:
    Entity* TmpE1 = CreateOverlayEntity(pGUIEnt, "testE1", "interface/numbers.rttex", 0,0);
    SetupAnimEntity(TmpE1 , 4, 4, 0, 0);
    
    //let's force the second instance to keep its own copy, so we won't overwrite its grid setup
    Entity* TmpE2 = CreateOverlayEntity(pGUIEnt, "testE2", "", 256,256);
    
    //get access to the overlay component inside the entity we just created above
    OverlayRenderComponent *pOverlay = (OverlayRenderComponent*)TmpE2->GetComponentByName("OverlayRender");
    
    //create a new surface manually
    SurfaceAnim *pCustomSurface = new SurfaceAnim;
    pCustomSurface->LoadFile("interface/numbers.rttex");
    
    //feed it into the SurfaceOverlay to use, and tell it to delete it when done with it
    pOverlay->SetSurface(pCustomSurface, true);
    SetupAnimEntity(TmpE2 , 2, 2, 0, 0); //now this will work on our custom surface without affecting the first one
    Seth A. Robinson
    Robinson Technologies

  5. #5
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,343

    Default

    An alternate fix would be to rename numbers.png to numbers2.png for the second instance.
    Seth A. Robinson
    Robinson Technologies

Similar Threads

  1. Get screen texture
    By Ockonal in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 06-20-2011, 01:00 AM
  2. Texture Coordinates
    By hmroz in forum Proton SDK
    Replies: 5
    Last Post: 04-11-2011, 12:58 PM
  3. Texture instead of gradient
    By Ockonal in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 12-25-2010, 08:18 AM
  4. New Texture 3D example
    By rombust in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 11-24-2009, 02:12 PM
  5. relationship between GC and Texture?
    By logixoul in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 07-07-2008, 07:17 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
  •