How to display the texture coordinate of an object?

Say the object has n vertices and after a series of transf it has displayed on the screen.
then how to display their texture coordinates of these n vertices? or print out their list value?

The simplest way to visualize the texture coordiantes is to write them out as color in the fragment shader.

For 2D texture coordinates, the s component ends up in the red channel and the t component in the green
channel. More redish color means big s and rather small t, more green means small s and large t. Yellowish
colors means s and t are roughly equal with dark yellow being small values and bright yellow large values.

You can see the smooth transitions of the texture coordinates as they are interpolated over the triangle areas.

Of course, you could also use the texture coordinates to map a texture image onto the mesh. Something like a
debug texture with a regular grid on it.

Thanks, I wish to get their values coordiinates, not color. ntor take account of interpolate, either at present.
could you show a couple of code examples? or where can download that?

If you want to capture the output of the vertex shader, use transform feedback mode.

If you want something else, you’ll need to clarify your question.

[QUOTE=GClements;1266710]If you want to capture the output of the vertex shader, use transform feedback mode.

If you want something else, you’ll need to clarify your question.[/QUOTE]
Nor vertex shader output, either. just want to get the vertices’ texture coordinate values. This likes this,
A group of vertices of an object, through project to display on scteen.
glMatrixMode(GL_PROJECT); gkPerspective(…); glLoadIdentity();
glMatrixMode(GL_MODELVIEW); glLoadIdentity();
…then input vertices coordinate data…
ater cpu or gpu calculate, the object is projected on screen, Then how to get the its texture coordinate values?

If derive individually, I can use MmMpvec4f(…)^T; but how to get it from api command?

Texture coordinates are not in any way affected by the projection or modelview matrices (the texture matrices can, but you didn’t say if you’re setting them). So the texture coordinates will simply be whatever you passed.

The vertex positions are affected by the matrices. And yes, you can transform the positions in the way you describe.

Also:

glMatrixMode(GL_PROJECT); gkPerspective(...); glLoadIdentity();

The glLoadIdentity() here undoes the perspective projection matrix setup.

[QUOTE=Alfonse Reinheart;1266716]Texture coordinates are not in any way affected by the projection or modelview matrices (the texture matrices can, but you didn’t say if you’re setting them). So the texture coordinates will simply be whatever you passed.

The vertex positions are affected by the matrices. And yes, you can transform the positions in the way you describe.
.[/QUOTE]
Im aftraid, I make no sense of it. would u please show a sample?

lso:

glMatrixMode(GL_PROJECT); gkPerspective(...); glLoadIdentity();

The glLoadIdentity() here undoes the perspective projection matrix setu

Most of codes used to invoke it. it will calibrate center position.

btw, don’t show us how a sphere, cycline or cube map to texture coordinate. I know this mapping.

A sample of what? You asked how to get the texture coordinates you’re using to render something. I just said that, unless you’re using a texture matrix or texture coordinate generation, you already have those texture coordinates. You had to have them, because you were the one who passed them to OpenGL. And unless you’re using a texture matrix or coordinate generation, those texture coordinates will be used as is.

Now, if you’re concerned that what you think you’re passing isn’t what OpenGL’s actually getting, that’s one thing. But Agent D’s suggestion to simply render the texture coordinate values as colors would be sufficient to determine if the values are at least approximately what they ought to be.

Now, if you are using a texture matrix or texture coordinate generation (which should have been mentioned, since these are fairly rarely used features), that’s another matter entirely. Your only recourse is to read the OpenGL specification’s sections on whatever generation method you’re using, and mirror that mathematics in your code.

No, it does not. Other code call glLoadIdentity before calling gluPerspective. That’s the important point. It’s like doing this:


a = 5;
a = 0;

a isn’t 5 after this code is executed.

[QUOTE=Alfonse Reinheart;1266720]A sample of what? You asked how to get the texture coordinates you’re using to render something. I just said that, unless you’re using a texture matrix or texture coordinate generation, you already have those texture coordinates. You had to have them, because you were the one who passed them to OpenGL. And unless you’re using a texture matrix or coordinate generation, those texture coordinates will be used as is.

