Pointer Conversion

Hi guys,

Have a very basic question. I have a kinect video feed as an unsigned char* . How do I convert that to ofTexture* ?

I’ve tried typecasting and it doesn’t work: (ofTexture&)outputKinectFrame. Basically I need to replace the webcam feed (cam.getTextureReference()) with kinect.

Thanks much,

the typical use is like this:

ofTexture texture;
texture.allocate(yourImageWidth, yourImageHeight, GL_RGBA);

usigned char * data is usually pixels so you can do this:

unsigned char* yourData;
texture.loadData(yourData);

However the kinect is a bit different depending on what your data is as it can be from the video feed, depth feed or the IR feed. Each one of these has a different color format that you have to deal with.

You can take a look at ofxKinect and see how it deals with it internally

Thanks so much for the quick reply. How do I then convert ofTexture to ofTexture* ? Because I need a reference to pass to my shader.

ofTexture* texturePointer = &texture;

That worked. Thank you! Really appreciate it.