triangle.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * 3D Engine
  3. * triangle.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 04/03/2021.
  8. */
  9. #ifndef THREEDENGINE_SOURCE_INCLUDE_TRIANGLE_H
  10. #define THREEDENGINE_SOURCE_INCLUDE_TRIANGLE_H
  11. #include <stdint.h>
  12. #include <display.h>
  13. #include <vector.h>
  14. /***********************************************************************************************************************
  15. * Data types
  16. **********************************************************************************************************************/
  17. typedef struct face_t
  18. {
  19. int a, b, c;
  20. colour_t colour;
  21. } face_t;
  22. typedef struct triangle_t
  23. {
  24. vec2_t points[3];
  25. colour_t colour;
  26. double averageDepth;
  27. } triangle_t;
  28. /***********************************************************************************************************************
  29. * Prototypes
  30. **********************************************************************************************************************/
  31. void drawTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t x2, int32_t y2, colour_t colour);
  32. void drawFilledTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t x2, int32_t y2, colour_t colour);
  33. int compareTrianglesZOrder(const void *p1, const void *p2);
  34. #endif /* THREEDENGINE_SOURCE_INCLUDE_TRIANGLE_H */