import .x file

Is it possible to import a 3d studio max file, probably exported as .x (like in some game engines) to be rendered in OpenGL? How?

My thanks in advanced

Of course!

By writing an importer.

Can you give me any reference or link so that i can read as an example?


Having coded an x-importer, i found this page most informative:

First of all, google for the “x file format”. There are several articles that explain how the file format works in general.

When you then want to know the details, to implement it, that msdn-page will be very valuable.

The format is actually quite straight-forward to understand, but implementing an importer is a bit of work.


This article should help Loading and displaying .X files without DirectX… Its a bit old, but it still renders X files in OpenGL. It basically goes into the file format in more detail, and example code to load a model.

Thanks for all your answers.
I see this is not an easy task. Is there any other way, maybe a most common way to add 3d Studio Max or Maya objects, to OpenGL and control them?

Nope. OpenGL does not provide any built-in mechanisms. It allows you to render stuff. Where you get the data from, and how that is stored etc. is not a concern of OpenGL. So no matter what format you are trying to use, be it for models, textures, animations, whatever, you always need to write your own importers (or use other peoples importers, if there are any).

Part of the reason is, that there is no “standard” way to render your stuff. Someone might use VBOs, someone else uses display lists, the layout of the data can change, depending on your needs etc., so having ONE importer is usually not possible, because everyone has different needs how to render things.


You could also write your own exporter (3d modeller) and importer (openGL)…

I’ve my own exporter for blender (with python), that exports ertices,UVs and animations…

I think thats the “easiest” ^^

I think thats the “easiest”

Technically, what would be “easiest” is if Blender had a decent exporter to Collada, which has a specific and well-documented format. Then you can write an offline tool to convert this into whatever format you want.