Change the menu font, fix windows blurriness

This commit is contained in:
Simon Gellis 2024-10-31 21:34:43 -04:00
parent f6ed4d6f27
commit 2ea4235771
4 changed files with 13 additions and 3 deletions

View File

@ -9,4 +9,9 @@ const uint8_t *LEFT_EYE_DEFAULT = &_binary_assets_lefteye_bin_start;
extern const uint8_t _binary_assets_righteye_bin_start;
const uint8_t *RIGHT_EYE_DEFAULT = &_binary_assets_righteye_bin_start;
extern const uint8_t _binary_assets_selawk_bin_start;
extern const uint8_t _binary_assets_selawk_bin_end;
const uint8_t *SELAWIK = &_binary_assets_selawk_bin_start;
#define SELAWIK_LEN (&_binary_assets_selawk_bin_end - &_binary_assets_selawk_bin_start)
#endif

BIN
assets/selawk.bin Normal file

Binary file not shown.

1
main.c
View File

@ -15,6 +15,7 @@ int main(int argc, char **argv) {
}
SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "0");
SDL_SetHint(SDL_HINT_WINDOWS_DPI_AWARENESS, "system");
if (SDL_Init(SDL_INIT_EVERYTHING)) {
fprintf(stderr, "Error initializing SDL: %s\n", SDL_GetError());
return 1;

View File

@ -1,3 +1,4 @@
#include "assets.h"
#include "nuklear.h"
#include "window.h"
@ -6,7 +7,7 @@
#define SCREEN_HEIGHT 224
static void setColorTable(struct nk_color *table) {
table[NK_COLOR_TEXT] = nk_rgb(80, 80, 80);
table[NK_COLOR_TEXT] = nk_rgb(40, 40, 40);
table[NK_COLOR_WINDOW] = nk_rgb(255, 255, 255);
table[NK_COLOR_HEADER] = nk_rgb(40, 40, 40);
table[NK_COLOR_BORDER] = nk_rgb(175, 175, 175);
@ -51,7 +52,7 @@ static void applyStyles(struct nk_context *ctx, float scaleX, float scaleY) {
ctx->style.menu_button.hover = nk_style_item_color(table[NK_COLOR_BUTTON_HOVER]);
ctx->style.menu_button.active = nk_style_item_color(table[NK_COLOR_BUTTON_ACTIVE]);
ctx->style.menu_button.padding = nk_vec2(2 * scaleX, 4 * scaleY);
ctx->style.menu_button.padding = nk_vec2(2 * scaleX, 2 * scaleY);
ctx->style.contextual_button.padding = nk_vec2(20 * scaleX, 4 * scaleY);
}
@ -113,9 +114,12 @@ int windowInit(WindowContext *win, const char *title) {
{
struct nk_font_atlas *atlas;
struct nk_font_config config = nk_font_config(0);
config.pixel_snap = 1;
config.oversample_h = 8;
config.oversample_v = 8;
nk_sdl_font_stash_begin(&atlas);
win->font = nk_font_atlas_add_default(atlas, 11 * win->screenScaleY, &config);
win->font = nk_font_atlas_add_from_memory(atlas, (void*) SELAWIK, SELAWIK_LEN, 13 * win->screenScaleY, &config);
nk_sdl_font_stash_end();
nk_style_set_font(win->nk, &win->font->handle);