The crash is caused by dereferencing a invalid pointer to a texture. The D3D11 renderer as a arbitrary limit of 32 textures (there is normally no reason to have more than 2 or 3 textures in 4coder) because it needs to keep track of a few pointer in its state, while OpenGL doesn't (it just uses the id returned by `glGenTexture`). The code that recreate the texture atlas when changing the font size, never frees the previous texture, so both DirectX and OpenGL are leaking texture. So this fix just frees the previous texture after 4coder successfully creates a new one. If for some reason the new texture can't be created, we continue using the last one. This is better than crashing as we can still use 4coder, but since we can't change font size anymore the editor might be stuck with a uncomfortable font size. Unfortunately 4coder doesn't expose a way to delete texture outside the platform layer, and the font size code is not in the platform layer. So I had to expose a `free texture` function, which lead me to understand how 4coder generates API in the `generated` folder. I updated the README to keep that information somewhere since it's not clear from the get go. The basic idea is that there are a few files that you can compile as a small standalone program and run to generate the files. For the graphics api, you need to compile `4ed_graphics_api.cpp`. I took some time to also modify a little the generator so that the generated file contains the name of the file that generated them, and added a bit of indentation to make the file a bit more readable (even if we're not supposed to modify them). |
||
---|---|---|
build_new | ||
code | ||
non-source | ||
triage | ||
.gitignore | ||
4ed.rdbg | ||
README.md | ||
TODO.md | ||
project.4coder |
README.md
4Coder Community
Welcome to the 4coder community repository.
Building
Windows
- Setup the MSVC toolchain in your environment, this can be done with the
code/custom/bin/setup_cl_x64.bat
script - call the
package.bat
script from the code directory$ cd 4cc\code
.\bin\package.bat
- You can also use the
build.bat
script if you want just build the binaries, this does not copy the default config, fonts and bindings$ cd 4cc\code
$ .\bin\build.bat
Linux
tested on Ubuntu 22.04:
-
Get required libraries (apt names):
$ sudo apt install build-essential libx11-dev libxfixes-dev libglx-dev mesa-common-dev libasound2-dev libfreetype-dev libfontconfig-dev
-
Use the
package-linux.sh
script to build and package an application$ cd 4cc/code
$ ./bin/package-linux.sh
-
You can also use the
build-linux.sh
script if you want just build the binaries, this does not copy the default config, fonts and bindings$ cd 4cc/code
$ ./bin/build-linux.sh
Mac
4coder targets x86_64. If you are using a M1+ ARM CPU you need to prefix the build scripts commands with:
arch -arch x86_64
-
Use the
package-mac.sh
script from the code directory (this builds a distribution in thedistributions
directory with all the non-binary dependencies)$ cd 4cc/code
$ ./bin/package-mac.sh
-
You can also use the
build-mac.sh
script if you want just build the binaries, (this produces the build artifacts in thebuild
directory, this doesn't produce a functional distribution)$ cd 4cc/code
$ ./bin/build-mac.sh
Older Macs, 10.15.7 Catalina
If you are using an older version of mac, such as 10.15.7 Catalina you need to install the realpath command:
$ sudo port install coreutils
- macports names the
realpath
commandgrealpath
, so make a symbolic link in order to use build-mac.sh:$ sudo ln -s /opt/local/bin/grealpath /opt/local/bin/realpath
Build script parameter
The build script accepts a parameter (mutually exclusive):
/DDEV_BUILD
or/DDEV_BUILD_X86
(default value) : build without optimizations. Produces debug symbols. Defines:FRED_INTERNAL
,FRED_SUPER
,DO_CRAZY_EXPENSIVE_ASSERTS
(on Windows) macros./DOPT_BUILD
or/DOPT_BUILD_X86
(similar tobuild_optimized
script): build with optimizations. Doesn't produce debug symbols. DefinesFRED_SUPER
macro./DPACKAGE_SUPER_X64
or/DPACKAGE_SUPER_X86
(similar topackage
script): package 4coder for distribution. Turns on optimizations. Produces debug symbols. DefinesSHIP_MODE
,FRED_SUPER
,DO_CRAZY_EXPENSIVE_ASSERTS
(on Windows) macros./DPACKAGE_DEMO_X64
or/DPACKAGE_DEMO_X86
: packages 4coder demo for distribution. Turns on optimizations. Produces debug symbols. DefinesSHIP_MODE
,DO_CRAZY_EXPENSIVE_ASSERTS
(on Windows) macros.
API generators
4coder uses several small programs to generate some headers and source files. Those do not run automatically, you must build them and run them when needed (which shouldn't really happen).
code\4ed_font_api.cpp
creates, incode\generated
,font_api.h
,font_api.cpp
,font_api_constructor.cpp
(not used) andfont_api_master_list.h
(not used);code\4ed_graphics_api.cpp
creates, incode\generated
,graphics_api.h
andgraphics_api.cpp
,graphics_api_constructor.cpp
(not used) andgraphics_api_master_list.h
(not used);code\4ed_system_api.cpp
creates, incode\custom\generated
,system_api.h
,system_api.cpp
,system_api_constructor.cpp
,system_api_master_list.h
;code\4ed_api_parser_main.cpp
is a little different, as it parses source files passed as parameters to search for functions and type preceded byapi(some_api_name)
and creates 4 files in thecode\custom\generated
. It is used to generatecustom_api.h
,custom_api.cpp
,custom_api_constructor.cpp
andcustom_api_master_list.h
by passingcode\4ed_api_implementation.cpp
as a parameter.
You need to compile one of those file and run it from the code
directory.
There is also code\4ed_api_check.cpp
to verify the generated file but it's not clear at the moment what to check against.
code\4ed_generate_keycodes.cpp
is also a bit appart as it generatescode\custom\generated\4coder_event_codes.h
which are keyboard key codes and some event hook ids.