pikaMain.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <filesystem>
  4. #include <glad/glad.h>
  5. #include <windowSystemm/window.h>
  6. #include "logs/assert.h"
  7. #include "dllLoader/dllLoader.h"
  8. #include "pikaImgui/pikaImgui.h"
  9. #include <pikaAllocator/memoryArena.h>
  10. #include <runtimeContainer/runtimeContainer.h>
  11. #include <logs/log.h>
  12. #include <logWindow.h>
  13. int main()
  14. {
  15. #pragma region log
  16. pika::LogManager logs;
  17. logs.init("logs.txt");
  18. pika::LogWindow logWindow;
  19. logWindow.init();
  20. #pragma endregion
  21. #pragma region load dll
  22. std::filesystem::path currentPath = std::filesystem::current_path();
  23. pika::DllLoader dllLoader;
  24. PIKA_PERMA_ASSERT(dllLoader.loadDll(currentPath), "Couldn't load dll");
  25. #pragma endregion
  26. #pragma region init window opengl imgui and context
  27. PIKA_PERMA_ASSERT(glfwInit(), "Problem initializing glfw");
  28. //glfwSetErrorCallback(error_callback); todo
  29. pika::PikaWindow window = {};
  30. window.create();
  31. PIKA_PERMA_ASSERT(gladLoadGL(), "Problem initializing glad");
  32. pika::initImgui(window.context);
  33. window.context.glfwMakeContextCurrentPtr = glfwMakeContextCurrent;
  34. #pragma endregion
  35. #pragma region init dll reaml
  36. dllLoader.gameplayStart_(window.context);
  37. std::vector<ContainerInformation> loadedContainers;
  38. //todo validate stuff
  39. dllLoader.getContainersInfo_(loadedContainers);
  40. #pragma endregion
  41. logs.log("test");
  42. RuntimeContainer container;
  43. container.arena.allocateStaticMemory(loadedContainers[0]); //this just allocates the memory
  44. dllLoader.constructRuntimeContainer(container, "Gameplay"); //this calls the constructors
  45. container.pointer->create(); //this calls create()
  46. while (!window.shouldClose())
  47. {
  48. #pragma region reload dll
  49. if (dllLoader.reloadDll())
  50. {
  51. dllLoader.gameplayReload_(window.context);
  52. }
  53. #pragma endregion
  54. #pragma region start imgui
  55. pika::imguiStartFrame(window.context);
  56. #pragma endregion
  57. #pragma region clear screen
  58. glClear(GL_COLOR_BUFFER_BIT);
  59. #pragma endregion
  60. #pragma region editor stuff
  61. if (ImGui::BeginMenuBar())
  62. {
  63. if (ImGui::BeginMenu("Open..."))
  64. {
  65. ImGui::Text("menu text");
  66. ImGui::EndMenu();
  67. }
  68. ImGui::EndMenuBar();
  69. }
  70. logWindow.update(logs);
  71. #pragma endregion
  72. container.pointer->update(window.input, window.deltaTime, window.windowState);
  73. #pragma region end imgui frame
  74. pika::imguiEndFrame(window.context);
  75. #pragma endregion
  76. window.update();
  77. }
  78. return 0;
  79. }