Changeset 24 for trunk/src


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

Sort layers before rendering.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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.