├── LICENSE-noto_sans_regular.txt
├── LICENSE.md
├── README.md
├── build_static_lib.bat
├── build_static_lib.sh
├── build_static_lib_debug.bat
├── doc
├── vdb-logo.svg
└── vdb.svg
├── include
├── vdb.h
└── vdb
│ ├── compute.h
│ ├── imgui.h
│ ├── khrplatform.h
│ ├── opengl.h
│ ├── opengl_debug.h
│ ├── stb_image.h
│ └── stb_image_write.h
├── src
├── camera.h
├── colormap.h
├── config.h
├── data
│ ├── colormap_data.h
│ ├── generate_colormap_data.py
│ ├── noto_sans_regular.h
│ └── window_icon.h
├── framebuffer.h
├── framegrab.h
├── freetype.h
├── freetype
│ ├── FTL.TXT
│ ├── GPLv2.TXT
│ ├── LICENSE.TXT
│ ├── README.md
│ ├── include
│ │ ├── freetype
│ │ │ ├── config
│ │ │ │ ├── ftconfig.h
│ │ │ │ ├── ftheader.h
│ │ │ │ ├── ftmodule.h
│ │ │ │ ├── ftoption.h
│ │ │ │ └── ftstdlib.h
│ │ │ ├── freetype.h
│ │ │ ├── ftadvanc.h
│ │ │ ├── ftbbox.h
│ │ │ ├── ftbdf.h
│ │ │ ├── ftbitmap.h
│ │ │ ├── ftbzip2.h
│ │ │ ├── ftcache.h
│ │ │ ├── ftchapters.h
│ │ │ ├── ftcid.h
│ │ │ ├── ftdriver.h
│ │ │ ├── fterrdef.h
│ │ │ ├── fterrors.h
│ │ │ ├── ftfntfmt.h
│ │ │ ├── ftgasp.h
│ │ │ ├── ftglyph.h
│ │ │ ├── ftgxval.h
│ │ │ ├── ftgzip.h
│ │ │ ├── ftimage.h
│ │ │ ├── ftincrem.h
│ │ │ ├── ftlcdfil.h
│ │ │ ├── ftlist.h
│ │ │ ├── ftlzw.h
│ │ │ ├── ftmac.h
│ │ │ ├── ftmm.h
│ │ │ ├── ftmodapi.h
│ │ │ ├── ftmoderr.h
│ │ │ ├── ftotval.h
│ │ │ ├── ftoutln.h
│ │ │ ├── ftparams.h
│ │ │ ├── ftpfr.h
│ │ │ ├── ftrender.h
│ │ │ ├── ftsizes.h
│ │ │ ├── ftsnames.h
│ │ │ ├── ftstroke.h
│ │ │ ├── ftsynth.h
│ │ │ ├── ftsystem.h
│ │ │ ├── fttrigon.h
│ │ │ ├── fttypes.h
│ │ │ ├── ftwinfnt.h
│ │ │ ├── t1tables.h
│ │ │ ├── ttnameid.h
│ │ │ ├── tttables.h
│ │ │ └── tttags.h
│ │ └── ft2build.h
│ ├── win32
│ │ ├── freetype.dll
│ │ └── freetype.lib
│ └── win64
│ │ ├── freetype.dll
│ │ └── freetype.lib
├── glad
│ ├── glad_3_1_debug.c
│ └── glad_3_1_release.c
├── hints.h
├── image.h
├── imgui
│ ├── LICENSE.txt
│ ├── README.md
│ ├── imconfig.h
│ ├── imgui.cpp
│ ├── imgui_demo.cpp
│ ├── imgui_draw.cpp
│ ├── imgui_freetype.cpp
│ ├── imgui_freetype.h
│ ├── imgui_impl_opengl3.cpp
│ ├── imgui_impl_opengl3.h
│ ├── imgui_impl_sdl.cpp
│ ├── imgui_impl_sdl.h
│ ├── imgui_internal.h
│ ├── imgui_widgets.cpp
│ ├── imstb_rectpack.h
│ ├── imstb_textedit.h
│ └── imstb_truetype.h
├── immediate.h
├── immediate_util.h
├── keys.h
├── log.h
├── matrix.h
├── matrix_stack.h
├── mouse.h
├── render_scaler.h
├── render_target.h
├── ruler.h
├── settings.h
├── shader.h
├── shaders
│ ├── image.h
│ ├── lines.h
│ ├── points.h
│ ├── points_sprite.h
│ ├── thick_lines.h
│ └── triangles.h
├── sketch.h
├── style.h
├── transform.h
├── ui.h
├── vdb.cpp
├── widgets.h
└── window.h
└── test
├── Makefile
├── build.bat
└── test.cpp
/LICENSE-noto_sans_regular.txt:
--------------------------------------------------------------------------------
1 | Noto is a trademark of Google Inc. Noto fonts are open source. All Noto fonts are published under the SIL Open Font License, Version 1.1. Language data and some sample texts are from the Unicode CLDR project. Noto Sans is obtained from Google Web Fonts using the Apache License Version 2.0.
2 |
3 | Apache License Version 2.0
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License"); you
6 | may not use this file except in compliance with the License. You may
7 | obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 | implied. See the License for the specific language governing
15 | permissions and limitations under the License.
16 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT) Copyright (c) 2020 Simen Haugo
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |

