Ejemplo n.º 1
0
void mirrorclamp_app::render(double T)
{
    glViewport(0, 0, info.windowWidth, info.windowHeight);

    glClearBufferfv(GL_COLOR, 0, sb7::color::Black);

    Sleep(1);

    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, input_texture);

    glBindVertexArray(dummy_vao);
    glUseProgram(render_program);

    switch (display_mode)
    {
        case CLAMP_TO_BORDER:
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
            break;
        case MIRROR_CLAMP_TO_EDGE:
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRROR_CLAMP_TO_EDGE);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRROR_CLAMP_TO_EDGE);
            break;
    }

    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

    overlay.clear();
    overlay.drawText(display_mode == CLAMP_TO_BORDER ? "Mode = GL_CLAMP_TO_BORDER (M toggles)" : "Mode = GL_MIRROR_CLAMP_TO_EDGE (M toggles)", 0, 0);
    overlay.draw();
}
Ejemplo n.º 2
0
void cullindirect_app::updateOverlay()
{
    char buffer[256];

    overlay.clear();
    sprintf(buffer, "%2.2fms / frame (%4.2f FPS)", 1000.0f / fps, fps);
    overlay.drawText(buffer, 0, 0);
    overlay.draw();
}
Ejemplo n.º 3
0
void pmbstreaming_app::updateOverlay()
{
    char buffer[256];
    static const char * modenames[] =
    {
        "BRAK_SYNCHRONIZACJI",
        "FUNKCJA_FINISH",
        "POJEDYNCZA_SYNCHRONIZACJA",
        "WIELE_SYNCHRONIZACJI"
    };

    overlay.clear();
    sprintf(buffer, "%2.2fms / klatka (%4.2f FPS)", 1000.0f / fps, fps);
    overlay.drawText(buffer, 0, 0);
    sprintf(buffer, "TRYB: %s", modenames[mode]);
    overlay.drawText(buffer, 0, 1);
    if (stalled)
    {
        overlay.drawText("BLOKOWANIE", 0, 2);
    }

    overlay.draw();
}
Ejemplo n.º 4
0
void pmbstreaming_app::updateOverlay()
{
    char buffer[256];
    static const char * modenames[] =
    {
        "NO_SYNC",
        "FINISH",
        "ONE_SYNC",
        "RINGED_SYNC"
    };

    overlay.clear();
    sprintf(buffer, "%2.2fms / frame (%4.2f FPS)", 1000.0f / fps, fps);
    overlay.drawText(buffer, 0, 0);
    sprintf(buffer, "MODE: %s", modenames[mode]);
    overlay.drawText(buffer, 0, 1);
    if (stalled)
    {
        overlay.drawText("STALLED", 0, 2);
    }

    overlay.draw();
}
Ejemplo n.º 5
0
void dof_app::render(double currentTime)
{
    static const GLfloat zeros[] = { 0.0f, 0.0f, 0.0f, 0.0f };
    
    static double last_time = 0.0;
    static double total_time = 0.0;

    if (!paused)
        total_time += (currentTime - last_time);
    last_time = currentTime;

    const float f = (float)total_time + 30.0f;

    vmath::vec3 view_position = vmath::vec3(0.0f, 0.0f, 40.0f);

    camera_proj_matrix = vmath::perspective(50.0f,
                                            (float)info.windowWidth / (float)info.windowHeight,
                                            2.0f,
                                            300.0f);

    camera_view_matrix = vmath::lookat(view_position,
                                       vmath::vec3(0.0f),
                                       vmath::vec3(0.0f, 1.0f, 0.0f));

    objects[0].model_matrix = vmath::translate(5.0f, 0.0f, 20.0f) *
                              vmath::rotate(f * 14.5f, 0.0f, 1.0f, 0.0f) *
                              vmath::rotate(20.0f, 1.0f, 0.0f, 0.0f) *
                              vmath::translate(0.0f, -4.0f, 0.0f);

    objects[1].model_matrix = vmath::translate(-5.0f, 0.0f, 0.0f) *
                              vmath::rotate(f * 14.5f, 0.0f, 1.0f, 0.0f) *
                              vmath::rotate(20.0f, 1.0f, 0.0f, 0.0f) *
                              vmath::translate(0.0f, -4.0f, 0.0f);

    objects[2].model_matrix = vmath::translate(-15.0f, 0.0f, -20.0f) *
                              vmath::rotate(f * 14.5f, 0.0f, 1.0f, 0.0f) *
                              vmath::rotate(20.0f, 1.0f, 0.0f, 0.0f) *
                              vmath::translate(0.0f, -4.0f, 0.0f);

    objects[3].model_matrix = vmath::translate(-25.0f, 0.0f, -40.0f) *
                              vmath::rotate(f * 14.5f, 0.0f, 1.0f, 0.0f) *
                              vmath::rotate(20.0f, 1.0f, 0.0f, 0.0f) *
                              vmath::translate(0.0f, -4.0f, 0.0f);

    objects[4].model_matrix = vmath::translate(-35.0f, 0.0f, -60.0f) *
                              vmath::rotate(f * 14.5f, 0.0f, 1.0f, 0.0f) *
                              vmath::rotate(20.0f, 1.0f, 0.0f, 0.0f) *
                              vmath::translate(0.0f, -4.0f, 0.0f);

    glEnable(GL_DEPTH_TEST);
    render_scene(total_time);

    glUseProgram(filter_program);

    glBindImageTexture(0, color_tex, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA32F);
    glBindImageTexture(1, temp_tex, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA32F);

    glDispatchCompute(info.windowHeight, 1, 1);

    glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);

    glBindImageTexture(0, temp_tex, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA32F);
    glBindImageTexture(1, color_tex, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA32F);

    glDispatchCompute(info.windowWidth, 1, 1);

    glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);

    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, color_tex);
    glDisable(GL_DEPTH_TEST);
    glUseProgram(display_program);
    glUniform1f(uniforms.dof.focal_distance, focal_distance);
    glUniform1f(uniforms.dof.focal_depth, focal_depth);
    glBindVertexArray(quad_vao);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

    overlay.draw();
}