Jump to content
  • Advertisement
Sign in to follow this  

beginning openGL, loading from file

This topic is 4063 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi i am pretty apt at java and C programming.. recently moved onto openGL of which i have a 'fair' knowledge about.. ok so what i am stuck on is mainly just theory side of stuff.. i want to load up a file, of co-ordinates.. - reading file i find V EASY just how to i make openGL display everything.. glBegin and keep drawing point after point.. i dont see how can you control how many points use in a for loop, or even while. anyone have any idea's on what is the best way to go about it.. please let me know.. thank you. using GLUT heavily too, if that helps thanks

Share this post

Link to post
Share on other sites
Take a look at NeHe lesson 10

It loads a basic 3d world from a text file, see if you can make anything from it, if not try doing some of the previous tutorials on the site... they should help you on your way with opengl.

Good Luck,

Share this post

Link to post
Share on other sites
If you have a set of coordinates in your file and the order is not likely to change, I would store them in a vector:

struct coord3f{
float x, y, z;

std::vector<coord3f> coordinates;

//load your coordinates in your vector...I don't know how your file is formatted, so a simple example:
for(int i = 0; i < num_coordinates_in_file; i++){
coordinates.push_back( coord3f() );
coordinates.back.x = x_coord_from_file;
coordinates.back.y = y_coord_from_file;
coordinates.back.z = z_coord_from_file;

for(int i = 0; i < coordinates.size(); i++)
glVertex3f(coordinates.x, coordinates.y, coordinates.z);

Share this post

Link to post
Share on other sites
ok i pretty much can read in triangles, this can be used to build up my scene like lighhouses, houses, etc is my understanding.. correct me if i am wrong please?
-- looked over at NeHe find that out --

ok i need to now from the file, specify facet windings how do i do that, and know vaguely what they are, they make up an edge of objec.. but more detail would be awesome

thanks guys

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!