   Generating texture coordinates
  Ok, developing and developing, it's time for texturing... I read something about texture coordinates all over the net, but many questions are still without an answer... 1. glTexGen* should be used to generate texture coodinates, but how I could use this 'offline', to save texture coordinates for a mesh? I mean, I thought I had to pass to a function a texture size (width, height), vertex coordinates (x,y,z) and a mode (for cube/sphere/etc mapping) to retrieve correct (u,v)... but it seems glTexGen* doesn't work as I expected... I suppose glTexGen* are used to specify what kind of coordinates I have to generate, while glTexGen*v should return values... but if it's the case... how should I specify what's the vertex to map in texture space? :(2. Is it possible to use glTexGen* with VertexArrays? I suppose so, but I can't figure how...3. Is there a tutorial/example about glTexGen*?4. Rendering animated meshes, I should compute 'offline' texture coordinates for each key frame, or it's better to let OpenGL generate them at runtime (if I didn't misunderstood glTexGen* usage... and it could be so...)?I find texturing not so easy as I thought, indeed... :P   
  Ok, I finally decided to consult my RedBook, founding some useful information... without clearing all my dubts... this is my first problem... RedBook says:--------------------------- RED BOOK -----------------------------------void glTexGen{ifd}(GLenum coord, GLenum pname, TYPEparam);void glTexGen{ifd}v(GLenum coord, GLenum pname, TYPE *param);Specifies the functions for automatically generating texture coordinates.The first parameter <...>The pname parameter is GL_TEXTURE_GEN_MODE, GL_OBJECT_PLANE, or GL_EYE_PLANE.If it's GL_TEXTURE_GEN_MODE, param is an integer (or, in the vector versionof the command, points to an integer) that's either GL_OBJECT_LINEAR,GL_EYE_LINEAR, or GL_SPHERE_MAP. These symbolic constants determine whichfunction is used to generate the texture coordinate.With either of the other possible values for pname, param is a pointer to an array of values (for the vector version) specifying parameters for thetexture-generation function.-----------------------------------------------------------------------So, it says that I can call glTexGen* or glTexGen*v, depending on my needs:I can use the first with GL_TEXTURE_GEN_MODE, specifying next what kind of mapping I intend to do, and setting up texture plane by the second function (the one accepting vectors).Now, reading I assumed that I could use glTexGen*(GL_S,GL_OBJECT_PLANE,...) [the not-vector form] but MSDN says definitely NOT:--------------------------- MSDN ------------------------------------void glTexGen*( GLenum coord, GLenum pname, GLdouble param);pname The symbolic name of the texture coordinategeneration function. Must be GL_TEXTURE_GEN_MODE.---------------------------------------------------------------------If my understanding are correct, MSDN is right, I can't call the not-vector-based function with a parameter different from GL_TEXTURE_GEN_MODE, since there is no int parameter associated to GL_OBJECT_PLANE or GL_EYE_PLANE...am I correct about this?So, the not-vector-based form, is only used to specify the texture coordinates generation function, the vector-based one is needed to define clip planes...And here lies my other dubt... how should I define this planes? To generate correct texture coordinates for a complex mesh (like a human body), what kind of planes I should define and, above all, why? I'd like to understand a bit more about it...Moreover, rendering dynamic scenes, is it too expansive to call glTexGen* every frame? Is it better to precompute texture coordinates (it can be easily done for object coordinates, but doing it for view coordinates is not so good, since every time modelview matrix changes I should recompute coordinates... --') or let OpenGL do this work for me? How professional programs handle this, if anybody knows (Since this is my first attempt to create a 3D engine, I don't want to create a professional product, but I'd like to know a bit more about this scenario)?Thnx in advance :D   ;  If your making a 3d engine that uses polygonal models I dont see why would you need glTexGen, as all the uv's are stored in the model format and you can just store them in your vertex class or structure (or in some other manner).   ;  Yes, but what if I would deal with dynamic meshes? In such a case texture coordinates should be calculated every time the mesh changes it's shape... Am I wrong? Moreover, what if the model I loaded has no texture coordinates? I would like to be able to generate them... that's why I'm asking informations about glTexGen, to go deeper and learn how to calculate them... that's why I'm asking now, how to define (what equation) texture planes... I know I can "copy" the function provided in the docs to calculate texture coordinates *offline* now, but I'd like to understand well what are that planes for, understanding the underlying math... :P   ;  TexGen is not magic, it can't map textures intelligently to any random animated mesh and have it work with whatever texture you provide. With models you'll want to load in texture coordinates that have been manually setup for use with a specific texture. Texture coordinates are usually static for animated meshes, unless you're specifically scrolling or warping the texture as well (like for water flow).TexGen is useful when you want to do on-the-fly placement of textures on existing geometry (like projecting flashlight textures or shadows) or when you want to add an environment map which constantly changes depending on the orientation of the model.   ;  Thanks, this is clear now... anyway, if someone could point me to an article/paper/book, about texture mapping theory, I would be glad :D   ;  orangytang is correct there is no magic solution getting texturecoordinats for a model is a timeconsuming + boring taskyour best bet for info is a modelling site eg try www.polycount.com   ;  Thnx, I'll look at it! :P   