Example #1
0
	Window::Window(HINSTANCE instance, const Description& description)
		: m_instance(instance)
		, m_handle(NULL)
		, m_exitValue(0)
	{
		if (!SetupClass(description))
			throw r2ExceptionRuntimeM("Failed to setup window class");
		if (!SetupWindow(description))
			throw r2ExceptionRuntimeM("Failed to create window");
	}
Example #2
0
int main(int p_argc, char* p_argv[])
{
	try {
		throw r2ExceptionRuntimeM("Error");
	} catch (std::exception& p_exception) {
		std::cout << "Exception Test Passed" << std::endl;
		try {
			r2AssertM(false, "Error");
		} catch (std::exception& p_exception) {
			std::cout << "Assertion Test Passed" << std::endl;
		}
	}
	
	std::cout << r2::Math::K_PI << std::endl;
	r2::Math::FloatCompare(0.0f, 0.0f);
	
	std::cout << "Math Test Passed" << std::endl;
	
	
	std::cout << "sizeof(r2::Byte): " << sizeof(r2::Byte) << std::endl;
	
	std::cout << "sizeof(r2::SInt8): " << sizeof(r2::SInt8) << std::endl;
	std::cout << "sizeof(r2::SInt16): " << sizeof(r2::SInt16) << std::endl;
	std::cout << "sizeof(r2::SInt32): " << sizeof(r2::SInt32) << std::endl;
	std::cout << "sizeof(r2::SInt64): " << sizeof(r2::SInt64) << std::endl;
	
	std::cout << "sizeof(r2::UInt8): " << sizeof(r2::UInt8) << std::endl;
	std::cout << "sizeof(r2::UInt16): " << sizeof(r2::UInt16) << std::endl;
	std::cout << "sizeof(r2::UInt32): " << sizeof(r2::UInt32) << std::endl;
	std::cout << "sizeof(r2::UInt64): " << sizeof(r2::UInt64) << std::endl;

	union {
		r2::UInt64 i;
		r2::Byte c[8];
	} a = { 0x0102030405060708 };
	
	r2::SwapEndian(a.i);
	r2AssertM(a.c[0] == 0x08 && a.c[1] == 0x07 && a.c[2] == 0x06 && a.c[3] == 0x05 && a.c[4] == 0x04 && a.c[5] == 0x03 && a.c[6] == 0x02 && a.c[7] == 0x01, "64-bit endian swap failed");

	std::cout << "64-bit Endian Swap Test Succeeded" << std::endl;
	
	
	HighscoreList list;
	list.AddEntry("Rarosu", HighscoreList::Easy, 100);
	list.AddEntry("Raze", HighscoreList::Easy, 120);
	list.AddEntry("Rarosu", HighscoreList::Normal, 435);
	list.AddEntry("Raze", HighscoreList::Normal, 435);
	list.AddEntry("Rogan", HighscoreList::Hard, 695);
	list.AddEntry("Billy The Paperboy", HighscoreList::Hard, 780);
	list.Save("highscore.dat");
	//list.Print();
	
	HighscoreList loaded_list;
	loaded_list.Load("highscore.dat");
	loaded_list.Print();

	return 0;
}