📄 t3dlib10.h
字号:
// T3DLIB10.H - header file for T3DLIB10.H
// watch for multiple inclusions
#ifndef T3DLIB10
#define T3DLIB10
// DEFINES //////////////////////////////////////////////////////////////////
// alpha blending defines
#define NUM_ALPHA_LEVELS 8 // total number of alpha levels
// perspective correct/ 1/z buffer defines
#define FIXP28_SHIFT 28 // used for 1/z buffering
#define FIXP22_SHIFT 22 // used for u/z, v/z perspective texture mapping
// new attributes to support mip mapping
#define POLY4DV2_ATTR_MIPMAP 0x0400 // flags if polygon has a mipmap
#define OBJECT4DV2_ATTR_MIPMAP 0x0008 // flags if object has a mipmap
///////////////////////////////////////////////////////////////////////////////
// defines that control the rendering function state attributes
// note each class of control flags is contained within
// a 4-bit nibble where possible, this helps with future expansion
// no z buffering, polygons will be rendered as are in list
#define RENDER_ATTR_NOBUFFER 0x00000001
// use z buffering rasterization
#define RENDER_ATTR_ZBUFFER 0x00000002
// use 1/z buffering rasterization
#define RENDER_ATTR_INVZBUFFER 0x00000004
// use mipmapping
#define RENDER_ATTR_MIPMAP 0x00000010
// enable alpha blending and override
#define RENDER_ATTR_ALPHA 0x00000020
// enable bilinear filtering, but only supported for
// constant shaded/affine textures
#define RENDER_ATTR_BILERP 0x00000040
// use affine texturing for all polys
#define RENDER_ATTR_TEXTURE_PERSPECTIVE_AFFINE 0x00000100
// use perfect perspective texturing
#define RENDER_ATTR_TEXTURE_PERSPECTIVE_CORRECT 0x00000200
// use linear piecewise perspective texturing
#define RENDER_ATTR_TEXTURE_PERSPECTIVE_LINEAR 0x00000400
// use a hybrid of affine and linear piecewise based on distance
#define RENDER_ATTR_TEXTURE_PERSPECTIVE_HYBRID1 0x00000800
// not implemented yet
#define RENDER_ATTR_TEXTURE_PERSPECTIVE_HYBRID2 0x00001000
// TYPES ///////////////////////////////////////////////////////////////////
// this is a new type to contain the "rendering context" RC, so
// we don't have to keep passing more and more variables to the
// rendering functions, we can fill this structure in with what we
// need and then pass it as a whole
typedef struct RENDERCONTEXTV1_TYP
{
int attr; // all the rendering attributes
RENDERLIST4DV2_PTR rend_list; // ptr to rendering list to render
UCHAR *video_buffer; // ptr to video buffer to render to
int lpitch; // memory pitch in bytes of video buffer
UCHAR *zbuffer; // ptr to z buffer or 1/z buffer
int zpitch; // memory pitch in bytes of z or 1/z buffer
int alpha_override; // alpha value to override ALL polys with
int mip_dist; // maximum distance to divide up into
// mip levels
// 0 - (NUM_ALPHA_LEVELS - 1)
int texture_dist, // the distance to enable affine texturing
texture_dist2; // when using hybrid perspective/affine mode
// future expansion
int ival1, ivalu2; // extra integers
float fval1, fval2; // extra floats
void *vptr; // extra pointer
} RENDERCONTEXTV1, *RENDERCONTEXTV1_PTR;
// CLASSES /////////////////////////////////////////////////////////////////
// MACROS ///////////////////////////////////////////////////////////////////
// EXTERNALS ///////////////////////////////////////////////////////////////
// this table contains each possible RGB value multiplied by some scaler
extern USHORT rgb_alpha_table[NUM_ALPHA_LEVELS][65536];
extern HWND main_window_handle; // save the window handle
extern HINSTANCE main_instance; // save the instance
// PROTOTYPES //////////////////////////////////////////////////////////////
// z buffered versions
void Draw_Textured_TriangleZB2_16(POLYF4DV2_PTR face, // ptr to face
UCHAR *_dest_buffer, // pointer to video buffer
int mem_pitch, // bytes per line, 320, 640 etc.
UCHAR *zbuffer, // pointer to z-buffer
int zpitch); // bytes per line of zbuffer
void Draw_Textured_Bilerp_TriangleZB_16(POLYF4DV2_PTR face, // ptr to face
UCHAR *_dest_buffer, // pointer to video buffer
int mem_pitch, // bytes per line, 320, 640 etc.
UCHAR *zbuffer, // pointer to z-buffer
int zpitch); // bytes per line of zbuffer
void Draw_Textured_TriangleFSZB2_16(POLYF4DV2_PTR face, // ptr to face
UCHAR *_dest_buffer, // pointer to video buffer
int mem_pitch, // bytes per line, 320, 640 etc.
UCHAR *zbuffer, // pointer to z-buffer
int zpitch); // bytes per line of zbuffer
void Draw_Textured_TriangleGSZB_16(POLYF4DV2_PTR face, // ptr to face
UCHAR *_dest_buffer, // pointer to video buffer
int mem_pitch, // bytes per line, 320, 640 etc.
UCHAR *_zbuffer, // pointer to z-buffer
int zpitch); // bytes per line of zbuffer
void Draw_Triangle_2DZB2_16(POLYF4DV2_PTR face, // ptr to face
UCHAR *_dest_buffer, // pointer to video buffer
int mem_pitch, // bytes per line, 320, 640 etc.
UCHAR *zbuffer, // pointer to z-buffer
int zpitch); // bytes per line of zbuffer
void Draw_Gouraud_TriangleZB2_16(POLYF4DV2_PTR face, // ptr to face
UCHAR *_dest_buffer,// pointer to video buffer
int mem_pitch, // bytes per line, 320, 640 etc.
UCHAR *zbuffer, // pointer to z-buffer
int zpitch); // bytes per line of zbuffer
void Draw_RENDERLIST4DV2_SolidZB2_16(RENDERLIST4DV2_PTR rend_list,
UCHAR *video_buffer,
int lpitch,
UCHAR *zbuffer,
int zpitch);
// 1/z versions
void Draw_Textured_TriangleINVZB_16(POLYF4DV2_PTR face, // ptr to face
UCHAR *_dest_buffer, // pointer to video buffer
int mem_pitch, // bytes per line, 320, 640 etc.
UCHAR *zbuffer, // pointer to z-buffer
int zpitch); // bytes per line of zbuffer
void Draw_Textured_Bilerp_TriangleINVZB_16(POLYF4DV2_PTR face, // ptr to face
UCHAR *_dest_buffer, // pointer to video buffer
int mem_pitch, // bytes per line, 320, 640 etc.
UCHAR *zbuffer, // pointer to z-buffer
int zpitch); // bytes per line of zbuffer
void Draw_Textured_TriangleFSINVZB_16(POLYF4DV2_PTR face, // ptr to face
UCHAR *_dest_buffer, // pointer to video buffer
int mem_pitch, // bytes per line, 320, 640 etc.
UCHAR *zbuffer, // pointer to z-buffer
int zpitch); // bytes per line of zbuffer
void Draw_Textured_TriangleGSINVZB_16(POLYF4DV2_PTR face, // ptr to face
UCHAR *_dest_buffer, // pointer to video buffer
int mem_pitch, // bytes per line, 320, 640 etc.
UCHAR *_zbuffer, // pointer to z-buffer
int zpitch); // bytes per line of zbuffer
void Draw_Triangle_2DINVZB_16(POLYF4DV2_PTR face, // ptr to face
UCHAR *_dest_buffer, // pointer to video buffer
int mem_pitch, // bytes per line, 320, 640 etc.
UCHAR *zbuffer, // pointer to z-buffer
int zpitch); // bytes per line of zbuffer
void Draw_Gouraud_TriangleINVZB_16(POLYF4DV2_PTR face, // ptr to face
UCHAR *_dest_buffer, // pointer to video buffer
int mem_pitch, // bytes per line, 320, 640 etc.
UCHAR *zbuffer, // pointer to z-buffer
int zpitch); // bytes per line of zbuffer
void Draw_Textured_Perspective_Triangle_INVZB_16(POLYF4DV2_PTR face, // ptr to face
UCHAR *_dest_buffer, // pointer to video buffer
int mem_pitch, // bytes per line, 320, 640 etc.
UCHAR *_zbuffer, // pointer to z-buffer
int zpitch); // bytes per line of zbuffer
void Draw_Textured_Perspective_Triangle_FSINVZB_16(POLYF4DV2_PTR face,// ptr to face
UCHAR *_dest_buffer,// pointer to video buffer
int mem_pitch, // bytes per line, 320, 640 etc.
UCHAR *_zbuffer, // pointer to z-buffer
int zpitch); // bytes per line of zbuffer
void Draw_Textured_PerspectiveLP_Triangle_FSINVZB_16(POLYF4DV2_PTR face,// ptr to face
UCHAR *_dest_buffer, // pointer to video buffer
int mem_pitch, // bytes per line, 320, 640 etc.
UCHAR *_zbuffer, // pointer to z-buffer
int zpitch); // bytes per line of zbuffer
void Draw_Textured_PerspectiveLP_Triangle_INVZB_16(POLYF4DV2_PTR face, // ptr to face
UCHAR *_dest_buffer, // pointer to video buffer
int mem_pitch, // bytes per line, 320, 640 etc.
UCHAR *_zbuffer, // pointer to z-buffer
int zpitch); // bytes per line of zbuffer
void Draw_RENDERLIST4DV2_SolidINVZB_16(RENDERLIST4DV2_PTR rend_list,
UCHAR *video_buffer,
int lpitch,
UCHAR *zbuffer,
int zpitch);
// testing function
void Draw_RENDERLIST4DV2_Hybrid_Textured_SolidINVZB_16(RENDERLIST4DV2_PTR rend_list,
UCHAR *video_buffer,
int lpitch,
UCHAR *zbuffer,
int zpitch,
float dist1, float dist2);
// z buffered and alpha
void Draw_Textured_TriangleZB_Alpha16(POLYF4DV2_PTR face, // ptr to face
UCHAR *_dest_buffer, // pointer to video buffer
int mem_pitch, // bytes per line, 320, 640 etc.
UCHAR *zbuffer, // pointer to z-buffer
int zpitch, // bytes per line of zbuffer
int alpha);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -