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

📄 vertex.c

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
      {
      return;
      }

   HXF_PROFILER_TRANSITION(HXFPROFILE_DRAW_PREPARE);
   if(IMG_FALSE != PrepareToDraw(gc))
      {
      MRLState* pState = gc->sTransform.pMRLState;
      CTL_RASTER_CALLBACKS sCallbacks;
      CTLU32 u32NewOffset, u32VtxSize;

      HXF_PROFILER_TRANSITION(HXFPROFILE_DRAW_VALIDATE);
      ValidateState(gc);

      gc->sHWContext.ui32TAControland3DState |= MBX1_TASTATEPRES_ISPCTL;

      if(gc->sHWContext.ui32TAControland3DState & ~MBX1_TASTATEPRES_CLRMASK)
         {
         GLESEmitState(gc);
         }

      // Setup the callback pointers (the first two are consistent but the 
      // vertex callback function varies depending on the vertex stride 
      // of these primitives, and the type of clip list to begin depends 
      // on the primitive type being rendered.
      //
      sCallbacks.BeginPrimitiveList = HXFBeginPrimitiveList;
      sCallbacks.EndPrimitiveList   = HXFEndPrimitiveList;
      
      sCallbacks.BeginClipList = 0;
      if(( CTLPRIMITIVE_LINELIST <= ctlPT ) && ( ctlPT <= CTLPRIMITIVE_LINELOOP ))
         sCallbacks.BeginClipList = HXFBeginClippedLineList;
      else if(( CTLPRIMITIVE_TRILIST <= ctlPT ) && ( ctlPT <= CTLPRIMITIVE_TRIFAN ))
         sCallbacks.BeginClipList = HXFBeginClippedTriList;
      
      u32VtxSize = CTL_GetVertexSize( gc->sTransform.ctl );
      sCallbacks.Vertex = s_SPProcs[u32VtxSize >> 2];

      CTL_SetRasterCallbacks( gc->sTransform.ctl, &sCallbacks );

      // Set up the slave port for writing.
      pState->SPAddr = pState->SPBaseAddr + *(pState->pHWState->psHWInfo->sDeviceSpecific.sMBX.sTASlavePort.pui32Offset);
      pState->SPAddr = ( pState->SPAddr & HXF_ALIGN_MASK ) + HXF_ALIGN;

      pState->PrimitiveHeader = pState->pHWState->ui32PrimitiveHeader;

      pState->pSPProc = sCallbacks.Vertex;

      CTL_SetIndices( gc->sTransform.ctl, pIndices );
      if( !CTL_DrawPrimitives( gc->sTransform.ctl, ctlPT, FirstVtx, VtxCount, u32NumPrimitives ))
         {
         SetError(gc, GL_OUT_OF_MEMORY);
         }  // if

      // Update slave port offset.
      u32NewOffset = pState->SPAddr - pState->SPBaseAddr;
      if( u32NewOffset >= pState->pHWState->psHWInfo->sDeviceSpecific.sMBX.sTASlavePort.ui32DataRange )
         {
         u32NewOffset = 0;
         }  // if

      *(pState->pHWState->psHWInfo->sDeviceSpecific.sMBX.sTASlavePort.pui32Offset) = 
            u32NewOffset;

      GLESReleaseTA(gc, IMG_FALSE);
      }

   }  /* DoDrawPrimitive */


