OpenGL Source Code Generator

Moderator
Posts: 529
Joined: 2003.03
Post: #1
If this does what I think it does, this is somewhat interesting.

http://translate.google.com/translate?hl...s%26sa%3DN

Perhaps someone here Sprechen zie Deutsche? Google's translations leave something to be desired.

"Yes, well, that's the sort of blinkered, Philistine pig-ignorance I've come to expect from you non-creative garbage."
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #2
I assume this is a program which takes files from existing 3D model formats and exports C source code which generates the appropriate shape in OpenGL. Is that what you're thinking, or am I missing something?

Luckily, this kind of thing already exists on the Mac. Cheetah 3D can export C headers full of data arrays for OpenGL, complete with helpful comments detailing how to use it. Smile

For example, a cube:

Code:
// Headerfile *.h (generated by Cheetah3D)
//
// There are the following name conventions:
//     NAME            =name of the object in Cheetah3D. Caution!! Avoid giving two objects the same name
//     NAME_vertex        =float array which contains the vertex,normal and uvcoord data
//     NAME_index        =int array which contains the polygon index data
//     NAME_vertexcount    =number of vertices
//     NAME_polygoncount    =number of triangles
//
// The vertex data is saved in the following format:
//     u0,v0,normalx0,normaly0,normalz0,x0,y0,z0
//     u1,v1,normalx1,normaly1,normalz1,x1,y1,z1
//     u2,v2,normalx2,normaly2,normalz2,x2,y2,z2
//     ...
// You can draw the mesh the following way:
//     glEnableClientState(GL_INDEX_ARRAY);
//     glEnableClientState(GL_NORMAL_ARRAY);
//     glEnableClientState(GL_VERTEX_ARRAY);
//     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
//     glInterleavedArrays(GL_T2F_N3F_V3F,0,NAME_vertex);
//     glDrawElements(GL_TRIANGLES,NAME_polygoncount*3,GL_UNSIGNED_INT,NAME_index)​;
//

#define Box_vertexcount     24
#define Box_polygoncount     12


float Box_vertex[Box_vertexcount][8]={
        {0.00000, 0.00000, 0.00000, 0.00000, 1.00000, -0.50000, -0.50000, 0.50000},
        {0.00000, 0.00000, 0.00000, 0.00000, 1.00000, -0.50000, 0.50000, 0.50000},
        {0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.50000, 0.50000, 0.50000},
        {0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.50000, -0.50000, 0.50000},
        {0.00000, 0.00000, 0.00000, 0.00000, -1.00000, 0.50000, -0.50000, -0.50000},
        {0.00000, 0.00000, 0.00000, 0.00000, -1.00000, 0.50000, 0.50000, -0.50000},
        {0.00000, 0.00000, 0.00000, 0.00000, -1.00000, -0.50000, 0.50000, -0.50000},
        {0.00000, 0.00000, 0.00000, 0.00000, -1.00000, -0.50000, -0.50000, -0.50000},
        {0.00000, 0.00000, -1.00000, 0.00000, 0.00000, -0.50000, -0.50000, -0.50000},
        {0.00000, 0.00000, -1.00000, 0.00000, 0.00000, -0.50000, 0.50000, -0.50000},
        {0.00000, 0.00000, -1.00000, 0.00000, 0.00000, -0.50000, 0.50000, 0.50000},
        {0.00000, 0.00000, -1.00000, 0.00000, 0.00000, -0.50000, -0.50000, 0.50000},
        {0.00000, 0.00000, 1.00000, 0.00000, 0.00000, 0.50000, -0.50000, 0.50000},
        {0.00000, 0.00000, 1.00000, 0.00000, 0.00000, 0.50000, 0.50000, 0.50000},
        {0.00000, 0.00000, 1.00000, 0.00000, 0.00000, 0.50000, 0.50000, -0.50000},
        {0.00000, 0.00000, 1.00000, 0.00000, 0.00000, 0.50000, -0.50000, -0.50000},
        {0.00000, 0.00000, 0.00000, 1.00000, 0.00000, -0.50000, 0.50000, 0.50000},
        {0.00000, 0.00000, 0.00000, 1.00000, 0.00000, -0.50000, 0.50000, -0.50000},
        {0.00000, 0.00000, 0.00000, 1.00000, 0.00000, 0.50000, 0.50000, -0.50000},
        {0.00000, 0.00000, 0.00000, 1.00000, 0.00000, 0.50000, 0.50000, 0.50000},
        {0.00000, 0.00000, 0.00000, -1.00000, 0.00000, -0.50000, -0.50000, -0.50000},
        {0.00000, 0.00000, 0.00000, -1.00000, 0.00000, -0.50000, -0.50000, 0.50000},
        {0.00000, 0.00000, 0.00000, -1.00000, 0.00000, 0.50000, -0.50000, 0.50000},
        {0.00000, 0.00000, 0.00000, -1.00000, 0.00000, 0.50000, -0.50000, -0.50000},
        };


int Box_index[Box_polygoncount][3]={
        {0, 1, 2},
        {2, 3, 0},
        {4, 5, 6},
        {6, 7, 4},
        {8, 9, 10},
        {10, 11, 8},
        {12, 13, 14},
        {14, 15, 12},
        {16, 17, 18},
        {18, 19, 16},
        {20, 21, 22},
        {22, 23, 20},
        };

EDIT: on closer inspection, it looks like this OpenGL Source Code Generator also does something useful with attributes, and I don't think Cheetah 3D does that.

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
Member
Posts: 114
Joined: 2005.03
Post: #3
This is not a finished code generator, it is a product requirement specification for such a code generator, which would have to be built by the people attending this particular course.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Noise generator reubert 7 4,824 Dec 27, 2007 12:57 PM
Last Post: reubert
  NEED HELP! OpenGL code for my exam doesn't work mr02077 2 2,777 Feb 9, 2007 05:44 PM
Last Post: stevejohnson
  SDL/OpenGL Initialization Code Nick 15 7,093 Sep 7, 2005 07:28 AM
Last Post: Nick
  OpenGL code optimization unknown 38 13,472 Jul 28, 2005 10:22 PM
Last Post: unknown
  bus error with opengl code mnorton 2 3,824 Jan 21, 2005 02:53 PM
Last Post: ThemsAllTook