Haiku API: PlatformΒΆ

In this section, we present the basic api proposed by Haiku-hpp to create an interactive application.

As an introduction, here is an simple example:

#include <stdio.h>
#include "haiku/haiku.hpp"
using namespace Haiku;

class MyApp : public IApplication
{
    public:
        void Create(void) override  {glClearColor(0.1f,0.2f,0.7f,1.f);}
        void Render(void) override  {glClear(GL_COLOR_BUFFER_BIT);}
        void Update(void) override
        {
            if(IO::IsMouseJustPressed(HAIKU_MOUSE_BUTTON_1))
                printf("MOUSE_BUTTON_1 is just pressed !\n");
            if(IO::IsKeyPressed(HAIKU_KEY_SPACE))
                printf("KEY_SPACE is pressed !\n");
            if(IO::IsKeyJustPressed(HAIKU_KEY_RETURN))
                printf("RETURN is just pressed !\n");

            if(IO::IsKeyJustPressed(HAIKU_KEY_A))
            {
                Message::Note("Here's a popup window !");
            }
        }
};

HaikuDesc HaikuMain(void)
{
    HaikuDesc desc;
    desc.app = std::make_shared<MyApp>();
    return(desc);
}

As you can see, the main function is hidden from the user. The user has to provide a function called HaikuMain which configures the application:

For keyboard/mouse inputs and outputs, Haiku-hpp provides a namespace for the current state of the application:

Haiku-hpp also offers the possibility of notifying the user via simple popups at runtime: