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


C++ CreateVertexBuffer函数代码示例

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


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

示例1: CreateVertexBuffer

Slider::Slider(Rect slider_rect, float _minValue, float _maxValue, float _value, char* slider_id, SliderStyle *slider_style)
{
	if(slider_style == NULL)
		style = &gDefaultSliderStyle;
	else
		style = slider_style;

	id = slider_id;

	rect = slider_rect;
	screenRect = rect;

	D3DVIEWPORT9 viewPort = gEngine->GetDriver()->GetViewPort(0);
	screenRect.TransLate(viewPort.X, viewPort.Y);

	minValue = _minValue;
	maxValue = _maxValue;
	value = _value;
	if(value < minValue)
		value = minValue;
	if(value > maxValue)
		value = maxValue;

	CreateVertexBuffer();
}
开发者ID:SinYocto,项目名称:Zee,代码行数:25,代码来源:GUI.cpp

示例2:

bool eae6320::Graphics::Mesh::LoadGraphicsMeshData()
{
	o_direct3dDevice = eae6320::Graphics::GetLocalDirect3dDevice();

	//o_vertexDeclaration = m_vertexDeclaration;
	//o_vertexBuffer = m_vertexBuffer;
	//o_indexBuffer = m_indexBuffer;

	//o_vertexData = m_vertexData;
	//o_indexData = m_indexData;

	//o_vertexCount = m_vertexCount;
	//o_indexCount = m_indexCount;


	if (!CreateVertexBuffer())
	{
		return false;
	}
	if (!CreateIndexBuffer())
	{
		return false;
	}
	return true;
}
开发者ID:hardit826,项目名称:Game-Engineering-3,代码行数:25,代码来源:Mesh.d3d.cpp

示例3: window

Application::Application() :
	window(new Window(1280, 720, L"testerata!")),
	device(new D3D12Device(*window)),
	frameQueueIndex(0)
{
	// Create a command allocator for every inflight-frame
	for (int i = 0; i < D3D12Device::MAX_FRAMES_INFLIGHT; ++i)
	{
		if (FAILED(device->GetD3D12Device()->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&commandAllocator[i]))))
			CRITICAL_ERROR("Failed to create command list allocator.");
	}
	// Create the command list.
	if (FAILED(device->GetD3D12Device()->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, commandAllocator[frameQueueIndex].Get(), pso.Get(), IID_PPV_ARGS(&commandList))))
		CRITICAL_ERROR("Failed to create command list");
	commandList->Close();

	CreateRootSignature();
	CreatePSO();
	CreateVertexBuffer();
	CreateTextures();

	// Configure viewport and scissor rect.
	viewport.TopLeftX = 0.0f;
	viewport.TopLeftY = 0.0f;
	viewport.Width = static_cast<float>(window->GetWidth());
	viewport.Height = static_cast<float>(window->GetHeight());
	viewport.MinDepth = 0.0f;
	viewport.MaxDepth = 1.0f;
	scissorRect.left = 0;
	scissorRect.top = 0;
	scissorRect.right = static_cast<LONG>(window->GetWidth());
	scissorRect.bottom = static_cast<LONG>(window->GetHeight());
}
开发者ID:Wumpf,项目名称:d3d12gettingstartedplayground,代码行数:33,代码来源:Application.cpp

示例4: DL_DEBUG

	void ParticleEmitterInstance::Initiate(ParticleEmitterData* someData, bool anAllowManyParticles)
	{
		myParticleEmitterData = someData;
		myEmitterPath = myParticleEmitterData->myFileName;

		int particleCount = static_cast<int>(myParticleEmitterData->myParticlesPerEmitt * myParticleEmitterData->myParticlesLifeTime / myParticleEmitterData->myEmissionRate) + 1;

		
		DL_DEBUG(("Loading :" + myEmitterPath).c_str());
		DL_ASSERT_EXP(anAllowManyParticles == true || particleCount <= 201, "Can't have more than 201 particles in an emitter!");

		myGraphicalParticles.Init(particleCount);
		myLogicalParticles.Init(particleCount);

		myEmissionTime = myParticleEmitterData->myEmissionRate;

		myDiffColor = (myParticleEmitterData->myData.myEndColor - myParticleEmitterData->myData.myStartColor) / myParticleEmitterData->myParticlesLifeTime;

		for (int i = 0; i < particleCount; ++i)
		{
			GraphicalParticle tempGraphics;
			myGraphicalParticles.Add(tempGraphics);
			LogicalParticle tempLogic;
			myLogicalParticles.Add(tempLogic);
		}

		myIsActive = myParticleEmitterData->myIsActiveAtStart;
		myShouldLive = myParticleEmitterData->myIsActiveAtStart;

		myEmitterLife = myParticleEmitterData->myEmitterLifeTime;
		CreateVertexBuffer();
	}
