Hello! I will present a small class that displays a sprite on a WebGL screen with a texture: As promised, I am opening you the MovieClip class for WebGL. To initialize the class, use the following:

clip = new MovieClip(gl,2036,2032);
clip->loadSprite("background.jpg",0);
clip->loadMovieClip("video.webm",1);

You need to add an event to download:

Image event

clip->getImageElement()->addEventListener("load",cheerp::Callback(isImageLoaded));

Video event

clip->getVideoElement()->addEventListener("loadeddata",cheerp::Callback(onAnimLoad));

Sample event image loaded

void Scene::isImageLoaded(Event* e)
{
HTMLImageElement* target=(HTMLImageElement*)e->get_target();
int clipIndex = parseInt(target->getAttribute("clipID"));
target->removeEventListener("load",cheerp::Callback(isImageLoaded));
clip->set_timeupdate(true);
clip->set_playing(true);
clip->checkReady();
clip->updateTexture();
}

There are other options for adding a boot event, I will try to use this trick in other lessons.

Visit on my GitHub

K.games

By K.games

Leave a Reply

Your email address will not be published. Required fields are marked *

Secured By miniOrange