Example #1
0
void
sge::postprocessing::fullscreen_quad::render(
	sge::renderer::context::core &_context)
{
	sge::renderer::vertex::scoped_declaration scoped_vd(
		_context,
		vertex_declaration_);

	sge::renderer::vertex::scoped_buffer scoped_vb(
		_context,
		*vertex_buffer_);

	_context.render_nonindexed(
		sge::renderer::vertex::first(
			0u),
		sge::renderer::vertex::count(
			vertex_buffer_->linear_size()),
		sge::renderer::primitive_type::triangle_strip);
}
Example #2
0
void
fruitapp::fruit::rendering::ffp::render(
	sge::renderer::context::core &_context)
{
	sge::renderer::context::ffp &ffp_context(
		dynamic_cast<sge::renderer::context::ffp &>(
			_context));

	sge::renderer::state::ffp::lighting::scoped const scoped_lighting(
		ffp_context,
		*lighting_);

	sge::renderer::state::ffp::lighting::light::scoped const scoped_light(
		ffp_context,
		sge::renderer::state::ffp::lighting::light::const_object_ref_vector{
			fcppt::make_cref(
				*light_)});

	sge::renderer::state::core::depth_stencil::scoped scoped_depth_stencil(
		ffp_context,
		*depth_stencil_state_);

	sge::renderer::state::ffp::transform::object_unique_ptr const projection_state(
		renderer_.create_transform_state(
			sge::renderer::state::ffp::transform::parameters(
				camera_.projection_matrix().get())));

	sge::renderer::state::ffp::transform::scoped const projection_transform(
		ffp_context,
		sge::renderer::state::ffp::transform::mode::projection,
		*projection_state);

	sge::renderer::vertex::scoped_declaration scoped_vd(
		ffp_context,
		manager_.vertex_declaration());

	fruitapp::fruit::rendering::fruit_pointer_sequence fruit_pointers;
	fruitapp::fruit::rendering::sort_fruits(
		manager_.fruits(),
		fruit_pointers);

	fruitapp::fruit::prototype const *previous_prototype =
		nullptr;

	fcppt::optional::object<
		sge::renderer::state::ffp::lighting::material::object_unique_ptr
	>
	previous_material_state;

	for(
		fruitapp::fruit::rendering::fruit_pointer_sequence::const_iterator i =
			fruit_pointers.begin();
		i != fruit_pointers.end();
		++i)
	{
		sge::renderer::vertex::scoped_buffer scoped_vb(
			_context,
			(*i)->vb());

		sge::renderer::state::ffp::transform::object_unique_ptr const world_state(
			renderer_.create_transform_state(
				sge::renderer::state::ffp::transform::parameters(
					sge::camera::matrix_conversion::world(
						camera_.coordinate_system()) *
					(*i)->world_transform())));

		sge::renderer::state::ffp::transform::scoped const world_transform(
			ffp_context,
			sge::renderer::state::ffp::transform::mode::world,
			*world_state);

		if(&((*i)->prototype()) != previous_prototype)
		{
			ffp_context.texture(
				sge::renderer::texture::const_optional_base_ref(
					fcppt::reference_to_base<
						sge::renderer::texture::base const
					>(
						fcppt::make_cref(
							*(*i)->prototype().texture()))),
				sge::renderer::texture::stage(
					0u));

			sge::renderer::state::ffp::lighting::material::object_unique_ptr const &material_state(
				fcppt::optional::assign(
					previous_material_state,
					renderer_.create_material_state(
						fruit_material_to_ffp_material(
							(*i)->prototype().material(),
							ambient_intensity_))));

			ffp_context.material_state(
				sge::renderer::state::ffp::lighting::material::const_optional_object_ref(
					fcppt::make_cref(
						*material_state)));

			previous_prototype =
				&((*i)->prototype());
		}

		ffp_context.render_nonindexed(
			sge::renderer::vertex::first(
				static_cast<sge::renderer::size_type>(
					0)),
			sge::renderer::vertex::count(
				(*i)->vb().linear_size()),
			sge::renderer::primitive_type::triangle_list);
	}

	ffp_context.texture(
		sge::renderer::texture::const_optional_base_ref(),
		sge::renderer::texture::stage(
			0u));

	ffp_context.material_state(
		sge::renderer::state::ffp::lighting::material::const_optional_object_ref());
}
Example #3
0
void
flake::volume::density_visualization::raycaster::object::render(
	sge::renderer::context::core &_context)
{
	sge::renderer::vertex::scoped_declaration scoped_vd(
		_context,
		*vertex_declaration_);

	sge::shader::scoped_pair scoped_shader(
		_context,
		shader_);

	mvp_parameter_.set(
		sge::camera::matrix_conversion::world_projection(
			camera_.coordinate_system(),
			camera_.projection_matrix()));

	camera_position_parameter_.set(
		-camera_.coordinate_system().position().get());

	camera_is_inside_cube_parameter_.set(
		this->camera_is_inside_cube()
		?
			static_cast<sge::renderer::scalar>(
				1.0f)
		:
			static_cast<sge::renderer::scalar>(
				0.0f));

	sge::renderer::state::core::blend::scoped scoped_blend_state(
		_context,
		*blend_state_);

	sge::renderer::state::core::rasterizer::object_unique_ptr const rasterizer_state(
		renderer_.create_rasterizer_state(
			sge::renderer::state::core::rasterizer::parameters(
				this->camera_is_inside_cube()
				?
					sge::renderer::state::core::rasterizer::cull_mode::counter_clockwise
				:
					sge::renderer::state::core::rasterizer::cull_mode::clockwise,
				sge::renderer::state::core::rasterizer::fill_mode::solid,
				sge::renderer::state::core::rasterizer::enable_scissor_test(
					false))));

	sge::renderer::state::core::rasterizer::scoped scoped_rasterizer_state(
		_context,
		*rasterizer_state);

	sge::renderer::state::core::sampler::scoped scoped_sampler_state{
		_context,
		sge::renderer::state::core::sampler::const_object_ref_map{
			sge::renderer::state::core::sampler::const_object_ref_map::value_type{
				sge::renderer::texture::stage{
					0u
				},
				fcppt::make_cref(
					*sampler_state_
				)
			}
		}
	};

	sge::renderer::vertex::scoped_buffer scoped_vb(
		_context,
		*vertex_buffer_);

	_context.render_nonindexed(
		sge::renderer::vertex::first(
			0u),
		sge::renderer::vertex::count(
			36u),
		sge::renderer::primitive_type::triangle_list);
}