source: golgotha/src/render/mip_average.hh

Last change on this file was 80, checked in by Sam Hocevar, 12 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: 4.3 KB
RevLine 
[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 MIP_AVERAGE_HH
10#define MIP_AVERAGE_HH
11
12struct i4_pixel_format;
13#include "math/num_type.hh"
14#include "time/profile.hh"
15
16//regular shifting info
17extern w32 mip_r_and; extern w8 mip_r_shift; //r and g shifts are to the left
18extern w32 mip_g_and; extern w8 mip_g_shift;
19extern w32 mip_b_and; extern w8 mip_b_shift; //b shift is to the right
20
21//chroma-key shifting info
22extern w32 mip_c_r_and; extern w8 mip_c_r_shift; //r and g shifts are to the left
23extern w32 mip_c_g_and; extern w8 mip_c_g_shift;
24extern w32 mip_c_b_and; extern w8 mip_c_b_shift; //b shift is to the right
25extern w32 mip_c_a_and; extern w8 mip_c_a_shift; //a shift is to the left
26
27//alpha texture shifting info
28extern w32 mip_a_r_and; extern w8 mip_a_r_shift; //r and g shifts are to the left
29extern w32 mip_a_g_and; extern w8 mip_a_g_shift;
30extern w32 mip_a_b_and; extern w8 mip_a_b_shift; //b shift is to the right
31extern w32 mip_a_a_and; extern w8 mip_a_a_shift; //a shift is to the left
32
33extern w8 mip_chroma_red,mip_chroma_green,mip_chroma_blue;
34
35extern i4_profile_class pf_make_next_mip;
36extern i4_profile_class pf_mip_24_to_16;
37
38void setup_pixel_formats(i4_pixel_format &reg_fmt,
39                         i4_pixel_format &chroma_fmt,
40                         i4_pixel_format &alpha_fmt,
41                         w32 chroma_color);
42
43inline void remap_pixel(w16 *&dst, w8 *&src)
44{
45  //convert 24bit RGB to 16bit RGB
46 
47  //shifts must go first, ands last 
48  *dst = (((w16)src[0] << mip_r_shift) & mip_r_and) |
49         (((w16)src[1] << mip_g_shift) & mip_g_and) |
50         (((w16)src[2] >> mip_b_shift) & mip_b_and);
51}
52
53inline void chroma_remap_pixel(w16 *&dst, w8 *&src)
54{
55  //convert 24bit RGB to argb 
56 
57  if (src[0]==mip_chroma_red && src[1]==mip_chroma_green && src[2]==mip_chroma_blue)
58  {
59    *dst = 0;
60  }
61  else
62  {
63    //alpha bit(s) is set if its not transparent
64    *dst = (((w16)src[0] << mip_c_r_shift) & mip_c_r_and) |
65           (((w16)src[1] << mip_c_g_shift) & mip_c_g_and) |
66           (((w16)src[2] >> mip_c_b_shift) & mip_c_b_and) |         
67           ((0xFFFFFFFF  << mip_c_a_shift) & mip_c_a_and);
68  }
69}
70
71inline void alpha_remap_pixel(w16 *&dst, w8 *&src)
72{
73  //convert 32bit ARGB to 16bit ARGB 
74 
75  //alpha bit(s) is set if its not transparent
76  *dst = (((w16)src[1] << mip_a_r_shift) & mip_a_r_and) |
77         (((w16)src[2] << mip_a_g_shift) & mip_a_g_and) |
78         (((w16)src[3] >> mip_a_b_shift) & mip_a_b_and) |         
79         (((w16)src[0] << mip_a_a_shift) & mip_a_a_and); 
80}
81
82void r1_dos_paths(char *src);
83
84void r1_unix_paths(char *src);
85
86char *r1_remove_paths(char *src);
87
88void r1_remove_extention(char *src);
89
90void r1_concatenate_path(char *src, char *path);
91
92void chroma_process(w8 *&p, float &r, float &g, float &b, sw8 &num_regular, sw8 &num_chroma);
93
94void average_4x4_chroma(w16 *&dst, w8 *dst_24, w8 *&p0, w8 *p1, w8 *p2, w8 *p3);
95
96void average_4x4_chroma(w8 *dst_24, w8 *&p0, w8 *p1, w8 *p2, w8 *p3);
97
98void average_4x4_alpha(w8 *dst_24, w8 *&p0, w8 *p1, w8 *p2, w8 *p3);
99
100void average_4x4_alpha(w16 *dst, w8 *dst_24, w8 *&p0, w8 *p1, w8 *p2, w8 *p3);
101
102void average_4x4_normal(w16 *dst, w8 *dst_24, w8 *p0, w32 bpl);
103
104void average_4x4_normal(w8 *dst_24, w8 *p0, w32 bpl);
105
106void mip_24_to_16(w8 *mip24, w16 *mip16, sw32 &width,
107                         sw32 &height, sw32 &base_width, w8 &flags);
108
109void make_next_mip(w8 *mip24, w16 *mip16, sw32 &width, sw32 &height,
110                          sw32 &base_width, w8 &flags);
111
112void make_square(w8 *mip24, w8 *square_mip24, w8 base_pixel_size, sw32 base_width,
113                        sw32 base_height, sw32 new_dimention);
114
115void generate_mip_offsets(sw32 base_width,sw32 base_height,
116                          sw32 num_to_copy,
117                          sw32 *offsets, sw32 pixel_size);
118
119#endif
Note: See TracBrowser for help on using the repository browser.