2 | vdb - visual debugger
3 |
4 | vdb is a C++ library that lets you easily create interactive 2D/3D visualization breakpoints. It can be used for things like:
5 |
6 | * Analyzing intermediate results in steps of an algorithm
7 | * Visualizing and pre-processing 2D and 3D input data
8 | * Prototyping a GUI application for annotating data
9 |
10 | vdb runs on Windows, Linux and Mac OS, and requires only an OpenGL 3.1 compatible GPU (which even really old laptops have).
11 |
12 |
13 |
14 |
15 |
16 |
17 | **Basic example**
18 |
19 | vdb works like a breakpoint debugger:
20 |
21 | * you set breakpoints in your code by declaring named "blocks".
22 | * your visualization code goes inside the block.
23 | * inside the block you can access variables from outside.
24 |
25 | For example, here's a program that opens a window and clears the background color to red using data outside the breakpoint block.
26 |
27 | ```c++
28 | #include
29 | int main(int, char**) {
30 | float color[3] = { 1.0f, 0.3f, 0.1f };
31 |
32 | VDBB("Test window");
33 | vdbClear(color[0], color[1], color[2], 1.0f);
34 | VDBE();
35 |
36 | return 0;
37 | }
38 | ```
39 |
40 | This program only has one breakpoint, but your program can have many. As with a normal debugger, you can resume control flow and step to the next breakpoint.
41 |
42 | **Quick start**
43 |
44 | For a quick start, compile and run [test/test.cpp](test/test.cpp) by following the instructions inside the file. This is a self-contained program that uses the library to show off basic usage patterns.
45 |
46 | **Using vdb in your project**
47 |
48 | Once you are able to compile and run [test/test.cpp](test/test.cpp) you should be good to go integrate the library into your own project! Here are some tips to get you further:
49 |
50 | * Use [test/Makefile](test/Makefile) or [test/build.bat](test/build.bat) to build vdb in with your application
51 |
52 | * Learn to use vdb by running the **interactive guide** [test/test.cpp](test/test.cpp) and following along in the source code.
53 |
54 | * Learn to use **Dear ImGui** by visiting its [project page](https://github.com/ocornut/imgui/).
55 |
56 | **Using vdb in other languages**
57 |
58 | vdb is currently a C++ library, but it should be possible to create bindings to other languages (such as Python). If anyone would like to assist with this I would gladly accept pull requests.
59 |
--------------------------------------------------------------------------------
/build_static_lib.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | if not exist "lib" mkdir lib
4 | pushd lib
5 |
6 | set INCLUDES=-I..\include\ -I..\include\vdb\ -I%SDL2_DIR%\include -I..\src\freetype\include
7 | set FLAGS=-EHsc -MD -Oi -fp:fast -nologo -O2 -WX -W3 -wd4100 -wd4189 -wd4996 -wd4055
8 |
9 | cl %INCLUDES% %FLAGS% -c ..\src\vdb.cpp
10 | lib *.obj -nologo -out:vdb.lib
11 |
12 | popd
13 |
--------------------------------------------------------------------------------
/build_static_lib.sh:
--------------------------------------------------------------------------------
1 | # This compiles vdb into a library (libvdb.a) in the directory ./lib
2 | # Make sure you have SDL2 (https://www.libsdl.org/).
3 | # For example (linux): sudo apt-get install libsdl2-dev
4 |
5 | g++ -std=c++11 -c -O2 -fPIC -Werror -Wall src/vdb.cpp -Iinclude/vdb -Isrc/freetype/include -Iinclude `sdl2-config --cflags`
6 | mkdir -p lib
7 | ar rvs lib/libvdb.a vdb.o
8 | rm vdb.o
9 |
--------------------------------------------------------------------------------
/build_static_lib_debug.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | if not exist "lib" mkdir lib
4 | pushd lib
5 |
6 | set INCLUDES=-I..\include\ -I..\include\vdb\ -I%SDL2_DIR%\include -I..\src\freetype\include
7 | set FLAGS=-EHsc -MD -Zi -Oi -fp:fast -nologo -Od -WX -W3 -wd4100 -wd4189 -wd4996 -wd4055 -DVDB_DEBUG
8 |
9 | cl %INCLUDES% %FLAGS% -c ..\src\vdb.cpp
10 | lib *.obj -nologo -out:vdb.lib
11 |
12 | popd
13 |
--------------------------------------------------------------------------------
/doc/vdb-logo.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
22 |
--------------------------------------------------------------------------------
/doc/vdb.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
95 |
--------------------------------------------------------------------------------
/src/colormap.h:
--------------------------------------------------------------------------------
1 | #include "data/colormap_data.h"
2 |
3 | namespace colormap
4 | {
5 | static int current_colormap = 0;
6 | static int current_color = 0;
7 |
8 | static vdbColormapData *GetColormapData()
9 | {
10 | assert(current_colormap >= 0);
11 | assert(current_colormap < NUM_COLORMAPS);
12 | return &vdb_colormap_data[current_colormap];
13 | }
14 |
15 | static void NewFrame()
16 | {
17 | current_colormap = 0;
18 | }
19 |
20 | static void BeginFrame()
21 | {
22 | current_color = 0;
23 | }
24 | }
25 |
26 | vdbVec3 vdbGetForegroundColor()
27 | {
28 | if (settings.global_theme == VDB_DARK_THEME)
29 | return vdbVec3(1,1,1);
30 | else
31 | return vdbVec3(0,0,0);
32 | }
33 |
34 | vdbVec3 vdbGetBackgroundColor()
35 | {
36 | if (settings.global_theme == VDB_DARK_THEME)
37 | return vdbVec3(VDB_DARK_THEME_BACKGROUND);
38 | else
39 | return vdbVec3(VDB_BRIGHT_THEME_BACKGROUND);
40 | }
41 |
42 | int vdbSetColormap(const char *name)
43 | {
44 | int found = 0;
45 | for (int i = 0; i < NUM_COLORMAPS; i++)
46 | {
47 | if (strcmp(vdb_colormap_data[i].name, name) == 0)
48 | {
49 | found = i;
50 | break;
51 | }
52 | }
53 | assert(found >= 0);
54 | assert(found < NUM_COLORMAPS);
55 | colormap::current_colormap = found;
56 | colormap::current_color = 0;
57 | return vdb_colormap_data[found].num_colors;
58 | }
59 |
60 | void vdbColor4ub(unsigned char,unsigned char,unsigned char,unsigned char);
61 |
62 | vdbVec4 vdbNextColor()
63 | {
64 | int n = vdb_colormap_data[colormap::current_colormap].num_colors;
65 | int i = colormap::current_color;
66 | unsigned char *rgb = vdb_colormap_data[colormap::current_colormap].colors + 3*i;
67 | colormap::current_color = (colormap::current_color + 1) % n;
68 | unsigned char a8 = 255;
69 | vdbColor4ub(rgb[0], rgb[1], rgb[2], a8);
70 | return vdbVec4(rgb[0]/255.0f, rgb[1]/255.0f, rgb[2]/255.0f, a8/255.0f);
71 | }
72 |
73 | vdbVec4 vdbResetColor(int offset)
74 | {
75 | colormap::current_color = 0;
76 | int n = vdb_colormap_data[colormap::current_colormap].num_colors;
77 | int i = colormap::current_color;
78 | unsigned char *rgb = vdb_colormap_data[colormap::current_colormap].colors + 3*i;
79 | unsigned char a8 = 255;
80 | vdbColor4ub(rgb[0], rgb[1], rgb[2], a8);
81 | return vdbVec4(rgb[0]/255.0f, rgb[1]/255.0f, rgb[2]/255.0f, a8/255.0f);
82 | }
83 |
84 | vdbVec4 vdbGetColor(float t, float alpha)
85 | {
86 | int n = vdb_colormap_data[colormap::current_colormap].num_colors;
87 | int i = (int)(t*n);
88 | if (i < 0) i = 0;
89 | if (i > n-1) i = n-1;
90 | unsigned char *rgb = vdb_colormap_data[colormap::current_colormap].colors + 3*i;
91 | return vdbVec4(rgb[0]/255.0f, rgb[1]/255.0f, rgb[2]/255.0f, alpha);
92 | }
93 |
94 | vdbVec4 vdbGetColor(int i, float alpha)
95 | {
96 | int n = vdb_colormap_data[colormap::current_colormap].num_colors;
97 | i = (colormap::current_color + i) % n;
98 | unsigned char *rgb = vdb_colormap_data[colormap::current_colormap].colors + 3*i;
99 | return vdbVec4(rgb[0]/255.0f, rgb[1]/255.0f, rgb[2]/255.0f, alpha);
100 | }
101 |
102 | void vdbColor(float t, float alpha)
103 | {
104 | int n = vdb_colormap_data[colormap::current_colormap].num_colors;
105 | int i = (int)(t*n);
106 | if (i < 0) i = 0;
107 | if (i > n-1) i = n-1;
108 | unsigned char *rgb = vdb_colormap_data[colormap::current_colormap].colors + 3*i;
109 | int a8 = (int)(alpha*255.0f);
110 | if (a8 < 0) a8 = 0;
111 | if (a8 > 255) a8 = 255;
112 | vdbColor4ub(rgb[0], rgb[1], rgb[2], (unsigned char)a8);
113 | }
114 |
115 | void vdbColor(int i, float alpha)
116 | {
117 | int n = vdb_colormap_data[colormap::current_colormap].num_colors;
118 | i = (colormap::current_color + i) % n;
119 | unsigned char *rgb = vdb_colormap_data[colormap::current_colormap].colors + 3*i;
120 | int a8 = (int)(alpha*255.0f);
121 | if (a8 < 0) a8 = 0;
122 | if (a8 > 255) a8 = 255;
123 | vdbColor4ub(rgb[0], rgb[1], rgb[2], (unsigned char)a8);
124 | }
125 |
126 | void vdbColorForeground(float alpha)
127 | {
128 | vdbColor(vdbGetForegroundColor(), alpha);
129 | }
130 |
131 | void vdbColorBackground(float alpha)
132 | {
133 | vdbColor(vdbGetBackgroundColor(), alpha);
134 | }
135 |
--------------------------------------------------------------------------------
/src/config.h:
--------------------------------------------------------------------------------
1 | // COMPILE-TIME OPTIONS FOR VDB
2 | // You may edit this file in your local copy of vdb if you want to overwrite
3 | // the default configuration.
4 |
5 | // When enabled, ImGui will use FreeType for font rendering (less blurry for small
6 | // font sizes). Unless VDB_IMGUI_FREETYPE_DYNAMIC is enabled, you need to manually
7 | // link Freetype with your final executable. Precompiled library binaries for Win32
8 | // and Win64 are included in vdb/lib/freetype.
9 | #define VDB_IMGUI_FREETYPE 1
10 |
11 | // If enabled, VDB will try to locate freetype.dll on startup and link it for you
12 | // dynamically. This means you don't have to change the build system for your final
13 | // executable, and only need to make sure that freetype.dll is accessible (e.g. in
14 | // the same directory), and matches the version of the header files provided in
15 | // vdb/lib/freetype/include. If freetype.dll is not found, freetype is not used.
16 | #define VDB_IMGUI_FREETYPE_DYNAMIC 1
17 |
18 | // For small font sizes I recommend using the Freetype renderer.
19 | #define VDB_DEFAULT_FONT_SIZE 18
20 |
21 | // Set to > 0 to get smooth edges on points, lines and triangles.
22 | #define VDB_MULTISAMPLES 4
23 |
24 | // Set to > 0 to be able to take screenshots with transparent backgrounds.
25 | #define VDB_ALPHABITS 8
26 |
27 | // Set to > 0 if you want to use the OpenGL stencil operations.
28 | #define VDB_STENCILBITS 8
29 |
30 | // Set to > 0 if you want to use OpenGL depth testing.
31 | #define VDB_DEPTHBITS 24
32 |
33 | // The size of the vdb window is remembered between sessions.
34 | // This path specifies the path (relative to working directory)
35 | // where the information is stored.
36 | #define VDB_SETTINGS_FILENAME "./vdb.ini"
37 |
38 | // Number of frames to pass between saving settings to disk
39 | #define VDB_SAVE_SETTINGS_PERIOD 60*5
40 |
41 | // When true, save settings every SAVE_SAVE_SETTINGS_PERIOD frame
42 | #define VDB_SAVE_SETTINGS_REGULARLY false
43 |
44 | // The state of ImGui windows is remembered between sessions.
45 | // This path specifies the path (relative to working directory)
46 | // where the information is stored.
47 | #define VDB_IMGUI_INI_FILENAME "./imgui.ini"
48 |
49 | #define VDB_HOTKEY_FRAMEGRAB (keys::pressed[VDB_KEY_S] && keys::down[VDB_KEY_LALT])
50 | #define VDB_HOTKEY_WINDOW_SIZE (keys::pressed[VDB_KEY_W] && keys::down[VDB_KEY_LALT])
51 | #define VDB_HOTKEY_SKETCH_MODE (keys::pressed[VDB_KEY_D] && keys::down[VDB_KEY_LALT])
52 | #define VDB_HOTKEY_RULER_MODE (keys::pressed[VDB_KEY_R] && keys::down[VDB_KEY_LALT])
53 | #define VDB_HOTKEY_TOGGLE_MENU (keys::pressed[VDB_KEY_M] && keys::down[VDB_KEY_LALT])
54 | #define VDB_HOTKEY_LOGS_WINDOW (keys::pressed[VDB_KEY_L] && keys::down[VDB_KEY_LALT])
55 | #define VDB_HOTKEY_AUTO_STEP (keys::pressed[VDB_KEY_F6])
56 |
57 | // Colors for standard themes
58 | #define VDB_DARK_THEME_BACKGROUND 0.22f, 0.22f, 0.22f
59 | #define VDB_DARK_THEME_X_AXIS 0.89f, 0.38f, 0.45f
60 | #define VDB_DARK_THEME_Y_AXIS 0.54f, 0.85f, 0.00f
61 | #define VDB_DARK_THEME_Z_AXIS 0.16f, 0.56f, 1.00f
62 | #define VDB_DARK_THEME_GRID_LINES 1.00f, 1.00f, 1.00f
63 | #define VDB_BRIGHT_THEME_BACKGROUND 1.00f, 1.00f, 1.00f
64 | #define VDB_BRIGHT_THEME_X_AXIS 0.71f, 0.05f, 0.10f
65 | #define VDB_BRIGHT_THEME_Y_AXIS 0.06f, 0.50f, 0.04f
66 | #define VDB_BRIGHT_THEME_Z_AXIS 0.20f, 0.40f, 0.84f
67 | #define VDB_BRIGHT_THEME_GRID_LINES 0.00f, 0.00f, 0.00f
68 |
--------------------------------------------------------------------------------
/src/data/generate_colormap_data.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import matplotlib.pyplot as plt
3 | from collections import OrderedDict
4 |
5 | cmaps = OrderedDict()
6 |
7 | cmaps['Perceptually Uniform Sequential'] = [
8 | 'viridis', 'plasma', 'inferno', 'magma', 'cividis']
9 |
10 | cmaps['Sequential'] = [
11 | 'Greys', 'Purples', 'Blues', 'Greens', 'Oranges', 'Reds',
12 | 'YlOrBr', 'YlOrRd', 'OrRd', 'PuRd', 'RdPu', 'BuPu',
13 | 'GnBu', 'PuBu', 'YlGnBu', 'PuBuGn', 'BuGn', 'YlGn', 'gray']
14 |
15 | cmaps['Diverging'] = [
16 | 'PiYG', 'PRGn', 'BrBG', 'PuOr', 'RdGy', 'RdBu',
17 | 'RdYlBu', 'RdYlGn', 'Spectral', 'coolwarm', 'bwr', 'seismic']
18 |
19 | cmaps['Cyclic'] = ['twilight', 'twilight_shifted', 'hsv']
20 |
21 | cmaps['Qualitative'] = ['Pastel1', 'Pastel2', 'Paired', 'Accent',
22 | 'Dark2', 'Set1', 'Set2', 'Set3',
23 | 'tab10', 'tab20', 'tab20b', 'tab20c']
24 |
25 | cmaps['Miscellaneous'] = [
26 | 'flag', 'prism', 'ocean', 'gist_earth', 'terrain', 'gist_stern',
27 | 'gnuplot', 'gnuplot2', 'CMRmap', 'cubehelix', 'brg',
28 | 'gist_rainbow', 'rainbow', 'jet', 'nipy_spectral', 'gist_ncar']
29 |
30 | def f32_to_u08(x):
31 | i = int(x*255.0)
32 | if i < 0:
33 | return 0
34 | elif i > 255:
35 | return 255
36 | else:
37 | return i
38 |
39 | print('// This file is automatically generated.')
40 | print('// Colormap data is obtained from Matplotlib:')
41 | print('// https://matplotlib.org/tutorials/colors/colormaps.html')
42 |
43 | print("""
44 | struct vdbColormapData
45 | {
46 | const char *name;
47 | int num_colors;
48 | GLuint gl_texture;
49 | unsigned char colors[3*1024];
50 | };""")
51 |
52 | print('#define NUM_COLORMAPS (sizeof(vdb_colormap_data)/sizeof(vdb_colormap_data[0]))')
53 |
54 | print("static vdbColormapData vdb_colormap_data[] = \n{")
55 | for cmap_category, names in cmaps.items():
56 | for name in names:
57 | if name == 'gray':
58 | r = np.arange(256)/255.0
59 | colors = np.vstack((r,r,r)).T
60 | else:
61 | cmap = plt.cm.get_cmap(name)
62 | if hasattr(cmap, 'colors'):
63 | colors = cmap.colors
64 | else:
65 | colors = cmap(np.linspace(0.0,1.0,256))
66 | colors = colors[:,:3]
67 | print(' {')
68 | print(' \"%s\",' % name)
69 | print(' %d,' % len(colors))
70 | print(' 0,')
71 | for r,g,b in colors:
72 | r8 = f32_to_u08(r)
73 | g8 = f32_to_u08(g)
74 | b8 = f32_to_u08(b)
75 | print(' %d, %d, %d,' % (r8,g8,b8))
76 | print(' },')
77 | num_colormaps += 1
78 | print("};")
79 |
80 |
--------------------------------------------------------------------------------
/src/data/window_icon.h:
--------------------------------------------------------------------------------
1 | // File: 'icon2.png' (2336 bytes)
2 | // Exported using binary_to_compressed_c.cpp
3 | static const unsigned int window_icon_size = 2336;
4 | static const unsigned int window_icon_data[2336/4] =
5 | {
6 | 0x474e5089, 0x0a1a0a0d, 0x0d000000, 0x52444849, 0x80000000, 0x80000000, 0x00000608, 0x613ec300, 0x000000cb, 0x49427304, 0x08080854, 0x64087c08,
7 | 0x00000088, 0x59487009, 0x0d000073, 0x0d0000d7, 0x284201d7, 0x0000789b, 0x45741900, 0x6f537458, 0x61777466, 0x77006572, 0x692e7777, 0x63736b6e,
8 | 0x2e657061, 0x9b67726f, 0x001a3cee, 0x499d0800, 0x78544144, 0x6d9ded9c, 0x1d451e8c, 0x97db7fc0, 0x2223116b, 0x31115114, 0x055cc2f8, 0x930f5da9,
9 | 0x16c5a486, 0x1101b044, 0x80944d4c, 0x7cb6bb49, 0xb410b150, 0x0631a0b1, 0xb628a349, 0xa1fac553, 0x8a4a870d, 0x68989ad4, 0x244289a4, 0xe848529d,
10 | 0x06aa04ad, 0x4adaa4a3, 0xb85f4978, 0x761fadeb, 0xfb77b42f, 0xff2fb73c, 0x9ddd9e7d, 0x767c7df9, 0x7bff3fe7, 0x73b377e6, 0x5e733b33, 0xec384514,
11 | 0x13bf4665, 0x2717f470, 0x0138e580, 0x6009c72c, 0xcb004e39, 0x8e580271, 0x9c72c013, 0x04e39600, 0x80271cb0, 0x2c0138e5, 0x396009c7, 0x71cb004e,
12 | 0x138e5802, 0xf56672c0, 0xe13a813b, 0x819be107, 0xff568cd3, 0x6f7d51ea, 0x6ff01403, 0xab461fe0, 0x619cbf9e, 0x107e00b5, 0x808602ce, 0xe032c0a5,
13 | 0xe011e012, 0xf4eb0afa, 0x8b813b81, 0x709d7781, 0x083f35e9, 0x19b6019f, 0x555c7ead, 0x6cf193fd, 0x0fc8237b, 0x37120fc2, 0x096052f6, 0xb74996f0,
14 | 0x699c02bc, 0xae151ab4, 0x0df01677, 0xffd31d60, 0x6e04ede2, 0x941d5a32, 0xd68d21cc, 0xe107e00b, 0x3d8dc459, 0x4e7e5bf1, 0x8ccb6286, 0xcc107f56,
15 | 0x077e03c1, 0xd8a39e5c, 0x4685c00b, 0xf2a457ab, 0x8f75a348, 0xdf083f00, 0xdc4a5c04, 0x0b80cbd8, 0x98672f01, 0x013101ab, 0x6be49580, 0x8173807c,
16 | 0x135f026f, 0x8d0a63cc, 0x20fc01ef, 0xe42c019c, 0x117d6e8d, 0xec325030, 0xfbd5a37e, 0xe006e6ca, 0xc039e107, 0x6a3ea63e, 0x5c0a30b2, 0xabfab464,
17 | 0x34692e44, 0x83f007b2, 0x68de7cf0, 0xd380cbf0, 0xdf38ab85, 0x840bc20f, 0x1495f8be, 0xd9807c6b, 0x15c0bdc0, 0xd2a47902, 0x3f0079b8, 0xe7818708,
18 | 0x75c04d81, 0x04fe37c8, 0x738a129f, 0x97f2c951, 0x01f841fb, 0x68524c91, 0xd754009c, 0x5ab993e0, 0x01594e28, 0xc40be600, 0x0289a548, 0x0afc0d3c,
19 | 0x0f7011f8, 0x22789db0, 0x7e459a45, 0xcd929610, 0xc0d9c20f, 0x0cb90279, 0xa548c40a, 0xa3006371, 0x3f93edd5, 0x14f083f3, 0x04f12d60, 0x7f11de4b,
20 | 0x57026627, 0x0d140f02, 0xf51ab460, 0xe005f083, 0x7173253d, 0x8c37403d, 0x568c4756, 0x2dbe02df, 0x40997a1c, 0x6205278c, 0x464031b8, 0x087604ee,
21 | 0x10205bc6, 0x8c40b763, 0x52310263, 0xc9009569, 0xc02dca62, 0x95485098, 0xb0cbc73c, 0x64b17811, 0xcb25038c, 0x0255a477, 0xfead1800, 0x142c3c09,
22 | 0x0392806e, 0xcbd5a330, 0xe19652c4, 0x77cb253f, 0x240275a4, 0xeb182bdc, 0x180365c3, 0xbf03b6ad, 0xf5c2112e, 0x5a307900, 0x4dfc063d, 0x42c5dc28,
23 | 0x5e216e71, 0x15422c69, 0x2d02e67f, 0x8f612015, 0x3dd29c50, 0x92f24000, 0x8b051dc9, 0x872259ff, 0xc02cda34, 0x2238a15e, 0x066c2402, 0x79967246,
24 | 0x4fb568d1, 0x70938730, 0x19cf4c02, 0x695e8ac9, 0x81c7568c, 0xd3591329, 0xba897bf0, 0xc804e13b, 0x0038d486, 0x604ed5a3, 0x4e228e57, 0xad182280,
25 | 0x7837200e, 0x000c7c92, 0xbef19fdc, 0xa5009c51, 0x0038e3a8, 0xf78ca9e0, 0x5722270d, 0x1b201386, 0xcf71abd2, 0x6ef4fd32, 0xb84f7c04, 0x5db429de,
26 | 0xe2856780, 0x0e2853bc, 0x31ab4600, 0x07bdba60, 0xf472adbf, 0x05db413f, 0x9c031a90, 0x5ce107ee, 0x1b1358a1, 0xe69bce50, 0xeaa5bbb6, 0x05db46eb,
27 | 0x73e1dc90, 0x85ac60b6, 0x1feeff74, 0x36555a33, 0x6d2273f9, 0x0a724017, 0xb1821df5, 0x2d72e92e, 0xac156e02, 0x16ad2bab, 0x2af568c0, 0x3850aaf0,
28 | 0x50c071c9, 0x8c5b6b97, 0xd6084f56, 0x0b5695d5, 0x0bd52090, 0x7e00f488, 0x7c069e10, 0x97e5c3bc, 0x505ebe28, 0x76402708, 0x6b011ea4, 0xb876b781,
29 | 0xf568ceb6, 0x327aa15f, 0x52008361, 0x02d2c103, 0xbf14fb24, 0x53f2e1dc, 0x3d458bc4, 0xea0106c5, 0x1d7c03d4, 0xf3e53538, 0x2c935808, 0x1b14f516,
30 | 0x0f45a804, 0xb9e107e0, 0xf2e1d040, 0xe3d5a306, 0xc517e265, 0xd2ea0106, 0xe607ac03, 0x886e7ca4, 0xe0be867b, 0xbccec804, 0xdc8790e4, 0x49f841f8,
31 | 0x4b94a6e0, 0xa42b01af, 0x83c8a30f, 0x3d48020d, 0xace03c02, 0x20fc85bc, 0x8db02f7c, 0xab4b1df4, 0x97cf568d, 0x360cac4d, 0x67f92008, 0xae00da55,
32 | 0xb596c923, 0x686fa4ed, 0xdab466dd, 0x0955922a, 0xd1802f5a, 0x352030ea, 0xf07bceba, 0xdfd226c4, 0xac0fda26, 0x794e9f2e, 0x82402f5a, 0x993b39d4,
33 | 0x41f90977, 0x76370018, 0x64bae5c8, 0xd8efba9a, 0x97d48022, 0xf007a99d, 0xf4887083, 0x03af29cd, 0x9ead1ad7, 0x34a7ca16, 0xd52008b6, 0x802b4c03,
34 | 0x80f3841f, 0x8dee5287, 0x568d1b80, 0x45ca147f, 0x3e402704, 0x07e00aba, 0xfbc4a9e1, 0x729ddf12, 0xd5a356f9, 0x88794283, 0x47c804e1, 0x11920147,
35 | 0x53e24eff, 0xc1b326ca, 0xa17df568, 0x45b1441c, 0x00c74a80, 0x3b62ebc9, 0x9729c580, 0x015e201f, 0x08b625ac, 0xe00f5950, 0xe21ce107, 0xca697f6e,
36 | 0x2f815bfd, 0xe810e3f4, 0xf20138ac, 0x7e009271, 0x0f100e10, 0x72913ef8, 0xf41e26af, 0x2f857cf5, 0x243b8d0f, 0x8fe220aa, 0xe05d6480, 0x271fa417,
37 | 0xead18f77, 0x2b3aa136, 0xf900f5c5, 0x83f00018, 0x0c302670, 0xcf72935c, 0x3e34a6fa, 0x8803d3d8, 0xfe349009, 0x2933e056, 0xd75abfd7, 0x9c277ed1,
38 | 0x0b98f900, 0x31581cfc, 0x2071f3e9, 0x54fd5a30, 0x619e9ea8, 0x6352008b, 0x7980db80, 0x231b3e93, 0x0b0fe91e, 0x6c53d1d5, 0x07aa4011, 0xc7f8dc98,
39 | 0xad1acf80, 0xdf8a111e, 0xc5009c73, 0x635c0c39, 0xff74aab4, 0x0138d57e, 0x7032f18a, 0x591a7255, 0x0045b1a3, 0x43f7b5c9, 0x2b4615c0, 0xfac853a9,
40 | 0xc8079b8a, 0x4581dfc7, 0xb07c696d, 0xade48044, 0xc325a3db, 0x663e06ec, 0x743a92b4, 0x215816a2, 0x5e994240, 0xd8b00760, 0x99d95568, 0x26c2fdbd,
41 | 0x038e8a01, 0x8d7e23ee, 0x3264b0eb, 0x4196c175, 0x01efe420, 0xd1ad6022, 0xc915436a, 0x049b05d4, 0x7b2cb3c8, 0xd1bcf814, 0x92aaa1ea, 0x09360ba9,
42 | 0xfe9df590, 0x7ef2c043, 0x35ecd66d, 0xd993804e, 0xb4695c0f, 0x64eaae7a, 0x834d82ea, 0xf804e9c0, 0x799ff10b, 0xd83e34d6, 0xd6da4025, 0x03b609ec,
43 | 0xdfe2f597, 0x9b0dd7b5, 0x03d4e804, 0xdeb800fc, 0x97a47568, 0x9b05d4c9, 0xc0e300c7, 0x3f568c57, 0x753247ec, 0x8e0156c1, 0x5a339f00, 0x4e47f995,
44 | 0x0126c0ad, 0x3817e222, 0xee9f010e, 0x758c61e5, 0xdaa28bc6, 0xf47059ee, 0x81069b00, 0x009c148e, 0xb004e396, 0xe580271c, 0xc72c0138, 0x4e396009,
45 | 0x0271cb00, 0x052b4e58, 0x2ed77258, 0x4b38669b, 0xc0999ad1, 0x591eae8f, 0xcb7b8d1e, 0x9a21f3c1, 0x0c041c0f, 0xc607bb78, 0xfc7befc6, 0xf5ffc1fe,
46 | 0xd23ac73b, 0xd6860178, 0x7e3d9c8c, 0x5c08dbdc, 0x03b6e5db, 0xf697c791, 0xf70f526c, 0x50a6af2a, 0x87bb805a, 0x70dd940f, 0x2bedca91, 0x3fed3ede,
47 | 0x84105c6a, 0x4f099fef, 0xf3187e90, 0xef88a214, 0xd6acd9ec, 0xaab7b965, 0x2c9a4b9f, 0x243753df, 0xdedd959e, 0xcf0ca9b4, 0x8ab85bc3, 0xf1b1919f,
48 | 0xf8773293, 0x637e46ab, 0x59660f36, 0xcfcbec09, 0x3b1a6bd5, 0xcac8fc08, 0x69703570, 0xf03362ce, 0xba1f2dbc, 0xa9ef2461, 0xb1a5addf, 0x371e7802,
49 | 0x383a2c17, 0xffaecce7, 0x1a2ad3b9, 0x6abf8029, 0x7e606ccf, 0x71def2d1, 0xd3a60816, 0xc0291a68, 0x907737b8, 0xcf68cf32, 0x23413009, 0xd1c87005,
50 | 0x44660148, 0xdf884747, 0xc4462bef, 0x9a6cb95e, 0x3005234d, 0x028e179b, 0x8f968afb, 0x26013a66, 0x0000a468, 0x8296c451, 0x1d8e4745, 0x9c11bdc4,
51 | 0x9e0158d0, 0x08da89fc, 0xb16729fc, 0xe6e8a271, 0xf8397e67, 0x3539157a, 0x100ac691, 0xe1c74445, 0x394bc08b, 0xe3377cca, 0x9435a02c, 0x7a3e0a9e,
52 | 0x1229c8ec, 0xaf611489, 0xad0dcf56, 0xbccc1919, 0x2fb3a418, 0xe7f3f506, 0x5f8d25ea, 0x2dc09c0d, 0x35a31707, 0x92c89c02, 0x7acd76bb, 0xb1e2fd74,
53 | 0x04d1e77e, 0x2380295a, 0x041d8d3b, 0x0270643a, 0xc0138e58, 0x96009c72, 0x1cb004e3, 0x38e58027, 0x09c72c01, 0x004e3960, 0x580271cb, 0x72c0138e,
54 | 0xe396009c, 0x271cb004, 0x1ffce580, 0x722fcefa, 0x8e0b05c9, 0x00000000, 0x444e4549, 0x826042ae,
55 | };
56 |
57 |
--------------------------------------------------------------------------------
/src/framebuffer.h:
--------------------------------------------------------------------------------
1 | struct framebuffer_t
2 | {
3 | GLuint fbo; // usage: glBindFramebuffer(GL_FRAMEBUFFER, fbo)
4 | GLuint *color; // usage: glBindTexture(GL_TEXTURE_2D, color[i])
5 | GLuint depth;
6 | int width, height; // usage: glViewport(0, 0, width, height)
7 | int num_color_attachments;
8 | GLint last_viewport[4];
9 | framebuffer_t *last_framebuffer;
10 |
11 | GLenum internal_format;
12 | };
13 |
14 | static framebuffer_t *current_framebuffer = NULL;
15 |
16 | static void EnableFramebuffer(framebuffer_t *fb)
17 | {
18 | fb->last_framebuffer = current_framebuffer;
19 | glGetIntegerv(GL_VIEWPORT, fb->last_viewport);
20 | glBindFramebuffer(GL_FRAMEBUFFER, fb->fbo);
21 | vdbViewporti(0, 0, fb->width, fb->height);
22 | current_framebuffer = fb;
23 | }
24 |
25 | static void DisableFramebuffer(framebuffer_t *fb)
26 | {
27 | current_framebuffer = fb->last_framebuffer;
28 | if (current_framebuffer) glBindFramebuffer(GL_FRAMEBUFFER, current_framebuffer->fbo);
29 | else glBindFramebuffer(GL_FRAMEBUFFER, 0);
30 | vdbViewporti(fb->last_viewport[0], fb->last_viewport[1], fb->last_viewport[2], fb->last_viewport[3]);
31 | }
32 |
33 | static void FreeFramebuffer(framebuffer_t *fb)
34 | {
35 | if (fb->fbo) glDeleteFramebuffers(1, &fb->fbo);
36 | if (fb->depth) glDeleteRenderbuffers(1, &fb->depth);
37 | if (fb->color)
38 | {
39 | for (int i = 0; i < fb->num_color_attachments; i++)
40 | glDeleteTextures(1, &fb->color[i]);
41 | free(fb->color);
42 | fb->color = NULL;
43 | }
44 | fb->num_color_attachments = 0;
45 | fb->width = 0;
46 | fb->height = 0;
47 | fb->fbo = 0;
48 | fb->depth = 0;
49 | }
50 |
51 | static framebuffer_t MakeFramebuffer(
52 | int width, int height,
53 | GLenum mag_filter=GL_LINEAR,
54 | GLenum min_filter=GL_LINEAR,
55 | bool enable_depth=false,
56 | GLenum internal_format=GL_RGBA,
57 | int num_color_attachments = 1)
58 | {
59 | static GLint max_color_attachments = 0;
60 | if (!max_color_attachments)
61 | glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
62 | assert(num_color_attachments <= max_color_attachments && "Number of requested color attachments exceeds device capabilities");
63 |
64 | framebuffer_t result = {0};
65 | result.width = width;
66 | result.height = height;
67 | result.num_color_attachments = num_color_attachments;
68 |
69 | glGenFramebuffers(1, &result.fbo);
70 | glBindFramebuffer(GL_FRAMEBUFFER, result.fbo);
71 |
72 | result.color = new GLuint[num_color_attachments];
73 | for (int i = 0; i < num_color_attachments; i++)
74 | {
75 | GLuint color = TexImage2D(NULL, width, height, GL_RGBA, GL_UNSIGNED_BYTE,
76 | mag_filter, min_filter, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE,
77 | internal_format);
78 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, color, 0);
79 | result.color[i] = color;
80 | result.internal_format = internal_format;
81 | }
82 |
83 | if (enable_depth)
84 | {
85 | // DEPTH_COMPONENT16
86 | // DEPTH_COMPONENT24
87 | // DEPTH_COMPONENT32
88 | // DEPTH_COMPONENT32F
89 | result.depth = TexImage2D(NULL, width, height, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, GL_NEAREST, GL_NEAREST, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, GL_DEPTH_COMPONENT24);
90 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, result.depth, 0);
91 | }
92 |
93 | GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
94 | assert(status == GL_FRAMEBUFFER_COMPLETE);
95 | glBindFramebuffer(GL_FRAMEBUFFER, 0);
96 |
97 | return result;
98 | }
99 |
--------------------------------------------------------------------------------
/src/framegrab.h:
--------------------------------------------------------------------------------
1 | struct framegrab_options_t
2 | {
3 | const char *filename; // If no extension is provided, file will be saved as .bmp.
4 | // If %d is present, it will be filled with screenshot counter
5 |
6 | bool alpha_channel;
7 | bool draw_imgui; // If disabled ImGui will not render at all (including overlays)
8 | bool draw_cursor; // If draw_imgui is false the cursor is a crosshair
9 |
10 | bool reset_counter; // Reset screenshot or image sequence counter
11 | int start_from; // Set initial screenshot or image sequence counter
12 |
13 | float ffmpeg_fps;
14 | int ffmpeg_crf; // Quality (lower is better)
15 | int video_frame_cap; // Stop after capturing this number of frames (0 -> no limit, call StopRecording to stop)
16 | };
17 |
18 | #ifdef _MSC_VER
19 | #define popen _popen
20 | #define pclose _pclose
21 | #endif
22 |
23 | namespace framegrab
24 | {
25 | enum framegrab_mode_t { MODE_SCREENSHOT, MODE_SEQUENCE, MODE_FFMPEG };
26 | static framegrab_options_t options;
27 | static framegrab_mode_t mode;
28 | static bool active;
29 | static int num_frames;
30 | static int suffix_counter;
31 | static bool should_stop;
32 |
33 | static void StopRecording()
34 | {
35 | should_stop = true;
36 | }
37 |
38 | static void StartFramegrab(framegrab_options_t _options)
39 | {
40 | options = _options;
41 | if (options.reset_counter)
42 | suffix_counter = options.start_from;
43 | num_frames = 0;
44 | active = true;
45 | should_stop = false;
46 | }
47 |
48 | static void TakeScreenshot(framegrab_options_t _options)
49 | // Save the back framebuffer of the current frame to file.
50 | {
51 | mode = MODE_SCREENSHOT;
52 | StartFramegrab(_options);
53 | }
54 |
55 | static void RecordImageSequence(framegrab_options_t _options)
56 | // Save the back framebuffer of the current and each subsequent frame to file.
57 | {
58 | mode = MODE_SEQUENCE;
59 | StartFramegrab(_options);
60 | }
61 |
62 | static void RecordFFmpeg(framegrab_options_t _options)
63 | // Pipe the back framebuffer of the current and each subsequent frame to ffmpeg.
64 | // The function uses _popen to open a pipe, and assumes that the ffmpeg executable is present on the
65 | // terminal that the application ran from (in the PATH variable). If you're on Windows, you will want
66 | // to change your PATH environment variable to point to the folder holding the ffmpeg executable.
67 | {
68 | mode = MODE_FFMPEG;
69 | StartFramegrab(_options);
70 | }
71 |
72 | static void SaveFrame(unsigned char *data,
73 | int width,
74 | int height,
75 | int channels,
76 | GLenum format)
77 | {
78 | if (mode == MODE_FFMPEG)
79 | {
80 | static FILE *ffmpeg = 0;
81 | if (!ffmpeg)
82 | {
83 | // todo: linux/osx
84 | char cmd[1024];
85 | sprintf(cmd, "ffmpeg -r %f -f rawvideo -pix_fmt %s -s %dx%d -i - "
86 | "-threads 0 -preset fast -y -pix_fmt yuv420p -crf %d -vf vflip %s",
87 | options.ffmpeg_fps, // -r
88 | options.alpha_channel ? "rgba" : "rgb24", // -pix_fmt
89 | width, height, // -s
90 | options.ffmpeg_crf, // -crf
91 | options.filename);
92 | ffmpeg = popen(cmd, "wb");
93 | }
94 |
95 | fwrite(data, width*height*channels, 1, ffmpeg);
96 |
97 | num_frames++;
98 | if (options.video_frame_cap && num_frames == options.video_frame_cap)
99 | {
100 | StopRecording();
101 | }
102 | if (should_stop)
103 | {
104 | active = false;
105 | pclose(ffmpeg);
106 | ffmpeg = 0;
107 | }
108 | }
109 | else
110 | {
111 | bool save_as_bmp = false;
112 | bool save_as_png = false;
113 |
114 | if (strstr(options.filename, ".png"))
115 | {
116 | save_as_png = true;
117 | save_as_bmp = false;
118 | }
119 | else if (strstr(options.filename, ".bmp"))
120 | {
121 | save_as_bmp = true;
122 | save_as_png = false;
123 | }
124 | else
125 | {
126 | save_as_bmp = false;
127 | save_as_png = false;
128 | // did user specify any extension at all?
129 | }
130 |
131 | // todo: what happens if filename doesn't contain a %d?
132 | char filename[1024];
133 | sprintf(filename, options.filename, suffix_counter);
134 | suffix_counter++;
135 |
136 | if (save_as_bmp)
137 | {
138 | stbi_write_bmp(filename, width, height, channels, data);
139 | printf("Saved %s...\n", filename);
140 | }
141 | else if (save_as_png)
142 | {
143 | int stride = width*channels;
144 | stbi_write_png(filename, width, height, channels, data+stride*(height-1), -stride);
145 | printf("Saved %s...\n", filename);
146 | }
147 | else
148 | {
149 | stbi_write_bmp(filename, width, height, channels, data);
150 | printf("Saved %s (bmp)...\n", filename);
151 | }
152 |
153 | if (mode == MODE_SEQUENCE)
154 | {
155 | num_frames++;
156 | if (options.video_frame_cap > 0 && num_frames == options.video_frame_cap)
157 | {
158 | StopRecording();
159 | }
160 | if (should_stop)
161 | {
162 | active = false;
163 | }
164 | }
165 | else
166 | {
167 | active = false;
168 | }
169 | }
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/src/freetype.h:
--------------------------------------------------------------------------------
1 | // Obs! When copying latest version of ImGui into VDB, you need to disable
2 | // freetype includes in imgui_freetype.cpp in the unity build.
3 |
4 | // Obs! This file must be included before ImGui that uses freetype functions
5 | // because we redefine them. This is so that we don't have to change the ImGui
6 | // source code to use differently named functions (allow for easy updates).
7 | #if VDB_IMGUI_FREETYPE_DYNAMIC==1
8 | #include
9 | #include FT_FREETYPE_H
10 | #include FT_GLYPH_H
11 | #include FT_SYNTHESIS_H
12 | #include FT_MODULE_H
13 | typedef FT_Error (*PFNFTNEWLIBRARY)(FT_Memory memory, FT_Library *alibrary);
14 | typedef FT_Error (*PFNFTDONELIBRARY)(FT_Library library);
15 | typedef void (*PFNFTADDDEFAULTMODULES)(FT_Library library);
16 | typedef FT_Error (*PFNFTINITFREETYPE)(FT_Library *alibrary);
17 | typedef FT_Error (*PFNFTRENDERGLYPH)(FT_GlyphSlot slot, FT_Render_Mode render_mode);
18 | typedef FT_Error (*PFNFTNEWMEMORYFACE)(FT_Library library, const FT_Byte* file_base, FT_Long file_size, FT_Long face_index, FT_Face *aface);
19 | typedef FT_Error (*PFNFTSELECTCHARMAP)(FT_Face face, FT_Encoding encoding);
20 | typedef FT_Error (*PFNFTDONEFACE)(FT_Face face);
21 | typedef FT_Error (*PFNFTDONEFREETYPE)(FT_Library library);
22 | typedef FT_Error (*PFNFTREQUESTSIZE)(FT_Face face, FT_Size_Request req);
23 | typedef FT_UInt (*PFNFTGETCHARINDEX)(FT_Face face, FT_ULong charcode);
24 | typedef FT_Error (*PFNFTLOADGLYPH)(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags);
25 | typedef void (*PFNFTGLYPHSLOTEMBOLDEN)(FT_GlyphSlot slot);
26 | typedef void (*PFNFTGLYPHSLOTOBLIQUE)(FT_GlyphSlot slot);
27 | typedef FT_Error (*PFNFTGETGLYPH)(FT_GlyphSlot slot, FT_Glyph *aglyph);
28 | typedef FT_Error (*PFNFTGLYPHTOBITMAP)(FT_Glyph* the_glyph, FT_Render_Mode render_mode, FT_Vector* origin, FT_Bool destroy);
29 | typedef void (*PFNFTDONEGLYPH)(FT_Glyph glyph);
30 | PFNFTNEWLIBRARY VDB_FT_New_Library;
31 | PFNFTDONELIBRARY VDB_FT_Done_Library;
32 | PFNFTADDDEFAULTMODULES VDB_FT_Add_Default_Modules;
33 | PFNFTINITFREETYPE VDB_FT_Init_FreeType;
34 | PFNFTRENDERGLYPH VDB_FT_Render_Glyph;
35 | PFNFTNEWMEMORYFACE VDB_FT_New_Memory_Face;
36 | PFNFTSELECTCHARMAP VDB_FT_Select_Charmap;
37 | PFNFTDONEFACE VDB_FT_Done_Face;
38 | PFNFTDONEFREETYPE VDB_FT_Done_FreeType;
39 | PFNFTREQUESTSIZE VDB_FT_Request_Size;
40 | PFNFTGETCHARINDEX VDB_FT_Get_Char_Index;
41 | PFNFTLOADGLYPH VDB_FT_Load_Glyph;
42 | PFNFTGLYPHSLOTEMBOLDEN VDB_FT_GlyphSlot_Embolden;
43 | PFNFTGLYPHSLOTOBLIQUE VDB_FT_GlyphSlot_Oblique;
44 | PFNFTGETGLYPH VDB_FT_Get_Glyph;
45 | PFNFTGLYPHTOBITMAP VDB_FT_Glyph_To_Bitmap;
46 | PFNFTDONEGLYPH VDB_FT_Done_Glyph;
47 | #define FT_New_Library VDB_FT_New_Library
48 | #define FT_Done_Library VDB_FT_Done_Library
49 | #define FT_Add_Default_Modules VDB_FT_Add_Default_Modules
50 | #define FT_Init_FreeType VDB_FT_Init_FreeType
51 | #define FT_Render_Glyph VDB_FT_Render_Glyph
52 | #define FT_New_Memory_Face VDB_FT_New_Memory_Face
53 | #define FT_Select_Charmap VDB_FT_Select_Charmap
54 | #define FT_Done_Face VDB_FT_Done_Face
55 | #define FT_Done_FreeType VDB_FT_Done_FreeType
56 | #define FT_Request_Size VDB_FT_Request_Size
57 | #define FT_Get_Char_Index VDB_FT_Get_Char_Index
58 | #define FT_Load_Glyph VDB_FT_Load_Glyph
59 | #define FT_GlyphSlot_Embolden VDB_FT_GlyphSlot_Embolden
60 | #define FT_GlyphSlot_Oblique VDB_FT_GlyphSlot_Oblique
61 | #define FT_Get_Glyph VDB_FT_Get_Glyph
62 | #define FT_Glyph_To_Bitmap VDB_FT_Glyph_To_Bitmap
63 | #define FT_Done_Glyph VDB_FT_Done_Glyph
64 | #endif
65 |
66 | #include "imgui/imgui_freetype.cpp"
67 |
68 | bool TryLoadFreetype()
69 | {
70 | static bool ok = false;
71 | static bool have_tried = false;
72 | if (have_tried)
73 | return ok;
74 | have_tried = true;
75 |
76 | static void *freetype = SDL_LoadObject("freetype.dll");
77 | if (freetype)
78 | {
79 | ok = true;
80 | FT_New_Library = (PFNFTNEWLIBRARY) SDL_LoadFunction(freetype, "FT_New_Library");
81 | FT_Done_Library = (PFNFTDONELIBRARY) SDL_LoadFunction(freetype, "FT_Done_Library");
82 | FT_Add_Default_Modules = (PFNFTADDDEFAULTMODULES) SDL_LoadFunction(freetype, "FT_Add_Default_Modules");
83 | FT_Init_FreeType = (PFNFTINITFREETYPE) SDL_LoadFunction(freetype, "FT_Init_FreeType"); if (!VDB_FT_Init_FreeType) ok = false;
84 | FT_Render_Glyph = (PFNFTRENDERGLYPH) SDL_LoadFunction(freetype, "FT_Render_Glyph"); if (!VDB_FT_Render_Glyph) ok = false;
85 | FT_New_Memory_Face = (PFNFTNEWMEMORYFACE) SDL_LoadFunction(freetype, "FT_New_Memory_Face"); if (!VDB_FT_New_Memory_Face) ok = false;
86 | FT_Select_Charmap = (PFNFTSELECTCHARMAP) SDL_LoadFunction(freetype, "FT_Select_Charmap"); if (!VDB_FT_Select_Charmap) ok = false;
87 | FT_Done_Face = (PFNFTDONEFACE) SDL_LoadFunction(freetype, "FT_Done_Face"); if (!VDB_FT_Done_Face) ok = false;
88 | FT_Done_FreeType = (PFNFTDONEFREETYPE) SDL_LoadFunction(freetype, "FT_Done_FreeType"); if (!VDB_FT_Done_FreeType) ok = false;
89 | FT_Request_Size = (PFNFTREQUESTSIZE) SDL_LoadFunction(freetype, "FT_Request_Size"); if (!VDB_FT_Request_Size) ok = false;
90 | FT_Get_Char_Index = (PFNFTGETCHARINDEX) SDL_LoadFunction(freetype, "FT_Get_Char_Index"); if (!VDB_FT_Get_Char_Index) ok = false;
91 | FT_Load_Glyph = (PFNFTLOADGLYPH) SDL_LoadFunction(freetype, "FT_Load_Glyph"); if (!VDB_FT_Load_Glyph) ok = false;
92 | FT_GlyphSlot_Embolden = (PFNFTGLYPHSLOTEMBOLDEN) SDL_LoadFunction(freetype, "FT_GlyphSlot_Embolden"); if (!VDB_FT_GlyphSlot_Embolden) ok = false;
93 | FT_GlyphSlot_Oblique = (PFNFTGLYPHSLOTOBLIQUE) SDL_LoadFunction(freetype, "FT_GlyphSlot_Oblique"); if (!VDB_FT_GlyphSlot_Oblique) ok = false;
94 | FT_Get_Glyph = (PFNFTGETGLYPH) SDL_LoadFunction(freetype, "FT_Get_Glyph"); if (!VDB_FT_Get_Glyph) ok = false;
95 | FT_Glyph_To_Bitmap = (PFNFTGLYPHTOBITMAP) SDL_LoadFunction(freetype, "FT_Glyph_To_Bitmap"); if (!VDB_FT_Glyph_To_Bitmap) ok = false;
96 | FT_Done_Glyph = (PFNFTDONEGLYPH) SDL_LoadFunction(freetype, "FT_Done_Glyph"); if (!VDB_FT_Done_Glyph) ok = false;
97 | }
98 | return ok;
99 | }
100 |
--------------------------------------------------------------------------------
/src/freetype/FTL.TXT:
--------------------------------------------------------------------------------
1 | The FreeType Project LICENSE
2 | ----------------------------
3 |
4 | 2006-Jan-27
5 |
6 | Copyright 1996-2002, 2006 by
7 | David Turner, Robert Wilhelm, and Werner Lemberg
8 |
9 |
10 |
11 | Introduction
12 | ============
13 |
14 | The FreeType Project is distributed in several archive packages;
15 | some of them may contain, in addition to the FreeType font engine,
16 | various tools and contributions which rely on, or relate to, the
17 | FreeType Project.
18 |
19 | This license applies to all files found in such packages, and
20 | which do not fall under their own explicit license. The license
21 | affects thus the FreeType font engine, the test programs,
22 | documentation and makefiles, at the very least.
23 |
24 | This license was inspired by the BSD, Artistic, and IJG
25 | (Independent JPEG Group) licenses, which all encourage inclusion
26 | and use of free software in commercial and freeware products
27 | alike. As a consequence, its main points are that:
28 |
29 | o We don't promise that this software works. However, we will be
30 | interested in any kind of bug reports. (`as is' distribution)
31 |
32 | o You can use this software for whatever you want, in parts or
33 | full form, without having to pay us. (`royalty-free' usage)
34 |
35 | o You may not pretend that you wrote this software. If you use
36 | it, or only parts of it, in a program, you must acknowledge
37 | somewhere in your documentation that you have used the
38 | FreeType code. (`credits')
39 |
40 | We specifically permit and encourage the inclusion of this
41 | software, with or without modifications, in commercial products.
42 | We disclaim all warranties covering The FreeType Project and
43 | assume no liability related to The FreeType Project.
44 |
45 |
46 | Finally, many people asked us for a preferred form for a
47 | credit/disclaimer to use in compliance with this license. We thus
48 | encourage you to use the following text:
49 |
50 | """
51 | Portions of this software are copyright © The FreeType
52 | Project (www.freetype.org). All rights reserved.
53 | """
54 |
55 | Please replace with the value from the FreeType version you
56 | actually use.
57 |
58 |
59 | Legal Terms
60 | ===========
61 |
62 | 0. Definitions
63 | --------------
64 |
65 | Throughout this license, the terms `package', `FreeType Project',
66 | and `FreeType archive' refer to the set of files originally
67 | distributed by the authors (David Turner, Robert Wilhelm, and
68 | Werner Lemberg) as the `FreeType Project', be they named as alpha,
69 | beta or final release.
70 |
71 | `You' refers to the licensee, or person using the project, where
72 | `using' is a generic term including compiling the project's source
73 | code as well as linking it to form a `program' or `executable'.
74 | This program is referred to as `a program using the FreeType
75 | engine'.
76 |
77 | This license applies to all files distributed in the original
78 | FreeType Project, including all source code, binaries and
79 | documentation, unless otherwise stated in the file in its
80 | original, unmodified form as distributed in the original archive.
81 | If you are unsure whether or not a particular file is covered by
82 | this license, you must contact us to verify this.
83 |
84 | The FreeType Project is copyright (C) 1996-2000 by David Turner,
85 | Robert Wilhelm, and Werner Lemberg. All rights reserved except as
86 | specified below.
87 |
88 | 1. No Warranty
89 | --------------
90 |
91 | THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
92 | KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
93 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
94 | PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
95 | BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO
96 | USE, OF THE FREETYPE PROJECT.
97 |
98 | 2. Redistribution
99 | -----------------
100 |
101 | This license grants a worldwide, royalty-free, perpetual and
102 | irrevocable right and license to use, execute, perform, compile,
103 | display, copy, create derivative works of, distribute and
104 | sublicense the FreeType Project (in both source and object code
105 | forms) and derivative works thereof for any purpose; and to
106 | authorize others to exercise some or all of the rights granted
107 | herein, subject to the following conditions:
108 |
109 | o Redistribution of source code must retain this license file
110 | (`FTL.TXT') unaltered; any additions, deletions or changes to
111 | the original files must be clearly indicated in accompanying
112 | documentation. The copyright notices of the unaltered,
113 | original files must be preserved in all copies of source
114 | files.
115 |
116 | o Redistribution in binary form must provide a disclaimer that
117 | states that the software is based in part of the work of the
118 | FreeType Team, in the distribution documentation. We also
119 | encourage you to put an URL to the FreeType web page in your
120 | documentation, though this isn't mandatory.
121 |
122 | These conditions apply to any software derived from or based on
123 | the FreeType Project, not just the unmodified files. If you use
124 | our work, you must acknowledge us. However, no fee need be paid
125 | to us.
126 |
127 | 3. Advertising
128 | --------------
129 |
130 | Neither the FreeType authors and contributors nor you shall use
131 | the name of the other for commercial, advertising, or promotional
132 | purposes without specific prior written permission.
133 |
134 | We suggest, but do not require, that you use one or more of the
135 | following phrases to refer to this software in your documentation
136 | or advertising materials: `FreeType Project', `FreeType Engine',
137 | `FreeType library', or `FreeType Distribution'.
138 |
139 | As you have not signed this license, you are not required to
140 | accept it. However, as the FreeType Project is copyrighted
141 | material, only this license, or another one contracted with the
142 | authors, grants you the right to use, distribute, and modify it.
143 | Therefore, by using, distributing, or modifying the FreeType
144 | Project, you indicate that you understand and accept all the terms
145 | of this license.
146 |
147 | 4. Contacts
148 | -----------
149 |
150 | There are two mailing lists related to FreeType:
151 |
152 | o freetype@nongnu.org
153 |
154 | Discusses general use and applications of FreeType, as well as
155 | future and wanted additions to the library and distribution.
156 | If you are looking for support, start in this list if you
157 | haven't found anything to help you in the documentation.
158 |
159 | o freetype-devel@nongnu.org
160 |
161 | Discusses bugs, as well as engine internals, design issues,
162 | specific licenses, porting, etc.
163 |
164 | Our home page can be found at
165 |
166 | https://www.freetype.org
167 |
168 |
169 | --- end of FTL.TXT ---
170 |
--------------------------------------------------------------------------------
/src/freetype/LICENSE.TXT:
--------------------------------------------------------------------------------
1 |
2 | The FreeType 2 font engine is copyrighted work and cannot be used
3 | legally without a software license. In order to make this project
4 | usable to a vast majority of developers, we distribute it under two
5 | mutually exclusive open-source licenses.
6 |
7 | This means that *you* must choose *one* of the two licenses described
8 | below, then obey all its terms and conditions when using FreeType 2 in
9 | any of your projects or products.
10 |
11 | - The FreeType License, found in the file `FTL.TXT', which is similar
12 | to the original BSD license *with* an advertising clause that forces
13 | you to explicitly cite the FreeType project in your product's
14 | documentation. All details are in the license file. This license
15 | is suited to products which don't use the GNU General Public
16 | License.
17 |
18 | Note that this license is compatible to the GNU General Public
19 | License version 3, but not version 2.
20 |
21 | - The GNU General Public License version 2, found in `GPLv2.TXT' (any
22 | later version can be used also), for programs which already use the
23 | GPL. Note that the FTL is incompatible with GPLv2 due to its
24 | advertisement clause.
25 |
26 | The contributed BDF and PCF drivers come with a license similar to that
27 | of the X Window System. It is compatible to the above two licenses (see
28 | file src/bdf/README and src/pcf/README). The same holds for the files
29 | `fthash.c' and `fthash.h'; their code was part of the BDF driver in
30 | earlier FreeType versions.
31 |
32 | The gzip module uses the zlib license (see src/gzip/zlib.h) which too is
33 | compatible to the above two licenses.
34 |
35 | The MD5 checksum support (only used for debugging in development builds)
36 | is in the public domain.
37 |
38 |
39 | --- end of LICENSE.TXT ---
40 |
--------------------------------------------------------------------------------
/src/freetype/README.md:
--------------------------------------------------------------------------------
1 | FreeType 2.9.1
2 | =========================
3 | ###### Windows binaries (DLL) of FreeType (win32/win64)
4 |
5 | Compiled with VS Express 2015
6 | Compatible with Windows XP, Vista, 7, 8, 10
7 |
8 | > *freetype.dll* uses the *Universal CRT* and therefore **_requires_** Visual C++ 2017 Redistributable to be present on system (*VC++ 2017 Redistributable supersedes VC++ 2015 Redistributable*).
9 |
10 | | filename | sha256 |
11 | | :-- | :-- |
12 | | win32\\**freetype.dll** | `50BE9F0AAE77ED3419088168A3EE67FDF2A1C2B33A89D46548062B636B1EE893` |
13 | | win32\\**freetype.lib** | `184A993AD300F8CE39D48C0500CD0F34BB44C7DDAFDB22F8C1049F5031D4F6BF` |
14 | | win64\\**freetype.dll** | `8B0F1E91E80D441869169A3E9D924BAAFB2203A04CB90D1A11AC7ED22C81A24E` |
15 | | win64\\**freetype.lib** | `81C9050FE6C1A02D176131E45A37CC994AF027F94853EEAFFA06BB087ECCBF0A` |
16 |
--------------------------------------------------------------------------------
/src/freetype/include/freetype/config/ftmodule.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file registers the FreeType modules compiled into the library.
3 | *
4 | * If you use GNU make, this file IS NOT USED! Instead, it is created in
5 | * the objects directory (normally `/objs/') based on information
6 | * from `/modules.cfg'.
7 | *
8 | * Please read `docs/INSTALL.ANY' and `docs/CUSTOMIZE' how to compile
9 | * FreeType without GNU make.
10 | *
11 | */
12 |
13 | FT_USE_MODULE( FT_Module_Class, autofit_module_class )
14 | FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class )
15 | FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class )
16 | FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class )
17 | FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class )
18 | FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class )
19 | FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class )
20 | FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class )
21 | FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class )
22 | FT_USE_MODULE( FT_Module_Class, psaux_module_class )
23 | FT_USE_MODULE( FT_Module_Class, psnames_module_class )
24 | FT_USE_MODULE( FT_Module_Class, pshinter_module_class )
25 | FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class )
26 | FT_USE_MODULE( FT_Module_Class, sfnt_module_class )
27 | FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class )
28 | FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class )
29 | FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcdv_renderer_class )
30 | FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class )
31 |
32 | /* EOF */
33 |
--------------------------------------------------------------------------------
/src/freetype/include/freetype/config/ftstdlib.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************/
2 | /* */
3 | /* ftstdlib.h */
4 | /* */
5 | /* ANSI-specific library and header configuration file (specification */
6 | /* only). */
7 | /* */
8 | /* Copyright 2002-2018 by */
9 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */
10 | /* */
11 | /* This file is part of the FreeType project, and may only be used, */
12 | /* modified, and distributed under the terms of the FreeType project */
13 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14 | /* this file you indicate that you have read the license and */
15 | /* understand and accept it fully. */
16 | /* */
17 | /***************************************************************************/
18 |
19 |
20 | /*************************************************************************/
21 | /* */
22 | /* This file is used to group all #includes to the ANSI C library that */
23 | /* FreeType normally requires. It also defines macros to rename the */
24 | /* standard functions within the FreeType source code. */
25 | /* */
26 | /* Load a file which defines FTSTDLIB_H_ before this one to override it. */
27 | /* */
28 | /*************************************************************************/
29 |
30 |
31 | #ifndef FTSTDLIB_H_
32 | #define FTSTDLIB_H_
33 |
34 |
35 | #include
36 |
37 | #define ft_ptrdiff_t ptrdiff_t
38 |
39 |
40 | /**********************************************************************/
41 | /* */
42 | /* integer limits */
43 | /* */
44 | /* UINT_MAX and ULONG_MAX are used to automatically compute the size */
45 | /* of `int' and `long' in bytes at compile-time. So far, this works */
46 | /* for all platforms the library has been tested on. */
47 | /* */
48 | /* Note that on the extremely rare platforms that do not provide */
49 | /* integer types that are _exactly_ 16 and 32 bits wide (e.g. some */
50 | /* old Crays where `int' is 36 bits), we do not make any guarantee */
51 | /* about the correct behaviour of FT2 with all fonts. */
52 | /* */
53 | /* In these case, `ftconfig.h' will refuse to compile anyway with a */
54 | /* message like `couldn't find 32-bit type' or something similar. */
55 | /* */
56 | /**********************************************************************/
57 |
58 |
59 | #include
60 |
61 | #define FT_CHAR_BIT CHAR_BIT
62 | #define FT_USHORT_MAX USHRT_MAX
63 | #define FT_INT_MAX INT_MAX
64 | #define FT_INT_MIN INT_MIN
65 | #define FT_UINT_MAX UINT_MAX
66 | #define FT_LONG_MIN LONG_MIN
67 | #define FT_LONG_MAX LONG_MAX
68 | #define FT_ULONG_MAX ULONG_MAX
69 |
70 |
71 | /**********************************************************************/
72 | /* */
73 | /* character and string processing */
74 | /* */
75 | /**********************************************************************/
76 |
77 |
78 | #include
79 |
80 | #define ft_memchr memchr
81 | #define ft_memcmp memcmp
82 | #define ft_memcpy memcpy
83 | #define ft_memmove memmove
84 | #define ft_memset memset
85 | #define ft_strcat strcat
86 | #define ft_strcmp strcmp
87 | #define ft_strcpy strcpy
88 | #define ft_strlen strlen
89 | #define ft_strncmp strncmp
90 | #define ft_strncpy strncpy
91 | #define ft_strrchr strrchr
92 | #define ft_strstr strstr
93 |
94 |
95 | /**********************************************************************/
96 | /* */
97 | /* file handling */
98 | /* */
99 | /**********************************************************************/
100 |
101 |
102 | #include
103 |
104 | #define FT_FILE FILE
105 | #define ft_fclose fclose
106 | #define ft_fopen fopen
107 | #define ft_fread fread
108 | #define ft_fseek fseek
109 | #define ft_ftell ftell
110 | #define ft_sprintf sprintf
111 |
112 |
113 | /**********************************************************************/
114 | /* */
115 | /* sorting */
116 | /* */
117 | /**********************************************************************/
118 |
119 |
120 | #include
121 |
122 | #define ft_qsort qsort
123 |
124 |
125 | /**********************************************************************/
126 | /* */
127 | /* memory allocation */
128 | /* */
129 | /**********************************************************************/
130 |
131 |
132 | #define ft_scalloc calloc
133 | #define ft_sfree free
134 | #define ft_smalloc malloc
135 | #define ft_srealloc realloc
136 |
137 |
138 | /**********************************************************************/
139 | /* */
140 | /* miscellaneous */
141 | /* */
142 | /**********************************************************************/
143 |
144 |
145 | #define ft_strtol strtol
146 | #define ft_getenv getenv
147 |
148 |
149 | /**********************************************************************/
150 | /* */
151 | /* execution control */
152 | /* */
153 | /**********************************************************************/
154 |
155 |
156 | #include
157 |
158 | #define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */
159 | /* jmp_buf is defined as a macro */
160 | /* on certain platforms */
161 |
162 | #define ft_longjmp longjmp
163 | #define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) ) /* same thing here */
164 |
165 |
166 | /* the following is only used for debugging purposes, i.e., if */
167 | /* FT_DEBUG_LEVEL_ERROR or FT_DEBUG_LEVEL_TRACE are defined */
168 |
169 | #include
170 |
171 |
172 | #endif /* FTSTDLIB_H_ */
173 |
174 |
175 | /* END */
176 |
--------------------------------------------------------------------------------
/src/freetype/include/freetype/ftbbox.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************/
2 | /* */
3 | /* ftbbox.h */
4 | /* */
5 | /* FreeType exact bbox computation (specification). */
6 | /* */
7 | /* Copyright 1996-2018 by */
8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */
9 | /* */
10 | /* This file is part of the FreeType project, and may only be used, */
11 | /* modified, and distributed under the terms of the FreeType project */
12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 | /* this file you indicate that you have read the license and */
14 | /* understand and accept it fully. */
15 | /* */
16 | /***************************************************************************/
17 |
18 |
19 | /*************************************************************************/
20 | /* */
21 | /* This component has a _single_ role: to compute exact outline bounding */
22 | /* boxes. */
23 | /* */
24 | /* It is separated from the rest of the engine for various technical */
25 | /* reasons. It may well be integrated in `ftoutln' later. */
26 | /* */
27 | /*************************************************************************/
28 |
29 |
30 | #ifndef FTBBOX_H_
31 | #define FTBBOX_H_
32 |
33 |
34 | #include
35 | #include FT_FREETYPE_H
36 |
37 | #ifdef FREETYPE_H
38 | #error "freetype.h of FreeType 1 has been loaded!"
39 | #error "Please fix the directory search order for header files"
40 | #error "so that freetype.h of FreeType 2 is found first."
41 | #endif
42 |
43 |
44 | FT_BEGIN_HEADER
45 |
46 |
47 | /*************************************************************************/
48 | /* */
49 | /* */
50 | /* outline_processing */
51 | /* */
52 | /*************************************************************************/
53 |
54 |
55 | /*************************************************************************/
56 | /* */
57 | /* */
58 | /* FT_Outline_Get_BBox */
59 | /* */
60 | /* */
61 | /* Compute the exact bounding box of an outline. This is slower */
62 | /* than computing the control box. However, it uses an advanced */
63 | /* algorithm that returns _very_ quickly when the two boxes */
64 | /* coincide. Otherwise, the outline Bezier arcs are traversed to */
65 | /* extract their extrema. */
66 | /* */
67 | /* */
68 | /* outline :: A pointer to the source outline. */
69 | /* */
70 | /*