<p>The open source implementation <a href="https://sourceforge.net/projects/freeglut/" rel="nofollow noreferrer">FreeGLUT</a> has these functions.
The geometry code can be found in <a href="https://sourceforge.net/p/freeglut/code/HEAD/tree/trunk/freeglut/freeglut/src/fg_geometry.c" rel="nofollow noreferrer"><code>freeglut/freeglut/src/fg_geometry.c</code></a>.</p>
<p>For the dodecahedron, these are the values:</p>
<pre><code>#define DODECAHEDRON_NUM_VERT           20
#define DODECAHEDRON_NUM_FACES          12
#define DODECAHEDRON_NUM_EDGE_PER_FACE  5
#define DODECAHEDRON_VERT_PER_OBJ       (DODECAHEDRON_NUM_FACES*DODECAHEDRON_NUM_EDGE_PER_FACE)
#define DODECAHEDRON_VERT_ELEM_PER_OBJ  (DODECAHEDRON_VERT_PER_OBJ*3)
#define DODECAHEDRON_VERT_PER_OBJ_TRI   (DODECAHEDRON_VERT_PER_OBJ+DODECAHEDRON_NUM_FACES*4)    /* 4 extra edges per face when drawing pentagons as triangles */
/* Vertex Coordinates */
static GLfloat dodecahedron_v[DODECAHEDRON_NUM_VERT*3] =
{
               0.0f,  1.61803398875f,  0.61803398875f,
    -          1.0f,            1.0f,            1.0f,
    -0.61803398875f,            0.0f,  1.61803398875f,
     0.61803398875f,            0.0f,  1.61803398875f,
               1.0f,            1.0f,            1.0f,
               0.0f,  1.61803398875f, -0.61803398875f,
               1.0f,            1.0f, -          1.0f,
     0.61803398875f,            0.0f, -1.61803398875f,
    -0.61803398875f,            0.0f, -1.61803398875f,
    -          1.0f,            1.0f, -          1.0f,
               0.0f, -1.61803398875f,  0.61803398875f,
               1.0f, -          1.0f,            1.0f,
    -          1.0f, -          1.0f,            1.0f,
               0.0f, -1.61803398875f, -0.61803398875f,
    -          1.0f, -          1.0f, -          1.0f,
               1.0f, -          1.0f, -          1.0f,
     1.61803398875f, -0.61803398875f,            0.0f,
     1.61803398875f,  0.61803398875f,            0.0f,
    -1.61803398875f,  0.61803398875f,            0.0f,
    -1.61803398875f, -0.61803398875f,            0.0f
};
/* Normal Vectors */
static GLfloat dodecahedron_n[DODECAHEDRON_NUM_FACES*3] =
{
                0.0f,  0.525731112119f,  0.850650808354f,
                0.0f,  0.525731112119f, -0.850650808354f,
                0.0f, -0.525731112119f,  0.850650808354f,
                0.0f, -0.525731112119f, -0.850650808354f,

     0.850650808354f,             0.0f,  0.525731112119f,
    -0.850650808354f,             0.0f,  0.525731112119f,
     0.850650808354f,             0.0f, -0.525731112119f,
    -0.850650808354f,             0.0f, -0.525731112119f,

     0.525731112119f,  0.850650808354f,             0.0f,
     0.525731112119f, -0.850650808354f,             0.0f,
    -0.525731112119f,  0.850650808354f,             0.0f, 
    -0.525731112119f, -0.850650808354f,             0.0f,
};

/* Vertex indices */
static GLubyte dodecahedron_vi[DODECAHEDRON_VERT_PER_OBJ] =
{
     0,  1,  2,  3,  4, 
     5,  6,  7,  8,  9, 
    10, 11,  3,  2, 12, 
    13, 14,  8,  7, 15, 

     3, 11, 16, 17,  4, 
     2,  1, 18, 19, 12, 
     7,  6, 17, 16, 15, 
     8, 14, 19, 18,  9, 

    17,  6,  5,  0,  4, 
    16, 11, 10, 13, 15, 
    18,  1,  0,  5,  9, 
    19, 14, 13, 10, 12
};
</code></pre>
<p>As for the second part of your question, tools such as <a href="https://renderdoc.org" rel="nofollow noreferrer">renderdoc</a> allow you to export meshes which are used in a render. To do this, you must first take a capture, find the corresponding draw call in event browser, open the Mesh Viewer and click on the export icon. You can do this with almost any mesh input to a vertex shader drawn in a supported API.
<a href="https://i.sstatic.net/O9wtV.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/O9wtV.png" alt="Export any mesh with renderdoc" /></a></p>

CC BY-SA 4.0
2020-06-22T09:30:25.160Z
2020-06-22T09:30:25.160Z
bwrsandman
<p>I am trying to build a dedocohedron in OpenGL, and I know that there is a built-in function in GLUT for the purpose. I was wondering if there is a way to either see the sourcecode for those functions, or to extract the generated data for vertices, colors, and indeces and print them?</p>