开发者ID:nian0601,项目名称:Spaceshooter,代码行数:32,代码来源:ParticleEmitterInstance.cpp

示例5: ARRAYSIZE

	void ProxyModel::Initialize()
	{
		// Load a compiled vertex shader
		std::string compiledVertexShader = Utility::LoadBinaryFile("Content\\Shaders\\BasicVS.cso");
		Utility::ThrowIfFailed(mGame->GetD3DDevice()->CreateVertexShader(&compiledVertexShader[0], compiledVertexShader.size(), nullptr, mVertexShader.ReleaseAndGetAddressOf()), "ID3D11Device::CreatedVertexShader() failed.");

		// Load a compiled pixel shader
		std::string compiledPixelShader = Utility::LoadBinaryFile("Content\\Shaders\\BasicPS.cso");
		Utility::ThrowIfFailed(mGame->GetD3DDevice()->CreatePixelShader(&compiledPixelShader[0], compiledPixelShader.size(), nullptr, mPixelShader.ReleaseAndGetAddressOf()), "ID3D11Device::CreatedPixelShader() failed.");

		// Create an input layout
		D3D11_INPUT_ELEMENT_DESC inputElementDescriptions[] =
		{
			{ "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
			{ "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }
		};

		Utility::ThrowIfFailed(mGame->GetD3DDevice()->CreateInputLayout(inputElementDescriptions, ARRAYSIZE(inputElementDescriptions), &compiledVertexShader[0], compiledVertexShader.size(), mInputLayout.ReleaseAndGetAddressOf()), "ID3D11Device::CreateInputLayout() failed.");

		// Create constant buffers
		D3D11_BUFFER_DESC constantBufferDesc;
		ZeroMemory(&constantBufferDesc, sizeof(constantBufferDesc));
		constantBufferDesc.ByteWidth = sizeof(mVertexCBufferPerObjectData);
		constantBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
		Utility::ThrowIfFailed(mGame->GetD3DDevice()->CreateBuffer(&constantBufferDesc, nullptr, mVertexCBufferPerObject.ReleaseAndGetAddressOf()), "ID3D11Device::CreateBuffer() failed.");

		// Load a model
		std::unique_ptr<Model> model(new Model(*mGame, mModelFileName, true));

		Mesh* mesh = model->Meshes().at(0);
		CreateVertexBuffer(mGame->GetD3DDevice(), *mesh, mVertexBuffer.ReleaseAndGetAddressOf());
		mesh->CreateIndexBuffer(mIndexBuffer.ReleaseAndGetAddressOf());
		mIndexCount = static_cast<UINT>(mesh->Indices().size());
	}
开发者ID:CalWLee,项目名称:FIEAGraphicsDemo,代码行数:34,代码来源:ProxyModel.cpp

示例6: Init

    bool Init()
    {
        Vector3f Pos(5.0f, 1.0f, -3.0f);
        Vector3f Target(0.0f, 0.0f, 1.0f);
        Vector3f Up(0.0, 1.0f, 0.0f);

        m_pGameCamera = new Camera(WINDOW_WIDTH, WINDOW_HEIGHT, Pos, Target, Up);

        CreateVertexBuffer();
        
        m_pEffect = new LightingTechnique();

        if (!m_pEffect->Init())
        {
            printf("Error initializing the lighting technique\n");
            return false;
        }

        m_pEffect->Enable();

        m_pEffect->SetTextureUnit(0);

        m_pTexture = new Texture(GL_TEXTURE_2D, "../Content/test.png");

        if (!m_pTexture->Load()) {
            return false;
        }

        return true;
    }
开发者ID:c14006078,项目名称:opengl,代码行数:30,代码来源:tutorial21.cpp

示例7: Allocate

    void Allocate(ID3D11Device *device, const int meshCount, const int *verticesPerMesh,
        const int *indicesPerMesh) override
    {
        int totalVertexCount = 0;
        int totalIndexCount = 0;

        for (int i = 0; i < meshCount; ++i)
        {
            totalVertexCount += verticesPerMesh[i];
            totalIndexCount += indicesPerMesh[i];
        }

        CreateVertexBuffer(device, totalVertexCount);
        CreateIndexBuffer(device, totalIndexCount);

        int indexOffset = 0;
        int vertexOffset = 0;
        for (int i = 0; i < meshCount; ++i)
        {
            meshes_.emplace_back(std::unique_ptr<StaticMesh>(
                new StaticMesh(verticesPerMesh[i], indicesPerMesh[i], i)));
            meshes_[i]->vertexBuffer = vertexBuffer_;
            meshes_[i]->vertexBufferSRV = vertexBufferSRV_;
            meshes_[i]->indexBuffer = indexBuffer_;
            meshes_[i]->indexBufferSRV = indexBufferSRV_;

            meshes_[i]->indexOffset = indexOffset;
            indexOffset += indicesPerMesh[i] * sizeof(int);

            meshes_[i]->vertexOffset = vertexOffset;
            vertexOffset += verticesPerMesh[i] * 3 * sizeof(float);
        }

        CreateMeshConstantsBuffer(device);
    }
开发者ID:GPUOpen-Effects,项目名称:GeometryFX,代码行数:35,代码来源:GeometryFXMeshManager.cpp

示例8: Init

	bool Init()
	{
		m_pGameCamera = new Camera(WINDOW_WIDTH, WINDOW_HEIGHT);

		CreateVertexBuffer();
		CreateIndexBuffer();

		m_pEffect = new LightingTechnique();

		if (!m_pEffect->Init())
		{
			return false;
		}

		m_pEffect->Enable();

		m_pEffect->SetTextureUnit(0);

		m_pTexture = new Texture(GL_TEXTURE_2D, "../Content/test.png");

		if (!m_pTexture->Load()) {
			return false;
		}

		return true;
	}
开发者ID:qunny0,项目名称:FTools,代码行数:26,代码来源:tutorial17.cpp

示例9: main

int main(int argc, char* argv[])
{
	glutInit(&argc, argv);

	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);

	glutInitWindowSize(800, 600);
	glutInitWindowPosition(100, 100);
	glutCreateWindow("Tutorial 09");

	GLenum res = glewInit();
	if (res != GLEW_OK)
	{
		fprintf(stderr, "Error: '%s'\n", glewGetErrorString(res));
		return 1;
	}

	glClearColor(0.8f, 0.3f, 0.1f, 1.0f);

	InitializeGlutCallbacks();

	CreateVertexBuffer();
	CompileShader();

	glutMainLoop();

	return 0;
}
开发者ID:onerain88,项目名称:OGLDev,代码行数:28,代码来源:Source.cpp

示例10: CreateVertexBuffer

void BasicShapes::CreateCube(
    _Out_ ID3D11Buffer **vertexBuffer,
    _Out_ ID3D11Buffer **indexBuffer,
    _Out_opt_ unsigned int *vertexCount,
    _Out_opt_ unsigned int *indexCount
    )
{
    CreateVertexBuffer(
        ARRAYSIZE(cubeVertices),
        cubeVertices,
        vertexBuffer
        );
    if (vertexCount != nullptr)
    {
        *vertexCount = ARRAYSIZE(cubeVertices);
    }

    CreateIndexBuffer(
        ARRAYSIZE(cubeIndices),
        cubeIndices,
        indexBuffer
        );
    if (indexCount != nullptr)
    {
        *indexCount = ARRAYSIZE(cubeIndices);
    }
}
开发者ID:mbin,项目名称:Win81App,代码行数:27,代码来源:BasicShapes.cpp

示例11: main

int main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
	glutInitWindowSize(1024, 768);
	glutInitWindowPosition(100, 100);
	glutCreateWindow("Tutorial 02");

	InitializeGlutCallbacks();

	// Must be done after glut is initialized!
	GLenum res = glewInit();
	if (res != GLEW_OK) {
		fprintf(stderr, "Error: '%s'\n", glewGetErrorString(res));
		return 1;
	}

	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

	CreateVertexBuffer();

	glutMainLoop();

	return 0;
}
开发者ID:MaxLingwei,项目名称:openGL,代码行数:25,代码来源:tut02.c

