Drawing on screen from raw image data


I have a fairly simple question which goes back to understanding the basics of how OF works. I have raw data coming in from a camera (unsigned char*). I know it’s 640x480, what I don’t know is whether it’s bpp.

I’ve been looking into ofImage, ofTexture, ofPixels… and seem to not understand what the easiest way would be to try and get the image drawn.

Using myTexture.loadData(pixelData, 640, 480, GL_RGB) and then myTexture.draw seems to do the trick, the problem is that I get 3 images drawn next to each other and the whole thing crashes after a few seconds. So I’m assuming GL_RGB is not the way to go, unfortunately nothing else works.

Thanks for the help in advance!

1 Like

Alright, so here’s what I ended up doing to get things working. Primarily I needed GL_LUMINANCE as a glformat.

In the header:

ofTexture myTexture;

in setup:

myTexture.allocate(640, 480, GL_LUMINANCE);

In update:

unsigned char* pixelData = (unsigned char*)cameraData.data;
myTexture.loadData(pixelData, 640, 480, GL_LUMINANCE);

In draw:

myTexture.draw(10, 10);