How strange it is that I recently learned that the Cheerp C / C ++ compiler creates Web applications. These times are gone. One may be surprised at this. With great practice, C ++ decided to use it as an application development and so i’m stopped at WebGL graphics and the task is to create a MovieClip component or Movie.

Used component HTMLVideoElement for his animation, as well as HTMLImageElement for displaying large images. updateTexture() – function updates the texture of the movie after which it is drawn on the screen. Do not forget to initialize a component or variable with the InitTexture () function – initializing the texture for a complete explanation I will give it below and tell what it is described about.

void MovieClip::InitTexture() //init texture
tex = gl->createTexture(); //create texture
gl->activeTexture(gl->get_TEXTURE0()); //activation texture
gl->bindTexture(gl->get_TEXTURE_2D(), tex); //set bind texture
// let's assume all images are not a power of 2
Uint8Array *pixels = new Uint8Array(new int[0,255,0,255]); //create array pixels for send in texture GPU.
gl->texImage2D(gl->get_TEXTURE_2D(), 0, gl->get_RGBA(), 1, 1, 0, gl->get_RGBA(), gl->get_UNSIGNED_BYTE(), pixels);
gl->texParameteri(gl->get_TEXTURE_2D(), gl->get_TEXTURE_MIN_FILTER(), gl->get_NEAREST());
gl->texParameteri(gl->get_TEXTURE_2D(), gl->get_TEXTURE_MAG_FILTER(), gl->get_NEAREST());
gl->texParameteri(gl->get_TEXTURE_2D(), gl->get_TEXTURE_WRAP_S(), gl->get_CLAMP_TO_EDGE());
gl->texParameteri(gl->get_TEXTURE_2D(), gl->get_TEXTURE_WRAP_T(), gl->get_CLAMP_TO_EDGE());

You can watch a small sample which shows a small example of texture mapping and initialization.

Thank you! By!


Leave a Reply

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

Secured By miniOrange