示例12: main

int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
    glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT);
    glutInitWindowPosition(100, 100);
    glutCreateWindow("Homework 3: camera");
    glutGameModeString("[email protected]");
    glutEnterGameMode();

    InitializeGlutCallbacks();

    pGameCamera = new Camera(WINDOW_WIDTH, WINDOW_HEIGHT);

    GLenum res = glewInit();
    if (res != GLEW_OK) {
      fprintf(stderr, "Error: '%s'\n", glewGetErrorString(res));
      return 1;
    }

    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    CreateVertexBuffer();
    CreateIndexBuffer();

    CompileShaders();

    glutMainLoop();

    return 0;
}
开发者ID:forsaken1,项目名称:glut,代码行数:31,代码来源:main.cpp

示例13: Initialize

void Initialize()
{
    RenderContext& rc = GlobalRenderContext;

    glswInit();
    glswSetPath("../", ".glsl");
    glswAddDirectiveToken("GL3", "#version 130");

    rc.VertexBuffer = CreateVertexBuffer();
    rc.IndexBuffer = CreateIndexBuffer();
    
#if defined(__APPLE__)
    rc.ToonHandle = BuildProgram("Toon.Vertex.GL2", "Toon.Fragment.GL2");
#else
    rc.ToonHandle = BuildProgram("Toon.Vertex.GL3", "Toon.Fragment.GL3");
#endif
    
    rc.ToonUniforms.Projection = glGetUniformLocation(rc.ToonHandle, "Projection");
    rc.ToonUniforms.Modelview = glGetUniformLocation(rc.ToonHandle, "Modelview");
    rc.ToonUniforms.NormalMatrix = glGetUniformLocation(rc.ToonHandle, "NormalMatrix");
    rc.ToonUniforms.LightPosition = glGetUniformLocation(rc.ToonHandle, "LightPosition");
    rc.ToonUniforms.AmbientMaterial = glGetUniformLocation(rc.ToonHandle, "AmbientMaterial");
    rc.ToonUniforms.DiffuseMaterial = glGetUniformLocation(rc.ToonHandle, "DiffuseMaterial");
    rc.ToonUniforms.SpecularMaterial = glGetUniformLocation(rc.ToonHandle, "SpecularMaterial");
    rc.ToonUniforms.Shininess = glGetUniformLocation(rc.ToonHandle, "Shininess");

    glEnable(GL_DEPTH_TEST);

    const float S = 0.46f;
    const float H = S * ViewportHeight / ViewportWidth;
    rc.Projection = mat4::Frustum(-S, S, -H, H, 4, 10);
}
开发者ID:jsj2008,项目名称:blog-source,代码行数:32,代码来源:Mobius.cpp

