예제 #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();
}
예제 #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();
}
예제 #3
0
void mirrorclamp_app::startup()
{
    overlay.init(80, 50);

    input_texture = sb7::ktx::file::load("media/textures/flare.ktx");

    load_shaders();

    glGenVertexArrays(1, &dummy_vao);
}
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();
}
예제 #5
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();
}
예제 #6
0
void cullindirect_app::startup()
{
    GLuint first, count;

    object.load("media/objects/asteroids.sbm");

    glGenBuffers(1, &buffers.parameters);
    glBindBuffer(GL_PARAMETER_BUFFER_ARB, buffers.parameters);
    glBufferStorage(GL_PARAMETER_BUFFER_ARB, 256, nullptr, 0);

    glGenBuffers(1, &buffers.drawCandidates);
    glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffers.drawCandidates);

    CandidateDraw* pDraws = new CandidateDraw[CANDIDATE_COUNT];

    int i;

    for (i = 0; i < CANDIDATE_COUNT; i++)
    {
        object.get_sub_object_info(i % object.get_sub_object_count(), first, count);
        pDraws[i].sphereCenter = vmath::vec3(0.0f);
        pDraws[i].sphereRadius = 4.0f;
        pDraws[i].firstVertex = first;
        pDraws[i].vertexCount = count;
    }

    glBufferStorage(GL_SHADER_STORAGE_BUFFER, CANDIDATE_COUNT * sizeof(CandidateDraw), pDraws, 0);

    delete [] pDraws;

    glGenBuffers(1, &buffers.drawCommands);
    glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffers.drawCommands);
    glBufferStorage(GL_SHADER_STORAGE_BUFFER, CANDIDATE_COUNT * sizeof(DrawArraysIndirectCommand), nullptr, GL_MAP_READ_BIT);

    glGenBuffers(1, &buffers.modelMatrices);
    glBindBuffer(GL_UNIFORM_BUFFER, buffers.modelMatrices);
    glBufferStorage(GL_UNIFORM_BUFFER, 1024 * sizeof(vmath::mat4), nullptr, GL_MAP_WRITE_BIT);

    glGenBuffers(1, &buffers.transforms);
    glBindBuffer(GL_UNIFORM_BUFFER, buffers.transforms);
    glBufferStorage(GL_UNIFORM_BUFFER, sizeof(TransformBuffer), nullptr, GL_MAP_WRITE_BIT);

    load_shaders();

    overlay.init(128, 50);

    texture = sb7::ktx::file::load("media/textures/rocks.ktx");
}
void pmbstreaming_app::startup()
{
    glGenBuffers(1, &buffer);
    glBindBuffer(GL_UNIFORM_BUFFER, buffer);

    glBufferStorage(GL_UNIFORM_BUFFER,
                    BUFFER_SIZE,
                    nullptr,
                    GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
    vs_uniforms = (MATRICES*)glMapBufferRange(GL_UNIFORM_BUFFER,
                                   0,
                                   BUFFER_SIZE,
                                   GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);

    GLuint shaders[2] =
    {
        sb7::shader::load("media/shaders/pmbstreaming/pmbstreaming.vs.glsl", GL_VERTEX_SHADER),
        sb7::shader::load("media/shaders/pmbstreaming/pmbstreaming.fs.glsl", GL_FRAGMENT_SHADER)
    };

    program = sb7::program::link_from_shaders(shaders, 2, true);

    object.load("media/objects/torus_nrms_tc.sbm");

    glBindBufferBase(GL_UNIFORM_BUFFER, 0, buffer);

    overlay.init(128, 50);

    glActiveTexture(GL_TEXTURE0);
    texture = sb7::ktx::file::load("media/textures/pattern1.ktx");

    for (int i = 0; i < CHUNK_COUNT; i++)
    {
        fence[i] = 0;
    }
}
예제 #8
0
파일: dof.cpp 프로젝트: DebugChopra/sb7code
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();
}
예제 #9
0
파일: dof.cpp 프로젝트: DebugChopra/sb7code
void dof_app::startup()
{
    load_shaders();

    int i;

    static const char * const object_names[] =
    {
        "media/objects/dragon.sbm",
        "media/objects/sphere.sbm",
        "media/objects/cube.sbm",
        "media/objects/cube.sbm",
        "media/objects/cube.sbm",
    };

    static const vmath::vec4 object_colors[] =
    {
        vmath::vec4(1.0f, 0.7f, 0.8f, 1.0f),
        vmath::vec4(0.7f, 0.8f, 1.0f, 1.0f),
        vmath::vec4(0.3f, 0.9f, 0.4f, 1.0f),
        vmath::vec4(0.6f, 0.4f, 0.9f, 1.0f),
        vmath::vec4(0.8f, 0.2f, 0.1f, 1.0f),
    };

    for (i = 0; i < OBJECT_COUNT; i++)
    {
        objects[i].obj.load(object_names[i]);
        objects[i].diffuse_albedo = object_colors[i];
    }

    glGenFramebuffers(1, &depth_fbo);
    glBindFramebuffer(GL_FRAMEBUFFER, depth_fbo);

    glGenTextures(1, &depth_tex);
    glBindTexture(GL_TEXTURE_2D, depth_tex);
    glTexStorage2D(GL_TEXTURE_2D, 11, GL_DEPTH_COMPONENT32F, FBO_SIZE, FBO_SIZE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    glGenTextures(1, &color_tex);
    glBindTexture(GL_TEXTURE_2D, color_tex);
    glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA32F, FBO_SIZE, FBO_SIZE);

    glGenTextures(1, &temp_tex);
    glBindTexture(GL_TEXTURE_2D, temp_tex);
    glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA32F, FBO_SIZE, FBO_SIZE);

    glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depth_tex, 0);
    glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, color_tex, 0);

    glBindTexture(GL_TEXTURE_2D, 0);
    glBindFramebuffer(GL_FRAMEBUFFER, 0);

    glEnable(GL_DEPTH_TEST);

    glGenVertexArrays(1, &quad_vao);
    glBindVertexArray(quad_vao);

    overlay.init(80, 50);
    overlay.clear();
    overlay.drawText("Q: Increas focal distance", 0, 0);
    overlay.drawText("A: Decrease focal distance", 0, 1);
    overlay.drawText("W: Increase focal depth", 0, 2);
    overlay.drawText("S: Decrease focal depth", 0, 3);
    overlay.drawText("P: Pause", 0, 4);
}