Provided a convex shape A, which is composed by 100 triangles: A1, A2, ... A100; and RGB values of the 10,000 pixels inside this convex shape A have been extracted.
Now, I adjusted some of the shape vertexes, which brings me a new shape B, which is composed by another 100 triangles: B1, B2, B100. These triangles are sequentially corresponding to the above 100 triangles A1, A2... A100 .
Now, I would like to do a warp over the whole shape from A to B.
(I think until now, OpenGL can do it. )
Finally, I would like to extract (interpolate or extrapolate) the RGB values of the corresponding 10,000 pixels inside shape B. (of course, if you show on the screen, there might be less or more pixels within shape B, but I just wonder whether there is a way in OpenGL, which may not let me do my own interpolationi or extrapolation)
I'm not sure whether OpenGL has a fuction like "warp", but I happened to find in Java Advanced Image, there is a "Warp" class.
I believe the following code might finish this warp task. (however, can we just don't display it to save the time??)
(Oh, yes, BTW, what should glTexCoord2f( ??, ??); refer to ?? )
Anyway, if we can do the warp using OpenGL speedily, how can we finally extracted those 10,000 pixels' RGB value? I really hope OpenGL has a very very fast method (function) to deal with this texture extraction.
Looking forward to your reply. If my description is still not clear, please do let me know.
Thanks for your kind and detailed reply. Thank you !!
Let me give a simple example due to my requirement.
A single triangle T1 is now warped into another one T2.
I sampled 1000 pixels inside triangle T1 and after warping, I still would like to have 1000 corresponding pixels within triangle T2, and those pixels' RGB values are going to be used for further calculation. Is that possible be done directly by OpenGL Render To Texture technology?
If no, I've got to the interpolation one pixel after another.
By the way, I don't even need the screen to show what's inside the triangle. I mean, to display everything on the screen is not a must, in order to save the computation time. In another word, I only need a kind of warp by calculation, rather than by display. I was suggested that using OpenGL should bring me faster speed, but I have been wondering how come?
Can you please give me some more explanation? Thanks
1) yes, to use the technology named "Render To Texture" seems to be the correct way out. However, can anybody give me a simple instruction, what is a "texture" defined in OpenGL? Is it just a "string"? Or a vector of RGB values? or something else like a data structure?
2) If a "texture" is a vector of RGB, which is attached to what's going to be rendered on the screen, will this "texture" be a fix size vector over all frames? Or, this "texture" size may change when the rendered image changes?
My shape is composed by around 100 triangles, and we can even simplify this issue, the shape composed by 100 triangles is a convex shape.
I'd love to know what are the pixel intensities of an image, with this shape, and store all pixel intensities in sequence (row by row, left to right) for later calculation.
That is my purpose. It looks like glReadPixels should work.
However, you mentioned that glReadPixels is to read the pixel value on the screen. How about if I don't display it (for speed issue) ? Is it possible for me to still read the pixels' RGB value without wasting the time on display this image ?
Finally, thank all for your prompt and kind reply. Seriously thanks!!!!