コード例 #1
0
// ----------------------------------------------------------------------------
VertexAttribute *
vertex_attribute_parse( char *format )
{
    // Generic attribute
    char *p = strpbrk ( format, "0123456789" );
    if (p == format) 
    {
        // Normalized
        p = strpbrk ( format, "n" );
        if ( p != NULL )
        {
            int size, index;
            char ctype;
            sscanf( format, "%dgn%d%c", &index, &size, &ctype );

			{
            GLenum type = GL_TYPE( ctype );
            return vertex_attribute_new( 0, index, size, type, GL_TRUE, 0, 0 );
			}
        }
        else
        {
            int size, index;
            char ctype;
            sscanf( format, "%dg%d%c", &index, &size, &ctype );

			{
            GLenum type = GL_TYPE( ctype );
            return vertex_attribute_new( 0, index, size, type, GL_FALSE, 0, 0 );
			}
        }
    }
    
    // Known attribute
    p = strpbrk ( format, "vcntfse" );
    if ( p != 0 )
    {
        int size;
        char ctarget, ctype;
        sscanf( format, "%c%d%c", &ctarget, &size, &ctype );

		{
        GLenum type = GL_TYPE( ctype );
        GLenum target = GL_VERTEX_ATTRIBUTE_TARGET( ctarget );
        return vertex_attribute_new( target, 0, size, type, GL_FALSE, 0, 0 );
		}
    }

    fprintf(stderr, "Vertex attribute format not understood\n");
    return 0;
}
コード例 #2
0
ファイル: vertex-buffer.c プロジェクト: Eizen/ogldev
// ----------------------------------------------------------------------------
VertexAttribute *
vertex_attribute_parse( int index, char *format )
{   
     char* p = strpbrk ( format, "vcntfse" );
    
    if ( p != 0 )
    {
        int size;
        char ctarget, ctype;
        sscanf( format, "%c%d%c", &ctarget, &size, &ctype );
        GLenum type = GL_TYPE( ctype );
        return vertex_attribute_new( index, size, type, GL_FALSE, 0, 0 );
    }

    fprintf(stderr, "Vertex attribute format not understood\n");
    return 0;
}