Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

The Graphics Plugin

Kyle Martin edited this page Aug 23, 2017 · 2 revisions

The graphics plugin provides the interface for the application as a whole - it manages all input and has complete control with how one interfaces with the application. The default provided graphics plugin also lays out how one might want to deal with various menu screens.

Folder Layout

First, the "Graphics" folder should be in Plugins/

There are a number of files that are required by EMA of the Graphics plugin (six, to be exact):

  • Graphics.h
  • Graphics.cpp
  • EntitiyDefaultDrawCode.cpp
  • Input.cpp
  • ControlledEvents.cpp
  • WindowedEvents.cpp

Grahpics.h

Must be at least:

class Graphics : public GraphicsInternals
{
public:
  using GraphicsInternals::GraphicsInternals; //But a custom contructer can be defined, as Graphics(Bin* const bin, ThreadManager* const manager) : GraphicsInternals(bin, manager) {}

  void eventLoop() override;
}

Graphics.cpp

Needs to exist, you can write your code in the .h if you want. Whatever you do, don't #include "Graphics.h", as EMA works it out on its own (Main/Graphics.(h/cpp) include these Graphics files).

EntitiyDefaultDrawCode.cpp

This defines how entities are drawn if their plugin does no provide any code of their own.

Input.cpp

Defines real-time input, such as smoothly moving the simulator around with arrow keys.

ControlledEvents.cpp

Defines input on a keystroke basis, such as getting exactly one press from the '+' button to time-accelerate EMA (as opposed to checking if the '+' button is pressed each loop as with real-time input).

WindowedEvents.cpp

Windowed events are the most basic events dealing with the window, that you'll probably always want to call.. By default, this also provides an example on how to properly exit the application.