Getting the color of specific texture coordinates?

Getting the color of specific texture coordinates?

Post by Hans Loeblic » Fri, 15 Nov 2002 09:59:51



I have a program in which I would like to be able to retreive the single
specific color of a texture, given some texture coordinates.
I suppose, if it is possible, the call would be something like:

glTexCoord2f(coord_x,coord_y);
glGetFloatv(GL_CURRENT_COLOR, color);

But I think this call only returns the color set by glColor.  How can I
"get" the current texture color?

As far as I can tell, the only way to do this is if I retrieved the
entire texture from opengl(using glGetTexImage), and then extract the
specific value from the array by myself, but I would prefer not to be
required to make a complete copy of an image that opengl is already
storing for me.  This seems incredibly wasteful.

Thanks
Hans Loeblich

 
 
 

Getting the color of specific texture coordinates?

Post by Jon Lee » Fri, 15 Nov 2002 10:28:23




Quote:>I have a program in which I would like to be able to retreive the single
>specific color of a texture, given some texture coordinates.
>I suppose, if it is possible, the call would be something like:

>glTexCoord2f(coord_x,coord_y);
>glGetFloatv(GL_CURRENT_COLOR, color);

>But I think this call only returns the color set by glColor.  How can I
>"get" the current texture color?

    There is no current texture color, in the sense of the color
associated with whatever the current texture coordinates are - only a
current *texture*.

    The GL was almost certainly given the texture from the client to
begin with, so I'm not clear on why you can't just use the client's
copy. But if not, you could turn off texture filtering and render a
point with a specific texture coordinate, then read back the single
pixel that results.

    Jon Leech
    SGI

 
 
 

Getting the color of specific texture coordinates?

Post by Dmitry Shulg » Fri, 15 Nov 2002 10:42:26



Quote:> I have a program in which I would like to be able to retreive the single
> specific color of a texture, given some texture coordinates.
> I suppose, if it is possible, the call would be something like:

> glTexCoord2f(coord_x,coord_y);
> glGetFloatv(GL_CURRENT_COLOR, color);

> But I think this call only returns the color set by glColor.  How can I
> "get" the current texture color?

> As far as I can tell, the only way to do this is if I retrieved the
> entire texture from opengl(using glGetTexImage), and then extract the
> specific value from the array by myself, but I would prefer not to be
> required to make a complete copy of an image that opengl is already
> storing for me.  This seems incredibly wasteful.

> Thanks
> Hans Loeblich

Depends what kind of coordinates of color pixel you want. If absolute then it is
a piece of a cake - you have your texture in memory as a buffer. So you simply
use it as a 1D array of elements of related width (1 for luminance, 3 for RGB, 4
for RGBA). Otherwise, if you meen a color of distorted texture, say, you map it
onto arbitrarily shaped polygon then it is pain in the butt.

-d

 
 
 

Getting the color of specific texture coordinates?

Post by Andy » Fri, 15 Nov 2002 11:26:38



> I have a program in which I would like to be able to retreive the single
> specific color of a texture, given some texture coordinates.
> I suppose, if it is possible, the call would be something like:

> glTexCoord2f(coord_x,coord_y);

glDrawQuad (...)
glReadPixels (...)

--
Andy V (OpenGL Alpha Geek)
"In order to make progress, one must leave the door to the unknown
ajar."
Richard P. Feynman, quoted by Jagdish Mehra in _The Beat of a Different
Drum_.

Paul Martz's OpenGL FAQ:
http://www.opengl.org/developers/faqs/technical.html

 
 
 

1. Getting texture coordinates

Hi,
        I am using SoVertexPrimitives and SoFaceDetails (and PointDetail)
to get the texture coordinate of vertices.
The texture coordinates are returned in object space (Vec4f).

I think I have to multiply the values from the SoTexture2Transform
in order to get the proper texture coordinates. My problem
is that I don't know how to interpret the fields. Scaling and translation
is easy, but how should use the center and rotation fields?

Thanks,

--
Ricardo Galli

Voice: +34 71 17 2968/3013/3000
Fax:   +34 71 17 3003
www: http://anim.uib.es/people/gallir.html

2. Evaluators and Colors

3. Using/Getting Texture coordinates

4. quadratic surface fit over adjacent triangles

5. Specific texture to specific zone, please...

6. Tons of software at low prices

7. Getting Coordinates in "Plane coordinate system"

8. CONVERSION: Quicktime -> MPEG

9. getting the texture color of an intersection point

10. Texture color gets changed

11. Getting pixel color of a texture

12. Specific coordinates screen capture