From afdd6589a721ab5edb03914be8147c82fcbe7cd0 Mon Sep 17 00:00:00 2001 From: Knaapchen Date: Sun, 9 Oct 2022 13:55:39 +0200 Subject: [PATCH] FINALLY fixed the bug that caused rendering to suck --- fugg-client/src/export/env.cpp | 37 +++++++++++++++++++++++++++++----- fugg-client/src/export/gl.cpp | 2 +- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/fugg-client/src/export/env.cpp b/fugg-client/src/export/env.cpp index 46684fc..5d8003c 100644 --- a/fugg-client/src/export/env.cpp +++ b/fugg-client/src/export/env.cpp @@ -288,28 +288,55 @@ WASM_IMPORT_IMPL(env, __emscripten_get_now_is_monotonic) = []() { /* __gmtime_js */ WASM_IMPORT_IMPL(env, __gmtime_js) = [](u32 a, u32 b) { // FIXME: - // puts("__gmtime_js is not implemented yet."); + auto& t = fugg::module_ref(a); + const auto& info = gmtime(&t); + + auto& result = fugg::module_ref(b); + result.tm_sec = info->tm_sec; + result.tm_min = info->tm_min; + result.tm_hour = info->tm_hour; + result.tm_mday = info->tm_mday; + result.tm_mon = info->tm_mon; + result.tm_year = info->tm_year; + result.tm_wday = info->tm_wday; + result.tm_yday = info->tm_yday; }; /* import: 'a' 'Kb' */ /* __localtime_js */ WASM_IMPORT_IMPL(env, __localtime_js) = [](u32 a, u32 b) { // FIXME: - // puts("__localtime_js is not implemented yet."); + auto& t = fugg::module_ref(a); + const auto& info = gmtime(&t); + + auto& result = fugg::module_ref(b); + result.tm_sec = info->tm_sec; + result.tm_min = info->tm_min; + result.tm_hour = info->tm_hour; + result.tm_mday = info->tm_mday; + result.tm_mon = info->tm_mon; + result.tm_year = info->tm_year; + result.tm_wday = info->tm_wday; + result.tm_yday = info->tm_yday; + result.tm_isdst = info->tm_isdst; + result.tm_gmtoff = info->tm_gmtoff; }; /* import: 'a' 'Lb' */ /* __mktime_js */ WASM_IMPORT_IMPL(env, __mktime_js) = [](u32 a) { // FIXME: // puts("__mktime_js is not implemented yet."); + auto& t = fugg::module_ref(a); - return static_cast(0); + auto result = mktime(&t); + + return static_cast(result); }; /* import: 'a' 'Mb' */ /* __tzset_js */ WASM_IMPORT_IMPL(env, __tzset_js) = [](u32 a, u32 b, u32 c) { // FIXME: - // puts("__tzset_js is not implemented yet."); - + // Not sure if this is correct... + tzset(); }; /* import: 'a' 'Rb' */ diff --git a/fugg-client/src/export/gl.cpp b/fugg-client/src/export/gl.cpp index 0cdd216..5572a2f 100644 --- a/fugg-client/src/export/gl.cpp +++ b/fugg-client/src/export/gl.cpp @@ -233,7 +233,7 @@ WASM_IMPORT_IMPL(env, _glBindFramebuffer) = [](u32 a, u32 b) { /* import: 'a' 'D' */ /* _glDrawElements */ WASM_IMPORT_IMPL(env, _glDrawElements) = [](u32 a, u32 b, u32 c, u32 d) { - const auto& indices = fugg::ModulePointer(d); + const auto& indices = reinterpret_cast(d); #if TRACE_GL_CALLS std::cout << "_glDrawElements("