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


C++ LPD3DXBUFFER::GetBufferPointer方法代码示例

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


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

示例1: defined

bool CD3D8ShaderMaterialRenderer::createPixelShader(const c8* pxsh)
{
	if (!pxsh)
		return true;

#if defined( _IRR_XBOX_PLATFORM_)
	return false;
#else
	// compile shader

	LPD3DXBUFFER code = 0;
	LPD3DXBUFFER errors = 0;

	#ifdef _IRR_D3D_NO_SHADER_DEBUGGING

		// compile shader without debug info
		D3DXAssembleShader(pxsh, (UINT)strlen(pxsh), 0, 0, &code, &errors);

	#else

		// compile shader and emitt some debug informations to
		// make it possible to debug the shader in visual studio

		static int irr_dbg_file_nr = 0;
		++irr_dbg_file_nr;
		char tmp[32];
		sprintf(tmp, "irr_d3d8_dbg_shader_%d.psh", irr_dbg_file_nr);

		FILE* f = fopen(tmp, "wb");
		fwrite(pxsh, strlen(pxsh), 1, f);
		fflush(f);
		fclose(f);

		D3DXAssembleShaderFromFile(tmp, D3DXASM_DEBUG, 0, &code, &errors);
	#endif
	if (errors)
	{
		// print out compilation errors.
		os::Printer::log("Pixel shader compilation failed:", ELL_ERROR);
		os::Printer::log((c8*)errors->GetBufferPointer(), ELL_ERROR);

		if (code)
			code->Release();

		errors->Release();
		return false;
	}

	if (FAILED(pID3DDevice->CreatePixelShader((DWORD*)code->GetBufferPointer(), &PixelShader)))
	{
		os::Printer::log("Could not create pixel shader.", ELL_ERROR);
		code->Release();
		return false;
	}

	code->Release();
	return true;
#endif

}
开发者ID:NotKyon,项目名称:DarkIrrlicht,代码行数:60,代码来源:CD3D8ShaderMaterialRenderer.cpp

示例2:

HRESULT U2Dx9ShaderMgr::CreateShader( LPD3DXBUFFER pbufShader,
									 U2Dx9ShaderDesc::ShaderType ShaderType,
									U2Dx9ShaderDesc * pDesc )
{
	HRESULT hr = S_OK;
	FAIL_IF_NULL( pbufShader );
	FAIL_IF_NULL( pDesc );
	FAIL_IF_NULL( ms_pD3DDev );

	pDesc->m_type			= ShaderType;

	if( ShaderType == U2Dx9ShaderDesc::SHADERTYPE_VERTEX )
	{
		hr = ms_pD3DDev->CreateVertexShader( (DWORD*) pbufShader->GetBufferPointer(),
			(IDirect3DVertexShader9**) & pDesc->m_pShader );
		SAFE_RELEASE( pbufShader );
		BREAK_AND_RET_VAL_IF_FAILED(hr);		
	}
	else
	{
		hr = ms_pD3DDev->CreatePixelShader( (DWORD*) pbufShader->GetBufferPointer(),
			(IDirect3DPixelShader9**) & pDesc->m_pShader );
		SAFE_RELEASE( pbufShader );		
		BREAK_AND_RET_VAL_IF_FAILED(hr);				
	}
	return( hr );
}
开发者ID:DanielNeander,项目名称:my-3d-engine,代码行数:27,代码来源:U2Dx9ShaderMgr.cpp

示例3: LoadShader

CShaderPtr Graphics::LoadShader( const std::string& strFileName, const std::string& strFuncName, const std::string& profile )
{
	CShaderPtr pShader = new CShader;
	if (FAILED(pShader->Load(strFileName, strFuncName, profile)))
		return NULL;

	LPD3DXBUFFER pShaderBuff = pShader->GetCompileBuffer();
	if (pShader->IsPS())
	{
		// создаЄм пиксельный шейдер
		LPDIRECT3DPIXELSHADER9 pPixelShader;
		m_pd3dDevice->CreatePixelShader(( DWORD* )pShaderBuff->GetBufferPointer(), &pPixelShader);
		pShader->SetHardwareShader(m_pd3dDevice, pPixelShader);
	}
	else
	{
		// создаЄм вертексный шейдер
		LPDIRECT3DVERTEXSHADER9 pVertexShader;
		m_pd3dDevice->CreateVertexShader(( DWORD* )pShaderBuff->GetBufferPointer(), &pVertexShader);
		pShader->SetHardwareShader(m_pd3dDevice, pVertexShader);
	}
	
	m_vecShaders.push_back(pShader);
	return pShader;
}
开发者ID:marmusevich,项目名称:Cpp_projects-all-,代码行数:25,代码来源:Graphics.cpp

