Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void loadObj(char *fname)
- FILE *fp;
- int read;
- GLfloat x, y, z;
- char ch;
- elephant = glGenLists(1);
- fp = fopen(fname, "r");
- if (!fp)
- {
- printf("can't open file %sn", fname);
- exit(1);
- }
- glPointSize(2.0);
- glNewList(elephant, GL_COMPILE);
- {
- glPushMatrix();
- glBegin(GL_POINTS);
- while (!(feof(fp)))
- {
- read = fscanf(fp, "%c %f %f %f", &ch, &x, &y, &z);
- if (read == 4 && ch == 'v')
- {
- glVertex3f(x, y, z);
- }
- }
- glEnd();
- }
- glPopMatrix();
- glEndList();
- fclose(fp);
- }
Add Comment
Please, Sign In to add comment