Skip to content

Commit f29f971

Browse files
committed
misc
1 parent f0c6d3c commit f29f971

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+44106
-5
lines changed

compile_flags.txt

+1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
-std=c99
66
-I.
77
-Iext
8+
-Iext/lua/src
89
-Wno-unused-function
910
-Wno-unused-variable

d_app.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1363,8 +1363,8 @@ static void d_term_present(int w, int h, d_color* buf) {
13631363
struct winsize term_size;
13641364

13651365
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &term_size) != -1 && term_size.ws_col != 0) {
1366-
tw = mini(w, term_size.ws_col);
1367-
th = mini(h, term_size.ws_row * 2 - 2);
1366+
tw = d_mini(w, term_size.ws_col);
1367+
th = d_mini(h, term_size.ws_row * 2 - 2);
13681368
}
13691369

13701370
d_color prev_c1 = d_colorx(0x00000000);

d_lua.c

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <lua.h>
2+
#include <lauxlib.h>
3+
#include <lualib.h>
4+
5+
int main(int argc, char** argv) {
6+
lua_State *L = luaL_newstate();
7+
luaL_openlibs(L);
8+
lua_close(L);
9+
return 0;
10+
}

demo/bling.c

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#define STB_IMAGE_IMPLEMENTATION
2+
#include <stb_image.h>
3+
4+
#define D_IMPL
5+
#include <d_plat.h>
6+
#include <d_fs.h>
7+
#include <d_math.h>
8+
#include <d_app.h>
9+
#include <d_gfx.h>
10+
11+
#define WIDTH 240
12+
#define HEIGHT 240
13+
#define SCALE 2
14+
#define MAX_BLINGS 1024
15+
16+
d_img img;
17+
float timer = 0.0;
18+
float bling_time = 0.5f;
19+
20+
typedef struct {
21+
d_t2 t;
22+
bool dead;
23+
} bling_t;
24+
25+
bling_t blings[MAX_BLINGS];
26+
int num_blings;
27+
28+
void init(void) {
29+
30+
d_gfx_init((d_gfx_desc) {
31+
.width = WIDTH,
32+
.height = HEIGHT,
33+
.clear_color = d_colori(0, 0, 0, 255),
34+
});
35+
36+
img = d_img_load(d_res_path("res/bling.png"));
37+
38+
}
39+
40+
void frame(void) {
41+
42+
float dt = d_app_dt();
43+
d_vec2 mpos = d_gfx_mouse_pos();
44+
45+
if (d_app_key_pressed(D_KEY_ESC)) {
46+
d_app_quit();
47+
}
48+
49+
if (d_app_key_pressed(D_KEY_F)) {
50+
d_app_set_fullscreen(!d_app_is_fullscreen());
51+
}
52+
53+
d_gfx_clear();
54+
55+
if (d_app_mouse_moved()) {
56+
timer += dt;
57+
if (timer >= bling_time) {
58+
timer = 0.0f;
59+
float dx = R(-4, 4);
60+
float dy = R(-4, 4);
61+
blings[num_blings++] = (bling_t) {
62+
.t = (d_t2) {
63+
.pos = d_vec2_add(mpos, V(dx, dy)),
64+
.rot = 0,
65+
.scale = V(0),
66+
.origin = d_vec2_scale(V(img.width, img.height), 0.5),
67+
},
68+
.dead = false,
69+
};
70+
}
71+
}
72+
73+
for (int i = 0; i < num_blings; i++) {
74+
bling_t b = blings[i];
75+
if (b.dead) {
76+
// TODO
77+
continue;
78+
}
79+
}
80+
81+
d_gfx_present();
82+
83+
}
84+
85+
int main(void) {
86+
d_app_run((d_app_desc) {
87+
.title = "bling",
88+
.init = init,
89+
.frame = frame,
90+
.width = WIDTH * SCALE,
91+
.height = HEIGHT * SCALE,
92+
});
93+
}

