Example #1
0
MF_API void MFDebug_DebugAssert(const char *pReason, const char *pMessage, const char *pFile, int line)
{
	MFDebug_Message(MFStr("%s(%d) : Assertion Failure.",pFile,line));
	MFDebug_Message(MFStr("Failed Condition: (%s)\n%s", pReason, pMessage));

	// build callstack log string for message box
#if !defined(_RETAIL)
	MFCallstack_Log();
	const char *pCallstack = MFCallstack_GetCallstackString();
#else
	const char *pCallstack = "Not available in _RETAIL builds";
#endif

	MFDebug_Breakpoint();

	exit(0);

	// TODO: show the android message box...
/*
	// query for debug or exit of process
	if(!MFDebugAndroid_MsgBox(MFStr("Failed Condition: (%s)\n%s\nFile: %s\nLine: %d\n\nCallstack:\n%s", pReason, pMessage, pFile, line, pCallstack), "Assertion Failure, do you wish to debug?"))
	{
		exit(0);
	}
*/
}
MF_API void MFDebug_DebugAssert(const char *pReason, const char *pMessage, const char *pFile, int line)
{
	MFDebug_Message(MFStr("%s(%d) : Assertion Failure.",pFile,line));
	MFDebug_Message(MFStr("Failed Condition: %s\n%s", pReason, pMessage));
#if !defined(_RETAIL)
	MFCallstack_Log();
#endif

#if defined(MF_LINUX) || defined(MF_OSX)
	MFDebug_Breakpoint();
#endif

	if(!MFFont_GetDebugFont())
		return;

	while(!gQuit)
	{
		MFSystem_HandleEventsPlatformSpecific();

		MFSystem_UpdateTimeDelta();
		gFrameCount++;

		MFSystem_Update();
		MFSystem_PostUpdate();

		MFRenderer_BeginFramePlatformSpecific();

		MFRenderer_SetClearColour(0,0,0,0);
		MFRenderer_ClearScreen();

		MFView_SetDefault();
		MFView_SetOrtho();

		if(!(((uint32)gSystemTimer.GetSecondsF()) % 2))
		{
			MFMaterial_SetMaterial(MFMaterial_GetStockMaterial(MFMat_White));
			MFPrimitive(PT_QuadList);

			MFBegin(4);
			MFSetColour(1,0,0,1);
			MFSetPosition(50, 50, 0);
			MFSetPosition(590, 110, 0);

			MFSetColour(0,0,0,1);
			MFSetPosition(55, 55, 0);
			MFSetPosition(585, 105, 0);
			MFEnd();
		}

		MFFont_DrawText2f(MFFont_GetDebugFont(), 110, 60, 20, MakeVector(1,0,0,1), "Software Failure. Press left mouse button to continue.");
		MFFont_DrawText2f(MFFont_GetDebugFont(), 240, 80, 20, MakeVector(1,0,0,1), "Guru Meditation: ");

		MFFont_DrawText2f(MFFont_GetDebugFont(), 80, 120, 20, MakeVector(1,0,0,1), "Assertion Failure:");
		MFFont_DrawText2f(MFFont_GetDebugFont(), 80, 140, 20, MakeVector(1,0,0,1), MFStr("Failed Condition: %s", pReason));
		MFFont_DrawText2f(MFFont_GetDebugFont(), 80, 160, 20, MakeVector(1,0,0,1), MFStr("File: %s, Line: %d", pFile, line));
		MFFont_DrawText2f(MFFont_GetDebugFont(), 80, 190, 20, MakeVector(1,0,0,1), MFStr("Message: %s", pMessage));

#if !defined(_RETAIL)
		MFFont_DrawText2f(MFFont_GetDebugFont(), 80, 230, 20, MakeVector(1,0,0,1), "Callstack:");
		MFFont_DrawText2f(MFFont_GetDebugFont(), 100, 250.0f, 20, MakeVector(1,0,0,1), MFCallstack_GetCallstackString());
#else
		MFFont_DrawText2f(MFFont_GetDebugFont(), 80, 230, 20, MakeVector(1,0,0,1), "Callstack not available in RETAIL builds");
#endif

//		MFSystem_Draw();
		MFRenderer_EndFramePlatformSpecific();
	}
}