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

C++ VertexBuffer类代码示例

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

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



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

示例1: draw_elements

	void Painter::draw_elements(DrawMode mode,
	                            VertexBuffer& indices,
	                            etc::size_type start,
	                            etc::size_type count)
	{
		ETC_TRACE.debug("draw elements");
		if (indices.attributes().size() == 0)
			throw Exception{
				"No attributes found in indices VertexBuffer."
			};
		if (indices.attributes().size() > 1)
			throw Exception{
				"Indices VertexBuffer contains more that one attributes."
			};

		auto const& attr = indices.attributes()[0];


		if (count == ((etc::size_type) -1))
			count = attr->nb_elements - start;
		else if (count > attr->nb_elements - start)
			throw Exception{"Count is out of range."};

		Bindable::Guard guard{indices, this->state()};
		_renderer.draw_elements(
			mode,
			count,
			attr->type,
			(uint8_t*)0 + (start * get_content_type_size(attr->type))
		);
	}
开发者ID:hotgloupi,项目名称:8cube,代码行数:31,代码来源:Painter.cpp


示例2: OnFirstUpdate

void SkinController::OnFirstUpdate()
{
    // Get access to the vertex buffer positions to store the blended targets.
    Visual* visual = reinterpret_cast<Visual*>(mObject);
    VertexBuffer* vbuffer = visual->GetVertexBuffer().get();
    if (mNumVertices == static_cast<int>(vbuffer->GetNumElements()))
    {
        // Get the position data.
        VertexFormat vformat = vbuffer->GetFormat();
        int const numAttributes = vformat.GetNumAttributes();
        for (int i = 0; i < numAttributes; ++i)
        {
            VASemantic semantic;
            DFType type;
            unsigned int unit, offset;
            if (vformat.GetAttribute(i, semantic, type, unit, offset))
            {
                if (semantic == VA_POSITION && (type == DF_R32G32B32_FLOAT 
                    || type == DF_R32G32B32A32_FLOAT))
                {
                    mPosition = vbuffer->GetData() + offset;
                    mStride = vformat.GetVertexSize();
                    mCanUpdate = true;
                    break;
                }
            }
        }
    }

    mCanUpdate = (mPosition != nullptr);
}
开发者ID:c0g,项目名称:FaceWarpApp,代码行数:31,代码来源:GteSkinController.cpp


示例3: VertexBuffer

VertexBuffer *VertexBuffer::createQuad() {
    VertexBuffer *vbo = new VertexBuffer();


    GLfloat vertices[] = {0, 1.0, 0, // top left corner
                          1.0, 1.0, 0, // top right corner
                          1.0, 0, 0, // bottom right corner
                          0, 0, 0}; // bottom left corner

    GLfloat uvs[] = {
            0, 1,
            1, 1,
            1, 0,
            0, 0
    };

    GLubyte indices[] = {0,1,2, // first triangle (bottom left - top left - top right)
            0,2,3}; // second triangle (bottom left - top right - bottom right)

    for(int i = 0; i < 4; i++)
        vbo->addVertex(glm::vec3(vertices[i*3], vertices[(i*3)+1], vertices[(i*3)+2]));

    for(int i = 0; i < 4; i++)
        vbo->addUV(glm::vec2(uvs[i*2], uvs[(i*2)+1]));

    for(int i = 0; i < 6; i++)
        vbo->addIndex(indices[i]);
    vbo->upload();
    return vbo;
}
开发者ID:tdgunes,项目名称:Spy-E,代码行数:30,代码来源:VertexBuffer.cpp


示例4: doadvance

	void PrimitiveShape::doadvance()
	{
		VertexBuffer* vb = m_vertexbuffer;
		if( vb )
		{
			vb->advance();
		}
		// IndexBuffer* ib = m_indexbuffer;
		// if( ib )
		// {
			// ib->advance();
		// }
		Program* pr = m_program;
		if( pr )
		{
			pr->advance();
		}
		// for( int i = 0; i < 8; ++i )
		// {
			// Texture* t = m_textures[ i ];
			// if( t )
			// {
				// t->advance();
			// }
		// }
	}
开发者ID:delfigamer,项目名称:mist,代码行数:26,代码来源:primitiveshape.cpp


