From 21c604104f63a8dae5f4503c72a2dedcc86be566 Mon Sep 17 00:00:00 2001 From: martinfouilleul Date: Wed, 8 Feb 2023 19:38:59 +0100 Subject: [PATCH] fix mp_app_get_resource_path() --- examples/win_canvas/main.c | 9 ++++---- src/win32_app.c | 2 +- src/win32_app.h | 1 + todo.txt | 46 ++++++++++++++++++++++++++------------ 4 files changed, 39 insertions(+), 19 deletions(-) diff --git a/examples/win_canvas/main.c b/examples/win_canvas/main.c index 9d02fa6..7cf0fd4 100644 --- a/examples/win_canvas/main.c +++ b/examples/win_canvas/main.c @@ -8,6 +8,7 @@ *****************************************************************/ #include #include +#include #define _USE_MATH_DEFINES //NOTE: necessary for MSVC #include @@ -20,15 +21,15 @@ mg_font create_font() { //NOTE(martin): create font -/* str8 fontPath = mp_app_get_resource_path(mem_scratch(), "../resources/OpenSansLatinSubset.ttf"); - char* fontPathCString = str8_to_cstring(mem_scratch(), fontPath); -*/ + str8 fontPath = mp_app_get_resource_path(mem_scratch(), "../resources/OpenSansLatinSubset.ttf"); +// char* fontPathCString = str8_to_cstring(mem_scratch(), fontPath); + char* fontPathCString = "resources/OpenSansLatinSubset.ttf"; FILE* fontFile = fopen(fontPathCString, "r"); if(!fontFile) { - LOG_ERROR("Could not load font file '%s'\n", fontPathCString); + LOG_ERROR("Could not load font file '%s': %s\n", fontPathCString, strerror(errno)); return(mg_font_nil()); } unsigned char* fontData = 0; diff --git a/src/win32_app.c b/src/win32_app.c index 27176f7..1f1e960 100644 --- a/src/win32_app.c +++ b/src/win32_app.c @@ -781,7 +781,7 @@ mp_rect mp_window_get_content_rect(mp_window window) str8 mp_app_get_executable_path(mem_arena* arena) { char* buffer = mem_arena_alloc_array(arena, char, MAX_PATH+1); - int size = GetModuleFileNameA(NULL, buffer, MAX_PATH+1); + int size = GetModuleFileName(NULL, buffer, MAX_PATH+1); //TODO: check for errors... return(str8_from_buffer(size, buffer)); diff --git a/src/win32_app.h b/src/win32_app.h index 60611dd..483d665 100644 --- a/src/win32_app.h +++ b/src/win32_app.h @@ -13,6 +13,7 @@ #include"mp_app.h" #define WIN32_LEAN_AND_MEAN +#define UNICODE #include typedef struct win32_window_data diff --git a/todo.txt b/todo.txt index ff22248..ffd9320 100644 --- a/todo.txt +++ b/todo.txt @@ -1,22 +1,21 @@ -Canvas renderer perf --------------------- -[.] Perf - [x] Split vertex data into per-vertex and per-shape data. Keep only pos, cubics, and shapeID in vertex data - [?] use half-floats or short fixed-point for pos and uv, packing them in two ints - [?] pre-compute triangle edges/bounding boxes? +Overview +-------- +[ ] Clean+Fixes of canvas code and examples +[ ] Make backend selection easier +[ ] Investigate and fix artifact when seam is aligned to tile boundary? -[!] Investigate artifact when shifting positions of vertices by (0.5, 0.5) before multiplying - by subpixel precision and truncating... -> ie sampling at the middle of pixels vs at integer coordinates... - [ ] What alignment gives crisp-ier lines? +[ ] Image API and backend + [ ] Build image atlas on top + [ ] Baked fonts? -[>] Add surface scaling for high dpi surfaces and check that our fonts are renderer smoothly +[ ] Allow different versions of GL to co-exist +[ ] Backport canvas to GLES -[x] Allow setting swap interval - [!] Allow swap interval of 0 on macos - -[x] Use clip rects in tiling/drawing pass +[ ] Delegated drawing API+Impl +Clean+Fixes +----------- [ ] Clean canvas code [ ] make zIndex implicit when calling push_vertex [ ] rename zIndex with "shapeIndex" everywhere @@ -29,7 +28,26 @@ Canvas renderer perf [ ] GL loader: allow using different GL versions (eg using a desktop GL surface and a GLES surface in the same app). [ ] Clean up surface backend and canvas backend compile-time and run-time selections +[!] Investigate artifact when shifting positions of vertices by (0.5, 0.5) before multiplying + by subpixel precision and truncating... -> ie sampling at the middle of pixels vs at integer coordinates... + [ ] What alignment gives crisp-ier lines? + + +Canvas renderer +--------------- +[.] Perf + [x] Split vertex data into per-vertex and per-shape data. Keep only pos, cubics, and shapeID in vertex data + [?] use half-floats or short fixed-point for pos and uv, packing them in two ints + [?] pre-compute triangle edges/bounding boxes? + +[x] Add surface scaling for high dpi surfaces and check that our fonts are rendered smoothly +[x] Allow setting swap interval + [!] Allow swap interval of 0 on macos + +[x] Use clip rects in tiling/drawing pass + [/] backport to GLES? +[/] Handle changing monitors/dpi [ ] Ghostscript tiger stress test? -> need an svg loader, and a way to flush external command list