Changeset 664


Ignore:
Timestamp:
Feb 18, 2011, 1:09:28 AM (12 years ago)
Author:
sam
Message:

Get rid of float3, float4, int3 etc. in favour of GLSL types.

Location:
trunk
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/deushax/debugsprite.cpp

    r633 r664  
    2525    Game *game;
    2626    int tiler;
    27     float3 pos;
     27    vec3 pos;
    2828};
    2929
     
    3939    data->tiler = Tiler::Register("art/test/character-dress.png",
    4040                                  32, 0, sqrtf(2));
    41     data->pos = float3(320, 206, 0);
     41    data->pos = vec3(320, 206, 0);
    4242}
    4343
     
    4646    Entity::TickGame(deltams);
    4747
    48     float3 move = deltams * (float3)Input::GetAxis(0);
    49     data->pos = data->pos + move * float3(0.1f * sqrtf(2.0f), .1f, 0.1f);
     48    vec3 move = deltams * (vec3)Input::GetAxis(0);
     49    data->pos = data->pos + move * vec3(0.1f * sqrtf(2.0f), .1f, 0.1f);
    5050}
    5151
     
    5454    Entity::TickDraw(deltams);
    5555
    56     int3 pos = (int3)data->pos;
     56    vec3i pos = (vec3i)data->pos;
    5757
    5858    Scene::GetDefault()->AddTile((data->tiler << 16) | 31,
  • trunk/monsterz/board.cpp

    r639 r664  
    3737    Board::game_t game;
    3838
    39     int2 dim, size;
     39    vec2i dim, size;
    4040    int minnpieces, npieces, maxnpieces;
    4141
     
    5353    struct Pair grabbed;
    5454    int nmoves;
    55     int2 src_cell, dst_cell;
     55    vec2i src_cell, dst_cell;
    5656
    5757    /* Fusion */
     
    6666    Thumbs *thumbs;
    6767
    68     int2 oldmouse;
    69     int3 oldbuttons;
     68    vec2i oldmouse;
     69    vec3i oldbuttons;
    7070    float whipdelay;
    7171
     
    8484 */
    8585
    86 Board::Board(game_t game, int2 dim, int minnpieces, int maxnpieces)
     86Board::Board(game_t game, vec2i dim, int minnpieces, int maxnpieces)
    8787  : data(new BoardData())
    8888{
     
    109109    data->whip = Sampler::Register(WAV_WHIP);
    110110
    111     data->emitter = new Emitter(data->tiles, float3(0, -0.0006f, 0));
     111    data->emitter = new Emitter(data->tiles, vec3(0, -0.0006f, 0));
    112112    Ticker::Ref(data->emitter);
    113113
     
    131131        data->current[1].id = GetRandomId();
    132132        data->current[0].piece = new Piece(Piece::PIECE_FUSION,
    133                                            data->emitter, int2(3, 8),
     133                                           data->emitter, vec2i(3, 8),
    134134                                           data->current[0].id);
    135135        data->current[1].piece = new Piece(Piece::PIECE_FUSION,
    136                                            data->emitter, int2(4, 8),
     136                                           data->emitter, vec2i(4, 8),
    137137                                           data->current[1].id);
    138138        Ticker::Ref(data->current[0].piece);
    139139        Ticker::Ref(data->current[1].piece);
    140         data->current[0].piece->SetPos(int2(3, 7) * data->size);
    141         data->current[1].piece->SetPos(int2(4, 7) * data->size);
     140        data->current[0].piece->SetPos(vec2i(3, 7) * data->size);
     141        data->current[1].piece->SetPos(vec2i(4, 7) * data->size);
    142142
    143143        data->next[0] = GetRandomId();
     
    155155    data->scoretext = new Text(NULL, "monsterz/gfx/font2.png");
    156156    data->scoretext->SetAlign(Text::ALIGN_RIGHT);
    157     data->scoretext->SetPos(int3(624, 432, 20));
     157    data->scoretext->SetPos(vec3i(624, 432, 20));
    158158    Ticker::Ref(data->scoretext);
    159159    data->score = 0;
    160160
    161     position = int3(24, 72, 1);
     161    position = vec3i(24, 72, 1);
    162162    bbox[0] = position;
    163     bbox[1] = bbox[0] + int3(384, 384, 0);
     163    bbox[1] = bbox[0] + vec3i(384, 384, 0);
    164164
    165165    Input::TrackMouse(this);
     
    170170    Entity::TickGame(deltams);
    171171
    172     int3 buttons = Input::GetMouseButtons();
     172    vec3i buttons = Input::GetMouseButtons();
    173173
    174174    /* Do not whip too often, the sound may become annoying */
     
    196196        if (buttons[0] && !data->oldbuttons[0] && mousepos.x != -1)
    197197        {
    198             int2 cell = mousepos / data->size;
    199             if (data->pairs[cell.x][cell.y].piece->Grab(int2(0, 0)))
     198            vec2i cell = mousepos / data->size;
     199            if (data->pairs[cell.x][cell.y].piece->Grab(vec2i(0, 0)))
    200200            {
    201201                Sampler::PlaySample(data->click);
    202202                data->grabbed = data->pairs[cell.x][cell.y];
    203203                data->src_cell = mousepos / data->size;
    204                 data->dst_cell = int2(-1);
     204                data->dst_cell = vec2i(-1);
    205205                data->state = BoardData::HUNT_GRAB;
    206206            }
     
    215215            /* Mouse is still in the window, keep grabbing */
    216216            data->grabbed.piece->Grab(mousepos - data->oldmouse);
    217             int2 cur_pos = data->grabbed.piece->GetPos();
    218             int2 cur_cell = (cur_pos + data->size / 2) / data->size;
     217            vec2i cur_pos = data->grabbed.piece->GetPos();
     218            vec2i cur_cell = (cur_pos + data->size / 2) / data->size;
    219219            if (cur_cell.i < 0 || cur_cell.i >= data->dim.i
    220220                 || cur_cell.j < 0 || cur_cell.j >= data->dim.j
    221221                 || (cur_pos - cur_cell * data->size).sqlen() > data->size.sqlen() / 8
    222222                 || (cur_cell - data->src_cell).sqlen() != 1)
    223                 cur_cell = int2(-1);
     223                cur_cell = vec2i(-1);
    224224            /* If potential target changed, update our cache. */
    225225            if (cur_cell != data->dst_cell)
     
    230230                    data->whipdelay = DELAY_WHIP;
    231231                }
    232                 if (data->dst_cell != int2(-1))
     232                if (data->dst_cell != vec2i(-1))
    233233                    data->pairs[data->dst_cell.i]
    234234                               [data->dst_cell.j].piece->Ungrab(data->dst_cell * data->size);
    235                 if (cur_cell != int2(-1))
     235                if (cur_cell != vec2i(-1))
    236236                    data->pairs[cur_cell.i]
    237237                               [cur_cell.j].piece->Ungrab(data->src_cell * data->size);
     
    245245            /* Mouse released, or exited window, or dragged too far. */
    246246            data->grabbed.piece->Ungrab(data->grabbed.piece->GetCell() * data->size);
    247             if (data->dst_cell != int2(-1))
     247            if (data->dst_cell != vec2i(-1))
    248248                Switch(data->src_cell, data->dst_cell);
    249249            data->state = BoardData::HUNT_IDLE;
     
    287287            if (data->rotation)
    288288            {
    289                 data->current[0].piece->SetCell(int2(column, 6));
    290                 data->current[1].piece->SetCell(int2(column, 7));
     289                data->current[0].piece->SetCell(vec2i(column, 6));
     290                data->current[1].piece->SetCell(vec2i(column, 7));
    291291            }
    292292            else
    293293            {
    294                 data->current[0].piece->SetCell(int2(column, 7));
    295                 data->current[1].piece->SetCell(int2(column + 1, 7));
     294                data->current[0].piece->SetCell(vec2i(column, 7));
     295                data->current[1].piece->SetCell(vec2i(column + 1, 7));
    296296            }
    297297
     
    308308                    if (data->pairs[i][j].id == 0)
    309309                    {
    310                         data->current[t].piece->SetCell(int2(i, j));
    311                         data->current[t].piece->Move(int2(i, j) * data->size);
     310                        data->current[t].piece->SetCell(vec2i(i, j));
     311                        data->current[t].piece->Move(vec2i(i, j) * data->size);
    312312                        data->pairs[i][j] = data->current[t];
    313313                        data->thumbs->AddCount(data->current[t].id, 1);
     
    319319            data->current[1].id = data->next[1];
    320320            data->current[0].piece = new Piece(Piece::PIECE_FUSION,
    321                                                data->emitter, int2(3, 7),
     321                                               data->emitter, vec2i(3, 7),
    322322                                               data->current[0].id);
    323323            data->current[1].piece = new Piece(Piece::PIECE_FUSION,
    324                                                data->emitter, int2(4, 7),
     324                                               data->emitter, vec2i(4, 7),
    325325                                               data->current[1].id);
    326326            Ticker::Ref(data->current[0].piece);
    327327            Ticker::Ref(data->current[1].piece);
    328             data->current[0].piece->SetPos(int2(3, 8) * data->size);
    329             data->current[1].piece->SetPos(int2(4, 8) * data->size);
     328            data->current[0].piece->SetPos(vec2i(3, 8) * data->size);
     329            data->current[1].piece->SetPos(vec2i(4, 8) * data->size);
    330330            data->current[0].piece->Move(data->current[0].piece->GetCell() * data->size);
    331331            data->current[1].piece->Move(data->current[1].piece->GetCell() * data->size);
     
    382382        for (int i = 0; i < data->dim.i; i++)
    383383        {
    384             int2 newpos = int2(i, j + data->dim.j) * data->size;
     384            vec2i newpos = vec2i(i, j + data->dim.j) * data->size;
    385385            int id = data->pairs[i][j].id;
    386386            data->pairs[i][j].piece = new Piece(Piece::PIECE_HUNT,
    387                                                 data->emitter, int2(i, j), id);
     387                                                data->emitter, vec2i(i, j), id);
    388388            data->pairs[i][j].piece->SetPos(newpos);
    389             data->pairs[i][j].piece->Move(int2(i, j) * data->size);
     389            data->pairs[i][j].piece->Move(vec2i(i, j) * data->size);
    390390            if (j)
    391391                data->pairs[i][j].piece->SetBelow(data->pairs[i][j - 1].piece);
     
    394394}
    395395
    396 void Board::Switch(int2 cell_a, int2 cell_b)
     396void Board::Switch(vec2i cell_a, vec2i cell_b)
    397397{
    398398    BoardData::Pair a = data->pairs[cell_a.i][cell_a.j];
     
    473473                int id = 1 + rand() % data->npieces;
    474474                data->pairs[i][j].id = id;
    475                 data->pairs[i][j].piece = new Piece(Piece::PIECE_HUNT, data->emitter, int2(i, j), id);
     475                data->pairs[i][j].piece = new Piece(Piece::PIECE_HUNT, data->emitter, vec2i(i, j), id);
    476476                data->pairs[i][j].piece->SetBelow(old->GetBelow());
    477477                data->pairs[i][j].piece->SetAbove(old->GetAbove());
     
    488488                {
    489489                    data->pairs[i][j2 - 1] = data->pairs[i][j2];
    490                     data->pairs[i][j2 - 1].piece->SetCell(int2(i, j2 - 1));
    491                     data->pairs[i][j2 - 1].piece->Move(int2(i, j2 - 1) * data->size);
     490                    data->pairs[i][j2 - 1].piece->SetCell(vec2i(i, j2 - 1));
     491                    data->pairs[i][j2 - 1].piece->Move(vec2i(i, j2 - 1) * data->size);
    492492                    list[i][j2 - 1] = list[i][j2];
    493493                }
     
    495495                /* Spawn a new piece above all the others and attach it to
    496496                 * the board. */
    497                 int2 newpos = int2(i * data->size.x,
    498                                    below->GetPos().y + data->size.y);
    499                 int2 newcell = int2(i, data->dim.j - 1);
     497                vec2i newpos = vec2i(i * data->size.x,
     498                                     below->GetPos().y + data->size.y);
     499                vec2i newcell = vec2i(i, data->dim.j - 1);
    500500                int id = 1 + rand() % data->npieces;
    501501                Piece *tmp = new Piece(Piece::PIECE_HUNT, data->emitter,
     
    735735        }
    736736        data->pairs[i][j].piece = new Piece(Piece::PIECE_FUSION,
    737                                             data->emitter, int2(i, j),
     737                                            data->emitter, vec2i(i, j),
    738738                                            data->pairs[i][j].id);
    739739        Ticker::Ref(data->pairs[i][j].piece);
    740         data->pairs[i][j].piece->SetPos(int2(i, j) * data->size);
     740        data->pairs[i][j].piece->SetPos(vec2i(i, j) * data->size);
    741741        data->thumbs->AddCount(data->pairs[i][j].id, 1);
    742742        count[list[i][j]] = 0;
     
    755755            if (data->pairs[i][j2 - 1].id)
    756756            {
    757                 data->pairs[i][j2 - 1].piece->SetCell(int2(i, j2 - 1));
    758                 data->pairs[i][j2 - 1].piece->Move(int2(i, j2 - 1) * data->size);
     757                data->pairs[i][j2 - 1].piece->SetCell(vec2i(i, j2 - 1));
     758                data->pairs[i][j2 - 1].piece->Move(vec2i(i, j2 - 1) * data->size);
    759759            }
    760760            list[i][j2 - 1] = list[i][j2];
     
    771771int Board::TagNeighbours(int list[MAX_PIECES][MAX_PIECES], int i, int j)
    772772{
    773     int2 const off[] = { int2(-1, 0), int2(1, 0), int2(0, -1), int2(0, 1) };
     773    vec2i const off[] = { vec2i(-1, 0), vec2i(1, 0), vec2i(0, -1), vec2i(0, 1) };
    774774
    775775    int count = 1;
  • trunk/monsterz/board.h

    r423 r664  
    3131    game_t;
    3232
    33     Board(game_t, int2 dim, int minnpieces, int maxnpieces);
     33    Board(game_t, vec2i dim, int minnpieces, int maxnpieces);
    3434    virtual ~Board();
    3535
     
    4242    /* Hunt mode */
    4343    void Fill();
    44     void Switch(int2 cell_a, int2 cell_b);
     44    void Switch(vec2i cell_a, vec2i cell_b);
    4545    int ListMashes(int list[MAX_WIDTH][MAX_HEIGHT]);
    4646    int ListMoves(int list[MAX_WIDTH][MAX_HEIGHT]);
  • trunk/monsterz/interface.cpp

    r639 r664  
    5555    data->title = NULL;
    5656    data->board = NULL;
    57     data->screen = Tiler::Register(PNG_BACKGROUND, int2(640, 480), 0, 1.0f);
     57    data->screen = Tiler::Register(PNG_BACKGROUND, vec2i(640, 480), 0, 1.0f);
    5858    data->tiles = Tiler::Register(PNG_TILES, 48, 0, 1.0f);
    5959    data->state = InterfaceData::INIT;
    6060
    61     position = int3(0, 0, 1);
     61    position = vec3i(0, 0, 1);
    6262    bbox[0] = position;
    63     bbox[1] = bbox[0] + int3(640, 480, 0);
     63    bbox[1] = bbox[0] + vec3i(640, 480, 0);
    6464}
    6565
     
    8181            data->title = NULL;
    8282            if (rand() & 1)
    83                 data->board = new Board(Board::GAME_FUSION, int2(6, 8), 3, 12);
     83                data->board = new Board(Board::GAME_FUSION, vec2i(6, 8), 3, 12);
    8484            else
    85                 data->board = new Board(Board::GAME_HUNT, int2(8, 8), 8, 8);
     85                data->board = new Board(Board::GAME_HUNT, vec2i(8, 8), 8, 8);
    8686            Ticker::Ref(data->board);
    8787            data->state = InterfaceData::GAME;
     
    9797    WorldEntity::TickDraw(deltams);
    9898
    99     int2 mouse = Input::GetMousePos();
     99    vec2i mouse = Input::GetMousePos();
    100100
    101101    Scene::GetDefault()->AddTile((data->screen << 16) | 0, 0, 0, 10, 0);
     
    103103    if (mouse.x >= 0 && mouse.y >= 0)
    104104    {
    105         int2 m = mouse + int2(-6, 6 - 48);
     105        vec2i m = mouse + vec2i(-6, 6 - 48);
    106106        Scene::GetDefault()->AddTile((data->tiles << 16) | 22, m.x, m.y, 30, 0);
    107107    }
  • trunk/monsterz/mash.cpp

    r384 r664  
    3333    int duh, pop;
    3434    Piece *pieces[MAX_WIDTH * MAX_HEIGHT];
    35     int2 cells[MAX_WIDTH * MAX_HEIGHT];
     35    vec2i cells[MAX_WIDTH * MAX_HEIGHT];
    3636    int npieces;
    3737    float timer;
     
    8787        {
    8888            /* If piece is still too high, don't start the animation */
    89             int2 shift = data->pieces[n]->GetShift();
     89            vec2i shift = data->pieces[n]->GetShift();
    9090            if (shift.y > 2 || abs(shift.x) > 2)
    9191                allready = 0;
  • trunk/monsterz/piece.cpp

    r633 r664  
    3434    Emitter *emitter;
    3535    Piece *above, *below;
    36     int2 size, cell, pos, src, dst;
     36    vec2i size, cell, pos, src, dst;
    3737    int id;
    3838    float speed, timer, blink, idle;
     
    5757 */
    5858
    59 Piece::Piece(piece_t piece, Emitter *emitter, int2 cell, int id)
     59Piece::Piece(piece_t piece, Emitter *emitter, vec2i cell, int id)
    6060  : data(new PieceData())
    6161{
     
    9696}
    9797
    98 void Piece::SetCell(int2 cell)
     98void Piece::SetCell(vec2i cell)
    9999{
    100100    data->cell = cell;
    101101}
    102102
    103 int2 Piece::GetCell() const
     103vec2i Piece::GetCell() const
    104104{
    105105    return data->cell;
    106106}
    107107
    108 void Piece::SetPos(int2 pos)
     108void Piece::SetPos(vec2i pos)
    109109{
    110110    data->pos = pos;
    111111}
    112112
    113 int2 Piece::GetPos() const
     113vec2i Piece::GetPos() const
    114114{
    115115    return data->pos;
    116116}
    117117
    118 int2 Piece::GetSize() const
     118vec2i Piece::GetSize() const
    119119{
    120120    return data->size;
    121121}
    122122
    123 int2 Piece::GetShift() const
     123vec2i Piece::GetShift() const
    124124{
    125125    return data->pos - data->cell * data->size;
     
    197197}
    198198
    199 int Piece::Grab(int2 dir)
     199int Piece::Grab(vec2i dir)
    200200{
    201201    switch (data->state)
     
    219219}
    220220
    221 int Piece::Ungrab(int2 pos)
     221int Piece::Ungrab(vec2i pos)
    222222{
    223223    switch (data->state)
     
    239239}
    240240
    241 int Piece::Move(int2 pos)
     241int Piece::Move(vec2i pos)
    242242{
    243243    switch (data->state)
     
    289289    {
    290290        data->timer += deltams;
    291         int2 trip = data->dst - data->src;
     291        vec2i trip = data->dst - data->src;
    292292        float moving_time = trip.len() / data->speed;
    293293        float t = moving_time ? data->timer / moving_time : 1.0f;
     
    315315        if (data->timer < 0.0f)
    316316        {
    317             float3 pos(data->pos.x + 24, data->pos.y + 72, 5);
     317            vec3 pos(data->pos.x + 24, data->pos.y + 72, 5);
    318318            int start = data->id + 12;
    319319            int stop = data->id + 15;
     
    322322                float angle = RandF(-1.2f, 1.2f);
    323323                float speed = RandF(0.3f, 0.5f);
    324                 float3 vel(speed * sinf(angle), speed * cosf(angle), 0.0f);
     324                vec3 vel(speed * sinf(angle), speed * cosf(angle), 0.0f);
    325325                data->emitter->AddParticle(id, pos, vel);
    326326            }
  • trunk/monsterz/piece.h

    r419 r664  
    3131    piece_t;
    3232
    33     Piece(piece_t, Emitter *emitter, int2 cell, int id);
     33    Piece(piece_t, Emitter *emitter, vec2i cell, int id);
    3434    virtual ~Piece();
    3535
    3636    virtual char const *GetName();
    3737
    38     void SetCell(int2 cell);
    39     int2 GetCell() const;
    40     void SetPos(int2 pos);
    41     int2 GetPos() const;
     38    void SetCell(vec2i cell);
     39    vec2i GetCell() const;
     40    void SetPos(vec2i pos);
     41    vec2i GetPos() const;
    4242
    43     int2 GetSize() const;
    44     int2 GetShift() const;
     43    vec2i GetSize() const;
     44    vec2i GetShift() const;
    4545
    4646    void SetAbove(Piece *below);
     
    5252
    5353    int Pop();
    54     int Grab(int2 dir);
    55     int Ungrab(int2 pos);
    56     int Move(int2 pos);
     54    int Grab(vec2i dir);
     55    int Ungrab(vec2i pos);
     56    int Move(vec2i pos);
    5757
    5858protected:
  • trunk/monsterz/thumbs.cpp

    r639 r664  
    5151
    5252#if 0
    53     position = int3(24, 72, 1);
     53    position = vec3i(24, 72, 1);
    5454    bbox[0] = position;
    55     bbox[1] = bbox[0] + int3(384, 384, 0);
     55    bbox[1] = bbox[0] + vec3i(384, 384, 0);
    5656#endif
    5757}
     
    7171    for (int n = 0; n < data->npieces; n++)
    7272    {
    73         int2 p = int2(459, 372 - 27 * n);
     73        vec2i p = vec2i(459, 372 - 27 * n);
    7474        Scene::GetDefault()->AddTile((data->icons << 16) | n, p.x, p.y, 11, 0);
    7575    }
     
    8686        data->text[n] = new Text(NULL, "monsterz/gfx/font1.png");
    8787        Ticker::Ref(data->text[n]);
    88         int3 p = int3(492, 374 - 27 * n, 20);
     88        vec3i p = vec3i(492, 374 - 27 * n, 20);
    8989        data->text[n]->SetPos(p);
    9090    }
  • trunk/monsterz/title.cpp

    r633 r664  
    5858    period, nextperiod;
    5959
    60     float2 cloudpos[5];
    61     float2 cloudspeed[5];
     60    vec2 cloudpos[5];
     61    vec2 cloudspeed[5];
    6262
    6363    int eagley;
     
    6767};
    6868
    69 static int2 const animsize[] =
    70 {
    71     int2(384, 384),
    72     int2(284, 81),
    73     int2(38, 146),
    74     int2(29, 137),
    75     int2(284, 82),
    76     int2(384, 384),
    77 };
    78 
    79 static int2 const animpos[] =
    80 {
    81     int2(0, 0),
    82     int2(65, 255),
    83     int2(239, 168),
    84     int2(248, 168),
    85     int2(63, 255),
    86     int2(0, 0),
    87 };
    88 
    89 static int2 const eventsize[] =
    90 {
    91     int2(143, 16),
    92     int2(68, 49),
    93     int2(17, 29),
    94     int2(50, 80),
    95     int2(237, 238),
    96     int2(59, 53),
    97     int2(140, 15),
    98 };
    99 
    100 static int2 const eventpos[] =
    101 {
    102     int2(0, 322),
    103     int2(316, 286),
    104     int2(246, 245),
    105     int2(279, 173),
    106     int2(42, 101),
    107     int2(231, 154),
    108     int2(0, 322),
     69static vec2i const animsize[] =
     70{
     71    vec2i(384, 384),
     72    vec2i(284, 81),
     73    vec2i(38, 146),
     74    vec2i(29, 137),
     75    vec2i(284, 82),
     76    vec2i(384, 384),
     77};
     78
     79static vec2i const animpos[] =
     80{
     81    vec2i(0, 0),
     82    vec2i(65, 255),
     83    vec2i(239, 168),
     84    vec2i(248, 168),
     85    vec2i(63, 255),
     86    vec2i(0, 0),
     87};
     88
     89static vec2i const eventsize[] =
     90{
     91    vec2i(143, 16),
     92    vec2i(68, 49),
     93    vec2i(17, 29),
     94    vec2i(50, 80),
     95    vec2i(237, 238),
     96    vec2i(59, 53),
     97    vec2i(140, 15),
     98};
     99
     100static vec2i const eventpos[] =
     101{
     102    vec2i(0, 322),
     103    vec2i(316, 286),
     104    vec2i(246, 245),
     105    vec2i(279, 173),
     106    vec2i(42, 101),
     107    vec2i(231, 154),
     108    vec2i(0, 322),
    109109};
    110110
     
    118118    srand(rand() ^ time(NULL));
    119119
    120     data->logo = Tiler::Register(PNG_LOGO, int2(380, 181), 0, 1.0f);
     120    data->logo = Tiler::Register(PNG_LOGO, vec2i(380, 181), 0, 1.0f);
    121121    data->title = Tiler::Register(PNG_TITLE, 384, 0, 1.0f);
    122     data->stars = Tiler::Register(PNG_STARS, int2(384, 144), 0, 1.0f);
    123     data->clouds = Tiler::Register(PNG_CLOUDS, int2(160, 32), 0, 1.0f);
     122    data->stars = Tiler::Register(PNG_STARS, vec2i(384, 144), 0, 1.0f);
     123    data->clouds = Tiler::Register(PNG_CLOUDS, vec2i(160, 32), 0, 1.0f);
    124124    data->eagle = Tiler::Register(PNG_EAGLE, 16, 0, 1.0f);
    125125    for (int n = 0; n < 6; n++)
     
    137137    for (int n = 0; n < 5; n++)
    138138    {
    139         data->cloudpos[n] = float2(RandF(384), RandF(130, 190));
     139        data->cloudpos[n] = vec2(RandF(384), RandF(130, 190));
    140140        data->cloudspeed[n] = RandF(-0.01f, 0.01f);
    141141    }
     
    143143    data->eagley = 140 + rand() % 40;
    144144
    145     position = int3(24, 72, 1);
     145    position = vec3i(24, 72, 1);
    146146    bbox[0] = position;
    147     bbox[1] = bbox[0] + int3(384, 384, 0);
     147    bbox[1] = bbox[0] + vec3i(384, 384, 0);
    148148
    149149    Input::TrackMouse(this);
     
    310310    int tiler = 0;
    311311    int id = 0;
    312     int2 pos;
     312    vec2i pos;
    313313
    314314    switch (data->state)
  • trunk/src/debugfps.cpp

    r646 r664  
    4141    {
    4242        data->lines[i] = new Text(NULL, "gfx/font/ascii.png");
    43         data->lines[i]->SetPos(int3(x, y + (i ? 8 : 0) + 16 * i, 0));
     43        data->lines[i]->SetPos(vec3i(x, y + (i ? 8 : 0) + 16 * i, 0));
    4444        Ticker::Ref(data->lines[i]);
    4545    }
    4646#else
    4747    data->lines[0] = new Text(NULL, "gfx/font/ascii.png");
    48     data->lines[0]->SetPos(int3(x, y, 100));
     48    data->lines[0]->SetPos(vec3i(x, y, 100));
    4949    Ticker::Ref(data->lines[0]);
    5050#endif
  • trunk/src/emitter.cpp

    r298 r664  
    3030private:
    3131    int tiler;
    32     float3 gravity;
     32    vec3 gravity;
    3333    int particles[MAX_PARTICLES];
    34     float3 positions[MAX_PARTICLES];
    35     float3 velocities[MAX_PARTICLES];
     34    vec3 positions[MAX_PARTICLES];
     35    vec3 velocities[MAX_PARTICLES];
    3636    int nparticles;
    3737};
     
    4141 */
    4242
    43 Emitter::Emitter(int tiler, float3 gravity)
     43Emitter::Emitter(int tiler, vec3 gravity)
    4444  : data(new EmitterData())
    4545{
     
    7878}
    7979
    80 void Emitter::AddParticle(int id, float3 pos, float3 vel)
     80void Emitter::AddParticle(int id, vec3 pos, vec3 vel)
    8181{
    8282    if (data->nparticles >= EmitterData::MAX_PARTICLES)
  • trunk/src/emitter.h

    r294 r664  
    2424{
    2525public:
    26     Emitter(int tiler, float3 gravity);
     26    Emitter(int tiler, vec3 gravity);
    2727    virtual ~Emitter();
    2828
    29     void AddParticle(int id, float3 pos, float3 vel);
     29    void AddParticle(int id, vec3 pos, vec3 vel);
    3030
    3131protected:
  • trunk/src/font.cpp

    r639 r664  
    2929    char *name;
    3030    int tiler;
    31     int2 size;
     31    vec2i size;
    3232};
    3333
     
    6565}
    6666
    67 void Font::Print(int3 pos, char const *str)
     67void Font::Print(vec3i pos, char const *str)
    6868{
    6969    Scene *scene = Scene::GetDefault();
     
    8181}
    8282
    83 int2 Font::GetSize() const
     83vec2i Font::GetSize() const
    8484{
    8585    return data->size;
  • trunk/src/font.h

    r639 r664  
    3434public:
    3535    /* New methods */
    36     void Print(int3 pos, char const *str);
    37     int2 GetSize() const;
     36    void Print(vec3i pos, char const *str);
     37    vec2i GetSize() const;
    3838
    3939private:
  • trunk/src/input.cpp

    r339 r664  
    3838
    3939private:
    40     int2 mouse;
    41     int3 buttons;
     40    vec2i mouse;
     41    vec3i buttons;
    4242
    4343    static int const MAX_ENTITIES = 100;
     
    5454 */
    5555
    56 float2 Input::GetAxis(int axis)
     56vec2 Input::GetAxis(int axis)
    5757{
    5858    float invsqrt2 = sqrtf(0.5f);
    59     float2 f;
     59    vec2 f;
    6060
    6161    /* Simulate a joystick using the keyboard. This SDL call is free. */
     
    7171}
    7272
    73 int2 Input::GetMousePos()
     73vec2i Input::GetMousePos()
    7474{
    7575    return data->mouse;
    7676}
    7777
    78 int3 Input::GetMouseButtons()
     78vec3i Input::GetMouseButtons()
    7979{
    8080    return data->buttons;
     
    102102}
    103103
    104 void Input::SetMousePos(int2 coord)
     104void Input::SetMousePos(vec2i coord)
    105105{
    106106    data->mouse = coord;
     
    124124        if (data->entities[n] == best)
    125125        {
    126             data->entities[n]->mousepos = (int2)((int3)coord - best->bbox[0]);
     126            data->entities[n]->mousepos = (vec2i)((vec3i)coord - best->bbox[0]);
    127127            if (best != data->lastfocus)
    128128                data->entities[n]->pressed = data->buttons;
     
    132132        else
    133133        {
    134             data->entities[n]->mousepos = int2(-1);
     134            data->entities[n]->mousepos = vec2i(-1);
    135135            /* FIXME */
    136136            data->entities[n]->released = 0;
  • trunk/src/input.h

    r329 r664  
    2525public:
    2626    /* These methods are general queries */
    27     static float2 GetAxis(int axis);
    28     static int2 GetMousePos();
    29     static int3 GetMouseButtons();
     27    static vec2 GetAxis(int axis);
     28    static vec2i GetMousePos();
     29    static vec3i GetMouseButtons();
    3030
    3131    /* Entities can subscribe to events */
     
    3434
    3535    /* These methods are called by the underlying input listeners */
    36     static void SetMousePos(int2 coord);
     36    static void SetMousePos(vec2i coord);
    3737    static void SetMouseButton(int index);
    3838    static void UnsetMouseButton(int index);
  • trunk/src/matrix.cpp

    r661 r664  
    2828}
    2929
    30 static inline float cofact3(float4x4 const &mat, int i, int j)
     30static inline float cofact3(mat4 const &mat, int i, int j)
    3131{
    3232    return det3(mat[(i + 1) & 3][(j + 1) & 3],
     
    4141}
    4242
    43 template<> float float4x4::det() const
     43template<> float mat4::det() const
    4444{
    4545    float ret = 0;
     
    4949}
    5050
    51 template<> float4x4 float4x4::invert() const
     51template<> mat4 mat4::invert() const
    5252{
    53     float4x4 ret;
     53    mat4 ret;
    5454    float d = det();
    5555    if (d)
     
    6363}
    6464
    65 template<> float4x4 float4x4::ortho(float left, float right, float bottom,
    66                                     float top, float near, float far)
     65template<> mat4 mat4::ortho(float left, float right, float bottom,
     66                            float top, float near, float far)
    6767{
    6868    float invrl = (right != left) ? 1.0f / (right - left) : 0.0f;
     
    7070    float invfn = (far != near) ? 1.0f / (far - near) : 0.0f;
    7171
    72     float4x4 ret(0.0f);
     72    mat4 ret(0.0f);
    7373    ret[0][0] = 2.0f * invrl;
    7474    ret[1][1] = 2.0f * invtb;
     
    8181}
    8282
    83 template<> float4x4 float4x4::frustum(float left, float right, float bottom,
    84                                       float top, float near, float far)
     83template<> mat4 mat4::frustum(float left, float right, float bottom,
     84                              float top, float near, float far)
    8585{
    8686    float invrl = (right != left) ? 1.0f / (right - left) : 0.0f;
     
    8888    float invfn = (far != near) ? 1.0f / (far - near) : 0.0f;
    8989
    90     float4x4 ret(0.0f);
     90    mat4 ret(0.0f);
    9191    ret[0][0] = 2.0f * near * invrl;
    9292    ret[1][1] = 2.0f * near * invtb;
     
    9999}
    100100
    101 template<> float4x4 float4x4::perspective(float theta, float width,
    102                                           float height, float near, float far)
     101template<> mat4 mat4::perspective(float theta, float width,
     102                                  float height, float near, float far)
    103103{
    104104    float t1 = tanf(theta / 2.0f);
     
    108108}
    109109
    110 template<> float4x4 float4x4::translate(float x, float y, float z)
     110template<> mat4 mat4::translate(float x, float y, float z)
    111111{
    112     float4x4 ret(1.0f);
     112    mat4 ret(1.0f);
    113113    ret[3][0] = x;
    114114    ret[3][1] = y;
     
    117117}
    118118
    119 template<> float4x4 float4x4::rotate(float theta, float x, float y, float z)
     119template<> mat4 mat4::rotate(float theta, float x, float y, float z)
    120120{
    121121    float st = sinf(theta);
     
    132132    float mtz = (1.0f - ct) * z;
    133133
    134     float4x4 ret(1.0f);
     134    mat4 ret(1.0f);
    135135
    136136    ret[0][0] = x * mtx + ct;
  • trunk/src/matrix.h

    r663 r664  
    279279typedef Mat4<int> mat4i;
    280280
    281 /* Aliases for deprecated stuff */
    282 typedef Vec2<float> float2;
    283 typedef Vec2<int> int2;
    284 typedef Vec3<float> float3;
    285 typedef Vec3<int> int3;
    286 typedef Vec4<float> float4;
    287 typedef Vec4<int> int4;
    288 typedef Mat4<float> float4x4;
    289 typedef Mat4<int> int4x4;
    290 
    291281#endif // __DH_MATRIX_H__
    292282
  • trunk/src/scene.cpp

    r663 r664  
    3939extern Shader *stdshader;
    4040#endif
    41 extern float4x4 projection_matrix, view_matrix, model_matrix;
     41extern mat4 projection_matrix, view_matrix, model_matrix;
    4242
    4343/*
     
    137137
    138138    // XXX: debug stuff
    139     model_matrix = float4x4::translate(320.0f, 240.0f, 0.0f);
    140     model_matrix *= float4x4::rotate(-data->angle, 1.0f, 0.0f, 0.0f);
     139    model_matrix = mat4::translate(320.0f, 240.0f, 0.0f);
     140    model_matrix *= mat4::rotate(-data->angle, 1.0f, 0.0f, 0.0f);
    141141#if 0
    142142    static float f = 0.0f;
    143143    f += 0.01f;
    144     model_matrix *= float4x4::rotate(0.1f * sinf(f), 1.0f, 0.0f, 0.0f);
    145     model_matrix *= float4x4::rotate(0.3f * cosf(f), 0.0f, 0.0f, 1.0f);
    146 #endif
    147     model_matrix *= float4x4::translate(-320.0f, -240.0f, 0.0f);
     144    model_matrix *= mat4::rotate(0.1f * sinf(f), 1.0f, 0.0f, 0.0f);
     145    model_matrix *= mat4::rotate(0.3f * cosf(f), 0.0f, 0.0f, 1.0f);
     146#endif
     147    model_matrix *= mat4::translate(-320.0f, -240.0f, 0.0f);
    148148    // XXX: end of debug stuff
    149149
  • trunk/src/sdlinput.cpp

    r294 r664  
    4949
    5050    /* Handle mouse input */
    51     int2 mouse;
     51    vec2i mouse;
    5252    if (SDL_GetAppState() & SDL_APPMOUSEFOCUS)
    5353    {
  • trunk/src/text.cpp

    r326 r664  
    3030    int font, align, length;
    3131    char *text;
    32     int3 pos;
     32    vec3i pos;
    3333};
    3434
     
    4343    data->text = text ? strdup(text) : NULL;
    4444    data->length = text ? strlen(text) : 0;
    45     data->pos = int3(0, 0, 0);
     45    data->pos = vec3i(0, 0, 0);
    4646
    4747    drawgroup = DRAWGROUP_HUD;
     
    6666}
    6767
    68 void Text::SetPos(int3 pos)
     68void Text::SetPos(vec3i pos)
    6969{
    7070    data->pos = pos;
     
    8383    {
    8484        Font *font = Forge::GetFont(data->font);
    85         int3 delta = 0;
     85        vec3i delta = 0;
    8686        if (data->align == ALIGN_RIGHT)
    8787            delta.x -= data->length * font->GetSize().x;
  • trunk/src/text.h

    r326 r664  
    2929    void SetText(char const *text);
    3030    void SetInt(int val);
    31     void SetPos(int3 pos);
     31    void SetPos(vec3i pos);
    3232    void SetAlign(int align);
    3333
  • trunk/src/tiler.cpp

    r658 r664  
    4646 */
    4747
    48 int Tiler::Register(char const *path, int2 size, int2 count, float dilate)
     48int Tiler::Register(char const *path, vec2i size, vec2i count, float dilate)
    4949{
    5050    int id = data->tilesets.MakeSlot(path);
     
    6868}
    6969
    70 int2 Tiler::GetSize(int id)
     70vec2i Tiler::GetSize(int id)
    7171{
    7272    TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id - 1);
     
    8181}
    8282
    83 int2 Tiler::GetCount(int id)
     83vec2i Tiler::GetCount(int id)
    8484{
    8585    TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id - 1);
  • trunk/src/tiler.h

    r645 r664  
    2323{
    2424public:
    25     static int Register(char const *path, int2 size, int2 count, float dilate);
     25    static int Register(char const *path, vec2i size, vec2i count,
     26                        float dilate);
    2627    static void Deregister(int id);
    2728
    28     static int2 GetSize(int id);
    29     static int2 GetCount(int id);
     29    static vec2i GetSize(int id);
     30    static vec2i GetCount(int id);
    3031    static void Bind(uint32_t code);
    3132    static void BlitTile(uint32_t code, int x, int y, int z, int o,
  • trunk/src/tileset.cpp

    r658 r664  
    4343    char *name, *path;
    4444    int *tiles, ntiles;
    45     int2 size, count;
     45    vec2i size, count;
    4646    float dilate, tx, ty;
    4747
     
    5454 */
    5555
    56 TileSet::TileSet(char const *path, int2 size, int2 count, float dilate)
     56TileSet::TileSet(char const *path, vec2i size, vec2i count, float dilate)
    5757  : data(new TileSetData())
    5858{
     
    8181    {
    8282        data->count = count;
    83         data->size = int2(data->img->w, data->img->h) / count;
     83        data->size = vec2i(data->img->w, data->img->h) / count;
    8484    }
    8585    else
     
    158158}
    159159
    160 int2 TileSet::GetSize() const
     160vec2i TileSet::GetSize() const
    161161{
    162162    return data->size;
    163163}
    164164
    165 int2 TileSet::GetCount() const
     165vec2i TileSet::GetCount() const
    166166{
    167167    return data->count;
  • trunk/src/tileset.h

    r645 r664  
    2929{
    3030public:
    31     TileSet(char const *path, int2 size, int2 count, float dilate);
     31    TileSet(char const *path, vec2i size, vec2i count, float dilate);
    3232    virtual ~TileSet();
    3333
     
    3939public:
    4040    /* New methods */
    41     int2 GetSize() const;
    42     int2 GetCount() const;
     41    vec2i GetSize() const;
     42    vec2i GetCount() const;
    4343    void Bind();
    4444    void BlitTile(uint32_t id, int x, int y, int z, int o,
  • trunk/src/video.cpp

    r662 r664  
    3232Shader *stdshader;
    3333#endif
    34 float4x4 projection_matrix, view_matrix, model_matrix;
     34mat4 projection_matrix, view_matrix, model_matrix;
    3535
    3636#if LOL_EXPERIMENTAL
     
    9393#undef near /* Fuck Microsoft */
    9494#undef far /* Fuck Microsoft again */
    95     float4x4 proj;
     95    mat4 proj;
    9696
    9797    float width = GetWidth();
     
    104104    {
    105105        /* The easy way: purely orthogonal projection. */
    106         proj = float4x4::ortho(0, width, 0, height, near, far);
     106        proj = mat4::ortho(0, width, 0, height, near, far);
    107107    }
    108108    else
     
    124124        }
    125125
    126         proj = float4x4::frustum(-near * t1, near * t1,
    127                                  -near * t2, near * t2, near, far)
    128              * float4x4::translate(-0.5f * width, -0.5f * height, -dist);
     126        proj = mat4::frustum(-near * t1, near * t1,
     127                             -near * t2, near * t2, near, far)
     128             * mat4::translate(-0.5f * width, -0.5f * height, -dist);
    129129    }
    130130
    131131#if LOL_EXPERIMENTAL
    132132    projection_matrix = proj;
    133     view_matrix = float4x4(1.0f);
     133    view_matrix = mat4(1.0f);
    134134#else
    135135    glMatrixMode(GL_PROJECTION);
  • trunk/src/worldentity.h

    r332 r664  
    2222{
    2323public:
    24     float3 position;
    25     float3 rotation;
    26     float3 velocity;
    27     float3 bbox[2];
     24    vec3 position;
     25    vec3 rotation;
     26    vec3 velocity;
     27    vec3 bbox[2];
    2828
    29     int2 mousepos;
    30     int3 mousebuttons;
    31     int3 pressed, clicked, released;
     29    vec2i mousepos;
     30    vec3i mousebuttons;
     31    vec3i pressed, clicked, released;
    3232
    3333protected:
  • trunk/test/matrix.cpp

    r651 r664  
    3333    void setUp()
    3434    {
    35         identity = float4x4(1.0f);
    36         triangular = float4x4(float4(1.0f, 0.0f, 0.0f, 0.0f),
    37                               float4(7.0f, 2.0f, 0.0f, 0.0f),
    38                               float4(1.0f, 5.0f, 3.0f, 0.0f),
    39                               float4(8.0f, 9.0f, 2.0f, 4.0f));
    40         invertible = float4x4(float4( 1.0f,  1.0f,  2.0f, -1.0f),
    41                               float4(-2.0f, -1.0f, -2.0f,  2.0f),
    42                               float4( 4.0f,  2.0f,  5.0f, -4.0f),
    43                               float4( 5.0f, -3.0f, -7.0f, -6.0f));
     35        identity = mat4(1.0f);
     36        triangular = mat4(vec4(1.0f, 0.0f, 0.0f, 0.0f),
     37                          vec4(7.0f, 2.0f, 0.0f, 0.0f),
     38                          vec4(1.0f, 5.0f, 3.0f, 0.0f),
     39                          vec4(8.0f, 9.0f, 2.0f, 4.0f));
     40        invertible = mat4(vec4( 1.0f,  1.0f,  2.0f, -1.0f),
     41                          vec4(-2.0f, -1.0f, -2.0f,  2.0f),
     42                          vec4( 4.0f,  2.0f,  5.0f, -4.0f),
     43                          vec4( 5.0f, -3.0f, -7.0f, -6.0f));
    4444    }
    4545
     
    5656    void test_mat_mul()
    5757    {
    58         float4x4 m0 = identity;
    59         float4x4 m1 = identity;
    60         float4x4 m2 = m0 * m1;
     58        mat4 m0 = identity;
     59        mat4 m1 = identity;
     60        mat4 m2 = m0 * m1;
    6161
    6262        CPPUNIT_ASSERT(m2[0][0] == 1.0f);
     
    8383    void test_mat_inv()
    8484    {
    85         float4x4 m0 = invertible;
    86         float4x4 m1 = m0.invert();
     85        mat4 m0 = invertible;
     86        mat4 m1 = m0.invert();
    8787
    88         float4x4 m2 = m0 * m1;
     88        mat4 m2 = m0 * m1;
    8989
    9090        CPPUNIT_ASSERT(m2[0][0] == 1.0f);
     
    110110
    111111private:
    112     float4x4 triangular, identity, invertible;
     112    mat4 triangular, identity, invertible;
    113113};
    114114
Note: See TracChangeset for help on using the changeset viewer.