示例4: loadVertexShader

bool Viewer::loadVertexShader()
{
  g_pD3DDevice->CreateVertexDeclaration( decl, &m_pVertexDeclaration );

  // Load bumpmapping vertex shader

  LPD3DXBUFFER pCode;
  LPD3DXBUFFER pError;

  if(FAILED(D3DXAssembleShader(vertexShaderStr,sizeof(vertexShaderStr),NULL, NULL, 0,  
                          &pCode, &pError)))
  {
    	  std::cout << "Error while assembling default vertex shader:\n " << (char *)pError->GetBufferPointer();
	      pError->Release();
		  return false;	  
  }	    

  if(FAILED(g_pD3DDevice->CreateVertexShader((DWORD*)pCode->GetBufferPointer(),
                                  &m_pVS)))
  {
      pCode->Release();
	  return false;
  }
  pCode->Release();
   
  return true;
}
开发者ID:AAnguix,项目名称:TTOD_Engine,代码行数:27,代码来源:viewer.cpp

示例5: CompileShader

  GXHRESULT GShaderImpl::CompileShader(clBuffer* pIntermediateCode, GXLPCSTR szSourceCode, size_t nSourceLen, LPD3DXINCLUDE pInclude, GXDEFINITION* pMacros, CompiledType eCompiled)
  {
    LPD3DXBUFFER pShader = NULL;
    LPD3DXBUFFER pErrorBuf = NULL;
    GXHRESULT hval = GX_OK;

    LPCSTR szFunctionName = NULL;
    LPCSTR szProfile = NULL;

    switch(eCompiled)
    {
    case CompiledComponentPixelShder:
      szFunctionName = "compose_ps_main";
      szProfile = "ps_3_0";
      break;
    case CompiledPixelShder:
      szFunctionName = "ps_main";
      szProfile = "ps_3_0";
      break;
    case CompiledComponentVertexShder:
      szFunctionName = "compose_vs_main";
      szProfile = "vs_3_0";
      break;
    case CompiledVertexShder:
      szFunctionName = "vs_main";
      szProfile = "vs_3_0";
      break;
    default:
      return GX_FAIL;
    }

    if(FAILED(D3DXCompileShader((LPCSTR)szSourceCode, (UINT)nSourceLen,
      (D3DXMACRO*)pMacros, pInclude, szFunctionName, szProfile, NULL, &pShader, &pErrorBuf, NULL)))
    {
      LPCSTR szErrorString = (LPCSTR)pErrorBuf->GetBufferPointer();
      CLOG_ERROR("Shader compiled error:\n>%s\n", szErrorString);
      hval = GX_FAIL;
    }
#if 0
    // Test D3DXDisassembleShader
    LPD3DXBUFFER pAsmBuffer = NULL;
    GXHRESULT hval2 = D3DXDisassembleShader((DWORD*)pShader->GetBufferPointer(),
      FALSE, NULL, &pAsmBuffer);
    if(GXSUCCEEDED(hval2) && pAsmBuffer)
    {
      LPCSTR szAsmString = (LPCSTR)pAsmBuffer->GetBufferPointer();
      TRACE(szAsmString);
    }
    SAFE_RELEASE(pAsmBuffer);
#endif // #if

    pIntermediateCode->Resize(0, FALSE);
    if(pShader) {
      pIntermediateCode->Append(pShader->GetBufferPointer(), pShader->GetBufferSize());
    }

    SAFE_RELEASE(pErrorBuf);
    SAFE_RELEASE(pShader);
    return hval;
  }
开发者ID:artint-liu,项目名称:Marimo,代码行数:60,代码来源:GShaderImpl_d3d9.cpp

