• Advertisement
Sign in to follow this  

problem with LPD3DXBUFFER (writing to file)

This topic is 4929 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Sorry for stupid question. I have: LPD3DXBUFFER lpError; D3DXCreateEffectFromFile( C_View::p_D3DDevice, fileName, &g_lpEffect, &lpError ); How can I save content lpError to file (in VC++)?

Share this post


Link to post
Share on other sites
Advertisement
(1) Allocate a character buffer
(2) Copy the error buffer into the character buffer
(3) Output to file

// This is our error buffer
LPD3DXBUFFER buffer = NULL;

// Attempt to create the effect
if( FAILED( D3DXCreateEffectFromFile( d3dDevice, "effect.fx", NULL, NULL, 0, NULL, &effect, &buffer ) ) )
{
// Error(s) have occured.
// Allocate a character buffer the size of the ID3DXBuffer
char* data = new char[buffer->GetBufferSize()];

// Copy the buffer data over
memcpy( data, buffer->GetBufferPointer(), buffer->GetBufferSize() );

// Open a file and output the error string(s)
FILE* file = fopen( "errors.txt", "w" );
fprintf( file, "%s", data );
fclose( file );

// Release allocated objects
delete[] data;
buffer->Release();

return E_FAIL;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement