Still hadn't completely wrote C++ part of interface, I am not ready for rust part yet
This commit is contained in:
parent
0808250637
commit
8d041d021d
3
.gitignore
vendored
3
.gitignore
vendored
@ -17,4 +17,5 @@ GRAPH*.png
|
||||
SICK_JOKE*
|
||||
*.hi
|
||||
*_stub.h
|
||||
copying_to_cpp.sh
|
||||
copying_to_cpp.sh
|
||||
target
|
||||
14
Cargo.lock
generated
Normal file
14
Cargo.lock
generated
Normal file
@ -0,0 +1,14 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "alice_and_misc"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "daria"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"alice_and_misc",
|
||||
]
|
||||
11
Cargo.toml
Normal file
11
Cargo.toml
Normal file
@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "daria"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[[bin]]
|
||||
name = "r4d"
|
||||
path = "src/l3/r4/r4d.rs"
|
||||
|
||||
[dependencies]
|
||||
alice_and_misc = {path = "src/l2/allie_rs"}
|
||||
75
Makefile
75
Makefile
@ -123,7 +123,7 @@ out/l2/r3: src/l2/tests/r3/r3.c $(HEADERS_src_l2) $(l_wl_protocols)
|
||||
run_r3: out/l2/r3
|
||||
./out/l2/r3
|
||||
|
||||
out/l3/r4b: src/l3/r4/r4.c $(HEADERS_src_l3) $(l_wl_protocols) $(ASSETS_gen_l_adele)
|
||||
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
|
||||
|
||||
@ -139,6 +139,17 @@ 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
|
||||
|
||||
full_allie_obj := out/l2/allie/glue.o $(xdg_shell_private_o)
|
||||
|
||||
out/l2/allie/liballie.a: $(full_allie_obj)
|
||||
ar rcs $@ $^
|
||||
|
||||
# -------------------------------------------------------------
|
||||
# =============================================================
|
||||
# ====================== ПЛЮСЫ ================================
|
||||
@ -146,6 +157,8 @@ clean:
|
||||
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)
|
||||
|
||||
cxx_cpp := g++
|
||||
cxxflags_cpp := -Wall -Wextra -Werror=return-type -Wno-unused-parameter \
|
||||
@ -167,8 +180,7 @@ out/l2/allie_cpp/glue.o: src/l2/allie_cpp/glue.c $(HEADERS_src_l2) $(xdg_shell_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 src/l1/allie_cpp/utils.hpp \
|
||||
src/l2/allie_cpp/alice.hpp $(full_allie_cpp_obj)
|
||||
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
|
||||
@ -185,26 +197,45 @@ run_r4c: out/l3/allie_cpp/r4c
|
||||
# =============================================================
|
||||
# ========================== ХАСКЕЛЬ ==========================
|
||||
|
||||
find_haskell_hs = $(shell find src/$(1) -type f -name '*.hs' )
|
||||
|
||||
# Whoever needs this will also need out/l_wl_protocols
|
||||
out/l2/allie_hs/glue.o: src/l2/allie_hs/glue.c $(HEADERS_src_l2) $(xdg_shell_client_h) gen/l_adele/dorothy.txt $(HEADERS_gen_l2)
|
||||
mkdir -p out/l2/allie_hs/
|
||||
$(cc) $(cflags) -o $@ -c $< -lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype
|
||||
|
||||
full_allie_hs_obj := out/l2/allie_hs/glue.o $(xdg_shell_private_o)
|
||||
|
||||
# todo: write a function that gets all .hs files from l2/allie_hs. Call it
|
||||
out/l3/allie_hs/r4: src/l3/r4/R4.hs src/l2/allie_hs/Alice.hs \
|
||||
src/l2/allie_hs/Geom.hs $(full_allie_hs_obj)
|
||||
mkdir -p out/l3/allie_hs
|
||||
ghc -isrc/l2/allie_hs -hidir out/l3/ -odir out/l3 -o $@ $< $(full_allie_hs_obj) \
|
||||
-lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype
|
||||
|
||||
.PHONY: run_r4
|
||||
run_r4: out/l3/allie_hs/r4
|
||||
./out/l3/allie_hs/r4
|
||||
#find_haskell_hs = $(shell find src/$(1) -type f -name '*.hs' )
|
||||
#
|
||||
## Whoever needs this will also need out/l_wl_protocols
|
||||
#out/l2/allie_hs/glue.o: src/l2/allie_hs/glue.c $(HEADERS_src_l2) $(xdg_shell_client_h) gen/l_adele/dorothy.txt $(HEADERS_gen_l2)
|
||||
# mkdir -p out/l2/allie_hs/
|
||||
# $(cc) $(cflags) -o $@ -c $< -lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype
|
||||
#
|
||||
#full_allie_hs_obj := out/l2/allie_hs/glue.o $(xdg_shell_private_o)
|
||||
#
|
||||
## todo: write a function that gets all .hs files from l2/allie_hs. Call it
|
||||
#out/l3/allie_hs/r4: src/l3/r4/R4.hs src/l2/allie_hs/Alice.hs \
|
||||
# src/l2/allie_hs/Geom.hs $(full_allie_hs_obj)
|
||||
# mkdir -p out/l3/allie_hs
|
||||
# ghc -isrc/l2/allie_hs -hidir out/l3/ -odir out/l3 -o $@ $< $(full_allie_hs_obj) \
|
||||
# -lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype
|
||||
#
|
||||
#.PHONY: run_r4
|
||||
#run_r4: out/l3/allie_hs/r4
|
||||
# ./out/l3/allie_hs/r4
|
||||
|
||||
# ========================== ХАСКЕЛЬ ВСЁ ======================
|
||||
# =============================================================
|
||||
# -------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------------
|
||||
# =============================================================
|
||||
# ============================= РАСТ ==========================
|
||||
|
||||
rustflags := -L native=$(abspath out/l2/allie/) -l static=allie
|
||||
|
||||
target/debug/r4d: src/l3/r4/r4d.rs $(full_allie_obj) out/l2/allie/liballie.a
|
||||
mkdir -p out/l3/allie_rs
|
||||
echo "$(rustflags)"
|
||||
RUSTFLAGS="$(rustflags)" cargo build --bin r4d
|
||||
|
||||
.PHONY: run_r4d
|
||||
run_r4d: target/debug/r4d
|
||||
./target/debug/r4d
|
||||
|
||||
# ========================== РАСТ ВСЁ =========================
|
||||
# =============================================================
|
||||
# -------------------------------------------------------------
|
||||
|
||||
@ -246,5 +246,6 @@ void l1_generate_geom_hpp() {
|
||||
}
|
||||
}
|
||||
}
|
||||
std::filesystem::create_directories("l1/allie_cpp");
|
||||
write_text_file("l1/allie_cpp/geom.hpp", res);
|
||||
}
|
||||
|
||||
@ -33,11 +33,6 @@ struct allie_VecU32 {
|
||||
U64 capacity;
|
||||
};
|
||||
|
||||
struct allie_VecU8 {
|
||||
const U8* buf;
|
||||
U64 len;
|
||||
};
|
||||
|
||||
struct U32Segment {
|
||||
U32 start;
|
||||
U32 len;
|
||||
@ -107,4 +102,17 @@ template<typename T, typename VecT>
|
||||
void allie_form_cpp_vector_of_matching_types(std::vector<T>& dst, const VecT& src) {
|
||||
dst.resize(src.len);
|
||||
memcpy(dst.data(), src.buf, src.len * sizeof(T));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct allie_VecU8 {
|
||||
U8* buf;
|
||||
U64 len;
|
||||
U64 capacity;
|
||||
|
||||
explicit allie_VecU8(std::string_view src) {
|
||||
len = capacity = src.size();
|
||||
buf = static_cast<U8*>(safe_malloc( src.size() ));
|
||||
memcpy(buf, src.data(), src.size());
|
||||
}
|
||||
};
|
||||
@ -108,12 +108,12 @@ struct allie_AliceCallbacks {
|
||||
extern "C" {
|
||||
allie_Alice allie_Alice_new();
|
||||
void allie_Alice_mainloop(allie_Alice, const allie_AliceCallbacks*);
|
||||
allie_LucyFace allie_Alice_new_LucyFace(allie_Alice alice, allie_SpanU8 path);
|
||||
allie_LucyFace allie_Alice_new_LucyFace(allie_Alice alice, allie_VecU8 path);
|
||||
void allie_Alice_lucy_cache_add_glyphs(allie_Alice alice, allie_VecLucyGlyphCachingRequest req);
|
||||
void allie_Alice_lucy_renderer_add_simple_label(allie_Alice alice, void* ffs,
|
||||
vec4 color, S32 additional_y_advance, allie_SpanU8 text, ivec2 start_pos);
|
||||
U32 allie_Alice_load_r8g8b8a8_texture(allie_Alice alice, allie_SpanU8 file_path);
|
||||
U32 allie_Alice_load_r8_texture(allie_Alice alice, allie_SpanU8 file_path);
|
||||
U32 allie_Alice_load_r8g8b8a8_texture(allie_Alice alice, allie_VecU8 file_path);
|
||||
U32 allie_Alice_load_r8_texture(allie_Alice alice, allie_VecU8 file_path);
|
||||
allie_AliceAcknGenericMesh allie_Alice_add_generic_mesh(allie_Alice alice,
|
||||
const allie_AliceGenericMeshTopology* topology, U32 diffuse_tex, U32 normal_tex, U32 specular_tex);
|
||||
allie_AliceAcknShinyMesh allie_Alice_add_shiny_mesh(allie_Alice alice, const allie_AliceShinyMeshTopology* top);
|
||||
@ -172,7 +172,7 @@ struct Alice {
|
||||
}
|
||||
|
||||
LucyFace new_lucy_face (std::string_view path) noexcept {
|
||||
return LucyFace{allie_Alice_new_LucyFace(opa, allie_SpanU8(path))};
|
||||
return LucyFace{allie_Alice_new_LucyFace(opa, allie_VecU8(path))};
|
||||
}
|
||||
|
||||
void lucy_cache_add_glyphs(std::vector<LucyGlyphCachingRequest>&& reqs) {
|
||||
@ -194,11 +194,11 @@ struct Alice {
|
||||
}
|
||||
|
||||
AliceTextureSlot load_r8g8b8a8_texture(std::string_view path) noexcept {
|
||||
return {.id = allie_Alice_load_r8g8b8a8_texture(opa, allie_SpanU8(path))};
|
||||
return {.id = allie_Alice_load_r8g8b8a8_texture(opa, allie_VecU8(path))};
|
||||
}
|
||||
|
||||
AliceTextureSlot load_r8_texture(std::string_view path) noexcept {
|
||||
return {.id = allie_Alice_load_r8_texture(opa, allie_SpanU8(path))};
|
||||
return {.id = allie_Alice_load_r8_texture(opa, allie_VecU8(path))};
|
||||
}
|
||||
|
||||
AliceAcknGenericMesh add_generic_mesh(
|
||||
|
||||
@ -24,7 +24,7 @@ struct allie_AliceGenericMeshTopology {
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
allie_AliceGenericMeshTopology allie_alice_expect_read_generic_mesh_from_file(allie_SpanU8 file_path);
|
||||
allie_AliceGenericMeshTopology allie_alice_expect_read_generic_mesh_from_file(allie_VecU8 file_path);
|
||||
}
|
||||
|
||||
struct AliceGenericMeshTopology {
|
||||
@ -33,7 +33,7 @@ struct AliceGenericMeshTopology {
|
||||
};
|
||||
|
||||
AliceGenericMeshTopology alice_expect_read_generic_mesh_from_file(std::string_view file_path) {
|
||||
allie_AliceGenericMeshTopology a_top = allie_alice_expect_read_generic_mesh_from_file(allie_SpanU8(file_path));
|
||||
allie_AliceGenericMeshTopology a_top = allie_alice_expect_read_generic_mesh_from_file(allie_VecU8(file_path));
|
||||
AliceGenericMeshTopology top{};
|
||||
allie_form_cpp_vector_of_matching_types(top.vertices, a_top.vertices);
|
||||
allie_form_cpp_vector_of_matching_types(top.indexes, a_top.indexes);
|
||||
@ -65,7 +65,7 @@ struct allie_AliceShinyMeshTopology {
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
allie_AliceShinyMeshTopology allie_alice_expect_read_shiny_mesh_from_file(allie_SpanU8 file_path);
|
||||
allie_AliceShinyMeshTopology allie_alice_expect_read_shiny_mesh_from_file(allie_VecU8 file_path);
|
||||
}
|
||||
|
||||
struct AliceShinyMeshTopology {
|
||||
@ -74,7 +74,7 @@ struct AliceShinyMeshTopology {
|
||||
};
|
||||
|
||||
AliceShinyMeshTopology alice_expect_read_shiny_mesh_from_file(std::string_view file_path) {
|
||||
allie_AliceShinyMeshTopology a_top = allie_alice_expect_read_shiny_mesh_from_file(allie_SpanU8(file_path));
|
||||
allie_AliceShinyMeshTopology a_top = allie_alice_expect_read_shiny_mesh_from_file(allie_VecU8(file_path));
|
||||
AliceShinyMeshTopology top;
|
||||
allie_form_cpp_vector_of_matching_types(top.vertices, a_top.vertices);
|
||||
allie_form_cpp_vector_of_matching_types(top.indexes, a_top.indexes);
|
||||
|
||||
@ -12,8 +12,8 @@ void allie_Alice_drop(Alice* self) {
|
||||
// todo: implment
|
||||
}
|
||||
|
||||
LucyFace* allie_Alice_new_LucyFace(Alice* alice, SpanU8 path) {
|
||||
return Alice_new_LucyFace(alice, VecU8_from_span(path));
|
||||
LucyFace* allie_Alice_new_LucyFace(Alice* alice, VecU8 path) {
|
||||
return Alice_new_LucyFace(alice, path);
|
||||
}
|
||||
|
||||
|
||||
@ -32,20 +32,20 @@ void allie_Alice_lucy_renderer_add_simple_label(Alice* alice, RBTreeNodeLucyFace
|
||||
}
|
||||
|
||||
/* This has nothing to do with game engine API, GenericMeshTopology is just a datatype that holds model data */
|
||||
GenericMeshTopology allie_alice_expect_read_generic_mesh_from_file(SpanU8 file_path) {
|
||||
return alice_expect_read_generic_mesh_from_file(VecU8_from_span(file_path));
|
||||
GenericMeshTopology allie_alice_expect_read_generic_mesh_from_file(VecU8 file_path) {
|
||||
return alice_expect_read_generic_mesh_from_file(file_path);
|
||||
}
|
||||
|
||||
ShinyMeshTopology allie_alice_expect_read_shiny_mesh_from_file(SpanU8 file_path) {
|
||||
return alice_expect_read_shiny_mesh_from_file(VecU8_from_span(file_path));
|
||||
ShinyMeshTopology allie_alice_expect_read_shiny_mesh_from_file(VecU8 file_path) {
|
||||
return alice_expect_read_shiny_mesh_from_file(file_path);
|
||||
}
|
||||
|
||||
U32 allie_Alice_load_r8g8b8a8_texture(Alice* alice, SpanU8 file_path) {
|
||||
return Alice_load_r8g8b8a8_texture(alice, VecU8_from_span(file_path));
|
||||
U32 allie_Alice_load_r8g8b8a8_texture(Alice* alice, VecU8 file_path) {
|
||||
return Alice_load_r8g8b8a8_texture(alice, file_path);
|
||||
}
|
||||
|
||||
U32 allie_Alice_load_r8_texture(Alice* alice, SpanU8 file_path) {
|
||||
return Alice_load_r8_texture(alice, VecU8_from_span(file_path));
|
||||
U32 allie_Alice_load_r8_texture(Alice* alice, VecU8 file_path) {
|
||||
return Alice_load_r8_texture(alice, file_path);
|
||||
}
|
||||
|
||||
|
||||
|
||||
6
src/l2/allie_glue.c
Normal file
6
src/l2/allie_glue.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void allie_funny_hello() {
|
||||
printf("HIIIIII\n");
|
||||
}
|
||||
7
src/l2/allie_rs/Cargo.toml
Normal file
7
src/l2/allie_rs/Cargo.toml
Normal file
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "alice_and_misc"
|
||||
version="0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
||||
12
src/l2/allie_rs/lib.rs
Normal file
12
src/l2/allie_rs/lib.rs
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
unsafe extern "C" {
|
||||
fn allie_funny_hello();
|
||||
}
|
||||
|
||||
pub fn funny_hello() {
|
||||
unsafe { allie_funny_hello(); }
|
||||
}
|
||||
|
||||
pub fn funny_test(){
|
||||
println!("HELLOOOO\nHELLOOOOOOOO :3");
|
||||
}
|
||||
6
src/l3/r4/r4d.rs
Normal file
6
src/l3/r4/r4d.rs
Normal file
@ -0,0 +1,6 @@
|
||||
use alice_and_misc::{funny_test, funny_hello};
|
||||
|
||||
fn main() {
|
||||
funny_test();
|
||||
funny_hello();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user