1 /* TSI 2023.xmo */
2 /*******************************************************************************
3  * Copyright (c) 2023 Think Silicon Single Member PC
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy
6  * of this header file and/or associated documentation files to use, copy,
7  * modify, merge, publish, distribute, sublicense, and/or sell copies of the
8  * Materials, and to permit persons to whom the Materials are furnished to do
9  * so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Materials.
13  *
14  * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
15  * NEMAGFX API. THE UNMODIFIED, NORMATIVE VERSIONS OF THINK-SILICON NEMAGFX
16  * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT:
17  *   https://think-silicon.com/products/software/nemagfx-api
18  *
19  *  The software is provided 'as is', without warranty of any kind, express or
20  *  implied, including but not limited to the warranties of merchantability,
21  *  fitness for a particular purpose and noninfringement. In no event shall
22  *  Think Silicon Single Member PC be liable for any claim, damages or other
23  *  liability, whether in an action of contract, tort or otherwise, arising
24  *  from, out of or in connection with the software or the use or other dealings
25  *  in the software.
26  ******************************************************************************/
27 
28 
29 #ifndef _NEMA_INTERPOLATORS_H_
30 #define _NEMA_INTERPOLATORS_H_
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include "nema_sys_defs.h"
37 
38 typedef struct _color_var_t {
39     float r; /**< Red */
40     float g; /**< Green */
41     float b; /**< Blue */
42     float a; /**< Alpha */
43 } color_var_t;
44 
45 /** \brief Interpolate color gradient for rectangle
46  *
47  * \param x0 x coordinate of the upper left vertex of the rectangle
48  * \param y0 y coordinate at the upper left vertex of the rectangle
49  * \param w width of the rectangle
50  * \param h height of the rectangle
51  * \param col0 color for the first vertex
52  * \param col1 color for the second vertex
53  * \param col1 color for the third vertex
54  *
55  */
56 void nema_interpolate_rect_colors(int x0, int y0, int w, int h, color_var_t* col0, color_var_t* col1, color_var_t* col2);
57 
58 
59 /** \brief Interpolate color gradient for triangle
60  *
61  * \details The upper left vertex of the triangle to be drawn
62  *  must be in the vertex arguments as well. In addition, if
63  * clipping is applied for rendering a triangle with gradient,
64  * the upper left vertex must be within the clipping area.
65  * \param x0 x coordinate at the first vertex of the triangle
66  * \param y0 y coordinate at the first vertex of the triangle
67  * \param x1 x coordinate at the second vertex of the triangle
68  * \param y1 y coordinate at the second vertex of the triangle
69  * \param x2 x coordinate at the third vertex of the triangle
70  * \param y2 y coordinate at the third vertex of the triangle
71  * \param col0 color for the first vertex
72  * \param col1 color for the second vertex
73  * \param col1 color for the third vertex
74  *
75  */
76 void nema_interpolate_tri_colors(float x0, float y0, float x1, float y1, float x2, float y2, color_var_t* col0, color_var_t* col1, color_var_t* col2);
77 
78 /** \brief Interpolate depth buffer values for triangle
79  *
80  * \param x0 x coordinate at the first vertex of the triangle
81  * \param y0 y coordinate at the first vertex of the triangle
82  * \param z0 z coordinate at the first vertex of the triangle
83  * \param x1 x coordinate at the second vertex of the triangle
84  * \param y1 y coordinate at the second vertex of the triangle
85  * \param z1 z coordinate at the second vertex of the triangle
86  * \param x2 x coordinate at the third vertex of the triangle
87  * \param y2 y coordinate at the third vertex of the triangle
88  * \param z2 z coordinate at the third vertex of the triangle
89  *
90  */
91 void nema_interpolate_tri_depth(float x0, float y0, float z0, float x1, float y1, float z1, float x2, float y2, float z2);
92 
93 /** \brief Interpolate texture values for triangle
94  *
95  * \param x0 x coordinate at the first vertex of the triangle
96  * \param y0 y coordinate at the first vertex of the triangle
97  * \param w0 w coordinate at the first vertex of the triangle
98  * \param tx0 x texture coordinate at the first vertex of the triangle
99  * \param ty0 y texture coordinate at the first vertex of the triangle
100  * \param x1 x coordinate at the second vertex of the triangle
101  * \param y1 y coordinate at the second vertex of the triangle
102  * \param w1 w coordinate at the second vertex of the triangle
103  * \param tx1 x texture coordinate at the second vertex of the triangle
104  * \param ty1 y texture coordinate at the second vertex of the triangle
105  * \param x2 x coordinate at the third vertex of the triangle
106  * \param y2 y coordinate at the third vertex of the triangle
107  * \param w2 w coordinate at the third vertex of the triangle
108  * \param tx2 x texture coordinate at the third vertex of the triangle
109  * \param ty2 x texture coordinate at the third vertex of the triangle
110  * \param tex_width texture width
111  * \param tex_height texture height
112  *
113  */
114 void nema_interpolate_tx_ty(float x0, float y0, float w0, float tx0, float ty0,
115                             float x1, float y1, float w1, float tx1, float ty1,
116                             float x2, float y2, float w2, float tx2, float ty2,
117                             int tex_width, int tex_height );
118 #ifdef __cplusplus
119 }
120 #endif
121 
122 #endif // _NEMA_INTERPOLATORS_H_
123