• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ VertexLayout类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中VertexLayout的典型用法代码示例。如果您正苦于以下问题:C++ VertexLayout类的具体用法?C++ VertexLayout怎么用?C++ VertexLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: LOG

//----------------------------------------------------------------------
bool FontManager::Initialise(const glm::ivec2& screenResolution)
{
  this->screenResolution = screenResolution;

  if (!effect.Load("assets\\effects\\fonteffect.glsl", "RenderFont"))
  {
    LOG("did not load font rendering effect\n");
    return false;
  }
  // Since the screen resolution does not change at runtime, set this now...
  effect.ScreenSize->Set(glm::vec2(screenResolution));
  effect.GlyphTexture->Set(GlyphTextureSlot);

  sampler = boost::make_shared<Sampler2D>();
  sampler->SetMagFilter(GL_LINEAR);
  sampler->SetMinFilter(GL_LINEAR);
  sampler->SetWrapS(GL_CLAMP_TO_EDGE);
  sampler->SetWrapT(GL_CLAMP_TO_EDGE);

  VertexLayout vertexLayout;
  vertexLayout.AddAttribute(vertexAttribute);

  // Initialise vertex buffers for dynamic update...
  for (size_t i = 0; i < bufferCount; ++i)
  {
    boost::shared_ptr<VertexBuffer> vertexBuffer(new VertexBuffer());
    vertexBuffer->Initialise(vertexLayout, VerticesInBuffer, GL_DYNAMIC_DRAW);
    geometry[i].Initialise(vertexBuffer);
  }

  return true;
}
开发者ID:geoff-wode,项目名称:bfm,代码行数:33,代码来源:font.cpp


示例2: getParticleQuad

//////////////////////////////////////////////////////////////////////////
///  Particle Quad
gfx::ModelMesh* ContentManager::getParticleQuad()
{
    if (m_ParticleQuad == nullptr)
    {    
        using namespace gfx;
        VertexLayout layout;
        layout.addElement(VertexElement(eShaderAttribute_Position, eShaderAttributeType_Float, eShaderAttributeTypeComponents_3, 0));

        he::ObjectList<VertexPos> vertices(4);
        vertices.add(VertexPos(vec3(-1, 1, 0.0f)));
        vertices.add(VertexPos(vec3(1, 1, 0.0f)));
        vertices.add(VertexPos(vec3(-1, -1, 0.0f)));
        vertices.add(VertexPos(vec3(1, -1, 0.0f)));

        he::PrimitiveList<uint16> indices(6);
        indices.add(1); indices.add(0); indices.add(2);
        indices.add(1); indices.add(2); indices.add(3);

        ObjectHandle handle(ResourceFactory<ModelMesh>::getInstance()->create());
        m_ParticleQuad = ResourceFactory<ModelMesh>::getInstance()->get(handle);
        m_ParticleQuad->setName(he::String("Particle quad"));

        m_ParticleQuad->init(layout, gfx::MeshDrawMode_Triangles);
        m_ParticleQuad->setVertices(&vertices[0], 4, gfx::MeshUsage_Static, false);
        m_ParticleQuad->setIndices(&indices[0], 6, gfx::IndexStride_UShort, gfx::MeshUsage_Static);
        m_ParticleQuad->setLoaded(eLoadResult_Success);
    }

    m_ParticleQuad->instantiate();
    return m_ParticleQuad;
}
开发者ID:EvilInteractive,项目名称:happy-engine,代码行数:33,代码来源:ContentManager.cpp


示例3: GetVertexLayout

    static VertexLayout GetVertexLayout( PC_Vertexes& vertexes )
    {
        VertexLayout layout;

        layout.push_back( VertexAttributeProperties( "inPosition", 3, GL_FLOAT, false, sizeof( Vertex3D_PC ), (int) &vertexes[0].position ) );
        layout.push_back( VertexAttributeProperties( "inColor", 4, GL_UNSIGNED_BYTE, true, sizeof( Vertex3D_PC ), (int) &vertexes[0].color ) );

        return layout;
    }
开发者ID:tbgeorge,项目名称:putty_engine,代码行数:9,代码来源:Vertex3D.hpp


示例4: sizeof

VertexLayout VertexLayout::GetDefaultTerrainVertexLayout()
{
	const int structSize = sizeof(VertexDataTerrain);

	VertexLayout layout;
	layout.AddEntry("position", 0, 3, Float, false, structSize, (const void*)(offsetof(VertexDataTerrain, Position)));
	layout.AddEntry("uv", 1, 2, Float, false, structSize, (const void*)(offsetof(VertexDataTerrain, UV)));

	return layout;
}
开发者ID:dazzlex27,项目名称:S3DGE,代码行数:10,代码来源:VertexLayout.cpp


示例5: initialize

