display.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * 3D Engine
  3. * display.h:
  4. * Based on pikuma.com 3D software renderer in C
  5. * Copyright (c) 2021 986-Studio. All rights reserved.
  6. *
  7. * Created by Manoël Trapier on 01/03/2021.
  8. */
  9. #ifndef THREEDENGINE_SOURCE_INCLUDE_DISPLAY_H
  10. #define THREEDENGINE_SOURCE_INCLUDE_DISPLAY_H
  11. #include <SDL.h>
  12. /***********************************************************************************************************************
  13. * Constants
  14. **********************************************************************************************************************/
  15. #define FPS (30)
  16. #define FRAME_TARGET_TIME (1000 / FPS)
  17. /***********************************************************************************************************************
  18. * Global variables
  19. **********************************************************************************************************************/
  20. extern SDL_Window *window;
  21. extern SDL_Renderer *renderer;
  22. extern uint32_t *frameBuffer;
  23. extern SDL_Texture *frameBufferTexture;
  24. extern int32_t windowWidth;
  25. extern int32_t windowHeight;
  26. /***********************************************************************************************************************
  27. * Prototypes
  28. **********************************************************************************************************************/
  29. /* --- Window functions --- */
  30. bool initialiseWindow(bool fullScreen);
  31. void destroyWindow();
  32. void renderFrameBuffer();
  33. /* --- Drawing functions --- */
  34. void drawPixel(uint32_t x, uint32_t y, uint32_t colour);
  35. void clearFrameBuffer(int32_t colour);
  36. void drawGrid(int spacing, uint32_t colour);
  37. void drawRectangle(int32_t x, int32_t y, int32_t w, uint32_t h, uint32_t colour);
  38. void drawVLine(int32_t x, int32_t y0, int32_t y1, uint32_t colour);
  39. void drawHLine(int32_t x0, int32_t y, int32_t x1, uint32_t colour);
  40. void drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t colour);
  41. void drawTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint32_t colour);
  42. #endif /* THREEDENGINE_SOURCE_INCLUDE_DISPLAY_H */