Ejemplo n.º 1
0
void
texture_output::draw_texture_2d_uint(const gl::render_context_ptr& context,
                                     const gl::texture_2d_ptr&     tex,
                                     const math::vec4f&            scale,
                                     const math::vec2ui&           position,
                                     const math::vec2ui&           extend) const
{
    using namespace scm::gl;
    using namespace scm::math;

    context_state_objects_guard csg(context);
    context_texture_units_guard tug(context);
    context_framebuffer_guard   fbg(context);

    vec2ui tile_size = vec2ui(0);

    float aspect =  static_cast<float>(tex->descriptor()._size.x)
                  / static_cast<float>(tex->descriptor()._size.y);

    tile_size.x = extend.x;
    tile_size.y = static_cast<unsigned>(tile_size.x / aspect);

    if (tile_size.y > extend.y) {
        tile_size.y = extend.y;
        tile_size.x = static_cast<unsigned>(tile_size.y * aspect);
    }

    context->set_depth_stencil_state(_dstate_no_z_write);
    context->set_blend_state(_bstate_no_blend);
    context->set_rasterizer_state(_rstate_cull_back);

    context->set_viewport(viewport(position, tile_size));

    if (channel_count(tex->descriptor()._format) > 1) {
        _fs_program_color_uint->uniform("in_scale", scale);
        context->bind_program(_fs_program_color_uint);
    }
    else {
        _fs_program_gray_uint->uniform("in_scale", scale);
        context->bind_program(_fs_program_gray_uint);
    }
    context->bind_texture(tex, _filter_nearest, 0/*texture unit 0*/);

    _quad_geom->draw(context, geometry::MODE_SOLID);
}
Ejemplo n.º 2
0
void
application_window::display_scene(const gl::render_context_ptr& context)
{
    using namespace scm::gl;
    using namespace scm::math;

    const mat4f& view_matrix         = _viewer->main_camera().view_matrix();
    const mat4f& proj_matrix         = _viewer->main_camera().projection_matrix();

    { // draw volumes
        context_framebuffer_guard cfg(context);

        //_coord_cross->draw(context, proj_matrix, view_matrix, 4.0f);

        if (_volume_data) {
            vec2f o = vec2f(0.0f, 0.0f);
            vec2f s = vec2f(_viewport_size.x, _viewport_size.y);

            context->set_viewport(viewport(o, s));

#if 1
            mat4f mv_matrix = view_matrix * _volume_data->transform();
            _volume_highlight->draw(context, _volume_data->bbox_geometry(),
                                            proj_matrix, mv_matrix,
                                            geometry::MODE_WIRE_FRAME, vec4f(0.0f, 1.0f, 0.3f, 1.0f), 2.0f);
#endif
            if (_use_opencl_renderer) {
                _volume_renderer_cuda->draw(context, _volume_data_cuda);
                _volume_renderer_cuda->present(context);
            }
            else {
                _volume_renderer->draw(context, _volume_data,
                                       _show_raw ? volume_renderer::volume_raw : volume_renderer::volume_color_map,
                                       _use_sample_shading, _use_volume_supersampling);
            }
        }
    }
}