reading coordinates from a file

Hi …
sometink i can’t figure out how to do,

Suppose I have this 2D coordinates file that is structured like

Coordinates -2.0 2.0
Coordinates -1.9 2.1

Anyone knows of the OpenGL function that can read the file???

Hi, i’m not sure there is a ogl function that read a file like u want.

U just have to parse this file, u open it (FILE* file=fopen(namefile, “r”)
U read each of its components and u close it.

OpenGL has no function to read from files, in fact OpenGL has only functions to draw polys and other graphics stuff
everything else has to be done by yourself
for reading files use a filestream (ifstream), parse these lines and convert the coordinates into numbers (e.g. atof or atol)
now u can send them via glvertex to OpenGL

hope that helps (;

Maybe you prefer load a binary file, and not to preprocess your data files when you run your application (if it’s slow, you can avoid to do it everytime), so you can do a “tool” to do this. So, your program only need to read the binary file.

(if quake2 must recompile his bsp maps every time you started it, nobody would had play).

[excuse grammar and ortography mistakes, but english is not my mother language :frowning:

i tink i get what u all mean … thanks =>