Пример #1
0
void
uniform_1ui::apply_value(const render_context& context, const program& p)
{
    const opengl::gl_core& glapi = context.opengl_api();
    glapi.glUniform1uiv(_location, _elements, &(_value.front()));//&_value);
    gl_assert(glapi, leaving uniform_1ui::apply_value());
}
Пример #2
0
void
uniform_vec4ui::apply_value(const render_context& context, const program& p)
{
    const opengl::gl_core& glapi = context.opengl_api();
    glapi.glUniform4uiv(_location, _elements, (_value.front().data_array));//_value.data_array);
    gl_assert(glapi, leaving uniform_vec4ui::apply_value());
}
Пример #3
0
void
uniform_image_sampler_base::apply_value(const render_context& context, const program& p)
{
    const opengl::gl_core& glapi = context.opengl_api();
#if SCM_GL_CORE_USE_EXT_DIRECT_STATE_ACCESS
    if (_bound_unit >= 0) {
        glapi.glProgramUniform1i(p.program_id(), _location, _bound_unit);
    }
    else if (   glapi.extension_ARB_bindless_texture
             && _resident_handle != 0ull)
    {
        glapi.glProgramUniformHandleui64ARB(p.program_id(), _location, _resident_handle);
    }
#else
    if (_bound_unit >= 0) {
        glapi.glUniform1i(_location, _bound_unit);
    }
    else if (   glapi.extension_ARB_bindless_texture
             && _resident_handle != 0ull)
    {
        glapi.glUniformHandleui64ARB(_location, _resident_handle);
    }
#endif
    gl_assert(glapi, leaving uniform_1f::apply_value());

}
Пример #4
0
void
transform_feedback::end(render_context& in_context)
{
    assert(state().ok());
    gl_assert(in_context.opengl_api(), entering transform_feedback:end());

    const opengl::gl_core& glapi = in_context.opengl_api();

    if (active()) {
        glapi.glEndTransformFeedback();
    }
    unbind(in_context);

    _active            = false;

    gl_assert(in_context.opengl_api(), leaving transform_feedback:end());
}
Пример #5
0
void
transform_feedback::begin(render_context& in_context, primitive_type in_topology_mode) 
{
    assert(state().ok());
    gl_assert(in_context.opengl_api(), entering transform_feedback:begin());

    const opengl::gl_core& glapi = in_context.opengl_api();

    bind(in_context);
    if (!active()) {
        glapi.glBeginTransformFeedback(util::gl_primitive_type(in_topology_mode));
    }
    gl_assert(in_context.opengl_api(), leaving transform_feedback:begin());

    _active            = true;
    _captured_topology = in_topology_mode;

    gl_assert(in_context.opengl_api(), leaving transform_feedback:begin());
}
Пример #6
0
void
query::end(const render_context& in_context) const
{
    const opengl::gl_core& glapi = in_context.opengl_api();
    assert(0 != query_id());
    assert(0 != query_type());

    glapi.glEndQuery(query_type());

    gl_assert(glapi, leaving query::end());
}
Пример #7
0
void
transform_feedback::unbind(render_context& in_context) const
{
    assert(state().ok());

    if (SCM_GL_CORE_OPENGL_CORE_VERSION >= SCM_GL_CORE_OPENGL_CORE_VERSION_400) {
        assert(object_id() != 0);

        const opengl::gl_core& glapi = in_context.opengl_api();

        glapi.glBindTransformFeedback(object_target(), 0);

        gl_assert(glapi, transform_feedback::unbind() after glBindTransformFeedback());
    }
    else {
        unbind_stream_out_buffers(in_context);
    }

    gl_assert(in_context.opengl_api(), leaving transform_feedback:unbind());
}
Пример #8
0
void
sync::server_wait(const render_context& in_context,
                        scm::uint64     in_timeout) const
{
    const opengl::gl_core& glapi = in_context.opengl_api();
    assert(0 != object());

    glapi.glWaitSync(object(), 0, sync_timeout_ignored);

    gl_assert(glapi, leaving sync::server_wait());
}
Пример #9
0
void
transform_feedback::unbind_stream_out_buffers(render_context& in_context) const
{
    const opengl::gl_core& glapi = in_context.opengl_api();

    for (int bind_index = 0; bind_index < _stream_out_setup.used_streams(); ++bind_index) {
        const buffer_ptr& cur_buffer = _stream_out_setup[bind_index].first;

        if (cur_buffer) {
            cur_buffer->unbind_range(in_context, BIND_TRANSFORM_FEEDBACK_BUFFER, bind_index);
        }
        assert(cur_buffer->ok());
    }
}
Пример #10
0
bool
query::available(const render_context& in_context) const
{
    const opengl::gl_core& glapi = in_context.opengl_api();
    assert(0 != query_id());
    assert(0 != query_type());

    int query_available = GL_FALSE;

    glapi.glGetQueryObjectiv(query_id(), GL_QUERY_RESULT_AVAILABLE, &query_available);
    
    gl_assert(glapi, leaving query::available());

    return query_available != GL_FALSE;
}
Пример #11
0
sync_status
sync::status(const render_context& in_context) const
{
    const opengl::gl_core& glapi = in_context.opengl_api();
    assert(0 != object());

    int cur_status = 0;

    glapi.glGetSynciv(object(), GL_SYNC_STATUS, 1, 0, &cur_status);

    switch (cur_status) {
        case GL_SIGNALED:   return SYNC_SIGNALED;
        case GL_UNSIGNALED:
        default:            return SYNC_UNSIGNALED;
    }

    gl_assert(glapi, leaving sync::status());
}
Пример #12
0
sync_wait_result
sync::client_wait(const render_context& in_context,
                        scm::uint64     in_timeout,
                        bool            in_flush) const
{
    const opengl::gl_core& glapi = in_context.opengl_api();
    assert(0 != object());

    GLenum r = glapi.glClientWaitSync(object(), in_flush ? GL_SYNC_FLUSH_COMMANDS_BIT : 0, in_timeout);

    gl_assert(glapi, leaving sync::client_wait());

    switch (r) {
        case GL_ALREADY_SIGNALED:       return SYNC_WAIT_ALREADY_SIGNALED;
        case GL_CONDITION_SATISFIED:    return SYNC_WAIT_CONDITION_SATISFIED;
        case GL_TIMEOUT_EXPIRED:        return SYNC_WAIT_TIMEOUT_EXPIRED;
        case GL_WAIT_FAILED:
        default:                        return SYNC_WAIT_FAILED;
    }
}
Пример #13
0
void
rasterizer_state::apply(const render_context&   in_context,
                        const float             in_line_width,
                        const float             in_point_size,
                        const rasterizer_state& in_applied_state,
                        const float             in_applied_line_width,
                        const float             in_applied_point_size) const
{
    const opengl::gl_core& glapi = in_context.opengl_api();

    if (_descriptor._fill_mode != in_applied_state._descriptor._fill_mode) {
        glapi.glPolygonMode(GL_FRONT_AND_BACK, util::gl_fill_mode(_descriptor._fill_mode));
        gl_assert(glapi, rasterizer_state::apply() after glPolygonMode);
    }
    if (_descriptor._cull_mode != in_applied_state._descriptor._cull_mode) {
        if (_descriptor._cull_mode == CULL_NONE) {
            glapi.glDisable(GL_CULL_FACE);
        }
        else {
            glapi.glEnable(GL_CULL_FACE);
            glapi.glCullFace(util::gl_cull_mode(_descriptor._cull_mode));
        }
        gl_assert(glapi, rasterizer_state::apply() after glCullFace);
    }
    if (_descriptor._front_face != in_applied_state._descriptor._front_face) {
        glapi.glFrontFace(util::gl_polygon_orientation(_descriptor._front_face));
        gl_assert(glapi, rasterizer_state::apply() after glFrontFace);
    }
    if (_descriptor._multi_sample != in_applied_state._descriptor._multi_sample) {
        if (_descriptor._multi_sample) {
            glapi.glEnable(GL_MULTISAMPLE);
        }
        else {
            glapi.glDisable(GL_MULTISAMPLE);
        }
        gl_assert(glapi, rasterizer_state::apply() after GL_MULTISAMPLE);
    }

    if (SCM_GL_CORE_OPENGL_CORE_VERSION >= SCM_GL_CORE_OPENGL_CORE_VERSION_400) {
        if (   _descriptor._multi_sample
            && _descriptor._sample_shading)
        {
            glapi.glEnable(GL_SAMPLE_SHADING);
        }
        else {
            glapi.glDisable(GL_SAMPLE_SHADING);
        }
        gl_assert(glapi, rasterizer_state::apply() after GL_SAMPLE_SHADING);

        glapi.glMinSampleShading(math::clamp(_descriptor._min_sample_shading, 0.0f, 1.0f));
        gl_assert(glapi, rasterizer_state::apply() after glMinSampleShading);
    }

    if (_descriptor._scissor_test != in_applied_state._descriptor._scissor_test) {
        if (_descriptor._scissor_test) {
            glapi.glEnable(GL_SCISSOR_TEST);
        }
        else {
            glapi.glDisable(GL_SCISSOR_TEST);
        }
        gl_assert(glapi, rasterizer_state::apply() after GL_SCISSOR_TEST);
    }
    if (_descriptor._smooth_lines != in_applied_state._descriptor._smooth_lines) {
        if (_descriptor._smooth_lines) {
            glapi.glEnable(GL_LINE_SMOOTH);
        }
        else {
            glapi.glDisable(GL_LINE_SMOOTH);
        }
        gl_assert(glapi, rasterizer_state::apply() after GL_LINE_SMOOTH);
    }

    if (in_line_width != in_applied_line_width) { // i do no care about float compare at this point
        glapi.glLineWidth(math::max<float>(0.0f, in_line_width));
        gl_assert(glapi, rasterizer_state::apply() after glLineWidth);
    }
    if (in_point_size != in_applied_point_size) { // i do no care about float compare at this point
        glapi.glPointSize(math::max<float>(0.0f, in_point_size));
        gl_assert(glapi, rasterizer_state::apply() after glPointSize);
    }
    if (_descriptor._point_state != in_applied_state._descriptor._point_state) {
        if (_descriptor._point_state._shader_point_size) {
            glapi.glEnable(GL_PROGRAM_POINT_SIZE);
        }
        else {
            glapi.glDisable(GL_PROGRAM_POINT_SIZE);
        }
        glapi.glPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE, math::max<float>(0.0f, _descriptor._point_state._point_fade_threshold));
        glapi.glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, util::gl_origin_mode( _descriptor._point_state._point_origin_mode));
        gl_assert(glapi, rasterizer_state::apply() after glPointParameter);
    }

    gl_assert(glapi, leaving rasterizer_state::apply());
}