示例6: if

void* LcD3D_BuildShader(PDEV pDev, char* sStrAssem, int iLen, char* sShader)
{
	HRESULT	hr;

	DWORD dFlag = 0;
	#if defined( _DEBUG ) || defined( DEBUG )
	dFlag |= D3DXSHADER_DEBUG;
	#endif

	LPD3DXBUFFER	pAsm = NULL;
	LPD3DXBUFFER	pErr = NULL;
	void*			pShd = NULL;

	hr = D3DXAssembleShader(
			sStrAssem
		,	iLen
		,	NULL
		,	NULL
		,	dFlag
		,	&pAsm
		,	&pErr);

	if( FAILED(hr) )
	{
		if(pErr)
		{
			char* sErr = (char*)pErr->GetBufferPointer();
			LcD3D_GetDxError(hr, sErr);
			pErr->Release();
		}
		else
			LcD3D_GetDxError(hr);

		return NULL;
	}

	if( 0 == _strnicmp(sShader, "vs", 2))
	{
		PDVS pVS = NULL;
		hr = pDev->CreateVertexShader( (DWORD*)pAsm->GetBufferPointer() , &pVS);
		pShd = pVS;
	}

	else if( 0 == _strnicmp(sShader, "ps", 2))
	{
		PDPS pPS	= NULL;
		hr = pDev->CreatePixelShader( (DWORD*)pAsm->GetBufferPointer() , &pPS);
		pShd = pPS;
	}

	pAsm->Release();

	if( FAILED(hr) )
	{
		LcD3D_GetDxError(hr);
		return NULL;
	}

	return pShd;
}
开发者ID:GALICSOFT,项目名称:glc220_src,代码行数:60,代码来源:LnUtilDx.cpp

示例7: if

  GPUContextDX9::VertexShaderHandle GPUContextDX9::createVertexShader( const char* inSource )
  {
    IDirect3DVertexShader9* shader;
    HRESULT result;
    LPD3DXBUFFER codeBuffer;
    LPD3DXBUFFER errorBuffer;

    result = D3DXAssembleShader( inSource, strlen(inSource), NULL, NULL, 0, &codeBuffer, &errorBuffer );
    if( errorBuffer != NULL )
    {
      const char* errorMessage = (const char*)errorBuffer->GetBufferPointer();
      GPUWARN << "Vertex shader failed to compile:\n" << errorMessage;
      return NULL;
    }
    else if( FAILED(result) )
    {
      GPUWARN << "Vertex shader failed to compile.";
      return NULL;
    }

    result = _device->CreateVertexShader( (DWORD*)codeBuffer->GetBufferPointer(), &shader );
    codeBuffer->Release();

    if( FAILED(result) )
    {
      DX9WARN << "Failed to allocate vertex shader.";
      return NULL;
    }

    return (VertexShaderHandle)shader;
  }
开发者ID:darwin,项目名称:inferno,代码行数:31,代码来源:dx9runtime.cpp

示例8:

bool CDx9FragmentProgram::load(const char* buf,size_t fsize)
{
	if (m_isLoad)
		release();
	LPD3DXBUFFER errors;
	LPD3DXBUFFER pBuffer;

	HRESULT hr;
	hr = D3DXPreprocessShader(
	    buf,
	    static_cast<uint>(fsize),
	    ((DX9_ShaderMacroMgr*)ShaderMacroMgr::GetInst())->GET_MACRO(m_ID),
	    DX9_ShaderInclude::GetInst(),
	    &pBuffer,
	    &errors);

	if (FAILED(hr))
	{
		string message = "D3D9 Pixel Shader拼接不成功 Errors:\n";
		message.append(static_cast<const char*>(errors->GetBufferPointer()));
		errors->Release();
		OutputDebugString(message.c_str());
		GenErr(GraphicErr::GetErrTypeStr(ShaderInit_Err),message);
		return false;
	}

	m_cCode = static_cast<const char*>(pBuffer->GetBufferPointer());
	SafeRelease(pBuffer);
	return true;

}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:31,代码来源:CDx9FragmentProgram.cpp

示例9: strlen

