Sign in to follow this  
dcmk09

beginning openGL, loading from file

Recommended Posts

dcmk09    122
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
win_crook    171
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,
David

Share this post


Link to post
Share on other sites
CrimsonSun    336
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;
}



//loop
glBegin(GL_YOURTYPE);
for(int i = 0; i < coordinates.size(); i++)
glVertex3f(coordinates[i].x, coordinates[i].y, coordinates[i].z);
glEnd();


Share this post


Link to post
Share on other sites
dcmk09    122
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

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