Linked Lists
hi
i am using OpenGL to make my 3D engines, now i have a little problem. I can show the triangles on the screen, but if i want to make a big world, i need something where i can store the triangles. I think that Linked Lists would be good. If there are other ways to do that, please tell me. I know how to make linked lists but i dont know how to use them.
struct LL
{
int x, y, z;
int u, v;
LL * next;
}
so how do i go through the list and how do i change variables at the right position.
i am the 2 between 0 and 1
To handle through a single linked list is a very simple
operation!
LL* top; // = top of the list item
LL* ptr; // = temporary list item
// now let''s go through the list
ptr = top
// have we reached the end of the list?
while (ptr != NULL)
{
// no, do anything with the list item
printf("x: %d\n", ptr->x);
...
...
// that''s important now, update to the next item in list
ptr = ptr->next;
}
That''s all!
operation!
LL* top; // = top of the list item
LL* ptr; // = temporary list item
// now let''s go through the list
ptr = top
// have we reached the end of the list?
while (ptr != NULL)
{
// no, do anything with the list item
printf("x: %d\n", ptr->x);
...
...
// that''s important now, update to the next item in list
ptr = ptr->next;
}
That''s all!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement