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

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

File:
1 edited

Legend:

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