2006-03-20 16:43:15 +00:00
|
|
|
/*
|
2014-06-01 17:55:23 +00:00
|
|
|
* Portions of this file are copyright Rebirth contributors and licensed as
|
|
|
|
* described in COPYING.txt.
|
|
|
|
* Portions of this file are copyright Parallax Software and licensed
|
|
|
|
* according to the Parallax license below.
|
|
|
|
* See COPYING.txt for license details.
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
|
|
|
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
|
|
|
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
|
|
|
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
|
|
|
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
|
|
|
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
|
|
|
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
|
|
|
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
2013-02-24 02:39:48 +00:00
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
2006-03-20 16:43:15 +00:00
|
|
|
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
2013-03-03 01:03:33 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Header file for 3d library
|
2013-03-03 01:03:33 +00:00
|
|
|
* except for functions implemented in interp.c
|
2006-03-20 16:43:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-01-29 04:27:36 +00:00
|
|
|
#pragma once
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2015-01-29 04:27:36 +00:00
|
|
|
#include <cstdint>
|
2014-08-16 18:14:11 +00:00
|
|
|
#include "dxxsconf.h"
|
2016-03-19 19:08:10 +00:00
|
|
|
#include "dsx-ns.h"
|
2012-07-01 02:54:33 +00:00
|
|
|
#include "maths.h"
|
2013-02-21 00:20:26 +00:00
|
|
|
#include "vecmat.h" //the vector/matrix library
|
2017-02-11 21:42:33 +00:00
|
|
|
#include "fwd-gr.h"
|
2020-05-02 21:18:42 +00:00
|
|
|
#include <array>
|
2022-09-24 17:47:52 +00:00
|
|
|
#include <span>
|
2015-01-29 04:27:36 +00:00
|
|
|
|
2022-06-05 17:44:52 +00:00
|
|
|
#if DXX_USE_OGL
|
2022-06-25 06:06:27 +00:00
|
|
|
#if defined(__APPLE__) && defined(__MACH__)
|
|
|
|
#include <OpenGL/gl.h>
|
|
|
|
#else
|
2022-06-05 17:44:52 +00:00
|
|
|
#include <GL/gl.h>
|
|
|
|
#endif
|
2022-06-25 06:06:27 +00:00
|
|
|
#endif
|
2022-06-05 17:44:52 +00:00
|
|
|
|
2016-09-11 18:49:16 +00:00
|
|
|
#if DXX_USE_EDITOR
|
2015-12-13 18:00:49 +00:00
|
|
|
namespace dcx {
|
2013-02-21 00:20:26 +00:00
|
|
|
extern int g3d_interp_outline; //if on, polygon models outlined in white
|
2015-12-13 18:00:48 +00:00
|
|
|
}
|
2015-02-28 22:34:07 +00:00
|
|
|
#endif
|
2013-03-03 01:03:33 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
//Structure for storing u,v,light values. This structure doesn't have a
|
|
|
|
//prefix because it was defined somewhere else before it was moved here
|
2013-12-22 22:03:07 +00:00
|
|
|
struct g3s_uvl {
|
2006-03-20 16:43:15 +00:00
|
|
|
fix u,v,l;
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2011-04-07 20:32:47 +00:00
|
|
|
//Structure for storing light color. Also uses l of g3s-uvl to add/compute mono (white) light
|
2013-12-22 22:03:07 +00:00
|
|
|
struct g3s_lrgb {
|
2011-04-07 20:32:47 +00:00
|
|
|
fix r,g,b;
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2011-04-07 20:32:47 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
//Stucture to store clipping codes in a word
|
2013-12-22 22:03:07 +00:00
|
|
|
struct g3s_codes {
|
2018-12-30 00:43:58 +00:00
|
|
|
//or is low byte, and is high byte
|
|
|
|
uint8_t uor = 0, uand = 0xff;
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//flags for point structure
|
2017-10-14 17:10:30 +00:00
|
|
|
constexpr std::integral_constant<uint8_t, 1> PF_PROJECTED{}; //has been projected, so sx,sy valid
|
|
|
|
constexpr std::integral_constant<uint8_t, 2> PF_OVERFLOW{}; //can't project
|
|
|
|
#if !DXX_USE_OGL
|
|
|
|
constexpr std::integral_constant<uint8_t, 4> PF_TEMP_POINT{}; //created during clip
|
|
|
|
constexpr std::integral_constant<uint8_t, 8> PF_UVS{}; //has uv values set
|
|
|
|
constexpr std::integral_constant<uint8_t, 16> PF_LS{}; //has lighting values set
|
2017-11-05 20:49:08 +00:00
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//clipping codes flags
|
|
|
|
|
2017-10-14 17:10:30 +00:00
|
|
|
constexpr std::integral_constant<uint8_t, 1> CC_OFF_LEFT{};
|
|
|
|
constexpr std::integral_constant<uint8_t, 2> CC_OFF_RIGHT{};
|
|
|
|
constexpr std::integral_constant<uint8_t, 4> CC_OFF_BOT{};
|
|
|
|
constexpr std::integral_constant<uint8_t, 8> CC_OFF_TOP{};
|
|
|
|
constexpr std::integral_constant<uint8_t, 0x80> CC_BEHIND{};
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//Used to store rotated points for mines. Has frame count to indictate
|
|
|
|
//if rotated, and flag to indicate if projected.
|
2013-12-22 22:03:07 +00:00
|
|
|
struct g3s_point {
|
2013-03-03 01:03:33 +00:00
|
|
|
vms_vector p3_vec; //x,y,z of rotated point
|
2019-01-01 04:54:35 +00:00
|
|
|
#if !DXX_USE_OGL
|
2013-03-03 01:03:33 +00:00
|
|
|
fix p3_u,p3_v,p3_l; //u,v,l coords
|
2019-01-01 04:54:35 +00:00
|
|
|
#endif
|
2013-02-21 00:20:26 +00:00
|
|
|
fix p3_sx,p3_sy; //screen x&y
|
|
|
|
ubyte p3_codes; //clipping codes
|
|
|
|
ubyte p3_flags; //projected?
|
2014-08-20 01:28:22 +00:00
|
|
|
uint16_t p3_last_generation;
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//macros to reference x,y,z elements of a 3d point
|
|
|
|
#define p3_x p3_vec.x
|
|
|
|
#define p3_y p3_vec.y
|
|
|
|
#define p3_z p3_vec.z
|
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#ifdef __cplusplus
|
2006-03-20 16:43:15 +00:00
|
|
|
//Functions in library
|
|
|
|
|
|
|
|
//Frame setup functions:
|
|
|
|
|
2015-12-13 18:00:49 +00:00
|
|
|
namespace dcx {
|
2015-12-05 22:57:24 +00:00
|
|
|
|
2021-09-04 12:17:14 +00:00
|
|
|
struct g3_instance_context
|
|
|
|
{
|
|
|
|
const vms_matrix matrix;
|
|
|
|
const vms_vector position;
|
|
|
|
};
|
|
|
|
|
2016-09-24 18:06:11 +00:00
|
|
|
#if DXX_USE_OGL
|
2014-11-16 19:14:51 +00:00
|
|
|
typedef const g3s_point cg3s_point;
|
|
|
|
#else
|
|
|
|
typedef g3s_point cg3s_point;
|
|
|
|
#endif
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
//start the frame
|
2017-02-11 21:42:34 +00:00
|
|
|
void g3_start_frame(grs_canvas &);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//set view from x,y,z, viewer matrix, and zoom. Must call one of g3_set_view_*()
|
2014-10-26 22:01:00 +00:00
|
|
|
void g3_set_view_matrix(const vms_vector &view_pos,const vms_matrix &view_matrix,fix zoom);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//end the frame
|
2016-09-24 18:06:11 +00:00
|
|
|
#if DXX_USE_OGL
|
2014-11-16 19:14:51 +00:00
|
|
|
#define g3_end_frame() ogl_end_frame()
|
|
|
|
#else
|
|
|
|
#define g3_end_frame()
|
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//Instancing
|
|
|
|
|
|
|
|
//instance at specified point with specified orientation
|
2021-09-04 12:17:14 +00:00
|
|
|
[[nodiscard]]
|
|
|
|
g3_instance_context g3_start_instance_matrix();
|
|
|
|
[[nodiscard]]
|
|
|
|
g3_instance_context g3_start_instance_matrix(const vms_vector &pos, const vms_matrix &orient);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//instance at specified point with specified orientation
|
2021-09-04 12:17:14 +00:00
|
|
|
[[nodiscard]]
|
|
|
|
g3_instance_context g3_start_instance_angles(const vms_vector &pos, const vms_angvec &angles);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//pops the old context
|
2021-09-04 12:17:14 +00:00
|
|
|
void g3_done_instance(const g3_instance_context &);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//Misc utility functions:
|
|
|
|
|
|
|
|
//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
|
2014-10-02 03:02:35 +00:00
|
|
|
bool g3_check_normal_facing(const vms_vector &v,const vms_vector &norm);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2015-12-05 22:57:24 +00:00
|
|
|
}
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
//Point definition and rotation functions:
|
|
|
|
|
2015-12-13 18:00:49 +00:00
|
|
|
namespace dcx {
|
2015-12-05 22:57:24 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
//rotates a point. returns codes. does not check if already rotated
|
2014-10-02 03:02:35 +00:00
|
|
|
ubyte g3_rotate_point(g3s_point &dest,const vms_vector &src);
|
2021-06-28 03:37:51 +00:00
|
|
|
|
|
|
|
[[nodiscard]]
|
2014-11-13 03:41:29 +00:00
|
|
|
static inline g3s_point g3_rotate_point(const vms_vector &src)
|
|
|
|
{
|
|
|
|
g3s_point dest;
|
|
|
|
return g3_rotate_point(dest, src), dest;
|
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//projects a point
|
2014-11-13 03:21:33 +00:00
|
|
|
void g3_project_point(g3s_point &point);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//calculate the depth of a point - returns the z coord of the rotated point
|
2014-10-26 22:01:04 +00:00
|
|
|
fix g3_calc_point_depth(const vms_vector &pnt);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//from a 2d point, compute the vector through that point
|
2014-10-02 03:02:36 +00:00
|
|
|
void g3_point_2_vec(vms_vector &v,short sx,short sy);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//code a point. fills in the p3_codes field of the point, and returns the codes
|
2014-11-13 03:16:17 +00:00
|
|
|
ubyte g3_code_point(g3s_point &point);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//delta rotation functions
|
2015-02-03 00:37:08 +00:00
|
|
|
void g3_rotate_delta_vec(vms_vector &dest,const vms_vector &src);
|
2015-12-05 22:57:24 +00:00
|
|
|
|
2014-10-02 03:02:36 +00:00
|
|
|
ubyte g3_add_delta_vec(g3s_point &dest,const g3s_point &src,const vms_vector &deltav);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//Drawing functions:
|
|
|
|
|
|
|
|
//draw a flat-shaded face.
|
|
|
|
//returns 1 if off screen, 0 if drew
|
2022-09-24 17:47:52 +00:00
|
|
|
void _g3_draw_poly(grs_canvas &, std::span<cg3s_point *const> pointlist, uint8_t color);
|
2014-11-15 03:10:06 +00:00
|
|
|
template <std::size_t N>
|
2020-05-02 21:18:42 +00:00
|
|
|
static inline void g3_draw_poly(grs_canvas &canvas, const uint_fast32_t nv, const std::array<cg3s_point *, N> &pointlist, const uint8_t color)
|
2014-11-15 03:10:06 +00:00
|
|
|
{
|
2022-09-24 17:47:52 +00:00
|
|
|
_g3_draw_poly(canvas, std::span(pointlist).first(nv), color);
|
2014-11-15 03:10:06 +00:00
|
|
|
}
|
|
|
|
|
2017-10-14 17:10:30 +00:00
|
|
|
constexpr std::integral_constant<std::size_t, 64> MAX_POINTS_PER_POLY{};
|
2014-09-04 03:02:21 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
//draw a texture-mapped face.
|
|
|
|
//returns 1 if off screen, 0 if drew
|
2022-09-24 17:47:52 +00:00
|
|
|
void _g3_draw_tmap(grs_canvas &canvas, std::span<cg3s_point *const> pointlist, const g3s_uvl *uvl_list, const g3s_lrgb *light_rgb, grs_bitmap &bm);
|
2014-09-04 03:02:21 +00:00
|
|
|
|
|
|
|
template <std::size_t N>
|
2020-05-02 21:18:42 +00:00
|
|
|
static inline void g3_draw_tmap(grs_canvas &canvas, unsigned nv, const std::array<cg3s_point *, N> &pointlist, const std::array<g3s_uvl, N> &uvl_list, const std::array<g3s_lrgb, N> &light_rgb, grs_bitmap &bm)
|
2014-09-04 03:02:21 +00:00
|
|
|
{
|
|
|
|
static_assert(N <= MAX_POINTS_PER_POLY, "too many points in tmap");
|
2015-07-29 03:05:28 +00:00
|
|
|
#ifdef DXX_CONSTANT_TRUE
|
|
|
|
if (DXX_CONSTANT_TRUE(nv > N))
|
2014-09-04 03:02:21 +00:00
|
|
|
DXX_ALWAYS_ERROR_FUNCTION(dxx_trap_tmap_overread, "reading beyond array");
|
|
|
|
#endif
|
2017-06-07 02:44:55 +00:00
|
|
|
if (nv > N)
|
|
|
|
return;
|
2022-09-24 17:47:52 +00:00
|
|
|
_g3_draw_tmap(canvas, std::span(pointlist).first(nv), &uvl_list[0], &light_rgb[0], bm);
|
2014-09-04 03:02:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <std::size_t N>
|
2022-09-24 17:47:52 +00:00
|
|
|
requires(N <= MAX_POINTS_PER_POLY)
|
2020-05-02 21:18:42 +00:00
|
|
|
static inline void g3_draw_tmap(grs_canvas &canvas, const std::array<cg3s_point *, N> &pointlist, const std::array<g3s_uvl, N> &uvl_list, const std::array<g3s_lrgb, N> &light_rgb, grs_bitmap &bm)
|
2014-09-04 03:02:21 +00:00
|
|
|
{
|
2022-09-24 17:47:52 +00:00
|
|
|
_g3_draw_tmap(canvas, pointlist, uvl_list.data(), light_rgb.data(), bm);
|
2014-09-04 03:02:21 +00:00
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//draw a sortof sphere - i.e., the 2d radius is proportional to the 3d
|
|
|
|
//radius, but not to the distance from the eye
|
2017-08-16 01:54:26 +00:00
|
|
|
void g3_draw_sphere(grs_canvas &, cg3s_point &pnt, fix rad, uint8_t color);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//@@//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
|
|
|
|
//is passed, this function works like g3_check_normal_facing() plus
|
|
|
|
//g3_draw_poly().
|
|
|
|
//returns -1 if not facing, 1 if off screen, 0 if drew
|
2020-05-02 21:18:42 +00:00
|
|
|
bool do_facing_check(const std::array<cg3s_point *, 3> &vertlist);
|
2014-08-27 03:16:51 +00:00
|
|
|
|
|
|
|
//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
|
|
|
|
//is passed, this function works like g3_check_normal_facing() plus
|
|
|
|
//g3_draw_poly().
|
|
|
|
//returns -1 if not facing, 1 if off screen, 0 if drew
|
2020-05-02 21:18:42 +00:00
|
|
|
static inline void g3_check_and_draw_poly(grs_canvas &canvas, const std::array<cg3s_point *, 3> &pointlist, const uint8_t color)
|
2014-08-27 03:16:51 +00:00
|
|
|
{
|
|
|
|
if (do_facing_check(pointlist))
|
2017-02-11 21:42:42 +00:00
|
|
|
g3_draw_poly(canvas, pointlist.size(), pointlist, color);
|
2014-08-27 03:16:51 +00:00
|
|
|
}
|
|
|
|
|
2014-09-04 03:02:21 +00:00
|
|
|
template <std::size_t N>
|
2020-05-02 21:18:42 +00:00
|
|
|
static inline void g3_check_and_draw_tmap(grs_canvas &canvas, unsigned nv, const std::array<cg3s_point *, N> &pointlist, const std::array<g3s_uvl, N> &uvl_list, const std::array<g3s_lrgb, N> &light_rgb, grs_bitmap &bm)
|
2014-08-27 03:16:51 +00:00
|
|
|
{
|
|
|
|
if (do_facing_check(pointlist))
|
2017-02-11 21:42:40 +00:00
|
|
|
g3_draw_tmap(canvas, nv, pointlist, uvl_list, light_rgb, bm);
|
2014-08-27 03:16:51 +00:00
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2014-09-04 03:02:21 +00:00
|
|
|
template <std::size_t N>
|
2020-05-02 21:18:42 +00:00
|
|
|
static inline void g3_check_and_draw_tmap(grs_canvas &canvas, const std::array<cg3s_point *, N> &pointlist, const std::array<g3s_uvl, N> &uvl_list, const std::array<g3s_lrgb, N> &light_rgb, grs_bitmap &bm)
|
2014-09-04 03:02:21 +00:00
|
|
|
{
|
2017-02-11 21:42:40 +00:00
|
|
|
g3_check_and_draw_tmap(canvas, N, pointlist, uvl_list, light_rgb, bm);
|
2014-09-04 03:02:21 +00:00
|
|
|
}
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
//draws a line. takes two points.
|
2019-08-06 02:59:41 +00:00
|
|
|
#if !DXX_USE_OGL
|
2014-11-16 19:14:51 +00:00
|
|
|
struct temporary_points_t;
|
2019-08-06 02:59:41 +00:00
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//draw a bitmap object that is always facing you
|
|
|
|
//returns 1 if off screen, 0 if drew
|
2017-02-11 21:42:40 +00:00
|
|
|
void g3_draw_rod_tmap(grs_canvas &, grs_bitmap &bitmap, const g3s_point &bot_point, fix bot_width, const g3s_point &top_point, fix top_width, g3s_lrgb light);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2013-02-21 00:20:26 +00:00
|
|
|
//draws a bitmap with the specified 3d width & height
|
2006-03-20 16:43:15 +00:00
|
|
|
//returns 1 if off screen, 0 if drew
|
2017-02-11 21:42:42 +00:00
|
|
|
void g3_draw_bitmap(grs_canvas &, const vms_vector &pos, fix width, fix height, grs_bitmap &bm);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2022-06-05 17:44:52 +00:00
|
|
|
#if DXX_USE_OGL
|
|
|
|
struct g3_draw_line_colors
|
|
|
|
{
|
|
|
|
const std::array<GLfloat, 8> color_array;
|
|
|
|
g3_draw_line_colors(color_palette_index color);
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2022-06-05 17:44:52 +00:00
|
|
|
class g3_draw_line_context
|
2022-06-05 17:44:52 +00:00
|
|
|
#if DXX_USE_OGL
|
|
|
|
: public g3_draw_line_colors
|
|
|
|
#endif
|
2022-06-05 17:44:52 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
grs_canvas &canvas;
|
|
|
|
const color_palette_index color;
|
|
|
|
g3_draw_line_context(grs_canvas &canvas, color_palette_index color) :
|
2022-06-05 17:44:52 +00:00
|
|
|
#if DXX_USE_OGL
|
|
|
|
g3_draw_line_colors(color),
|
|
|
|
#endif
|
2022-06-05 17:44:52 +00:00
|
|
|
canvas(canvas), color(color)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
g3_draw_line_context(const g3_draw_line_context &) = delete;
|
|
|
|
g3_draw_line_context &operator=(const g3_draw_line_context &) = delete;
|
|
|
|
};
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
//specifies 2d drawing routines to use instead of defaults. Passing
|
|
|
|
//NULL for either or both restores defaults
|
2016-09-24 18:06:11 +00:00
|
|
|
#if DXX_USE_OGL
|
2015-11-14 18:17:20 +00:00
|
|
|
enum class tmap_drawer_constant : uint_fast8_t
|
2015-01-22 03:34:20 +00:00
|
|
|
{
|
2015-11-14 18:17:20 +00:00
|
|
|
polygon,
|
|
|
|
flat,
|
2015-01-22 03:34:20 +00:00
|
|
|
};
|
|
|
|
|
2015-11-14 18:17:20 +00:00
|
|
|
#define draw_tmap tmap_drawer_constant::polygon
|
|
|
|
#define draw_tmap_flat tmap_drawer_constant::flat
|
2015-01-22 03:34:20 +00:00
|
|
|
|
|
|
|
class tmap_drawer_type
|
|
|
|
{
|
2015-11-14 18:17:20 +00:00
|
|
|
tmap_drawer_constant type;
|
2015-01-22 03:34:20 +00:00
|
|
|
public:
|
2015-11-14 18:17:20 +00:00
|
|
|
constexpr tmap_drawer_type(tmap_drawer_constant t) : type(t)
|
2015-01-22 03:34:20 +00:00
|
|
|
{
|
|
|
|
}
|
2015-11-14 18:17:20 +00:00
|
|
|
bool operator==(tmap_drawer_constant t) const
|
2015-01-22 03:34:20 +00:00
|
|
|
{
|
|
|
|
return type == t;
|
|
|
|
}
|
2015-11-14 18:17:20 +00:00
|
|
|
bool operator!=(tmap_drawer_constant t) const
|
2015-01-22 03:34:20 +00:00
|
|
|
{
|
|
|
|
return type != t;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#else
|
2022-06-05 17:44:52 +00:00
|
|
|
void g3_draw_line(const g3_draw_line_context &, cg3s_point &p0, cg3s_point &p1, temporary_points_t &);
|
2017-10-14 17:10:30 +00:00
|
|
|
constexpr std::integral_constant<std::size_t, 100> MAX_POINTS_IN_POLY{};
|
2015-03-11 02:19:15 +00:00
|
|
|
|
2022-09-24 17:47:52 +00:00
|
|
|
using tmap_drawer_type = void (*)(grs_canvas &, const grs_bitmap &bm, std::span<const g3s_point *const> vertlist);
|
2015-03-11 02:19:15 +00:00
|
|
|
|
|
|
|
// This is the gr_upoly-like interface to the texture mapper which uses texture-mapper compatible
|
|
|
|
// (ie, avoids cracking) edge/delta computation.
|
2020-05-02 21:18:42 +00:00
|
|
|
void gr_upoly_tmap(grs_canvas &, uint_fast32_t nverts, const std::array<fix, MAX_POINTS_IN_POLY * 2> &vert, uint8_t color);
|
2015-01-22 03:34:20 +00:00
|
|
|
#endif
|
2022-06-05 17:44:52 +00:00
|
|
|
void g3_draw_line(const g3_draw_line_context &context, cg3s_point &p0, cg3s_point &p1);
|
2015-12-05 22:57:24 +00:00
|
|
|
|
2014-08-08 02:52:35 +00:00
|
|
|
void g3_set_special_render(tmap_drawer_type tmap_drawer);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2012-11-11 00:14:30 +00:00
|
|
|
extern tmap_drawer_type tmap_drawer_ptr;
|
|
|
|
|
2015-12-05 22:57:24 +00:00
|
|
|
}
|
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#endif
|