fix mp_app_get_resource_path()

This commit is contained in:
martinfouilleul 2023-02-08 19:38:59 +01:00
parent c0601961f1
commit 21c604104f
4 changed files with 39 additions and 19 deletions

View File

@ -8,6 +8,7 @@
*****************************************************************/ *****************************************************************/
#include<stdlib.h> #include<stdlib.h>
#include<string.h> #include<string.h>
#include<errno.h>
#define _USE_MATH_DEFINES //NOTE: necessary for MSVC #define _USE_MATH_DEFINES //NOTE: necessary for MSVC
#include<math.h> #include<math.h>
@ -20,15 +21,15 @@
mg_font create_font() mg_font create_font()
{ {
//NOTE(martin): create font //NOTE(martin): create font
/* str8 fontPath = mp_app_get_resource_path(mem_scratch(), "../resources/OpenSansLatinSubset.ttf"); str8 fontPath = mp_app_get_resource_path(mem_scratch(), "../resources/OpenSansLatinSubset.ttf");
char* fontPathCString = str8_to_cstring(mem_scratch(), fontPath); // char* fontPathCString = str8_to_cstring(mem_scratch(), fontPath);
*/
char* fontPathCString = "resources/OpenSansLatinSubset.ttf"; char* fontPathCString = "resources/OpenSansLatinSubset.ttf";
FILE* fontFile = fopen(fontPathCString, "r"); FILE* fontFile = fopen(fontPathCString, "r");
if(!fontFile) 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()); return(mg_font_nil());
} }
unsigned char* fontData = 0; unsigned char* fontData = 0;

View File

@ -781,7 +781,7 @@ mp_rect mp_window_get_content_rect(mp_window window)
str8 mp_app_get_executable_path(mem_arena* arena) str8 mp_app_get_executable_path(mem_arena* arena)
{ {
char* buffer = mem_arena_alloc_array(arena, char, MAX_PATH+1); 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... //TODO: check for errors...
return(str8_from_buffer(size, buffer)); return(str8_from_buffer(size, buffer));

View File

@ -13,6 +13,7 @@
#include"mp_app.h" #include"mp_app.h"
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#define UNICODE
#include<windows.h> #include<windows.h>
typedef struct win32_window_data typedef struct win32_window_data

View File

@ -1,22 +1,21 @@
Canvas renderer perf Overview
-------------------- --------
[.] Perf [ ] Clean+Fixes of canvas code and examples
[x] Split vertex data into per-vertex and per-shape data. Keep only pos, cubics, and shapeID in vertex data [ ] Make backend selection easier
[?] use half-floats or short fixed-point for pos and uv, packing them in two ints [ ] Investigate and fix artifact when seam is aligned to tile boundary?
[?] pre-compute triangle edges/bounding boxes?
[!] Investigate artifact when shifting positions of vertices by (0.5, 0.5) before multiplying [ ] Image API and backend
by subpixel precision and truncating... -> ie sampling at the middle of pixels vs at integer coordinates... [ ] Build image atlas on top
[ ] What alignment gives crisp-ier lines? [ ] 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 [ ] Delegated drawing API+Impl
[!] Allow swap interval of 0 on macos
[x] Use clip rects in tiling/drawing pass
Clean+Fixes
-----------
[ ] Clean canvas code [ ] Clean canvas code
[ ] make zIndex implicit when calling push_vertex [ ] make zIndex implicit when calling push_vertex
[ ] rename zIndex with "shapeIndex" everywhere [ ] 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). [ ] 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 [ ] 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? [/] backport to GLES?
[/] Handle changing monitors/dpi
[ ] Ghostscript tiger stress test? -> need an svg loader, and a way to flush external command list [ ] Ghostscript tiger stress test? -> need an svg loader, and a way to flush external command list