void Vao::initialize(RenderState& rs, ShaderProgram& _program, const VertexOffsets& _vertexOffsets,
                     VertexLayout& _layout, GLuint _vertexBuffer, GLuint _indexBuffer) {

    m_glVAOs.resize(_vertexOffsets.size());

    GL::genVertexArrays(m_glVAOs.size(), m_glVAOs.data());

    fastmap<std::string, GLuint> locations;

    // FIXME (use a bindAttrib instead of getLocation) to make those locations shader independent
    for (auto& attrib : _layout.getAttribs()) {
        GLint location = _program.getAttribLocation(attrib.name);
        locations[attrib.name] = location;
    }

    rs.vertexBuffer(_vertexBuffer);

    int vertexOffset = 0;
    for (size_t i = 0; i < _vertexOffsets.size(); ++i) {
        auto vertexIndexOffset = _vertexOffsets[i];
        int nVerts = vertexIndexOffset.second;
        GL::bindVertexArray(m_glVAOs[i]);

        // ELEMENT_ARRAY_BUFFER must be bound after bindVertexArray to be used by VAO
        if (_indexBuffer != 0) {
            rs.indexBufferUnset(_indexBuffer);
            rs.indexBuffer(_indexBuffer);
        }

        // Enable vertex layout on the specified locations
        _layout.enable(locations, vertexOffset * _layout.getStride());

        vertexOffset += nVerts;
    }

    GL::bindVertexArray(0);

    rs.vertexBuffer(0);
    rs.indexBuffer(0);
}
开发者ID:enterstudio,项目名称:tangram-es,代码行数:40,代码来源:vao.cpp


示例6:

bool D3DVertexBuffer::create(const VertexLayout& layout, int length, int usage)
{
   mStride = layout.getStride();

   D3D11_BUFFER_DESC desc = {0};
   desc.ByteWidth = mStride * length;
   desc.Usage = D3D11_USAGE_DYNAMIC;
   desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
   desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
   desc.MiscFlags = 0;
   desc.StructureByteStride = 0;

   HRESULT hr = mDevice.getDevice().CreateBuffer(&desc, NULL, &mpBuffer);
   if ( FAILED(hr) )
      return false;

   return true;
}
开发者ID:crafter2d,项目名称:crafter2d,代码行数:18,代码来源:d3dvertexbuffer.cpp


示例7: init

void Vao::init(GLuint _vertexBuffer, GLuint _indexBuffer,
    VertexLayout& _layout,
    const std::unordered_map<std::string, GLuint>&
    _locations)
{
    generate();

    // Bind the vertex array for initialization
    bind();

    // Bind the vertex and index buffer
    if (_vertexBuffer) {
        GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer));
    }

    if (_indexBuffer) {
        GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer));
    }

    _layout.enable(_locations);

    // Make sure VAO is not modified outside
    unbind();
}
开发者ID:ForeverDavid,项目名称:oglw,代码行数:24,代码来源:vao.cpp


示例8: OnAttach

	bool Impl_SkyBox::OnAttach()
	{
		m_pRD = m_pManager->alloc_object<RenderData>();

		
		VertexLayout layout;
		layout.AddAttribute(G_FORMAT_R32G32B32_FLOAT);
		
		float size = 1.0f;
		int nVerts = 36;

		math::Vector3 verts[] = 
		{
			math::Vector3(-size, size, -size),
			math::Vector3(size, -size, -size),
			math::Vector3(size, size, -size),

			math::Vector3(-size, size, -size),
			math::Vector3(-size, -size, -size),
			math::Vector3(size, -size, -size),

			math::Vector3(-size, size, size),
			math::Vector3(size, size, size),
			math::Vector3(size, -size, size),

			math::Vector3(-size, size, size),
			math::Vector3(size, -size, size),
			math::Vector3(-size, -size, size),


			math::Vector3(-size, size, size),
			math::Vector3(size, size, -size),
			math::Vector3(size, size, size),

			math::Vector3(-size, size, size),
			math::Vector3(-size, size, -size),
			math::Vector3(size, size, -size),


			math::Vector3(-size, -size, size),
			math::Vector3(size, -size, size),
			math::Vector3(size, -size, -size),

			math::Vector3(-size, -size, size),
			math::Vector3(size, -size, -size),
			math::Vector3(-size, -size, -size),


			math::Vector3(-size, size, size),
			math::Vector3(-size, -size, -size),
			math::Vector3(-size, size, -size),

			math::Vector3(-size, size, size),
			math::Vector3(-size, -size, size),
			math::Vector3(-size, -size, -size),


			math::Vector3(size, size, size),
			math::Vector3(size, size, -size),
			math::Vector3(size, -size, -size),

			math::Vector3(size, size, size),
			math::Vector3(size, -size, -size),
			math::Vector3(size, -size, size),

		};

		m_pRD->geometry = m_pManager->GetRenderManager()->CreateGeometryData();

		m_pRD->geometry->BeginGeometry(PT_TRIANGLE_LIST);
		{
			m_pRD->geometry->AllocVertexBuffer(sizeof(math::Vector3) * 36, verts, false, layout);
		}
		m_pRD->geometry->EndGeometry();

		m_pRD->base_vertex = 0;
		m_pRD->index_count = 0;
		m_pRD->start_index = 0;
		m_pRD->vertex_count = 36;
		m_pRD->world_matrix.MakeIdentity();

		m_pRD->material = m_pManager->GetRenderManager()->CreateMaterialFromFile("./assets/standard/material/skybox.material");

		m_hFrustumCull = m_pManager->AddEventHandler(EV_FRUSTUM_CULL, boost::bind(&Impl_SkyBox::on_event_frustum_cull, this, _1));


		m_pTex = m_pManager->GetRenderManager()->CreateTextureFromFile("./assets/standard/texture/001.dds");

		MaterialParameterPtr pParam = m_pRD->material->GetParameterByName("sky_map");
		
		pParam->SetParameterTexture(m_pTex);
		
		m_pWorldPos = m_pRD->material->GetParameterByName("world_pos");
		return true;
	}
