ah, I just noticed what's happening. I'm using a RECT as an argument and its replacing Count with rect.bottom. Crazy crazy stuff. I just made a little console app to test it and it works fine with that, so I'm assuming I'm out of memory or something. There might be something wrong with my code also, take a look:
Class structure
Code:
class __declspec(dllexport) ArkButton
{
protected:
LPDIRECT3DTEXTURE9 m_Texture;
LPD3DXSPRITE m_Sprite;
sButton *m_Button;
int ButtonCount; // <<<<<<<<<<<<<<<
Function in question:
Code:
BOOL ArkButton::CreateButton(RECT *pSrcRect, void (*Function)(void* DataPtr), float XPosition, float YPosition, float ZPosition, RECT *pOverRect, RECT *pDownRect )
{
// BUTTONCOUNT is 0!!!
if( pSrcRect == NULL || Function == NULL )
return FALSE;
m_Button[ButtonCount].m_XPos = XPosition; //BUTTONCOUNT IS pSrcRect.bottom!!!!
m_Button[ButtonCount].m_YPos = YPosition; //SAME ALL THE WAY DOWN
m_Button[ButtonCount].m_ZPos = ZPosition;
m_Button[ButtonCount].srcRect = pSrcRect;
m_Button[ButtonCount].Function = Function;
if( pOverRect != NULL )
m_Button[ButtonCount].overRect = pOverRect;
if( pDownRect != NULL )
m_Button[ButtonCount].downRect = pDownRect;
ButtonCount++;
return TRUE;
}
and the calling code:
Code:
AB->Init(AC, "C:\\UI\\Buttons.jpg", 2);
RECT rect;
rect.left = 0;
rect.top = 0;
rect.right = 40;
rect.bottom = 45; // THIS WILL BE BUTTONCOUNT =\
AB->CreateButton(&rect, &tempfunction, 200, 200, 0);