canoi12 / tinycoffee Goto Github PK
View Code? Open in Web Editor NEWtiny coffee is a framework to develop simple 2d games with opengl 3
License: MIT License
tiny coffee is a framework to develop simple 2d games with opengl 3
License: MIT License
Actually doesn't happens always, sometimes it works, but generally, it will return an tc_Resource with a .data
field with NULL value.
I made a project to reproduce the bug, it is in nelua, but the generated C is there too:
https://gitlab.com/Andre-LA/tico-test
(note: use git clone --recurse-submodules https://gitlab.com/Andre-LA/tico-test.git
, building the tinycoffee
inside is also necessary).
What is the project's license?
-- in nelua
##[[
TICO = {
L = '../../tinycoffee/build',
I = {
include = "../../tinycoffee/include",
external = "../../tinycoffee/external"
},
}
]]
require 'tico'
local nelua_argc: cint <cimport, nodecl>
local nelua_argv: *[0]cstring <cimport, nodecl>
local config = tico.config_load('project.tico', nelua_argc, nelua_argv)
--local config = tico.config_init('mytest', 800, 600, nelua_argc, nelua_argv)
tico.init(config)
for i = 1, 10 do
local res = tico.plugin_resources_get('image', 'lunarlander')
end
while not tico.window_should_close() do
tico.update()
tico.begin_draw()
tico.graphics_clear(tico.BG)
tico.end_draw()
end
tico.terminate()
(this generates this C code)
// some typedefs:
static char __strlit1[13] = "project.tico";
typedef char** nlcstring_ptr;
typedef tc_Resource* tc_Resource_ptr;
static char __strlit2[6] = "image";
static char __strlit3[12] = "lunarlander";
static tc_Color tico_tico_BG = {75U, 90U, 90U, 255U};
/// [...]
testes_config = tico_config_load(__strlit1, nelua_argc, (nlcstring_ptr)nelua_argv);
tico_init(&testes_config);
for(int64_t i = 1; i <= 10; i = i + 1) {
tc_Resource_ptr res = tico_plugin_resources_get(__strlit2, __strlit3);
}
while(!tico_window_should_close()) {
tico_update();
tico_begin_draw();
tico_graphics_clear(tico_tico_BG);
tico_end_draw();
}
tico_terminate();
return 0;
// [...]
Running this code will give this error at exit:
[...]
19:38:47 Render Module terminated
19:38:47 Graphics Module terminated
Thread 1 "testes" received signal SIGSEGV, Segmentation fault.
0x00007ffff69b884f in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#0 0x00007ffff69b884f in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#1 0x00007ffff69b8dc6 in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#2 0x00007ffff6784e9d in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#3 0x00007ffff67b3adf in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#4 0x00007ffff66cfa5d in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#5 0x00007ffff6594f78 in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#6 0x00007ffff6630517 in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#7 0x00007ffff74aefb3 in ?? () from /lib/x86_64-linux-gnu/libGLX_mesa.so.0
#8 0x00007ffff7499539 in ?? () from /lib/x86_64-linux-gnu/libGLX_mesa.so.0
#9 0x000055555567d625 in destroyContextGLX (window=0x555555b477c0) at /home/dreunix/origami-sword/momonave/rotor-quick/tinycoffee/external/glfw/src/glx_context.c:241
241 glXDestroyContext(_glfw.x11.display, window->context.glx.handle);
#10 0x00005555556790f1 in _glfwPlatformDestroyWindow (window=0x555555b477c0) at /home/dreunix/origami-sword/momonave/rotor-quick/tinycoffee/external/glfw/src/x11_window.c:2055
2055 window->context.destroy(window);
#11 0x000055555566e41a in glfwDestroyWindow (handle=0x555555b477c0) at /home/dreunix/origami-sword/momonave/rotor-quick/tinycoffee/external/glfw/src/window.c:459
459 _glfwPlatformDestroyWindow(window);
#12 0x00005555555bce28 in tico_window_deinit (window=0x55555585ce68 <Core+24360>) at /home/dreunix/origami-sword/momonave/rotor-quick/tinycoffee/src/window.c:48
48 glfwDestroyWindow(window->handle);
#13 0x0000555555564681 in tico_terminate () at /home/dreunix/origami-sword/momonave/rotor-quick/tinycoffee/src/core.c:230
230 tico_window_deinit(&Core.window);
#14 0x0000555555563265 in nelua_main (nelua_argc=1, nelua_argv=0x7fffffffde38) at nelua_cache/testes.c:133
133 tico_terminate();
#15 0x00005555555632a4 in main (argc=1, argv=0x7fffffffde38) at nelua_cache/testes.c:137
137 return nelua_main(argc, argv);
However, changing the for
count will create other errors, for instance, changing from 10
to 13
will give this error at startup:
19:40:54 Lua lib: editor added
19:40:54 Plugin: editor enabled
malloc(): unaligned tcache chunk detected
Thread 1 "testes" hit Breakpoint 1, __GI_abort () at abort.c:49
49 abort.c: Arquivo ou diretório inexistente.
#0 __GI_abort () at abort.c:49
49 in abort.c
#1 0x00007ffff7910af6 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff7a38128 "%s\n") at ../sysdeps/posix/libc_fatal.c:155
155 ../sysdeps/posix/libc_fatal.c: Arquivo ou diretório inexistente.
#2 0x00007ffff791946c in malloc_printerr (str=str@entry=0x7ffff7a3abf0 "malloc(): unaligned tcache chunk detected") at malloc.c:5389
5389 malloc.c: Arquivo ou diretório inexistente.
#3 0x00007ffff791e85c in tcache_get (tc_idx=<optimized out>) at malloc.c:2953
2953 in malloc.c
#4 __GI___libc_malloc (bytes=88) at malloc.c:3071
3071 in malloc.c
#5 0x00007ffff69b8b11 in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#6 0x00007ffff696e50a in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#7 0x00007ffff696ebc9 in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#8 0x00007ffff6930065 in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#9 0x00007ffff68a3532 in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#10 0x00007ffff67ae782 in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#11 0x00005555556d9366 in ImGui_ImplOpenGL3_CreateDeviceObjects ()
#12 0x00005555556d817b in ImGui_ImplOpenGL3_NewFrame ()
#13 0x0000555555563a52 in tico_imgui_update () at /home/dreunix/origami-sword/momonave/rotor-quick/tinycoffee/include/tico_imgui.h:50
50 ImGui_ImplOpenGL3_NewFrame();
#14 0x00005555555646cd in tico_update () at /home/dreunix/origami-sword/momonave/rotor-quick/tinycoffee/src/core.c:242
242 tico_imgui_update();
#15 0x000055555556322c in nelua_main (nelua_argc=1, nelua_argv=0x7fffffffde38) at nelua_cache/testes.c:128
128 tico_update();
#16 0x00005555555632a4 in main (argc=1, argv=0x7fffffffde38) at nelua_cache/testes.c:137
137 return nelua_main(argc, argv);
I remember that there is another one which gives an error on miniaudio
, which also makes the game's sound a little weird.
the cimgui
, miniaudio
, wren
and zip
directories are empty either with git clone
or with the .zip download on the releases page.
To compile and use it (from a .c code, using tinycoffe as a library), it only runs and compiles using g++ as a compiler (generated through nelua, which is the language I use).
g++ -o "nelua_cache/teste" "nelua_cache/teste.c" -Wall -fwrapv -g -Llibs -Iinclude -Iexternal -ltico_lib -lglfw -lgl3w -lGL -llua -lcimgui -ldl -lX11 -lpthread -lm
However, I would like to use a C compiler instead of a C++ one, but with gcc
, this is the output:
gcc -o "nelua_cache/teste" "nelua_cache/teste.c" -Wall -fwrapv -g -Llibs -Iinclude -Iexternal -ltico_lib -lglfw -lgl3w -lGL -llua -lcimgui -ldl -lX11 -lpthread -lm
C compilation for 'nelua_cache/teste' failed:
In file included from include/tico.h:103,
from nelua_cache/teste.c:34:
include/json.h:19:1: warning: multi-line comment [-Wcomment]
19 | // TIC_API int tico_json_get_##name_t (cJSON *const json, type_t type); \
| ^
In file included from include/tico.h:105,
from nelua_cache/teste.c:34:
include/engine.h:119:1: warning: multi-line comment [-Wcomment]
119 | // #define FIELD_FUNCTION(func_name, ...) \
| ^
include/engine.h:122:1: warning: multi-line comment [-Wcomment]
122 | // #define FIELD_TYPE(name_p, type_t) \
| ^
include/engine.h:132:1: warning: multi-line comment [-Wcomment]
132 | // #define FIELD_TYPE(name_p, type_p) \
| ^
/usr/bin/ld: libs/liblua.a(loslib.c.o): na função "os_tmpname":
/home/dreunix/Downloads/git/nelua-projs/tinycoffe-binding/tinycoffee/external/lua/src/loslib.c:172: aviso: the use of `tmpnam' is dangerous, better use `mkstemp'
/usr/bin/ld: libs/libcimgui.a(cimgui.cpp.o): na função "GetCimguiStorage()":
cimgui.cpp:(.text+0xcd6d): referência não definida para "operator new(unsigned long)"
/usr/bin/ld: libs/libcimgui.a(cimgui.cpp.o):(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): referência não definida para "__gxx_personality_v0"
/usr/bin/ld: libs/libcimgui.a(imgui_demo.cpp.o): na função "ShowDemoWindowWidgets()":
imgui_demo.cpp:(.text+0x3f0c): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0x3f2d): referência não definida para "__cxa_guard_release"
/usr/bin/ld: imgui_demo.cpp:(.text+0x4672): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0x46b3): referência não definida para "__cxa_guard_release"
/usr/bin/ld: imgui_demo.cpp:(.text+0x48e9): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0x4924): referência não definida para "__cxa_guard_release"
/usr/bin/ld: imgui_demo.cpp:(.text+0x4a27): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0x4a48): referência não definida para "__cxa_guard_release"
/usr/bin/ld: imgui_demo.cpp:(.text+0x4f2a): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0x4f67): referência não definida para "__cxa_guard_release"
/usr/bin/ld: imgui_demo.cpp:(.text+0x5241): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0x5282): referência não definida para "__cxa_guard_release"
/usr/bin/ld: libs/libcimgui.a(imgui_demo.cpp.o): na função "ShowDemoWindowLayout()":
imgui_demo.cpp:(.text+0x9176): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0x9197): referência não definida para "__cxa_guard_release"
/usr/bin/ld: imgui_demo.cpp:(.text+0xb2d5): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0xb306): referência não definida para "__cxa_guard_release"
/usr/bin/ld: imgui_demo.cpp:(.text+0xb322): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0xb353): referência não definida para "__cxa_guard_release"
/usr/bin/ld: libs/libcimgui.a(imgui_demo.cpp.o): na função "ShowDemoWindowMisc()":
imgui_demo.cpp:(.text+0xce2c): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0xce5a): referência não definida para "__cxa_guard_release"
/usr/bin/ld: imgui_demo.cpp:(.text+0xe12a): referência não definida para "__cxa_guard_abort"
/usr/bin/ld: libs/libcimgui.a(imgui_demo.cpp.o): na função "ImGui::ShowStyleEditor(ImGuiStyle*)":
imgui_demo.cpp:(.text+0xf495): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0xf4bc): referência não definida para "__cxa_guard_release"
/usr/bin/ld: imgui_demo.cpp:(.text+0x100f6): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0x10124): referência não definida para "__cxa_guard_release"
/usr/bin/ld: imgui_demo.cpp:(.text+0x10b10): referência não definida para "__cxa_guard_abort"
/usr/bin/ld: imgui_demo.cpp:(.text+0x10b33): referência não definida para "__cxa_guard_abort"
/usr/bin/ld: libs/libcimgui.a(imgui_demo.cpp.o): na função "ShowExampleAppConsole(bool*)":
imgui_demo.cpp:(.text+0x110e1): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0x11108): referência não definida para "__cxa_guard_release"
/usr/bin/ld: imgui_demo.cpp:(.text+0x11156): referência não definida para "__cxa_guard_abort"
/usr/bin/ld: libs/libcimgui.a(imgui_demo.cpp.o): na função "ShowExampleAppLog(bool*)":
imgui_demo.cpp:(.text+0x111ae): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0x111d5): referência não definida para "__cxa_guard_release"
/usr/bin/ld: imgui_demo.cpp:(.text+0x113e0): referência não definida para "__cxa_guard_abort"
/usr/bin/ld: libs/libcimgui.a(imgui_demo.cpp.o): na função "ShowExampleAppLongText(bool*)":
imgui_demo.cpp:(.text+0x11a80): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0x11aa1): referência não definida para "__cxa_guard_release"
/usr/bin/ld: libs/libcimgui.a(imgui_demo.cpp.o): na função "ShowExampleAppCustomRendering(bool*)":
imgui_demo.cpp:(.text+0x12cdf): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0x12d20): referência não definida para "__cxa_guard_release"
/usr/bin/ld: imgui_demo.cpp:(.text+0x13e83): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0x13ea4): referência não definida para "__cxa_guard_release"
/usr/bin/ld: imgui_demo.cpp:(.text+0x13eda): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0x13f03): referência não definida para "__cxa_guard_release"
/usr/bin/ld: libs/libcimgui.a(imgui_demo.cpp.o): na função "ShowExampleAppDocuments(bool*)":
imgui_demo.cpp:(.text+0x14cb8): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0x14cdf): referência não definida para "__cxa_guard_release"
/usr/bin/ld: imgui_demo.cpp:(.text+0x15313): referência não definida para "__cxa_guard_acquire"
/usr/bin/ld: imgui_demo.cpp:(.text+0x15334): referência não definida para "__cxa_guard_release"
/usr/bin/ld: imgui_demo.cpp:(.text+0x156dc): referência não definida para "__cxa_guard_abort"
collect2: error: ld returned 1 exit status
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.