From b58e9a3faa4e35ff6e872e28c7051fa19e2b11ad Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Wed, 25 Nov 2020 11:43:13 -0500 Subject: icon --- .gitignore | 1 + assets/icon.bmp | Bin 0 -> 8994 bytes assets/icon.ico | Bin 0 -> 4542 bytes buffer.c | 4 ++-- main.c | 7 ++++++- make.bat | 3 ++- ted.rc | 1 + text.h | 4 ++-- 8 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 assets/icon.bmp create mode 100644 assets/icon.ico create mode 100644 ted.rc diff --git a/.gitignore b/.gitignore index 163534b..c3220c4 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ TAGS *.dll *.pdb *.ilk +*.res SDL2 diff --git a/assets/icon.bmp b/assets/icon.bmp new file mode 100644 index 0000000..6809d69 Binary files /dev/null and b/assets/icon.bmp differ diff --git a/assets/icon.ico b/assets/icon.ico new file mode 100644 index 0000000..453dadf Binary files /dev/null and b/assets/icon.ico differ diff --git a/buffer.c b/buffer.c index 8641eb1..a1c0516 100644 --- a/buffer.c +++ b/buffer.c @@ -125,8 +125,8 @@ void text_buffer_render(TextBuffer *buffer, Font *font, float box_x, float box_y text_chars_begin(font); TextRenderState text_state = { .x = box_x, .y = box_y, - .edge_right = box_x+box_w, - .edge_bottom = box_y+box_h + .min_x = box_x, .min_y = box_y, + .max_x = box_x+box_w, .max_y = box_y+box_h }; for (uint block_idx = 0; block_idx < nblocks; ++block_idx) { diff --git a/main.c b/main.c index f2812f5..d4c61d9 100644 --- a/main.c +++ b/main.c @@ -43,6 +43,12 @@ int main(void) { if (!window) die("%s", SDL_GetError()); + { // set icon + SDL_Surface *icon = SDL_LoadBMP("assets/icon.bmp"); + SDL_SetWindowIcon(window, icon); + SDL_FreeSurface(icon); + } + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); SDL_GLContext *glctx = SDL_GL_CreateContext(window); @@ -95,7 +101,6 @@ int main(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1,1,1); - //text_render(font, "hellσ! öθ☺", 50, 50); text_buffer_render(&text_buffer, font, 50, window_heightf-50, window_widthf-100, window_heightf-100); if (text_has_err()) { printf("Text error: %s\n", text_get_err()); diff --git a/make.bat b/make.bat index ca72723..42eef65 100644 --- a/make.bat +++ b/make.bat @@ -5,7 +5,8 @@ if _%VCVARS% == _ ( ) SET CFLAGS=/nologo /W3 /D_CRT_SECURE_NO_WARNINGS /I SDL2/include SDL2/lib/x64/SDL2main.lib SDL2/lib/x64/SDL2.lib opengl32.lib -SET SOURCES=main.c text.c +rc /nologo ted.rc +SET SOURCES=main.c text.c ted.res if _%1 == _ ( cl %SOURCES% /DDEBUG /DEBUG /Zi %CFLAGS% /Fe:ted ) diff --git a/ted.rc b/ted.rc new file mode 100644 index 0000000..cd4466b --- /dev/null +++ b/ted.rc @@ -0,0 +1 @@ +icon ICON assets\icon.ico diff --git a/text.h b/text.h index 45cc6bb..9f0d351 100644 --- a/text.h +++ b/text.h @@ -12,8 +12,8 @@ typedef struct Font Font; typedef struct { float x, y; - // points at which the text should be cut off in the x and y directions - float edge_right, edge_bottom; + // points at which the text should be cut off + float min_x, max_x, min_y, max_y; } TextRenderState; extern bool text_has_err(void); -- cgit v1.2.3