kick
/Users/morten/Programmering/cpp/kick/src/kick/core/engine.h
00001 //
00002 //  Engine.h
00003 //  KickCPP
00004 //
00005 //  Created by Morten Nobel-Jørgensen on 5/21/13.
00006 //  Copyright (c) 2013 Morten Nobel-Joergensen. All rights reserved.
00007 //
00008 
00009 #pragma once
00010 
00011 #include <iostream>
00012 #include <vector>
00013 #include "kick/scene/scene.h"
00014 #include "kick/context/context.h"
00015 #include "kick/core/event_listener.h"
00016 #include "kick/core/event.h"
00017 #include "kick/core/project.h"
00018 #include "kick/core/engine.h"
00019 #include "kick/core/mouse_input.h"
00020 #include "kick/core/key_input.h"
00021 #include "kick/core/touch_input.h"
00022 #include "kick/core/default_key_handler.h"
00023 #include "kick/core/event_queue.h"
00024 
00025 namespace kick {
00026     
00027     struct EngineConfig {
00028         bool shadows = false;
00029         int maxNumerOfLights = 3;
00030     };
00031 
00032     class Engine {
00033         friend class Project;
00034     public:
00035         static void init(int &argc, char **argv, const WindowConfig& config = WindowConfig::plain);
00036         static Scene *activeScene() { return instance->mActiveScene; }
00037         static void setActiveScene(Scene *scene) { instance->mActiveScene = scene; }
00038         static Scene * createScene(const std::string &name);
00039         static std::vector<Scene>::const_iterator begin();
00040         static std::vector<Scene>::const_iterator end();
00041 
00042         static const EngineConfig& config(){ return instance->mConfig; }
00043         static Context* context();
00044         static DefaultKeyHandler &defaultKeyHandler();
00045         static void startMainLoop();
00046         static void startFrame();
00047         static void update();
00048         static void render();
00049 
00050         // return the version number of the header
00051         inline static std::string headerVersion(){
00052             return std::string("0.0.1")
00053 #ifdef DEBUG
00054                 +"d"
00055 #endif
00056 #ifdef NDEBUG
00057                 +"n"
00058 #endif
00059             ;
00060         }
00061 
00062         static std::string libVersion();
00063 
00064         static EventQueue & getEventQueue();
00065 
00066     private:
00067         static Engine* instance;
00068         EngineConfig mConfig;
00069         EventQueue eventQueue;
00070         Engine(int &argc, char **argv, const WindowConfig& config = WindowConfig::plain);
00071         float tickStartTime;
00072 
00073         Project project;
00074         std::vector<Scene> scenes;
00075         EngineUniforms engineUniforms;
00076         Scene *mActiveScene = nullptr;
00077         Context* mContext = nullptr;
00078         DefaultKeyHandler mDefaultKeyHandler;
00079     };
00080 };
 All Classes Functions Variables