here is the create resources function
bool VideoDemo::createResources()
{
HRESULT hr;
hr = m_Direct3D->CheckDeviceFormat(0,D3DDEVTYPE_HAL,m_DispMode.Format,D3DUSAGE_DYNAMIC,D3DRTYPE_TEXTURE,D3DFMT_X8B8G8R8);
if(FAILED(hr))
{
const char* err = DXGetErrorDescriptionA(hr);
MessageBoxA(NULL,(LPCSTR)err,NULL,MB_OK);
}
hr = m_Direct3DDevice->CreateTexture(512,512,1,D3DUSAGE_DYNAMIC,D3DFMT_A8B8G8R8,D3DPOOL_DEFAULT,&m_pTexture,NULL);
if(FAILED(hr))
{
const char* err = DXGetErrorDescriptionA(hr);
MessageBoxA(NULL,(LPCSTR)err,NULL,MB_OK);
}
hr = m_pTexture->LockRect(0,&this->m_Rect,NULL,D3DLOCK_DISCARD);
if(FAILED(hr))
{
const char* err = DXGetErrorDescriptionA(hr);
MessageBoxA(NULL,(LPCSTR)err,"",MB_OK);
}
for(int x = 0; x < this->m_pTexture->Width; x++)
{
for(int y = 0; y < this->m_pTexture->Height; y++)
{
DWORD* imageData = reinterpret_cast<DWORD*>(&m_Rect.pBits);
int index = x * m_Rect.Pitch / 4 * y;
imageData[index++] = 0xFF000000;
imageData[index++ / 2] = 0xFF00FF00;
}
}
m_pTexture->UnlockRect(0);
hr = D3DXSaveTextureToFileA("Image.png",D3DXIFF_PNG,m_pTexture,NULL);
if(FAILED(hr))
{
const char* err = DXGetErrorDescriptionA(hr);
MessageBoxA(NULL,(LPCSTR)err,"",MB_OK);
}
return true;
}
not really sure WHY it does this.






