I think decay follows me whereever I go. В какой бы дом я не приходил, распад не заставляет себя ждать

This commit is contained in:
Андреев Григорий 2026-04-15 02:18:25 +03:00
parent 8d041d021d
commit 7ef20dbf56
5 changed files with 109 additions and 24 deletions

View File

@ -123,9 +123,12 @@ out/l2/r3: src/l2/tests/r3/r3.c $(HEADERS_src_l2) $(l_wl_protocols)
run_r3: out/l2/r3
./out/l2/r3
# Jesus sees your abomination
alice_bundle_link_flags := -lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype
out/l3/r4b: src/l3/r4/r4b.c $(HEADERS_src_l3) $(l_wl_protocols) $(ASSETS_gen_l_adele)
mkdir -p out/l3
$(cc) $(cflags) -o $@ $< $(xdg_shell_private_c) -lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype
$(cc) $(cflags) -o $@ $< $(xdg_shell_private_c) $(alice_bundle_link_flags)
.PHONY: run_r4b
run_r4b: out/l3/r4b
@ -143,7 +146,7 @@ clean:
# ------------------------ ИНОАГЕНТЫ --------------------------
out/l2/allie/glue.o: src/l2/allie_glue.c $(HEADERS_src_l2) $(xdg_shell_client_h) gen/l_adele/dorothy.txt $(HEADERS_gen_l2)
mkdir -p out/l2/allie
$(cc) $(cflags) -o $@ -c $< -lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype
$(cc) $(cflags) -o $@ -c $<
full_allie_obj := out/l2/allie/glue.o $(xdg_shell_private_o)
@ -158,7 +161,7 @@ find_hpp_cpp = $(shell find src/$(1) -type f -name '*.hpp' )
HEADERS_src_l1_allie_cpp := $(call find_hpp_cpp,l1/allie_cpp)
HEADERS_src_l2_allie_hpp := $(call find_hpp_cpp,l2/allie_cpp) gen/l1/allie_cpp/dorothy.txt
HEADERS_src_l3_allie_hpp := $(call find_hpp_cpp,l3/allie_cpp) $(HEADERS_src_l2_allie_hpp)
HEADERS_src_l3_allie_hpp := $(call find_hpp_cpp,l3/r4) $(HEADERS_src_l2_allie_hpp)
cxx_cpp := g++
cxxflags_cpp := -Wall -Wextra -Werror=return-type -Wno-unused-parameter \
@ -175,15 +178,14 @@ gen/l1/allie_cpp/dorothy.txt: out/l1/allie_cpp/codegen
out/l2/allie_cpp/glue.o: src/l2/allie_cpp/glue.c $(HEADERS_src_l2) $(xdg_shell_client_h) gen/l_adele/dorothy.txt $(HEADERS_gen_l2)
mkdir -p out/l2/allie_cpp/
$(cc) $(cflags) -o $@ -c $< -lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype
$(cc) $(cflags) -o $@ -c $<
full_allie_cpp_obj := out/l2/allie_cpp/glue.o $(xdg_shell_private_o)
# todo: add a call to a function that obtains all .hpp files from l2/allie_cpp
out/l3/allie_cpp/r4c: src/l3/r4/r4c.cpp $(HEADERS_src_l3_allie_hpp) $(full_allie_cpp_obj)
mkdir -p out/l3/allie_cpp
$(cxx_cpp) $(cxxflags_cpp) -o $@ $< $(full_allie_cpp_obj) \
-lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype
$(cxx_cpp) $(cxxflags_cpp) -o $@ $< $(full_allie_cpp_obj) $(alice_bundle_link_flags)
.PHONY: run_r4c
run_r4c: out/l3/allie_cpp/r4c
@ -225,8 +227,9 @@ run_r4c: out/l3/allie_cpp/r4c
# =============================================================
# ============================= РАСТ ==========================
rustflags := -L native=$(abspath out/l2/allie/) -l static=allie
rustflags := -L native=$(abspath out/l2/allie/) -l static=allie $(alice_bundle_link_flags)
.PHONY: target/debug/r4d
target/debug/r4d: src/l3/r4/r4d.rs $(full_allie_obj) out/l2/allie/liballie.a
mkdir -p out/l3/allie_rs
echo "$(rustflags)"

View File

@ -1,6 +1,2 @@
#include <stdlib.h>
#include <stdio.h>
void allie_funny_hello() {
printf("HIIIIII\n");
}
#include "alice/engine.h"
#include "alice/model_file.h"

View File

