Query Pixel data from texture

Hi all,

I am developing an algorithm for 3d modelling from 2d images. One of the approaches I thought would be to load textures into texture memory and subsequently query appropriate pixel data from the texture.

However, I do not know of a way to do so… and would be glad if somebody could help me on how to get pixel data from textures?

I am aiming to make my application fast and hence want to limit my use of glReadPixels(). Is there any quick alternative whereby I could get the color information of the pixel in question from texture itself…?

I know I am repeating myself, but its just that iam stuck…!

If I understood correctly, you want to fetch a texel (not pixel) from a texture to use in your app?

You don`t need to involved GL in this. Just do

mytexture[y*line+x]

for your texture that is in RAM.

i understand tht texels can be easily referenced in RAM, but i wish to mkae use of GPUs only…

trying to determine what is possible on the latest nVidia cards… and use it in my research.

I was also wonering, would pixel shaders or vertex shaders allow me to make such a query… what about Cg… would that help?..

Thanks for ur reply.

It’s in a fragment program (pixel shader) that you can fetch texels. You should read about it in the documents at ati and nvidia and read the registry
http://oss.sgi.com/projects/ogl-sample/registry/

You can learn Cg if you wish. It’s possible there too.

Thanks V-Man…

You’ve been a great help. Hopefully this should solve the problem… I have the Cg book with me and may start it soon… in the mean time would go through the docs at nVidia…

Cheers…

another approach would be to render a square with the texture applied, then do a glReadPixels to extract the value.

He wants to avoid glReadPixels (and also that’s really stupid if all you want to do is get some texels)

I can add that the next programmable hw will be able to access textures in VP. I saw that in some document about the next generation of D3D.

I’m wondering what’s the next step for GL.
Either ASM style is dead and HLSL all the way or their will be ARB_vertex_program2 ARB_fragment_program2.

I can add that the next programmable hw will be able to access textures in VP. I saw that in some document about the next generation of D3D.

Because texture accesses are exactly the kind of thing you want to do in a vertex program.

They should be working on getting us memory buffer that can be accessed (in a strictly non-texture-like fashion) from the vertex programs. The memory buffer API could actually be fast to upload new data to, rather than the texture API which is very slow. I want to be able to upload a sequence of matrices to the graphics hardware every frame for multiple characters. A VBO-esque buffer is more what is needed than a texture.

I think their choice for a texture buffer instead of a general one is that it somehow involves the need for the texture hw for doing filtering for LOD.

Don’t take my word for it. I can’t be certain.