Start New Discussion within our Software Development Community

Hi!
In my direct 2d game i want to draw a big background picture entered by the user.
Im currently trying to do this as described on http://msdn.microsoft.com/en-us/library/ee719658%28v=vs.85%29.aspx .
Altough it gives me read error at pos 0x0000.

Heres the code:

RECT rc;
	GetClientRect(hWnd, &rc);

	using namespace D2D1;


	//Render Target
	ID2D1Factory *pD2DFactory = NULL;
	HRESULT hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED,&pD2DFactory); 

	ID2D1HwndRenderTarget* pRT = NULL;			
	hr = pD2DFactory->CreateHwndRenderTarget(RenderTargetProperties(),
		HwndRenderTargetProperties(hWnd,
		SizeU( rc.right - rc.left,rc.bottom - rc.top)),
		&pRT);


	// Wallpaper
	IWICBitmapDecoder *pDecoder = NULL;
	IWICImagingFactory *pImagingFactory = NULL;

	hr = pImagingFactory->CreateDecoderFromFilename(L"wall.jpg",// Image to be decoded
		NULL,                            // Do not prefer a particular vendor
		GENERIC_WRITE,                    // Desired read access to the file
		WICDecodeMetadataCacheOnDemand,  // Cache metadata when needed
		&pDecoder                        // Pointer to the decoder
		);

Its the CreateDecoderFromFilename that causes the error.
I'm guessing this is because it either tries to read or write at &pDecoder which is the address of a pointer to null.


If theres any better way to do this performance wise i would like to know(Since I'm going to draw it every frame), even using something else than direct2d would be ok as long as i can draw on top of it. Maybe i can have the large bitmap predrawn to something surface like so i wont have to redraw it every frame.

Thanks David.

Seriously i need help with this, what should i do to avoid producing the error, my code is almost exactly the same as the msdn code.

This article has been dead for over six months. Start a new discussion instead.