当前位置: 首页>>代码示例>>C++>>正文


C++ Shared::apply方法代码示例

本文整理汇总了C++中Shared::apply方法的典型用法代码示例。如果您正苦于以下问题:C++ Shared::apply方法的具体用法?C++ Shared::apply怎么用?C++ Shared::apply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Shared的用法示例。


在下文中一共展示了Shared::apply方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: will_become_current

	void MazeSolverScene::will_become_current(ISceneManager * manager) {
		Scene::will_become_current(manager);
		//_grid = new Grid ();
		//_axes = new Axes ();

		_camera = new BirdsEyeCamera;
		Ref<IProjection> projection = new PerspectiveProjection(R90, 1.0, 1024.0);
		
		_renderer_state = new RendererState;
		_renderer_state->shader_manager = new ShaderManager;
		_renderer_state->texture_manager = new TextureManager;
		_renderer_state->resource_loader = manager->resource_loader();
		_renderer_state->viewport = new Viewport(_camera, projection);

		{
			_flat_program = _renderer_state->load_program("Shaders/flat");
			_flat_program->set_attribute_location("position", POSITION);
			_flat_program->set_attribute_location("normal", NORMAL);
			_flat_program->set_attribute_location("mapping", MAPPING);
			_flat_program->link();

			auto binding = _flat_program->binding();
			binding.set_texture_unit("diffuse_texture", 0);
		}

		{
			_wireframe_program = _renderer_state->load_program("Shaders/wireframe");
			_wireframe_program->set_attribute_location("position", WireframeRenderer::POSITION);
			_wireframe_program->link();

			_wireframe_renderer = new WireframeRenderer;
		}

		{
			using namespace Geometry;

			Shared<MeshT> mesh = new MeshT;
			mesh->layout = LINES;
			Generate::grid(*mesh, 32, 2.0);

			_grid_mesh_buffer = new MeshBuffer<MeshT>();
			_grid_mesh_buffer->set_mesh(mesh);

			{
				auto binding = _grid_mesh_buffer->vertex_array().binding();

				// Attach indices
				binding.attach(_grid_mesh_buffer->index_buffer());

				// Attach attributes
				auto attributes = binding.attach(_grid_mesh_buffer->vertex_buffer());
				attributes[POSITION] = &MeshT::VertexT::position;
				attributes[NORMAL] = &MeshT::VertexT::normal;
				attributes[MAPPING] = &MeshT::VertexT::mapping;
			}
		}

		{
			Shared<MeshT> mesh = new MeshT;
			Generate::plane(*mesh, Vec2(9.6, 9.6));
			mesh->layout = Geometry::TRIANGLE_FAN;

			_floor_mesh_buffer = new MeshBufferT(mesh);

			{
				auto binding = _floor_mesh_buffer->vertex_array().binding();

				// Attach indices
				binding.attach(_floor_mesh_buffer->index_buffer());

				// Attach attributes
				auto attributes = binding.attach(_floor_mesh_buffer->vertex_buffer());
				attributes[POSITION] = &MeshT::VertexT::position;
				attributes[NORMAL] = &MeshT::VertexT::normal;
				attributes[MAPPING] = &MeshT::VertexT::mapping;
			}
		}

		{
			Shared<MeshT> mesh = new MeshT;
			Generate::plane(*mesh, Vec2(9.6, 9.6));
			mesh->layout = Geometry::TRIANGLE_FAN;

			Mat44 transform = IDENTITY;
			transform = transform.translated_matrix(Vec3(-10, 0, 10));
			transform = transform * transform.rotating_matrix_around_y(R90);
			mesh->apply(transform);

			_wall_mesh_buffer = new MeshBufferT(mesh);

			{
				auto binding = _wall_mesh_buffer->vertex_array().binding();

				// Attach indices
				binding.attach(_wall_mesh_buffer->index_buffer());

				// Attach attributes
				auto attributes = binding.attach(_wall_mesh_buffer->vertex_buffer());
				attributes[POSITION] = &MeshT::VertexT::position;
				attributes[NORMAL] = &MeshT::VertexT::normal;
//.........这里部分代码省略.........
开发者ID:DerDolch,项目名称:dream-examples,代码行数:101,代码来源:MazeSolverScene.cpp


注:本文中的Shared::apply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。