/***********************************************************************************
 Function Name      : glDrawArrays
 Inputs             : mode, first. count
 Outputs            : -
 Returns            : -
 Description        : ENTRYPOINT: Draws primitives of type mode using vertex arrays.
					  Will validate as necessary, then send geometry through TNL as
					  appropriate, and then write geometry to slave port.
************************************************************************************/
GLAPI void APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count)
{
	__GL_GET_CONTEXT();

    /* check that first and count are positive */
    if(first < 0 || count < 0)
	{
		SetError(gc, GL_INVALID_VALUE);
		return;
    }

    if(mode > GL_TRIANGLE_FAN)
	{
		SetError(gc, GL_INVALID_ENUM);
		return;
    }

    if(count == 0 )
	{
		return;
	}

	if(!(gc->sVertexArray.ui32ArrayEnables & VARRAY_VERT_ENABLE) ||
		gc->sVertexArray.sVPState.pui8Pointer == NULL)
	{
		return;
	}

	if(gc->sPolygon.ui32CullFlag == GLES_CULLFLAG_BOTH)
	{
		return;
	}

	HXF_PROFILER_START(HXFPROFILE_DRAW_SETUP);

	DoDrawPrimitive(gc, mode, first, count, count, NULL);

	HXF_PROFILER_STOP(HXFPROFILE_DRAW_SETUP);
}

/***********************************************************************************
 Function Name      : glDrawElements
 Inputs             : mode, count, type indices
 Outputs            : -
 Returns            : -
 Description        : ENTRYPOINT: Draws primitives of type mode using vertex arrays.
					  Will validate as necessary, then send geometry through TNL as
					  appropriate, and then write geometry to slave port. De-indexes
					  indices as no indexed geometry is supported by MBX.
************************************************************************************/
GLAPI void APIENTRY  glDrawElements(GLenum mode, GLsizei NumIndices, GLenum type,
									const GLvoid *indices)
{
    IMG_UINT16 *pui16Elements;
	IMG_UINT32 ui32MinIndex=0xFFFFFFFF, ui32MaxIndex=0;
	__GL_GET_CONTEXT();

     /* check that count is positive */
	if(NumIndices < 0)
	{
		SetError(gc, GL_INVALID_VALUE);
		return;
    }

    if(mode > GL_TRIANGLE_FAN)
	{
		SetError(gc, GL_INVALID_ENUM);
		return;
    }

	switch(type)
	{
		case GL_UNSIGNED_BYTE:
		case GL_UNSIGNED_SHORT:
			break;
		default:
			SetError(gc, GL_INVALID_ENUM);
			return;
	}

    if(NumIndices == 0)
	{
		return;
	}

	if(!(gc->sVertexArray.ui32ArrayEnables & VARRAY_VERT_ENABLE) ||
		gc->sVertexArray.sVPState.pui8Pointer == NULL)
	{
		return;
	}

	if(gc->sPolygon.ui32CullFlag == GLES_CULLFLAG_BOTH)
	{
		return;
	}

	HXF_PROFILER_START(HXFPROFILE_DRAW_SETUP);

	if(type == GL_UNSIGNED_BYTE)
	{
		HINT32 i = 0;
		HUINT8* pByteIndices = NULL;
		pui16Elements = (IMG_UINT16*)GLESMalloc(gc, NumIndices * sizeof(IMG_UINT16));
		if(!pui16Elements)
		{
			SetError(gc, GL_OUT_OF_MEMORY);
			return;
		}

		pByteIndices = (HUINT8*)indices;
		for(i = 0; i < NumIndices; ++i)
		{
			pui16Elements[i] = (HUINT16)pByteIndices[i];
		}

		HXFCountVertices(pui16Elements, NumIndices,
				  &ui32MinIndex, &ui32MaxIndex);

// FIXME this function need work		HXFCountVertices_Convert8To16( pui16Elements, (IMG_UINT8 *)indices, NumIndices,
// FIXME				  &ui32MinIndex, &ui32MaxIndex);
	}
	else if(type == GL_UNSIGNED_SHORT)
	{
		pui16Elements = (IMG_UINT16 *)indices;
		HXFCountVertices(pui16Elements, NumIndices,
				  &ui32MinIndex, &ui32MaxIndex);
	}

	DoDrawPrimitive(gc, mode,
						ui32MinIndex, ui32MaxIndex - ui32MinIndex + 1,
						NumIndices, pui16Elements);

	if(indices != pui16Elements)
	{
		GLESFree(gc, pui16Elements);
	}
	HXF_PROFILER_STOP(HXFPROFILE_DRAW_SETUP);
}

