Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Eric kim

In the HalfLife MDL Viewer Source code

This topic is 5300 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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 ...

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!