cf_video_texture¶
Category: video
GitHub: cute_video.h
The picture currently being shown, as a texture ready to draw.
| Parameters | Description |
|---|---|
video |
The video. |
Return Value¶
Returns a texture owned by the video.
Remarks¶
Created on the first call and re-uploaded only when the frame actually changes, so calling this every frame costs nothing extra. Do not call cf_destroy_texture on it; cf_destroy_video handles it. Requires the app to be running, like any other texture.
This is the one to feed a custom shader or a 3D draw. To simply put the video on screen with the 2D draw API, cf_video_sprite is fewer steps.
A custom 2D draw shader samples it the same way the 3D API does -- bind it by name:
cf_draw_push_shader(my_draw_shader);
cf_draw_set_texture("u_video", cf_video_texture(video));
cf_draw_box(box, 0, 0); // or any other draw call the shader covers
cf_draw_pop_shader();
Onto geometry with the 3D Draw API, bind it by the name its shader samples:
cf_video_update(video, CF_DELTA_TIME);
cf_draw3d_push_shader(my_shader);
cf_draw3d_set_texture("u_image", cf_video_texture(video));
cf_draw3d_mesh(screen_quad);
cf_draw3d_pop_shader();
A shader written for sprite-textured meshes works unchanged. in_uv_rect is the full
rect when no sprite is pushed, so mix(in_uv_rect.xy, in_uv_rect.zw, in_uv) reduces
to in_uv and the same code serves both. Which means cf_draw3d_push_texture with
cf_video_sprite also works -- it just sends the frames through the atlas, which is
the wrong place for something that changes every frame. Mesh v runs top-down: the top
edge of the quad takes v = 0. See samples/video.c.
Related Pages¶
CF_Video
cf_video_sprite
cf_video_update
cf_video_frame
CF_Texture
cf_draw3d_set_texture