Phát video MPEG-1 có tiếng: cutscene toàn màn hình, màn hình trong thế giới 3D. Tiếp...
Classes | |
| struct | njin::video_desc |
| Cách mở một video bằng video_open(). Tiếp... | |
Các hàm | |
| video_handle | njin::video_open (context &ctx, const video_desc &desc) |
| Mở một video. | |
| void | njin::video_close (context &ctx, video_handle handle) |
| Đóng video, giải phóng texture và tiếng của nó. | |
| void | njin::video_play (context &ctx, video_handle handle) |
| Phát tiếp (hoặc phát lại từ đầu nếu đã hết). | |
| void | njin::video_pause (context &ctx, video_handle handle) |
| Tạm dừng; hình đứng ở frame hiện tại. | |
| bool | njin::video_playing (const context &ctx, video_handle handle) |
| Video có đang phát không. | |
| bool | njin::video_finished (const context &ctx, video_handle handle) |
| Video đã phát hết chưa (không lặp và đã đến cuối): lúc chuyển cảnh sau cutscene. | |
| void | njin::video_seek (context &ctx, video_handle handle, f32 seconds) |
| Nhảy tới giây seconds. | |
| f32 | njin::video_time (const context &ctx, video_handle handle) |
| Đang ở giây thứ mấy. | |
| f32 | njin::video_duration (const context &ctx, video_handle handle) |
| Video dài bao nhiêu giây. | |
| void | njin::video_set_loop (context &ctx, video_handle handle, bool loop) |
| Bật tắt phát lặp. | |
| void | njin::video_set_volume (context &ctx, video_handle handle, f32 volume) |
| Đặt âm lượng riêng của video, 0..1. | |
| vec2 | njin::video_size (const context &ctx, video_handle handle) |
| Cỡ hình, pixel. | |
| f32 | njin::video_framerate (const context &ctx, video_handle handle) |
| Số frame hình mỗi giây của file. | |
| bool | njin::video_has_audio (const context &ctx, video_handle handle) |
| Video có phát tiếng không: file có tiếng, video_desc::audio bật và máy có thiết bị âm thanh. | |
| i32 | njin::video_frame_count (const context &ctx, video_handle handle) |
| Số frame hình đã hiện kể từ khi mở (tăng cả khi tua): để biết hình đã đổi chưa. | |
| texture_handle | njin::video_texture (const context &ctx, video_handle handle) |
| Texture chứa frame hình hiện tại. | |
| void | njin::video_draw (const context &ctx, video_handle handle, rect dest, rgba tint={1.0f, 1.0f, 1.0f, 1.0f}) |
| Vẽ frame hiện tại co giãn vào dest (2D, như texture_draw_ex()). | |
| void | njin::video_draw_fit (const context &ctx, video_handle handle, rect area, rgba bars={0.0f, 0.0f, 0.0f, 1.0f}) |
| Vẽ frame hiện tại vừa khít trong area, giữ tỉ lệ khung hình: phần thừa hai bên hay trên dưới tô bars (dải đen của cutscene toàn màn hình). | |
Phát video MPEG-1 có tiếng: cutscene toàn màn hình, màn hình trong thế giới 3D.
| video_handle njin::video_open | ( | context & | ctx, |
| const video_desc & | desc ) |
Mở một video.
Engine giải mã nó trong phase_post_update theo thời gian thật (không theo time_set_scale(), vẫn chạy khi game pause), hình và tiếng khớp nhau. Mỗi frame hình mới được chép vào texture của video (video_texture()).
| ctx | Context của engine. |
| desc | Cách mở. |
| void njin::video_close | ( | context & | ctx, |
| video_handle | handle ) |
Đóng video, giải phóng texture và tiếng của nó.
Handle không hợp lệ bị bỏ qua.
| ctx | Context của engine. |
| handle | Video. |
| void njin::video_play | ( | context & | ctx, |
| video_handle | handle ) |
Phát tiếp (hoặc phát lại từ đầu nếu đã hết).
| ctx | Context của engine. |
| handle | Video. |
| void njin::video_pause | ( | context & | ctx, |
| video_handle | handle ) |
Tạm dừng; hình đứng ở frame hiện tại.
| ctx | Context của engine. |
| handle | Video. |
| bool njin::video_playing | ( | const context & | ctx, |
| video_handle | handle ) |
Video có đang phát không.
| ctx | Context của engine. |
| handle | Video. |
| bool njin::video_finished | ( | const context & | ctx, |
| video_handle | handle ) |
Video đã phát hết chưa (không lặp và đã đến cuối): lúc chuyển cảnh sau cutscene.
| ctx | Context của engine. |
| handle | Video. |
| void njin::video_seek | ( | context & | ctx, |
| video_handle | handle, | ||
| f32 | seconds ) |
Nhảy tới giây seconds.
Hình hiện ngay là frame gần nhất trước chỗ đó.
| ctx | Context của engine. |
| handle | Video. |
| seconds | Thời điểm, giây, kẹp trong 0..video_duration(). |
| f32 njin::video_time | ( | const context & | ctx, |
| video_handle | handle ) |
Đang ở giây thứ mấy.
| ctx | Context của engine. |
| handle | Video. |
| f32 njin::video_duration | ( | const context & | ctx, |
| video_handle | handle ) |
Video dài bao nhiêu giây.
| ctx | Context của engine. |
| handle | Video. |
| void njin::video_set_loop | ( | context & | ctx, |
| video_handle | handle, | ||
| bool | loop ) |
Bật tắt phát lặp.
| ctx | Context của engine. |
| handle | Video. |
| loop | Lặp. |
| void njin::video_set_volume | ( | context & | ctx, |
| video_handle | handle, | ||
| f32 | volume ) |
Đặt âm lượng riêng của video, 0..1.
| ctx | Context của engine. |
| handle | Video. |
| volume | Âm lượng. |
| vec2 njin::video_size | ( | const context & | ctx, |
| video_handle | handle ) |
Cỡ hình, pixel.
| ctx | Context của engine. |
| handle | Video. |
| f32 njin::video_framerate | ( | const context & | ctx, |
| video_handle | handle ) |
Số frame hình mỗi giây của file.
| ctx | Context của engine. |
| handle | Video. |
| bool njin::video_has_audio | ( | const context & | ctx, |
| video_handle | handle ) |
Video có phát tiếng không: file có tiếng, video_desc::audio bật và máy có thiết bị âm thanh.
| ctx | Context của engine. |
| handle | Video. |
| i32 njin::video_frame_count | ( | const context & | ctx, |
| video_handle | handle ) |
Số frame hình đã hiện kể từ khi mở (tăng cả khi tua): để biết hình đã đổi chưa.
| ctx | Context của engine. |
| handle | Video. |
| texture_handle njin::video_texture | ( | const context & | ctx, |
| video_handle | handle ) |
Texture chứa frame hình hiện tại.
Vẽ nó như mọi texture (texture_draw_ex()), hay dán lên hình 3D (material3d::texture, model_material): màn hình TV, bảng quảng cáo. Texture thuộc về video: đừng texture_unload() nó; video_close() giải phóng.
| ctx | Context của engine. |
| handle | Video. |
| void njin::video_draw | ( | const context & | ctx, |
| video_handle | handle, | ||
| rect | dest, | ||
| rgba | tint = {1.0f, 1.0f, 1.0f, 1.0f} ) |
Vẽ frame hiện tại co giãn vào dest (2D, như texture_draw_ex()).
| ctx | Context của engine. |
| handle | Video. |
| dest | Vùng vẽ. |
| tint | Màu nhân vào hình. |
| void njin::video_draw_fit | ( | const context & | ctx, |
| video_handle | handle, | ||
| rect | area, | ||
| rgba | bars = {0.0f, 0.0f, 0.0f, 1.0f} ) |
Vẽ frame hiện tại vừa khít trong area, giữ tỉ lệ khung hình: phần thừa hai bên hay trên dưới tô bars (dải đen của cutscene toàn màn hình).
| ctx | Context của engine. |
| handle | Video. |
| area | Vùng, thường là cả màn hình. |
| bars | Màu dải thừa; trong suốt là không tô. |