I am new to OpenGL and and using it with OpenHaptics.
I have a polygon with a texture image applied to it.
I want modify the colors of a few pixels around the ‘haptic cursor’. Assume that the haptic cursor is just a point on the polygon. Someone told me to use Pixel Buffer Object (PBO) but I do not know what it is. I could not find it in the red book. I had an idea of using glReadPixels() and then change the contents of read data and use glDrawPixels() but I think it will be slower. What is the easiest way to do it?
I also cannot find a relationship between the pixel location on the window and the position of the cursor. The cursor location that I get is returned in terms of the x,y,z in glVertex(x,y,z).
thanks a lot in advance
If you know the position of the cursor in window coordinates, and if you know the size of your window, the easiest (and fastest) way is probably to switch to an orthographic projection and blend a second texture over the polygon.
glReadPixels and glDrawPixels are definitely going to be slow. You could also look at using glTexSubImage2D but you’ll need to keep a copy of your texture data in system memory and you’ll still be stuck with the problem of translating coords.
thanks mhagain, I researched both the issues: translating coords and the texture overlay as you indicated. Apparently with my knowledge of opengl and graphics there is no easy way that I know of at the moment.
so here is what I want to do now:
Pick a color from my texture by a mouse click. How do I do that?
Apply this color to a disk centered at the next click and make it translucent or semi transparent. How do I do it?
Thanks a lot
Could anyone guide me to a solution:
- Pick a color from a texture on a polygon by a mouse click?