[80] | 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 |
|
---|
| 29 | union span_entry;
|
---|
| 30 | struct span_tri_info;
|
---|
| 31 | struct s_vert;
|
---|
| 32 | struct tri_edge;
|
---|
| 33 |
|
---|
| 34 | //span sorting function types
|
---|
| 35 | typedef i4_bool build_triangle_span_lists_func();
|
---|
| 36 | typedef i4_bool (*build_triangle_span_lists_func_ptr)();
|
---|
| 37 |
|
---|
| 38 | build_triangle_span_lists_func intel_build_triangle_span_lists;
|
---|
| 39 |
|
---|
| 40 | extern build_triangle_span_lists_func_ptr cur_build_span_lists_function;
|
---|
| 41 |
|
---|
| 42 | //texturemapping function types
|
---|
| 43 | typedef void (texture_scanline_func)(w16 *scanline, sw32 offset, void *span_info, sw32 width);
|
---|
| 44 | typedef void (*texture_scanline_func_ptr)(w16 *scanline, sw32 offset, void *span_info, sw32 width);
|
---|
| 45 |
|
---|
| 46 | extern texture_scanline_func_ptr texture_scanline_functions[];
|
---|
| 47 | extern texture_scanline_func_ptr cur_scanline_texture_func;
|
---|
| 48 |
|
---|
| 49 | texture_scanline_func texture_scanline_affine_lit;
|
---|
| 50 | texture_scanline_func texture_scanline_affine_unlit;
|
---|
| 51 | texture_scanline_func texture_scanline_affine_unlit_holy;
|
---|
| 52 |
|
---|
| 53 | texture_scanline_func texture_scanline_perspective_lit;
|
---|
| 54 | texture_scanline_func texture_scanline_perspective_unlit;
|
---|
| 55 | texture_scanline_func texture_scanline_perspective_unlit_holy;
|
---|
| 56 | texture_scanline_func texture_scanline_perspective_unlit_alpha;
|
---|
| 57 | texture_scanline_func texture_scanline_perspective_unlit_true_alpha;
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | texture_scanline_func texture_scanline_solid_blend_half;
|
---|
| 61 | texture_scanline_func texture_scanline_solid_fill;
|
---|
| 62 | texture_scanline_func texture_scanline_affine_unlit_holy_blend;
|
---|
| 63 | texture_scanline_func texture_scanline_affine_unlit_alpha;
|
---|
| 64 | texture_scanline_func texture_scanline_affine_unlit_alpha_sprite;
|
---|
| 65 | texture_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
|
---|
| 92 | typedef void (poly_setup_func)(s_vert *v, sw32 t_verts);
|
---|
| 93 | typedef void (*poly_setup_func_ptr)(s_vert *v, sw32 t_verts);
|
---|
| 94 |
|
---|
| 95 | poly_setup_func poly_setup_affine_lit;
|
---|
| 96 | poly_setup_func poly_setup_perspective_lit;
|
---|
| 97 | poly_setup_func poly_setup_solid_color;
|
---|
| 98 |
|
---|
| 99 | //special cased alpha-blend sprite
|
---|
| 100 | poly_setup_func sprite_setup_affine_unlit_alpha;
|
---|
| 101 |
|
---|
| 102 | extern poly_setup_func_ptr poly_setup_functions[];
|
---|
| 103 |
|
---|
| 104 | //spanning functions (steps through the list of spans for the tri)
|
---|
| 105 | typedef void (span_draw_func)(span_tri_info *tri);
|
---|
| 106 | typedef void (*span_draw_func_ptr)(span_tri_info *tri);
|
---|
| 107 |
|
---|
| 108 | span_draw_func span_draw_affine_unlit;
|
---|
| 109 | span_draw_func span_draw_affine_lit;
|
---|
| 110 |
|
---|
| 111 | span_draw_func span_draw_perspective_unlit;
|
---|
| 112 | span_draw_func span_draw_perspective_lit;
|
---|
| 113 |
|
---|
| 114 | span_draw_func span_draw_solid_color;
|
---|
| 115 |
|
---|
| 116 | extern span_draw_func_ptr span_draw_functions[];
|
---|
| 117 |
|
---|
| 118 | //straight rasterization functions
|
---|
| 119 | typedef 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);
|
---|
| 120 | typedef 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 |
|
---|
| 122 | tri_draw_func tri_draw_affine_unlit;
|
---|
| 123 | tri_draw_func tri_draw_affine_lit;
|
---|
| 124 | tri_draw_func tri_draw_perspective_lit;
|
---|
| 125 | tri_draw_func tri_draw_perspective_unlit;
|
---|
| 126 | tri_draw_func tri_draw_solid_color;
|
---|
| 127 |
|
---|
| 128 | extern tri_draw_func_ptr tri_draw_functions[];
|
---|
| 129 |
|
---|
| 130 | #ifdef USE_AMD3D
|
---|
| 131 |
|
---|
| 132 | //declare these amd3d functions
|
---|
| 133 |
|
---|
| 134 | build_triangle_span_lists_func amd3d_build_triangle_span_lists;
|
---|
| 135 |
|
---|
| 136 | texture_scanline_func texture_scanline_affine_lit_amd3d;
|
---|
| 137 | texture_scanline_func texture_scanline_perspective_lit_amd3d;
|
---|
| 138 | texture_scanline_func texture_scanline_perspective_unlit_amd3d;
|
---|
| 139 | texture_scanline_func texture_scanline_perspective_unlit_holy_amd3d;
|
---|
| 140 | texture_scanline_func texture_scanline_perspective_unlit_alpha_amd3d;
|
---|
| 141 |
|
---|
| 142 | span_draw_func span_draw_affine_unlit_amd3d;
|
---|
| 143 | span_draw_func span_draw_affine_lit_amd3d;
|
---|
| 144 | span_draw_func span_draw_perspective_unlit_amd3d;
|
---|
| 145 | span_draw_func span_draw_perspective_lit_amd3d;
|
---|
| 146 |
|
---|
| 147 | #endif
|
---|
| 148 |
|
---|
| 149 | #endif
|
---|
| 150 |
|
---|