Example #1
0
void hmd_common_swap(float center,
                     float scale,
                     const float *barrel_correction,
                     const float *chroma_correction)
{
    int w = config_get_d(CONFIG_WIDTH);
    int h = config_get_d(CONFIG_HEIGHT);

    float a = (float) w / (float) h / 2;

    /* Prepare to draw a screen-filling pair of rectangles. */

    glBindFramebuffer_(GL_FRAMEBUFFER, 0);
    glViewport(0, 0, w, h);

    glDisable(GL_BLEND);
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);

    glUseProgram_(distortion.program);
    {
        /* Set distortion parameters for both eyes. */

        glsl_uniform2f(&distortion, "ScaleOut", 0.5f / scale, 0.5f * a / scale);
        glsl_uniform2f(&distortion, "ScaleIn",  2.0f,         2.0f / a);
        glsl_uniform4f(&distortion, "DistortionK",  barrel_correction[0],
                                                    barrel_correction[1],
                                                    barrel_correction[2],
                                                    barrel_correction[3]);
        glsl_uniform4f(&distortion, "ChromAbParam", chroma_correction[0],
                                                    chroma_correction[1],
                                                    chroma_correction[2],
                                                    chroma_correction[3]);
        /* Draw the left eye. */

        glsl_uniform2f(&distortion, "LensCenter", 0.5f + 0.5f * center, 0.5f);
        hmd_common_draw(L_fbo.color_texture, L_vbo);

        /* Draw the right eye.*/

        glsl_uniform2f(&distortion, "LensCenter", 0.5f - 0.5f * center, 0.5f);
        hmd_common_draw(R_fbo.color_texture, R_vbo);
    }
    glUseProgram_(0);

    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisableClientState(GL_VERTEX_ARRAY);
    glEnable(GL_BLEND);
}
Example #2
0
GLAPI void APIENTRY glUseProgram(
    GLuint program)
{
    glUseProgram_(program);
}