deepstone

diff src/mglimpl.h @ 25:5ff8ce78059a

first pass at converting the rasterizer to fixed point
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 22 Sep 2013 02:21:30 +0300
parents 4ad71b558ab2
children 11d14f688485
line diff
     1.1 --- a/src/mglimpl.h	Sat Sep 21 20:18:28 2013 +0300
     1.2 +++ b/src/mglimpl.h	Sun Sep 22 02:21:30 2013 +0300
     1.3 @@ -26,6 +26,14 @@
     1.4  	int cidx;
     1.5  };
     1.6  
     1.7 +struct fixed_vertex {
     1.8 +	vec4x_t pos;
     1.9 +	vec4x_t norm;
    1.10 +	vec2x_t tc;
    1.11 +	fixed energy;
    1.12 +	int cidx;
    1.13 +};
    1.14 +
    1.15  struct texture {
    1.16  	int width, height;
    1.17  	int xshift, yshift;
    1.18 @@ -57,6 +65,25 @@
    1.19  };
    1.20  
    1.21  
    1.22 +#define vertex_to_fixedvertex(v, vx) \
    1.23 +	do { \
    1.24 +		vec4_to_fixed4((v).pos, (vx).pos); \
    1.25 +		vec3_to_fixed3((v).norm, (vx).norm); \
    1.26 +		vec2_to_fixed2((v).tc, (vx).tc); \
    1.27 +		(vx).energy = fixedf((v).energy); \
    1.28 +		(vx).cidx = (v).cidx; \
    1.29 +	} while(0)
    1.30 +
    1.31 +#define fixedvertex_to_vertex(vx, v) \
    1.32 +	do { \
    1.33 +		fixed4_to_vec4((vx).pos, (v).pos); \
    1.34 +		fixed3_to_vec3((vx).norm, (v).norm); \
    1.35 +		fixed2_to_vec2((vx).tc, (v).tc); \
    1.36 +		(v).energy = fixed_float((vx).energy); \
    1.37 +		(v).cidx = (vx).cidx; \
    1.38 +	} while(0)
    1.39 +
    1.40 +
    1.41  int mgl_rast_init(struct state *state, struct framebuffer *fbuf);
    1.42  void mgl_rast_cleanup(void);
    1.43  void mgl_rast_prepare(void);