/***********************************************************************************
 Function Name      : glDrawRangeElements
 Inputs             : mode, count, type indices
 Outputs            : -
 Returns            : -
 Description        : ENTRYPOINT: Draws primitives of type mode using vertex arrays.
					  Will validate as necessary, then send geometry through TNL as
					  appropriate, and then write geometry to slave port. De-indexes
					  indices as no indexed geometry is supported by MBX.
************************************************************************************/
void glDrawRangeElements(GLenum mode, GLuint ui32MinIndex, GLuint ui32MaxIndex,
						GLsizei NumIndices, GLenum type, const GLvoid *indices)
{
    IMG_UINT16* pui16Elements = (IMG_UINT16*)indices;
	__GL_GET_CONTEXT();

     /* check that count is positive */
	if(NumIndices < 0)
	{
		SetError(gc, GL_INVALID_VALUE);
		return;
    }

	if(ui32MinIndex > ui32MaxIndex || ui32MaxIndex > GLES_MAX_VERTICES)
	{
		SetError(gc, GL_INVALID_VALUE);
		return;
    }

    if(mode > GL_TRIANGLE_FAN)
	{
		SetError(gc, GL_INVALID_ENUM);
		return;
    }

	switch(type)
	{
		case GL_UNSIGNED_BYTE:
		case GL_UNSIGNED_SHORT:
			break;
		default:
			SetError(gc, GL_INVALID_ENUM);
			return;
	}

    if(NumIndices == 0)
	{
		return;
	}

	if( !(gc->sVertexArray.ui32ArrayEnables & VARRAY_VERT_ENABLE) ||
		gc->sVertexArray.sVPState.pui8Pointer == NULL)
	{
		return;
	}

	if(gc->sPolygon.ui32CullFlag == GLES_CULLFLAG_BOTH)
	{
		return;
	}

	HXF_PROFILER_START(HXFPROFILE_DRAW_SETUP);
	if(type == GL_UNSIGNED_BYTE)
	{
		HINT32 i = 0;
		HUINT8* pByteIndices = NULL;
		pui16Elements = (IMG_UINT16*)GLESMalloc(gc, NumIndices * sizeof(IMG_UINT16));
		if(!pui16Elements)
		{
			SetError(gc, GL_OUT_OF_MEMORY);
			return;
		}

		pByteIndices = (HUINT8*)indices;
		for(i = 0; i < NumIndices; ++i)
		{
			pui16Elements[i] = *pByteIndices++;
		}
	}

	DoDrawPrimitive(gc, mode,
						ui32MinIndex, ui32MaxIndex - ui32MinIndex + 1,
						NumIndices, pui16Elements);

	if(indices != pui16Elements)
	{
		GLESFree(gc, pui16Elements);
	}
	HXF_PROFILER_STOP(HXFPROFILE_DRAW_SETUP);
}


/***********************************************************************************
 Function Name      : InitVertexArrayState
 Inputs             : gc
 Outputs            : -
 Returns            : -
 Description        : Initialises internal vertex array state to default values
************************************************************************************/

IMG_VOID InitVertexArrayState(GLESContext *gc)
{
    GLint i;

    /*
     * Set up vertex array default values
     */
	gc->sVertexArray.sVPState.ui32Size = 4;
	gc->sVertexArray.sNPState.ui32Size = 3;
	gc->sVertexArray.sCPState.ui32Size = 4;

	for (i=0; i<GLES_MAX_TEXTURE_UNITS; ++i)
	{
		gc->sVertexArray.asTPState[i].ui32Size = 4;
    }
}

/* ************************************************************************* *\
** ************************************************************************* **
** EOF
** ************************************************************************* **
\* ************************************************************************* */


⌨️ 快捷键说明

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