convert line ends
[canaan.git] / prj / tech / libsrc / r3d / init.c
blob08e45b87197ab6d22cecafe4a69cfeaf10144f4f
1 // $Header: x:/prj/tech/libsrc/r3d/RCS/init.c 1.9 1997/10/03 13:02:13 KEVIN Exp $
2 // this has the r3d initializers, as well as global state setup
4 #include <string.h>
5 #include <ctxts.h>
6 #include <r3dctxt.h>
7 #include <_ctxt.h>
8 #include <_xfrm.h>
10 r3s_global_context r3d_glob; // global context
11 r3s_global_state r3d_state; // global state
13 // more complex call that let's the user set stuff
14 // trans depth is expected object transform depth
15 // clip_planes is the number of expected clip planes
16 void r3_init_defaults(int trans_depth,int clip_planes,r3e_space space,int ctxt_cnt, int stride)
18 r3_init_context( (ctxt_cnt==-1)?R3_DEF_CTXT_STACK:ctxt_cnt );
20 r3d_state.trans_depth = (trans_depth==-1)?8:trans_depth;
21 r3d_state.clip_planes = (clip_planes==-1)?4:clip_planes;
22 r3d_state.space = (space==-1)?R3_CLIPPING_SPACE:space;
23 r3d_state.stride = (stride==-1)?(sizeof (r3s_point )):stride;
25 // indicate that there is no current space
26 r3d_glob.cur_space = -1;
28 // set world default to turn x into z, y into -x, z into -y
29 memset(&r3d_state.world,0,sizeof(r3d_state.world));
30 X2MAT(&r3d_state.world)->m2 = 1.0;
31 X2MAT(&r3d_state.world)->m3 = -1.0;
32 X2MAT(&r3d_state.world)->m7 = -1.0;
34 r3_use_g2(); // set the default driver
37 // simple init call that most users will use, that just uses all the default
38 void r3_init(void)
40 r3_init_defaults(-1,-1,-1,-1,-1); // need to do this for real
43 void r3_close(void)
45 r3_close_context();
48 // Sets a world coord system inherited by all subsequent context creations.
49 // The default is the identity transform. As well, the handedness bit is set
50 // in the transform. If you have a current context.
52 void r3_set_default_world(mxs_trans *w)
54 // wow, copying structures!
55 *X2TRANS(&r3d_state.world) = *w;
58 mxs_trans *r3_get_default_world()
60 return X2TRANS(&r3d_state.world);
63 // Sets the default camera space that all new contexts inherit. The default
64 // is R3_CLIPPING.
66 void r3_set_default_space(r3e_space s)
68 r3d_state.space = s;
71 r3e_space r3_get_default_space()
73 return r3d_state.space;
76 void r3_set_default_stride(int stride)
78 r3d_state.stride = stride;
81 int r3_get_default_stride()
83 return r3d_state.stride;