I’m trying to take a texture out of an IplImage structure. In the following code, try to ignore the OpenCV functions; I only included them to illustrate what I’m trying to do. However, the texture I come up with keeps displaying as a white image. Of all the example code I’ve seen, it always depicts loading in a picture from a file. So knowing that I’m trying to pass in pieces of a pre-made structure as a texture, am I missing something fundamental in my code?
//Cv Functions for working with a webcam
cvGrabFrame( capture );
frame = cvRetrieveFrame( capture );
//Resizes the IplImage frame into camTexture which is of a preset size (power of 2).
cvResize(frame, camTexture);
//Corrects flipping caused by the copy.
cvFlip(camTexture, NULL, 0);
glBindTexture(GL_TEXTURE_2D, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, camTexture->width, camTexture->height, 0, GL_RGB, GL_UNSIGNED_BYTE, camTexture->imageData);
explantions of code-snipets (at least, what I THINK they do):
camTexture->height : Part of the IplStructure indicating the height of the image (int).
camTexture->width : ditto… only for width.
camTexture->imageData : A “pointer to the aligned image date” (char*).
Any advice or insights? Anybody?