bool CD3D9ShaderMaterialRenderer::createVertexShader(const char* vtxsh)
{
	if (!vtxsh)
		return true;

	// compile shader

	LPD3DXBUFFER code = 0;
	LPD3DXBUFFER errors = 0;

	#ifdef _IRR_D3D_NO_SHADER_DEBUGGING

		// compile shader without debug info
		stubD3DXAssembleShader(vtxsh, strlen(vtxsh), 0, 0, 0, &code, &errors);

	#else

		// compile shader and emitt some debug informations to
		// make it possible to debug the shader in visual studio

		static int irr_dbg_file_nr = 0; 
		++irr_dbg_file_nr;
		char tmp[32];
		sprintf(tmp, "irr_d3d9_dbg_shader_%d.vsh", irr_dbg_file_nr);

		FILE* f = fopen(tmp, "wb");
		fwrite(vtxsh, strlen(vtxsh), 1, f);
		fflush(f);
		fclose(f);

        stubD3DXAssembleShaderFromFile(tmp, 0, 0, D3DXSHADER_DEBUG, &code, &errors);

	#endif
	

	if (errors)
	{
		// print out compilation errors.
		os::Printer::log("Vertex shader compilation failed:");
		os::Printer::log((c8*)errors->GetBufferPointer());

		if (code)
			code->Release();

		errors->Release();
		return false;
	}

	if (!code || FAILED(pID3DDevice->CreateVertexShader((DWORD*)code->GetBufferPointer(), &VertexShader)))
	{
		os::Printer::log("Could not create vertex shader.");
		if (code)
			code->Release();
		return false;
	}

	code->Release();
	return true;
}
开发者ID:John-He-928,项目名称:krkrz,代码行数:59,代码来源:CD3D9ShaderMaterialRenderer.cpp

示例10: ICreate

HRESULT plDXVertexShader::ICreate(plDXPipeline* pipe)
{
    fHandle = nil; // in case something goes wrong.
    fPipe = nil;
    ISetError(nil);

#ifdef HS_DEBUGGING
    DWORD   flags = D3DXSHADER_DEBUG | D3DXSHADER_SKIPOPTIMIZATION;
#else // HS_DEBUGGING
    DWORD   flags = 0;
#endif // HS_DEBUGGING

    // We could store the compiled buffer and skip the assembly step
    // if we need to recreate the shader (e.g. on device lost).
    // But whatever.
    DWORD* shaderCodes = nil;

    HRESULT hr = S_OK;
    if( plShaderTable::LoadFromFile() || !fOwner->GetDecl()->GetCodes() )
    {
        if( fOwner->GetDecl()->GetFileName() )
        {
            LPD3DXBUFFER compiledShader = nil;
            LPD3DXBUFFER compilationErrors = nil;

            hr = D3DXAssembleShaderFromFile(
                            fOwner->GetDecl()->GetFileName(),
                            NULL, NULL, flags,
                            &compiledShader,
                            &compilationErrors);

            if( FAILED(hr) )
            {
                return IOnError(hr, compilationErrors
                        ? reinterpret_cast<const char *>(compilationErrors->GetBufferPointer())
                        : "File not found");
            }

            shaderCodes = (DWORD*)(compiledShader->GetBufferPointer());
        }
    }
    if( !shaderCodes )
    {
        shaderCodes = (DWORD*)(fOwner->GetDecl()->GetCodes());
    }
    if( !shaderCodes )
        return IOnError(-1, "No file and no compiled codes");

    hr = pipe->GetD3DDevice()->CreateVertexShader(shaderCodes, &fHandle);

    if( FAILED(hr) )
        return IOnError(hr, "Error on CreateVertexShader");

    hsAssert(fHandle, "No error, but no vertex shader handle. Grrrr.");

    fPipe = pipe;

    return S_OK;
}
开发者ID:GPNMilano,项目名称:Plasma,代码行数:59,代码来源:plDXVertexShader.cpp

示例11: DXGetErrorString

