Esempio n. 1
0
View
sge::d3d9::index_buffer::do_lock(
	sge::renderer::lock_segment const &_segment,
	sge::renderer::lock_flags::method const _method
) const
{
	if(
		lock_dest_
		!=
		nullptr
	)
		throw sge::renderer::exception(
			FCPPT_TEXT("d3d::index_buffer::lock() you have to unlock first!")
		);

	// TODO: Move this to another function
	void *dest(
		nullptr
	);

	if(
		this->get().Lock(
			fcppt::cast::size<
				UINT
			>(
				_segment.pos().x()
				*
				stride_
			),
			fcppt::cast::size<
				UINT
			>(
				_segment.size().w()
				*
				stride_
			),
			&dest,
			sge::d3d9::convert::lock_flags(
				_method,
				this->resource_flags()
			).get()
		)
		!= D3D_OK
	)
		throw sge::renderer::exception(
			FCPPT_TEXT("Cannot lock index buffer!")
		);

	lock_dest_ =
		fcppt::cast::from_void_ptr<
			sge::renderer::raw_pointer
		>(
			dest
		);

	return
		View(
			lock_dest_,
			_segment.size().w(),
			format_
		);
}
Esempio n. 2
0
View
sge::d3d9::vertex::buffer::do_lock(
    sge::renderer::lock_segment const &_segment,
    sge::renderer::lock_flags::method const _method
) const
{
    if(
        lock_dest_
    )
        throw sge::renderer::exception(
            FCPPT_TEXT("d3d::vertex::buffer::lock() you have to unlock first!")
        );

    // TODO: Put this in another function
    void *data(
        nullptr
    );

    if(
        this->get().Lock(
            fcppt::cast::size<
            UINT
            >(
                _segment.pos().x()
                *
                this->stride().get()
            ),
            fcppt::cast::size<
            UINT
            >(
                _segment.size().w()
                *
                this->stride().get()
            ),
            &data,
            sge::d3d9::convert::lock_flags(
                _method,
                this->resource_flags()
            ).get()
        )
        != D3D_OK
    )
        throw sge::renderer::exception(
            FCPPT_TEXT("Cannot lock d3d vertex buffer!")
        );

    lock_dest_ =
        fcppt::cast::from_void_ptr<
        sge::renderer::raw_pointer
        >(
            data
        );

    converter_.lock(
        sge::renderer::vf::dynamic::locked_part(
            lock_dest_,
            _segment,
            _method
        )
    );

    return
        View(
            lock_dest_,
    sge::renderer::vertex::count{
        _segment.size().w()
    },
    this->format(),
    this->format_part_index()
        );
}