Skip to main content
gamedev.net
🔒 Locked

Using Buffered Files

Started by sakky Oct 22, 2005 at 11:02 AM 1 replies 650+ views
Original Post
sakky
sakky
Okay, I have a quick question about buffering files. I’m loading a 3D model from file. I read the header information first, then allocate a BYTE array equal to the size of the remaining file. I then user one read command to read in the file’s contents. So after this, I run through setting various pointers to point into the buffer. I use the offsets from the file header to offset into the BYTE array. I have figured that the offsets given in the file header pertain to file position from the beginning of the file. So I have subtracted sizeof( FILE_HEADER ) from the offset value into the BYTE array. This should work, right!? I only have to reconfigure the offsets into the file to match with those in the buffer. The header’s offsets are from the beginning of the file. So I figured that they would be valid if I subtracted the header’s size from the index. My main concern is that an offset had a negative or irregular value. This can happen, can’t it? For instance, the file in question is fragmented. How much can I trust file offsets? By the way, the file in question is an MD2. The header contains the EOF offset, so I though it would be quick and easy to load an MD2 into memory this way. Then later converting the data as needed, for example, a vertex buffer. Am I incorrect in my assumptions?
Take back the internet with the most awsome browser around, FireFox
sakky
sakky
No one has any comments?
Take back the internet with the most awsome browser around, FireFox

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.