示例5: sizeof

bool Fluids3DWindow::CreateNestedBoxes()
{
    std::string path = mEnvironment.GetPath("VolumeRender.hlsl");
    std::shared_ptr<VisualProgram> program =
        mProgramFactory.CreateFromFiles(path, path, "");
    if (!program)
    {
        return false;
    }

    mPVWMatrixBuffer = std::make_shared<ConstantBuffer>(
        sizeof(Matrix4x4<float>), true);
    *mPVWMatrixBuffer->Get<Matrix4x4<float>>() = Matrix4x4<float>::Identity();

    mTrilinearClampSampler = std::make_shared<SamplerState>();
    mTrilinearClampSampler->filter = SamplerState::MIN_L_MAG_L_MIP_P;
    mTrilinearClampSampler->mode[0] = SamplerState::CLAMP;
    mTrilinearClampSampler->mode[1] = SamplerState::CLAMP;
    mTrilinearClampSampler->mode[2] = SamplerState::CLAMP;

    program->GetVShader()->Set("PVWMatrix", mPVWMatrixBuffer);
    program->GetPShader()->Set("volumeTexture", mFluid.GetState());
    program->GetPShader()->Set("trilinearClampSampler",
        mTrilinearClampSampler);

    std::shared_ptr<VisualEffect> effect =
        std::make_shared<VisualEffect>(program);

    struct Vertex { Vector3<float> position, tcoord; };
    VertexFormat vformat;
    vformat.Bind(VA_POSITION, DF_R32G32B32_FLOAT, 0);
    vformat.Bind(VA_TEXCOORD, DF_R32G32B32_FLOAT, 0);

    MeshFactory mf;
    mf.SetVertexFormat(vformat);
    int const numBoxes = 128;
    for (int i = 1; i <= numBoxes; ++i)
    {
        float extent = 0.5f*i/(numBoxes - 1.0f);
        std::shared_ptr<Visual> visual(mf.CreateBox(extent, extent, extent));
        VertexBuffer* vbuffer = visual->GetVertexBuffer().get();
        Vertex* vertex = vbuffer->Get<Vertex>();
        for (unsigned int j = 0; j < vbuffer->GetNumElements(); ++j, ++vertex)
        {
            Vector3<float>& tcd = vertex->tcoord;
            Vector3<float> pos = vertex->position;
            Vector4<float> tmp{ pos[0] + 0.5f, pos[1] + 0.5f, pos[2] + 0.5f,
                0.0f };
            for (int k = 0; k < 3; ++k)
            {
                tcd[k] = 0.5f*(tmp[k] + 1.0f);
            }
        }

        visual->SetEffect(effect);
        mVisible.push_back(visual);
    }

    return true;
}
开发者ID:c0g,项目名称:FaceWarpApp,代码行数:60,代码来源:Fluids3DWindow.cpp


示例6: vba

//----------------------------------------------------------------------------
void GeoObjFactory::UpdateCtrlColor1(Movable *mov, Float4 color)
{
	PX2::Node *node = DynamicCast<Node>(mov);

	if (!node)
		return;

	for (int i = 0; i < node->GetNumChildren(); i++)
	{
		PX2::Movable *child = node->GetChild(i);
		PX2::TriMesh *mesh = DynamicCast<TriMesh>(child);
		if (mesh)
		{
			VertexBuffer *vBuffer = mesh->GetVertexBuffer();

			VertexFormat *vf = PX2_GR.GetVertexFormat(GraphicsRoot::VFT_PC);
			VertexBufferAccessor vba(vf, vBuffer);
			for (int i = 0; i < vBuffer->GetNumElements(); i++)
			{
				vba.Color<Float4>(0, i) = color;
			}

			Renderer::UpdateAll(vBuffer);
		}

	}
}
开发者ID:PhoenixSteam,项目名称:Phoenix3D,代码行数:28,代码来源:PX2GeoObjFactory.cpp


示例7: Process

