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


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

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


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

示例1: LoadPS

int uPixelShader::LoadPS(char *filename, char *pixelprog)
{
	int er=0;
	// Create the pixel shader.
	LPD3DXBUFFER pCode;                             // assembled shader code
	LPD3DXBUFFER pError;
	if(hPixelShader!=NULL) pd->DeletePixelShader( hPixelShader);
	if(filename==NULL)
		D3DXAssembleShader( pixelprog, strlen(pixelprog), 0, NULL, &pCode, &pError );  // assemble shader code
	else
	{
		if( D3DXAssembleShaderFromFile( filename, 0, NULL, &pCode, &pError) != D3D_OK)er=1;  // assemble shader code
	}

	if(pError!=NULL)
	{
		char text[150];
		char* error_text = new char[pError->GetBufferSize()+1];
		memcpy(error_text,pError->GetBufferPointer(),pError->GetBufferSize());
		error_text[pError->GetBufferSize()]=NULL;
		pError->Release();

		if(filename!=NULL)
			sprintf( text, "ERROR in pixel shader: %s", filename);
		else
			sprintf( text, "ERROR in pixel shader: %s");

		MessageBox(hWnd, error_text, text, MB_OK);
		delete [] error_text;
		hPixelShader = NULL;
		return 0;
	}
	else if(er==1)
	{
		MessageBox(hWnd, filename, english ? "Couldn't find file for pixel shader":"Nenajdeny subor pre pixel shader", MB_OK);
		return 0;
	}

	if(	pd->CreatePixelShader( (DWORD*)pCode->GetBufferPointer(), &hPixelShader )
		== D3D_OK )
	{
		pCode->Release();
		return 1;
	}
	pCode->Release();
	MessageBox(hWnd, filename, english ? "ERROR in pixel shader":"Chyba pri nacitavani pixel shader", MB_OK);
	return 0;
}
开发者ID:Mantora,项目名称:GA,代码行数:48,代码来源:Util.cpp

示例2: Compile

bool Shader::Compile(string &shaderCode)
{
    LPD3DXBUFFER error = nullptr;
    SOC_dword flags = 0;
    LPDIRECT3DDEVICE9 device = dynamic_cast<Device::Graphics*>(graphics)->GetD3DDevice();
    bool success = true;

#if _DEBUG
    flags |= D3DXSHADER_DEBUG;
#endif

    success = SUCCEEDED( D3DXCreateEffect(device, shaderCode.data(), shaderCode.length(), NULL, NULL, flags, NULL, &shader, &error) );

#if _DEBUG
    if(error)
    {
        int size = error->GetBufferSize();
        void *ack = error->GetBufferPointer();

        if(ack)
        {
            char *str = new char[size];
            memcpy(str, (const char*)ack, size);
            //					sprintf(str, (const char*)ack, size);
            OutputDebugString(str);
            delete[] str;
        }
    }
#endif
    compiled = success;
    if(success)
        GetRequiredParameters(&requiredMatrixParam, &requiredLightParam);

    return success;
}
开发者ID:TeamSOC,项目名称:SOCEngine-Prototype,代码行数:35,代码来源:Shader.cpp

示例3: ICreateHeader

void ICreateHeader(const char* const varName, const char* const fileName, FILE* fp, LPD3DXBUFFER shader)
{
    fprintf(fp, "\n\n\n");

    int byteLen = shader->GetBufferSize();
    int quadLen = byteLen >> 2;

    unsigned char* codes = (unsigned char*)shader->GetBufferPointer();

    fprintf(fp, "static const uint32_t %sbyteLen = %d;\n\n", varName, byteLen);
    fprintf(fp, "static const uint8_t %sCodes[] = {\n", varName);

    int i;
    for( i = 0; i < quadLen-1; i++ )
    {
        fprintf(fp, "\t0x%x,", *codes++);
        fprintf(fp, "\t0x%x,", *codes++);
        fprintf(fp, "\t0x%x,", *codes++);
        fprintf(fp, "\t0x%x,\n", *codes++);
    }
    fprintf(fp, "\t0x%x,", *codes++);
    fprintf(fp, "\t0x%x,", *codes++);
    fprintf(fp, "\t0x%x,", *codes++);
    fprintf(fp, "\t0x%x\n", *codes++);
    fprintf(fp, "\t};");
    fprintf(fp, "\n\n");

    fprintf(fp, "static const plShaderDecl %sDecl(\"%s\", %s, %sbyteLen, %sCodes);\n\n", varName, fileName, varName, varName, varName);
    fprintf(fp, "static const plShaderRegister %sRegister(&%sDecl);\n\n", varName, varName);
}
开发者ID:Asteral,项目名称:Plasma,代码行数:30,代码来源:main.cpp

示例4: 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

示例5: if

bool CD3DEffect::CreateEffect()
{
  HRESULT hr;
  LPD3DXBUFFER pError = NULL;

  std::vector<D3DXMACRO> definemacros;

  for( DefinesMap::const_iterator it = m_defines.begin(); it != m_defines.end(); ++it )
	{
		D3DXMACRO m;
		m.Name = it->first.c_str();
    if (it->second.IsEmpty())
      m.Definition = NULL;
    else
		  m.Definition = it->second.c_str();
		definemacros.push_back( m );
	}

  definemacros.push_back(D3DXMACRO());
	definemacros.back().Name = 0;
	definemacros.back().Definition = 0;

  hr = D3DXCreateEffect(g_Windowing.Get3DDevice(),  m_effectString, m_effectString.length(), &definemacros[0], NULL, 0, NULL, &m_effect, &pError );
  if(hr == S_OK)
    return true;
  else if(pError)
  {
    CStdString error;
    error.assign((const char*)pError->GetBufferPointer(), pError->GetBufferSize());
    CLog::Log(LOGERROR, "CD3DEffect::CreateEffect(): %s", error.c_str());
  }
  else
    CLog::Log(LOGERROR, "CD3DEffect::CreateEffect(): call to D3DXCreateEffect() failed with %" PRId32, hr);
  return false;
}
开发者ID:reinhardd,项目名称:xbmc,代码行数:35,代码来源:D3DResource.cpp

示例6: InitFX

bool DDModel::InitFX( std::wstring filename )
{
	LPD3DXBUFFER pError = nullptr;
	LPDIRECT3DDEVICE9 pD3DDevice = DDRenderer::GetInstance()->GetDevice();
	D3DVERTEXELEMENT9 decl[MAX_FVF_DECL_SIZE];
	D3DXDeclaratorFromFVF( m_MeshInfo->m_pMesh->GetFVF(), decl );
	pD3DDevice->CreateVertexDeclaration( decl, &m_pDecl );

// 	std::wstring fullpath = L".\\Shader\\";
// 	fullpath.append( filename );

//	if ( D3DXCreateEffectFromFileW( pD3DDevice, fullpath.c_str(), NULL, NULL, 0, NULL, &m_pEffect, NULL ) )
	D3DXCreateEffectFromFileW( pD3DDevice, filename.c_str(), NULL, NULL, 0, NULL, &m_pEffect, &pError );

	if ( !m_pEffect && pError )
	{
		int size = pError->GetBufferSize();
		void *ack = pError->GetBufferPointer();

		if ( ack )
		{
			wchar_t* str = new wchar_t[size];
			wsprintf( str, (const wchar_t*)ack, size );
			OutputDebugString( str );
			delete[] str;
		}
	}
	
	m_UseShader = true;
	return true;
}
开发者ID:NHNNEXT,项目名称:2014-01-HUDIGAME-skyLab,代码行数:31,代码来源:DDModel.cpp

示例7: LoadShader

// loading shaders
LPD3DXEFFECT LoadShader(const char * filename)
{
	LPD3DXEFFECT ret = NULL;

	LPD3DXBUFFER pError = NULL;
	DWORD dwShaderFlags = 0;

#if _DEBUG
	dwShaderFlags |= D3DXSHADER_DEBUG;
#endif

	D3DXCreateEffectFromFile(gpD3DDevice, filename,
		NULL, NULL, dwShaderFlags, NULL, &ret, &pError);

	// if failed at loading shaders, display compile error
	// to output window
	if (!ret && pError)
	{
		int size = pError->GetBufferSize();
		void *ack = pError->GetBufferPointer();

		if (ack)
		{
			char* str = new char[size];
			sprintf(str, (const char*)ack, size);
			OutputDebugString(str);
			delete[] str;
		}
	}

	return ret;
}
开发者ID:popekim,项目名称:ShaderPrimer,代码行数:33,代码来源:ShaderFramework.cpp

示例8: LoadShader

