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

OpenGL code refactoring.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/video.cpp

    r664 r665  
    3232Shader *stdshader;
    3333#endif
    34 mat4 projection_matrix, view_matrix, model_matrix;
     34mat4 proj_matrix, view_matrix, model_matrix;
    3535
    3636#if LOL_EXPERIMENTAL
     
    4242    "in vec2 in_TexCoord;\n"
    4343    "out vec3 pass_Color;\n"
    44     "uniform mat4 projection_matrix;\n"
     44    "uniform mat4 proj_matrix;\n"
    4545    "uniform mat4 view_matrix;\n"
    4646    "uniform mat4 model_matrix;\n"
     
    4848    "void main()\n"
    4949    "{\n"
    50     "    gl_Position = projection_matrix * view_matrix *"
    51     "                  model_matrix * vec4(in_Position, 1.0f);\n"
     50    "    gl_Position = proj_matrix * view_matrix * model_matrix"
     51    "                * vec4(in_Position, 1.0f);\n"
    5252    "    gl_TexCoord[0] = vec4(in_TexCoord, 0.0, 0.0);\n"
    5353    "    pass_Color = in_Color;\n"
     
    104104    {
    105105        /* The easy way: purely orthogonal projection. */
    106         proj = mat4::ortho(0, width, 0, height, near, far);
     106        proj_matrix = mat4::ortho(0, width, 0, height, near, far);
    107107    }
    108108    else
     
    124124        }
    125125
    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);
     126        proj_matrix = 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
    131 #if LOL_EXPERIMENTAL
    132     projection_matrix = proj;
    133131    view_matrix = mat4(1.0f);
    134 #else
     132
     133#if !LOL_EXPERIMENTAL
    135134    glMatrixMode(GL_PROJECTION);
    136135    glLoadIdentity();
    137     glMultMatrixf(&proj[0][0]);
     136    glMultMatrixf(&proj_matrix[0][0]);
    138137
    139138    /* Reset the model view matrix, just in case */
    140139    glMatrixMode(GL_MODELVIEW);
    141140    glLoadIdentity();
     141    glMultMatrixf(&view_matrix[0][0]);
    142142#endif
    143143}
     
    153153void Video::Clear()
    154154{
    155 #if LOL_EXPERIMENTAL
    156155    glViewport(0, 0, GetWidth(), GetHeight());
    157156    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    158157
     158#if LOL_EXPERIMENTAL
    159159    GLuint uni;
    160     uni = stdshader->GetUniformLocation("projection_matrix");
    161     glUniformMatrix4fv(uni, 1, GL_FALSE, &projection_matrix[0][0]);
     160    uni = stdshader->GetUniformLocation("proj_matrix");
     161    glUniformMatrix4fv(uni, 1, GL_FALSE, &proj_matrix[0][0]);
    162162    uni = stdshader->GetUniformLocation("view_matrix");
    163163    glUniformMatrix4fv(uni, 1, GL_FALSE, &view_matrix[0][0]);
    164 #else
    165     glEnable(GL_DEPTH_TEST);
    166     glDepthFunc(GL_LEQUAL);
    167     glEnable(GL_ALPHA_TEST);
    168     glAlphaFunc(GL_GEQUAL, 0.01f);
    169     glEnable(GL_BLEND);
    170     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    171 
    172     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    173164#endif
    174165
Note: See TracChangeset for help on using the changeset viewer.