⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hxfassemble.c

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* ************************************************************************* *\
**
**    INTEL Corporation Proprietary Information
**
**    This listing is supplied under the terms of a license
**    agreement with INTEL Corporation and may not be copied
**    nor disclosed except in accordance with the terms of
**    that agreement.
**
**    Copyright (c) 2003 Intel Corporation.
**    All Rights Reserved.
**
** ************************************************************************* **
**	FILE: HXFAssemble.c
**	DESCRIPTION: Reference implementaton of primitive assembly routines
**	AUTHOR: Cian Montgomery
**	CREATED: June 06, 2003
**
 *  $Date: 4/14/04 10:07a $ $Revision: 17 $
 *  $Log: /Intel_Development/Drivers/Marathon/WinCE42/opengles/HXFAssemble.c $
 * 
 * 17    4/14/04 10:07a Cmdoan
 * update bInPrimitive for clipped Line Loops.
 * 
 * 16    4/05/04 2:19p Clmontgo
 * Fixes for Light w/ w != 0 or 1 and Attenuation > 1.0
 * 
 * 15    3/19/04 2:09p Clmontgo
 * Broke out VP transform to after clip and W Divide
 *
 * 14    3/18/04 10:37p Clmontgo
 * Fixes for Clipping and SP clean up
 *
 * 13    2/04/04 5:42p Clmontgo
 * Rewrite of Slaveport code to do incremental writes, should eliminate
 * Slaveport write buffer stalls. Added some error handling to Draw*
 * functions.
 *
 * 12    1/21/04 2:09p Cmdoan
 * fixed hw level strip cull direction
 *
 * 11    12/21/03 12:50p Clmontgo
 *
 * 10    12/17/03 9:20a Clmontgo
 * Added Version ID and log to file headers
\* ************************************************************************* */
#include "HXFLocal.h"

/* ************************************************************************* *\
	FUNCTION: HXFAssembleIndexedLineList
	DESCRIPTION: Actually line segments..
	Draw a pair of connected vertices.  All individual.
	Basically, submit 2 vertices at a time.  No culling, but clipping.

\* ************************************************************************* */
void HXFAssembleIndexedLineList(HXFState* pState)
{
	HBOOL bInPrimitive = HFALSE;
	HBOOL bDraw = HTRUE;
	HUINT32 count;
	void* pVtx0, *pVtx1;
	HUINT32 a, b;
	HUINT16* pSegs = (HUINT16*) pState->pIndices;
	HUINT8* pFlags = pState->pOutClipFlags;
	HUINT8* pCF1 = NULL;
	HUINT8* pCF2 = NULL;
	HUINT32 BaseIdx = pState->BaseIndex;

	// Algorithm:  Take consecutive point pairs {(0,1), (2,3), ...} and submit
	// individual Line Strips.
	for (count = 0; count < ((HUINT32) (pState->NumPrimitives) ); count++)
	{
		a = pSegs[2*count] - BaseIdx;
		pVtx0 = pState->pOutVertices + (a * pState->OutVertexSize);

		b = pSegs[2*count +1] - BaseIdx;
		pVtx1 = pState->pOutVertices + (b * pState->OutVertexSize);

		{
			pCF1 = pFlags + (a);
			pCF2 = pFlags + (b);

			if (0 != ((*pCF1 & *pCF2)))
			{ // Test to see if both points are outside of the same boundary
				bDraw = HFALSE;
			}
			else if (0 != ((*pCF1 | *pCF2)))
			{ //	Test to see if the triangle spans no boundaries
				bDraw = HFALSE;
				HXFClipLine(pState, pCF1, pCF2);
			}
		}

		if (bDraw)
		{
			ctlBeginPrimitiveList( pState, pVtx0, pVtx1, 0 );
			ctlEndPrimitiveList( pState );
		}
		else
		{
			// Check if we are close to overflow on the clip vertices
			if(	   ((HXF_CLIP_VTX_SPACE  - pState->NumClippedVertices)
					<= HXF_CLIP_VERTEX_BUFFER_PAD )
				|| ((HXF_CLIP_PRIMITIVE_SPACE - pState->NumClippedPrimitives)
						<= HXF_CLIP_PRIMITIVE_BUFFER_PAD))
			{
				HXFDrawClippedLines(pState);
			}
		}
		bDraw = HTRUE;
	}

	// Draw the Clipped Vertices
	if(pState->NumClippedPrimitives)
	{
		HXFDrawClippedLines(pState);
	}
}


