本文整理汇总了C++中tokenizer::expect_dword方法的典型用法代码示例。如果您正苦于以下问题:C++ tokenizer::expect_dword方法的具体用法?C++ tokenizer::expect_dword怎么用?C++ tokenizer::expect_dword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tokenizer
的用法示例。
在下文中一共展示了tokenizer::expect_dword方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_faces
void read_faces(tokenizer& t,int count,std::vector<face_type>& faces)
{
t.expect_literal( "{" );
t.expect_linefeed();
for( int i = 0 ; i< count ; i++ ) {
face_type f;
f.vertex_count = t.expect_integer( 2, 4 );
f.material_index = -1;
for( int j = 0 ; j < f.vertex_count ; j++ ) {
f.colors[ j ].red = f.colors[ j ].green =
f.colors[ j ].blue = f.colors[ j ].alpha = 1;
}
for( ; ; ) {
substr token = t();
if( token == "V" ) {
t.expect_literal( "(" );
for( int j = 0 ; j< f.vertex_count ; j++ ) {
f.vertex_indices[ j ] =
t.expect_integer( 0 );
}
t.expect_literal( ")" );
} else if( token == "M" ) {
t.expect_literal( "(" );
f.material_index = t.expect_integer( -1 );
t.expect_literal( ")" );
} else if( token == "UV" ) {
t.expect_literal( "(" );
for( int j = 0 ; j< f.vertex_count ; j++ ) {
f.uv[ j ].u = t.expect_float();
f.uv[ j ].v = t.expect_float();
}
t.expect_literal( ")" );
} else if( token == "COL" ) {
t.expect_literal( "(" );
for( int j = 0 ; j < f.vertex_count ; j++ ) {
DWORD c = t.expect_dword();
f.colors[ j ].red =
( c & 0xff ) / 255.0f;
f.colors[ j ].green =
( ( c & 0xff00 ) >> 8 ) /
255.0f;
f.colors[ j ].blue =
( ( c & 0xff0000 ) >> 16 ) /
255.0f;
f.colors[ j ].alpha =
( ( c & 0xff000000 ) >> 24 ) /
255.0f;
}
t.expect_literal( ")" );
} else if( token == "\n" ) {
break;
} else {
throw mqo_reader_error(
"unexpected token: "+token.str() );
}
}