Commit graph

378 commits

Author SHA1 Message Date
Andrei Alexeyev
b9ee7628ba
resource/font: no need to enable face culling in text_render 2024-10-04 16:27:28 +02:00
Andrei Alexeyev
fda8556a39
src: deprecate strdup(), use mem_strdup() explicitly
This fixes a nasty bug that manifests on windows when building without
precompiled headers. util/stringops.h used to silently replace strdup
with a macro that's compatible with mem_free(). This header would
typically be included everywhere due to PCH, but without it the strdup
from libc would sometimes be in scope. On most platforms mem_free() is
equivalent to free(), but not on windows, because we have to use
_aligned_free() there. Attempting to mem_free() the result of a libc
strdup() would segfault in such a configuration.

Avoid the footgun by banning strdup() entirely. Maybe redefining libc
names isn't such a great idea, who knew?
2024-09-10 14:31:55 +02:00
Andrei Alexeyev
141c942432
resource/font: disable mipmap generation
The mipmaps were never used
2024-08-30 11:52:47 +02:00
Andrei Alexeyev
be06946a31
renderer/api: add NUM_TEXTURE_CLASSES constant 2024-08-30 11:52:47 +02:00
Andrei Alexeyev
718fc9685f
resource/texture_loader: remove bad assert; handle r_texture_create() failure 2024-08-30 11:52:47 +02:00
Andrei Alexeyev
a8322f5e1d
util/rectpack: refactor to use standard mempools 2024-06-05 23:53:30 +02:00
Andrei Alexeyev
8b37d1cbf2
src: the great #include massacre of 2024 2024-05-17 14:11:48 +02:00
Andrei Alexeyev
be7905d6a3
src: run upkeep 2024-05-17 04:58:47 +02:00
Andrei Alexeyev
cc01be15fe
all: use the clamp() macro 2023-09-28 17:43:14 +02:00
Andrei Alexeyev
8f8ca2beca
all: use min/max macros; avoid some unnecessary conversions 2023-09-28 17:43:14 +02:00
Andrei Alexeyev
c15934f666
dynarray: get rid of memset and add optional initializer arg to dynarray_append 2023-09-28 17:43:14 +02:00
Andrei Alexeyev
c2810e228d
all: use re()/im() macros 2023-09-28 17:43:14 +02:00
Andrei Alexeyev
9a476f58e2
resource/font: lots of text rendering improvements
* Consistently use floats in the API and internally; don't round stuff
  arbitrarily.
* Use freetype's "normal" hinting algorithm.
* Implement subpixel positioning to avoid bad glyph spacing at small
  font sizes.
* Improved border control: inner and outer borders can be adjusted
  separately and per-font. (The "inner border" affects the "highlight"
  effect used in some shaders (blue channel)).
* Fix borders causing all glyphs to be misaligned (shifted down-right)
  by a constant offset.
* Various other improvements.
2023-05-12 08:29:26 +02:00
Andrei Alexeyev
18408a46fa
resource/font: implement reloading 2023-05-12 08:29:26 +02:00
Andrei Alexeyev
25f67ffa59
resource: fix init order 2023-05-12 08:29:26 +02:00
Andrei Alexeyev
7133618cb3
resource: fix/simplify unload
Wait for ongoing load to finish before doing anything, and do actual
unload after releasing the ires.
2023-05-08 10:05:21 +02:00
Andrei Alexeyev
ca15faf23c
resource: remove dead code 2023-05-08 10:05:21 +02:00
Andrei Alexeyev
701db8a5ac
resource: init ireses with refcount of 1
Removes the need for dumb extra work of putting the ires into purgatory
only to immediately remove it, and avoids a nasty race condition there.
2023-05-08 10:05:21 +02:00
Andrei Alexeyev
3e91b047bc
resource: fix a bunch of shit that i cbf to explain 2023-04-30 23:13:06 +02:00
Andrei Alexeyev
9dade8ad33
resource: lifetime management redesign (WIP) 2023-04-29 20:01:50 +02:00
Andrei Alexeyev
d7b1ecfd6f
resource: remove res_util_filename 2023-04-29 20:01:50 +02:00
Andrei Alexeyev
ad295005db
resource: more consistent API function names 2023-04-29 20:01:50 +02:00
Andrei Alexeyev
3dc0faec9e
renderer/api: rename ClearBufferFlags to BufferKindFlags 2023-04-10 06:47:55 +02:00
Andrei Alexeyev
886ba290a9
util/callchain: split from eventloop 2023-04-07 16:08:49 +02:00
Andrei Alexeyev
6242961ccc
resource/font: make possible to specify pos as cmplx in TextParams 2023-04-07 16:08:49 +02:00
Andrei Alexeyev
8b9602c402
util/rectpack: pool sections, support custom allocators 2023-04-03 01:53:36 +02:00
Andrei Alexeyev
a78b67ad65
resource: set name before ires is put into the hashtable
This should fix a rare race condition in res_load_dependency where the
dep could make its way to ires_make_dependent_one without having the
name set yet, failing an assertion there.

