Two ofTexture objects seem too many

Hi! I’m posting this here 'cause I don’t know if it’s a bug (most likely not), or my ignorance (probably so…:slight_smile:

Playing with MovieGrabberExample, I came to the following situation: I can’t draw two different textures on screen.

I added a new texture, and want to draw it just right to the image inversion this example draws. But I can just draw one (texture) or the other, not both at the same time. I just get a black square on the texture that draws second (note: the app draws first vidGrabber.getFrame(), and then the textures.)

Am I just blocked by the stupidest problem ever? (ab-so-lute-ly plausible:)


hi pablo,

no worries! can you post a zip of the code and we can take a look at what you are doing?


Hi Zach, what part of the world are you at now? :frowning:

greetings from brooklyn!

aha – the problem is not with the texture, but with doing this call:

if (vidGrabber.isFrameNew()){  

twice in a row, because it’s basically a flag, which is getting set back to false after the first time that you call it.

if (vidGrabber.isFrameNew()){  
if (vidGrabber.isFrameNew()){  
// this will not get called ... because now the frame isn't new....  

if you combine the code to update the texture under one isFrameNew call, it should work. can you try that and let me know if that works?

take care,

A-ha! I new I was the “bugger”! :?
THX again

no – I think it’s not clear in the documentation…

the problem is that we are trying to make one thing fit into another, ie, making a “callback” type approach fit into a looping approach. There are, as I see it, several ways we could have done it:

a) every call to arePixelsNew sets them to be “old” (this is what we did)
b) ask the user to set the flag to old, ie (videoGrabber.setPixelsOld() )
c) use the frame counter to know if we are on a new frame or not
d) set new or not new every time you call grabFrame()

it might be that it makes more sense to roll with D or C. we will take a look at it and see if that makes sense for both videoGrabbing and videoPlaying.

in the meantime, we’ll try to make the docs clear …

thanks !!

Thanks so much for the feedback! You really help our projects move on.

I think documentation is always the best way to go. Please, say if you need anything. I’ll be glad to help.