Updating a texture as quickly as possible?

Hello All!

    I would like to know what the correct and most optimal method of updating textures on an object is. Essenitally I have an image which is on each rendering iteration available with new data in which I would like to use to update a texture. Looking through the forums it apeared as though I should be able to setup the texture as follows:

texture = new Texture();


ts1 = display.getRenderer().createTextureState();





and then in the simpleUpdate() method I should update the raster in the image, theimage, followed by a call to updateRenderState:


However the texture does not seem to update. If however within simpleUpdate()  I create a new texture using the image followed by setting the texture of the render state the texture does update.

Must I create a new texture object each time and use ts1.setTexture(texture) after updating the image data, or is there a more effecient way?

Another suggestion was to delete the texture from the texture state before calling cylinder.updateRenderState(). However this also didn't work, and rather just removed any texture from the object.

My graphics card is an nVidia 5600 incase that's the trouble. Thank you for your help :slight_smile:

[editing for clarity]

Hi people, I don’t know if its right to put screen shots of stuff on here like this, but just in case - here is a screen shot of streaming web camera live into JME using JMF to grab frames and the method above to stick it onto a textured surface, where a new texture is created and the texture state is updated on each iteration. I would love to know the more optimal approach, not requiring the texture object re-creation.

Thanks again :slight_smile:

Thank you! I will check it out!

OK ranewc, I think I made it sound a bit too easy…

What I meant is, it's possible to render directly to a buffer, and have it show up in the texture right away. However it's not completly automatic, so I pointed to LWJGLImageGraphics as an example of how to do it.

Then I thought, since you're using JMF anyway, I can write up a small example of how to let that very same LWJGLImageGraphics do all the hard work for you:


Thank you llama! you ROCK!

ranewc, can you post the exact code you use to init the webcam capture stuff and such in JMF? I'm working a bit on a JMF renderer plugin that renders onto a jME texture directly. Right now it only supports rendering with FOBS, but I'm trying to make it work with generic JMF input plugins as well. No garantuees that on the end of the day it'll work though :slight_smile:

Hi Llama,

  Sure thing, I should just neaten it up first though. I have two available classes which make use of either the pulling of the data or the pushing technique through JMF, but I'll neaten up the one which I use the most and works for me with a few different media types (webcam and some video types from files or other URLs).

Hopefully you will be able to neaten it up further and make it even more generic for all the supported video types.

You did see the topic in user showcase about my new video to texture renderer? All I want to do is test if it will work with a webcam as input source, so I'd just like the code on how you create the webcam on the input side, so I can see if it'll work.