/* ************************************************************************* *\
	FUNCTION: HXFAssembleIndexedLineStrip
	DESCRIPTION: Line Strip - Actually a connected polyline.
	Draw a connected polyline.
	Submit 1 vertex at a time.  No culling, but clipping.

\* ************************************************************************* */
void HXFAssembleIndexedLineStrip(HXFState* pState)
{
	HBOOL bInPrimitive = HFALSE;
	HBOOL bDraw = HTRUE;
	HUINT32 count;
	void* pVtx0, *pVtx1;
	HUINT32 a,b;
	HUINT16 * pSegs = (HUINT16*) pState->pIndices;
	HUINT8* pFlags = pState->pOutClipFlags;
	HUINT8* pCF1 = NULL;
	HUINT8* pCF2 = NULL;
	HUINT32 BaseIdx = pState->BaseIndex;

	a = pSegs[0] - BaseIdx;
	pVtx0 = pState->pOutVertices + (a * pState->OutVertexSize);

	for (count = 1; count <= ((HUINT32) (pState->NumPrimitives) ); count++)
	{
		b = pSegs[count] - BaseIdx;
		pVtx1 = pState->pOutVertices + (b * pState->OutVertexSize);

		{
			pCF1 = pFlags + a;
			pCF2 = pFlags + b;

			if (0 != ((*pCF1 & *pCF2)))
			{
				bDraw = HFALSE;
			}
			else if (0 != ((*pCF1 | *pCF2)))
			{ //	Test to see if the triangle spans no boundaries
				bDraw = HFALSE;
				HXFClipLine(pState, pCF1, pCF2);
			}
		}

		if(bDraw != HFALSE)
		{

			if(HFALSE == bInPrimitive) // first triangle in visible strip segment!
			{
				bInPrimitive = HTRUE;
				ctlBeginPrimitiveList( pState, pVtx0, NULL, 0 );
			}
			ctlVertex( pState, pVtx1, NULL, NULL );
		}
		else
		{
			if(HFALSE != bInPrimitive)
			{ // For lists we only need to end the list when we flush the
				// clip cache. For Strips and Fans this will need to be done
				// when ever a triangle is not drawn
				bInPrimitive = HFALSE;
				ctlEndPrimitiveList( pState );
			}

			// Check if we are close to overflow on the clip vertices
			if(	   ((HXF_CLIP_VTX_SPACE  - pState->NumClippedVertices)
					<= HXF_CLIP_VERTEX_BUFFER_PAD )
				|| ((HXF_CLIP_PRIMITIVE_SPACE - pState->NumClippedPrimitives)
						<= HXF_CLIP_PRIMITIVE_BUFFER_PAD))
			{
				HXFDrawClippedLines(pState);
			}
		}

		a = b;
		pVtx0 = pVtx1;
		bDraw = HTRUE;
	}

	// All done; if still in strip, then end list.
	if(HFALSE != bInPrimitive)
	{
		ctlEndPrimitiveList( pState );
	}

	// Draw the Clipped Vertices
	if(pState->NumClippedPrimitives)
	{
		HXFDrawClippedLines(pState);
	}
}


