View Full Version : reading coordinates from a file
07-08-2001, 09:22 PM
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") http://www.opengl.org/discussion_boards/ubb/wink.gif
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 (;
07-09-2001, 02:34 AM
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 :-(
07-09-2001, 06:28 PM
i tink i get what u all mean ... thanks =>
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.