Re-implementation of Izanami game engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

49 lignes
1014 B

  1. #include <SDL.h>
  2. #include <stdbool.h>
  3. #include <stdio.h>
  4. const char* APP_NAME = "SDL2";
  5. const int SCREEN_WIDTH = 640;
  6. const int SCREEN_HEIGHT = 480;
  7. int main(int argc, char* args[]) {
  8. SDL_Window* window = NULL;
  9. SDL_Surface* screenSurface = NULL;
  10. if (SDL_Init(SDL_INIT_VIDEO) < 0) {
  11. printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());
  12. return -1;
  13. }
  14. window = SDL_CreateWindow(
  15. APP_NAME,
  16. SDL_WINDOWPOS_UNDEFINED,
  17. SDL_WINDOWPOS_UNDEFINED,
  18. SCREEN_WIDTH,
  19. SCREEN_HEIGHT,
  20. SDL_WINDOW_SHOWN
  21. );
  22. if (window == NULL) {
  23. printf("Window could not be created! SDL_Error: %s\n", SDL_GetError());
  24. return -2;
  25. }
  26. bool quit = false;
  27. SDL_Event e;
  28. screenSurface = SDL_GetWindowSurface(window);
  29. while (!quit) {
  30. while (SDL_PollEvent(&e) != 0) {
  31. if (e.type == SDL_QUIT) {
  32. quit = true;
  33. }
  34. SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));
  35. SDL_UpdateWindowSurface(window);
  36. }
  37. }
  38. SDL_DestroyWindow(window);
  39. SDL_Quit();
  40. return 0;
  41. }