1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- /*
- * 3D Engine
- * triangle.h:
- * Based on pikuma.com 3D software renderer in C
- * Copyright (c) 2021 986-Studio. All rights reserved.
- *
- * Created by Manoël Trapier on 04/03/2021.
- */
- #ifndef THREEDENGINE_SOURCE_INCLUDE_TRIANGLE_H
- #define THREEDENGINE_SOURCE_INCLUDE_TRIANGLE_H
- #include <stdint.h>
- #include <display.h>
- #include <vector.h>
- #include <texture.h>
- /***********************************************************************************************************************
- * Data types
- **********************************************************************************************************************/
- typedef struct face_t
- {
- int a, b, c;
- int at, bt, ct;
- tex2_t a_uv, b_uv, c_uv;
- colour_t colour;
- } face_t;
- typedef struct triangle_t
- {
- vec4_t points[3];
- tex2_t textureCoordinates[3];
- colour_t colour;
- double averageDepth;
- uint32_t *texture;
- } triangle_t;
- /***********************************************************************************************************************
- * Global variables
- **********************************************************************************************************************/
- extern bool doPerpectiveCorrection;
- /***********************************************************************************************************************
- * Prototypes
- **********************************************************************************************************************/
- void drawTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t x2, int32_t y2, colour_t colour);
- void drawFilledTriangle(struct triangle_t *t);
- void drawTextureTriangle(struct triangle_t *t);
- int compareTrianglesZOrder(const void *p1, const void *p2);
- #endif /* THREEDENGINE_SOURCE_INCLUDE_TRIANGLE_H */
|