demo/btfly.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ void frame(void) {
6060

6161
d_transform_push();
6262
d_transform_pos3(d_vec3f(d_gfx_width() / 2.0, d_gfx_height() / 2.0, 0));
63-
d_transform_rot_y(d_app_time());
64-
d_transform_rot_z(d_app_time() / 2);
63+
d_transform_rot_y(d_app_time() * -20);
64+
d_transform_rot_z(d_app_time() * -10);
6565
d_transform_scale3(d_vec3f(3, -3, 3));
6666
d_transform_pos3(d_vec3_scale(btfly.center, -1));
6767
d_draw_model(&btfly);

demo/d_lua.c

-1
This file was deleted.

ext/lua/Makefile

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Makefile for installing Lua
2+
# See doc/readme.html for installation and customization instructions.
3+
4+
# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT =======================
5+
6+
# Your platform. See PLATS for possible values.
7+
PLAT= guess
8+
9+
# Where to install. The installation starts in the src and doc directories,
10+
# so take care if INSTALL_TOP is not an absolute path. See the local target.
11+
# You may want to make INSTALL_LMOD and INSTALL_CMOD consistent with
12+
# LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h.
13+
INSTALL_TOP= /usr/local
14+
INSTALL_BIN= $(INSTALL_TOP)/bin
15+
INSTALL_INC= $(INSTALL_TOP)/include
16+
INSTALL_LIB= $(INSTALL_TOP)/lib
17+
INSTALL_MAN= $(INSTALL_TOP)/man/man1
18+
INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V
19+
INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V
20+
21+
# How to install. If your install program does not support "-p", then
22+
# you may have to run ranlib on the installed liblua.a.
23+
INSTALL= install -p
24+
INSTALL_EXEC= $(INSTALL) -m 0755
25+
INSTALL_DATA= $(INSTALL) -m 0644
26+
#
27+
# If you don't have "install" you can use "cp" instead.
28+
# INSTALL= cp -p
29+
# INSTALL_EXEC= $(INSTALL)
30+
# INSTALL_DATA= $(INSTALL)
31+
32+
# Other utilities.
33+
MKDIR= mkdir -p
34+
RM= rm -f
35+
36+
# == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE =======
37+
38+
# Convenience platforms targets.
39+
PLATS= guess aix bsd c89 freebsd generic ios linux linux-readline macosx mingw posix solaris
40+
41+
# What to install.
42+
TO_BIN= lua luac
43+
TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp
44+
TO_LIB= liblua.a
45+
TO_MAN= lua.1 luac.1
46+
47+
# Lua version and release.
48+
V= 5.4
49+
R= $V.7
50+
51+
# Targets start here.
52+
all: $(PLAT)
53+
54+
$(PLATS) help test clean:
55+
@cd src && $(MAKE) $@
56+
57+
install: dummy
58+
cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
59+
cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
60+
cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
61+
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
62+
cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
63+
64+
uninstall:
65+
cd src && cd $(INSTALL_BIN) && $(RM) $(TO_BIN)
66+
cd src && cd $(INSTALL_INC) && $(RM) $(TO_INC)
67+
cd src && cd $(INSTALL_LIB) && $(RM) $(TO_LIB)
68+
cd doc && cd $(INSTALL_MAN) && $(RM) $(TO_MAN)
69+
70+
local:
71+
$(MAKE) install INSTALL_TOP=../install
72+
73+
# make may get confused with install/ if it does not support .PHONY.
74+
dummy:
75+
76+
# Echo config parameters.
77+
echo:
78+
@cd src && $(MAKE) -s echo
79+
@echo "PLAT= $(PLAT)"
80+
@echo "V= $V"
81+
@echo "R= $R"
82+
@echo "TO_BIN= $(TO_BIN)"
83+
@echo "TO_INC= $(TO_INC)"
84+
@echo "TO_LIB= $(TO_LIB)"
85+
@echo "TO_MAN= $(TO_MAN)"
86+
@echo "INSTALL_TOP= $(INSTALL_TOP)"
87+
@echo "INSTALL_BIN= $(INSTALL_BIN)"
88+
@echo "INSTALL_INC= $(INSTALL_INC)"
89+
@echo "INSTALL_LIB= $(INSTALL_LIB)"
90+
@echo "INSTALL_MAN= $(INSTALL_MAN)"
91+
@echo "INSTALL_LMOD= $(INSTALL_LMOD)"
92+
@echo "INSTALL_CMOD= $(INSTALL_CMOD)"
93+
@echo "INSTALL_EXEC= $(INSTALL_EXEC)"
94+
@echo "INSTALL_DATA= $(INSTALL_DATA)"
95+
96+
# Echo pkg-config data.
97+
pc:
98+
@echo "version=$R"
99+
@echo "prefix=$(INSTALL_TOP)"
100+
@echo "libdir=$(INSTALL_LIB)"
101+
@echo "includedir=$(INSTALL_INC)"
102+
103+
# Targets that do not create files (not all makes understand .PHONY).
104+
.PHONY: all $(PLATS) help test clean install uninstall local dummy echo pc
105+
106+
# (end of Makefile)

ext/lua/README

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
This is Lua 5.4.7, released on 13 Jun 2024.
3+
4+
For installation instructions, license details, and
5+
further information about Lua, see doc/readme.html.
6+

ext/lua/doc/OSIApproved_100X125.png

11.8 KB
Loading

0 commit comments

Comments
 (0)