ofTexture question - read pixels values like ofImage.getColor()

Hi all. How to read color from ofTexture (equivalent to ofImage.getColor() ) ?

ofTexture exists on the graphics card, so getting data into RAM requires moving from gpu to cpu, (either direction, cpu->gpu or gpu->cpu is a bit of a bottleneck). that said, ofTexture objects have a readToPixels() function, which reads back the data into an ofPixels object which might help?

1 Like

Clear answer :ok_hand:
Thank you zach !

While it’s a paradigm shift … and ultimately depends on your application you might consider manipulating the colors directly on the graphics card using a shader. If you need the pixel value as a number in order to do something with the CPU (like trigger a sound or tweet a message … ), then you’ll need to go the readToPixels() route that @zach mentioned.

Shader is difficult for my level of OpenGL knowledge… I just try to pas color from image to particles with ofImage.getColor() and worked, but I thought to try it with oftexture because of RAM ( is large image ).
Thank you @bakercp.

1 Like