void ProjectPass::Process(VertexBuffer& localBuf,VertexBuffer& globalBuf,Int32 p)
{
    VertexBuffer& buf = p < 0 ? globalBuf : localBuf;
    p = p >= 0 ? p : -p;
    Point& pt = buf.GetPosition(p);
    pt = r_pCamera->GetProjectMatrix() * pt;
    pt.ProjectDiv();
    pt = r_pCamera->GetScreenMatrix() * pt;

    if(localBuf.HasAttribute(VA_TEXTCOOR))
    {
	TextureCoord& coor = buf.GetTextureCoord(p);
	coor.t *= pt.z;
	coor.s *= pt.z;
        Int32 nT = TextFix::Double2Fix(coor.t);
        Int32 nS = TextFix::Double2Fix(coor.s);
	++nS;
    }

    if(localBuf.HasAttribute(VA_TEXTCOOR1))
    {
	TextureCoord& coor1 = buf.GetTextureCoord1(p);
	coor1.t *= pt.z;
	coor1.s *= pt.z;
        TextFix::Double2Fix(coor1.t);
        TextFix::Double2Fix(coor1.s);
    }
    Fix28::Double2Fix(pt.z);
}
开发者ID:shgli,项目名称:GameEngine,代码行数:29,代码来源:ProjectPass.cpp


示例8: UpdateCbPerDraw

void BasicRenderer::DrawIndexedPrimitive(PrimitiveTypeEnum pt,                                                             
                        ObjectGUID vbId, 
                        ObjectGUID ibId,
                        uint32_t startIndex,
                        uint32_t indexCount,
                        uint32_t startVertex,                        
                        float* color,
                        float* xform)                        
 {
    if(!m_context) return; 
    UpdateCbPerDraw(xform,color);
	
	// Set primitive topology
    m_context->IASetPrimitiveTopology( (D3D11_PRIMITIVE_TOPOLOGY)pt );	

    // set vertex buffer
    VertexBuffer* vb = reinterpret_cast<VertexBuffer*>(vbId);
    UINT stride = vb->GetStride();    
    UINT Offset = 0;
    ID3D11Buffer* buffer = vb->GetBuffer();
    m_context->IASetVertexBuffers( 0, 1, &buffer, &stride, &Offset);

    // set index buffer
    IndexBuffer* ib = reinterpret_cast<IndexBuffer*>(ibId);
    m_context->IASetIndexBuffer(ib->GetBuffer(),(DXGI_FORMAT)ib->GetFormat(),0);

    m_context->DrawIndexed(indexCount,startIndex,startVertex);	
   
 }
开发者ID:Clever-Boy,项目名称:XLE,代码行数:29,代码来源:BasicRenderer.cpp


示例9: cos

	Skydome::Skydome() {
		VertexBuffer buff;
		int nb_segments=64;
		int i,j;
	
		const float R = 1./(float)(nb_segments-1);
		
		for(i = 0; i<nb_segments; i++) {
			for(j = 0; j<nb_segments; j++) {
				float x = cos(2*M_PI*j*R)*sin(M_PI*i*R);
				float y = sin(-M_PI_2+M_PI*i*R);
				float z = sin(2*M_PI*j*R)*sin(M_PI*i*R);
				buff.addVertex(Vertex3D(glm::vec3(x,y,z), glm::vec3(-x,-y,-z), glm::vec2(0,0), sf::Color(255,255,255,255)));

			}
		}

		for(i=0; i<nb_segments; i++){
			for(j=0; j<nb_segments; j++){
				//buff.getVertex(i*nb_segments+j).normal = glm::normalize(buff.getVertex(i*nb_segments+j).normal);
				buff.addTriangle(sf::Vector3i((i*nb_segments+j), (i*nb_segments+j+1), ((i+1)*nb_segments+j)));
				buff.addTriangle(sf::Vector3i((i*nb_segments+j+1), ((i+1)*nb_segments+j+1), ((i+1)*nb_segments+j)));
			}
		}

		loadFromMemory(buff);
	}
开发者ID:IMACoconut,项目名称:ImaKart,代码行数:27,代码来源:Skydome.cpp


