Thanks for your responses…
Look for glTexGen() in your favourite OpenGL reference (I use the spec PDF, which is available on the front page of this web site).
I did-- as far as I was able to tell, NOWHERE in the spec (I checked opengl1.2.1.pdf and glspec14.pdf) does the string glTexGen appear, it’s not in the index, and in fact there are NO functions that begin with gl in the index at all. I found a few such functions in the GLU pdf, but not in the OpenGL pdfs. After your post, I looked a bit more and did find there’s a “TexGen” function which seems to be what you are referring to-- how am I supposed to know this? Is there a note somewhere that says “the C functions all have gl appended to the front of them, despite what they are called in the spec?” The spec is some 300 pages long, I must have overlooked it. So far, my use of OpenGl has ben through the Delphi GLScene library, so I haven’t done much exploration at this level, I’ve been trying to figure out how I can adapt the cited demo to GLScene, or call the OpenGL functions directly from Delphi, and it appears I’m in pretty deep here…
Assuming the function TexGen is what you are talking about, I see the specification is pretty terse-- it cites five coordinate generation types-- OBJECT_LINEAR, EYE_LINEAR, SPHERE_MAP, REFLECTION_MAP and NORMAL_MAP. The demo apparently uses OBJECT_LINEAR, which in the spec is defined with:
If TEXTURE GEN MODE indicates OBJECT LINEAR, then the generation function
for the coordinate indicated by coord is
g = p1xo + p2yo + p3zo + p4wo:
xo, yo, zo, and wo are the object coordinates of the vertex. p1; : : : ; p4 are specified
by calling TexGen with pname set to OBJECT PLANE in which case params points
to an array containing p1; : : : ; p4. There is a distinct group of plane equation coefficients
for each texture coordinate; coord indicates the coordinate to which the
specified coefficients pertain.
Anyone care to translate that into english? And the use of S and T in the demo seems unclear-- I took them to mean x and y in the 2D texture coordinate space. It’s a bit less that obvious that the net effect is the projection onto an object which I mentioned, and it’s also not clear how that might apply to projecting a texture onto an object from an arbitrary direction, which I would think would be of particular interest. I realize the math is important, but if I don’t know what the math here is trying to accomplish, I can’t tell if it has any bearing on what I’m trying to do-- so I can spend hours trying all of these texture operations to see what they all do to figure it out, OR I can ask in a forum where (hopefully) there are those who have already been down that path and can shed a little more directional light on the subject…
No offence intended but how about actually reading the article at URL you posted thoroughly before posting. Even the OpenGL code to do the texgen is at the bottom of the page.
None taken-- the problem is I read the article and understand that the code works, but the part of the code that actually calculated the texture coordinates was not at all obvious to me from the demo, and when looking up the functions glTexGeni, glTexGenfv in the specs, found no mention of them. And in fact, there are no versions of these particular calls WITHOUT the “gl” prefix either, as there is in the case of TexGen, so I still don’t know where to look for their documentation. The comments in the demo implied that there is some hidden voodoo going on in at least one of the gl… calls:
The texture generation will map the currently bound caustic texture object onto every object in the scene based on its object coordinates. See the underwater.c source code for more details.
But it wasn’t clear to me what it was referring to when it says “the texture generation”-- that’s somewhat generic, it doesn’t say “the glTexGeni function” so for all I know it was deep in the glEnable(GL_TEXTURE_GEN_S) call where the elusive voodoo is occurring.
And this comment:
As the briefest aside, I’d like to point out that many other 3D APIs (Direct3D in particular though) lack the texture coordinate generation capability (present in OpenGL since release 1.0) that makes possible the object-coordinate texturing of the caustic patterns onto arbitary geometry.
Was tantalizing enough to tell me that the logic of interest was indeed in there but not enough to tell me just where and neither was the spec…
I’m coming at this from the GLScene API where most of the OpenGL calls are buried, having found an example of this effect which I’d REALLY like to translate into what I’m doing, and having little or no idea what is in OpenGL, what is in GLU, and what is in GLUT in the demo and trying to translate it into something that is even less documented than any of these (GLScene) which works at a completely different level. So I’m diving in the deep end before I’ve really learned to swim…
May thanks though, it seems to be getting a little less muddled the more I bang my head against it…
kazoo