Skip to main content

Prerequisites

Before building for PC, ensure you have:
  1. Completed the dependency setup
  2. Installed system libraries (zlib, glfw3, glew)
  3. CMake 3.14 or higher
  4. GCC or compatible C compiler
  5. OpenGL 2.0 support

Install System Dependencies

Install the required libraries using your system package manager:
sudo apt-get install build-essential cmake zlib1g-dev libglfw3-dev libglew-dev

Build Process

1

Navigate to source directory

cd /path/to/fcavex/source
2

Create build directory

mkdir build_pc
cd build_pc
3

Run CMake

Configure the project:
cmake ..
4

Compile

Build the executable:
make
This will create the cavex executable in the build directory.

Build Configuration

The PC build uses CMake with the following configuration (from CMakeLists.txt):

Compiler Flags

add_compile_options(-O3 -march=native -g)
  • -O3 - Maximum optimization level
  • -march=native - Optimize for your CPU architecture
  • -g - Include debug symbols

Platform Definitions

target_compile_definitions(cavex PRIVATE PLATFORM_PC CGLM_ALL_UNALIGNED)
  • PLATFORM_PC - Enables PC-specific code paths
  • CGLM_ALL_UNALIGNED - cglm configuration for compatibility

Linked Libraries

From CMakeLists.txt:179:
target_link_libraries(cavex 
  ${CMAKE_THREAD_LIBS_INIT} 
  ZLIB::ZLIB 
  glfw 
  GLEW::GLEW 
  OpenGL::GL 
  m
)

Running the Game

1

Copy shader files

The PC version requires fragment and vertex shaders. Copy them from the resources/ directory:
cp ../resources/*.glsl .
Place these shader files next to your assets/ directory.
2

Set up assets directory

Ensure your directory structure looks like this:
build_pc/
├── cavex (executable)
├── assets/
│   ├── terrain.png
│   ├── items.png
│   ├── anim.png
│   ├── default.png
│   ├── gui.png
│   └── gui2.png
├── saves/
│   └── world/
├── config.json
├── fragment_shader.glsl
└── vertex_shader.glsl
3

Launch the game

./cavex

Controls

The PC version uses keyboard and mouse controls:
  • Mouse - Look around
  • WASD - Movement
  • Space - Jump
  • Shift - Sneak
  • E - Inventory
  • Escape - Pause menu
  • Mouse buttons - Break/place blocks
For detailed controls, check the controls.md file in the source repository.

Advanced Build Options

Custom Compiler

To use a specific compiler:
CXX=clang++ CC=clang cmake ..
make

Build Types

cmake -DCMAKE_BUILD_TYPE=Release ..
make
LTO is enabled by default (from CMakeLists.txt:177):
set_property(TARGET cavex PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
This provides additional optimization at link time for better performance.

Performance Considerations

Default Window Resolution

The default window size is defined in source/graphics/gfx_settings.h:47-48:
#define GFX_PC_WINDOW_WIDTH 640
#define GFX_PC_WINDOW_HEIGHT 400
You can modify these values before building. See Video Settings for details.

Optimization Tips

For maximum performance, ensure you’re building with -march=native to take advantage of your CPU’s instruction set. The default CMake configuration already includes this flag.
  • Lower resolution improves performance on integrated GPUs
  • Disable GFX_FANCY_LIQUIDS for better FPS on low-end GPUs
  • Adjust GFX_GUI_SCALE based on your resolution

Troubleshooting

CMake can’t find libraries

Make sure development packages are installed:
ldconfig -p | grep -E '(glfw|glew|GL)'

Missing shaders

If the game fails to launch with shader errors, ensure the .glsl files from resources/ are in the same directory as the executable.

OpenGL version errors

fCavEX requires OpenGL 2.0 or higher. Check your driver:
glxinfo | grep "OpenGL version"

Cleaning Build Files

To rebuild from scratch:
cd build_pc
rm -rf *
cmake ..
make

Build docs developers (and LLMs) love