/* ************************************************************************* *\
	FUNCTION: HXFAssembleIndexedLineLoop
	DESCRIPTION: Line List - Actually a connected CLOSED polyline

	Draw a connected polyline.

	Submit 1 vertex at a time.  No culling, but clipping.

	For the last vertex, submit the first vertex of the primitive.

\* ************************************************************************* */
void HXFAssembleIndexedLineLoop(HXFState* pState)
{
	HBOOL bInPrimitive = HFALSE;
	HBOOL bDraw = HTRUE;
	HUINT32 count;
	void* pVtx0, *pVtx1;
	HUINT32 a,b;
	HUINT16 * pSegs = (HUINT16*) pState->pIndices;
	HUINT8* pFlags = pState->pOutClipFlags;
	HUINT8* pCF1 = NULL;
	HUINT8* pCF2 = NULL;
	HUINT32 BaseIdx = pState->BaseIndex;

	a = pSegs[0] - BaseIdx;
	pVtx0 = pState->pOutVertices + (a * pState->OutVertexSize);

	for (count = 1; count <= ((HUINT32) (pState->NumPrimitives) ); count++)
	{
		b = pSegs[count] - BaseIdx;
		pVtx1 = pState->pOutVertices + (b * pState->OutVertexSize);

		{
			pCF1 = pFlags + (a);
			pCF2 = pFlags + (b);

			if (0 != ((*pCF1 & *pCF2)))
			{ // Test to see if both points are outside of the same boundry
				bDraw = HFALSE;
			}
			else if (0 != ((*pCF1 | *pCF2)))
			{ //	Test to see if the triangle spans no boundaries
				bDraw = HFALSE;
				HXFClipLine(pState, pCF1, pCF2);
			}
		}

		if(bDraw != HFALSE)
		{
			if(HFALSE == bInPrimitive) // first triangle in visible strip segment!
			{
				bInPrimitive = HTRUE;
				ctlBeginPrimitiveList( pState, pVtx0, NULL, 0 );
			}
			ctlVertex( pState, pVtx1, NULL, NULL );
		}
		else
		{
			if(HFALSE != bInPrimitive)
			{
				ctlEndPrimitiveList( pState );
			}

			// Check if we are close to overflow on the clip vertices
			if(	   ((HXF_CLIP_VTX_SPACE  - pState->NumClippedVertices)
					<= HXF_CLIP_VERTEX_BUFFER_PAD )
				|| ((HXF_CLIP_PRIMITIVE_SPACE - pState->NumClippedPrimitives)
						<= HXF_CLIP_PRIMITIVE_BUFFER_PAD))
			{
				HXFDrawClippedLines(pState);
			}
		}

		// Roll Vertex up
		a = b;
		pVtx0 = pVtx1;
		bDraw = HTRUE;
	}

	// Send the closing link
	{
		pCF1 = pFlags + (a);
		pCF2 = pFlags + (pSegs[0] - BaseIdx);


		if (0 != ((*pCF1 & *pCF2)))
		{ // Test to see if both points are outside of the same boundry
			bDraw = HFALSE;
		}
		else if (0 != ((*pCF1 | *pCF2)))
		{ //	Test to see if the triangle spans no boundaries
			bDraw = HFALSE;
			HXFClipLine(pState, pCF1, pCF2);
		}
	}

	if(bDraw != HFALSE)
	{
		if(HFALSE == bInPrimitive) // first triangle in visible strip segment!
		{
			bInPrimitive = HTRUE;
			ctlBeginPrimitiveList( pState, pVtx0, NULL, 0 );
		}

		pVtx1 = pState->pOutVertices + ((pSegs[0] - BaseIdx) * pState->OutVertexSize);
		ctlVertex( pState, pVtx1, NULL, NULL );
	}

	// All done; if still in strip, then end list.
	if(HFALSE != bInPrimitive)
	{
		ctlEndPrimitiveList( pState );
	}

	// Draw the Clipped Vertices
	if(pState->NumClippedPrimitives)
	{
		HXFDrawClippedLines(pState);
	}
}


/* ************************************************************************* *\
	FUNCTION: HXFAssembleIndexedPoints
	DESCRIPTION: Point List
	Draw a bunch of dots..
	Submit 1 vertex at a time.  No culling, but clipping.

\* ************************************************************************* */
void HXFAssembleIndexedPoints(HXFState* pState)
{
	HBOOL bInPrimitive = HFALSE;
	HBOOL bDraw = HTRUE;
	HUINT32 count = 0;
	void* pVtx0 = NULL;
	HUINT16* pArray = (HUINT16*)pState->pIndices;
	HUINT32 a = 0;
	HUINT8* pFlags = pState->pOutClipFlags;
	HUINT32 BaseIdx = pState->BaseIndex;

	for (count = 0; count < ((HUINT32) (pState->NumPrimitives) ); count++)
	{
		a = pArray[count] - BaseIdx;
		pVtx0 = pState->pOutVertices + (a * pState->OutVertexSize);

		{
			if(pFlags[a]  & (HXF_VTX_CLIP_FLAG_NEG_Z | HXF_VTX_CLIP_FLAG_POS_Z) )
			{
				bDraw = HFALSE;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -