3d-renderer/scripts/triangle.h

48 lines
975 B
C

#ifndef TRIANGLE_H
#define TRIANGLE_H
#include <stdint.h>
#include "texture.h"
#include "swap.h"
#include "vector.h"
#include "texture.h"
typedef uint32_t color_t;
typedef struct {
int a;
int b;
int c;
tex2_t a_uv;
tex2_t b_uv;
tex2_t c_uv;
color_t color;
} face_t;
typedef struct {
int x;
int y;
} int_vec2_t;
typedef struct {
vec2_t points[3];
tex2_t texcoords[3];
color_t color;
float average_depth;
} triangle_t;
void draw_triangle(triangle_t triangle, uint32_t color);
void draw_filled_triangle(int x0, int y0, int x1, int y1, int x2, int y2, color_t color);
void draw_textured_triangle(
int x0, int y0, float u0, float v0,
int x1, int y1, float u1, float v1,
int x2, int y2, float u2, float v2,
uint32_t* texture);
void draw_texel(
int x, int y, uint32_t* texture,
vec2_t point_a, vec2_t point_b, vec2_t point_c,
float u0, float v0, float u1, float v1, float u2, float v2);
#endif