PDA

View Full Version : dynamic textures help needed



Shahzad
10-10-2010, 12:05 PM
Hi,
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

mhagain
10-10-2010, 12:34 PM
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.

Shahzad
10-10-2010, 09:41 PM
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:

1. Pick a color from my texture by a mouse click. How do I do that?

2. 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

Shahzad
10-11-2010, 09:27 PM
Could anyone guide me to a solution:

1. Pick a color from a texture on a polygon by a mouse click?

thanks