Compare commits
No commits in common. "master" and "1.4.0" have entirely different histories.
8
.github/FUNDING.yml
vendored
|
|
@ -1,8 +0,0 @@
|
||||||
# These are supported funding model platforms
|
|
||||||
|
|
||||||
github: raysan5
|
|
||||||
patreon: # raylib
|
|
||||||
open_collective: # Replace with a single Open Collective username
|
|
||||||
ko_fi: # raysan
|
|
||||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
|
||||||
custom: # Replace with a single custom sponsorship URL
|
|
||||||
1
.github/ISSUE_TEMPLATE/config.yml
vendored
|
|
@ -1 +0,0 @@
|
||||||
blank_issues_enabled: false
|
|
||||||
41
.github/ISSUE_TEMPLATE/new-issue-template.md
vendored
|
|
@ -1,41 +0,0 @@
|
||||||
---
|
|
||||||
name: new issue template
|
|
||||||
about: generic template for new issues
|
|
||||||
title: "[module] Short description of the issue/bug/feature"
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**WARNING: Please, read this note carefully before submitting a new issue:**
|
|
||||||
|
|
||||||
It is important to realise that **this is NOT A SUPPORT FORUM**, this is for reproducible BUGS with raylib ONLY.
|
|
||||||
|
|
||||||
There are lots of generous and helpful people ready to help you out on [raylib Discord forum](https://discord.gg/raylib) or [raylib reddit](https://www.reddit.com/r/raylib/).
|
|
||||||
|
|
||||||
Remember that asking for support questions here actively takes developer time away from improving raylib.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Please, before submitting a new issue verify and check:
|
|
||||||
|
|
||||||
- [ ] I tested it on latest raylib version from master branch
|
|
||||||
- [ ] I checked there is no similar issue already reported
|
|
||||||
- [ ] I checked the documentation on the [wiki](https://github.com/raysan5/raylib/wiki)
|
|
||||||
- [ ] My code has no errors or misuse of raylib
|
|
||||||
|
|
||||||
### Issue description
|
|
||||||
|
|
||||||
*Briefly describe the issue you are experiencing (or the feature you want to see added to raylib). Tell us what you were trying to do and what happened instead. Remember, this is not the best place to ask questions. For questions, go to [raylib Discord server](https://discord.gg/raylib).*
|
|
||||||
|
|
||||||
### Environment
|
|
||||||
|
|
||||||
*Provide your Platform, Operating System, OpenGL version, GPU details where you experienced the issue.*
|
|
||||||
|
|
||||||
### Issue Screenshot
|
|
||||||
|
|
||||||
*If possible, provide a screenshot that illustrates the issue. Usually an image is better than a thousand words.*
|
|
||||||
|
|
||||||
### Code Example
|
|
||||||
|
|
||||||
*Provide minimal reproduction code to test the issue. Please, format the code properly and try to keep it as simple as possible, just focusing on the experienced issue.*
|
|
||||||
135
.github/workflows/analyze_codeql.yml
vendored
|
|
@ -1,135 +0,0 @@
|
||||||
# For most projects, this workflow file will not need changing; you simply need
|
|
||||||
# to commit it to your repository.
|
|
||||||
#
|
|
||||||
# You may wish to alter this file to override the set of languages analyzed,
|
|
||||||
# or to provide custom queries or build logic.
|
|
||||||
name: Analyze raylib with CodeQL
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
# push:
|
|
||||||
# branches: [ "main", "master" ]
|
|
||||||
pull_request:
|
|
||||||
branches: '*'
|
|
||||||
schedule:
|
|
||||||
- cron: '0 0 * * 1'
|
|
||||||
|
|
||||||
env:
|
|
||||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
|
||||||
BUILD_TYPE: Release
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
analyze:
|
|
||||||
name: Analyze
|
|
||||||
# Runner size impacts CodeQL analysis time. To learn more, please see:
|
|
||||||
# - https://gh.io/recommended-hardware-resources-for-running-codeql
|
|
||||||
# - https://gh.io/supported-runners-and-hardware-resources
|
|
||||||
# - https://gh.io/using-larger-runners
|
|
||||||
# Consider using larger runners for possible analysis time improvements.
|
|
||||||
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
|
|
||||||
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
|
|
||||||
permissions:
|
|
||||||
actions: read
|
|
||||||
contents: read
|
|
||||||
security-events: write
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
language: [ 'cpp' ]
|
|
||||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
|
|
||||||
# Use only 'java' to analyze code written in Java, Kotlin or both
|
|
||||||
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
|
|
||||||
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- name: Create Build Environment
|
|
||||||
# Some projects don't allow in-source building, so create a separate build directory
|
|
||||||
# We'll use this as our working directory for all subsequent commands
|
|
||||||
run: cmake -E make_directory ${{github.workspace}}/build
|
|
||||||
|
|
||||||
- name: Setup Environment
|
|
||||||
run: |
|
|
||||||
sudo apt-get update -qq
|
|
||||||
sudo apt-get install gcc-multilib
|
|
||||||
sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-dev libxkbcommon-dev
|
|
||||||
|
|
||||||
- name: Configure CMake
|
|
||||||
# Use a bash shell so we can use the same syntax for environment variable
|
|
||||||
# access regardless of the host operating system
|
|
||||||
shell: bash
|
|
||||||
working-directory: ${{github.workspace}}/build
|
|
||||||
# Note the current convention is to use the -S and -B options here to specify source
|
|
||||||
# and build directories, but this is only available with CMake 3.13 and higher.
|
|
||||||
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
|
|
||||||
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPLATFORM=Desktop
|
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
|
||||||
- name: Initialize CodeQL
|
|
||||||
uses: github/codeql-action/init@v3
|
|
||||||
with:
|
|
||||||
languages: ${{ matrix.language }}
|
|
||||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
||||||
# By default, queries listed here will override any specified in a config file.
|
|
||||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
||||||
|
|
||||||
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
|
||||||
# queries: security-extended,security-and-quality
|
|
||||||
queries: security-and-quality
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
# Execute the build. You can specify a specific target with "--target <NAME>"
|
|
||||||
run: |
|
|
||||||
cd build
|
|
||||||
cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPLATFORM=Desktop
|
|
||||||
cmake --build . --config $BUILD_TYPE
|
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
|
||||||
uses: github/codeql-action/analyze@v3
|
|
||||||
with:
|
|
||||||
category: "/language:${{matrix.language}}"
|
|
||||||
upload: false
|
|
||||||
id: step1
|
|
||||||
|
|
||||||
# Filter out rules with low severity or high false positve rate
|
|
||||||
# Also filter out warnings in third-party code
|
|
||||||
- name: Filter out unwanted errors and warnings
|
|
||||||
uses: advanced-security/filter-sarif@v1
|
|
||||||
with:
|
|
||||||
patterns: |
|
|
||||||
-**:cpp/path-injection
|
|
||||||
-**:cpp/world-writable-file-creation
|
|
||||||
-**:cpp/poorly-documented-function
|
|
||||||
-**:cpp/potentially-dangerous-function
|
|
||||||
-**:cpp/use-of-goto
|
|
||||||
-**:cpp/integer-multiplication-cast-to-long
|
|
||||||
-**:cpp/comparison-with-wider-type
|
|
||||||
-**:cpp/leap-year/*
|
|
||||||
-**:cpp/ambiguously-signed-bit-field
|
|
||||||
-**:cpp/suspicious-pointer-scaling
|
|
||||||
-**:cpp/suspicious-pointer-scaling-void
|
|
||||||
-**:cpp/unsigned-comparison-zero
|
|
||||||
-**/cmake*/Modules/**
|
|
||||||
-**/src/external/glfw/**
|
|
||||||
-**/src/external/**
|
|
||||||
input: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
|
|
||||||
output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
|
|
||||||
|
|
||||||
- name: Upload CodeQL results to code scanning
|
|
||||||
uses: github/codeql-action/upload-sarif@v2
|
|
||||||
with:
|
|
||||||
sarif_file: ${{ steps.step1.outputs.sarif-output }}
|
|
||||||
category: "/language:${{matrix.language}}"
|
|
||||||
|
|
||||||
- name: Upload CodeQL results as an artifact
|
|
||||||
if: success() || failure()
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: codeql-results
|
|
||||||
path: ${{ steps.step1.outputs.sarif-output }}
|
|
||||||
retention-days: 5
|
|
||||||
98
.github/workflows/build_android.yml
vendored
|
|
@ -1,98 +0,0 @@
|
||||||
name: Build raylib - Android
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'examples/**'
|
|
||||||
- '.github/workflows/android.yml'
|
|
||||||
pull_request:
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'examples/**'
|
|
||||||
- '.github/workflows/android.yml'
|
|
||||||
release:
|
|
||||||
types: [published]
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
permissions:
|
|
||||||
contents: write # for actions/upload-release-asset to upload release asset
|
|
||||||
runs-on: windows-latest
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
max-parallel: 1
|
|
||||||
matrix:
|
|
||||||
ARCH: ["arm64", "x86_64"]
|
|
||||||
|
|
||||||
env:
|
|
||||||
RELEASE_NAME: raylib-dev_android_api29_${{ matrix.ARCH }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@master
|
|
||||||
|
|
||||||
- name: Setup Release Version
|
|
||||||
run: |
|
|
||||||
echo "RELEASE_NAME=raylib-${{ github.event.release.tag_name }}_android_api29_${{ matrix.ARCH }}" >> $GITHUB_ENV
|
|
||||||
shell: bash
|
|
||||||
if: github.event_name == 'release' && github.event.action == 'published'
|
|
||||||
|
|
||||||
- name: Setup Android NDK
|
|
||||||
id: setup-ndk
|
|
||||||
uses: nttld/setup-ndk@v1
|
|
||||||
with:
|
|
||||||
ndk-version: r25
|
|
||||||
add-to-path: false
|
|
||||||
env:
|
|
||||||
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
|
||||||
|
|
||||||
- name: Setup Environment
|
|
||||||
run: |
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
mkdir ${{ env.RELEASE_NAME }}
|
|
||||||
cd ${{ env.RELEASE_NAME }}
|
|
||||||
mkdir include
|
|
||||||
mkdir lib
|
|
||||||
cd ../..
|
|
||||||
|
|
||||||
# Generating static + shared library for 64bit arquitectures and API version 29
|
|
||||||
- name: Build Library
|
|
||||||
run: |
|
|
||||||
cd src
|
|
||||||
make PLATFORM=PLATFORM_ANDROID ANDROID_ARCH=${{ matrix.ARCH }} ANDROID_API_VERSION=29 ANDROID_NDK=${{ env.ANDROID_NDK_HOME }} RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib"
|
|
||||||
make PLATFORM=PLATFORM_ANDROID ANDROID_ARCH=${{ matrix.ARCH }} ANDROID_API_VERSION=29 ANDROID_NDK=${{ env.ANDROID_NDK_HOME }} RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
|
||||||
cd ..
|
|
||||||
shell: cmd
|
|
||||||
|
|
||||||
- name: Generate Artifacts
|
|
||||||
run: |
|
|
||||||
cp -v ./src/raylib.h ./build/${{ env.RELEASE_NAME }}/include
|
|
||||||
cp -v ./src/raymath.h ./build/${{ env.RELEASE_NAME }}/include
|
|
||||||
cp -v ./src/rlgl.h ./build/${{ env.RELEASE_NAME }}/include
|
|
||||||
cp -v ./CHANGELOG ./build/${{ env.RELEASE_NAME }}/CHANGELOG
|
|
||||||
cp -v ./README.md ./build/${{ env.RELEASE_NAME }}/README.md
|
|
||||||
cp -v ./LICENSE ./build/${{ env.RELEASE_NAME }}/LICENSE
|
|
||||||
cd build
|
|
||||||
tar -czvf ${{ env.RELEASE_NAME }}.tar.gz ${{ env.RELEASE_NAME }}
|
|
||||||
|
|
||||||
- name: Upload Artifacts
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: ${{ env.RELEASE_NAME }}
|
|
||||||
path: |
|
|
||||||
./build/${{ env.RELEASE_NAME }}
|
|
||||||
!./build/${{ env.RELEASE_NAME }}.tar.gz
|
|
||||||
|
|
||||||
- name: Upload Artifact to Release
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
with:
|
|
||||||
files: ./build/${{ env.RELEASE_NAME }}.tar.gz
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
if: github.event_name == 'release' && github.event.action == 'published'
|
|
||||||
111
.github/workflows/build_cmake.yml
vendored
|
|
@ -1,111 +0,0 @@
|
||||||
name: Build raylib CMake - Windows+Linux
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'examples/**'
|
|
||||||
- '.github/workflows/cmake.yml'
|
|
||||||
- 'CMakeList.txt'
|
|
||||||
- 'CMakeOptions.txt'
|
|
||||||
- 'cmake/**'
|
|
||||||
pull_request:
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'examples/**'
|
|
||||||
- '.github/workflows/cmake.yml'
|
|
||||||
- 'CMakeList.txt'
|
|
||||||
- 'CMakeOptions.txt'
|
|
||||||
- 'cmake/**'
|
|
||||||
|
|
||||||
env:
|
|
||||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
|
||||||
BUILD_TYPE: Release
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build_windows:
|
|
||||||
name: Windows Build
|
|
||||||
# The CMake configure and build commands are platform agnostic and should work equally
|
|
||||||
# well on Windows or Mac. You can convert this to a matrix build if you need
|
|
||||||
# cross-platform coverage.
|
|
||||||
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
|
|
||||||
runs-on: windows-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Create Build Environment
|
|
||||||
# Some projects don't allow in-source building, so create a separate build directory
|
|
||||||
# We'll use this as our working directory for all subsequent commands
|
|
||||||
run: cmake -E make_directory ${{github.workspace}}/build
|
|
||||||
|
|
||||||
- name: Configure CMake
|
|
||||||
# Use a bash shell so we can use the same syntax for environment variable
|
|
||||||
# access regardless of the host operating system
|
|
||||||
shell: powershell
|
|
||||||
working-directory: ${{github.workspace}}/build
|
|
||||||
# Note the current convention is to use the -S and -B options here to specify source
|
|
||||||
# and build directories, but this is only available with CMake 3.13 and higher.
|
|
||||||
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
|
|
||||||
run: cmake $env:GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$env:BUILD_TYPE -DPLATFORM=Desktop
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
working-directory: ${{github.workspace}}/build
|
|
||||||
shell: powershell
|
|
||||||
# Execute the build. You can specify a specific target with "--target <NAME>"
|
|
||||||
run: cmake --build . --config $env:BUILD_TYPE
|
|
||||||
|
|
||||||
- name: Test
|
|
||||||
working-directory: ${{github.workspace}}/build
|
|
||||||
shell: powershell
|
|
||||||
# Execute tests defined by the CMake configuration.
|
|
||||||
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
|
||||||
run: ctest -C $env:BUILD_TYPE
|
|
||||||
|
|
||||||
build_linux:
|
|
||||||
name: Linux Build
|
|
||||||
# The CMake configure and build commands are platform agnostic and should work equally
|
|
||||||
# well on Windows or Mac. You can convert this to a matrix build if you need
|
|
||||||
# cross-platform coverage.
|
|
||||||
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Create Build Environment
|
|
||||||
# Some projects don't allow in-source building, so create a separate build directory
|
|
||||||
# We'll use this as our working directory for all subsequent commands
|
|
||||||
run: cmake -E make_directory ${{github.workspace}}/build
|
|
||||||
|
|
||||||
- name: Setup Environment
|
|
||||||
run: |
|
|
||||||
sudo apt-get update -qq
|
|
||||||
sudo apt-get install gcc-multilib
|
|
||||||
sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-dev libwayland-bin libxkbcommon-dev
|
|
||||||
- name: Configure CMake
|
|
||||||
# Use a bash shell so we can use the same syntax for environment variable
|
|
||||||
# access regardless of the host operating system
|
|
||||||
shell: bash
|
|
||||||
working-directory: ${{github.workspace}}/build
|
|
||||||
# Note the current convention is to use the -S and -B options here to specify source
|
|
||||||
# and build directories, but this is only available with CMake 3.13 and higher.
|
|
||||||
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
|
|
||||||
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPLATFORM=Desktop
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
working-directory: ${{github.workspace}}/build
|
|
||||||
shell: bash
|
|
||||||
# Execute the build. You can specify a specific target with "--target <NAME>"
|
|
||||||
run: cmake --build . --config $BUILD_TYPE
|
|
||||||
|
|
||||||
- name: Test
|
|
||||||
working-directory: ${{github.workspace}}/build
|
|
||||||
shell: bash
|
|
||||||
# Execute tests defined by the CMake configuration.
|
|
||||||
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
|
||||||
run: ctest -C $BUILD_TYPE
|
|
||||||
42
.github/workflows/build_examples_linux.yml
vendored
|
|
@ -1,42 +0,0 @@
|
||||||
name: Build raylib examples - Linux
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'examples/**'
|
|
||||||
- '.github/workflows/linux_examples.yml'
|
|
||||||
pull_request:
|
|
||||||
branches: [ master ]
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'examples/**'
|
|
||||||
- '.github/workflows/linux_examples.yml'
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Environment
|
|
||||||
run: |
|
|
||||||
sudo apt-get update -qq
|
|
||||||
sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-dev libxkbcommon-dev
|
|
||||||
|
|
||||||
- name: Build Library
|
|
||||||
run: |
|
|
||||||
cd src
|
|
||||||
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=STATIC
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
- name: Build Examples
|
|
||||||
run: |
|
|
||||||
cd examples
|
|
||||||
make PLATFORM=PLATFORM_DESKTOP -B
|
|
||||||
cd ..
|
|
||||||
36
.github/workflows/build_examples_windows.yml
vendored
|
|
@ -1,36 +0,0 @@
|
||||||
name: Build raylib examples - Windows
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'examples/**'
|
|
||||||
- '.github/workflows/windows_examples.yml'
|
|
||||||
pull_request:
|
|
||||||
branches: [ master ]
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'examples/**'
|
|
||||||
- '.github/workflows/windows_examples.yml'
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: windows-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Add MSBuild to PATH
|
|
||||||
uses: microsoft/setup-msbuild@v1
|
|
||||||
|
|
||||||
- name: Build Library (MSVC16)
|
|
||||||
run: |
|
|
||||||
cd projects/VS2019
|
|
||||||
msbuild.exe raylib.sln /property:Configuration=Release /property:Platform=x86
|
|
||||||
cd ../..
|
|
||||||
shell: cmd
|
|
||||||
|
|
||||||
128
.github/workflows/build_linux.yml
vendored
|
|
@ -1,128 +0,0 @@
|
||||||
name: Build raylib - Linux
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'examples/**'
|
|
||||||
- '.github/workflows/linux.yml'
|
|
||||||
pull_request:
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'examples/**'
|
|
||||||
- '.github/workflows/linux.yml'
|
|
||||||
release:
|
|
||||||
types: [published]
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
permissions:
|
|
||||||
contents: write # for actions/upload-release-asset to upload release asset
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
max-parallel: 1
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- bits: 32
|
|
||||||
ARCH: "i386"
|
|
||||||
ARCH_NAME: "i386"
|
|
||||||
COMPILER_PATH: "/usr/bin"
|
|
||||||
runner: "ubuntu-latest"
|
|
||||||
- bits: 64
|
|
||||||
ARCH: "x86_64"
|
|
||||||
ARCH_NAME: "amd64"
|
|
||||||
COMPILER_PATH: "/usr/bin"
|
|
||||||
runner: "ubuntu-latest"
|
|
||||||
- bits: 64
|
|
||||||
ARCH: "aarch64"
|
|
||||||
ARCH_NAME: "arm64"
|
|
||||||
COMPILER_PATH: "/usr/bin"
|
|
||||||
runner: "ubuntu-24.04-arm"
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.runner }}
|
|
||||||
env:
|
|
||||||
RELEASE_NAME: raylib-dev_linux_${{ matrix.ARCH_NAME }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@master
|
|
||||||
|
|
||||||
- name: Setup Release Version
|
|
||||||
run: |
|
|
||||||
echo "RELEASE_NAME=raylib-${{ github.event.release.tag_name }}_linux_${{ matrix.ARCH_NAME }}" >> $GITHUB_ENV
|
|
||||||
shell: bash
|
|
||||||
if: github.event_name == 'release' && github.event.action == 'published'
|
|
||||||
|
|
||||||
- name: Setup Environment
|
|
||||||
run: |
|
|
||||||
sudo apt-get update -qq
|
|
||||||
sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-dev libxkbcommon-dev
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
mkdir ${{ env.RELEASE_NAME }}
|
|
||||||
cd ${{ env.RELEASE_NAME }}
|
|
||||||
mkdir include
|
|
||||||
mkdir lib
|
|
||||||
cd ../../../raylib
|
|
||||||
# ${{ matrix.ARCH }}-linux-gnu-gcc -v
|
|
||||||
|
|
||||||
- name: Setup Environment (x86)
|
|
||||||
run : |
|
|
||||||
sudo apt-get install gcc-multilib
|
|
||||||
if: matrix.bits == 32 && matrix.ARCH == 'i386'
|
|
||||||
|
|
||||||
# TODO: Support 32bit (i386) static/shared library building
|
|
||||||
- name: Build Library (32-bit)
|
|
||||||
run: |
|
|
||||||
cd src
|
|
||||||
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" CUSTOM_CFLAGS="-m32" -B
|
|
||||||
# make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
|
||||||
cd ..
|
|
||||||
if: matrix.bits == 32
|
|
||||||
|
|
||||||
- name: Build Library (64-bit x86)
|
|
||||||
run: |
|
|
||||||
cd src
|
|
||||||
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
|
||||||
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
|
||||||
cd ..
|
|
||||||
if: matrix.bits == 64 && matrix.ARCH == 'x86_64'
|
|
||||||
|
|
||||||
- name: Build Library (64-bit ARM)
|
|
||||||
run: |
|
|
||||||
cd src
|
|
||||||
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
|
||||||
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
|
||||||
cd ..
|
|
||||||
if: matrix.bits == 64 && matrix.ARCH == 'aarch64'
|
|
||||||
|
|
||||||
- name: Generate Artifacts
|
|
||||||
run: |
|
|
||||||
cp -v ./src/raylib.h ./build/${{ env.RELEASE_NAME }}/include
|
|
||||||
cp -v ./src/raymath.h ./build/${{ env.RELEASE_NAME }}/include
|
|
||||||
cp -v ./src/rlgl.h ./build/${{ env.RELEASE_NAME }}/include
|
|
||||||
cp -v ./CHANGELOG ./build/${{ env.RELEASE_NAME }}/CHANGELOG
|
|
||||||
cp -v ./README.md ./build/${{ env.RELEASE_NAME }}/README.md
|
|
||||||
cp -v ./LICENSE ./build/${{ env.RELEASE_NAME }}/LICENSE
|
|
||||||
cd build
|
|
||||||
tar -czvf ${{ env.RELEASE_NAME }}.tar.gz ${{ env.RELEASE_NAME }}
|
|
||||||
|
|
||||||
- name: Upload Artifacts
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: ${{ env.RELEASE_NAME }}
|
|
||||||
path: |
|
|
||||||
./build/${{ env.RELEASE_NAME }}
|
|
||||||
!./build/${{ env.RELEASE_NAME }}.tar.gz
|
|
||||||
|
|
||||||
- name: Upload Artifact to Release
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
with:
|
|
||||||
files: ./build/${{ env.RELEASE_NAME }}.tar.gz
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
if: github.event_name == 'release' && github.event.action == 'published'
|
|
||||||
115
.github/workflows/build_macos.yml
vendored
|
|
@ -1,115 +0,0 @@
|
||||||
name: Build raylib - macOS
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'examples/**'
|
|
||||||
- '.github/workflows/macos.yml'
|
|
||||||
pull_request:
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'examples/**'
|
|
||||||
- '.github/workflows/macos.yml'
|
|
||||||
release:
|
|
||||||
types: [published]
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
permissions:
|
|
||||||
contents: write # for actions/upload-release-asset to upload release asset
|
|
||||||
runs-on: macos-latest
|
|
||||||
|
|
||||||
env:
|
|
||||||
RELEASE_NAME: raylib-dev_macos
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@master
|
|
||||||
|
|
||||||
- name: Setup Release Version
|
|
||||||
run: |
|
|
||||||
echo "RELEASE_NAME=raylib-${{ github.event.release.tag_name }}_macos" >> $GITHUB_ENV
|
|
||||||
shell: bash
|
|
||||||
if: github.event_name == 'release' && github.event.action == 'published'
|
|
||||||
|
|
||||||
- name: Setup Environment
|
|
||||||
run: |
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
mkdir ${{ env.RELEASE_NAME }}
|
|
||||||
cd ${{ env.RELEASE_NAME }}
|
|
||||||
mkdir include
|
|
||||||
mkdir lib
|
|
||||||
cd ../..
|
|
||||||
|
|
||||||
# Generating static + shared library, note that i386 architecture is deprecated
|
|
||||||
# Defining GL_SILENCE_DEPRECATION because OpenGL is deprecated on macOS
|
|
||||||
- name: Build Library
|
|
||||||
run: |
|
|
||||||
cd src
|
|
||||||
clang --version
|
|
||||||
|
|
||||||
# Extract version numbers from Makefile
|
|
||||||
brew install grep
|
|
||||||
RAYLIB_API_VERSION=`ggrep -Po 'RAYLIB_API_VERSION\s*=\s\K(.*)' Makefile`
|
|
||||||
RAYLIB_VERSION=`ggrep -Po 'RAYLIB_VERSION\s*=\s\K(.*)' Makefile`
|
|
||||||
|
|
||||||
# Build raylib x86_64 static
|
|
||||||
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=STATIC CUSTOM_CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION"
|
|
||||||
mv libraylib.a /tmp/libraylib_x86_64.a
|
|
||||||
make clean
|
|
||||||
|
|
||||||
# Build raylib arm64 static
|
|
||||||
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=STATIC CUSTOM_CFLAGS="-target arm64-apple-macos11 -DGL_SILENCE_DEPRECATION" -B
|
|
||||||
mv libraylib.a /tmp/libraylib_arm64.a
|
|
||||||
make clean
|
|
||||||
|
|
||||||
# Join x86_64 and arm64 static
|
|
||||||
lipo -create -output ../build/${{ env.RELEASE_NAME }}/lib/libraylib.a /tmp/libraylib_x86_64.a /tmp/libraylib_arm64.a
|
|
||||||
|
|
||||||
# Build raylib x86_64 dynamic
|
|
||||||
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED CUSTOM_CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION" CUSTOM_LDFLAGS="-target x86_64-apple-macos10.12" -B
|
|
||||||
mv libraylib.${RAYLIB_VERSION}.dylib /tmp/libraylib_x86_64.${RAYLIB_VERSION}.dylib
|
|
||||||
make clean
|
|
||||||
|
|
||||||
# Build raylib arm64 dynamic
|
|
||||||
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED CUSTOM_CFLAGS="-target arm64-apple-macos11 -DGL_SILENCE_DEPRECATION" CUSTOM_LDFLAGS="-target arm64-apple-macos11" -B
|
|
||||||
mv libraylib.${RAYLIB_VERSION}.dylib /tmp/libraylib_arm64.${RAYLIB_VERSION}.dylib
|
|
||||||
|
|
||||||
# Join x86_64 and arm64 dynamic
|
|
||||||
lipo -create -output ../build/${{ env.RELEASE_NAME }}/lib/libraylib.${RAYLIB_VERSION}.dylib /tmp/libraylib_x86_64.${RAYLIB_VERSION}.dylib /tmp/libraylib_arm64.${RAYLIB_VERSION}.dylib
|
|
||||||
ln -sv libraylib.${RAYLIB_VERSION}.dylib ../build/${{ env.RELEASE_NAME }}/lib/libraylib.dylib
|
|
||||||
ln -sv libraylib.${RAYLIB_VERSION}.dylib ../build/${{ env.RELEASE_NAME }}/lib/libraylib.${RAYLIB_API_VERSION}.dylib
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
- name: Generate Artifacts
|
|
||||||
run: |
|
|
||||||
cp -v ./src/raylib.h ./build/${{ env.RELEASE_NAME }}/include
|
|
||||||
cp -v ./src/raymath.h ./build/${{ env.RELEASE_NAME }}/include
|
|
||||||
cp -v ./src/rlgl.h ./build/${{ env.RELEASE_NAME }}/include
|
|
||||||
cp -v ./CHANGELOG ./build/${{ env.RELEASE_NAME }}/CHANGELOG
|
|
||||||
cp -v ./README.md ./build/${{ env.RELEASE_NAME }}/README.md
|
|
||||||
cp -v ./LICENSE ./build/${{ env.RELEASE_NAME }}/LICENSE
|
|
||||||
cd build
|
|
||||||
tar -czvf ${{ env.RELEASE_NAME }}.tar.gz ${{ env.RELEASE_NAME }}
|
|
||||||
|
|
||||||
- name: Upload Artifacts
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: ${{ env.RELEASE_NAME }}
|
|
||||||
path: |
|
|
||||||
./build/${{ env.RELEASE_NAME }}
|
|
||||||
!./build/${{ env.RELEASE_NAME }}.tar.gz
|
|
||||||
|
|
||||||
- name: Upload Artifact to Release
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
with:
|
|
||||||
files: ./build/${{ env.RELEASE_NAME }}.tar.gz
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
if: github.event_name == 'release' && github.event.action == 'published'
|
|
||||||
85
.github/workflows/build_webassembly.yml
vendored
|
|
@ -1,85 +0,0 @@
|
||||||
name: Build raylib - WebAssembly
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'examples/**'
|
|
||||||
- '.github/workflows/webassembly.yml'
|
|
||||||
pull_request:
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'examples/**'
|
|
||||||
- '.github/workflows/webassembly.yml'
|
|
||||||
release:
|
|
||||||
types: [published]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: windows-latest
|
|
||||||
|
|
||||||
env:
|
|
||||||
RELEASE_NAME: raylib-dev_webassembly
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@master
|
|
||||||
|
|
||||||
- name: Setup emsdk
|
|
||||||
uses: mymindstorm/setup-emsdk@v14
|
|
||||||
with:
|
|
||||||
version: 5.0.3
|
|
||||||
actions-cache-folder: 'emsdk-cache'
|
|
||||||
|
|
||||||
- name: Setup Release Version
|
|
||||||
run: |
|
|
||||||
echo "RELEASE_NAME=raylib-${{ github.event.release.tag_name }}_webassembly" >> $GITHUB_ENV
|
|
||||||
shell: bash
|
|
||||||
if: github.event_name == 'release' && github.event.action == 'published'
|
|
||||||
|
|
||||||
- name: Setup Environment
|
|
||||||
run: |
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
mkdir ${{ env.RELEASE_NAME }}
|
|
||||||
cd ${{ env.RELEASE_NAME }}
|
|
||||||
mkdir include
|
|
||||||
mkdir lib
|
|
||||||
cd ../..
|
|
||||||
|
|
||||||
- name: Build Library
|
|
||||||
run: |
|
|
||||||
cd src
|
|
||||||
emcc -v
|
|
||||||
make PLATFORM=PLATFORM_WEB EMSDK_PATH="D:/a/raylib/raylib/emsdk-cache/emsdk-main" RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
- name: Generate Artifacts
|
|
||||||
run: |
|
|
||||||
copy /Y .\src\raylib.h .\build\${{ env.RELEASE_NAME }}\include\raylib.h
|
|
||||||
copy /Y .\src\raymath.h .\build\${{ env.RELEASE_NAME }}\include\raymath.h
|
|
||||||
copy /Y .\src\rlgl.h .\build\${{ env.RELEASE_NAME }}\include\rlgl.h
|
|
||||||
copy /Y .\CHANGELOG .\build/${{ env.RELEASE_NAME }}\CHANGELOG
|
|
||||||
copy /Y .\README.md .\build\${{ env.RELEASE_NAME }}\README.md
|
|
||||||
copy /Y .\LICENSE .\build\${{ env.RELEASE_NAME }}\LICENSE
|
|
||||||
cd build
|
|
||||||
7z a ./${{ env.RELEASE_NAME }}.zip ./${{ env.RELEASE_NAME }}
|
|
||||||
dir
|
|
||||||
shell: cmd
|
|
||||||
|
|
||||||
- name: Upload Artifacts
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: ${{ env.RELEASE_NAME }}
|
|
||||||
path: |
|
|
||||||
./build/${{ env.RELEASE_NAME }}
|
|
||||||
!./build/${{ env.RELEASE_NAME }}.zip
|
|
||||||
|
|
||||||
- name: Upload Artifact to Release
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
with:
|
|
||||||
files: ./build/${{ env.RELEASE_NAME }}.zip
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
if: github.event_name == 'release' && github.event.action == 'published'
|
|
||||||
156
.github/workflows/build_windows.yml
vendored
|
|
@ -1,156 +0,0 @@
|
||||||
name: Build raylib - Windows
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'examples/**'
|
|
||||||
- '.github/workflows/windows.yml'
|
|
||||||
pull_request:
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'examples/**'
|
|
||||||
- '.github/workflows/windows.yml'
|
|
||||||
release:
|
|
||||||
types: [published]
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
permissions:
|
|
||||||
contents: write # for actions/upload-release-asset to upload release asset
|
|
||||||
runs-on: windows-latest
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
max-parallel: 1
|
|
||||||
matrix:
|
|
||||||
compiler: [mingw-w64, msvc16]
|
|
||||||
ziptarget: [ win32, win64, winarm64 ]
|
|
||||||
include:
|
|
||||||
- compiler: mingw-w64
|
|
||||||
ARCH: "i686"
|
|
||||||
WINDRES_ARCH: pe-i386
|
|
||||||
ziptarget: "win32"
|
|
||||||
- compiler: mingw-w64
|
|
||||||
ARCH: "x86_64"
|
|
||||||
WINDRES_ARCH: pe-x86-64
|
|
||||||
ziptarget: "win64"
|
|
||||||
- compiler: msvc16
|
|
||||||
ARCH: "x86"
|
|
||||||
VSARCHPATH: "Win32"
|
|
||||||
ziptarget: "win32"
|
|
||||||
- compiler: msvc16
|
|
||||||
ARCH: "x64"
|
|
||||||
VSARCHPATH: "x64"
|
|
||||||
ziptarget: "win64"
|
|
||||||
- compiler: msvc16
|
|
||||||
ARCH: "ARM64"
|
|
||||||
VSARCHPATH: "ARM64"
|
|
||||||
ziptarget: "winarm64"
|
|
||||||
exclude:
|
|
||||||
- compiler: mingw-w64
|
|
||||||
ziptarget: winarm64 # We don't build arm64 with mingw-w64 yet
|
|
||||||
|
|
||||||
env:
|
|
||||||
RELEASE_NAME: raylib-dev_${{ matrix.ziptarget }}_${{ matrix.compiler }}
|
|
||||||
GNUTARGET: default
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@master
|
|
||||||
|
|
||||||
- name: Setup Release Version
|
|
||||||
run: |
|
|
||||||
echo "RELEASE_NAME=raylib-${{ github.event.release.tag_name }}_${{ matrix.ziptarget }}_${{ matrix.compiler }}" >> $GITHUB_ENV
|
|
||||||
shell: bash
|
|
||||||
if: github.event_name == 'release' && github.event.action == 'published'
|
|
||||||
|
|
||||||
- name: Setup Environment
|
|
||||||
run: |
|
|
||||||
dir
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
mkdir ${{ env.RELEASE_NAME }}
|
|
||||||
cd ${{ env.RELEASE_NAME }}
|
|
||||||
mkdir include
|
|
||||||
mkdir lib
|
|
||||||
cd ../../../raylib
|
|
||||||
|
|
||||||
# Setup MSBuild.exe path if required
|
|
||||||
- name: Setup MSBuild
|
|
||||||
uses: microsoft/setup-msbuild@v2
|
|
||||||
if: matrix.compiler == 'msvc16'
|
|
||||||
|
|
||||||
- name: Build Library (MinGW-w64 32bit)
|
|
||||||
run: |
|
|
||||||
cd src
|
|
||||||
x86_64-w64-mingw32-gcc.exe --version
|
|
||||||
windres.exe --version
|
|
||||||
dir C:\msys64\mingw64\bin
|
|
||||||
make PLATFORM=PLATFORM_DESKTOP CC=x86_64-w64-mingw32-gcc.exe RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" CUSTOM_CFLAGS=-m32
|
|
||||||
//windres.exe -i raylib.dll.rc -o raylib.dll.rc.data -O coff --target=${{ matrix.WINDRES_ARCH }}
|
|
||||||
//make PLATFORM=PLATFORM_DESKTOP CC=${{ matrix.ARCH }}-w64-mingw32-gcc.exe RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
|
||||||
cd ..
|
|
||||||
shell: cmd
|
|
||||||
if: |
|
|
||||||
matrix.compiler == 'mingw-w64' &&
|
|
||||||
matrix.arch == 'i686'
|
|
||||||
|
|
||||||
- name: Build Library (MinGW-w64 64bit)
|
|
||||||
run: |
|
|
||||||
cd src
|
|
||||||
${{ matrix.ARCH }}-w64-mingw32-gcc.exe --version
|
|
||||||
windres.exe --version
|
|
||||||
dir C:\msys64\mingw64\bin
|
|
||||||
make PLATFORM=PLATFORM_DESKTOP CC=${{ matrix.ARCH }}-w64-mingw32-gcc.exe RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib"
|
|
||||||
windres.exe -i raylib.dll.rc -o raylib.dll.rc.data -O coff --target=${{ matrix.WINDRES_ARCH }}
|
|
||||||
make PLATFORM=PLATFORM_DESKTOP CC=${{ matrix.ARCH }}-w64-mingw32-gcc.exe RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
|
||||||
cd ..
|
|
||||||
shell: cmd
|
|
||||||
if: |
|
|
||||||
matrix.compiler == 'mingw-w64' &&
|
|
||||||
matrix.arch == 'x86_64'
|
|
||||||
|
|
||||||
- name: Build Library (MSVC16)
|
|
||||||
run: |
|
|
||||||
cd projects/VS2022
|
|
||||||
msbuild.exe raylib.sln /target:raylib /property:Configuration=Release /property:Platform=${{ matrix.ARCH }}
|
|
||||||
copy /Y .\build\raylib\bin\${{ matrix.VSARCHPATH }}\Release\raylib.lib .\..\..\build\${{ env.RELEASE_NAME }}\lib\raylib.lib
|
|
||||||
msbuild.exe raylib.sln /target:raylib /property:Configuration=Release.DLL /property:Platform=${{ matrix.ARCH }}
|
|
||||||
copy /Y .\build\raylib\bin\${{ matrix.VSARCHPATH }}\Release.DLL\raylib.dll .\..\..\build\${{ env.RELEASE_NAME }}\lib\raylib.dll
|
|
||||||
copy /Y .\build\raylib\bin\${{ matrix.VSARCHPATH }}\Release.DLL\raylib.lib .\..\..\build\${{ env.RELEASE_NAME }}\lib\raylibdll.lib
|
|
||||||
cd ../..
|
|
||||||
shell: cmd
|
|
||||||
if: matrix.compiler == 'msvc16'
|
|
||||||
|
|
||||||
- name: Generate Artifacts
|
|
||||||
run: |
|
|
||||||
copy /Y .\src\raylib.h .\build\${{ env.RELEASE_NAME }}\include\raylib.h
|
|
||||||
copy /Y .\src\raymath.h .\build\${{ env.RELEASE_NAME }}\include\raymath.h
|
|
||||||
copy /Y .\src\rlgl.h .\build\${{ env.RELEASE_NAME }}\include\rlgl.h
|
|
||||||
copy /Y .\CHANGELOG .\build\${{ env.RELEASE_NAME }}\CHANGELOG
|
|
||||||
copy /Y .\README.md .\build\${{ env.RELEASE_NAME }}\README.md
|
|
||||||
copy /Y .\LICENSE .\build\${{ env.RELEASE_NAME }}\LICENSE
|
|
||||||
cd build
|
|
||||||
7z a ./${{ env.RELEASE_NAME }}.zip ./${{ env.RELEASE_NAME }}
|
|
||||||
dir
|
|
||||||
shell: cmd
|
|
||||||
|
|
||||||
- name: Upload Artifacts
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: ${{ env.RELEASE_NAME }}
|
|
||||||
path: |
|
|
||||||
./build/${{ env.RELEASE_NAME }}
|
|
||||||
!./build/${{ env.RELEASE_NAME }}.zip
|
|
||||||
|
|
||||||
- name: Upload Artifact to Release
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
with:
|
|
||||||
files: ./build/${{ env.RELEASE_NAME }}.zip
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
if: github.event_name == 'release' && github.event.action == 'published'
|
|
||||||
37
.github/workflows/parse_api.yml
vendored
|
|
@ -1,37 +0,0 @@
|
||||||
name: Parse raylib API
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- "src/raylib.h"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Update parse files
|
|
||||||
working-directory: tools/rlparser
|
|
||||||
run: |
|
|
||||||
make raylib_api
|
|
||||||
mv raylib_api.* output
|
|
||||||
|
|
||||||
- name: Diff parse files
|
|
||||||
id: diff
|
|
||||||
run: |
|
|
||||||
git add -N tools/rlparser/output
|
|
||||||
git diff --name-only --exit-code
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: Commit parse files
|
|
||||||
if: steps.diff.outcome == 'failure'
|
|
||||||
run: |
|
|
||||||
set -x
|
|
||||||
git config user.name "github-actions[bot]"
|
|
||||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
||||||
git add tools/rlparser/output
|
|
||||||
git commit -m "rlparser: update raylib_api.* by CI"
|
|
||||||
git push
|
|
||||||
73
.github/workflows/update_examples.yml
vendored
|
|
@ -1,73 +0,0 @@
|
||||||
name: Update examples collection
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- 'examples/**'
|
|
||||||
pull_request:
|
|
||||||
paths:
|
|
||||||
- 'examples/**'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup emsdk
|
|
||||||
uses: mymindstorm/setup-emsdk@v14
|
|
||||||
with:
|
|
||||||
version: 'latest'
|
|
||||||
actions-cache-folder: 'emsdk-cache'
|
|
||||||
|
|
||||||
- name: Clone raylib.com repo to update files
|
|
||||||
run: |
|
|
||||||
git clone https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/raysan5/raylib.com.git
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Build and run rexm tool (requires GNU Makefile)
|
|
||||||
# "rexm validate" validates examples collection, looking for inconsistencies, it does not rebuild examples
|
|
||||||
# "rexm update" validates and updates all examples with inconsistencies, pushing fixes to raylib and raylib.com repos
|
|
||||||
# note that rexm calls examples/Makefile.Web internally, so it requires [make] tool available
|
|
||||||
run: |
|
|
||||||
sudo apt-get update && sudo apt-get install -y libopengl0 libglu1-mesa libx11-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libgl1-mesa-dev libglu1-mesa-dev
|
|
||||||
cd "${{ github.workspace }}/src"
|
|
||||||
make PLATFORM=PLATFORM_DESKTOP
|
|
||||||
sudo make install
|
|
||||||
make clean
|
|
||||||
make PLATFORM=PLATFORM_WEB
|
|
||||||
cd ../tools/rexm/
|
|
||||||
make
|
|
||||||
export REXM_EXAMPLES_BASE_PATH="${{ github.workspace }}/examples"
|
|
||||||
export REXM_EXAMPLES_WEB_PATH="${{ github.workspace }}/raylib.com/examples"
|
|
||||||
export REXM_EXAMPLES_TEMPLATE_FILE_PATH="${{ github.workspace }}/examples/examples_template.c"
|
|
||||||
export REXM_EXAMPLES_TEMPLATE_SCREENSHOT_PATH="${{ github.workspace }}/examples/examples_template.png"
|
|
||||||
export REXM_EXAMPLES_COLLECTION_FILE_PATH="${{ github.workspace }}/examples/examples_list.txt"
|
|
||||||
export REXM_EXAMPLES_VS2022_SLN_FILE="${{ github.workspace }}/projects/VS2022/raylib.sln"
|
|
||||||
export EMSDK_PATH="${{ github.workspace }}/emsdk-cache/emsdk-main"
|
|
||||||
./rexm validate
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Commit changes to raylib repo (DISABLED)
|
|
||||||
if: github.event_name == 'push' && false
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
|
||||||
git config --global user.name "github-actions[bot]"
|
|
||||||
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
||||||
git add -A
|
|
||||||
git commit -m "Update examples collection" || echo "git exited with code 1, nothing changed"
|
|
||||||
git push
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Push changes to raylib.com repo (DISABLED)
|
|
||||||
if: github.event_name == 'push' && false
|
|
||||||
run: |
|
|
||||||
cd raylib.com
|
|
||||||
git add -A
|
|
||||||
git commit -m "Update web examples" || echo "git exited with code 1, nothing changed"
|
|
||||||
git push origin
|
|
||||||
shell: bash
|
|
||||||
102
.gitignore
vendored
|
|
@ -1,10 +1,11 @@
|
||||||
# Ignore generated files
|
# Ignore generated files
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
# Ignore VIM's backup generated files
|
# Ignore Android generated files and folders
|
||||||
*.swp
|
src_android/obj/
|
||||||
*.swo
|
templates/android_project/bin/
|
||||||
*~
|
templates/android_project/obj/
|
||||||
|
templates/android_project/libs/
|
||||||
|
|
||||||
# Ignore thumbnails created by windows
|
# Ignore thumbnails created by windows
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
|
@ -13,10 +14,9 @@ Thumbs.db
|
||||||
# *.obj --> Can be confused with 3d model!
|
# *.obj --> Can be confused with 3d model!
|
||||||
*.pdb
|
*.pdb
|
||||||
*.aps
|
*.aps
|
||||||
*.user
|
*.vcproj.*.user
|
||||||
# *.vcproj
|
*.vcxproj*
|
||||||
# *.vcxproj*
|
*.sln
|
||||||
# *.sln
|
|
||||||
*.vspscc
|
*.vspscc
|
||||||
*_i.c
|
*_i.c
|
||||||
*.i
|
*.i
|
||||||
|
|
@ -30,51 +30,22 @@ Thumbs.db
|
||||||
*.cache
|
*.cache
|
||||||
*.ilk
|
*.ilk
|
||||||
*.log
|
*.log
|
||||||
.vs
|
|
||||||
|
|
||||||
[Bb]in
|
[Bb]in
|
||||||
[Dd]ebug/
|
[Dd]ebug/
|
||||||
|
[Dd]ebug.win32/
|
||||||
*.sbr
|
*.sbr
|
||||||
*.sdf
|
*.sdf
|
||||||
obj/
|
obj/
|
||||||
[R]elease/
|
[Rr]elease.win32/
|
||||||
_ReSharper*/
|
_ReSharper*/
|
||||||
[Tt]est[Rr]esult*
|
[Tt]est[Rr]esult*
|
||||||
ipch/
|
ipch/
|
||||||
*.opensdf
|
*.opensdf
|
||||||
*.db
|
|
||||||
*.opendb
|
|
||||||
packages/
|
|
||||||
!examples/models/resources/models/obj/
|
|
||||||
|
|
||||||
# Ignore compiled binaries
|
# Ignore compiled binaries
|
||||||
*.o
|
*.o
|
||||||
*.exe
|
*.exe
|
||||||
*.a
|
!tools/rrem.exe
|
||||||
*.bc
|
|
||||||
*.so
|
|
||||||
*.so.*
|
|
||||||
*.dll
|
|
||||||
*.h.pch
|
|
||||||
./*.obj
|
|
||||||
|
|
||||||
# Ignore SDL libs for testing
|
|
||||||
src/external/SDL2
|
|
||||||
src/external/SDL3
|
|
||||||
|
|
||||||
# Emscripten
|
|
||||||
emsdk
|
|
||||||
|
|
||||||
# Ignore binaries generated in examples/
|
|
||||||
examples/**/*
|
|
||||||
!examples/**/*.*
|
|
||||||
!examples/**/*/
|
|
||||||
examples/**/*.exe
|
|
||||||
examples/**/*.wasm
|
|
||||||
examples/**/*.data
|
|
||||||
examples/**/*.js
|
|
||||||
examples/**/*.html
|
|
||||||
examples/**/logs/*
|
|
||||||
|
|
||||||
# Ignore files build by xcode
|
# Ignore files build by xcode
|
||||||
*.mode*v*
|
*.mode*v*
|
||||||
|
|
@ -89,52 +60,5 @@ xcschememanagement.plist
|
||||||
._.*
|
._.*
|
||||||
xcuserdata/
|
xcuserdata/
|
||||||
DerivedData/
|
DerivedData/
|
||||||
|
*.dll
|
||||||
# VSCode project
|
src/libraylib.a
|
||||||
.vscode
|
|
||||||
.clangd
|
|
||||||
|
|
||||||
# Jetbrains project
|
|
||||||
.idea/
|
|
||||||
cmake-build-*/
|
|
||||||
|
|
||||||
# CMake stuff
|
|
||||||
CMakeCache.txt
|
|
||||||
CMakeFiles
|
|
||||||
CMakeScripts
|
|
||||||
Testing
|
|
||||||
cmake_install.cmake
|
|
||||||
cmake_uninstall.cmake
|
|
||||||
install_manifest.txt
|
|
||||||
compile_commands.json
|
|
||||||
CTestTestfile.cmake
|
|
||||||
build
|
|
||||||
|
|
||||||
# Ignore GNU global tags
|
|
||||||
GPATH
|
|
||||||
GRTAGS
|
|
||||||
GTAGS
|
|
||||||
|
|
||||||
# Zig programming language
|
|
||||||
.zig-cache/
|
|
||||||
zig-cache/
|
|
||||||
zig-pkg/
|
|
||||||
zig-out/
|
|
||||||
build/
|
|
||||||
build-*/
|
|
||||||
docgen_tmp/
|
|
||||||
|
|
||||||
# Tools stuff
|
|
||||||
tools/rlparser/rlparser.exe
|
|
||||||
tools/rlparser/rlparser
|
|
||||||
tools/rexm/rexm.exe
|
|
||||||
tools/rexm/rexm
|
|
||||||
|
|
||||||
# CI
|
|
||||||
emsdk-cache/
|
|
||||||
raylib.com/
|
|
||||||
|
|
||||||
# Wayland files
|
|
||||||
src/*protocol.h
|
|
||||||
src/*protocol-code.h
|
|
||||||
src/*protocol-code.c
|
|
||||||
193
BINDINGS.md
|
|
@ -1,193 +0,0 @@
|
||||||
# raylib bindings and wrappers
|
|
||||||
|
|
||||||
Some people ported raylib to other languages in the form of bindings or wrappers to the library. Here is a list with all the ports available. Feel free to send a PR if you know of any binding/wrapper not in this list.
|
|
||||||
|
|
||||||
### Language Bindings
|
|
||||||
|
|
||||||
| Name | raylib Version | Language | License |
|
|
||||||
| :--------------------------------------------------------------------------------------- | :--------------: | :------------------------------------------------------------------: | :------------------: |
|
|
||||||
| [raylib](https://github.com/raysan5/raylib) | **6.0** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | Zlib |
|
|
||||||
| [raylib-ada](https://github.com/Fabien-Chouteau/raylib-ada) | **5.5** | [Ada](https://en.wikipedia.org/wiki/Ada_(programming_language)) | MIT |
|
|
||||||
| [raylib-beef](https://github.com/Starpelly/raylib-beef) | **5.5** | [Beef](https://www.beeflang.org) | MIT |
|
|
||||||
| [raybit](https://github.com/Alex-Velez/raybit) | **5.0** | [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck) | MIT |
|
|
||||||
| [raylib-c3](https://github.com/c3lang/vendor/tree/main/libraries/raylib6.c3l) | **6** | [C3](https://c3-lang.org) | MIT |
|
|
||||||
| [raylib-cs](https://github.com/raylib-cs/raylib-cs) | **6.0** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | Zlib |
|
|
||||||
| [Raylib-CsLo](https://github.com/NotNotTech/Raylib-CsLo) | 4.2 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 |
|
|
||||||
| [Raylib-CSharp-Vinculum](https://github.com/ZeroElectric/Raylib-CSharp-Vinculum) | **5.0** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 |
|
|
||||||
| [Raylib-CSharp](https://github.com/MrScautHD/Raylib-CSharp) | **5.5** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MIT |
|
|
||||||
| [Raylib-cs.BleedingEdge](https://github.com/danilwhale/Raylib-cs.BleedingEdge) | **5.6-dev** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | Zlib |
|
|
||||||
| [cl-raylib](https://github.com/longlene/cl-raylib) | 4.0 | [Common Lisp](https://common-lisp.net) | MIT |
|
|
||||||
| [claylib/wrap](https://github.com/defun-games/claylib) | 4.5 | [Common Lisp](https://common-lisp.net) | Zlib |
|
|
||||||
| [claw-raylib](https://github.com/bohonghuang/claw-raylib) | **auto** | [Common Lisp](https://common-lisp.net) | Apache-2.0 |
|
|
||||||
| [raylib](https://github.com/fosskers/raylib) | 5.5 | [Common Lisp](https://common-lisp.net) | MPL-2.0 |
|
|
||||||
| [chez-raylib](https://github.com/Yunoinsky/chez-raylib) | **auto** | [Chez Scheme](https://cisco.github.io/ChezScheme) | GPLv3 |
|
|
||||||
| [chicken-raylib](https://github.com/meowstr/chicken-raylib) | 5.5 | [CHICKEN Scheme](https://wiki.call-cc.org) | MIT |
|
|
||||||
| [CLIPSraylib](https://github.com/mrryanjohnston/CLIPSraylib) | **auto** | [CLIPS](https://www.clipsrules.net/) | MIT |
|
|
||||||
| [raylib-cr](https://github.com/sol-vin/raylib-cr) | 4.6-dev (5e1a81) | [Crystal](https://crystal-lang.org) | Apache-2.0 |
|
|
||||||
| [ray-cyber](https://github.com/fubark/ray-cyber) | **5.0** | [Cyber](https://cyberscript.dev) | MIT |
|
|
||||||
| [dart-raylib](https://gitlab.com/wolfenrain/dart-raylib) | 4.0 | [Dart](https://dart.dev) | MIT |
|
|
||||||
| [raylib_dart](https://pub.dev/packages/raylib_dart) | 6.0 | [Dart](https://dart.dev) | MIT |
|
|
||||||
| [bindbc-raylib3](https://github.com/o3o/bindbc-raylib3) | **5.0** | [D](https://dlang.org) | BSL-1.0 |
|
|
||||||
| [dray](https://github.com/redthing1/dray) | **5.0** | [D](https://dlang.org) | Apache-2.0 |
|
|
||||||
| [raylib-d](https://github.com/schveiguy/raylib-d) | **6.0** | [D](https://dlang.org) | Zlib |
|
|
||||||
| [Deno-Raylib](https://github.com/JJLDonley/Deno-Raylib) | **6.0** | [Deno / TS](https://deno.land) | MIT |
|
|
||||||
| [rayex](https://github.com/shiryel/rayex) | 3.7 | [elixir](https://elixir-lang.org) | Apache-2.0 |
|
|
||||||
| [raylib-elle](https://github.com/acquitelol/elle/blob/rewrite/std/raylib.le) | **5.5** | [Elle](https://github.com/acquitelol/elle) | GPL-3.0 |
|
|
||||||
| [raylib-factor](https://github.com/factor/factor/blob/master/extra/raylib/raylib.factor) | 5.5 | [Factor](https://factorcode.org) | BSD |
|
|
||||||
| [raylib4fb](https://github.com/mudhairless/raylib4fb) | **6.0** | [FreeBASIC](https://www.freebasic.net) | Zlib |
|
|
||||||
| [raylib-freebasic](https://github.com/WIITD/raylib-freebasic) | **5.0** | [FreeBASIC](https://www.freebasic.net) | MIT |
|
|
||||||
| [raylib.f](https://github.com/cthulhuology/raylib.f) | **5.5** | [Forth](https://forth.com) | Zlib |
|
|
||||||
| [fortran-raylib](https://github.com/interkosmos/fortran-raylib) | **5.5** | [Fortran](https://fortran-lang.org) | ISC |
|
|
||||||
| [raylib-go](https://github.com/gen2brain/raylib-go) | **6.0** | [Go](https://golang.org) | Zlib |
|
|
||||||
| [raylib-guile](https://github.com/petelliott/raylib-guile) | **auto** | [Guile](https://www.gnu.org/software/guile) | Zlib |
|
|
||||||
| [gforth-raylib](https://github.com/ArnautDaniel/gforth-raylib) | 3.5 | [Gforth](https://gforth.org) | **???** |
|
|
||||||
| [h-raylib](https://github.com/Anut-py/h-raylib) | **5.5-dev** | [Haskell](https://haskell.org) | Apache-2.0 |
|
|
||||||
| [raylib-hx](https://github.com/foreignsasquatch/raylib-hx) | 4.2 | [Haxe](https://haxe.org) | Zlib |
|
|
||||||
| [hb-raylib](https://github.com/MarcosLeonardoMendezGerencir/hb-raylib) | 3.5 | [Harbour](https://harbour.github.io) | MIT |
|
|
||||||
| [jaylib](https://github.com/janet-lang/jaylib) | **5.0** | [Janet](https://janet-lang.org) | MIT |
|
|
||||||
| [jaylib](https://github.com/electronstudio/jaylib/) | **5.5** | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | GPLv3+CE |
|
|
||||||
| [raylib-j](https://github.com/CreedVI/Raylib-J) | 4.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | Zlib |
|
|
||||||
| [Raylib.jl](https://github.com/chengchingwen/Raylib.jl) | 4.2 | [Julia](https://julialang.org) | Zlib |
|
|
||||||
| [kaylib](https://github.com/electronstudio/kaylib) | 3.7 | [Kotlin/native](https://kotlinlang.org) | **???** |
|
|
||||||
| [KaylibKit](https://codeberg.org/Kenta/KaylibKit) | 4.5 | [Kotlin/native](https://kotlinlang.org) | Zlib |
|
|
||||||
| [raylib-lua](https://github.com/TSnake41/raylib-lua) | 5.5 | [Lua](http://www.lua.org) | ISC |
|
|
||||||
| [raylib-lua-bindings (WIP)](https://github.com/legendaryredfox/raylib-lua-bindings) | 5.5 | [Lua](http://www.lua.org) | ISC |
|
|
||||||
| [ReiLua](https://github.com/nullstare/ReiLua) | 5.5 | [Lua](http://www.lua.org) | MIT |
|
|
||||||
| [raylib-lua-sol](https://github.com/RobLoach/raylib-lua-sol) | 5.5 | [Lua](http://www.lua.org) | Zlib |
|
|
||||||
| [raylib-luajit](https://github.com/homma/raylib-luajit) | 5.5 | [Lua](http://www.lua.org) | MIT |
|
|
||||||
| [raylib-luajit-generated](https://github.com/james2doyle/raylib-luajit-generated) | 5.5 | [Lua](http://www.lua.org) | MIT |
|
|
||||||
| [raylib-matte](https://github.com/jcorks/raylib-matte) | 4.6-dev | [Matte](https://github.com/jcorks/matte) | **???** |
|
|
||||||
| [Raylib.nelua](https://github.com/AuzFox/Raylib.nelua) | **5.5** | [nelua](https://nelua.io) | Zlib |
|
|
||||||
| [raylib-bindings](https://github.com/vaiorabbit/raylib-bindings) | 5.6-dev | [Ruby](https://www.ruby-lang.org/en) | Zlib |
|
|
||||||
| [naylib](https://github.com/planetis-m/naylib) | **5.6-dev** | [Nim](https://nim-lang.org) | MIT |
|
|
||||||
| [node-raylib](https://github.com/RobLoach/node-raylib) | 4.5 | [Node.js](https://nodejs.org/en) | Zlib |
|
|
||||||
| [raylib-odin](https://github.com/odin-lang/Odin/tree/master/vendor/raylib) | **5.5** | [Odin](https://odin-lang.org) | Zlib |
|
|
||||||
| [raylib_odin_bindings](https://github.com/Deathbat2190/raylib_odin_bindings) | 4.0-dev | [Odin](https://odin-lang.org) | MIT |
|
|
||||||
| [raylib-ocaml](https://github.com/tjammer/raylib-ocaml) | **6.0** | [OCaml](https://ocaml.org) | MIT |
|
|
||||||
| [TurboRaylib](https://github.com/turborium/TurboRaylib) | 4.5 | [Object Pascal](https://en.wikipedia.org/wiki/Object_Pascal) | MIT |
|
|
||||||
| [Ray4Laz](https://github.com/GuvaCode/Ray4Laz) | **6.0** | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal)/[Delphi](https://en.wikipedia.org/wiki/Delphi_(software)) | Zlib |
|
|
||||||
| [Raylib.4.0.Pascal](https://github.com/sysrpl/Raylib.4.0.Pascal) | 4.0 | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal) | Zlib |
|
|
||||||
| [pyraylib](https://github.com/Ho011/pyraylib) | 3.7 | [Python](https://www.python.org) | Zlib |
|
|
||||||
| [raylib-python-cffi](https://github.com/electronstudio/raylib-python-cffi) | **5.5** | [Python](https://www.python.org) | EPL-2.0 |
|
|
||||||
| [raylibpyctbg](https://github.com/overdev/raylibpyctbg) | 5.5 | [Python](https://www.python.org) | MIT |
|
|
||||||
| [raylib-py](https://github.com/overdev/raylib-py) | 5.5 | [Python](https://www.python.org) | MIT |
|
|
||||||
| [raylib-python-ctypes](https://github.com/sDos280/raylib-python-ctypes) | 4.6-dev | [Python](https://www.python.org) | MIT |
|
|
||||||
| [raylib-pkpy-bindings](https://github.com/blueloveTH/pkpy-bindings) | 5.1-dev | [pocketpy](https://pocketpy.dev) | MIT |
|
|
||||||
| [raylib-php](https://github.com/joseph-montanez/raylib-php) | 4.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | Zlib |
|
|
||||||
| [raylib-phpcpp](https://github.com/oraoto/raylib-phpcpp) | 3.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | Zlib |
|
|
||||||
| [raylibr](https://github.com/jeroenjanssens/raylibr) | 4.0 | [R](https://www.r-project.org) | MIT |
|
|
||||||
| [raylib-ffi](https://github.com/ewpratten/raylib-ffi) | 5.5 | [Rust](https://www.rust-lang.org) | GPLv3 |
|
|
||||||
| [raylib-rs](https://github.com/raylib-rs/raylib-rs) | **5.5** | [Rust](https://www.rust-lang.org) | Zlib |
|
|
||||||
| [sola-raylib](https://github.com/brettchalupa/sola-raylib) | **6.0** | [Rust](https://www.rust-lang.org) | Zlib |
|
|
||||||
| [raylib-ruby](https://github.com/wilsonsilva/raylib-ruby) | 4.5 | [Ruby](https://www.ruby-lang.org) | Zlib |
|
|
||||||
| [Relib](https://github.com/RedCubeDev-ByteSpace/Relib) | 3.5 | [ReCT](https://github.com/RedCubeDev-ByteSpace/ReCT) | **???** |
|
|
||||||
| [racket-raylib](https://github.com/eutro/racket-raylib) | **5.5** | [Racket](https://racket-lang.org) | MIT/Apache-2.0 |
|
|
||||||
| [raylib-swift](https://github.com/STREGAsGate/Raylib) | 4.0 | [Swift](https://swift.org) | MIT |
|
|
||||||
| [raylib-scopes](https://github.com/salotz/raylib-scopes) | auto | [Scopes](http://scopes.rocks) | MIT |
|
|
||||||
| [raylib-SmallBASIC](https://github.com/smallbasic/smallbasic.plugins/tree/master/raylib) | **5.5** | [SmallBASIC](https://github.com/smallbasic/SmallBASIC) | GPLv3 |
|
|
||||||
| [raylib-umka](https://github.com/robloach/raylib-umka) | 4.5 | [Umka](https://github.com/vtereshkov/umka-lang) | Zlib |
|
|
||||||
| [raylib-v](https://github.com/vlang/raylib) | 5.5 | [V](https://vlang.io) | MIT/Unlicense |
|
|
||||||
| [raylib.v](https://github.com/irishgreencitrus/raylib.v) | 4.2 | [V](https://vlang.io) | Zlib |
|
|
||||||
| [raylib-vapi](https://github.com/lxmcf/raylib-vapi) | **6.0** | [Vala](https://vala.dev) | Zlib |
|
|
||||||
| [raylib-wave](https://github.com/wavefnd/raylib-wave) | **auto** |[Wave](http://wave-lang.dev) | Zlib |
|
|
||||||
| [raylib-wren](https://github.com/TSnake41/raylib-wren) | 4.5 | [Wren](http://wren.io) | ISC |
|
|
||||||
| [raylib-zig](https://github.com/raylib-zig/raylib-zig) | **6.0** | [Zig](https://ziglang.org) | MIT |
|
|
||||||
| [raylib.zig](https://github.com/ryupold/raylib.zig) | **5.1-dev** | [Zig](https://ziglang.org) | MIT |
|
|
||||||
| [raylib-zig-bindings](https://github.com/L-Briand/raylib-zig-bindings) | **5.0** | [Zig](https://ziglang.org) | Zlib |
|
|
||||||
| [hare-raylib](https://git.sr.ht/~evantj/hare-raylib) | **auto** | [Hare](https://harelang.org) | Zlib |
|
|
||||||
| [raylib-sunder](https://github.com/ashn-dot-dev/raylib-sunder) | **auto** | [Sunder](https://github.com/ashn-dot-dev/sunder) | 0BSD |
|
|
||||||
| [raylib-bqn](https://github.com/Brian-ED/raylib-bqn) | **5.0** | [BQN](https://mlochbaum.github.io/BQN) | MIT |
|
|
||||||
| [rayjs](https://github.com/mode777/rayjs) | 4.6-dev | [QuickJS](https://bellard.org/quickjs) | MIT |
|
|
||||||
| [rayjule](https://github.com/SabeDoesThings/rayjule) | **5.5** | [Jule](https://jule.dev/) | MIT |
|
|
||||||
| [raylib-raku](https://github.com/vushu/raylib-raku) | **auto** | [Raku](https://www.raku.org) | Artistic License 2.0 |
|
|
||||||
| [Raylib.lean](https://github.com/KislyjKisel/Raylib.lean) | **5.5-dev** | [Lean4](https://lean-lang.org) | BSD-3-Clause |
|
|
||||||
| [raylib-cobol](https://codeberg.org/glowiak/raylib-cobol) | **auto** | [COBOL](https://gnucobol.sourceforge.io) | Public domain |
|
|
||||||
| [raylib-apl](https://github.com/Brian-ED/raylib-apl) | **5.0** | [Dyalog APL](https://www.dyalog.com/) | MIT |
|
|
||||||
| [raylib-jai](https://github.com/ahmedqarmout2/raylib-jai) | **6.0** | [Jai](https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md) | MIT |
|
|
||||||
| [fnl-raylib](https://github.com/0riginaln0/fnl-raylib) | **5.5** | [Fennel](https://fennel-lang.org/) | MIT |
|
|
||||||
| [Rayua](https://github.com/uiua-lang/rayua) | **5.5** | [Uiua](https://www.uiua.org/) | **???** |
|
|
||||||
| [Target](https://github.com/FinnDemonCat/Target/tree/main/libs/raylib) | **5.5** | [Dart](https://dart.dev/) | Apache-2.0 license |
|
|
||||||
| [gclang-raylib](https://github.com/gnuchanos/gcLang_Compiler/tree/main/windows_version/raylib_version)| **6.0** | [gclang](https://github.com/gnuchanos/gcLang_Compiler) | AGPL-3.0 |
|
|
||||||
|
|
||||||
|
|
||||||
### Utility Wrapers
|
|
||||||
|
|
||||||
These are utility wrappers for specific languages, they are not required to use raylib in the language but may adapt the raylib API to be more inline with the language's paradigm.
|
|
||||||
| Name | raylib Version | Language | License |
|
|
||||||
| ---------------------------------------------------- | :------------: | :------------------------------------------: | :-----: |
|
|
||||||
| [raylib-cpp](https://github.com/robloach/raylib-cpp) | **6.0** | [C++](https://en.wikipedia.org/wiki/C%2B%2B) | Zlib |
|
|
||||||
| [claylib](https://github.com/defun-games/claylib) | 4.5 | [Common Lisp](https://common-lisp.net) | Zlib |
|
|
||||||
| [rayed-bqn](https://github.com/Brian-ED/rayed-bqn) | **5.0** | [BQN](https://mlochbaum.github.io/BQN) | MIT |
|
|
||||||
| [DOOR](https://github.com/RealDoigt/DOOR) | 4.0 | [D](https://dlang.org) | MIT |
|
|
||||||
| [Iris](https://github.com/Marcos-cat/iris) | **5.5** | [Uiua](https://www.uiua.org/) | MIT |
|
|
||||||
|
|
||||||
### Older or Unmaintained Language Bindings
|
|
||||||
|
|
||||||
These are older raylib bindings that are more than 2 versions old or have not been maintained.
|
|
||||||
| Name | raylib Version | Language |
|
|
||||||
| ---------------------------------------------------------------------------------- | :------------: | :---------------------------------------------------------------------: |
|
|
||||||
| [raylib-cppsharp](https://github.com/phxvyper/raylib-cppsharp) | 2.5 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) |
|
|
||||||
| [RaylibFS](https://github.com/dallinbeutler/RaylibFS) | 2.5 | [F#](https://fsharp.org) |
|
|
||||||
| [raylib\*d](https://github.com/Sepheus/raylib_d) | 2.5 | [D](https://dlang.org) |
|
|
||||||
| [bindbc-raylib](https://github.com/o3o/bindbc-raylib) | 3.0 | [D](https://dlang.org) |
|
|
||||||
| [go-raylib](https://github.com/chunqian/go-raylib) | 3.5 | [Go](https://golang.org) |
|
|
||||||
| [raylib-goplus](https://github.com/Lachee/raylib-goplus) | 2.6-dev | [Go](https://golang.org) |
|
|
||||||
| [ray-go](https://github.com/hecate-tech/ray-go) | 2.6-dev | [Go](https://golang.org) |
|
|
||||||
| [raylib-luamore](https://github.com/HDPLocust/raylib-luamore) | 3.0 | [Lua](http://www.lua.org) |
|
|
||||||
| [LuaJIT-Raylib](https://github.com/Bambofy/LuaJIT-Raylib) | 2.6 | [Lua](http://www.lua.org) |
|
|
||||||
| [raylib-lua-sol](https://github.com/RobLoach/raylib-lua-sol) | 2.5 | [Lua](http://www.lua.org) |
|
|
||||||
| [raylib-lua-ffi](https://github.com/raysan5/raylib/issues/693) | 2.0 | [Lua](http://www.lua.org) |
|
|
||||||
| [raylib-lua](https://github.com/raysan5/raylib-lua) | 1.7 | [Lua](http://www.lua.org) |
|
|
||||||
| [raylib-nelua](https://github.com/Andre-LA/raylib-nelua) | 3.0 | [Nelua](https://nelua.io) |
|
|
||||||
| [raylib-nim](https://github.com/Skrylar/raylib-nim) | 2.0 | [Nim](https://nim-lang.org) |
|
|
||||||
| [raylib-Nim](https://gitlab.com/define-private-public/raylib-Nim) | 1.7 | [Nim](https://nim-lang.org) |
|
|
||||||
| [nim-raylib](https://github.com/tomc1998/nim-raylib) | 3.1-dev | [Nim](https://nim-lang.org) |
|
|
||||||
| [raylib-Forever](https://github.com/Guevara-chan/Raylib-Forever) | auto | [Nim](https://nim-lang.org) |
|
|
||||||
| [NimraylibNow!](https://github.com/greenfork/nimraylib_now) | 4.2 | [Nim](https://nim-lang.org) |
|
|
||||||
| [raylib-haskell](https://github.com/DevJac/raylib-haskell) | 2.0 | [Haskell](https://www.haskell.org) |
|
|
||||||
| [raylib-cr](https://github.com/AregevDev/raylib-cr) | 2.5-dev | [Crystal](https://crystal-lang.org) |
|
|
||||||
| [raylib.cr](https://github.com/sam0x17/raylib.cr) | 2.0 | [Crystal](https://crystal-lang.org) |
|
|
||||||
| [cray](https://gitlab.com/Zatherz/cray) | 1.8 | [Crystal](https://crystal-lang.org) |
|
|
||||||
| [raylib-pas](https://github.com/tazdij/raylib-pas) | 3.0 | [Pascal](https://en.wikipedia.org/wiki/Pascal*(programming*language)) |
|
|
||||||
| [raylib-pascal](https://github.com/drezgames/raylib-pascal) | 2.0 | [Pascal](https://en.wikipedia.org/wiki/Pascal*(programming*language)) |
|
|
||||||
| [Graphics-Raylib](https://github.com/athreef/Graphics-Raylib) | 1.4 | [Perl](https://www.perl.org) |
|
|
||||||
| [raylib-ruby](https://github.com/a0/raylib-ruby) | 2.6 | [Ruby](https://www.ruby-lang.org/en) |
|
|
||||||
| [raylib-ruby-ffi](https://github.com/D3nX/raylib-ruby-ffi) | 2.0 | [Ruby](https://www.ruby-lang.org/en) |
|
|
||||||
| [raylib-mruby](https://github.com/lihaochen910/raylib-mruby) | 2.5-dev | [mruby](https://github.com/mruby/mruby) |
|
|
||||||
| [raylib-java](https://github.com/XoanaIO/raylib-java) | 2.0 | [Java](https://en.wikipedia.org/wiki/Java*(programming_language)) |
|
|
||||||
| [clj-raylib](https://github.com/lsevero/clj-raylib) | 3.0 | [Clojure](https://clojure.org) |
|
|
||||||
| [QuickJS-raylib](https://github.com/sntg-p/QuickJS-raylib) | 3.0 | [QuickJS](https://bellard.org/quickjs) |
|
|
||||||
| [raylib-duktape](https://github.com/RobLoach/raylib-duktape) | 2.6 | [JavaScript (Duktape)](https://en.wikipedia.org/wiki/JavaScript) |
|
|
||||||
| [raylib-chaiscript](https://github.com/RobLoach/raylib-chaiscript) | 2.6 | [ChaiScript](http://chaiscript.com) |
|
|
||||||
| [raylib-squirrel](https://github.com/RobLoach/raylib-squirrel) | 2.5 | [Squirrel](http://www.squirrel-lang.org) |
|
|
||||||
| [racket-raylib-2d](https://github.com/arvyy/racket-raylib-2d) | 2.5 | [Racket](https://racket-lang.org) |
|
|
||||||
| [raylib-php-ffi](https://github.com/oraoto/raylib-php-ffi) | 2.4-dev | [PHP](https://en.wikipedia.org/wiki/PHP) |
|
|
||||||
| [raylib-haxe](https://github.com/ibilon/raylib-haxe) | 2.4 | [Haxe](https://haxe.org) |
|
|
||||||
| [ringraylib](https://github.com/ringpackages/ringraylib) | 2.6 | [Ring](http://ring-lang.sourceforge.net) |
|
|
||||||
| [raylib-scm](https://github.com/yashrk/raylib-scm) | 2.5 | [Chicken Scheme](https://www.call-cc.org) |
|
|
||||||
| [raylib-chibi](https://github.com/VincentToups/raylib-chibi) | 2.5 | [Chibi-Scheme](https://github.com/ashinn/chibi-scheme) |
|
|
||||||
| [raylib-gambit-scheme](https://github.com/georgjz/raylib-gambit-scheme) | 3.1-dev | [Gambit Scheme](https://github.com/gambit/gambit) |
|
|
||||||
| [Euraylib](https://github.com/gAndy50/Euraylib) | 3.0 | [Euphoria](https://openeuphoria.org) |
|
|
||||||
| [raylib-odin](https://github.com/kevinw/raylib-odin) | 3.0 | [Odin](https://odin-lang.org) |
|
|
||||||
| [vraylib](https://github.com/waotzi/vraylib) | 3.5 | [V](https://vlang.io) |
|
|
||||||
| [raylib-vala](https://code.guddler.uk/mart/raylibVapi) | 3.0 | [Vala](https://wiki.gnome.org/Projects/Vala) |
|
|
||||||
| [raylib-jai](https://github.com/kujukuju/raylib-jai) | 3.1-dev | [Jai](https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md) |
|
|
||||||
| [ray.zig](https://github.com/BitPuffin/zig-raylib-experiments) | 2.5 | [Zig](https://ziglang.org) |
|
|
||||||
| [raylib-Ada](https://github.com/mimo/raylib-Ada) | 3.0 | [Ada](https://www.adacore.com/about-ada) |
|
|
||||||
| [raykit](https://github.com/Gamerfiend/raykit) | **???** | [Kit](https://www.kitlang.org) |
|
|
||||||
| [ray.mod](https://github.com/bmx-ng/ray.mod) | 3.0 | [BlitzMax](https://blitzmax.org) |
|
|
||||||
| [raylib-mosaic](https://github.com/pluckyporcupine/raylib-mosaic) | 3.0 | [Mosaic](https://github.com/sal55/langs/tree/master/Mosaic) |
|
|
||||||
| [raylib-xdpw](https://github.com/vtereshkov/raylib-xdpw) | 2.6 | [XD Pascal](https://github.com/vtereshkov/xdpw) |
|
|
||||||
| [raylib-carp](https://github.com/sacredbirdman/raylib-carp) | 3.0 | [Carp](https://github.com/carp-lang/Carp) |
|
|
||||||
| [raylib-fb](https://github.com/IchMagBier/raylib-fb) | 3.0 | [FreeBasic](https://www.freebasic.net) |
|
|
||||||
| [raylib-purebasic](https://github.com/D-a-n-i-l-o/raylib-purebasic) | 3.0 | [PureBasic](https://www.purebasic.com) |
|
|
||||||
| [raylib-ats2](https://github.com/mephistopheles-8/raylib-ats2) | 3.0 | [ATS2](http://www.ats-lang.org) |
|
|
||||||
| [raylib-beef](https://github.com/M0n7y5/raylib-beef) | 3.0 | [Beef](https://www.beeflang.org) |
|
|
||||||
| [raylib-never](https://github.com/never-lang/raylib-never) | 3.0 | [Never](https://github.com/never-lang/never) |
|
|
||||||
| [raylib.cbl](https://github.com/Martinfx/Cobol/tree/master/OpenCobol/Games/raylib) | 2.0 | [COBOL](https://en.wikipedia.org/wiki/COBOL) |
|
|
||||||
|
|
||||||
Missing some language or wrapper? Feel free to create a new one! :)
|
|
||||||
|
|
||||||
Usually, raylib bindings follow the convention: `raylib-{language}`
|
|
||||||
|
|
||||||
Let me know if you're writing a new binding for raylib, I will list it here!
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
cmake_minimum_required(VERSION 3.22)
|
|
||||||
project(raylib)
|
|
||||||
|
|
||||||
# Avoid excessive expansion of variables in conditionals. In particular, if
|
|
||||||
# "PLATFORM" is "DRM" then:
|
|
||||||
#
|
|
||||||
# if (${PLATFORM} MATCHES "DRM")
|
|
||||||
#
|
|
||||||
# may expand e.g to:
|
|
||||||
#
|
|
||||||
# if (/usr/lib/aarch64-linux-gnu/libdrm.so MATCHES "DRM")
|
|
||||||
#
|
|
||||||
# See https://cmake.org/cmake/help/latest/policy/CMP0054.html
|
|
||||||
cmake_policy(SET CMP0054 NEW)
|
|
||||||
|
|
||||||
# Makes a hidden visibility preset on a static lib respected
|
|
||||||
# This is used to hide glfw's symbols from the library exports when building an so/dylib
|
|
||||||
# See https://cmake.org/cmake/help/latest/policy/CMP0063.html
|
|
||||||
cmake_policy(SET CMP0063 NEW)
|
|
||||||
|
|
||||||
# Directory for easier includes
|
|
||||||
# Anywhere you see include(...) you can check <root>/cmake for that file
|
|
||||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
|
||||||
|
|
||||||
# Sets compiler flags and language standard
|
|
||||||
include(CompilerFlags)
|
|
||||||
|
|
||||||
# Registers build options that are exposed to cmake
|
|
||||||
include(CMakeOptions.txt)
|
|
||||||
|
|
||||||
if (UNIX AND NOT APPLE AND NOT "${PLATFORM}" MATCHES "DRM" AND NOT "${PLATFORM}" MATCHES "Web" AND NOT "${PLATFORM}" MATCHES "SDL")
|
|
||||||
if (NOT GLFW_BUILD_WAYLAND AND NOT GLFW_BUILD_X11)
|
|
||||||
message(FATAL_ERROR "Cannot disable both Wayland and X11")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Main sources directory (the second parameter sets the output directory name to raylib)
|
|
||||||
add_subdirectory(src raylib)
|
|
||||||
|
|
||||||
# Uninstall target, only create when building raylib by itself
|
|
||||||
# Avoid conflicting target names when using raylib with other libraries
|
|
||||||
if(NOT TARGET uninstall AND PROJECT_IS_TOP_LEVEL)
|
|
||||||
configure_file(
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Uninstall.cmake"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
|
||||||
IMMEDIATE @ONLY)
|
|
||||||
|
|
||||||
add_custom_target(uninstall
|
|
||||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (${BUILD_EXAMPLES})
|
|
||||||
message(STATUS "Building examples is enabled")
|
|
||||||
add_subdirectory(examples)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
enable_testing()
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
# ## Config options ###
|
|
||||||
include(CMakeDependentOption)
|
|
||||||
include(EnumOption)
|
|
||||||
|
|
||||||
if(EMSCRIPTEN)
|
|
||||||
# When configuring web builds with "emcmake cmake -B build -S .", set PLATFORM to Web by default
|
|
||||||
SET(PLATFORM Web CACHE STRING "Platform to build for.")
|
|
||||||
endif()
|
|
||||||
enum_option(PLATFORM "Desktop;Win32;Web;WebRGFW;Android;Raspberry Pi;DRM;SDL;RGFW;Memory" "Platform to build for.")
|
|
||||||
|
|
||||||
enum_option(OPENGL_VERSION "OFF;4.3;3.3;2.1;1.1;ES 2.0;ES 3.0;Software" "Force a specific OpenGL Version?")
|
|
||||||
|
|
||||||
# Configuration options
|
|
||||||
option(BUILD_EXAMPLES "Build the examples." ${PROJECT_IS_TOP_LEVEL})
|
|
||||||
option(CUSTOMIZE_BUILD "Show options for customizing your Raylib library build." OFF)
|
|
||||||
option(ENABLE_ASAN "Enable AddressSanitizer (ASAN) for debugging (degrades performance)" OFF)
|
|
||||||
option(ENABLE_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan) for debugging" OFF)
|
|
||||||
option(ENABLE_MSAN "Enable MemorySanitizer (MSan) for debugging (not recommended to run with ASAN)" OFF)
|
|
||||||
|
|
||||||
# Shared library is always PIC. Static library should be PIC too if linked into a shared library
|
|
||||||
option(WITH_PIC "Compile static library as position-independent code" OFF)
|
|
||||||
option(BUILD_SHARED_LIBS "Build raylib as a shared library" OFF)
|
|
||||||
cmake_dependent_option(USE_AUDIO "Build raylib with audio module" ON CUSTOMIZE_BUILD ON)
|
|
||||||
|
|
||||||
enum_option(USE_EXTERNAL_GLFW "OFF;IF_POSSIBLE;ON" "Link raylib against system GLFW instead of embedded one")
|
|
||||||
|
|
||||||
# GLFW build options
|
|
||||||
option(GLFW_BUILD_WAYLAND "Build the bundled GLFW with Wayland support" OFF)
|
|
||||||
option(GLFW_BUILD_X11 "Build the bundled GLFW with X11 support" ON)
|
|
||||||
|
|
||||||
option(INCLUDE_EVERYTHING "Include everything disabled by default (for CI usage)" OFF)
|
|
||||||
|
|
||||||
include(ParseConfigHeader)
|
|
||||||
|
|
||||||
foreach(FLAG IN LISTS CONFIG_HEADER_FLAGS)
|
|
||||||
string(REGEX MATCH "([^=]+)=(.+)" _ ${FLAG})
|
|
||||||
set(CONFIG_HEADER_FLAG_DEFAULT ${CMAKE_MATCH_2})
|
|
||||||
if (INCLUDE_EVERYTHING AND "${CONFIG_HEADER_FLAG_DEFAULT}" STREQUAL "OFF")
|
|
||||||
set(CONFIG_HEADER_FLAG_DEFAULT ON)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
cmake_dependent_option(${CMAKE_MATCH_1} "" ${CONFIG_HEADER_FLAG_DEFAULT} CUSTOMIZE_BUILD ${CONFIG_HEADER_FLAG_DEFAULT})
|
|
||||||
endforeach()
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
||||||
## Contributing to raylib
|
|
||||||
|
|
||||||
Hello contributors! Welcome to raylib!
|
|
||||||
|
|
||||||
Do you enjoy raylib and want to contribute? Nice! You can help with the following points:
|
|
||||||
|
|
||||||
- `C programming` - Can you write/review/test/improve the code?
|
|
||||||
- `Documentation/Tutorials/Example` - Can you write some tutorials/examples?
|
|
||||||
- `Porting to other platforms` - Can you port/adapt/compile raylib on other systems?
|
|
||||||
- `Web Development` - Can you help [with the website](https://github.com/raysan5/raylib.com)?
|
|
||||||
- `Testing` - Can you find some bugs in raylib?
|
|
||||||
|
|
||||||
This document contains a set of guidelines to contribute to the project. These are mostly guidelines, not rules.
|
|
||||||
Use your best judgment, and feel free to propose changes to this document in a pull request.
|
|
||||||
|
|
||||||
### raylib philosophy
|
|
||||||
|
|
||||||
- raylib is a tool to **ENJOY** videogames programming, every function in raylib is designed as a mini-tutorial on itself.
|
|
||||||
- raylib is **SIMPLE** and **EASY-TO-USE**, I tried to keep it compact with a small set of functions, if a function is too complex, better not including it.
|
|
||||||
- raylib is open source and free; educators and institutions can use this tool to **TEACH** videogames programming completely for free.
|
|
||||||
- raylib is collaborative; contribution of tutorials / code examples / bug fixes / code comments are highly appreciated.
|
|
||||||
- raylib's license (and its external libs respective licenses) allow using raylib on commercial projects.
|
|
||||||
|
|
||||||
### Some interesting reads to start with
|
|
||||||
|
|
||||||
- [raylib history](HISTORY.md)
|
|
||||||
- [raylib architecture](https://github.com/raysan5/raylib/wiki/raylib-architecture)
|
|
||||||
- [raylib license](LICENSE)
|
|
||||||
- [raylib roadmap](ROADMAP.md)
|
|
||||||
|
|
||||||
[raylib Wiki](https://github.com/raysan5/raylib/wiki) contains some information about the library and is open to anyone to edit.
|
|
||||||
Feel free to review it if required, just take care not to break something.
|
|
||||||
|
|
||||||
### raylib C coding conventions
|
|
||||||
|
|
||||||
Despite being written in C, raylib does not follow the standard Hungarian notation for C,
|
|
||||||
it [follows Pascal-case/camel-case notation](https://github.com/raysan5/raylib/wiki/raylib-coding-conventions),
|
|
||||||
more common in C# language. All code formatting decisions have been carefully taken
|
|
||||||
to make it easier for students/users to read, write and understand code.
|
|
||||||
|
|
||||||
Source code is extensively commented for that purpose, raylib primary learning method is:
|
|
||||||
|
|
||||||
> `Learn by reading code and examples`
|
|
||||||
|
|
||||||
For detailed information on building raylib and examples, please check [raylib Wiki](https://github.com/raysan5/raylib/wiki).
|
|
||||||
|
|
||||||
### Opening new Issues
|
|
||||||
|
|
||||||
To open new issues for raylib (bug, enhancement, discussion...), just try to follow these rules:
|
|
||||||
|
|
||||||
- Make sure the issue has not already been reported before by searching on GitHub under Issues.
|
|
||||||
- If you're unable to find an open issue addressing the problem, open a new one. Be sure to include a
|
|
||||||
title and clear description, as much relevant information as possible, and a code sample demonstrating the unexpected behavior.
|
|
||||||
- If applicable, attach some screenshot of the issue and a .zip file with the code sample and required resources.
|
|
||||||
- On issue description, add a brackets tag about the raylib module that relates to this issue.
|
|
||||||
If don't know which module, just report the issue, I will review it.
|
|
||||||
- You can check other issues to see how it's being done!
|
|
||||||
|
|
||||||
### Sending a Pull-Request
|
|
||||||
|
|
||||||
- Make sure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
|
|
||||||
- Don't send big pull requests (lots of changelists), they are difficult to review. It's better to send small pull requests, one at a time.
|
|
||||||
- Verify that changes don't break the build (at least on Windows platform). The more platforms where you can test it, the better, but don't worry
|
|
||||||
if you cannot test all the platforms.
|
|
||||||
|
|
||||||
### Contact information
|
|
||||||
|
|
||||||
If you have any doubt, don't hesitate to [contact me](mailto:ray@raylib.com)!.
|
|
||||||
You can write me a direct mail but you can also contact me on the following networks:
|
|
||||||
|
|
||||||
- [raylib Discord](https://discord.gg/raylib) - A direct communication channel for project discussions.
|
|
||||||
- [raylib reddit](https://www.reddit.com/r/raylib/) - A good place for discussions or to ask for help.
|
|
||||||
- [raylib web](http://www.raylib.com/) - On top-right corner there is a bunch of networks where you can find me.
|
|
||||||
- [raylib X](https://x.com/raysan5) - My personal X account, I usually post about raylib, you can send me PMs.
|
|
||||||
|
|
||||||
Thank you very much for your time! :)
|
|
||||||
|
|
@ -1,99 +0,0 @@
|
||||||
## C Coding Style Conventions
|
|
||||||
|
|
||||||
Here is a list with some of the code conventions used by raylib:
|
|
||||||
|
|
||||||
Code element | Convention | Example
|
|
||||||
--- | :---: | ---
|
|
||||||
Defines | ALL_CAPS | `#define PLATFORM_DESKTOP`
|
|
||||||
Macros | ALL_CAPS | `#define MIN(a,b) (((a)<(b))?(a):(b))`
|
|
||||||
Variables | lowerCase | `int screenWidth = 0;`, `float targetFrameTime = 0.016f;`
|
|
||||||
Local variables | lowerCase | `Vector2 playerPosition = { 0 };`
|
|
||||||
Global variables | lowerCase | `bool windowReady = false;`
|
|
||||||
Constants | lowerCase | `const int maxValue = 8;`
|
|
||||||
Pointers | MyType *pointer | `Texture2D *array = NULL;`
|
|
||||||
float values | always x.xf | `float gravity = 10.0f` (avoid `10.f`)
|
|
||||||
Operators | value1*value2 | `int product = value*6;`
|
|
||||||
Operators | value1/value2 | `int division = value/4;`
|
|
||||||
Operators | value1 + value2 | `int sum = value + 10;`
|
|
||||||
Operators | value1 - value2 | `int res = value - 5;`
|
|
||||||
Enum | TitleCase | `enum TextureFormat`
|
|
||||||
Enum members | ALL_CAPS | `PIXELFORMAT_UNCOMPRESSED_R8G8B8`
|
|
||||||
Struct | TitleCase | `struct Texture2D`, `struct Material`
|
|
||||||
Struct members | lowerCase | `texture.width`, `color.r`
|
|
||||||
Functions | TitleCase | `InitWindow()`, `LoadImageFromMemory()`
|
|
||||||
Functions params | lowerCase | `width`, `height`
|
|
||||||
Ternary Operator | (condition)? result1 : result2 | `printf("Value is 0: %s", (value == 0)? "yes" : "no");`
|
|
||||||
|
|
||||||
Some other conventions to follow:
|
|
||||||
- **ALWAYS** initialize all defined variables.
|
|
||||||
- **Do not use TABS**, use 4 spaces instead.
|
|
||||||
- Avoid trailing spaces, please, avoid them
|
|
||||||
- Comments always start with space + capital letter and never end with a '.', place them **before** the line(s) they refer to
|
|
||||||
```c
|
|
||||||
// This is a comment in raylib or raylib examples
|
|
||||||
```
|
|
||||||
- Control flow statements always are followed **by a space**:
|
|
||||||
```c
|
|
||||||
if (condition) value = 0;
|
|
||||||
|
|
||||||
while (!WindowShouldClose())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Always use accumulators as `x++` instead of `++x`
|
|
||||||
for (int i = 0; i < NUM_VALUES; i++) printf("%i", i);
|
|
||||||
|
|
||||||
// Be careful with the switch formatting!
|
|
||||||
switch (value)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
|
|
||||||
} break;
|
|
||||||
case 2: break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- All conditions checks are **always between parenthesis** but not boolean values:
|
|
||||||
```c
|
|
||||||
if ((value > 1) && (value < 50) && valueActive)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- When dealing with braces or curly brackets, open-close them in aligned mode:
|
|
||||||
```c
|
|
||||||
void SomeFunction()
|
|
||||||
{
|
|
||||||
// TODO: Do something here!
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**If proposing new functions, please try to use a clear naming for function-name and functions-parameters, in case of doubt, open an issue for discussion.**
|
|
||||||
|
|
||||||
## Files and Directories Naming Conventions
|
|
||||||
|
|
||||||
- Directories will be named using `snake_case`: `resources/models`, `resources/fonts`
|
|
||||||
|
|
||||||
- Files will be named using `snake_case`: `main_title.png`, `cubicmap.png`, `sound.wav`
|
|
||||||
|
|
||||||
_NOTE: Avoid any space or special character in the files/dir naming!_
|
|
||||||
|
|
||||||
## Games/Examples Directories Organization Conventions
|
|
||||||
|
|
||||||
- Data files should be organized by context and usage in the game, think about the loading requirements for data and put all the resources that need to be loaded at the same time together.
|
|
||||||
- Use descriptive names for the files, it would be perfect if just reading the name of the file, it was possible to know what is that file and where fits in the game.
|
|
||||||
- Here is an example, note that some resources require to be loaded all at once while other require to be loaded only at initialization (gui, font).
|
|
||||||
|
|
||||||
```
|
|
||||||
resources/audio/fx/long_jump.wav
|
|
||||||
resources/audio/music/main_theme.ogg
|
|
||||||
resources/screens/logo/logo.png
|
|
||||||
resources/screens/title/title.png
|
|
||||||
resources/screens/gameplay/background.png
|
|
||||||
resources/characters/player.png
|
|
||||||
resources/characters/enemy_slime.png
|
|
||||||
resources/common/font_arial.ttf
|
|
||||||
resources/common/gui.png
|
|
||||||
```
|
|
||||||
138
FAQ.md
|
|
@ -1,138 +0,0 @@
|
||||||
# Frequently Asked Questions
|
|
||||||
|
|
||||||
- [What is raylib?](#what-is-raylib)
|
|
||||||
- [What can I do with raylib?](#what-can-i-do-with-raylib)
|
|
||||||
- [Which kinds of games can I make with raylib?](#which-kinds-of-games-can-i-make-with-raylib)
|
|
||||||
- [Can I create non-game applications with raylib?](#can-i-create-non-game-applications-with-raylib)
|
|
||||||
- [How can I learn to use raylib? Is there some official documentation or tutorials?](#how-can-i-learn-to-use-raylib-is-there-some-official-documentation-or-tutorials)
|
|
||||||
- [How much does it cost?](#how-much-does-it-cost)
|
|
||||||
- [What is the raylib license?](#what-is-the-raylib-license)
|
|
||||||
- [What platforms are supported by raylib?](#what-platforms-are-supported-by-raylib)
|
|
||||||
- [What programming languages can I use with raylib?](#what-programming-languages-can-i-use-with-raylib)
|
|
||||||
- [Why is it coded in C?](#why-is-it-coded-in-c)
|
|
||||||
- [Is raylib a videogames engine?](#is-raylib-a-videogames-engine)
|
|
||||||
- [What does raylib provide that other engines or libraries don't?](#what-does-raylib-provide-that-other-engines-or-libraries-dont)
|
|
||||||
- [How does raylib compare to Unity/Unreal/Godot?](#how-does-raylib-compare-to-unityunrealgodot)
|
|
||||||
- [What development tools are required for raylib?](#what-development-tools-are-required-for-raylib)
|
|
||||||
- [What are raylib's external dependencies?](#what-are-raylibs-external-dependencies)
|
|
||||||
- [Can I use raylib with other technologies or libraries?](#can-i-use-raylib-with-other-technologies-or-libraries)
|
|
||||||
- [What file formats are supported by raylib?](#what-file-formats-are-supported-by-raylib)
|
|
||||||
- [Does raylib support the Vulkan API?](#does-raylib-support-the-vulkan-api)
|
|
||||||
- [What could I expect to see in raylib in the future?](#what-could-i-expect-to-see-in-raylib-in-the-future)
|
|
||||||
- [Who are the raylib developers?](#who-are-the-raylib-developers)
|
|
||||||
- [MORE QUESTIONS...](https://github.com/raysan5/raylib/wiki/Frequently-Asked-Questions)
|
|
||||||
|
|
||||||
### What is raylib?
|
|
||||||
|
|
||||||
raylib is a C programming library, designed to be simple and easy-to-use. It provides a set of functions intended for graphics/multimedia applications programming.
|
|
||||||
|
|
||||||
### What can I do with raylib?
|
|
||||||
|
|
||||||
raylib can be used to create any kind of graphics/multimedia applications: videogames, tools, mobile apps, web applications... Actually it can be used to create any application that requires something to be shown in a display with graphic hardware acceleration (OpenGL); including [IoT](https://en.wikipedia.org/wiki/Internet_of_things) devices with a graphics display.
|
|
||||||
|
|
||||||
### Which kinds of games can I make with raylib?
|
|
||||||
|
|
||||||
With enough time and effort any kind of game/application can be created but small-mid sized 2d videogames are the best fit. The raylib [examples](https://www.raylib.com/examples.html)/[games](https://www.raylib.com/games.html) and [raylibtech](https://raylibtech.itch.io/) tools are an example of what can be accomplished with raylib.
|
|
||||||
|
|
||||||
### Can I create non-game applications with raylib?
|
|
||||||
|
|
||||||
Yes, raylib can be used to create any kind of application, not just videogames. For example, it can be used to create [desktop/web tools](https://raylibtech.itch.io/) or also applications for an IoT devices like [Raspberry Pi](https://www.raspberrypi.org/).
|
|
||||||
|
|
||||||
### How can I learn to use raylib? Is there some official documentation or tutorials?
|
|
||||||
|
|
||||||
raylib does not provide a "standard" API reference documentation like other libraries, all of the raylib functionality is exposed in a simple [cheatsheet](https://www.raylib.com/cheatsheet/cheatsheet.html). Most of the functions are self-explanatory and the required parameters are very intuitive. It's also highly recommended to take a look at [`raylib.h`](https://github.com/raysan5/raylib/blob/master/src/raylib.h) header file or even the source code, that is very clean and organized, intended for teaching.
|
|
||||||
|
|
||||||
raylib also provides a big [collection of examples](https://www.raylib.com/examples.html), to showcase the multiple functionality usage (+120 examples). Examples are categorized by the internal module functionality and also define an estimated level of difficulty to guide the users checking them.
|
|
||||||
|
|
||||||
There is also a [FAQ on the raylib Wiki](https://github.com/raysan5/raylib/wiki/Frequently-Asked-Questions) with common technical questions.
|
|
||||||
|
|
||||||
There are also many tutorials on the internet and YouTube created by the growing raylib community over the years.
|
|
||||||
|
|
||||||
[raylib Discord Community](https://discord.gg/raylib) is also a great place to join and ask questions, the community is very friendly and always ready to help.
|
|
||||||
|
|
||||||
### How much does it cost?
|
|
||||||
|
|
||||||
raylib is [free and open source](https://github.com/raysan5/raylib). Anyone can use raylib library for free to create games/tools/apps but also the source code of raylib is open for anyone to check it, modify it, adapt it as required or just learn how it works internally.
|
|
||||||
|
|
||||||
### What is the raylib license?
|
|
||||||
|
|
||||||
raylib source code is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed-source software. Check [LICENSE](https://github.com/raysan5/raylib/blob/master/LICENSE) for further details.
|
|
||||||
|
|
||||||
### What platforms are supported by raylib?
|
|
||||||
|
|
||||||
raylib source code can be compiled for the following platforms:
|
|
||||||
|
|
||||||
- Windows (7, 8.1, 10, 11)
|
|
||||||
- Linux - Desktop (multiple distributions, X11 and Wayland based)
|
|
||||||
- Linux - Native (no windowing system, [DRM](https://en.wikipedia.org/wiki/Direct_Rendering_Manager))
|
|
||||||
- macOS (multiple versions, including ARM64)
|
|
||||||
- FreeBSD, OpenBSD, NetBSD, DragonFly
|
|
||||||
- Raspberry Pi (desktop and native)
|
|
||||||
- Android (multiple API versions and architectures)
|
|
||||||
- HTML5 (WebAssembly)
|
|
||||||
- Haiku
|
|
||||||
|
|
||||||
raylib code has also been ported to several [homebrew](https://en.wikipedia.org/wiki/Homebrew_(video_games)) platforms: N3DS, Switch, PS4, PSVita.
|
|
||||||
|
|
||||||
Also note that raylib is a low-level library that can be easily ported to any platform with OpenGL support (or similar API).
|
|
||||||
|
|
||||||
### What programming languages can I use with raylib?
|
|
||||||
|
|
||||||
raylib original version is coded in C language (using some C99 features) but it has bindings to +60 programming languages. Check [BINDINGS.md](https://github.com/raysan5/raylib/blob/master/BINDINGS.md) for details.
|
|
||||||
|
|
||||||
### Why is it coded in C?
|
|
||||||
|
|
||||||
It's a simple language, no high-level code abstractions like [OOP](https://en.wikipedia.org/wiki/Object-oriented_programming), just data types and functions. It's a very enjoyable language to code.
|
|
||||||
|
|
||||||
### Is raylib a videogames engine?
|
|
||||||
|
|
||||||
I personally consider raylib a graphics library with some high-level features rather than an engine. The line that separates a library/framework from an engine could be very confusing; raylib provides all the required functionality to create simple games or small applications but it does not provide 3 elements that I personally consider any "engine" should provide: Screen manager, GameObject/Entity manager and Resource Manager. Still, most users do not need those elements or just code simple approaches on their own.
|
|
||||||
|
|
||||||
### What does raylib provide that other engines or libraries don't?
|
|
||||||
|
|
||||||
I would say "simplicity" and "enjoyment" at a really low level of coding but actually it is up to the user to discover it, to try it and to see if it fits their needs. raylib is not good for everyone but it's worth a try.
|
|
||||||
|
|
||||||
### How does raylib compare to Unity/Unreal/Godot?
|
|
||||||
|
|
||||||
Those engines are usually big and complex to use, providing lot of functionality. They require some time to learn and test, they usually abstract many parts of the game development process and they usually provide a set of tools to assist users on their creations (like a GUI editor).
|
|
||||||
|
|
||||||
raylib is a simple programming library, with no integrated tools or editors. It gives full control to users at a very low level to create graphics applications in a more handmade way.
|
|
||||||
|
|
||||||
### What development tools are required for raylib?
|
|
||||||
|
|
||||||
To develop raylib programs you only need a text editor (with recommended code syntax highlighting) and a compiler.
|
|
||||||
|
|
||||||
A [raylib Windows Installer](https://raysan5.itch.io/raylib) package is distributed including the Notepad++ editor and MinGW (GCC) compiler pre-configured for Windows for new users as an starter-pack but for more advanced configurations with other editors/compilers, [raylib Wiki](https://github.com/raysan5/raylib/wiki) provides plenty of configuration tutorials.
|
|
||||||
|
|
||||||
### What are raylib's external dependencies?
|
|
||||||
|
|
||||||
raylib is self-contained, it has no external dependencies to build it. But internally raylib uses several libraries from other developers, mostly used to load specific file formats.
|
|
||||||
|
|
||||||
A detailed list of raylib dependencies can be found on the [raylib Wiki](https://github.com/raysan5/raylib/wiki/raylib-dependencies).
|
|
||||||
|
|
||||||
### Can I use raylib with other technologies or libraries?
|
|
||||||
|
|
||||||
Yes, raylib can be used with other libraries that provide specific functionality. There are multiple examples of raylib integrations with libraries like Spine, Tiled, Dear Imgui and several physics engines.
|
|
||||||
|
|
||||||
### What file formats are supported by raylib?
|
|
||||||
|
|
||||||
raylib can load data from multiple standard file formats:
|
|
||||||
|
|
||||||
- Image/Textures: PNG, BMP, TGA, JPG, GIF, QOI, PSD, DDS, HDR, KTX, ASTC, PKM, PVR
|
|
||||||
- Fonts: FNT (sprite font), TTF, OTF
|
|
||||||
- Models/Meshes: OBJ, IQM, GLTF, VOX, M3D
|
|
||||||
- Audio: WAV, OGG, MP3, FLAC, XM, MOD, QOA
|
|
||||||
|
|
||||||
### Does raylib support the Vulkan API?
|
|
||||||
|
|
||||||
No, raylib is built on top of OpenGL API, and there are currently no plans to support any other graphics APIs. In any case, raylib uses rlgl as an abstraction layer to support different OpenGL versions. If really required, a Vulkan backend equivalent could be added but creating that abstraction layer would imply a considerable amount of work.
|
|
||||||
|
|
||||||
### What could I expect to see in raylib in the future?
|
|
||||||
|
|
||||||
The main focus of the library is simplicity. Most of the efforts are invested in maintainability and bug-fixing. Despite new small features being regularly added, it's not the objective for raylib to become a full-featured engine. Personally I prefer to keep it small and enjoyable.
|
|
||||||
|
|
||||||
### Who are the raylib developers?
|
|
||||||
|
|
||||||
The main raylib developer and maintainer is [Ramon Santamaria](https://www.linkedin.com/in/raysan/) but there are 360+ contributors that have helped by adding new features, testing the library and solving issues in the 9+ years life of raylib.
|
|
||||||
|
|
||||||
The full list of raylib contributors can be seen [on GitHub](https://github.com/raysan5/raylib/graphs/contributors).
|
|
||||||
39
HELPME.md
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
help me!
|
||||||
|
--------
|
||||||
|
|
||||||
|
I’m working hard on raylib but my resources are quite limited. If you enjoy raylib and want to help / contribute in some way,
|
||||||
|
please, [let me know][raysan5].
|
||||||
|
|
||||||
|
The following help is highly appreciated:
|
||||||
|
|
||||||
|
- C programming - Can you write / review / test / improve the code?
|
||||||
|
- Translators / Localizators - Can you translate raylib to another language?
|
||||||
|
- Documentation / Tutorials / Example writters - Can you write some tutorial / example?
|
||||||
|
- Web Development - Can you help with the web? Can you setup a forum?
|
||||||
|
- Porting to Linux, OSX... - Can you compile and test raylib on another OS?
|
||||||
|
- Testers of current features and multiple systems - Can you find some bug on raylib?
|
||||||
|
|
||||||
|
If you can not help on any of the above points but you still want to contribute in some way... please, consider helping
|
||||||
|
with a small [donation](http://www.raylib.com/helpme.htm) (just some euros...). It will really motivate to continue improving this project (and pay some bills… or some coffee).
|
||||||
|
|
||||||
|
raylib philosophy
|
||||||
|
------------------
|
||||||
|
|
||||||
|
* raylib is a tool to LEARN videogames programming, every single function in raylib should be a tutorial on itself (clear code).
|
||||||
|
* raylib is SIMPLE and EASY-TO-USE, I tried to keep it compact with a small set of functions, if a function is too complex or
|
||||||
|
has not a clear usefulness, better not to include it.
|
||||||
|
* raylib is open source and free; educators and institutions can use this tool to TEACH videogames programming completely by free.
|
||||||
|
* raylib is, hopefully, collaborative; contribution of tutorials / code-examples / bugs-solving / code-comments are highly appreciated.
|
||||||
|
* raylib's license (and its external libs respective licenses) allow using it for commercial products.
|
||||||
|
|
||||||
|
contact
|
||||||
|
-------
|
||||||
|
|
||||||
|
* Webpage: [http://www.raylib.com](http://www.raylib.com)
|
||||||
|
* Twitter: [http://www.twitter.com/raysan5](http://www.twitter.com/raysan5)
|
||||||
|
* Facebook: [http://www.facebook.com/raylibgames](http://www.facebook.com/raylibgames)
|
||||||
|
* Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
|
||||||
|
* Twitch: [http://www.twitch.tv/raysan5](http://www.twitch.tv/raysan5)
|
||||||
|
* Patreon: [https://www.patreon.com/raysan5](https://www.patreon.com/raysan5)
|
||||||
|
|
||||||
|
[raysan5]: mailto:raysan5@gmail.com "Ramon Santamaria - Ray San"
|
||||||
604
HISTORY.md
|
|
@ -1,604 +0,0 @@
|
||||||

|
|
||||||
|
|
||||||
introduction
|
|
||||||
------------
|
|
||||||
|
|
||||||
I started developing videogames in 2006 and some years later I started teaching videogames development to young people with artistic profiles, most of students had never written a single line of code.
|
|
||||||
|
|
||||||
I decided to start with C language basis and, after searching for the most simple and easy-to-use library to teach videogames programming, I found [WinBGI](https://winbgim.codecutter.org/); it was great and it worked very well with students, in just a couple of weeks, those students that had never written a single line of code were able to program (and understand) a simple PONG game, some of them even a BREAKOUT!
|
|
||||||
|
|
||||||
But WinBGI was not the clearest and most organized library for my taste. There were lots of things I found confusing and some function names were not clear enough for most of the students; not to mention the lack of transparencies support and no hardware acceleration.
|
|
||||||
|
|
||||||
So, I decided to create my own library, hardware accelerated, clear function names, quite organized, well structured, plain C coding and, most importantly, primarily intended to learn videogames programming.
|
|
||||||
|
|
||||||
My previous videogames development experience was mostly in C# and [XNA](https://en.wikipedia.org/wiki/Microsoft_XNA) and I really loved it, so, I decided to use C# language style notation and XNA naming conventions. That way, students were able to move from raylib to XNA, MonoGame or similar libs extremely easily.
|
|
||||||
|
|
||||||
raylib started as a weekend project and after three months of hard work, **raylib 1.0 was published on November 2013**.
|
|
||||||
|
|
||||||
Enjoy it.
|
|
||||||
|
|
||||||
notes on raylib 1.1
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
On April 2014, after 6 months of first raylib release, raylib 1.1 was released. This new version presents a complete internal redesign of the library to support OpenGL 1.1, OpenGL 3.3+ and OpenGL ES 2.0.
|
|
||||||
|
|
||||||
- A new module named [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) has been added to the library. This new module translates raylib-OpenGL-style immediate mode functions (i.e. rlVertex3f(), rlBegin(), ...) to different versions of OpenGL (1.1, 3.3+, ES2), selectable by one define.
|
|
||||||
|
|
||||||
- [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) also comes with a second new module named [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h), which includes a bunch of useful functions for 3d-math with vectors, matrices and quaternions.
|
|
||||||
|
|
||||||
Some other big changes of this new version have been the support for OGG file loading and stream playing, and the support of DDS texture files (compressed and uncompressed) along with mipmaps support.
|
|
||||||
|
|
||||||
Lots of code changes and a lot of testing have concluded in this amazing new raylib 1.1.
|
|
||||||
|
|
||||||
notes on raylib 1.2
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
On September 2014, after 5 months of raylib 1.1 release, it comes raylib 1.2. Again, this version presents a complete internal redesign of [core](https://github.com/raysan5/raylib/blob/master/src/rcore.c) module to support two new platforms: [Android](http://www.android.com/) and [Raspberry Pi](http://www.raspberrypi.org/).
|
|
||||||
|
|
||||||
It's been some months of really hard work to accommodate raylib to those new platforms while keeping it easy for the users. On Android, raylib manages internally the activity cycle, as well as the inputs; on Raspberry Pi, a complete raw input system has been written from scratch.
|
|
||||||
|
|
||||||
- A new display initialization system has been created to support multiple resolutions, adding black bars if required; the user only defines the desired screen size and it gets properly displayed.
|
|
||||||
|
|
||||||
- Now raylib can easily deploy games to Android devices and Raspberry Pi (console mode).
|
|
||||||
|
|
||||||
Lots of code changes and a lot of testing have concluded in this amazing new raylib 1.2.
|
|
||||||
|
|
||||||
In December 2014, new raylib 1.2.2 was published with support to compile directly for web (html5) using [emscripten](http://kripken.github.io/emscripten-site/) and [asm.js](http://asmjs.org/).
|
|
||||||
|
|
||||||
notes on raylib 1.3
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
On September 2015, after 1 year of raylib 1.2 release, arrives raylib 1.3. This version adds shaders functionality, improves tremendously textures module and also provides some new modules (camera system, gestures system, immediate-mode gui).
|
|
||||||
|
|
||||||
- Shaders support is the biggest addition to raylib 1.3, with support for easy shaders loading and use. Loaded shaders can be attached to 3d models or used as fullscreen post-processing effects. A bunch of postprocessing shaders are also included in this release, check raylib/shaders folder.
|
|
||||||
|
|
||||||
- Textures module has grown to support most of the internal texture formats available in OpenGL (RGB565, RGB888, RGBA5551, RGBA4444, etc.), including compressed texture formats (DXT, ETC1, ETC2, ASTC, PVRT); raylib 1.3 can load .dds, .pkm, .ktx, .astc and .pvr files.
|
|
||||||
|
|
||||||
- A brand new [camera](https://github.com/raysan5/raylib/blob/master/src/rcamera.h) module offers to the user multiple preconfigured ready-to-use camera systems (free camera, 1st person, 3rd person). Camera modes are very easy to use, just check examples: [core_3d_camera_free.c](https://github.com/raysan5/raylib/blob/master/examples/core/core_3d_camera_free.c) and [core_3d_camera_first_person.c](https://github.com/raysan5/raylib/blob/master/examples/core/core_3d_camera_first_person.c).
|
|
||||||
|
|
||||||
- New [gestures](https://github.com/raysan5/raylib/blob/master/src/rgestures.h) module simplifies gestures detection on Android and HTML5 programs.
|
|
||||||
|
|
||||||
- [raygui](https://github.com/raysan5/raylib/blob/master/examples/shapes/raygui.h), the new immediate-mode GUI module offers a set of functions to create simple user interfaces, primarily intended for tools development. It's still in an experimental state but already fully functional.
|
|
||||||
|
|
||||||
Most of the examples have been completely rewritten and +10 new examples have been added to show the new raylib features.
|
|
||||||
|
|
||||||
Lots of code changes and a lot of testing have concluded in this amazing new raylib 1.3.
|
|
||||||
|
|
||||||
notes on raylib 1.4
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
On February 2016, after 4 months of raylib 1.3 release, it comes raylib 1.4. For this new version, lots of parts of the library have been reviewed, lots of bugs have been solved and some interesting features have been added.
|
|
||||||
|
|
||||||
- First big addition is a set of [Image manipulation functions](https://github.com/raysan5/raylib/blob/master/src/raylib.h#L1331) that have been added to crop, resize, colorize, flip, dither and even draw image-to-image or text-to-image. Now basic image processing can be done before converting the image to texture for usage.
|
|
||||||
|
|
||||||
- SpriteFonts system has been improved, adding support for AngelCode fonts (.fnt) and TrueType Fonts (using [stb_truetype](https://github.com/nothings/stb/blob/master/stb_truetype.h) helper library). Now raylib can read standard .fnt font data and also generate at loading a SpriteFont from a TTF file.
|
|
||||||
|
|
||||||
- New [physac](https://github.com/raysan5/raylib/blob/master/src/physac.h) physics module for basic 2D physics support. Still in development but already functional. Module comes with some usage examples for basic jump and level interaction and also force-based physic movements.
|
|
||||||
|
|
||||||
- [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h) module has been reviewed; some bugs have been solved and the module has been converted to a header-only file for easier portability, optionally, functions can also be used as inline.
|
|
||||||
|
|
||||||
- [gestures](https://github.com/raysan5/raylib/blob/master/src/rgestures.h) module has been redesigned and simplified, now it can process touch events from any source, including the mouse. This way, gestures system can be used on any platform providing a unified way to work with inputs and allowing the user to create multiplatform games with only one source code.
|
|
||||||
|
|
||||||
- Raspberry Pi input system has been redesigned to better read raw inputs using generic Linux event handlers (keyboard:`stdin`, mouse:`/dev/input/mouse0`, gamepad:`/dev/input/js0`). Gamepad support has also been added (experimental).
|
|
||||||
|
|
||||||
Other important improvements are the functional raycast system for 3D picking, including some ray collision-detection functions,
|
|
||||||
and the addition of two simple functions for persistent data storage. Now raylib users can save and load game data in a file (only some platforms are supported). A simple [easings](https://github.com/raysan5/raylib/blob/master/examples/shapes/reasings.h) module has also been added for values animation.
|
|
||||||
|
|
||||||
Up to 8 new code examples have been added to show the new raylib features and +10 complete game samples have been provided to learn
|
|
||||||
how to create some classic games like Arkanoid, Asteroids, Missile Commander, Snake or Tetris.
|
|
||||||
|
|
||||||
Lots of code changes and lots of hours of hard work have concluded in this amazing new raylib 1.4.
|
|
||||||
|
|
||||||
notes on raylib 1.5
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
On July 2016, after 5 months of raylib 1.4 release, arrives raylib 1.5. This new version is the biggest boost of the library until now, lots of parts of the library have been redesigned, lots of bugs have been solved and some **AMAZING** new features have been added.
|
|
||||||
|
|
||||||
- VR support: raylib supports **Oculus Rift CV1**, one of the most anticipated VR devices in the market. Additionally, raylib supports simulated VR stereo rendering, independent of the VR device; it means, raylib can generate stereo renders with custom head-mounted-display device parameters, that way, any VR device in the market can be **simulated in any platform** just configuring device parameters (and consequently, lens distortion). To enable VR is [extremely easy](https://github.com/raysan5/raylib/blob/master/examples/core_oculus_rift.c).
|
|
||||||
|
|
||||||
- New materials system: now raylib supports standard material properties for 3D models, including diffuse-ambient-specular colors and diffuse-normal-specular textures. Just assign values to standard material and everything is processed internally.
|
|
||||||
|
|
||||||
- New lighting system: added support for up to 8 configurable lights and 3 light types: **point**, **directional** and **spot** lights. Just create a light, configure its parameters and raylib manages to render internally for every 3d object using standard material.
|
|
||||||
|
|
||||||
- Complete gamepad support on Raspberry Pi: Gamepad system has been completely redesigned. Now multiple gamepads can be easily configured and used; gamepad data is read and processed in raw mode in a second thread.
|
|
||||||
|
|
||||||
- Redesigned physics module: [physac](https://github.com/raysan5/raylib/blob/master/src/physac.h) module has been converted to header only and usage [has been simplified](https://github.com/raysan5/raylib/blob/master/examples/physics_basic_rigidbody.c). Performance has also been significantly improved, now physic objects are managed internally in a second thread.
|
|
||||||
|
|
||||||
- Audio chiptunes support and mixing channels: Added support for module audio music (.xm, .mod) loading and playing. Multiple mixing channels are now also supported. All these features thanks to the amazing work of @kd7tck.
|
|
||||||
|
|
||||||
Other additions include a [2D camera system](https://github.com/raysan5/raylib/blob/master/examples/core/core_2d_rcamera.c), render textures for offline render (and most comprehensive [postprocessing](https://github.com/raysan5/raylib/blob/master/examples/shaders/shaders_postprocessing.c)) or support for legacy OpenGL 2.1 on desktop platforms.
|
|
||||||
|
|
||||||
This new version is so massive that is difficult to list all the improvements, most of the raylib modules have been reviewed and [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) module has been completely redesigned to accommodate to new material-lighting systems and stereo rendering. You can check [CHANGELOG](https://github.com/raysan5/raylib/blob/master/CHANGELOG) file for a more detailed list of changes.
|
|
||||||
|
|
||||||
Up to 8 new code examples have been added to show the new raylib features and also some samples to show the usage of [rlgl](https://github.com/raysan5/raylib/blob/master/examples/others/rlgl_standalone.c) and [audio](https://github.com/raysan5/raylib/blob/master/examples/audio_standalone.c) raylib modules as standalone libraries.
|
|
||||||
|
|
||||||
Lots of code changes (+400 commits) and lots of hours of hard work have concluded in this amazing new raylib 1.5.
|
|
||||||
|
|
||||||
notes on raylib 1.6
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
On November 2016, only 4 months after raylib 1.5, arrives raylib 1.6. This new version represents another big review of the library and includes some interesting additions. This version commemorates raylib 3rd anniversary (raylib 1.0 was published on November 2013) and it is a stepping stone for raylib future. raylib roadmap has been reviewed and redefined to focus on its primary objective: create a simple and easy-to-use library to learn videogames programming. Some of the new features:
|
|
||||||
|
|
||||||
- Complete [raylib Lua binding](https://github.com/raysan5/raylib-lua). All raylib functions plus the +60 code examples have been ported to Lua, now Lua users can enjoy coding videogames in Lua while using all the internal power of raylib. This addition also open the doors to Lua scripting support for a future raylib-based engine, being able to move game logic (Init, Update, Draw, De-Init) to Lua scripts while keep using raylib functionality.
|
|
||||||
|
|
||||||
- Completely redesigned [audio module](https://github.com/raysan5/raylib/blob/master/src/raudio.c). Based on the new direction taken in raylib 1.5, it has been further improved and more functionality added (+20 new functions) to allow raw audio processing and streaming. [FLAC file format support](https://github.com/raysan5/raylib/blob/master/src/external/dr_flac.h) has also been added. In the same line, [OpenAL Soft](https://github.com/kcat/openal-soft) backend is now provided as a static library in Windows to allow static linking and get ride of OpenAL32.dll. Now raylib Windows games are completely self-contained, no external libraries are required anymore!
|
|
||||||
|
|
||||||
- [Physac](https://github.com/victorfisac/Physac) module has been moved to its own repository and it has been improved A LOT, actually, the library has been completely rewritten from scratch by [@victorfisac](https://github.com/victorfisac), multiple samples have been added together with countless new features to match current standard 2D physic libraries. Results are amazing!
|
|
||||||
|
|
||||||
- Camera and gestures modules have been reviewed, highly simplified and ported to single-file header-only libraries for easier portability and usage flexibility. Consequently, camera system usage has been simplified in all examples.
|
|
||||||
|
|
||||||
- Improved Gamepad support on Windows and Raspberry Pi with the addition of new functions for custom gamepad configurations but supporting by default PS3 and Xbox-based gamepads.
|
|
||||||
|
|
||||||
- Improved textures and text functionality, adding new functions for texture filtering control and better TTF/AngelCode fonts loading and generation support.
|
|
||||||
|
|
||||||
Build system improvement. Added support for raylib dynamic library generation (raylib.dll) for users that prefer dynamic library linking. Also thinking on advanced users, it has been added pre-configured [Visual Studio C++ 2015 solution](https://github.com/raysan5/raylib/tree/master/projects/vs2015) with raylib project and C/C++ examples for users that prefer that professional IDE and compiler.
|
|
||||||
|
|
||||||
New examples, new functions, complete code-base review, multiple bugs corrected... this is raylib 1.6. Enjoy making games.
|
|
||||||
|
|
||||||
notes on raylib 1.7
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
On May 2017, around 6 months after raylib 1.6, comes another raylib installment, raylib 1.7. This time library has been improved a lot in terms of consistency and cleanness. As stated in [this patreon article](https://www.patreon.com/posts/raylib-future-7501034), this new raylib version has focused efforts in becoming more simple and easy-to-use to learn videogames programming. Some highlights of this new version are:
|
|
||||||
|
|
||||||
- More than 30 new functions added to the library, functions to control Window, utils to work with filenames and extensions, functions to draw lines with custom thick, mesh loading, functions for 3d ray collisions detailed detection, functions for VR simulation and much more... Just check [CHANGELOG](CHANGELOG) for a detailed list of additions!
|
|
||||||
|
|
||||||
- Support of [configuration flags](https://github.com/raysan5/raylib/issues/200) on every raylib module. Advanced users can customize raylib just by choosing desired features, and defining some configuration flags on modules compilation. That way users can control library size and available functionality.
|
|
||||||
|
|
||||||
- Improved [build system](https://github.com/raysan5/raylib/blob/master/src/Makefile) for all supported platforms (Windows, Linux, OSX, RPI, Android, HTML5) with a unique Makefile to compile sources. Added support for Android compilation with a custom standalone toolchain and also multiple build compilation flags.
|
|
||||||
|
|
||||||
- New [examples](http://www.raylib.com/examples.html) and [sample games](http://www.raylib.com/games.html) added. All sample material has been reviewed, removing useless examples and adding more comprehensive ones; all material has been ported to the latest raylib version and tested on multiple platforms. Examples folder structure has been improved and also build systems.
|
|
||||||
|
|
||||||
- Improved library consistency and organization in general. Functions and parameters have been renamed, some parts of the library have been cleaned and simplified, some functions have been moved to examples (lighting, Oculus Rift CV1 support) towards a more generic library implementation. Lots of hours have been invested in this process...
|
|
||||||
|
|
||||||
Some other features: Gamepad support on HTML5, RPI touch screen support, 32bit audio support, frames timing improvements, public log system, rres file format support, automatic GIF recording...
|
|
||||||
|
|
||||||
And here is another version of **raylib, a simple and easy-to-use library to enjoy videogames programming**. Enjoy it.
|
|
||||||
|
|
||||||
notes on raylib 1.8
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
October 2017, around 5 months after latest raylib version, another release is published: raylib 1.8. Again, several modules of the library have been reviewed and some new functionality added. Main changes of this new release are:
|
|
||||||
|
|
||||||
- [Procedural image generation](https://github.com/raysan5/raylib/blob/master/examples/textures/textures_image_generation.c) function, a set of new functions have been added to generate gradients, checked, noise and cellular images from scratch. Image generation could be useful for certain textures or learning purposes.
|
|
||||||
|
|
||||||
- [Parametric mesh generation](https://github.com/raysan5/raylib/blob/master/examples/models/models_mesh_generation.c) functions, create 3d meshes from scratch just defining a set of parameters, meshes like cube, sphere, cylinder, torus, knot and more can be very useful for prototyping or for lighting and texture testing.
|
|
||||||
|
|
||||||
- PBR Materials support, a completely redesigned shaders and material system allows advanced materials definition and usage, with fully customizable shaders. Some new functions have been added to generate the environment textures required for PBR shading and a a new complete [PBR material example](https://github.com/raysan5/raylib/blob/master/examples/models/models_material_pbr.c) is also provided for reference.
|
|
||||||
|
|
||||||
- Custom Android APK build pipeline with [simple Makefile](https://github.com/raysan5/raylib/blob/master/templates/simple_game/Makefile). Actually, full code building mechanism based on plain Makefile has been completely reviewed and Android building has been added for sources and also for examples and templates building into the final APK package. This way, raylib Android building has been greatly simplified and integrated seamlessly into standard build scripts.
|
|
||||||
|
|
||||||
- [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) module has been completely reviewed and most of the functions renamed for consistency. This way, standalone usage of rlgl is promoted, with a [complete example provided](https://github.com/raysan5/raylib/blob/master/examples/others/rlgl_standalone.c). rlgl offers a pseudo-OpenGL 1.1 immediate-mode programming-style layer, with backends to multiple OpenGL versions.
|
|
||||||
|
|
||||||
- [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h) library has been also reviewed to align with other advance math libraries like [GLM](https://github.com/g-truc/glm). Matrix math has been improved and simplified, some new Quaternion functions have been added and Vector3 functions have been renamed all around the library for consistency with new Vector2 functionality.
|
|
||||||
|
|
||||||
Additionally, as always, examples and templates have been reviewed to work with new version (some new examples have been added), all external libraries have been updated to latest stable version and latest Notepad++ and MinGW have been configured to work with new raylib. For a full list of changes, just check [CHANGELOG](CHANGELOG).
|
|
||||||
|
|
||||||
New installer provided, web updated, examples re-builded, documentation reviewed... **new raylib 1.8 published**. Enjoy coding games.
|
|
||||||
|
|
||||||
notes on raylib 2.0
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
It's been 9 months since last raylib version was published, a lot of things have changed since then... This new raylib version represents an inflection point in the development of the library and so, we jump to a new major version... Here is the result of almost **5 years and thousands of hours of hard work**... here is... **raylib 2.0**
|
|
||||||
|
|
||||||
In **raylib 2.0** the full API has been carefully reviewed for better consistency, some new functionality has been added and the overall raylib experience has been greatly improved... The key features of new version are:
|
|
||||||
|
|
||||||
- **Complete removal of external dependencies.** Finally, raylib does not require external libraries to be installed and linked along with raylib, all required libraries are contained and compiled within raylib. Obviously some external libraries are required but only the strictly platform-dependent ones, the ones that come installed with the OS. So, raylib becomes a self-contained platform-independent games development library.
|
|
||||||
|
|
||||||
- **Full redesign of audio module to use the amazing miniaudio library**, along with external dependencies removal, OpenAL library has been replaced by [miniaudio](https://github.com/dr-soft/miniaudio), this brand new library offers automatic dynamic linking with default OS audio systems. Undoubtedly, the perfect low-level companion for raylib audio module!
|
|
||||||
|
|
||||||
- **Support for continuous integration building*** through AppVeyor and Travis CI. Consequently, raylib GitHub develop branch has been removed, simplifying the code-base to a single master branch, always stable. Every time a new commit is deployed, library is compiled for **up-to 12 different configurations**, including multiple platforms, 32bit/64bit and multiple compiler options! All those binaries are automatically attached to any new release!
|
|
||||||
|
|
||||||
- **More platforms supported and tested**, including BSD family (FreeBSD, openBSD, NetBSD, DragonFly) and Linux-based family platforms (openSUSE, Debian, Ubuntu, Arch, NixOS...). raylib has already been added to some package managers! Oh, and last but not less important, **Android 64bit** is already supported by raylib!
|
|
||||||
|
|
||||||
- **Support for TCC compiler!** Thanks to the lack of external dependencies, raylib can now be easily compiled with a **minimal toolchain**, like the one provided by Tiny C Compiler. It opens the door to an amazing future, allowing, for example, static linkage of libtcc for **runtime compilation of raylib-based code**... and the library itself if required! Moreover, TCC is blazing fast, it can compile all raylib in a couple of seconds!
|
|
||||||
|
|
||||||
- Refactored all raylib configuration #defines into a **centralized `config.h` header**, with more than **40 possible configuration options** to compile a totally customizable raylib version including only desired options like supported file formats or specific functionality support. It allows generating a trully ligth-weight version of the library if desired!
|
|
||||||
|
|
||||||
A part of that, lots of new features, like a brand **new font rendering and packaging system** for TTF fonts with **SDF support** (thanks to the amazing STB headers), new functions for **CPU image data manipulation**, new orthographic 3d camera mode, a complete review of `raymath.h` single-file header-only library for better consistency and performance, new examples and way, [way more](https://github.com/raysan5/raylib/blob/master/CHANGELOG).
|
|
||||||
|
|
||||||
Probably by now, **raylib 2.0 is the simplest and easiest-to-use library to enjoy (and learn) videogames programming**... but, undoubtedly its development has exceeded any initial objective; raylib has become a simple and easy-to-use truly multiplatform portable standalone media library with thousands of possibilities... and that's just the beginning!
|
|
||||||
|
|
||||||
notes on raylib 2.5
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
After almost one years since latest raylib installment, here is **raylib 2.5**. A lot of work has been put on this new version and consequently I decided to bump versioning several digits. The complete list of changes and additions is humungous, details can be found in the [CHANGELOG](CHANGELOG), and here is a short recap with the highlight improvements.
|
|
||||||
|
|
||||||
- New **window management and file system functions** to query monitor information, deal with clipboard, check directory files info and even launch a URL with default system web browser. Experimental **High-DPI monitor support** has also been added through a compile flag.
|
|
||||||
|
|
||||||
- **Redesigned Gamepad mechanism**, now generic for all platforms and gamepads, no more specific gamepad configurations.
|
|
||||||
**Redesigned UWP input system**, now raylib supports UWP seamlessly, previous implementation required a custom input system implemented in user code.
|
|
||||||
|
|
||||||
- `rlgl` module has been redesigned to **support a unique buffer for shapes drawing batching**, including LINES, TRIANGLES, QUADS in the same indexed buffer, also added support for multi-buffering if required. Additionally, `rlPushMatrix()`/`rlPopMatrix()` functionality has been reviewed to behave exactly like OpenGL 1.1, `models_rlgl_solar_system` example has been added to illustrate this behavior.
|
|
||||||
|
|
||||||
- **VR simulator** has been reviewed to **allow custom configuration of Head-Mounted-Device parameters and distortion shader**, `core_vr_simulator` has been properly adapted to showcase this new functionality, now the VR simulator is a generic configurable stereo rendering system that allows any VR device simulation with just a few lines of code or even dynamic tweaking of HMD parameters.
|
|
||||||
|
|
||||||
- Support for **Unicode text drawing**; now raylib processes UTF8 strings on drawing, supporting Unicode codepoints, allowing rendering mostly any existent language (as long as the font with the glyphs is provided). An amazing example showing this feature has also been added: `text_unicode`.
|
|
||||||
|
|
||||||
- Brand **new text management API**, with the addition of multiple functions to deal with string data, including functionality like replace, insert, join, split, append, to uppercase, to lower... Note that most of those functions are intended for text management on rendering, using pre-loaded internal buffers, avoiding new memory allocation that user should free manually.
|
|
||||||
|
|
||||||
- Multiple **new shapes and textures drawing functions** to support rings (`DrawRing()`, `DrawRingLines()`), circle sectors (`DrawCircleSector()`, `DrawCircleSectorLines()`), rounded rectangles (`DrawRectangleRounded()`, `DrawRectangleRoundedLines()`) and also n-patch textures (`DrawTextureNPatch()`), detailed examples have been added to illustrate all this new functionality.
|
|
||||||
|
|
||||||
- Experimental **cubemap support**, to automatically load multiple cubemap layouts (`LoadTextureCubemap()`). It required some internal `rlgl` redesign to allow cubemap textures.
|
|
||||||
|
|
||||||
- **Skeletal animation support for 3d models**, this addition implied a redesign of `Model` data structure to accommodate multiple mesh/multiple materials support and bones information. Multiple models functions have been reviewed and added on this process, also **glTF models loading support** has been added.
|
|
||||||
|
|
||||||
This is just a brief list with some of the changes of the new **raylib 2.5** but there is way more, about **70 new functions** have been added and several subsystems have been redesigned. More than **30 new examples** have been created to show the new functionalities and better illustrate already available ones.
|
|
||||||
|
|
||||||
It has been a long year of hard work to make raylib a solid technology to develop new products over it.
|
|
||||||
|
|
||||||
notes on raylib 3.0
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
After **10 months of intense development**, new raylib version is ready. Despite primary intended as a minor release, the [CHANGELIST](CHANGELOG) has grown so big and the library has changed so much internally that it finally became a major release. Library **internal ABI** has received a big redesign and review, targeting portability, integration with other platforms and making it a perfect option for other programming [language bindings](BINDINGS.md).
|
|
||||||
|
|
||||||
- All **global variables** from the multiple raylib modules have been moved to a **global context state**, it has several benefits, first, better code readability with more comprehensive variable naming and categorization (organized by types, i.e. `CORE.Window.display.width`, `CORE.Input.Keyboard.currentKeyState` or `RLGL.State.modelview`). Second, it allows better memory management to load global context state dynamically when required (not at the moment), making it easy to implement a **hot-reloading mechanism** if desired.
|
|
||||||
|
|
||||||
- All **memory allocations** on raylib and its dependencies now use `RL_MALLOC`, `RL_FREE` and similar macros. Now users can easily hook their own memory allocation mechanism if desired, having more control over memory allocated internally by the library. Additionally, it makes it easier to port the library to embedded devices where memory control is critical. For more info check raylib issue #1074.
|
|
||||||
|
|
||||||
- All **I/O file accesses** from raylib are being moved to **memory data access**, now all I/O file access is centralized into just four functions: `LoadFileData()`, `SaveFileData()`, `LoadFileText()`, `SaveFileText()`. Users can just update those functions to any I/O file system. This change makes it easier to integrate raylib with **Virtual File Systems** or custom I/O file implementations.
|
|
||||||
|
|
||||||
- All **raylib data structures** have been reviewed and optimized for pass-by-value usage. One of raylib distinctive design decisions is that most of its functions receive and return data by value. This design makes raylib really simple for newcomers, avoiding pointers and allowing complete access to all structures data in a simple way. The downside is that data is copied on stack every function call and that copy could be costly so, all raylib data structures have been optimized to **stay under 64 bytes** for fast copy and retrieve.
|
|
||||||
|
|
||||||
- All **raylib tracelog messages** have been reviewed and categorized for a more comprehensive output information when developing raylib applications, now all display, input, timer, platform, auxiliar libraries, file-accesses, data loading/unloading issues are properly reported with more detailed and visual messages.
|
|
||||||
|
|
||||||
- `raudio` module has been internally reviewed to accommodate the new `Music` structure (converted from previous pointer format) and the module has been adapted to the **highly improved** [`miniaudio v0.10`](https://github.com/dr-soft/miniaudio).
|
|
||||||
|
|
||||||
- `text` module reviewed to **improve fonts generation** and text management functions, `Font` structure has been redesigned to better accommodate characters data, decoupling individual characters as `Image` glyphs from the font atlas parameters. Several improvements have been made to better support Unicode strings with UTF-8 encoding.
|
|
||||||
|
|
||||||
- **Multiple new examples added** (most of them contributed by raylib users) and all examples reviewed for correct execution on most of the supported platforms, specially Web and Raspberry Pi. A detailed categorized table has been created on github for easy examples navigation and code access.
|
|
||||||
|
|
||||||
- New **GitHub Actions CI** system has been implemented for Windows, Linux and macOS code and examples compilation on every new commit or PR to make sure library keeps stable and usable with no breaking bugs.
|
|
||||||
|
|
||||||
Note that only key changes are listed here but there is way more! About **30 new functions**, multiple functions reviewed, bindings to [+40 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md) and great samples/demos/tutorials [created by the community](https://discord.gg/raylib), including raylib integration with [Spine](https://github.com/WEREMSOFT/spine-raylib-runtimes), [Unity](https://unitycoder.com/blog/2019/12/09/using-raylib-dll-in-unity/), [Tiled](https://github.com/OnACoffeeBreak/raylib_tiled_import_with_tmx), [Nuklear](http://bedroomcoders.co.uk/implementing-a-3d-gui-with-raylib/), [enet](https://github.com/nxrighthere/NetDynamics) and [more](https://github.com/raysan5/raylib/issues/1079)!
|
|
||||||
|
|
||||||
It has been **10 months of improvements** to create the best raylib ever.
|
|
||||||
|
|
||||||
Welcome to **raylib 3.0**.
|
|
||||||
|
|
||||||
notes on raylib 3.5 - 7th Anniversary Edition
|
|
||||||
---------------------------------------------
|
|
||||||
|
|
||||||
It's December 25th... this crazy 2020 is about to finish and finally the holidays gave me some time to put a new version of raylib. It's been **9 months since last release** and last November raylib become 7 years old... I was not able to release this new version back then but here it is. Many changes and improvements have happened in those months and, even, last August, raylib was awarded with an [Epic Megagrant](https://www.unrealengine.com/en-US/blog/epic-megagrants-fall-2020-update)! Bindings list kept growing to [+50 programming languages](BINDINGS.md) and some new platforms have been supported. Let's see this new version details:
|
|
||||||
|
|
||||||
First, some general numbers of this new update:
|
|
||||||
|
|
||||||
- **+650** commits since previous RELEASE
|
|
||||||
- **+30** functions ADDED (for a TOTAL of **475**!)
|
|
||||||
- **+90** functions REVIEWED/REDESIGNED
|
|
||||||
- **+30** contributors (for a TOTAL of **170**!)
|
|
||||||
- **+8** new examples (for a TOTAL of **+120**!)
|
|
||||||
|
|
||||||
Here the list with some highlights for `raylib 3.5`.
|
|
||||||
|
|
||||||
- NEW **Platform** supported: **Raspberry Pi 4 native mode** (no X11 windows) through [DRM](https://en.wikipedia.org/wiki/Direct_Rendering_Manager) subsystem and GBM API. Actually this is a really interesting improvement because it opens the door to raylib to support other embedded platforms (Odroid, GameShell, NanoPi...). Also worth mentioning the un-official homebrew ports of raylib for [PS4](https://github.com/orbisdev/orbisdev-orbisGl2) and [PSVita](https://github.com/psp2dev/raylib4Vita).
|
|
||||||
|
|
||||||
- NEW **configuration options** exposed: For custom raylib builds, `config.h` now exposes **more than 150 flags and defines** to build raylib with only the desired features, for example, it allows to build a minimal raylib library in just some KB removing all external data filetypes supported, very useful to generate **small executables or embedded devices**.
|
|
||||||
|
|
||||||
- NEW **automatic GIF recording** feature: Actually, automatic GIF recording (**CTRL+F12**) for any raylib application has been available for some versions but this feature was really slow and low-performant using an old gif library with many file accesses. It has been replaced by a **high-performant alternative** (`msf_gif.h`) that operates directly on memory... and actually works very well! Try it out!
|
|
||||||
|
|
||||||
- NEW **RenderBatch** system: `rlgl` module has been redesigned to support custom **render batches** to allow grouping draw calls as desired, previous implementation just had one default render batch. This feature has not been exposed to raylib API yet but it can be used by advanced users dealing with `rlgl` directly. For example, multiple `RenderBatch` can be created for 2D sprites and 3D geometry independently.
|
|
||||||
|
|
||||||
- NEW **Framebuffer** system: `rlgl` module now exposes an API for custom **Framebuffer attachments** (including cubemaps!). raylib `RenderTexture` is a basic use-case, just allowing color and depth textures, but this new API allows the creation of more advanced Framebuffers with multiple attachments, like the **G-Buffers**. `GenTexture*()` functions have been redesigned to use this new API.
|
|
||||||
|
|
||||||
- Improved **software rendering**: raylib `Image*()` API is intended for software rendering, for those cases when **no GPU or no Window is available**. Those functions operate directly with **multi-format** pixel data on RAM and they have been completely redesigned to be way faster, specially for small resolutions and retro-gaming. Low-end embedded devices like **microcontrollers with custom displays** could benefit of this raylib functionality!
|
|
||||||
|
|
||||||
- File **loading from memory**: Multiple functions have been redesigned to load data from memory buffers **instead of directly accessing the files**, now all raylib file loading/saving goes through a couple of functions that load data into memory. This feature allows **custom virtual-file-systems** and it gives more control to the user to access data already loaded in memory (i.e. images, fonts, sounds...).
|
|
||||||
|
|
||||||
- NEW **Window states** management system: raylib `core` module has been redesigned to support Window **state check and setup more easily** and also **before/after Window initialization**, `SetConfigFlags()` has been reviewed and `SetWindowState()` has been added to control Window minification, maximization, hiding, focusing, topmost and more.
|
|
||||||
|
|
||||||
- NEW **GitHub Actions** CI/CD system: Previous CI implementation has been reviewed and improved a lot to support **multiple build configurations** (platforms, compilers, static/shared build) and also an **automatic deploy system** has been implemented to automatically attach the different generated artifacts to every new release. As the system seems to work very good, previous CI platforms (AppVeyor/TravisCI) have been removed.
|
|
||||||
|
|
||||||
A part of those changes, many new functions have been added, some redundant functions removed and many functions have been reviewed for consistency with the full API (function name, parameters name and order, code formatting...). Again, this release represents is a **great improvement for raylib and marks the way forward** for the library. Make sure to check [CHANGELOG](CHANGELOG) for details! Hope you enjoy it!
|
|
||||||
|
|
||||||
Happy holidays! :)
|
|
||||||
|
|
||||||
notes on raylib 3.7
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
April 2021, it's been about 4 months since the last raylib release and here is already a new one, this time with a bunch of internal redesigns and improvements. Surprisingly, on April 8th I was awarded for a second time with the [Google Open Source Peer Bonus Award](https://opensource.googleblog.com/2021/04/announcing-first-group-of-google-open-source-peer-bonus-winners.html) for my contribution to open source world with raylib and it seems the library is getting some traction, what a better moment for a new release? Let's see what can be found in this new version:
|
|
||||||
|
|
||||||
Let's start with some numbers:
|
|
||||||
|
|
||||||
- **+100** closed issues (for a TOTAL of **+900**!)
|
|
||||||
- **+400** commits since previous RELEASE
|
|
||||||
- **+50** functions ADDED (**+30** of them to rlgl API)
|
|
||||||
- **+30** functions REVIEWED/REDESIGNED
|
|
||||||
- **+40** new contributors (for a TOTAL of **+210**!)
|
|
||||||
|
|
||||||
Highlights for `raylib 3.7`:
|
|
||||||
|
|
||||||
- **REDESIGNED: `rlgl` module for greater abstraction level**. This suppose an **important change in raylib architecture**, now `rlgl` functionality is self-contained in the module and used by higher-level layers (specially by `core` module), those upper layers are the ones that expose functionality to the main API when required, for example the `Shaders`, `Mesh` and `Materials` functionality. Multiple `rlgl` functions have been renamed for consistency, in this case, following the `rl*()` prefix convention. Functions have also been reorganized internally by categories and `GenTexture*()` functions have been removed from the library and moved to [`models_material_pbr`](https://github.com/raysan5/raylib/blob/master/examples/models/models_material_pbr.c) example.
|
|
||||||
|
|
||||||
- **REDESIGNED: VR simulator and stereo rendering mechanism**. A **brand new API** has been added, more comprehensive and better integrated with raylib, the **new stereo rendering** can be combined with `RenderTexture` and `Shader` API allowing the user to **manage fbo and distortion shader directly**. Also, the new rendering mechanism supports **instancing on stereo rendering**! Check the updated [`core_vr_simulator`](https://github.com/raysan5/raylib/blob/master/examples/core/core_vr_simulator.c) example for reference!
|
|
||||||
|
|
||||||
- **ADDED: New file access callbacks system**. Several new callback functions have been added to the API to allow custom file loaders. A [nice example](https://github.com/RobLoach/raylib-physfs) it's the **raylib integration with a virtual file system** [PhysFS](https://icculus.org/physfs/).
|
|
||||||
|
|
||||||
- **ADDED: glTF animations support**. glTF is the preferred models file format to be used with raylib and along the addition of a models animation API on latest raylib versions, now animations support for glTF format has come to raylib, thanks for this great contribution to [Hristo Stamenov](@object71)
|
|
||||||
|
|
||||||
- **ADDED: Music streaming support from memory**. raylib has been adding the `Load*FromMemory()` option to all its supported file formats but **music streaming** was not supported yet... until now. Thanks to this great contribution by [Agnis "NeZvērs" Aldiņš](@nezvers), now raylib supports music streaming from memory data for all supported file formats: WAV, OGG, MP3, FLAC, XM and MOD.
|
|
||||||
|
|
||||||
- **RENAMED: enums values for consistency**. Most raylib enums names and values names have been renamed for consistency, now all value names start with the type of data they represent. It increases clarity and readability when using those values and also **improves overall library consistency**.
|
|
||||||
|
|
||||||
Besides those key changes, many functions have been reviewed with improvements and bug fixes, many of them contributed by the community! Thanks! And again, this release sets a **new milestone for raylib library**. Make sure to check [CHANGELOG](CHANGELOG) for detailed list of changes! Hope you enjoy this new raylib installment!
|
|
||||||
|
|
||||||
Happy **gamedev/tools/graphics** programming! :)
|
|
||||||
|
|
||||||
notes on raylib 4.0 - 8th Anniversary Edition
|
|
||||||
---------------------------------------------
|
|
||||||
|
|
||||||
It's been about 6 months since last raylib release and it's been **8 years since I started with this project**, what an adventure! It's time for a new release: `raylib 4.0`, **the biggest release ever** and an inflection point for the library. Many hours have been put in this release to make it special, **many library details have been polished**: syntax, naming conventions, code comments, functions descriptions, log outputs... Almost all the issues have been closed (only 3 remain open at the moment of this writing) and some amazing new features have been added. I expect this **`raylib 4.0`** to be a long-term version (LTS), stable and complete enough for any new graphic/game/tool application development.
|
|
||||||
|
|
||||||
Let's start with some numbers:
|
|
||||||
|
|
||||||
- **+130** closed issues (for a TOTAL of **+1030**!)
|
|
||||||
- **+550** commits since previous RELEASE
|
|
||||||
- **+20** functions ADDED to raylib API
|
|
||||||
- **+60** functions ADDED to rlgl API
|
|
||||||
- **+40** functions RENAMED/REVIEWED/REDESIGNED
|
|
||||||
- **+60** new contributors (for a TOTAL of **+275**!)
|
|
||||||
|
|
||||||
Highlights for `raylib 4.0`:
|
|
||||||
|
|
||||||
- **Naming consistency and coherency**: `raylib` API has been completely reviewed to be consistent on naming conventions for data structures and functions, comments and descriptions have been reviewed, also the syntax of many symbols for consistency; some functions and structs have been renamed (i.e. `struct CharInfo` to `struct GlyphInfo`). Output log messages have been also improved to show more info to the users. Several articles have been written in this process: [raylib_syntax analysis](https://github.com/raysan5/raylib/wiki/raylib-syntax-analysis) and [raylib API usage analysis](https://gist.github.com/raysan5/7c0c9fff1b6c19af24bb4a51b7383f1e). In general, a big polishment of the library to make it more consistent and coherent.
|
|
||||||
|
|
||||||
- **Event Automation System**: This new _experimental_ feature has been added for future usage, it allows to **record input events and re-play them automatically**. This feature could be very useful to automatize examples testing but also for tutorials with assisted game playing, in-game cinematics, speedruns, AI playing and more! Note this feature is still experimental.
|
|
||||||
|
|
||||||
- **Custom game-loop control**: As requested by some advanced users, **the game-loop control can be exposed** compiling raylib with the config flag: `SUPPORT_CUSTOM_FRAME_CONTROL`. It's intended for advanced users that want to control the events polling and also the timing mechanisms of their games.
|
|
||||||
|
|
||||||
- [**`rlgl 4.0`**](https://github.com/raysan5/raylib/blob/master/src/rlgl.h): This module has been completely **decoupled from platform layer** and raylib, now `rlgl` single-file header-only library only depends on the multiple OpenGL backends supported, even the dependency on `raymath` has been removed. Additionally, **support for OpenGL 4.3** has been added, supporting compute shaders and Shader Storage Buffer Objects (SSBO). Now `rlgl` can be used as a complete standalone portable library to wrap several OpenGL version and providing **a simple and easy-to-use pseudo-OpenGL immediate-mode API**.
|
|
||||||
|
|
||||||
- [**`raymath 1.5`**](https://github.com/raysan5/raylib/blob/master/src/raymath.h): This module has been reviewed and some new conventions have been adopted to make it **more portable and self-contained**:
|
|
||||||
- Functions are self-contained, no function use other raymath function inside, required code is directly re-implemented
|
|
||||||
- Functions input parameters are always received by value
|
|
||||||
- Functions use always a "result" variable for return
|
|
||||||
- Angles are always in radians (`DEG2RAD`/`RAD2DEG` macros provided for convenience)
|
|
||||||
|
|
||||||
- [**`raygui 3.0`**](https://github.com/raysan5/raygui): The **official raylib immediate-mode gui library** (included in `raylib/src/extras`) has been updated to a new version, embedding the icons collection and adding mulstiple improvements. It has been simplified and constrained for a better focus on its task: provide a simple and easy-to-use immediate-mode-gui library for small tools development.
|
|
||||||
|
|
||||||
- [**`raylib_parser`**](https://github.com/raysan5/raylib/tree/master/parser): Added **new tool to parse `raylib.h`** and tokenize its enums, structs and functions, extracting all required info (name, params, descriptions...) into custom output formats (TXT, XML, JSON...) for further processing. This tool is specially useful to **automatize bindings generation**. Hopefully, this tool will make life easier to binding creators to update their bindings for raylib 4.0 or adding new ones!
|
|
||||||
|
|
||||||
- **Zig and Odin official support for raylib**: Those two new amazing programming languages are officially supporting raylib, `Zig` lists raylib as an [official example for C interoperatibility](https://ziglang.org/learn/samples/#c-interoperability) and Odin [officially supports raylib as a vendor library](https://github.com/odin-lang/Odin/tree/master/vendor/raylib). Both languages also have several bingings to raylib. Additionally, Zig build system supported has been added to compile raylib library and examples.
|
|
||||||
|
|
||||||
Those are some of the key features for this new release but actually there is way more! **Support for `VOX` ([MagikaVoxel](https://ephtracy.github.io/)) 3d model format** has been added, **new [raylib_game_template](https://github.com/raysan5/raylib-game-template)** repo shared, **new `EncodeDataBase64()` and `DecodeDataBase64()` functions** added, **improved HiDPI support**, new `DrawTextPro()` with support for text rotations, completely **reviewed `glTF` models loading**, added **`SeekMusicStream()` for music seeking**, many new examples and +20 examples reviewed... **hundreds of improvements and bug fixes**! Make sure to check [CHANGELOG](CHANGELOG) for a detailed list of changes!
|
|
||||||
|
|
||||||
Undoubtedly, **this is the best raylib ever**. Enjoy gamedev/tools/graphics programming! :)
|
|
||||||
|
|
||||||
notes on raylib 4.2
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
**New raylib release!** Nine months after latest raylib, here is a new version. It was supposed to be just a small update but, actually, it's a huge update with lots of changes a improvements. It has been possible thanks to the many contributors that has helped with issues and improvements, it's the **update with more contributors to date** and that's amazing!
|
|
||||||
|
|
||||||
Some numbers to start with:
|
|
||||||
|
|
||||||
- **+200** closed issues (for a TOTAL of **1230**!)
|
|
||||||
- **+540** commits since previous RELEASE (for a TOTAL of **+6000**!)
|
|
||||||
- **+20** functions ADDED to raylib API (for a TOTAL of **502**!)
|
|
||||||
- **+60** functions REVIEWED/REDESIGNED
|
|
||||||
- **+70** new contributors (for a TOTAL of **+360**!)
|
|
||||||
|
|
||||||
Highlights for `raylib 4.2`:
|
|
||||||
|
|
||||||
- **raylib extra libraries cleanup**: raylib has been on diet and all the _extra_ libraries included on previous releases have been removed from raylib. Now raylib only includes the original **7** raylib modules: `rcore`, `rlgl`, `rshapes`, `rtextures`, `rtext`, `rmodels` and `raudio`. But no worries, _extra_ libraries have not been deleted, they have been moved to their own repos for better maintainability and more focus on its functionality. The libraries moved out from raylib repo are: [`raygui`](https://github.com/raysan5/raygui), [`physac`](https://github.com/raysan5/physac), [`rmem`](https://github.com/raylib-extras/rmem), [`reasings`](https://github.com/raylib-extras/reasings) and [`raudio`](https://github.com/raysan5/raudio) (standalone mode). On that same line, a new **amazing GitHub group:** [`raylib-extras`](https://github.com/raylib-extras) has been created by @JeffM2501 to contain raylib extra libraries as well as other raylib add-ons provided by the community. Jeff has done an amazing work on that line, providing multiple libraries and examples for raylib, like [custom first-person and third person camera systems](https://github.com/raylib-extras/extras-c/tree/main/cameras), [Dear ImGui raylib integration](https://github.com/raylib-extras/rlImGui), [multiple specific examples](https://github.com/raylib-extras/examples-c) and even a complete [RPG Game Example](https://github.com/raylib-extras/RPGExample)! Great work Jeff! :D
|
|
||||||
|
|
||||||
- **raylib examples review**: The +120 raylib examples have been reviewed to add clearer information about when the were first created (raylib version used) and when they were updated for the last time. But the greatest improvement for users has been the **addition of an estimated difficulty level** for every example, [web has been updated accordingly](https://www.raylib.com/examples.html) to reflect those difficulty levels. Now examples are classified with **1 to 4 stars** depending on difficulty to help users with their learning process. Personally, I think this "small" addition could be a game-changer to better guide new users on the library adoption! Additionally, this new raylib release includes 7 new examples; the most interesting one: [`text_codepoints_loading`](https://www.raylib.com/examples/text/loader.html?name=text_codepoints_loading) that illustrates how to load and draw custom codepoints from a font file, very useful for Asian languages.
|
|
||||||
|
|
||||||
- [**`rres 1.0`**](https://github.com/raysan5/rres): New `rres` **resources packaging file-format**, including a [`rres-raylib`](https://github.com/raysan5/rres/blob/master/src/rres-raylib.h) library implementation and [`rrespacker`](https://raylibtech.itch.io/rrespacker) tool. `rres` file format has been [under development for +8 years](https://github.com/raysan5/rres#design-history) and it was originally created to be part of raylib. It was highly inspired by _XNA XNB_ resources file format but design has changed a lot along the years. This first release of the format specs is engine-agnostic and has been designed to be portable to any engine, including lots of professional features like data processing, compression and encryption.
|
|
||||||
|
|
||||||
- [**`raygui 3.2`**](https://github.com/raysan5/raygui): The **official raylib immediate-mode gui library** designed for tools development has been updated to a new version aligned with raylib 4.2. Multiple controls have been reviewed for library consistency, now all controls follow a similar function signature. It has been battle-tested with the development of +8 published tools in the last months. The tools can be seen and used for free in the [raylib technologies tools page](https://raylibtech.itch.io/). Worth mentioning that several of those **tools have been open sourced** for anyone to use, compile, contribute or learn how the code works.
|
|
||||||
|
|
||||||
- [**`raylib_parser`**](https://github.com/raysan5/raylib/tree/master/parser): Multiple contributors **using the tool to automatize bindings creation** have contributed with improvements of this **tool to parse `raylib.h`** (and other raylib-style headers) to tokenize its enums, structs and functions. Processed data can be exported to custom file formats (i.e XML, JSON, LUA) for bindings generation or even docs generation if required.
|
|
||||||
|
|
||||||
- **New file system API**: Current API has been redesigned to be more comprehensive and better aligned with raylib naming conventions, two new functions are provided `LoadDirectoryFiles()`/`LoadDirectoryFilesEx()` to load a `FilePathList` for provided path, supporting extension filtering and recursive directory scan. `LoadDroppedFiles()` has been renamed to better reflect its internal functionality. Now, all raylib functions that start with `Load*()` allocate memory internally and a equivalent `Unload*()` function is defined to take care of that memory internally when not required any more!
|
|
||||||
|
|
||||||
- **New audio stream processors API** (_experimental_): Now real-time audio stream data processors can be added using callbacks to played Music. It allows users to create custom effects for audio like delays of low-pass-filtering (example provided). The new API uses a callback system and it's still _ highly experimental_, it differs from the usual level of complexity that provides raylib and it is intended for advanced users. It could change in the future but, actually, `raudio` module is in the spotlight for future updates; [miniaudio](https://github.com/mackron/miniaudio) implements a new higher-level API that can be useful in the future for raylib.
|
|
||||||
|
|
||||||
As always, there are more improvements than the key features listed, make sure to check raylib [CHANGELOG](CHANGELOG) for the detailed list of changes; for this release a `WARNING` flag has been added to all the changes that could affect bindings or productivity code. **raylib keeps improving one more version** and a special focus on maintainability has been put on the library for the future. Specific/advance functionality will be provided through **raylib-extras** repos and raylib main repo devlelopment will be focused on what made raylib popular: being a simple and easy-to-use library to **enjoy videogames programming**.
|
|
||||||
|
|
||||||
**Enjoy gamedev/tools/graphics programming!** :)
|
|
||||||
|
|
||||||
notes on raylib 4.5
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
It's been **7 months** since latest raylib release. As usual, **many parts of the library have been reviewed and improved** along those months. Many issues have been closed, staying under 10 open issues at the moment of this writting and also many PRs from contributors have been received, reviewed and merged into raylib library. Some new functions have been added and some others have been removed to improve library coherence and avoid moving too high level, giving the users the tools to implement advance functionality themselfs over raylib. Again, this is a big release with a considerable amount of changes and improvements. Here is a small summary highlighting this new **rayib 4.5**.
|
|
||||||
|
|
||||||
Some numbers for this release:
|
|
||||||
|
|
||||||
- **+100** closed issues (for a TOTAL of **+1340**!)
|
|
||||||
- **+350** commits since previous RELEASE (for a TOTAL of **+6350**!)
|
|
||||||
- **+25** functions ADDED to raylib API (for a TOTAL of **516**!)
|
|
||||||
- **+40** functions REVIEWED/REDESIGNED
|
|
||||||
- **+40** new contributors (for a TOTAL of **405**!)
|
|
||||||
|
|
||||||
Highlights for `raylib 4.5`:
|
|
||||||
|
|
||||||
- **`NEW` Improved ANGLE support on Desktop platforms**: Support for OpenGL ES 2.0 on Desktop platforms (Windows, Linux, macOS) has been reviewed by @wtnbgo GitHub user. Now raylib can be compiled on desktop for OpenGL ES 2.0 and linked against [`ANGLE`](https://github.com/google/angle). This _small_ addition open the door to building raylib for all **ANGLE supported backends: Direct3D 11, Vulkan and Metal**. Please note that this new feature is still experimental and requires further testing!
|
|
||||||
|
|
||||||
- **`NEW` Camera module**: A brand new implementation from scratch for `rcamera` module, contributed by @Crydsch GitHub user! **New camera system is simpler, more flexible, more granular and more extendable**. Specific camera math transformations (movement/rotation) have been moved to individual functions, exposing them to users if required. Global state has been removed from the module and standalone usage has been greatly improved; now `rcamera.h` single-file header-only library can be used externally, independently of raylib. A new `UpdateCameraPro()` function has been added to address input-dependency of `UpdateCamera()`, now advanced users have **full control over camera inputs and movement/rotation speeds**!
|
|
||||||
|
|
||||||
- **`NEW` Support for M3D models and M3D/GLTF animations**: 3d models animations support has been a limited aspect of raylib for long time, some versions ago IQM animations were supported but raylib 4.5 also adds support for the brand new [M3D file format](https://bztsrc.gitlab.io/model3d/), including animations and the long expected support for **GLTF animations**! The new M3D file format is **simple, portable, feature complete, extensible and open source**. It also provides a complete set of tools to export/visualize M3D models from/to Blender! Now raylib supports up to **3 model file-formats with animations**: `IQM`, `GLTF` and `M3D`.
|
|
||||||
|
|
||||||
- **`NEW` Support QOA audio format (import/export)**: Just a couple of months ago the new [QOA file format](https://qoaformat.org/) was published, a very simple, portable and open source quite-ok-audio file format. raylib already supports it, added to `raudio` module and including audio loading from file, loading from memory, streaming from file, streaming from memory and **exporting to QOA** audio format. **Because simplicity really matters to raylib!**
|
|
||||||
|
|
||||||
- **`NEW` Module for compressed textures loading**: [`rl_gputex`](https://github.com/raysan5/raylib/blob/master/src/external/rltexgpu.h), a portable single-file header-only small library to load compressed texture file-formats (DDS, PKM, KTX, PVR, ASTC). Provided functionality is not new to raylib but it was part of the raylib `rtextures` module, now it has been moved into a separate self-contained library, **improving portability**. Note that this module is only intended to **load compressed data from files, ready to be uploaded to GPU**, no compression/decompression functionality is provided. This change is a first step towards a better modularization of raylib library.
|
|
||||||
|
|
||||||
- **Reviewed `rlgl` module for automatic limits checking**: Again, [`rlgl`](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) has been reviewed to simplify usage. Now users do not need to worry about reaching the internal render-batch limits when they send their triangles to draw 2d/3d, `rlgl` manages it automatically! This change allows a **great simplification for other modules** like `rshapes`, `rtextures` and `rmodels` that do not need to worry about bufffer overflows and can just define as many vertex as desired!
|
|
||||||
|
|
||||||
- **Reviewed `rshapes` module to minimize the rlgl dependency**: Now `rshapes` 2d shapes drawing functions **only depend on 6 low-level functions**: `rlBegin()`, `rlEnd()`, `rlVertex3f()`, `rlTexCoord2f()`, `rlNormal3f()`, `rlSetTexture()`. With only those pseudo-OpenGl 1.1 minimal functionality, everything can be drawn! This improvement converts `rshapes` module in a **self-contained, portable shapes-drawing library that can be used independently of raylib**, as far as entry points for those 6 functions are provided by the user. It even allows to be used for software rendering, with the proper backend!
|
|
||||||
|
|
||||||
- **Added data structures validation functions**: Multiple functions have been added by @RobLoach GitHub user to ease the validation of raylib data structures: `IsImageReady()`, `IsTextureReady()`, `IsSoundReady()`... Now users have a simple mechanism to **make sure data has been correctly loaded**, instead of checking internal structure values by themselves.
|
|
||||||
|
|
||||||
As usual, those are only some highlights but there is much more! New image generators, new color transformation functionality, improved blending support for color/alpha, etc... Make sure to check raylib [CHANGELOG]([CHANGELOG](https://github.com/raysan5/raylib/blob/master/CHANGELOG)) for a detailed list of changes! Please, note that all breaking changes have been flagged with a `WARNING` in the CHANGELOG, specially useful for binding creators!
|
|
||||||
|
|
||||||
**raylib keeps improving one more version** with a special focus on maintainability and sustainability. Always working towards making the library more **simple and easy-to-use**.
|
|
||||||
|
|
||||||
Let's keep **enjoying games/tools/graphics programming!** :)
|
|
||||||
|
|
||||||
notes on raylib 5.0
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
It's been **7 months** since latest raylib release and **10 years** since raylib 1.0 was officially released... what an adventure! In the last 10 years raylib has improved a lot, new functions have been added, many new features and improvements implemented, up to **500 contributors** have helped to shape the library as it is today. `raylib 5.0` is the final result of all this incredible amount of work and dedication. Here is the summary with the key features and additions of this NEW major version of raylib.
|
|
||||||
|
|
||||||
Some numbers for this release:
|
|
||||||
|
|
||||||
- **+200** closed issues (for a TOTAL of **+1540**!)
|
|
||||||
- **+550** commits since previous RELEASE (for a TOTAL of **+6950**!)
|
|
||||||
- **+35** functions ADDED to raylib API (for a TOTAL of **552**!)
|
|
||||||
- **+60** functions REVIEWED/REDESIGNED
|
|
||||||
- **+80** new contributors (for a TOTAL of **+500**!)
|
|
||||||
|
|
||||||
Highlights for `raylib 5.0`:
|
|
||||||
|
|
||||||
- **`rcore` module platform-split**: Probably the biggest raylib redesign in the last 10 years. raylib started as a library targeting 3 desktop platforms: `Windows`, `Linux` and `macOS` (thanks to `GLFW` underlying library) but with the years support for several new platforms has been added (`Android`, `Web`, `Rapsberry Pi`, `RPI native`...); lot of the platform code was shared so the logic was all together on `rcore.c` module, separated by compilation flags. This approach was very handy but also made it very difficult to support new platforms and specially painful for contributors not familiar with the module, navigating +8000 lines of code in a single file. A big redesign was really needed but the amount of work required was humungous and quite scary for a solo-developer like me, moreover considering that everything was working and the chances to break things were really high. Fortunately, some contributors were ready for the task (@ubkp, @michaelfiber, @Bigfoot71) and thanks to their initiative and super-hard work, the `rcore` [platform split](https://github.com/raysan5/raylib/blob/master/src/platforms) has been possible! This new raylib architecture greatly improves the platforms maintenance but also greatly simplifies the addition of new platforms. A [`platforms/rcore_template.c`](https://github.com/raysan5/raylib/blob/master/src/platforms/rcore_template.c) file is provided with the required structure and functions to be filled for the addition of new platforms, actually it has been simplified to mostly filling some pre-defined functions: `InitPlatform()`, `ClosePlatform`, `PollInputEvents`... Undoubtedly, **this redesign opens the doors to a new era for raylib**, letting the users to plug new platforms as desired.
|
|
||||||
|
|
||||||
- **`NEW` Platform backend supported: SDL**: Thanks to the new `rcore` platform-split, the addition of new platforms/backends to raylib has been greatly simplified. As a proof of concept, [`SDL2`](https://libsdl.org/) platform backend has been added to raylib as an alternative for `GLFW` library for desktop builds: [`platforms/rcore_desktop_sdl`](https://github.com/raysan5/raylib/blob/master/src/platforms/rcore_desktop_sdl.c). Lot of work has been put to provide exactly the same features as the other platforms and carefully test the new implementation. Now `SDL2` fans can use this new backend, just providing the required include libraries on compilation and linkage (not included in raylib, like `GLFW`). `SDL` backend support also **eases the process of supporting a wider range of platforms** that already support `SDL`.
|
|
||||||
|
|
||||||
- **`NEW` Platform backend supported: Nintendo Switch (closed source)**: The addition of the `SDL` backend was quite a challenge but to really verify the robustness and ease of the new platform plugin system, adding support for a console was a more demanding adventure. Surprisingly, only two days of work were required to add support for `Nintendo Switch` to raylib! Implementation result showed an outstanding level of simplicity, with a **self-contained module** (`rcore_swith.cpp`) supporting graphics and inputs. Unfortunately this module can not be open-sourced due to licensing restrictions.
|
|
||||||
|
|
||||||
- **`NEW` Splines drawing and evaluation API**: A complete set of functions has been added to [draw](https://github.com/raysan5/raylib/blob/master/src/raylib.h#L1258) and [evaluate](https://github.com/raysan5/raylib/blob/master/src/raylib.h#L1270) different types of splines: `Linear`, `Basis`, `Catmull-Rom`, `Quadratic Bezier` and `Cubic Bezier`. Splines are extremely useful for game development (describe paths, control NPC movement...) but they can also be very useful on tools development (node-conections, elements-movement, 3d modelling, animations...). This was the missing feature on the raylib [`rshapes`](https://github.com/raysan5/raylib/blob/master/src/rshapes.h) module to make it complete! Note that `rshapes` module can also be used independently of raylib just providing the **only 6 functions required for vertex definition and drawing**.
|
|
||||||
|
|
||||||
- **`NEW` Pseudo-random numbers generator: rprand**: After several years of users asking for this missing piece, a brand new pseudo-random generator module has been added to raylib. [`rprand`](https://github.com/raysan5/raylib/blob/master/src/external/rprand.h) implements the `Xoshiro128**` algorithm combined with `SplitMix64`, specially suited for **fast software pseudo-random numbers generation**. The module also implies some useful functions to generate non-repetitive random numbers sequences, functionality exposed by raylib. usage of this module can be controlled by a compilation flag, in case the default libc `rand()` function was preferred.
|
|
||||||
|
|
||||||
- **`NEW` Automation Events System API**: This new system was first added in `raylib 4.0` as an experimental feature but it was a bit clumsy and there was no API exposed to users. For the new `raylib 5.0` the system has been redesigned and [proper API](https://github.com/raysan5/raylib/blob/master/src/raylib.h#L1135) added for the users. With this new events automation system, users can **record input events for later replay**, very useful feature for testing automation, tutorials generation, assisted game playing, in-game cinematics, speedruns saving or even AI assited game playing!
|
|
||||||
|
|
||||||
- **`NEW` [`raygui 4.0`](https://github.com/raysan5/raygui)**: The **official raylib immediate-mode gui library** designed for tools development has been updated to a new version, aligned with raylib 5.0. This new version is a complete redesign of raygui to unify all controls structure and usage, now all controls have the same function signature!. `raygui` has been battle-tested with the development of +12 published tools in the last few years. The tools can be seen and used for free in the [raylib technologies tools page](https://raylibtech.itch.io/). Worth mentioning that several of those **tools have been open sourced** for anyone to use, compile, contribute or learn how the code works.
|
|
||||||
|
|
||||||
- **`NEW` raylib web examples functionality**: Beside the addition of several new examples, the web examples functionality has been improved. Examples have been organized by [complexity level](https://www.raylib.com/examples.html), marked with one star for simple examples and up to 4 stars for more complex ones. A new option has been added to web to allow to **filter examples by function-name** usage, to ease the learning process when looking for an usage example of some function. Finally, **open-graph metadata** information has been added to all examples individual webpages, improving a the visuals and information when sharing those webpages on social networks, sharing the example screenshot and details.
|
|
||||||
|
|
||||||
As always, those are only some highlights of the new `raylib 5.0` but there is many more improvements! Support for 16-bit HDR images/textures, SVG loading and scaling support, new OpenGL ES 3.0 graphic backend, new image gradient generators, sound alias loading, improved 3d models loading, multiple optimizations, new bindings, CodeQL integration and much more!
|
|
||||||
|
|
||||||
Make sure to check raylib [CHANGELOG]([CHANGELOG](https://github.com/raysan5/raylib/blob/master/CHANGELOG)) for a detailed list of changes!
|
|
||||||
|
|
||||||
Undoubtedly, this is the **biggest raylib update in 10 years**. Many new features and improvements with a special focus on maintainability and long-term sustainability. **Undoubtedly, this is the raylib of the future**.
|
|
||||||
|
|
||||||
**Enjoy programming!** :)
|
|
||||||
|
|
||||||
notes on raylib 5.5
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
One year after raylib 5.0 release, arrives `raylib 5.5`, the next big revision of the library. It's been **11 years** since raylib 1.0 release and in all this time it has never stopped growing and improving. With an outstanding number of new contributors and improvements, it's, again, the biggest raylib release to date.
|
|
||||||
|
|
||||||
Some numbers for this release:
|
|
||||||
|
|
||||||
- **+270** closed issues (for a TOTAL of **+1810**!)
|
|
||||||
- **+800** commits since previous RELEASE (for a TOTAL of **+7770**!)
|
|
||||||
- **+30** functions ADDED to raylib API (for a TOTAL of **580**!)
|
|
||||||
- **+110** functions REVIEWED with fixes and improvements
|
|
||||||
- **+140** new contributors (for a TOTAL of **+640**!)
|
|
||||||
|
|
||||||
Highlights for `raylib 5.5`:
|
|
||||||
|
|
||||||
- **`NEW` raylib pre-configured Windows package**: The new raylib **portable and self-contained Windows package** for `raylib 5.5`, intended for nobel devs that start in programming world, comes with one big addition: support for **C code building for Web platform with one-single-mouse-click!** For the last 10 years, the pre-configured raylib Windows package allowed to edit simple C projects on Notepad++ and easely compile Windows executables with an automatic script; this new release adds the possibility to compile the same C projects for Web platform with a simple mouse click. This new addition **greatly simplifies C to WebAssembly project building for new users**. The `raylib Windows Installer` package can be downloaded for free from [raylib on itch.io](https://raysan5.itch.io/raylib).
|
|
||||||
|
|
||||||
- **`NEW` raylib project creator tool**: A brand new tool developed to help raylib users to **setup new projects in a professional way**. `raylib project creator` generates a complete project structure with **multiple build systems ready-to-use** and **GitHub CI/CD actions pre-configured**. It only requires providing some C files and basic project parameters! The tools is [free and open-source](https://raysan5.itch.io/raylib-project-creator), and [it can be used online](https://raysan5.itch.io/raylib-project-creator)!.
|
|
||||||
|
|
||||||
- **`NEW` Platform backend supported: RGFW**: Thanks to the `rcore` platform-split implemented in `raylib 5.0`, **adding new platforms backends has been greatly simplified**, new backends can be added using provided template, self-contained in a single C module, completely portable. A new platform backend has been added: [`RGFW`](https://github.com/raysan5/raylib/blob/master/src/platforms/rcore_desktop_rgfw.c). `RGFW` is a **new single-file header-only portable library** ([`RGFW.h`](https://github.com/ColleagueRiley/RGFW)) intended for platform-functionality management (windowing and inputs); in this case for **desktop platforms** (Windows, Linux, macOS) but also for **Web platform**. It adds a new alternative to the already existing `GLFW` and `SDL` platform backends.
|
|
||||||
|
|
||||||
- **`NEW` Platform backend version supported: SDL3**: Previous `raylib 5.0` added support for `SDL2` library, and `raylib 5.5` not only improves SDL2 functionality, with several issues reviewed, but also adds support for the recently released big SDL update in years: [`SDL3`](https://wiki.libsdl.org/SDL3/FrontPage). Now users can **select at compile time the desired SDL version to use**, increasing the number of potential platforms supported in the future!
|
|
||||||
|
|
||||||
- **`NEW` Retro-console platforms supported: Dreamcast, N64, PSP, PSVita, PS4**: Thanks to the platform-split on `raylib 5.0`, **supporting new platform backends is easier than ever!** Along the raylib `rlgl` module support for the `OpenGL 1.1` graphics API, it opened the door to [**multiple homebrew retro-consoles backend implementations!**](https://github.com/raylib4Consoles) It's amazing to see raylib running on +20 year old consoles like [Dreamcast](https://github.com/raylib4Consoles/raylib4Dreamcast), [PSP](https://github.com/raylib4Consoles/raylib4Psp) or [PSVita](https://github.com/psp2dev/raylib4Vita), considering the hardware constraints of those platforms and proves **raylib outstanding versability!** Those additional platforms can be found in separate repositories and have been created by the amazing programmer Antonio Jose Ramos Marquez (@psxdev).
|
|
||||||
|
|
||||||
- **`NEW` GPU Skinning support**: After lots of requests for this feature, it has been finally added to raylib thanks to the contributor Daniel Holden (@orangeduck), probably the developer that has further pushed models animations with raylib, developing two amazing tools to visualize and test animations: [GenoView](https://github.com/orangeduck/GenoView) and [BVHView](https://github.com/orangeduck/BVHView). Adding GPU skinning was a tricky feature, considering it had to be **available for all raylib supported platforms**, including limited ones like Raspberry Pi with OpenGL ES 2.0, where some advance OpenGL features are not available (UBO, SSBO, Transform Feedback) but a multi-platform solution was found to make it possible. A new example, [`models_gpu_skinning`](https://github.com/raysan5/raylib/blob/master/examples/models/models_gpu_skinning.c) has been added to illustrate this new functionality. As an extra, previous existing CPU animation system has been greatly improved, multiplying performance by a factor (simplifiying required maths).
|
|
||||||
|
|
||||||
- **`NEW` [`raymath`](https://github.com/raysan5/raylib/blob/master/src/raymath.h) C++ operators**: After several requested for this feature, C++ math operators for `Vector2`, `Vector3`, `Vector4`, `Quaternion` and `Matrix` has been added to `raymath` as an extension to current implementation. Despite being only available for C++ because C does not support it, these operators **simplify C++ code when doing math operations**.
|
|
||||||
|
|
||||||
Beside those new big features, `raylib 5.5` comes with MANY other improvements:
|
|
||||||
|
|
||||||
- Normals support on batching system
|
|
||||||
- Clipboard images reading support
|
|
||||||
- CRC32/MD5/SHA1 hash computation
|
|
||||||
- Gamepad vibration support
|
|
||||||
- Improved font loading (no GPU required) with BDF fonts support
|
|
||||||
- Time-based camera movement
|
|
||||||
- Improved GLTF animations loading
|
|
||||||
|
|
||||||
...and [much much more](https://github.com/raysan5/raylib/blob/master/CHANGELOG), including **many functions reviews and new functions added!**
|
|
||||||
|
|
||||||
Make sure to check raylib [CHANGELOG](https://github.com/raysan5/raylib/blob/master/CHANGELOG) for a detailed list of changes!
|
|
||||||
|
|
||||||
To end with, I want to **thank all the contributors (+640!**) that along the years have **greatly improved raylib** and pushed it further and better day after day. Thanks to all of them, raylib is the amazing library it is today.
|
|
||||||
|
|
||||||
Last but not least, I want to thank **raylib sponsors and all the raylib community** for their support and continuous engagement with the library, creating and sharing amazing raylib projects on a daily basis. **Thanks for making raylib a great platform to enjoy games/tools/graphic programming!**
|
|
||||||
|
|
||||||
**After 11 years of development, `raylib 5.5` is the best raylib ever.**
|
|
||||||
|
|
||||||
**Enjoy programming with raylib!** :)
|
|
||||||
|
|
||||||
notes on raylib 6.0
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
A new `raylib` release is finally ready and, again, this is the **biggest `raylib` release ever**! Thanks to the support of many amazing contributors this release comes packed with many new features and improvements, also thanks to the financial support of [NLnet](https://nlnet.nl/) and the [NGI Zero Commond Fund](https://nlnet.nl/NGI0/) that allow me to work on this project mostly fulltime for the past few months.
|
|
||||||
|
|
||||||
Some astonishing numbers for this release:
|
|
||||||
|
|
||||||
- **+330** closed issues (for a TOTAL of **+2150**!)
|
|
||||||
- **+2000** commits since previous RELEASE (for a TOTAL of **+9760**!)
|
|
||||||
- **+20** new functions ADDED to raylib API (for a TOTAL of **600**!)
|
|
||||||
- **+70** new examples to learn from (for a TOTAL of **+215**!)
|
|
||||||
- **+210** new contributors (for a TOTAL of **+850**!)
|
|
||||||
|
|
||||||
Highlights for `raylib 6.0`:
|
|
||||||
|
|
||||||
- **`NEW` Software Renderer - [`rlsw`](https://github.com/raysan5/raylib/blob/master/src/external/rlsw.h)**: The biggest addition of this new release. A new software renderer backend, that allows raylib to run purely on CPU, with no neeed for a GPU. It finally closes the circle of my search for a portable self-contained, with **no-external-dependencies**, graphics library, able to run on any device providing some CPU-power and some RAM memory. It has been possible thanks to the amazing work of **Le Juez Victor** ([@Bigfoot71](https://github.com/Bigfoot71)), who created [`rlsw`](https://github.com/raysan5/raylib/blob/master/src/external/rlsw.h), a single-file header-only library implementing OpenGL 1.1+ specification, tailored to fit into raylib [`rlgl`](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) OpenGL wrapper, and allowing to run raylib seamlessly over CPU with **no code changes required on user side**. As expected, software rendering is slower than hardware-accelerated rendering but it is still fast enough to run basic application at 30-60 fps. Actually, it already proved it usefulness on a new [raylib port for ESP32](https://components.espressif.com/components/georgik/raylib/versions/6.0.0/readme) microcontroller by Espressif, useful for industrial applications, and opens the door to the upcoming RISC-V powered devices that start arriving to the marked, and many times come with no GPU. Along the new software renderer, some of the existing platform backends have been adapted to support it (SDL, RGFW, DRM) and also **new platforms backends have been created** to accomodate it (Win32, Emscripten), incluing a new `PLATFORM_MEMORY`, that allows direct rendering to a memory framebuffer.
|
|
||||||
|
|
||||||
- **`NEW` Platform backend: Memory - [`rcore_memory`](https://github.com/raysan5/raylib/blob/master/src/platforms/rcore_memory.c)**: This new platform has been added along the **software renderer** backend, allowing 2d and 3d rendering over a **platform-agnostic memory framebuffer**, it can run headless and output frames can be directly exported to images. This new backend could also be useful for graphics rendering on servers or process images directly using the memory buffer.
|
|
||||||
|
|
||||||
- **`NEW` Platform backend: Win32 - [`rcore_desktop_win32`](https://github.com/raysan5/raylib/blob/master/src/platforms/rcore_desktop_win32.c)**: A new **Windows platform backend** and the first step towards a potential replacement/alternative to the platform libraries currently used by raylib (GLFW/SDL/RGFW). This backend follows same API template structure than the other raylib backends, but directly implementing Win32 API calls. It allows initializing OpenGL GPU-accelerated windows and also GDI based windows, useful for the software renderer backend. This new backend approach, following a common template-structure and separating the platform logic by specific OS/Windowing system, will simplify code, improve maintenance, readability and portability for raylib, setting some bases for the future. *NOTE: This backend is new and it could require further testing, use it as an experimental backend for now.*
|
|
||||||
|
|
||||||
- **`NEW` Platform backend: Emscripten - [`rcore_web_emscripten`](https://github.com/raysan5/raylib/blob/master/src/platforms/rcore_web_emscripten.c)**: In the same line as Win32 backend, this new web backend moves away from `libglfw.js` and **directly implements Emscripten/JS functionality**, with **no other dependencies**, adding support for the new software renderer to draw directly on a **non-accelerated 2d canvas** but also supporting a WebGL-hardware-accelerated canvas when required. *NOTE: This backend is new and it could require further testing, use it as an experimental backend for now.*
|
|
||||||
|
|
||||||
- **`REDESIGNED` Fullscreen modes and High-DPI content scaling**: After many years and many related issues, the full-screen and high-dpi content scaling support has been **completely redesigned** from scratch. New design prioritizes **borderless fullscreen modes** and automatically detects current monitor content scaling configuration to scale window and framebuffer accordingly when required. Still, High-DPI support must be requested by user if desired enabling `FLAG_WINDOW_HIGHDPI` on window creation. This new system has been carefully tested on Windows, Linux (X11, Wayland), macOS with multiple monitors and multiple resolutions, including 4K monitors.
|
|
||||||
|
|
||||||
- **`REDESIGNED` Skeletal Animation System**: A new animation system for 3d models has been created to support animation blending, between single frames but also between differents frames on different animations, to allow easy **timed transitions** between animations. This redesign implied reviewing several raylib structures to better accomodate animation data: `Model`, `ModelSkeleton`, `ModelAnimation`, but the API was simplified and support for GPU-skinning was improved with multiple optimizations.
|
|
||||||
|
|
||||||
- **`REDESIGNED` Build Config System - [`config.h`](https://github.com/raysan5/raylib/blob/master/src/config.h)**: raylib allows lot of customization for specific needs (i.e. disabling modules not needed for specific applications like rmodels or raudio) but previous implementation did not allow easely disabling some features from **custom build systems**. New design not only allows disabling features with simple `-DSUPPORT_FILEFORMAT_OBJ=0` on building command-line but also the full system has been reviewed, removing useless flags and exposing new ones.
|
|
||||||
|
|
||||||
- **`NEW` File System API**: Along the years, multiple filesystem functions have been added to raylib API as required but it felt somewhat inconsistent with some pieces missing. In this new release, the full filesystem API has beeen reviewed and reorganized, compiling all the functionality single module: [rcore](https://github.com/raysan5/raylib/blob/master/src/raylib.h#L1126), consequently `utils` module has been removed and build system has been simplified even more; **only 6-7 modules (.c) need to be compiled containing the full raylib library**. This new filesystem API will allow raylib to be used on the creation of custom build systems, as already demostrated with the new `rexm` tool for examples management. At the moment raylib includes **+40 file system management functions**, here a list with the new functions added:
|
|
||||||
```c
|
|
||||||
int FileRename(const char *fileName, const char *fileRename); // Rename file (if exists)
|
|
||||||
int FileRemove(const char *fileName); // Remove file (if exists)
|
|
||||||
int FileCopy(const char *srcPath, const char *dstPath); // Copy file from one path to another, dstPath created if it doesn't exist
|
|
||||||
int FileMove(const char *srcPath, const char *dstPath); // Move file from one directory to another, dstPath created if it doesn't exist
|
|
||||||
int FileTextReplace(const char *fileName, const char *search, const char *replacement); // Replace text in an existing file
|
|
||||||
int FileTextFindIndex(const char *fileName, const char *search); // Find text in existing file
|
|
||||||
```
|
|
||||||
|
|
||||||
- **`NEW` Text Management API**: Along with the new file system functionality, a new set of text management functions has been added, also very useful for text procesing and also used in custom build systems creation using raylib. At the moment raylib includes **+30 text management functions**, here a list with the new functions added:
|
|
||||||
```c
|
|
||||||
char **LoadTextLines(const char *text, int *count); // Load text as separate lines ('\n')
|
|
||||||
void UnloadTextLines(char **text, int lineCount); // Unload text lines
|
|
||||||
const char *TextRemoveSpaces(const char *text); // Remove text spaces, concat words
|
|
||||||
char *GetTextBetween(const char *text, const char *begin, const char *end); // Get text between two strings
|
|
||||||
char *TextReplace(const char *text, const char *search, const char *replacement); // Replace text string with new string
|
|
||||||
char *TextReplaceAlloc(const char *text, const char *search, const char *replacement); // Replace text string with new string, memory must be MemFree()
|
|
||||||
char *TextReplaceBetween(const char *text, const char *begin, const char *end, const char *replacement); // Replace text between two specific strings
|
|
||||||
char *TextReplaceBetweenAlloc(const char *text, const char *begin, const char *end, const char *replacement); // Replace text between two specific strings, memory must be MemFree()
|
|
||||||
char *TextInsertAlloc(const char *text, const char *insert, int position); // Insert text in a defined byte position, memory must be MemFree()
|
|
||||||
```
|
|
||||||
|
|
||||||
- **`NEW` tool: raylib examples manager - [rexm](https://github.com/raysan5/raylib/tree/master/tools/rexm)**: raylib examples collection is huge, with **more than 200 examples** it was quite difficult to manage: adding, removing, renaming examples was a very costly process involving many files to be modified (including build systems), also the examples did not follow a common header convention neither a structure conventions. For that reason, a new support tool has been created: **rexm**, a raylib examples manager that allows to easely add/remove/rename examples, automatically fix inconsistencies and even **building and automated testing** on multiple platforms.
|
|
||||||
```
|
|
||||||
USAGE:
|
|
||||||
> rexm <command> <example_name> [<example_rename>]
|
|
||||||
|
|
||||||
COMMANDS:
|
|
||||||
create <new_example_name> : Creates an empty example, from internal template
|
|
||||||
add <example_name> : Add existing example to collection
|
|
||||||
rename <old_examples_name> <new_example_name> : Rename an existing example
|
|
||||||
remove <example_name> : Remove an existing example from collection
|
|
||||||
build <example_name> : Build example for Desktop and Web platforms
|
|
||||||
test <example_name> : Build and Test example for Desktop and Web platforms
|
|
||||||
validate : Validate examples collection, generates report
|
|
||||||
update : Validate and update examples collection, generates report
|
|
||||||
```
|
|
||||||
|
|
||||||
- **`NEW` +70 new examples**: Thanks to `rexm` and the simplification on examples management, this new raylib release includes +70 new examples to learn from, most of them contributed by community. Multiple examples have also been renamed for consistency and all examples header and structure have been reviewed and unified.
|
|
||||||
|
|
||||||
Make sure to check raylib [CHANGELOG](https://github.com/raysan5/raylib/blob/master/CHANGELOG) for a detailed list of changes!
|
|
||||||
|
|
||||||
I want to **thank all the contributors (+850!**) that along the years have **greatly improved raylib** and pushed it further and better day after day. And **many thanks to raylib community and all raylib users** for supporting the library along those many years.
|
|
||||||
|
|
||||||
Finally, I want to thank [puffer.ai](https://puffer.ai/) and [comma.ai](https://comma.ai/) for **using raylib and supporting the project** as platinum sponsors, along many others individuals that have been sponsoring raylib along the years. Thanks to all of you for allowing me to keep working on this library!
|
|
||||||
|
|
||||||
**After +12 years of development, `raylib 6.0` is today one of the bests libraries to enjoy games/tools/graphics programming!**
|
|
||||||
|
|
||||||
**Enjoy graphics programming with raylib!** :)
|
|
||||||
16
LICENSE
|
|
@ -1,16 +0,0 @@
|
||||||
Copyright (c) 2013-2026 Ramon Santamaria (@raysan5)
|
|
||||||
|
|
||||||
This software is provided "as-is", without any express or implied warranty. In no event
|
|
||||||
will the authors be held liable for any damages arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, including commercial
|
|
||||||
applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you
|
|
||||||
wrote the original software. If you use this software in a product, an acknowledgment
|
|
||||||
in the product documentation would be appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
|
||||||
as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
|
||||||
381
LICENSE.md
Normal file
|
|
@ -0,0 +1,381 @@
|
||||||
|
license
|
||||||
|
=======
|
||||||
|
|
||||||
|
source code
|
||||||
|
-----------
|
||||||
|
|
||||||
|
raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||||
|
BSD-like license that allows static linking with closed source software:
|
||||||
|
|
||||||
|
Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
|
||||||
|
|
||||||
|
This software is provided "as-is", without any express or implied warranty. In no event
|
||||||
|
will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose, including commercial
|
||||||
|
applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you
|
||||||
|
wrote the original software. If you use this software in a product, an acknowledgment
|
||||||
|
in the product documentation would be appreciated but is not required.
|
||||||
|
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||||
|
as being the original software.
|
||||||
|
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
fonts
|
||||||
|
------
|
||||||
|
|
||||||
|
All rBMF fonts provided with raylib are free to use (freeware) and have been designed by the following people:
|
||||||
|
|
||||||
|
* Alpha Beta - Brian Kent (AEnigma)
|
||||||
|
* Setback - Brian Kent (AEnigma)
|
||||||
|
* Jupiter Crash - Brian Kent (AEnigma)
|
||||||
|
* Alagard - Hewett Tsoi
|
||||||
|
* Romulus - Hewett Tsoi
|
||||||
|
* Mecha - Captain Falcon
|
||||||
|
* PixelPlay - Aleksander Shevchuk
|
||||||
|
* PixAntiqua - Gerhard Großmann
|
||||||
|
|
||||||
|
3d models
|
||||||
|
---------
|
||||||
|
|
||||||
|
dwarf 3d model used in examples is created by David Moreno and licensed as Creative Commons Attribution-NonCommercial 3.0
|
||||||
|
|
||||||
|
Full license provided below:
|
||||||
|
|
||||||
|
Creative Commons Legal Code
|
||||||
|
|
||||||
|
Attribution-NonCommercial 3.0 Unported
|
||||||
|
|
||||||
|
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||||
|
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
|
||||||
|
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||||
|
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||||
|
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
|
||||||
|
DAMAGES RESULTING FROM ITS USE.
|
||||||
|
|
||||||
|
License
|
||||||
|
|
||||||
|
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
|
||||||
|
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
|
||||||
|
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
|
||||||
|
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
|
||||||
|
|
||||||
|
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
|
||||||
|
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
|
||||||
|
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
|
||||||
|
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
|
||||||
|
CONDITIONS.
|
||||||
|
|
||||||
|
1. Definitions
|
||||||
|
|
||||||
|
a. "Adaptation" means a work based upon the Work, or upon the Work and
|
||||||
|
other pre-existing works, such as a translation, adaptation,
|
||||||
|
derivative work, arrangement of music or other alterations of a
|
||||||
|
literary or artistic work, or phonogram or performance and includes
|
||||||
|
cinematographic adaptations or any other form in which the Work may be
|
||||||
|
recast, transformed, or adapted including in any form recognizably
|
||||||
|
derived from the original, except that a work that constitutes a
|
||||||
|
Collection will not be considered an Adaptation for the purpose of
|
||||||
|
this License. For the avoidance of doubt, where the Work is a musical
|
||||||
|
work, performance or phonogram, the synchronization of the Work in
|
||||||
|
timed-relation with a moving image ("synching") will be considered an
|
||||||
|
Adaptation for the purpose of this License.
|
||||||
|
b. "Collection" means a collection of literary or artistic works, such as
|
||||||
|
encyclopedias and anthologies, or performances, phonograms or
|
||||||
|
broadcasts, or other works or subject matter other than works listed
|
||||||
|
in Section 1(f) below, which, by reason of the selection and
|
||||||
|
arrangement of their contents, constitute intellectual creations, in
|
||||||
|
which the Work is included in its entirety in unmodified form along
|
||||||
|
with one or more other contributions, each constituting separate and
|
||||||
|
independent works in themselves, which together are assembled into a
|
||||||
|
collective whole. A work that constitutes a Collection will not be
|
||||||
|
considered an Adaptation (as defined above) for the purposes of this
|
||||||
|
License.
|
||||||
|
c. "Distribute" means to make available to the public the original and
|
||||||
|
copies of the Work or Adaptation, as appropriate, through sale or
|
||||||
|
other transfer of ownership.
|
||||||
|
d. "Licensor" means the individual, individuals, entity or entities that
|
||||||
|
offer(s) the Work under the terms of this License.
|
||||||
|
e. "Original Author" means, in the case of a literary or artistic work,
|
||||||
|
the individual, individuals, entity or entities who created the Work
|
||||||
|
or if no individual or entity can be identified, the publisher; and in
|
||||||
|
addition (i) in the case of a performance the actors, singers,
|
||||||
|
musicians, dancers, and other persons who act, sing, deliver, declaim,
|
||||||
|
play in, interpret or otherwise perform literary or artistic works or
|
||||||
|
expressions of folklore; (ii) in the case of a phonogram the producer
|
||||||
|
being the person or legal entity who first fixes the sounds of a
|
||||||
|
performance or other sounds; and, (iii) in the case of broadcasts, the
|
||||||
|
organization that transmits the broadcast.
|
||||||
|
f. "Work" means the literary and/or artistic work offered under the terms
|
||||||
|
of this License including without limitation any production in the
|
||||||
|
literary, scientific and artistic domain, whatever may be the mode or
|
||||||
|
form of its expression including digital form, such as a book,
|
||||||
|
pamphlet and other writing; a lecture, address, sermon or other work
|
||||||
|
of the same nature; a dramatic or dramatico-musical work; a
|
||||||
|
choreographic work or entertainment in dumb show; a musical
|
||||||
|
composition with or without words; a cinematographic work to which are
|
||||||
|
assimilated works expressed by a process analogous to cinematography;
|
||||||
|
a work of drawing, painting, architecture, sculpture, engraving or
|
||||||
|
lithography; a photographic work to which are assimilated works
|
||||||
|
expressed by a process analogous to photography; a work of applied
|
||||||
|
art; an illustration, map, plan, sketch or three-dimensional work
|
||||||
|
relative to geography, topography, architecture or science; a
|
||||||
|
performance; a broadcast; a phonogram; a compilation of data to the
|
||||||
|
extent it is protected as a copyrightable work; or a work performed by
|
||||||
|
a variety or circus performer to the extent it is not otherwise
|
||||||
|
considered a literary or artistic work.
|
||||||
|
g. "You" means an individual or entity exercising rights under this
|
||||||
|
License who has not previously violated the terms of this License with
|
||||||
|
respect to the Work, or who has received express permission from the
|
||||||
|
Licensor to exercise rights under this License despite a previous
|
||||||
|
violation.
|
||||||
|
h. "Publicly Perform" means to perform public recitations of the Work and
|
||||||
|
to communicate to the public those public recitations, by any means or
|
||||||
|
process, including by wire or wireless means or public digital
|
||||||
|
performances; to make available to the public Works in such a way that
|
||||||
|
members of the public may access these Works from a place and at a
|
||||||
|
place individually chosen by them; to perform the Work to the public
|
||||||
|
by any means or process and the communication to the public of the
|
||||||
|
performances of the Work, including by public digital performance; to
|
||||||
|
broadcast and rebroadcast the Work by any means including signs,
|
||||||
|
sounds or images.
|
||||||
|
i. "Reproduce" means to make copies of the Work by any means including
|
||||||
|
without limitation by sound or visual recordings and the right of
|
||||||
|
fixation and reproducing fixations of the Work, including storage of a
|
||||||
|
protected performance or phonogram in digital form or other electronic
|
||||||
|
medium.
|
||||||
|
|
||||||
|
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
|
||||||
|
limit, or restrict any uses free from copyright or rights arising from
|
||||||
|
limitations or exceptions that are provided for in connection with the
|
||||||
|
copyright protection under copyright law or other applicable laws.
|
||||||
|
|
||||||
|
3. License Grant. Subject to the terms and conditions of this License,
|
||||||
|
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
|
||||||
|
perpetual (for the duration of the applicable copyright) license to
|
||||||
|
exercise the rights in the Work as stated below:
|
||||||
|
|
||||||
|
a. to Reproduce the Work, to incorporate the Work into one or more
|
||||||
|
Collections, and to Reproduce the Work as incorporated in the
|
||||||
|
Collections;
|
||||||
|
b. to create and Reproduce Adaptations provided that any such Adaptation,
|
||||||
|
including any translation in any medium, takes reasonable steps to
|
||||||
|
clearly label, demarcate or otherwise identify that changes were made
|
||||||
|
to the original Work. For example, a translation could be marked "The
|
||||||
|
original work was translated from English to Spanish," or a
|
||||||
|
modification could indicate "The original work has been modified.";
|
||||||
|
c. to Distribute and Publicly Perform the Work including as incorporated
|
||||||
|
in Collections; and,
|
||||||
|
d. to Distribute and Publicly Perform Adaptations.
|
||||||
|
|
||||||
|
The above rights may be exercised in all media and formats whether now
|
||||||
|
known or hereafter devised. The above rights include the right to make
|
||||||
|
such modifications as are technically necessary to exercise the rights in
|
||||||
|
other media and formats. Subject to Section 8(f), all rights not expressly
|
||||||
|
granted by Licensor are hereby reserved, including but not limited to the
|
||||||
|
rights set forth in Section 4(d).
|
||||||
|
|
||||||
|
4. Restrictions. The license granted in Section 3 above is expressly made
|
||||||
|
subject to and limited by the following restrictions:
|
||||||
|
|
||||||
|
a. You may Distribute or Publicly Perform the Work only under the terms
|
||||||
|
of this License. You must include a copy of, or the Uniform Resource
|
||||||
|
Identifier (URI) for, this License with every copy of the Work You
|
||||||
|
Distribute or Publicly Perform. You may not offer or impose any terms
|
||||||
|
on the Work that restrict the terms of this License or the ability of
|
||||||
|
the recipient of the Work to exercise the rights granted to that
|
||||||
|
recipient under the terms of the License. You may not sublicense the
|
||||||
|
Work. You must keep intact all notices that refer to this License and
|
||||||
|
to the disclaimer of warranties with every copy of the Work You
|
||||||
|
Distribute or Publicly Perform. When You Distribute or Publicly
|
||||||
|
Perform the Work, You may not impose any effective technological
|
||||||
|
measures on the Work that restrict the ability of a recipient of the
|
||||||
|
Work from You to exercise the rights granted to that recipient under
|
||||||
|
the terms of the License. This Section 4(a) applies to the Work as
|
||||||
|
incorporated in a Collection, but this does not require the Collection
|
||||||
|
apart from the Work itself to be made subject to the terms of this
|
||||||
|
License. If You create a Collection, upon notice from any Licensor You
|
||||||
|
must, to the extent practicable, remove from the Collection any credit
|
||||||
|
as required by Section 4(c), as requested. If You create an
|
||||||
|
Adaptation, upon notice from any Licensor You must, to the extent
|
||||||
|
practicable, remove from the Adaptation any credit as required by
|
||||||
|
Section 4(c), as requested.
|
||||||
|
b. You may not exercise any of the rights granted to You in Section 3
|
||||||
|
above in any manner that is primarily intended for or directed toward
|
||||||
|
commercial advantage or private monetary compensation. The exchange of
|
||||||
|
the Work for other copyrighted works by means of digital file-sharing
|
||||||
|
or otherwise shall not be considered to be intended for or directed
|
||||||
|
toward commercial advantage or private monetary compensation, provided
|
||||||
|
there is no payment of any monetary compensation in connection with
|
||||||
|
the exchange of copyrighted works.
|
||||||
|
c. If You Distribute, or Publicly Perform the Work or any Adaptations or
|
||||||
|
Collections, You must, unless a request has been made pursuant to
|
||||||
|
Section 4(a), keep intact all copyright notices for the Work and
|
||||||
|
provide, reasonable to the medium or means You are utilizing: (i) the
|
||||||
|
name of the Original Author (or pseudonym, if applicable) if supplied,
|
||||||
|
and/or if the Original Author and/or Licensor designate another party
|
||||||
|
or parties (e.g., a sponsor institute, publishing entity, journal) for
|
||||||
|
attribution ("Attribution Parties") in Licensor's copyright notice,
|
||||||
|
terms of service or by other reasonable means, the name of such party
|
||||||
|
or parties; (ii) the title of the Work if supplied; (iii) to the
|
||||||
|
extent reasonably practicable, the URI, if any, that Licensor
|
||||||
|
specifies to be associated with the Work, unless such URI does not
|
||||||
|
refer to the copyright notice or licensing information for the Work;
|
||||||
|
and, (iv) consistent with Section 3(b), in the case of an Adaptation,
|
||||||
|
a credit identifying the use of the Work in the Adaptation (e.g.,
|
||||||
|
"French translation of the Work by Original Author," or "Screenplay
|
||||||
|
based on original Work by Original Author"). The credit required by
|
||||||
|
this Section 4(c) may be implemented in any reasonable manner;
|
||||||
|
provided, however, that in the case of a Adaptation or Collection, at
|
||||||
|
a minimum such credit will appear, if a credit for all contributing
|
||||||
|
authors of the Adaptation or Collection appears, then as part of these
|
||||||
|
credits and in a manner at least as prominent as the credits for the
|
||||||
|
other contributing authors. For the avoidance of doubt, You may only
|
||||||
|
use the credit required by this Section for the purpose of attribution
|
||||||
|
in the manner set out above and, by exercising Your rights under this
|
||||||
|
License, You may not implicitly or explicitly assert or imply any
|
||||||
|
connection with, sponsorship or endorsement by the Original Author,
|
||||||
|
Licensor and/or Attribution Parties, as appropriate, of You or Your
|
||||||
|
use of the Work, without the separate, express prior written
|
||||||
|
permission of the Original Author, Licensor and/or Attribution
|
||||||
|
Parties.
|
||||||
|
d. For the avoidance of doubt:
|
||||||
|
|
||||||
|
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
|
||||||
|
which the right to collect royalties through any statutory or
|
||||||
|
compulsory licensing scheme cannot be waived, the Licensor
|
||||||
|
reserves the exclusive right to collect such royalties for any
|
||||||
|
exercise by You of the rights granted under this License;
|
||||||
|
ii. Waivable Compulsory License Schemes. In those jurisdictions in
|
||||||
|
which the right to collect royalties through any statutory or
|
||||||
|
compulsory licensing scheme can be waived, the Licensor reserves
|
||||||
|
the exclusive right to collect such royalties for any exercise by
|
||||||
|
You of the rights granted under this License if Your exercise of
|
||||||
|
such rights is for a purpose or use which is otherwise than
|
||||||
|
noncommercial as permitted under Section 4(b) and otherwise waives
|
||||||
|
the right to collect royalties through any statutory or compulsory
|
||||||
|
licensing scheme; and,
|
||||||
|
iii. Voluntary License Schemes. The Licensor reserves the right to
|
||||||
|
collect royalties, whether individually or, in the event that the
|
||||||
|
Licensor is a member of a collecting society that administers
|
||||||
|
voluntary licensing schemes, via that society, from any exercise
|
||||||
|
by You of the rights granted under this License that is for a
|
||||||
|
purpose or use which is otherwise than noncommercial as permitted
|
||||||
|
under Section 4(c).
|
||||||
|
e. Except as otherwise agreed in writing by the Licensor or as may be
|
||||||
|
otherwise permitted by applicable law, if You Reproduce, Distribute or
|
||||||
|
Publicly Perform the Work either by itself or as part of any
|
||||||
|
Adaptations or Collections, You must not distort, mutilate, modify or
|
||||||
|
take other derogatory action in relation to the Work which would be
|
||||||
|
prejudicial to the Original Author's honor or reputation. Licensor
|
||||||
|
agrees that in those jurisdictions (e.g. Japan), in which any exercise
|
||||||
|
of the right granted in Section 3(b) of this License (the right to
|
||||||
|
make Adaptations) would be deemed to be a distortion, mutilation,
|
||||||
|
modification or other derogatory action prejudicial to the Original
|
||||||
|
Author's honor and reputation, the Licensor will waive or not assert,
|
||||||
|
as appropriate, this Section, to the fullest extent permitted by the
|
||||||
|
applicable national law, to enable You to reasonably exercise Your
|
||||||
|
right under Section 3(b) of this License (right to make Adaptations)
|
||||||
|
but not otherwise.
|
||||||
|
|
||||||
|
5. Representations, Warranties and Disclaimer
|
||||||
|
|
||||||
|
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
|
||||||
|
OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
|
||||||
|
KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
|
||||||
|
INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
|
||||||
|
LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
|
||||||
|
WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
|
||||||
|
OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
|
||||||
|
|
||||||
|
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
|
||||||
|
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
|
||||||
|
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
|
||||||
|
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
|
||||||
|
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
7. Termination
|
||||||
|
|
||||||
|
a. This License and the rights granted hereunder will terminate
|
||||||
|
automatically upon any breach by You of the terms of this License.
|
||||||
|
Individuals or entities who have received Adaptations or Collections
|
||||||
|
from You under this License, however, will not have their licenses
|
||||||
|
terminated provided such individuals or entities remain in full
|
||||||
|
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
|
||||||
|
survive any termination of this License.
|
||||||
|
b. Subject to the above terms and conditions, the license granted here is
|
||||||
|
perpetual (for the duration of the applicable copyright in the Work).
|
||||||
|
Notwithstanding the above, Licensor reserves the right to release the
|
||||||
|
Work under different license terms or to stop distributing the Work at
|
||||||
|
any time; provided, however that any such election will not serve to
|
||||||
|
withdraw this License (or any other license that has been, or is
|
||||||
|
required to be, granted under the terms of this License), and this
|
||||||
|
License will continue in full force and effect unless terminated as
|
||||||
|
stated above.
|
||||||
|
|
||||||
|
8. Miscellaneous
|
||||||
|
|
||||||
|
a. Each time You Distribute or Publicly Perform the Work or a Collection,
|
||||||
|
the Licensor offers to the recipient a license to the Work on the same
|
||||||
|
terms and conditions as the license granted to You under this License.
|
||||||
|
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
|
||||||
|
offers to the recipient a license to the original Work on the same
|
||||||
|
terms and conditions as the license granted to You under this License.
|
||||||
|
c. If any provision of this License is invalid or unenforceable under
|
||||||
|
applicable law, it shall not affect the validity or enforceability of
|
||||||
|
the remainder of the terms of this License, and without further action
|
||||||
|
by the parties to this agreement, such provision shall be reformed to
|
||||||
|
the minimum extent necessary to make such provision valid and
|
||||||
|
enforceable.
|
||||||
|
d. No term or provision of this License shall be deemed waived and no
|
||||||
|
breach consented to unless such waiver or consent shall be in writing
|
||||||
|
and signed by the party to be charged with such waiver or consent.
|
||||||
|
e. This License constitutes the entire agreement between the parties with
|
||||||
|
respect to the Work licensed here. There are no understandings,
|
||||||
|
agreements or representations with respect to the Work not specified
|
||||||
|
here. Licensor shall not be bound by any additional provisions that
|
||||||
|
may appear in any communication from You. This License may not be
|
||||||
|
modified without the mutual written agreement of the Licensor and You.
|
||||||
|
f. The rights granted under, and the subject matter referenced, in this
|
||||||
|
License were drafted utilizing the terminology of the Berne Convention
|
||||||
|
for the Protection of Literary and Artistic Works (as amended on
|
||||||
|
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
|
||||||
|
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
|
||||||
|
and the Universal Copyright Convention (as revised on July 24, 1971).
|
||||||
|
These rights and subject matter take effect in the relevant
|
||||||
|
jurisdiction in which the License terms are sought to be enforced
|
||||||
|
according to the corresponding provisions of the implementation of
|
||||||
|
those treaty provisions in the applicable national law. If the
|
||||||
|
standard suite of rights granted under applicable copyright law
|
||||||
|
includes additional rights not granted under this License, such
|
||||||
|
additional rights are deemed to be included in the License; this
|
||||||
|
License is not intended to restrict the license of any rights under
|
||||||
|
applicable law.
|
||||||
|
|
||||||
|
|
||||||
|
Creative Commons Notice
|
||||||
|
|
||||||
|
Creative Commons is not a party to this License, and makes no warranty
|
||||||
|
whatsoever in connection with the Work. Creative Commons will not be
|
||||||
|
liable to You or any party on any legal theory for any damages
|
||||||
|
whatsoever, including without limitation any general, special,
|
||||||
|
incidental or consequential damages arising in connection to this
|
||||||
|
license. Notwithstanding the foregoing two (2) sentences, if Creative
|
||||||
|
Commons has expressly identified itself as the Licensor hereunder, it
|
||||||
|
shall have all rights and obligations of Licensor.
|
||||||
|
|
||||||
|
Except for the limited purpose of indicating to the public that the
|
||||||
|
Work is licensed under the CCPL, Creative Commons does not authorize
|
||||||
|
the use by either party of the trademark "Creative Commons" or any
|
||||||
|
related trademark or logo of Creative Commons without the prior
|
||||||
|
written consent of Creative Commons. Any permitted use will be in
|
||||||
|
compliance with Creative Commons' then-current trademark usage
|
||||||
|
guidelines, as may be published on its website or otherwise made
|
||||||
|
available upon request from time to time. For the avoidance of doubt,
|
||||||
|
this trademark restriction does not form part of the License.
|
||||||
|
|
||||||
|
Creative Commons may be contacted at https://creativecommons.org/.
|
||||||
295
README.md
|
|
@ -1,152 +1,211 @@
|
||||||
<img align="left" style="width:260px" src="https://github.com/raysan5/raylib/blob/master/logo/raylib_logo_animation.gif" width="288px">
|
<img src="http://www.raylib.com/img/fb_raylib_logo.png" width=256>
|
||||||
|
|
||||||
**raylib is a simple and easy-to-use library to enjoy videogames programming.**
|
about
|
||||||
|
-----
|
||||||
|
|
||||||
raylib is highly inspired by Borland BGI graphics lib and by XNA framework and it's especially well suited for prototyping, tooling, graphical applications, embedded systems and education.
|
raylib is a simple and easy-to-use library to learn videogames programming.
|
||||||
|
|
||||||
*NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming; no fancy interface, no visual helpers, no debug button... just coding in the most pure spartan-programmers way.*
|
raylib is highly inspired by Borland BGI graphics lib and by XNA framework.
|
||||||
|
|
||||||
Ready to learn? Jump to [code examples!](https://www.raylib.com/examples.html)
|
NOTE for ADVENTURERS: raylib is a programming library to learn videogames programming;
|
||||||
|
no fancy interface, no visual helpers, no auto-debugging... just coding in the most
|
||||||
|
pure spartan-programmers way. Are you ready to learn? Jump to [code examples!](http://www.raylib.com/examples.htm)
|
||||||
|
|
||||||
---
|
history
|
||||||
|
-------
|
||||||
|
|
||||||
<br>
|
I've developed videogames for some years and 4 years ago I started teaching videogames development
|
||||||
|
to young people with artistic profile, most of them had never written a single line of code.
|
||||||
|
|
||||||
[](https://github.com/raysan5/raylib/releases)
|
I started with C language basis and, after searching for the most simple and easy-to-use library to teach
|
||||||
[](https://github.com/raysan5/raylib/stargazers)
|
videogames programming, I found WinBGI; it was great and it worked very well with students, in just a
|
||||||
[](https://github.com/raysan5/raylib/commits/master)
|
couple of weeks that people that had never written a single line of code were able to program (and understand)
|
||||||
[](https://github.com/sponsors/raysan5)
|
a simple PONG and some of them even a BREAKOUT!
|
||||||
[](https://repology.org/project/raylib/versions)
|
|
||||||
[](LICENSE)
|
|
||||||
|
|
||||||
[](https://discord.gg/raylib)
|
But WinBGI was not the clearer and most organized lib. There were a lot of things I found useless and
|
||||||
[](https://www.reddit.com/r/raylib/)
|
confusing and some function names were not clear enough for most of the students; not to mention points
|
||||||
[](https://www.youtube.com/c/raylib)
|
like no transparencies support or no hardware acceleration.
|
||||||
[](https://www.twitch.tv/raysan5)
|
|
||||||
|
|
||||||
[](https://github.com/raysan5/raylib/actions/workflows/build_windows.yml)
|
So, I decided to create my own lib, hardware accelerated, clear function names, quite organized, well structured,
|
||||||
[](https://github.com/raysan5/raylib/actions/workflows/build_linux.yml)
|
plain C coding and, the most important, primarily intended to LEARN videogames programming.
|
||||||
[](https://github.com/raysan5/raylib/actions/workflows/build_macos.yml)
|
|
||||||
[](https://github.com/raysan5/raylib/actions/workflows/build_webassembly.yml)
|
|
||||||
|
|
||||||
[](https://github.com/raysan5/raylib/actions/workflows/build_cmake.yml)
|
I've coded quite a lot in C# and XNA and I really love it (in fact, my students learn C# after C),
|
||||||
[](https://github.com/raysan5/raylib/actions/workflows/build_examples_windows.yml)
|
so, I decided to use C# language notation and XNA naming conventions. That way, students can jump from
|
||||||
[](https://github.com/raysan5/raylib/actions/workflows/build_examples_linux.yml)
|
raylib to XNA, MonoGame or similar libs extremely easily.
|
||||||
|
|
||||||
|
raylib started as a weekend project and after three months of hard work, raylib 1.0 was published on November 2013.
|
||||||
|
|
||||||
|
Enjoy it.
|
||||||
|
|
||||||
|
notes on raylib 1.1
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
On April 2014, after 6 month of first raylib release, raylib 1.1 has been released. This new version presents a
|
||||||
|
complete internal redesign of the library to support OpenGL 1.1, OpenGL 3.3+ and OpenGL ES 2.0.
|
||||||
|
|
||||||
|
A new module named [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) has been added to the library. This new module translate raylib-OpenGL-style
|
||||||
|
immediate mode functions (i.e. rlVertex3f(), rlBegin(), ...) to different versions of OpenGL (1.1, 3.3+, ES2), selectable by one define.
|
||||||
|
|
||||||
|
[rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) also comes with a second new module named [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h), which includes
|
||||||
|
a bunch of useful functions for 3d-math with vectors, matrices and quaternions.
|
||||||
|
|
||||||
|
Some other big changes of this new version have been the support for OGG files loading and stream playing, and the
|
||||||
|
support of DDS texture files (compressed and uncompressed) along with mipmaps support.
|
||||||
|
|
||||||
|
Lots of code changes and lot of testing have concluded in this amazing new raylib 1.1.
|
||||||
|
|
||||||
|
notes on raylib 1.2
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
On September 2014, after 5 month of raylib 1.1 release, it comes raylib 1.2. Again, this version presents a
|
||||||
|
complete internal redesign of [core](https://github.com/raysan5/raylib/blob/master/src/core.c) module to support two new platforms: [Android](http://www.android.com/) and [Raspberry Pi](http://www.raspberrypi.org/).
|
||||||
|
|
||||||
|
It's been some month of really hard work to accomodate raylib to those new platforms while keeping it easy for the user.
|
||||||
|
On Android, raylib manages internally the activity cicle, as well as the inputs; on Raspberry Pi, a complete raw input
|
||||||
|
system has been written from scratch.
|
||||||
|
|
||||||
|
A new display initialization system has been created to support multiple resolutions, adding black bars if required;
|
||||||
|
user only defines desired screen size and it gets properly displayed.
|
||||||
|
|
||||||
|
Now raylib can easily deploy games to Android devices and Raspberry Pi (console mode).
|
||||||
|
|
||||||
|
Lots of code changes and lot of testing have concluded in this amazing new raylib 1.2.
|
||||||
|
|
||||||
|
In December 2014, new raylib 1.2.2 was published with support to compile directly for web (html5) using [emscripten](http://kripken.github.io/emscripten-site/) and [asm.js](http://asmjs.org/).
|
||||||
|
|
||||||
|
notes on raylib 1.3
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
On September 2015, after 1 year of raylib 1.2 release, arrives raylib 1.3. This version adds shaders functionality,
|
||||||
|
improves tremendously textures module and also provides some new modules (camera system, gestures system, IMGUI).
|
||||||
|
|
||||||
|
Shaders support is the biggest addition to raylib 1.3, with support for easy shaders loading and use. Loaded shaders can be
|
||||||
|
attached to 3d models or used as fullscreen postrocessing effects. A bunch of postprocessing shaders are also included
|
||||||
|
in this release, check raylib/shaders folder.
|
||||||
|
|
||||||
|
Textures module has grown to support most of the internal texture formats available in OpenGL (RGB565, RGB888, RGBA5551, RGBA4444, etc.),
|
||||||
|
including compressed texture formats (DXT, ETC1, ETC2, ASTC, PVRT); raylib 1.3 can load .dds, .pkm, .ktx, .astc and .pvr files.
|
||||||
|
|
||||||
|
A brand new [camera](https://github.com/raysan5/raylib/blob/develop/src/camera.c) module offers to the user multiple preconfigured ready-to-use camera systems (free camera, 1st person, 3rd person).
|
||||||
|
Camera modes are very easy to use, just check examples: [core_3d_camera_free.c](https://github.com/raysan5/raylib/blob/develop/examples/core_3d_camera_free.c) and [core_3d_camera_first_person.c](https://github.com/raysan5/raylib/blob/develop/examples/core_3d_camera_first_person.c).
|
||||||
|
|
||||||
|
New [gestures](https://github.com/raysan5/raylib/blob/develop/src/gestures.h) module simplifies gestures detection on Android and HTML5 programs.
|
||||||
|
|
||||||
|
[raygui](https://github.com/raysan5/raylib/blob/develop/src/raygui.h), the new IMGUI (Immediate Mode GUI) module offers a set of functions to create simple user interfaces,
|
||||||
|
primary intended for tools development. It's still in experimental state but already fully functional.
|
||||||
|
|
||||||
|
Most of the examples have been completely rewritten and +10 new examples have been added to show the new raylib features.
|
||||||
|
|
||||||
|
Lots of code changes and lot of testing have concluded in this amazing new raylib 1.3.
|
||||||
|
|
||||||
|
notes on raylib 1.4
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
On February 2016, after 4 months of raylib 1.3 release, it comes raylib 1.4. For this new version, lots of parts of the library have been reviewed, lots of bugs have been solved and some interesting features have been added.
|
||||||
|
|
||||||
|
First big addition is a set of [Image manipulation functions](https://github.com/raysan5/raylib/blob/develop/src/raylib.h#L673) have been added to crop, resize, colorize, flip, dither and even draw image-to-image or text-to-image. Now a basic image processing can be done before converting the image to texture for usage.
|
||||||
|
|
||||||
|
SpriteFonts system has been improved, adding support for AngelCode fonts (.fnt) and TrueType Fonts (using [stb_truetype](https://github.com/nothings/stb/blob/master/stb_truetype.h) helper library). Now raylib can read standard .fnt font data and also generate at loading a SpriteFont from a TTF file.
|
||||||
|
|
||||||
|
New [physac](https://github.com/raysan5/raylib/blob/develop/src/physac.h) physics module for basic 2D physics support. Still in development but already functional. Module comes with some usage examples for basic jump and level interaction and also force-based physic movements.
|
||||||
|
|
||||||
|
[raymath](https://github.com/raysan5/raylib/blob/develop/src/raymath.h) module has been reviewed; some bugs have been solved and the module has been converted to a header-only file for easier portability, optionally, functions can also be used as inline.
|
||||||
|
|
||||||
|
[gestures](https://github.com/raysan5/raylib/blob/develop/src/gestures.c) module has redesigned and simplified, now it can process touch events from any source, including mouse. This way, gestures system can be used on any platform providing an unified way to work with inputs and allowing the user to create multiplatform games with only one source code.
|
||||||
|
|
||||||
|
Raspberry Pi input system has been redesigned to better read raw inputs using generic Linux event handlers (keyboard:`stdin`, mouse:`/dev/input/mouse0`, gamepad:`/dev/input/js0`). Gamepad support has also been added (experimental).
|
||||||
|
|
||||||
|
Other important improvements are the functional raycast system for 3D picking, including some ray collision-detection functions, and the addition of two simple functions for persistent data storage. Now raylib user can save and load game data in a file (only some platforms supported). A simple [easings](https://github.com/raysan5/raylib/blob/develop/src/easings.h) module has also been added for values animation.
|
||||||
|
|
||||||
|
Up to 8 new code examples have been added to show the new raylib features and +10 complete game samples have been provided to learn how to create some classic games like Arkanoid, Asteroids, Missile Commander, Snake or Tetris.
|
||||||
|
|
||||||
|
Lots of code changes and lots of hours of hard work have concluded in this amazing new raylib 1.4.
|
||||||
|
|
||||||
features
|
features
|
||||||
--------
|
--------
|
||||||
- **NO external dependencies**, all required libraries are [included into raylib](https://github.com/raysan5/raylib/tree/master/src/external)
|
|
||||||
- Multiple platforms supported: **Windows, Linux, MacOS, RPI, Android, HTML5... and more!**
|
|
||||||
- Written in plain C code (C99) using PascalCase/camelCase notation
|
|
||||||
- Hardware accelerated with OpenGL: **1.1, 2.1, 3.3, 4.3, ES 2.0, ES 3.0**
|
|
||||||
- **Unique OpenGL abstraction layer** (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h)
|
|
||||||
- **Software Renderer** backend (no OpenGL required!): [rlsw](https://github.com/raysan5/raylib/blob/master/src/external/rlsw.h)
|
|
||||||
- Multiple **Fonts** formats supported (TTF, OTF, FNT, BDF, sprite fonts)
|
|
||||||
- Multiple texture formats supported, including **compressed formats** (DXT, ETC, ASTC)
|
|
||||||
- **Full 3D support**, including 3D Shapes, Models, Billboards, Heightmaps and more!
|
|
||||||
- Flexible Materials system, supporting classic maps and **PBR maps**
|
|
||||||
- **Animated 3D models** supported (skeletal bones animation) (IQM, M3D, glTF)
|
|
||||||
- Shaders support, including model shaders and **postprocessing** shaders
|
|
||||||
- **Powerful math module** for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h)
|
|
||||||
- Audio loading and playing with streaming support (WAV, QOA, OGG, MP3, FLAC, XM, MOD)
|
|
||||||
- **VR stereo rendering** support with configurable HMD device parameters
|
|
||||||
- Huge examples collection with [+140 code examples](https://github.com/raysan5/raylib/tree/master/examples)!
|
|
||||||
- Bindings to [+70 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
|
|
||||||
- **Free and open source**
|
|
||||||
|
|
||||||
basic example
|
* Written in plain C code (C99)
|
||||||
--------------
|
* Uses C# PascalCase/camelCase notation
|
||||||
This is a basic raylib example, it creates a window and draws the text `"Congrats! You created your first window!"` in the middle of the screen. Check this example [running live on web here](https://www.raylib.com/examples/core/loader.html?name=core_basic_window).
|
* Hardware accelerated with OpenGL (1.1, 3.3 or ES2)
|
||||||
```c
|
* Unique OpenGL abstraction layer (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c)
|
||||||
#include "raylib.h"
|
* Powerful fonts module with multiple SpriteFonts formats support (XNA bitmap fonts, AngelCode fonts, TTF)
|
||||||
|
* Outstanding texture formats support, including compressed formats (DXT, ETC, PVRT, ASTC)
|
||||||
|
* Basic 3d support for Shapes, Models, Billboards, Heightmaps and Cubicmaps
|
||||||
|
* Powerful math module for Vector and Matrix operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.c)
|
||||||
|
* Audio loading and playing with streaming support (WAV and OGG)
|
||||||
|
* Custom color palette for fancy visuals on raywhite background
|
||||||
|
* Multiple platforms support: Windows, Linux, Mac, **Android**, **Raspberry Pi** and **HTML5**
|
||||||
|
|
||||||
int main(void)
|
raylib uses on its core module the outstanding [GLFW3](http://www.glfw.org/) library. The best option by far I found for
|
||||||
{
|
multiplatform (Windows, Linux, Mac) window/context and input management (clean, focused, great license, well documented, modern, ...).
|
||||||
InitWindow(800, 450, "raylib example - basic window");
|
|
||||||
|
|
||||||
while (!WindowShouldClose())
|
raylib uses on its [audio](https://github.com/raysan5/raylib/blob/master/src/audio.c) module, [OpenAL Soft](http://kcat.strangesoft.net/openal.html) audio library, in multiple flavours,
|
||||||
{
|
to accomodate to Android, Raspberry Pi and HTML5.
|
||||||
BeginDrawing();
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
|
|
||||||
EndDrawing();
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseWindow();
|
On Android, raylib uses `native_app_glue module` (provided on Android NDK) and native Android libraries to manage window/context, inputs and activity cycle.
|
||||||
|
|
||||||
return 0;
|
On Raspberry Pi, raylib uses Videocore API and EGL for window/context management and raw inputs reading.
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
build and installation
|
raylib is licensed under a zlib/libpng license. View [LICENSE](https://github.com/raysan5/raylib/blob/master/LICENSE.md).
|
||||||
----------------------
|
|
||||||
|
|
||||||
raylib binary releases for Windows, Linux, macOS, Android and HTML5 are available at the [Github Releases page](https://github.com/raysan5/raylib/releases).
|
tools requirements
|
||||||
|
|
||||||
raylib is also available via multiple package managers on multiple OS distributions.
|
|
||||||
|
|
||||||
#### Installing and building raylib on multiple platforms
|
|
||||||
|
|
||||||
[raylib Wiki](https://github.com/raysan5/raylib/wiki#development-platforms) contains detailed instructions on building and usage on multiple platforms.
|
|
||||||
|
|
||||||
- [Working on Windows](https://github.com/raysan5/raylib/wiki/Working-on-Windows)
|
|
||||||
- [Working on macOS](https://github.com/raysan5/raylib/wiki/Working-on-macOS)
|
|
||||||
- [Working on GNU Linux](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux)
|
|
||||||
- [Working on Chrome OS](https://github.com/raysan5/raylib/wiki/Working-on-Chrome-OS)
|
|
||||||
- [Working on FreeBSD](https://github.com/raysan5/raylib/wiki/Working-on-FreeBSD)
|
|
||||||
- [Working on Raspberry Pi](https://github.com/raysan5/raylib/wiki/Working-on-Raspberry-Pi)
|
|
||||||
- [Working for Android](https://github.com/raysan5/raylib/wiki/Working-for-Android)
|
|
||||||
- [Working for Web (HTML5)](https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5))
|
|
||||||
- [Working anywhere with CMake](https://github.com/raysan5/raylib/wiki/Working-with-CMake)
|
|
||||||
|
|
||||||
*Note that the Wiki is open for edit, if you find some issues while building raylib for your target platform, feel free to edit the Wiki or open an issue related to it.*
|
|
||||||
|
|
||||||
#### Setup raylib with multiple IDEs
|
|
||||||
|
|
||||||
raylib has been developed on Windows platform using [Notepad++](https://notepad-plus-plus.org/) and [MinGW GCC](https://www.mingw-w64.org/) compiler but it can be used with other IDEs on multiple platforms.
|
|
||||||
|
|
||||||
[Projects directory](https://github.com/raysan5/raylib/tree/master/projects) contains several ready-to-use **project templates** to build raylib and code examples with multiple IDEs.
|
|
||||||
|
|
||||||
*Note that there are lots of IDEs supported, some of the provided templates could require some review, so please, if you find some issue with a template or you think they could be improved, feel free to send a PR or open a related issue.*
|
|
||||||
|
|
||||||
learning and docs
|
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
raylib is designed to be learned using [the examples](https://github.com/raysan5/raylib/tree/master/examples) as the main reference. There is no standard API documentation but there is a [**cheatsheet**](https://www.raylib.com/cheatsheet/cheatsheet.html) containing all the functions available on the library a short description of each one of them, input parameters and result value names should be intuitive enough to understand how each function works.
|
raylib has been developed using exclusively two tools:
|
||||||
|
|
||||||
Some additional documentation about raylib design can be found in [raylib GitHub Wiki](https://github.com/raysan5/raylib/wiki). Here are the relevant links:
|
* Notepad++ (text editor) - [http://notepad-plus-plus.org/](http://notepad-plus-plus.org/)
|
||||||
|
* MinGW (GCC compiler) - [http://www.mingw.org/](http://www.mingw.org/)
|
||||||
|
|
||||||
- [raylib cheatsheet](https://www.raylib.com/cheatsheet/cheatsheet.html)
|
Those are the tools I recommend to develop with raylib, in fact, those are the tools my students use.
|
||||||
- [raylib architecture](https://github.com/raysan5/raylib/wiki/raylib-architecture)
|
I believe those are the best tools to train spartan-programmers.
|
||||||
- [raylib library design](https://github.com/raysan5/raylib/wiki)
|
|
||||||
- [raylib examples collection](https://github.com/raysan5/raylib/tree/master/examples)
|
|
||||||
- [raylib games collection](https://github.com/raysan5/raylib-games)
|
|
||||||
|
|
||||||
|
Someone could argue about debugging. raylib is a library intended for learning and I think C it's a clear enough language
|
||||||
|
to allow writing small-mid size programs with a printf-based debugging. All raylib examples have also been written this way.
|
||||||
|
|
||||||
contact and networks
|
Since raylib v1.1, you can download a Windows Installer package for easy installation and configuration. Check [raylib Webpage](http://www.raylib.com/)
|
||||||
---------------------
|
|
||||||
|
|
||||||
raylib is present in several networks and raylib community is growing everyday. If you are using raylib and enjoying it, feel free to join us in any of these networks. The most active network is our [Discord server](https://discord.gg/raylib)! :)
|
building source (generate libraylib.a)
|
||||||
|
--------------------------------------
|
||||||
|
|
||||||
- Webpage: [https://www.raylib.com](https://www.raylib.com)
|
Check raylib wiki page: [Building source](https://github.com/raysan5/raylib/wiki/Building-source)
|
||||||
- Discord: [https://discord.gg/raylib](https://discord.gg/raylib)
|
|
||||||
- X: [https://x.com/raysan5](https://x.com/raysan5)
|
|
||||||
- BlueSky: [https://bsky.app/profile/raysan5](https://bsky.app/profile/raysan5.bsky.social)
|
|
||||||
- Twitch: [https://www.twitch.tv/raysan5](https://www.twitch.tv/raysan5)
|
|
||||||
- Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
|
|
||||||
- Patreon: [https://www.patreon.com/raylib](https://www.patreon.com/raylib)
|
|
||||||
- YouTube: [https://www.youtube.com/channel/raylib](https://www.youtube.com/c/raylib)
|
|
||||||
|
|
||||||
contributors
|
building examples
|
||||||
------------
|
-----------------
|
||||||
|
|
||||||
<a href="https://github.com/raysan5/raylib/graphs/contributors">
|
Check raylib wiki page: [Building examples](https://github.com/raysan5/raylib/wiki/Building-examples)
|
||||||
<img src="https://contrib.rocks/image?repo=raysan5/raylib&max=800&columns=24&anon=0" />
|
|
||||||
</a>
|
|
||||||
|
|
||||||
license
|
contact
|
||||||
-------
|
-------
|
||||||
|
|
||||||
raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE) for further details.
|
* Webpage: [http://www.raylib.com](http://www.raylib.com)
|
||||||
|
* Twitter: [http://www.twitter.com/raysan5](http://www.twitter.com/raysan5)
|
||||||
|
* Facebook: [http://www.facebook.com/raylibgames](http://www.facebook.com/raylibgames)
|
||||||
|
* Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
|
||||||
|
* Twitch: [http://www.twitch.tv/raysan5](http://www.twitch.tv/raysan5)
|
||||||
|
* Patreon: [https://www.patreon.com/raysan5](https://www.patreon.com/raysan5)
|
||||||
|
|
||||||
raylib uses internally some libraries for window/graphics/inputs management and also to support different file formats loading, all those libraries are embedded with and are available in [src/external](https://github.com/raysan5/raylib/tree/master/src/external) directory. Check [raylib dependencies LICENSES](https://github.com/raysan5/raylib/wiki/raylib-dependencies) on [raylib Wiki](https://github.com/raysan5/raylib/wiki) for details.
|
If you are using raylib and you enjoy it, please, [let me know][raysan5].
|
||||||
|
|
||||||
|
If you feel you can help, then, [helpme!](http://www.raylib.com/helpme.htm)
|
||||||
|
|
||||||
|
acknowledgements
|
||||||
|
---------------
|
||||||
|
|
||||||
|
The following people have contributed in some way to make raylib project a reality. Big thanks to them!
|
||||||
|
|
||||||
|
- [Zopokx](https://github.com/Zopokx) for testing the web.
|
||||||
|
- [Elendow](http://www.elendow.com) for testing and helping on web development.
|
||||||
|
- Victor Dual for implementating and testing of 3D shapes functions.
|
||||||
|
- Marc Palau for implementating and testing of 3D shapes functions and helping on development of camera and getures modules.
|
||||||
|
- Kevin Gato for improving texture internal formats support and helping on raygui development.
|
||||||
|
- Daniel Nicolas for improving texture internal formats support and helping on raygui development.
|
||||||
|
- Marc Agüera for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com))
|
||||||
|
- Daniel Moreno for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com))
|
||||||
|
- Daniel Gomez for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com))
|
||||||
|
- Sergio Martinez for helping on raygui development and tools development.
|
||||||
|
- Victor Fisac for developing physics raylib module (physac) and implementing light shaders and raycast system... and multiple tools and games.
|
||||||
|
- Albert Martos for helping on raygui and porting examples and game-templates to Android and HTML5.
|
||||||
|
- Ian Eito for helping on raygui and porting examples and game-templates to Android and HTML5.
|
||||||
|
|
||||||
|
|
||||||
|
[raysan5]: mailto:raysan5@gmail.com "Ramon Santamaria - Ray San"
|
||||||
|
|
|
||||||
126
ROADMAP.md
|
|
@ -1,105 +1,37 @@
|
||||||
# raylib roadmap
|
roadmap
|
||||||
|
-------
|
||||||
|
|
||||||
Here is a wishlist with features and ideas to improve the library. Note that features listed here are usually long term improvements or just describe a route to follow for the library. There are also some additional places to look for raylib improvements and ideas:
|
Current version of raylib is quite complete and functional but there is still a lot of things to add and improve.
|
||||||
|
Here it is a wish list of features I would like to add and functions to improve.
|
||||||
|
|
||||||
- [GitHub Issues](https://github.com/raysan5/raylib/issues) has several open issues for possible improvements or bugs to fix.
|
Note that around the raylib source code there are multiple TODO points with pending revisions/bugs. Check [GitHub Issues](https://github.com/raysan5/raylib/issues) for further details!
|
||||||
- [GitHub PRs](https://github.com/raysan5/raylib/pulls) open with improvements to be reviewed.
|
|
||||||
- [raylib source code](https://github.com/raysan5/raylib/tree/master/src) has multiple *TODO* comments around code with pending things to review or improve.
|
|
||||||
- raylib wishlists discussions are open to everyone to ask for improvements, feel free to check and comment:
|
|
||||||
- [raylib 7.0 wishlist](https://github.com/raysan5/raylib/discussions/5710)
|
|
||||||
- [raylib 6.0 wishlist](https://github.com/raysan5/raylib/discussions/4660)
|
|
||||||
- [raylib 5.0 wishlist](https://github.com/raysan5/raylib/discussions/2952)
|
|
||||||
- [raylib wishlist 2022](https://github.com/raysan5/raylib/discussions/2272)
|
|
||||||
- [raylib wishlist 2021](https://github.com/raysan5/raylib/discussions/1502)
|
|
||||||
|
|
||||||
_Current version of raylib is complete and functional but there is always room for improvements._
|
raylib 1.5
|
||||||
|
|
||||||
**raylib 7.0**
|
Redesign Shaders/Textures system, use Materials
|
||||||
- [ ] `rcore_desktop_win32`: Improve new Windows platform backend - inputs, highdpi
|
Redesign physics module (physac)
|
||||||
- [ ] `rcore_desktop_emscripten`: Improve new Web platform backend - inputs, highdpi
|
Basic GPU stats sytem (memory, draws, time...)
|
||||||
- [ ] `rcore_desktop_cocoa`: Create additional platform backend: macOS
|
Procedural image generation functions (spot, gradient, noise...)
|
||||||
- [ ] `rcore_desktop_x11`: Create additional platform backend: Linux/X11
|
Procedural mesh generation functions (cube, cone, sphere...)
|
||||||
- [ ] `rcore_desktop_wayland`: Create additional platform backend: Linux/Wayland
|
Touch-based camera controls for Android
|
||||||
- [ ] `rcore`: Investigate alternative embedded platforms and realtime OSs
|
Skybox and Fog support
|
||||||
- [ ] `rlsw`: Software renderer optimizations: mipmaps, platform-specific SIMD
|
[IN PROGRESS] LUA scripting support (wrapper to lua lib)
|
||||||
- [ ] `rtextures`: Consider removing N-patch system, provide as separate example
|
|
||||||
- [ ] `rtextures`: Review blending modes system, provide more options or better samples
|
|
||||||
- [ ] `rtext`: Investigate the recently opened [`Slug`](https://sluglibrary.com/) font rendering algorithm
|
|
||||||
- [ ] `raudio`: Support microphone input, basic API to read microphone
|
|
||||||
- [ ] `rltexgpu`: Improve compressed textures support, loading and saving, improve KTX 2.0
|
|
||||||
- [ ] `rlobj`: Create OBJ loader, supporting material file separately (low priority)
|
|
||||||
|
|
||||||
**raylib 6.0**
|
raylib 1.4
|
||||||
- [x] `rlsw`: New Software Renderer backend, pseudo-OpenGL 1.1 implementation
|
|
||||||
- [x] `rcore_emscripten`: New emscripten-only backend, avoiding GLFW dependency
|
|
||||||
- [x] `rlgl`: Review GLSL shaders naming conventions for consistency, redesigned shader API
|
|
||||||
- [x] `rmodels`: Improve 3d objects loading, specially animations (obj, gltf)
|
|
||||||
- [x] `examples`: Review all examples, add more and better code explanations
|
|
||||||
|
|
||||||
**raylib 5.0**
|
[DONE] TTF fonts support (using stb_truetype)
|
||||||
- [x] Split core module into separate platforms?
|
[DONE] Raycast system for 3D picking (including collisions detection)
|
||||||
- [x] Redesign gestures system, improve touch inputs management
|
[DONE] Floyd-Steinberg dithering on 16bit image format conversion
|
||||||
- [x] Redesign camera module (more flexible) ([#1143](https://github.com/raysan5/raylib/issues/1143), https://github.com/raysan5/raylib/discussions/2507)
|
[DONE] Basic image manipulation functions (crop, resize, draw...)
|
||||||
- [x] Better documentation and improved examples, reviewed webpage with examples complexity level
|
[DONE] Storage load/save data functionality
|
||||||
- [x] Focus on HTML5 ([raylib 5k gamejam](https://itch.io/jam/raylib-5k-gamejam)) and embedded platforms (RPI and similar SOCs)
|
[DONE] Add Physics module (physac)
|
||||||
- [x] Additional support libraries: [raygui](https://github.com/raysan5/raygui), [rres](https://github.com/raysan5/rres)
|
[DONE] Remove GLEW dependency -> Replaced by GLAD
|
||||||
|
[DONE] Redesign Raspberry PI inputs system
|
||||||
|
[DONE] Redesign gestures module to be multiplatform
|
||||||
|
[DONE] Module raymath as header-only and functions inline
|
||||||
|
[DONE] Add Easings module (easings.h)
|
||||||
|
|
||||||
**raylib 4.0**
|
Any feature missing? Do you have a request? [Let me know!][raysan5]
|
||||||
- [x] Improved consistency and coherency in raylib API
|
|
||||||
- [x] Continuous Deployment using GitHub Actions
|
|
||||||
- [x] rlgl improvements for standalone usage (avoid raylib coupling)
|
|
||||||
- Basic CPU/GPU stats system (memory, draws, time...) ([#1295](https://github.com/raysan5/raylib/issues/1295)) - _DISCARDED_
|
|
||||||
- Software rendering backend (avoiding OpenGL) ([#1370](https://github.com/raysan5/raylib/issues/1370)) - _DISCARDED_
|
|
||||||
- Network module (UDP): `rnet` ([#753](https://github.com/raysan5/raylib/issues/753)) - _DISCARDED_ - Use [nbnet](https://github.com/nathhB/nbnet).
|
|
||||||
|
|
||||||
**raylib 3.0**
|
[raysan5]: mailto:raysan5@gmail.com "Ramon Santamaria - Ray San"
|
||||||
- [x] Custom memory allocators support
|
[isssues]: https://github.com/raysan5/raylib/issues
|
||||||
- [x] Global variables moved to global context
|
|
||||||
- [x] Optimize data structures for pass-by-value
|
|
||||||
- [x] Trace log messages redesign ([#1065](https://github.com/raysan5/raylib/issues/1065))
|
|
||||||
- [x] Continuous Integration using GitHub Actions
|
|
||||||
|
|
||||||
**raylib 2.5**
|
|
||||||
- [x] Support Animated models
|
|
||||||
- [x] Support glTF models file format
|
|
||||||
- [x] Unicode support on text drawing
|
|
||||||
|
|
||||||
**raylib 2.0**
|
|
||||||
- [x] Removed external dependencies (GLFW3 and OpenAL)
|
|
||||||
- [x] Support TCC compiler (32bit and 64bit)
|
|
||||||
|
|
||||||
**raylib 1.8**
|
|
||||||
- [x] Improved Materials system with PBR support
|
|
||||||
- [x] Procedural image generation functions (spot, gradient, noise...)
|
|
||||||
- [x] Procedural mesh generation functions (cube, sphere...)
|
|
||||||
- [x] Custom Android APK build pipeline (default Makefile)
|
|
||||||
|
|
||||||
**raylib 1.7**
|
|
||||||
- [x] Support configuration flags
|
|
||||||
- [x] Improved build system for Android
|
|
||||||
- [x] Gamepad support on HTML5
|
|
||||||
|
|
||||||
**raylib 1.6**
|
|
||||||
- [x] Lua scripting support (raylib Lua wrapper)
|
|
||||||
- [x] Redesigned audio module
|
|
||||||
- [x] Support FLAC file format
|
|
||||||
|
|
||||||
**raylib 1.5**
|
|
||||||
- [x] Support Oculus Rift CV1 and VR stereo rendering (simulator)
|
|
||||||
- [x] Redesign Shaders/Textures system -> New Materials system
|
|
||||||
- [x] Support lighting: Omni, Directional and Spotlights
|
|
||||||
- [x] Redesign physics module (physac)
|
|
||||||
- [x] Chiptunes audio modules support
|
|
||||||
|
|
||||||
**raylib 1.4**
|
|
||||||
- [x] TTF fonts support (using stb_truetype)
|
|
||||||
- [x] Raycast system for 3D picking (including collisions detection)
|
|
||||||
- [x] Floyd-Steinberg dithering on 16bit image format conversion
|
|
||||||
- [x] Basic image manipulation functions (crop, resize, draw...)
|
|
||||||
- [x] Storage load/save data functionality
|
|
||||||
- [x] Add Physics module (physac)
|
|
||||||
- [x] Remove GLEW dependency -> Replaced by GLAD
|
|
||||||
- [x] Redesign Raspberry PI inputs system
|
|
||||||
- [x] Redesign gestures module to be multiplatform
|
|
||||||
- [x] Module raymath as header-only and functions inline
|
|
||||||
- [x] Add Easings module (easings.h)
|
|
||||||
|
|
|
||||||
18
SECURITY.md
|
|
@ -1,18 +0,0 @@
|
||||||
# Security Policy
|
|
||||||
|
|
||||||
## Supported Versions
|
|
||||||
|
|
||||||
Most considerations of errors and defects can be handled using the project Issues and/or Discussions.
|
|
||||||
|
|
||||||
| Version | Supported |
|
|
||||||
| ------- | ------------------ |
|
|
||||||
| 6.0.x | :white_check_mark: |
|
|
||||||
| < 5.5 | :x: |
|
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
|
||||||
|
|
||||||
Discovered vulnerability can be directly reported using the project Issues and/or Discussions.
|
|
||||||
|
|
||||||
_TODO: Tell them where to go, how often they can expect to get an update on a
|
|
||||||
reported vulnerability, what to expect if the vulnerability is accepted or
|
|
||||||
declined, etc._
|
|
||||||
796
build.zig
|
|
@ -1,796 +0,0 @@
|
||||||
const std = @import("std");
|
|
||||||
const builtin = @import("builtin");
|
|
||||||
|
|
||||||
pub const emsdk = struct {
|
|
||||||
const zemscripten = @import("zemscripten");
|
|
||||||
|
|
||||||
pub fn shell(raylib_dep: *std.Build.Dependency) std.Build.LazyPath {
|
|
||||||
return raylib_dep.path("src/shell.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const FlagsOptions = struct {
|
|
||||||
optimize: std.builtin.OptimizeMode,
|
|
||||||
asyncify: bool = true,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn emccDefaultFlags(allocator: std.mem.Allocator, options: FlagsOptions) zemscripten.EmccFlags {
|
|
||||||
var emcc_flags = zemscripten.emccDefaultFlags(allocator, .{
|
|
||||||
.optimize = options.optimize,
|
|
||||||
.fsanitize = true,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (options.asyncify)
|
|
||||||
emcc_flags.put("-sASYNCIFY", {}) catch unreachable;
|
|
||||||
|
|
||||||
return emcc_flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const SettingsOptions = struct {
|
|
||||||
optimize: std.builtin.OptimizeMode,
|
|
||||||
es3: bool = false,
|
|
||||||
glfw3: bool = true,
|
|
||||||
memory_growth: bool = false,
|
|
||||||
total_memory: u32 = 134217728,
|
|
||||||
emsdk_allocator: zemscripten.EmsdkAllocator = .emmalloc,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn emccDefaultSettings(allocator: std.mem.Allocator, options: SettingsOptions) zemscripten.EmccSettings {
|
|
||||||
var emcc_settings = zemscripten.emccDefaultSettings(allocator, .{
|
|
||||||
.optimize = options.optimize,
|
|
||||||
.emsdk_allocator = options.emsdk_allocator,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (options.es3) {
|
|
||||||
emcc_settings.put("FULL_ES3", "1") catch unreachable;
|
|
||||||
emcc_settings.put("MIN_WEBGL_VERSION", "2") catch unreachable;
|
|
||||||
emcc_settings.put("MAX_WEBGL_VERSION", "2") catch unreachable;
|
|
||||||
}
|
|
||||||
if (options.glfw3) {
|
|
||||||
emcc_settings.put("USE_GLFW", "3") catch unreachable;
|
|
||||||
}
|
|
||||||
|
|
||||||
const total_memory = std.fmt.allocPrint(allocator, "{d}", .{options.total_memory}) catch unreachable;
|
|
||||||
|
|
||||||
emcc_settings.put("EXPORTED_RUNTIME_METHODS", "['requestFullscreen']") catch unreachable;
|
|
||||||
emcc_settings.put("TOTAL_MEMORY", total_memory) catch unreachable;
|
|
||||||
emcc_settings.put("FORCE_FILESYSTEM", "1") catch unreachable;
|
|
||||||
emcc_settings.put("EXPORTED_RUNTIME_METHODS", "ccall") catch unreachable;
|
|
||||||
|
|
||||||
if (options.memory_growth)
|
|
||||||
emcc_settings.put("ALLOW_MEMORY_GROWTH", "1") catch unreachable;
|
|
||||||
|
|
||||||
return emcc_settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn emccStep(b: *std.Build, raylib: *std.Build.Step.Compile, wasm: *std.Build.Step.Compile, options: zemscripten.StepOptions) *std.Build.Step {
|
|
||||||
const activate_emsdk_step = zemscripten.activateEmsdkStep(b);
|
|
||||||
|
|
||||||
const emsdk_dep = b.dependency("emsdk", .{});
|
|
||||||
raylib.root_module.addIncludePath(emsdk_dep.path("upstream/emscripten/cache/sysroot/include"));
|
|
||||||
wasm.root_module.addIncludePath(emsdk_dep.path("upstream/emscripten/cache/sysroot/include"));
|
|
||||||
|
|
||||||
const emcc_step = zemscripten.emccStep(b, wasm, options);
|
|
||||||
emcc_step.dependOn(activate_emsdk_step);
|
|
||||||
|
|
||||||
return emcc_step;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn emrunStep(
|
|
||||||
b: *std.Build,
|
|
||||||
html_path: []const u8,
|
|
||||||
extra_args: []const []const u8,
|
|
||||||
) *std.Build.Step {
|
|
||||||
return zemscripten.emrunStep(b, html_path, extra_args);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn linkWindows(mod: *std.Build.Module, opengl: bool, comptime shcore: bool) void {
|
|
||||||
if (opengl) mod.linkSystemLibrary("opengl32", .{});
|
|
||||||
mod.linkSystemLibrary("winmm", .{});
|
|
||||||
mod.linkSystemLibrary("gdi32", .{});
|
|
||||||
if (shcore) mod.linkSystemLibrary("shcore", .{});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn findWaylandScanner(b: *std.Build) void {
|
|
||||||
_ = b.findProgram(&.{"wayland-scanner"}, &.{}) catch {
|
|
||||||
std.log.err(
|
|
||||||
\\ `wayland-scanner` may not be installed on the system.
|
|
||||||
\\ You can switch to X11 in your `build.zig` by changing `Options.linux_display_backend`
|
|
||||||
, .{});
|
|
||||||
@panic("`wayland-scanner` not found");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn linkLinux(mod: *std.Build.Module, comptime display_backend: LinuxDisplayBackend) void {
|
|
||||||
if (display_backend == .None) {
|
|
||||||
mod.linkSystemLibrary("GL", .{});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (display_backend == .X11) {
|
|
||||||
mod.linkSystemLibrary("X11", .{});
|
|
||||||
mod.linkSystemLibrary("Xrandr", .{});
|
|
||||||
mod.linkSystemLibrary("Xinerama", .{});
|
|
||||||
mod.linkSystemLibrary("Xi", .{});
|
|
||||||
mod.linkSystemLibrary("Xcursor", .{});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (display_backend == .Wayland) {
|
|
||||||
mod.linkSystemLibrary("wayland-client", .{});
|
|
||||||
mod.linkSystemLibrary("wayland-cursor", .{});
|
|
||||||
mod.linkSystemLibrary("wayland-egl", .{});
|
|
||||||
mod.linkSystemLibrary("xkbcommon", .{});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn linkBSD(_: *std.Build, mod: *std.Build.Module) void {
|
|
||||||
mod.linkSystemLibrary("GL", .{});
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn linkMacOS(b: *std.Build, mod: *std.Build.Module) void {
|
|
||||||
// Include xcode_frameworks for cross compilation
|
|
||||||
if (b.lazyDependency("xcode_frameworks", .{})) |dep| {
|
|
||||||
mod.addSystemFrameworkPath(dep.path("Frameworks"));
|
|
||||||
mod.addSystemIncludePath(dep.path("include"));
|
|
||||||
mod.addLibraryPath(dep.path("lib"));
|
|
||||||
}
|
|
||||||
|
|
||||||
mod.linkFramework("Foundation", .{});
|
|
||||||
mod.linkFramework("CoreServices", .{});
|
|
||||||
mod.linkFramework("CoreGraphics", .{});
|
|
||||||
mod.linkFramework("AppKit", .{});
|
|
||||||
mod.linkFramework("IOKit", .{});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, options: Options) !*std.Build.Step.Compile {
|
|
||||||
const raylib_mod = b.createModule(.{
|
|
||||||
.optimize = optimize,
|
|
||||||
.target = target,
|
|
||||||
.link_libc = true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const raylib = b.addLibrary(.{
|
|
||||||
.name = "raylib",
|
|
||||||
.linkage = options.linkage,
|
|
||||||
.root_module = raylib_mod,
|
|
||||||
});
|
|
||||||
|
|
||||||
raylib_mod.addCMacro("_GNU_SOURCE", "");
|
|
||||||
raylib_mod.addCMacro("GL_SILENCE_DEPRECATION", "199309L");
|
|
||||||
|
|
||||||
var arena: std.heap.ArenaAllocator = .init(b.allocator);
|
|
||||||
defer arena.deinit();
|
|
||||||
|
|
||||||
var raylib_flags_arr: std.array_list.Managed([]const u8) = .init(arena.allocator());
|
|
||||||
var c_source_files: std.array_list.Managed([]const u8) = .init(arena.allocator());
|
|
||||||
|
|
||||||
try c_source_files.append("src/rcore.c");
|
|
||||||
|
|
||||||
if (target.result.os.tag == .emscripten) {
|
|
||||||
try raylib_flags_arr.append("-std=gnu99");
|
|
||||||
} else {
|
|
||||||
try raylib_flags_arr.append("-std=c99");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.linkage == .dynamic) {
|
|
||||||
raylib_mod.pic = true;
|
|
||||||
raylib_mod.addCMacro("BUILD_LIBTYPE_SHARED", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.config.len > 0) {
|
|
||||||
// Splits a space-separated list of config flags into multiple flags
|
|
||||||
//
|
|
||||||
// Note: This means certain flags like `-x c++` won't be processed properly.
|
|
||||||
// `-xc++` or similar should be used when possible
|
|
||||||
var config_iter = std.mem.tokenizeScalar(u8, options.config, ' ');
|
|
||||||
|
|
||||||
// Apply config flags supplied by the user
|
|
||||||
while (config_iter.next()) |config_flag| {
|
|
||||||
try raylib_flags_arr.append(config_flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
raylib_mod.addCMacro("SUPPORT_MODULE_RSHAPES", &.{@as(u8, @intFromBool(options.rshapes)) + 0x30});
|
|
||||||
if (options.rshapes) {
|
|
||||||
try c_source_files.append("src/rshapes.c");
|
|
||||||
}
|
|
||||||
raylib_mod.addCMacro("SUPPORT_MODULE_RTEXTURES", &.{@as(u8, @intFromBool(options.rtextures)) + 0x30});
|
|
||||||
if (options.rtextures) {
|
|
||||||
try c_source_files.append("src/rtextures.c");
|
|
||||||
}
|
|
||||||
raylib_mod.addCMacro("SUPPORT_MODULE_RTEXT", &.{@as(u8, @intFromBool(options.rtext)) + 0x30});
|
|
||||||
if (options.rtext) {
|
|
||||||
try c_source_files.append("src/rtext.c");
|
|
||||||
}
|
|
||||||
raylib_mod.addCMacro("SUPPORT_MODULE_RMODELS", &.{@as(u8, @intFromBool(options.rmodels)) + 0x30});
|
|
||||||
if (options.rmodels) {
|
|
||||||
try c_source_files.append("src/rmodels.c");
|
|
||||||
}
|
|
||||||
raylib_mod.addCMacro("SUPPORT_MODULE_RAUDIO", &.{@as(u8, @intFromBool(options.raudio)) + 0x30});
|
|
||||||
if (options.raudio) {
|
|
||||||
try c_source_files.append("src/raudio.c");
|
|
||||||
}
|
|
||||||
|
|
||||||
raylib_mod.addIncludePath(b.path("src/platforms"));
|
|
||||||
switch (options.platform) {
|
|
||||||
.glfw => {
|
|
||||||
var opengl_version: OpenglVersion = options.opengl_version;
|
|
||||||
if (opengl_version == .gl_soft) {
|
|
||||||
@panic("The opengl version is not supported by this platform");
|
|
||||||
}
|
|
||||||
|
|
||||||
raylib_mod.addIncludePath(b.path("src/external/glfw/include"));
|
|
||||||
|
|
||||||
if (target.result.os.tag != .emscripten) {
|
|
||||||
if (opengl_version == .auto) {
|
|
||||||
opengl_version = OpenglVersion.gl_3_3;
|
|
||||||
}
|
|
||||||
raylib_mod.addCMacro("PLATFORM_DESKTOP_GLFW", "");
|
|
||||||
try c_source_files.append("src/rglfw.c");
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (target.result.os.tag) {
|
|
||||||
.windows => linkWindows(raylib_mod, true, false),
|
|
||||||
.linux => {
|
|
||||||
if (target.result.abi.isAndroid()) {
|
|
||||||
@panic("Target is not supported with this platform");
|
|
||||||
}
|
|
||||||
|
|
||||||
linkLinux(raylib_mod, .None);
|
|
||||||
|
|
||||||
if (options.linux_display_backend == .X11 or options.linux_display_backend == .Both) {
|
|
||||||
raylib_mod.addCMacro("_GLFW_X11", "");
|
|
||||||
linkLinux(raylib_mod, .X11);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.linux_display_backend == .Wayland or options.linux_display_backend == .Both) {
|
|
||||||
findWaylandScanner(b);
|
|
||||||
|
|
||||||
raylib_mod.addCMacro("_GLFW_WAYLAND", "");
|
|
||||||
linkLinux(raylib_mod, .Wayland);
|
|
||||||
try waylandGenerate(b, raylib, "src/external/glfw/deps/wayland/", false);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
.freebsd, .openbsd, .netbsd, .dragonfly => linkBSD(b, raylib_mod),
|
|
||||||
.macos => {
|
|
||||||
// On macos rglfw.c include Objective-C files.
|
|
||||||
_ = c_source_files.pop();
|
|
||||||
try raylib_flags_arr.append("-ObjC");
|
|
||||||
raylib_mod.addCSourceFile(.{
|
|
||||||
.file = b.path("src/rglfw.c"),
|
|
||||||
.flags = raylib_flags_arr.items,
|
|
||||||
});
|
|
||||||
_ = raylib_flags_arr.pop();
|
|
||||||
|
|
||||||
linkMacOS(b, raylib_mod);
|
|
||||||
},
|
|
||||||
.emscripten => {
|
|
||||||
switch (opengl_version) {
|
|
||||||
.auto => opengl_version = OpenglVersion.gles_2,
|
|
||||||
.gles_2, .gles_3, .gl_soft => {},
|
|
||||||
else => @panic("opengl version not supported"),
|
|
||||||
}
|
|
||||||
|
|
||||||
raylib_mod.addCMacro("PLATFORM_WEB", "");
|
|
||||||
|
|
||||||
const activate_emsdk_step = emsdk.zemscripten.activateEmsdkStep(b);
|
|
||||||
raylib.step.dependOn(activate_emsdk_step);
|
|
||||||
},
|
|
||||||
else => @panic("Target is not supported with this platform"),
|
|
||||||
}
|
|
||||||
raylib_mod.addCMacro(opengl_version.toCMacroStr(), "");
|
|
||||||
},
|
|
||||||
.rgfw => {
|
|
||||||
var opengl_version: OpenglVersion = options.opengl_version;
|
|
||||||
|
|
||||||
if (target.result.os.tag != .emscripten) {
|
|
||||||
if (opengl_version == .auto) {
|
|
||||||
opengl_version = OpenglVersion.gl_3_3;
|
|
||||||
}
|
|
||||||
raylib_mod.addCMacro("PLATFORM_DESKTOP_RGFW", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (target.result.os.tag) {
|
|
||||||
.windows => linkWindows(raylib_mod, true, false),
|
|
||||||
.linux => {
|
|
||||||
if (target.result.abi.isAndroid()) {
|
|
||||||
@panic("Target is not supported with this platform");
|
|
||||||
}
|
|
||||||
|
|
||||||
linkLinux(raylib_mod, .None);
|
|
||||||
|
|
||||||
if (options.linux_display_backend == .X11 or options.linux_display_backend == .Both) {
|
|
||||||
raylib_mod.addCMacro("RGFW_X11", "");
|
|
||||||
raylib_mod.addCMacro("RGFW_UNIX", "");
|
|
||||||
|
|
||||||
linkLinux(raylib_mod, .X11);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.linux_display_backend == .Wayland or options.linux_display_backend == .Both) {
|
|
||||||
findWaylandScanner(b);
|
|
||||||
|
|
||||||
if (options.linux_display_backend != .Both) {
|
|
||||||
raylib_mod.addCMacro("RGFW_NO_X11", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
raylib_mod.addCMacro("RGFW_WAYLAND", "");
|
|
||||||
raylib_mod.addCMacro("EGLAPIENTRY", "");
|
|
||||||
|
|
||||||
linkLinux(raylib_mod, .Wayland);
|
|
||||||
|
|
||||||
try waylandGenerate(b, raylib, "src/external/RGFW/deps/wayland/", true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
.freebsd, .openbsd, .netbsd, .dragonfly => linkBSD(b, raylib_mod),
|
|
||||||
.macos => linkMacOS(b, raylib_mod),
|
|
||||||
.emscripten => {
|
|
||||||
switch (opengl_version) {
|
|
||||||
.auto => opengl_version = OpenglVersion.gles_2,
|
|
||||||
.gles_2, .gles_3, .gl_soft => {},
|
|
||||||
else => @panic("opengl version not supported"),
|
|
||||||
}
|
|
||||||
|
|
||||||
raylib_mod.addCMacro("PLATFORM_WEB_RGFW", "");
|
|
||||||
const activate_emsdk_step = emsdk.zemscripten.activateEmsdkStep(b);
|
|
||||||
raylib.step.dependOn(activate_emsdk_step);
|
|
||||||
},
|
|
||||||
else => @panic("Target is not supported with this platform"),
|
|
||||||
}
|
|
||||||
|
|
||||||
raylib_mod.addCMacro(opengl_version.toCMacroStr(), "");
|
|
||||||
},
|
|
||||||
.sdl, .sdl2, .sdl3 => {
|
|
||||||
if (options.opengl_version == .auto) {
|
|
||||||
raylib_mod.addCMacro(OpenglVersion.gl_3_3.toCMacroStr(), "");
|
|
||||||
} else {
|
|
||||||
raylib_mod.addCMacro(options.opengl_version.toCMacroStr(), "");
|
|
||||||
}
|
|
||||||
|
|
||||||
raylib_mod.addCMacro("PLATFORM_DESKTOP_SDL", "");
|
|
||||||
|
|
||||||
if (options.platform == .sdl2) {
|
|
||||||
raylib_mod.addCMacro("USING_SDL2_PACKAGE", "");
|
|
||||||
}
|
|
||||||
if (options.platform == .sdl3) {
|
|
||||||
raylib_mod.addCMacro("USING_SDL3_PACKAGE", "");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
.memory => {
|
|
||||||
if (options.opengl_version != .auto and options.opengl_version != .gl_soft) {
|
|
||||||
@panic("The opengl version is not supported by this platform");
|
|
||||||
}
|
|
||||||
raylib_mod.addCMacro(OpenglVersion.gl_soft.toCMacroStr(), "");
|
|
||||||
raylib_mod.addCMacro("PLATFORM_MEMORY", "");
|
|
||||||
},
|
|
||||||
.win32 => {
|
|
||||||
if (target.result.os.tag != .windows) {
|
|
||||||
@panic("Target is not supported with this platform");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.opengl_version == .auto) {
|
|
||||||
raylib_mod.addCMacro(OpenglVersion.gl_3_3.toCMacroStr(), "");
|
|
||||||
} else {
|
|
||||||
raylib_mod.addCMacro(options.opengl_version.toCMacroStr(), "");
|
|
||||||
}
|
|
||||||
|
|
||||||
raylib_mod.addCMacro("PLATFORM_DESKTOP_WIN32", "");
|
|
||||||
|
|
||||||
linkWindows(raylib_mod, options.opengl_version != .gl_soft, true);
|
|
||||||
},
|
|
||||||
.drm => {
|
|
||||||
if (target.result.os.tag != .linux) {
|
|
||||||
@panic("Target is not supported with this platform");
|
|
||||||
}
|
|
||||||
|
|
||||||
raylib_mod.addCMacro("PLATFORM_DRM", "");
|
|
||||||
raylib_mod.addCMacro("EGL_NO_X11", "");
|
|
||||||
raylib_mod.addCMacro("DEFAULT_BATCH_BUFFER_ELEMENT", "");
|
|
||||||
|
|
||||||
try raylib_flags_arr.append("-Werror=implicit-function-declaration");
|
|
||||||
|
|
||||||
raylib_mod.linkSystemLibrary("libdrm", .{ .use_pkg_config = .force });
|
|
||||||
raylib_mod.linkSystemLibrary("drm", .{});
|
|
||||||
raylib_mod.linkSystemLibrary("gbm", .{});
|
|
||||||
|
|
||||||
switch (options.opengl_version) {
|
|
||||||
.auto, .gles_2 => {
|
|
||||||
raylib_mod.addCMacro(OpenglVersion.gles_2.toCMacroStr(), "");
|
|
||||||
raylib_mod.linkSystemLibrary("GLESv2", .{});
|
|
||||||
raylib_mod.linkSystemLibrary("EGL", .{});
|
|
||||||
},
|
|
||||||
.gl_soft => {},
|
|
||||||
else => @panic("The opengl version is not supported by this platform"),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
.android => {
|
|
||||||
if (!target.result.abi.isAndroid()) {
|
|
||||||
@panic("Target is not supported with this platform");
|
|
||||||
}
|
|
||||||
|
|
||||||
raylib_mod.addCMacro("PLATFORM_ANDROID", "");
|
|
||||||
|
|
||||||
raylib_mod.linkSystemLibrary("EGL", .{});
|
|
||||||
switch (options.opengl_version) {
|
|
||||||
.auto, .gles_2 => {
|
|
||||||
raylib_mod.addCMacro(OpenglVersion.gles_2.toCMacroStr(), "");
|
|
||||||
raylib_mod.linkSystemLibrary("GLESv2", .{});
|
|
||||||
},
|
|
||||||
else => @panic("The opengl version is not supported by this platform"),
|
|
||||||
}
|
|
||||||
|
|
||||||
//these are the only tag options per https://developer.android.com/ndk/guides/other_build_systems
|
|
||||||
const hostTuple = switch (builtin.target.os.tag) {
|
|
||||||
.linux => "linux-x86_64",
|
|
||||||
.windows => "windows-x86_64",
|
|
||||||
.macos => "darwin-x86_64",
|
|
||||||
else => @panic("unsupported host OS"),
|
|
||||||
};
|
|
||||||
|
|
||||||
const androidTriple = switch (target.result.cpu.arch) {
|
|
||||||
.x86 => "i686-linux-android",
|
|
||||||
.x86_64 => "x86_64-linux-android",
|
|
||||||
.arm => "arm-linux-androideabi",
|
|
||||||
.aarch64 => "aarch64-linux-android",
|
|
||||||
.riscv64 => "riscv64-linux-android",
|
|
||||||
else => error.InvalidAndroidTarget,
|
|
||||||
} catch @panic("invalid android target!");
|
|
||||||
const androidNdkPathString: []const u8 = options.android_ndk;
|
|
||||||
if (androidNdkPathString.len < 1) @panic("no ndk path provided and ANDROID_NDK_HOME is not set");
|
|
||||||
const androidApiLevel: []const u8 = options.android_api_version;
|
|
||||||
|
|
||||||
const androidSysroot = try std.fs.path.join(b.allocator, &.{ androidNdkPathString, "/toolchains/llvm/prebuilt/", hostTuple, "/sysroot" });
|
|
||||||
const androidLibPath = try std.fs.path.join(b.allocator, &.{ androidSysroot, "/usr/lib/", androidTriple });
|
|
||||||
const androidApiSpecificPath = try std.fs.path.join(b.allocator, &.{ androidLibPath, androidApiLevel });
|
|
||||||
const androidIncludePath = try std.fs.path.join(b.allocator, &.{ androidSysroot, "/usr/include" });
|
|
||||||
const androidArchIncludePath = try std.fs.path.join(b.allocator, &.{ androidIncludePath, androidTriple });
|
|
||||||
const androidAsmPath = try std.fs.path.join(b.allocator, &.{ androidIncludePath, "/asm-generic" });
|
|
||||||
const androidGluePath = try std.fs.path.join(b.allocator, &.{ androidNdkPathString, "/sources/android/native_app_glue/" });
|
|
||||||
|
|
||||||
raylib_mod.addLibraryPath(.{ .cwd_relative = androidLibPath });
|
|
||||||
raylib_mod.addLibraryPath(.{ .cwd_relative = androidApiSpecificPath });
|
|
||||||
raylib_mod.addSystemIncludePath(.{ .cwd_relative = androidIncludePath });
|
|
||||||
raylib_mod.addSystemIncludePath(.{ .cwd_relative = androidArchIncludePath });
|
|
||||||
raylib_mod.addSystemIncludePath(.{ .cwd_relative = androidAsmPath });
|
|
||||||
raylib_mod.addSystemIncludePath(.{ .cwd_relative = androidGluePath });
|
|
||||||
|
|
||||||
const libc_data = try std.fmt.allocPrint(b.allocator,
|
|
||||||
\\include_dir={0s}/sysroot/usr/include
|
|
||||||
\\sys_include_dir={0s}/sysroot/usr/include/aarch64-linux-android
|
|
||||||
\\crt_dir={0s}/sysroot/usr/lib/aarch64-linux-android/24
|
|
||||||
\\static_lib_dir={0s}/sysroot/usr/lib/aarch64-linux-android/24
|
|
||||||
\\msvc_lib_dir=
|
|
||||||
\\kernel32_lib_dir=
|
|
||||||
\\gcc_dir=
|
|
||||||
\\
|
|
||||||
, .{androidNdkPathString});
|
|
||||||
const write_step = b.addWriteFiles();
|
|
||||||
const libcFile = write_step.add("android-libc.txt", libc_data);
|
|
||||||
raylib.setLibCFile(libcFile);
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
raylib_mod.addCSourceFiles(.{
|
|
||||||
.files = c_source_files.items,
|
|
||||||
.flags = raylib_flags_arr.items,
|
|
||||||
});
|
|
||||||
|
|
||||||
return raylib;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn addRaygui(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, raylib: *std.Build.Step.Compile) void {
|
|
||||||
if (b.lazyDependency("raygui", .{
|
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
.link_libc = true,
|
|
||||||
})) |raygui_dep| {
|
|
||||||
var gen_step = b.addWriteFiles();
|
|
||||||
raylib.step.dependOn(&gen_step.step);
|
|
||||||
|
|
||||||
const raygui_c_path = gen_step.add("raygui.c", "#define RAYGUI_IMPLEMENTATION\n#include \"raygui.h\"\n");
|
|
||||||
raylib.root_module.addCSourceFile(.{ .file = raygui_c_path });
|
|
||||||
raylib.root_module.addIncludePath(raygui_dep.path("src"));
|
|
||||||
raylib.root_module.addIncludePath(b.path("src"));
|
|
||||||
|
|
||||||
raylib.installHeader(raygui_dep.path("src/raygui.h"), "raygui.h");
|
|
||||||
|
|
||||||
const c = b.addTranslateC(.{
|
|
||||||
.root_source_file = raygui_dep.path("src/raygui.h"),
|
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
.link_libc = true,
|
|
||||||
});
|
|
||||||
c.addIncludePath(b.path("src"));
|
|
||||||
const c_mod = c.createModule();
|
|
||||||
c_mod.linkLibrary(raylib);
|
|
||||||
b.modules.put(b.graph.arena, "raygui", c_mod) catch @panic("OOM");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const Options = struct {
|
|
||||||
raudio: bool = true,
|
|
||||||
rmodels: bool = true,
|
|
||||||
rshapes: bool = true,
|
|
||||||
rtext: bool = true,
|
|
||||||
rtextures: bool = true,
|
|
||||||
raygui: bool = false,
|
|
||||||
platform: PlatformBackend = .glfw,
|
|
||||||
linkage: std.builtin.LinkMode = .static,
|
|
||||||
linux_display_backend: LinuxDisplayBackend = .X11,
|
|
||||||
opengl_version: OpenglVersion = .auto,
|
|
||||||
android_ndk: []const u8 = "",
|
|
||||||
android_api_version: []const u8 = "35",
|
|
||||||
/// config should be a list of space-separated cflags, eg, "-DSUPPORT_CUSTOM_FRAME_CONTROL"
|
|
||||||
config: []const u8 = &.{},
|
|
||||||
|
|
||||||
const defaults = Options{};
|
|
||||||
|
|
||||||
pub fn getOptions(b: *std.Build) Options {
|
|
||||||
return .{
|
|
||||||
.platform = b.option(PlatformBackend, "platform", "Choose the platform backend for desktop target") orelse defaults.platform,
|
|
||||||
.raudio = b.option(bool, "raudio", "Compile with audio support") orelse defaults.raudio,
|
|
||||||
.rmodels = b.option(bool, "rmodels", "Compile with models support") orelse defaults.rmodels,
|
|
||||||
.rtext = b.option(bool, "rtext", "Compile with text support") orelse defaults.rtext,
|
|
||||||
.rtextures = b.option(bool, "rtextures", "Compile with textures support") orelse defaults.rtextures,
|
|
||||||
.rshapes = b.option(bool, "rshapes", "Compile with shapes support") orelse defaults.rshapes,
|
|
||||||
.raygui = b.option(bool, "raygui", "Include raygui") orelse defaults.raygui,
|
|
||||||
.linkage = b.option(std.builtin.LinkMode, "linkage", "Compile as shared or static library") orelse defaults.linkage,
|
|
||||||
.linux_display_backend = b.option(LinuxDisplayBackend, "linux_display_backend", "Linux display backend to use") orelse defaults.linux_display_backend,
|
|
||||||
.opengl_version = b.option(OpenglVersion, "opengl_version", "OpenGL version to use") orelse defaults.opengl_version,
|
|
||||||
.config = b.option([]const u8, "config", "Compile with custom define macros overriding config.h") orelse &.{},
|
|
||||||
.android_ndk = b.option([]const u8, "android_ndk", "specify path to android ndk") orelse b.graph.environ_map.get("ANDROID_NDK_HOME") orelse "",
|
|
||||||
.android_api_version = b.option([]const u8, "android_api_version", "specify target android API level") orelse defaults.android_api_version,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const OpenglVersion = enum {
|
|
||||||
auto,
|
|
||||||
gl_soft,
|
|
||||||
gl_1_1,
|
|
||||||
gl_2_1,
|
|
||||||
gl_3_3,
|
|
||||||
gl_4_3,
|
|
||||||
gles_2,
|
|
||||||
gles_3,
|
|
||||||
|
|
||||||
pub fn toCMacroStr(self: @This()) []const u8 {
|
|
||||||
switch (self) {
|
|
||||||
.auto => @panic("OpenglVersion.auto cannot be turned into a C macro string"),
|
|
||||||
.gl_soft => return "GRAPHICS_API_OPENGL_SOFTWARE",
|
|
||||||
.gl_1_1 => return "GRAPHICS_API_OPENGL_11",
|
|
||||||
.gl_2_1 => return "GRAPHICS_API_OPENGL_21",
|
|
||||||
.gl_3_3 => return "GRAPHICS_API_OPENGL_33",
|
|
||||||
.gl_4_3 => return "GRAPHICS_API_OPENGL_43",
|
|
||||||
.gles_2 => return "GRAPHICS_API_OPENGL_ES2",
|
|
||||||
.gles_3 => return "GRAPHICS_API_OPENGL_ES3",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const LinuxDisplayBackend = enum {
|
|
||||||
None,
|
|
||||||
X11,
|
|
||||||
Wayland,
|
|
||||||
Both,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const PlatformBackend = enum {
|
|
||||||
glfw,
|
|
||||||
rgfw,
|
|
||||||
sdl,
|
|
||||||
sdl2,
|
|
||||||
sdl3,
|
|
||||||
memory,
|
|
||||||
win32,
|
|
||||||
drm,
|
|
||||||
android,
|
|
||||||
};
|
|
||||||
|
|
||||||
fn translateCMod(
|
|
||||||
comptime header: []const u8,
|
|
||||||
b: *std.Build,
|
|
||||||
target: std.Build.ResolvedTarget,
|
|
||||||
optimize: std.builtin.OptimizeMode,
|
|
||||||
raylib: *std.Build.Step.Compile,
|
|
||||||
) void {
|
|
||||||
const c = b.addTranslateC(.{
|
|
||||||
.root_source_file = b.path("src/" ++ header ++ ".h"),
|
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
.link_libc = true,
|
|
||||||
});
|
|
||||||
const c_mod = c.createModule();
|
|
||||||
c_mod.linkLibrary(raylib);
|
|
||||||
b.modules.put(b.graph.arena, header, c_mod) catch @panic("OOM");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn build(b: *std.Build) !void {
|
|
||||||
const target = b.standardTargetOptions(.{});
|
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
|
||||||
const options: Options = .getOptions(b);
|
|
||||||
|
|
||||||
const lib = try compileRaylib(b, target, optimize, options);
|
|
||||||
|
|
||||||
lib.installHeader(b.path("src/raylib.h"), "raylib.h");
|
|
||||||
lib.installHeader(b.path("src/rcamera.h"), "rcamera.h");
|
|
||||||
lib.installHeader(b.path("src/raymath.h"), "raymath.h");
|
|
||||||
lib.installHeader(b.path("src/rlgl.h"), "rlgl.h");
|
|
||||||
|
|
||||||
b.installArtifact(lib);
|
|
||||||
|
|
||||||
translateCMod("raylib", b, target, optimize, lib);
|
|
||||||
translateCMod("rcamera", b, target, optimize, lib);
|
|
||||||
translateCMod("raymath", b, target, optimize, lib);
|
|
||||||
translateCMod("rlgl", b, target, optimize, lib);
|
|
||||||
|
|
||||||
if (options.raygui) {
|
|
||||||
addRaygui(b, target, optimize, lib);
|
|
||||||
}
|
|
||||||
|
|
||||||
const examples = b.step("examples", "build/install all examples");
|
|
||||||
examples.dependOn(try addExamples("core", b, target, optimize, lib, options.platform));
|
|
||||||
examples.dependOn(try addExamples("audio", b, target, optimize, lib, options.platform));
|
|
||||||
examples.dependOn(try addExamples("models", b, target, optimize, lib, options.platform));
|
|
||||||
examples.dependOn(try addExamples("shaders", b, target, optimize, lib, options.platform));
|
|
||||||
examples.dependOn(try addExamples("shapes", b, target, optimize, lib, options.platform));
|
|
||||||
examples.dependOn(try addExamples("text", b, target, optimize, lib, options.platform));
|
|
||||||
examples.dependOn(try addExamples("textures", b, target, optimize, lib, options.platform));
|
|
||||||
examples.dependOn(try addExamples("others", b, target, optimize, lib, options.platform));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn addExamples(
|
|
||||||
comptime module: []const u8,
|
|
||||||
b: *std.Build,
|
|
||||||
target: std.Build.ResolvedTarget,
|
|
||||||
optimize: std.builtin.OptimizeMode,
|
|
||||||
raylib: *std.Build.Step.Compile,
|
|
||||||
platform: PlatformBackend,
|
|
||||||
) !*std.Build.Step {
|
|
||||||
const all = b.step(module, "All " ++ module ++ " examples");
|
|
||||||
const module_subpath = b.pathJoin(&.{ "examples", module });
|
|
||||||
|
|
||||||
var dir = try b.build_root.handle.openDir(b.graph.io, module_subpath, .{ .iterate = true });
|
|
||||||
defer dir.close(b.graph.io);
|
|
||||||
|
|
||||||
var iter = dir.iterate();
|
|
||||||
while (try iter.next(b.graph.io)) |entry| {
|
|
||||||
if (entry.kind != .file) continue;
|
|
||||||
|
|
||||||
const filetype = std.fs.path.extension(entry.name);
|
|
||||||
if (!std.mem.eql(u8, filetype, ".c")) continue;
|
|
||||||
|
|
||||||
const filename = std.fs.path.stem(entry.name);
|
|
||||||
const path = b.pathJoin(&.{ module_subpath, entry.name });
|
|
||||||
|
|
||||||
const exe_mod = b.createModule(.{
|
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
.link_libc = true,
|
|
||||||
});
|
|
||||||
exe_mod.addCSourceFile(.{ .file = b.path(path) });
|
|
||||||
exe_mod.linkLibrary(raylib);
|
|
||||||
|
|
||||||
if (platform == .sdl) {
|
|
||||||
exe_mod.linkSystemLibrary("SDL2", .{});
|
|
||||||
exe_mod.linkSystemLibrary("SDL3", .{});
|
|
||||||
}
|
|
||||||
if (platform == .sdl2) {
|
|
||||||
exe_mod.linkSystemLibrary("SDL2", .{});
|
|
||||||
}
|
|
||||||
if (platform == .sdl3) {
|
|
||||||
exe_mod.linkSystemLibrary("SDL3", .{});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (std.mem.eql(u8, filename, "rlgl_standalone")) {
|
|
||||||
if (platform != .glfw) continue;
|
|
||||||
exe_mod.addIncludePath(b.path("src"));
|
|
||||||
exe_mod.addIncludePath(b.path("src/external/glfw/include"));
|
|
||||||
}
|
|
||||||
if (std.mem.eql(u8, filename, "raylib_opengl_interop")) {
|
|
||||||
if (platform == .drm) continue;
|
|
||||||
if (target.result.os.tag == .macos) continue;
|
|
||||||
exe_mod.addIncludePath(b.path("src/external"));
|
|
||||||
}
|
|
||||||
|
|
||||||
const run_step = b.step(filename, filename);
|
|
||||||
|
|
||||||
// web exports are completely separate
|
|
||||||
if (target.query.os_tag == .emscripten) {
|
|
||||||
exe_mod.addCMacro("PLATFORM_WEB", "");
|
|
||||||
|
|
||||||
const wasm = b.addLibrary(.{
|
|
||||||
.name = filename,
|
|
||||||
.root_module = exe_mod,
|
|
||||||
});
|
|
||||||
|
|
||||||
const install_dir: std.Build.InstallDir = .{ .custom = b.fmt("web/{s}/{s}", .{ module, filename }) };
|
|
||||||
const emcc_flags = emsdk.emccDefaultFlags(b.allocator, .{ .optimize = optimize });
|
|
||||||
const emcc_settings = emsdk.emccDefaultSettings(b.allocator, .{ .optimize = optimize });
|
|
||||||
|
|
||||||
const EmccExamplesPreloadMap = std.static_string_map.StaticStringMap([]const emsdk.zemscripten.EmccFilePath);
|
|
||||||
const EmccExamplesPreloadKV = struct { []const u8, []const emsdk.zemscripten.EmccFilePath };
|
|
||||||
const emcc_examples_preloads: []const EmccExamplesPreloadKV = @import("examples/example_resources.zon");
|
|
||||||
const emcc_examples_preloads_map = EmccExamplesPreloadMap.initComptime(emcc_examples_preloads);
|
|
||||||
|
|
||||||
const emcc_step = emsdk.emccStep(b, raylib, wasm, .{
|
|
||||||
.optimize = optimize,
|
|
||||||
.flags = emcc_flags,
|
|
||||||
.settings = emcc_settings,
|
|
||||||
.preload_paths = emcc_examples_preloads_map.get(filename) orelse &.{},
|
|
||||||
.shell_file_path = b.path("src/shell.html"),
|
|
||||||
.install_dir = install_dir,
|
|
||||||
});
|
|
||||||
b.getInstallStep().dependOn(emcc_step);
|
|
||||||
|
|
||||||
const html_filename = try std.fmt.allocPrint(b.allocator, "{s}.html", .{wasm.name});
|
|
||||||
const emrun_step = emsdk.emrunStep(
|
|
||||||
b,
|
|
||||||
b.getInstallPath(install_dir, html_filename),
|
|
||||||
&.{},
|
|
||||||
);
|
|
||||||
|
|
||||||
emrun_step.dependOn(emcc_step);
|
|
||||||
run_step.dependOn(emrun_step);
|
|
||||||
all.dependOn(emcc_step);
|
|
||||||
} else {
|
|
||||||
exe_mod.addCMacro("PLATFORM_DESKTOP", "");
|
|
||||||
|
|
||||||
const exe = b.addExecutable(.{
|
|
||||||
.name = filename,
|
|
||||||
.root_module = exe_mod,
|
|
||||||
.use_lld = target.result.os.tag == .windows,
|
|
||||||
});
|
|
||||||
|
|
||||||
const install_cmd = b.addInstallArtifact(exe, .{ .dest_sub_path = b.fmt("{s}/{s}", .{ module, filename }) });
|
|
||||||
|
|
||||||
const run_cmd = b.addRunArtifact(exe);
|
|
||||||
run_cmd.cwd = b.path(module_subpath);
|
|
||||||
run_cmd.step.dependOn(&install_cmd.step);
|
|
||||||
|
|
||||||
run_step.dependOn(&run_cmd.step);
|
|
||||||
all.dependOn(&install_cmd.step);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return all;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn waylandGenerate(
|
|
||||||
b: *std.Build,
|
|
||||||
raylib: *std.Build.Step.Compile,
|
|
||||||
comptime waylandDir: []const u8,
|
|
||||||
comptime source: bool,
|
|
||||||
) !void {
|
|
||||||
const dir = try b.build_root.handle.openDir(b.graph.io, waylandDir, .{ .iterate = true });
|
|
||||||
defer dir.close(b.graph.io);
|
|
||||||
|
|
||||||
var iter = dir.iterate();
|
|
||||||
while (try iter.next(b.graph.io)) |entry| {
|
|
||||||
if (entry.kind != .file) continue;
|
|
||||||
const protocolDir = b.pathJoin(&.{ waylandDir, entry.name });
|
|
||||||
|
|
||||||
const filename = std.fs.path.stem(entry.name);
|
|
||||||
|
|
||||||
const clientHeader = b.fmt("{s}-client-protocol.h", .{filename});
|
|
||||||
const client_step = b.addSystemCommand(&.{ "wayland-scanner", "client-header" });
|
|
||||||
client_step.addFileArg(b.path(protocolDir));
|
|
||||||
raylib.root_module.addIncludePath(client_step.addOutputFileArg(clientHeader).dirname());
|
|
||||||
raylib.step.dependOn(&client_step.step);
|
|
||||||
|
|
||||||
if (comptime source) {
|
|
||||||
const privateCode = b.fmt("{s}-client-protocol-code.c", .{filename});
|
|
||||||
const private_step = b.addSystemCommand(&.{ "wayland-scanner", "private-code" });
|
|
||||||
private_step.addFileArg(b.path(protocolDir));
|
|
||||||
raylib.root_module.addCSourceFile(.{
|
|
||||||
.file = private_step.addOutputFileArg(privateCode),
|
|
||||||
.flags = &.{ "-std=c99", "-O2" },
|
|
||||||
});
|
|
||||||
raylib.step.dependOn(&private_step.step);
|
|
||||||
} else {
|
|
||||||
const privateCodeHeader = b.fmt("{s}-client-protocol-code.h", .{filename});
|
|
||||||
const private_head_step = b.addSystemCommand(&.{ "wayland-scanner", "private-code" });
|
|
||||||
private_head_step.addFileArg(b.path(protocolDir));
|
|
||||||
raylib.root_module.addIncludePath(private_head_step.addOutputFileArg(privateCodeHeader).dirname());
|
|
||||||
raylib.step.dependOn(&private_head_step.step);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
.{
|
|
||||||
.name = .raylib,
|
|
||||||
.version = "6.0.0",
|
|
||||||
.minimum_zig_version = "0.16.0",
|
|
||||||
|
|
||||||
.fingerprint = 0x13035e5cb8bc1ac2, // Changing this has security and trust implications.
|
|
||||||
|
|
||||||
.dependencies = .{
|
|
||||||
.xcode_frameworks = .{
|
|
||||||
.url = "https://pkg.machengine.org/xcode-frameworks/8a1cfb373587ea4c9bb1468b7c986462d8d4e10e.tar.gz",
|
|
||||||
.hash = "N-V-__8AALShqgXkvqYU6f__FrA22SMWmi2TXCJjNTO1m8XJ",
|
|
||||||
.lazy = true,
|
|
||||||
},
|
|
||||||
.raygui = .{
|
|
||||||
.url = "git+https://github.com/raysan5/raygui#3b2855842ab578a034f827c38cf8f62c042fc983",
|
|
||||||
.hash = "N-V-__8AAHvybwBw1kyBGn0BW_s1RqIpycNjLf_XbE-fpLUF",
|
|
||||||
.lazy = true,
|
|
||||||
},
|
|
||||||
.emsdk = .{
|
|
||||||
.url = "git+https://github.com/emscripten-core/emsdk#4.0.9",
|
|
||||||
.hash = "N-V-__8AAJl1DwBezhYo_VE6f53mPVm00R-Fk28NPW7P14EQ",
|
|
||||||
},
|
|
||||||
.zemscripten = .{
|
|
||||||
.url = "git+https://github.com/zig-gamedev/zemscripten#3fa4b778852226c7346bdcc3c1486e875a9a6d02",
|
|
||||||
.hash = "zemscripten-0.2.0-dev-sRlDqApRAACspTbAZnuNKWIzfWzSYgYkb2nWAXZ-tqqt",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
.paths = .{
|
|
||||||
"build.zig",
|
|
||||||
"build.zig.zon",
|
|
||||||
"src",
|
|
||||||
"examples",
|
|
||||||
"LICENSE",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
include(CheckCCompilerFlag)
|
|
||||||
function(add_if_flag_compiles flag)
|
|
||||||
CHECK_C_COMPILER_FLAG("${flag}" COMPILER_HAS_THOSE_TOGGLES)
|
|
||||||
set(outcome "Failed")
|
|
||||||
if(COMPILER_HAS_THOSE_TOGGLES)
|
|
||||||
foreach(var ${ARGN})
|
|
||||||
set(${var} "${flag} ${${var}}" PARENT_SCOPE)
|
|
||||||
endforeach()
|
|
||||||
set(outcome "compiles")
|
|
||||||
endif()
|
|
||||||
message(STATUS "Testing if ${flag} can be used -- ${outcome}")
|
|
||||||
endfunction()
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
# Adding compile definitions
|
|
||||||
target_compile_definitions("raylib" PUBLIC "${PLATFORM_CPP}")
|
|
||||||
target_compile_definitions("raylib" PUBLIC "${GRAPHICS}")
|
|
||||||
|
|
||||||
function(define_if target variable)
|
|
||||||
if(${${variable}})
|
|
||||||
message(STATUS "${variable}=${${variable}}")
|
|
||||||
target_compile_definitions(${target} PRIVATE "${variable}")
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
if(${CUSTOMIZE_BUILD})
|
|
||||||
target_compile_definitions("raylib" PRIVATE EXTERNAL_CONFIG_FLAGS)
|
|
||||||
|
|
||||||
foreach(FLAG IN LISTS CONFIG_HEADER_FLAGS)
|
|
||||||
string(REGEX MATCH "([^=]+)=(.+)" _ ${FLAG})
|
|
||||||
define_if("raylib" ${CMAKE_MATCH_1})
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
foreach(VALUE IN LISTS CONFIG_HEADER_VALUES)
|
|
||||||
target_compile_definitions("raylib" PRIVATE ${VALUE})
|
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
|
|
@ -1,79 +0,0 @@
|
||||||
include(AddIfFlagCompiles)
|
|
||||||
|
|
||||||
# Makes +/- operations on void pointers be considered an error
|
|
||||||
# https://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html
|
|
||||||
add_if_flag_compiles(-Werror=pointer-arith CMAKE_C_FLAGS)
|
|
||||||
|
|
||||||
# Generates error whenever a function is used before being declared
|
|
||||||
# https://gcc.gnu.org/onlinedocs/gcc-4.0.1/gcc/Warning-Options.html
|
|
||||||
add_if_flag_compiles(-Werror=implicit-function-declaration CMAKE_C_FLAGS)
|
|
||||||
|
|
||||||
# Allows some casting of pointers without generating a warning
|
|
||||||
add_if_flag_compiles(-fno-strict-aliasing CMAKE_C_FLAGS)
|
|
||||||
|
|
||||||
if (ENABLE_MSAN AND ENABLE_ASAN)
|
|
||||||
# MSAN and ASAN both work on memory - ASAN does more things
|
|
||||||
MESSAGE(WARNING "Compiling with both AddressSanitizer and MemorySanitizer is not recommended")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (ENABLE_ASAN)
|
|
||||||
|
|
||||||
# If enabled it would generate errors/warnings for all kinds of memory errors
|
|
||||||
# (like returning a stack variable by reference)
|
|
||||||
# https://clang.llvm.org/docs/AddressSanitizer.html
|
|
||||||
|
|
||||||
add_if_flag_compiles(-fno-omit-frame-pointer CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
|
||||||
add_if_flag_compiles(-fsanitize=address CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
|
||||||
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (ENABLE_UBSAN)
|
|
||||||
|
|
||||||
# If enabled this will generate errors for undefined behavior points
|
|
||||||
# (like adding +1 to the maximum int value)
|
|
||||||
# https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
|
|
||||||
|
|
||||||
add_if_flag_compiles(-fno-omit-frame-pointer CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
|
||||||
add_if_flag_compiles(-fsanitize=undefined CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
|
||||||
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (ENABLE_MSAN)
|
|
||||||
|
|
||||||
# If enabled this will generate warnings for places where uninitialized memory is used
|
|
||||||
# https://clang.llvm.org/docs/MemorySanitizer.html
|
|
||||||
|
|
||||||
add_if_flag_compiles(-fno-omit-frame-pointer CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
|
||||||
add_if_flag_compiles(-fsanitize=memory CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
|
||||||
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_VERSION VERSION_LESS "3.1")
|
|
||||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
|
||||||
add_if_flag_compiles(-std=gnu99 CMAKE_C_FLAGS)
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
set (CMAKE_C_STANDARD 99)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(${PLATFORM} MATCHES "Android")
|
|
||||||
|
|
||||||
# If enabled will remove dead code during the linking process
|
|
||||||
# https://gcc.gnu.org/onlinedocs/gnat_ugn/Compilation-options.html
|
|
||||||
add_if_flag_compiles(-ffunction-sections CMAKE_C_FLAGS)
|
|
||||||
|
|
||||||
# If enabled will generate some exception data (usually disabled for C programs)
|
|
||||||
# https://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Code-Gen-Options.html
|
|
||||||
add_if_flag_compiles(-funwind-tables CMAKE_C_FLAGS)
|
|
||||||
|
|
||||||
# If enabled adds stack protection guards around functions that allocate memory
|
|
||||||
# https://www.keil.com/support/man/docs/armclang_ref/armclang_ref_cjh1548250046139.htm
|
|
||||||
add_if_flag_compiles(-fstack-protector-strong CMAKE_C_FLAGS)
|
|
||||||
|
|
||||||
# Marks that the library will not be compiled with an executable stack
|
|
||||||
add_if_flag_compiles(-Wa,--noexecstack CMAKE_C_FLAGS)
|
|
||||||
|
|
||||||
# Do not expand symbolic links or resolve paths like "/./" or "/../", etc.
|
|
||||||
# https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html
|
|
||||||
add_if_flag_compiles(-no-canonical-prefixes CMAKE_C_FLAGS)
|
|
||||||
endif()
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
macro(enum_option var values description)
|
|
||||||
set(${var}_VALUES ${values})
|
|
||||||
list(GET ${var}_VALUES 0 default)
|
|
||||||
set(${var} "${default}" CACHE STRING "${description}")
|
|
||||||
set_property(CACHE ${var} PROPERTY STRINGS ${${var}_VALUES})
|
|
||||||
if (NOT ";${${var}_VALUES};" MATCHES ";${${var}};")
|
|
||||||
message(FATAL_ERROR "Unknown value ${${var}}. Only -D${var}=${${var}_VALUES} allowed.")
|
|
||||||
endif()
|
|
||||||
endmacro()
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
|
|
||||||
if(USE_EXTERNAL_GLFW STREQUAL "ON")
|
|
||||||
find_package(glfw3 3.4 REQUIRED)
|
|
||||||
elseif(USE_EXTERNAL_GLFW STREQUAL "IF_POSSIBLE")
|
|
||||||
find_package(glfw3 3.4 QUIET)
|
|
||||||
endif()
|
|
||||||
if (glfw3_FOUND)
|
|
||||||
set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Explicitly check against "ON", because USE_EXTERNAL_GLFW is a tristate option
|
|
||||||
# Also adding only on desktop (web also uses glfw but it is more limited and is added using an emcc linker flag)
|
|
||||||
if(NOT glfw3_FOUND AND NOT USE_EXTERNAL_GLFW STREQUAL "ON" AND "${PLATFORM}" MATCHES "Desktop")
|
|
||||||
MESSAGE(STATUS "Using raylib's GLFW")
|
|
||||||
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
|
|
||||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
|
||||||
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
|
||||||
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
|
|
||||||
set(GLFW_LIBRARY_TYPE "OBJECT" CACHE STRING "" FORCE)
|
|
||||||
|
|
||||||
|
|
||||||
add_subdirectory(external/glfw)
|
|
||||||
|
|
||||||
# Hide glfw's symbols when building a shared lib
|
|
||||||
if (BUILD_SHARED_LIBS)
|
|
||||||
set_property(TARGET glfw PROPERTY C_VISIBILITY_PRESET hidden)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
list(APPEND raylib_sources $<TARGET_OBJECTS:glfw>)
|
|
||||||
include_directories(BEFORE SYSTEM external/glfw/include)
|
|
||||||
elseif("${PLATFORM}" STREQUAL "DRM")
|
|
||||||
MESSAGE(STATUS "No GLFW required on PLATFORM_DRM")
|
|
||||||
else()
|
|
||||||
MESSAGE(STATUS "Using external GLFW")
|
|
||||||
set(GLFW_PKG_DEPS glfw3)
|
|
||||||
endif()
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
install(
|
|
||||||
TARGETS raylib EXPORT raylib-targets
|
|
||||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
||||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
||||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
|
||||||
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# PKG_CONFIG_LIBS_PRIVATE is used in raylib.pc.in
|
|
||||||
if (NOT BUILD_SHARED_LIBS)
|
|
||||||
include(LibraryPathToLinkerFlags)
|
|
||||||
set(PKG_CONFIG_LIBS_PRIVATE ${GLFW_PKG_LIBS})
|
|
||||||
string(REPLACE ";" " " PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE}")
|
|
||||||
elseif (BUILD_SHARED_LIBS)
|
|
||||||
set(PKG_CONFIG_LIBS_EXTRA "")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
join_paths(libdir_for_pc_file "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}")
|
|
||||||
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
|
|
||||||
configure_file(../raylib.pc.in raylib.pc @ONLY)
|
|
||||||
configure_file(../cmake/raylib-config-version.cmake raylib-config-version.cmake @ONLY)
|
|
||||||
configure_file(../cmake/raylib-config.cmake raylib-config.cmake @ONLY)
|
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/raylib.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/raylib-config-version.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/raylib")
|
|
||||||
install(FILES
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/raylib-config-version.cmake"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/raylib-config.cmake"
|
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/raylib
|
|
||||||
)
|
|
||||||
install(EXPORT raylib-targets
|
|
||||||
FILE raylib-targets.cmake
|
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/raylib
|
|
||||||
)
|
|
||||||
|
|
||||||
# populates raylib_{FOUND, INCLUDE_DIRS, LIBRARIES, LDFLAGS, DEFINITIONS}
|
|
||||||
include(PopulateConfigVariablesLocally)
|
|
||||||
populate_config_variables_locally(raylib)
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
# This module provides function for joining paths
|
|
||||||
# known from most languages
|
|
||||||
#
|
|
||||||
# Original license:
|
|
||||||
# SPDX-License-Identifier: (MIT OR CC0-1.0)
|
|
||||||
# Explicit permission given to distribute this module under
|
|
||||||
# the terms of the project as described in /LICENSE.rst.
|
|
||||||
# Copyright 2020 Jan Tojnar
|
|
||||||
# https://github.com/jtojnar/cmake-snips
|
|
||||||
#
|
|
||||||
# Modelled after Python’s os.path.join
|
|
||||||
# https://docs.python.org/3.7/library/os.path.html#os.path.join
|
|
||||||
# Windows not supported
|
|
||||||
function(join_paths joined_path first_path_segment)
|
|
||||||
set(temp_path "${first_path_segment}")
|
|
||||||
foreach(current_segment IN LISTS ARGN)
|
|
||||||
if(NOT ("${current_segment}" STREQUAL ""))
|
|
||||||
if(IS_ABSOLUTE "${current_segment}")
|
|
||||||
set(temp_path "${current_segment}")
|
|
||||||
else()
|
|
||||||
set(temp_path "${temp_path}/${current_segment}")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
set(${joined_path} "${temp_path}" PARENT_SCOPE)
|
|
||||||
endfunction()
|
|
||||||
|
|
@ -1,274 +0,0 @@
|
||||||
# Set OpenGL_GL_PREFERENCE to new "GLVND" even when legacy library exists and
|
|
||||||
# cmake is <= 3.10
|
|
||||||
#
|
|
||||||
# See https://cmake.org/cmake/help/latest/policy/CMP0072.html for more
|
|
||||||
# information.
|
|
||||||
if(POLICY CMP0072)
|
|
||||||
cmake_policy(SET CMP0072 NEW)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(CheckCSourceCompiles)
|
|
||||||
include(CMakePushCheckState)
|
|
||||||
|
|
||||||
function(raylib_check_libatomic_required result)
|
|
||||||
set(_atomic_test_source "
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
volatile long long value = 0;
|
|
||||||
return (int)__atomic_fetch_add(&value, 1, __ATOMIC_SEQ_CST);
|
|
||||||
}")
|
|
||||||
|
|
||||||
check_c_source_compiles("${_atomic_test_source}" RAYLIB_ATOMICS_WITHOUT_LIBATOMIC)
|
|
||||||
|
|
||||||
if (RAYLIB_ATOMICS_WITHOUT_LIBATOMIC)
|
|
||||||
set(${result} FALSE PARENT_SCOPE)
|
|
||||||
else ()
|
|
||||||
cmake_push_check_state()
|
|
||||||
list(APPEND CMAKE_REQUIRED_LIBRARIES atomic)
|
|
||||||
check_c_source_compiles("${_atomic_test_source}" RAYLIB_ATOMICS_WITH_LIBATOMIC)
|
|
||||||
cmake_pop_check_state()
|
|
||||||
set(${result} ${RAYLIB_ATOMICS_WITH_LIBATOMIC} PARENT_SCOPE)
|
|
||||||
endif ()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
set(RAYLIB_DEPENDENCIES "include(CMakeFindDependencyMacro)")
|
|
||||||
|
|
||||||
if (${PLATFORM} STREQUAL "Desktop")
|
|
||||||
set(PLATFORM_CPP "PLATFORM_DESKTOP")
|
|
||||||
|
|
||||||
if (APPLE)
|
|
||||||
# Need to force OpenGL 3.3 on OS X
|
|
||||||
# See: https://github.com/raysan5/raylib/issues/341
|
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_33")
|
|
||||||
find_library(OPENGL_LIBRARY OpenGL)
|
|
||||||
set(LIBS_PRIVATE ${OPENGL_LIBRARY})
|
|
||||||
link_libraries("${LIBS_PRIVATE}")
|
|
||||||
if (NOT CMAKE_SYSTEM STRLESS "Darwin-18.0.0")
|
|
||||||
add_definitions(-DGL_SILENCE_DEPRECATION)
|
|
||||||
MESSAGE(AUTHOR_WARNING "OpenGL is deprecated starting with macOS 10.14 (Mojave)!")
|
|
||||||
endif ()
|
|
||||||
elseif (WIN32)
|
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
|
||||||
find_package(OpenGL QUIET)
|
|
||||||
set(LIBS_PRIVATE ${OPENGL_LIBRARIES} winmm)
|
|
||||||
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "QNX")
|
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
|
||||||
find_library(GLESV2 GLESv2)
|
|
||||||
find_library(EGL EGL)
|
|
||||||
set(LIBS_PUBLIC m)
|
|
||||||
set(LIBS_PRIVATE ${GLESV2} ${EGL} atomic pthread dl)
|
|
||||||
elseif (UNIX)
|
|
||||||
find_library(pthread NAMES pthread)
|
|
||||||
find_package(OpenGL QUIET)
|
|
||||||
if ("${OPENGL_LIBRARIES}" STREQUAL "")
|
|
||||||
set(OPENGL_LIBRARIES "GL")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD")
|
|
||||||
find_library(OSS_LIBRARY ossaudio)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
set(LIBS_PRIVATE pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
|
|
||||||
set(LIBS_PUBLIC m)
|
|
||||||
else ()
|
|
||||||
find_library(pthread NAMES pthread)
|
|
||||||
find_package(OpenGL QUIET)
|
|
||||||
if ("${OPENGL_LIBRARIES}" STREQUAL "")
|
|
||||||
set(OPENGL_LIBRARIES "GL")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
set(LIBS_PRIVATE pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
|
|
||||||
set(LIBS_PUBLIC m)
|
|
||||||
|
|
||||||
if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD")
|
|
||||||
find_library(OSS_LIBRARY ossaudio)
|
|
||||||
else ()
|
|
||||||
set(LIBS_PRIVATE ${LIBS_PRIVATE} atomic)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (NOT "${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD" AND USE_AUDIO)
|
|
||||||
set(LIBS_PRIVATE ${LIBS_PRIVATE} dl)
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
elseif (${PLATFORM} STREQUAL "Win32")
|
|
||||||
if ((NOT WIN32) AND (NOT CMAKE_C_COMPILER MATCHES "mingw|mingw32|mingw64"))
|
|
||||||
message(FATAL_ERROR "Win32 platform requires Windows or a cross compiler.")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
set(PLATFORM_CPP "PLATFORM_DESKTOP_WIN32")
|
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
|
||||||
|
|
||||||
if (${OPENGL_VERSION} MATCHES "Software")
|
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_SOFTWARE")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
find_package(OpenGL QUIET)
|
|
||||||
set(LIBS_PRIVATE ${OPENGL_LIBRARIES} winmm)
|
|
||||||
|
|
||||||
elseif (${PLATFORM} STREQUAL "Web")
|
|
||||||
set(PLATFORM_CPP "PLATFORM_WEB")
|
|
||||||
if(NOT GRAPHICS)
|
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
|
||||||
endif()
|
|
||||||
set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
|
|
||||||
|
|
||||||
elseif (${PLATFORM} STREQUAL "Android")
|
|
||||||
set(PLATFORM_CPP "PLATFORM_ANDROID")
|
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
list(APPEND raylib_sources ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
|
|
||||||
include_directories(${ANDROID_NDK}/sources/android/native_app_glue)
|
|
||||||
|
|
||||||
# NOTE: We remove '-Wl,--no-undefined' (set by default) as it conflicts with '-Wl,-undefined,dynamic_lookup' needed
|
|
||||||
# for compiling with the missing 'void main(void)' declaration in `android_main()`.
|
|
||||||
# We also remove other unnecessary or problematic flags.
|
|
||||||
|
|
||||||
string(REPLACE "-Wl,--no-undefined -Qunused-arguments" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
|
|
||||||
string(REPLACE "-static-libstdc++" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
|
|
||||||
|
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -u ANativeActivity_onCreate -Wl,-undefined,dynamic_lookup")
|
|
||||||
|
|
||||||
find_library(OPENGL_LIBRARY OpenGL)
|
|
||||||
set(LIBS_PRIVATE log android EGL GLESv2 OpenSLES atomic c)
|
|
||||||
set(LIBS_PUBLIC m)
|
|
||||||
|
|
||||||
elseif ("${PLATFORM}" STREQUAL "DRM")
|
|
||||||
set(PLATFORM_CPP "PLATFORM_DRM")
|
|
||||||
|
|
||||||
add_definitions(-D_DEFAULT_SOURCE)
|
|
||||||
add_definitions(-DPLATFORM_DRM)
|
|
||||||
|
|
||||||
find_library(DRM drm)
|
|
||||||
|
|
||||||
if (NOT CMAKE_CROSSCOMPILING OR NOT CMAKE_SYSROOT)
|
|
||||||
include_directories(/usr/include/libdrm)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if ("${OPENGL_VERSION}" STREQUAL "Software")
|
|
||||||
# software rendering does not require EGL/GBM.
|
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_SOFTWARE")
|
|
||||||
set(LIBS_PRIVATE ${DRM} atomic pthread dl)
|
|
||||||
else ()
|
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
|
||||||
add_definitions(-DEGL_NO_X11)
|
|
||||||
|
|
||||||
find_library(GLESV2 GLESv2)
|
|
||||||
find_library(EGL EGL)
|
|
||||||
find_library(GBM gbm)
|
|
||||||
|
|
||||||
set(LIBS_PRIVATE ${GLESV2} ${EGL} ${DRM} ${GBM} atomic pthread dl)
|
|
||||||
endif ()
|
|
||||||
set(LIBS_PUBLIC m)
|
|
||||||
|
|
||||||
elseif ("${PLATFORM}" STREQUAL "SDL")
|
|
||||||
# First, check if SDL is included as a subdirectory
|
|
||||||
if(TARGET SDL3::SDL3)
|
|
||||||
message(STATUS "Using SDL3 from subdirectory")
|
|
||||||
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
|
|
||||||
set(LIBS_PRIVATE SDL3::SDL3)
|
|
||||||
add_compile_definitions(USING_SDL3_PROJECT)
|
|
||||||
elseif(TARGET SDL2::SDL2)
|
|
||||||
message(STATUS "Using SDL2 from subdirectory")
|
|
||||||
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
|
|
||||||
set(LIBS_PRIVATE SDL2::SDL2)
|
|
||||||
add_compile_definitions(USING_SDL2_PROJECT)
|
|
||||||
else()
|
|
||||||
# No SDL added via add_subdirectory(), try find_package()
|
|
||||||
message(STATUS "No SDL target from subdirectory, searching via find_package()...")
|
|
||||||
|
|
||||||
# First try SDL3
|
|
||||||
find_package(SDL3 QUIET)
|
|
||||||
if(SDL3_FOUND)
|
|
||||||
message(STATUS "Found SDL3 via find_package()")
|
|
||||||
set(LIBS_PUBLIC SDL3::SDL3)
|
|
||||||
set(RAYLIB_DEPENDENCIES "${RAYLIB_DEPENDENCIES}\nfind_dependency(SDL3 REQUIRED)")
|
|
||||||
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
|
|
||||||
add_compile_definitions(USING_SDL3_PACKAGE)
|
|
||||||
else()
|
|
||||||
# Fallback to SDL2
|
|
||||||
find_package(SDL2 REQUIRED)
|
|
||||||
message(STATUS "Found SDL2 via find_package()")
|
|
||||||
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
|
|
||||||
set(LIBS_PUBLIC SDL2::SDL2)
|
|
||||||
set(RAYLIB_DEPENDENCIES "${RAYLIB_DEPENDENCIES}\nfind_dependency(SDL2 REQUIRED)")
|
|
||||||
add_compile_definitions(USING_SDL2_PACKAGE)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
elseif ("${PLATFORM}" STREQUAL "RGFW")
|
|
||||||
set(PLATFORM_CPP "PLATFORM_DESKTOP_RGFW")
|
|
||||||
|
|
||||||
if (APPLE)
|
|
||||||
find_library(COCOA Cocoa)
|
|
||||||
find_library(OPENGL OpenGL)
|
|
||||||
|
|
||||||
set(LIBS_PRIVATE ${COCOA} ${OPENGL})
|
|
||||||
elseif (WIN32)
|
|
||||||
find_package(OpenGL REQUIRED)
|
|
||||||
|
|
||||||
set(LIBS_PRIVATE ${OPENGL_LIBRARIES} gdi32)
|
|
||||||
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "QNX")
|
|
||||||
message(FATAL_ERROR "RGFW platform does not support QNX. Use PLATFORM=Desktop or PLATFORM=SDL instead.")
|
|
||||||
elseif (UNIX)
|
|
||||||
find_package(X11 REQUIRED)
|
|
||||||
find_package(OpenGL REQUIRED)
|
|
||||||
|
|
||||||
set(LIBS_PRIVATE ${X11_LIBRARIES} ${OPENGL_LIBRARIES})
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
elseif ("${PLATFORM}" STREQUAL "WebRGFW")
|
|
||||||
set(PLATFORM_CPP "PLATFORM_WEB_RGFW")
|
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
|
||||||
set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
|
|
||||||
|
|
||||||
elseif ("${PLATFORM}" STREQUAL "Memory")
|
|
||||||
set(PLATFORM_CPP "PLATFORM_MEMORY")
|
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_SOFTWARE")
|
|
||||||
set(OPENGL_VERSION "Software")
|
|
||||||
|
|
||||||
if(WIN32 OR CMAKE_C_COMPILER MATCHES "mingw|mingw32|mingw64")
|
|
||||||
set(LIBS_PRIVATE winmm)
|
|
||||||
endif()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (NOT ${OPENGL_VERSION} MATCHES "OFF")
|
|
||||||
set(SUGGESTED_GRAPHICS "${GRAPHICS}")
|
|
||||||
|
|
||||||
if (${OPENGL_VERSION} MATCHES "4.3")
|
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_43")
|
|
||||||
elseif (${OPENGL_VERSION} MATCHES "3.3")
|
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_33")
|
|
||||||
elseif (${OPENGL_VERSION} MATCHES "2.1")
|
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_21")
|
|
||||||
elseif (${OPENGL_VERSION} MATCHES "1.1")
|
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_11")
|
|
||||||
elseif (${OPENGL_VERSION} MATCHES "ES 2.0")
|
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
|
||||||
elseif (${OPENGL_VERSION} MATCHES "ES 3.0")
|
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_ES3")
|
|
||||||
elseif (${OPENGL_VERSION} MATCHES "Software")
|
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_SOFTWARE")
|
|
||||||
endif ()
|
|
||||||
if (NOT "${SUGGESTED_GRAPHICS}" STREQUAL "" AND NOT "${SUGGESTED_GRAPHICS}" STREQUAL "${GRAPHICS}")
|
|
||||||
message(WARNING "You are overriding the suggested GRAPHICS=${SUGGESTED_GRAPHICS} with ${GRAPHICS}! This may fail.")
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (NOT GRAPHICS)
|
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_33")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
set(LIBS_PRIVATE ${LIBS_PRIVATE} ${OPENAL_LIBRARY})
|
|
||||||
|
|
||||||
if (SUPPORT_MODULE_RAUDIO AND UNIX AND NOT APPLE)
|
|
||||||
raylib_check_libatomic_required(RAYLIB_LIBATOMIC_REQUIRED)
|
|
||||||
if (RAYLIB_LIBATOMIC_REQUIRED)
|
|
||||||
message(STATUS "64-bit atomics require libatomic")
|
|
||||||
list(APPEND LIBS_PRIVATE atomic)
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (${PLATFORM} MATCHES "Desktop")
|
|
||||||
set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
|
|
||||||
endif ()
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
function(library_path_to_linker_flags LD_FLAGS LIB_PATHS)
|
|
||||||
foreach(L ${LIB_PATHS})
|
|
||||||
get_filename_component(DIR ${L} PATH)
|
|
||||||
get_filename_component(LIBFILE ${L} NAME_WE)
|
|
||||||
STRING(REGEX REPLACE "^lib" "" FILE ${LIBFILE})
|
|
||||||
|
|
||||||
if (${L} MATCHES "[.]framework$")
|
|
||||||
set(FILE_OPT "-framework ${FILE}")
|
|
||||||
set(DIR_OPT "-F${DIR}")
|
|
||||||
else()
|
|
||||||
set(FILE_OPT "-l${FILE}")
|
|
||||||
set(DIR_OPT "-L${DIR}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if ("${DIR}" STREQUAL "" OR "${DIR}" STREQUAL "${LASTDIR}")
|
|
||||||
set (DIR_OPT "")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(LASTDIR ${DIR})
|
|
||||||
|
|
||||||
set(${LD_FLAGS} ${${LD_FLAGS}} ${DIR_OPT} ${FILE_OPT} PARENT_SCOPE)
|
|
||||||
string (REPLACE ";" " " ${LD_FLAGS} "${${LD_FLAGS}}")
|
|
||||||
endforeach()
|
|
||||||
endfunction()
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
# Packaging
|
|
||||||
SET(CPACK_PACKAGE_NAME "raylib")
|
|
||||||
SET(CPACK_PACKAGE_CONTACT "raysan5")
|
|
||||||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Simple and easy-to-use library to enjoy videogames programming")
|
|
||||||
SET(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
|
|
||||||
SET(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
|
|
||||||
SET(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
|
|
||||||
SET(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
|
|
||||||
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/../README.md")
|
|
||||||
SET(CPACK_RESOURCE_FILE_WELCOME "${PROJECT_SOURCE_DIR}/../README.md")
|
|
||||||
SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/../LICENSE")
|
|
||||||
SET(CPACK_PACKAGE_FILE_NAME "raylib-${PROJECT_VERSION}$ENV{RAYLIB_PACKAGE_SUFFIX}")
|
|
||||||
SET(CPACK_GENERATOR "ZIP;TGZ;DEB;RPM") # Remove this, if you want the NSIS installer on Windows
|
|
||||||
SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF) # can be used to generate deps, slow and requires tools.
|
|
||||||
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libatomic1, libc6, libglfw3, libglu1-mesa | libglu1, libglx0, libopengl0")
|
|
||||||
SET(CPACK_DEBIAN_PACKAGE_NAME "lib${CPACK_PACKAGE_NAME}-dev")
|
|
||||||
SET(CPACK_RPM_PACKAGE_NAME "lib${CPACK_PACKAGE_NAME}-devel")
|
|
||||||
include(CPack)
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/config.h" CONFIG_HEADER_CONTENT)
|
|
||||||
|
|
||||||
set(BLANK_OR_BACKSLASH_PATTERN "[ \t\r\n\\]")
|
|
||||||
set(VALID_IDENTIFIER_PATTERN "[A-Za-z_]+[A-Za-z_0-9]*")
|
|
||||||
set(VALID_VALUE_PATTERN [=["?[A-Za-z_0-9.-]+"?]=]) # not really correct but does the job since the config.h file hopefully will have been checked by a C preprocessor.
|
|
||||||
set(MACRO_REGEX "(//${BLANK_OR_BACKSLASH_PATTERN}*)?\#define${BLANK_OR_BACKSLASH_PATTERN}+(${VALID_IDENTIFIER_PATTERN})${BLANK_OR_BACKSLASH_PATTERN}+(${VALID_VALUE_PATTERN})")
|
|
||||||
|
|
||||||
string(REGEX MATCHALL ${MACRO_REGEX} MACRO_LIST ${CONFIG_HEADER_CONTENT})
|
|
||||||
|
|
||||||
set(CONFIG_HEADER_FLAGS ${MACRO_LIST})
|
|
||||||
list(FILTER CONFIG_HEADER_FLAGS INCLUDE REGEX "^.+SUPPORT_")
|
|
||||||
list(TRANSFORM CONFIG_HEADER_FLAGS REPLACE ${MACRO_REGEX} [[\2=OFF]] REGEX "^//")
|
|
||||||
list(TRANSFORM CONFIG_HEADER_FLAGS REPLACE ${MACRO_REGEX} [[\2=\3]] REGEX "^[^/]")
|
|
||||||
list(TRANSFORM CONFIG_HEADER_FLAGS REPLACE [[=0$]] [[=OFF]])
|
|
||||||
list(TRANSFORM CONFIG_HEADER_FLAGS REPLACE [[=1$]] [[=ON]])
|
|
||||||
|
|
||||||
set(CONFIG_HEADER_VALUES ${MACRO_LIST})
|
|
||||||
list(FILTER CONFIG_HEADER_VALUES EXCLUDE REGEX "(^.+SUPPORT_)|(^//)")
|
|
||||||
list(TRANSFORM CONFIG_HEADER_VALUES REPLACE ${MACRO_REGEX} [[\2=\3]])
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
macro(populate_config_variables_locally target)
|
|
||||||
get_property(raylib_INCLUDE_DIRS TARGET ${target} PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
|
||||||
#get_property(raylib_LIBRARIES TARGET ${target} PROPERTY LOCATION) # only works for SHARED
|
|
||||||
get_property(raylib_LDFLAGS TARGET ${target} PROPERTY INTERFACE_LINK_LIBRARIES)
|
|
||||||
get_property(raylib_DEFINITIONS TARGET ${target} PROPERTY DEFINITIONS)
|
|
||||||
|
|
||||||
set(raylib_INCLUDE_DIRS "${raylib_INCLUDE_DIRS}" PARENT_SCOPE)
|
|
||||||
#set(raylib_LIBRARIES "${raylib_INCLUDE_DIRS}" PARENT_SCOPE)
|
|
||||||
set(raylib_LDFLAGS "${raylib_LDFLAGS}" PARENT_SCOPE)
|
|
||||||
set(raylib_DEFINITIONS "${raylib_DEFINITIONS}" PARENT_SCOPE)
|
|
||||||
endmacro()
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
|
|
||||||
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
|
|
||||||
string(REGEX REPLACE "\n" ";" files "${files}")
|
|
||||||
foreach(file ${files})
|
|
||||||
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
|
|
||||||
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
|
||||||
exec_program(
|
|
||||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
|
||||||
OUTPUT_VARIABLE rm_out
|
|
||||||
RETURN_VALUE rm_retval
|
|
||||||
)
|
|
||||||
if(NOT "${rm_retval}" STREQUAL 0)
|
|
||||||
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
|
|
||||||
endif()
|
|
||||||
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
|
||||||
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
set(PACKAGE_VERSION "@PROJECT_VERSION@")
|
|
||||||
|
|
||||||
if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
|
|
||||||
set(PACKAGE_VERSION_EXACT TRUE)
|
|
||||||
endif()
|
|
||||||
if(NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
|
|
||||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
|
||||||
else(NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
|
|
||||||
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
|
||||||
endif(NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
|
|
||||||
|
|
||||||
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
|
|
||||||
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@CMAKE_SIZEOF_VOID_P@")
|
|
||||||
math(EXPR installedBits "8 * 8")
|
|
||||||
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
|
|
||||||
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
|
||||||
endif()
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
@PACKAGE_INIT@
|
|
||||||
@RAYLIB_DEPENDENCIES@
|
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/raylib-targets.cmake")
|
|
||||||
BIN
docs/cheatsheet.png
Normal file
|
After Width: | Height: | Size: 371 KiB |
|
|
@ -1,210 +0,0 @@
|
||||||
# Setup the project and settings
|
|
||||||
project(examples)
|
|
||||||
|
|
||||||
# Directories that contain examples
|
|
||||||
set(example_dirs
|
|
||||||
audio
|
|
||||||
core
|
|
||||||
models
|
|
||||||
others
|
|
||||||
shaders
|
|
||||||
shapes
|
|
||||||
text
|
|
||||||
textures
|
|
||||||
)
|
|
||||||
|
|
||||||
# Next few lines will check for existence of symbols or header files
|
|
||||||
# They are needed for the physac example and threads examples
|
|
||||||
set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=199309L)
|
|
||||||
include(CheckSymbolExists)
|
|
||||||
check_symbol_exists(CLOCK_MONOTONIC time.h HAVE_CLOCK_MONOTONIC)
|
|
||||||
check_symbol_exists(QueryPerformanceCounter windows.h HAVE_QPC)
|
|
||||||
set(CMAKE_REQUIRED_DEFINITIONS)
|
|
||||||
|
|
||||||
if (HAVE_QPC OR HAVE_CLOCK_MONOTONIC)
|
|
||||||
set(example_dirs ${example_dirs} physac)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
include(CheckIncludeFile)
|
|
||||||
CHECK_INCLUDE_FILE("stdatomic.h" HAVE_STDATOMIC_H)
|
|
||||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
|
||||||
find_package(Threads)
|
|
||||||
if (CMAKE_USE_PTHREADS_INIT AND HAVE_STDATOMIC_H)
|
|
||||||
add_if_flag_compiles("-std=c11" CMAKE_C_FLAGS)
|
|
||||||
if (THREADS_HAVE_PTHREAD_ARG)
|
|
||||||
add_if_flag_compiles("-pthread" CMAKE_C_FLAGS)
|
|
||||||
endif ()
|
|
||||||
if (CMAKE_THREAD_LIBS_INIT)
|
|
||||||
link_libraries("${CMAKE_THREAD_LIBS_INIT}")
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (APPLE AND NOT CMAKE_SYSTEM STRLESS "Darwin-18.0.0")
|
|
||||||
add_definitions(-DGL_SILENCE_DEPRECATION)
|
|
||||||
MESSAGE(AUTHOR_WARNING "OpenGL is deprecated starting with macOS 10.14 (Mojave)!")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# Collect all source files and resource files
|
|
||||||
# into a CMake variable
|
|
||||||
set(example_sources)
|
|
||||||
set(example_resources)
|
|
||||||
foreach (example_dir ${example_dirs})
|
|
||||||
# Get the .c files
|
|
||||||
file(GLOB sources ${example_dir}/*.c)
|
|
||||||
list(APPEND example_sources ${sources})
|
|
||||||
|
|
||||||
# Any any resources
|
|
||||||
file(GLOB resources ${example_dir}/resources/*)
|
|
||||||
list(APPEND example_resources ${resources})
|
|
||||||
endforeach ()
|
|
||||||
|
|
||||||
if(NOT CMAKE_USE_PTHREADS_INIT OR NOT HAVE_STDATOMIC_H)
|
|
||||||
# Items requiring pthreads
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_loading_thread.c)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (${PLATFORM} MATCHES "Android")
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/standard_lighting.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_picking.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_vr_simulator.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_camera_free.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_camera_first_person.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_world_screen.c)
|
|
||||||
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_cubicmap.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_skybox.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_generation.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_heightmap.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_billboard.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_rlgl_solar_system.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_rlgl_full_solar_system.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_solar_system.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_obj_viewer.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_animation.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_first_person_maze.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_magicavoxel_loading.c)
|
|
||||||
|
|
||||||
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_custom_uniform.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_model_shader.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_view_depth.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_postprocessing.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_raymarching.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_palette_switch.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_basic_lighting.c)
|
|
||||||
|
|
||||||
elseif (${PLATFORM} MATCHES "Web")
|
|
||||||
set(example_sources) # clear example_sources
|
|
||||||
list(APPEND example_sources core/core_input_gestures_testbed.c)
|
|
||||||
|
|
||||||
elseif ("${PLATFORM}" STREQUAL "DRM")
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/raylib_opengl_interop.c)
|
|
||||||
|
|
||||||
elseif ("${PLATFORM}" MATCHES "Memory")
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/raylib_opengl_interop.c)
|
|
||||||
|
|
||||||
elseif ("${OPENGL_VERSION}" STREQUAL "Software")
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/raylib_opengl_interop.c)
|
|
||||||
|
|
||||||
elseif (NOT SUPPORT_GESTURES_SYSTEM)
|
|
||||||
# Items requiring gestures system
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/textures/textures_mouse_painting.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_basic_screen_manager.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_input_gestures_web.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_input_gestures.c)
|
|
||||||
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# The rlgl_standalone example only targets desktop, without shared libraries.
|
|
||||||
if (BUILD_SHARED_LIBS OR NOT ${PLATFORM} MATCHES "Desktop")
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# The audio examples fail to link if raylib is built without raudio
|
|
||||||
if (NOT SUPPORT_MODULE_RAUDIO)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/audio/audio_mixed_processor.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/audio/audio_module_playing.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/audio/audio_music_stream.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/audio/audio_raw_stream.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/audio/audio_sound_loading.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/audio/audio_sound_multi.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/audio/audio_stream_effects.c)
|
|
||||||
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/embedded_files_loading.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/textures/textures_sprite_button.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/textures/textures_sprite_explosion.c)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include_directories(BEFORE SYSTEM others/external/include)
|
|
||||||
|
|
||||||
if (NOT TARGET raylib)
|
|
||||||
find_package(raylib 2.0 REQUIRED)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# Do each example
|
|
||||||
foreach (example_source ${example_sources})
|
|
||||||
# Create the basename for the example
|
|
||||||
get_filename_component(example_name ${example_source} NAME)
|
|
||||||
string(REPLACE ".c" "" example_name ${example_name})
|
|
||||||
|
|
||||||
# Setup the example
|
|
||||||
add_executable(${example_name} ${example_source})
|
|
||||||
|
|
||||||
target_link_libraries(${example_name} raylib)
|
|
||||||
if (NOT WIN32)
|
|
||||||
target_link_libraries(${example_name} m)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
string(REGEX MATCH ".*/.*/" resources_dir ${example_source})
|
|
||||||
string(APPEND resources_dir "resources")
|
|
||||||
|
|
||||||
if (${PLATFORM} MATCHES "Web")
|
|
||||||
target_compile_options(${example_name} PRIVATE -Os)
|
|
||||||
target_link_options(${example_name} PRIVATE
|
|
||||||
-sALLOW_MEMORY_GROWTH=1
|
|
||||||
-sEXPORTED_RUNTIME_METHODS=[requestFullscreen]
|
|
||||||
-sUSE_GLFW=3
|
|
||||||
--shell-file "${CMAKE_SOURCE_DIR}/src/shell.html"
|
|
||||||
)
|
|
||||||
set_target_properties(${example_name} PROPERTIES SUFFIX ".html")
|
|
||||||
|
|
||||||
if (EXISTS ${resources_dir})
|
|
||||||
# The local resources path needs to be mapped to /resources virtual path
|
|
||||||
string(APPEND resources_dir "@resources")
|
|
||||||
set_target_properties(${example_name} PROPERTIES LINK_FLAGS "--preload-file ${resources_dir}")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if(${GRAPHICS} MATCHES "GRAPHICS_API_OPENGL_ES3")
|
|
||||||
target_link_options(${example_name} PUBLIC "-sMIN_WEBGL_VERSION=2")
|
|
||||||
target_link_options(${example_name} PUBLIC "-sMAX_WEBGL_VERSION=2")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Checks if OSX and links appropriate frameworks (Only required on MacOS)
|
|
||||||
if (APPLE)
|
|
||||||
target_link_libraries(${example_name} "-framework IOKit")
|
|
||||||
target_link_libraries(${example_name} "-framework Cocoa")
|
|
||||||
target_link_libraries(${example_name} "-framework OpenGL")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
elseif (${PLATFORM} MATCHES "RGFW")
|
|
||||||
if (APPLE)
|
|
||||||
target_link_libraries(${example_name} "-framework IOKit")
|
|
||||||
target_link_libraries(${example_name} "-framework Cocoa")
|
|
||||||
target_link_libraries(${example_name} "-framework OpenGL")
|
|
||||||
elseif (WIN32)
|
|
||||||
target_link_libraries(${example_name} "-lgdi32")
|
|
||||||
target_link_libraries(${example_name} "-lwinmm")
|
|
||||||
elseif (UNIX)
|
|
||||||
target_link_libraries(${example_name} "-lX11")
|
|
||||||
target_link_libraries(${example_name} "-lXrandr")
|
|
||||||
endif()
|
|
||||||
endif ()
|
|
||||||
endforeach ()
|
|
||||||
|
|
||||||
# Copy all of the resource files to the destination
|
|
||||||
file(COPY ${example_resources} DESTINATION "resources/")
|
|
||||||
|
|
@ -1,827 +0,0 @@
|
||||||
#**************************************************************************************************
|
|
||||||
#
|
|
||||||
# raylib makefile for multiple platforms
|
|
||||||
#
|
|
||||||
# This file supports building raylib examples for the following platforms:
|
|
||||||
#
|
|
||||||
# > PLATFORM_DESKTOP
|
|
||||||
# - Defaults to PLATFORM_DESKTOP_GLFW
|
|
||||||
# > PLATFORM_DESKTOP_GFLW (GLFW backend):
|
|
||||||
# - Windows (Win32, Win64)
|
|
||||||
# - Linux (X11/Wayland desktop mode)
|
|
||||||
# - macOS/OSX (x64, arm64)
|
|
||||||
# - FreeBSD, OpenBSD, NetBSD, DragonFly (X11 desktop)
|
|
||||||
# > PLATFORM_DESKTOP_SDL (SDL backend):
|
|
||||||
# - Windows (Win32, Win64)
|
|
||||||
# - Linux (X11/Wayland desktop mode)
|
|
||||||
# - Others (not tested)
|
|
||||||
# > PLATFORM_DESKTOP_RGFW (RGFW backend):
|
|
||||||
# - Windows (Win32, Win64)
|
|
||||||
# - Linux (X11 desktop mode)
|
|
||||||
# - macOS/OSX (x64, arm64 (not tested))
|
|
||||||
# - Others (not tested)
|
|
||||||
# > PLATFORM_DESKTOP_WIN32 (native Win32):
|
|
||||||
# - Windows (Win32, Win64)
|
|
||||||
# > PLATFORM_WEB_RGFW:
|
|
||||||
# - HTML5 (WebAssembly)
|
|
||||||
# > PLATFORM_WEB:
|
|
||||||
# - HTML5 (WebAssembly)
|
|
||||||
# > PLATFORM_DRM:
|
|
||||||
# - Raspberry Pi 0-5 (DRM/KMS)
|
|
||||||
# - Linux DRM subsystem (KMS mode)
|
|
||||||
# > PLATFORM_ANDROID:
|
|
||||||
# - Android (ARM, ARM64)
|
|
||||||
#
|
|
||||||
# Copyright (c) 2013-2026 Ramon Santamaria (@raysan5)
|
|
||||||
#
|
|
||||||
# This software is provided "as-is", without any express or implied warranty. In no event
|
|
||||||
# will the authors be held liable for any damages arising from the use of this software.
|
|
||||||
#
|
|
||||||
# Permission is granted to anyone to use this software for any purpose, including commercial
|
|
||||||
# applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
|
||||||
#
|
|
||||||
# 1. The origin of this software must not be misrepresented; you must not claim that you
|
|
||||||
# wrote the original software. If you use this software in a product, an acknowledgment
|
|
||||||
# in the product documentation would be appreciated but is not required.
|
|
||||||
#
|
|
||||||
# 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
|
||||||
# as being the original software.
|
|
||||||
#
|
|
||||||
# 3. This notice may not be removed or altered from any source distribution.
|
|
||||||
#
|
|
||||||
#**************************************************************************************************
|
|
||||||
|
|
||||||
.PHONY: all clean
|
|
||||||
|
|
||||||
# Define required environment variables
|
|
||||||
#------------------------------------------------------------------------------------------------
|
|
||||||
# Define target platform: PLATFORM_DESKTOP, PLATFORM_DESKTOP_SDL, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB, PLATFORM_WEB_RGFW
|
|
||||||
PLATFORM ?= PLATFORM_DESKTOP
|
|
||||||
|
|
||||||
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW))
|
|
||||||
TARGET_PLATFORM := $(PLATFORM)
|
|
||||||
override PLATFORM = PLATFORM_DESKTOP
|
|
||||||
else
|
|
||||||
ifeq ($(PLATFORM), PLATFORM_DESKTOP)
|
|
||||||
TARGET_PLATFORM = PLATFORM_DESKTOP_GLFW
|
|
||||||
else
|
|
||||||
TARGET_PLATFORM = $(PLATFORM)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define required raylib variables
|
|
||||||
PROJECT_NAME ?= raylib_examples
|
|
||||||
RAYLIB_VERSION ?= 6.0.0
|
|
||||||
RAYLIB_PATH ?= ..
|
|
||||||
|
|
||||||
# Define raylib source code path
|
|
||||||
RAYLIB_SRC_PATH ?= ../src
|
|
||||||
|
|
||||||
# Locations of raylib.h and libraylib.a/libraylib.so
|
|
||||||
# NOTE: Those variables are only used for PLATFORM_OS: LINUX, BSD
|
|
||||||
DESTDIR ?= /usr/local
|
|
||||||
RAYLIB_INCLUDE_PATH ?= $(DESTDIR)/include
|
|
||||||
RAYLIB_LIB_PATH ?= $(DESTDIR)/lib
|
|
||||||
|
|
||||||
# Library type compilation: STATIC (.a) or SHARED (.so/.dll)
|
|
||||||
RAYLIB_LIBTYPE ?= STATIC
|
|
||||||
|
|
||||||
# Build mode for project: DEBUG or RELEASE
|
|
||||||
BUILD_MODE ?= RELEASE
|
|
||||||
|
|
||||||
# Use external GLFW library instead of rglfw module
|
|
||||||
USE_EXTERNAL_GLFW ?= FALSE
|
|
||||||
|
|
||||||
# Enable support for X11 by default on Linux when using GLFW
|
|
||||||
# NOTE: Wayland is disabled by default, only enable if you are sure
|
|
||||||
GLFW_LINUX_ENABLE_WAYLAND ?= FALSE
|
|
||||||
GLFW_LINUX_ENABLE_X11 ?= TRUE
|
|
||||||
|
|
||||||
# Enable support for X11 by default on Linux when using RGFW
|
|
||||||
# NOTE: Wayland is disabled by default, only enable if you are sure
|
|
||||||
RGFW_LINUX_ENABLE_WAYLAND ?= FALSE
|
|
||||||
RGFW_LINUX_ENABLE_X11 ?= TRUE
|
|
||||||
|
|
||||||
# PLATFORM_DESKTOP_SDL: It requires SDL library to be provided externally
|
|
||||||
# WARNING: Library is not included in raylib, it MUST be configured by users
|
|
||||||
SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include
|
|
||||||
SDL_LIBRARY_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/lib
|
|
||||||
SDL_LIBRARIES ?= -lSDL2 -lSDL2main
|
|
||||||
|
|
||||||
# Use Wayland display server protocol on Linux desktop (by default it uses X11 windowing system)
|
|
||||||
# NOTE: This variable is only used for PLATFORM_OS: LINUX
|
|
||||||
USE_WAYLAND_DISPLAY ?= FALSE
|
|
||||||
|
|
||||||
# PLATFORM_WEB: Default properties
|
|
||||||
BUILD_WEB_ASYNCIFY ?= TRUE
|
|
||||||
BUILD_WEB_SHELL ?= $(RAYLIB_PATH)/src/minshell.html
|
|
||||||
BUILD_WEB_HEAP_SIZE ?= 134217728
|
|
||||||
BUILD_WEB_RESOURCES ?= TRUE
|
|
||||||
BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources
|
|
||||||
# Use WebGL2 backend (OpenGL 3.0)
|
|
||||||
# WARNING: Requires raylib compiled with GRAPHICS_API_OPENGL_ES3
|
|
||||||
BUILD_WEB_WEBGL2 ?= FALSE
|
|
||||||
|
|
||||||
# Determine PLATFORM_OS when required
|
|
||||||
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW PLATFORM_WEB PLATFORM_WEB_RGFW))
|
|
||||||
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
|
|
||||||
# ifeq ($(UNAME),Msys) -> Windows
|
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
PLATFORM_OS = WINDOWS
|
|
||||||
else
|
|
||||||
UNAMEOS = $(shell uname)
|
|
||||||
ifeq ($(UNAMEOS),Linux)
|
|
||||||
PLATFORM_OS = LINUX
|
|
||||||
endif
|
|
||||||
ifeq ($(UNAMEOS),FreeBSD)
|
|
||||||
PLATFORM_OS = BSD
|
|
||||||
endif
|
|
||||||
ifeq ($(UNAMEOS),OpenBSD)
|
|
||||||
PLATFORM_OS = BSD
|
|
||||||
endif
|
|
||||||
ifeq ($(UNAMEOS),NetBSD)
|
|
||||||
PLATFORM_OS = BSD
|
|
||||||
endif
|
|
||||||
ifeq ($(UNAMEOS),DragonFly)
|
|
||||||
PLATFORM_OS = BSD
|
|
||||||
endif
|
|
||||||
ifeq ($(UNAMEOS),Darwin)
|
|
||||||
PLATFORM_OS = OSX
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
|
|
||||||
UNAMEOS = $(shell uname)
|
|
||||||
ifeq ($(UNAMEOS),Linux)
|
|
||||||
PLATFORM_OS = LINUX
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Default path for raylib on Raspberry Pi
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
|
|
||||||
RAYLIB_PATH ?= /home/pi/raylib
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define raylib release directory for compiled library
|
|
||||||
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src
|
|
||||||
|
|
||||||
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
|
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
|
||||||
# Emscripten required variables
|
|
||||||
EMSDK_PATH ?= C:/raylib/emsdk
|
|
||||||
EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten
|
|
||||||
CLANG_PATH = $(EMSDK_PATH)/upstream/bin
|
|
||||||
PYTHON_PATH = $(EMSDK_PATH)/python/3.13.3_64bit
|
|
||||||
NODE_PATH = $(EMSDK_PATH)/node/22.16.0_64bit/bin
|
|
||||||
export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH):$$(PATH)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define default C compiler: CC
|
|
||||||
#------------------------------------------------------------------------------------------------
|
|
||||||
CC = gcc
|
|
||||||
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
|
||||||
ifeq ($(PLATFORM_OS),OSX)
|
|
||||||
# OSX default compiler
|
|
||||||
CC = clang
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
|
||||||
# FreeBSD, OpenBSD, NetBSD, DragonFly default compiler
|
|
||||||
CC = clang
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
|
|
||||||
# HTML5 emscripten compiler
|
|
||||||
# WARNING: To compile to HTML5, code must be redesigned
|
|
||||||
# to use emscripten.h and emscripten_set_main_loop()
|
|
||||||
CC = emcc
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define default make program: MAKE
|
|
||||||
#------------------------------------------------------------------------------------------------
|
|
||||||
MAKE ?= make
|
|
||||||
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
|
||||||
MAKE = mingw32-make
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
|
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
|
||||||
MAKE = mingw32-make
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
|
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
|
||||||
MAKE = mingw32-make
|
|
||||||
else
|
|
||||||
EMMAKE := $(shell command -v emmake)
|
|
||||||
ifneq (, $(EMMAKE))
|
|
||||||
MAKE = $(EMMAKE) make
|
|
||||||
else
|
|
||||||
MAKE = mingw32-make
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define compiler flags: CFLAGS
|
|
||||||
#------------------------------------------------------------------------------------------------
|
|
||||||
# -O1 defines optimization level
|
|
||||||
# -g include debug information on compilation
|
|
||||||
# -s strip unnecessary data from build
|
|
||||||
# -Wall turns on most, but not all, compiler warnings
|
|
||||||
# -std=c99 defines C language mode (standard C from 1999 revision)
|
|
||||||
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
|
||||||
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
|
|
||||||
# -Wno-unused-value ignore unused return values of some functions (i.e. fread())
|
|
||||||
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
|
|
||||||
CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wno-unused-result
|
|
||||||
|
|
||||||
ifeq ($(BUILD_MODE),DEBUG)
|
|
||||||
CFLAGS += -g -D_DEBUG
|
|
||||||
else
|
|
||||||
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
|
|
||||||
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
|
|
||||||
CFLAGS += -O3
|
|
||||||
else
|
|
||||||
CFLAGS += -Os
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
CFLAGS += -O2
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Additional flags for compiler (if desired)
|
|
||||||
# -Wextra enables some extra warning flags that are not enabled by -Wall
|
|
||||||
# -Wmissing-prototypes warn if a global function is defined without a previous prototype declaration
|
|
||||||
# -Wstrict-prototypes warn if a function is declared or defined without specifying the argument types
|
|
||||||
# -Werror=implicit-function-declaration catch function calls without prior declaration
|
|
||||||
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
|
||||||
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
|
||||||
CFLAGS += -D_DEFAULT_SOURCE
|
|
||||||
endif
|
|
||||||
ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
|
||||||
# Explicitly enable runtime link to libraylib.so
|
|
||||||
CFLAGS += -Wl,-rpath,$(RAYLIB_RELEASE_PATH)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
|
|
||||||
CFLAGS += -std=gnu99 -DEGL_NO_X11
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define include paths for required headers: INCLUDE_PATHS
|
|
||||||
# NOTE: Some external/extras libraries could be required (stb, easings...)
|
|
||||||
#------------------------------------------------------------------------------------------------
|
|
||||||
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external $(EXTRA_INCLUDE_PATHS)
|
|
||||||
|
|
||||||
# Define additional directories containing required header files
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
|
||||||
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH) -I/usr/pkg/include -I/usr/X11R7/include
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
|
||||||
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
|
|
||||||
INCLUDE_PATHS += -I$(SDL_INCLUDE_PATH)
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
|
|
||||||
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
|
|
||||||
INCLUDE_PATHS += -I/usr/include/libdrm
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define library paths containing required libs: LDFLAGS
|
|
||||||
#------------------------------------------------------------------------------------------------
|
|
||||||
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH)
|
|
||||||
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
|
||||||
# NOTE: The resource .rc file contains windows executable icon and properties
|
|
||||||
LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data
|
|
||||||
# -Wl,--subsystem,windows hides the console window
|
|
||||||
ifeq ($(BUILD_MODE), RELEASE)
|
|
||||||
LDFLAGS += -Wl,--subsystem,windows
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
|
||||||
LDFLAGS += -L$(RAYLIB_LIB_PATH)
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
|
||||||
LDFLAGS += -Lsrc -L$(RAYLIB_LIB_PATH)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
|
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
|
||||||
# NOTE: The resource .rc file contains windows executable icon and properties
|
|
||||||
LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data
|
|
||||||
# -Wl,--subsystem,windows hides the console window
|
|
||||||
ifeq ($(BUILD_MODE), RELEASE)
|
|
||||||
LDFLAGS += -Wl,--subsystem,windows
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
LDFLAGS += -L$(SDL_LIBRARY_PATH)
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
|
|
||||||
# -Os # size optimization
|
|
||||||
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
|
||||||
# -sUSE_GLFW=3 # Use glfw3 library (context/input management)
|
|
||||||
# -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
|
|
||||||
# -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB)
|
|
||||||
# -sUSE_PTHREADS=1 # multithreading support
|
|
||||||
# -sWASM=0 # disable Web Assembly, emitted by default
|
|
||||||
# -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
|
|
||||||
# -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data
|
|
||||||
# -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off)
|
|
||||||
# -sMINIFY_HTML=0 # minify generated html from shell.html
|
|
||||||
# --profiling # include information for code profiling
|
|
||||||
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
|
||||||
# --preload-file resources # specify a resources folder for data compilation
|
|
||||||
# --source-map-base # allow debugging in browser with source map
|
|
||||||
# --shell-file shell.html # define a custom shell .html and output extension
|
|
||||||
LDFLAGS += -sTOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -sFORCE_FILESYSTEM=1 -sEXPORTED_RUNTIME_METHODS=ccall -sMINIFY_HTML=0
|
|
||||||
|
|
||||||
# Using GLFW3 library (instead of RGFW)
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
|
|
||||||
LDFLAGS += -sUSE_GLFW=3
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Build using asyncify
|
|
||||||
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
|
|
||||||
LDFLAGS += -sASYNCIFY
|
|
||||||
endif
|
|
||||||
|
|
||||||
# NOTE: Flags required for WebGL 2.0 (OpenGL ES 3.0)
|
|
||||||
# WARNING: Requires raylib compiled with GRAPHICS_API_OPENGL_ES3
|
|
||||||
ifeq ($(BUILD_WEB_WEBGL2),TRUE)
|
|
||||||
LDFLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Add resources building if required
|
|
||||||
ifeq ($(BUILD_WEB_RESOURCES),TRUE)
|
|
||||||
LDFLAGS += --preload-file $(BUILD_WEB_RESOURCES_PATH)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Add debug mode flags if required
|
|
||||||
ifeq ($(BUILD_MODE),DEBUG)
|
|
||||||
LDFLAGS += -sASSERTIONS=1 --profiling
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define a custom shell .html and output extension
|
|
||||||
LDFLAGS += --shell-file $(BUILD_WEB_SHELL)
|
|
||||||
EXT = .html
|
|
||||||
|
|
||||||
# NOTE: Simple raylib examples are compiled to be interpreter with asyncify, that way,
|
|
||||||
# we can compile same code for ALL platforms with no change required, but, working on bigger
|
|
||||||
# projects, code needs to be refactored to avoid a blocking while() loop, moving Update and Draw
|
|
||||||
# logic to a self contained function: UpdateDrawFrame(), check core_basic_window_web.c for reference.
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define libraries required on linking: LDLIBS
|
|
||||||
# NOTE: To link libraries (lib<name>.so or lib<name>.a), use -l<name>
|
|
||||||
#------------------------------------------------------------------------------------------------
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
|
||||||
# Libraries for Windows desktop compilation
|
|
||||||
# NOTE: WinMM library required to set high-res timer resolution
|
|
||||||
LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
|
||||||
# Libraries for Debian GNU/Linux desktop compiling
|
|
||||||
# NOTE: Required packages: libegl1-mesa-dev
|
|
||||||
LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
|
|
||||||
|
|
||||||
# On Wayland, additional libraries requires
|
|
||||||
ifeq ($(GLFW_LINUX_ENABLE_WAYLAND),TRUE)
|
|
||||||
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(GLFW_LINUX_ENABLE_X11),TRUE)
|
|
||||||
# On X11, additional libraries required
|
|
||||||
LDLIBS += -lX11
|
|
||||||
# NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
|
|
||||||
#LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
|
|
||||||
endif
|
|
||||||
# Explicit link to libc
|
|
||||||
ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
|
||||||
LDLIBS += -lc
|
|
||||||
endif
|
|
||||||
|
|
||||||
# NOTE: On ARM 32bit arch, miniaudio requires atomics library
|
|
||||||
LDLIBS += -latomic
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),OSX)
|
|
||||||
# Libraries for OSX 10.9 desktop compiling
|
|
||||||
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
|
|
||||||
LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
|
||||||
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
|
||||||
# NOTE: Required packages: mesa-libs
|
|
||||||
LDFLAGS += -L/usr/X11R7/lib -Wl,-R/usr/X11R7/lib
|
|
||||||
LDLIBS = -lraylib -lGL -lm -lpthread
|
|
||||||
|
|
||||||
# On XWindow requires also below libraries
|
|
||||||
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
|
|
||||||
endif
|
|
||||||
ifeq ($(USE_EXTERNAL_GLFW),TRUE)
|
|
||||||
# NOTE: It could require additional packages installed: libglfw3-dev
|
|
||||||
LDLIBS += -lglfw
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
|
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
|
||||||
# Libraries for Windows desktop compilation
|
|
||||||
LDLIBS = -lraylib $(SDL_LIBRARIES) -lopengl32 -lgdi32
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
|
||||||
# Libraries for Debian GNU/Linux desktop compiling
|
|
||||||
# NOTE: Required packages: libegl1-mesa-dev
|
|
||||||
LDLIBS = -lraylib $(SDL_LIBRARIES) -lGL -lm -lpthread -ldl -lrt
|
|
||||||
|
|
||||||
# On X11, addition libraries required
|
|
||||||
LDLIBS += -lX11
|
|
||||||
# NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
|
|
||||||
#LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
|
|
||||||
|
|
||||||
# On Wayland, additional libraries requires
|
|
||||||
ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
|
|
||||||
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Explicit link to libc
|
|
||||||
ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
|
||||||
LDLIBS += -lc
|
|
||||||
endif
|
|
||||||
|
|
||||||
# NOTE: On ARM 32bit arch, miniaudio requires atomics library
|
|
||||||
LDLIBS += -latomic
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
|
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
|
||||||
# Libraries for Windows desktop compilation
|
|
||||||
LDFLAGS += -L..\src
|
|
||||||
LDLIBS = -lraylib -lgdi32 -lwinmm -lopengl32
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
|
||||||
# Libraries for Debian GNU/Linux desktop compipling
|
|
||||||
# NOTE: Required packages: libegl1-mesa-dev
|
|
||||||
LDFLAGS += -L../src
|
|
||||||
LDLIBS = -lraylib -lm
|
|
||||||
|
|
||||||
ifeq ($(RGFW_LINUX_ENABLE_X11),TRUE)
|
|
||||||
LDLIBS += -lGL -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lpthread -ldl -lrt
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE)
|
|
||||||
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Explicit link to libc
|
|
||||||
ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
|
||||||
LDLIBS += -lc
|
|
||||||
endif
|
|
||||||
|
|
||||||
# NOTE: On ARM 32bit arch, miniaudio requires atomics library
|
|
||||||
LDLIBS += -latomic
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),OSX)
|
|
||||||
# Libraries for Debian GNU/Linux desktop compiling
|
|
||||||
# NOTE: Required packages: libegl1-mesa-dev
|
|
||||||
LDFLAGS += -L../src
|
|
||||||
LDLIBS = -lraylib -lm
|
|
||||||
LDLIBS += -framework Foundation -framework AppKit -framework IOKit -framework OpenGL -framework CoreVideo
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
|
|
||||||
# Libraries for DRM compiling
|
|
||||||
# NOTE: Required packages: libasound2-dev (ALSA)
|
|
||||||
LDLIBS = -lraylib -lGLESv2 -lEGL -ldrm -lgbm -lpthread -lrt -lm -ldl -latomic
|
|
||||||
# TODO: Examples compilation does not define GRAPHICS, is it required?
|
|
||||||
#ifeq ($(GRAPHICS),GRAPHICS_API_OPENGL_ES2)
|
|
||||||
# LDLIBS += -lGLESv2 -lEGL
|
|
||||||
#endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_WIN32)
|
|
||||||
# Libraries for Windows desktop compilation
|
|
||||||
LDFLAGS += -L..\src
|
|
||||||
LDLIBS = -lraylib -lgdi32 -lwinmm -lshcore
|
|
||||||
ifneq ($(GRAPHICS),GRAPHICS_API_OPENGL_SOFTWARE)
|
|
||||||
LDLIBS += -lopengl32
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
|
|
||||||
# Libraries for web (HTML5) compiling
|
|
||||||
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.web.a
|
|
||||||
endif
|
|
||||||
|
|
||||||
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
|
|
||||||
|
|
||||||
# Define source code object files required
|
|
||||||
#------------------------------------------------------------------------------------------------
|
|
||||||
#EXAMPLES_LIST_START
|
|
||||||
CORE = \
|
|
||||||
core/core_2d_camera \
|
|
||||||
core/core_2d_camera_mouse_zoom \
|
|
||||||
core/core_2d_camera_platformer \
|
|
||||||
core/core_2d_camera_split_screen \
|
|
||||||
core/core_3d_camera_first_person \
|
|
||||||
core/core_3d_camera_fps \
|
|
||||||
core/core_3d_camera_free \
|
|
||||||
core/core_3d_camera_mode \
|
|
||||||
core/core_3d_camera_split_screen \
|
|
||||||
core/core_3d_picking \
|
|
||||||
core/core_automation_events \
|
|
||||||
core/core_basic_screen_manager \
|
|
||||||
core/core_basic_window \
|
|
||||||
core/core_clipboard_text \
|
|
||||||
core/core_compute_hash \
|
|
||||||
core/core_custom_frame_control \
|
|
||||||
core/core_custom_logging \
|
|
||||||
core/core_delta_time \
|
|
||||||
core/core_directory_files \
|
|
||||||
core/core_drop_files \
|
|
||||||
core/core_highdpi_demo \
|
|
||||||
core/core_highdpi_testbed \
|
|
||||||
core/core_input_actions \
|
|
||||||
core/core_input_gamepad \
|
|
||||||
core/core_input_gestures \
|
|
||||||
core/core_input_gestures_testbed \
|
|
||||||
core/core_input_keys \
|
|
||||||
core/core_input_mouse \
|
|
||||||
core/core_input_mouse_wheel \
|
|
||||||
core/core_input_multitouch \
|
|
||||||
core/core_input_virtual_controls \
|
|
||||||
core/core_keyboard_testbed \
|
|
||||||
core/core_monitor_detector \
|
|
||||||
core/core_random_sequence \
|
|
||||||
core/core_random_values \
|
|
||||||
core/core_render_texture \
|
|
||||||
core/core_scissor_test \
|
|
||||||
core/core_screen_recording \
|
|
||||||
core/core_smooth_pixelperfect \
|
|
||||||
core/core_storage_values \
|
|
||||||
core/core_text_file_loading \
|
|
||||||
core/core_undo_redo \
|
|
||||||
core/core_viewport_scaling \
|
|
||||||
core/core_vr_simulator \
|
|
||||||
core/core_window_flags \
|
|
||||||
core/core_window_letterbox \
|
|
||||||
core/core_window_should_close \
|
|
||||||
core/core_window_web \
|
|
||||||
core/core_world_screen
|
|
||||||
|
|
||||||
SHAPES = \
|
|
||||||
shapes/shapes_ball_physics \
|
|
||||||
shapes/shapes_basic_shapes \
|
|
||||||
shapes/shapes_bouncing_ball \
|
|
||||||
shapes/shapes_bullet_hell \
|
|
||||||
shapes/shapes_circle_sector_drawing \
|
|
||||||
shapes/shapes_clock_of_clocks \
|
|
||||||
shapes/shapes_collision_area \
|
|
||||||
shapes/shapes_colors_palette \
|
|
||||||
shapes/shapes_dashed_line \
|
|
||||||
shapes/shapes_digital_clock \
|
|
||||||
shapes/shapes_double_pendulum \
|
|
||||||
shapes/shapes_easings_ball \
|
|
||||||
shapes/shapes_easings_box \
|
|
||||||
shapes/shapes_easings_rectangles \
|
|
||||||
shapes/shapes_easings_testbed \
|
|
||||||
shapes/shapes_following_eyes \
|
|
||||||
shapes/shapes_hilbert_curve \
|
|
||||||
shapes/shapes_kaleidoscope \
|
|
||||||
shapes/shapes_lines_bezier \
|
|
||||||
shapes/shapes_lines_drawing \
|
|
||||||
shapes/shapes_logo_raylib \
|
|
||||||
shapes/shapes_logo_raylib_anim \
|
|
||||||
shapes/shapes_math_angle_rotation \
|
|
||||||
shapes/shapes_math_sine_cosine \
|
|
||||||
shapes/shapes_mouse_trail \
|
|
||||||
shapes/shapes_penrose_tile \
|
|
||||||
shapes/shapes_pie_chart \
|
|
||||||
shapes/shapes_rectangle_advanced \
|
|
||||||
shapes/shapes_rectangle_scaling \
|
|
||||||
shapes/shapes_recursive_tree \
|
|
||||||
shapes/shapes_ring_drawing \
|
|
||||||
shapes/shapes_rlgl_color_wheel \
|
|
||||||
shapes/shapes_rlgl_triangle \
|
|
||||||
shapes/shapes_rounded_rectangle_drawing \
|
|
||||||
shapes/shapes_simple_particles \
|
|
||||||
shapes/shapes_splines_drawing \
|
|
||||||
shapes/shapes_starfield_effect \
|
|
||||||
shapes/shapes_top_down_lights \
|
|
||||||
shapes/shapes_triangle_strip \
|
|
||||||
shapes/shapes_vector_angle
|
|
||||||
|
|
||||||
TEXTURES = \
|
|
||||||
textures/textures_background_scrolling \
|
|
||||||
textures/textures_blend_modes \
|
|
||||||
textures/textures_bunnymark \
|
|
||||||
textures/textures_cellular_automata \
|
|
||||||
textures/textures_clipboard_image \
|
|
||||||
textures/textures_fog_of_war \
|
|
||||||
textures/textures_framebuffer_rendering \
|
|
||||||
textures/textures_gif_player \
|
|
||||||
textures/textures_image_channel \
|
|
||||||
textures/textures_image_drawing \
|
|
||||||
textures/textures_image_generation \
|
|
||||||
textures/textures_image_kernel \
|
|
||||||
textures/textures_image_loading \
|
|
||||||
textures/textures_image_processing \
|
|
||||||
textures/textures_image_rotate \
|
|
||||||
textures/textures_image_text \
|
|
||||||
textures/textures_logo_raylib \
|
|
||||||
textures/textures_magnifying_glass \
|
|
||||||
textures/textures_mouse_painting \
|
|
||||||
textures/textures_npatch_drawing \
|
|
||||||
textures/textures_particles_blending \
|
|
||||||
textures/textures_polygon_drawing \
|
|
||||||
textures/textures_raw_data \
|
|
||||||
textures/textures_screen_buffer \
|
|
||||||
textures/textures_sprite_animation \
|
|
||||||
textures/textures_sprite_button \
|
|
||||||
textures/textures_sprite_explosion \
|
|
||||||
textures/textures_sprite_stacking \
|
|
||||||
textures/textures_srcrec_dstrec \
|
|
||||||
textures/textures_textured_curve \
|
|
||||||
textures/textures_tiled_drawing \
|
|
||||||
textures/textures_to_image
|
|
||||||
|
|
||||||
TEXT = \
|
|
||||||
text/text_3d_drawing \
|
|
||||||
text/text_codepoints_loading \
|
|
||||||
text/text_font_filters \
|
|
||||||
text/text_font_loading \
|
|
||||||
text/text_font_sdf \
|
|
||||||
text/text_font_spritefont \
|
|
||||||
text/text_format_text \
|
|
||||||
text/text_inline_styling \
|
|
||||||
text/text_input_box \
|
|
||||||
text/text_rectangle_bounds \
|
|
||||||
text/text_sprite_fonts \
|
|
||||||
text/text_strings_management \
|
|
||||||
text/text_unicode_emojis \
|
|
||||||
text/text_unicode_ranges \
|
|
||||||
text/text_words_alignment \
|
|
||||||
text/text_writing_anim
|
|
||||||
|
|
||||||
MODELS = \
|
|
||||||
models/models_animation_blend_custom \
|
|
||||||
models/models_animation_blending \
|
|
||||||
models/models_animation_gpu_skinning \
|
|
||||||
models/models_animation_timing \
|
|
||||||
models/models_basic_voxel \
|
|
||||||
models/models_billboard_rendering \
|
|
||||||
models/models_bone_socket \
|
|
||||||
models/models_box_collisions \
|
|
||||||
models/models_cubicmap_rendering \
|
|
||||||
models/models_decals \
|
|
||||||
models/models_directional_billboard \
|
|
||||||
models/models_first_person_maze \
|
|
||||||
models/models_geometric_shapes \
|
|
||||||
models/models_heightmap_rendering \
|
|
||||||
models/models_loading \
|
|
||||||
models/models_loading_gltf \
|
|
||||||
models/models_loading_iqm \
|
|
||||||
models/models_loading_m3d \
|
|
||||||
models/models_loading_vox \
|
|
||||||
models/models_mesh_generation \
|
|
||||||
models/models_mesh_picking \
|
|
||||||
models/models_orthographic_projection \
|
|
||||||
models/models_point_rendering \
|
|
||||||
models/models_rlgl_solar_system \
|
|
||||||
models/models_rotating_cube \
|
|
||||||
models/models_skybox_rendering \
|
|
||||||
models/models_tesseract_view \
|
|
||||||
models/models_textured_cube \
|
|
||||||
models/models_waving_cubes \
|
|
||||||
models/models_yaw_pitch_roll
|
|
||||||
|
|
||||||
SHADERS = \
|
|
||||||
shaders/shaders_ascii_rendering \
|
|
||||||
shaders/shaders_basic_lighting \
|
|
||||||
shaders/shaders_basic_pbr \
|
|
||||||
shaders/shaders_cel_shading \
|
|
||||||
shaders/shaders_color_correction \
|
|
||||||
shaders/shaders_custom_uniform \
|
|
||||||
shaders/shaders_deferred_rendering \
|
|
||||||
shaders/shaders_depth_rendering \
|
|
||||||
shaders/shaders_depth_writing \
|
|
||||||
shaders/shaders_eratosthenes_sieve \
|
|
||||||
shaders/shaders_fog_rendering \
|
|
||||||
shaders/shaders_game_of_life \
|
|
||||||
shaders/shaders_hot_reloading \
|
|
||||||
shaders/shaders_hybrid_rendering \
|
|
||||||
shaders/shaders_julia_set \
|
|
||||||
shaders/shaders_lightmap_rendering \
|
|
||||||
shaders/shaders_mandelbrot_set \
|
|
||||||
shaders/shaders_mesh_instancing \
|
|
||||||
shaders/shaders_model_shader \
|
|
||||||
shaders/shaders_multi_sample2d \
|
|
||||||
shaders/shaders_normalmap_rendering \
|
|
||||||
shaders/shaders_palette_switch \
|
|
||||||
shaders/shaders_postprocessing \
|
|
||||||
shaders/shaders_raymarching_rendering \
|
|
||||||
shaders/shaders_rlgl_compute \
|
|
||||||
shaders/shaders_rounded_rectangle \
|
|
||||||
shaders/shaders_shadowmap_rendering \
|
|
||||||
shaders/shaders_shapes_textures \
|
|
||||||
shaders/shaders_simple_mask \
|
|
||||||
shaders/shaders_spotlight_rendering \
|
|
||||||
shaders/shaders_texture_outline \
|
|
||||||
shaders/shaders_texture_rendering \
|
|
||||||
shaders/shaders_texture_tiling \
|
|
||||||
shaders/shaders_texture_waves \
|
|
||||||
shaders/shaders_vertex_displacement
|
|
||||||
|
|
||||||
AUDIO = \
|
|
||||||
audio/audio_mixed_processor \
|
|
||||||
audio/audio_module_playing \
|
|
||||||
audio/audio_music_stream \
|
|
||||||
audio/audio_raw_stream \
|
|
||||||
audio/audio_sound_loading \
|
|
||||||
audio/audio_sound_multi \
|
|
||||||
audio/audio_sound_positioning \
|
|
||||||
audio/audio_spectrum_visualizer \
|
|
||||||
audio/audio_stream_callback \
|
|
||||||
audio/audio_stream_effects
|
|
||||||
#EXAMPLES_LIST_END
|
|
||||||
|
|
||||||
# Define processes to execute
|
|
||||||
#------------------------------------------------------------------------------------------------
|
|
||||||
# Default target entry
|
|
||||||
all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO)
|
|
||||||
|
|
||||||
core: $(CORE)
|
|
||||||
shapes: $(SHAPES)
|
|
||||||
textures: $(TEXTURES)
|
|
||||||
text: $(TEXT)
|
|
||||||
models: $(MODELS)
|
|
||||||
shaders: $(SHADERS)
|
|
||||||
audio: $(AUDIO)
|
|
||||||
|
|
||||||
# Generic compilation pattern
|
|
||||||
# NOTE: Examples must be ready for Android compilation!
|
|
||||||
%: %.c
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
|
|
||||||
$(MAKE) -f Makefile.Android PROJECT_NAME=$@ PROJECT_SOURCE_FILES=$<
|
|
||||||
else ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
|
|
||||||
$(MAKE) -f Makefile.Web $@
|
|
||||||
else
|
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -D$(TARGET_PLATFORM)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Clean everything
|
|
||||||
clean:
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
|
||||||
del *.o *.exe /s
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
|
||||||
find . -type f -perm -ugo+x -delete
|
|
||||||
rm -fv *.o
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
|
||||||
find . -type f -executable -delete
|
|
||||||
rm -fv *.o
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),OSX)
|
|
||||||
find . -type f -perm +ugo+x -delete
|
|
||||||
rm -f *.o
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_WIN32)
|
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
|
||||||
del *.o *.exe /s
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
|
||||||
find . -type f -perm -ugo+x -delete
|
|
||||||
rm -fv *.o
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
|
||||||
find . -type f -executable -delete
|
|
||||||
rm -fv *.o
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),OSX)
|
|
||||||
find . -type f -perm +ugo+x -delete
|
|
||||||
rm -f *.o
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
|
|
||||||
find . -type f -executable -delete
|
|
||||||
rm -fv *.o
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
|
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
|
||||||
del *.wasm *.html *.js *.data
|
|
||||||
else
|
|
||||||
rm -f */*.wasm */*.html */*.js */*.data
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
@echo Cleaning done
|
|
||||||
|
|
@ -1,412 +0,0 @@
|
||||||
#**************************************************************************************************
|
|
||||||
#
|
|
||||||
# raylib makefile for Android project (APK building)
|
|
||||||
#
|
|
||||||
# Copyright (c) 2017-2026 Ramon Santamaria (@raysan5)
|
|
||||||
#
|
|
||||||
# This software is provided "as-is", without any express or implied warranty. In no event
|
|
||||||
# will the authors be held liable for any damages arising from the use of this software.
|
|
||||||
#
|
|
||||||
# Permission is granted to anyone to use this software for any purpose, including commercial
|
|
||||||
# applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
|
||||||
#
|
|
||||||
# 1. The origin of this software must not be misrepresented; you must not claim that you
|
|
||||||
# wrote the original software. If you use this software in a product, an acknowledgment
|
|
||||||
# in the product documentation would be appreciated but is not required.
|
|
||||||
#
|
|
||||||
# 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
|
||||||
# as being the original software.
|
|
||||||
#
|
|
||||||
# 3. This notice may not be removed or altered from any source distribution.
|
|
||||||
#
|
|
||||||
#**************************************************************************************************
|
|
||||||
|
|
||||||
# Define required raylib variables
|
|
||||||
PLATFORM ?= PLATFORM_ANDROID
|
|
||||||
RAYLIB_PATH ?= ..\..
|
|
||||||
|
|
||||||
# Define Android architecture (armeabi-v7a, arm64-v8a, x86, x86-64) and API version
|
|
||||||
# Starting in 2019 using ARM64 is mandatory for published apps,
|
|
||||||
# Starting on August 2020, minimum required target API is Android 10 (API level 29)
|
|
||||||
ANDROID_ARCH ?= ARM64
|
|
||||||
ANDROID_API_VERSION = 29
|
|
||||||
|
|
||||||
# Android required path variables
|
|
||||||
# NOTE: Starting with Android NDK r21, no more toolchain generation is required, NDK is the toolchain on itself
|
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
ANDROID_NDK = C:/android-ndk
|
|
||||||
ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/windows-x86_64
|
|
||||||
else
|
|
||||||
ANDROID_NDK ?= /usr/lib/android/ndk
|
|
||||||
ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(ANDROID_ARCH),ARM)
|
|
||||||
ANDROID_ARCH_NAME = armeabi-v7a
|
|
||||||
endif
|
|
||||||
ifeq ($(ANDROID_ARCH),ARM64)
|
|
||||||
ANDROID_ARCH_NAME = arm64-v8a
|
|
||||||
endif
|
|
||||||
ifeq ($(ANDROID_ARCH),x86)
|
|
||||||
ANDROID_ARCH_NAME = x86
|
|
||||||
endif
|
|
||||||
ifeq ($(ANDROID_ARCH),x86_64)
|
|
||||||
ANDROID_ARCH_NAME = x86_64
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Required path variables
|
|
||||||
# NOTE: JAVA_HOME must be set to JDK (using OpenJDK 13)
|
|
||||||
JAVA_HOME ?= C:/open-jdk
|
|
||||||
ANDROID_HOME ?= C:/android-sdk
|
|
||||||
ANDROID_BUILD_TOOLS ?= $(ANDROID_HOME)/build-tools/29.0.3
|
|
||||||
ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools
|
|
||||||
|
|
||||||
# Android project configuration variables
|
|
||||||
PROJECT_NAME ?= raylib_game
|
|
||||||
PROJECT_LIBRARY_NAME ?= main
|
|
||||||
PROJECT_BUILD_ID ?= android
|
|
||||||
PROJECT_BUILD_PATH ?= $(PROJECT_BUILD_ID).$(PROJECT_NAME)
|
|
||||||
PROJECT_RESOURCES_PATH ?= resources
|
|
||||||
PROJECT_SOURCE_FILES ?= raylib_game.c
|
|
||||||
NATIVE_APP_GLUE_PATH = $(ANDROID_NDK)/sources/android/native_app_glue
|
|
||||||
|
|
||||||
# Some source files are placed in directories, when compiling to some
|
|
||||||
# output directory other than source, that directory must pre-exist.
|
|
||||||
# Here we get a list of required folders that need to be created on
|
|
||||||
# code output folder $(PROJECT_BUILD_PATH)\obj to avoid GCC errors.
|
|
||||||
PROJECT_SOURCE_DIRS = $(sort $(dir $(PROJECT_SOURCE_FILES)))
|
|
||||||
|
|
||||||
# Android app configuration variables
|
|
||||||
APP_LABEL_NAME ?= rGame
|
|
||||||
APP_COMPANY_NAME ?= raylib
|
|
||||||
APP_PRODUCT_NAME ?= rgame
|
|
||||||
APP_VERSION_CODE ?= 1
|
|
||||||
APP_VERSION_NAME ?= 1.0
|
|
||||||
APP_ICON_LDPI ?= $(RAYLIB_PATH)/logo/raylib_36x36.png
|
|
||||||
APP_ICON_MDPI ?= $(RAYLIB_PATH)/logo/raylib_48x48.png
|
|
||||||
APP_ICON_HDPI ?= $(RAYLIB_PATH)/logo/raylib_72x72.png
|
|
||||||
APP_SCREEN_ORIENTATION ?= landscape
|
|
||||||
APP_KEYSTORE_PASS ?= raylib
|
|
||||||
|
|
||||||
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
|
|
||||||
RAYLIB_LIBTYPE ?= STATIC
|
|
||||||
|
|
||||||
# Library path for libraylib.a/libraylib.so
|
|
||||||
RAYLIB_LIB_PATH = $(RAYLIB_PATH)/src
|
|
||||||
|
|
||||||
# Define copy command depending on OS
|
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
COPY_COMMAND ?= copy /Y
|
|
||||||
else
|
|
||||||
COPY_COMMAND ?= cp -f
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Shared libs must be added to APK if required
|
|
||||||
# NOTE: Generated NativeLoader.java automatically load those libraries
|
|
||||||
ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
|
||||||
PROJECT_SHARED_LIBS = lib/$(ANDROID_ARCH_NAME)/libraylib.so
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Compiler and archiver
|
|
||||||
ifeq ($(ANDROID_ARCH),ARM)
|
|
||||||
CC = $(ANDROID_TOOLCHAIN)/bin/armv7a-linux-androideabi$(ANDROID_API_VERSION)-clang
|
|
||||||
AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar
|
|
||||||
endif
|
|
||||||
ifeq ($(ANDROID_ARCH),ARM64)
|
|
||||||
CC = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android$(ANDROID_API_VERSION)-clang
|
|
||||||
AR = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-ar
|
|
||||||
endif
|
|
||||||
ifeq ($(ANDROID_ARCH),x86)
|
|
||||||
CC = $(ANDROID_TOOLCHAIN)/bin/i686-linux-android$(ANDROID_API_VERSION)-clang
|
|
||||||
AR = $(ANDROID_TOOLCHAIN)/bin/i686-linux-android-ar
|
|
||||||
endif
|
|
||||||
ifeq ($(ANDROID_ARCH),x86_64)
|
|
||||||
CC = $(ANDROID_TOOLCHAIN)/bin/x86_64-linux-android$(ANDROID_API_VERSION)-clang
|
|
||||||
AR = $(ANDROID_TOOLCHAIN)/bin/x86_64-linux-android-ar
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Compiler flags for arquitecture
|
|
||||||
ifeq ($(ANDROID_ARCH),ARM)
|
|
||||||
CFLAGS = -std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
|
|
||||||
endif
|
|
||||||
ifeq ($(ANDROID_ARCH),ARM64)
|
|
||||||
CFLAGS = -std=c99 -mfix-cortex-a53-835769
|
|
||||||
endif
|
|
||||||
# Compilation functions attributes options
|
|
||||||
CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC
|
|
||||||
# Compiler options for the linker
|
|
||||||
CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes
|
|
||||||
# Preprocessor macro definitions
|
|
||||||
CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION)
|
|
||||||
|
|
||||||
# Paths containing required header files
|
|
||||||
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(NATIVE_APP_GLUE_PATH)
|
|
||||||
|
|
||||||
# Linker options
|
|
||||||
LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a
|
|
||||||
LDFLAGS += -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings
|
|
||||||
# Force linking of library module to define symbol
|
|
||||||
LDFLAGS += -u ANativeActivity_onCreate
|
|
||||||
# Library paths containing required libs
|
|
||||||
LDFLAGS += -L. -L$(PROJECT_BUILD_PATH)/obj -L$(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME) -L$(ANDROID_TOOLCHAIN)\sysroot\usr\lib
|
|
||||||
|
|
||||||
# Define any libraries to link into executable
|
|
||||||
# if you want to link libraries (libname.so or libname.a), use the -lname
|
|
||||||
LDLIBS = -lm -lc -lraylib -llog -landroid -lEGL -lGLESv2 -lOpenSLES -ldl
|
|
||||||
|
|
||||||
# Generate target objects list from PROJECT_SOURCE_FILES
|
|
||||||
OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES))
|
|
||||||
|
|
||||||
# Android APK building process... some steps required...
|
|
||||||
# NOTE: typing 'make' will invoke the default target entry called 'all'
|
|
||||||
# TODO: Use apksigner for APK signing, jarsigner is not recommended
|
|
||||||
all: create_temp_project_dirs \
|
|
||||||
copy_project_required_libs \
|
|
||||||
copy_project_resources \
|
|
||||||
generate_loader_script \
|
|
||||||
generate_android_manifest \
|
|
||||||
generate_apk_keystore \
|
|
||||||
config_project_package \
|
|
||||||
compile_project_code \
|
|
||||||
compile_project_class \
|
|
||||||
compile_project_class_dex \
|
|
||||||
create_project_apk_package \
|
|
||||||
sign_project_apk_package \
|
|
||||||
zipalign_project_apk_package
|
|
||||||
|
|
||||||
# WARNING: About build signing process:
|
|
||||||
# - If using apksigner, zipalign must be used before the APK file has been signed.
|
|
||||||
# - If using jarsigner (not recommended), zipalign must be used after the APK file has been signed.
|
|
||||||
# REF: https://developer.android.com/tools/zipalign
|
|
||||||
# REF: https://developer.android.com/tools/apksigner
|
|
||||||
|
|
||||||
# Create required temp directories for APK building
|
|
||||||
create_temp_project_dirs:
|
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
if not exist $(PROJECT_BUILD_PATH) mkdir $(PROJECT_BUILD_PATH)
|
|
||||||
if not exist $(PROJECT_BUILD_PATH)\obj mkdir $(PROJECT_BUILD_PATH)\obj
|
|
||||||
if not exist $(PROJECT_BUILD_PATH)\obj mkdir $(PROJECT_BUILD_PATH)\obj\src
|
|
||||||
if not exist $(PROJECT_BUILD_PATH)\src mkdir $(PROJECT_BUILD_PATH)\src
|
|
||||||
if not exist $(PROJECT_BUILD_PATH)\src\com mkdir $(PROJECT_BUILD_PATH)\src\com
|
|
||||||
if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)
|
|
||||||
if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME)
|
|
||||||
if not exist $(PROJECT_BUILD_PATH)\lib mkdir $(PROJECT_BUILD_PATH)\lib
|
|
||||||
if not exist $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME) mkdir $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)
|
|
||||||
if not exist $(PROJECT_BUILD_PATH)\bin mkdir $(PROJECT_BUILD_PATH)\bin
|
|
||||||
if not exist $(PROJECT_BUILD_PATH)\res mkdir $(PROJECT_BUILD_PATH)\res
|
|
||||||
if not exist $(PROJECT_BUILD_PATH)\res\drawable-ldpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-ldpi
|
|
||||||
if not exist $(PROJECT_BUILD_PATH)\res\drawable-mdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-mdpi
|
|
||||||
if not exist $(PROJECT_BUILD_PATH)\res\drawable-hdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-hdpi
|
|
||||||
if not exist $(PROJECT_BUILD_PATH)\res\values mkdir $(PROJECT_BUILD_PATH)\res\values
|
|
||||||
if not exist $(PROJECT_BUILD_PATH)\assets mkdir $(PROJECT_BUILD_PATH)\assets
|
|
||||||
if not exist $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) mkdir $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH)
|
|
||||||
if not exist $(PROJECT_BUILD_PATH)\obj\screens mkdir $(PROJECT_BUILD_PATH)\obj\screens
|
|
||||||
else
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/obj
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/obj/src
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/src
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/src/com
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/lib
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME)
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/bin
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/res
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/res/drawable-ldpi
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/res/drawable-mdpi
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/res/drawable-hdpi
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/res/values
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/assets
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/assets/$(PROJECT_RESOURCES_PATH)
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/obj/screens
|
|
||||||
endif
|
|
||||||
$(foreach dir, $(PROJECT_SOURCE_DIRS), $(call create_dir, $(dir)))
|
|
||||||
|
|
||||||
define create_dir
|
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/obj/$(1)
|
|
||||||
endef
|
|
||||||
|
|
||||||
# Copy required shared libs for integration into APK
|
|
||||||
# NOTE: If using shared libs they are loaded by generated NativeLoader.java
|
|
||||||
copy_project_required_libs:
|
|
||||||
ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
|
||||||
$(COPY_COMMAND) $(RAYLIB_LIB_PATH)/libraylib.so $(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME)/libraylib.so
|
|
||||||
endif
|
|
||||||
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
|
||||||
$(COPY_COMMAND) $(RAYLIB_LIB_PATH)/libraylib.a $(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME)/libraylib.a
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Copy project required resources: strings.xml, icon.png, assets
|
|
||||||
# NOTE: Required strings.xml is generated and game resources are copied to assets folder
|
|
||||||
copy_project_resources:
|
|
||||||
$(COPY_COMMAND) $(APP_ICON_LDPI) $(PROJECT_BUILD_PATH)/res/drawable-ldpi/icon.png
|
|
||||||
$(COPY_COMMAND) $(APP_ICON_MDPI) $(PROJECT_BUILD_PATH)/res/drawable-mdpi/icon.png
|
|
||||||
$(COPY_COMMAND) $(APP_ICON_HDPI) $(PROJECT_BUILD_PATH)/res/drawable-hdpi/icon.png
|
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
@echo ^<?xml version="1.0" encoding="utf-8"^?^> > $(PROJECT_BUILD_PATH)/res/values/strings.xml
|
|
||||||
@echo ^<resources^>^<string name="app_name"^>$(APP_LABEL_NAME)^</string^>^</resources^> >> $(PROJECT_BUILD_PATH)/res/values/strings.xml
|
|
||||||
if exist $(PROJECT_RESOURCES_PATH) C:\Windows\System32\xcopy $(PROJECT_RESOURCES_PATH) $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) /Y /E /F
|
|
||||||
else
|
|
||||||
@echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>" > $(PROJECT_BUILD_PATH)/res/values/strings.xml
|
|
||||||
@echo "<resources><string name=\"app_name\">$(APP_LABEL_NAME)</string></resources>" >> $(PROJECT_BUILD_PATH)/res/values/strings.xml
|
|
||||||
@[ -d "$(PROJECT_RESOURCES_PATH)" ] || cp -rf $(PROJECT_RESOURCES_PATH) $(PROJECT_BUILD_PATH)/assets/$(PROJECT_RESOURCES_PATH)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Generate NativeLoader.java to load required shared libraries
|
|
||||||
# NOTE: Probably not the bet way to generate this file... but it works.
|
|
||||||
generate_loader_script:
|
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
@echo package com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME); > $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
|
||||||
@echo. >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
|
||||||
@echo public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
|
||||||
@echo static { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
|
||||||
ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
|
||||||
@echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
|
||||||
endif
|
|
||||||
@echo System.loadLibrary("$(PROJECT_LIBRARY_NAME)"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
|
||||||
@echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
|
||||||
@echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
|
||||||
else
|
|
||||||
@echo "package com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME);" > $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
|
||||||
@echo "" >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
|
||||||
@echo "public class NativeLoader extends android.app.NativeActivity {" >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
|
||||||
@echo " static {" >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
|
||||||
ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
|
||||||
@echo " System.loadLibrary(\"raylib\");" >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
|
||||||
endif
|
|
||||||
@echo " System.loadLibrary(\"$(PROJECT_LIBRARY_NAME)\");" >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
|
||||||
@echo " }" >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
|
||||||
@echo "}" >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Generate AndroidManifest.xml with all the required options
|
|
||||||
# NOTE: Probably not the bet way to generate this file... but it works.
|
|
||||||
generate_android_manifest:
|
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
@echo ^<?xml version="1.0" encoding="utf-8"^?^> > $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo ^<manifest xmlns:android="http://schemas.android.com/apk/res/android" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo package="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME)" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo android:versionCode="$(APP_VERSION_CODE)" android:versionName="$(APP_VERSION_NAME)" ^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo ^<uses-sdk android:minSdkVersion="$(ANDROID_API_VERSION)" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo ^<uses-feature android:glEsVersion="0x00020000" android:required="true" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo ^<application android:allowBackup="false" android:label="@string/app_name" android:icon="@drawable/icon" ^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo ^<activity android:name="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME).NativeLoader" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo android:configChanges="orientation|keyboardHidden|screenSize" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo android:screenOrientation="$(APP_SCREEN_ORIENTATION)" android:launchMode="singleTask" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo android:clearTaskOnLaunch="true"^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo ^<meta-data android:name="android.app.lib_name" android:value="$(PROJECT_LIBRARY_NAME)" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo ^<intent-filter^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo ^<action android:name="android.intent.action.MAIN" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo ^<category android:name="android.intent.category.LAUNCHER" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo ^</intent-filter^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo ^</activity^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo ^</application^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo ^</manifest^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
else
|
|
||||||
@echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>" > $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo " package=\"com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME)\" " >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo " android:versionCode=\"$(APP_VERSION_CODE)\" android:versionName=\"$(APP_VERSION_NAME)\" >" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo " <uses-sdk android:minSdkVersion=\"$(ANDROID_API_VERSION)\" />" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo " <uses-feature android:glEsVersion=\"0x00020000\" android:required=\"true\" />" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo " <application android:allowBackup=\"false\" android:label=\"@string/app_name\" android:icon=\"@drawable/icon\" >" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo " <activity android:name=\"com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME).NativeLoader\"" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo " android:theme=\"@android:style/Theme.NoTitleBar.Fullscreen\"" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo " android:configChanges=\"orientation|keyboardHidden|screenSize\"" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo " android:screenOrientation=\"$(APP_SCREEN_ORIENTATION)\" android:launchMode=\"singleTask\"" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo " android:clearTaskOnLaunch=\"true\">" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo " <meta-data android:name=\"android.app.lib_name\" android:value=\"$(PROJECT_LIBRARY_NAME)\" />" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo " <intent-filter>" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo " <action android:name=\"android.intent.action.MAIN\" />" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo " <category android:name=\"android.intent.category.LAUNCHER\" />" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo " </intent-filter>" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo " </activity>" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo " </application>" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
@echo "</manifest>" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Generate storekey for APK signing: $(PROJECT_NAME).keystore
|
|
||||||
# NOTE: Configure here your Distinguished Names (-dname) if required!
|
|
||||||
generate_apk_keystore:
|
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
if not exist $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore $(JAVA_HOME)/bin/keytool -genkeypair -validity 10000 -dname "CN=$(APP_COMPANY_NAME),O=Android,C=ES" -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA
|
|
||||||
else
|
|
||||||
@[ -f "$(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore" ] || $(JAVA_HOME)/bin/keytool -genkeypair -validity 10000 -dname "CN=$(APP_COMPANY_NAME),O=Android,C=ES" -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Config project package and resource using AndroidManifest.xml and res/values/strings.xml
|
|
||||||
# NOTE: Generates resources file: src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java
|
|
||||||
config_project_package:
|
|
||||||
$(ANDROID_BUILD_TOOLS)/aapt package -f -m -S $(PROJECT_BUILD_PATH)/res -J $(PROJECT_BUILD_PATH)/src -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar
|
|
||||||
|
|
||||||
# Compile native_app_glue code as static library: obj/libnative_app_glue.a
|
|
||||||
compile_native_app_glue:
|
|
||||||
$(CC) -c $(NATIVE_APP_GLUE_PATH)/android_native_app_glue.c -o $(PROJECT_BUILD_PATH)/obj/native_app_glue.o $(CFLAGS)
|
|
||||||
$(AR) rcs $(PROJECT_BUILD_PATH)/obj/libnative_app_glue.a $(PROJECT_BUILD_PATH)/obj/native_app_glue.o
|
|
||||||
|
|
||||||
# Compile project code into a shared library: lib/lib$(PROJECT_LIBRARY_NAME).so
|
|
||||||
compile_project_code: $(OBJS)
|
|
||||||
$(CC) -o $(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(OBJS) -shared $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS)
|
|
||||||
|
|
||||||
# Compile all .c files required into object (.o) files
|
|
||||||
# NOTE: Those files will be linked into a shared library
|
|
||||||
$(PROJECT_BUILD_PATH)/obj/%.o:%.c
|
|
||||||
$(CC) -c $^ -o $@ $(INCLUDE_PATHS) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot
|
|
||||||
|
|
||||||
# Compile project .java code into .class (Java bytecode)
|
|
||||||
compile_project_class:
|
|
||||||
$(JAVA_HOME)/bin/javac -verbose -source 1.7 -target 1.7 -d $(PROJECT_BUILD_PATH)/obj -bootclasspath $(JAVA_HOME)/jre/lib/rt.jar -classpath $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar -d $(PROJECT_BUILD_PATH)/obj $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
|
||||||
|
|
||||||
# Compile .class files into Dalvik executable bytecode (.dex)
|
|
||||||
# NOTE: Since Android 5.0, Dalvik interpreter (JIT) has been replaced by ART (AOT)
|
|
||||||
compile_project_class_dex:
|
|
||||||
$(ANDROID_BUILD_TOOLS)/dx --verbose --dex --output=$(PROJECT_BUILD_PATH)/bin/classes.dex $(PROJECT_BUILD_PATH)/obj
|
|
||||||
|
|
||||||
# Create Android APK package: bin/$(PROJECT_NAME).unsigned.apk
|
|
||||||
# NOTE: Requires compiled classes.dex and lib$(PROJECT_LIBRARY_NAME).so
|
|
||||||
# NOTE: Use -A resources to define additional directory in which to find raw asset files
|
|
||||||
create_project_apk_package:
|
|
||||||
$(ANDROID_BUILD_TOOLS)/aapt package -f -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -S $(PROJECT_BUILD_PATH)/res -A $(PROJECT_BUILD_PATH)/assets -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar -F $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_BUILD_PATH)/bin
|
|
||||||
cd $(PROJECT_BUILD_PATH) && $(ANDROID_BUILD_TOOLS)/aapt add bin/$(PROJECT_NAME).unsigned.apk lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(PROJECT_SHARED_LIBS)
|
|
||||||
|
|
||||||
# Create signed APK package using generated Key: bin/$(PROJECT_NAME).signed.apk
|
|
||||||
sign_project_apk_package:
|
|
||||||
$(JAVA_HOME)/bin/jarsigner -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -signedjar $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key
|
|
||||||
|
|
||||||
# Create zip-aligned APK package: $(PROJECT_NAME).apk
|
|
||||||
zipalign_project_apk_package:
|
|
||||||
$(ANDROID_BUILD_TOOLS)/zipalign -f 4 $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_NAME).apk
|
|
||||||
|
|
||||||
# Install $(PROJECT_NAME).apk to default emulator/device
|
|
||||||
# NOTE: Use -e (emulator) or -d (device) parameters if required
|
|
||||||
install:
|
|
||||||
$(ANDROID_PLATFORM_TOOLS)/adb install $(PROJECT_NAME).apk
|
|
||||||
|
|
||||||
# Check supported ABI for the device (armeabi-v7a, arm64-v8a, x86, x86_64)
|
|
||||||
check_device_abi:
|
|
||||||
$(ANDROID_PLATFORM_TOOLS)/adb shell getprop ro.product.cpu.abi
|
|
||||||
|
|
||||||
# Monitorize output log coming from device, only raylib tag
|
|
||||||
logcat:
|
|
||||||
$(ANDROID_PLATFORM_TOOLS)/adb logcat -c
|
|
||||||
$(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S
|
|
||||||
|
|
||||||
# Install and monitorize $(PROJECT_NAME).apk to default emulator/device
|
|
||||||
deploy:
|
|
||||||
$(ANDROID_PLATFORM_TOOLS)/adb install $(PROJECT_NAME).apk
|
|
||||||
$(ANDROID_PLATFORM_TOOLS)/adb logcat -c
|
|
||||||
$(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S
|
|
||||||
|
|
||||||
#$(ANDROID_PLATFORM_TOOLS)/adb logcat *:W
|
|
||||||
|
|
||||||
# Clean everything
|
|
||||||
clean:
|
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
del $(PROJECT_BUILD_PATH)\* /f /s /q
|
|
||||||
rmdir $(PROJECT_BUILD_PATH) /s /q
|
|
||||||
else
|
|
||||||
rm -r $(PROJECT_BUILD_PATH)
|
|
||||||
endif
|
|
||||||
@echo Cleaning done
|
|
||||||
|
|
@ -1,284 +0,0 @@
|
||||||
## Building the Examples
|
|
||||||
|
|
||||||
The examples assume you have already built the `raylib` library in `../src`.
|
|
||||||
|
|
||||||
### With GNU make
|
|
||||||
|
|
||||||
- `make` builds all examples
|
|
||||||
- `make [module]` builds all examples for a particular module (e.g `make core`)
|
|
||||||
- `make [module]/[name]` builds one examples for a particular module (e.g `make core/core_basic_window`)
|
|
||||||
|
|
||||||
### With Zig
|
|
||||||
|
|
||||||
The [Zig](https://ziglang.org/) toolchain can compile `C` and `C++` in addition to `Zig`.
|
|
||||||
You may find it easier to use than other toolchains, especially when it comes to cross-compiling.
|
|
||||||
|
|
||||||
- `zig build` to compile all examples
|
|
||||||
- `zig build [module]` to compile all examples for a module (e.g. `zig build core`)
|
|
||||||
- `zig build [example]` to compile _and run_ a particular example (e.g. `zig build core_basic_window`)
|
|
||||||
|
|
||||||
## EXAMPLES COLLECTION [TOTAL: 212]
|
|
||||||
|
|
||||||
### category: core [49]
|
|
||||||
|
|
||||||
Examples using raylib [core](../src/rcore.c) module platform functionality: window creation, inputs, drawing modes and system functionality.
|
|
||||||
|
|
||||||
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
|
||||||
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
|
||||||
| [core_basic_window](core/core_basic_window.c) | <img src="core/core_basic_window.png" alt="core_basic_window" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_delta_time](core/core_delta_time.c) | <img src="core/core_delta_time.png" alt="core_delta_time" width="80"> | ⭐☆☆☆ | 5.5 | 6.0 | [Robin](https://github.com/RobinsAviary) |
|
|
||||||
| [core_input_keys](core/core_input_keys.c) | <img src="core/core_input_keys.png" alt="core_input_keys" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_input_mouse](core/core_input_mouse.c) | <img src="core/core_input_mouse.png" alt="core_input_mouse" width="80"> | ⭐☆☆☆ | 1.0 | 5.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_input_mouse_wheel](core/core_input_mouse_wheel.c) | <img src="core/core_input_mouse_wheel.png" alt="core_input_mouse_wheel" width="80"> | ⭐☆☆☆ | 1.1 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_input_gamepad](core/core_input_gamepad.c) | <img src="core/core_input_gamepad.png" alt="core_input_gamepad" width="80"> | ⭐☆☆☆ | 1.1 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_input_multitouch](core/core_input_multitouch.c) | <img src="core/core_input_multitouch.png" alt="core_input_multitouch" width="80"> | ⭐☆☆☆ | 2.1 | 2.5 | [Berni](https://github.com/Berni8k) |
|
|
||||||
| [core_input_gestures](core/core_input_gestures.c) | <img src="core/core_input_gestures.png" alt="core_input_gestures" width="80"> | ⭐⭐☆☆ | 1.4 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_input_gestures_testbed](core/core_input_gestures_testbed.c) | <img src="core/core_input_gestures_testbed.png" alt="core_input_gestures_testbed" width="80"> | ⭐⭐⭐☆ | 5.0 | 6.0 | [ubkp](https://github.com/ubkp) |
|
|
||||||
| [core_input_virtual_controls](core/core_input_virtual_controls.c) | <img src="core/core_input_virtual_controls.png" alt="core_input_virtual_controls" width="80"> | ⭐⭐☆☆ | 5.0 | 5.0 | [GreenSnakeLinux](https://github.com/GreenSnakeLinux) |
|
|
||||||
| [core_2d_camera](core/core_2d_camera.c) | <img src="core/core_2d_camera.png" alt="core_2d_camera" width="80"> | ⭐⭐☆☆ | 1.5 | 3.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_2d_camera_mouse_zoom](core/core_2d_camera_mouse_zoom.c) | <img src="core/core_2d_camera_mouse_zoom.png" alt="core_2d_camera_mouse_zoom" width="80"> | ⭐⭐☆☆ | 4.2 | 4.2 | [Jeffery Myers](https://github.com/JeffM2501) |
|
|
||||||
| [core_2d_camera_platformer](core/core_2d_camera_platformer.c) | <img src="core/core_2d_camera_platformer.png" alt="core_2d_camera_platformer" width="80"> | ⭐⭐⭐☆ | 2.5 | 3.0 | [arvyy](https://github.com/arvyy) |
|
|
||||||
| [core_2d_camera_split_screen](core/core_2d_camera_split_screen.c) | <img src="core/core_2d_camera_split_screen.png" alt="core_2d_camera_split_screen" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [Gabriel dos Santos Sanches](https://github.com/gabrielssanches) |
|
|
||||||
| [core_3d_camera_mode](core/core_3d_camera_mode.c) | <img src="core/core_3d_camera_mode.png" alt="core_3d_camera_mode" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_3d_camera_free](core/core_3d_camera_free.c) | <img src="core/core_3d_camera_free.png" alt="core_3d_camera_free" width="80"> | ⭐☆☆☆ | 1.3 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_3d_camera_first_person](core/core_3d_camera_first_person.c) | <img src="core/core_3d_camera_first_person.png" alt="core_3d_camera_first_person" width="80"> | ⭐⭐☆☆ | 1.3 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_3d_camera_split_screen](core/core_3d_camera_split_screen.c) | <img src="core/core_3d_camera_split_screen.png" alt="core_3d_camera_split_screen" width="80"> | ⭐⭐⭐☆ | 3.7 | 4.0 | [Jeffery Myers](https://github.com/JeffM2501) |
|
|
||||||
| [core_3d_camera_fps](core/core_3d_camera_fps.c) | <img src="core/core_3d_camera_fps.png" alt="core_3d_camera_fps" width="80"> | ⭐⭐⭐☆ | 5.5 | 5.5 | [Agnis Aldiņš](https://github.com/nezvers) |
|
|
||||||
| [core_3d_picking](core/core_3d_picking.c) | <img src="core/core_3d_picking.png" alt="core_3d_picking" width="80"> | ⭐⭐☆☆ | 1.3 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_world_screen](core/core_world_screen.c) | <img src="core/core_world_screen.png" alt="core_world_screen" width="80"> | ⭐⭐☆☆ | 1.3 | 1.4 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_window_flags](core/core_window_flags.c) | <img src="core/core_window_flags.png" alt="core_window_flags" width="80"> | ⭐⭐⭐☆ | 3.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_window_letterbox](core/core_window_letterbox.c) | <img src="core/core_window_letterbox.png" alt="core_window_letterbox" width="80"> | ⭐⭐☆☆ | 2.5 | 4.0 | [Anata](https://github.com/anatagawa) |
|
|
||||||
| [core_window_should_close](core/core_window_should_close.c) | <img src="core/core_window_should_close.png" alt="core_window_should_close" width="80"> | ⭐☆☆☆ | 4.2 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_monitor_detector](core/core_monitor_detector.c) | <img src="core/core_monitor_detector.png" alt="core_monitor_detector" width="80"> | ⭐☆☆☆ | 5.5 | 5.6 | [Maicon Santana](https://github.com/maiconpintoabreu) |
|
|
||||||
| [core_custom_logging](core/core_custom_logging.c) | <img src="core/core_custom_logging.png" alt="core_custom_logging" width="80"> | ⭐⭐⭐☆ | 2.5 | 2.5 | [Pablo Marcos Oltra](https://github.com/pamarcos) |
|
|
||||||
| [core_drop_files](core/core_drop_files.c) | <img src="core/core_drop_files.png" alt="core_drop_files" width="80"> | ⭐⭐☆☆ | 1.3 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_random_values](core/core_random_values.c) | <img src="core/core_random_values.png" alt="core_random_values" width="80"> | ⭐☆☆☆ | 1.1 | 1.1 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_storage_values](core/core_storage_values.c) | <img src="core/core_storage_values.png" alt="core_storage_values" width="80"> | ⭐⭐☆☆ | 1.4 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_vr_simulator](core/core_vr_simulator.c) | <img src="core/core_vr_simulator.png" alt="core_vr_simulator" width="80"> | ⭐⭐⭐☆ | 2.5 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_scissor_test](core/core_scissor_test.c) | <img src="core/core_scissor_test.png" alt="core_scissor_test" width="80"> | ⭐☆☆☆ | 2.5 | 3.0 | [Chris Dill](https://github.com/MysteriousSpace) |
|
|
||||||
| [core_basic_screen_manager](core/core_basic_screen_manager.c) | <img src="core/core_basic_screen_manager.png" alt="core_basic_screen_manager" width="80"> | ⭐☆☆☆ | 4.0 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_custom_frame_control](core/core_custom_frame_control.c) | <img src="core/core_custom_frame_control.png" alt="core_custom_frame_control" width="80"> | ⭐⭐⭐⭐️ | 4.0 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_smooth_pixelperfect](core/core_smooth_pixelperfect.c) | <img src="core/core_smooth_pixelperfect.png" alt="core_smooth_pixelperfect" width="80"> | ⭐⭐⭐☆ | 3.7 | 4.0 | [Giancamillo Alessandroni](https://github.com/NotManyIdeasDev) |
|
|
||||||
| [core_random_sequence](core/core_random_sequence.c) | <img src="core/core_random_sequence.png" alt="core_random_sequence" width="80"> | ⭐☆☆☆ | 5.0 | 5.0 | [Dalton Overmyer](https://github.com/REDl3east) |
|
|
||||||
| [core_automation_events](core/core_automation_events.c) | <img src="core/core_automation_events.png" alt="core_automation_events" width="80"> | ⭐⭐⭐☆ | 5.0 | 5.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_highdpi_demo](core/core_highdpi_demo.c) | <img src="core/core_highdpi_demo.png" alt="core_highdpi_demo" width="80"> | ⭐⭐☆☆ | 5.0 | 5.5 | [Jonathan Marler](https://github.com/marler8997) |
|
|
||||||
| [core_render_texture](core/core_render_texture.c) | <img src="core/core_render_texture.png" alt="core_render_texture" width="80"> | ⭐☆☆☆ | 6.0 | 6.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_undo_redo](core/core_undo_redo.c) | <img src="core/core_undo_redo.png" alt="core_undo_redo" width="80"> | ⭐⭐⭐☆ | 5.5 | 5.6 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_viewport_scaling](core/core_viewport_scaling.c) | <img src="core/core_viewport_scaling.png" alt="core_viewport_scaling" width="80"> | ⭐⭐☆☆ | 5.5 | 5.5 | [Agnis Aldiņš](https://github.com/nezvers) |
|
|
||||||
| [core_input_actions](core/core_input_actions.c) | <img src="core/core_input_actions.png" alt="core_input_actions" width="80"> | ⭐⭐☆☆ | 5.5 | 5.6 | [Jett](https://github.com/JettMonstersGoBoom) |
|
|
||||||
| [core_directory_files](core/core_directory_files.c) | <img src="core/core_directory_files.png" alt="core_directory_files" width="80"> | ⭐☆☆☆ | 5.5 | 5.6 | [Hugo ARNAL](https://github.com/hugoarnal) |
|
|
||||||
| [core_highdpi_testbed](core/core_highdpi_testbed.c) | <img src="core/core_highdpi_testbed.png" alt="core_highdpi_testbed" width="80"> | ⭐☆☆☆ | 6.0 | 6.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_screen_recording](core/core_screen_recording.c) | <img src="core/core_screen_recording.png" alt="core_screen_recording" width="80"> | ⭐⭐☆☆ | 6.0 | 6.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_clipboard_text](core/core_clipboard_text.c) | <img src="core/core_clipboard_text.png" alt="core_clipboard_text" width="80"> | ⭐⭐☆☆ | 6.0 | 6.0 | [Ananth S](https://github.com/Ananth1839) |
|
|
||||||
| [core_text_file_loading](core/core_text_file_loading.c) | <img src="core/core_text_file_loading.png" alt="core_text_file_loading" width="80"> | ⭐☆☆☆ | 5.5 | 5.6 | [Aanjishnu Bhattacharyya](https://github.com/NimComPoo-04) |
|
|
||||||
| [core_compute_hash](core/core_compute_hash.c) | <img src="core/core_compute_hash.png" alt="core_compute_hash" width="80"> | ⭐⭐☆☆ | 6.0 | 6.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_keyboard_testbed](core/core_keyboard_testbed.c) | <img src="core/core_keyboard_testbed.png" alt="core_keyboard_testbed" width="80"> | ⭐⭐☆☆ | 5.6 | 5.6 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [core_window_web](core/core_window_web.c) | <img src="core/core_window_web.png" alt="core_window_web" width="80"> | ⭐☆☆☆ | 1.3 | 5.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
|
|
||||||
### category: shapes [40]
|
|
||||||
|
|
||||||
Examples using raylib shapes drawing functionality, provided by raylib [shapes](../src/rshapes.c) module.
|
|
||||||
|
|
||||||
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
|
||||||
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
|
||||||
| [shapes_basic_shapes](shapes/shapes_basic_shapes.c) | <img src="shapes/shapes_basic_shapes.png" alt="shapes_basic_shapes" width="80"> | ⭐☆☆☆ | 1.0 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shapes_bouncing_ball](shapes/shapes_bouncing_ball.c) | <img src="shapes/shapes_bouncing_ball.png" alt="shapes_bouncing_ball" width="80"> | ⭐☆☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shapes_bullet_hell](shapes/shapes_bullet_hell.c) | <img src="shapes/shapes_bullet_hell.png" alt="shapes_bullet_hell" width="80"> | ⭐☆☆☆ | 5.6 | 5.6 | [Zero](https://github.com/zerohorsepower) |
|
|
||||||
| [shapes_colors_palette](shapes/shapes_colors_palette.c) | <img src="shapes/shapes_colors_palette.png" alt="shapes_colors_palette" width="80"> | ⭐⭐☆☆ | 1.0 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shapes_logo_raylib](shapes/shapes_logo_raylib.c) | <img src="shapes/shapes_logo_raylib.png" alt="shapes_logo_raylib" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shapes_logo_raylib_anim](shapes/shapes_logo_raylib_anim.c) | <img src="shapes/shapes_logo_raylib_anim.png" alt="shapes_logo_raylib_anim" width="80"> | ⭐⭐☆☆ | 2.5 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shapes_rectangle_scaling](shapes/shapes_rectangle_scaling.c) | <img src="shapes/shapes_rectangle_scaling.png" alt="shapes_rectangle_scaling" width="80"> | ⭐⭐☆☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
|
|
||||||
| [shapes_lines_bezier](shapes/shapes_lines_bezier.c) | <img src="shapes/shapes_lines_bezier.png" alt="shapes_lines_bezier" width="80"> | ⭐☆☆☆ | 1.7 | 1.7 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shapes_collision_area](shapes/shapes_collision_area.c) | <img src="shapes/shapes_collision_area.png" alt="shapes_collision_area" width="80"> | ⭐⭐☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shapes_following_eyes](shapes/shapes_following_eyes.c) | <img src="shapes/shapes_following_eyes.png" alt="shapes_following_eyes" width="80"> | ⭐⭐☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shapes_easings_ball](shapes/shapes_easings_ball.c) | <img src="shapes/shapes_easings_ball.png" alt="shapes_easings_ball" width="80"> | ⭐⭐☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shapes_easings_box](shapes/shapes_easings_box.c) | <img src="shapes/shapes_easings_box.png" alt="shapes_easings_box" width="80"> | ⭐⭐☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shapes_easings_rectangles](shapes/shapes_easings_rectangles.c) | <img src="shapes/shapes_easings_rectangles.png" alt="shapes_easings_rectangles" width="80"> | ⭐⭐⭐☆ | 2.0 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shapes_recursive_tree](shapes/shapes_recursive_tree.c) | <img src="shapes/shapes_recursive_tree.png" alt="shapes_recursive_tree" width="80"> | ⭐⭐⭐☆ | 6.0 | 6.0 | [Jopestpe](https://github.com/jopestpe) |
|
|
||||||
| [shapes_ring_drawing](shapes/shapes_ring_drawing.c) | <img src="shapes/shapes_ring_drawing.png" alt="shapes_ring_drawing" width="80"> | ⭐⭐⭐☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
|
|
||||||
| [shapes_circle_sector_drawing](shapes/shapes_circle_sector_drawing.c) | <img src="shapes/shapes_circle_sector_drawing.png" alt="shapes_circle_sector_drawing" width="80"> | ⭐⭐⭐☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
|
|
||||||
| [shapes_rounded_rectangle_drawing](shapes/shapes_rounded_rectangle_drawing.c) | <img src="shapes/shapes_rounded_rectangle_drawing.png" alt="shapes_rounded_rectangle_drawing" width="80"> | ⭐⭐⭐☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
|
|
||||||
| [shapes_top_down_lights](shapes/shapes_top_down_lights.c) | <img src="shapes/shapes_top_down_lights.png" alt="shapes_top_down_lights" width="80"> | ⭐⭐⭐⭐️ | 4.2 | 4.2 | [Jeffery Myers](https://github.com/JeffM2501) |
|
|
||||||
| [shapes_rectangle_advanced](shapes/shapes_rectangle_advanced.c) | <img src="shapes/shapes_rectangle_advanced.png" alt="shapes_rectangle_advanced" width="80"> | ⭐⭐⭐⭐️ | 5.5 | 5.5 | [Everton Jr.](https://github.com/evertonse) |
|
|
||||||
| [shapes_splines_drawing](shapes/shapes_splines_drawing.c) | <img src="shapes/shapes_splines_drawing.png" alt="shapes_splines_drawing" width="80"> | ⭐⭐⭐☆ | 5.0 | 5.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shapes_digital_clock](shapes/shapes_digital_clock.c) | <img src="shapes/shapes_digital_clock.png" alt="shapes_digital_clock" width="80"> | ⭐⭐⭐⭐️ | 5.5 | 5.6 | [Hamza RAHAL](https://github.com/hmz-rhl) |
|
|
||||||
| [shapes_double_pendulum](shapes/shapes_double_pendulum.c) | <img src="shapes/shapes_double_pendulum.png" alt="shapes_double_pendulum" width="80"> | ⭐⭐☆☆ | 5.5 | 5.5 | [JoeCheong](https://github.com/Joecheong2006) |
|
|
||||||
| [shapes_dashed_line](shapes/shapes_dashed_line.c) | <img src="shapes/shapes_dashed_line.png" alt="shapes_dashed_line" width="80"> | ⭐☆☆☆ | 5.5 | 5.5 | [Luís Almeida](https://github.com/luis605) |
|
|
||||||
| [shapes_triangle_strip](shapes/shapes_triangle_strip.c) | <img src="shapes/shapes_triangle_strip.png" alt="shapes_triangle_strip" width="80"> | ⭐⭐☆☆ | 6.0 | 6.0 | [Jopestpe](https://github.com/jopestpe) |
|
|
||||||
| [shapes_vector_angle](shapes/shapes_vector_angle.c) | <img src="shapes/shapes_vector_angle.png" alt="shapes_vector_angle" width="80"> | ⭐⭐☆☆ | 1.0 | 5.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shapes_pie_chart](shapes/shapes_pie_chart.c) | <img src="shapes/shapes_pie_chart.png" alt="shapes_pie_chart" width="80"> | ⭐⭐⭐☆ | 5.5 | 5.6 | [Gideon Serfontein](https://github.com/GideonSerf) |
|
|
||||||
| [shapes_kaleidoscope](shapes/shapes_kaleidoscope.c) | <img src="shapes/shapes_kaleidoscope.png" alt="shapes_kaleidoscope" width="80"> | ⭐⭐☆☆ | 5.5 | 5.6 | [Hugo ARNAL](https://github.com/hugoarnal) |
|
|
||||||
| [shapes_clock_of_clocks](shapes/shapes_clock_of_clocks.c) | <img src="shapes/shapes_clock_of_clocks.png" alt="shapes_clock_of_clocks" width="80"> | ⭐⭐☆☆ | 5.5 | 6.0 | [JP Mortiboys](https://github.com/themushroompirates) |
|
|
||||||
| [shapes_math_sine_cosine](shapes/shapes_math_sine_cosine.c) | <img src="shapes/shapes_math_sine_cosine.png" alt="shapes_math_sine_cosine" width="80"> | ⭐⭐☆☆ | 6.0 | 6.0 | [Jopestpe](https://github.com/jopestpe) |
|
|
||||||
| [shapes_mouse_trail](shapes/shapes_mouse_trail.c) | <img src="shapes/shapes_mouse_trail.png" alt="shapes_mouse_trail" width="80"> | ⭐☆☆☆ | 5.6 | 6.0 | [Balamurugan R](https://github.com/Bala050814) |
|
|
||||||
| [shapes_simple_particles](shapes/shapes_simple_particles.c) | <img src="shapes/shapes_simple_particles.png" alt="shapes_simple_particles" width="80"> | ⭐⭐☆☆ | 5.6 | 5.6 | [Jordi Santonja](https://github.com/JordSant) |
|
|
||||||
| [shapes_starfield_effect](shapes/shapes_starfield_effect.c) | <img src="shapes/shapes_starfield_effect.png" alt="shapes_starfield_effect" width="80"> | ⭐⭐☆☆ | 5.5 | 6.0 | [JP Mortiboys](https://github.com/themushroompirates) |
|
|
||||||
| [shapes_lines_drawing](shapes/shapes_lines_drawing.c) | <img src="shapes/shapes_lines_drawing.png" alt="shapes_lines_drawing" width="80"> | ⭐☆☆☆ | 6.0 | 5.6 | [Robin](https://github.com/RobinsAviary) |
|
|
||||||
| [shapes_math_angle_rotation](shapes/shapes_math_angle_rotation.c) | <img src="shapes/shapes_math_angle_rotation.png" alt="shapes_math_angle_rotation" width="80"> | ⭐☆☆☆ | 6.0 | 5.6 | [Kris](https://github.com/krispy-snacc) |
|
|
||||||
| [shapes_rlgl_color_wheel](shapes/shapes_rlgl_color_wheel.c) | <img src="shapes/shapes_rlgl_color_wheel.png" alt="shapes_rlgl_color_wheel" width="80"> | ⭐⭐⭐☆ | 6.0 | 6.0 | [Robin](https://github.com/RobinsAviary) |
|
|
||||||
| [shapes_rlgl_triangle](shapes/shapes_rlgl_triangle.c) | <img src="shapes/shapes_rlgl_triangle.png" alt="shapes_rlgl_triangle" width="80"> | ⭐⭐☆☆ | 6.0 | 6.0 | [Robin](https://github.com/RobinsAviary) |
|
|
||||||
| [shapes_ball_physics](shapes/shapes_ball_physics.c) | <img src="shapes/shapes_ball_physics.png" alt="shapes_ball_physics" width="80"> | ⭐⭐☆☆ | 6.0 | 6.0 | [David Buzatto](https://github.com/davidbuzatto) |
|
|
||||||
| [shapes_penrose_tile](shapes/shapes_penrose_tile.c) | <img src="shapes/shapes_penrose_tile.png" alt="shapes_penrose_tile" width="80"> | ⭐⭐⭐⭐️ | 5.5 | 6.0 | [David Buzatto](https://github.com/davidbuzatto) |
|
|
||||||
| [shapes_hilbert_curve](shapes/shapes_hilbert_curve.c) | <img src="shapes/shapes_hilbert_curve.png" alt="shapes_hilbert_curve" width="80"> | ⭐⭐⭐☆ | 5.6 | 5.6 | [Hamza RAHAL](https://github.com/hmz-rhl) |
|
|
||||||
| [shapes_easings_testbed](shapes/shapes_easings_testbed.c) | <img src="shapes/shapes_easings_testbed.png" alt="shapes_easings_testbed" width="80"> | ⭐⭐⭐☆ | 2.5 | 2.5 | [Juan Miguel López](https://github.com/flashback-fx) |
|
|
||||||
|
|
||||||
### category: textures [32]
|
|
||||||
|
|
||||||
Examples using raylib textures functionality, including image/textures loading/generation and drawing, provided by raylib [textures](../src/rtextures.c) module.
|
|
||||||
|
|
||||||
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
|
||||||
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
|
||||||
| [textures_clipboard_image](textures/textures_clipboard_image.c) | <img src="textures/textures_clipboard_image.png" alt="textures_clipboard_image" width="80"> | ⭐☆☆☆ | 6.0 | 6.0 | [Maicon Santana](https://github.com/maiconpintoabreu) |
|
|
||||||
| [textures_magnifying_glass](textures/textures_magnifying_glass.c) | <img src="textures/textures_magnifying_glass.png" alt="textures_magnifying_glass" width="80"> | ⭐⭐⭐☆ | 5.6 | 5.6 | [Luke Vaughan](https://github.com/badram) |
|
|
||||||
| [textures_logo_raylib](textures/textures_logo_raylib.c) | <img src="textures/textures_logo_raylib.png" alt="textures_logo_raylib" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [textures_srcrec_dstrec](textures/textures_srcrec_dstrec.c) | <img src="textures/textures_srcrec_dstrec.png" alt="textures_srcrec_dstrec" width="80"> | ⭐⭐⭐☆ | 1.3 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [textures_image_drawing](textures/textures_image_drawing.c) | <img src="textures/textures_image_drawing.png" alt="textures_image_drawing" width="80"> | ⭐⭐☆☆ | 1.4 | 1.4 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [textures_image_generation](textures/textures_image_generation.c) | <img src="textures/textures_image_generation.png" alt="textures_image_generation" width="80"> | ⭐⭐☆☆ | 1.8 | 1.8 | [Wilhem Barbier](https://github.com/nounoursheureux) |
|
|
||||||
| [textures_image_loading](textures/textures_image_loading.c) | <img src="textures/textures_image_loading.png" alt="textures_image_loading" width="80"> | ⭐☆☆☆ | 1.3 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [textures_image_processing](textures/textures_image_processing.c) | <img src="textures/textures_image_processing.png" alt="textures_image_processing" width="80"> | ⭐⭐⭐☆ | 1.4 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [textures_image_text](textures/textures_image_text.c) | <img src="textures/textures_image_text.png" alt="textures_image_text" width="80"> | ⭐⭐☆☆ | 1.8 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [textures_to_image](textures/textures_to_image.c) | <img src="textures/textures_to_image.png" alt="textures_to_image" width="80"> | ⭐☆☆☆ | 1.3 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [textures_raw_data](textures/textures_raw_data.c) | <img src="textures/textures_raw_data.png" alt="textures_raw_data" width="80"> | ⭐⭐⭐☆ | 1.3 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [textures_particles_blending](textures/textures_particles_blending.c) | <img src="textures/textures_particles_blending.png" alt="textures_particles_blending" width="80"> | ⭐☆☆☆ | 1.7 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [textures_npatch_drawing](textures/textures_npatch_drawing.c) | <img src="textures/textures_npatch_drawing.png" alt="textures_npatch_drawing" width="80"> | ⭐⭐⭐☆ | 2.0 | 2.5 | [Jorge A. Gomes](https://github.com/overdev) |
|
|
||||||
| [textures_background_scrolling](textures/textures_background_scrolling.c) | <img src="textures/textures_background_scrolling.png" alt="textures_background_scrolling" width="80"> | ⭐☆☆☆ | 2.0 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [textures_sprite_animation](textures/textures_sprite_animation.c) | <img src="textures/textures_sprite_animation.png" alt="textures_sprite_animation" width="80"> | ⭐⭐☆☆ | 1.3 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [textures_sprite_button](textures/textures_sprite_button.c) | <img src="textures/textures_sprite_button.png" alt="textures_sprite_button" width="80"> | ⭐⭐☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [textures_sprite_explosion](textures/textures_sprite_explosion.c) | <img src="textures/textures_sprite_explosion.png" alt="textures_sprite_explosion" width="80"> | ⭐⭐☆☆ | 2.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [textures_bunnymark](textures/textures_bunnymark.c) | <img src="textures/textures_bunnymark.png" alt="textures_bunnymark" width="80"> | ⭐⭐⭐☆ | 1.6 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [textures_mouse_painting](textures/textures_mouse_painting.c) | <img src="textures/textures_mouse_painting.png" alt="textures_mouse_painting" width="80"> | ⭐⭐⭐☆ | 3.0 | 3.0 | [Chris Dill](https://github.com/MysteriousSpace) |
|
|
||||||
| [textures_blend_modes](textures/textures_blend_modes.c) | <img src="textures/textures_blend_modes.png" alt="textures_blend_modes" width="80"> | ⭐☆☆☆ | 3.5 | 3.5 | [Karlo Licudine](https://github.com/accidentalrebel) |
|
|
||||||
| [textures_tiled_drawing](textures/textures_tiled_drawing.c) | <img src="textures/textures_tiled_drawing.png" alt="textures_tiled_drawing" width="80"> | ⭐⭐⭐☆ | 3.0 | 4.2 | [Vlad Adrian](https://github.com/demizdor) |
|
|
||||||
| [textures_polygon_drawing](textures/textures_polygon_drawing.c) | <img src="textures/textures_polygon_drawing.png" alt="textures_polygon_drawing" width="80"> | ⭐☆☆☆ | 3.7 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
|
|
||||||
| [textures_fog_of_war](textures/textures_fog_of_war.c) | <img src="textures/textures_fog_of_war.png" alt="textures_fog_of_war" width="80"> | ⭐⭐⭐☆ | 4.2 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [textures_gif_player](textures/textures_gif_player.c) | <img src="textures/textures_gif_player.png" alt="textures_gif_player" width="80"> | ⭐⭐⭐☆ | 4.2 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [textures_image_kernel](textures/textures_image_kernel.c) | <img src="textures/textures_image_kernel.png" alt="textures_image_kernel" width="80"> | ⭐⭐⭐⭐️ | 1.3 | 1.3 | [Karim Salem](https://github.com/kimo-s) |
|
|
||||||
| [textures_image_channel](textures/textures_image_channel.c) | <img src="textures/textures_image_channel.png" alt="textures_image_channel" width="80"> | ⭐⭐☆☆ | 5.5 | 5.5 | [Bruno Cabral](https://github.com/brccabral) |
|
|
||||||
| [textures_image_rotate](textures/textures_image_rotate.c) | <img src="textures/textures_image_rotate.png" alt="textures_image_rotate" width="80"> | ⭐⭐☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [textures_screen_buffer](textures/textures_screen_buffer.c) | <img src="textures/textures_screen_buffer.png" alt="textures_screen_buffer" width="80"> | ⭐⭐☆☆ | 5.5 | 5.5 | [Agnis Aldiņš](https://github.com/nezvers) |
|
|
||||||
| [textures_textured_curve](textures/textures_textured_curve.c) | <img src="textures/textures_textured_curve.png" alt="textures_textured_curve" width="80"> | ⭐⭐⭐☆ | 4.5 | 4.5 | [Jeffery Myers](https://github.com/JeffM2501) |
|
|
||||||
| [textures_sprite_stacking](textures/textures_sprite_stacking.c) | <img src="textures/textures_sprite_stacking.png" alt="textures_sprite_stacking" width="80"> | ⭐⭐☆☆ | 6.0 | 6.0 | [Robin](https://github.com/RobinsAviary) |
|
|
||||||
| [textures_cellular_automata](textures/textures_cellular_automata.c) | <img src="textures/textures_cellular_automata.png" alt="textures_cellular_automata" width="80"> | ⭐⭐☆☆ | 5.6 | 5.6 | [Jordi Santonja](https://github.com/JordSant) |
|
|
||||||
| [textures_framebuffer_rendering](textures/textures_framebuffer_rendering.c) | <img src="textures/textures_framebuffer_rendering.png" alt="textures_framebuffer_rendering" width="80"> | ⭐⭐☆☆ | 5.6 | 5.6 | [Jack Boakes](https://github.com/jackboakes) |
|
|
||||||
|
|
||||||
### category: text [16]
|
|
||||||
|
|
||||||
Examples using raylib text functionality, including sprite fonts loading/generation and text drawing, provided by raylib [text](../src/rtext.c) module.
|
|
||||||
|
|
||||||
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
|
||||||
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
|
||||||
| [text_sprite_fonts](text/text_sprite_fonts.c) | <img src="text/text_sprite_fonts.png" alt="text_sprite_fonts" width="80"> | ⭐☆☆☆ | 1.7 | 3.7 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [text_font_spritefont](text/text_font_spritefont.c) | <img src="text/text_font_spritefont.png" alt="text_font_spritefont" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [text_font_filters](text/text_font_filters.c) | <img src="text/text_font_filters.png" alt="text_font_filters" width="80"> | ⭐⭐☆☆ | 1.3 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [text_font_loading](text/text_font_loading.c) | <img src="text/text_font_loading.png" alt="text_font_loading" width="80"> | ⭐☆☆☆ | 1.4 | 3.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [text_font_sdf](text/text_font_sdf.c) | <img src="text/text_font_sdf.png" alt="text_font_sdf" width="80"> | ⭐⭐⭐☆ | 1.3 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [text_format_text](text/text_format_text.c) | <img src="text/text_format_text.png" alt="text_format_text" width="80"> | ⭐☆☆☆ | 1.1 | 3.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [text_input_box](text/text_input_box.c) | <img src="text/text_input_box.png" alt="text_input_box" width="80"> | ⭐⭐☆☆ | 1.7 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [text_writing_anim](text/text_writing_anim.c) | <img src="text/text_writing_anim.png" alt="text_writing_anim" width="80"> | ⭐⭐☆☆ | 1.4 | 1.4 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [text_rectangle_bounds](text/text_rectangle_bounds.c) | <img src="text/text_rectangle_bounds.png" alt="text_rectangle_bounds" width="80"> | ⭐⭐⭐⭐️ | 2.5 | 4.0 | [Vlad Adrian](https://github.com/demizdor) |
|
|
||||||
| [text_unicode_emojis](text/text_unicode_emojis.c) | <img src="text/text_unicode_emojis.png" alt="text_unicode_emojis" width="80"> | ⭐⭐⭐⭐️ | 2.5 | 4.0 | [Vlad Adrian](https://github.com/demizdor) |
|
|
||||||
| [text_unicode_ranges](text/text_unicode_ranges.c) | <img src="text/text_unicode_ranges.png" alt="text_unicode_ranges" width="80"> | ⭐⭐⭐⭐️ | 5.5 | 5.6 | [Vadim Gunko](https://github.com/GuvaCode) |
|
|
||||||
| [text_3d_drawing](text/text_3d_drawing.c) | <img src="text/text_3d_drawing.png" alt="text_3d_drawing" width="80"> | ⭐⭐⭐⭐️ | 3.5 | 4.0 | [Vlad Adrian](https://github.com/demizdor) |
|
|
||||||
| [text_codepoints_loading](text/text_codepoints_loading.c) | <img src="text/text_codepoints_loading.png" alt="text_codepoints_loading" width="80"> | ⭐⭐⭐☆ | 4.2 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [text_inline_styling](text/text_inline_styling.c) | <img src="text/text_inline_styling.png" alt="text_inline_styling" width="80"> | ⭐⭐⭐☆ | 6.0 | 6.0 | [Wagner Barongello](https://github.com/SultansOfCode) |
|
|
||||||
| [text_words_alignment](text/text_words_alignment.c) | <img src="text/text_words_alignment.png" alt="text_words_alignment" width="80"> | ⭐☆☆☆ | 6.0 | 6.0 | [JP Mortiboys](https://github.com/themushroompirates) |
|
|
||||||
| [text_strings_management](text/text_strings_management.c) | <img src="text/text_strings_management.png" alt="text_strings_management" width="80"> | ⭐⭐⭐☆ | 6.0 | 6.0 | [David Buzatto](https://github.com/davidbuzatto) |
|
|
||||||
|
|
||||||
### category: models [30]
|
|
||||||
|
|
||||||
Examples using raylib models functionality, including models loading/generation and drawing, provided by raylib [models](../src/rmodels.c) module.
|
|
||||||
|
|
||||||
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
|
||||||
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
|
||||||
| [models_loading_iqm](models/models_loading_iqm.c) | <img src="models/models_loading_iqm.png" alt="models_loading_iqm" width="80"> | ⭐⭐☆☆ | 2.5 | 3.5 | [Culacant](https://github.com/culacant) |
|
|
||||||
| [models_billboard_rendering](models/models_billboard_rendering.c) | <img src="models/models_billboard_rendering.png" alt="models_billboard_rendering" width="80"> | ⭐⭐⭐☆ | 1.3 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [models_box_collisions](models/models_box_collisions.c) | <img src="models/models_box_collisions.png" alt="models_box_collisions" width="80"> | ⭐☆☆☆ | 1.3 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [models_cubicmap_rendering](models/models_cubicmap_rendering.c) | <img src="models/models_cubicmap_rendering.png" alt="models_cubicmap_rendering" width="80"> | ⭐⭐☆☆ | 1.8 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [models_first_person_maze](models/models_first_person_maze.c) | <img src="models/models_first_person_maze.png" alt="models_first_person_maze" width="80"> | ⭐⭐☆☆ | 2.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [models_geometric_shapes](models/models_geometric_shapes.c) | <img src="models/models_geometric_shapes.png" alt="models_geometric_shapes" width="80"> | ⭐☆☆☆ | 1.0 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [models_mesh_generation](models/models_mesh_generation.c) | <img src="models/models_mesh_generation.png" alt="models_mesh_generation" width="80"> | ⭐⭐☆☆ | 1.8 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [models_mesh_picking](models/models_mesh_picking.c) | <img src="models/models_mesh_picking.png" alt="models_mesh_picking" width="80"> | ⭐⭐⭐☆ | 1.7 | 4.0 | [Joel Davis](https://github.com/joeld42) |
|
|
||||||
| [models_loading](models/models_loading.c) | <img src="models/models_loading.png" alt="models_loading" width="80"> | ⭐☆☆☆ | 2.0 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [models_loading_gltf](models/models_loading_gltf.c) | <img src="models/models_loading_gltf.png" alt="models_loading_gltf" width="80"> | ⭐☆☆☆ | 3.7 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [models_loading_vox](models/models_loading_vox.c) | <img src="models/models_loading_vox.png" alt="models_loading_vox" width="80"> | ⭐☆☆☆ | 4.0 | 4.0 | [Johann Nadalutti](https://github.com/procfxgen) |
|
|
||||||
| [models_loading_m3d](models/models_loading_m3d.c) | <img src="models/models_loading_m3d.png" alt="models_loading_m3d" width="80"> | ⭐⭐☆☆ | 4.5 | 4.5 | [bzt](https://github.com/bztsrc) |
|
|
||||||
| [models_orthographic_projection](models/models_orthographic_projection.c) | <img src="models/models_orthographic_projection.png" alt="models_orthographic_projection" width="80"> | ⭐☆☆☆ | 2.0 | 3.7 | [Max Danielsson](https://github.com/autious) |
|
|
||||||
| [models_point_rendering](models/models_point_rendering.c) | <img src="models/models_point_rendering.png" alt="models_point_rendering" width="80"> | ⭐⭐⭐☆ | 5.0 | 5.0 | [Reese Gallagher](https://github.com/satchelfrost) |
|
|
||||||
| [models_rlgl_solar_system](models/models_rlgl_solar_system.c) | <img src="models/models_rlgl_solar_system.png" alt="models_rlgl_solar_system" width="80"> | ⭐⭐⭐⭐️ | 2.5 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [models_yaw_pitch_roll](models/models_yaw_pitch_roll.c) | <img src="models/models_yaw_pitch_roll.png" alt="models_yaw_pitch_roll" width="80"> | ⭐⭐☆☆ | 1.8 | 4.0 | [Berni](https://github.com/Berni8k) |
|
|
||||||
| [models_waving_cubes](models/models_waving_cubes.c) | <img src="models/models_waving_cubes.png" alt="models_waving_cubes" width="80"> | ⭐⭐⭐☆ | 2.5 | 3.7 | [Codecat](https://github.com/codecat) |
|
|
||||||
| [models_heightmap_rendering](models/models_heightmap_rendering.c) | <img src="models/models_heightmap_rendering.png" alt="models_heightmap_rendering" width="80"> | ⭐☆☆☆ | 1.8 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [models_skybox_rendering](models/models_skybox_rendering.c) | <img src="models/models_skybox_rendering.png" alt="models_skybox_rendering" width="80"> | ⭐⭐☆☆ | 1.8 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [models_textured_cube](models/models_textured_cube.c) | <img src="models/models_textured_cube.png" alt="models_textured_cube" width="80"> | ⭐⭐☆☆ | 4.5 | 4.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [models_animation_gpu_skinning](models/models_animation_gpu_skinning.c) | <img src="models/models_animation_gpu_skinning.png" alt="models_animation_gpu_skinning" width="80"> | ⭐⭐⭐☆ | 4.5 | 4.5 | [Daniel Holden](https://github.com/orangeduck) |
|
|
||||||
| [models_bone_socket](models/models_bone_socket.c) | <img src="models/models_bone_socket.png" alt="models_bone_socket" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [iP](https://github.com/ipzaur) |
|
|
||||||
| [models_tesseract_view](models/models_tesseract_view.c) | <img src="models/models_tesseract_view.png" alt="models_tesseract_view" width="80"> | ⭐⭐☆☆ | 6.0 | 6.0 | [Timothy van der Valk](https://github.com/arceryz) |
|
|
||||||
| [models_basic_voxel](models/models_basic_voxel.c) | <img src="models/models_basic_voxel.png" alt="models_basic_voxel" width="80"> | ⭐⭐☆☆ | 5.5 | 5.5 | [Tim Little](https://github.com/timlittle) |
|
|
||||||
| [models_rotating_cube](models/models_rotating_cube.c) | <img src="models/models_rotating_cube.png" alt="models_rotating_cube" width="80"> | ⭐☆☆☆ | 6.0 | 6.0 | [Jopestpe](https://github.com/jopestpe) |
|
|
||||||
| [models_decals](models/models_decals.c) | <img src="models/models_decals.png" alt="models_decals" width="80"> | ⭐⭐⭐⭐️ | 6.0 | 6.0 | [JP Mortiboys](https://github.com/themushroompirates) |
|
|
||||||
| [models_directional_billboard](models/models_directional_billboard.c) | <img src="models/models_directional_billboard.png" alt="models_directional_billboard" width="80"> | ⭐⭐☆☆ | 6.0 | 6.0 | [Robin](https://github.com/RobinsAviary) |
|
|
||||||
| [models_animation_blend_custom](models/models_animation_blend_custom.c) | <img src="models/models_animation_blend_custom.png" alt="models_animation_blend_custom" width="80"> | ⭐⭐⭐⭐️ | 5.5 | 6.0 | [dmitrii-brand](https://github.com/dmitrii-brand) |
|
|
||||||
| [models_animation_blending](models/models_animation_blending.c) | <img src="models/models_animation_blending.png" alt="models_animation_blending" width="80"> | ⭐⭐⭐⭐️ | 5.5 | 6.0 | [Kirandeep](https://github.com/Kirandeep-Singh-Khehra) |
|
|
||||||
| [models_animation_timing](models/models_animation_timing.c) | <img src="models/models_animation_timing.png" alt="models_animation_timing" width="80"> | ⭐⭐⭐☆ | 6.0 | 6.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
|
|
||||||
### category: shaders [35]
|
|
||||||
|
|
||||||
Examples using raylib shaders functionality, including shaders loading, parameters configuration and drawing using them (model shaders and postprocessing shaders). This functionality is directly provided by raylib [rlgl](../src/rlgl.h) module.
|
|
||||||
|
|
||||||
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
|
||||||
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
|
||||||
| [shaders_ascii_rendering](shaders/shaders_ascii_rendering.c) | <img src="shaders/shaders_ascii_rendering.png" alt="shaders_ascii_rendering" width="80"> | ⭐⭐☆☆ | 5.5 | 6.0 | [Maicon Santana](https://github.com/maiconpintoabreu) |
|
|
||||||
| [shaders_basic_lighting](shaders/shaders_basic_lighting.c) | <img src="shaders/shaders_basic_lighting.png" alt="shaders_basic_lighting" width="80"> | ⭐⭐⭐⭐️ | 3.0 | 4.2 | [Chris Camacho](https://github.com/chriscamacho) |
|
|
||||||
| [shaders_model_shader](shaders/shaders_model_shader.c) | <img src="shaders/shaders_model_shader.png" alt="shaders_model_shader" width="80"> | ⭐⭐☆☆ | 1.3 | 3.7 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shaders_shapes_textures](shaders/shaders_shapes_textures.c) | <img src="shaders/shaders_shapes_textures.png" alt="shaders_shapes_textures" width="80"> | ⭐⭐☆☆ | 1.7 | 3.7 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shaders_custom_uniform](shaders/shaders_custom_uniform.c) | <img src="shaders/shaders_custom_uniform.png" alt="shaders_custom_uniform" width="80"> | ⭐⭐☆☆ | 1.3 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shaders_postprocessing](shaders/shaders_postprocessing.c) | <img src="shaders/shaders_postprocessing.png" alt="shaders_postprocessing" width="80"> | ⭐⭐⭐☆ | 1.3 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shaders_palette_switch](shaders/shaders_palette_switch.c) | <img src="shaders/shaders_palette_switch.png" alt="shaders_palette_switch" width="80"> | ⭐⭐⭐☆ | 2.5 | 3.7 | [Marco Lizza](https://github.com/MarcoLizza) |
|
|
||||||
| [shaders_raymarching_rendering](shaders/shaders_raymarching_rendering.c) | <img src="shaders/shaders_raymarching_rendering.png" alt="shaders_raymarching_rendering" width="80"> | ⭐⭐⭐⭐️ | 2.0 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shaders_texture_rendering](shaders/shaders_texture_rendering.c) | <img src="shaders/shaders_texture_rendering.png" alt="shaders_texture_rendering" width="80"> | ⭐⭐☆☆ | 2.0 | 3.7 | [Michał Ciesielski](https://github.com/ciessielski) |
|
|
||||||
| [shaders_texture_outline](shaders/shaders_texture_outline.c) | <img src="shaders/shaders_texture_outline.png" alt="shaders_texture_outline" width="80"> | ⭐⭐⭐☆ | 4.0 | 4.0 | [Serenity Skiff](https://github.com/GoldenThumbs) |
|
|
||||||
| [shaders_texture_waves](shaders/shaders_texture_waves.c) | <img src="shaders/shaders_texture_waves.png" alt="shaders_texture_waves" width="80"> | ⭐⭐☆☆ | 2.5 | 3.7 | [Anata](https://github.com/anatagawa) |
|
|
||||||
| [shaders_julia_set](shaders/shaders_julia_set.c) | <img src="shaders/shaders_julia_set.png" alt="shaders_julia_set" width="80"> | ⭐⭐⭐☆ | 2.5 | 4.0 | [Josh Colclough](https://github.com/joshcol9232) |
|
|
||||||
| [shaders_mandelbrot_set](shaders/shaders_mandelbrot_set.c) | <img src="shaders/shaders_mandelbrot_set.png" alt="shaders_mandelbrot_set" width="80"> | ⭐⭐⭐☆ | 6.0 | 6.0 | [Jordi Santonja](https://github.com/JordSant) |
|
|
||||||
| [shaders_color_correction](shaders/shaders_color_correction.c) | <img src="shaders/shaders_color_correction.png" alt="shaders_color_correction" width="80"> | ⭐⭐☆☆ | 6.0 | 6.0 | [Jordi Santonja](https://github.com/JordSant) |
|
|
||||||
| [shaders_eratosthenes_sieve](shaders/shaders_eratosthenes_sieve.c) | <img src="shaders/shaders_eratosthenes_sieve.png" alt="shaders_eratosthenes_sieve" width="80"> | ⭐⭐⭐☆ | 2.5 | 4.0 | [ProfJski](https://github.com/ProfJski) |
|
|
||||||
| [shaders_fog_rendering](shaders/shaders_fog_rendering.c) | <img src="shaders/shaders_fog_rendering.png" alt="shaders_fog_rendering" width="80"> | ⭐⭐⭐☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
|
|
||||||
| [shaders_simple_mask](shaders/shaders_simple_mask.c) | <img src="shaders/shaders_simple_mask.png" alt="shaders_simple_mask" width="80"> | ⭐⭐☆☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
|
|
||||||
| [shaders_hot_reloading](shaders/shaders_hot_reloading.c) | <img src="shaders/shaders_hot_reloading.png" alt="shaders_hot_reloading" width="80"> | ⭐⭐⭐☆ | 3.0 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shaders_mesh_instancing](shaders/shaders_mesh_instancing.c) | <img src="shaders/shaders_mesh_instancing.png" alt="shaders_mesh_instancing" width="80"> | ⭐⭐⭐⭐️ | 3.7 | 4.2 | [seanpringle](https://github.com/seanpringle) |
|
|
||||||
| [shaders_multi_sample2d](shaders/shaders_multi_sample2d.c) | <img src="shaders/shaders_multi_sample2d.png" alt="shaders_multi_sample2d" width="80"> | ⭐⭐☆☆ | 3.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [shaders_normalmap_rendering](shaders/shaders_normalmap_rendering.c) | <img src="shaders/shaders_normalmap_rendering.png" alt="shaders_normalmap_rendering" width="80"> | ⭐⭐⭐⭐️ | 6.0 | 6.0 | [Jeremy Montgomery](https://github.com/Sir_Irk) |
|
|
||||||
| [shaders_spotlight_rendering](shaders/shaders_spotlight_rendering.c) | <img src="shaders/shaders_spotlight_rendering.png" alt="shaders_spotlight_rendering" width="80"> | ⭐⭐☆☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
|
|
||||||
| [shaders_deferred_rendering](shaders/shaders_deferred_rendering.c) | <img src="shaders/shaders_deferred_rendering.png" alt="shaders_deferred_rendering" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [Justin Andreas Lacoste](https://github.com/27justin) |
|
|
||||||
| [shaders_hybrid_rendering](shaders/shaders_hybrid_rendering.c) | <img src="shaders/shaders_hybrid_rendering.png" alt="shaders_hybrid_rendering" width="80"> | ⭐⭐⭐⭐️ | 4.2 | 4.2 | [Buğra Alptekin Sarı](https://github.com/BugraAlptekinSari) |
|
|
||||||
| [shaders_texture_tiling](shaders/shaders_texture_tiling.c) | <img src="shaders/shaders_texture_tiling.png" alt="shaders_texture_tiling" width="80"> | ⭐⭐☆☆ | 4.5 | 4.5 | [Luis Almeida](https://github.com/luis605) |
|
|
||||||
| [shaders_shadowmap_rendering](shaders/shaders_shadowmap_rendering.c) | <img src="shaders/shaders_shadowmap_rendering.png" alt="shaders_shadowmap_rendering" width="80"> | ⭐⭐⭐⭐️ | 5.0 | 5.0 | [TheManTheMythTheGameDev](https://github.com/TheManTheMythTheGameDev) |
|
|
||||||
| [shaders_vertex_displacement](shaders/shaders_vertex_displacement.c) | <img src="shaders/shaders_vertex_displacement.png" alt="shaders_vertex_displacement" width="80"> | ⭐⭐⭐☆ | 5.0 | 4.5 | [Alex ZH](https://github.com/ZzzhHe) |
|
|
||||||
| [shaders_depth_writing](shaders/shaders_depth_writing.c) | <img src="shaders/shaders_depth_writing.png" alt="shaders_depth_writing" width="80"> | ⭐⭐☆☆ | 4.2 | 4.2 | [Buğra Alptekin Sarı](https://github.com/BugraAlptekinSari) |
|
|
||||||
| [shaders_basic_pbr](shaders/shaders_basic_pbr.c) | <img src="shaders/shaders_basic_pbr.png" alt="shaders_basic_pbr" width="80"> | ⭐⭐⭐⭐️ | 5.0 | 5.5 | [Afan OLOVCIC](https://github.com/_DevDad) |
|
|
||||||
| [shaders_lightmap_rendering](shaders/shaders_lightmap_rendering.c) | <img src="shaders/shaders_lightmap_rendering.png" alt="shaders_lightmap_rendering" width="80"> | ⭐⭐⭐☆ | 4.5 | 4.5 | [Jussi Viitala](https://github.com/nullstare) |
|
|
||||||
| [shaders_rounded_rectangle](shaders/shaders_rounded_rectangle.c) | <img src="shaders/shaders_rounded_rectangle.png" alt="shaders_rounded_rectangle" width="80"> | ⭐⭐⭐☆ | 5.5 | 5.5 | [Anstro Pleuton](https://github.com/anstropleuton) |
|
|
||||||
| [shaders_depth_rendering](shaders/shaders_depth_rendering.c) | <img src="shaders/shaders_depth_rendering.png" alt="shaders_depth_rendering" width="80"> | ⭐⭐⭐☆ | 6.0 | 6.0 | [Luís Almeida](https://github.com/luis605) |
|
|
||||||
| [shaders_game_of_life](shaders/shaders_game_of_life.c) | <img src="shaders/shaders_game_of_life.png" alt="shaders_game_of_life" width="80"> | ⭐⭐⭐☆ | 6.0 | 6.0 | [Jordi Santonja](https://github.com/JordSant) |
|
|
||||||
| [shaders_rlgl_compute](shaders/shaders_rlgl_compute.c) | <img src="shaders/shaders_rlgl_compute.png" alt="shaders_rlgl_compute" width="80"> | ⭐⭐⭐⭐️ | 4.0 | 4.0 | [Teddy Astie](https://github.com/tsnake41) |
|
|
||||||
| [shaders_cel_shading](shaders/shaders_cel_shading.c) | <img src="shaders/shaders_cel_shading.png" alt="shaders_cel_shading" width="80"> | ⭐⭐⭐☆ | 6.0 | 6.0 | [Gleb A](https://github.com/ggrizzly) |
|
|
||||||
|
|
||||||
### category: audio [10]
|
|
||||||
|
|
||||||
Examples using raylib audio functionality, including sound/music loading and playing. This functionality is provided by raylib [raudio](../src/raudio.c) module. Note this module can be used standalone independently of raylib.
|
|
||||||
|
|
||||||
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
|
||||||
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
|
||||||
| [audio_module_playing](audio/audio_module_playing.c) | <img src="audio/audio_module_playing.png" alt="audio_module_playing" width="80"> | ⭐☆☆☆ | 1.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [audio_music_stream](audio/audio_music_stream.c) | <img src="audio/audio_music_stream.png" alt="audio_music_stream" width="80"> | ⭐☆☆☆ | 1.3 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [audio_raw_stream](audio/audio_raw_stream.c) | <img src="audio/audio_raw_stream.png" alt="audio_raw_stream" width="80"> | ⭐⭐⭐☆ | 1.6 | 6.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [audio_sound_loading](audio/audio_sound_loading.c) | <img src="audio/audio_sound_loading.png" alt="audio_sound_loading" width="80"> | ⭐☆☆☆ | 1.1 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [audio_mixed_processor](audio/audio_mixed_processor.c) | <img src="audio/audio_mixed_processor.png" alt="audio_mixed_processor" width="80"> | ⭐⭐⭐⭐️ | 4.2 | 4.2 | [hkc](https://github.com/hatkidchan) |
|
|
||||||
| [audio_stream_effects](audio/audio_stream_effects.c) | <img src="audio/audio_stream_effects.png" alt="audio_stream_effects" width="80"> | ⭐⭐⭐⭐️ | 4.2 | 5.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
|
||||||
| [audio_sound_multi](audio/audio_sound_multi.c) | <img src="audio/audio_sound_multi.png" alt="audio_sound_multi" width="80"> | ⭐⭐☆☆ | 5.0 | 5.0 | [Jeffery Myers](https://github.com/JeffM2501) |
|
|
||||||
| [audio_sound_positioning](audio/audio_sound_positioning.c) | <img src="audio/audio_sound_positioning.png" alt="audio_sound_positioning" width="80"> | ⭐⭐☆☆ | 5.5 | 5.5 | [Le Juez Victor](https://github.com/Bigfoot71) |
|
|
||||||
| [audio_spectrum_visualizer](audio/audio_spectrum_visualizer.c) | <img src="audio/audio_spectrum_visualizer.png" alt="audio_spectrum_visualizer" width="80"> | ⭐⭐⭐☆ | 6.0 | 6.0 | [IANN](https://github.com/meisei4) |
|
|
||||||
| [audio_stream_callback](audio/audio_stream_callback.c) | <img src="audio/audio_stream_callback.png" alt="audio_stream_callback" width="80"> | ⭐⭐⭐☆ | 6.0 | 6.0 | [Dan Hoang](https://github.com/dan-hoang) |
|
|
||||||
|
|
||||||
Some example missing? As always, contributions are welcome, feel free to send new examples!
|
|
||||||
Here is an [examples template](examples_template.c) with instructions to start with!
|
|
||||||
|
|
@ -1,238 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [audio] example - amp envelope
|
|
||||||
*
|
|
||||||
* Example complexity rating: [★☆☆☆] 1/4
|
|
||||||
*
|
|
||||||
* Example originally created with raylib 6.0, last time updated with raylib 6.0
|
|
||||||
*
|
|
||||||
* Example contributed by Arbinda Rizki Muhammad (@arbipink) and reviewed by Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2026 Arbinda Rizki Muhammad (@arbipink)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
#define RAYGUI_IMPLEMENTATION
|
|
||||||
#include "raygui.h"
|
|
||||||
|
|
||||||
#include <math.h> // Required for: sinf()
|
|
||||||
|
|
||||||
#define BUFFER_SIZE 4096
|
|
||||||
#define SAMPLE_RATE 44100
|
|
||||||
|
|
||||||
// Wave state
|
|
||||||
typedef enum {
|
|
||||||
IDLE,
|
|
||||||
ATTACK,
|
|
||||||
DECAY,
|
|
||||||
SUSTAIN,
|
|
||||||
RELEASE
|
|
||||||
} ADSRState;
|
|
||||||
|
|
||||||
// Grouping all ADSR parameters and state into a struct
|
|
||||||
typedef struct {
|
|
||||||
float attackTime;
|
|
||||||
float decayTime;
|
|
||||||
float sustainLevel;
|
|
||||||
float releaseTime;
|
|
||||||
float currentValue;
|
|
||||||
ADSRState state;
|
|
||||||
} Envelope;
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Module Functions Declaration
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
static void FillAudioBuffer(int i, float *buffer, float envelopeValue, float *audioTime);
|
|
||||||
static void UpdateEnvelope(Envelope *env);
|
|
||||||
static void DrawADSRGraph(Envelope *env, Rectangle bounds);
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - amp envelope");
|
|
||||||
|
|
||||||
InitAudioDevice();
|
|
||||||
|
|
||||||
// Set the number of samples the stream will keep in memory at a time to BUFFER_SIZE
|
|
||||||
SetAudioStreamBufferSizeDefault(BUFFER_SIZE);
|
|
||||||
float buffer[BUFFER_SIZE] = { 0 };
|
|
||||||
|
|
||||||
// Init raw audio stream (sample rate: 44100, sample size: 32bit-float, channels: 1-mono)
|
|
||||||
AudioStream stream = LoadAudioStream(SAMPLE_RATE, 32, 1);
|
|
||||||
|
|
||||||
// Init Phase
|
|
||||||
float audioTime = 0.0f;
|
|
||||||
|
|
||||||
// Initialize the struct
|
|
||||||
Envelope env = {
|
|
||||||
.attackTime = 1.0f,
|
|
||||||
.decayTime = 1.0f,
|
|
||||||
.sustainLevel = 0.5f,
|
|
||||||
.releaseTime = 1.0f,
|
|
||||||
.currentValue = 0.0f,
|
|
||||||
.state = IDLE
|
|
||||||
};
|
|
||||||
|
|
||||||
SetTargetFPS(60);
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose())
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
if (IsKeyPressed(KEY_SPACE)) env.state = ATTACK;
|
|
||||||
|
|
||||||
if (IsKeyReleased(KEY_SPACE) && (env.state != IDLE)) env.state = RELEASE;
|
|
||||||
|
|
||||||
if (IsAudioStreamProcessed(stream))
|
|
||||||
{
|
|
||||||
if ((env.state != IDLE) || (env.currentValue > 0.0f))
|
|
||||||
{
|
|
||||||
for (int i = 0; i < BUFFER_SIZE; i++)
|
|
||||||
{
|
|
||||||
UpdateEnvelope(&env);
|
|
||||||
FillAudioBuffer(i, buffer, env.currentValue, &audioTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Clear buffer if silent to avoid looping noise
|
|
||||||
for (int i = 0; i < BUFFER_SIZE; i++) buffer[i] = 0;
|
|
||||||
audioTime = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateAudioStream(stream, buffer, BUFFER_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!IsAudioStreamPlaying(stream)) PlayAudioStream(stream);
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
GuiSliderBar((Rectangle){ 100, 60, 400, 30 }, "Attack (s)", TextFormat("%2.2fs", env.attackTime), &env.attackTime, 0.1f, 3.0f);
|
|
||||||
GuiSliderBar((Rectangle){ 100, 100, 400, 30 }, "Decay (s)", TextFormat("%2.2fs", env.decayTime), &env.decayTime, 0.1f, 3.0f);
|
|
||||||
GuiSliderBar((Rectangle){ 100, 140, 400, 30 }, "Sustain", TextFormat("%2.2f", env.sustainLevel), &env.sustainLevel, 0.0f, 1.0f);
|
|
||||||
GuiSliderBar((Rectangle){ 100, 180, 400, 30 }, "Release (s)", TextFormat("%2.2fs", env.releaseTime), &env.releaseTime, 0.1f, 3.0f);
|
|
||||||
|
|
||||||
DrawADSRGraph(&env, (Rectangle){ 100, 250, 400, 100 });
|
|
||||||
|
|
||||||
DrawCircleV((Vector2){ 520, 350 - (env.currentValue * 100) }, 5, MAROON);
|
|
||||||
DrawText(TextFormat("Current Gain: %2.2f", env.currentValue), 535, 345 - (env.currentValue * 100), 10, MAROON);
|
|
||||||
|
|
||||||
DrawText("Press SPACE to PLAY the sound!", 200, 400, 20, LIGHTGRAY);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
UnloadAudioStream(stream);
|
|
||||||
CloseAudioDevice();
|
|
||||||
|
|
||||||
CloseWindow();
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Module Functions Definition
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
static void FillAudioBuffer(int i, float *buffer, float envelopeValue, float *audioTime)
|
|
||||||
{
|
|
||||||
int frequency = 440;
|
|
||||||
buffer[i] = envelopeValue*sinf(2.0f*PI*frequency*(*audioTime));
|
|
||||||
*audioTime += (1.0f/SAMPLE_RATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void UpdateEnvelope(Envelope *env)
|
|
||||||
{
|
|
||||||
// Calculate the time delta for ONE sample (1/44100)
|
|
||||||
float sampleTime = 1.0f/SAMPLE_RATE;
|
|
||||||
|
|
||||||
switch(env->state)
|
|
||||||
{
|
|
||||||
case ATTACK:
|
|
||||||
{
|
|
||||||
env->currentValue += (1.0f/env->attackTime)*sampleTime;
|
|
||||||
if (env->currentValue >= 1.0f)
|
|
||||||
{
|
|
||||||
env->currentValue = 1.0f;
|
|
||||||
env->state = DECAY;
|
|
||||||
}
|
|
||||||
|
|
||||||
} break;
|
|
||||||
case DECAY:
|
|
||||||
{
|
|
||||||
env->currentValue -= ((1.0f - env->sustainLevel)/env->decayTime)*sampleTime;
|
|
||||||
if (env->currentValue <= env->sustainLevel)
|
|
||||||
{
|
|
||||||
env->currentValue = env->sustainLevel;
|
|
||||||
env->state = SUSTAIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
} break;
|
|
||||||
case SUSTAIN:
|
|
||||||
{
|
|
||||||
env->currentValue = env->sustainLevel;
|
|
||||||
|
|
||||||
} break;
|
|
||||||
case RELEASE:
|
|
||||||
{
|
|
||||||
env->currentValue -= (env->sustainLevel/env->releaseTime)*sampleTime;
|
|
||||||
if (env->currentValue <= 0.001f) // Use a small threshold to avoid infinite tail
|
|
||||||
{
|
|
||||||
env->currentValue = 0.0f;
|
|
||||||
env->state = IDLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
} break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void DrawADSRGraph(Envelope *env, Rectangle bounds)
|
|
||||||
{
|
|
||||||
DrawRectangleRec(bounds, Fade(LIGHTGRAY, 0.3f));
|
|
||||||
DrawRectangleLinesEx(bounds, 1, GRAY);
|
|
||||||
|
|
||||||
// Fixed visual width for sustain stage since it's an amplitude not a time value
|
|
||||||
float sustainWidth = 1.0f;
|
|
||||||
|
|
||||||
// Total time to visualize (sum of A, D, R + a padding for Sustain)
|
|
||||||
float totalTime = env->attackTime + env->decayTime + sustainWidth + env->releaseTime;
|
|
||||||
|
|
||||||
float scaleX = bounds.width/totalTime;
|
|
||||||
float scaleY = bounds.height;
|
|
||||||
|
|
||||||
Vector2 start = { bounds.x, bounds.y + bounds.height };
|
|
||||||
Vector2 peak = { start.x + (env->attackTime*scaleX), bounds.y };
|
|
||||||
Vector2 sustain = { peak.x + (env->decayTime*scaleX), bounds.y + (1.0f - env->sustainLevel)*scaleY };
|
|
||||||
Vector2 rel = { sustain.x + (sustainWidth*scaleX), sustain.y };
|
|
||||||
Vector2 end = { rel.x + (env->releaseTime*scaleX), bounds.y + bounds.height };
|
|
||||||
|
|
||||||
DrawLineV(start, peak, SKYBLUE);
|
|
||||||
DrawLineV(peak, sustain, BLUE);
|
|
||||||
DrawLineV(sustain, rel, DARKBLUE);
|
|
||||||
DrawLineV(rel, end, ORANGE);
|
|
||||||
|
|
||||||
DrawText("ADSR Visualizer", bounds.x, bounds.y - 20, 10, DARKGRAY);
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 11 KiB |
|
|
@ -1,125 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [audio] example - mixed processor
|
|
||||||
*
|
|
||||||
* Example complexity rating: [★★★★] 4/4
|
|
||||||
*
|
|
||||||
* Example originally created with raylib 4.2, last time updated with raylib 4.2
|
|
||||||
*
|
|
||||||
* Example contributed by hkc (@hatkidchan) and reviewed by Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2023-2025 hkc (@hatkidchan)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
#include "raylib.h"
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
static float exponent = 1.0f; // Audio exponentiation value
|
|
||||||
static float averageVolume[400] = { 0.0f }; // Average volume history
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Audio processing function
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
void ProcessAudio(void *buffer, unsigned int frames)
|
|
||||||
{
|
|
||||||
float *samples = (float *)buffer; // Samples internally stored as <float>s
|
|
||||||
float average = 0.0f; // Temporary average volume
|
|
||||||
|
|
||||||
for (unsigned int frame = 0; frame < frames; frame++)
|
|
||||||
{
|
|
||||||
float *left = &samples[frame*2 + 0], *right = &samples[frame*2 + 1];
|
|
||||||
|
|
||||||
*left = powf(fabsf(*left), exponent)*( (*left < 0.0f)? -1.0f : 1.0f );
|
|
||||||
*right = powf(fabsf(*right), exponent)*( (*right < 0.0f)? -1.0f : 1.0f );
|
|
||||||
|
|
||||||
average += fabsf(*left)/frames; // accumulating average volume
|
|
||||||
average += fabsf(*right)/frames;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Moving history to the left
|
|
||||||
for (int i = 0; i < 399; i++) averageVolume[i] = averageVolume[i + 1];
|
|
||||||
|
|
||||||
averageVolume[399] = average; // Adding last average value
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - mixed processor");
|
|
||||||
|
|
||||||
InitAudioDevice(); // Initialize audio device
|
|
||||||
|
|
||||||
AttachAudioMixedProcessor(ProcessAudio);
|
|
||||||
|
|
||||||
Music music = LoadMusicStream("resources/country.mp3");
|
|
||||||
Sound sound = LoadSound("resources/coin.wav");
|
|
||||||
|
|
||||||
PlayMusicStream(music);
|
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
UpdateMusicStream(music); // Update music buffer with new stream data
|
|
||||||
|
|
||||||
// Modify processing variables
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
if (IsKeyPressed(KEY_LEFT)) exponent -= 0.05f;
|
|
||||||
if (IsKeyPressed(KEY_RIGHT)) exponent += 0.05f;
|
|
||||||
|
|
||||||
if (exponent <= 0.5f) exponent = 0.5f;
|
|
||||||
if (exponent >= 3.0f) exponent = 3.0f;
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_SPACE)) PlaySound(sound);
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
DrawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, LIGHTGRAY);
|
|
||||||
|
|
||||||
DrawText(TextFormat("EXPONENT = %.2f", exponent), 215, 180, 20, LIGHTGRAY);
|
|
||||||
|
|
||||||
DrawRectangle(199, 199, 402, 34, LIGHTGRAY);
|
|
||||||
for (int i = 0; i < 400; i++)
|
|
||||||
{
|
|
||||||
DrawLine(201 + i, 232 - (int)(averageVolume[i]*32), 201 + i, 232, MAROON);
|
|
||||||
}
|
|
||||||
DrawRectangleLines(199, 199, 402, 34, GRAY);
|
|
||||||
|
|
||||||
DrawText("PRESS SPACE TO PLAY OTHER SOUND", 200, 250, 20, LIGHTGRAY);
|
|
||||||
DrawText("USE LEFT AND RIGHT ARROWS TO ALTER DISTORTION", 140, 280, 20, LIGHTGRAY);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
UnloadMusicStream(music); // Unload music stream buffers from RAM
|
|
||||||
|
|
||||||
DetachAudioMixedProcessor(ProcessAudio); // Disconnect audio processor
|
|
||||||
|
|
||||||
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 8.5 KiB |
|
|
@ -1,162 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [audio] example - module playing
|
|
||||||
*
|
|
||||||
* Example complexity rating: [★☆☆☆] 1/4
|
|
||||||
*
|
|
||||||
* Example originally created with raylib 1.5, last time updated with raylib 3.5
|
|
||||||
*
|
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2016-2025 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
#define MAX_CIRCLES 64
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
Vector2 position;
|
|
||||||
float radius;
|
|
||||||
float alpha;
|
|
||||||
float speed;
|
|
||||||
Color color;
|
|
||||||
} CircleWave;
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
SetConfigFlags(FLAG_MSAA_4X_HINT); // NOTE: Try to enable MSAA 4X
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing");
|
|
||||||
|
|
||||||
InitAudioDevice(); // Initialize audio device
|
|
||||||
|
|
||||||
Color colors[14] = { ORANGE, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK,
|
|
||||||
YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE };
|
|
||||||
|
|
||||||
// Creates some circles for visual effect
|
|
||||||
CircleWave circles[MAX_CIRCLES] = { 0 };
|
|
||||||
|
|
||||||
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
circles[i].alpha = 0.0f;
|
|
||||||
circles[i].radius = (float)GetRandomValue(10, 40);
|
|
||||||
circles[i].position.x = (float)GetRandomValue((int)circles[i].radius, (int)(screenWidth - circles[i].radius));
|
|
||||||
circles[i].position.y = (float)GetRandomValue((int)circles[i].radius, (int)(screenHeight - circles[i].radius));
|
|
||||||
circles[i].speed = (float)GetRandomValue(1, 100)/2000.0f;
|
|
||||||
circles[i].color = colors[GetRandomValue(0, 13)];
|
|
||||||
}
|
|
||||||
|
|
||||||
Music music = LoadMusicStream("resources/mini1111.xm");
|
|
||||||
music.looping = false;
|
|
||||||
float pitch = 1.0f;
|
|
||||||
|
|
||||||
PlayMusicStream(music);
|
|
||||||
|
|
||||||
float timePlayed = 0.0f;
|
|
||||||
bool pause = false;
|
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
UpdateMusicStream(music); // Update music buffer with new stream data
|
|
||||||
|
|
||||||
// Restart music playing (stop and play)
|
|
||||||
if (IsKeyPressed(KEY_SPACE))
|
|
||||||
{
|
|
||||||
StopMusicStream(music);
|
|
||||||
PlayMusicStream(music);
|
|
||||||
pause = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pause/Resume music playing
|
|
||||||
if (IsKeyPressed(KEY_P))
|
|
||||||
{
|
|
||||||
pause = !pause;
|
|
||||||
|
|
||||||
if (pause) PauseMusicStream(music);
|
|
||||||
else ResumeMusicStream(music);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsKeyDown(KEY_DOWN)) pitch -= 0.01f;
|
|
||||||
else if (IsKeyDown(KEY_UP)) pitch += 0.01f;
|
|
||||||
|
|
||||||
SetMusicPitch(music, pitch);
|
|
||||||
|
|
||||||
// Get timePlayed scaled to bar dimensions
|
|
||||||
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music)*(screenWidth - 40);
|
|
||||||
|
|
||||||
// Color circles animation
|
|
||||||
for (int i = MAX_CIRCLES - 1; (i >= 0) && !pause; i--)
|
|
||||||
{
|
|
||||||
circles[i].alpha += circles[i].speed;
|
|
||||||
circles[i].radius += circles[i].speed*10.0f;
|
|
||||||
|
|
||||||
if (circles[i].alpha > 1.0f) circles[i].speed *= -1;
|
|
||||||
|
|
||||||
if (circles[i].alpha <= 0.0f)
|
|
||||||
{
|
|
||||||
circles[i].alpha = 0.0f;
|
|
||||||
circles[i].radius = (float)GetRandomValue(10, 40);
|
|
||||||
circles[i].position.x = (float)GetRandomValue((int)circles[i].radius, (int)(screenWidth - circles[i].radius));
|
|
||||||
circles[i].position.y = (float)GetRandomValue((int)circles[i].radius, (int)(screenHeight - circles[i].radius));
|
|
||||||
circles[i].color = colors[GetRandomValue(0, 13)];
|
|
||||||
circles[i].speed = (float)GetRandomValue(1, 100)/2000.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
DrawCircleV(circles[i].position, circles[i].radius, Fade(circles[i].color, circles[i].alpha));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw time bar
|
|
||||||
DrawRectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, LIGHTGRAY);
|
|
||||||
DrawRectangle(20, screenHeight - 20 - 12, (int)timePlayed, 12, MAROON);
|
|
||||||
DrawRectangleLines(20, screenHeight - 20 - 12, screenWidth - 40, 12, GRAY);
|
|
||||||
|
|
||||||
// Draw help instructions
|
|
||||||
DrawRectangle(20, 20, 425, 145, WHITE);
|
|
||||||
DrawRectangleLines(20, 20, 425, 145, GRAY);
|
|
||||||
DrawText("PRESS SPACE TO RESTART MUSIC", 40, 40, 20, BLACK);
|
|
||||||
DrawText("PRESS P TO PAUSE/RESUME", 40, 70, 20, BLACK);
|
|
||||||
DrawText("PRESS UP/DOWN TO CHANGE SPEED", 40, 100, 20, BLACK);
|
|
||||||
DrawText(TextFormat("SPEED: %f", pitch), 40, 130, 20, MAROON);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
UnloadMusicStream(music); // Unload music stream buffers from RAM
|
|
||||||
|
|
||||||
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 44 KiB |
|
|
@ -1,144 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [audio] example - music stream
|
|
||||||
*
|
|
||||||
* Example complexity rating: [★☆☆☆] 1/4
|
|
||||||
*
|
|
||||||
* Example originally created with raylib 1.3, last time updated with raylib 4.2
|
|
||||||
*
|
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015-2025 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - music stream");
|
|
||||||
|
|
||||||
InitAudioDevice(); // Initialize audio device
|
|
||||||
|
|
||||||
Music music = LoadMusicStream("resources/country.mp3");
|
|
||||||
|
|
||||||
PlayMusicStream(music);
|
|
||||||
|
|
||||||
float timePlayed = 0.0f; // Time played normalized [0.0f..1.0f]
|
|
||||||
bool pause = false; // Music playing paused
|
|
||||||
|
|
||||||
float pan = 0.0f; // Default audio pan center [-1.0f..1.0f]
|
|
||||||
SetMusicPan(music, pan);
|
|
||||||
|
|
||||||
float volume = 0.8f; // Default audio volume [0.0f..1.0f]
|
|
||||||
SetMusicVolume(music, volume);
|
|
||||||
|
|
||||||
SetTargetFPS(30); // Set our game to run at 30 frames-per-second
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
UpdateMusicStream(music); // Update music buffer with new stream data
|
|
||||||
|
|
||||||
// Restart music playing (stop and play)
|
|
||||||
if (IsKeyPressed(KEY_SPACE))
|
|
||||||
{
|
|
||||||
StopMusicStream(music);
|
|
||||||
PlayMusicStream(music);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pause/Resume music playing
|
|
||||||
if (IsKeyPressed(KEY_P))
|
|
||||||
{
|
|
||||||
pause = !pause;
|
|
||||||
|
|
||||||
if (pause) PauseMusicStream(music);
|
|
||||||
else ResumeMusicStream(music);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set audio pan
|
|
||||||
if (IsKeyDown(KEY_LEFT))
|
|
||||||
{
|
|
||||||
pan -= 0.05f;
|
|
||||||
if (pan < -1.0f) pan = -1.0f;
|
|
||||||
SetMusicPan(music, pan);
|
|
||||||
}
|
|
||||||
else if (IsKeyDown(KEY_RIGHT))
|
|
||||||
{
|
|
||||||
pan += 0.05f;
|
|
||||||
if (pan > 1.0f) pan = 1.0f;
|
|
||||||
SetMusicPan(music, pan);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set audio volume
|
|
||||||
if (IsKeyDown(KEY_DOWN))
|
|
||||||
{
|
|
||||||
volume -= 0.05f;
|
|
||||||
if (volume < 0.0f) volume = 0.0f;
|
|
||||||
SetMusicVolume(music, volume);
|
|
||||||
}
|
|
||||||
else if (IsKeyDown(KEY_UP))
|
|
||||||
{
|
|
||||||
volume += 0.05f;
|
|
||||||
if (volume > 1.0f) volume = 1.0f;
|
|
||||||
SetMusicVolume(music, volume);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get normalized time played for current music stream
|
|
||||||
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music);
|
|
||||||
|
|
||||||
if (timePlayed > 1.0f) timePlayed = 1.0f; // Make sure time played is no longer than music
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
DrawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, LIGHTGRAY);
|
|
||||||
|
|
||||||
DrawText("LEFT-RIGHT for PAN CONTROL", 320, 74, 10, DARKBLUE);
|
|
||||||
DrawRectangle(300, 100, 200, 12, LIGHTGRAY);
|
|
||||||
DrawRectangleLines(300, 100, 200, 12, GRAY);
|
|
||||||
DrawRectangle((int)(300 + (pan + 1.0f)/2.0f*200 - 5), 92, 10, 28, DARKGRAY);
|
|
||||||
|
|
||||||
DrawRectangle(200, 200, 400, 12, LIGHTGRAY);
|
|
||||||
DrawRectangle(200, 200, (int)(timePlayed*400.0f), 12, MAROON);
|
|
||||||
DrawRectangleLines(200, 200, 400, 12, GRAY);
|
|
||||||
|
|
||||||
DrawText("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, LIGHTGRAY);
|
|
||||||
DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, LIGHTGRAY);
|
|
||||||
|
|
||||||
DrawText("UP-DOWN for VOLUME CONTROL", 320, 334, 10, DARKGREEN);
|
|
||||||
DrawRectangle(300, 360, 200, 12, LIGHTGRAY);
|
|
||||||
DrawRectangleLines(300, 360, 200, 12, GRAY);
|
|
||||||
DrawRectangle((int)(300 + volume*200 - 5), 352, 10, 28, DARKGRAY);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
UnloadMusicStream(music); // Unload music stream buffers from RAM
|
|
||||||
|
|
||||||
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,146 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [audio] example - raw stream
|
|
||||||
*
|
|
||||||
* Example complexity rating: [★★★☆] 3/4
|
|
||||||
*
|
|
||||||
* Example originally created with raylib 1.6, last time updated with raylib 6.0
|
|
||||||
*
|
|
||||||
* Example created by Ramon Santamaria (@raysan5) and reviewed by James Hofmann (@triplefox)
|
|
||||||
*
|
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015-2026 Ramon Santamaria (@raysan5) and James Hofmann (@triplefox)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#define BUFFER_SIZE 4096
|
|
||||||
#define SAMPLE_RATE 44100
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - raw stream");
|
|
||||||
|
|
||||||
InitAudioDevice();
|
|
||||||
|
|
||||||
// Set the number of samples the stream will keep in memory at a time to BUFFER_SIZE
|
|
||||||
SetAudioStreamBufferSizeDefault(BUFFER_SIZE);
|
|
||||||
float buffer[BUFFER_SIZE] = {};
|
|
||||||
|
|
||||||
// Init raw audio stream (sample rate: 44100, sample size: 32bit-float, channels: 1-mono)
|
|
||||||
AudioStream stream = LoadAudioStream(SAMPLE_RATE, 32, 1);
|
|
||||||
float pan = 0.0f;
|
|
||||||
SetAudioStreamPan(stream, pan);
|
|
||||||
PlayAudioStream(stream);
|
|
||||||
|
|
||||||
int sineFrequency = 440;
|
|
||||||
int newSineFrequency = 440;
|
|
||||||
int sineIndex = 0;
|
|
||||||
double sineStartTime = 0.0;
|
|
||||||
|
|
||||||
SetTargetFPS(30);
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
if (IsKeyDown(KEY_UP))
|
|
||||||
{
|
|
||||||
newSineFrequency += 10;
|
|
||||||
if (newSineFrequency > 12500) newSineFrequency = 12500;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsKeyDown(KEY_DOWN))
|
|
||||||
{
|
|
||||||
newSineFrequency -= 10;
|
|
||||||
if (newSineFrequency < 20) newSineFrequency = 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsKeyDown(KEY_LEFT))
|
|
||||||
{
|
|
||||||
pan -= 0.01f;
|
|
||||||
if (pan < -1.0f) pan = -1.0f;
|
|
||||||
SetAudioStreamPan(stream, pan);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsKeyDown(KEY_RIGHT))
|
|
||||||
{
|
|
||||||
pan += 0.01f;
|
|
||||||
if (pan > 1.0f) pan = 1.0f;
|
|
||||||
SetAudioStreamPan(stream, pan);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsAudioStreamProcessed(stream))
|
|
||||||
{
|
|
||||||
for (int i = 0; i < BUFFER_SIZE; i++)
|
|
||||||
{
|
|
||||||
int wavelength = SAMPLE_RATE/sineFrequency;
|
|
||||||
buffer[i] = sin(2*PI*sineIndex/wavelength);
|
|
||||||
sineIndex++;
|
|
||||||
|
|
||||||
if (sineIndex >= wavelength)
|
|
||||||
{
|
|
||||||
sineFrequency = newSineFrequency;
|
|
||||||
sineIndex = 0;
|
|
||||||
sineStartTime = GetTime();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateAudioStream(stream, buffer, BUFFER_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
DrawText(TextFormat("sine frequency: %i", sineFrequency), screenWidth - 220, 10, 20, RED);
|
|
||||||
DrawText(TextFormat("pan: %.2f", pan), screenWidth - 220, 30, 20, RED);
|
|
||||||
DrawText("Up/down to change frequency", 10, 10, 20, DARKGRAY);
|
|
||||||
DrawText("Left/right to pan", 10, 30, 20, DARKGRAY);
|
|
||||||
|
|
||||||
int windowStart = (GetTime() - sineStartTime)*SAMPLE_RATE;
|
|
||||||
int windowSize = 0.1f*SAMPLE_RATE;
|
|
||||||
int wavelength = SAMPLE_RATE/sineFrequency;
|
|
||||||
|
|
||||||
// Draw a sine wave with the same frequency as the one being sent to the audio stream
|
|
||||||
for (int i = 0; i < screenWidth; i++)
|
|
||||||
{
|
|
||||||
int t0 = windowStart + i*windowSize/screenWidth;
|
|
||||||
int t1 = windowStart + (i + 1)*windowSize/screenWidth;
|
|
||||||
Vector2 startPos = { i, 250 + 50*sin(2*PI*t0/wavelength) };
|
|
||||||
Vector2 endPos = { i + 1, 250 + 50*sin(2*PI*t1/wavelength) };
|
|
||||||
DrawLineV(startPos, endPos, RED);
|
|
||||||
}
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
UnloadAudioStream(stream); // Close raw audio stream and delete buffers from RAM
|
|
||||||
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 16 KiB |
|
|
@ -1,91 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [audio] example - sound multi
|
|
||||||
*
|
|
||||||
* Example complexity rating: [★★☆☆] 2/4
|
|
||||||
*
|
|
||||||
* Example originally created with raylib 5.0, last time updated with raylib 5.0
|
|
||||||
*
|
|
||||||
* Example contributed by Jeffery Myers (@JeffM2501) and reviewed by Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2023-2025 Jeffery Myers (@JeffM2501)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
#define MAX_SOUNDS 10
|
|
||||||
Sound soundArray[MAX_SOUNDS] = { 0 };
|
|
||||||
int currentSound;
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound multi");
|
|
||||||
|
|
||||||
InitAudioDevice(); // Initialize audio device
|
|
||||||
|
|
||||||
// Load audio file into the first slot as the 'source' sound,
|
|
||||||
// this sound owns the sample data
|
|
||||||
soundArray[0] = LoadSound("resources/sound.wav");
|
|
||||||
|
|
||||||
// Load an alias of the sound into slots 1-9. These do not own the sound data, but can be played
|
|
||||||
for (int i = 1; i < MAX_SOUNDS; i++) soundArray[i] = LoadSoundAlias(soundArray[0]);
|
|
||||||
|
|
||||||
currentSound = 0; // Set the sound list to the start
|
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
if (IsKeyPressed(KEY_SPACE))
|
|
||||||
{
|
|
||||||
PlaySound(soundArray[currentSound]); // Play the next open sound slot
|
|
||||||
currentSound++; // Increment the sound slot
|
|
||||||
|
|
||||||
// If the sound slot is out of bounds, go back to 0
|
|
||||||
if (currentSound >= MAX_SOUNDS) currentSound = 0;
|
|
||||||
|
|
||||||
// NOTE: Another approach would be to look at the list for the first sound
|
|
||||||
// that is not playing and use that slot
|
|
||||||
}
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
DrawText("Press SPACE to PLAY a WAV sound!", 200, 180, 20, LIGHTGRAY);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
for (int i = 1; i < MAX_SOUNDS; i++) UnloadSoundAlias(soundArray[i]); // Unload sound aliases
|
|
||||||
UnloadSound(soundArray[0]); // Unload source sound data
|
|
||||||
|
|
||||||
CloseAudioDevice(); // Close audio device
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 15 KiB |
|
|
@ -1,131 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [audio] example - sound positioning
|
|
||||||
*
|
|
||||||
* Example complexity rating: [★★☆☆] 2/4
|
|
||||||
*
|
|
||||||
* Example originally created with raylib 5.5, last time updated with raylib 5.5
|
|
||||||
*
|
|
||||||
* Example contributed by Le Juez Victor (@Bigfoot71) and reviewed by Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2025 Le Juez Victor (@Bigfoot71)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
#include "raymath.h"
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Module Functions Declaration
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
static void SetSoundPosition(Camera listener, Sound sound, Vector3 position, float maxDist);
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound positioning");
|
|
||||||
|
|
||||||
InitAudioDevice();
|
|
||||||
|
|
||||||
Sound sound = LoadSound("resources/coin.wav");
|
|
||||||
|
|
||||||
Camera camera = {
|
|
||||||
.position = (Vector3) { 0, 5, 5 },
|
|
||||||
.target = (Vector3) { 0, 0, 0 },
|
|
||||||
.up = (Vector3) { 0, 1, 0 },
|
|
||||||
.fovy = 60,
|
|
||||||
.projection = CAMERA_PERSPECTIVE
|
|
||||||
};
|
|
||||||
|
|
||||||
DisableCursor();
|
|
||||||
|
|
||||||
SetTargetFPS(60);
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose())
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
UpdateCamera(&camera, CAMERA_FREE);
|
|
||||||
|
|
||||||
float th = (float)GetTime();
|
|
||||||
|
|
||||||
Vector3 spherePos = {
|
|
||||||
.x = 5.0f*cosf(th),
|
|
||||||
.y = 0.0f,
|
|
||||||
.z = 5.0f*sinf(th)
|
|
||||||
};
|
|
||||||
|
|
||||||
SetSoundPosition(camera, sound, spherePos, 1.0f);
|
|
||||||
|
|
||||||
if (!IsSoundPlaying(sound)) PlaySound(sound);
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
BeginMode3D(camera);
|
|
||||||
DrawGrid(10, 2);
|
|
||||||
DrawSphere(spherePos, 0.5f, RED);
|
|
||||||
EndMode3D();
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
UnloadSound(sound);
|
|
||||||
CloseAudioDevice(); // Close audio device
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Module Functions Definition
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Set sound 3d position
|
|
||||||
static void SetSoundPosition(Camera listener, Sound sound, Vector3 position, float maxDist)
|
|
||||||
{
|
|
||||||
// Calculate direction vector and distance between listener and sound source
|
|
||||||
Vector3 direction = Vector3Subtract(position, listener.position);
|
|
||||||
float distance = Vector3Length(direction);
|
|
||||||
|
|
||||||
// Apply logarithmic distance attenuation and clamp between 0-1
|
|
||||||
float attenuation = 1.0f/(1.0f + (distance/maxDist));
|
|
||||||
attenuation = Clamp(attenuation, 0.0f, 1.0f);
|
|
||||||
|
|
||||||
// Calculate normalized vectors for spatial positioning
|
|
||||||
Vector3 normalizedDirection = Vector3Normalize(direction);
|
|
||||||
Vector3 forward = Vector3Normalize(Vector3Subtract(listener.target, listener.position));
|
|
||||||
Vector3 right = Vector3Normalize(Vector3CrossProduct(listener.up, forward));
|
|
||||||
|
|
||||||
// Reduce volume for sounds behind the listener
|
|
||||||
float dotProduct = Vector3DotProduct(forward, normalizedDirection);
|
|
||||||
if (dotProduct < 0.0f) attenuation *= (1.0f + dotProduct*0.5f);
|
|
||||||
|
|
||||||
// Set stereo panning based on sound position relative to listener
|
|
||||||
float pan = 0.5f + 0.5f*Vector3DotProduct(normalizedDirection, right);
|
|
||||||
|
|
||||||
// Apply final sound properties
|
|
||||||
SetSoundVolume(sound, attenuation);
|
|
||||||
SetSoundPan(sound, pan);
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 26 KiB |
|
|
@ -1,285 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [audio] example - spectrum visualizer
|
|
||||||
*
|
|
||||||
* Example complexity rating: [★★★☆] 3/4
|
|
||||||
*
|
|
||||||
* Example originally created with raylib 6.0, last time updated with raylib 6.0
|
|
||||||
*
|
|
||||||
* Inspired by Inigo Quilez's https://www.shadertoy.com/
|
|
||||||
* Resources/specification: https://gist.github.com/soulthreads/2efe50da4be1fb5f7ab60ff14ca434b8
|
|
||||||
*
|
|
||||||
* Example created by created by IANN (@meisei4) reviewed by Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2025 IANN (@meisei4)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
#include "raymath.h"
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
|
||||||
#define GLSL_VERSION 330
|
|
||||||
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
|
||||||
#define GLSL_VERSION 100
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MONO 1
|
|
||||||
#define SAMPLE_RATE 44100
|
|
||||||
#define SAMPLE_RATE_F 44100.0f
|
|
||||||
#define FFT_WINDOW_SIZE 1024
|
|
||||||
#define BUFFER_SIZE 512
|
|
||||||
#define PER_SAMPLE_BIT_DEPTH 16
|
|
||||||
#define AUDIO_STREAM_RING_BUFFER_SIZE (FFT_WINDOW_SIZE*2)
|
|
||||||
#define EFFECTIVE_SAMPLE_RATE (SAMPLE_RATE_F*0.5f)
|
|
||||||
#define WINDOW_TIME ((double)FFT_WINDOW_SIZE/(double)EFFECTIVE_SAMPLE_RATE)
|
|
||||||
#define FFT_HISTORICAL_SMOOTHING_DUR 2.0f
|
|
||||||
#define MIN_DECIBELS (-100.0f) // https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/minDecibels
|
|
||||||
#define MAX_DECIBELS (-30.0f) // https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/maxDecibels
|
|
||||||
#define INVERSE_DECIBEL_RANGE (1.0f/(MAX_DECIBELS - MIN_DECIBELS))
|
|
||||||
#define DB_TO_LINEAR_SCALE (20.0f/2.302585092994046f)
|
|
||||||
#define SMOOTHING_TIME_CONSTANT 0.8f // https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/smoothingTimeConstant
|
|
||||||
#define TEXTURE_HEIGHT 1
|
|
||||||
#define FFT_ROW 0
|
|
||||||
#define UNUSED_CHANNEL 0.0f
|
|
||||||
|
|
||||||
typedef struct FFTComplex { float real, imaginary; } FFTComplex;
|
|
||||||
|
|
||||||
typedef struct FFTData {
|
|
||||||
FFTComplex *spectrum;
|
|
||||||
FFTComplex *workBuffer;
|
|
||||||
float *prevMagnitudes;
|
|
||||||
float (*fftHistory)[BUFFER_SIZE];
|
|
||||||
int fftHistoryLen;
|
|
||||||
int historyPos;
|
|
||||||
double lastFftTime;
|
|
||||||
float tapbackPos;
|
|
||||||
} FFTData;
|
|
||||||
|
|
||||||
static void CaptureFrame(FFTData *fftData, const float *audioSamples);
|
|
||||||
static void RenderFrame(const FFTData *fftData, Image *fftImage);
|
|
||||||
static void CooleyTukeyFFTSlow(FFTComplex *spectrum, int n);
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//----------------------------------------------------------------------------------- ---
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - spectrum visualizer");
|
|
||||||
|
|
||||||
Image fftImage = GenImageColor(BUFFER_SIZE, TEXTURE_HEIGHT, WHITE);
|
|
||||||
Texture2D fftTexture = LoadTextureFromImage(fftImage);
|
|
||||||
RenderTexture2D bufferA = LoadRenderTexture(screenWidth, screenHeight);
|
|
||||||
Vector2 iResolution = { (float)screenWidth, (float)screenHeight };
|
|
||||||
|
|
||||||
Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/fft.fs", GLSL_VERSION));
|
|
||||||
|
|
||||||
int iResolutionLocation = GetShaderLocation(shader, "iResolution");
|
|
||||||
int iChannel0Location = GetShaderLocation(shader, "iChannel0");
|
|
||||||
SetShaderValue(shader, iResolutionLocation, &iResolution, SHADER_UNIFORM_VEC2);
|
|
||||||
SetShaderValueTexture(shader, iChannel0Location, fftTexture);
|
|
||||||
|
|
||||||
InitAudioDevice();
|
|
||||||
SetAudioStreamBufferSizeDefault(AUDIO_STREAM_RING_BUFFER_SIZE);
|
|
||||||
|
|
||||||
// WARNING: Memory out-of-bounds on PLATFORM_WEB
|
|
||||||
Wave wav = LoadWave("resources/country.mp3");
|
|
||||||
WaveFormat(&wav, SAMPLE_RATE, PER_SAMPLE_BIT_DEPTH, MONO);
|
|
||||||
|
|
||||||
AudioStream audioStream = LoadAudioStream(SAMPLE_RATE, PER_SAMPLE_BIT_DEPTH, MONO);
|
|
||||||
PlayAudioStream(audioStream);
|
|
||||||
|
|
||||||
int fftHistoryLen = (int)ceilf(FFT_HISTORICAL_SMOOTHING_DUR/WINDOW_TIME) + 1;
|
|
||||||
|
|
||||||
FFTData fft = {
|
|
||||||
.spectrum = RL_CALLOC(sizeof(FFTComplex), FFT_WINDOW_SIZE),
|
|
||||||
.workBuffer = RL_CALLOC(sizeof(FFTComplex), FFT_WINDOW_SIZE),
|
|
||||||
.prevMagnitudes = RL_CALLOC(BUFFER_SIZE, sizeof(float)),
|
|
||||||
.fftHistory = RL_CALLOC(fftHistoryLen, sizeof(float[BUFFER_SIZE])),
|
|
||||||
.fftHistoryLen = fftHistoryLen,
|
|
||||||
.historyPos = 0,
|
|
||||||
.lastFftTime = 0.0,
|
|
||||||
.tapbackPos = 0.01f
|
|
||||||
};
|
|
||||||
|
|
||||||
unsigned int wavCursor = 0;
|
|
||||||
const short *wavPCM16 = wav.data;
|
|
||||||
|
|
||||||
short chunkSamples[AUDIO_STREAM_RING_BUFFER_SIZE] = { 0 };
|
|
||||||
float audioSamples[FFT_WINDOW_SIZE] = { 0 };
|
|
||||||
|
|
||||||
SetTargetFPS(60);
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
while (IsAudioStreamProcessed(audioStream))
|
|
||||||
{
|
|
||||||
for (int i = 0; i < AUDIO_STREAM_RING_BUFFER_SIZE; i++)
|
|
||||||
{
|
|
||||||
int left = (wav.channels == 2)? wavPCM16[wavCursor*2 + 0] : wavPCM16[wavCursor];
|
|
||||||
int right = (wav.channels == 2)? wavPCM16[wavCursor*2 + 1] : left;
|
|
||||||
chunkSamples[i] = (short)((left + right)/2);
|
|
||||||
|
|
||||||
if (++wavCursor >= wav.frameCount) wavCursor = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateAudioStream(audioStream, chunkSamples, AUDIO_STREAM_RING_BUFFER_SIZE);
|
|
||||||
|
|
||||||
for (int i = 0; i < FFT_WINDOW_SIZE; i++) audioSamples[i] = (chunkSamples[i*2] + chunkSamples[i*2 + 1])*0.5f/32767.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
CaptureFrame(&fft, audioSamples);
|
|
||||||
RenderFrame(&fft, &fftImage);
|
|
||||||
UpdateTexture(fftTexture, fftImage.data);
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
BeginShaderMode(shader);
|
|
||||||
SetShaderValueTexture(shader, iChannel0Location, fftTexture);
|
|
||||||
DrawTextureRec(bufferA.texture,
|
|
||||||
(Rectangle){ 0, 0, (float)screenWidth, (float)-screenHeight },
|
|
||||||
(Vector2){ 0, 0 }, WHITE);
|
|
||||||
EndShaderMode();
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
UnloadShader(shader);
|
|
||||||
UnloadRenderTexture(bufferA);
|
|
||||||
UnloadTexture(fftTexture);
|
|
||||||
UnloadImage(fftImage);
|
|
||||||
UnloadAudioStream(audioStream);
|
|
||||||
UnloadWave(wav);
|
|
||||||
CloseAudioDevice();
|
|
||||||
|
|
||||||
RL_FREE(fft.spectrum);
|
|
||||||
RL_FREE(fft.workBuffer);
|
|
||||||
RL_FREE(fft.prevMagnitudes);
|
|
||||||
RL_FREE(fft.fftHistory);
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cooley–Tukey FFT https://en.wikipedia.org/wiki/Cooley%E2%80%93Tukey_FFT_algorithm#Data_reordering,_bit_reversal,_and_in-place_algorithms
|
|
||||||
static void CooleyTukeyFFTSlow(FFTComplex *spectrum, int n)
|
|
||||||
{
|
|
||||||
int j = 0;
|
|
||||||
for (int i = 1; i < n - 1; i++)
|
|
||||||
{
|
|
||||||
int bit = n >> 1;
|
|
||||||
while (j >= bit)
|
|
||||||
{
|
|
||||||
j -= bit;
|
|
||||||
bit >>= 1;
|
|
||||||
}
|
|
||||||
j += bit;
|
|
||||||
if (i < j)
|
|
||||||
{
|
|
||||||
FFTComplex temp = spectrum[i];
|
|
||||||
spectrum[i] = spectrum[j];
|
|
||||||
spectrum[j] = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int len = 2; len <= n; len <<= 1)
|
|
||||||
{
|
|
||||||
float angle = -2.0f*PI/len;
|
|
||||||
FFTComplex twiddleUnit = { cosf(angle), sinf(angle) };
|
|
||||||
for (int i = 0; i < n; i += len)
|
|
||||||
{
|
|
||||||
FFTComplex twiddleCurrent = { 1.0f, 0.0f };
|
|
||||||
for (int j = 0; j < len/2; j++)
|
|
||||||
{
|
|
||||||
FFTComplex even = spectrum[i + j];
|
|
||||||
FFTComplex odd = spectrum[i + j + len/2];
|
|
||||||
FFTComplex twiddledOdd = {
|
|
||||||
odd.real*twiddleCurrent.real - odd.imaginary*twiddleCurrent.imaginary,
|
|
||||||
odd.real*twiddleCurrent.imaginary + odd.imaginary*twiddleCurrent.real
|
|
||||||
};
|
|
||||||
|
|
||||||
spectrum[i + j].real = even.real + twiddledOdd.real;
|
|
||||||
spectrum[i + j].imaginary = even.imaginary + twiddledOdd.imaginary;
|
|
||||||
spectrum[i + j + len/2].real = even.real - twiddledOdd.real;
|
|
||||||
spectrum[i + j + len/2].imaginary = even.imaginary - twiddledOdd.imaginary;
|
|
||||||
|
|
||||||
float twiddleRealNext = twiddleCurrent.real*twiddleUnit.real - twiddleCurrent.imaginary*twiddleUnit.imaginary;
|
|
||||||
twiddleCurrent.imaginary = twiddleCurrent.real*twiddleUnit.imaginary + twiddleCurrent.imaginary*twiddleUnit.real;
|
|
||||||
twiddleCurrent.real = twiddleRealNext;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void CaptureFrame(FFTData *fftData, const float *audioSamples)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < FFT_WINDOW_SIZE; i++)
|
|
||||||
{
|
|
||||||
float x = (2.0f*PI*i)/(FFT_WINDOW_SIZE - 1.0f);
|
|
||||||
float blackmanWeight = 0.42f - 0.5f*cosf(x) + 0.08f*cosf(2.0f*x); // https://en.wikipedia.org/wiki/Window_function#Blackman_window
|
|
||||||
fftData->workBuffer[i].real = audioSamples[i]*blackmanWeight;
|
|
||||||
fftData->workBuffer[i].imaginary = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
CooleyTukeyFFTSlow(fftData->workBuffer, FFT_WINDOW_SIZE);
|
|
||||||
memcpy(fftData->spectrum, fftData->workBuffer, sizeof(FFTComplex)*FFT_WINDOW_SIZE);
|
|
||||||
|
|
||||||
float smoothedSpectrum[BUFFER_SIZE];
|
|
||||||
|
|
||||||
for (int bin = 0; bin < BUFFER_SIZE; bin++)
|
|
||||||
{
|
|
||||||
float re = fftData->workBuffer[bin].real;
|
|
||||||
float im = fftData->workBuffer[bin].imaginary;
|
|
||||||
float linearMagnitude = sqrtf(re*re + im*im)/FFT_WINDOW_SIZE;
|
|
||||||
|
|
||||||
float smoothedMagnitude = SMOOTHING_TIME_CONSTANT*fftData->prevMagnitudes[bin] + (1.0f - SMOOTHING_TIME_CONSTANT)*linearMagnitude;
|
|
||||||
fftData->prevMagnitudes[bin] = smoothedMagnitude;
|
|
||||||
|
|
||||||
float db = logf(fmaxf(smoothedMagnitude, 1e-40f))*DB_TO_LINEAR_SCALE;
|
|
||||||
float normalized = (db - MIN_DECIBELS)*INVERSE_DECIBEL_RANGE;
|
|
||||||
smoothedSpectrum[bin] = Clamp(normalized, 0.0f, 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
fftData->lastFftTime = GetTime();
|
|
||||||
memcpy(fftData->fftHistory[fftData->historyPos], smoothedSpectrum, sizeof(smoothedSpectrum));
|
|
||||||
fftData->historyPos = (fftData->historyPos + 1)%fftData->fftHistoryLen;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void RenderFrame(const FFTData *fftData, Image *fftImage)
|
|
||||||
{
|
|
||||||
float framesSinceTapback = floorf((float)(fftData->tapbackPos/WINDOW_TIME));
|
|
||||||
framesSinceTapback = Clamp(framesSinceTapback, 0.0f, (float)(fftData->fftHistoryLen - 1));
|
|
||||||
|
|
||||||
int historyPosition = (fftData->historyPos - 1 - (int)framesSinceTapback)%fftData->fftHistoryLen;
|
|
||||||
if (historyPosition < 0) historyPosition += fftData->fftHistoryLen;
|
|
||||||
|
|
||||||
const float *amplitude = fftData->fftHistory[historyPosition];
|
|
||||||
for (int bin = 0; bin < BUFFER_SIZE; bin++) ImageDrawPixel(fftImage, bin, FFT_ROW, ColorFromNormalized((Vector4){ amplitude[bin], UNUSED_CHANNEL, UNUSED_CHANNEL, UNUSED_CHANNEL }));
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 15 KiB |
|
|
@ -1,246 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [audio] example - stream callback
|
|
||||||
*
|
|
||||||
* Example complexity rating: [★★★☆] 3/4
|
|
||||||
*
|
|
||||||
* Example originally created with raylib 6.0, last time updated with raylib 6.0
|
|
||||||
*
|
|
||||||
* Example created by Dan Hoang (@dan-hoang) and reviewed by Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
* NOTE: Example sends a wave to the audio device,
|
|
||||||
* user gets the choice of four waves: sine, square, triangle, and sawtooth
|
|
||||||
* A stream is set up to play to the audio device; stream is hooked to a callback that
|
|
||||||
* generates a wave, that is determined by user choice
|
|
||||||
*
|
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2026 Dan Hoang (@dan-hoang)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#define BUFFER_SIZE 4096
|
|
||||||
#define SAMPLE_RATE 44100
|
|
||||||
|
|
||||||
// Wave type
|
|
||||||
typedef enum {
|
|
||||||
SINE,
|
|
||||||
SQUARE,
|
|
||||||
TRIANGLE,
|
|
||||||
SAWTOOTH
|
|
||||||
} WaveType;
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Module Functions Declaration
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
static void SineCallback(void *framesOut, unsigned int frameCount);
|
|
||||||
static void SquareCallback(void *framesOut, unsigned int frameCount);
|
|
||||||
static void TriangleCallback(void *framesOut, unsigned int frameCount);
|
|
||||||
static void SawtoothCallback(void *framesOut, unsigned int frameCount);
|
|
||||||
|
|
||||||
static int waveFrequency = 440;
|
|
||||||
static int newWaveFrequency = 440;
|
|
||||||
static int waveIndex = 0;
|
|
||||||
|
|
||||||
// Buffer to keep the last second of uploaded audio,
|
|
||||||
// part of which will be drawn on the screen
|
|
||||||
static float buffer[SAMPLE_RATE] = { 0 };
|
|
||||||
static AudioCallback waveCallbacks[] = { SineCallback, SquareCallback, TriangleCallback, SawtoothCallback };
|
|
||||||
static char *waveTypesAsString[] = { "sine", "square", "triangle", "sawtooth" };
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - stream callback");
|
|
||||||
|
|
||||||
InitAudioDevice();
|
|
||||||
|
|
||||||
// Set the number of samples the stream will keep in memory at a time to BUFFER_SIZE
|
|
||||||
SetAudioStreamBufferSizeDefault(BUFFER_SIZE);
|
|
||||||
|
|
||||||
// Init raw audio stream (sample rate: 44100, sample size: 32bit-float, channels: 1-mono)
|
|
||||||
AudioStream stream = LoadAudioStream(SAMPLE_RATE, 32, 1);
|
|
||||||
PlayAudioStream(stream);
|
|
||||||
|
|
||||||
// Configure it so that waveCallbacks[waveType] is called whenever stream is out of samples
|
|
||||||
WaveType waveType = SINE;
|
|
||||||
SetAudioStreamCallback(stream, waveCallbacks[waveType]);
|
|
||||||
|
|
||||||
SetTargetFPS(30);
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
if (IsKeyDown(KEY_UP))
|
|
||||||
{
|
|
||||||
newWaveFrequency += 10;
|
|
||||||
if (newWaveFrequency > 12500) newWaveFrequency = 12500;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsKeyDown(KEY_DOWN))
|
|
||||||
{
|
|
||||||
newWaveFrequency -= 10;
|
|
||||||
if (newWaveFrequency < 20) newWaveFrequency = 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_LEFT))
|
|
||||||
{
|
|
||||||
if (waveType == SINE) waveType = SAWTOOTH;
|
|
||||||
else if (waveType == SQUARE) waveType = SINE;
|
|
||||||
else if (waveType == TRIANGLE) waveType = SQUARE;
|
|
||||||
else waveType = TRIANGLE;
|
|
||||||
|
|
||||||
SetAudioStreamCallback(stream, waveCallbacks[waveType]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_RIGHT))
|
|
||||||
{
|
|
||||||
if (waveType == SINE) waveType = SQUARE;
|
|
||||||
else if (waveType == SQUARE) waveType = TRIANGLE;
|
|
||||||
else if (waveType == TRIANGLE) waveType = SAWTOOTH;
|
|
||||||
else waveType = SINE;
|
|
||||||
|
|
||||||
SetAudioStreamCallback(stream, waveCallbacks[waveType]);
|
|
||||||
}
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
DrawText(TextFormat("frequency: %i", newWaveFrequency), screenWidth - 220, 10, 20, RED);
|
|
||||||
DrawText(TextFormat("wave type: %s", waveTypesAsString[waveType]), screenWidth - 220, 30, 20, RED);
|
|
||||||
DrawText("Up/down to change frequency", 10, 10, 20, DARKGRAY);
|
|
||||||
DrawText("Left/right to change wave type", 10, 30, 20, DARKGRAY);
|
|
||||||
|
|
||||||
// Draw the last 10 ms of uploaded audio
|
|
||||||
for (int i = 0; i < screenWidth; i++)
|
|
||||||
{
|
|
||||||
Vector2 startPos = { i, 250 - 50*buffer[SAMPLE_RATE - SAMPLE_RATE/100 + i*SAMPLE_RATE/100/screenWidth] };
|
|
||||||
Vector2 endPos = { i + 1, 250 - 50*buffer[SAMPLE_RATE - SAMPLE_RATE/100 + (i + 1)*SAMPLE_RATE/100/screenWidth] };
|
|
||||||
DrawLineV(startPos, endPos, RED);
|
|
||||||
}
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
UnloadAudioStream(stream); // Close raw audio stream and delete buffers from RAM
|
|
||||||
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Module Functions Definition
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
static void SineCallback(void *framesOut, unsigned int frameCount)
|
|
||||||
{
|
|
||||||
int wavelength = SAMPLE_RATE/waveFrequency;
|
|
||||||
|
|
||||||
// Synthesize the sine wave
|
|
||||||
for (int i = 0; i < frameCount; i++)
|
|
||||||
{
|
|
||||||
((float *)framesOut)[i] = sin(2*PI*waveIndex/wavelength);
|
|
||||||
|
|
||||||
waveIndex++;
|
|
||||||
|
|
||||||
if (waveIndex >= wavelength)
|
|
||||||
{
|
|
||||||
waveFrequency = newWaveFrequency;
|
|
||||||
waveIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the synthesized samples for later drawing
|
|
||||||
for (int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount];
|
|
||||||
for (int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float *)framesOut)[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SquareCallback(void *framesOut, unsigned int frameCount)
|
|
||||||
{
|
|
||||||
int wavelength = SAMPLE_RATE/waveFrequency;
|
|
||||||
|
|
||||||
// Synthesize the square wave
|
|
||||||
for (int i = 0; i < frameCount; i++)
|
|
||||||
{
|
|
||||||
((float *)framesOut)[i] = (waveIndex < wavelength/2)? 1 : -1;
|
|
||||||
waveIndex++;
|
|
||||||
|
|
||||||
if (waveIndex >= wavelength)
|
|
||||||
{
|
|
||||||
waveFrequency = newWaveFrequency;
|
|
||||||
waveIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the synthesized samples for later drawing
|
|
||||||
for (int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount];
|
|
||||||
for (int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float *)framesOut)[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void TriangleCallback(void *framesOut, unsigned int frameCount)
|
|
||||||
{
|
|
||||||
int wavelength = SAMPLE_RATE/waveFrequency;
|
|
||||||
|
|
||||||
// Synthesize the triangle wave
|
|
||||||
for (int i = 0; i < frameCount; i++)
|
|
||||||
{
|
|
||||||
((float *)framesOut)[i] = (waveIndex < wavelength/2)? (-1 + 2.0f*waveIndex/(wavelength/2)) : (1 - 2.0f*(waveIndex - wavelength/2)/(wavelength/2));
|
|
||||||
waveIndex++;
|
|
||||||
|
|
||||||
if (waveIndex >= wavelength)
|
|
||||||
{
|
|
||||||
waveFrequency = newWaveFrequency;
|
|
||||||
waveIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the synthesized samples for later drawing
|
|
||||||
for (int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount];
|
|
||||||
for (int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float *)framesOut)[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SawtoothCallback(void *framesOut, unsigned int frameCount)
|
|
||||||
{
|
|
||||||
int wavelength = SAMPLE_RATE/waveFrequency;
|
|
||||||
|
|
||||||
// Synthesize the sawtooth wave
|
|
||||||
for (int i = 0; i < frameCount; i++)
|
|
||||||
{
|
|
||||||
((float *)framesOut)[i] = -1 + 2.0f*waveIndex/wavelength;
|
|
||||||
waveIndex++;
|
|
||||||
|
|
||||||
if (waveIndex >= wavelength)
|
|
||||||
{
|
|
||||||
waveFrequency = newWaveFrequency;
|
|
||||||
waveIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the synthesized samples for later drawing
|
|
||||||
for (int i = 0; i < SAMPLE_RATE - frameCount; i++) buffer[i] = buffer[i + frameCount];
|
|
||||||
for (int i = 0; i < frameCount; i++) buffer[SAMPLE_RATE - frameCount + i] = ((float *)framesOut)[i];
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 15 KiB |
|
|
@ -1,187 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [audio] example - stream effects
|
|
||||||
*
|
|
||||||
* Example complexity rating: [★★★★] 4/4
|
|
||||||
*
|
|
||||||
* Example originally created with raylib 4.2, last time updated with raylib 5.0
|
|
||||||
*
|
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2022-2025 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
#include <stdlib.h> // Required for: NULL
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Global Variables Definition
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
static float *delayBuffer = NULL;
|
|
||||||
static unsigned int delayBufferSize = 0;
|
|
||||||
static unsigned int delayReadIndex = 2;
|
|
||||||
static unsigned int delayWriteIndex = 0;
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Module Functions Declaration
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
static void AudioProcessEffectLPF(void *buffer, unsigned int frames); // Audio effect: lowpass filter
|
|
||||||
static void AudioProcessEffectDelay(void *buffer, unsigned int frames); // Audio effect: delay
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - stream effects");
|
|
||||||
|
|
||||||
InitAudioDevice(); // Initialize audio device
|
|
||||||
|
|
||||||
Music music = LoadMusicStream("resources/country.mp3");
|
|
||||||
|
|
||||||
// Allocate buffer for the delay effect
|
|
||||||
delayBufferSize = 48000*2; // 1 second delay (device sampleRate*channels)
|
|
||||||
delayBuffer = (float *)RL_CALLOC(delayBufferSize, sizeof(float));
|
|
||||||
|
|
||||||
PlayMusicStream(music);
|
|
||||||
|
|
||||||
float timePlayed = 0.0f; // Time played normalized [0.0f..1.0f]
|
|
||||||
bool pause = false; // Music playing paused
|
|
||||||
|
|
||||||
bool enableEffectLPF = false; // Enable effect low-pass-filter
|
|
||||||
bool enableEffectDelay = false; // Enable effect delay (1 second)
|
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
UpdateMusicStream(music); // Update music buffer with new stream data
|
|
||||||
|
|
||||||
// Restart music playing (stop and play)
|
|
||||||
if (IsKeyPressed(KEY_SPACE))
|
|
||||||
{
|
|
||||||
StopMusicStream(music);
|
|
||||||
PlayMusicStream(music);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pause/Resume music playing
|
|
||||||
if (IsKeyPressed(KEY_P))
|
|
||||||
{
|
|
||||||
pause = !pause;
|
|
||||||
|
|
||||||
if (pause) PauseMusicStream(music);
|
|
||||||
else ResumeMusicStream(music);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add/Remove effect: lowpass filter
|
|
||||||
if (IsKeyPressed(KEY_F))
|
|
||||||
{
|
|
||||||
enableEffectLPF = !enableEffectLPF;
|
|
||||||
if (enableEffectLPF) AttachAudioStreamProcessor(music.stream, AudioProcessEffectLPF);
|
|
||||||
else DetachAudioStreamProcessor(music.stream, AudioProcessEffectLPF);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add/Remove effect: delay
|
|
||||||
if (IsKeyPressed(KEY_D))
|
|
||||||
{
|
|
||||||
enableEffectDelay = !enableEffectDelay;
|
|
||||||
if (enableEffectDelay) AttachAudioStreamProcessor(music.stream, AudioProcessEffectDelay);
|
|
||||||
else DetachAudioStreamProcessor(music.stream, AudioProcessEffectDelay);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get normalized time played for current music stream
|
|
||||||
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music);
|
|
||||||
|
|
||||||
if (timePlayed > 1.0f) timePlayed = 1.0f; // Make sure time played is no longer than music
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
DrawText("MUSIC SHOULD BE PLAYING!", 245, 150, 20, LIGHTGRAY);
|
|
||||||
|
|
||||||
DrawRectangle(200, 180, 400, 12, LIGHTGRAY);
|
|
||||||
DrawRectangle(200, 180, (int)(timePlayed*400.0f), 12, MAROON);
|
|
||||||
DrawRectangleLines(200, 180, 400, 12, GRAY);
|
|
||||||
|
|
||||||
DrawText("PRESS SPACE TO RESTART MUSIC", 215, 230, 20, LIGHTGRAY);
|
|
||||||
DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 260, 20, LIGHTGRAY);
|
|
||||||
|
|
||||||
DrawText(TextFormat("PRESS F TO TOGGLE LPF EFFECT: %s", enableEffectLPF? "ON" : "OFF"), 200, 320, 20, GRAY);
|
|
||||||
DrawText(TextFormat("PRESS D TO TOGGLE DELAY EFFECT: %s", enableEffectDelay? "ON" : "OFF"), 180, 350, 20, GRAY);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
UnloadMusicStream(music); // Unload music stream buffers from RAM
|
|
||||||
|
|
||||||
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
|
|
||||||
|
|
||||||
RL_FREE(delayBuffer); // Free delay buffer
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Module Functions Definition
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Audio effect: lowpass filter
|
|
||||||
static void AudioProcessEffectLPF(void *buffer, unsigned int frames)
|
|
||||||
{
|
|
||||||
static float low[2] = { 0.0f, 0.0f };
|
|
||||||
static const float cutoff = 70.0f/44100.0f; // 70 Hz lowpass filter
|
|
||||||
const float k = cutoff/(cutoff + 0.1591549431f); // RC filter formula
|
|
||||||
|
|
||||||
// Converts the buffer data before using it
|
|
||||||
float *bufferData = (float *)buffer;
|
|
||||||
for (unsigned int i = 0; i < frames*2; i += 2)
|
|
||||||
{
|
|
||||||
const float l = bufferData[i];
|
|
||||||
const float r = bufferData[i + 1];
|
|
||||||
|
|
||||||
low[0] += k*(l - low[0]);
|
|
||||||
low[1] += k*(r - low[1]);
|
|
||||||
bufferData[i] = low[0];
|
|
||||||
bufferData[i + 1] = low[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Audio effect: delay
|
|
||||||
static void AudioProcessEffectDelay(void *buffer, unsigned int frames)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < frames*2; i += 2)
|
|
||||||
{
|
|
||||||
float leftDelay = delayBuffer[delayReadIndex++]; // ERROR: Reading buffer -> WHY??? Maybe thread related???
|
|
||||||
float rightDelay = delayBuffer[delayReadIndex++];
|
|
||||||
|
|
||||||
if (delayReadIndex == delayBufferSize) delayReadIndex = 0;
|
|
||||||
|
|
||||||
((float *)buffer)[i] = 0.5f*((float *)buffer)[i] + 0.5f*leftDelay;
|
|
||||||
((float *)buffer)[i + 1] = 0.5f*((float *)buffer)[i + 1] + 0.5f*rightDelay;
|
|
||||||
|
|
||||||
delayBuffer[delayWriteIndex++] = ((float *)buffer)[i];
|
|
||||||
delayBuffer[delayWriteIndex++] = ((float *)buffer)[i + 1];
|
|
||||||
if (delayWriteIndex == delayBufferSize) delayWriteIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 16 KiB |
|
|
@ -1,10 +0,0 @@
|
||||||
| resource | author | licence | notes |
|
|
||||||
| :------------------- | :---------: | :------ | :---- |
|
|
||||||
| country.mp3 | [@emegeme](https://github.com/emegeme) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Originally created for "DART that TARGET" game |
|
|
||||||
| target.ogg | [@emegeme](https://github.com/emegeme) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Originally created for "DART that TARGET" game |
|
|
||||||
| target.flac | [@emegeme](https://github.com/emegeme) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Originally created for "DART that TARGET" game |
|
|
||||||
| coin.wav | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Made with [rFXGen](https://raylibtech.itch.io/rfxgen) |
|
|
||||||
| sound.wav | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Made with [rFXGen](https://raylibtech.itch.io/rfxgen) |
|
|
||||||
| spring.wav | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Made with [rFXGen](https://raylibtech.itch.io/rfxgen) |
|
|
||||||
| weird.wav | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Made with [rFXGen](https://raylibtech.itch.io/rfxgen) |
|
|
||||||
| mini1111.xm | [tPORt](https://modarchive.org/index.php?request=view_by_moduleid&query=51891) | [Mod Archive Distribution license](https://modarchive.org/index.php?terms-upload) | - |
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
#version 100
|
|
||||||
|
|
||||||
precision mediump float;
|
|
||||||
|
|
||||||
// Input vertex attributes (from vertex shader)
|
|
||||||
varying vec2 fragTexCoord;
|
|
||||||
varying vec4 fragColor;
|
|
||||||
|
|
||||||
// Input uniform values
|
|
||||||
uniform vec2 iResolution;
|
|
||||||
uniform sampler2D iChannel0;
|
|
||||||
|
|
||||||
const vec4 BLACK = vec4(0.0, 0.0, 0.0, 1.0);
|
|
||||||
const vec4 WHITE = vec4(1.0, 1.0, 1.0, 1.0);
|
|
||||||
const float FFT_ROW = 0.0;
|
|
||||||
const float NUM_OF_BINS = 512.0;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
vec2 fragCoord = fragTexCoord*iResolution;
|
|
||||||
float cellWidth = iResolution.x/NUM_OF_BINS;
|
|
||||||
float binIndex = floor(fragCoord.x/cellWidth);
|
|
||||||
float localX = mod(fragCoord.x, cellWidth);
|
|
||||||
float barWidth = cellWidth - 1.0;
|
|
||||||
vec4 color = WHITE;
|
|
||||||
|
|
||||||
if (localX <= barWidth)
|
|
||||||
{
|
|
||||||
float sampleX = (binIndex + 0.5)/NUM_OF_BINS;
|
|
||||||
vec2 sampleCoord = vec2(sampleX, FFT_ROW);
|
|
||||||
float amplitude = texture2D(iChannel0, sampleCoord).r; // Only filled the red channel, all channels left open for alternative use
|
|
||||||
|
|
||||||
if (fragTexCoord.y < amplitude) color = BLACK;
|
|
||||||
}
|
|
||||||
|
|
||||||
gl_FragColor = color;
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
#version 120
|
|
||||||
|
|
||||||
// Input vertex attributes (from vertex shader)
|
|
||||||
varying vec2 fragTexCoord;
|
|
||||||
varying vec4 fragColor;
|
|
||||||
|
|
||||||
// Input uniform values
|
|
||||||
uniform vec2 iResolution;
|
|
||||||
uniform sampler2D iChannel0;
|
|
||||||
|
|
||||||
const vec4 BLACK = vec4(0.0, 0.0, 0.0, 1.0);
|
|
||||||
const vec4 WHITE = vec4(1.0, 1.0, 1.0, 1.0);
|
|
||||||
const float FFT_ROW = 0.0;
|
|
||||||
const float NUM_OF_BINS = 512.0;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
vec2 fragCoord = fragTexCoord*iResolution;
|
|
||||||
float cellWidth = iResolution.x/NUM_OF_BINS;
|
|
||||||
float binIndex = floor(fragCoord.x/cellWidth);
|
|
||||||
float localX = mod(fragCoord.x, cellWidth);
|
|
||||||
float barWidth = cellWidth - 1.0;
|
|
||||||
vec4 color = WHITE;
|
|
||||||
|
|
||||||
if (localX <= barWidth)
|
|
||||||
{
|
|
||||||
float sampleX = (binIndex + 0.5)/NUM_OF_BINS;
|
|
||||||
vec2 sampleCoord = vec2(sampleX, FFT_ROW);
|
|
||||||
float amplitude = texture2D(iChannel0, sampleCoord).r; // Only filled the red channel, all channels left open for alternative use
|
|
||||||
|
|
||||||
if (fragTexCoord.y < amplitude) color = BLACK;
|
|
||||||
}
|
|
||||||
|
|
||||||
gl_FragColor = color;
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
#version 330
|
|
||||||
|
|
||||||
in vec2 fragTexCoord;
|
|
||||||
in vec4 fragColor;
|
|
||||||
|
|
||||||
out vec4 finalColor;
|
|
||||||
|
|
||||||
uniform vec2 iResolution;
|
|
||||||
uniform sampler2D iChannel0;
|
|
||||||
|
|
||||||
const vec4 BLACK = vec4(0.0, 0.0, 0.0, 1.0);
|
|
||||||
const vec4 WHITE = vec4(1.0, 1.0, 1.0, 1.0);
|
|
||||||
const float FFT_ROW = 0.0;
|
|
||||||
const float NUM_OF_BINS = 512.0;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
vec2 fragCoord = fragTexCoord*iResolution;
|
|
||||||
float cellWidth = iResolution.x/NUM_OF_BINS;
|
|
||||||
float binIndex = floor(fragCoord.x/cellWidth);
|
|
||||||
float localX = mod(fragCoord.x, cellWidth);
|
|
||||||
float barWidth = cellWidth - 1.0;
|
|
||||||
vec4 color = WHITE;
|
|
||||||
|
|
||||||
if (localX <= barWidth)
|
|
||||||
{
|
|
||||||
float sampleX = (binIndex + 0.5)/NUM_OF_BINS;
|
|
||||||
vec2 sampleCoord = vec2(sampleX, FFT_ROW);
|
|
||||||
float amplitude = texture(iChannel0, sampleCoord).r; // Only filled the red channel, all channels left open for alternative use
|
|
||||||
|
|
||||||
if (fragTexCoord.y < amplitude) color = BLACK;
|
|
||||||
}
|
|
||||||
|
|
||||||
finalColor = color;
|
|
||||||
}
|
|
||||||
92
examples/audio_music_stream.c
Normal file
|
|
@ -0,0 +1,92 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [audio] example - Music playing (streaming)
|
||||||
|
*
|
||||||
|
* NOTE: This example requires OpenAL Soft library installed
|
||||||
|
*
|
||||||
|
* This example has been created using raylib 1.3 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
int screenWidth = 800;
|
||||||
|
int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)");
|
||||||
|
|
||||||
|
InitAudioDevice(); // Initialize audio device
|
||||||
|
|
||||||
|
PlayMusicStream("resources/audio/guitar_noodling.ogg"); // Play music stream
|
||||||
|
|
||||||
|
int framesCounter = 0;
|
||||||
|
float timePlayed = 0.0f;
|
||||||
|
//float volume = 1.0;
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
framesCounter++;
|
||||||
|
|
||||||
|
// Testing music fading from one file to another
|
||||||
|
/*
|
||||||
|
if (framesCounter > 600) // Wait for 10 seconds (600 frames)
|
||||||
|
{
|
||||||
|
volume -= 0.01; // Decrement music volume level
|
||||||
|
|
||||||
|
// When music volume level equal or lower than 0,
|
||||||
|
// restore volume level and init another music file
|
||||||
|
if (volume <= 0)
|
||||||
|
{
|
||||||
|
volume = 1.0;
|
||||||
|
framesCounter = 0;
|
||||||
|
PlayMusicStream("resources/audio/another_file.ogg");
|
||||||
|
}
|
||||||
|
|
||||||
|
SetMusicVolume(volume);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if (IsWindowMinimized()) PauseMusicStream();
|
||||||
|
else ResumeMusicStream();
|
||||||
|
|
||||||
|
timePlayed = GetMusicTimePlayed()/GetMusicTimeLength()*100*4; // We scale by 4 to fit 400 pixels
|
||||||
|
|
||||||
|
UpdateMusicStream(); // Update music buffer with new stream data
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
DrawText("MUSIC SHOULD BE PLAYING!", 255, 200, 20, LIGHTGRAY);
|
||||||
|
|
||||||
|
DrawRectangle(200, 250, 400, 12, LIGHTGRAY);
|
||||||
|
DrawRectangle(200, 250, (int)timePlayed, 12, MAROON);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
|
@ -1,38 +1,33 @@
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [audio] example - sound loading
|
* raylib [audio] example - Sound loading and playing
|
||||||
*
|
*
|
||||||
* Example complexity rating: [★☆☆☆] 1/4
|
* NOTE: This example requires OpenAL Soft library installed
|
||||||
*
|
*
|
||||||
* Example originally created with raylib 1.1, last time updated with raylib 3.5
|
* This example has been created using raylib 1.0 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2014-2025 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
int main()
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound loading");
|
InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing");
|
||||||
|
|
||||||
InitAudioDevice(); // Initialize audio device
|
InitAudioDevice(); // Initialize audio device
|
||||||
|
|
||||||
Sound fxWav = LoadSound("resources/sound.wav"); // Load WAV audio file
|
Sound fxWav = LoadSound("resources/audio/weird.wav"); // Load WAV audio file
|
||||||
Sound fxOgg = LoadSound("resources/target.ogg"); // Load OGG audio file
|
Sound fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60);
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
|
|
@ -41,6 +36,7 @@ int main(void)
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (IsKeyPressed(KEY_SPACE)) PlaySound(fxWav); // Play WAV sound
|
if (IsKeyPressed(KEY_SPACE)) PlaySound(fxWav); // Play WAV sound
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_ENTER)) PlaySound(fxOgg); // Play OGG sound
|
if (IsKeyPressed(KEY_ENTER)) PlaySound(fxOgg); // Play OGG sound
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -51,6 +47,7 @@ int main(void)
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, LIGHTGRAY);
|
DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, LIGHTGRAY);
|
||||||
|
|
||||||
DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, LIGHTGRAY);
|
DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, LIGHTGRAY);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
|
@ -1,44 +0,0 @@
|
||||||
::@echo off
|
|
||||||
:: .
|
|
||||||
:: Compile your examples for web using: build_example_web.bat <example_category>/<example_name>
|
|
||||||
:: .
|
|
||||||
SET "INPUT_FILE=%1"
|
|
||||||
:: Change delimiter for the FOR loop
|
|
||||||
FOR /f "tokens=1-10 delims=/" %%a IN ("%INPUT_FILE%") DO (
|
|
||||||
SET CATEGORY=%%a
|
|
||||||
SET FILENAME=%%b
|
|
||||||
)
|
|
||||||
:: > SETup required Environment
|
|
||||||
:: -------------------------------------
|
|
||||||
SET RAYLIB_PATH=C:\GitHub\raylib
|
|
||||||
SET EMSDK_PATH=C:\raylib\emsdk
|
|
||||||
SET COMPILER_PATH=C:\raylib\w64devkit\bin
|
|
||||||
ENV_SET PATH=%COMPILER_PATH%
|
|
||||||
SET MAKE=mingw32-make
|
|
||||||
echo
|
|
||||||
:: Set required web compilation options
|
|
||||||
:: -------------------------------------
|
|
||||||
::SET CC=%EMSDK_PATH%\upstream\emscripten\emcc
|
|
||||||
::SET CFLAGS=-Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result -O3 -I. -Iexternal -I%RAYLIB_PATH%\src -I%RAYLIB_PATH%\external -DPLATFORM_WEB
|
|
||||||
::SET LDFLAGS=-L. -L$(RAYLIB_PATH)\src -sUSE_GLFW=3 -sEXPORTED_RUNTIME_METHODS=ccall -sASYNCIFY --shell-file %RAYLIB_PATH%\src\shell.html
|
|
||||||
::SET LDLIBS=%RAYLIB_PATH%\src\libraylib.web.a
|
|
||||||
echo
|
|
||||||
:: Clean latest build
|
|
||||||
:: ------------------------
|
|
||||||
cmd /c if exist %FILENAME%.html del /F %FILENAME%.html
|
|
||||||
cmd /c if exist %FILENAME%.wasm del /F %FILENAME%.wasm
|
|
||||||
cmd /c if exist %FILENAME%.js del /F %FILENAME%.js
|
|
||||||
cmd /c if exist %FILENAME%.data del /F %FILENAME%.data
|
|
||||||
echo
|
|
||||||
:: Setup emsdk environment
|
|
||||||
:: --------------------------
|
|
||||||
call %EMSDK_PATH%\emsdk_env.bat
|
|
||||||
echo on
|
|
||||||
:: Compile program
|
|
||||||
:: -----------------------
|
|
||||||
C:
|
|
||||||
cd %RAYLIB_PATH%\examples
|
|
||||||
%MAKE% -f Makefile.Web %CATEGORY%/%FILENAME% PLATFORM=PLATFORM_WEB -B
|
|
||||||
::%CC% -o %FILENAME%.html %FILENAME%.c %CFLAGS% %LDFLAGS% %LDLIBS% %RESOURCES%
|
|
||||||
cd ..
|
|
||||||
echo
|
|
||||||
|
|
@ -1,144 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [core] example - 2d camera
|
|
||||||
*
|
|
||||||
* Example complexity rating: [★★☆☆] 2/4
|
|
||||||
*
|
|
||||||
* Example originally created with raylib 1.5, last time updated with raylib 3.0
|
|
||||||
*
|
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2016-2025 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#define MAX_BUILDINGS 100
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera");
|
|
||||||
|
|
||||||
Rectangle player = { 400, 280, 40, 40 };
|
|
||||||
Rectangle buildings[MAX_BUILDINGS] = { 0 };
|
|
||||||
Color buildColors[MAX_BUILDINGS] = { 0 };
|
|
||||||
|
|
||||||
int spacing = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < MAX_BUILDINGS; i++)
|
|
||||||
{
|
|
||||||
buildings[i].width = (float)GetRandomValue(50, 200);
|
|
||||||
buildings[i].height = (float)GetRandomValue(100, 800);
|
|
||||||
buildings[i].y = screenHeight - 130.0f - buildings[i].height;
|
|
||||||
buildings[i].x = -6000.0f + spacing;
|
|
||||||
|
|
||||||
spacing += (int)buildings[i].width;
|
|
||||||
|
|
||||||
buildColors[i] = (Color){
|
|
||||||
(unsigned char)GetRandomValue(200, 240),
|
|
||||||
(unsigned char)GetRandomValue(200, 240),
|
|
||||||
(unsigned char)GetRandomValue(200, 250),
|
|
||||||
255};
|
|
||||||
}
|
|
||||||
|
|
||||||
Camera2D camera = { 0 };
|
|
||||||
camera.target = (Vector2){ player.x + 20.0f, player.y + 20.0f };
|
|
||||||
camera.offset = (Vector2){ screenWidth/2.0f, screenHeight/2.0f };
|
|
||||||
camera.rotation = 0.0f;
|
|
||||||
camera.zoom = 1.0f;
|
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Player movement
|
|
||||||
if (IsKeyDown(KEY_RIGHT)) player.x += 2;
|
|
||||||
else if (IsKeyDown(KEY_LEFT)) player.x -= 2;
|
|
||||||
|
|
||||||
// Camera target follows player
|
|
||||||
camera.target = (Vector2){ player.x + 20, player.y + 20 };
|
|
||||||
|
|
||||||
// Camera rotation controls
|
|
||||||
if (IsKeyDown(KEY_A)) camera.rotation--;
|
|
||||||
else if (IsKeyDown(KEY_S)) camera.rotation++;
|
|
||||||
|
|
||||||
// Limit camera rotation to 80 degrees (-40 to 40)
|
|
||||||
if (camera.rotation > 40) camera.rotation = 40;
|
|
||||||
else if (camera.rotation < -40) camera.rotation = -40;
|
|
||||||
|
|
||||||
// Camera zoom controls
|
|
||||||
// Uses log scaling to provide consistent zoom speed
|
|
||||||
camera.zoom = expf(logf(camera.zoom) + ((float)GetMouseWheelMove()*0.1f));
|
|
||||||
|
|
||||||
if (camera.zoom > 3.0f) camera.zoom = 3.0f;
|
|
||||||
else if (camera.zoom < 0.1f) camera.zoom = 0.1f;
|
|
||||||
|
|
||||||
// Camera reset (zoom and rotation)
|
|
||||||
if (IsKeyPressed(KEY_R))
|
|
||||||
{
|
|
||||||
camera.zoom = 1.0f;
|
|
||||||
camera.rotation = 0.0f;
|
|
||||||
}
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
BeginMode2D(camera);
|
|
||||||
|
|
||||||
DrawRectangle(-6000, 320, 13000, 8000, DARKGRAY);
|
|
||||||
|
|
||||||
for (int i = 0; i < MAX_BUILDINGS; i++) DrawRectangleRec(buildings[i], buildColors[i]);
|
|
||||||
|
|
||||||
DrawRectangleRec(player, RED);
|
|
||||||
|
|
||||||
DrawLine((int)camera.target.x, -screenHeight*10, (int)camera.target.x, screenHeight*10, GREEN);
|
|
||||||
DrawLine(-screenWidth*10, (int)camera.target.y, screenWidth*10, (int)camera.target.y, GREEN);
|
|
||||||
|
|
||||||
EndMode2D();
|
|
||||||
|
|
||||||
DrawText("SCREEN AREA", 640, 10, 20, RED);
|
|
||||||
|
|
||||||
DrawRectangle(0, 0, screenWidth, 5, RED);
|
|
||||||
DrawRectangle(0, 5, 5, screenHeight - 10, RED);
|
|
||||||
DrawRectangle(screenWidth - 5, 5, 5, screenHeight - 10, RED);
|
|
||||||
DrawRectangle(0, screenHeight - 5, screenWidth, 5, RED);
|
|
||||||
|
|
||||||
DrawRectangle( 10, 10, 250, 113, Fade(SKYBLUE, 0.5f));
|
|
||||||
DrawRectangleLines( 10, 10, 250, 113, BLUE);
|
|
||||||
|
|
||||||
DrawText("Free 2D camera controls:", 20, 20, 10, BLACK);
|
|
||||||
DrawText("- Right/Left to move player", 40, 40, 10, DARKGRAY);
|
|
||||||
DrawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, DARKGRAY);
|
|
||||||
DrawText("- A / S to Rotate", 40, 80, 10, DARKGRAY);
|
|
||||||
DrawText("- R to reset Zoom and Rotation", 40, 100, 10, DARKGRAY);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 8.3 KiB |
|
|
@ -1,146 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [core] example - 2d camera mouse zoom
|
|
||||||
*
|
|
||||||
* Example complexity rating: [★★☆☆] 2/4
|
|
||||||
*
|
|
||||||
* Example originally created with raylib 4.2, last time updated with raylib 4.2
|
|
||||||
*
|
|
||||||
* Example contributed by Jeffery Myers (@JeffM2501) and reviewed by Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2022-2025 Jeffery Myers (@JeffM2501)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
#include "rlgl.h"
|
|
||||||
#include "raymath.h"
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera mouse zoom");
|
|
||||||
|
|
||||||
Camera2D camera = { 0 };
|
|
||||||
camera.zoom = 1.0f;
|
|
||||||
|
|
||||||
int zoomMode = 0; // 0-Mouse Wheel, 1-Mouse Move
|
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
if (IsKeyPressed(KEY_ONE)) zoomMode = 0;
|
|
||||||
else if (IsKeyPressed(KEY_TWO)) zoomMode = 1;
|
|
||||||
|
|
||||||
// Translate based on mouse right click
|
|
||||||
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
|
|
||||||
{
|
|
||||||
Vector2 delta = GetMouseDelta();
|
|
||||||
delta = Vector2Scale(delta, -1.0f/camera.zoom);
|
|
||||||
camera.target = Vector2Add(camera.target, delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (zoomMode == 0)
|
|
||||||
{
|
|
||||||
// Zoom based on mouse wheel
|
|
||||||
float wheel = GetMouseWheelMove();
|
|
||||||
if (wheel != 0)
|
|
||||||
{
|
|
||||||
// Get the world point that is under the mouse
|
|
||||||
Vector2 mouseWorldPos = GetScreenToWorld2D(GetMousePosition(), camera);
|
|
||||||
|
|
||||||
// Set the offset to where the mouse is
|
|
||||||
camera.offset = GetMousePosition();
|
|
||||||
|
|
||||||
// Set the target to match, so that the camera maps the world space point
|
|
||||||
// under the cursor to the screen space point under the cursor at any zoom
|
|
||||||
camera.target = mouseWorldPos;
|
|
||||||
|
|
||||||
// Zoom increment
|
|
||||||
// Uses log scaling to provide consistent zoom speed
|
|
||||||
float scale = 0.2f*wheel;
|
|
||||||
camera.zoom = Clamp(expf(logf(camera.zoom)+scale), 0.125f, 64.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Zoom based on mouse right click
|
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT))
|
|
||||||
{
|
|
||||||
// Get the world point that is under the mouse
|
|
||||||
Vector2 mouseWorldPos = GetScreenToWorld2D(GetMousePosition(), camera);
|
|
||||||
|
|
||||||
// Set the offset to where the mouse is
|
|
||||||
camera.offset = GetMousePosition();
|
|
||||||
|
|
||||||
// Set the target to match, so that the camera maps the world space point
|
|
||||||
// under the cursor to the screen space point under the cursor at any zoom
|
|
||||||
camera.target = mouseWorldPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT))
|
|
||||||
{
|
|
||||||
// Zoom increment
|
|
||||||
// Uses log scaling to provide consistent zoom speed
|
|
||||||
float deltaX = GetMouseDelta().x;
|
|
||||||
float scale = 0.005f*deltaX;
|
|
||||||
camera.zoom = Clamp(expf(logf(camera.zoom)+scale), 0.125f, 64.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
BeginMode2D(camera);
|
|
||||||
// Draw the 3d grid, rotated 90 degrees and centered around 0,0
|
|
||||||
// just so we have something in the XY plane
|
|
||||||
rlPushMatrix();
|
|
||||||
rlTranslatef(0, 25*50, 0);
|
|
||||||
rlRotatef(90, 1, 0, 0);
|
|
||||||
DrawGrid(100, 50);
|
|
||||||
rlPopMatrix();
|
|
||||||
|
|
||||||
// Draw a reference circle
|
|
||||||
DrawCircle(GetScreenWidth()/2, GetScreenHeight()/2, 50, MAROON);
|
|
||||||
EndMode2D();
|
|
||||||
|
|
||||||
// Draw mouse reference
|
|
||||||
//Vector2 mousePos = GetWorldToScreen2D(GetMousePosition(), camera)
|
|
||||||
DrawCircleV(GetMousePosition(), 4, DARKGRAY);
|
|
||||||
DrawTextEx(GetFontDefault(), TextFormat("[%i, %i]", GetMouseX(), GetMouseY()),
|
|
||||||
Vector2Add(GetMousePosition(), (Vector2){ -44, -24 }), 20, 2, BLACK);
|
|
||||||
|
|
||||||
DrawText("[1][2] Select mouse zoom mode (Wheel or Move)", 20, 20, 20, DARKGRAY);
|
|
||||||
if (zoomMode == 0) DrawText("Mouse left button drag to move, mouse wheel to zoom", 20, 50, 20, DARKGRAY);
|
|
||||||
else DrawText("Mouse left button drag to move, mouse press and move to zoom", 20, 50, 20, DARKGRAY);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 16 KiB |
|
|
@ -1,307 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [core] example - 2d camera platformer
|
|
||||||
*
|
|
||||||
* Example complexity rating: [★★★☆] 3/4
|
|
||||||
*
|
|
||||||
* Example originally created with raylib 2.5, last time updated with raylib 3.0
|
|
||||||
*
|
|
||||||
* Example contributed by arvyy (@arvyy) and reviewed by Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2019-2025 arvyy (@arvyy)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
#include "raymath.h"
|
|
||||||
|
|
||||||
#define G 400
|
|
||||||
#define PLAYER_JUMP_SPD 350.0f
|
|
||||||
#define PLAYER_HOR_SPD 200.0f
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Types and Structures Definition
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
typedef struct Player {
|
|
||||||
Vector2 position;
|
|
||||||
float speed;
|
|
||||||
bool canJump;
|
|
||||||
} Player;
|
|
||||||
|
|
||||||
typedef struct EnvItem {
|
|
||||||
Rectangle rect;
|
|
||||||
int blocking;
|
|
||||||
Color color;
|
|
||||||
} EnvItem;
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Module Functions Declaration
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
void UpdatePlayer(Player *player, EnvItem *envItems, int envItemsLength, float delta);
|
|
||||||
void UpdateCameraCenter(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
|
|
||||||
void UpdateCameraCenterInsideMap(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
|
|
||||||
void UpdateCameraCenterSmoothFollow(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
|
|
||||||
void UpdateCameraEvenOutOnLanding(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
|
|
||||||
void UpdateCameraPlayerBoundsPush(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera platformer");
|
|
||||||
|
|
||||||
Player player = { 0 };
|
|
||||||
player.position = (Vector2){ 400, 280 };
|
|
||||||
player.speed = 0;
|
|
||||||
player.canJump = false;
|
|
||||||
EnvItem envItems[] = {
|
|
||||||
{{ 0, 0, 1000, 400 }, 0, LIGHTGRAY },
|
|
||||||
{{ 0, 400, 1000, 200 }, 1, GRAY },
|
|
||||||
{{ 300, 200, 400, 10 }, 1, GRAY },
|
|
||||||
{{ 250, 300, 100, 10 }, 1, GRAY },
|
|
||||||
{{ 650, 300, 100, 10 }, 1, GRAY }
|
|
||||||
};
|
|
||||||
|
|
||||||
int envItemsLength = sizeof(envItems)/sizeof(envItems[0]);
|
|
||||||
|
|
||||||
Camera2D camera = { 0 };
|
|
||||||
camera.target = player.position;
|
|
||||||
camera.offset = (Vector2){ screenWidth/2.0f, screenHeight/2.0f };
|
|
||||||
camera.rotation = 0.0f;
|
|
||||||
camera.zoom = 1.0f;
|
|
||||||
|
|
||||||
// Store pointers to the multiple update camera functions
|
|
||||||
void (*cameraUpdaters[])(Camera2D*, Player*, EnvItem*, int, float, int, int) = {
|
|
||||||
UpdateCameraCenter,
|
|
||||||
UpdateCameraCenterInsideMap,
|
|
||||||
UpdateCameraCenterSmoothFollow,
|
|
||||||
UpdateCameraEvenOutOnLanding,
|
|
||||||
UpdateCameraPlayerBoundsPush
|
|
||||||
};
|
|
||||||
|
|
||||||
int cameraOption = 0;
|
|
||||||
int cameraUpdatersLength = sizeof(cameraUpdaters)/sizeof(cameraUpdaters[0]);
|
|
||||||
|
|
||||||
char *cameraDescriptions[] = {
|
|
||||||
"Follow player center",
|
|
||||||
"Follow player center, but clamp to map edges",
|
|
||||||
"Follow player center; smoothed",
|
|
||||||
"Follow player center horizontally; update player center vertically after landing",
|
|
||||||
"Player push camera on getting too close to screen edge"
|
|
||||||
};
|
|
||||||
|
|
||||||
SetTargetFPS(60);
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose())
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
float deltaTime = GetFrameTime();
|
|
||||||
|
|
||||||
UpdatePlayer(&player, envItems, envItemsLength, deltaTime);
|
|
||||||
|
|
||||||
camera.zoom += ((float)GetMouseWheelMove()*0.05f);
|
|
||||||
|
|
||||||
if (camera.zoom > 3.0f) camera.zoom = 3.0f;
|
|
||||||
else if (camera.zoom < 0.25f) camera.zoom = 0.25f;
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_R))
|
|
||||||
{
|
|
||||||
camera.zoom = 1.0f;
|
|
||||||
player.position = (Vector2){ 400, 280 };
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_C)) cameraOption = (cameraOption + 1)%cameraUpdatersLength;
|
|
||||||
|
|
||||||
// Call update camera function by its pointer
|
|
||||||
cameraUpdaters[cameraOption](&camera, &player, envItems, envItemsLength, deltaTime, screenWidth, screenHeight);
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(LIGHTGRAY);
|
|
||||||
|
|
||||||
BeginMode2D(camera);
|
|
||||||
|
|
||||||
for (int i = 0; i < envItemsLength; i++) DrawRectangleRec(envItems[i].rect, envItems[i].color);
|
|
||||||
|
|
||||||
Rectangle playerRect = { player.position.x - 20, player.position.y - 40, 40.0f, 40.0f };
|
|
||||||
DrawRectangleRec(playerRect, RED);
|
|
||||||
|
|
||||||
DrawCircleV(player.position, 5.0f, GOLD);
|
|
||||||
|
|
||||||
EndMode2D();
|
|
||||||
|
|
||||||
DrawText("Controls:", 20, 20, 10, BLACK);
|
|
||||||
DrawText("- Right/Left to move", 40, 40, 10, DARKGRAY);
|
|
||||||
DrawText("- Space to jump", 40, 60, 10, DARKGRAY);
|
|
||||||
DrawText("- Mouse Wheel to Zoom in-out", 40, 80, 10, DARKGRAY);
|
|
||||||
DrawText("- R to reset position + zoom", 40, 100, 10, DARKGRAY);
|
|
||||||
DrawText("- C to change camera mode", 40, 120, 10, DARKGRAY);
|
|
||||||
DrawText("Current camera mode:", 20, 140, 10, BLACK);
|
|
||||||
DrawText(cameraDescriptions[cameraOption], 40, 160, 10, DARKGRAY);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdatePlayer(Player *player, EnvItem *envItems, int envItemsLength, float delta)
|
|
||||||
{
|
|
||||||
if (IsKeyDown(KEY_LEFT)) player->position.x -= PLAYER_HOR_SPD*delta;
|
|
||||||
if (IsKeyDown(KEY_RIGHT)) player->position.x += PLAYER_HOR_SPD*delta;
|
|
||||||
if (IsKeyDown(KEY_SPACE) && player->canJump)
|
|
||||||
{
|
|
||||||
player->speed = -PLAYER_JUMP_SPD;
|
|
||||||
player->canJump = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hitObstacle = false;
|
|
||||||
for (int i = 0; i < envItemsLength; i++)
|
|
||||||
{
|
|
||||||
EnvItem *ei = envItems + i;
|
|
||||||
Vector2 *p = &(player->position);
|
|
||||||
if (ei->blocking &&
|
|
||||||
ei->rect.x <= p->x &&
|
|
||||||
ei->rect.x + ei->rect.width >= p->x &&
|
|
||||||
ei->rect.y >= p->y &&
|
|
||||||
ei->rect.y <= p->y + player->speed*delta)
|
|
||||||
{
|
|
||||||
hitObstacle = true;
|
|
||||||
player->speed = 0.0f;
|
|
||||||
p->y = ei->rect.y;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hitObstacle)
|
|
||||||
{
|
|
||||||
player->position.y += player->speed*delta;
|
|
||||||
player->speed += G*delta;
|
|
||||||
player->canJump = false;
|
|
||||||
}
|
|
||||||
else player->canJump = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateCameraCenter(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height)
|
|
||||||
{
|
|
||||||
camera->offset = (Vector2){ width/2.0f, height/2.0f };
|
|
||||||
camera->target = player->position;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateCameraCenterInsideMap(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height)
|
|
||||||
{
|
|
||||||
camera->target = player->position;
|
|
||||||
camera->offset = (Vector2){ width/2.0f, height/2.0f };
|
|
||||||
float minX = 1000, minY = 1000, maxX = -1000, maxY = -1000;
|
|
||||||
|
|
||||||
for (int i = 0; i < envItemsLength; i++)
|
|
||||||
{
|
|
||||||
EnvItem *ei = envItems + i;
|
|
||||||
minX = fminf(ei->rect.x, minX);
|
|
||||||
maxX = fmaxf(ei->rect.x + ei->rect.width, maxX);
|
|
||||||
minY = fminf(ei->rect.y, minY);
|
|
||||||
maxY = fmaxf(ei->rect.y + ei->rect.height, maxY);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 max = GetWorldToScreen2D((Vector2){ maxX, maxY }, *camera);
|
|
||||||
Vector2 min = GetWorldToScreen2D((Vector2){ minX, minY }, *camera);
|
|
||||||
|
|
||||||
if (max.x < width) camera->offset.x = width - (max.x - (float)width/2);
|
|
||||||
if (max.y < height) camera->offset.y = height - (max.y - (float)height/2);
|
|
||||||
if (min.x > 0) camera->offset.x = (float)width/2 - min.x;
|
|
||||||
if (min.y > 0) camera->offset.y = (float)height/2 - min.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateCameraCenterSmoothFollow(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height)
|
|
||||||
{
|
|
||||||
static float minSpeed = 30;
|
|
||||||
static float minEffectLength = 10;
|
|
||||||
static float fractionSpeed = 0.8f;
|
|
||||||
|
|
||||||
camera->offset = (Vector2){ width/2.0f, height/2.0f };
|
|
||||||
Vector2 diff = Vector2Subtract(player->position, camera->target);
|
|
||||||
float length = Vector2Length(diff);
|
|
||||||
|
|
||||||
if (length > minEffectLength)
|
|
||||||
{
|
|
||||||
float speed = fmaxf(fractionSpeed*length, minSpeed);
|
|
||||||
camera->target = Vector2Add(camera->target, Vector2Scale(diff, speed*delta/length));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateCameraEvenOutOnLanding(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height)
|
|
||||||
{
|
|
||||||
static float evenOutSpeed = 700;
|
|
||||||
static int eveningOut = false;
|
|
||||||
static float evenOutTarget;
|
|
||||||
|
|
||||||
camera->offset = (Vector2){ width/2.0f, height/2.0f };
|
|
||||||
camera->target.x = player->position.x;
|
|
||||||
|
|
||||||
if (eveningOut)
|
|
||||||
{
|
|
||||||
if (evenOutTarget > camera->target.y)
|
|
||||||
{
|
|
||||||
camera->target.y += evenOutSpeed*delta;
|
|
||||||
|
|
||||||
if (camera->target.y > evenOutTarget)
|
|
||||||
{
|
|
||||||
camera->target.y = evenOutTarget;
|
|
||||||
eveningOut = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
camera->target.y -= evenOutSpeed*delta;
|
|
||||||
|
|
||||||
if (camera->target.y < evenOutTarget)
|
|
||||||
{
|
|
||||||
camera->target.y = evenOutTarget;
|
|
||||||
eveningOut = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (player->canJump && (player->speed == 0) && (player->position.y != camera->target.y))
|
|
||||||
{
|
|
||||||
eveningOut = 1;
|
|
||||||
evenOutTarget = player->position.y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateCameraPlayerBoundsPush(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height)
|
|
||||||
{
|
|
||||||
static Vector2 bbox = { 0.2f, 0.2f };
|
|
||||||
|
|
||||||
Vector2 bboxWorldMin = GetScreenToWorld2D((Vector2){ (1 - bbox.x)*0.5f*width, (1 - bbox.y)*0.5f*height }, *camera);
|
|
||||||
Vector2 bboxWorldMax = GetScreenToWorld2D((Vector2){ (1 + bbox.x)*0.5f*width, (1 + bbox.y)*0.5f*height }, *camera);
|
|
||||||
camera->offset = (Vector2){ (1 - bbox.x)*0.5f*width, (1 - bbox.y)*0.5f*height };
|
|
||||||
|
|
||||||
if (player->position.x < bboxWorldMin.x) camera->target.x = player->position.x;
|
|
||||||
if (player->position.y < bboxWorldMin.y) camera->target.y = player->position.y;
|
|
||||||
if (player->position.x > bboxWorldMax.x) camera->target.x = bboxWorldMin.x + (player->position.x - bboxWorldMax.x);
|
|
||||||
if (player->position.y > bboxWorldMax.y) camera->target.y = bboxWorldMin.y + (player->position.y - bboxWorldMax.y);
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 16 KiB |
|
|
@ -1,169 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [core] example - 2d camera split screen
|
|
||||||
*
|
|
||||||
* Example complexity rating: [★★★★] 4/4
|
|
||||||
*
|
|
||||||
* Addapted from the core_3d_camera_split_screen example:
|
|
||||||
* https://github.com/raysan5/raylib/blob/master/examples/core/core_3d_camera_split_screen.c
|
|
||||||
*
|
|
||||||
* Example originally created with raylib 4.5, last time updated with raylib 4.5
|
|
||||||
*
|
|
||||||
* Example contributed by Gabriel dos Santos Sanches (@gabrielssanches) and reviewed by Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2023-2025 Gabriel dos Santos Sanches (@gabrielssanches)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
#define PLAYER_SIZE 40
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 440;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera split screen");
|
|
||||||
|
|
||||||
Rectangle player1 = { 200, 200, PLAYER_SIZE, PLAYER_SIZE };
|
|
||||||
Rectangle player2 = { 250, 200, PLAYER_SIZE, PLAYER_SIZE };
|
|
||||||
|
|
||||||
Camera2D camera1 = { 0 };
|
|
||||||
camera1.target = (Vector2){ player1.x, player1.y };
|
|
||||||
camera1.offset = (Vector2){ 200.0f, 200.0f };
|
|
||||||
camera1.rotation = 0.0f;
|
|
||||||
camera1.zoom = 1.0f;
|
|
||||||
|
|
||||||
Camera2D camera2 = { 0 };
|
|
||||||
camera2.target = (Vector2){ player2.x, player2.y };
|
|
||||||
camera2.offset = (Vector2){ 200.0f, 200.0f };
|
|
||||||
camera2.rotation = 0.0f;
|
|
||||||
camera2.zoom = 1.0f;
|
|
||||||
|
|
||||||
RenderTexture screenCamera1 = LoadRenderTexture(screenWidth/2, screenHeight);
|
|
||||||
RenderTexture screenCamera2 = LoadRenderTexture(screenWidth/2, screenHeight);
|
|
||||||
|
|
||||||
// Build a flipped rectangle the size of the split view to use for drawing later
|
|
||||||
Rectangle splitScreenRect = { 0.0f, 0.0f, (float)screenCamera1.texture.width, (float)-screenCamera1.texture.height };
|
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
if (IsKeyDown(KEY_S)) player1.y += 3.0f;
|
|
||||||
else if (IsKeyDown(KEY_W)) player1.y -= 3.0f;
|
|
||||||
if (IsKeyDown(KEY_D)) player1.x += 3.0f;
|
|
||||||
else if (IsKeyDown(KEY_A)) player1.x -= 3.0f;
|
|
||||||
|
|
||||||
if (IsKeyDown(KEY_UP)) player2.y -= 3.0f;
|
|
||||||
else if (IsKeyDown(KEY_DOWN)) player2.y += 3.0f;
|
|
||||||
if (IsKeyDown(KEY_RIGHT)) player2.x += 3.0f;
|
|
||||||
else if (IsKeyDown(KEY_LEFT)) player2.x -= 3.0f;
|
|
||||||
|
|
||||||
camera1.target = (Vector2){ player1.x, player1.y };
|
|
||||||
camera2.target = (Vector2){ player2.x, player2.y };
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginTextureMode(screenCamera1);
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
BeginMode2D(camera1);
|
|
||||||
|
|
||||||
// Draw full scene with first camera
|
|
||||||
for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++)
|
|
||||||
{
|
|
||||||
DrawLineV((Vector2){(float)PLAYER_SIZE*i, 0}, (Vector2){ (float)PLAYER_SIZE*i, (float)screenHeight}, LIGHTGRAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < screenHeight/PLAYER_SIZE + 1; i++)
|
|
||||||
{
|
|
||||||
DrawLineV((Vector2){0, (float)PLAYER_SIZE*i}, (Vector2){ (float)screenWidth, (float)PLAYER_SIZE*i}, LIGHTGRAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < screenWidth/PLAYER_SIZE; i++)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < screenHeight/PLAYER_SIZE; j++)
|
|
||||||
{
|
|
||||||
DrawText(TextFormat("[%i,%i]", i, j), 10 + PLAYER_SIZE*i, 15 + PLAYER_SIZE*j, 10, LIGHTGRAY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawRectangleRec(player1, RED);
|
|
||||||
DrawRectangleRec(player2, BLUE);
|
|
||||||
EndMode2D();
|
|
||||||
|
|
||||||
DrawRectangle(0, 0, GetScreenWidth()/2, 30, Fade(RAYWHITE, 0.6f));
|
|
||||||
DrawText("PLAYER1: W/S/A/D to move", 10, 10, 10, MAROON);
|
|
||||||
|
|
||||||
EndTextureMode();
|
|
||||||
|
|
||||||
BeginTextureMode(screenCamera2);
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
BeginMode2D(camera2);
|
|
||||||
|
|
||||||
// Draw full scene with second camera
|
|
||||||
for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++)
|
|
||||||
{
|
|
||||||
DrawLineV((Vector2){ (float)PLAYER_SIZE*i, 0}, (Vector2){ (float)PLAYER_SIZE*i, (float)screenHeight}, LIGHTGRAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < screenHeight/PLAYER_SIZE + 1; i++)
|
|
||||||
{
|
|
||||||
DrawLineV((Vector2){0, (float)PLAYER_SIZE*i}, (Vector2){ (float)screenWidth, (float)PLAYER_SIZE*i}, LIGHTGRAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < screenWidth/PLAYER_SIZE; i++)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < screenHeight/PLAYER_SIZE; j++)
|
|
||||||
{
|
|
||||||
DrawText(TextFormat("[%i,%i]", i, j), 10 + PLAYER_SIZE*i, 15 + PLAYER_SIZE*j, 10, LIGHTGRAY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawRectangleRec(player1, RED);
|
|
||||||
DrawRectangleRec(player2, BLUE);
|
|
||||||
|
|
||||||
EndMode2D();
|
|
||||||
|
|
||||||
DrawRectangle(0, 0, GetScreenWidth()/2, 30, Fade(RAYWHITE, 0.6f));
|
|
||||||
DrawText("PLAYER2: UP/DOWN/LEFT/RIGHT to move", 10, 10, 10, DARKBLUE);
|
|
||||||
|
|
||||||
EndTextureMode();
|
|
||||||
|
|
||||||
// Draw both views render textures to the screen side by side
|
|
||||||
BeginDrawing();
|
|
||||||
ClearBackground(BLACK);
|
|
||||||
|
|
||||||
DrawTextureRec(screenCamera1.texture, splitScreenRect, (Vector2){ 0, 0 }, WHITE);
|
|
||||||
DrawTextureRec(screenCamera2.texture, splitScreenRect, (Vector2){ screenWidth/2.0f, 0 }, WHITE);
|
|
||||||
|
|
||||||
DrawRectangle(GetScreenWidth()/2 - 2, 0, 4, GetScreenHeight(), LIGHTGRAY);
|
|
||||||
EndDrawing();
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
UnloadRenderTexture(screenCamera1); // Unload render texture
|
|
||||||
UnloadRenderTexture(screenCamera2); // Unload render texture
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 21 KiB |
|
|
@ -1,207 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [core] example - 3d camera first person
|
|
||||||
*
|
|
||||||
* Example complexity rating: [★★☆☆] 2/4
|
|
||||||
*
|
|
||||||
* Example originally created with raylib 1.3, last time updated with raylib 1.3
|
|
||||||
*
|
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015-2025 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
#include "rcamera.h"
|
|
||||||
|
|
||||||
#define MAX_COLUMNS 20
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person");
|
|
||||||
|
|
||||||
// Define the camera to look into our 3d world (position, target, up vector)
|
|
||||||
Camera camera = { 0 };
|
|
||||||
camera.position = (Vector3){ 0.0f, 2.0f, 4.0f }; // Camera position
|
|
||||||
camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point
|
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
|
||||||
camera.fovy = 60.0f; // Camera field-of-view Y
|
|
||||||
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
|
||||||
|
|
||||||
int cameraMode = CAMERA_FIRST_PERSON;
|
|
||||||
|
|
||||||
// Generates some random columns
|
|
||||||
float heights[MAX_COLUMNS] = { 0 };
|
|
||||||
Vector3 positions[MAX_COLUMNS] = { 0 };
|
|
||||||
Color colors[MAX_COLUMNS] = { 0 };
|
|
||||||
|
|
||||||
for (int i = 0; i < MAX_COLUMNS; i++)
|
|
||||||
{
|
|
||||||
heights[i] = (float)GetRandomValue(1, 12);
|
|
||||||
positions[i] = (Vector3){ (float)GetRandomValue(-15, 15), heights[i]/2.0f, (float)GetRandomValue(-15, 15) };
|
|
||||||
colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 };
|
|
||||||
}
|
|
||||||
|
|
||||||
DisableCursor(); // Limit cursor to relative movement inside the window
|
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Switch camera mode
|
|
||||||
if (IsKeyPressed(KEY_ONE))
|
|
||||||
{
|
|
||||||
cameraMode = CAMERA_FREE;
|
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Reset roll
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_TWO))
|
|
||||||
{
|
|
||||||
cameraMode = CAMERA_FIRST_PERSON;
|
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Reset roll
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_THREE))
|
|
||||||
{
|
|
||||||
cameraMode = CAMERA_THIRD_PERSON;
|
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Reset roll
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_FOUR))
|
|
||||||
{
|
|
||||||
cameraMode = CAMERA_ORBITAL;
|
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Reset roll
|
|
||||||
}
|
|
||||||
|
|
||||||
// Switch camera projection
|
|
||||||
if (IsKeyPressed(KEY_P))
|
|
||||||
{
|
|
||||||
if (camera.projection == CAMERA_PERSPECTIVE)
|
|
||||||
{
|
|
||||||
// Create isometric view
|
|
||||||
cameraMode = CAMERA_THIRD_PERSON;
|
|
||||||
// Note: The target distance is related to the render distance in the orthographic projection
|
|
||||||
camera.position = (Vector3){ 0.0f, 2.0f, -100.0f };
|
|
||||||
camera.target = (Vector3){ 0.0f, 2.0f, 0.0f };
|
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
|
||||||
camera.projection = CAMERA_ORTHOGRAPHIC;
|
|
||||||
camera.fovy = 20.0f; // near plane width in CAMERA_ORTHOGRAPHIC
|
|
||||||
CameraYaw(&camera, -135*DEG2RAD, true);
|
|
||||||
CameraPitch(&camera, -45*DEG2RAD, true, true, false);
|
|
||||||
}
|
|
||||||
else if (camera.projection == CAMERA_ORTHOGRAPHIC)
|
|
||||||
{
|
|
||||||
// Reset to default view
|
|
||||||
cameraMode = CAMERA_THIRD_PERSON;
|
|
||||||
camera.position = (Vector3){ 0.0f, 2.0f, 10.0f };
|
|
||||||
camera.target = (Vector3){ 0.0f, 2.0f, 0.0f };
|
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
|
||||||
camera.projection = CAMERA_PERSPECTIVE;
|
|
||||||
camera.fovy = 60.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update camera computes movement internally depending on the camera mode
|
|
||||||
// Some default standard keyboard/mouse inputs are hardcoded to simplify use
|
|
||||||
// For advanced camera controls, it's recommended to compute camera movement manually
|
|
||||||
UpdateCamera(&camera, cameraMode); // Update camera
|
|
||||||
/*
|
|
||||||
// Camera PRO usage example (EXPERIMENTAL)
|
|
||||||
// This new camera function allows custom movement/rotation values to be directly provided
|
|
||||||
// as input parameters, with this approach, rcamera module is internally independent of raylib inputs
|
|
||||||
UpdateCameraPro(&camera,
|
|
||||||
(Vector3){
|
|
||||||
(IsKeyDown(KEY_W) || IsKeyDown(KEY_UP))*0.1f - // Move forward-backward
|
|
||||||
(IsKeyDown(KEY_S) || IsKeyDown(KEY_DOWN))*0.1f,
|
|
||||||
(IsKeyDown(KEY_D) || IsKeyDown(KEY_RIGHT))*0.1f - // Move right-left
|
|
||||||
(IsKeyDown(KEY_A) || IsKeyDown(KEY_LEFT))*0.1f,
|
|
||||||
0.0f // Move up-down
|
|
||||||
},
|
|
||||||
(Vector3){
|
|
||||||
GetMouseDelta().x*0.05f, // Rotation: yaw
|
|
||||||
GetMouseDelta().y*0.05f, // Rotation: pitch
|
|
||||||
0.0f // Rotation: roll
|
|
||||||
},
|
|
||||||
GetMouseWheelMove()*2.0f); // Move to target (zoom)
|
|
||||||
*/
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
BeginMode3D(camera);
|
|
||||||
|
|
||||||
DrawPlane((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector2){ 32.0f, 32.0f }, LIGHTGRAY); // Draw ground
|
|
||||||
DrawCube((Vector3){ -16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, BLUE); // Draw a blue wall
|
|
||||||
DrawCube((Vector3){ 16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, LIME); // Draw a green wall
|
|
||||||
DrawCube((Vector3){ 0.0f, 2.5f, 16.0f }, 32.0f, 5.0f, 1.0f, GOLD); // Draw a yellow wall
|
|
||||||
|
|
||||||
// Draw some cubes around
|
|
||||||
for (int i = 0; i < MAX_COLUMNS; i++)
|
|
||||||
{
|
|
||||||
DrawCube(positions[i], 2.0f, heights[i], 2.0f, colors[i]);
|
|
||||||
DrawCubeWires(positions[i], 2.0f, heights[i], 2.0f, MAROON);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw player cube
|
|
||||||
if (cameraMode == CAMERA_THIRD_PERSON)
|
|
||||||
{
|
|
||||||
DrawCube(camera.target, 0.5f, 0.5f, 0.5f, PURPLE);
|
|
||||||
DrawCubeWires(camera.target, 0.5f, 0.5f, 0.5f, DARKPURPLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
EndMode3D();
|
|
||||||
|
|
||||||
// Draw info boxes
|
|
||||||
DrawRectangle(5, 5, 330, 100, Fade(SKYBLUE, 0.5f));
|
|
||||||
DrawRectangleLines(5, 5, 330, 100, BLUE);
|
|
||||||
|
|
||||||
DrawText("Camera controls:", 15, 15, 10, BLACK);
|
|
||||||
DrawText("- Move keys: W, A, S, D, Space, Left-Ctrl", 15, 30, 10, BLACK);
|
|
||||||
DrawText("- Look around: arrow keys or mouse", 15, 45, 10, BLACK);
|
|
||||||
DrawText("- Camera mode keys: 1, 2, 3, 4", 15, 60, 10, BLACK);
|
|
||||||
DrawText("- Zoom keys: num-plus, num-minus or mouse scroll", 15, 75, 10, BLACK);
|
|
||||||
DrawText("- Camera projection key: P", 15, 90, 10, BLACK);
|
|
||||||
|
|
||||||
DrawRectangle(600, 5, 195, 100, Fade(SKYBLUE, 0.5f));
|
|
||||||
DrawRectangleLines(600, 5, 195, 100, BLUE);
|
|
||||||
|
|
||||||
DrawText("Camera status:", 610, 15, 10, BLACK);
|
|
||||||
DrawText(TextFormat("- Mode: %s", (cameraMode == CAMERA_FREE) ? "FREE" :
|
|
||||||
(cameraMode == CAMERA_FIRST_PERSON) ? "FIRST_PERSON" :
|
|
||||||
(cameraMode == CAMERA_THIRD_PERSON) ? "THIRD_PERSON" :
|
|
||||||
(cameraMode == CAMERA_ORBITAL) ? "ORBITAL" : "CUSTOM"), 610, 30, 10, BLACK);
|
|
||||||
DrawText(TextFormat("- Projection: %s", (camera.projection == CAMERA_PERSPECTIVE) ? "PERSPECTIVE" :
|
|
||||||
(camera.projection == CAMERA_ORTHOGRAPHIC) ? "ORTHOGRAPHIC" : "CUSTOM"), 610, 45, 10, BLACK);
|
|
||||||
DrawText(TextFormat("- Position: (%06.3f, %06.3f, %06.3f)", camera.position.x, camera.position.y, camera.position.z), 610, 60, 10, BLACK);
|
|
||||||
DrawText(TextFormat("- Target: (%06.3f, %06.3f, %06.3f)", camera.target.x, camera.target.y, camera.target.z), 610, 75, 10, BLACK);
|
|
||||||
DrawText(TextFormat("- Up: (%06.3f, %06.3f, %06.3f)", camera.up.x, camera.up.y, camera.up.z), 610, 90, 10, BLACK);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 17 KiB |