示例10: SHOOT_ASSERT

	//! adds an entity to a render map
	void EntityRenderer::AddToRenderMap(RenderMap& renderMap, GraphicComponent* pGraphic)
	{
		Material* pMaterial = pGraphic->GetMaterial();
		VertexBuffer* pVertexBuffer = pGraphic->GetVertexBuffer();
		
		if(pMaterial && pVertexBuffer)
		{
			if(pVertexBuffer->GetNumVertices() || pVertexBuffer->GetNumIndices())
			{
				SHOOT_ASSERT(pGraphic->GetParent()->IsA(RenderableEntity::TypeID), "Invalid GraphicComponent");
				RenderableEntity* pEntity = static_cast<RenderableEntity*>(pGraphic->GetParent());
				u32 materialID = (u32)pMaterial;
				u32 ID = ((pGraphic->GetRenderingPriority()&0xFF)<<24) | (materialID&0x00FFFFFF);

				u32 vbID = (u32)pVertexBuffer;
				renderMap[ID].pMaterial = pMaterial;
				renderMap[ID].m_VertexMap[vbID].pVertexBuffer = pVertexBuffer;
				renderMap[ID].m_VertexMap[vbID].aWorldTransforms.push_back(pEntity->GetTransformationMatrix());
				renderMap[ID].m_VertexMap[vbID].aTextureTransforms.push_back(pEntity->GetTextureTransformationMatrix());
			}
		}
		else
		{
			SHOOT_WARNING(false, "Incomplete GraphicComponent found");
		}
	}
开发者ID:aminere,项目名称:VLADHeavyStrikePublic,代码行数:27,代码来源:EntityRenderer.cpp


示例11:

const ShaderFeatures& Submesh::features()
{
	if (mFeatures.isEmpty() && !mVertexBuffers.empty()) {
		// build the features struct
		for (VertexBuffers::iterator it = mVertexBuffers.begin(); it != mVertexBuffers.end(); ++it) {
			VertexBuffer* vb = *it;
			int nElems = vb->vertexElementCount();
			for (int i=0; i<nElems; ++i) {
				VertexElement* elem = vb->vertexElement(i);
				switch(elem->mUsage) {
					case VEU_POSITION:
						mFeatures.setFeature(INTERP_POSITION);
						break;
					case VEU_NORMAL:
						mFeatures.setFeature(INTERP_NORMAL);
						break;
					case VEU_TEXCOORD:
						mFeatures.setFeature(INTERP_TEXCOORD, elem->mIndex);
						break;
				}
			}
		}
	}

	return mFeatures;
}
开发者ID:nbtdev,项目名称:teardrop,代码行数:26,代码来源:Submesh.cpp


示例12: VertexBuffer

VertexBuffer* VertexBufferManager::CreateVertexBuffer( const VertexSettings& Settings )
{
	VertexBuffer* pVertex = new VertexBuffer( Settings );
	pVertex->Init();
	mVBOs[ mVboCount++ ] = pVertex;
	return pVertex;
}
开发者ID:Kaaml,项目名称:Vxy,代码行数:7,代码来源:VBOManager.cpp


示例13: vba

//----------------------------------------------------------------------------
void GeoObjFactory::UpdateCtrlColor(PX2::Renderer *renderer,
	PX2::Movable *mov, Float4 color)
{
	PX2::Node *node = DynamicCast<Node>(mov);

	if (!node)
		return;

	for (int i = 0; i < node->GetNumChildren(); i++)
	{
		PX2::Movable *child = node->GetChild(i);
		PX2::Polysegment *poly = DynamicCast<Polysegment>(child);
		if (poly)
		{
			VertexBuffer *vBuffer = poly->GetVertexBuffer();

			VertexFormat *vf = PX2_GR.GetVertexFormat(GraphicsRoot::VFT_PC);
			VertexBufferAccessor vba(vf, vBuffer);
			for (int i = 0; i < vBuffer->GetNumElements(); i++)
			{
				vba.Color<Float4>(0, i) = color;
			}

			renderer->Update(vBuffer);
		}

	}
}
开发者ID:JamShan,项目名称:Phoenix3D_2.1,代码行数:29,代码来源:PX2GeoObjFactory.cpp