开发者ID:johndragon,项目名称:ld3d,代码行数:95,代码来源:Impl_SkyBox.cpp


示例9: HE_ASSERT

void SkyBox::load( const he::String& asset )
{
    HE_ASSERT(m_Drawable == nullptr, "Skybox is loaded twice!");
    m_Drawable = HENew(Drawable)();
    m_Drawable->setLocalScale(vec3(1000000000)); // bounds must be huge
    //////////////////////////////////////////////////////////////////////////
    /// Load Model
    //////////////////////////////////////////////////////////////////////////
    ModelMesh* const cube(
        ResourceFactory<gfx::ModelMesh>::getInstance()->get(ResourceFactory<gfx::ModelMesh>::getInstance()->create()));
    cube->setName(he::String("skybox-") + asset);
    he::PrimitiveList<vec3> vertices(8);
    vertices.add(vec3(-1,  1, -1));
    vertices.add(vec3( 1,  1, -1));
    vertices.add(vec3(-1, -1, -1));
    vertices.add(vec3( 1, -1, -1));

    vertices.add(vec3(-1,  1,  1));
    vertices.add(vec3( 1,  1,  1));
    vertices.add(vec3(-1, -1,  1));
    vertices.add(vec3( 1, -1,  1));

    he::PrimitiveList<uint16> indices(36);
    indices.add(0); indices.add(1); indices.add(2); //front
    indices.add(1); indices.add(3); indices.add(2);

    indices.add(5); indices.add(4); indices.add(7); //back
    indices.add(4); indices.add(6); indices.add(7);

    indices.add(4); indices.add(0); indices.add(6); //left
    indices.add(0); indices.add(2); indices.add(6);

    indices.add(1); indices.add(5); indices.add(3); //right
    indices.add(5); indices.add(7); indices.add(3);

    indices.add(4); indices.add(5); indices.add(0); //top
    indices.add(5); indices.add(1); indices.add(0);

    indices.add(3); indices.add(7); indices.add(2); //bottom
    indices.add(7); indices.add(6); indices.add(2);

    VertexLayout layout;
    layout.addElement(VertexElement(eShaderAttribute_Position, eShaderAttributeType_Float, eShaderAttributeTypeComponents_3, 0));
    cube->init(layout, MeshDrawMode_Triangles);
    cube->setVertices(&vertices[0], static_cast<uint32>(vertices.size()), MeshUsage_Static, false);
    cube->setIndices(&indices[0], static_cast<uint32>(indices.size()), IndexStride_UShort, MeshUsage_Static);
    cube->setLoaded(eLoadResult_Success);
    m_Drawable->setModelMesh(cube);
    cube->release();

    Material* const material(CONTENT->loadMaterial("engine/sky.material"));
    m_Drawable->setMaterial(material);
    material->release();

    const int8 cubeMap(m_Drawable->getMaterial()->findParameter(HEFS::strcubeMap));
    if (cubeMap >= 0)
    {
        const TextureCube* cube(CONTENT->asyncLoadTextureCube(asset));
        m_Drawable->getMaterial()->getParameter(cubeMap).setTextureCube(cube);
        cube->release();
    }
}
开发者ID:EvilInteractive,项目名称:happy-engine,代码行数:62,代码来源:SkyBox.cpp


示例10:

VertexLayout::VertexLayout(const VertexLayout& layout)
{
	for (auto item : layout.GetAttributes())
		_attributes.emplace_back(item);
}
开发者ID:dazzlex27,项目名称:S3DGE,代码行数:5,代码来源:VertexLayout.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ VertexList类代码示例发布时间:2022-05-31
下一篇:
C++ VertexFormat类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap