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 | #include "r1_win.hh"
|
---|
10 | #include "r1_clip.hh"
|
---|
11 |
|
---|
12 | void r1_render_window_class::clip_with_z(i4_draw_context_class &context)
|
---|
13 | {
|
---|
14 | api->set_constant_color(0);
|
---|
15 |
|
---|
16 | api->set_alpha_mode(R1_ALPHA_DISABLED);
|
---|
17 | api->set_shading_mode(R1_CONSTANT_SHADING);
|
---|
18 | api->disable_texture();
|
---|
19 |
|
---|
20 | i4_rect_list_class area_to_mask;
|
---|
21 |
|
---|
22 | i4_rect_list_class::area_iter cl;
|
---|
23 | i4_rect_list_class *clip=&context.clip;
|
---|
24 |
|
---|
25 | int dx1, dy1, dx2, dy2;
|
---|
26 | dx1=0; dy1=0;
|
---|
27 | dx2=dx1 + render_area_width() -1;
|
---|
28 | dy2=dy1 + render_area_height() -1;
|
---|
29 |
|
---|
30 |
|
---|
31 | area_to_mask.add_area(dx1, dy1, dx2, dy2);
|
---|
32 | for (cl = clip->list.begin(); cl != clip->list.end(); ++cl)
|
---|
33 | area_to_mask.remove_area(cl->x1, cl->y1, cl->x2, cl->y2);
|
---|
34 |
|
---|
35 | i4_float near_z = 0.0001f;
|
---|
36 | i4_float far_z = r1_far_clip_z;
|
---|
37 |
|
---|
38 | api->set_z_range(near_z,far_z);
|
---|
39 |
|
---|
40 | api->set_write_mode(R1_WRITE_W);
|
---|
41 |
|
---|
42 | for (cl = clip->list.begin(); cl != clip->list.end(); ++cl)
|
---|
43 | api->clear_area(cl->x1+dx1, cl->y1+dy1, cl->x2+dx1, cl->y2+dy1,
|
---|
44 | api->get_constant_color(),
|
---|
45 | far_z);
|
---|
46 |
|
---|
47 | for (cl = area_to_mask.list.begin(); cl!= area_to_mask.list.end(); ++cl)
|
---|
48 | api->clear_area(cl->x1+dx1, cl->y1+dy1, cl->x2+dx1, cl->y2+dy1,
|
---|
49 | api->get_constant_color(),
|
---|
50 | near_z);
|
---|
51 |
|
---|
52 | api->set_write_mode(R1_WRITE_W | R1_WRITE_COLOR | R1_COMPARE_W);
|
---|
53 | }
|
---|
54 |
|
---|
55 | int r1_render_window_class::render_area_width()
|
---|
56 | {
|
---|
57 | if (expand_type == R1_COPY_1x1 ||
|
---|
58 | expand_type == R1_COPY_1x1_SCANLINE_SKIP)
|
---|
59 | return width();
|
---|
60 | else
|
---|
61 | return width()/2;
|
---|
62 | }
|
---|
63 |
|
---|
64 | int r1_render_window_class::render_area_height()
|
---|
65 | {
|
---|
66 | if (expand_type == R1_COPY_1x1 || expand_type == R1_COPY_1x1_SCANLINE_SKIP)
|
---|
67 | return height();
|
---|
68 | else
|
---|
69 | return height()/2;
|
---|
70 | }
|
---|
71 |
|
---|
72 | void r1_render_window_class::resize(w16 new_width, w16 new_height)
|
---|
73 | {
|
---|
74 | if (children.begin()!=children.end())
|
---|
75 | children.begin()->resize(new_width, new_height);
|
---|
76 |
|
---|
77 | i4_parent_window_class::resize(new_width, new_height);
|
---|
78 | }
|
---|
79 |
|
---|