Menu

qEngine

Benedict Jäggi

qEngine

This is the main class of the engine wrapper.
It connects the user to the underlying graphics and game engine.
Get the singleton instance with:
qEngine* e = qEngine::getInstance();

Then you can do all your stuff with e.

static qEngine* getInstance()

Returns the qEngine Singleton instance and creates it if it does not exist.

bool createWindow(std::string title, int width, int height, bool fullscreen)

Creates the main window with the given title, width and height.
Fullscreen is false by default.

Call this function right after you got the engine instance.
Other functions depend on the stuff created with createWindow.

bool isRunning()

Use that for your main loop. Returns true if running, false if not.

void update()

Call this once in your main loop. It refreshes and updates the window, gets the delta time and does some other stuff.

void quit()

Call this after your main loop, when exiting the program.

qEntity* createEntity(std:;string entityName, std::string meshFileName, std::string textureFileName)

Use this to create an entity, load its mesh and texture and add it to the scenemanager.
DON'T CREATE ENTITIES WITH NEW,
CREATE THEM WITH engine->createEntity(...)
You can create different entities with the mesh file name:
@sphere creates a sphere.
@cube creates a cube.
fileNametries to load the fileName mesh.

void deleteEntity(qEntity* entity)

Use this to delete an entity.
All entities will be deleted when quit() gets called.

void clearScene()

Remove all entities from the scene and delete them.

qGUIWindow* addGUIWindow(qRecti rect, std::string title, bool modal)

Creates a GUI window with a close button and a title.

qGUIWindow* addGUIMessageBox(std::string title, std::string text)

Creates a messagebox with a title, text and OK button.

qGUIStaticText* addGUIStaticText(std::string text, int posX, int posY, int width, int height)

Adds a static GUI text window with the given width and height, on posX, posY with the given text to display.
createWindow must be called before.

qGUIButton* addGUIButton(int id, qRecti rect, std::string text, std::string hint)

Adds a GUI button. You can catch its clicks by deriving a class from qGUIClickReceiver and setting it with engine->setGUIClickReceiver().
Just overwrite the virtual function OnClick(int id)of qGUIClickReceiver.
Also you can get the pressed status by calling button->isPressed(), but this will be set continuously and not just once.

qEntity* getEntityAtMousePos()

Returns the entity at the mouse x and y position.

qEntity* getEntityAtScreenPos(int x, int y)

Returns the entity at the given screen position, seen from the actual camera.
You can use this in ego shooters with screenWidth/2, screenHeight/2 as parameters.

qEntity* getEntityByID(unsigned int id)

Returns the entity with the given ID.

qEntity* getEntityByName(std::string name)

Returns the FIRST entity with the given name.

float getDeltaTime()

Returns the time passed since the last frame, in seconds.

qCamera * getCamera()

Returns the camera instance.

bool getKeyDown(qKey whichkey)

Returns if the key with the given code is down (true) or up (false).

int getMouseX()

Returns the current X position of the mouse.

int getMouseY()

Returns the current Y position of the mouse.

qTexture* getTexture(char * fileName)

Creates a texture and loads the given fileName image into it.

void setBackgroundColor(u32 r, u32 g, u32 b, u32 alpha)

void setBackgroundColor(qColor4i color)

Sets the background color. Note that the alpha value comes last in the function but first in the qColor4i constructor.

void setClickReceiver(qClickReceiver* r)

Sets the given click receiver.
Derive a class from qClickReceiver, over write the functions
OnGUIButtonClick, OnMouseDown, OnMouseUpand register it with this function.
See [qClickReceiver] for more information, or [example_02].

void setCameraMayaStyle()

Removes the actual camera and replaces it with a camera that is controllable like the camera on the 3d application Maya.

qiSceneManager* getGraphicsSceneManager()

Returns the graphics engine's scenemanager. You should not use this.

qiGUIEnvironment* getGUIEnvironment()

Returns the GUI environment where you can create buttons, text boxes, scroll bars and stuff.
The most important GUI elements have their own function on the engine.


Related

Wiki: Home
Wiki: example_02
Wiki: qEventReceiver

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.