示例14: Material

	//! called during the initialization of the entity
	void PelletManager::Init()
	{
		super::Init();
		
		GraphicComponent* pGraphic = GetComponent<GraphicComponent>();

		if(!pGraphic->GetMaterial())
		{
			pGraphic->SetMaterial(snew Material());
		}

		u32 maxBullets = m_BulletPoolSize/sizeof(Bullet);
		VertexBuffer* pVB = GraphicsDriver::Instance()->CreateVertexBuffer();
		
		pVB->SetVertexFlag(Vertex3D::VF_Pos);		
		pVB->SetName(GetClassName());
		if(GraphicExtensionHandler::Instance()->HasExtension(GraphicExtensionHandler::E_PointSprite))
		{
			pVB->SetPrimitiveType(GraphicsDriver::PT_Point);
			pVB->SetRenderStateSetter(snew PointSpriteStateSetter(m_fBulletSize));
			pVB->SetVertices(snew Vertex3D[maxBullets], maxBullets);
		}
		else
		{
			pVB->SetPrimitiveType(GraphicsDriver::PT_Triangle);
			pVB->SetVertexFlag(Vertex3D::VF_UV);
			pVB->SetVertices(snew Vertex3D[maxBullets*6], maxBullets*6);
		}
		pGraphic->SetVertexBuffer(pVB);

		pVB->SetDynamic(true);
	}	
开发者ID:aminere,项目名称:VLADHeavyStrikePublic,代码行数:33,代码来源:PelletManager.cpp


示例15: bindBuffers

bool RenderDevice::bindBuffers(RenderBatch* renderable)
{
    BufferManager* buffers = activeContext->bufferManager;
    GeometryBuffer* gb = renderable->getGeometryBuffer().get();

    VertexBuffer* vb = buffers->getVertexBuffer(gb).get();
    IndexBuffer* ib = buffers->getIndexBuffer(gb).get();
    
    if( !vb ) return false;

    if( !vb->isBuilt() || gb->needsRebuild )
    {
        // If the vertex buffer is not built yet, then we build it.
        renderBackend->buildVertexBuffer(vb);
    }

    renderBackend->bindVertexBuffer(vb);

    // If there is no index buffer associated with the geometry, we are done.
    if( !ib ) goto done;

    renderBackend->bindIndexBuffer(ib);
    
    if( !ib->isBuilt || gb->needsRebuild )
    {
        // If the index buffer is not built, we also need to build it.
        renderBackend->buildIndexBuffer(ib);
    }

done:

    gb->needsRebuild = false;
    return true;
}
开发者ID:FloodProject,项目名称:flood,代码行数:34,代码来源:RenderDevice.cpp


示例16: HasDynamicBuffers

bool HasDynamicBuffers(Model* model, unsigned lodLevel)
{
    unsigned numGeometries = model->GetNumGeometries();

    for (unsigned i = 0; i < numGeometries; ++i)
    {
        Geometry* geometry = model->GetGeometry(i, lodLevel);
        if (!geometry)
            continue;
        unsigned numVertexBuffers = geometry->GetNumVertexBuffers();
        for (unsigned j = 0; j < numVertexBuffers; ++j)
        {
            VertexBuffer* buffer = geometry->GetVertexBuffer(j);
            if (!buffer)
                continue;
            if (buffer->IsDynamic())
                return true;
        }
        IndexBuffer* buffer = geometry->GetIndexBuffer();
        if (buffer && buffer->IsDynamic())
            return true;
    }

    return false;
}
开发者ID:gameogre,项目名称:Urho3D,代码行数:25,代码来源:CollisionShape.cpp


示例17: ToLineList

void Plane::ToLineList(VertexBuffer &vb, float uWidth, float vHeight, const vec &centerPoint, int numLinesU, int numLinesV) const
{
	vec topLeft = Point(-uWidth*0.5f, -vHeight *0.5f, centerPoint);
	vec uEdge = (Point(uWidth*0.5f, -vHeight *0.5f, centerPoint) - topLeft) / (float)numLinesU;
	vec vEdge = (Point(-uWidth*0.5f, vHeight *0.5f, centerPoint) - topLeft) / (float)numLinesV;

	int i = vb.AppendVertices((numLinesU + numLinesV) * 2);
	for(int y = 0; y < numLinesV; ++y)
	{
		float4 start = POINT_TO_FLOAT4(topLeft + vEdge * (float)y);
		float4 end   = POINT_TO_FLOAT4(topLeft + uWidth * uEdge + vEdge * (float)y);
		vb.Set(i, VDPosition, start);
		vb.Set(i+1, VDPosition, end);
		i += 2;
	}

	for(int x = 0; x < numLinesU; ++x)
	{
		float4 start = POINT_TO_FLOAT4(topLeft + uEdge * (float)x);
		float4 end   = POINT_TO_FLOAT4(topLeft + vHeight * vEdge + uEdge * (float)x);
		vb.Set(i, VDPosition, start);
		vb.Set(i+1, VDPosition, end);
		i += 2;
	}
}
开发者ID:ggf31416,项目名称:CompGraf1,代码行数:25,代码来源:Plane.cpp


