Changeset 664 for trunk/src


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

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

Location:
trunk/src
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • 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:
Note: See TracChangeset for help on using the changeset viewer.