Jump to content
  • Advertisement
Sign in to follow this  
cozman

API Entrypoint

This topic is 4915 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently working on an C++ API (it is for 2D and simple 3D games, but the question doesn't apply specifically to what it is for) and I am having some trouble deciding how I want user code to interface with the API. Since I do hope to release this to the public, I'd like to get an opinion of what other developers think: Option 1: Traditional
int main(int argc, char** argv)
{
    initAPI(argv[0]);
    
    while(!app.quitRequested())
    {
        video.update();
    }

    shutdownAPI();
}




Option 2: Initialization hidden through Application class
class Test : public Application
{
public:
    
    int main(StrVec argv)
    {  
        while(!app.quitRequested())
        {
            video.update();
        }
        
        return 0;
    }

};

ENTRYPOINT(Test);  // macro that takes care of calling initialization functions and calling Test.main()




Option 3: State-based system
class MainState : public State
{
    void update()
    {
        video.update();
        // could have a call to Application::changeState("otherState")
    }
}

int main(int argc, char** argv)
{
    Application::init(argv[0]);
    
    MainState mainState;
    
    Application::registerState("main",mainState);
    
    Application::runState("main");

}




[Edited by - cozman on March 4, 2005 12:45:44 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • 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!