Re-implementation of Izanami game engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
1.9 KiB

  1. #include <SDL.h>
  2. #include <stdbool.h>
  3. #include <stdio.h>
  4. #include "IZ_app.h"
  5. const char* APP_NAME = "SDL2";
  6. //const unsigned int SCREEN_WIDTH = 320;
  7. //const unsigned int SCREEN_HEIGHT = 240;
  8. // NES frame rate
  9. //const float SCREEN_FPS = 59.94f;
  10. //#define SDL_GetTicks64 SDL_GetTicks
  11. //
  12. //SDL_Window* IZ_GetWindow() {
  13. // if (SDL_Init(SDL_INIT_VIDEO) < 0) {
  14. // printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());
  15. // return NULL;
  16. // }
  17. //
  18. // SDL_Window* window = SDL_CreateWindow(
  19. // APP_NAME,
  20. // SDL_WINDOWPOS_UNDEFINED,
  21. // SDL_WINDOWPOS_UNDEFINED,
  22. // (int) SCREEN_WIDTH,
  23. // (int) SCREEN_HEIGHT,
  24. // SDL_WINDOW_SHOWN
  25. // );
  26. //
  27. // if (window == NULL) {
  28. // printf("Window could not be created! SDL_Error: %s\n", SDL_GetError());
  29. // return NULL;
  30. // }
  31. //
  32. // return window;
  33. //}
  34. int main(int argc, char** argv) {
  35. IZ_App app;
  36. return IZ_AppRun(&app, argc, argv, APP_NAME, 0, 0, 0);
  37. // SDL_Window* window = IZ_GetWindow();
  38. // if (!window) {
  39. // return -1;
  40. // }
  41. // SDL_Surface* screenSurface = SDL_GetWindowSurface(window);
  42. //
  43. // uint64_t start = SDL_GetTicks64();
  44. // unsigned int seconds_elapsed = 0;
  45. // uint64_t last_update = start;
  46. // unsigned int frames = 0;
  47. // bool quit = false;
  48. // SDL_Event e;
  49. // while (!quit) {
  50. // while (SDL_PollEvent(&e) != 0) {
  51. // if (e.type == SDL_QUIT) {
  52. // quit = true;
  53. // }
  54. // }
  55. //
  56. // unsigned int current_ticks = SDL_GetTicks64();
  57. // unsigned int delta = current_ticks - last_update;
  58. // unsigned int new_seconds_elapsed = current_ticks / 1000;
  59. //
  60. // if (new_seconds_elapsed > seconds_elapsed) {
  61. // printf("%u\n", frames);
  62. // frames = 0;
  63. // seconds_elapsed = new_seconds_elapsed;
  64. // }
  65. //
  66. // if ((float) delta < 1000.f / SCREEN_FPS) {
  67. // continue;
  68. // }
  69. //
  70. // last_update = current_ticks;
  71. // frames += 1;
  72. //
  73. // SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));
  74. // SDL_UpdateWindowSurface(window);
  75. // }
  76. //
  77. // SDL_DestroyWindow(window);
  78. // SDL_Quit();
  79. //
  80. // return 0;
  81. }