My main:
Code:
//
// WinMain
//
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE prevInstance,
PSTR cmdLine,
int showCmd)
{
//Create window for app
//Load settings from INI
INIReader *pReader = 0;
try
{
pReader = new INIReader();
pReader->LoadAndParse("..\\INI\\Options.ini");
}
catch (INIReader::INIFileError &err)
{
err;
::MessageBox(0,"Cannot open INI file",0,0);
return 0;
}
int iWidth = pReader->GetInt("Display","ScreenWidth");
int iHeight = pReader->GetInt("Display","ScreenHeight");
//Really need to make an ini function to get a bool from the file
bool bWindowed = false;
int result = ::MessageBox(0,"Do you wish to run in fullscreen mode?","Screen mode",
MB_YESNO | MB_ICONQUESTION);
if (result == IDNO)
{
bWindowed = true;
}
pReader->Cleanup();
delete pReader;
SpaceXApp::CreateInstance();
//Start the app by initializing D3D
if(!SpaceXApp::GetInstance()->InitD3D(hInstance,
iWidth,
iHeight,
bWindowed,
D3DDEVTYPE_HAL,
"SpaceX application",
true))
{
::MessageBox(0, "InitD3D() - FAILED", 0, 0);
return 0;
}
try
{
//Setup the app
if(!SpaceXApp::GetInstance()->Setup())
{
::MessageBox(0, "Setup() - FAILED", 0, 0);
return 0;
}
}
catch (X3DException &e)
{
e.ShowError();
}
catch (std::exception &e)
{
SpaceXApp::GetInstance()->Cleanup();
::MessageBox(0,e.what(),"UNKNOWN EXCEPTION CAUGHT",MB_OK | MB_ICONEXCLAMATION);
std::cout << e.what() << std::endl;
}
//Start the loop
SpaceXApp::GetInstance()->EnterMsgLoop();
//If we get here, we are done
//Clean up the memory and COM objects
SpaceXApp::GetInstance()->Cleanup();
//Ok Windows, it's all yours
return 0;
}
I should break out the sections into functions but haven't yet. My main then would consist of about 4 functions.
Is there any way to be sure that when i send them the code it will work in windows as long as I am not using any linux specific functions.
The APIs are different and the calls are different. It will be more of a 'how do I do this in Linux/Windows' question when porting between the two. API calls for Win32 won't work in Linux.
The best way in my opinion is to define an interface that will not change and will define the behavior of the application. Then the implementation can be in Linux or Windows and as long as the interface does not change it will not break either of you.