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 _R1_SOFTWARE_HH_
|
---|
10 | #define _R1_SOFTWARE_HH_
|
---|
11 |
|
---|
12 | //define this to enable the use of assembly code
|
---|
13 | #define USE_ASM
|
---|
14 |
|
---|
15 | //define this to use amd3d assembly or intel assembly (not defining it will use intel)
|
---|
16 | #define USE_AMD3D
|
---|
17 |
|
---|
18 | #include "r1_api.hh"
|
---|
19 | #include "r1_win.hh"
|
---|
20 | #include "software/r1_software_types.hh"
|
---|
21 | #include <ddraw.h>
|
---|
22 |
|
---|
23 | class r1_software_class : public r1_render_api_class
|
---|
24 | {
|
---|
25 | public:
|
---|
26 | char *name() { return "Software Span Buffer"; }
|
---|
27 |
|
---|
28 | friend class r1_software_render_window_class;
|
---|
29 |
|
---|
30 | r1_render_window_class *create_render_window(int w, int h, r1_expand_type expand_type);
|
---|
31 | //creates a render_window class (again, i dunno wtf those do)
|
---|
32 |
|
---|
33 | i4_bool expand_type_supported(r1_expand_type type);
|
---|
34 | //used when creating r1_render_windows, I think. determines if
|
---|
35 | //the r1 implementation supports things like double pixel, scanline skip, etc
|
---|
36 | //(the software rasterizer supports all of em)
|
---|
37 |
|
---|
38 | r1_software_class();
|
---|
39 | ~r1_software_class();
|
---|
40 |
|
---|
41 |
|
---|
42 | i4_bool init(i4_display_class *display);
|
---|
43 |
|
---|
44 | void uninit();
|
---|
45 |
|
---|
46 | void modify_features(w32 feature_bits, int on);
|
---|
47 | //the 'features' are the main way an external application can control
|
---|
48 | //exactly what the software rasterizer does. R1_SPANS can be used to turn
|
---|
49 | //span buffering on and off (if its off, the faces must be pre-sorted),
|
---|
50 | //R1_PERSPECTIVE can be used to turn perspective mapping off, R1_Z_BIAS
|
---|
51 | //can be used to help things sort somewhat in front of other things in the
|
---|
52 | //scene (although it should truely just be removed). R1_LOCK_CHEAT draws
|
---|
53 | //to an unlocked surface (ie, it calls DirectDrawSurface->Lock() to get
|
---|
54 | //the pointer, then calls Unlock() but still uses the pointer).
|
---|
55 |
|
---|
56 | i4_bool is_feature_on(w32 feature_bits);
|
---|
57 |
|
---|
58 | //i4_image handling routines
|
---|
59 | i4_image_class *create_compatible_image(w16 w, w16 h);
|
---|
60 | //creates an image of the same bit depth and palette of screen (for use with put_image)
|
---|
61 |
|
---|
62 |
|
---|
63 | //the r1 interface
|
---|
64 | void set_alpha_mode(r1_alpha_type type);
|
---|
65 | void set_write_mode(r1_write_mask_type mask);
|
---|
66 | void set_shading_mode(r1_shading_type type);
|
---|
67 | void set_constant_color(w32 color);
|
---|
68 | void set_z_range(i4_float near_z, i4_float far_z);
|
---|
69 |
|
---|
70 | void render_poly(int t_verts, r1_vert *verts);
|
---|
71 | void render_sprite(r1_vert *verts);
|
---|
72 | void render_pixel(r1_vert *pixel);
|
---|
73 | void render_lines(int t_lines, r1_vert *verts);
|
---|
74 | void clear_area(int x1, int y1, int x2, int y2, w32 color, float w);
|
---|
75 |
|
---|
76 | void use_texture(r1_texture_handle material_ref,
|
---|
77 | sw32 desired_width,
|
---|
78 | w32 frame);
|
---|
79 |
|
---|
80 | void disable_texture();
|
---|
81 | //no texturemapping, drawing is done with the constant color (see set_constant_color)
|
---|
82 |
|
---|
83 | r1_color_tint_handle register_color_tint(i4_float r, i4_float g, i4_float b);
|
---|
84 |
|
---|
85 | //calling this with a handle of 0 disables tinting
|
---|
86 | void set_color_tint(r1_color_tint_handle color_tint_handle);
|
---|
87 |
|
---|
88 | //these are currently public so that non member functions (of which there are
|
---|
89 | //several) can access them
|
---|
90 | i4_bool use_spans;
|
---|
91 | i4_bool lock_cheat;
|
---|
92 | i4_bool allow_backfaces;
|
---|
93 | sw8 cur_color_tint;
|
---|
94 |
|
---|
95 | void copy_part(i4_image_class *im,
|
---|
96 | int x, int y, // position on screen
|
---|
97 | int x1, int y1, // area of image to copy
|
---|
98 | int x2, int y2);
|
---|
99 |
|
---|
100 | private:
|
---|
101 |
|
---|
102 | sw32 total_texture_mem() { return 1024*1024*2; }
|
---|
103 | sw32 texture_mem_start() { return 0; }
|
---|
104 |
|
---|
105 | void initialize_function_pointers(i4_bool use_amd3d_functions);
|
---|
106 | void init_color_tints();
|
---|
107 |
|
---|
108 | void update_tri_function();
|
---|
109 |
|
---|
110 | //private primitive functions
|
---|
111 | void draw_line(sw32 x0, sw32 y0, sw32 x1, sw32 y1, w16 color);
|
---|
112 | void draw_line(sw32 x0, sw32 y0, sw32 x1, sw32 y1, w16 start_color, w16 end_color);
|
---|
113 |
|
---|
114 |
|
---|
115 | void prepare_verts(s_vert *s_v, r1_vert *r1_v, sw32 num_verts);
|
---|
116 |
|
---|
117 | i4_pixel_format fmt;
|
---|
118 |
|
---|
119 | i4_bool holy_mode;
|
---|
120 | i4_bool alphatexture_mode;
|
---|
121 | i4_bool do_perspective;
|
---|
122 | i4_bool do_flat;
|
---|
123 | i4_bool texture_mode;
|
---|
124 | float z_bias;
|
---|
125 |
|
---|
126 | sw32 width_compare;
|
---|
127 | sw32 height_compare;
|
---|
128 |
|
---|
129 | w32 cur_color;
|
---|
130 |
|
---|
131 | float cur_s_width,cur_t_height;
|
---|
132 |
|
---|
133 | float const_color_red,
|
---|
134 | const_color_green,
|
---|
135 | const_color_blue,
|
---|
136 | const_color_alpha;
|
---|
137 |
|
---|
138 | float red_clight_mul;
|
---|
139 | float green_clight_mul;
|
---|
140 | float blue_clight_mul;
|
---|
141 | };
|
---|
142 |
|
---|
143 | extern r1_software_class r1_software_class_instance;
|
---|
144 | #endif
|
---|
145 |
|
---|