Menu

example_01

Benedict Jäggi
#include "engine.hpp"

const int screenWidth=640;
const int screenHeight=480;

int main()
{
    // get the singleton of the engine.
    qEngine *e = qEngine::getInstance();

    // create the main window.
    // call this before any other calls to the engine because stuff depends on stuff initialized here.
    if(!e->createWindow(L"BeOS", screenWidth, screenHeight))
    {
        printf("Could not create the main Window. Aborting.\n");
        return 1;
    }

    // set background color to dark red.
    e->setBackgroundColor(100,0,0,255);

    // set camera position
    e->getCamera()->setPosition(qVec3f(10,10,10));

     // create two entities, one with 3dCross.obj mesh, the other with a sphere mesh and both with a texture.
    qNodeEntity *entity = e->createEntity("entity1","models/3dCross.obj", "irrlicht-1.8.5/media/sydney.bmp");
    qNodeEntity *entity2 = e->createEntity("entity2", "@sphere","irrlicht-1.8.5/media/sydney.bmp");

    // disable lighting on both entities
    entity->enableLighting(false);
    entity2->enableLighting(false);

    // set the position of entity 2
    entity2->setPosition(qVec3f(-5.0f,0.0f,0.0f));

    // enter the main loop
    while(e->isRunning()) 
    {
        // update the window, events and other stuff
        e->update();

         // get time in seconds since the last frame.
        printf("Deltatime: %f\n",e->getDeltaTime());
    }

    e->quit();

    return 0;
}

/*
That's it. Compile and run.
**/

Related

Wiki: Home