// 쉐이더 로딩
LPD3DXEFFECT LoadShader(const char * filename)
{
	LPD3DXEFFECT ret = NULL;

	LPD3DXBUFFER pError = NULL;
	DWORD dwShaderFlags = 0;

#if _DEBUG
	dwShaderFlags |= D3DXSHADER_DEBUG;
#endif

	D3DXCreateEffectFromFile(gpD3DDevice, filename,
		NULL, NULL, dwShaderFlags, NULL, &ret, &pError);

	// 쉐이더 로딩에 실패한 경우 output창에 쉐이더
	// 컴파일 에러를 출력한다.
	if (!ret && pError)
	{
		int size = pError->GetBufferSize();
		void *ack = pError->GetBufferPointer();

		if (ack)
		{
			char* str = new char[size];
			sprintf(str, (const char*)ack, size);
			OutputDebugString(str);
			delete[] str;
		}
	}

	return ret;
}
开发者ID:popekim,项目名称:ShaderPrimerKR,代码行数:33,代码来源:ShaderFramework.cpp

示例9: 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

示例10: 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

示例11: dumpShader

void RSManager::dumpShader(UINT32 hash, const char *directory, LPD3DXBUFFER pBuffer) {
	char fileNameBuffer[64];
	sprintf_s(fileNameBuffer, "%s/%08x.asm", directory, hash);
	const char *fileName = GetDirectoryFile(fileNameBuffer);
	if (writeFile(fileName, static_cast<char *>(pBuffer->GetBufferPointer()), pBuffer->GetBufferSize() - 1)) {
		SDLOG(0, "Wrote disassembled shader to %s\n", fileNameBuffer);
	}
	else {
		SDLOG(0, "Failed to write disassembled shader to %s\n", fileNameBuffer);
	}
}
开发者ID:PeterTh,项目名称:dsfix,代码行数:11,代码来源:RenderstateManager.cpp

示例12: file

void D3D9PixelShader::Reset(GraphicsDevice &graphics)
{
    FreeMemory();

    HRESULT hr;

    _device = graphics.CastD3D9().GetDevice();
    Assert(_device != NULL, "_device == NULL");

    DWORD dwShaderFlags = 0;
    #ifdef DEBUG_PS
        dwShaderFlags |= D3DXSHADER_SKIPOPTIMIZATION | D3DXSHADER_DEBUG;
    #endif

    LPD3DXBUFFER pCode = NULL;
    LPD3DXBUFFER pErrors = NULL;

    PersistentAssert(Utility::FileExists(_shaderFile), String("Shader file not found: ") + _shaderFile);

    // Assemble the vertex shader from the file
    hr = D3DXCompileShaderFromFile( _shaderFile.CString(), NULL, NULL, "PShaderEntry",
                                    "ps_3_0", dwShaderFlags, &pCode,
                                    &pErrors, &_constantTable );
    
    String ErrorString;
    if(pErrors)
    {
        char *ErrorMessage = (char *)pErrors->GetBufferPointer();
        DWORD ErrorLength = pErrors->GetBufferSize();

        ofstream file("ShaderDebug.txt");
        for(UINT i = 0; i < ErrorLength; i++)
        {
            file << ErrorMessage[i];
            ErrorString += String(ErrorMessage[i]);
        }
        file.close();
    }

    PersistentAssert(!FAILED(hr), String("D3DXCompileShaderFromFile failed: ") + ErrorString);

    hr = _device->CreatePixelShader( (DWORD*)pCode->GetBufferPointer(),
                                            &_shader );

    if(pErrors)
    {
        pErrors->Release();
    }
    if(pCode)
    {
        pCode->Release();
    }
    PersistentAssert(!FAILED(hr), "CreatePixelShader failed");
}
开发者ID:dmead,项目名称:sc2bot,代码行数:54,代码来源:D3D9PixelShader.cpp

示例13: file

void D3D9PixelShader::Reset(LPDIRECT3DDEVICE9 _Device)
{
    FreeMemory();

    HRESULT hr;

    Device = _Device;
    Assert(Device != NULL, "Device == NULL");

    DWORD dwShaderFlags = 0;
    #ifdef DEBUG_PS
        dwShaderFlags |= D3DXSHADER_SKIPOPTIMIZATION | D3DXSHADER_DEBUG;
    #endif

    LPD3DXBUFFER pCode = NULL;
    LPD3DXBUFFER pErrors = NULL;

    // Assemble the vertex shader from the file
    hr = D3DXCompileShaderFromFile( ShaderFile.CString(), NULL, NULL, "PShaderEntry",
                                    "ps_3_0", dwShaderFlags, &pCode,
                                    &pErrors, &ConstantTable );
    
    String ErrorString;
    if(pErrors)
    {
        char *ErrorMessage = (char *)pErrors->GetBufferPointer();
        DWORD ErrorLength = pErrors->GetBufferSize();

        ofstream file("ShaderDebug.txt");
        for(UINT i = 0; i < ErrorLength; i++)
        {
            file << ErrorMessage[i];
            ErrorString += String(ErrorMessage[i]);
        }
        file.close();
    }

    PersistentAssert(!FAILED(hr), String("D3DXCompileShaderFromFile failed: ") + ErrorString);

    // Create the vertex shader
    hr = Device->CreatePixelShader( (DWORD*)pCode->GetBufferPointer(),
                                            &Shader );

    if(pErrors)
    {
        pErrors->Release();
    }
    if(pCode)
    {
        pCode->Release();
    }
    PersistentAssert(!FAILED(hr), "CreatePixelShader failed");
}
开发者ID:ghsoftco,项目名称:basecode14,代码行数:53,代码来源:D3D9PixelShader.cpp

