Changeset 24


Ignore:
Timestamp:
Jul 1, 2010, 12:54:13 AM (10 years ago)
Author:
sam
Message:

Sort layers before rendering.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/maps/testmap.tmx

    r23 r24  
    44  <image source="../art/test/groundtest.png"/>
    55 </tileset>
    6  <layer name="Layer 1" width="32" height="32">
     6 <layer name="Layer 0" width="32" height="32">
    77  <data encoding="base64" compression="gzip">
    88   H4sIAAAAAAAAA+3QyQ2AMAxEUSuQAsJWQCD0XyITyWnBIPQPT5ZPY08xs/IBSSaZJfueA/MXWWWTKofsgTdU//3yzL43uV/oYMzkPUTl959P72DMFpgPAAAAAH/2ACvSWwAAEAAA
    99  </data>
    1010 </layer>
    11  <layer name="Layer 1.5" width="32" height="32">
     11 <layer name="Layer 1" width="32" height="32">
    1212  <data encoding="base64" compression="gzip">
    13    H4sIAAAAAAAAA+3TsQ0AIAhEUVZxBTZw/6WsaCg0JuBZ/DcAdwlghjDVBQ6i32jMuJld1cOL5nTkv7gJTx0697vLV+7BTdsj5//QQUX9jwAAAOizAOK0B+4AEAAA
    14   </data>
    15  </layer>
    16  <layer name="Layer perso" width="32" height="32">
    17   <data encoding="base64" compression="gzip">
    18    H4sIAAAAAAAAA+3BAQkAAAACoD71/1s/Qm0AAACAdwMtfmIFABAAAA==
     13   H4sIAAAAAAAAA+2SzQqEMAyE62nRFxD25snq0cv+3Hz/lzLBBoagyEK6C8t8MGAKdoZpUiLG+usAF1i+oaLHJ3dH5ViC7on0v4va9J2dWFwG7fUlyqKuKB/8p+dtoD9meIimolw0OW89mwP8LQN+30Rv0Zj2LmY3W55nJX+czd/PmqUP8vdZvL/fhajez/wR3AVTVO+Ivrn12YD0fCyyHajRO4L+hBBCCCH/xAZZWJEpABAAAA==
    1914  </data>
    2015 </layer>
    2116 <layer name="Layer 2" width="32" height="32">
    2217  <data encoding="base64" compression="gzip">
    23    H4sIAAAAAAAAA+2SSwqAMAwF60r0AoIX6Gfnyur9D2aCLYTQKkigRTIwi0blxTTG9MPWuoEXeu/vj7Sa+QpOjbKRA3TgnHSFd7Au1SP/3x30SZf0LBtrQSgf8yI5j+AJWnPPIrBz7icaGTBvqTzL+fxsH775Qm3nSrsgNXcKvwNa90ypuVPoHQxErNtk3gHJuZeg+YqiKIqiKH/iAnTxBh8AEAAA
     18   H4sIAAAAAAAAA+3RMQ6AIBAEQDrEDxj5AFpSafz/w9hLuITOCo7oTrItt1mcm0e2LvBi9n5fpJtHZK0JBj0u5ESOmtEdPJKaHvfg+2pHHmTr8Lb8scXfKtnWalch2y4/vk9ERERE/RUNp14bABAAAA==
    2419  </data>
    2520 </layer>
    2621 <layer name="Layer 3" width="32" height="32">
    2722  <data encoding="base64" compression="gzip">
    28    H4sIAAAAAAAAA+3RsQkAIBAEQTPtQKzAHuy/MN8elDeYgc0PrhTgdzWa2SPCiFbUs4dw3fm2ZY8AAOCpDZX+fl8AEAAA
     23   H4sIAAAAAAAAA+3SMQ0AIAxFwVrBAg7wb4oFGhw0DXfJT9c3NAJ6mGerOoQ0qgM+cX8/nlvRAABAbxsfaCDKABAAAA==
    2924  </data>
    3025 </layer>
    3126 <layer name="Layer 4" width="32" height="32">
    3227  <data encoding="base64" compression="gzip">
    33    H4sIAAAAAAAAA+3RwQkAIAxDUY/qBjqBTqD7T2YLHlxAIvIf5JyShgC8r1ryThL0D0u3tB3FDecdU9R/k/9YtavzbZW7FksU9gMAAOB/C0yy2/0AEAAA
    34   </data>
    35  </layer>
    36  <layer name="Layer 4.5" width="32" height="32">
    37   <data encoding="base64" compression="gzip">
    38    H4sIAAAAAAAAA2NgGAWjgDRgOED2GkGx4wDZPwowgeJAO2CEAFjaZ0CiB8INo2AUjIJRMApGwSgYBaNgaAMAylMPngAQAAA=
     28   H4sIAAAAAAAAA+3OMQEAAAwCICutf7ll8PKBBCTQuXUAAACA2gPEOzOTABAAAA==
    3929  </data>
    4030 </layer>
  • trunk/src/test-map.cpp

    r22 r24  
    5555    int playerx, playery;
    5656    SDL_GetMouseState(&playerx, &playery);
    57     tiler->AddTile(50, playerx, playery, nlayers);
     57    tiler->AddTile(50, playerx, playery, 1);
    5858
    5959    tiler->Render();
  • trunk/src/tiler.cpp

    r22 r24  
    2828
    2929private:
     30    static int Compare(void const *p1, void const *p2)
     31    {
     32        int const *n1 = (int const *)p1;
     33        int const *n2 = (int const *)p2;
     34
     35        return n1[2] + 32 * n1[3] - (n2[2] + 32 * n2[3]);
     36    }
     37
    3038    int *tiles;
    3139    int ntiles;
     
    9199void Tiler::Render()
    92100{
     101    /* Sort tiles */
     102    qsort(data->tiles, data->ntiles, 4 * sizeof(int), TilerData::Compare);
     103
    93104    /* Texture coord buffer */
    94105    float uvs[8 * data->ntiles];
Note: See TracChangeset for help on using the changeset viewer.