3d model loading with OpenGL

Started by
0 comments, last by drago 24 years, 4 months ago
Hi,

Does anybody here know how to load a 3d model into an OpenGL application, no GLUT, using C/C++... I dont care if it's .3ds or .obj or whatever, as long as it works..

Thanks in advance...

------------------
Drago

osu!
Advertisement
Prepare some structures to receive your triangle and vertex information

something like this

typedef struct{
unsigned ver[3];
//insert texture coords, normals etc here
} tri_t;

typedef struct{
{
float pos[3];
} ver_t;

typedef struct{
unsigned numverts;
unsigned numtris;
ver_t *ver;
tri_t *tri;
} object_t;

then declare a struct of object_t type, load in a 3D object from the 3D modeller of your choice (you'll have to research the file format a little so you can extract the data you want), allocate memory for tris and vertices

(something like)

object.tri=malloc(sizeof(tri_t)*numtris);
object.ver=malloc(sizeof(ver_t)*numvers);

and load the data into your structures.

hope that helps

BW

after loading the file, make sure you allocate memory for the tri



____________________________________________________________www.elf-stone.com | Automated GL Extension Loading: GLee 5.00 for Win32 and Linux

This topic is closed to new replies.

Advertisement