本文整理汇总了C++中LPD3DXBUFFER::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ LPD3DXBUFFER::Release方法的具体用法?C++ LPD3DXBUFFER::Release怎么用?C++ LPD3DXBUFFER::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPD3DXBUFFER
的用法示例。
在下文中一共展示了LPD3DXBUFFER::Release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strlen
TRESULT D3DWrapper::CompilePixelShader( OCShader*& shader )
{
if( NULL == shader )
return RE_FAILED;
if( NULL == shader->GetPixelShaderCode() )
return RE_FAILED;
UINT codeSize = static_cast<UINT>( strlen(shader->GetPixelShaderCode()) );
if( 0 == codeSize )
return RE_FAILED;
LPD3DXBUFFER pCode;
LPD3DXBUFFER pErrorMsgs;
HRESULT hr = D3DXCompileShader( shader->GetPixelShaderCode(), codeSize, NULL, NULL, "main", "ps_3_0", 0, &pCode, &pErrorMsgs, shader->GetConstantTablePtr() );
if(FAILED(hr))return RE_FAILED;
hr = m_pD3dDevice->CreatePixelShader( (DWORD*)pCode->GetBufferPointer(), shader->GetPixelShaderPtr() );
if(FAILED(hr))return RE_FAILED;
if(pCode)
pCode->Release();
if(pErrorMsgs)
pErrorMsgs->Release();
return RE_SUCCEED;
}
示例2: 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
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: strlen
bool CD3DEffectMgr::Load(const char* szFilename, bool bSoftware)
{
// make sure we're term'd first
Term();
Init();
if(szFilename == NULL)
{
return false;
}
LPD3DXBUFFER pErrorBuffer = NULL;
DWORD dwShaderFlags = 0;
if(bSoftware)
{
dwShaderFlags |= D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT;
dwShaderFlags |= D3DXSHADER_NO_PRESHADER;
dwShaderFlags |= D3DXSHADER_DEBUG;
}
LTEffectInclude includeSolver;
//includeSolver.SetParentFilename(szFilename);
HRESULT hr = D3DXCreateEffectFromFile(PD3DDEVICE,
szFilename,
NULL,
&includeSolver,
dwShaderFlags,
NULL,
&m_pEffect,
&pErrorBuffer);
if(FAILED(hr))
{
if(pErrorBuffer)
{
const char* pszError = (pErrorBuffer != NULL) ? (const char*)pErrorBuffer->GetBufferPointer() : "<Unknown Error>";
// Save the error to our last error buffer.
int nLen = strlen(pszError);
strncpy(m_pszLastError, pszError, (nLen < 1023) ? nLen : 1023);
pErrorBuffer->Release();
}
m_pEffect = NULL;
return false;
}
if(pErrorBuffer)
{
pErrorBuffer->Release();
}
return true;
}
示例8: 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();
}
}
示例9: CompileShader
void CompileShader()
{
DWORD dwShaderFlags = 0;
#if defined( DEBUG ) || defined( _DEBUG )
// Set the D3DXSHADER_DEBUG flag to embed debug information in the shaders.
// Setting this flag improves the shader debugging experience, but still allows
// the shaders to be optimized and to run exactly the way they will run in
// the release configuration of this program.
dwShaderFlags |= D3DXSHADER_DEBUG;
#endif
#ifdef DEBUG_VS
dwShaderFlags |= D3DXSHADER_SKIPOPTIMIZATION|D3DXSHADER_DEBUG;
#endif
#ifdef DEBUG_PS
dwShaderFlags |= D3DXSHADER_SKIPOPTIMIZATION|D3DXSHADER_DEBUG;
#endif
WCHAR* shader_file = L"torus_shader.hlsl";
// Compile Vertex Shader
LPD3DXBUFFER pVertexShaderCode;
HRESULT hr = D3DXCompileShaderFromFile(shader_file, NULL, NULL, "VS", "vs_3_0", dwShaderFlags, &pVertexShaderCode, NULL, NULL);
if(FAILED(hr))
{
MessageBox(NULL, L"Error", L"Compile Vertex Shader Failed!", 0);
}
// Create Vertex Shader
hr = g_pd3dDevice->CreateVertexShader((DWORD*)pVertexShaderCode->GetBufferPointer(), &g_pVertexShader);
if(FAILED(hr))
{
MessageBox(NULL, L"Error", L"Create Vertex Shader Failed!", 0);
}
// Compile Pixel Shader
LPD3DXBUFFER pPixelShaderCode;
hr = D3DXCompileShaderFromFile(shader_file, NULL, NULL, "PS", "ps_3_0", dwShaderFlags, &pPixelShaderCode, NULL, NULL);
if(FAILED(hr))
{
MessageBox(NULL, L"Error", L"Compile Pixel Shader Failed!", 0);
}
// Create Pixel Shader
hr = g_pd3dDevice->CreatePixelShader((DWORD*)pPixelShaderCode->GetBufferPointer(), &g_pPixelShader);
if(FAILED(hr))
{
MessageBox(NULL, L"Error", L"Create Pixel Shader Failed!", 0);
}
// cleanup
pVertexShaderCode->Release();
pPixelShaderCode->Release();
}
示例10: flags
bool CD3D9HLSLMaterialRenderer::createHLSLPixelShader(const char* pixelShaderProgram,
const char* shaderEntryPointName,
const char* shaderTargetName)
{
if (!pixelShaderProgram)
return true;
LPD3DXBUFFER buffer = 0;
LPD3DXBUFFER errors = 0;
HRESULT h = stubD3DXCompileShader(
pixelShaderProgram,
strlen(pixelShaderProgram),
0, // macros
0, // no includes
shaderEntryPointName,
shaderTargetName,
0, // no flags (D3DXSHADER_DEBUG)
&buffer,
&errors,
&PSConstantsTable);
if (FAILED(h))
{
os::Printer::log("HLSL pixel shader compilation failed:");
if (errors)
{
os::Printer::log((c8*)errors->GetBufferPointer());
errors->Release();
if (buffer)
buffer->Release();
}
return false;
}
if (errors)
errors->Release();
if (buffer)
{
if (FAILED(pID3DDevice->CreatePixelShader((DWORD*)buffer->GetBufferPointer(),
&PixelShader)))
{
os::Printer::log("Could not create hlsl pixel shader.");
buffer->Release();
return false;
}
buffer->Release();
return true;
}
return false;
}
示例11: 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");
}
示例12: 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");
}
示例13: init
Plane* Plane::init(LPDIRECT3DDEVICE9 device) {
CUSTOMVERTEX vtx[] = {
CUSTOMVERTEX(D3DXVECTOR3(-1, 0, 1), D3DXVECTOR3(0, 1, 0), 0x00ffffff, D3DXVECTOR2(0, 0)),
CUSTOMVERTEX(D3DXVECTOR3( 1, 0, 1), D3DXVECTOR3(0, 1, 0), 0x00ffffff, D3DXVECTOR2(1, 0)),
CUSTOMVERTEX(D3DXVECTOR3(-1, 0, -1), D3DXVECTOR3(0, 1, 0), 0xffffffff, D3DXVECTOR2(0, 1)),
CUSTOMVERTEX(D3DXVECTOR3( 1, 0, -1), D3DXVECTOR3(0, 1, 0), 0xffffffff, D3DXVECTOR2(1, 1)),
};
setVertices(vtx, 4);
LPD3DXBUFFER code;
LPD3DXBUFFER error;
D3DXCompileShaderFromFile("shader.hlsl", NULL, NULL,
"vertexShaderTexture", "vs_2_0", 0,
&code, &error, &_vs_constant_table);
if(error) {
OutputDebugString((LPCSTR)error->GetBufferPointer());
vbuf->Release();
error->Release();
return 0;
}
device->CreateVertexShader((DWORD*)code->GetBufferPointer(), &_vs);
code->Release();
D3DXCompileShaderFromFile("shader.hlsl", NULL, NULL,
"pixelShaderTexture", "ps_2_0", 0,
&code, &error, &_ps_constant_table);
if(error) {
OutputDebugString((LPCSTR)error->GetBufferPointer());
vbuf->Release();
_vs_constant_table->Release();
_vs->Release();
error->Release();
return 0;
}
device->CreatePixelShader((DWORD*)code->GetBufferPointer(), &_ps);
code->Release();
D3DXCreateTextureFromFile(device, "textures/ground.png", &texture);
angle = (D3DX_PI / 180.0f * 2);
//D3DXMATRIX rot;
//D3DXMatrixRotationAxis(&rot, &D3DXVECTOR3(1, 0, 0), (D3DX_PI / 180.0f * -90));
//world *= rot;
return this;
}
示例14: 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;
}
示例15:
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;
}