コード例 #1
0
ファイル: PRIM.C プロジェクト: CGSG/SUM2016AVD
/* Primitive create function.
 * ARGUMENTS:
 *   - primitive structure pointer:
 *      avdPRIM *Pr;
 *   - vertex array:
 *       avdVERTEX *V;
 *   - vertex array size:
 *       INT NumOfV;
 *   - index array:
 *       INT *I;
 *   - INT array size:
 *       INT NumOfI;
 * RETURNS: None.
 */
VOID AVD_RndPrimCreate( avdPRIM *Pr, avdVERTEX *V, INT NumOfV, INT *I, INT NumOfI )
{
  INT i;

  memset(Pr, 0, sizeof(avdPRIM));

  Pr->M = MatrIdentity();
  Pr->NumOfI = NumOfI;

  /* Get min-max primitive info */
  Pr->Min = Pr->Max = V[0].P;
  for (i = 1; i < NumOfV; i++)
  {
    Pr->Min.X = AVD_MIN(Pr->Min.X, V[i].P.X);
    Pr->Min.Y = AVD_MIN(Pr->Min.Y, V[i].P.Y);
    Pr->Min.Z = AVD_MIN(Pr->Min.Z, V[i].P.Z);
    Pr->Max.X = AVD_MAX(Pr->Max.X, V[i].P.X);
    Pr->Max.Y = AVD_MAX(Pr->Max.Y, V[i].P.Y);
    Pr->Max.Z = AVD_MAX(Pr->Max.Z, V[i].P.Z);
  }
  /* Set central point */
  Pr->Center = VecDivNum(VecAddVec(Pr->Min, Pr->Max), 2);

  /* Create OpenGL buffers */
  glGenVertexArrays(1, &Pr->VA);
  glGenBuffers(1, &Pr->VBuf);
  glGenBuffers(1, &Pr->IBuf);

  /* Activate vertex array */
  glBindVertexArray(Pr->VA);
  /* Activate vertex buffer */
  glBindBuffer(GL_ARRAY_BUFFER, Pr->VBuf);
  /* Store vertex data */
  glBufferData(GL_ARRAY_BUFFER, sizeof(avdVERTEX) * NumOfV, V, GL_STATIC_DRAW);

  /* Setup data order */
  /*                    layout,
   *                      components count,
   *                          type
   *                                    should be normalize,
   *                                           vertex structure size in bytes (stride),
   *                                               offset in bytes to field start */
  glVertexAttribPointer(0, 3, GL_FLOAT, FALSE, sizeof(avdVERTEX),
                        (VOID *)0); /* position */
  glVertexAttribPointer(1, 2, GL_FLOAT, FALSE, sizeof(avdVERTEX),
                        (VOID *)sizeof(VEC)); /* texture coordinates */
  glVertexAttribPointer(2, 3, GL_FLOAT, FALSE, sizeof(avdVERTEX),
                        (VOID *)(sizeof(VEC) + sizeof(VEC2))); /* normal */
  glVertexAttribPointer(3, 4, GL_FLOAT, FALSE, sizeof(avdVERTEX),
                        (VOID *)(sizeof(VEC) * 2 + sizeof(VEC2))); /* color */

  /* Enable used attributes */
  glEnableVertexAttribArray(0);
  glEnableVertexAttribArray(1);
  glEnableVertexAttribArray(2);
  glEnableVertexAttribArray(3);

  /* Indices */
  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, Pr->IBuf);
  glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(INT) * NumOfI, I, GL_STATIC_DRAW);

  /* Disable vertex array */
  glBindVertexArray(0);
  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
} /* End of 'VG4_RndPrimCreate' function */
コード例 #2
0
ファイル: avd_hifb.c プロジェクト: 119/myimpsrc2
//extern AVD_RESULT_S g_AVD_Reslut;
void TDE_OUTPUT_AVD_RESULT(TDE_HANDLE s32Handle, TDE2_SURFACE_S* pstDst,AVD_RESULT_S *result)//,TDE2_RECT_S *pstDstRect)
{
    TDE2_RECT_S pstDstRect;
    HI_U32 u32FillData = 0x7c00;
    HI_U32 u32PEAData = 0x3e0;
    HI_U32 u32TWData = 0x3e0;
    HI_U32 u32BaseLine = 0x3e0;//0x1f;

    IMP_S32 zone = 0;
    IMP_RECT_S *rc;
    IMP_RECT_S rc1;
    IMP_FLOAT scale_x = (640.0/352);
    IMP_FLOAT scale_y = (512.0/288);
    IMP_S32 i = 0;
    IMP_S32 j = 0;
    IMP_S32 pixWidth = 4;
    IMP_S32 peaPixWidth = 8;
    IMP_S32 twPixWidth = 20;
    IMP_S32 s32Ret = 0;
    IMP_S16 cr;
    TDE2_FILLCOLOR_S pstFillColor;
    TDE2_OPT_S pstOpt;
    pstFillColor.enColorFmt = TDE2_COLOR_FMT_ARGB1555;
    pstFillColor.u32FillColor = 0x7c00;//red   green:0x3e0  yellow:0x7fe0

    //pstFillColor.u32FillColor = 0x7c00;

    memset(&pstOpt,0,sizeof(pstOpt));
    pstOpt.bDeflicker = HI_TRUE;
    rc1.s16X1 = 10+79+25;
    rc1.s16Y1 = 24+10+15;
    IMP_FLOAT scale = 2;
    for(i = 0; i < 8;i++)
    {
        pstDstRect.s32Xpos = rc1.s16X1;
        pstDstRect.s32Ypos =rc1.s16Y1 + i*21;
        pstDstRect.u32Height = 18;
        if(i == 0)
        {
            pstDstRect.u32Width =AVD_MIN(g_AVD_Reslut.s32SceneChg*scale,100*scale);
        }
        else if(i == 1)
        {
            pstDstRect.u32Width =AVD_MIN(g_AVD_Reslut.s32SignalValue*scale,100*scale);
        }
        else if(i == 2)
        {
            pstDstRect.u32Width = AVD_MIN(g_AVD_Reslut.s32ClarityValue*scale,100*scale);
        }
        else if(i == 3)
        {
            pstDstRect.u32Width = AVD_MIN(g_AVD_Reslut.s32BrightHValue*scale,100*scale);
        }
        else if(i == 4)
        {
            pstDstRect.u32Width = AVD_MIN(g_AVD_Reslut.s32BrightLValue*scale,100*scale);
        }
        else if(i == 5)
        {
            pstDstRect.u32Width = AVD_MIN(g_AVD_Reslut.s32ColorValue*scale,100*scale);
        }
        else if(i == 6)
        {
            pstDstRect.u32Width = AVD_MIN(g_AVD_Reslut.s32NoiseValue*scale,100*scale);
        }
        else if(i == 7)
        {
            pstDstRect.u32Width = AVD_MIN(g_AVD_Reslut.s32FreezValue*scale,100*scale);
        }
        else if(i == 8)
        {
            pstDstRect.u32Width = 0;
        }
        pstDstRect.u32Width = AVD_MAX(0,pstDstRect.u32Width);

        if(pstDstRect.u32Width > 30*scale && pstDstRect.u32Width < 60*scale)
        {
            pstFillColor.u32FillColor = 0x7fe0;
        }
        else if(pstDstRect.u32Width >= 60*scale)
        {
            pstFillColor.u32FillColor = 0x7c00;
        }
        else
        {
            pstFillColor.u32FillColor = 0x3e0;//0x4e73;
        }
        //printf("pstDstRect.u32Width:%d\n",pstDstRect.u32Width);
        HI_TDE2_SolidDraw( s32Handle,NULL,NULL,pstDst,&pstDstRect,&pstFillColor,&pstOpt);
    }
    pstFillColor.u32FillColor = 0x1f;
    pstDstRect.s32Xpos = rc1.s16X1-8;
    pstDstRect.s32Ypos =rc1.s16Y1;
    pstDstRect.u32Height = 170;
    pstDstRect.u32Width = 10;
    HI_TDE2_SolidDraw( s32Handle,NULL,NULL,pstDst,&pstDstRect,&pstFillColor,&pstOpt);
}