source: golgotha/src/render/software/mappers.hh @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 6.0 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#ifndef MAPPERS_HH
10#define MAPPERS_HH
11
12#include "software/r1_software.hh"
13
14//this is what defines all of the various texturemapping, tri setup, and span drawing functions
15//all of the various texturemappers / fillers / lit texturemappers / etc go through approximately
16//3 stages.
17
18//1 - "poly setup" - the polygon is broken into triangles and the gradients are calculated for
19//                   whatever is requried, edges are added to the span list table, etc
20
21//(if spanbuffering, all of the edges are sorted and spans generated for each tri inbetween)
22//steps 1 and 2
23
24//2 - "rasterization or spanning" - the tri's list of spans is stepped through or the edges
25//                                  of the tri are stepped down
26
27//3 - "scanline texturing" - the horizontal spans of the tri are drawn
28
29union span_entry;
30struct span_tri_info;
31struct s_vert;
32struct tri_edge;
33
34//span sorting function types
35typedef i4_bool build_triangle_span_lists_func();
36typedef i4_bool (*build_triangle_span_lists_func_ptr)();
37
38build_triangle_span_lists_func intel_build_triangle_span_lists;
39
40extern build_triangle_span_lists_func_ptr cur_build_span_lists_function;
41
42//texturemapping function types
43typedef void (texture_scanline_func)(w16 *scanline, sw32 offset, void *span_info, sw32 width);
44typedef void (*texture_scanline_func_ptr)(w16 *scanline, sw32 offset, void *span_info, sw32 width);
45
46extern texture_scanline_func_ptr texture_scanline_functions[];
47extern texture_scanline_func_ptr cur_scanline_texture_func;
48
49texture_scanline_func texture_scanline_affine_lit;
50texture_scanline_func texture_scanline_affine_unlit;
51texture_scanline_func texture_scanline_affine_unlit_holy;
52
53texture_scanline_func texture_scanline_perspective_lit;
54texture_scanline_func texture_scanline_perspective_unlit;
55texture_scanline_func texture_scanline_perspective_unlit_holy;
56texture_scanline_func texture_scanline_perspective_unlit_alpha;
57texture_scanline_func texture_scanline_perspective_unlit_true_alpha;
58
59
60texture_scanline_func texture_scanline_solid_blend_half;
61texture_scanline_func texture_scanline_solid_fill;
62texture_scanline_func texture_scanline_affine_unlit_holy_blend;
63texture_scanline_func texture_scanline_affine_unlit_alpha;
64texture_scanline_func texture_scanline_affine_unlit_alpha_sprite;
65texture_scanline_func texture_scanline_affine_unlit_true_alpha;
66
67//all texturemapping types are elisted below
68//these values should not interfere
69#define LEADING_1                               ((w8)128)
70
71#define SPAN_TRI_UNDEFINED                      ((w8) 0)
72#define SPAN_TRI_AFFINE_LIT                     ((w8) 1)
73#define SPAN_TRI_PERSPECTIVE_LIT                ((w8) 2)
74#define SPAN_TRI_AFFINE_UNLIT                   ((w8) 3)
75#define SPAN_TRI_PERSPECTIVE_UNLIT              ((w8) 4)
76#define SPAN_TRI_SOLID_FILL                     ((w8) 5)
77
78//all types above this are considered "solid"
79#define SPAN_TRI_SEE_THRU                       ((w8) 6) //used as comparison in span buffering
80//all types below this are considered "see-thru-able"
81
82#define SPAN_TRI_SOLID_BLEND                    ((w8) 7)
83#define SPAN_TRI_AFFINE_UNLIT_HOLY              ((w8) 8)
84#define SPAN_TRI_AFFINE_UNLIT_HOLY_BLEND        ((w8) 9)
85#define SPAN_TRI_AFFINE_UNLIT_ALPHA             ((w8)10)
86#define SPAN_TRI_AFFINE_UNLIT_ALPHA_SPRITE      ((w8)11)
87#define SPAN_TRI_PERSPECTIVE_UNLIT_HOLY         ((w8)12)
88#define SPAN_TRI_PERSPECTIVE_UNLIT_ALPHA        ((w8)13)
89#define SPAN_TRI_LAST                           ((w8)14)
90
91//poly setup functions
92typedef void (poly_setup_func)(s_vert *v, sw32 t_verts);
93typedef void (*poly_setup_func_ptr)(s_vert *v, sw32 t_verts);
94
95poly_setup_func poly_setup_affine_lit;
96poly_setup_func poly_setup_perspective_lit;
97poly_setup_func poly_setup_solid_color;
98
99//special cased alpha-blend sprite
100poly_setup_func sprite_setup_affine_unlit_alpha;
101
102extern poly_setup_func_ptr poly_setup_functions[];
103
104//spanning functions (steps through the list of spans for the tri)
105typedef void (span_draw_func)(span_tri_info *tri);
106typedef void (*span_draw_func_ptr)(span_tri_info *tri);
107
108span_draw_func span_draw_affine_unlit;
109span_draw_func span_draw_affine_lit;
110
111span_draw_func span_draw_perspective_unlit;
112span_draw_func span_draw_perspective_lit;
113
114span_draw_func span_draw_solid_color;
115
116extern span_draw_func_ptr span_draw_functions[];
117
118//straight rasterization functions
119typedef void (tri_draw_func)(tri_edge &top_to_mid, tri_edge &top_to_bot, tri_edge &mid_to_bot, sw32 start_y, i4_bool edge_comp);
120typedef void (*tri_draw_func_ptr)(tri_edge &top_to_mid, tri_edge &top_to_bot, tri_edge &mid_to_bot, sw32 start_y, i4_bool edge_comp);
121
122tri_draw_func tri_draw_affine_unlit;
123tri_draw_func tri_draw_affine_lit;
124tri_draw_func tri_draw_perspective_lit;
125tri_draw_func tri_draw_perspective_unlit;
126tri_draw_func tri_draw_solid_color;
127
128extern tri_draw_func_ptr tri_draw_functions[];
129
130#ifdef USE_AMD3D
131
132//declare these amd3d functions
133
134build_triangle_span_lists_func amd3d_build_triangle_span_lists;
135
136texture_scanline_func texture_scanline_affine_lit_amd3d;
137texture_scanline_func texture_scanline_perspective_lit_amd3d;
138texture_scanline_func texture_scanline_perspective_unlit_amd3d;
139texture_scanline_func texture_scanline_perspective_unlit_holy_amd3d;
140texture_scanline_func texture_scanline_perspective_unlit_alpha_amd3d;
141
142span_draw_func span_draw_affine_unlit_amd3d;
143span_draw_func span_draw_affine_lit_amd3d;
144span_draw_func span_draw_perspective_unlit_amd3d;
145span_draw_func span_draw_perspective_lit_amd3d;
146
147#endif
148
149#endif
150
Note: See TracBrowser for help on using the repository browser.