示例14: CreateVertexBuffer

//-----------------------------------------------------------------------------//
// load mesh, bone, material file
//-----------------------------------------------------------------------------//
SBMMLoader* CFileLoader::LoadModel( char *szFileName )
{
	ModelItor itor = s_ModelMap.find( szFileName );
	if( s_ModelMap.end() != itor )
	{
		SBMMLoader *p = (SBMMLoader*)itor->second.pItem;
		// Skinning Animation의 경우 모델마다 VertexBuffer를 생성해야 한다.
		// VertexBuffer 를 생성한다.
		if( ANI_SKIN == p->type )
			CreateVertexBuffer( (SBMMLoader*)itor->second.pItem );
		return (SBMMLoader*)itor->second.pItem;
	}

	// binary파일이 있다면 그것을 로드한다.
	// binary파일은 같은 파일명에서 확장자만(.bmm) 바뀐다. 
	char binfile[ MAX_PATH];
	strcpy( binfile, szFileName );
	strcpy( &binfile[ strlen(binfile)-3], "bmm" );

	SMapItem item;
	ZeroMemory( &item, sizeof(item) );
	if( PathFileExists(binfile) )
	{
		// binary파일이 있다면 그것을 로드한다.
		item.eType = MT_LINEAR;
		item.pItem = (BYTE*)LoadBMM_Bin( binfile );
		if( !item.pItem ) return FALSE;
		s_ModelMap.insert( ModelMap::value_type(szFileName,item) );
	}
	else
	{
		// binary파일이 없다면, binary파일을 생성한다.
		item.eType = MT_TREE;
		item.pItem = (BYTE*)LoadBMM_GPJ( szFileName );
		if( !item.pItem ) return FALSE;
		s_ModelMap.insert( ModelMap::value_type(szFileName,item) );
//		WriteScripttoBinary_Model( (SBMMLoader*)item.pItem, binfile );
	}

	ModifyTextureFilename( &((SBMMLoader*)item.pItem)->mtrl );

	// VertexBuffer, IndexBuffer를 생성한다.
	CreateVertexBuffer( (SBMMLoader*)item.pItem );
	CreateIndexBuffer( (SBMMLoader*)item.pItem );

	return (SBMMLoader*)item.pItem;
}
开发者ID:jjuiddong,项目名称:Dx3D-Study,代码行数:50,代码来源:FileLoader.cpp

示例15: CreateVertexBuffer

 void Material::CreateVertexBuffer(ID3D11Device* direct3d_device, const Model& model, std::vector<ID3D11Buffer*>& vertex_buffers) const {
   vertex_buffers.reserve(model.Meshes().size());
   for (Mesh* mesh : model.Meshes()) {
     ID3D11Buffer* vertex_buffer;
     CreateVertexBuffer(direct3d_device, *mesh, &vertex_buffer);
     vertex_buffers.push_back(vertex_buffer);
   }
 }
开发者ID:fromdemon,项目名称:dxTest,代码行数:8,代码来源:material.cpp


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