diff --git a/common/3d/clipper.cpp b/common/3d/clipper.cpp index aebb46768..01072cb60 100644 --- a/common/3d/clipper.cpp +++ b/common/3d/clipper.cpp @@ -13,6 +13,8 @@ #include "compiler-exchange.h" #include "compiler-range_for.h" +inline namespace dcx { + temporary_points_t::temporary_points_t() : free_point_num(0) { @@ -185,3 +187,4 @@ const polygon_clip_points &clip_polygon(polygon_clip_points &rsrc,polygon_clip_p return *src; //we swapped after we copied } +} diff --git a/common/3d/clipper.h b/common/3d/clipper.h index 5f87a39dc..ea59540c5 100644 --- a/common/3d/clipper.h +++ b/common/3d/clipper.h @@ -23,6 +23,8 @@ struct g3s_point; #include "globvars.h" #include "compiler-array.h" +inline namespace dcx { + struct polygon_clip_points : array {}; struct temporary_points_t { @@ -35,6 +37,8 @@ struct temporary_points_t const polygon_clip_points &clip_polygon(polygon_clip_points &src,polygon_clip_points &dest,int *nv,g3s_codes *cc,temporary_points_t &); void clip_line(g3s_point *&p0,g3s_point *&p1,uint_fast8_t codes_or,temporary_points_t &); + +} #endif #endif diff --git a/common/3d/draw.cpp b/common/3d/draw.cpp index ba397a9f8..803e0f87d 100644 --- a/common/3d/draw.cpp +++ b/common/3d/draw.cpp @@ -21,6 +21,8 @@ #include "gr.h" #endif +inline namespace dcx { + tmap_drawer_type tmap_drawer_ptr = draw_tmap; #ifndef OGL static const flat_drawer_type flat_drawer_ptr = gr_upoly_tmap; @@ -288,3 +290,4 @@ void g3_draw_sphere(g3s_point &pnt,fix rad) } #endif +} diff --git a/common/3d/globvars.cpp b/common/3d/globvars.cpp index 69c86e58e..ad0bf93ad 100644 --- a/common/3d/globvars.cpp +++ b/common/3d/globvars.cpp @@ -14,6 +14,8 @@ #include "3d.h" #include "globvars.h" +inline namespace dcx { + vms_vector View_position; fix View_zoom; @@ -40,3 +42,4 @@ double fCanv_h2; +} diff --git a/common/3d/globvars.h b/common/3d/globvars.h index ea16c995c..9363a0d66 100644 --- a/common/3d/globvars.h +++ b/common/3d/globvars.h @@ -18,6 +18,8 @@ struct vms_vector; struct vms_matrix; struct g3s_point; +inline namespace dcx { + extern int Canvas_width,Canvas_height; //the actual width & height extern fix Canv_w2,Canv_h2; //fixed-point width,height/2 @@ -31,6 +33,7 @@ extern fix View_zoom; extern vms_vector View_position,Matrix_scale; extern vms_matrix View_matrix,Unscaled_matrix; +} //vertex buffers for polygon drawing and clipping //list of 2d coords diff --git a/common/3d/instance.cpp b/common/3d/instance.cpp index 1a43d4b4d..df39c5733 100644 --- a/common/3d/instance.cpp +++ b/common/3d/instance.cpp @@ -16,6 +16,8 @@ #include "3d.h" #include "globvars.h" +inline namespace dcx { + #define MAX_INSTANCE_DEPTH 5 namespace { @@ -81,3 +83,4 @@ void g3_done_instance() } +} diff --git a/common/3d/matrix.cpp b/common/3d/matrix.cpp index ad195031c..49c9af1e1 100644 --- a/common/3d/matrix.cpp +++ b/common/3d/matrix.cpp @@ -14,6 +14,8 @@ #include "3d.h" #include "globvars.h" +inline namespace dcx { + static void scale_matrix(void); //set view from x,y,z, viewer matrix, and zoom. Must call one of g3_set_view_*() @@ -52,3 +54,4 @@ static void scale_matrix(void) } +} diff --git a/common/3d/points.cpp b/common/3d/points.cpp index 1d17c9eea..d505f7e9b 100644 --- a/common/3d/points.cpp +++ b/common/3d/points.cpp @@ -14,6 +14,7 @@ #include "3d.h" #include "globvars.h" +inline namespace dcx { //code a point. fills in the p3_codes field of the point, and returns the codes ubyte g3_code_point(g3s_point &p) @@ -144,3 +145,5 @@ fix g3_calc_point_depth(const vms_vector &pnt) fixmulaccum(&q,(pnt.z - View_position.z),View_matrix.fvec.z); return fixquadadjust(&q); } + +} diff --git a/common/3d/rod.cpp b/common/3d/rod.cpp index 962c58cc7..45d47af2c 100644 --- a/common/3d/rod.cpp +++ b/common/3d/rod.cpp @@ -20,6 +20,8 @@ #include "compiler-range_for.h" +inline namespace dcx { + namespace { struct rod_4point @@ -167,3 +169,4 @@ void g3_draw_bitmap(const vms_vector &pos,fix width,fix height,grs_bitmap &bm) +} diff --git a/common/3d/setup.cpp b/common/3d/setup.cpp index fa41f4420..d832af804 100644 --- a/common/3d/setup.cpp +++ b/common/3d/setup.cpp @@ -26,6 +26,8 @@ #endif #include "gr.h" +inline namespace dcx { + //start the frame void g3_start_frame(void) { @@ -60,3 +62,5 @@ void g3_start_frame(void) init_interface_vars_to_assembler(); //for the texture-mapper #endif } + +} diff --git a/common/include/3d.h b/common/include/3d.h index 1f1a4b0ea..a33ea10d9 100644 --- a/common/include/3d.h +++ b/common/include/3d.h @@ -105,6 +105,8 @@ struct g3s_object { //Frame setup functions: +inline namespace dcx { + #ifdef OGL typedef const g3s_point cg3s_point; #else @@ -124,9 +126,6 @@ void g3_set_view_matrix(const vms_vector &view_pos,const vms_matrix &view_matrix #define g3_end_frame() #endif -//draw a horizon -void g3_draw_horizon(int sky_color,int ground_color); - //Instancing //instance at specified point with specified orientation @@ -140,14 +139,12 @@ void g3_done_instance(); //Misc utility functions: -//get zoom. For a given window size, return the zoom which will achieve -//the given FOV along the given axis. -fix g3_get_zoom(char axis,fixang fov,short window_width,short window_height); - //returns true if a plane is facing the viewer. takes the unrotated surface //normal of the plane, and a point on it. The normal need not be normalized bool g3_check_normal_facing(const vms_vector &v,const vms_vector &norm); +} + //Point definition and rotation functions: //specify the arrays refered to by the 'pointlist' parms in the following @@ -158,6 +155,8 @@ bool g3_check_normal_facing(const vms_vector &v,const vms_vector &norm); //returns codes_and & codes_or of a list of points numbers g3s_codes g3_check_codes(int nv,g3s_point **pointlist); +inline namespace dcx { + //rotates a point. returns codes. does not check if already rotated ubyte g3_rotate_point(g3s_point &dest,const vms_vector &src); static inline g3s_point g3_rotate_point(const vms_vector &src) __attribute_warn_unused_result; @@ -181,6 +180,7 @@ ubyte g3_code_point(g3s_point &point); //delta rotation functions void g3_rotate_delta_vec(vms_vector &dest,const vms_vector &src); + ubyte g3_add_delta_vec(g3s_point &dest,const g3s_point &src,const vms_vector &deltav); //Drawing functions: @@ -230,7 +230,6 @@ void g3_draw_sphere(g3s_point &pnt,fix rad); //@@//return ligting value for a point //@@fix g3_compute_lighting_value(g3s_point *rotated_point,fix normval); - //like g3_draw_poly(), but checks to see if facing. If surface normal is //NULL, this routine must compute it, which will be slow. It is better to //pre-compute the normal, and pass it to this function. When the normal @@ -316,8 +315,11 @@ typedef void (*line_drawer_type)(fix x0,fix y0,fix x1,fix y1); // (ie, avoids cracking) edge/delta computation. void gr_upoly_tmap(uint_fast32_t nverts, const array &vert); #endif + void g3_set_special_render(tmap_drawer_type tmap_drawer); extern tmap_drawer_type tmap_drawer_ptr; +} + #endif diff --git a/common/include/maths.h b/common/include/maths.h index 84ec52837..93706698f 100644 --- a/common/include/maths.h +++ b/common/include/maths.h @@ -182,9 +182,13 @@ fixang fix_acos (fix v); __attribute_warn_unused_result fixang fix_atan2 (fix cos, fix sin); +inline namespace dcx { + __attribute_warn_unused_result int checkmuldiv(fix *r,fix a,fix b,fix c); +} + extern const array guess_table; extern const array sincos_table; extern const array asin_table; diff --git a/common/texmap/tmapflat.cpp b/common/texmap/tmapflat.cpp index 4a4018c4a..011489171 100644 --- a/common/texmap/tmapflat.cpp +++ b/common/texmap/tmapflat.cpp @@ -37,6 +37,8 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. //#include "tmapext.h" #ifndef OGL +#include "3d.h" +#include "dxxerror.h" static void gr_upoly_tmap_ylr(uint_fast32_t nverts, const int *vert); @@ -169,6 +171,7 @@ static void texture_map_flat(const g3ds_tmap &t, int color, void (*scanline_func (*scanline_func)(boty, xleft, xright); } +inline namespace dcx { // ----------------------------------------------------------------------------------------- // This is the gr_upoly-like interface to the texture mapper which uses texture-mapper compatible @@ -178,8 +181,7 @@ void gr_upoly_tmap(uint_fast32_t nverts, const array gr_upoly_tmap_ylr(nverts, vert.data()); } -#include "3d.h" -#include "dxxerror.h" +} struct pnt2d { fix x,y; diff --git a/similar/arch/ogl/ogl.cpp b/similar/arch/ogl/ogl.cpp index b8c76c986..5bcae9e85 100644 --- a/similar/arch/ogl/ogl.cpp +++ b/similar/arch/ogl/ogl.cpp @@ -539,6 +539,8 @@ void ogl_cache_level_textures(void) r_cachedtexcount = r_texcount; } +inline namespace dcx { + void g3_draw_line(const g3s_point &p0,const g3s_point &p1) { int c; @@ -567,6 +569,8 @@ void g3_draw_line(const g3s_point &p0,const g3s_point &p1) glDisableClientState(GL_COLOR_ARRAY); } +} + static void ogl_drawcircle(int nsides, int type, GLfloat *vertex_array) { glEnableClientState(GL_VERTEX_ARRAY); @@ -773,6 +777,8 @@ void ogl_draw_vertex_reticle(int cross,int primary,int secondary,int color,int a glLineWidth(linedotscale); } +inline namespace dcx { + /* * Stars on heaven in exit sequence, automap objects */ @@ -812,8 +818,6 @@ void g3_draw_sphere(g3s_point &pnt,fix rad) glPopMatrix(); } -inline namespace dcx { - int gr_ucircle(fix xc1, fix yc1, fix r1) { int c, nsides; @@ -852,8 +856,6 @@ int gr_disk(fix x,fix y,fix r) return 0; } -} - /* * Draw flat-shaded Polygon (Lasers, Drone-arms, Driller-ears) */ @@ -968,6 +970,8 @@ void _g3_draw_tmap(unsigned nv, const g3s_point *const *const pointlist, const g glDisableClientState(GL_TEXTURE_COORD_ARRAY); } +} + /* * Everything texturemapped with secondary texture (walls with secondary texture) */ @@ -1034,6 +1038,8 @@ void _g3_draw_tmap_2(unsigned nv, const g3s_point *const *const pointlist, const glDisableClientState(GL_TEXTURE_COORD_ARRAY); } +inline namespace dcx { + /* * 2d Sprites (Fireaballs, powerups, explosions). NOT hostages */ @@ -1121,6 +1127,8 @@ void g3_draw_bitmap(const vms_vector &pos, const fix iwidth, const fix iheight, glDisableClientState(GL_TEXTURE_COORD_ARRAY); } +} + /* * Movies * Since this function will create a new texture each call, mipmapping can be very GPU intensive - so it has an optional setting for texture filtering.