#ifdef __linux__

// ::Entry::Linux::Globals::End::

#include "entry_linux.h"

// ::ThirdParty::Include::
#include "xxhash/xxhash.c"
#include "fastlz/fastlz.c"

#include "platform/platform.c"
#include "util.c"
#include "assets.c"
#include "ds.c"
#include "allocators.c"
#include "renderer.c"
#include "game.c"
#ifdef BUILD_TEST
# include "tests.c"
#endif

static_assert(__COUNTER__ < Len(GLOBAL_PROFILER.anchors));

void TraverseNode(RBTree *tree, RBNode *node, RBNodeDir *dir)
{
	char *dir_str = dir == NULL ? "Root" : *dir == RB_RIGHT ? "Right" : "Left";
	Printfln("Color: %s Value: %d Dir: %s", node->color == RB_RED ? "Red" : "Black", node->key, dir_str);
	if (node->left != tree->nil)
	{
		RBNodeDir left_dir = RB_LEFT;
		TraverseNode(tree, node->left, &left_dir);
	}
	if (node->right != tree->nil)
	{
		RBNodeDir right_dir = RB_RIGHT;
		TraverseNode(tree, node->right, &right_dir);
	}
}

void Traverse(RBTree *tree)
{
	TraverseNode(tree, tree->root, NULL);
}

int main(int argc, char **argv) 
{
#ifdef BUILD_TEST
{
	RunTests();

	return 0;
}
#endif 

	Arena *arena = ArenaCreateDebug(MB(32), __LINE__);

  Assert(pWindowInit(WINDOW_NAME), "Failed to initialize the window");

	pGameInput *inputs = MakeArray(arena, pGameInput, 10);
	u32 i_count = 0;

	pWindowEventWaitFor(inputs);

	gGameCtx ctx = {0};

	gInit(&ctx);

	while (!global_quit)
	{
		pWindowEventsGet(inputs, &i_count);
		gRunCycle(&ctx, inputs, i_count);
	}

	gDestroy();
}

#endif // __linux__
