app.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * 2D Physic Engine
  3. * app.cpp: basic application handling.
  4. * Based on pikuma.com Learn Game Physics Engine Programming course.
  5. * Copyright (c) 2022 986-Studio. All rights reserved.
  6. *
  7. * Created by Manoël Trapier on 07/06/2022.
  8. */
  9. #include <app.h>
  10. #include <graphics.h>
  11. #include <imgui.h>
  12. #include <imgui_sdl.h>
  13. #include <imgui_impl_sdl.h>
  14. void application::parseParameters(int argc, char *argv[])
  15. {
  16. // Nothing to do for now
  17. }
  18. void application::setup()
  19. {
  20. running = graphics::openWindow();
  21. }
  22. void application::input()
  23. {
  24. SDL_Event event;
  25. while(SDL_PollEvent(&event))
  26. {
  27. //ImGui_ImplSDL2_ProcessEvent(&event);
  28. //ImGuiIO &io = ImGui::GetIO();
  29. switch(event.type)
  30. {
  31. case SDL_QUIT:
  32. running = false;
  33. break;
  34. case SDL_KEYDOWN:
  35. if (event.key.keysym.sym == SDLK_ESCAPE)
  36. {
  37. running = false;
  38. }
  39. break;
  40. }
  41. }
  42. }
  43. void application::update()
  44. {
  45. // Nothing for now.
  46. }
  47. void application::render()
  48. {
  49. graphics::clearScreen(0xFF056263);
  50. graphics::draw::fillCircle(200, 200, 40, 0xFFFFFFFF);
  51. graphics::draw::text(10, 10, graphics::makeColour(255, 12, 98), "Hello world!");
  52. graphics::renderFrame();
  53. }
  54. void application::destroy()
  55. {
  56. // Nothing for now.
  57. graphics::closeWindow();
  58. }