//----------------------------------------------------------------------------
PdrPixelShader::PdrPixelShader (Renderer* renderer,
								const PixelShader* pshader)
{
	IDirect3DDevice9* device = renderer->mData->mDevice;

	// 编译汇编着色器代码
	const char* programText =
		pshader->GetProgram(PixelShader::GetProfile())->c_str();

	int shaderKey = pshader->GetShaderKey();
	assertion(0!=shaderKey, "shaderKey must not be 0.\n");
	std::map<int, Renderer::SharePdrData>::iterator it = renderer->mSharePdrPixelShaders.find(shaderKey);
	if (it != renderer->mSharePdrPixelShaders.end())
	{
		mShader = (IDirect3DPixelShader9*)(it->second.DataPtr);
		mShader->AddRef();
	}
	else
	{
		int programLength = (int)strlen(programText);
		LPD3DXBUFFER compiledShader = 0;
		LPD3DXBUFFER errors = 0;
		HRESULT hr = D3DXAssembleShader(programText, programLength, 0, 0, 0,
			&compiledShader, &errors);
#ifdef _DEBUG
		if (errors)
		{
			DWORD size = errors->GetBufferSize();
			PX2_UNUSED(size);
			char* data = (char*)errors->GetBufferPointer();
			PX2_UNUSED(data);
			assertion(false, "Failed to assemble pixel shader.\n");
		}
#endif
		PX2_UNUSED(hr);
		assertion(hr == D3D_OK && compiledShader,
			"Failed to assemble pixel shader: %s\n", DXGetErrorString(hr));

		// 创建像素着色器
		hr = device->CreatePixelShader( 
			(DWORD*)(compiledShader->GetBufferPointer()), &mShader);
		assertion(hr == D3D_OK, "Failed to create pixel shader\n");

		// 释放需要释放的数据
		if (compiledShader)
		{
			compiledShader->Release();
		}
		if (errors)
		{
			errors->Release();
		}
				
		renderer->mSharePdrPixelShaders[shaderKey].DataPtr = mShader;
		((IDirect3DPixelShader9*)renderer->mSharePdrPixelShaders[shaderKey].DataPtr)
			->AddRef();
	}
}
开发者ID:SylviaTanenbaum,项目名称:3d-simulation-and-game,代码行数:59,代码来源:PX2Dx9PixelShader.cpp

示例12: compileasm

ErrorCode Shader::compileasm(std::string vert, std::string pixel) {
    LPD3DXBUFFER code;
    LPD3DXBUFFER err;

    HRESULT result;

    /**
     * Assemble Vertex Shader
     */

    result = D3DXAssembleShader(vert.c_str(), vert.length(), NULL, NULL, 0, &code, &err);

    if (FAILED(result))
    {
        ErrorHandleCritical(mamain->err, mamain->errCrit, ErrorCompileVertexShader, result, (char*) err->GetBufferPointer());
        err->Release();

        return ErrorCompileVertexShader;
    }

    result = mamain->d3ddev->CreateVertexShader((DWORD*) code->GetBufferPointer(), &VShader);
    code->Release();

    if (FAILED(result))
        return ErrorHandleCritical(mamain->err, mamain->errCrit, ErrorCreateVertexShader, result);

    /**
    * Assemble Pixel Shader
    */

    result = D3DXAssembleShader(pixel.c_str(), pixel.length(), NULL, NULL, 0, &code, &err);

    if (FAILED(result))
    {
        ErrorHandleCritical(mamain->err, mamain->errCrit, ErrorCompilePixelShader, result, (char*) err->GetBufferPointer());
        err->Release();

        VShader->Release();
        VShader = 0;

        return ErrorCompilePixelShader;
    }

    result = mamain->d3ddev->CreatePixelShader((DWORD*)code->GetBufferPointer(), &PShader);
    code->Release();

    if (FAILED(result))
    {
        ErrorHandleCritical(mamain->err, mamain->errCrit, ErrorCreatePixelShader, result);

        VShader->Release();
        VShader = 0;

        return ErrorCreatePixelShader;
    }

    return ErrorOk;
}
开发者ID:gitter-badger,项目名称:MA-Engine,代码行数:58,代码来源:Resources.cpp

示例13: memcpy

