3

I'm writing a simple PyOpenGL code, with the display part as

glBegin(GL_LINE_LOOP)
glVertex2f(0,0)
glVertex2f(0,1)
glVertex2f(1,1)
glVertex2f(1,0)
glEnd()

I want to export this model as a .OBJ file. Is there any library or algorithm I could use?

I searched for a while, but could only get resources to open a .OBJ model in OpenGL, not vice-versa.

Pranav Totla
  • 2,182
  • 2
  • 20
  • 28

1 Answers1

4

The Wavefront (.obj) file format is a pretty simple, text based format. It's relatively easy to read/write. For details, read this Page on Wikipedia

Your example in Wavefront would be

v 0.0 0.0 0.0
v 0.0 1.0 0.0
v 1.0 1.0 0.0
v 1.0 0.0 0.0
f 1 2 3 4
tkausl
  • 13,686
  • 2
  • 33
  • 50