how to read a .x file using opengl

I have some models which are in .x file.
I want to load them using opengl.
Does anyone know how to do it?
thanks

You don’t load using OpenGL. You draw using OpenGL. For loading, parse the file (if I remember correctly, it is ascii), and store into ram, then draw using GL.

Edit : google is your friend, here is the file format :
http://www.google.com/search?num=100&hl=…ctx&btnG=Search

then how to draw them?
I used a text editor to open the .x files,
see some points’ coord,
and I think it must have some format.
then how to draw it in opengl
thanks

you draw them the same way like you draw any other collection of triangles. if youre looking for a magic “glDrawXFile” function youre out of luck. same goes for “glDraw3dsFile” and “glDrawObjFile”. stuffing the geometry into arrays or buffers is your job, not opengls. an no, opengl doesnt automatically play any keyframed animations or does skinning all by itself. if thats what youre looking for then you need a 3d engine.

thanks.
Then I think I have to write such a function
glDrawXFile().
Is there any code implementing such function?
I have search for some thing like this, and find an article about this topic, but I can’t open that page!! :eek:
Does any one so generous to give me any help:>

Originally posted by Rubbish Kid:
I have search for some thing like this, and find an article about this topic, but I can’t open that page!! :eek:
Isn’t it hard to live in China sometimes ?
Try www.wotsit.org for file formats :
http://www.wotsit.org/download.asp?f=x
Or directly from Microsoft :
http://msdn.microsoft.com/archive/defaul…/FileFormat.asp

Thank you so much