Loading data in sdl program

Hello

Im now reading data for a SDL program from an ASCII text file.
Right now is only 3d data (vertexs,normals,etc…).
Is there something like SDL_sound or SDL_mixer,
but not for audio files, but for 3d data?
What format do you use or recomend to store 3d data?
If i use a binary file to store the data, the file will be smaller
and the load time will be faster. I think i will have some problems
with endianes in diferent architectures if i use my own binary format,
what do you do in your proyects to avoid that.

Thanks a lot—
Alejandro Arrieta Rios
Ms Cs Student UTFSM
Bs Computer Science UTFSM
Chile

Hello

Im now reading data for a SDL program from an ASCII text file.
Right now is only 3d data (vertexs,normals,etc…).
Is there something like SDL_sound or SDL_mixer,
but not for audio files, but for 3d data?

Why would you need anything SDL specific? SDL doesn’t deal with 3D
anyway; it just sets up an OpenGL display and lets you talk directly
to OpenGL.

What format do you use or recomend to store 3d data?

Normally, the handiest format would be something that
* Does what you need. (DUH!)
* Can be written directly by your content creation tools.
* Can be read directly with existing or easy to implement code.

If i use a binary file to store the data, the file will be smaller

…which doesn’t really matter if you do what “everyone” is doing
these days: Put the data in a compressed archive.

I’ve tried it with scripts (Audiality sounds) and bzip2, and really;
it’s pretty much irrelevant what format you use, as long as the
semantic contents are the same. If you say “model_vertex_list” or
(unsigned char)0x42 a few times in a file doesn’t really matter, as
either is reduced to at most one full copy (that is compressed as
well) and few bits per instance.

and the load time will be faster.

…which is mostly irrelevant, unless you want to handle insane
amounts of data on rather CPU limited platforms. Decompression is
probably more expensive than text file parsing, and that doesn’t seem
to be much of an issue.

I think i will have some problems
with endianes in diferent architectures if i use my own binary
format, what do you do in your proyects to avoid that.

Nah, it’s not much of an issue, really - if you’re aware of what’s
actually going on. Just make sure you clearly define the endianness
of things in the file format, and use an interface like WriteFloat(),
ReadLong() etc, that does the right thing. You can even code it
without #ifdefs, something like;

size_t WriteLong(FILE *f, Uint32 value)
{
char buf[4];
buf[0] = value;
buf[1] = value >> 8;
buf[2] = value >> 16;
buf[3] = value >> 24;
return fwrite(buf, 4, f);
}

This puts the least significant byte first, regardless of CPU endian.

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Wednesday 06 April 2005 06.27, Alejandro Arrieta Rios wrote: