I am working on a Java-application that makes use of processing for OpenGL. In fact, I am using mt4j-Framework which integrates the handling of touch events, since the final application is supposed to be running on a touchscreen. Anyhow, it doesn't matter if the framework is familiar to you - the crucial part is that it uses processing to display GL-content.
The problem which I haven't been able to solve is the following: I'm getting PImages from my webcam and want to display those on a simple rectangular plane.
This is what I do before drawing the whole scene and after setting up the cameras:
myImg.loadPixels(); //myImg is a PImage
myImg.getCameraFrame(myImages.pixels, 0); //function for my webcam to grab the current image
rectangle.setTexture(myImg); //function of the framework that sets up myImg as a texture for the rectangle-object
This, however, does not work. There is no texture being displayed on the rectangular plane. On the other hand, the following code DOES work:
anotherImg = myApp.loadImage("test1.jpg");
So, if I save the image to disk and reload it afterwards, everything is fine - the webcam images are displayed properly. If I don't do that, but directly use the PImage that has been captured from the camera, they aren't displayed at all. Obviously, I cannot save and load on every frame because this is awful slow...
Can anybody help me out with this? Are there some properties for GLTextures that might be set in one case that aren't set in the other one? Or is there a different approach for the whole thing I could try out?
Thanks a lot for any kind of hint that might help me out!! I've searched the web again and again and just can't find a solution...
P.S.: This sketch uses the same webcam-API that I use. Here, it is no problem to use the just captured images directly - everything is displayed as intended. This is why I think that the OpenGL part of my program must be the problem...
// Camera Variables
CLCamera myCameras = new CLCamera;
PImage myImages = new PImage;
int cameraWidth = 640;
int cameraHeight = 480;
int cameraRate = 30;
// Animation Variables (not required)
boolean animate = false;
float zoomVal, zoomDelta;
float rotateVal, rotateDelta;
// Library loading via native interface (JNI)
// If you see "UnsatisfiedLinkError" then target the library path otherwise leave it commented out.