kevin Posted July 9, 2015 Share Posted July 9, 2015 Let's say I have a video I'd like to play on a quad. What is the most efficient / preferred way to update a texture based on the current video frame? The snippet below is the best I've come up with so far, but it feels like a hack and only works with OpenGL (D3D11 crashes with a deallocation error). Is there a better way? Unigine::ImagePtr image = Unigine::Image::create(); Unigine::TexturePtr texture = material->getImageTexture(material->findTexture("diffuse")); texture->create2D(width, height, Unigine::Image::FORMAT_RGB8); texture->getImage(image); while(play_video) { unsigned char* texData = ... //Load raw pixel data image->setPixels(texData); texture->setImage(texImage); //engine update/render/swap ... } //where setPixels is a function I added to the Image.{h,cpp} source: void Image::setPixels(unsigned char *pixels) { data = pixels; } Link to comment
unclebob Posted July 10, 2015 Share Posted July 10, 2015 Hi Kevin! You can use a combination of ObjectGui / ObjectGuiMesh (https://developer.unigine.com/en/docs/1.0/scripting/library/objects/class.objectgui) and WidgetSpriteVideo (https://developer.unigine.com/en/docs/1.0/scripting/library/gui/class.widgetspritevideo). Link to comment
kevin Posted July 10, 2015 Author Share Posted July 10, 2015 Thanks unclebob, it looks like ObjectGuiMesh + WidgetSpriteVideo will do the job. Link to comment
Recommended Posts