tdfx_tris.c
来自「mesa-6.5-minigui源码」· C语言 代码 · 共 1,294 行 · 第 1/3 页
C
1,294 行
#define TAG(x) x##_offset_unfilled_fallback#include "tnl_dd/t_dd_tritmp.h"#define IND (TDFX_TWOSIDE_BIT|TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT)#define TAG(x) x##_twoside_unfilled_fallback#include "tnl_dd/t_dd_tritmp.h"#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT| \ TDFX_FALLBACK_BIT)#define TAG(x) x##_twoside_offset_unfilled_fallback#include "tnl_dd/t_dd_tritmp.h"/* Tdfx doesn't support provoking-vertex flat-shading? */#define IND (TDFX_FLAT_BIT)#define TAG(x) x##_flat#include "tnl_dd/t_dd_tritmp.h"#define IND (TDFX_OFFSET_BIT|TDFX_FLAT_BIT)#define TAG(x) x##_offset_flat#include "tnl_dd/t_dd_tritmp.h"#define IND (TDFX_TWOSIDE_BIT|TDFX_FLAT_BIT)#define TAG(x) x##_twoside_flat#include "tnl_dd/t_dd_tritmp.h"#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_FLAT_BIT)#define TAG(x) x##_twoside_offset_flat#include "tnl_dd/t_dd_tritmp.h"#define IND (TDFX_UNFILLED_BIT|TDFX_FLAT_BIT)#define TAG(x) x##_unfilled_flat#include "tnl_dd/t_dd_tritmp.h"#define IND (TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT|TDFX_FLAT_BIT)#define TAG(x) x##_offset_unfilled_flat#include "tnl_dd/t_dd_tritmp.h"#define IND (TDFX_TWOSIDE_BIT|TDFX_UNFILLED_BIT|TDFX_FLAT_BIT)#define TAG(x) x##_twoside_unfilled_flat#include "tnl_dd/t_dd_tritmp.h"#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT|TDFX_FLAT_BIT)#define TAG(x) x##_twoside_offset_unfilled_flat#include "tnl_dd/t_dd_tritmp.h"#define IND (TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)#define TAG(x) x##_fallback_flat#include "tnl_dd/t_dd_tritmp.h"#define IND (TDFX_OFFSET_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)#define TAG(x) x##_offset_fallback_flat#include "tnl_dd/t_dd_tritmp.h"#define IND (TDFX_TWOSIDE_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)#define TAG(x) x##_twoside_fallback_flat#include "tnl_dd/t_dd_tritmp.h"#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)#define TAG(x) x##_twoside_offset_fallback_flat#include "tnl_dd/t_dd_tritmp.h"#define IND (TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)#define TAG(x) x##_unfilled_fallback_flat#include "tnl_dd/t_dd_tritmp.h"#define IND (TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)#define TAG(x) x##_offset_unfilled_fallback_flat#include "tnl_dd/t_dd_tritmp.h"#define IND (TDFX_TWOSIDE_BIT|TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)#define TAG(x) x##_twoside_unfilled_fallback_flat#include "tnl_dd/t_dd_tritmp.h"#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT| \ TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)#define TAG(x) x##_twoside_offset_unfilled_fallback_flat#include "tnl_dd/t_dd_tritmp.h"static void init_rast_tab( void ){ init(); init_offset(); init_twoside(); init_twoside_offset(); init_unfilled(); init_offset_unfilled(); init_twoside_unfilled(); init_twoside_offset_unfilled(); init_fallback(); init_offset_fallback(); init_twoside_fallback(); init_twoside_offset_fallback(); init_unfilled_fallback(); init_offset_unfilled_fallback(); init_twoside_unfilled_fallback(); init_twoside_offset_unfilled_fallback(); init_flat(); init_offset_flat(); init_twoside_flat(); init_twoside_offset_flat(); init_unfilled_flat(); init_offset_unfilled_flat(); init_twoside_unfilled_flat(); init_twoside_offset_unfilled_flat(); init_fallback_flat(); init_offset_fallback_flat(); init_twoside_fallback_flat(); init_twoside_offset_fallback_flat(); init_unfilled_fallback_flat(); init_offset_unfilled_fallback_flat(); init_twoside_unfilled_fallback_flat(); init_twoside_offset_unfilled_fallback_flat();}/**********************************************************************//* Render whole begin/end objects *//**********************************************************************//* Accelerate vertex buffer rendering when renderindex == 0 and * there is no clipping. */#define INIT(x) tdfxRenderPrimitive( ctx, x )static void tdfx_render_vb_points( GLcontext *ctx, GLuint start, GLuint count, GLuint flags ){ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); tdfxVertex *fxVB = fxMesa->verts; GLint i; (void) flags; INIT(GL_POINTS); /* Adjust point coords */ for (i = start; i < count; i++) { fxVB[i].x += PNT_X_OFFSET - TRI_X_OFFSET; fxVB[i].y += PNT_Y_OFFSET - TRI_Y_OFFSET; } fxMesa->Glide.grDrawVertexArrayContiguous( GR_POINTS, count-start, fxVB + start, sizeof(tdfxVertex)); /* restore point coords */ for (i = start; i < count; i++) { fxVB[i].x -= PNT_X_OFFSET - TRI_X_OFFSET; fxVB[i].y -= PNT_Y_OFFSET - TRI_Y_OFFSET; }}static void tdfx_render_vb_line_strip( GLcontext *ctx, GLuint start, GLuint count, GLuint flags ){ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); tdfxVertex *fxVB = fxMesa->verts; GLint i; (void) flags; INIT(GL_LINE_STRIP); /* adjust line coords */ for (i = start; i < count; i++) { fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET; fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET; } fxMesa->Glide.grDrawVertexArrayContiguous( GR_LINE_STRIP, count-start, fxVB + start, sizeof(tdfxVertex) ); /* restore line coords */ for (i = start; i < count; i++) { fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET; fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET; }}static void tdfx_render_vb_line_loop( GLcontext *ctx, GLuint start, GLuint count, GLuint flags ){ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); tdfxVertex *fxVB = fxMesa->verts; GLint i; GLint j = start; (void) flags; INIT(GL_LINE_LOOP); if (!(flags & PRIM_BEGIN)) { j++; } /* adjust line coords */ for (i = start; i < count; i++) { fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET; fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET; } fxMesa->Glide.grDrawVertexArrayContiguous( GR_LINE_STRIP, count-j, fxVB + j, sizeof(tdfxVertex)); if (flags & PRIM_END) fxMesa->Glide.grDrawLine( fxVB + (count - 1), fxVB + start ); /* restore line coords */ for (i = start; i < count; i++) { fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET; fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET; }}static void tdfx_render_vb_lines( GLcontext *ctx, GLuint start, GLuint count, GLuint flags ){ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); tdfxVertex *fxVB = fxMesa->verts; GLint i; (void) flags; INIT(GL_LINES); /* adjust line coords */ for (i = start; i < count; i++) { fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET; fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET; } fxMesa->Glide.grDrawVertexArrayContiguous( GR_LINES, count-start, fxVB + start, sizeof(tdfxVertex)); /* restore line coords */ for (i = start; i < count; i++) { fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET; fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET; }}static void tdfx_render_vb_triangles( GLcontext *ctx, GLuint start, GLuint count, GLuint flags ){ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); tdfxVertex *fxVB = fxMesa->verts; (void) flags; INIT(GL_TRIANGLES);#if 0 /* [dBorca] * apparently, this causes troubles with some programs (GLExcess); * might be a bug in Glide... However, "grDrawVertexArrayContiguous" * eventually calls "grDrawTriangle" for GR_TRIANGLES, so we're better * off doing it by hand... */ fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLES, count-start, fxVB + start, sizeof(tdfxVertex));#else { GLuint j; for (j=start+2; j<count; j+=3) { fxMesa->Glide.grDrawTriangle(fxVB + (j-2), fxVB + (j-1), fxVB + j); } }#endif}static void tdfx_render_vb_tri_strip( GLcontext *ctx, GLuint start, GLuint count, GLuint flags ){ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); tdfxVertex *fxVB = fxMesa->verts; int mode; (void) flags; INIT(GL_TRIANGLE_STRIP);/* fprintf(stderr, "%s/%d\n", __FUNCTION__, 1<<shift); *//* if(!prevLockLine) abort(); */ mode = GR_TRIANGLE_STRIP; fxMesa->Glide.grDrawVertexArrayContiguous( mode, count-start, fxVB + start, sizeof(tdfxVertex));}static void tdfx_render_vb_tri_fan( GLcontext *ctx, GLuint start, GLuint count, GLuint flags ){ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); tdfxVertex *fxVB = fxMesa->verts; (void) flags; INIT(GL_TRIANGLE_FAN); fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLE_FAN, count-start, fxVB + start, sizeof(tdfxVertex) );}static void tdfx_render_vb_quads( GLcontext *ctx, GLuint start, GLuint count, GLuint flags ){ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); tdfxVertex *fxVB = fxMesa->verts; GLuint i; (void) flags; INIT(GL_QUADS); for (i = start + 3 ; i < count ; i += 4 ) {#define VERT(x) (fxVB + (x)) tdfxVertex *_v_[4]; _v_[0] = VERT(i); _v_[1] = VERT(i-3); _v_[2] = VERT(i-2); _v_[3] = VERT(i-1); fxMesa->Glide.grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_); /*fxMesa->Glide.grDrawTriangle( VERT(i-3), VERT(i-2), VERT(i) );*/ /*fxMesa->Glide.grDrawTriangle( VERT(i-2), VERT(i-1), VERT(i) );*/#undef VERT }}static void tdfx_render_vb_quad_strip( GLcontext *ctx, GLuint start, GLuint count, GLuint flags ){ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); tdfxVertex *fxVB = fxMesa->verts; (void) flags; INIT(GL_QUAD_STRIP); count -= (count-start)&1; fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLE_STRIP, count-start, fxVB + start, sizeof(tdfxVertex));}static void tdfx_render_vb_poly( GLcontext *ctx, GLuint start, GLuint count, GLuint flags ){ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); tdfxVertex *fxVB = fxMesa->verts; (void) flags; INIT(GL_POLYGON); fxMesa->Glide.grDrawVertexArrayContiguous( GR_POLYGON, count-start, fxVB + start, sizeof(tdfxVertex));}static void tdfx_render_vb_noop( GLcontext *ctx, GLuint start, GLuint count, GLuint flags ){ (void) (ctx && start && count && flags);}static void (*tdfx_render_tab_verts[GL_POLYGON+2])(GLcontext *, GLuint, GLuint, GLuint) = { tdfx_render_vb_points, tdfx_render_vb_lines, tdfx_render_vb_line_loop, tdfx_render_vb_line_strip, tdfx_render_vb_triangles, tdfx_render_vb_tri_strip, tdfx_render_vb_tri_fan, tdfx_render_vb_quads, tdfx_render_vb_quad_strip, tdfx_render_vb_poly, tdfx_render_vb_noop,};#undef INIT/**********************************************************************//* Render whole (indexed) begin/end objects *//**********************************************************************/#define VERT(x) (tdfxVertex *)(vertptr + (x))#define RENDER_POINTS( start, count ) \ for ( ; start < count ; start++) \ fxMesa->Glide.grDrawPoint( VERT(ELT(start)) );#define RENDER_LINE( v0, v1 ) \ fxMesa->Glide.grDrawLine( VERT(v0), VERT(v1) )#define RENDER_TRI( v0, v1, v2 ) \ fxMesa->Glide.grDrawTriangle( VERT(v0), VERT(v1), VERT(v2) )#define RENDER_QUAD( v0, v1, v2, v3 ) \ do { \ tdfxVertex *_v_[4]; \ _v_[0] = VERT(v3); \ _v_[1] = VERT(v0); \ _v_[2] = VERT(v1); \ _v_[3] = VERT(v2); \ fxMesa->Glide.grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_);\ /*fxMesa->Glide.grDrawTriangle( VERT(v0), VERT(v1), VERT(v3) );*/\ /*fxMesa->Glide.grDrawTriangle( VERT(v1), VERT(v2), VERT(v3) );*/\ } while (0)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?