Present frames and reset timing
ASPL 0.7.0 · Current release
Native only. Two window generations each present 30 frames at a target 60 FPS, changing sky blue to maroon halfway. Each prints time, frame time and FPS. The numeric values depend on the host. Success returns 0.
On this page
Prepare the native host
Native only, published ASPL 0.7.0. Two window generations each present 30 frames at a target 60 FPS, changing sky blue to maroon halfway. Each prints time, frame time and FPS. The numeric values depend on the host. Success returns 0.
Native installation · Drawing and input guide · API reference.
No source modules or data assets are required.
The page language is independent of source vocabulary. Download only supplied variants, with original filenames. Mixed-only programs are labelled in both locales; no source translation is generated.
Mixed source
Execution: Native only · ASPL 0.7.0
- Native ASPL 0.7.0 on x86_64 Linux with glibc 2.34 or later.
- Running needs a reachable Wayland/EGL or X11/GLX display and OpenGL 3.3 core; no system Raylib or C compiler is required. Checking and building need no display.
Input: No input lines are required.
No English source variant is supplied. Showing Mixed source as written; the source was not translated.
// Run with: aspl run docs/examples/raylib-frames.mixed.aspl
// Two brief clear-and-present loops show fresh timing after reopening.
import core::raylib;
استورد أساسي::رايليب.
fn draw_frames() -> i64 {
var frame: i64 = 0;
while frame < 30 {
let begun = raylib::ابدأ_الرسم();
if not begun::ok { print(begun::error::message); return 1; }
var color = raylib::SKYBLUE;
if frame >= 15 { color = رايليب::MAROON; }
let cleared = رايليب::ClearBackground(color);
if not cleared::ok { print(cleared::error::message); return 2; }
let ended = raylib::أنه_الرسم();
if not ended::ok { print(ended::error::message); return 3; }
frame = frame + 1;
}
let time = raylib::الزمن();
let delta = raylib::GetFrameTime();
let fps = رايليب::معدل_الإطارات();
if not time::ok or not delta::ok or not fps::ok { return 4; }
print("Frames / إطارات: time="); print(format_f64(time::value));
print(" frame="); print(format_f32(delta::value));
print(" fps="); print(format_i64(i64(fps::value))); print("\n");
return 0;
}
fn start_main() -> i64 {
let target = raylib::SetTargetFPS(60);
if not target::ok { print(target::error::message); return 1; }
var generation: i64 = 0;
while generation < 2 {
let opened = رايليب::هيئ_نافذة(640, 360, "ASPL frames / إطارات رايليب");
if not opened::ok { print(opened::error::message); return 2; }
if raylib::زمن_الإطار()::value not match 0.0 or raylib::GetFPS()::value not match 0 { return 3; }
let drawn = draw_frames();
if drawn not match 0 { return drawn; }
let closed = raylib::أغلق_النافذة();
if not closed::ok { print(closed::error::message); return 4; }
generation = generation + 1;
}
return 0;
}
Follow the Linux instructions to run this example. Download the source to keep a copy.
Download raylib-frames.mixed.asplExpected outcomes
{
"native": {
"check": 0,
"status": 0,
"behavior": {
"en": "Two window generations each present 30 frames at a target 60 FPS, changing sky blue to maroon halfway. Each prints time, frame time and FPS. The numeric values depend on the host. Success returns 0.",
"ar": "يعرض كل جيل من جيلي النافذة 30 إطارا بهدف 60 FPS، ويتغير الأزرق السماوي إلى العنابي في المنتصف. يطبع كل جيل الزمن وزمن الإطار وFPS. تعتمد القيم العددية على المضيف. يعيد النجاح 0."
}
}
}Commands and outcomes
Run from the directory containing the downloaded docs/ tree. Keep the generated .THIRD-PARTY-NOTICES companion when distributing the ELF program. Checking and building do not open a window. Running needs the stated graphics facilities.
mixed:
aspl check docs/examples/raylib-frames.mixed.aspl
aspl run docs/examples/raylib-frames.mixed.aspl
aspl build -o raylib-frames-mixed-program docs/examples/raylib-frames.mixed.aspl
./raylib-frames-mixed-program