njin
Engine 2D gọn nhẹ để tự tay làm game theo ý mình. Vibe coding cũng ổn luôn
Loading...
Searching...
No Matches
njin_video.h
1#pragma once
2#include "_math.h"
3#include "_types.h"
4#include "njin_audio.h"
5
6namespace njin {
7struct context;
8
11
20struct video_desc {
21 const char *path = nullptr;
22 bool loop = false;
23 bool play = true;
24 bool audio = true;
26 f32 volume = 1.0f;
27};
28
36video_handle video_open(context &ctx, const video_desc &desc);
37
41void video_close(context &ctx, video_handle handle);
42
46void video_play(context &ctx, video_handle handle);
47
51void video_pause(context &ctx, video_handle handle);
52
57bool video_playing(const context &ctx, video_handle handle);
58
63bool video_finished(const context &ctx, video_handle handle);
64
69void video_seek(context &ctx, video_handle handle, f32 seconds);
70
75f32 video_time(const context &ctx, video_handle handle);
76
81f32 video_duration(const context &ctx, video_handle handle);
82
87void video_set_loop(context &ctx, video_handle handle, bool loop);
88
93void video_set_volume(context &ctx, video_handle handle, f32 volume);
94
99vec2 video_size(const context &ctx, video_handle handle);
100
105f32 video_framerate(const context &ctx, video_handle handle);
106
112bool video_has_audio(const context &ctx, video_handle handle);
113
118i32 video_frame_count(const context &ctx, video_handle handle);
119
126texture_handle video_texture(const context &ctx, video_handle handle);
127
133void video_draw(const context &ctx, video_handle handle, rect dest, rgba tint = {1.0f, 1.0f, 1.0f, 1.0f});
134
141void video_draw_fit(const context &ctx, video_handle handle, rect area, rgba bars = {0.0f, 0.0f, 0.0f, 1.0f});
143} // namespace njin
audio_bus
Kênh trộn âm thanh, như thanh trượt trong menu cài đặt của game.
Definition njin_audio.h:17
@ bus_music
Nhạc nền (mọi music).
Definition njin_audio.h:19
std::int32_t i32
Số nguyên có dấu 32 bit.
Definition _types.h:14
float f32
Số thực 32 bit.
Definition _types.h:28
void video_set_loop(context &ctx, video_handle handle, bool loop)
Bật tắt phát lặp.
vec2 video_size(const context &ctx, video_handle handle)
Cỡ hình, pixel.
bool 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.
void video_pause(context &ctx, video_handle handle)
Tạm dừng; hình đứng ở frame hiện tại.
void video_set_volume(context &ctx, video_handle handle, f32 volume)
Đặt âm lượng riêng của video, 0..1.
bool 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.
bool video_playing(const context &ctx, video_handle handle)
Video có đang phát không.
f32 video_time(const context &ctx, video_handle handle)
Đang ở giây thứ mấy.
f32 video_duration(const context &ctx, video_handle handle)
Video dài bao nhiêu giây.
void 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 video_seek(context &ctx, video_handle handle, f32 seconds)
Nhảy tới giây seconds.
i32 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.
f32 video_framerate(const context &ctx, video_handle handle)
Số frame hình mỗi giây của file.
void video_play(context &ctx, video_handle handle)
Phát tiếp (hoặc phát lại từ đầu nếu đã hết).
void 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 ...
video_handle video_open(context &ctx, const video_desc &desc)
Mở một video.
void video_close(context &ctx, video_handle handle)
Đóng video, giải phóng texture và tiếng của nó.
texture_handle video_texture(const context &ctx, video_handle handle)
Texture chứa frame hình hiện tại.
Hình chữ nhật thẳng trục: pos là góc trên trái, size là rộng và cao.
Definition _math.h:13
Màu gồm đỏ, xanh lá, xanh dương và alpha.
Definition _types.h:64
Định danh của một texture, tạo bởi texture_load().
Definition _types.h:146
Vector 2 chiều. Dùng cho vị trí, kích thước, độ dời.
Definition _types.h:39
Cách mở một video bằng video_open().
Definition njin_video.h:20
bool audio
Phát tiếng (nếu file có tiếng và máy có thiết bị âm thanh).
Definition njin_video.h:24
f32 volume
Âm lượng riêng, 0..1, nhân với kênh và bus_master.
Definition njin_video.h:26
bool play
Phát ngay khi mở. false là mở rồi đứng ở hình đầu.
Definition njin_video.h:23
bool loop
Hết thì phát lại từ đầu.
Definition njin_video.h:22
audio_bus bus
Kênh âm lượng của tiếng (audio_set_bus_volume()).
Definition njin_video.h:25
const char * path
File .mpg, tìm như mọi asset.
Definition njin_video.h:21
Định danh của một video, mở bởi video_open().
Definition _types.h:293