示例14: LoadEffect

LPD3DXEFFECT cCube::LoadEffect( const char* szFileName )
{
	LPD3DXEFFECT pEffect = NULL;

	// 셰이더 로딩
	LPD3DXBUFFER		pError = NULL;			//에러 버퍼 ( 셰이더를 컴파일할때 잘못 된 문법이나 오류정보를 리턴해주는 버퍼 )
	DWORD				dwShaderFlag = 0;		//셰이더 플레그 0 

#ifdef _DEBUG
	dwShaderFlag = dwShaderFlag | D3DXSHADER_DEBUG;		//셰이더를 디버그모드로 컴파일하겠다 ( 디버그모드로 해야 잘못된 컴파일 오류가 날때 Error 버퍼에 오류정보가 들어간다 ) 
#endif

	//fx 파일로 부터 셰이더 객체 생성
	D3DXCreateEffectFromFile(
		g_pD3DDevice,				// 디바이스
		szFileName,					// 불러올 셰이더 코드 파일이름
		NULL,						// 셰이더를 컴파일할때 추가로 사용할 #define 정의 ( 일단 NULL )
		NULL,						// 셰이더를 컴파일할때 #include 지시문을 처리할때 사용할 인터페이스 플레그 ( 일단 NULL )
		dwShaderFlag,				// 셰이더 컴파일 플레그
		NULL,						// 셰이더 매개변수를 공유할 메모리풀 ( 일단 NULL )
		&pEffect,					// 로딩될 셰이더 Effect 포인터
		&pError						// 셰이더를 로딩하고 컴파일할때 문제가 생기면 해당 버퍼에 에러메시지가 들어간다 ( 성공적으로 로딩되면 NULL 이 참조된다 )
		);

	//셰이더 파일로딩에문재가 있다면..
	if( pError != NULL || pEffect == NULL ){

		//문제의 내용이 뭔지 문자열로 확인
		int size = pError->GetBufferSize();
		char* str = new char[ size ];

		//str에 버퍼에있는 내용을 저장한다.
		sprintf_s( str, size,(const char*)pError->GetBufferPointer() );
		
		OutputDebugString(str);
		//오류내용을 출력했으니 오류버퍼 해제
		SAFE_RELEASE( pError );
		SAFE_DELETE_ARRAY(str);

		return NULL;
	}

	m_pEffect = pEffect;

	return pEffect;
}
开发者ID:gawallsibya,项目名称:SGA_Direct3D,代码行数:46,代码来源:cCube.cpp

示例15: assertion

//----------------------------------------------------------------------------
PdrVertexShader::PdrVertexShader (Renderer* renderer,
    const VertexShader* vshader)
{
    IDirect3DDevice9* device = renderer->mData->mDevice;

    // Compile the shader to assembly code.
    const char* programText =
        vshader->GetProgram(VertexShader::GetProfile())->c_str();
    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();
        WM5_UNUSED(size);
        char* data = (char*)errors->GetBufferPointer();
        WM5_UNUSED(data);
        assertion(false, "Failed to assemble vertex shader.\n");
    }
#endif
    WM5_UNUSED(hr);
    assertion(hr == D3D_OK && compiledShader,
        "Failed to assemble vertex shader: %s\n", DXGetErrorString(hr));

    // Create the vertex shader.
    hr = device->CreateVertexShader(
        (DWORD*)(compiledShader->GetBufferPointer()), &mShader);
    assertion(hr == D3D_OK, "Failed to create vertex shader\n");

    // Release buffers, if necessary.
    if (compiledShader)
    {
        compiledShader->Release();
    }
    if (errors)
    {
        errors->Release();
    }
}
开发者ID:fishxz,项目名称:omni-bot,代码行数:43,代码来源:Wm5Dx9VertexShader.cpp


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