Running a loop while drawing text using pointers. [DirectX]

Hey guys,

Got a problem here with DirectX, basically the game runs the main loop, processing network shit, position stuff etc. But basically what im trying to do, is when its connecting to a game, in the top right hand of the screen everytime the status updates using 'iGameState' e.g

1
2
3
4
5
6
7
8
9
10
void CChatWindow::Draw()
{
        if(cw_CNetGame->i_GameState == GAMESTATE_CONNECTING)
            AddDebugMessage(MESSAGE_INFO_COLOR, 1000, 10, "Connecting...");

        if(cw_CNetGame->i_GameState == GAMESTATE_CONNECTED)
            AddDebugMessage(MESSAGE_INFO_COLOR, 1000, 10, "Connected...");

	AddDebugMessage(MESSAGE_INFO_COLOR, 10, 10, "Plains Alpha v1.0.0");
}


Here's the draw function also:

1
2
3
4
5
6
7
8
9
void CChatWindow::AddDebugMessage(DWORD dwColor, float fPosX, float fPosY, char * szText, ...)
{
	if(cw_D3DFont)
	{
		RECT rPosition;
		SetRect(&rPosition, (LONG)fPosX, (LONG)fPosY, 0, 0);
		cw_D3DFont->DrawTextA(NULL, szText, -1, &rPosition, DT_NOCLIP, dwColor);
	}
}


Now all is well with drawing 'Plains Alpha v1.0.0' when not using the gamestate statement it actually draws but i don't even get that when using the gamestate statement, basically once it hits the if(cw_CNetGame->iGameState == GAMESTATE_CONNECTING) it basically just crashes the program.

So to sum it all up, 'Plains Alpha v1.0.0' draws to the screen but the 'Connecting...' doesn't and also crashes the program, anyone know where I'm going wrong?

P.S I already have this initialized: cf_CChatWindow = new CChatWindow(p_D3DDevice, p_D3DFont, 20, 0, FW_BOLD, "Tahoma"); So that can't be the problem.

Thanks and many regards,

Rav. :)
Last edited on
Topic archived. No new replies allowed.