Getting Started - simple-entertainment/simplicity GitHub Wiki
Want to get something up and running quick sharpish? You can check out the Hello World example for a full minimal working demo but here is a breakdown of the steps you'll need to take:
The API header includes everything you'll need:
#include <simplicity/API.h>
using simplicity;
Link to the libsimplicity.so
library. Sorry I don't have downloads of the binary available yet but it's super easy to build. If you have Eclipse CDT or Visual Studio 2013 project files are included.
The same can be done for plugin projects. For the FreeGLUT and OpenGL plugins use these API headers:
#include <simplicity-freeglut/API.h>
using simplicity::freeglut;
#include <simplicity-opengl/API.h>
using simplicity::opengl;
And link to these libraries:
libsimplicity-freeglut.so
libsimplicity-opengl.so
Simplicity uses abstract factories to create objects that will vary in concrete type depending on which plugins you are using, before the factories can be used you'll need to provide instances for them. There is a SimpleModelFactory
but if you are using the OpenGL plugin you'll need the OpenGL factory.
std::unique_ptr<ModelFactory> modelFactory(new OpenGLModelFactory);
ModelFactory::setInstance(move(modelFactory));
The available factories are:
ModelFactory
PhysicsFactory
RenderingFactory
Generally, to get something on the screen, the minimum you'll need are a windowing engine and a rendering engine. The FreeGLUT and OpenGL plugins provide these.
std::unique_ptr<Engine> engine(new FreeGLUTEngine("I'm just getting started..."));
Simplicity::addEngine(move(engine));
Creating a working OpenGLRenderingEngine
is a little more involved. Look at the Hello World example to see how it's done.
Don't limit yourself to the engines that have been provided - create your own!
Now we need to create something for our engine to work with. All the entities in simplicity belong to a scene.
std::unique_ptr<Scene> scene(new Scene);
Simplicity::addScene("theOnly", move(scene)); // The first scene added becomes the current scene.
...and something to draw! Entities are basically just containers of components and a model is a drawable component (although they can also be used for other things).
std::unique_ptr<Entity> entity(new Entity);
std::unique_ptr<Model> model(ModelFactory::getInstance()->createCubeMesh(...));
entity->addUniqueComponent(move(model));
Simplicity::getScene()->addEntity(move(entity));
Don't limit yourself to the components that have been provided - create your own to work with your own engines!
Simplicity::play();