Ignore:
Timestamp:
Jan 28, 2013, 2:23:57 PM (8 years ago)
Author:
sam
Message:

easymesh: interface the shiny shader with new Light objects.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scene.cpp

    r2277 r2289  
    6262    mat4 m_proj_matrix;
    6363
    64     Array<Tile> tiles;
     64    Array<Tile> m_tiles;
     65    Array<Light *> m_lights;
    6566
    6667    Shader *m_shader;
     
    114115        delete data->bufs[i];
    115116    data->bufs.Empty();
     117    data->m_lights.Empty();
    116118}
    117119
     
    147149    t.scale = scale;
    148150
    149     data->tiles.Push(t);
     151    data->m_tiles.Push(t);
     152}
     153
     154void Scene::AddLight(Light *l)
     155{
     156    data->m_lights.Push(l);
     157}
     158
     159Array<Light *> const &Scene::GetLights() const
     160{
     161    return data->m_lights;
    150162}
    151163
     
    153165{
    154166    /* Early exit if nothing needs to be rendered */
    155     if (!data->tiles.Count())
     167    if (!data->m_tiles.Count())
    156168        return;
    157169
     
    161173#if 0
    162174    // Randomise, then sort.
    163     for (int i = 0; i < data->tiles.Count(); i++)
     175    for (int i = 0; i < data->m_tiles.Count(); i++)
    164176    {
    165         Tile tmp = data->tiles[i];
    166         int j = rand() % data->tiles.Count();
    167         data->tiles[i] = data->tiles[j];
    168         data->tiles[j] = tmp;
     177        Tile tmp = data->m_tiles[i];
     178        int j = rand() % data->m_tiles.Count();
     179        data->m_tiles[i] = data->m_tiles[j];
     180        data->m_tiles[j] = tmp;
    169181    }
    170182#endif
    171     qsort(&data->tiles[0], data->tiles.Count(),
     183    qsort(&data->m_tiles[0], data->m_tiles.Count(),
    172184          sizeof(Tile), SceneData::Compare);
    173185
     
    220232#endif
    221233
    222     for (int buf = 0, i = 0, n; i < data->tiles.Count(); i = n, buf += 2)
     234    for (int buf = 0, i = 0, n; i < data->m_tiles.Count(); i = n, buf += 2)
    223235    {
    224236        /* Count how many quads will be needed */
    225         for (n = i + 1; n < data->tiles.Count(); n++)
    226             if (data->tiles[i].tileset != data->tiles[n].tileset)
     237        for (n = i + 1; n < data->m_tiles.Count(); n++)
     238            if (data->m_tiles[i].tileset != data->m_tiles[n].tileset)
    227239                break;
    228240
     
    238250        for (int j = i; j < n; j++)
    239251        {
    240             data->tiles[i].tileset->BlitTile(data->tiles[j].id,
    241                             data->tiles[j].pos, data->tiles[j].o,
    242                             data->tiles[j].scale,
     252            data->m_tiles[i].tileset->BlitTile(data->m_tiles[j].id,
     253                            data->m_tiles[j].pos, data->m_tiles[j].o,
     254                            data->m_tiles[j].scale,
    243255                            vertex + 18 * (j - i), texture + 12 * (j - i));
    244256        }
     
    248260
    249261        /* Bind texture */
    250         data->tiles[i].tileset->Bind();
     262        data->m_tiles[i].tileset->Bind();
    251263
    252264        /* Bind vertex and texture coordinate buffers */
     
    258270        data->m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, (n - i) * 6);
    259271        data->m_vdecl->Unbind();
    260         data->tiles[i].tileset->Unbind();
     272        data->m_tiles[i].tileset->Unbind();
    261273    }
    262274
    263     data->tiles.Empty();
     275    data->m_tiles.Empty();
    264276
    265277    data->m_shader->Unbind();
Note: See TracChangeset for help on using the changeset viewer.