engine.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #include "engine.h"
  2. #include <string>
  3. Engine::Engine(){
  4. }
  5. Engine::~Engine(){
  6. }
  7. bool Engine::startUp(){
  8. bool success = true;
  9. //Startup window manager and create window
  10. if( !FEWindowManager.startUp() ){
  11. success = false;
  12. printf("Failed to initialize window manager.\n");
  13. }
  14. else{
  15. if( !FERenderManager.startUp(FEWindowManager) ){
  16. success = false;
  17. printf("Failed to initialize render manager.\n");
  18. }
  19. else{
  20. if( !FEInputManager.startUp() ){
  21. success = false;
  22. printf("Failed to initialize input manager.\n");
  23. }
  24. }
  25. }
  26. return success;
  27. }
  28. void Engine::shutDown(){
  29. delete sceneModels;
  30. sceneModels = nullptr;
  31. FEInputManager.shutDown();
  32. FERenderManager.shutDown();
  33. FEWindowManager.shutDown();
  34. }
  35. void Engine::mainLoop(){
  36. bool done = false;
  37. int count = 0;
  38. printf("Entered Main Loop!\n");
  39. while(!done){
  40. ++count;
  41. //Handle all user input
  42. done = FEInputManager.processInput();
  43. //Update entities here in the future
  44. //TO DO
  45. //Perform all render calculations and update screen
  46. FERenderManager.render(sceneModels);
  47. SDL_Delay(500);
  48. printf("Loop Iteration N:%d\n",count);
  49. }
  50. }
  51. void Engine::loadModels(){
  52. //In the future I want to read all o the models in the model folder
  53. //And build them here. For now I force it to be only one.
  54. std::string path = "../models/teapot.obj";
  55. sceneModels = new Model(path);
  56. //sceneModels->describeMesh();
  57. }