summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-02-28 17:00:49 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-02-28 17:00:49 -0500
commit410b9b764c4a6c81a3573cf7ca23330d43931829 (patch)
tree9766f5245c9c71a8a67948ef8d2bb05613d74a01
parent52fd5e0c95da236fd14682ed8a7cfa34afbab2c0 (diff)
speed up debug build time
-rw-r--r--Makefile6
-rw-r--r--README.md3
-rw-r--r--credits.txt2
-rw-r--r--main.c3
-rw-r--r--stb_truetype.c4
-rw-r--r--text.c18
6 files changed, 32 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index b049cd4..4b163c4 100644
--- a/Makefile
+++ b/Makefile
@@ -7,8 +7,10 @@ PROFILE_CFLAGS=$(ALL_CFLAGS) -O3 -g -DPROFILE=1
GLOBAL_DATA_DIR=/usr/share/ted
LOCAL_DATA_DIR=/home/`logname`/.local/share/ted
INSTALL_BIN_DIR=/usr/bin
-ted: *.[ch] libpcre2-32.a
- $(CC) main.c -o ted $(DEBUG_CFLAGS) $(LIBS)
+ted: *.[ch] libpcre2-32.a stb_truetype.o
+ $(CC) main.c stb_truetype.o -o ted $(DEBUG_CFLAGS) $(LIBS)
+stb_truetype.o: stb_truetype.c
+ $(CC) $< -c -o $@
release: *.[ch] libpcre2-32.a
$(CC) main.c -o ted $(RELEASE_CFLAGS) $(LIBS)
profile: *.[ch] libpcre2-32.a
diff --git a/README.md b/README.md
index b0f7a22..32f2824 100644
--- a/README.md
+++ b/README.md
@@ -48,7 +48,8 @@ wget https://ftp.pcre.org/pub/pcre/pcre2-10.36.zip
sudo make install -j4
```
-On Windows (64-bit), you will need the SDL2 VC development libraries: https://www.libsdl.org/download-2.0.php
+On Windows (64-bit), first you will need to install Microsoft Visual Studio, then find and add vcvarsall.bat to your PATH.
+Next you will need the SDL2 VC development libraries: https://www.libsdl.org/download-2.0.php
Extract the zip, copy SDL2-2.x.y into the ted directory, and rename it to SDL2. Also copy SDL2\lib\x64\SDL2.dll
to the ted directory.
You will also need PCRE2. Download it here: https://ftp.pcre.org/pub/pcre/pcre2-10.36.zip,
diff --git a/credits.txt b/credits.txt
index ce26dd1..3f7a6f4 100644
--- a/credits.txt
+++ b/credits.txt
@@ -1,5 +1,5 @@
assets/font.ttf (Noto Sans Mono Regular), assets/font-bold.ttf (Noto Sans Mono Bold):
These are from the Noto font family, licensed under the Apache License, version 2.0, as found in apache2.txt.
They can be found here: https://www.google.com/get/noto/
-stb_truetype.h:
+lib/stb_truetype.h:
See https://github.com/nothings/stb
diff --git a/main.c b/main.c
index 6a03b82..5dc3d51 100644
--- a/main.c
+++ b/main.c
@@ -15,6 +15,9 @@ no_warn_start
#if _WIN32
#include <SDL.h>
#else
+#if DEBUG || __TINYC__ // speed up compile time on debug, also tcc doesn't have immintrin.h
+#define SDL_DISABLE_IMMINTRIN_H
+#endif
#include <SDL2/SDL.h>
#endif
no_warn_end
diff --git a/stb_truetype.c b/stb_truetype.c
new file mode 100644
index 0000000..444b245
--- /dev/null
+++ b/stb_truetype.c
@@ -0,0 +1,4 @@
+// used for debug build to speed things up
+// just exports everything in stb_truetype.h
+#define STB_TRUETYPE_IMPLEMENTATION
+#include "lib/stb_truetype.h"
diff --git a/text.c b/text.c
index 1096e8c..9e9246f 100644
--- a/text.c
+++ b/text.c
@@ -1,11 +1,29 @@
#include "base.h"
#include "text.h"
#include "unicode.h"
+#if DEBUG
+typedef struct
+{
+ unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap
+ float xoff,yoff,xadvance;
+} stbtt_bakedchar;
+typedef struct
+{
+ float x0,y0,s0,t0; // top-left
+ float x1,y1,s1,t1; // bottom-right
+} stbtt_aligned_quad;
+
+extern void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule);
+extern int stbtt_BakeFontBitmap(const unsigned char *data, int offset, float pixel_height, unsigned char *pixels, int pw, int ph, int first_char, int num_chars, stbtt_bakedchar *chardata);
+#else
#define STB_TRUETYPE_IMPLEMENTATION
#define STBTT_STATIC
no_warn_start
#include "lib/stb_truetype.h"
no_warn_end
+#endif
+
+
#include <stdlib.h>
// We split up code points into a bunch of pages, so we don't have to load all of the font at