Ejemplo n.º 1
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);
}
Ejemplo n.º 2
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");
}
Ejemplo n.º 3
0
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;
    }
}
Ejemplo n.º 4
0
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);
}