Compare commits
No commits in common. "master" and "2.5.0" have entirely different histories.
6
.github/FUNDING.yml
vendored
|
|
@ -1,8 +1,8 @@
|
||||||
# These are supported funding model platforms
|
# These are supported funding model platforms
|
||||||
|
|
||||||
github: raysan5
|
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||||
patreon: # raylib
|
patreon: raylib
|
||||||
open_collective: # Replace with a single Open Collective username
|
open_collective: # Replace with a single Open Collective username
|
||||||
ko_fi: # raysan
|
ko_fi: raysan
|
||||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
custom: # Replace with a single custom sponsorship URL
|
custom: # Replace with a single custom sponsorship URL
|
||||||
|
|
|
||||||
1
.github/ISSUE_TEMPLATE/config.yml
vendored
|
|
@ -1 +0,0 @@
|
||||||
blank_issues_enabled: false
|
|
||||||
13
.github/ISSUE_TEMPLATE/new-issue-template.md
vendored
|
|
@ -7,26 +7,15 @@ 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:
|
Please, before submitting a new issue verify and check:
|
||||||
|
|
||||||
- [ ] I tested it on latest raylib version from master branch
|
- [ ] I tested it on latest raylib version from master branch
|
||||||
- [ ] I checked there is no similar issue already reported
|
- [ ] 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
|
- [ ] My code has no errors or misuse of raylib
|
||||||
|
|
||||||
### Issue description
|
### 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).*
|
*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/VkzNHUE).*
|
||||||
|
|
||||||
### Environment
|
### Environment
|
||||||
|
|
||||||
|
|
|
||||||
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
|
|
||||||
108
.gitignore
vendored
|
|
@ -30,14 +30,15 @@ Thumbs.db
|
||||||
*.cache
|
*.cache
|
||||||
*.ilk
|
*.ilk
|
||||||
*.log
|
*.log
|
||||||
.vs
|
|
||||||
|
|
||||||
[Bb]in
|
[Bb]in
|
||||||
[Dd]ebug/
|
[Dd]ebug/
|
||||||
|
[Dd]ebug.win32/
|
||||||
|
[Dd]ebug.DLL/
|
||||||
*.sbr
|
*.sbr
|
||||||
*.sdf
|
*.sdf
|
||||||
obj/
|
obj/
|
||||||
[R]elease/
|
[R]elease/
|
||||||
|
[Rr]elease.win32/
|
||||||
_ReSharper*/
|
_ReSharper*/
|
||||||
[Tt]est[Rr]esult*
|
[Tt]est[Rr]esult*
|
||||||
ipch/
|
ipch/
|
||||||
|
|
@ -45,36 +46,39 @@ ipch/
|
||||||
*.db
|
*.db
|
||||||
*.opendb
|
*.opendb
|
||||||
packages/
|
packages/
|
||||||
!examples/models/resources/models/obj/
|
|
||||||
|
|
||||||
# Ignore compiled binaries
|
# Ignore compiled binaries
|
||||||
*.o
|
*.o
|
||||||
*.exe
|
*.exe
|
||||||
*.a
|
*.a
|
||||||
*.bc
|
*.bc
|
||||||
*.so
|
!raylib.rc.o
|
||||||
*.so.*
|
|
||||||
*.dll
|
|
||||||
*.h.pch
|
|
||||||
./*.obj
|
|
||||||
|
|
||||||
# Ignore SDL libs for testing
|
# Ignore all examples files
|
||||||
src/external/SDL2
|
examples/*
|
||||||
src/external/SDL3
|
# Unignore all examples dirs
|
||||||
|
!examples/*/
|
||||||
|
# Unignore all examples files with extension
|
||||||
|
!examples/*.c
|
||||||
|
!examples/*.lua
|
||||||
|
!examples/*.png
|
||||||
|
# Unignore examples Makefile
|
||||||
|
!examples/Makefile
|
||||||
|
!examples/Makefile.Android
|
||||||
|
!examples/raylib_compile_execute.bat
|
||||||
|
!examples/raylib_makefile_example.bat
|
||||||
|
|
||||||
# Emscripten
|
# Ignore all games files
|
||||||
emsdk
|
games/*
|
||||||
|
# Unignore all games dirs
|
||||||
# Ignore binaries generated in examples/
|
!games/*/
|
||||||
examples/**/*
|
# Unignore all games files with extension
|
||||||
!examples/**/*.*
|
!games/*.c
|
||||||
!examples/**/*/
|
!games/*.lua
|
||||||
examples/**/*.exe
|
!games/*.png
|
||||||
examples/**/*.wasm
|
# Unignore games makefile
|
||||||
examples/**/*.data
|
!games/Makefile
|
||||||
examples/**/*.js
|
!games/Makefile.Android
|
||||||
examples/**/*.html
|
|
||||||
examples/**/logs/*
|
|
||||||
|
|
||||||
# Ignore files build by xcode
|
# Ignore files build by xcode
|
||||||
*.mode*v*
|
*.mode*v*
|
||||||
|
|
@ -90,51 +94,45 @@ xcschememanagement.plist
|
||||||
xcuserdata/
|
xcuserdata/
|
||||||
DerivedData/
|
DerivedData/
|
||||||
|
|
||||||
# VSCode project
|
# Visual Studio project
|
||||||
.vscode
|
project/VS2015.UWP/packages
|
||||||
.clangd
|
project/VS2017/packages
|
||||||
|
|
||||||
# Jetbrains project
|
# Web examples
|
||||||
.idea/
|
docs/examples/web/*.html
|
||||||
cmake-build-*/
|
docs/examples/web/*/*.html
|
||||||
|
!docs/examples/web/loader.html
|
||||||
|
!docs/examples/web/core/loader.html
|
||||||
|
!docs/examples/web/shapes/loader.html
|
||||||
|
!docs/examples/web/text/loader.html
|
||||||
|
!docs/examples/web/textures/loader.html
|
||||||
|
!docs/examples/web/audio/loader.html
|
||||||
|
!docs/examples/web/physac/loader.html
|
||||||
|
!docs/examples/web/shaders/loader.html
|
||||||
|
!docs/examples/web/models/loader.html
|
||||||
|
|
||||||
# CMake stuff
|
# CMake stuff
|
||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
CMakeFiles
|
CMakeFiles
|
||||||
CMakeScripts
|
CMakeScripts
|
||||||
Testing
|
Testing
|
||||||
|
TestingIfSymlinkWorks
|
||||||
cmake_install.cmake
|
cmake_install.cmake
|
||||||
cmake_uninstall.cmake
|
|
||||||
install_manifest.txt
|
install_manifest.txt
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
CTestTestfile.cmake
|
CTestTestfile.cmake
|
||||||
build
|
build
|
||||||
|
!templates/android_project/Makefile
|
||||||
|
|
||||||
|
# Unignore These makefiles...
|
||||||
|
!examples/CMakeLists.txt
|
||||||
|
!games/CMakeLists.txt
|
||||||
|
|
||||||
|
# Ignore Android generated files and folders
|
||||||
|
templates/android_project/output
|
||||||
|
|
||||||
# Ignore GNU global tags
|
# Ignore GNU global tags
|
||||||
GPATH
|
GPATH
|
||||||
GRTAGS
|
GRTAGS
|
||||||
GTAGS
|
GTAGS
|
||||||
|
.vs
|
||||||
# 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
|
|
||||||
|
|
|
||||||
166
.travis.yml
Normal file
|
|
@ -0,0 +1,166 @@
|
||||||
|
language: c
|
||||||
|
dist: trusty
|
||||||
|
|
||||||
|
git:
|
||||||
|
depth: 3
|
||||||
|
|
||||||
|
# TODO we could use a 32 bit Docker container for running true 32-bit tests
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: linux
|
||||||
|
env: ARCH=i386
|
||||||
|
sudo: required
|
||||||
|
- os: linux
|
||||||
|
env: ARCH=amd64 INSTALL_GLFW=YES USE_EXTERNAL_GLFW=OFF
|
||||||
|
sudo: required
|
||||||
|
- os: linux
|
||||||
|
env: ARCH=amd64 INSTALL_GLFW=YES STATIC=OFF RELEASE=NO
|
||||||
|
sudo: required
|
||||||
|
- os: linux
|
||||||
|
env: WAYLAND=ON ARCH=amd64 RELEASE=NO
|
||||||
|
sudo: required
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- libwayland-dev
|
||||||
|
- libxkbcommon-dev
|
||||||
|
- libegl1-mesa-dev
|
||||||
|
- os: osx
|
||||||
|
env: ARCH=universal
|
||||||
|
- os: osx
|
||||||
|
osx_image: xcode9.4
|
||||||
|
env: ARCH=universal SHARED=OFF RELEASE=NO
|
||||||
|
- os: linux
|
||||||
|
env: ARCH=arm64-android RELEASE=NO
|
||||||
|
sudo: required
|
||||||
|
- os: linux
|
||||||
|
env: ARCH=arm32-android RELEASE=NO
|
||||||
|
sudo: required
|
||||||
|
- os: linux
|
||||||
|
env: ARCH=html5 RELEASE=NO
|
||||||
|
sudo: required
|
||||||
|
- os: windows
|
||||||
|
compiler: gcc
|
||||||
|
env: ARCH=i386 SHARED=OFF RELEASE=NO
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- if [ -z "$USE_EXTERNAL_GLFW" ]; then export USE_EXTERNAL_GLFW=IF_POSSIBLE; fi
|
||||||
|
- if [ -z "$SHARED" ]; then export SHARED=ON ; fi
|
||||||
|
- if [ -z "$STATIC" ]; then export STATIC=ON ; fi
|
||||||
|
- if [[ "$INSTALL_GLFW" == "YES" && "$USE_EXTERNAL_GLFW" != "OFF" ]]; then
|
||||||
|
export DONT_TEST=1;
|
||||||
|
fi
|
||||||
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
|
||||||
|
if [[ "$ARCH" == *-android ]]; then
|
||||||
|
export DONT_TEST=1;
|
||||||
|
export RAYLIB_PACKAGE_SUFFIX="-Android-arm64";
|
||||||
|
wget https://dl.google.com/android/repository/android-ndk-r17-linux-x86_64.zip;
|
||||||
|
unzip -qq android-ndk*.zip;
|
||||||
|
if [[ "$ARCH" == arm64-* ]]; then
|
||||||
|
export RAYLIB_PACKAGE_SUFFIX="-Android-arm64";
|
||||||
|
TOOLCHAIN_ARCH=arm64;
|
||||||
|
PREFIX=aarch64-linux-android-;
|
||||||
|
else
|
||||||
|
export RAYLIB_PACKAGE_SUFFIX="-Android-arm32";
|
||||||
|
TOOLCHAIN_ARCH=arm;
|
||||||
|
PREFIX=arm-linux-androideabi-;
|
||||||
|
fi;
|
||||||
|
android-ndk*/build/tools/make_standalone_toolchain.py --arch $TOOLCHAIN_ARCH --api 21 --install-dir /tmp/android-toolchain;
|
||||||
|
export PATH=/tmp/android-toolchain/bin:$PATH;
|
||||||
|
export CC=${PREFIX}clang;
|
||||||
|
export CXX=${PREFIX}clang++;
|
||||||
|
export CMAKE_ARCH_ARGS='-DPLATFORM=Android';
|
||||||
|
elif [ "$ARCH" == "html5" ]; then
|
||||||
|
export DONT_TEST=1;
|
||||||
|
export RAYLIB_PACKAGE_SUFFIX="-html5";
|
||||||
|
docker run --privileged=true -dit --name emscripten -v $(pwd):/src trzeci/emscripten:sdk-incoming-64bit bash;
|
||||||
|
export CMAKE_ARCH_ARGS='-DPLATFORM=Web -DCMAKE_TOOLCHAIN_FILE=../cmake/emscripten.cmake';
|
||||||
|
RUNNER='docker exec -it emscripten cmake -E chdir build';
|
||||||
|
else
|
||||||
|
sudo apt-get install -y gcc-multilib
|
||||||
|
libasound2-dev:$ARCH
|
||||||
|
libxcursor-dev:$ARCH libxinerama-dev:$ARCH mesa-common-dev:$ARCH
|
||||||
|
libx11-dev:$ARCH libxrandr-dev:$ARCH libxrandr2:$ARCH libxi-dev:$ARCH
|
||||||
|
libgl1-mesa-dev:$ARCH libglu1-mesa-dev:$ARCH;
|
||||||
|
|
||||||
|
if [ "$OPENAL" == "ON" ]; then sudo apt-get install -y libopenal-dev; fi;
|
||||||
|
if [ "$ARCH" == "i386" ]; then export CMAKE_ARCH_ARGS='-DCMAKE_C_FLAGS=-m32 -DCMAKE_SYSTEM_LIBRARY_PATH=/usr/lib/i386-linux-gnu -DSUPPORT_FILEFORMAT_FLAC=OFF'; fi;
|
||||||
|
|
||||||
|
export RAYLIB_PACKAGE_SUFFIX="-Linux-$ARCH";
|
||||||
|
if [ "$INSTALL_GLFW" == "YES" ]; then
|
||||||
|
pushd src/external/glfw;
|
||||||
|
cmake . -DGLFW_BUILD_DOCS=OFF
|
||||||
|
-DGLFW_BUILD_TESTS=OFF
|
||||||
|
-DGLFW_BUILD_EXAMPLES=OFF
|
||||||
|
-DGLFW_INSTALL=ON
|
||||||
|
-DBUILD_SHARED_LIBS=ON
|
||||||
|
-DGLFW_USE_WAYLAND=$WAYLAND;
|
||||||
|
make;
|
||||||
|
sudo make install;
|
||||||
|
popd;
|
||||||
|
fi;
|
||||||
|
fi;
|
||||||
|
fi
|
||||||
|
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||||
|
export RAYLIB_PACKAGE_SUFFIX="-macOS";
|
||||||
|
if [ "$INSTALL_GLFW" == "YES" ]; then brew update; brew install glfw; fi;
|
||||||
|
fi
|
||||||
|
- if [ "$TRAVIS_OS_NAME" == "windows" ]; then
|
||||||
|
export DONT_TEST=1;
|
||||||
|
export RAYLIB_PACKAGE_SUFFIX="-windows";
|
||||||
|
export CMAKE_ARCH_ARGS='-DPLATFORM=Desktop';
|
||||||
|
fi
|
||||||
|
- mkdir build
|
||||||
|
- $RUNNER $CC --version
|
||||||
|
|
||||||
|
script:
|
||||||
|
- cd build
|
||||||
|
- if test -n "$WAYLAND"; then
|
||||||
|
wget https://mirrors.edge.kernel.org/ubuntu/pool/universe/e/extra-cmake-modules/extra-cmake-modules_5.44.0-0ubuntu1_amd64.deb;
|
||||||
|
sudo apt-get clean;
|
||||||
|
sudo apt-get update;
|
||||||
|
sudo apt-get install dpkg;
|
||||||
|
sudo dpkg -i extra-cmake-modules_5.44.0-0ubuntu1_amd64.deb;
|
||||||
|
git clone git://anongit.freedesktop.org/wayland/wayland-protocols;
|
||||||
|
pushd wayland-protocols;
|
||||||
|
git checkout 1.15 && ./autogen.sh --prefix=/usr && make && sudo make install;
|
||||||
|
popd;
|
||||||
|
fi
|
||||||
|
- $RUNNER cmake $CMAKE_ARCH_ARGS
|
||||||
|
-DMACOS_FATLIB=ON
|
||||||
|
-DSTATIC=$STATIC -DSHARED=$SHARED
|
||||||
|
-DBUILD_EXAMPLES=ON -DBUILD_GAMES=ON
|
||||||
|
-DUSE_EXTERNAL_GLFW=$USE_EXTERNAL_GLFW
|
||||||
|
-DUSE_WAYLAND=$WAYLAND
|
||||||
|
-DINCLUDE_EVERYTHING=ON
|
||||||
|
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
|
||||||
|
..
|
||||||
|
- $RUNNER cmake --build . --target
|
||||||
|
- if [ "$RELEASE" != "NO" ]; then $RUNNER cmake --build . --target package; fi
|
||||||
|
- if [ -n "$RUNNER" ]; then
|
||||||
|
sudo $RUNNER cmake --build . --target install;
|
||||||
|
else
|
||||||
|
$(which sudo) $RUNNER "$(which cmake)" --build . --target install;
|
||||||
|
fi
|
||||||
|
- if [ ! "$DONT_TEST" ]; then
|
||||||
|
pkg-config --static --libs raylib;
|
||||||
|
nm -g release/libraylib.a | grep glfwGetProcAddress || (echo "libraylib.a doesn't contain GLFW symbols! Aborting..." && false);
|
||||||
|
ctest --output-on-failure;
|
||||||
|
fi
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
provider: releases
|
||||||
|
api_key:
|
||||||
|
secure: LvqUIAN/3dJul+Ra2iK3tSaNG5IwsNMmGIwVMy0DK5IBCxiQPBc9pWGiE30RTBPt6Z+N4BhMEE8DtUl+vnISlMoHWNIIhF2zwC66hs/F7zY7qEITMRSmfiLcqxQysknFOnJB06CATgXcFqlEo9j+t4abrG/f3qcb92J4O2uNz336Au2myTx93Q5MxbyA7KiUuEutFnb2dWiPCY4d+sGeXEfsiD2R7aj/8MaWOkoGdZVrTkI9juMgvpImkjQBArvqdjUMeT3MsRrwgOIq5v2GFV9dOl8k1WzPeT8B2JHh00ed/o1/wuFq/cLLOxtYo2+Pv3+xatOrlexoX0WkDm7C9/L1W5U4rLexU3CQ9mMBmHPnp6k/WXZ5QXEE4uUF0+LpN3XlIXzFpdZmZiVV8VLxg2WvyncMmivYiu7/MTkyfZxyKkzwl7sZZslzHA9kOGedGaN7b7/2B77OFHoQK8lKfdFml7jJnarh+89nenNZYMab0E8qkOJOyb2bYlDTa0/2nyxGiyymYgq6YHLNrDbhqB/1LzdgzjMliQ8ri5q9Ux2vjfcqOzhfAmcwFwnY/D6yXJWYi0DWpHZdpKl3du6dYDrypW91/yDWbwiJ/YhrE7ZunzrcB6GH/QkbuzWxdCth39rQAHih8DG01co/K3Gvi4yGjvIH5tFUpyEolMnpMiA=
|
||||||
|
file_glob: true
|
||||||
|
file: raylib-*.tar.gz
|
||||||
|
skip_cleanup: true
|
||||||
|
on:
|
||||||
|
repo: raysan5/raylib
|
||||||
|
branch: master
|
||||||
|
tags: true
|
||||||
214
BINDINGS.md
|
|
@ -1,193 +1,33 @@
|
||||||
# raylib bindings and wrappers
|
### raylib bindings
|
||||||
|
|
||||||
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.
|
Some people ported raylib to other languages in form of bindings or wrappers to the library, here is a list with the ones I'm aware of:
|
||||||
|
|
||||||
### Language Bindings
|
- [raylib](https://github.com/raysan5/raylib) : raylib **C/C++** version (default)
|
||||||
|
- [raylib-lua](https://github.com/raysan5/raylib-lua) : raylib **Lua** binding
|
||||||
|
- [raylib-lua-ffi](https://github.com/raysan5/raylib/issues/693) : raylib **Lua** ffi binding
|
||||||
|
- [raylib-go](https://github.com/gen2brain/raylib-go) : raylib **Go** binding
|
||||||
|
- [raylib-Nim](https://gitlab.com/define-private-public/raylib-Nim) : raylib **Nim** binding
|
||||||
|
- [raylib-cr](https://github.com/AregevDev/raylib-cr) : raylib **Crystal** binding
|
||||||
|
- [cray](https://gitlab.com/Zatherz/cray) - raylib **Crystal** binding
|
||||||
|
- [Graphics::Raylib](https://metacpan.org/pod/Graphics::Raylib) : raylib **Perl** wrapper
|
||||||
|
- [raylib-pascal](https://github.com/drezgames/raylib-pascal) - raylib **Pascal** binding
|
||||||
|
- [Raylib-cs](https://github.com/ChrisDill/Raylib-cs) : raylib **C#** binding
|
||||||
|
- [RaylibSharp](https://github.com/TheLumaio/RaylibSharp) : raylib **C#** binding
|
||||||
|
- [raylib-ruby-ffi](https://github.com/D3nX/raylib-ruby-ffi) : raylib **Ruby** binding
|
||||||
|
- [raylib-rs](https://github.com/deltaphc/raylib-rs) : raylib **Rust** binding
|
||||||
|
- [raylib-py](https://github.com/overdev/raylib-py) : raylib **Python** binding
|
||||||
|
- [raylib-haskell](https://github.com/DevJac/raylib-haskell) : raylib **Haskell** binding
|
||||||
|
- [raylib-java](https://github.com/XoanaIO/raylib-java) : raylib **Java** binding
|
||||||
|
- [raylib-chaiscript](https://github.com/RobLoach/raylib-chaiscript) : raylib **ChaiScript** binding
|
||||||
|
- [node-raylib](https://github.com/RobLoach/node-raylib) : **Node.js** raylib binding
|
||||||
|
- [raylib-odin](https://github.com/kevinw/raylib-odin): **Odin** raylib binding
|
||||||
|
- [raylib-factor](https://github.com/Silverbeard00/raylib-factor): **Factor** raylib binding
|
||||||
|
- *[raylib COBOL Usage example](https://github.com/Martinfx/Cobol/tree/master/OpenCobol/Games/raylib)*
|
||||||
|
- *raylib flat-assembler Usage example*: not uploaded yet...
|
||||||
|
|
||||||
| Name | raylib Version | Language | License |
|
Missing some language? Check the [bindings not yet in this list](https://gist.github.com/raysan5/5764cc5b885183f523fce47f098f3d9b#bindings-not-yet-in-the-official-list) or create a new binding! :)
|
||||||
| :--------------------------------------------------------------------------------------- | :--------------: | :------------------------------------------------------------------: | :------------------: |
|
|
||||||
| [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}`
|
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!
|
Let me know if you're writing a new binding for raylib, I will list it here and I usually
|
||||||
|
provide the icon/logo for that new language binding.
|
||||||
|
|
|
||||||
|
|
@ -1,57 +1,54 @@
|
||||||
cmake_minimum_required(VERSION 3.22)
|
cmake_minimum_required(VERSION 3.0)
|
||||||
project(raylib)
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||||
|
|
||||||
# Avoid excessive expansion of variables in conditionals. In particular, if
|
# Config options
|
||||||
# "PLATFORM" is "DRM" then:
|
option(BUILD_EXAMPLES "Build the examples." ON)
|
||||||
#
|
option(BUILD_GAMES "Build the example games." ON)
|
||||||
# if (${PLATFORM} MATCHES "DRM")
|
option(ENABLE_ASAN "Enable AddressSanitizer (ASAN) for debugging (degrades performance)" OFF)
|
||||||
#
|
option(ENABLE_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan) for debugging" OFF)
|
||||||
# may expand e.g to:
|
option(ENABLE_MSAN "Enable MemorySanitizer (MSan) for debugging (not recommended to run with ASAN)" OFF)
|
||||||
#
|
|
||||||
# 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
|
if(CMAKE_VERSION VERSION_LESS "3.1")
|
||||||
# This is used to hide glfw's symbols from the library exports when building an so/dylib
|
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||||
# See https://cmake.org/cmake/help/latest/policy/CMP0063.html
|
set(CMAKE_C_FLAGS "-std=gnu99 ${CMAKE_C_FLAGS}")
|
||||||
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()
|
||||||
|
else()
|
||||||
|
set (CMAKE_C_STANDARD 99)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Main sources directory (the second parameter sets the output directory name to raylib)
|
include(AddIfFlagCompiles)
|
||||||
add_subdirectory(src raylib)
|
add_if_flag_compiles(-Werror=pointer-arith CMAKE_C_FLAGS)
|
||||||
|
add_if_flag_compiles(-Werror=implicit-function-declaration CMAKE_C_FLAGS)
|
||||||
|
# src/external/jar_xm.h does shady stuff
|
||||||
|
add_if_flag_compiles(-fno-strict-aliasing CMAKE_C_FLAGS)
|
||||||
|
|
||||||
# Uninstall target, only create when building raylib by itself
|
include(CheckFileSystemSymlinkSupport)
|
||||||
# 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
|
if (ENABLE_ASAN)
|
||||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
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()
|
endif()
|
||||||
|
if (ENABLE_UBSAN)
|
||||||
|
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)
|
||||||
|
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 (ENABLE_MSAN AND ENABLE_ASAN)
|
||||||
|
MESSAGE(WARNING "Compiling with both AddressSanitizer and MemorySanitizer is not recommended")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory(src)
|
||||||
|
|
||||||
if (${BUILD_EXAMPLES})
|
if (${BUILD_EXAMPLES})
|
||||||
message(STATUS "Building examples is enabled")
|
|
||||||
add_subdirectory(examples)
|
add_subdirectory(examples)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (${BUILD_GAMES})
|
||||||
|
add_subdirectory(games)
|
||||||
|
endif()
|
||||||
|
|
||||||
enable_testing()
|
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()
|
|
||||||
46
CODE_OF_CONDUCT.md
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment include:
|
||||||
|
|
||||||
|
* Using welcoming and inclusive language
|
||||||
|
* Being respectful of differing viewpoints and experiences
|
||||||
|
* Gracefully accepting constructive criticism
|
||||||
|
* Focusing on what is best for the community
|
||||||
|
* Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||||
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||||
|
|
||||||
|
## Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at ray@raylib.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||||
|
|
||||||
|
[homepage]: http://contributor-covenant.org
|
||||||
|
[version]: http://contributor-covenant.org/version/1/4/
|
||||||
108
CONTRIBUTING.md
|
|
@ -4,63 +4,63 @@ Hello contributors! Welcome to raylib!
|
||||||
|
|
||||||
Do you enjoy raylib and want to contribute? Nice! You can help with the following points:
|
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?
|
- C programming - Can you write/review/test/improve the code?
|
||||||
- `Documentation/Tutorials/Example` - Can you write some tutorials/examples?
|
- Documentation/Tutorials/Example - Can you write some tutorial/example?
|
||||||
- `Porting to other platforms` - Can you port/adapt/compile raylib on other systems?
|
- Web Development - Can you help [with the web](https://github.com/raysan5/raylib.com)?
|
||||||
- `Web Development` - Can you help [with the website](https://github.com/raysan5/raylib.com)?
|
- Porting to other platforms - Can you port and compile raylib on another systems?
|
||||||
- `Testing` - Can you find some bugs in raylib?
|
- Testing - Can you find some bugs on raylib?
|
||||||
|
|
||||||
This document contains a set of guidelines to contribute to the project. These are mostly guidelines, not rules.
|
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.
|
Use your best judgement, and feel free to propose changes to this document in a pull-request.
|
||||||
|
|
||||||
### raylib philosophy
|
### raylib philosophy
|
||||||
|
|
||||||
- raylib is a tool to **ENJOY** videogames programming, every function in raylib is designed as a mini-tutorial on itself.
|
- raylib is a tool to enjoy videogames programming, every single function in raylib should be a 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 SIMPLE and EASY-TO-USE, I tried to keep it compact with a small set of functions, if a function is too complex or is not clearly useful, better not to include it.
|
||||||
- raylib is open source and free; educators and institutions can use this tool to **TEACH** videogames programming completely for free.
|
- raylib is open source and free; educators and institutions can use this tool to TEACH videogames programming completely by free.
|
||||||
- raylib is collaborative; contribution of tutorials / code examples / bug fixes / code comments are highly appreciated.
|
- raylib is collaborative; contribution of tutorials / code-examples / bugs-solving / code-comments are highly appreciated.
|
||||||
- raylib's license (and its external libs respective licenses) allow using raylib on commercial projects.
|
- raylib's license (and its external libs respective licenses) allow using it for commercial products.
|
||||||
|
|
||||||
### Some interesting reads to start with
|
### Some interesting reads to start with
|
||||||
|
|
||||||
- [raylib history](HISTORY.md)
|
- [raylib history](HISTORY.md)
|
||||||
- [raylib architecture](https://github.com/raysan5/raylib/wiki/raylib-architecture)
|
- [raylib architecture](https://github.com/raysan5/raylib/wiki/raylib-architecture)
|
||||||
- [raylib license](LICENSE)
|
- [raylib license](LICENSE.md)
|
||||||
- [raylib roadmap](ROADMAP.md)
|
- [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.
|
[raylib Wiki](https://github.com/raysan5/raylib/wiki) contains some information about the library and is open to anyone for edit.
|
||||||
Feel free to review it if required, just take care not to break something.
|
Feel free to review it if required, just take care not to break something.
|
||||||
|
|
||||||
### raylib C coding conventions
|
### raylib C coding conventions
|
||||||
|
|
||||||
Despite being written in C, raylib does not follow the standard Hungarian notation for C,
|
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),
|
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
|
more common on C# language. All code formatting decisions have been carefully taken
|
||||||
to make it easier for students/users to read, write and understand code.
|
to make it easier for students to read, write and understand code.
|
||||||
|
|
||||||
Source code is extensively commented for that purpose, raylib primary learning method is:
|
Source code is extensively commented for that purpose, raylib primary learning method is:
|
||||||
|
|
||||||
> `Learn by reading code and examples`
|
> learn by reading code and examples
|
||||||
|
|
||||||
For detailed information on building raylib and examples, please check [raylib Wiki](https://github.com/raysan5/raylib/wiki).
|
For detailed information on building raylib and examples, please check [raylib Wiki](https://github.com/raysan5/raylib/wiki).
|
||||||
|
|
||||||
### Opening new Issues
|
### Opening new Issues
|
||||||
|
|
||||||
To open new issues for raylib (bug, enhancement, discussion...), just try to follow these rules:
|
To open new issue 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.
|
- 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
|
- 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.
|
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.
|
- If applies, 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.
|
- 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.
|
If don't know the module, just report the issue, I will review it.
|
||||||
- You can check other issues to see how it's being done!
|
- You can check other issues to see how is being done!
|
||||||
|
|
||||||
### Sending a Pull-Request
|
### Sending a Pull-Request
|
||||||
|
|
||||||
- Make sure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
|
- 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.
|
- Don't send big pull-requests (lots of changelists), they are difficult to review. It's better to send small pull-request, 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
|
- Verify that changes don't break the build (at least on Windows platform). As many platforms where you can test it, the better, but don't worry
|
||||||
if you cannot test all the platforms.
|
if you cannot test all the platforms.
|
||||||
|
|
||||||
### Contact information
|
### Contact information
|
||||||
|
|
@ -68,9 +68,69 @@ To open new issues for raylib (bug, enhancement, discussion...), just try to fol
|
||||||
If you have any doubt, don't hesitate to [contact me](mailto:ray@raylib.com)!.
|
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:
|
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 reddit](https://www.reddit.com/r/raylib/) - A good place for discussions or to ask for help.
|
||||||
|
- [raylib Discord](https://discord.gg/VkzNHUE) - A direct communication channel for project discussions.
|
||||||
|
- [raylib twitter](https://twitter.com/raysan5) - My personal twitter account, I usually post about raylib, you can send me PMs.
|
||||||
- [raylib web](http://www.raylib.com/) - On top-right corner there is a bunch of networks where you can find me.
|
- [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! :)
|
Thank you very much for your time! :)
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
Here is a list of raylib contributors, these people have invested part of their time
|
||||||
|
contributing (in some way or another) to make the raylib project better. Huge thanks to all of 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 implementing and testing 3D shapes functions.
|
||||||
|
- Marc Palau for implementing and testing 3D shapes functions and contribute on camera and gestures 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](https://github.com/anidealgift) for helping on raygui development and tools development (raygui_styler).
|
||||||
|
- [Victor Fisac](https://github.com/victorfisac) for developing physics raylib module (physac) and implementing PBR materials and lighting systems... among multiple other improvements 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.
|
||||||
|
- [procedural](https://github.com/procedural) for testing raylib on Linux, correcting some bugs and adding several mouse functions.
|
||||||
|
- [Chris Hemingway](https://github.com/cHemingway) for improving raylib on OSX build system.
|
||||||
|
- [Emanuele Petriglia](https://github.com/LelixSuper) for working on multiple GNU/Linux improvements and developing [TicTacToe](https://github.com/LelixSuper/TicTacToe) raylib game.
|
||||||
|
- [Joshua Reisenauer](https://github.com/kd7tck) for adding audio modules support (XM, MOD) and reviewing audio system.
|
||||||
|
- [Marcelo Paez](https://github.com/paezao) for helping on OSX High DPI display issue.
|
||||||
|
- [Ghassan Al-Mashareqa](https://github.com/ghassanpl) for an amazing contribution to raylib Lua module.
|
||||||
|
- [Teodor Stoenescu](https://github.com/teodor-stoenescu) for improvements on OBJ object loading.
|
||||||
|
- [RDR8](https://github.com/RDR8) for helping with Linux build improvements.
|
||||||
|
- [Saggi Mizrahi](https://github.com/ficoos) for multiple fixes on Linux and audio system.
|
||||||
|
- [Daniel Lemos](https://github.com/xspager) for fixing issues on Linux games building.
|
||||||
|
- [Joel Davis](https://github.com/joeld42) for adding raycast picking utilities and a [great example](https://github.com/raysan5/raylib/blob/master/examples/models/models_mesh_picking.c)
|
||||||
|
- [Richard Goodwin](https://github.com/AudioMorphology) for adding RPI touchscreen support.
|
||||||
|
- [Milan Nikolic](https://github.com/gen2brain) for adding Android build support with custom standalone toolchain.
|
||||||
|
- [Michael Vetter](https://github.com/jubalh) for improvements on build system and his work on Suse Linux package... and multiple fixes!
|
||||||
|
- [Wilhem Barbier](https://github.com/nounoursheureux) for adding Image generation functions and some fixes.
|
||||||
|
- [Benjamin Summerton](https://github.com/define-private-public) for improving OSX building and his amazing work on CMake build sytem.
|
||||||
|
- [MartinFX](https://github.com/Martinfx) for adding compilation support for FreeBSD OS and derivatives.
|
||||||
|
- [Wilhem Barbier](https://github.com/nounoursheureux) for supporting default shaders on shader loading, if shader not provided.
|
||||||
|
- [Ahmad Fatoum](https://github.com/a3f) for implementing CI support for raylib (Travis and AppVeyor) and great improvements on build system.
|
||||||
|
- [SamNChiet](https://github.com/SamNChiet) for a greatly improved UWP input implementation.
|
||||||
|
- [David Reid](https://github.com/mackron) for a complete review of audio module to support his amazing miniaudio library.
|
||||||
|
- [Kai](https://github.com/questor) for multiple code reviews and improvements.
|
||||||
|
- [RDR8](https://github.com/RDR8) for improvements on Makefiles for Linux.
|
||||||
|
- [Max Danielsson](https://github.com/autious) for adding support for orthographic 3d camera projection
|
||||||
|
- [Lumaio](https://github.com/TheLumaio) for his great work on GBuffers and GetCollisionRayModel().
|
||||||
|
- [Jonas Daeyaert](https://github.com/culacant) for an amazing work on IQM animated models support.
|
||||||
|
- [Seth Archambault](https://github.com/SethArchambault) for the work on Android Gamepad support (SNES model).
|
||||||
|
- [D3nX](https://github.com/D3nX) for adding Code::Blocks project template.
|
||||||
|
- [Jak Barnes](https://github.com/Syphonx) for a great work on `rnet`, new raylib network module
|
||||||
|
- [Vlad Adrian](https://github.com/Demizdor) for an amazing work on Unicode support, new shapes functions and raygui.
|
||||||
|
- [Reece Mackie](https://github.com/Rover656) for a great work on improving UWP support
|
||||||
|
- [flashback-fx](flashback-fx) for improving easings library and example
|
||||||
|
- [Jorge A. Gomes](https://github.com/overdev) for adding nine-patch textures support and example
|
||||||
|
- [Berni8k](https://github.com/Berni8k) for improving Raspberry Pi input system, using evdev
|
||||||
|
- [Wilhem Barbier](https://github.com/wbrbr) for implementing glTF loading support and solving several issues
|
||||||
|
- [Marco Lizza](https://github.com/MarcoLizza) for improving logging system and multiple issues
|
||||||
|
- [Anata](https://github.com/anatagawa) for creating amazing examples and contributing with them
|
||||||
|
- [Narice](https://github.com/narice) made easings.h includable as standalone header
|
||||||
|
- [Eric J.](https://github.com/ProfJski) for shaders_eratosthenes example contribution
|
||||||
|
|
||||||
|
Please, if I forget someone in this list, excuse me and send a PR!
|
||||||
|
|
|
||||||
|
|
@ -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).
|
|
||||||
537
HISTORY.md
|
|
@ -1,47 +1,47 @@
|
||||||

|

|
||||||
|
|
||||||
introduction
|
history
|
||||||
------------
|
-------
|
||||||
|
|
||||||
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've developed videogames since 2006 and in 2012 I started teaching videogames development to young people with artistic profile, most of them 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!
|
I started with C language basis and, after searching for the most simple and easy-to-use library to teach videogames programming, I found WinBGI; it was great and it worked very well with students, in just a couple of weeks that people that had never written a single line of code were able to program (and understand) a simple PONG and 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.
|
But WinBGI was not the clearer and most organized lib. There were a lot of things I found confusing and some function names were not clear enough for most of the students; not to mention points like no transparencies support or 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.
|
So, I decided to create my own library, hardware accelerated, clear function names, quite organized, well structured, plain C coding and, the most important, 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.
|
Most of my videogames coding experience was in C# and XNA and I really love it (in fact, my students learn C# after C), so, I decided to use C# language notation and XNA naming conventions. That way, students can jump 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**.
|
raylib started as a weekend project and after three months of hard work, raylib 1.0 was published on November 2013.
|
||||||
|
|
||||||
Enjoy it.
|
Enjoy it.
|
||||||
|
|
||||||
notes on raylib 1.1
|
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.
|
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 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.
|
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.
|
[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.
|
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 a lot of testing have concluded in this amazing new raylib 1.1.
|
Lots of code changes and lot of testing have concluded in this amazing new raylib 1.1.
|
||||||
|
|
||||||
notes on raylib 1.2
|
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/).
|
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 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.
|
It's been some month of really hard work to accomodate raylib to those new platforms while keeping it easy for the users. 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; the user only defines the desired screen size and it gets properly displayed.
|
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).
|
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.
|
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/).
|
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/).
|
||||||
|
|
||||||
|
|
@ -50,39 +50,39 @@ 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).
|
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.
|
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.
|
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).
|
A brand new [camera](https://github.com/raysan5/raylib/blob/master/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/master/examples/core_3d_camera_free.c) and [core_3d_camera_first_person.c](https://github.com/raysan5/raylib/blob/master/examples/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.
|
New [gestures](https://github.com/raysan5/raylib/blob/master/src/gestures.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.
|
[raygui](https://github.com/raysan5/raylib/blob/master/src/raygui.h), the new 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.
|
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.
|
Lots of code changes and lot of testing have concluded in this amazing new raylib 1.3.
|
||||||
|
|
||||||
notes on raylib 1.4
|
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.
|
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.
|
First big addition is a set of [Image manipulation functions](https://github.com/raysan5/raylib/blob/master/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.
|
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.
|
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.
|
[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.
|
[gestures](https://github.com/raysan5/raylib/blob/master/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).
|
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,
|
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.
|
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/master/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
|
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.
|
how to create some classic games like Arkanoid, Asteroids, Missile Commander, Snake or Tetris.
|
||||||
|
|
@ -94,82 +94,82 @@ 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.
|
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).
|
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 parameteres, 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 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.
|
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 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.
|
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.
|
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 singnificantly 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.
|
Audio chiptunese support and mixing channels: Added support for module audio music (.xm, .mod) loading and playing. Multiple mixing channels are now also supported. All this 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.
|
Other additions include a [2D camera system](https://github.com/raysan5/raylib/blob/master/examples/core_2d_camera.c), render textures for offline render (and most comprehensive [postprocessing](https://github.com/raysan5/raylib/blob/master/examples/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.
|
This new version is so massive that is difficult to list all the improvements, most of raylib modules have been reviewed and [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c) module has been completely redesigned to accomodate 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.
|
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/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.
|
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
|
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:
|
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 conmmemorates 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.
|
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!
|
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 completey self-contained, no external libraries required any more!
|
||||||
|
|
||||||
- [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!
|
[Physac](https://github.com/victorfisac/Physac) module has been moved to its own repository and it has been improved A LOT, actually, 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.
|
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 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.
|
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.
|
Build system improvement. Added support for raylib dynamic library generation (raylib.dll) for users that prefer dynamic library linking. Also thinking on advance users, it has been added pre-configured [Visual Studio C++ 2015 solution](https://github.com/raysan5/raylib/tree/master/project/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.
|
New examples, new functions, complete code-base review, multiple bugs corrected... this is raylib 1.6. Enjoy making games.
|
||||||
|
|
||||||
notes on raylib 1.7
|
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:
|
On May 2017, around 6 month after raylib 1.6, comes another raylib instalment, 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!
|
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, funtions 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.
|
Support of [configuration flags](https://github.com/raysan5/raylib/issues/200) on every raylib module. Advance users can customize raylib just choosing desired features, 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.
|
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 compliation 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.
|
New [examples](http://www.raylib.com/examples.html) and [sample games](http://www.raylib.com/games.html) added. All samples material has been reviewed, removing useless examples and adding more comprehensive ones; all material has been ported to latest raylib version and tested in 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...
|
Improved library consistency and organization in general. Functions and parameters have been renamed, some parts of the library have been cleaned and simplyfied, some functions has 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...
|
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.
|
And here it is another version of **raylib, a simple and easy-to-use library to enjoy videogames programming**. Enjoy it.
|
||||||
|
|
||||||
notes on raylib 1.8
|
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:
|
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.
|
[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 pourpouses.
|
||||||
|
|
||||||
- [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.
|
[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.
|
PBR Materials support, a completely redesigned shaders and material system allows advance 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.
|
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 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.
|
[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.
|
[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).
|
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).
|
||||||
|
|
||||||
|
|
@ -178,427 +178,50 @@ New installer provided, web updated, examples re-builded, documentation reviewed
|
||||||
notes on raylib 2.0
|
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**
|
It's been 9 month since last raylib version was published, a lots of things have changed since then... This new raylib version represents an inflexion point in the development of the library and so, we jump to a new major version... Here it is the result of almost **5 years and thousands of hours of hard work**... here it 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:
|
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.
|
**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-dependant 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!
|
**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. Undoubtly, 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!
|
**Support for continuous integration building*** through AppVeyor and Travis CI. Consequently, raylib GitHub develop branch has been removed, simplyfing 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!
|
**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!
|
**Support for TCC compiler!** Thanks to the lack of external dependencies, raylib can now be easily compiled with a **minimal toolchain**, like the one provide 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!
|
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).
|
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!
|
Probably by now, **raylib 2.0 is the simplest and easiest-to-use library to enjoy (and learn) videogames programming**... but, undoubtly its development has exceeded any initial objective; raylib has become a simple and easy-to-use trully multiplatform portable standalone media library with thousands of possibilities... and that's just the beginning!
|
||||||
|
|
||||||
notes on raylib 2.5
|
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.
|
After almost one years since latest raylib installment, here it 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 it 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.
|
New **window management and filesystem 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 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.
|
**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.
|
`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 behaviour.
|
||||||
|
|
||||||
- **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.
|
**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`.
|
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.
|
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.
|
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.
|
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.
|
**Skeletal animation support for 3d models**, this addition implied a redesign of `Model` data structure to accomodate 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.
|
This is a 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.
|
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!** :)
|
|
||||||
|
|
|
||||||
51
LICENSE.md
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
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-2019 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.
|
||||||
|
|
||||||
|
fonts
|
||||||
|
------
|
||||||
|
|
||||||
|
The following fonts [provided with raylib](https://github.com/raysan5/raylib/tree/master/examples/text/resources/fonts) 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
|
||||||
|
|
||||||
|
2d art
|
||||||
|
------
|
||||||
|
|
||||||
|
[scarfy spritesheet](https://github.com/raysan5/raylib/blob/master/examples/textures/resources/scarfy.png) and [fudesumi image](https://github.com/raysan5/raylib/blob/master/examples/textures/resources/fudesumi.png) have been created by [Eiden Marsal](https://www.artstation.com/artist/marshall_z) and are licensed as [Creative Commons Attribution-NonCommercial 3.0](https://creativecommons.org/licenses/by-nc/3.0/legalcode)
|
||||||
|
|
||||||
|
[cyberpunk street environments](https://github.com/raysan5/raylib/blob/master/examples/textures/resources) have been created by Luis Zuno ([@ansimuz](https://twitter.com/ansimuz)) and are licensed as [CC-BY-3.0](http://creativecommons.org/licenses/by/3.0/)
|
||||||
|
|
||||||
|
3d models
|
||||||
|
---------
|
||||||
|
|
||||||
|
[medieval city 3d models and textures](https://github.com/raysan5/raylib/tree/master/examples/models/resources/medieval) have been created by Alberto Cano and are licensed as [Creative Commons Attribution-NonCommercial 4.0](https://creativecommons.org/licenses/by-nc/4.0/legalcode)
|
||||||
160
README.md
|
|
@ -1,152 +1,78 @@
|
||||||
<img align="left" style="width:260px" src="https://github.com/raysan5/raylib/blob/master/logo/raylib_logo_animation.gif" width="288px">
|
<img align="left" src="https://github.com/raysan5/raylib/blob/master/logo/raylib_256x256.png" width=256>
|
||||||
|
|
||||||
**raylib is a simple and easy-to-use library to enjoy videogames programming.**
|
**raylib is a simple and easy-to-use library to enjoy videogames programming.**
|
||||||
|
|
||||||
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 highly inspired by Borland BGI graphics lib and by XNA framework and it's specially well suited for prototyping, tooling, graphical applications, embedded systems and education.
|
||||||
|
|
||||||
*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.*
|
*NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming; no fancy interface, no visual helpers, no auto-debugging... just coding in the most pure spartan-programmers way.*
|
||||||
|
|
||||||
Ready to learn? Jump to [code examples!](https://www.raylib.com/examples.html)
|
Ready to learn? Jump to [code examples!](http://www.raylib.com/examples.html)
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<br>
|
[](https://travis-ci.org/raysan5/raylib)
|
||||||
|
[](https://ci.appveyor.com/project/raysan5/raylib)
|
||||||
[](https://github.com/raysan5/raylib/releases)
|
[](https://discord.gg/VkzNHUE)
|
||||||
[](https://github.com/raysan5/raylib/stargazers)
|
[](LICENSE.md)
|
||||||
[](https://github.com/raysan5/raylib/commits/master)
|
[](https://twitter.com/raysan5)
|
||||||
[](https://github.com/sponsors/raysan5)
|
|
||||||
[](https://repology.org/project/raylib/versions)
|
|
||||||
[](LICENSE)
|
|
||||||
|
|
||||||
[](https://discord.gg/raylib)
|
|
||||||
[](https://www.reddit.com/r/raylib/)
|
|
||||||
[](https://www.youtube.com/c/raylib)
|
|
||||||
[](https://www.twitch.tv/raysan5)
|
|
||||||
|
|
||||||
[](https://github.com/raysan5/raylib/actions/workflows/build_windows.yml)
|
|
||||||
[](https://github.com/raysan5/raylib/actions/workflows/build_linux.yml)
|
|
||||||
[](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)
|
|
||||||
[](https://github.com/raysan5/raylib/actions/workflows/build_examples_windows.yml)
|
|
||||||
[](https://github.com/raysan5/raylib/actions/workflows/build_examples_linux.yml)
|
|
||||||
|
|
||||||
features
|
features
|
||||||
--------
|
--------
|
||||||
- **NO external dependencies**, all required libraries are [included into raylib](https://github.com/raysan5/raylib/tree/master/src/external)
|
- **NO external dependencies**, all required libraries are bundled into raylib
|
||||||
- Multiple platforms supported: **Windows, Linux, MacOS, RPI, Android, HTML5... and more!**
|
- Multiple platforms supported: **Windows, Linux, MacOS, Android... and many more!**
|
||||||
- Written in plain C code (C99) using PascalCase/camelCase notation
|
- Written in plain C code (C99) in PascalCase/camelCase notation
|
||||||
- Hardware accelerated with OpenGL: **1.1, 2.1, 3.3, 4.3, ES 2.0, ES 3.0**
|
- Hardware accelerated with OpenGL (**1.1, 2.1, 3.3 or ES 2.0**)
|
||||||
- **Unique OpenGL abstraction layer** (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h)
|
- **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 (XNA fonts, AngelCode fonts, TTF)
|
||||||
- Multiple **Fonts** formats supported (TTF, OTF, FNT, BDF, sprite fonts)
|
- Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC)
|
||||||
- Multiple texture formats supported, including **compressed formats** (DXT, ETC, ASTC)
|
|
||||||
- **Full 3D support**, including 3D Shapes, Models, Billboards, Heightmaps and more!
|
- **Full 3D support**, including 3D Shapes, Models, Billboards, Heightmaps and more!
|
||||||
- Flexible Materials system, supporting classic maps and **PBR maps**
|
- Flexible Materials system, supporting classic maps and **PBR maps**
|
||||||
- **Animated 3D models** supported (skeletal bones animation) (IQM, M3D, glTF)
|
- **Animated 3D models** supported (skeletal bones animation)
|
||||||
- Shaders support, including model shaders and **postprocessing** shaders
|
- Shaders support, including model and postprocessing shaders.
|
||||||
- **Powerful math module** for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h)
|
- **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)
|
- Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD)
|
||||||
- **VR stereo rendering** support with configurable HMD device parameters
|
- **VR stereo rendering** support with configurable HMD device parameters
|
||||||
- Huge examples collection with [+140 code examples](https://github.com/raysan5/raylib/tree/master/examples)!
|
- Huge examples collection with [+95 code examples](https://www.raylib.com/examples.html)!
|
||||||
- Bindings to [+70 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
|
- Bindings to [+25 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
|
||||||
- **Free and open source**
|
|
||||||
|
|
||||||
basic example
|
|
||||||
--------------
|
|
||||||
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).
|
|
||||||
```c
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
int main(void)
|
raylib uses on its [core](https://github.com/raysan5/raylib/blob/master/src/core.c) module the outstanding [GLFW3](http://www.glfw.org/) library, embedded in the form of [rglfw](https://github.com/raysan5/raylib/blob/master/src/rglfw.c) module, to avoid external dependencies.
|
||||||
{
|
|
||||||
InitWindow(800, 450, "raylib example - basic window");
|
|
||||||
|
|
||||||
while (!WindowShouldClose())
|
raylib uses on its [raudio](https://github.com/raysan5/raylib/blob/master/src/raudio.c) module, the amazing [miniaudio](https://github.com/dr-soft/miniaudio) library to support multiple platforms and multiple audio backends.
|
||||||
{
|
|
||||||
BeginDrawing();
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
|
|
||||||
EndDrawing();
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseWindow();
|
raylib uses internally multiple single-file header-only libraries to support different fileformats loading and saving, all those libraries are embedded with raylib and available in [src/external](https://github.com/raysan5/raylib/tree/master/src/external) directory. Check [raylib Wiki](https://github.com/raysan5/raylib/wiki/raylib-dependencies) for a detailed list.
|
||||||
|
|
||||||
return 0;
|
*On Android platform, `native_app_glue module` module (provided by Android NDK) and native Android libraries are used to manage window/context, inputs and activity life cycle.*
|
||||||
}
|
|
||||||
```
|
*On Raspberry Pi platform (native mode), `Videocore API` and `EGL` libraries are used for window/context management. Inputs are processed using `evdev` Linux libraries*
|
||||||
|
|
||||||
build and installation
|
build and installation
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
raylib binary releases for Windows, Linux, macOS, Android and HTML5 are available at the [Github Releases page](https://github.com/raysan5/raylib/releases).
|
Binary releases for Windows, Linux and macOS are available at the [Github Releases page](https://github.com/raysan5/raylib/releases). raylib is also available via multiple package managers on multiple OS distributions. Check [raylib Wiki](https://github.com/raysan5/raylib/wiki) for more info.
|
||||||
|
|
||||||
raylib is also available via multiple package managers on multiple OS distributions.
|
If you wish to build raylib yourself, [the raylib Wiki](https://github.com/raysan5/raylib/wiki) also contains detailed instructions on how to approach that.
|
||||||
|
|
||||||
#### Installing and building raylib on multiple platforms
|
raylib has been developed using two tools:
|
||||||
|
|
||||||
[raylib Wiki](https://github.com/raysan5/raylib/wiki#development-platforms) contains detailed instructions on building and usage on multiple platforms.
|
* Notepad++ (text editor) - [http://notepad-plus-plus.org](http://notepad-plus-plus.org/)
|
||||||
|
* MinGW (GCC compiler) - [http://www.mingw.org](http://www.mingw.org/)
|
||||||
|
|
||||||
- [Working on Windows](https://github.com/raysan5/raylib/wiki/Working-on-Windows)
|
Those are the tools recommended to enjoy raylib development.
|
||||||
- [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.*
|
contact
|
||||||
|
-------
|
||||||
|
|
||||||
#### Setup raylib with multiple IDEs
|
* Webpage: [http://www.raylib.com](http://www.raylib.com)
|
||||||
|
* Discord: [https://discord.gg/raylib](https://discord.gg/VkzNHUE)
|
||||||
|
* Twitter: [http://www.twitter.com/raysan5](http://www.twitter.com/raysan5)
|
||||||
|
* Twitch: [http://www.twitch.tv/raysan5](http://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/channel/UC8WIBkhYb5sBNqXO1mZ7WSQ)
|
||||||
|
|
||||||
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.
|
If you are using raylib and you enjoy it, please, join our [Discord server](https://discord.gg/VkzNHUE).
|
||||||
|
|
||||||
[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.
|
|
||||||
|
|
||||||
Some additional documentation about raylib design can be found in [raylib GitHub Wiki](https://github.com/raysan5/raylib/wiki). Here are the relevant links:
|
|
||||||
|
|
||||||
- [raylib cheatsheet](https://www.raylib.com/cheatsheet/cheatsheet.html)
|
|
||||||
- [raylib architecture](https://github.com/raysan5/raylib/wiki/raylib-architecture)
|
|
||||||
- [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)
|
|
||||||
|
|
||||||
|
|
||||||
contact and networks
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
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)! :)
|
|
||||||
|
|
||||||
- Webpage: [https://www.raylib.com](https://www.raylib.com)
|
|
||||||
- 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
|
|
||||||
------------
|
|
||||||
|
|
||||||
<a href="https://github.com/raysan5/raylib/graphs/contributors">
|
|
||||||
<img src="https://contrib.rocks/image?repo=raysan5/raylib&max=800&columns=24&anon=0" />
|
|
||||||
</a>
|
|
||||||
|
|
||||||
license
|
license
|
||||||
-------
|
-------
|
||||||
|
|
||||||
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.
|
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.md) for further details.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
|
||||||
67
ROADMAP.md
|
|
@ -1,63 +1,16 @@
|
||||||
# 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:
|
Here it is a wish-list with features and ideas to improve the library. Note that features listed here are quite high-level and could be long term additions for the library. Current version of raylib is complete and functional but there is a lot of room for improvement.
|
||||||
|
|
||||||
- [GitHub Issues](https://github.com/raysan5/raylib/issues) has several open issues for possible improvements or bugs to fix.
|
[raylib source code](https://github.com/raysan5/raylib/tree/master/src) has some *TODO* marks around code with pending things to review and improve.
|
||||||
- [GitHub PRs](https://github.com/raysan5/raylib/pulls) open with improvements to be reviewed.
|
Also, check [GitHub Issues](https://github.com/raysan5/raylib/issues) for further details!
|
||||||
- [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 2.x**
|
||||||
|
- [ ] rnet: raylib network module
|
||||||
**raylib 7.0**
|
- [ ] rres: raylib resource packer
|
||||||
- [ ] `rcore_desktop_win32`: Improve new Windows platform backend - inputs, highdpi
|
- [ ] rlvk: raylib Vulkan API support (GRAPHICS_API_VULKAN)
|
||||||
- [ ] `rcore_desktop_emscripten`: Improve new Web platform backend - inputs, highdpi
|
- [ ] Basic CPU/GPU stats sytem (memory, draws, time...)
|
||||||
- [ ] `rcore_desktop_cocoa`: Create additional platform backend: macOS
|
|
||||||
- [ ] `rcore_desktop_x11`: Create additional platform backend: Linux/X11
|
|
||||||
- [ ] `rcore_desktop_wayland`: Create additional platform backend: Linux/Wayland
|
|
||||||
- [ ] `rcore`: Investigate alternative embedded platforms and realtime OSs
|
|
||||||
- [ ] `rlsw`: Software renderer optimizations: mipmaps, platform-specific SIMD
|
|
||||||
- [ ] `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**
|
|
||||||
- [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**
|
|
||||||
- [x] Split core module into separate platforms?
|
|
||||||
- [x] Redesign gestures system, improve touch inputs management
|
|
||||||
- [x] Redesign camera module (more flexible) ([#1143](https://github.com/raysan5/raylib/issues/1143), https://github.com/raysan5/raylib/discussions/2507)
|
|
||||||
- [x] Better documentation and improved examples, reviewed webpage with examples complexity level
|
|
||||||
- [x] Focus on HTML5 ([raylib 5k gamejam](https://itch.io/jam/raylib-5k-gamejam)) and embedded platforms (RPI and similar SOCs)
|
|
||||||
- [x] Additional support libraries: [raygui](https://github.com/raysan5/raygui), [rres](https://github.com/raysan5/rres)
|
|
||||||
|
|
||||||
**raylib 4.0**
|
|
||||||
- [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**
|
|
||||||
- [x] Custom memory allocators support
|
|
||||||
- [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**
|
**raylib 2.5**
|
||||||
- [x] Support Animated models
|
- [x] Support Animated models
|
||||||
|
|
|
||||||
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._
|
|
||||||
65
appveyor.yml
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
#os: Visual Studio 2015
|
||||||
|
|
||||||
|
clone_depth: 5
|
||||||
|
|
||||||
|
cache:
|
||||||
|
- C:\ProgramData\chocolatey\bin -> appveyor.yml
|
||||||
|
- C:\ProgramData\chocolatey\lib -> appveyor.yml
|
||||||
|
|
||||||
|
init:
|
||||||
|
- cmake -E remove c:\programdata\chocolatey\bin\cpack.exe
|
||||||
|
- set PATH=%PATH:C:\Program Files (x86)\Git\usr\bin;=%
|
||||||
|
- set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
|
||||||
|
- if [%BITS%]==[32] set MINGW=C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1\mingw32
|
||||||
|
- if [%BITS%]==[64] set MINGW=C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64
|
||||||
|
- if [%COMPILER%]==[mingw] set PATH=%MINGW%\bin;%PATH%
|
||||||
|
- set RAYLIB_PACKAGE_SUFFIX=-Win%BITS%-%COMPILER%
|
||||||
|
- set VERBOSE=1
|
||||||
|
|
||||||
|
environment:
|
||||||
|
matrix:
|
||||||
|
- compiler: mingw
|
||||||
|
bits: 32
|
||||||
|
examples: ON
|
||||||
|
- compiler: mingw
|
||||||
|
bits: 64
|
||||||
|
examples: ON
|
||||||
|
- compiler: msvc15
|
||||||
|
bits: 32
|
||||||
|
examples: OFF
|
||||||
|
- compiler: msvc15
|
||||||
|
bits: 64
|
||||||
|
examples: OFF
|
||||||
|
|
||||||
|
before_build:
|
||||||
|
- if [%compiler%]==[mingw] set CFLAGS=-m%BITS% & set LDFLAGS=-m%BITS% & set GENERATOR="MinGW Makefiles"
|
||||||
|
- if [%COMPILER%]==[msvc15] if [%BITS%]==[32] set GENERATOR="Visual Studio 14 2015"
|
||||||
|
- if [%COMPILER%]==[msvc15] if [%BITS%]==[64] set GENERATOR="Visual Studio 14 2015 Win64"
|
||||||
|
- mkdir build
|
||||||
|
- cd build
|
||||||
|
|
||||||
|
build_script:
|
||||||
|
- cmake -G %GENERATOR% -DSTATIC=ON -DSHARED=ON -DBUILD_EXAMPLES=%examples% -DBUILD_GAMES=%examples% -DINCLUDE_EVERYTHING=ON ..
|
||||||
|
- cmake --build . --target install
|
||||||
|
|
||||||
|
after_build:
|
||||||
|
- cmake --build . --target package
|
||||||
|
|
||||||
|
before_test:
|
||||||
|
|
||||||
|
test_script:
|
||||||
|
|
||||||
|
artifacts:
|
||||||
|
- path: 'build\*.zip'
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
- provider: GitHub
|
||||||
|
auth_token:
|
||||||
|
secure: OxKnnT3tlkPl9365cOO84rDWU4UkHIYJc0D3r3Tv7rB3HaR2BBhlhCnl7g3nuOJy
|
||||||
|
artifact: /.*\.zip/
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
force_update: true
|
||||||
|
on:
|
||||||
|
branch: master
|
||||||
|
appveyor_repo_tag: true # deploy on tag push only
|
||||||
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",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
43
cmake/BuildType.cmake
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
# Set a default build type if none was specified
|
||||||
|
set(default_build_type "Release")
|
||||||
|
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||||
|
set(default_build_type "Debug")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||||
|
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
|
||||||
|
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
|
||||||
|
STRING "Choose the type of build." FORCE)
|
||||||
|
# Set the possible values of build type for cmake-gui
|
||||||
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
|
||||||
|
"MinSizeRel" "RelWithDebInfo")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Taken from the https://github.com/OpenChemistry/tomviz project
|
||||||
|
# Copyright (c) 2014-2017, Kitware, Inc.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
# list of conditions and the following disclaimer.
|
||||||
|
#
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
# this list of conditions and the following disclaimer in the documentation
|
||||||
|
# and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# 3. Neither the name of the copyright holder nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software
|
||||||
|
# without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
13
cmake/CheckFileSystemSymlinkSupport.cmake
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Populates a ${FILESYSTEM_LACKS_SYMLINKS} variable
|
||||||
|
message(STATUS "Testing if file system supports symlinks")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E create_symlink CMakeLists.txt "${CMAKE_CURRENT_BINARY_DIR}/TestingIfSymlinkWorks"
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
RESULT_VARIABLE FILESYSTEM_LACKS_SYMLINKS
|
||||||
|
)
|
||||||
|
If (FILESYSTEM_LACKS_SYMLINKS)
|
||||||
|
message(STATUS "Testing if file system supports symlinks -- unsupported")
|
||||||
|
else()
|
||||||
|
message(STATUS "Testing if file system supports symlinks -- supported")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
@ -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,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,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,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()
|
|
||||||
15
cmake/emscripten.cmake
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
SET(CMAKE_SYSTEM_NAME Linux)
|
||||||
|
|
||||||
|
SET(CMAKE_C_COMPILER emcc)
|
||||||
|
SET(CMAKE_CXX_COMPILER em++)
|
||||||
|
if(NOT DEFINED CMAKE_AR)
|
||||||
|
find_program(CMAKE_AR NAMES emar)
|
||||||
|
endif()
|
||||||
|
if(NOT DEFINED CMAKE_RANLIB)
|
||||||
|
find_program(CMAKE_RANLIB NAMES emranlib)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||||
|
|
@ -1,4 +1,75 @@
|
||||||
@PACKAGE_INIT@
|
# - Try to find raylib
|
||||||
@RAYLIB_DEPENDENCIES@
|
# Options:
|
||||||
|
# raylib_USE_STATIC_LIBS - OFF by default
|
||||||
|
# raylib_VERBOSE - OFF by default
|
||||||
|
# Once done, this defines a raylib target that can be passed to
|
||||||
|
# target_link_libraries as well as following variables:
|
||||||
|
#
|
||||||
|
# raylib_FOUND - System has raylib installed
|
||||||
|
# raylib_INCLUDE_DIRS - The include directories for the raylib header(s)
|
||||||
|
# raylib_LIBRARIES - The libraries needed to use raylib
|
||||||
|
# raylib_LDFLAGS - The linker flags needed with raylib
|
||||||
|
# raylib_DEFINITIONS - Compiler switches required for using raylib
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/raylib-targets.cmake")
|
set(XPREFIX PC_RAYLIB)
|
||||||
|
if (raylib_USE_STATIC_LIBS)
|
||||||
|
set(XPREFIX ${XPREFIX}_STATIC)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
pkg_check_modules(${XPREFIX} QUIET raylib)
|
||||||
|
set(raylib_DEFINITIONS ${${XPREFIX}_CFLAGS})
|
||||||
|
|
||||||
|
find_path(raylib_INCLUDE_DIR
|
||||||
|
NAMES raylib.h
|
||||||
|
HINTS ${${XPREFIX}_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
if (raylib_USE_STATIC_LIBS)
|
||||||
|
find_library(raylib_LIBRARY
|
||||||
|
NAMES raylib_static
|
||||||
|
HINTS ${${XPREFIX}_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
else ()
|
||||||
|
find_library(raylib_LIBRARY
|
||||||
|
NAMES raylib
|
||||||
|
HINTS ${${XPREFIX}_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(raylib_LIBRARIES ${raylib_LIBRARY})
|
||||||
|
set(raylib_LIBRARY_DIRS ${${XPREFIX}_LIBRARY_DIRS})
|
||||||
|
set(raylib_LIBRARY_DIR ${raylib_LIBRARY_DIRS})
|
||||||
|
set(raylib_INCLUDE_DIRS ${raylib_INCLUDE_DIR})
|
||||||
|
set(raylib_LDFLAGS ${${XPREFIX}_LDFLAGS})
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(raylib DEFAULT_MSG
|
||||||
|
raylib_LIBRARY
|
||||||
|
raylib_INCLUDE_DIR
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(raylib_LIBRARY raylib_INCLUDE_DIR)
|
||||||
|
|
||||||
|
if (raylib_USE_STATIC_LIBS)
|
||||||
|
add_library(raylib STATIC IMPORTED GLOBAL)
|
||||||
|
else()
|
||||||
|
add_library(raylib SHARED IMPORTED GLOBAL)
|
||||||
|
endif()
|
||||||
|
string (REPLACE ";" " " raylib_LDFLAGS "${raylib_LDFLAGS}")
|
||||||
|
|
||||||
|
set_target_properties(raylib
|
||||||
|
PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${raylib_LIBRARIES}"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${raylib_INCLUDE_DIRS}"
|
||||||
|
INTERFACE_LINK_LIBRARIES "${raylib_LDFLAGS}"
|
||||||
|
INTERFACE_COMPILE_OPTIONS "${raylib_DEFINITIONS}"
|
||||||
|
)
|
||||||
|
|
||||||
|
if (raylib_VERBOSE)
|
||||||
|
message(STATUS "raylib_FOUND: ${raylib_FOUND}")
|
||||||
|
message(STATUS "raylib_INCLUDE_DIRS: ${raylib_INCLUDE_DIRS}")
|
||||||
|
message(STATUS "raylib_LIBRARIES: ${raylib_LIBRARIES}")
|
||||||
|
message(STATUS "raylib_LDFLAGS: ${raylib_LDFLAGS}")
|
||||||
|
message(STATUS "raylib_DEFINITIONS: ${raylib_DEFINITIONS}")
|
||||||
|
endif()
|
||||||
|
|
|
||||||
21
cmake/test-pkgconfig.sh
Executable file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Test if including/linking/running an installed raylib works
|
||||||
|
|
||||||
|
set -x
|
||||||
|
export LD_RUN_PATH=/usr/local/lib
|
||||||
|
|
||||||
|
CFLAGS="-Wall -Wextra -Werror $CFLAGS"
|
||||||
|
if [ "$ARCH" = "i386" ]; then
|
||||||
|
CFLAGS="-m32 $CLFAGS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat << EOF | ${CC:-cc} -otest -xc - $(pkg-config --libs --cflags $@ raylib.pc) $CFLAGS && exec ./test
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <raylib.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int num = GetRandomValue(42, 1337);
|
||||||
|
return 42 <= num && num <= 1337 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
@ -1,30 +1,36 @@
|
||||||
# Setup the project and settings
|
# Setup the project and settings
|
||||||
project(examples)
|
project(examples)
|
||||||
|
|
||||||
# Directories that contain examples
|
# Get the sources together
|
||||||
set(example_dirs
|
set(example_dirs audio core models others shaders shapes text textures)
|
||||||
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)
|
set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=199309L)
|
||||||
include(CheckSymbolExists)
|
include(CheckSymbolExists)
|
||||||
check_symbol_exists(CLOCK_MONOTONIC time.h HAVE_CLOCK_MONOTONIC)
|
check_symbol_exists(CLOCK_MONOTONIC time.h HAVE_CLOCK_MONOTONIC)
|
||||||
check_symbol_exists(QueryPerformanceCounter windows.h HAVE_QPC)
|
check_symbol_exists(QueryPerformanceCounter windows.h HAVE_QPC)
|
||||||
set(CMAKE_REQUIRED_DEFINITIONS)
|
set(CMAKE_REQUIRED_DEFINITIONS)
|
||||||
|
|
||||||
if(HAVE_QPC OR HAVE_CLOCK_MONOTONIC)
|
if(HAVE_QPC OR HAVE_CLOCK_MONOTONIC)
|
||||||
set(example_dirs ${example_dirs} physac)
|
set(example_dirs ${example_dirs} physac)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
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 (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()
|
||||||
|
set(OUTPUT_EXT)
|
||||||
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
|
||||||
|
|
||||||
include(CheckIncludeFile)
|
include(CheckIncludeFile)
|
||||||
CHECK_INCLUDE_FILE("stdatomic.h" HAVE_STDATOMIC_H)
|
CHECK_INCLUDE_FILE("stdatomic.h" HAVE_STDATOMIC_H)
|
||||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||||
|
|
@ -37,32 +43,12 @@ if (CMAKE_USE_PTHREADS_INIT AND HAVE_STDATOMIC_H)
|
||||||
if(CMAKE_THREAD_LIBS_INIT)
|
if(CMAKE_THREAD_LIBS_INIT)
|
||||||
link_libraries("${CMAKE_THREAD_LIBS_INIT}")
|
link_libraries("${CMAKE_THREAD_LIBS_INIT}")
|
||||||
endif()
|
endif()
|
||||||
endif ()
|
else()
|
||||||
|
|
||||||
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
|
# Items requiring pthreads
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_loading_thread.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_loading_thread.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(${PLATFORM} MATCHES "Android")
|
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/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}/others/standard_lighting.c)
|
||||||
|
|
@ -73,6 +59,7 @@ if (${PLATFORM} MATCHES "Android")
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_world_screen.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_mesh_picking.c)
|
||||||
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_material_pbr.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_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_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_picking.c)
|
||||||
|
|
@ -80,64 +67,24 @@ if (${PLATFORM} MATCHES "Android")
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_heightmap.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_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_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_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_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_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_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_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_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_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_palette_switch.c)
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_basic_lighting.c)
|
|
||||||
|
|
||||||
elseif(${PLATFORM} MATCHES "Web")
|
elseif(${PLATFORM} MATCHES "Web")
|
||||||
set(example_sources) # clear example_sources
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1")
|
||||||
list(APPEND example_sources core/core_input_gestures_testbed.c)
|
# Since WASM is used, ALLOW_MEMORY_GROWTH has no extra overheads
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ALLOW_MEMORY_GROWTH=1 --no-heap-copy")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shell-file ${CMAKE_SOURCE_DIR}/src/shell.html")
|
||||||
|
|
||||||
elseif ("${PLATFORM}" STREQUAL "DRM")
|
set(OUTPUT_EXT ".html")
|
||||||
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()
|
endif()
|
||||||
|
|
||||||
include_directories(BEFORE SYSTEM others/external/include)
|
include_directories(BEFORE SYSTEM others/external/include)
|
||||||
|
|
@ -150,61 +97,36 @@ endif ()
|
||||||
foreach(example_source ${example_sources})
|
foreach(example_source ${example_sources})
|
||||||
# Create the basename for the example
|
# Create the basename for the example
|
||||||
get_filename_component(example_name ${example_source} NAME)
|
get_filename_component(example_name ${example_source} NAME)
|
||||||
string(REPLACE ".c" "" example_name ${example_name})
|
string(REPLACE ".c" "${OUTPUT_EXT}" example_name ${example_name})
|
||||||
|
|
||||||
# Setup the example
|
# Setup the example
|
||||||
add_executable(${example_name} ${example_source})
|
add_executable(${example_name} ${example_source})
|
||||||
|
|
||||||
target_link_libraries(${example_name} raylib)
|
target_link_libraries(${example_name} raylib)
|
||||||
if (NOT WIN32)
|
|
||||||
target_link_libraries(${example_name} m)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
string(REGEX MATCH ".*/.*/" resources_dir ${example_source})
|
string(REGEX MATCH ".*/.*/" resources_dir ${example_source})
|
||||||
string(APPEND resources_dir "resources")
|
string(APPEND resources_dir "resources")
|
||||||
|
|
||||||
if (${PLATFORM} MATCHES "Web")
|
if(${PLATFORM} MATCHES "Web" AND EXISTS ${resources_dir})
|
||||||
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
|
# The local resources path needs to be mapped to /resources virtual path
|
||||||
string(APPEND resources_dir "@resources")
|
string(APPEND resources_dir "@resources")
|
||||||
set_target_properties(${example_name} PROPERTIES LINK_FLAGS "--preload-file ${resources_dir}")
|
set_target_properties(${example_name} PROPERTIES LINK_FLAGS "--preload-file ${resources_dir}")
|
||||||
endif()
|
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()
|
endforeach()
|
||||||
|
|
||||||
|
if (${PLATFORM} MATCHES "Desktop")
|
||||||
|
# rlgl_standalone can't be linked with raylib because of duplicate rlgl symbols
|
||||||
|
foreach (example_source "others/rlgl_standalone.c")
|
||||||
|
# Create the basename for the example
|
||||||
|
get_filename_component(example_name ${example_source} NAME)
|
||||||
|
string(REPLACE ".c" "${OUTPUT_EXT}" example_name ${example_name})
|
||||||
|
add_executable(${example_name} ${example_source})
|
||||||
|
add_dependencies(${example_name} raylib)
|
||||||
|
target_link_libraries(${example_name} ${raylib_LDFLAGS})
|
||||||
|
target_include_directories(${example_name} PRIVATE ${raylib_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
# Copy all of the resource files to the destination
|
# Copy all of the resource files to the destination
|
||||||
file(COPY ${example_resources} DESTINATION "resources/")
|
file(COPY ${example_resources} DESTINATION "resources/")
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# raylib makefile for Android project (APK building)
|
# raylib makefile for Android project (APK building)
|
||||||
#
|
#
|
||||||
# Copyright (c) 2017-2026 Ramon Santamaria (@raysan5)
|
# Copyright (c) 2017 Ramon Santamaria (@raysan5)
|
||||||
#
|
#
|
||||||
# This software is provided "as-is", without any express or implied warranty. In no event
|
# 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.
|
# will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
|
@ -26,49 +26,29 @@ PLATFORM ?= PLATFORM_ANDROID
|
||||||
RAYLIB_PATH ?= ..\..
|
RAYLIB_PATH ?= ..\..
|
||||||
|
|
||||||
# Define Android architecture (armeabi-v7a, arm64-v8a, x86, x86-64) and API version
|
# Define Android architecture (armeabi-v7a, arm64-v8a, x86, x86-64) and API version
|
||||||
# Starting in 2019 using ARM64 is mandatory for published apps,
|
ANDROID_ARCH ?= ARM
|
||||||
# Starting on August 2020, minimum required target API is Android 10 (API level 29)
|
ANDROID_API_VERSION = 21
|
||||||
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)
|
ifeq ($(ANDROID_ARCH),ARM)
|
||||||
ANDROID_ARCH_NAME = armeabi-v7a
|
ANDROID_ARCH_NAME = armeabi-v7a
|
||||||
endif
|
endif
|
||||||
ifeq ($(ANDROID_ARCH),ARM64)
|
ifeq ($(ANDROID_ARCH),ARM64)
|
||||||
ANDROID_ARCH_NAME = arm64-v8a
|
ANDROID_ARCH_NAME = arm64-v8a
|
||||||
endif
|
endif
|
||||||
ifeq ($(ANDROID_ARCH),x86)
|
|
||||||
ANDROID_ARCH_NAME = x86
|
|
||||||
endif
|
|
||||||
ifeq ($(ANDROID_ARCH),x86_64)
|
|
||||||
ANDROID_ARCH_NAME = x86_64
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Required path variables
|
# Required path variables
|
||||||
# NOTE: JAVA_HOME must be set to JDK (using OpenJDK 13)
|
# NOTE: JAVA_HOME must be set to JDK
|
||||||
JAVA_HOME ?= C:/open-jdk
|
JAVA_HOME ?= C:/JavaJDK
|
||||||
ANDROID_HOME ?= C:/android-sdk
|
ANDROID_HOME = C:/android-sdk
|
||||||
ANDROID_BUILD_TOOLS ?= $(ANDROID_HOME)/build-tools/29.0.3
|
ANDROID_TOOLCHAIN = C:/android_toolchain_$(ANDROID_ARCH)_API$(ANDROID_API_VERSION)
|
||||||
|
ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/28.0.1
|
||||||
ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools
|
ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools
|
||||||
|
|
||||||
# Android project configuration variables
|
# Android project configuration variables
|
||||||
PROJECT_NAME ?= raylib_game
|
PROJECT_NAME ?= raylib_game
|
||||||
PROJECT_LIBRARY_NAME ?= main
|
PROJECT_LIBRARY_NAME ?= main
|
||||||
PROJECT_BUILD_ID ?= android
|
PROJECT_BUILD_PATH ?= android.$(PROJECT_NAME)
|
||||||
PROJECT_BUILD_PATH ?= $(PROJECT_BUILD_ID).$(PROJECT_NAME)
|
|
||||||
PROJECT_RESOURCES_PATH ?= resources
|
PROJECT_RESOURCES_PATH ?= resources
|
||||||
PROJECT_SOURCE_FILES ?= raylib_game.c
|
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
|
# Some source files are placed in directories, when compiling to some
|
||||||
# output directory other than source, that directory must pre-exist.
|
# output directory other than source, that directory must pre-exist.
|
||||||
|
|
@ -82,9 +62,9 @@ APP_COMPANY_NAME ?= raylib
|
||||||
APP_PRODUCT_NAME ?= rgame
|
APP_PRODUCT_NAME ?= rgame
|
||||||
APP_VERSION_CODE ?= 1
|
APP_VERSION_CODE ?= 1
|
||||||
APP_VERSION_NAME ?= 1.0
|
APP_VERSION_NAME ?= 1.0
|
||||||
APP_ICON_LDPI ?= $(RAYLIB_PATH)/logo/raylib_36x36.png
|
APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png
|
||||||
APP_ICON_MDPI ?= $(RAYLIB_PATH)/logo/raylib_48x48.png
|
APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png
|
||||||
APP_ICON_HDPI ?= $(RAYLIB_PATH)/logo/raylib_72x72.png
|
APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png
|
||||||
APP_SCREEN_ORIENTATION ?= landscape
|
APP_SCREEN_ORIENTATION ?= landscape
|
||||||
APP_KEYSTORE_PASS ?= raylib
|
APP_KEYSTORE_PASS ?= raylib
|
||||||
|
|
||||||
|
|
@ -92,14 +72,7 @@ APP_KEYSTORE_PASS ?= raylib
|
||||||
RAYLIB_LIBTYPE ?= STATIC
|
RAYLIB_LIBTYPE ?= STATIC
|
||||||
|
|
||||||
# Library path for libraylib.a/libraylib.so
|
# Library path for libraylib.a/libraylib.so
|
||||||
RAYLIB_LIB_PATH = $(RAYLIB_PATH)/src
|
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
|
# Shared libs must be added to APK if required
|
||||||
# NOTE: Generated NativeLoader.java automatically load those libraries
|
# NOTE: Generated NativeLoader.java automatically load those libraries
|
||||||
|
|
@ -108,29 +81,22 @@ ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Compiler and archiver
|
# Compiler and archiver
|
||||||
|
# NOTE: GCC is being deprecated in Android NDK r16
|
||||||
ifeq ($(ANDROID_ARCH),ARM)
|
ifeq ($(ANDROID_ARCH),ARM)
|
||||||
CC = $(ANDROID_TOOLCHAIN)/bin/armv7a-linux-androideabi$(ANDROID_API_VERSION)-clang
|
CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-clang
|
||||||
AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar
|
AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar
|
||||||
endif
|
endif
|
||||||
ifeq ($(ANDROID_ARCH),ARM64)
|
ifeq ($(ANDROID_ARCH),ARM64)
|
||||||
CC = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android$(ANDROID_API_VERSION)-clang
|
CC = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-clang
|
||||||
AR = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-ar
|
AR = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-ar
|
||||||
endif
|
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
|
# Compiler flags for arquitecture
|
||||||
ifeq ($(ANDROID_ARCH),ARM)
|
ifeq ($(ANDROID_ARCH),ARM)
|
||||||
CFLAGS = -std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
|
CFLAGS = -std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
|
||||||
endif
|
endif
|
||||||
ifeq ($(ANDROID_ARCH),ARM64)
|
ifeq ($(ANDROID_ARCH),ARM64)
|
||||||
CFLAGS = -std=c99 -mfix-cortex-a53-835769
|
CFLAGS = -std=c99 -target aarch64 -mfix-cortex-a53-835769
|
||||||
endif
|
endif
|
||||||
# Compilation functions attributes options
|
# Compilation functions attributes options
|
||||||
CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC
|
CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC
|
||||||
|
|
@ -140,7 +106,7 @@ CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical
|
||||||
CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION)
|
CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION)
|
||||||
|
|
||||||
# Paths containing required header files
|
# Paths containing required header files
|
||||||
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(NATIVE_APP_GLUE_PATH)
|
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external/android/native_app_glue
|
||||||
|
|
||||||
# Linker options
|
# Linker options
|
||||||
LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a
|
LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a
|
||||||
|
|
@ -158,8 +124,7 @@ LDLIBS = -lm -lc -lraylib -llog -landroid -lEGL -lGLESv2 -lOpenSLES -ldl
|
||||||
OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES))
|
OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES))
|
||||||
|
|
||||||
# Android APK building process... some steps required...
|
# Android APK building process... some steps required...
|
||||||
# NOTE: typing 'make' will invoke the default target entry called 'all'
|
# 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 \
|
all: create_temp_project_dirs \
|
||||||
copy_project_required_libs \
|
copy_project_required_libs \
|
||||||
copy_project_resources \
|
copy_project_resources \
|
||||||
|
|
@ -174,18 +139,10 @@ all: create_temp_project_dirs \
|
||||||
sign_project_apk_package \
|
sign_project_apk_package \
|
||||||
zipalign_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 required temp directories for APK building
|
||||||
create_temp_project_dirs:
|
create_temp_project_dirs:
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
if not exist $(PROJECT_BUILD_PATH) mkdir $(PROJECT_BUILD_PATH)
|
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
|
||||||
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 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 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) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)
|
||||||
|
|
@ -201,62 +158,36 @@ ifeq ($(OS),Windows_NT)
|
||||||
if not exist $(PROJECT_BUILD_PATH)\assets mkdir $(PROJECT_BUILD_PATH)\assets
|
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)\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
|
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)))
|
$(foreach dir, $(PROJECT_SOURCE_DIRS), $(call create_dir, $(dir)))
|
||||||
|
|
||||||
define create_dir
|
define create_dir
|
||||||
mkdir -p $(PROJECT_BUILD_PATH)/obj/$(1)
|
if not exist $(PROJECT_BUILD_PATH)\obj\$(1) mkdir $(PROJECT_BUILD_PATH)\obj\$(1)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# Copy required shared libs for integration into APK
|
# Copy required shared libs for integration into APK
|
||||||
# NOTE: If using shared libs they are loaded by generated NativeLoader.java
|
# NOTE: If using shared libs they are loaded by generated NativeLoader.java
|
||||||
copy_project_required_libs:
|
copy_project_required_libs:
|
||||||
ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
||||||
$(COPY_COMMAND) $(RAYLIB_LIB_PATH)/libraylib.so $(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME)/libraylib.so
|
copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.so
|
||||||
endif
|
endif
|
||||||
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
||||||
$(COPY_COMMAND) $(RAYLIB_LIB_PATH)/libraylib.a $(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME)/libraylib.a
|
copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.a
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Copy project required resources: strings.xml, icon.png, assets
|
# Copy project required resources: strings.xml, icon.png, assets
|
||||||
# NOTE: Required strings.xml is generated and game resources are copied to assets folder
|
# NOTE: Required strings.xml is generated and game resources are copied to assets folder
|
||||||
|
# TODO: Review xcopy usage, it can not be found in some systems!
|
||||||
copy_project_resources:
|
copy_project_resources:
|
||||||
$(COPY_COMMAND) $(APP_ICON_LDPI) $(PROJECT_BUILD_PATH)/res/drawable-ldpi/icon.png
|
copy $(APP_ICON_LDPI) $(PROJECT_BUILD_PATH)\res\drawable-ldpi\icon.png /Y
|
||||||
$(COPY_COMMAND) $(APP_ICON_MDPI) $(PROJECT_BUILD_PATH)/res/drawable-mdpi/icon.png
|
copy $(APP_ICON_MDPI) $(PROJECT_BUILD_PATH)\res\drawable-mdpi\icon.png /Y
|
||||||
$(COPY_COMMAND) $(APP_ICON_HDPI) $(PROJECT_BUILD_PATH)/res/drawable-hdpi/icon.png
|
copy $(APP_ICON_HDPI) $(PROJECT_BUILD_PATH)\res\drawable-hdpi\icon.png /Y
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
@echo ^<?xml version="1.0" encoding="utf-8"^?^> > $(PROJECT_BUILD_PATH)/res/values/strings.xml
|
@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
|
@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
|
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
|
# Generate NativeLoader.java to load required shared libraries
|
||||||
# NOTE: Probably not the bet way to generate this file... but it works.
|
# NOTE: Probably not the bet way to generate this file... but it works.
|
||||||
generate_loader_script:
|
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 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. >> $(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 public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
||||||
|
|
@ -267,23 +198,10 @@ endif
|
||||||
@echo System.loadLibrary("$(PROJECT_LIBRARY_NAME)"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
@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
|
||||||
@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
|
# Generate AndroidManifest.xml with all the required options
|
||||||
# NOTE: Probably not the bet way to generate this file... but it works.
|
# NOTE: Probably not the bet way to generate this file... but it works.
|
||||||
generate_android_manifest:
|
generate_android_manifest:
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
@echo ^<?xml version="1.0" encoding="utf-8"^?^> > $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
@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 ^<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 package="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME)" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||||
|
|
@ -304,37 +222,11 @@ ifeq ($(OS),Windows_NT)
|
||||||
@echo ^</activity^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
@echo ^</activity^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||||
@echo ^</application^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
@echo ^</application^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||||
@echo ^</manifest^> >> $(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
|
# Generate storekey for APK signing: $(PROJECT_NAME).keystore
|
||||||
# NOTE: Configure here your Distinguished Names (-dname) if required!
|
# NOTE: Configure here your Distinguished Names (-dname) if required!
|
||||||
generate_apk_keystore:
|
generate_apk_keystore:
|
||||||
ifeq ($(OS),Windows_NT)
|
if not exist $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -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
|
||||||
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
|
# 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
|
# NOTE: Generates resources file: src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java
|
||||||
|
|
@ -343,7 +235,7 @@ config_project_package:
|
||||||
|
|
||||||
# Compile native_app_glue code as static library: obj/libnative_app_glue.a
|
# Compile native_app_glue code as static library: obj/libnative_app_glue.a
|
||||||
compile_native_app_glue:
|
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)
|
$(CC) -c $(RAYLIB_PATH)/src/external/android/native_app_glue/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
|
$(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 into a shared library: lib/lib$(PROJECT_LIBRARY_NAME).so
|
||||||
|
|
@ -357,7 +249,7 @@ $(PROJECT_BUILD_PATH)/obj/%.o:%.c
|
||||||
|
|
||||||
# Compile project .java code into .class (Java bytecode)
|
# Compile project .java code into .class (Java bytecode)
|
||||||
compile_project_class:
|
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
|
$(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;$(PROJECT_BUILD_PATH)/obj -sourcepath $(PROJECT_BUILD_PATH)/src $(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)
|
# Compile .class files into Dalvik executable bytecode (.dex)
|
||||||
# NOTE: Since Android 5.0, Dalvik interpreter (JIT) has been replaced by ART (AOT)
|
# NOTE: Since Android 5.0, Dalvik interpreter (JIT) has been replaced by ART (AOT)
|
||||||
|
|
@ -382,7 +274,7 @@ zipalign_project_apk_package:
|
||||||
# Install $(PROJECT_NAME).apk to default emulator/device
|
# Install $(PROJECT_NAME).apk to default emulator/device
|
||||||
# NOTE: Use -e (emulator) or -d (device) parameters if required
|
# NOTE: Use -e (emulator) or -d (device) parameters if required
|
||||||
install:
|
install:
|
||||||
$(ANDROID_PLATFORM_TOOLS)/adb install $(PROJECT_NAME).apk
|
$(ANDROID_PLATFORM_TOOLS)/adb install --abi $(ANDROID_ARCH_NAME) -rds $(PROJECT_NAME).apk
|
||||||
|
|
||||||
# Check supported ABI for the device (armeabi-v7a, arm64-v8a, x86, x86_64)
|
# Check supported ABI for the device (armeabi-v7a, arm64-v8a, x86, x86_64)
|
||||||
check_device_abi:
|
check_device_abi:
|
||||||
|
|
@ -395,7 +287,7 @@ logcat:
|
||||||
|
|
||||||
# Install and monitorize $(PROJECT_NAME).apk to default emulator/device
|
# Install and monitorize $(PROJECT_NAME).apk to default emulator/device
|
||||||
deploy:
|
deploy:
|
||||||
$(ANDROID_PLATFORM_TOOLS)/adb install $(PROJECT_NAME).apk
|
$(ANDROID_PLATFORM_TOOLS)/adb install -r $(PROJECT_NAME).apk
|
||||||
$(ANDROID_PLATFORM_TOOLS)/adb logcat -c
|
$(ANDROID_PLATFORM_TOOLS)/adb logcat -c
|
||||||
$(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S
|
$(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S
|
||||||
|
|
||||||
|
|
@ -403,10 +295,6 @@ deploy:
|
||||||
|
|
||||||
# Clean everything
|
# Clean everything
|
||||||
clean:
|
clean:
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
del $(PROJECT_BUILD_PATH)\* /f /s /q
|
del $(PROJECT_BUILD_PATH)\* /f /s /q
|
||||||
rmdir $(PROJECT_BUILD_PATH) /s /q
|
rmdir $(PROJECT_BUILD_PATH) /s /q
|
||||||
else
|
|
||||||
rm -r $(PROJECT_BUILD_PATH)
|
|
||||||
endif
|
|
||||||
@echo Cleaning done
|
@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,15 +1,13 @@
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [audio] example - module playing
|
* raylib [audio] example - Module playing (streaming)
|
||||||
*
|
*
|
||||||
* Example complexity rating: [★☆☆☆] 1/4
|
* NOTE: This example requires OpenAL Soft library installed
|
||||||
*
|
*
|
||||||
* Example originally created with raylib 1.5, last time updated with raylib 3.5
|
* This example has been created using raylib 1.5 (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) 2016 Ramon Santamaria (@raysan5)
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2016-2025 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
|
@ -25,9 +23,6 @@ typedef struct {
|
||||||
Color color;
|
Color color;
|
||||||
} CircleWave;
|
} CircleWave;
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
|
|
@ -37,31 +32,29 @@ int main(void)
|
||||||
|
|
||||||
SetConfigFlags(FLAG_MSAA_4X_HINT); // NOTE: Try to enable MSAA 4X
|
SetConfigFlags(FLAG_MSAA_4X_HINT); // NOTE: Try to enable MSAA 4X
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing");
|
InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing (streaming)");
|
||||||
|
|
||||||
InitAudioDevice(); // Initialize audio device
|
InitAudioDevice(); // Initialize audio device
|
||||||
|
|
||||||
Color colors[14] = { ORANGE, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK,
|
Color colors[14] = { ORANGE, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK,
|
||||||
YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE };
|
YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE };
|
||||||
|
|
||||||
// Creates some circles for visual effect
|
// Creates ome circles for visual effect
|
||||||
CircleWave circles[MAX_CIRCLES] = { 0 };
|
CircleWave circles[MAX_CIRCLES] = { 0 };
|
||||||
|
|
||||||
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
|
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
circles[i].alpha = 0.0f;
|
circles[i].alpha = 0.0f;
|
||||||
circles[i].radius = (float)GetRandomValue(10, 40);
|
circles[i].radius = GetRandomValue(10, 40);
|
||||||
circles[i].position.x = (float)GetRandomValue((int)circles[i].radius, (int)(screenWidth - circles[i].radius));
|
circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius);
|
||||||
circles[i].position.y = (float)GetRandomValue((int)circles[i].radius, (int)(screenHeight - circles[i].radius));
|
circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius);
|
||||||
circles[i].speed = (float)GetRandomValue(1, 100)/2000.0f;
|
circles[i].speed = (float)GetRandomValue(1, 100)/20000.0f;
|
||||||
circles[i].color = colors[GetRandomValue(0, 13)];
|
circles[i].color = colors[GetRandomValue(0, 13)];
|
||||||
}
|
}
|
||||||
|
|
||||||
Music music = LoadMusicStream("resources/mini1111.xm");
|
Music xm = LoadMusicStream("resources/chiptun1.mod");
|
||||||
music.looping = false;
|
|
||||||
float pitch = 1.0f;
|
|
||||||
|
|
||||||
PlayMusicStream(music);
|
PlayMusicStream(xm);
|
||||||
|
|
||||||
float timePlayed = 0.0f;
|
float timePlayed = 0.0f;
|
||||||
bool pause = false;
|
bool pause = false;
|
||||||
|
|
@ -74,14 +67,13 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
UpdateMusicStream(music); // Update music buffer with new stream data
|
UpdateMusicStream(xm); // Update music buffer with new stream data
|
||||||
|
|
||||||
// Restart music playing (stop and play)
|
// Restart music playing (stop and play)
|
||||||
if (IsKeyPressed(KEY_SPACE))
|
if (IsKeyPressed(KEY_SPACE))
|
||||||
{
|
{
|
||||||
StopMusicStream(music);
|
StopMusicStream(xm);
|
||||||
PlayMusicStream(music);
|
PlayMusicStream(xm);
|
||||||
pause = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pause/Resume music playing
|
// Pause/Resume music playing
|
||||||
|
|
@ -89,17 +81,12 @@ int main(void)
|
||||||
{
|
{
|
||||||
pause = !pause;
|
pause = !pause;
|
||||||
|
|
||||||
if (pause) PauseMusicStream(music);
|
if (pause) PauseMusicStream(xm);
|
||||||
else ResumeMusicStream(music);
|
else ResumeMusicStream(xm);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsKeyDown(KEY_DOWN)) pitch -= 0.01f;
|
|
||||||
else if (IsKeyDown(KEY_UP)) pitch += 0.01f;
|
|
||||||
|
|
||||||
SetMusicPitch(music, pitch);
|
|
||||||
|
|
||||||
// Get timePlayed scaled to bar dimensions
|
// Get timePlayed scaled to bar dimensions
|
||||||
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music)*(screenWidth - 40);
|
timePlayed = GetMusicTimePlayed(xm)/GetMusicTimeLength(xm)*(screenWidth - 40);
|
||||||
|
|
||||||
// Color circles animation
|
// Color circles animation
|
||||||
for (int i = MAX_CIRCLES - 1; (i >= 0) && !pause; i--)
|
for (int i = MAX_CIRCLES - 1; (i >= 0) && !pause; i--)
|
||||||
|
|
@ -112,11 +99,11 @@ int main(void)
|
||||||
if (circles[i].alpha <= 0.0f)
|
if (circles[i].alpha <= 0.0f)
|
||||||
{
|
{
|
||||||
circles[i].alpha = 0.0f;
|
circles[i].alpha = 0.0f;
|
||||||
circles[i].radius = (float)GetRandomValue(10, 40);
|
circles[i].radius = GetRandomValue(10, 40);
|
||||||
circles[i].position.x = (float)GetRandomValue((int)circles[i].radius, (int)(screenWidth - circles[i].radius));
|
circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius);
|
||||||
circles[i].position.y = (float)GetRandomValue((int)circles[i].radius, (int)(screenHeight - circles[i].radius));
|
circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius);
|
||||||
circles[i].color = colors[GetRandomValue(0, 13)];
|
circles[i].color = colors[GetRandomValue(0, 13)];
|
||||||
circles[i].speed = (float)GetRandomValue(1, 100)/2000.0f;
|
circles[i].speed = (float)GetRandomValue(1, 100)/20000.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
@ -137,21 +124,13 @@ int main(void)
|
||||||
DrawRectangle(20, screenHeight - 20 - 12, (int)timePlayed, 12, MAROON);
|
DrawRectangle(20, screenHeight - 20 - 12, (int)timePlayed, 12, MAROON);
|
||||||
DrawRectangleLines(20, screenHeight - 20 - 12, screenWidth - 40, 12, GRAY);
|
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();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
UnloadMusicStream(music); // Unload music stream buffers from RAM
|
UnloadMusicStream(xm); // Unload music stream buffers from RAM
|
||||||
|
|
||||||
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
|
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
|
||||||
|
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 47 KiB |
|
|
@ -1,23 +1,18 @@
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [audio] example - music stream
|
* raylib [audio] example - Music playing (streaming)
|
||||||
*
|
*
|
||||||
* Example complexity rating: [★☆☆☆] 1/4
|
* NOTE: This example requires OpenAL Soft library installed
|
||||||
*
|
*
|
||||||
* Example originally created with raylib 1.3, last time updated with raylib 4.2
|
* 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)
|
||||||
*
|
*
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015-2025 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
|
|
@ -25,24 +20,18 @@ int main(void)
|
||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - music stream");
|
InitWindow(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)");
|
||||||
|
|
||||||
InitAudioDevice(); // Initialize audio device
|
InitAudioDevice(); // Initialize audio device
|
||||||
|
|
||||||
Music music = LoadMusicStream("resources/country.mp3");
|
Music music = LoadMusicStream("resources/guitar_noodling.ogg");
|
||||||
|
|
||||||
PlayMusicStream(music);
|
PlayMusicStream(music);
|
||||||
|
|
||||||
float timePlayed = 0.0f; // Time played normalized [0.0f..1.0f]
|
float timePlayed = 0.0f;
|
||||||
bool pause = false; // Music playing paused
|
bool pause = false;
|
||||||
|
|
||||||
float pan = 0.0f; // Default audio pan center [-1.0f..1.0f]
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
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
|
// Main game loop
|
||||||
|
|
@ -68,38 +57,10 @@ int main(void)
|
||||||
else ResumeMusicStream(music);
|
else ResumeMusicStream(music);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set audio pan
|
// Get timePlayed scaled to bar dimensions (400 pixels)
|
||||||
if (IsKeyDown(KEY_LEFT))
|
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music)*400;
|
||||||
{
|
|
||||||
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 (timePlayed > 400) StopMusicStream(music);
|
||||||
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
|
// Draw
|
||||||
|
|
@ -110,23 +71,13 @@ int main(void)
|
||||||
|
|
||||||
DrawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, LIGHTGRAY);
|
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, 400, 12, LIGHTGRAY);
|
||||||
DrawRectangle(200, 200, (int)(timePlayed*400.0f), 12, MAROON);
|
DrawRectangle(200, 200, (int)timePlayed, 12, MAROON);
|
||||||
DrawRectangleLines(200, 200, 400, 12, GRAY);
|
DrawRectangleLines(200, 200, 400, 12, GRAY);
|
||||||
|
|
||||||
DrawText("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, LIGHTGRAY);
|
DrawText("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, LIGHTGRAY);
|
||||||
DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 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();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,25 @@
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [audio] example - raw stream
|
* raylib [audio] example - Raw audio streaming
|
||||||
*
|
*
|
||||||
* Example complexity rating: [★★★☆] 3/4
|
* NOTE: This example requires OpenAL Soft library installed
|
||||||
*
|
*
|
||||||
* Example originally created with raylib 1.6, last time updated with raylib 6.0
|
* This example has been created using raylib 1.6 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Example created by Ramon Santamaria (@raysan5) and reviewed by James Hofmann (@triplefox)
|
* Copyright (c) 2015-2019 Ramon Santamaria (@raysan5) and 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 "raylib.h"
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#define BUFFER_SIZE 4096
|
#include <stdlib.h> // Required for: malloc(), free()
|
||||||
#define SAMPLE_RATE 44100
|
#include <math.h> // Required for: sinf()
|
||||||
|
#include <string.h> // Required for: memcpy()
|
||||||
|
|
||||||
|
#define MAX_SAMPLES 512
|
||||||
|
#define MAX_SAMPLES_PER_UPDATE 4096
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
|
|
@ -31,26 +27,39 @@ int main(void)
|
||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - raw stream");
|
InitWindow(screenWidth, screenHeight, "raylib [audio] example - raw audio streaming");
|
||||||
|
|
||||||
InitAudioDevice();
|
InitAudioDevice(); // Initialize audio device
|
||||||
|
|
||||||
// Set the number of samples the stream will keep in memory at a time to BUFFER_SIZE
|
// Init raw audio stream (sample rate: 22050, sample size: 16bit-short, channels: 1-mono)
|
||||||
SetAudioStreamBufferSizeDefault(BUFFER_SIZE);
|
AudioStream stream = InitAudioStream(22050, 16, 1);
|
||||||
float buffer[BUFFER_SIZE] = {};
|
|
||||||
|
|
||||||
// Init raw audio stream (sample rate: 44100, sample size: 32bit-float, channels: 1-mono)
|
// Buffer for the single cycle waveform we are synthesizing
|
||||||
AudioStream stream = LoadAudioStream(SAMPLE_RATE, 32, 1);
|
short *data = (short *)malloc(sizeof(short)*MAX_SAMPLES);
|
||||||
float pan = 0.0f;
|
|
||||||
SetAudioStreamPan(stream, pan);
|
|
||||||
PlayAudioStream(stream);
|
|
||||||
|
|
||||||
int sineFrequency = 440;
|
// Frame buffer, describing the waveform when repeated over the course of a frame
|
||||||
int newSineFrequency = 440;
|
short *writeBuf = (short *)malloc(sizeof(short)*MAX_SAMPLES_PER_UPDATE);
|
||||||
int sineIndex = 0;
|
|
||||||
double sineStartTime = 0.0;
|
|
||||||
|
|
||||||
SetTargetFPS(30);
|
PlayAudioStream(stream); // Start processing stream buffer (no data loaded currently)
|
||||||
|
|
||||||
|
// Position read in to determine next frequency
|
||||||
|
Vector2 mousePosition = { -100.0f, -100.0f };
|
||||||
|
|
||||||
|
// Cycles per second (hz)
|
||||||
|
float frequency = 440.0f;
|
||||||
|
|
||||||
|
// Previous value, used to test if sine needs to be rewritten, and to smoothly modulate frequency
|
||||||
|
float oldFrequency = 1.0f;
|
||||||
|
|
||||||
|
// Cursor to read and copy the samples of the sine wave buffer
|
||||||
|
int readCursor = 0;
|
||||||
|
|
||||||
|
// Computed size in samples of the sine wave
|
||||||
|
int waveLength = 1;
|
||||||
|
|
||||||
|
Vector2 position = { 0, 0 };
|
||||||
|
|
||||||
|
SetTargetFPS(30); // Set our game to run at 30 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
|
|
@ -59,75 +68,82 @@ int main(void)
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
if (IsKeyDown(KEY_UP))
|
// Sample mouse input.
|
||||||
|
mousePosition = GetMousePosition();
|
||||||
|
|
||||||
|
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
|
||||||
{
|
{
|
||||||
newSineFrequency += 10;
|
float fp = (float)(mousePosition.y);
|
||||||
if (newSineFrequency > 12500) newSineFrequency = 12500;
|
frequency = 40.0f + (float)(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsKeyDown(KEY_DOWN))
|
// Rewrite the sine wave.
|
||||||
|
// Compute two cycles to allow the buffer padding, simplifying any modulation, resampling, etc.
|
||||||
|
if (frequency != oldFrequency)
|
||||||
{
|
{
|
||||||
newSineFrequency -= 10;
|
// Compute wavelength. Limit size in both directions.
|
||||||
if (newSineFrequency < 20) newSineFrequency = 20;
|
int oldWavelength = waveLength;
|
||||||
|
waveLength = (int)(22050/frequency);
|
||||||
|
if (waveLength > MAX_SAMPLES/2) waveLength = MAX_SAMPLES/2;
|
||||||
|
if (waveLength < 1) waveLength = 1;
|
||||||
|
|
||||||
|
// Write sine wave.
|
||||||
|
for (int i = 0; i < waveLength*2; i++)
|
||||||
|
{
|
||||||
|
data[i] = (short)(sinf(((2*PI*(float)i/waveLength)))*32000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsKeyDown(KEY_LEFT))
|
// Scale read cursor's position to minimize transition artifacts
|
||||||
{
|
readCursor = (int)(readCursor * ((float)waveLength / (float)oldWavelength));
|
||||||
pan -= 0.01f;
|
oldFrequency = frequency;
|
||||||
if (pan < -1.0f) pan = -1.0f;
|
|
||||||
SetAudioStreamPan(stream, pan);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsKeyDown(KEY_RIGHT))
|
// Refill audio stream if required
|
||||||
|
if (IsAudioBufferProcessed(stream))
|
||||||
{
|
{
|
||||||
pan += 0.01f;
|
// Synthesize a buffer that is exactly the requested size
|
||||||
if (pan > 1.0f) pan = 1.0f;
|
int writeCursor = 0;
|
||||||
SetAudioStreamPan(stream, pan);
|
|
||||||
|
while (writeCursor < MAX_SAMPLES_PER_UPDATE)
|
||||||
|
{
|
||||||
|
// Start by trying to write the whole chunk at once
|
||||||
|
int writeLength = MAX_SAMPLES_PER_UPDATE-writeCursor;
|
||||||
|
|
||||||
|
// Limit to the maximum readable size
|
||||||
|
int readLength = waveLength-readCursor;
|
||||||
|
|
||||||
|
if (writeLength > readLength) writeLength = readLength;
|
||||||
|
|
||||||
|
// Write the slice
|
||||||
|
memcpy(writeBuf + writeCursor, data + readCursor, writeLength*sizeof(short));
|
||||||
|
|
||||||
|
// Update cursors and loop audio
|
||||||
|
readCursor = (readCursor + writeLength) % waveLength;
|
||||||
|
|
||||||
|
writeCursor += writeLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsAudioStreamProcessed(stream))
|
// Copy finished frame to audio stream
|
||||||
{
|
UpdateAudioStream(stream, writeBuf, MAX_SAMPLES_PER_UPDATE);
|
||||||
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
|
// Draw
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
DrawText(TextFormat("sine frequency: %i", sineFrequency), screenWidth - 220, 10, 20, RED);
|
DrawText(FormatText("sine frequency: %i",(int)frequency), GetScreenWidth() - 220, 10, 20, RED);
|
||||||
DrawText(TextFormat("pan: %.2f", pan), screenWidth - 220, 30, 20, RED);
|
DrawText("click mouse button to change frequency", 10, 10, 20, DARKGRAY);
|
||||||
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;
|
// Draw the current buffer state proportionate to the screen
|
||||||
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++)
|
for (int i = 0; i < screenWidth; i++)
|
||||||
{
|
{
|
||||||
int t0 = windowStart + i*windowSize/screenWidth;
|
position.x = i;
|
||||||
int t1 = windowStart + (i + 1)*windowSize/screenWidth;
|
position.y = 250 + 50*data[i*MAX_SAMPLES/screenWidth]/32000;
|
||||||
Vector2 startPos = { i, 250 + 50*sin(2*PI*t0/wavelength) };
|
|
||||||
Vector2 endPos = { i + 1, 250 + 50*sin(2*PI*t1/wavelength) };
|
DrawPixelV(position, RED);
|
||||||
DrawLineV(startPos, endPos, RED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
@ -136,7 +152,10 @@ int main(void)
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
UnloadAudioStream(stream); // Close raw audio stream and delete buffers from RAM
|
free(data); // Unload sine wave data
|
||||||
|
free(writeBuf); // Unload write buffer
|
||||||
|
|
||||||
|
CloseAudioStream(stream); // Close raw audio stream and delete buffers from RAM
|
||||||
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
|
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
|
@ -1,23 +1,18 @@
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* 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"
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
|
|
@ -25,12 +20,12 @@ int main(void)
|
||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const 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/sound.wav"); // Load WAV audio file
|
||||||
Sound fxOgg = LoadSound("resources/target.ogg"); // Load OGG audio file
|
Sound fxOgg = LoadSound("resources/tanatana.ogg"); // Load OGG audio file
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -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) | - |
|
|
||||||
BIN
examples/audio/resources/chiptun1.mod
Normal file
BIN
examples/audio/resources/guitar_noodling.ogg
Normal file
|
|
@ -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;
|
|
||||||
}
|
|
||||||
BIN
examples/audio/resources/tanatana.flac
Normal file
BIN
examples/audio/resources/tanatana.ogg
Normal file
|
|
@ -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
|
|
||||||
|
|
@ -2,25 +2,17 @@
|
||||||
*
|
*
|
||||||
* raylib [core] example - 2d camera
|
* raylib [core] example - 2d camera
|
||||||
*
|
*
|
||||||
* Example complexity rating: [★★☆☆] 2/4
|
* This example has been created using raylib 1.5 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Example originally created with raylib 1.5, last time updated with raylib 3.0
|
* Copyright (c) 2016 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) 2016-2025 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#define MAX_BUILDINGS 100
|
#define MAX_BUILDINGS 100
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
|
|
@ -38,23 +30,19 @@ int main(void)
|
||||||
|
|
||||||
for (int i = 0; i < MAX_BUILDINGS; i++)
|
for (int i = 0; i < MAX_BUILDINGS; i++)
|
||||||
{
|
{
|
||||||
buildings[i].width = (float)GetRandomValue(50, 200);
|
buildings[i].width = GetRandomValue(50, 200);
|
||||||
buildings[i].height = (float)GetRandomValue(100, 800);
|
buildings[i].height = GetRandomValue(100, 800);
|
||||||
buildings[i].y = screenHeight - 130.0f - buildings[i].height;
|
buildings[i].y = screenHeight - 130 - buildings[i].height;
|
||||||
buildings[i].x = -6000.0f + spacing;
|
buildings[i].x = -6000 + spacing;
|
||||||
|
|
||||||
spacing += (int)buildings[i].width;
|
spacing += buildings[i].width;
|
||||||
|
|
||||||
buildColors[i] = (Color){
|
buildColors[i] = (Color){ GetRandomValue(200, 240), GetRandomValue(200, 240), GetRandomValue(200, 250), 255 };
|
||||||
(unsigned char)GetRandomValue(200, 240),
|
|
||||||
(unsigned char)GetRandomValue(200, 240),
|
|
||||||
(unsigned char)GetRandomValue(200, 250),
|
|
||||||
255};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Camera2D camera = { 0 };
|
Camera2D camera = { 0 };
|
||||||
camera.target = (Vector2){ player.x + 20.0f, player.y + 20.0f };
|
camera.target = (Vector2){ player.x + 20, player.y + 20 };
|
||||||
camera.offset = (Vector2){ screenWidth/2.0f, screenHeight/2.0f };
|
camera.offset = (Vector2){ 0, 0 };
|
||||||
camera.rotation = 0.0f;
|
camera.rotation = 0.0f;
|
||||||
camera.zoom = 1.0f;
|
camera.zoom = 1.0f;
|
||||||
|
|
||||||
|
|
@ -66,9 +54,16 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Player movement
|
if (IsKeyDown(KEY_RIGHT))
|
||||||
if (IsKeyDown(KEY_RIGHT)) player.x += 2;
|
{
|
||||||
else if (IsKeyDown(KEY_LEFT)) player.x -= 2;
|
player.x += 2; // Player movement
|
||||||
|
camera.offset.x -= 2; // Camera displacement with player movement
|
||||||
|
}
|
||||||
|
else if (IsKeyDown(KEY_LEFT))
|
||||||
|
{
|
||||||
|
player.x -= 2; // Player movement
|
||||||
|
camera.offset.x += 2; // Camera displacement with player movement
|
||||||
|
}
|
||||||
|
|
||||||
// Camera target follows player
|
// Camera target follows player
|
||||||
camera.target = (Vector2){ player.x + 20, player.y + 20 };
|
camera.target = (Vector2){ player.x + 20, player.y + 20 };
|
||||||
|
|
@ -82,8 +77,7 @@ int main(void)
|
||||||
else if (camera.rotation < -40) camera.rotation = -40;
|
else if (camera.rotation < -40) camera.rotation = -40;
|
||||||
|
|
||||||
// Camera zoom controls
|
// Camera zoom controls
|
||||||
// Uses log scaling to provide consistent zoom speed
|
camera.zoom += ((float)GetMouseWheelMove()*0.05f);
|
||||||
camera.zoom = expf(logf(camera.zoom) + ((float)GetMouseWheelMove()*0.1f));
|
|
||||||
|
|
||||||
if (camera.zoom > 3.0f) camera.zoom = 3.0f;
|
if (camera.zoom > 3.0f) camera.zoom = 3.0f;
|
||||||
else if (camera.zoom < 0.1f) camera.zoom = 0.1f;
|
else if (camera.zoom < 0.1f) camera.zoom = 0.1f;
|
||||||
|
|
@ -110,8 +104,8 @@ int main(void)
|
||||||
|
|
||||||
DrawRectangleRec(player, RED);
|
DrawRectangleRec(player, RED);
|
||||||
|
|
||||||
DrawLine((int)camera.target.x, -screenHeight*10, (int)camera.target.x, screenHeight*10, GREEN);
|
DrawLine(camera.target.x, -screenHeight*10, camera.target.x, screenHeight*10, GREEN);
|
||||||
DrawLine(-screenWidth*10, (int)camera.target.y, screenWidth*10, (int)camera.target.y, GREEN);
|
DrawLine(-screenWidth*10, camera.target.y, screenWidth*10, camera.target.y, GREEN);
|
||||||
|
|
||||||
EndMode2D();
|
EndMode2D();
|
||||||
|
|
||||||
|
|
@ -125,8 +119,8 @@ int main(void)
|
||||||
DrawRectangle( 10, 10, 250, 113, Fade(SKYBLUE, 0.5f));
|
DrawRectangle( 10, 10, 250, 113, Fade(SKYBLUE, 0.5f));
|
||||||
DrawRectangleLines( 10, 10, 250, 113, BLUE);
|
DrawRectangleLines( 10, 10, 250, 113, BLUE);
|
||||||
|
|
||||||
DrawText("Free 2D camera controls:", 20, 20, 10, BLACK);
|
DrawText("Free 2d camera controls:", 20, 20, 10, BLACK);
|
||||||
DrawText("- Right/Left to move player", 40, 40, 10, DARKGRAY);
|
DrawText("- Right/Left to move Offset", 40, 40, 10, DARKGRAY);
|
||||||
DrawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, DARKGRAY);
|
DrawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, DARKGRAY);
|
||||||
DrawText("- A / S to Rotate", 40, 80, 10, DARKGRAY);
|
DrawText("- A / S to Rotate", 40, 80, 10, DARKGRAY);
|
||||||
DrawText("- R to reset Zoom and Rotation", 40, 100, 10, DARKGRAY);
|
DrawText("- R to reset Zoom and Rotation", 40, 100, 10, DARKGRAY);
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 21 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 |
|
|
@ -2,25 +2,17 @@
|
||||||
*
|
*
|
||||||
* raylib [core] example - 3d camera first person
|
* raylib [core] example - 3d camera first person
|
||||||
*
|
*
|
||||||
* Example complexity rating: [★★☆☆] 2/4
|
* 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)
|
||||||
*
|
*
|
||||||
* Example originally created with raylib 1.3, last time updated with raylib 1.3
|
* Copyright (c) 2015 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) 2015-2025 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
#include "rcamera.h"
|
|
||||||
|
|
||||||
#define MAX_COLUMNS 20
|
#define MAX_COLUMNS 20
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
|
|
@ -32,27 +24,25 @@ int main(void)
|
||||||
|
|
||||||
// Define the camera to look into our 3d world (position, target, up vector)
|
// Define the camera to look into our 3d world (position, target, up vector)
|
||||||
Camera camera = { 0 };
|
Camera camera = { 0 };
|
||||||
camera.position = (Vector3){ 0.0f, 2.0f, 4.0f }; // Camera position
|
camera.position = (Vector3){ 4.0f, 2.0f, 4.0f };
|
||||||
camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point
|
camera.target = (Vector3){ 0.0f, 1.8f, 0.0f };
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||||
camera.fovy = 60.0f; // Camera field-of-view Y
|
camera.fovy = 60.0f;
|
||||||
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
camera.type = CAMERA_PERSPECTIVE;
|
||||||
|
|
||||||
int cameraMode = CAMERA_FIRST_PERSON;
|
|
||||||
|
|
||||||
// Generates some random columns
|
// Generates some random columns
|
||||||
float heights[MAX_COLUMNS] = { 0 };
|
float heights[MAX_COLUMNS] = { 0.0f };
|
||||||
Vector3 positions[MAX_COLUMNS] = { 0 };
|
Vector3 positions[MAX_COLUMNS] = { 0 };
|
||||||
Color colors[MAX_COLUMNS] = { 0 };
|
Color colors[MAX_COLUMNS] = { 0 };
|
||||||
|
|
||||||
for (int i = 0; i < MAX_COLUMNS; i++)
|
for (int i = 0; i < MAX_COLUMNS; i++)
|
||||||
{
|
{
|
||||||
heights[i] = (float)GetRandomValue(1, 12);
|
heights[i] = (float)GetRandomValue(1, 12);
|
||||||
positions[i] = (Vector3){ (float)GetRandomValue(-15, 15), heights[i]/2.0f, (float)GetRandomValue(-15, 15) };
|
positions[i] = (Vector3){ GetRandomValue(-15, 15), heights[i]/2, GetRandomValue(-15, 15) };
|
||||||
colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 };
|
colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 };
|
||||||
}
|
}
|
||||||
|
|
||||||
DisableCursor(); // Limit cursor to relative movement inside the window
|
SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set a first person camera mode
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
@ -62,82 +52,7 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Switch camera mode
|
UpdateCamera(&camera); // Update camera
|
||||||
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
|
// Draw
|
||||||
|
|
@ -160,39 +75,14 @@ int main(void)
|
||||||
DrawCubeWires(positions[i], 2.0f, heights[i], 2.0f, MAROON);
|
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();
|
EndMode3D();
|
||||||
|
|
||||||
// Draw info boxes
|
DrawRectangle( 10, 10, 220, 70, Fade(SKYBLUE, 0.5f));
|
||||||
DrawRectangle(5, 5, 330, 100, Fade(SKYBLUE, 0.5f));
|
DrawRectangleLines( 10, 10, 220, 70, BLUE);
|
||||||
DrawRectangleLines(5, 5, 330, 100, BLUE);
|
|
||||||
|
|
||||||
DrawText("Camera controls:", 15, 15, 10, BLACK);
|
DrawText("First person camera default controls:", 20, 20, 10, BLACK);
|
||||||
DrawText("- Move keys: W, A, S, D, Space, Left-Ctrl", 15, 30, 10, BLACK);
|
DrawText("- Move with keys: W, A, S, D", 40, 40, 10, DARKGRAY);
|
||||||
DrawText("- Look around: arrow keys or mouse", 15, 45, 10, BLACK);
|
DrawText("- Mouse move to look around", 40, 60, 10, DARKGRAY);
|
||||||
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();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1,329 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [core] example - 3d camera fps
|
|
||||||
*
|
|
||||||
* Example complexity rating: [★★★☆] 3/4
|
|
||||||
*
|
|
||||||
* Example originally created with raylib 5.5, last time updated with raylib 5.5
|
|
||||||
*
|
|
||||||
* Example contributed by Agnis Aldiņš (@nezvers) 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 Agnis Aldiņš (@nezvers)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
#include "raymath.h"
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Defines and Macros
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Movement constants
|
|
||||||
#define GRAVITY 32.0f
|
|
||||||
#define MAX_SPEED 20.0f
|
|
||||||
#define CROUCH_SPEED 5.0f
|
|
||||||
#define JUMP_FORCE 12.0f
|
|
||||||
#define MAX_ACCEL 150.0f
|
|
||||||
// Grounded drag
|
|
||||||
#define FRICTION 0.86f
|
|
||||||
// Increasing air drag, increases strafing speed
|
|
||||||
#define AIR_DRAG 0.98f
|
|
||||||
// Responsiveness for turning movement direction to looked direction
|
|
||||||
#define CONTROL 15.0f
|
|
||||||
#define CROUCH_HEIGHT 0.0f
|
|
||||||
#define STAND_HEIGHT 1.0f
|
|
||||||
#define BOTTOM_HEIGHT 0.5f
|
|
||||||
|
|
||||||
#define NORMALIZE_INPUT 0
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Types and Structures Definition
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Body structure
|
|
||||||
typedef struct {
|
|
||||||
Vector3 position;
|
|
||||||
Vector3 velocity;
|
|
||||||
Vector3 dir;
|
|
||||||
bool isGrounded;
|
|
||||||
} Body;
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Global Variables Definition
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
static Vector2 sensitivity = { 0.001f, 0.001f };
|
|
||||||
|
|
||||||
static Body player = { 0 };
|
|
||||||
static Vector2 lookRotation = { 0 };
|
|
||||||
static float headTimer = 0.0f;
|
|
||||||
static float walkLerp = 0.0f;
|
|
||||||
static float headLerp = STAND_HEIGHT;
|
|
||||||
static Vector2 lean = { 0 };
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Module Functions Declaration
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
static void DrawLevel(void);
|
|
||||||
static void UpdateCameraFPS(Camera *camera);
|
|
||||||
static void UpdateBody(Body *body, float rot, char side, char forward, bool jumpPressed, bool crouchHold);
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera fps");
|
|
||||||
|
|
||||||
// Initialize camera variables
|
|
||||||
// NOTE: UpdateCameraFPS() takes care of the rest
|
|
||||||
Camera camera = { 0 };
|
|
||||||
camera.fovy = 60.0f;
|
|
||||||
camera.projection = CAMERA_PERSPECTIVE;
|
|
||||||
camera.position = (Vector3){
|
|
||||||
player.position.x,
|
|
||||||
player.position.y + (BOTTOM_HEIGHT + headLerp),
|
|
||||||
player.position.z,
|
|
||||||
};
|
|
||||||
|
|
||||||
UpdateCameraFPS(&camera); // Update camera parameters
|
|
||||||
|
|
||||||
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
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
Vector2 mouseDelta = GetMouseDelta();
|
|
||||||
lookRotation.x -= mouseDelta.x*sensitivity.x;
|
|
||||||
lookRotation.y += mouseDelta.y*sensitivity.y;
|
|
||||||
|
|
||||||
char sideway = (IsKeyDown(KEY_D) - IsKeyDown(KEY_A));
|
|
||||||
char forward = (IsKeyDown(KEY_W) - IsKeyDown(KEY_S));
|
|
||||||
bool crouching = IsKeyDown(KEY_LEFT_CONTROL);
|
|
||||||
UpdateBody(&player, lookRotation.x, sideway, forward, IsKeyPressed(KEY_SPACE), crouching);
|
|
||||||
|
|
||||||
float delta = GetFrameTime();
|
|
||||||
headLerp = Lerp(headLerp, (crouching ? CROUCH_HEIGHT : STAND_HEIGHT), 20.0f*delta);
|
|
||||||
camera.position = (Vector3){
|
|
||||||
player.position.x,
|
|
||||||
player.position.y + (BOTTOM_HEIGHT + headLerp),
|
|
||||||
player.position.z,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (player.isGrounded && ((forward != 0) || (sideway != 0)))
|
|
||||||
{
|
|
||||||
headTimer += delta*3.0f;
|
|
||||||
walkLerp = Lerp(walkLerp, 1.0f, 10.0f*delta);
|
|
||||||
camera.fovy = Lerp(camera.fovy, 55.0f, 5.0f*delta);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
walkLerp = Lerp(walkLerp, 0.0f, 10.0f*delta);
|
|
||||||
camera.fovy = Lerp(camera.fovy, 60.0f, 5.0f*delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
lean.x = Lerp(lean.x, sideway*0.02f, 10.0f*delta);
|
|
||||||
lean.y = Lerp(lean.y, forward*0.015f, 10.0f*delta);
|
|
||||||
|
|
||||||
UpdateCameraFPS(&camera);
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
BeginMode3D(camera);
|
|
||||||
DrawLevel();
|
|
||||||
EndMode3D();
|
|
||||||
|
|
||||||
// Draw info box
|
|
||||||
DrawRectangle(5, 5, 330, 75, Fade(SKYBLUE, 0.5f));
|
|
||||||
DrawRectangleLines(5, 5, 330, 75, 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(TextFormat("- Velocity Len: (%06.3f)", Vector2Length((Vector2){ player.velocity.x, player.velocity.z })), 15, 60, 10, BLACK);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Module Functions Definition
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Update body considering current world state
|
|
||||||
void UpdateBody(Body *body, float rot, char side, char forward, bool jumpPressed, bool crouchHold)
|
|
||||||
{
|
|
||||||
Vector2 input = (Vector2){ (float)side, (float)-forward };
|
|
||||||
|
|
||||||
#if defined(NORMALIZE_INPUT)
|
|
||||||
// Slow down diagonal movement
|
|
||||||
if ((side != 0) && (forward != 0)) input = Vector2Normalize(input);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
float delta = GetFrameTime();
|
|
||||||
|
|
||||||
if (!body->isGrounded) body->velocity.y -= GRAVITY*delta;
|
|
||||||
|
|
||||||
if (body->isGrounded && jumpPressed)
|
|
||||||
{
|
|
||||||
body->velocity.y = JUMP_FORCE;
|
|
||||||
body->isGrounded = false;
|
|
||||||
|
|
||||||
// Sound can be played at this moment
|
|
||||||
//SetSoundPitch(fxJump, 1.0f + (GetRandomValue(-100, 100)*0.001));
|
|
||||||
//PlaySound(fxJump);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector3 front = (Vector3){ sinf(rot), 0.f, cosf(rot) };
|
|
||||||
Vector3 right = (Vector3){ cosf(-rot), 0.f, sinf(-rot) };
|
|
||||||
|
|
||||||
Vector3 desiredDir = (Vector3){ input.x*right.x + input.y*front.x, 0.0f, input.x*right.z + input.y*front.z, };
|
|
||||||
body->dir = Vector3Lerp(body->dir, desiredDir, CONTROL*delta);
|
|
||||||
|
|
||||||
float decel = (body->isGrounded ? FRICTION : AIR_DRAG);
|
|
||||||
Vector3 hvel = (Vector3){ body->velocity.x*decel, 0.0f, body->velocity.z*decel };
|
|
||||||
|
|
||||||
float hvelLength = Vector3Length(hvel); // Magnitude
|
|
||||||
if (hvelLength < (MAX_SPEED*0.01f)) hvel = (Vector3){ 0 };
|
|
||||||
|
|
||||||
// This is what creates strafing
|
|
||||||
float speed = Vector3DotProduct(hvel, body->dir);
|
|
||||||
|
|
||||||
// Whenever the amount of acceleration to add is clamped by the maximum acceleration constant,
|
|
||||||
// a Player can make the speed faster by bringing the direction closer to horizontal velocity angle
|
|
||||||
// More info here: https://youtu.be/v3zT3Z5apaM?t=165
|
|
||||||
float maxSpeed = (crouchHold? CROUCH_SPEED : MAX_SPEED);
|
|
||||||
float accel = Clamp(maxSpeed - speed, 0.f, MAX_ACCEL*delta);
|
|
||||||
hvel.x += body->dir.x*accel;
|
|
||||||
hvel.z += body->dir.z*accel;
|
|
||||||
|
|
||||||
body->velocity.x = hvel.x;
|
|
||||||
body->velocity.z = hvel.z;
|
|
||||||
|
|
||||||
body->position.x += body->velocity.x*delta;
|
|
||||||
body->position.y += body->velocity.y*delta;
|
|
||||||
body->position.z += body->velocity.z*delta;
|
|
||||||
|
|
||||||
// Fancy collision system against the floor
|
|
||||||
if (body->position.y <= 0.0f)
|
|
||||||
{
|
|
||||||
body->position.y = 0.0f;
|
|
||||||
body->velocity.y = 0.0f;
|
|
||||||
body->isGrounded = true; // Enable jumping
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update camera for FPS behaviour
|
|
||||||
static void UpdateCameraFPS(Camera *camera)
|
|
||||||
{
|
|
||||||
const Vector3 up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
|
||||||
const Vector3 targetOffset = (Vector3){ 0.0f, 0.0f, -1.0f };
|
|
||||||
|
|
||||||
// Left and right
|
|
||||||
Vector3 yaw = Vector3RotateByAxisAngle(targetOffset, up, lookRotation.x);
|
|
||||||
|
|
||||||
// Clamp view up
|
|
||||||
float maxAngleUp = Vector3Angle(up, yaw);
|
|
||||||
maxAngleUp -= 0.001f; // Avoid numerical errors
|
|
||||||
if ( -(lookRotation.y) > maxAngleUp) { lookRotation.y = -maxAngleUp; }
|
|
||||||
|
|
||||||
// Clamp view down
|
|
||||||
float maxAngleDown = Vector3Angle(Vector3Negate(up), yaw);
|
|
||||||
maxAngleDown *= -1.0f; // Downwards angle is negative
|
|
||||||
maxAngleDown += 0.001f; // Avoid numerical errors
|
|
||||||
if ( -(lookRotation.y) < maxAngleDown) { lookRotation.y = -maxAngleDown; }
|
|
||||||
|
|
||||||
// Up and down
|
|
||||||
Vector3 right = Vector3Normalize(Vector3CrossProduct(yaw, up));
|
|
||||||
|
|
||||||
// Rotate view vector around right axis
|
|
||||||
float pitchAngle = -lookRotation.y - lean.y;
|
|
||||||
pitchAngle = Clamp(pitchAngle, -PI/2 + 0.0001f, PI/2 - 0.0001f); // Clamp angle so it doesn't go past straight up or straight down
|
|
||||||
Vector3 pitch = Vector3RotateByAxisAngle(yaw, right, pitchAngle);
|
|
||||||
|
|
||||||
// Head animation
|
|
||||||
// Rotate up direction around forward axis
|
|
||||||
float headSin = sinf(headTimer*PI);
|
|
||||||
float headCos = cosf(headTimer*PI);
|
|
||||||
const float stepRotation = 0.01f;
|
|
||||||
camera->up = Vector3RotateByAxisAngle(up, pitch, headSin*stepRotation + lean.x);
|
|
||||||
|
|
||||||
// Camera BOB
|
|
||||||
const float bobSide = 0.1f;
|
|
||||||
const float bobUp = 0.15f;
|
|
||||||
Vector3 bobbing = Vector3Scale(right, headSin*bobSide);
|
|
||||||
bobbing.y = fabsf(headCos*bobUp);
|
|
||||||
|
|
||||||
camera->position = Vector3Add(camera->position, Vector3Scale(bobbing, walkLerp));
|
|
||||||
camera->target = Vector3Add(camera->position, pitch);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw game level
|
|
||||||
static void DrawLevel(void)
|
|
||||||
{
|
|
||||||
const int floorExtent = 25;
|
|
||||||
const float tileSize = 5.0f;
|
|
||||||
const Color tileColor1 = (Color){ 150, 200, 200, 255 };
|
|
||||||
|
|
||||||
// Floor tiles
|
|
||||||
for (int y = -floorExtent; y < floorExtent; y++)
|
|
||||||
{
|
|
||||||
for (int x = -floorExtent; x < floorExtent; x++)
|
|
||||||
{
|
|
||||||
if ((y & 1) && (x & 1))
|
|
||||||
{
|
|
||||||
DrawPlane((Vector3){ x*tileSize, 0.0f, y*tileSize}, (Vector2){ tileSize, tileSize }, tileColor1);
|
|
||||||
}
|
|
||||||
else if (!(y & 1) && !(x & 1))
|
|
||||||
{
|
|
||||||
DrawPlane((Vector3){ x*tileSize, 0.0f, y*tileSize}, (Vector2){ tileSize, tileSize }, LIGHTGRAY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const Vector3 towerSize = (Vector3){ 16.0f, 32.0f, 16.0f };
|
|
||||||
const Color towerColor = (Color){ 150, 200, 200, 255 };
|
|
||||||
|
|
||||||
Vector3 towerPos = (Vector3){ 16.0f, 16.0f, 16.0f };
|
|
||||||
DrawCubeV(towerPos, towerSize, towerColor);
|
|
||||||
DrawCubeWiresV(towerPos, towerSize, DARKBLUE);
|
|
||||||
|
|
||||||
towerPos.x *= -1;
|
|
||||||
DrawCubeV(towerPos, towerSize, towerColor);
|
|
||||||
DrawCubeWiresV(towerPos, towerSize, DARKBLUE);
|
|
||||||
|
|
||||||
towerPos.z *= -1;
|
|
||||||
DrawCubeV(towerPos, towerSize, towerColor);
|
|
||||||
DrawCubeWiresV(towerPos, towerSize, DARKBLUE);
|
|
||||||
|
|
||||||
towerPos.x *= -1;
|
|
||||||
DrawCubeV(towerPos, towerSize, towerColor);
|
|
||||||
DrawCubeWiresV(towerPos, towerSize, DARKBLUE);
|
|
||||||
|
|
||||||
// Red sun
|
|
||||||
DrawSphere((Vector3){ 300.0f, 300.0f, 0.0f }, 100.0f, (Color){ 255, 0, 0, 255 });
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 8.9 KiB |
|
|
@ -1,23 +1,16 @@
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [core] example - 3d camera free
|
* raylib [core] example - Initialize 3d camera free
|
||||||
*
|
*
|
||||||
* Example complexity rating: [★☆☆☆] 1/4
|
* 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)
|
||||||
*
|
*
|
||||||
* Example originally created with raylib 1.3, last time updated with raylib 1.3
|
* Copyright (c) 2015 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) 2015-2025 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
|
|
@ -33,11 +26,11 @@ int main(void)
|
||||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||||
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
camera.type = CAMERA_PERSPECTIVE; // Camera mode type
|
||||||
|
|
||||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
||||||
|
|
||||||
DisableCursor(); // Limit cursor to relative movement inside the window
|
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
@ -47,9 +40,9 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
UpdateCamera(&camera, CAMERA_FREE);
|
UpdateCamera(&camera); // Update camera
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_Z)) camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
if (IsKeyDown('Z')) camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|
@ -67,13 +60,15 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawRectangle( 10, 10, 320, 93, Fade(SKYBLUE, 0.5f));
|
DrawRectangle( 10, 10, 320, 133, Fade(SKYBLUE, 0.5f));
|
||||||
DrawRectangleLines( 10, 10, 320, 93, BLUE);
|
DrawRectangleLines( 10, 10, 320, 133, BLUE);
|
||||||
|
|
||||||
DrawText("Free camera default controls:", 20, 20, 10, BLACK);
|
DrawText("Free camera default controls:", 20, 20, 10, BLACK);
|
||||||
DrawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, DARKGRAY);
|
DrawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, DARKGRAY);
|
||||||
DrawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, DARKGRAY);
|
DrawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, DARKGRAY);
|
||||||
DrawText("- Z to zoom to (0, 0, 0)", 40, 80, 10, DARKGRAY);
|
DrawText("- Alt + Mouse Wheel Pressed to Rotate", 40, 80, 10, DARKGRAY);
|
||||||
|
DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 40, 100, 10, DARKGRAY);
|
||||||
|
DrawText("- Z to zoom to (0, 0, 0)", 40, 120, 10, DARKGRAY);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||