Access violation reading location 0xbaadf00d

This is my initialise method for ObjectButton.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
void ObjectButton::initialise(IDirect3DDevice9* d3dDevice)
{
	// Create the background textures.
	HR(D3DXCreateTextureFromResource(d3dDevice, NULL,MAKEINTRESOURCE(IDB_Button_Down), &background));
	HR(D3DXCreateTextureFromResource(d3dDevice, NULL,MAKEINTRESOURCE(IDB_Button_Up), &backgroundInvert));
	backgroundCentre = D3DXVECTOR3(32, 32, 0);

	// Create font properties.
	fontDesc.Height				= clientSpace.bottom/8;
	fontDesc.Width				= clientSpace.right/20;
	fontDesc.Weight				= FW_BOLD;
	fontDesc.MipLevels			= 0;
	fontDesc.Italic				= true;
	fontDesc.CharSet			= DEFAULT_CHARSET;
	fontDesc.OutputPrecision	= OUT_DEFAULT_PRECIS;
	fontDesc.Quality			= DEFAULT_QUALITY;
	fontDesc.PitchAndFamily		= DEFAULT_PITCH | FF_DONTCARE;
	_tcscpy_s(fontDesc.FaceName, _T("Times New Roman"));
	// Create font.
	HR(D3DXCreateFontIndirect(d3dDevice, &fontDesc, &font));

	clicked = 0;
}


with the following code works fine
1
2
	ObjectButton buttonTest;
	buttonTest.initialise(App->d3dDevice);


however if I change it to,
1
2
3
	ObjectButton* buttonTest;
	buttonTest = new ObjectButton();
	buttonTest->initialise(App->d3dDevice);

I get "Invalid allocation size - DAA982CC (exceeded 7ffdefff)" at line 20.
Then later "0xC0000005: Access violation reading location 0xbaadf00d." as it tries to access 'font'

Any ideas? Because I have none.
Last edited on
Topic archived. No new replies allowed.