summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2025-04-26 15:26:41 +0200
committerMitya Selivanov <automainint@guattari.tech>2025-04-26 15:26:41 +0200
commitc1864d9409c5e7f8df6c92f2b1a16c10cb44ae3c (patch)
treee43f8efde2530ff2aaa8d5d2d5679e433e575344
parentb91f3df6ad13228d993db27ff94433ba6ebce042 (diff)
downloadreduced_system_layer-c1864d9409c5e7f8df6c92f2b1a16c10cb44ae3c.zip
Data formats procs
-rw-r--r--runtime.c128
1 files changed, 116 insertions, 12 deletions
diff --git a/runtime.c b/runtime.c
index c91382d..73a1ac8 100644
--- a/runtime.c
+++ b/runtime.c
@@ -647,19 +647,24 @@ typedef struct {
i64 input_len;
i64 input_capacity;
i64 num_drop_files;
- i64 clipboard_text_len;
- i64 clipboard_image_width;
- i64 clipboard_image_height;
- i64 clipboard_image_len;
- i64 num_clipboard_sound_samples;
- i64 clipboard_sound_len;
vec4_f32 *pixels;
Input_Key *input;
Drop_File *drop_files;
- c8 *clipboard_text;
- vec4_f32 *clipboard_image;
- f32 *clipboard_sound;
+
+ i64 clipboard_text_len;
+ c8 *clipboard_text;
+
+ i64 clipboard_image_width;
+ i64 clipboard_image_height;
+ i64 clipboard_image_len;
+ vec4_f32 *clipboard_image;
+
+ i64 clipboard_sound_num_channels;
+ i64 clipboard_sound_sample_rate;
+ i64 clipboard_sound_num_samples;
+ i64 clipboard_sound_len;
+ f32 *clipboard_sound;
b8 key_down [MAX_NUM_KEYS];
b8 key_pressed [MAX_NUM_KEYS];
@@ -710,8 +715,16 @@ void queue_primary_sound(i64 delay_in_samples, i64 num_samples, f32 *frames);
// Networking
b8 network_open(u16 slot, Network_Address address, u16 *local_port);
-i64 network_recv(u16 slot, Network_Address address, i64 size, u8 *data, u16 *local_port, Network_Address *remote_address);
-i64 network_send(u16 slot, Network_Address address, i64 size, u8 *data, u16 *local_port);
+i64 network_recv(u16 slot, Network_Address address, i64 len, u8 *data, u16 *local_port, Network_Address *remote_address);
+i64 network_send(u16 slot, Network_Address address, i64 len, u8 *data, u16 *local_port);
+
+// Data formats
+b8 bmp_read_from_memory(i64 *width, i64 *height, i64 colors_len, vec4_f32 *colors, i64 src_len, u8 *src);
+b8 bmp_write_to_memory(i64 *dst_len, u8 *dst, i64 width, i64 height, i64 stride, vec4_f32 *colors);
+b8 ppm_read_from_memory(i64 *width, i64 *height, i64 colors_len, vec4_f32 *colors, i64 src_len, u8 *src);
+b8 ppm_write_to_memory(i64 *dst_len, u8 *dst, i64 width, i64 height, i64 stride, vec4_f32 *colors);
+b8 wav_read_from_memory(i64 *num_channels, i64 *sample_rate, i64 *num_samples, i64 frames_len, f32 *frames, i64 src_len, u8 *src);
+b8 wav_write_to_memory(i64 *dst_len, u8 *dst, i64 num_channels, i64 sample_rate, i64 num_samples, f32 *frames);
// Dynamic libraries
void dynamic_library_open (u16 slot, c8 *name);
@@ -2330,6 +2343,97 @@ static c16 *buffer_utf16_from_utf8_(c8 *s) {
// ================================================================
//
+// Data formats
+//
+// ================================================================
+
+b8 bmp_read_from_memory(i64 *width, i64 *height, i64 colors_len, vec4_f32 *colors, i64 src_len, u8 *src) {
+ // TODO
+
+ (void) width;
+ (void) height;
+ (void) colors_len;
+ (void) colors;
+ (void) src_len;
+ (void) src;
+
+ LOG_error("Not implemented.");
+ return 0;
+}
+
+b8 bmp_write_to_memory(i64 *dst_len, u8 *dst, i64 width, i64 height, i64 stride, vec4_f32 *colors) {
+ // TODO
+
+ (void) dst_len;
+ (void) dst;
+ (void) width;
+ (void) height;
+ (void) stride;
+ (void) colors;
+
+ LOG_error("Not implemented.");
+ return 0;
+}
+
+b8 ppm_read_from_memory(i64 *width, i64 *height, i64 colors_len, vec4_f32 *colors, i64 src_len, u8 *src) {
+ // TODO
+
+ (void) width;
+ (void) height;
+ (void) colors_len;
+ (void) colors;
+ (void) src_len;
+ (void) src;
+
+ LOG_error("Not implemented.");
+ return 0;
+}
+
+b8 ppm_write_to_memory(i64 *dst_len, u8 *dst, i64 width, i64 height, i64 stride, vec4_f32 *colors) {
+ // TODO
+
+ (void) dst_len;
+ (void) dst;
+ (void) width;
+ (void) height;
+ (void) stride;
+ (void) colors;
+
+ LOG_error("Not implemented.");
+ return 0;
+}
+
+b8 wav_read_from_memory(i64 *num_channels, i64 *sample_rate, i64 *num_samples, i64 frames_len, f32 *frames, i64 src_len, u8 *src) {
+ // TODO
+
+ (void) num_channels;
+ (void) sample_rate;
+ (void) num_samples;
+ (void) frames_len;
+ (void) frames;
+ (void) src_len;
+ (void) src;
+
+ LOG_error("Not implemented.");
+ return 0;
+}
+
+b8 wav_write_to_memory(i64 *dst_len, u8 *dst, i64 num_channels, i64 sample_rate, i64 num_samples, f32 *frames) {
+ // TODO
+
+ (void) dst_len;
+ (void) dst;
+ (void) num_channels;
+ (void) sample_rate;
+ (void) num_samples;
+ (void) frames;
+
+ LOG_error("Not implemented.");
+ return 0;
+}
+
+// ================================================================
+//
// PLATFORM-SPECIFIC CODE
//
// ================================================================
@@ -4006,7 +4110,7 @@ i32 handle_main_window_events(void) {
if (ev.xselectionrequest.target == _targets) {
b8 has_text = g_platform.clipboard_text_len > 0;
b8 has_image = g_platform.clipboard_image_width > 0 && g_platform.clipboard_image_height > 0;
- b8 has_sound = g_platform.num_clipboard_sound_samples > 0;
+ b8 has_sound = g_platform.clipboard_sound_num_samples > 0;
if (!has_text && !has_image && !has_sound)
XDeleteProperty(