1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#ifndef _SOFTSHADEROOM_CLIP_H_
#define _SOFTSHADEROOM_CLIP_H_
#include "../util/type.h"
#include "vert.h"
#define LERP(t,a,b) ((1-(t))*(a)+(t)*(b))
typedef struct {
/*clipping coord*/
Vec4 clip_coord;
/*vertex data*/
Vert vertex;
/*register values*/
/*
float num[4];
Vec2 v2[6];
Vec3 v3[8];
Vec4 v4[6];
*/
} ClippedVert;
#define CLIP_BUFFER_SIZE 6
typedef struct {
ClippedVert vertices[CLIP_BUFFER_SIZE];
uint count;
/*temp register*/
float temp_reg_num[4][CLIP_BUFFER_SIZE];
Vec2 temp_reg_v2[6][CLIP_BUFFER_SIZE];
Vec3 temp_reg_v3[8][CLIP_BUFFER_SIZE];
Vec4 temp_reg_v4[6][CLIP_BUFFER_SIZE];
} ClippedBuffer;
ClippedBuffer clip_buffer;
typedef void* (*BcpInterpolator)(Vec3* bc, void* a, void* b, void* c, void* out);
typedef void* (*LinearInterpolator)(float t, void* a, void* b, void* c, void* out);
bool clip_triangle(Vec4* c0, Vec4* c1, Vec4* c2, Vert* v0, Vert* v1, Vert* v2, uint varying_flag, ClippedBuffer* clipped);
uint clip_line();
uint clip_point();
#endif
|