It also gets rid of a name parameter to load_resource, since the name is
always known at that point.
2023-03-30 00:47:12 +02:00
Andrei Alexeyev
e957f11790
thread: add over-engineered wrapper for thread management 2023-03-29 20:47:27 +02:00
Andrei Alexeyev
ce7159d630
resource: fix incorrect assumption in threaded loading 2023-03-26 03:26:19 +02:00
Andrei Alexeyev
711edc218f
util/assert: add optional message to assert, assume, and static_assert
Removed static_assert_nomsg, since static_assert's message argument is
optional now. In C2X mode this uses the native _Static_assert
functionality, otherwise it falls back to a macro-based overload.

Additionally, rewrote the assert macro so it correctly marks the failing
branch as a dead end.
2023-03-26 01:52:41 +01:00
Andrei Alexeyev
efe8370845
resource: add loading debug prints (disabled by default) 2023-03-26 01:04:42 +01:00
Andrei Alexeyev
7bf8e84fd6
resource/postprocess: fix -Wenum-int-mismatch 2023-03-12 17:19:02 +01:00
Andrei Alexeyev
c12b41fa3b
resource: remove deprecated getters 2023-02-24 18:15:02 +01:00
Andrei Alexeyev
b6978178b1
memory: use custom memory allocation wrappers
Introduces wrappers around memory allocation functions in `memory.h`
that should be used instead of the standard C ones.

These never return NULL and, with the exception of `mem_realloc()`,
zero-initialize the allocated memory like `calloc()` does.

All allocations made with the memory.h API must be deallocated with
`mem_free()`. Although standard `free()` will work on some platforms,
it's not portable (currently it won't work on Windows). Likewise,
`mem_free()` must not be used to free foreign allocations.

The standard C allocation functions are now diagnosed as deprecated.
They are, however, available with the `libc_` prefix in case interfacing
with foreign APIs is required. So far they are only used to implement
`memory.h`.

Perhaps the most important change is the introduction of the `ALLOC()`,
`ALLOC_ARRAY()`, and `ALLOC_FLEX()` macros. They take a type as a
parameter, and allocate enough memory with the correct alignment for
that type. That includes overaligned types as well. In most
circumstances you should prefer to use these macros. See the `memory.h`
header for some usage examples.
2023-01-18 13:23:22 +01:00
Andrei Alexeyev
deb7e7ae4c
resource/font: enlarge glyph spritesheet size
Should fit all characters in a single texture for 4k resolution.
2023-01-14 15:00:54 +01:00
Andrei Alexeyev
0adaf17d5f
sprite: handle virtual paddings transparently
Most client code no longer needs to care about paddings at all, aside
from some very special cases involving dynamic creation of padded
sprites. So far we only have one known example of this in portrait_render().

This should let us optimize most of our sprites with autotrimming in the
future.

Additionally, support for deprecated offset_{x,y} keys in sprite files
has been removed.
2022-11-27 20:14:05 +01:00
Andrei Alexeyev
1358f35856
resource/shader_program: fix segfault when file fails to open 2022-05-25 04:46:58 +03:00
Andrei Alexeyev
1f50ac45b0
resource: fix a bunch of threading bugs 2022-01-02 08:28:41 +02:00
Andrei Alexeyev
874593ccaf
resource/texture: support live reload 2022-01-02 08:28:41 +02:00
Andrei Alexeyev
d28de32b83
resource/sprite: support live reload 2022-01-02 08:28:41 +02:00
Andrei Alexeyev
b8ba3c331c
resource/shader_{object,program}: support live reload 2022-01-02 08:28:41 +02:00
Andrei Alexeyev
560391e58d
resource/material: support live reload 2022-01-02 08:28:41 +02:00
Andrei Alexeyev
8974f952f5
resource: groundwork for live reload support 2022-01-02 08:28:11 +02:00
Andrei Alexeyev
b39c9ba78e
resource: partial support for resource reloading 2022-01-02 08:28:02 +02:00
Andrei Alexeyev
1886e95a66
resource/font: fix calls to utf8_to_ucs4 2022-01-01 22:03:14 +02:00
Andrei Alexeyev
638a7a8303
resource/texture_loader: load texture_post_load shader as a dependency 2021-12-28 09:00:20 +02:00
Andrei Alexeyev
e65a7f1b7f
resource/material: don't panic if failed to load 2021-12-28 09:00:20 +02:00
Andrei Alexeyev
dc52836af7
gl33: enable sRGB conversion when rendering to sRGB textures
This matches the gles30 behavior, which can not be changed without
relying on extensions. It also lets us simplify the texture_post_load
shader.
2021-12-22 22:46:59 +02:00
Andrei Alexeyev
136292357d
audio: partial refactor
Move SFXPlayID and sfx loop handling logic into the front end.
2021-09-01 19:55:36 +03:00
Andrei Alexeyev
e471837d4e
pbr: support ambient occlusion maps
AO maps modulate environment light
2021-09-01 00:48:59 +03:00