示例#1
0
void Vertex::SetAttribute(string name, void* pvalue, const VertexFormat &vf)
{
    int offset = vf.GetOffsetOf(name);
    if(offset == -1) return;
    int type = vf.GetAttribute(name).GetComponentsType();
    void *pdata  = GetAttributePointer(name, vf);
    for(int i = 0; i < vf.GetAttribute(name).GetComponentsCount(); ++i)
    {
        if(type == GL_DOUBLE)      *((double*)pdata + i)        = *((double*)pvalue + i);
        else if(type == GL_FLOAT)  *((float*)pdata + i)         = *((float*)pvalue + i);
        else if(type == GL_INT)    *((int*)pdata + i)           = *((int*)pvalue + i);
        else if(type == GL_SHORT)  *((short*)pdata + i)         = *((short*)pvalue + i);
        else if(type == GL_BYTE)   *((unsigned char*)pdata + i) = *((unsigned char*)pvalue + i);
    }
}
示例#2
0
bool Vertex::HasAttribute(string name, const VertexFormat &vf) const
{
    int offset = vf.GetOffsetOf(name);
    return (offset != -1);
}