Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualTim Sarbin

Posted 20 January 2013 - 09:43 PM

Topic says it all. I'm attempting to create a texture from a file I already have stored in memory. Calling D3DXCreateTextureFromFileInMemory results in an S_FALSE result. Here's the relevant code:

 

void MapEditor::LoadTileset(const char* data, const UINT size) {
	if (d3dTexture != NULL) {
		d3dTexture->Release();
	}
	if (HRESULT hr = D3DXCreateTextureFromFileInMemory(d3dDevice, (LPCVOID)data, size, &d3dTexture) != D3D_OK) {
		wxMessageBox( "Error loading tileset data!", "Error", wxOK | wxICON_ERROR );
	};
}

 

I set a breakpoint and verified that size perfectly matches the size of the file in bytes, and that data points to a buffer that starts with the proper PNG header, so I'm guessing it's some other type of setup fail :-/ The image is exactly 256x256 pixels in size (power of two) and DOES have a transparency layer. I HAVE enabled D3DRS_ALPHABLENDENABLE as well. This is using DirectX9.

 

Any ideas on where to start?

 

Thanks a lot!


#1Tim Sarbin

Posted 20 January 2013 - 09:40 PM

Topic says it all. I'm attempting to create a texture from a file I already have stored in memory. Calling D3DXCreateTextureFromFileInMemory results in an S_FAIL result. Here's the relevant code:

 

void MapEditor::LoadTileset(const char* data, const UINT size) {
	if (d3dTexture != NULL) {
		d3dTexture->Release();
	}
	if (HRESULT hr = D3DXCreateTextureFromFileInMemory(d3dDevice, (LPCVOID)data, size, &d3dTexture) != D3D_OK) {
		wxMessageBox( "Error loading tileset data!", "Error", wxOK | wxICON_ERROR );
	};
}

 

I set a breakpoint and verified that size perfectly matches the size of the file in bytes, and that data points to a buffer that starts with the proper PNG header, so I'm guessing it's some other type of setup fail :-/ The image is exactly 256x256 pixels in size (power of two) and DOES have a transparency layer. I HAVE enabled D3DRS_ALPHABLENDENABLE as well. This is using DirectX9.

 

Any ideas on where to start?

 

Thanks a lot!


PARTNERS