Changeset 755


Ignore:
Timestamp:
Apr 4, 2011, 2:05:59 AM (10 years ago)
Author:
sam
Message:

video: get rid of Video::GetWidth() and Video::GetHeight().

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/deushax/gtk/glmapview.cpp

    r686 r755  
    127127    {
    128128        Ticker::Setup(FPS);
    129         Video::Setup(glarea->allocation.width, glarea->allocation.height);
     129        Video::Setup(vec2i(glarea->allocation.width,
     130                           glarea->allocation.height));
    130131    }
    131132
  • trunk/src/debugrecord.cpp

    r735 r755  
    3535private:
    3636    char const *path;
    37     int width, height, fps;
     37    vec2i size;
     38    int fps;
    3839#if defined USE_PIPI
    3940    pipi_sequence_t *sequence;
     
    5152
    5253    data->path = strdup(path);
    53     data->width = 0;
    54     data->height = 0;
     54    data->size = 0;
    5555    data->fps = (int)(fps + 0.5f);
    5656#if defined USE_PIPI
     
    7070    Entity::TickDraw(deltams);
    7171
    72     int width = Video::GetWidth();
    73     int height = Video::GetHeight();
     72    vec2i size = Video::GetSize();
    7473
    75     if (data->width != width || data->height != height)
     74    if (data->size != size)
    7675    {
    77         data->width = width;
    78         data->height = height;
     76        data->size = size;
    7977
    8078#if defined USE_PIPI
     
    8280            pipi_close_sequence(data->sequence);
    8381
    84         data->sequence = pipi_open_sequence(data->path, width, height,
     82        data->sequence = pipi_open_sequence(data->path, size.x, size.y,
    8583                                            1 /* RGB */, data->fps,
    8684                                            1, 1, 60 * 1024 * 1024);
     
    9189    if (data->sequence)
    9290    {
    93         uint32_t *buffer = new uint32_t[width * height];
     91        uint32_t *buffer = new uint32_t[size.x * size.y];
    9492        Video::Capture(buffer);
    95         pipi_feed_sequence(data->sequence, (uint8_t *)buffer, width, height);
     93        pipi_feed_sequence(data->sequence, (uint8_t *)buffer, size.x, size.y);
    9694        delete[] buffer;
    9795    }
  • trunk/src/eglapp.cpp

    r745 r755  
    150150    /* Initialise everything */
    151151    Ticker::Setup(fps);
    152     Video::Setup(gwa.width, gwa.height);
     152    Video::Setup(vec2i(gwa.width, gwa.height));
    153153    Audio::Setup(2);
    154154#endif
  • trunk/src/sdlapp.cpp

    r734 r755  
    6565    /* Initialise everything */
    6666    Ticker::Setup(fps);
    67     Video::Setup(video->w, video->h);
     67    Video::Setup(vec2i(video->w, video->h));
    6868    Audio::Setup(2);
    6969#endif
  • trunk/src/sdlinput.cpp

    r686 r755  
    5656    {
    5757        SDL_GetMouseState(&mouse.x, &mouse.y);
    58         mouse.y = Video::GetHeight() - 1 - mouse.y;
     58        mouse.y = Video::GetSize().y - 1 - mouse.y;
    5959    }
    6060    else
  • trunk/src/video.cpp

    r753 r755  
    9797    "    float t3 = mod(3.0 * dx3 + 2.0 * dy3, 4.0);\n"
    9898    "    float t1 = (1.0 + 16.0 * t1 + 4.0 * t2 + t3) / 65.0;\n"
    99     "    float t2 = t1;
    100     "    float t3 = t1;
     99    "    float t2 = t1;\n"
     100    "    float t3 = t1;\n"
    101101#else
    102102    "    float rand = sin(gl_FragCoord.x * 1.23456) * 123.456\n"
     
    123123 */
    124124
    125 void Video::Setup(int width, int height)
     125void Video::Setup(vec2i size)
    126126{
    127127    /* Initialise OpenGL */
    128     glViewport(0, 0, width, height);
    129 
    130 #if defined ANDROID_NDK
    131     saved_viewport = vec2i(width, height);
     128    glViewport(0, 0, size.x, size.y);
     129
     130#if defined ANDROID_NDK
     131    saved_viewport = vec2i(size.x, size.y);
    132132#endif
    133133
     
    149149    mat4 proj;
    150150
    151     float width = GetWidth();
    152     float height = GetHeight();
    153     float near = -width - height;
    154     float far = width + height;
    155 
    156 #if defined ANDROID_NDK
    157     width = 640.0f;
    158     height = 480.0f;
     151    vec2 size = GetSize();
     152    float near = -size.x - size.y;
     153    float far = size.x + size.y;
     154
     155#if defined ANDROID_NDK
     156    size = vec(640.0f, 480.0f);
    159157#endif
    160158
     
    163161    {
    164162        /* The easy way: purely orthogonal projection. */
    165         proj_matrix = mat4::ortho(0, width, 0, height, near, far);
     163        proj_matrix = mat4::ortho(0, size.x, 0, size.y, near, far);
    166164    }
    167165    else
     
    171169         * the screen. */
    172170        float t1 = tanf(theta / 2);
    173         float t2 = t1 * height / width;
    174         float dist = (float)width / (2.0f * t1);
     171        float t2 = t1 * size.y / size.y;
     172        float dist = size.x / (2.0f * t1);
    175173
    176174        near += dist;
     
    185183        proj_matrix = mat4::frustum(-near * t1, near * t1,
    186184                                    -near * t2, near * t2, near, far)
    187                     * mat4::translate(-0.5f * width, -0.5f * height, -dist);
     185                    * mat4::translate(-0.5f * size.x, -0.5f * size.y, -dist);
    188186    }
    189187
     
    208206void Video::Clear()
    209207{
    210     glViewport(0, 0, GetWidth(), GetHeight());
     208    vec2i size = GetSize();
     209    glViewport(0, 0, size.x, size.y);
    211210    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    212211
     
    256255}
    257256
    258 int Video::GetWidth()
    259 {
    260     return GetSize().x;
    261 }
    262 
    263 int Video::GetHeight()
    264 {
    265     return GetSize().y;
    266 }
    267 
    268257} /* namespace lol */
    269258
  • trunk/src/video.h

    r753 r755  
    2626{
    2727public:
    28     static void Setup(int width, int height);
     28    static void Setup(vec2i size);
    2929    static void Destroy();
    3030    static void SetFov(float theta);
     
    3333    static void Capture(uint32_t *buffer);
    3434    static vec2i GetSize();
    35     static int GetWidth();
    36     static int GetHeight();
    3735};
    3836
Note: See TracChangeset for help on using the changeset viewer.