In the HalfLife MDL Viewer Source code

Started by
0 comments, last by Eric kim 20 years ago
The below is the source code of HL SDK''s( old one in 1999 :-< ) model viewer. studiohdr_t *CMdlLoader::LoadModel( char *modelname ) { FILE *fp; long size; void *buffer;//pointer to file // load the model if( (fp = fopen( modelname, "rb" )) == NULL) { MessageBox( NULL, "unable to open model file", "Mdl Viewer", MB_ICONERROR|MB_OK ); exit(1); } fseek( fp, 0, SEEK_END ); size = ftell( fp ); fseek( fp, 0, SEEK_SET ); buffer = malloc( size ); fread( buffer, size, 1, fp ); // Skip / loading textures fclose( fp ); return (studiohdr_t *)buffer; } I''m curious about returning part. How can the buffer be changed to studiohdr_t? (studiohdr_t is the structure that has model''s info) There were no more funcions about loading models except loading textures.
Hello
Advertisement
the buffer is a pointer to a void segment, so it''s definitivly legal to perform this cast, it would be more interesting to know what they do with the returned pointer ...

This topic is closed to new replies.

Advertisement