示例18: ODL_OBJENTER

void
GraphicsPanel::drawFingertip(const FingerTip & stuff,
                             const Shape       theShape)
{
    ODL_OBJENTER(); //####
    ODL_P1("stuff = ", &stuff); //####
    ODL_I1("theShape = ", theShape); //####
    if (stuff._valid)
    {
        const Location & where = stuff._where;
        VertexBuffer *   selected;

        switch (theShape)
        {
            case kShapeCube :
                if (! _cubeData)
                {
                    setUpCube();
                }
                selected = _cubeData;
                break;

            case kShapeTetrahedron :
                if (! _tetrahedronData)
                {
                    setUpTetrahedron();
                }
                selected = _tetrahedronData;
                break;

            case kShapeOctahedron :
                if (! _octahedronData)
                {
                    setUpOctahedron();
                }
                selected = _octahedronData;
                break;

            default :
                selected = NULL;
                break;

        }
        if (selected)
        {
            ODL_LOG("(selected)"); //####
            if (NULL != _offsetUniform)
            {
                _offsetUniform->set(static_cast<float>(where.x), static_cast<float>(where.y),
                                    static_cast<float>(where.z), 0.0f);
            }
            selected->bind();
            enableVertexAttributes();
            glDrawElements(GL_TRIANGLES, selected->numberOfIndices(), GL_UNSIGNED_INT, 0);
            disableVertexAttributes();
        }
    }
    ODL_OBJEXIT(); //####
} // GraphicsPanel::drawFingertip
开发者ID:MovementAndMeaning,项目名称:Core_MPlusM,代码行数:59,代码来源:m+mLeapDisplayGraphicsPanel.cpp


示例19: void