<opengl>
glutSolid* source code
tado-mi
# glutSolid* source code

(Asked by: username_0 on 2020-05-30)

I am trying to build a dedocohedron in OpenGL, and I know that there is a built-in function in GLUT for the purpose. I was wondering if there is a way to either see the sourcecode for those functions, or to extract the generated data for vertices, colors, and indeces and print them?

**Tags:** opengl


---

## 1 answers

### Answer by username_1 on 2020-06-22. Score: 2

The open source implementation [FreeGLUT](https://sourceforge.net/projects/freeglut/) has these functions.
The geometry code can be found in [`freeglut/freeglut/src/fg_geometry.c`](https://sourceforge.net/p/freeglut/code/HEAD/tree/trunk/freeglut/freeglut/src/fg_geometry.c).

For the dodecahedron, these are the values:

```
#define DODECAHEDRON_NUM_VERT           20
#define DODECAHEDRON_NUM_FACES          12
#define DODECAHEDRON_NUM_EDGE_PER_FACE  5
#define DODECAHEDRON_VERT_PER_OBJ       (DODECAHEDRON_NUM_FACES*DODECAHEDRON_NUM_EDGE_PER_FACE)
#define DODECAHEDRON_VERT_ELEM_PER_OBJ  (DODECAHEDRON_VERT_PER_OBJ*3)
#define DODECAHEDRON_VERT_PER_OBJ_TRI   (DODECAHEDRON_VERT_PER_OBJ+DODECAHEDRON_NUM_FACES*4)    /* 4 extra edges per face when drawing pentagons as triangles */
/* Vertex Coordinates */
static GLfloat dodecahedron_v[DODECAHEDRON_NUM_VERT*3] =
{
               0.0f,  1.61803398875f,  0.61803398875f,
    -          1.0f,            1.0f,            1.0f,
    -0.61803398875f,            0.0f,  1.61803398875f,
     0.61803398875f,            0.0f,  1.61803398875f,
               1.0f,            1.0f,            1.0f,
               0.0f,  1.61803398875f, -0.61803398875f,
               1.0f,            1.0f, -          1.0f,
     0.61803398875f,            0.0f, -1.61803398875f,
    -0.61803398875f,            0.0f, -1.61803398875f,
    -          1.0f,            1.0f, -          1.0f,
               0.0f, -1.61803398875f,  0.61803398875f,
               1.0f, -          1.0f,            1.0f,
    -          1.0f, -          1.0f,            1.0f,
               0.0f, -1.61803398875f, -0.61803398875f,
    -          1.0f, -          1.0f, -          1.0f,
               1.0f, -          1.0f, -          1.0f,
     1.61803398875f, -0.61803398875f,            0.0f,
     1.61803398875f,  0.61803398875f,            0.0f,
    -1.61803398875f,  0.61803398875f,            0.0f,
    -1.61803398875f, -0.61803398875f,            0.0f
};
/* Normal Vectors */
static GLfloat dodecahedron_n[DODECAHEDRON_NUM_FACES*3] =
{
                0.0f,  0.525731112119f,  0.850650808354f,
                0.0f,  0.525731112119f, -0.850650808354f,
                0.0f, -0.525731112119f,  0.850650808354f,
                0.0f, -0.525731112119f, -0.850650808354f,

     0.850650808354f,             0.0f,  0.525731112119f,
    -0.850650808354f,             0.0f,  0.525731112119f,
     0.850650808354f,             0.0f, -0.525731112119f,
    -0.850650808354f,             0.0f, -0.525731112119f,

     0.525731112119f,  0.850650808354f,             0.0f,
     0.525731112119f, -0.850650808354f,             0.0f,
    -0.525731112119f,  0.850650808354f,             0.0f, 
    -0.525731112119f, -0.850650808354f,             0.0f,
};

/* Vertex indices */
static GLubyte dodecahedron_vi[DODECAHEDRON_VERT_PER_OBJ] =
{
     0,  1,  2,  3,  4, 
     5,  6,  7,  8,  9, 
    10, 11,  3,  2, 12, 
    13, 14,  8,  7, 15, 

     3, 11, 16, 17,  4, 
     2,  1, 18, 19, 12, 
     7,  6, 17, 16, 15, 
     8, 14, 19, 18,  9, 

    17,  6,  5,  0,  4, 
    16, 11, 10, 13, 15, 
    18,  1,  0,  5,  9, 
    19, 14, 13, 10, 12
};

```

As for the second part of your question, tools such as [renderdoc](https://renderdoc.org) allow you to export meshes which are used in a render. To do this, you must first take a capture, find the corresponding draw call in event browser, open the Mesh Viewer and click on the export icon. You can do this with almost any mesh input to a vertex shader drawn in a supported API.
[![Export any mesh with renderdoc](https://i.sstatic.net/O9wtV.png)](https://i.sstatic.net/O9wtV.png)


---

