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<string.h>
#include<errno.h>
#define _USE_MATH_DEFINES //NOTE: necessary for MSVC
#include<math.h>
@ -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;

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)
{
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));

View File

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

View File

@ -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