void SPK_PLQuadRenderer::UpdateVertexBuffer(const SPK::Group &group)
{
	// Get the vertex buffer instance from m_pSPK_PLBuffer and lock it
	VertexBuffer *pVertexBuffer = m_pSPK_PLBuffer->GetVertexBuffer();
	if (pVertexBuffer->Lock(Lock::WriteOnly)) {
		// Get particle renderer to use
		void (SPK_PLQuadRenderer::*pRenderParticle)(const SPK::Particle&);	// Pointer to the right render method
		switch (texturingMode) {
			case SPK::TEXTURE_2D:
				if (group.getModel()->isEnabled(SPK::PARAM_TEXTURE_INDEX))
					pRenderParticle = group.getModel()->isEnabled(SPK::PARAM_ANGLE) ? &SPK_PLQuadRenderer::Render2DAtlasRot : &SPK_PLQuadRenderer::Render2DAtlas;
				else
					pRenderParticle = group.getModel()->isEnabled(SPK::PARAM_ANGLE) ? &SPK_PLQuadRenderer::Render2DRot : &SPK_PLQuadRenderer::Render2D;
				break;

			case SPK::TEXTURE_3D:
				pRenderParticle = group.getModel()->isEnabled(SPK::PARAM_ANGLE) ? &SPK_PLQuadRenderer::Render3DRot : &SPK_PLQuadRenderer::Render3D;
				break;

			case SPK::TEXTURE_NONE:
				pRenderParticle = group.getModel()->isEnabled(SPK::PARAM_ANGLE) ? &SPK_PLQuadRenderer::Render2DRot : &SPK_PLQuadRenderer::Render2D;
				break;

			default:
				pRenderParticle = nullptr;
				break;
		}

		// Get current vertex buffer data
		m_nCurrentVertexSize	= pVertexBuffer->GetVertexSize();
		m_pfCurrentPosition		= static_cast<float*>(pVertexBuffer->GetData(0, VertexBuffer::Position));
		m_pfCurrentTexCoord		= static_cast<float*>(pVertexBuffer->GetData(0, VertexBuffer::TexCoord));
		m_pCurrentVertexBuffer	= pVertexBuffer;
		m_nCurrentVertex		= 0;

		// Calculate the current orientation
		const bool bGlobalOrientation = precomputeOrientation3D(
			group,
			SPK::Vector3D(-m_mWorldViewInverse.fM[8],  -m_mWorldViewInverse.fM[9],  -m_mWorldViewInverse.fM[10]),
			SPK::Vector3D( m_mWorldViewInverse.fM[4],   m_mWorldViewInverse.fM[5],   m_mWorldViewInverse.fM[6]),
			SPK::Vector3D( m_mWorldViewInverse.fM[12],  m_mWorldViewInverse.fM[13],  m_mWorldViewInverse.fM[14]));
		if (pRenderParticle) {
			if (bGlobalOrientation) {
				computeGlobalOrientation3D();
				for (size_t i=0; i<group.getNbParticles(); i++)
					(this->*pRenderParticle)(group.getParticle(i));
			} else {
				for (size_t i=0; i<group.getNbParticles(); i++) {
					const SPK::Particle &cParticle = group.getParticle(i);
					computeSingleOrientation3D(cParticle);
					(this->*pRenderParticle)(cParticle);
				}
			}
		}

		// Unlock the vertex buffer
		pVertexBuffer->Unlock();
	}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:59,代码来源:SPK_PLQuadRenderer.cpp


示例20: ASSERT

// static
angle::Result VertexDataManager::StoreStaticAttrib(const gl::Context *context,
                                                   TranslatedAttribute *translated)
{
    ASSERT(translated->attribute && translated->binding);
    const auto &attrib  = *translated->attribute;
    const auto &binding = *translated->binding;

    gl::Buffer *buffer = binding.getBuffer().get();
    ASSERT(buffer && attrib.enabled && !DirectStoragePossible(context, attrib, binding));
    BufferD3D *bufferD3D = GetImplAs<BufferD3D>(buffer);

    // Compute source data pointer
    const uint8_t *sourceData = nullptr;
    const int offset          = static_cast<int>(ComputeVertexAttributeOffset(attrib, binding));

    ANGLE_TRY(bufferD3D->getData(context, &sourceData));
    sourceData += offset;

    unsigned int streamOffset = 0;

    translated->storage = nullptr;
    ANGLE_TRY(bufferD3D->getFactory()->getVertexSpaceRequired(context, attrib, binding, 1, 0,
                                                              &translated->stride));

    auto *staticBuffer = bufferD3D->getStaticVertexBuffer(attrib, binding);
    ASSERT(staticBuffer);

    if (staticBuffer->empty())
    {
        // Convert the entire buffer
        int totalCount =
            ElementsInBuffer(attrib, binding, static_cast<unsigned int>(bufferD3D->getSize()));
        int startIndex = offset / static_cast<int>(ComputeVertexAttributeStride(attrib, binding));

        ANGLE_TRY(staticBuffer->storeStaticAttribute(context, attrib, binding, -startIndex,
                                                     totalCount, 0, sourceData));
    }

    unsigned int firstElementOffset =
        (static_cast<unsigned int>(offset) /
         static_cast<unsigned int>(ComputeVertexAttributeStride(attrib, binding))) *
        translated->stride;

    VertexBuffer *vertexBuffer = staticBuffer->getVertexBuffer();

    CheckedNumeric<unsigned int> checkedOffset(streamOffset);
    checkedOffset += firstElementOffset;

    ANGLE_CHECK_HR_MATH(GetImplAs<ContextD3D>(context), checkedOffset.IsValid());

    translated->vertexBuffer.set(vertexBuffer);
    translated->serial = vertexBuffer->getSerial();
    translated->baseOffset = streamOffset + firstElementOffset;

    // Instanced vertices do not apply the 'start' offset
    translated->usesFirstVertexOffset = (binding.getDivisor() == 0);

    return angle::Result::Continue();
}
开发者ID:jasonLaster,项目名称:gecko-dev,代码行数:60,代码来源:VertexDataManager.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ VertexBufferAccessor类代码示例发布时间:2022-05-31
下一篇:
C++ VertexAttribute类代码示例发布时间: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