Jump to content
Sign in to follow this  
  • entries
    292
  • comments
    557
  • views
    154306

139 source files, and what does it do?

Sign in to follow this  
TANSTAAFL

73 views

The answer is nothing.

I opened up my SDL/SDL_image/SDL_mixer/SDL_net/SDL_ttf/eXpat wrapper/framework/engine/codebase today. I got it to compile and to link.

And it does nothing, which is really what it is supposed to do.

Although, truth be told, it doesn't exactly do "nothing" per se... it writes the following to stderr.txt:

Quote:
IApplication::Execute:
No appliction object exists.


This tells me a few things. One, I somehow failed to spell "application" correctly, and two, it works.

The wrapper/framework/engine/codebase doesn't do anything on its own. IApplication is an abstract base class for... applications (duh), and there need to be a derived class and an instance of such a class in order to IApplication::Execute(static member function) to be happy.

IApplication::Execute is the sole function called by main. In fact, since it is short, I'll post the entire main function:

int main(int argc,char* argv[])
{
return(IApplication::Execute(argc,argv));
}


If I could make IApplication::Execute the entry point, I surely would, as the only think main accomplishes is a handful of extra bytes on the stack.

of course, IApplication::Execute is much more interesting:

int IApplication::Execute(int argc,char* argv[])
{
if(!GetApplication())
{
throw EGeneric(ERRID_NoApplication,"IApplication::Execute:\n\tNo appliction object exists.\n");
}
if(GetApplication()->OnStart(argc,argv))
{
while(!s_bQuit)
{
SDL_Event* pEvent;
switch(GetApplication()->GetAppType())
{
case APPTYPE_WAITEVENT:
{
pEvent=SEventManager::Wait();
GetApplication()->HandleBroadcast(MEventPointer(IEventHandler::MSGID_Event,pEvent),true);
GetApplication()->OnIdle();
}break;
case APPTYPE_POLLEVENT:
{
pEvent=SEventManager::Poll();
if(pEvent)
{
GetApplication()->HandleBroadcast(MEventPointer(IEventHandler::MSGID_Event,pEvent),true);
}
else
{
GetApplication()->OnIdle();
}
}break;
case APPTYPE_NOEVENT:
{
GetApplication()->OnIdle();
Quit();
}break;
}
}
GetApplication()->OnFinish();
}
return(GetApplication()->GetReturnValue());
}



Anyway, it's fun to look at some of this old code. I guess I'm doing okay as far as being a developer goes, as while I look at this stuff, I don't feel any major need to change anything.
Sign in to follow this  


1 Comment


Recommended Comments

Foo! Your main() is shorter than mine! :P

int main(int argc, char* argv[])
{
new CKatanaEngine;
KatanaEngine->Start("data/app.cfg");

while (KatanaEngine->IsRunning())
KatanaEngine->Run();

KatanaEngine->End();
delete KatanaEngine;

return 1;
}

Hm. I just noticed that instead of looping the Run() function, I should prob just have it not return until runtime is over. Funny how/when you notice things like that

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!