Now, if you’re concerned that what you think you’re passing isn’t what OpenGL’s actually getting, that’s one thing. But Agent D’s suggestion to simply render the texture coordinate values as colors would be sufficient to determine if the values are at least approximately what they ought to be.

Now, if you are using a texture matrix or texture coordinate generation (which should have been mentioned, since these are fairly rarely used features), that’s another matter entirely. Your only recourse is to read the OpenGL specification’s sections on whatever generation method you’re using, and mirror that mathematics in your code.

ecuted.[/QUOTE]

I seem to misunderstand or be misled by some articles copied from net. or may confused by these names, texture coor, d, tex map coord vertex tex coord…
now I think I make sense of them.

No, it does not. Other code call glLoadIdentity before calling gluPerspective. That’s the important point. It’s like doing this:

a = 5;
a = 0;

a isn’t 5 after this code is ex

I pay no attention to their order, is that mportatnt?
identify matrix is only unit matrix, then ME=M = EM; they are all the same no matter left multify or right.
your code example is quit incorrect,

glLoadIdenty does not multiply with the identity matrix (that would be completely pointless), it overwrites the current matrix with the
identity matrix. If you set up a perspective projection matrix and then call glLoadIdentity, it overwrites your perspective matrix with the
identity matrix.

[QUOTE=Agent D;1266729]glLoadIdenty does not multiply with the identity matrix (that would be completely pointless), it overwrites the current matrix with the
identity matrix. If you set up a perspective projection matrix and then call glLoadIdentity, it overwrites your perspective matrix with the
identity matrix.[/QUOTE]
You are right. It replaces the current matrix. but more efficient than call Identity matrix in some case.

returen to our topic. if opgl uses void glTexGen{if}(GLenum coord,GLenum pname,TYPE param) to produce automatiocally the tex coord.
How to print their value on the window?

If you don’t have access to NV_transform_feedback (which does allow for capturing fixed-function vertex processing outputs), then you will have to do what I said earlier. You have to look up exactly what the glTexGen functions are telling OpenGL to do per-vertex, then replicate that mathematics in your code.

That means there is no corresponding api to the situation. I have to repeat the whole process the glTexGen did? (for glTexGen() is void type.)

Yet, can we get the coordinate of the vertex at this state?(by some api)

but glGetTexGen — return texture coordinate generation parameters
seem to do the trick.

[QUOTE=reader1;1266742]That means there is no corresponding api to the situation. I have to repeat the whole process the glTexGen did? (for glTexGen() is void type.)

Yet, can we get the coordinate of the vertex at this state?(by some api)[/QUOTE]

No.

OpenGL is designed for processing information in one direction: from the user to the screen. OpenGL information processing is meant to flow in that direction, and all OpenGL processing is intended to support this idea.

Getting the texture coordinates used for a particular vertex is not something that fixed-function OpenGL can do.

but glGetTexGen — return texture coordinate generation parameters
seem to do the trick.

Seems to do what trick? You asked for texture coordinates. That function gets you texture coordinate generation parameters. If that “seems to do the trick”, then “the trick” was poorly explained.

glRenderMode(GL_FEEDBACK) will do that, sort of. However:

  • It reports “processed” geometry. Culled primitives aren’t reported, if quads or polygons are broken into triangles, it may report the triangles rather than the original primitives.

  • I wouldn’t bet heavily on it actually working on modern hardware.

If you want to do a lot of this sort of thing, you’re probably better off using shaders and transform feedback mode.

[QUOTE=Alfonse Reinheart;1266758]No.

OpenGL is designed for processing information in one direction: from the user to the screen. OpenGL information processing is meant to flow in that direction, and all OpenGL processing is intended to support this idea.

Getting the texture coordinates used for a particular vertex is not something that fixed-function OpenGL can do.
.[/QUOTE]
one or bidirection is not a problem. how that it can cope with memory, we can read out it from it.
and now that api can produce automatically texture coordinates it must be able to find the corresponding relation to a special vertex. As the object is made of a series of vertices.

Seems to do what trick? You asked for texture coordinates. That function gets you texture coordinate generation parameters. If that “seems to do the trick”, then “the trick” was poorly explained

certainly seems to find the tex values.So, what is tex coord geneation params? Does it include coordinate value? or we can solve the equation to get the value?