Use inline namespace dcx for common/3d

This commit is contained in:
Kp 2015-12-05 22:57:24 +00:00
parent 69c5a79058
commit 43dd620557
14 changed files with 62 additions and 14 deletions

View file

@ -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
}
}

View file

@ -23,6 +23,8 @@ struct g3s_point;
#include "globvars.h"
#include "compiler-array.h"
inline namespace dcx {
struct polygon_clip_points : array<g3s_point *, MAX_POINTS_IN_POLY> {};
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

View file

@ -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
}

View file

@ -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;
}

View file

@ -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

View file

@ -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()
}
}

View file

@ -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)
}
}

View file

@ -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);
}
}

View file

@ -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)
}

View file

@ -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
}
}

View file

@ -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<fix, MAX_POINTS_IN_POLY*2> &vert);
#endif
void g3_set_special_render(tmap_drawer_type tmap_drawer);
extern tmap_drawer_type tmap_drawer_ptr;
}
#endif

View file

@ -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<ubyte, 256> guess_table;
extern const array<short, 321> sincos_table;
extern const array<ushort, 258> asin_table;

View file

@ -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<fix, MAX_POINTS_IN_POLY*2>
gr_upoly_tmap_ylr(nverts, vert.data());
}
#include "3d.h"
#include "dxxerror.h"
}
struct pnt2d {
fix x,y;

View file

@ -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.