summaryrefslogtreecommitdiff
path: root/examples/sinewave.c
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2025-01-14 06:33:54 +0100
committerMitya Selivanov <automainint@guattari.tech>2025-01-14 06:33:54 +0100
commitdced6f7768e02252af11f9b41017d75c66b47d81 (patch)
tree008f4cb816a09b776013d5903b34fb89c01cf042 /examples/sinewave.c
parentc9208089c6074575342d529f494295c13269a1aa (diff)
downloadreduced_system_layer-dced6f7768e02252af11f9b41017d75c66b47d81.zip
Correct examples for changed graphics procs
Diffstat (limited to 'examples/sinewave.c')
-rw-r--r--examples/sinewave.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/examples/sinewave.c b/examples/sinewave.c
index 3a127ae..4f8bbe0 100644
--- a/examples/sinewave.c
+++ b/examples/sinewave.c
@@ -3,7 +3,7 @@
i64 time_0 = 0;
i64 audio_samples = 0;
-f32 frames[AUDIO_SAMPLE_RATE * AUDIO_NUM_CHANNELS] = {0};
+f32 frames[SOUND_SAMPLE_RATE * NUM_SOUND_CHANNELS] = {0};
b8 ui_button(f64 x, f64 y, f64 width, f64 height) {
b8 has_cursor = g_platform.cursor_x >= x && g_platform.cursor_x < x + width &&
@@ -12,11 +12,11 @@ b8 ui_button(f64 x, f64 y, f64 width, f64 height) {
b8 is_pressed = has_cursor && g_platform.key_down[BUTTON_LEFT];
if (is_pressed)
- fill_rectangle(OP_SET, (vec3_f32) { 1.f, 1.f, 1.f }, x, y, width, height);
+ fill_rectangle(RGB(1.f, 1.f, 1.f), x, y, width, height);
else if (has_cursor)
- fill_rectangle(OP_SET, (vec3_f32) { .8f, .8f, 0.f }, x, y, width, height);
+ fill_rectangle(RGB(.8f, .8f, 0.f), x, y, width, height);
else
- fill_rectangle(OP_SET, (vec3_f32) { .8f, .8f, .2f }, x, y, width, height);
+ fill_rectangle(RGB(.8f, .8f, .2f), x, y, width, height);
return has_cursor && g_platform.key_pressed[BUTTON_LEFT];
}
@@ -25,13 +25,13 @@ void update_and_render_frame(void) {
i32 num_events = p_handle_events();
if (num_events > 0) {
- fill_rectangle(OP_SET, (vec3_f32) { .1f, .1f, .1f }, 0, 0, g_platform.frame_width, g_platform.frame_height);
+ fill_rectangle(RGB(.1f, .1f, .1f), 0, 0, g_platform.frame_width, g_platform.frame_height);
if (ui_button(100, 100, 200, 200))
- p_queue_sound(0, AUDIO_SAMPLE_RATE, frames);
+ p_queue_sound(0, SOUND_SAMPLE_RATE, frames);
}
- i64 samples_elapsed = ((p_time() - time_0) * AUDIO_SAMPLE_RATE) / 1000 - audio_samples;
+ i64 samples_elapsed = ((p_time() - time_0) * SOUND_SAMPLE_RATE) / 1000 - audio_samples;
audio_samples += samples_elapsed;
p_handle_audio(samples_elapsed);
@@ -50,8 +50,8 @@ i32 main(i32 argc, c8 **argv) {
f64 frequency = 440.;
- for (i64 i = 0; i < AUDIO_SAMPLE_RATE; ++i) {
- f64 t = ((f64) i) / AUDIO_SAMPLE_RATE;
+ for (i64 i = 0; i < SOUND_SAMPLE_RATE; ++i) {
+ f64 t = ((f64) i) / SOUND_SAMPLE_RATE;
f64 x = sin(t * (M_PI * 2.) * frequency);
if (t < .005)
x *= t / .005;