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;

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

	// 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.

6 Years
Discussion Span
Last Post by frogster

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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.