Sign in to follow this  
KingofNoobs

WICTextureLoader

Recommended Posts

Hello,

I am trying to use the WICTextureLoader functions as provided by Frank Luna, and I keep branching to return E_NOINTERFACE. Here is how the code goes:

HRESULT CreateWICTextureFromMemory( _In_ ID3D11Device* d3dDevice,
_In_opt_ ID3D11DeviceContext* d3dContext,
_In_bytecount_(wicDataSize) const uint8_t* wicData,
_In_ size_t wicDataSize,
_Out_opt_ ID3D11Resource** texture,
_Out_opt_ ID3D11ShaderResourceView** textureView,
_In_ size_t maxsize
)
{
if (!d3dDevice || !wicData || (!texture && !textureView))
{
return E_INVALIDARG;
}
if ( !wicDataSize )
{
return E_FAIL;
}
#ifdef _M_AMD64
if ( wicDataSize > 0xFFFFFFFF )
return HRESULT_FROM_WIN32( ERROR_FILE_TOO_LARGE );
#endif
IWICImagingFactory* pWIC = _GetWIC();
if ( !pWIC )
return E_NOINTERFACE;

----------------
I read somewhere that this has something to do with not calling CoInitializeEx(), but since I know nothing about COM objects except for the fact that Direct3D and Windows use them heavily, I was hoping somebody could help me figure out where in my code to call CoInitializeInstanceEx() and what parameters to use, or if this is not the problem at all.

Thanks in advance.

-Dave Ottley

Share this post


Link to post
Share on other sites
eppo,

Here is the code for _GetWIC(), which fails with REGDB_E_CLASSNOTREG:

static IWICImagingFactory* _GetWIC()
{
static IWICImagingFactory* s_Factory = nullptr;
if ( s_Factory )
return s_Factory;
HRESULT hr = CoCreateInstance(
CLSID_WICImagingFactory,
nullptr,
CLSCTX_INPROC_SERVER,
__uuidof(IWICImagingFactory),
(LPVOID*)&s_Factory
);
if ( FAILED(hr) )
{
s_Factory = nullptr;
return nullptr;
}
return s_Factory;
}

Share this post


Link to post
Share on other sites
This is unrelated, but I thought I'd take this opportunity to ask why when I write:

assert(buffer[imageDataStartsHere] == 89 && "Image data does not really start here.");

The error message I receive is: Expression: buffer[imageDataStartsHere] == 89 && "Image data does not really start here."

I just wanted the stuff in double quotes. Is there any way to get this?

Thanks.

-Dave Ottley

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this