HRESULT CMyD3DApplication::OptimizeMeshData
    (
    LPD3DXMESH pMeshSysMem,
    LPD3DXBUFFER pAdjacencyBuffer,
    DWORD dwOptFlags, 
    SMeshData *pMeshData
    )
{
    HRESULT      hr = S_OK;
    LPD3DXBUFFER pbufTemp = NULL;
    DWORD iMaterial;

    // attribute sort - the un-optimized mesh option
    //          remember the adjacency for the vertex cache optimization
    hr = pMeshSysMem->Optimize( dwOptFlags|D3DXMESH_SYSTEMMEM,
                                 (DWORD*)pAdjacencyBuffer->GetBufferPointer(),
                                 NULL, NULL, NULL, &pMeshData->m_pMeshSysMem);
    if( FAILED(hr) )
        goto End;

    pMeshData->m_cStripDatas = m_dwNumMaterials;
    pMeshData->m_rgStripData = new SStripData[pMeshData->m_cStripDatas];
    if (pMeshData->m_rgStripData == NULL)
    {
        hr = E_OUTOFMEMORY;
        goto End;
    }

    for (iMaterial = 0; iMaterial < m_dwNumMaterials; iMaterial++)
    {
        hr = D3DXConvertMeshSubsetToSingleStrip(pMeshData->m_pMeshSysMem, iMaterial, 
                                D3DXMESH_IB_MANAGED, &pMeshData->m_rgStripData[iMaterial].m_pStrips, 
                                &pMeshData->m_rgStripData[iMaterial].m_cStripIndices);
        if (FAILED(hr))
            goto End;

        hr = D3DXConvertMeshSubsetToStrips(pMeshData->m_pMeshSysMem, iMaterial, 
                                D3DXMESH_IB_MANAGED, &pMeshData->m_rgStripData[iMaterial].m_pStripsMany, 
                                NULL, &pbufTemp, &pMeshData->m_rgStripData[iMaterial].m_cStrips);
        if (FAILED(hr))
            goto End;

        pMeshData->m_rgStripData[iMaterial].m_rgcStripLengths = new DWORD[pMeshData->m_rgStripData[iMaterial].m_cStrips];
        if (pMeshData->m_rgStripData[iMaterial].m_rgcStripLengths == NULL)
        {
            hr = E_OUTOFMEMORY;
            goto End;
        }
        memcpy(pMeshData->m_rgStripData[iMaterial].m_rgcStripLengths, pbufTemp->GetBufferPointer(), sizeof(DWORD)*pMeshData->m_rgStripData[iMaterial].m_cStrips);

    }

End:
    SAFE_RELEASE(pbufTemp);

    return hr;
}
开发者ID:grakidov,项目名称:Render3D,代码行数:57,代码来源:optimizedmesh.cpp

示例14: compileHLSLToD3D9

