Guest User

Untitled

a guest
Nov 18th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. void loadObj(char *fname)
  2.  
  3. FILE *fp;
  4. int read;
  5. GLfloat x, y, z;
  6. char ch;
  7. elephant = glGenLists(1);
  8. fp = fopen(fname, "r");
  9. if (!fp)
  10. {
  11. printf("can't open file %sn", fname);
  12. exit(1);
  13. }
  14. glPointSize(2.0);
  15. glNewList(elephant, GL_COMPILE);
  16. {
  17. glPushMatrix();
  18. glBegin(GL_POINTS);
  19. while (!(feof(fp)))
  20. {
  21. read = fscanf(fp, "%c %f %f %f", &ch, &x, &y, &z);
  22. if (read == 4 && ch == 'v')
  23. {
  24. glVertex3f(x, y, z);
  25. }
  26. }
  27. glEnd();
  28. }
  29. glPopMatrix();
  30. glEndList();
  31. fclose(fp);
  32. }
Add Comment
Please, Sign In to add comment