tags:

views:

397

answers:

2

It is mostly out of boredom, really... This afternoon I decided to make a simple 3D Game on Cocoa & OpenGL based on what I've done on one of my OpenGL class. I'm using the MD2 loading code that is posted at David Henry's "The Quake II's MD2 file format" and I like how it's put together, giving nice explanations, and nice C++ code. I want this to go all Cocoa/Objective-C so I can get the feel for the stuff and I got to a part which I cannot translate to C - I simply do not got enough experience in programming. Here is the code in question, which relates to file reading:

// read frame data...
file.seekg( header.ofs_frames, std::ios::beg );
file.read( (char *)buffer, num_frames * header.framesize );

So, my question is this: is there an equivalent for seek() on C's file functions that I can use? Any related info you think I might find useful?

Thank-you in advance, and bless.

+2  A: 

Take a look at fseek and fread from stdio.h.

dirkgently
Thank-you very much!
A: 

Not sure if you're still looking for resources for how to do this, but I found a great tutorial at the Kode80 blog: http://kode80.com/2009/09/24/iphone-md2-example/

There is a sample project in which the author wrote an MD2 reader for Objective-C/OpenGL ES from the MD2 spec (http://tfc.duke.free.fr/coding/md2-specs-en.html)

Andy R