third_party/virtualbox/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp
/* Convert VMWare vertex declaration to its OpenGL equivalent. */
Convert VMWare vertex declaration to its OpenGL equivalent.
Convert VMWare vertex declaration to its OpenGL equivalent .
int vmsvga3dVertexDecl2OGL(SVGA3dVertexArrayIdentity &identity, GLint &size, GLenum &type, GLboolean &normalized)
{
    normalized = GL_FALSE;
    switch (identity.type)
    {
    case SVGA3D_DECLTYPE_FLOAT1:
        size = 1;
        type = GL_FLOAT;
        break;
    case SVGA3D_DECLTYPE_FLOAT2:
        size = 2;
        type = GL_FLOAT;
        break;
    case SVGA3D_DECLTYPE_FLOAT3:
        size = 3;
        type = GL_FLOAT;
        break;
    case SVGA3D_DECLTYPE_FLOAT4:
        size = 4;
        type = GL_FLOAT;
        break;
    case SVGA3D_DECLTYPE_D3DCOLOR:
        size = GL_BGRA;                 
        type = GL_UNSIGNED_BYTE;
        normalized = GL_TRUE;   
        break;
    case SVGA3D_DECLTYPE_UBYTE4N:
        normalized = GL_TRUE;
        RT_FALL_THRU();
    case SVGA3D_DECLTYPE_UBYTE4:
        size = 4;
        type = GL_UNSIGNED_BYTE;
        break;
    case SVGA3D_DECLTYPE_SHORT2N:
        normalized = GL_TRUE;
        RT_FALL_THRU();
    case SVGA3D_DECLTYPE_SHORT2:
        size = 2;
        type = GL_SHORT;
        break;
    case SVGA3D_DECLTYPE_SHORT4N:
        normalized = GL_TRUE;
        RT_FALL_THRU();
    case SVGA3D_DECLTYPE_SHORT4:
        size = 4;
        type = GL_SHORT;
        break;
    case SVGA3D_DECLTYPE_USHORT4N:
        normalized = GL_TRUE;
        size = 4;
        type = GL_UNSIGNED_SHORT;
        break;
    case SVGA3D_DECLTYPE_USHORT2N:
        normalized = GL_TRUE;
        size = 2;
        type = GL_UNSIGNED_SHORT;
        break;
    case SVGA3D_DECLTYPE_UDEC3:
        size = 3;
        type = GL_UNSIGNED_INT_2_10_10_10_REV;    
        break;
    case SVGA3D_DECLTYPE_DEC3N:
        normalized = true;
        size = 3;
        type = GL_INT_2_10_10_10_REV;    
        break;
    case SVGA3D_DECLTYPE_FLOAT16_2:
        size = 2;
        type = GL_HALF_FLOAT;
        break;
    case SVGA3D_DECLTYPE_FLOAT16_4:
        size = 4;
        type = GL_HALF_FLOAT;
        break;
    default:
        AssertFailedReturn(VERR_INVALID_PARAMETER);
    }
    return VINF_SUCCESS;
}
int vmsvga3dVertexDecl2OGL ( SVGA3dVertexArrayIdentity & identity , GLint & size , GLenum & type , GLboolean & normalized ) { normalized = GL_FALSE ; switch ( identity . type ) { case SVGA3D_DECLTYPE_FLOAT1 : size = 1 ; type = GL_FLOAT ; break ; case SVGA3D_DECLTYPE_FLOAT2 : size = 2 ; type = GL_FLOAT ; break ; case SVGA3D_DECLTYPE_FLOAT3 : size = 3 ; type = GL_FLOAT ; break ; case SVGA3D_DECLTYPE_FLOAT4 : size = 4 ; type = GL_FLOAT ; break ; case SVGA3D_DECLTYPE_D3DCOLOR : size = GL_BGRA ; type = GL_UNSIGNED_BYTE ; normalized = GL_TRUE ; break ; case SVGA3D_DECLTYPE_UBYTE4N : normalized = GL_TRUE ; RT_FALL_THRU ( ) ; case SVGA3D_DECLTYPE_UBYTE4 : size = 4 ; type = GL_UNSIGNED_BYTE ; break ; case SVGA3D_DECLTYPE_SHORT2N : normalized = GL_TRUE ; RT_FALL_THRU ( ) ; case SVGA3D_DECLTYPE_SHORT2 : size = 2 ; type = GL_SHORT ; break ; case SVGA3D_DECLTYPE_SHORT4N : normalized = GL_TRUE ; RT_FALL_THRU ( ) ; case SVGA3D_DECLTYPE_SHORT4 : size = 4 ; type = GL_SHORT ; break ; case SVGA3D_DECLTYPE_USHORT4N : normalized = GL_TRUE ; size = 4 ; type = GL_UNSIGNED_SHORT ; break ; case SVGA3D_DECLTYPE_USHORT2N : normalized = GL_TRUE ; size = 2 ; type = GL_UNSIGNED_SHORT ; break ; case SVGA3D_DECLTYPE_UDEC3 : size = 3 ; type = GL_UNSIGNED_INT_2_10_10_10_REV ; break ; case SVGA3D_DECLTYPE_DEC3N : normalized = true ; size = 3 ; type = GL_INT_2_10_10_10_REV ; break ; case SVGA3D_DECLTYPE_FLOAT16_2 : size = 2 ; type = GL_HALF_FLOAT ; break ; case SVGA3D_DECLTYPE_FLOAT16_4 : size = 4 ; type = GL_HALF_FLOAT ; break ; default : AssertFailedReturn ( VERR_INVALID_PARAMETER ) ; } return VINF_SUCCESS ; }
Convert VMWare vertex declaration to its OpenGL equivalent.
Convert VMWare vertex declaration to its OpenGL equivalent .
/* @note requires GL_ARB_vertex_array_bgra */ /* glVertexAttribPointer fails otherwise */ /** @todo correct? */ /** @todo correct? */ //pVertexElement->Method      = identity.method; //pVertexElement->Usage       = identity.usage;