Ignore:
Timestamp:
Feb 21, 2011, 6:11:36 PM (10 years ago)
Author:
sam
Message:

Create the SdlApp class to avoid code duplication. Ensure USE_SDL is
tested wherever relevant.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tileset.cpp

    r673 r680  
    1414
    1515#include <cstdlib>
     16#include <cstdio>
    1617#include <cmath>
    1718
     
    2122#endif
    2223
    23 #include <SDL.h>
    24 #include <SDL_image.h>
     24#if defined USE_SDL
     25#   include <SDL.h>
     26#   include <SDL_image.h>
     27#endif
    2528
    2629#include "core.h"
     
    4144    float dilate, tx, ty;
    4245
     46#if defined USE_SDL
    4347    SDL_Surface *img;
     48#endif
    4449    GLuint texture;
    4550};
     
    5762
    5863    data->tiles = NULL;
     64#if defined USE_SDL
    5965    data->img = NULL;
     66#endif
    6067    data->texture = 0;
    6168
     69#if defined USE_SDL
    6270    for (char const *name = path; *name; name++)
    6371        if ((data->img = IMG_Load(name)))
     
    8795    }
    8896
     97    data->tx = (float)data->size.x / PotUp(data->img->w);
     98    data->ty = (float)data->size.y / PotUp(data->img->h);
     99#endif
     100
    89101    data->dilate = dilate;
    90102    data->ntiles = data->count.i * data->count.j;
    91     data->tx = (float)data->size.x / PotUp(data->img->w);
    92     data->ty = (float)data->size.y / PotUp(data->img->h);
    93103
    94104    drawgroup = DRAWGROUP_BEFORE;
     
    106116    Entity::TickDraw(deltams);
    107117
     118#if defined USE_SDL
    108119    if (IsDestroying())
    109120    {
     
    146157        data->img = NULL;
    147158    }
     159#endif
    148160}
    149161
     
    165177void TileSet::Bind()
    166178{
     179#if defined USE_SDL
    167180    if (!data->img)
    168181        glBindTexture(GL_TEXTURE_2D, data->texture);
     182#endif
    169183}
    170184
     
    180194    int dz = o ? data->size.y : 0;
    181195
     196#if defined USE_SDL
    182197    if (!data->img)
    183198    {
     
    221236    }
    222237    else
     238#endif
    223239    {
    224240        memset(vertex, 0, 3 * sizeof(float));
Note: See TracChangeset for help on using the changeset viewer.