int compileHLSLToD3D9(const char* from, const char* to, const std::map<std::string, int>& attributes) {
	LPD3DXBUFFER errors;
	LPD3DXBUFFER shader;
	LPD3DXCONSTANTTABLE table;
	HRESULT hr = D3DXCompileShaderFromFileA(from, nullptr, nullptr, "main", isVertexShader(from) ? "vs_2_0" : "ps_2_0", 0, &shader, &errors, &table);
	if (FAILED(hr)) hr = D3DXCompileShaderFromFileA(from, nullptr, nullptr, "main", isVertexShader(from) ? "vs_3_0" : "ps_3_0", 0, &shader, &errors, &table);
	if (errors != nullptr) std::cerr << (char*)errors->GetBufferPointer();
	if (!FAILED(hr)) {
		std::ofstream file(to, std::ios_base::binary);

		file.put(attributes.size());
		for (std::map<std::string, int>::const_iterator attribute = attributes.begin(); attribute != attributes.end(); ++attribute) {
			file << attribute->first.c_str();
			file.put(0);
			file.put(attribute->second);
		}

		D3DXCONSTANTTABLE_DESC desc;
		table->GetDesc(&desc);
		file.put(desc.Constants);
		for (UINT i = 0; i < desc.Constants; ++i) {
			D3DXHANDLE handle = table->GetConstant(nullptr, i);
			D3DXCONSTANT_DESC descriptions[10];
			UINT count = 10;
			table->GetConstantDesc(handle, descriptions, &count);
			if (count > 1) std::cerr << "Error: Number of descriptors for one constant is greater than one." << std::endl;
			for (UINT i2 = 0; i2 < count; ++i2) {
				char regtype;
				switch (descriptions[i2].RegisterSet) {
				case D3DXRS_BOOL:
					regtype = 'b';
					break;
				case D3DXRS_INT4:
					regtype = 'i';
					break;
				case D3DXRS_FLOAT4:
					regtype = 'f';
					break;
				case D3DXRS_SAMPLER:
					regtype = 's';
					break;
				}
				//std::cout << descriptions[i2].Name << " " << regtype << descriptions[i2].RegisterIndex << " " << descriptions[i2].RegisterCount << std::endl;
				file << descriptions[i2].Name;
				file.put(0);
				file.put(regtype);
				file.put(descriptions[i2].RegisterIndex);
				file.put(descriptions[i2].RegisterCount);
			}
		}
		DWORD* data = (DWORD*)shader->GetBufferPointer();
		for (unsigned i = 0; i < shader->GetBufferSize() / 4; ++i) {
			if ((data[i] & 0xffff) == 0xfffe) { //comment token
				unsigned size = (data[i] >> 16) & 0xffff;
				i += size;
			}
			else file.write((char*)&data[i], 4);
开发者ID:wighawag,项目名称:kfx,代码行数:57,代码来源:D3D9Compiler.cpp

示例15: Create

//-----------------------------------------------------------------------------
HRESULT CDXUTMesh::Create( LPDIRECT3DDEVICE9 pd3dDevice, LPCWSTR strFilename )
{
    WCHAR        strPath[MAX_PATH];
    LPD3DXBUFFER pAdjacencyBuffer = NULL;
    LPD3DXBUFFER pMtrlBuffer = NULL;
    HRESULT      hr;

    // Cleanup previous mesh if any
    Destroy();

    // Find the path for the file, and convert it to ANSI (for the D3DX API)
    DXUTFindDXSDKMediaFileCch( strPath, sizeof(strPath) / sizeof(WCHAR), strFilename );

    // Load the mesh
    if( FAILED( hr = D3DXLoadMeshFromX( strPath, D3DXMESH_MANAGED, pd3dDevice, 
                                        &pAdjacencyBuffer, &pMtrlBuffer, NULL,
                                        &m_dwNumMaterials, &m_pMesh ) ) )
    {
        return hr;
    }

    // Optimize the mesh for performance
    if( FAILED( hr = m_pMesh->OptimizeInplace(
                        D3DXMESHOPT_COMPACT | D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_VERTEXCACHE,
                        (DWORD*)pAdjacencyBuffer->GetBufferPointer(), NULL, NULL, NULL ) ) )
    {
        SAFE_RELEASE( pAdjacencyBuffer );
        SAFE_RELEASE( pMtrlBuffer );
        return hr;
    }

    // Set strPath to the path of the mesh file
    WCHAR *pLastBSlash = wcsrchr( strPath, L'\\' );
    if( pLastBSlash )
        *(pLastBSlash + 1) = L'\0';
    else
        *strPath = L'\0';

    D3DXMATERIAL* d3dxMtrls = (D3DXMATERIAL*)pMtrlBuffer->GetBufferPointer();
    hr = CreateMaterials( strPath, pd3dDevice, d3dxMtrls, m_dwNumMaterials );

    SAFE_RELEASE( pAdjacencyBuffer );
    SAFE_RELEASE( pMtrlBuffer );

    // Extract data from m_pMesh for easy access
    D3DVERTEXELEMENT9 decl[MAX_FVF_DECL_SIZE];
    m_dwNumVertices    = m_pMesh->GetNumVertices();
    m_dwNumFaces       = m_pMesh->GetNumFaces();
    m_dwBytesPerVertex = m_pMesh->GetNumBytesPerVertex();
    m_pMesh->GetIndexBuffer( &m_pIB );
    m_pMesh->GetVertexBuffer( &m_pVB );
    m_pMesh->GetDeclaration( decl );
    pd3dDevice->CreateVertexDeclaration( decl, &m_pDecl );

    return hr;
}
开发者ID:n-n-n,项目名称:Flow2D,代码行数:57,代码来源:DXUTMesh.cpp


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