Sign in to follow this  
vbms

new model format (1prob, cant copy image file code)

Recommended Posts

hello, im making my own model format for my games and for others to use, the idea is to have the vertex/face data in the same file as the texture image. the model/texture file would be opened, wertex/face data extacted the rest(image data) writen to a temp file that would then be used to create the texture. OK the probs is that i copy the image code, using while(fin.get(ch)) fout << ch; this works but can only copy some characters ie .. it hits a character it can copy then kills the while, i have tryed some other ways of getting thn writing but most stop at " " <-- white space! .. all others stop when thy hit unusual chars. MY REQUEST: if u know a way of copying bmp file content pls post otherwise if u have any sugestions ,ways u might try then pls post... i will now try getting the int value of each char just like keys[256] but dont think that will work ither, otherwise ill havto read throght the complex functions of <stdio> ... sos for the long mail... pls post ... thnx

Share this post


Link to post
Share on other sites

// 1° open in binary mode so special "end of file" characters do
// not stop you from reading
ifstream fin( inputFileName, ios::binary );

// 2° Find the size and start offset of the bitmap in your file
size_t size = ...
fin.seekg( ... )

// 3° Read the data from the file to a buffer
char* data = new char[size];
fin.read( data, size );

// 4° Do something with the buffer

// 5° Delete the buffer
delete[] data;


By "do something", I mean either to write the data to a file (using the symmetrical operations "ios::binary" and ".write") or to directly create a texture from memory if you have the API functions to do so.

Share this post


Link to post
Share on other sites
hey,
i got it incase any1 has this prob some other time an easy way to copy bmp or any other file that contains eof chars or other system chars:

ifstream fin(input_File_Name, ios::binary );
ofstream fout(output_File_Name, ios::binary );

if (fin && fout)
while (!fin.eof())
{
fin.get(ch);
if (!fin.eof()) fout << ch;
}
fin.close();
fout.close();

easy.. :+Pd+:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this