This script automates the setup of a new project using GLFW and GLAD on macOS. It creates a basic structure for an OpenGL project, allowing you to quickly start coding with GLFW GLAD, CGLM and SOKOL and generates necessary source files, a Makefile, and a default project structure.
Before running the script, ensure you have the following tools installed:
-
Homebrew: A package manager for macOS.
- Install it by following the Homebrew installation guide.
-
GLFW: A library for creating windows with OpenGL contexts and managing input.
- The script automatically checks and installs GLFW via Homebrew if it's not already installed.
-
GLAD: An OpenGL loader that handles the loading of OpenGL extensions.
- The script assumes GLAD is downloaded and placed in the
Downloadsfolder.
- The script assumes GLAD is downloaded and placed in the
-
Bear (optional but recommended if using Neovim): A tool that generates
compile_commands.jsonfor better LSP support with libraries like GLFW and OpenGL.- Install it by running:
$ brew install bear
- Install it by running:
-
gcc/g++/clang: C/C++ compiler
-
make
-
GLFW Installation: The script checks if GLFW is installed using Homebrew. If it's not installed, it installs it automatically.
-
GLAD Check: The script checks if GLAD exists in the
Downloadsfolder. If not, it prompts you to download and place GLAD in the folder. -
Project Structure:
- Creates a new project directory with the following subdirectories:
src/: Contains source files.build/: Contains build output.include/: Contains header files.lib/: Contains library files.
- Creates a new project directory with the following subdirectories:
-
Source File Creation:
- Prompts you to select between C or C++ for your project language.
- Creates a
main.cormain.cppfile depending on your choice, with default OpenGL setup code.
-
Makefile Generation:
- Automatically creates a Makefile that compiles the project using
gccorg++based on your language choice. - Includes necessary flags for GLFW and GLAD.
- Supports building, cleaning, and running the project with the
makecommand.
- Automatically creates a Makefile that compiles the project using
-
GLFW & GLAD Integration: The script sets up GLFW and GLAD for use in your project, ensuring that the necessary include paths and libraries are correctly configured.
-
Sokol Support: Added support for integrating the lightweight Sokol libraries for graphics, audio, and more.
-
cglm Support: Added integration with the
cglmmath library for easier vector and matrix operations in C. -
Interactive Setup: Added prompts for custom project names and paths during setup.
-
Verbose Logging: The script now provides detailed logging during installation and project creation.
-
Error Handling: Added robust error handling for missing dependencies and incorrect paths.
-
Custom Library Path: Allows you to specify a custom path for GLFW and GLAD libraries if they are installed outside default locations.
-
Automatic
compile_commands.jsonGeneration: IfBearis installed, the script automatically generatescompile_commands.jsonfor better LSP support in editors like Neovim and VSCode. -
Default Shader Files: Generates basic vertex and fragment shader files for quick setup.
-
Clone or download this repository.
-
Ensure that Homebrew and GLFW are installed.
-
Download GLAD from glad.dav1d.de and place it in your
Downloadsfolder. -
Ensure Bear is installed if you're using Neovim for better LSP support.
-
Run the script:
$ chmod +x openglAppleSilicon.sh $ ./openglAppleSilicon.sh