@ -1,12 +1,85 @@
/* *c_void is nothing special, it is the same as *u8 for example */
use std::ffi::{c_void};
type VoidPtr = *mut c_void;
#[repr(C)]
pub struct Vec2{
pub x: f32,
pub y: f32
}
#[repr(C)]
struct allie_AliceCallbacks{
guest: VoidPtr,
/* guest data, button, btn action */
on_wl_pointer_button: extern "C" fn (VoidPtr, u32, u32),
/* guest data, keysym, key action (wl_keyboard_key_state) */
on_wl_keyboard_key: extern "C" fn (VoidPtr, u32, u32),
/* guest data, passed time */
on_another_frame: extern "C" fn (VoidPtr, f32),
on_wl_pointer_motion: extern "C" fn (VoidPtr, Vec2),
}
unsafe extern "C" {
fn allie_funny_hello();
#[link_name="Alice_new"]
fn allie_Alice_new() -> *mut c_void;
#[link_name="Alice_mainloop"]
fn allie_Alice_mainloop(alice: VoidPtr, cb: *const allie_AliceCallbacks);
}
pub fn funny_hello() {
unsafe { allie_funny_hello(); }
pub struct Alice {
opa: *mut c_void,
}
pub fn funny_test(){
println!("HELLOOOO\nHELLOOOOOOOO :3");
}
pub struct AliceCallbacks {
pub on_wl_pointer_button: Box<dyn FnMut(u32, u32)>,
pub on_wl_keyboard_key: Box<dyn FnMut(u32, u32)>,
pub on_another_frame: Box<dyn FnMut(f32)>,
pub on_wl_pointer_motion: Box<dyn FnMut(Vec2)>,
}
extern "C" fn allie_AliceCallbacks_on_wl_pointer_button(dt: VoidPtr, button: u32, act: u32){
let cb: &mut AliceCallbacks = unsafe { &mut *(dt as *mut AliceCallbacks) };
(cb.on_wl_pointer_button)(button, act);
}
extern "C" fn allie_AliceCallbacks_on_wl_keyboard_key(dt: VoidPtr, keysym: u32, act: u32){
let cb: &mut AliceCallbacks = unsafe { &mut *(dt as *mut AliceCallbacks) };
(cb.on_wl_keyboard_key)(keysym, act);
}
extern "C" fn allie_AliceCallbacks_on_another_frame(dt: VoidPtr, fl: f32){
let cb: &mut AliceCallbacks = unsafe { &mut *(dt as *mut AliceCallbacks) };
(cb.on_another_frame)(fl);
}
extern "C" fn allie_AliceCallbacks_on_wl_pointer_motion(dt: VoidPtr, pos: Vec2){
let cb: &mut AliceCallbacks = unsafe { &mut *(dt as *mut AliceCallbacks) };
(cb.on_wl_pointer_motion)(pos);
}
impl Alice {
pub fn new() -> Self {
Alice{opa: unsafe { allie_Alice_new() }}
}
pub fn mainloop(&self, mut cb: AliceCallbacks) {
let guest_data = (&raw mut cb) as VoidPtr;
let a_cb = allie_AliceCallbacks {
guest: guest_data,
on_wl_pointer_button: allie_AliceCallbacks_on_wl_pointer_button,
on_wl_keyboard_key: allie_AliceCallbacks_on_wl_keyboard_key,
on_another_frame: allie_AliceCallbacks_on_another_frame,
on_wl_pointer_motion: allie_AliceCallbacks_on_wl_pointer_motion,
};
unsafe{ allie_Alice_mainloop(self.opa, &a_cb) };
}
}
impl Drop for Alice {
fn drop(&mut self) {
// todo: do something
}
}

View File

@ -284,7 +284,7 @@ void main_h_on_another_frame(void* data, float fl){
for (size_t i = 0; i < st->LS_state.len; i++) {
LightSourceState* ls = &st->LS_state.buf[i];
AliceAcknShinyMesh_set_inst(&st->LS_mesh->el, i, (ShinyMeshInstanceInc){
AliceAcknShinyMesh_set_inst(st->LS_mesh, i, (ShinyMeshInstanceInc){
.color_on = ls->color,
.model_t = marie_translation_mat4(ls->pos),
});
@ -293,7 +293,7 @@ void main_h_on_another_frame(void* data, float fl){
for (size_t i = 0; i < st->bullets_stuck_on_ROA.len; i++) {
vec3 bul_pos = st->bullets_stuck_on_ROA.buf[i];
AliceAcknShinyMesh_set_inst(&st->LS_mesh->el, st->LS_state.len + i, (ShinyMeshInstanceInc){
AliceAcknShinyMesh_set_inst(st->LS_mesh, st->LS_state.len + i, (ShinyMeshInstanceInc){
.color_on = (vec3){2, 0, 0},
.model_t = mat4_mul_mat4(mat4_mul_mat4(
RigidBodyState_get_tran_mat(&st->ROA_state),

View File

@ -1,6 +1,19 @@
use alice_and_misc::{funny_test, funny_hello};
use alice_and_misc::{*};
fn main() {
funny_test();
funny_hello();
let alice = Alice::new();
alice.mainloop(AliceCallbacks{
on_wl_pointer_button: Box::new(|_: u32, _: u32| {
println!("pointer button")
}),
on_wl_keyboard_key: Box::new(|_: u32, _: u32| {
println!("keyboard key");
}),
on_another_frame: Box::new(|_: f32| {
}),
on_wl_pointer_motion: Box::new(|_: Vec2| {
println!("pointer motion");
}),
})
}