diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index df8a6e4864..0e5a2d4e20 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,466 +1,530 @@ -name: build - -on: - pull_request: - paths-ignore: - - '**.md' - - '*.txt' - - '.gitignore' - - 'docs/*' - push: - branches: - - main - paths-ignore: - - '**.md' - - '*.txt' - - '.gitignore' - - 'docs/*' - release: - types: [published] - - workflow_dispatch: - -jobs: - windows-msys: - name: ${{ matrix.btype }} Windows-${{ matrix.cc }} ${{ matrix.arch }} - runs-on: windows-2022 - strategy: - fail-fast: false - matrix: - arch: [x86, x86_64] - cc: [gcc] - btype: [Release, Debug] - include: - - arch: x86 - msystem: MINGW32 - prefix: mingw-w64-i686 - - - arch: x86_64 - msystem: MINGW64 - prefix: mingw-w64-x86_64 - - - btype: Release - rule: install - - - btype: Debug - rule: debug - - defaults: - run: - shell: msys2 {0} - - steps: - - - uses: msys2/setup-msys2@v2 - with: - install: base-devel ${{ matrix.prefix }}-binutils ${{ matrix.prefix }}-make ${{ matrix.prefix }}-${{ matrix.cc }} - msystem: ${{ matrix.msystem }} - path-type: minimal - release: false - update: false - cache: false - - - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Build - if: ${{ github.event_name != 'release' || matrix.btype != 'Debug' }} # skip Debug configuration in Release build - run: | - make ${{ matrix.rule }} -j$(nproc) ARCH=${{ matrix.arch }} COMPILE_ARCH=${{ matrix.arch }} CC=${{ matrix.cc }} DESTDIR=bin USE_SDL=0 USE_RENDERER_DLOPEN=0 RENDERER_DEFAULT=vulkan CNAME=quake3e-vulkan BUILD_SERVER=0 - make clean ARCH=${{ matrix.arch }} - make ${{ matrix.rule }} -j$(nproc) ARCH=${{ matrix.arch }} COMPILE_ARCH=${{ matrix.arch }} CC=${{ matrix.cc }} DESTDIR=bin USE_SDL=0 USE_RENDERER_DLOPEN=0 RENDERER_DEFAULT=opengl - - - uses: actions/upload-artifact@v4 - if: matrix.cc == 'gcc' && matrix.btype == 'Release' - with: - name: windows-${{ matrix.cc }}-${{ matrix.arch }} - path: bin - if-no-files-found: error - retention-days: 5 - - windows-msys32: - name: ${{ matrix.btype }} Windows-msys32 ${{ matrix.arch }} - runs-on: windows-latest - strategy: - fail-fast: false - matrix: - arch: [x86, x86_64] -# btype: [Release, Debug] - btype: [Release] - include: - - btype: Release - rule: install - -# - btype: Debug -# rule: debug - - steps: - - name: Checkout current repo - uses: actions/checkout@v4 - - - name: Checkout msys32 tools from sibling repo - uses: actions/checkout@v4 - with: - repository: ec-/msys32 - path: msys - - - name: Extract msys32.7z - run: | - 7z x %GITHUB_WORKSPACE%/msys/msys32.7z -o%GITHUB_WORKSPACE%/msys - shell: cmd - - - name: Prepend msys/bin to PATH - run: | - echo "PATH=$GITHUB_WORKSPACE/msys/mingw/bin;$GITHUB_WORKSPACE/msys/bin;$GITHUB_WORKSPACE/msys" >> $GITHUB_ENV - shell: bash - - - name: Build - if: ${{ github.event_name != 'release' || matrix.btype != 'Debug' }} # skip Debug configuration in Release build - shell: cmd - run: | - make ${{ matrix.rule }} ARCH=${{ matrix.arch }} DESTDIR=bin USE_SDL=0 USE_RENDERER_DLOPEN=0 RENDERER_DEFAULT=vulkan CNAME=quake3e-vulkan BUILD_SERVER=0 - make clean ARCH=${{ matrix.arch }} - make ${{ matrix.rule }} ARCH=${{ matrix.arch }} DESTDIR=bin USE_SDL=0 USE_RENDERER_DLOPEN=0 RENDERER_DEFAULT=opengl - - - uses: actions/upload-artifact@v4 - if: matrix.btype == 'Release' - with: - name: windows-mingw-${{ matrix.arch }} - path: bin - if-no-files-found: error - retention-days: 5 - - windows-msvc: - name: ${{ matrix.btype }} Windows-MSVC ${{ matrix.arch }} - runs-on: windows-2022 - strategy: - fail-fast: false - matrix: - arch: [arm64, x86, x64] - btype: [Release, Debug] - include: - - arch: arm64 - platform: ARM64 - suffix: .arm64 - pkg_suffix: arm64 - - - arch: x86 - platform: Win32 - pkg_suffix: x86 - - - arch: x64 - platform: x64 - suffix: .x64 - pkg_suffix: x86_64 - - steps: - - - uses: microsoft/setup-msbuild@v2 - - - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Build - if: ${{ github.event_name != 'release' || matrix.btype != 'Debug' }} # skip Debug configuration in Release build - run: | - mkdir bin - - msbuild code\win32\msvc2017\quake3e-ded.vcxproj -p:TargetName=quake3e.ded,Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }} /p:PlatformToolset=v143 - copy code\win32\msvc2017\output\quake3e.ded.exe bin\quake3e.ded${{ matrix.suffix }}.exe - msbuild code\win32\msvc2017\quake3e-ded.vcxproj -p:TargetName=quake3e.ded,Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }} -t:Clean - - msbuild code\win32\msvc2017\renderer.vcxproj -p:Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }} /p:PlatformToolset=v143 - msbuild code\win32\msvc2017\quake3e.vcxproj -p:TargetName=quake3e,Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }},UseWasapi=USE_WASAPI=0 /p:PlatformToolset=v143 - copy code\win32\msvc2017\output\quake3e.exe bin\quake3e${{ matrix.suffix }}.exe - msbuild code\win32\msvc2017\renderer.vcxproj -p:Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }} -t:Clean - msbuild code\win32\msvc2017\quake3e.vcxproj -p:TargetName=quake3e,Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }},UseWasapi=USE_WASAPI=0 -t:Clean - - msbuild code\win32\msvc2017\renderervk.vcxproj -p:Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }} /p:PlatformToolset=v143 - msbuild code\win32\msvc2017\quake3e.vcxproj -p:TargetName=quake3e,Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }},UseWasapi=USE_WASAPI=0 /p:PlatformToolset=v143 - copy code\win32\msvc2017\output\quake3e.exe bin\quake3e-vulkan${{ matrix.suffix }}.exe - msbuild code\win32\msvc2017\renderervk.vcxproj -p:Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }} -t:Clean - msbuild code\win32\msvc2017\quake3e.vcxproj -p:TargetName=quake3e,Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }},UseWasapi=USE_WASAPI=0 -t:Clean - - - uses: actions/upload-artifact@v4 - if: ${{ matrix.btype == 'Release' }} - with: - name: windows-msvc-${{ matrix.pkg_suffix }} - path: bin - if-no-files-found: error - retention-days: 5 - - ubuntu-x86: - name: ${{ matrix.btype }} Ubuntu ${{ matrix.arch }} - runs-on: ubuntu-24.04 - strategy: - fail-fast: false - matrix: - arch: [x86, x86_64] - cc: [gcc] - btype: [Release, Debug] - include: - - btype: Release - rule: install - - - btype: Debug - if: ${{ github.event_name != 'release' }} - rule: debug - - - arch: x86 - use_sdl: USE_SDL=0 - - - arch: x86_64 - use_sdl: USE_SDL=1 - - steps: - - - name: Install tools - run: | - if [ ${{ matrix.arch }} == "x86" ]; then - sudo dpkg --add-architecture i386 - sudo apt-get -qq update - sudo apt-get -y install gcc-multilib libcurl4-openssl-dev:i386 mesa-common-dev:i386 libxxf86dga-dev:i386 libxrandr-dev:i386 libxxf86vm-dev:i386 libasound-dev:i386 - else - sudo apt-get -qq update - sudo apt-get -y install libcurl4-openssl-dev mesa-common-dev libxxf86dga-dev libxrandr-dev libxxf86vm-dev libasound-dev libsdl2-dev - fi - - - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Build - if: ${{ github.event_name != 'release' || matrix.btype != 'Debug' }} # skip in Release builds - run: | - make ${{ matrix.rule }} -j$(nproc) ARCH=${{ matrix.arch }} COMPILE_ARCH=${{ matrix.arch }} CC=${{ matrix.cc }} DESTDIR=bin ${{ matrix.use_sdl }} USE_RENDERER_DLOPEN=0 RENDERER_DEFAULT=vulkan CNAME=quake3e-vulkan BUILD_SERVER=0 - make clean ARCH=${{ matrix.arch }} - make ${{ matrix.rule }} -j$(nproc) ARCH=${{ matrix.arch }} COMPILE_ARCH=${{ matrix.arch }} CC=${{ matrix.cc }} DESTDIR=bin ${{ matrix.use_sdl }} USE_RENDERER_DLOPEN=0 RENDERER_DEFAULT=opengl - - - uses: actions/upload-artifact@v4 - if: matrix.cc == 'gcc' && matrix.btype == 'Release' - with: - name: linux-${{ matrix.arch }} - path: bin - if-no-files-found: error - retention-days: 5 - - ubuntu-arm: - name: ${{ matrix.btype }} Ubuntu [ARM] ${{ matrix.arch }} - runs-on: ubuntu-24.04 - strategy: - fail-fast: false - matrix: - arch: [aarch64, armv7] - cc: [gcc] - btype: [Release, Debug] - include: - - btype: Release - rule: install - - - btype: Debug - rule: debug - - steps: - - - uses: actions/checkout@v4 - if: false - with: - submodules: recursive - - - name: Build ${{ matrix.arch }} - #if: ${{ github.event_name != 'release' || matrix.btype != 'Debug' }} # skip Debug configuration in Release build - if: false - uses: uraimo/run-on-arch-action@v3 - with: - arch: ${{ matrix.arch }} - distro: ubuntu24.04 - githubToken: ${{ github.token }} - shell: /bin/sh - run: | - apt-get -qq update - apt-get install -y make gcc g++ - apt-get -y install libcurl4-openssl-dev mesa-common-dev libxxf86dga-dev libxrandr-dev libxxf86vm-dev libasound-dev - - make ${{ matrix.rule }} -j$(nproc) ARCH=${{ matrix.arch }} CC=${{ matrix.cc }} DESTDIR=bin USE_SDL=0 USE_RENDERER_DLOPEN=0 RENDERER_DEFAULT=vulkan CNAME=quake3e-vulkan BUILD_SERVER=0 - make clean ARCH=${{ matrix.arch }} - make ${{ matrix.rule }} -j$(nproc) ARCH=${{ matrix.arch }} CC=${{ matrix.cc }} DESTDIR=bin USE_SDL=0 USE_RENDERER_DLOPEN=0 RENDERER_DEFAULT=opengl - - - uses: actions/upload-artifact@v4 - if: false - #if: matrix.cc == 'gcc' && matrix.btype == 'Release' - with: - name: linux-${{ matrix.arch }} - path: bin - if-no-files-found: error - retention-days: 5 - - ubuntu-arm64: - name: ${{ matrix.btype }} Ubuntu ${{ matrix.arch }} - runs-on: ubuntu-22.04-arm - strategy: - fail-fast: false - matrix: - arch: [arm64] - cc: [gcc] - btype: [Release, Debug] - include: - - btype: Release - rule: install - - - btype: Debug - rule: debug - - steps: - - - name: Install tools - run: | - sudo apt-get -qq update - sudo apt-get install -y make gcc g++ - sudo apt-get -y install libcurl4-openssl-dev mesa-common-dev libxxf86dga-dev libxrandr-dev libxxf86vm-dev libasound-dev libsdl2-dev - - - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Build - if: ${{ github.event_name != 'release' || matrix.btype != 'Debug' }} # skip Debug configuration in Release build - run: | - make ${{ matrix.rule }} -j$(nproc) ARCH=${{ matrix.arch }} CC=${{ matrix.cc }} DESTDIR=bin USE_SDL=0 USE_RENDERER_DLOPEN=0 RENDERER_DEFAULT=vulkan CNAME=quake3e-vulkan BUILD_SERVER=0 - make clean ARCH=${{ matrix.arch }} - make ${{ matrix.rule }} -j$(nproc) ARCH=${{ matrix.arch }} CC=${{ matrix.cc }} DESTDIR=bin USE_SDL=0 USE_RENDERER_DLOPEN=0 RENDERER_DEFAULT=opengl - - - uses: actions/upload-artifact@v4 - if: matrix.cc == 'gcc' && matrix.btype == 'Release' - with: - name: linux-${{ matrix.arch }} - path: bin - if-no-files-found: error - retention-days: 5 - - macos-x86: - name: ${{ matrix.btype }} macOS ${{ matrix.arch }} - runs-on: macos-14 - strategy: - fail-fast: false - matrix: - arch: [x86_64, aarch64] - cc: [clang] - btype: [Release, Debug] - include: - - btype: Release - rule: install - - - btype: Debug - rule: debug - - steps: - - - name: Install tools - run: brew install coreutils sdl2 # pkg-config - - - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Build - if: ${{ github.event_name != 'release' || matrix.btype != 'Debug' }} # skip Debug configuration in Release build - run: | - make ${{ matrix.rule }} -j$(sysctl -n hw.logicalcpu) ARCH=${{ matrix.arch }} CC=${{ matrix.cc }} DESTDIR=bin INSTALL=ginstall USE_RENDERER_DLOPEN=0 RENDERER_DEFAULT=vulkan CNAME=quake3e-vulkan BUILD_SERVER=0 STRIP=echo - make clean ARCH=${{ matrix.arch }} - make ${{ matrix.rule }} -j$(sysctl -n hw.logicalcpu) ARCH=${{ matrix.arch }} CC=${{ matrix.cc }} DESTDIR=bin INSTALL=ginstall USE_RENDERER_DLOPEN=0 RENDERER_DEFAULT=opengl STRIP=echo - - - uses: actions/upload-artifact@v4 - if: matrix.cc == 'clang' && matrix.btype == 'Release' - with: - name: macos-${{ matrix.arch }} - path: bin - if-no-files-found: error - retention-days: 5 - - create-testing: - if: github.ref == 'refs/heads/main' && github.event_name == 'push' || github.event_name == 'workflow_dispatch' - needs: [windows-msys32, windows-msvc, ubuntu-x86, ubuntu-arm64, macos-x86] - runs-on: ubuntu-latest - steps: - - name: Download Artifacts - uses: actions/download-artifact@v4 - - - name: Create binary archives - run: | - 7z a -r quake3e-linux-x86.zip ./linux-x86/* - 7z a -r quake3e-linux-x86_64.zip ./linux-x86_64/* - 7z a -r quake3e-linux-arm64.zip ./linux-arm64/* - 7z a -r quake3e-windows-mingw-x86.zip ./windows-mingw-x86/* - 7z a -r quake3e-windows-mingw-x86_64.zip ./windows-mingw-x86_64/* - 7z a -r quake3e-windows-msvc-arm64.zip ./windows-msvc-arm64/* - 7z a -r quake3e-macos-x86_64.zip ./macos-x86_64/* - 7z a -r quake3e-macos-aarch64.zip ./macos-aarch64/* -# 7z a -r quake3e-linux-aarch64.zip ./linux-aarch64/* -# 7z a -r quake3e-linux-armv7.zip ./linux-armv7/* -# 7z a -r quake3e-windows-msvc-x86.zip ./windows-msvc-x86/* -# 7z a -r quake3e-windows-msvc-x86_64.zip ./windows-msvc-x86_64/* - - - name: Create latest build - uses: czietz/action-automatic-releases@latest - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - automatic_release_tag: "latest" - prerelease: false - title: Latest Build - files: | - *.zip - - update-release: - if: ${{ github.event_name == 'release' }} - needs: [windows-msys32, windows-msvc, ubuntu-x86, ubuntu-arm, macos-x86] - runs-on: ubuntu-latest - - strategy: - matrix: - include: -# - artifact_dir: linux-aarch64 -# artifact_name: quake3e-linux-aarch64.zip - -# - artifact_dir: linux-armv7 -# artifact_name: quake3e-linux-armv7.zip - - - artifact_dir: linux-x86 - artifact_name: quake3e-linux-x86.zip - - - artifact_dir: linux-x86_64 - artifact_name: quake3e-linux-x86_64.zip - - - artifact_dir: linux-arm64 - artifact_name: quake3e-linux-arm64.zip - - - artifact_dir: windows-mingw-x86 - artifact_name: quake3e-windows-x86.zip - - - artifact_dir: windows-mingw-x86_64 - artifact_name: quake3e-windows-x86_64.zip - - - artifact_dir: windows-msvc-arm64 - artifact_name: quake3e-windows-arm64.zip - - - artifact_dir: macos-x86_64 - artifact_name: quake3e-macos-x86_64.zip - - - artifact_dir: macos-aarch64 - artifact_name: quake3e-macos-aarch64.zip - - steps: - - name: Download Artifacts - uses: actions/download-artifact@v4 - - - name: Create archive - run: 7z a -r ${{ matrix.artifact_name }} ./${{ matrix.artifact_dir }}/* - - - name: Upload archive - uses: "svenstaro/upload-release-action@latest" - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ github.ref }} - overwrite: true - file: ${{ matrix.artifact_name }} +name: build + +on: + pull_request: + paths-ignore: + - '**.md' + - '*.txt' + - '.gitignore' + - 'docs/*' + push: + branches: + - main + paths-ignore: + - '**.md' + - '*.txt' + - '.gitignore' + - 'docs/*' + release: + types: [published] + + workflow_dispatch: + +jobs: + windows-msys: + name: ${{ matrix.btype }} Windows-${{ matrix.cc }} ${{ matrix.arch }} + runs-on: windows-2022 + strategy: + fail-fast: false + matrix: + arch: [x86, x86_64] + cc: [gcc] + btype: [Release, Debug] + include: + - arch: x86 + msystem: MINGW32 + prefix: mingw-w64-i686 + + - arch: x86_64 + msystem: MINGW64 + prefix: mingw-w64-x86_64 + + defaults: + run: + shell: msys2 {0} + + steps: + + - uses: msys2/setup-msys2@v2 + with: + install: base-devel ${{ matrix.prefix }}-binutils ${{ matrix.prefix }}-make ${{ matrix.prefix }}-${{ matrix.cc }} ${{ matrix.prefix }}-cmake ${{ matrix.prefix }}-ninja ${{ matrix.prefix }}-SDL2 + msystem: ${{ matrix.msystem }} + path-type: minimal + release: false + update: false + cache: false + + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Build Vulkan + if: ${{ github.event_name != 'release' || matrix.btype != 'Debug' }} # skip Debug configuration in Release build + env: + CFLAGS: "-DSKIP_IDPAK_CHECK=1" + run: | + mkdir -p build-vk-${{ matrix.btype }} + cmake -S . -B build-vk-${{ matrix.btype }} -G Ninja \ + -DCMAKE_BUILD_TYPE=${{ matrix.btype }} \ + -DUSE_STB_TRUETYPE=ON \ + -DENABLE_FORTIFY_SOURCE=OFF \ + -DENABLE_ASAN=OFF \ + -DBUILD_SERVER=OFF \ + -DUSE_VULKAN=ON \ + -DRENDERER_DEFAULT=vulkan \ + -DSKIP_IDPAK_CHECK=ON \ + -Wno-dev + cmake --build build-vk-${{ matrix.btype }} -j$(nproc) + mkdir -p bin + cp -f build-vk-${{ matrix.btype }}/idtech3* bin/ || true + + - name: Build OpenGL + if: ${{ github.event_name != 'release' || matrix.btype != 'Debug' }} # skip Debug configuration in Release build + env: + CFLAGS: "-DSKIP_IDPAK_CHECK=1" + run: | + mkdir -p build-gl-${{ matrix.btype }} + cmake -S . -B build-gl-${{ matrix.btype }} -G Ninja \ + -DCMAKE_BUILD_TYPE=${{ matrix.btype }} \ + -DUSE_STB_TRUETYPE=ON \ + -DENABLE_FORTIFY_SOURCE=OFF \ + -DENABLE_ASAN=OFF \ + -DBUILD_SERVER=OFF \ + -DUSE_VULKAN=ON \ + -DRENDERER_DEFAULT=opengl \ + -DSKIP_IDPAK_CHECK=ON \ + -Wno-dev + cmake --build build-gl-${{ matrix.btype }} -j$(nproc) + cp -f build-gl-${{ matrix.btype }}/idtech3* bin/ || true + + - uses: actions/upload-artifact@v4 + if: matrix.cc == 'gcc' && matrix.btype == 'Release' + with: + name: windows-${{ matrix.cc }}-${{ matrix.arch }} + path: bin + if-no-files-found: error + retention-days: 5 + + + + windows-msvc: + name: ${{ matrix.btype }} Windows-MSVC ${{ matrix.arch }} + runs-on: windows-2022 + strategy: + fail-fast: false + matrix: + arch: [arm64, x86, x64] + btype: [Release, Debug] + include: + - arch: arm64 + platform: ARM64 + suffix: .arm64 + pkg_suffix: arm64 + + - arch: x86 + platform: Win32 + pkg_suffix: x86 + + - arch: x64 + platform: x64 + suffix: .x64 + pkg_suffix: x86_64 + + steps: + + - uses: microsoft/setup-msbuild@v2 + + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Build + if: ${{ github.event_name != 'release' || matrix.btype != 'Debug' }} # skip Debug configuration in Release build + run: | + mkdir bin + + msbuild src\win32\msvc2017\quake3e-ded.vcxproj -p:TargetName=idtech3_server,Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }} /p:PlatformToolset=v143 + copy src\win32\msvc2017\output\idtech3_server.exe bin\idtech3_server${{ matrix.suffix }}.exe + msbuild src\win32\msvc2017\quake3e-ded.vcxproj -p:TargetName=idtech3_server,Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }} -t:Clean + + msbuild src\win32\msvc2017\renderer.vcxproj -p:Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }} /p:PlatformToolset=v143 + msbuild src\win32\msvc2017\quake3e.vcxproj -p:TargetName=idtech3,Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }},UseWasapi=USE_WASAPI=0 /p:PlatformToolset=v143 + copy src\win32\msvc2017\output\idtech3.exe bin\idtech3${{ matrix.suffix }}.exe + msbuild src\win32\msvc2017\renderer.vcxproj -p:Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }} -t:Clean + msbuild src\win32\msvc2017\quake3e.vcxproj -p:TargetName=idtech3,Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }},UseWasapi=USE_WASAPI=0 -t:Clean + + msbuild src\win32\msvc2017\renderervk.vcxproj -p:Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }} /p:PlatformToolset=v143 + msbuild src\win32\msvc2017\quake3e.vcxproj -p:TargetName=idtech3,Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }},UseWasapi=USE_WASAPI=0 /p:PlatformToolset=v143 + copy src\win32\msvc2017\output\idtech3.exe bin\idtech3-vulkan${{ matrix.suffix }}.exe + msbuild src\win32\msvc2017\renderervk.vcxproj -p:Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }} -t:Clean + msbuild src\win32\msvc2017\quake3e.vcxproj -p:TargetName=idtech3,Configuration=${{ matrix.btype }},Platform=${{ matrix.platform }},UseWasapi=USE_WASAPI=0 -t:Clean + + - uses: actions/upload-artifact@v4 + if: ${{ matrix.btype == 'Release' }} + with: + name: windows-msvc-${{ matrix.pkg_suffix }} + path: bin + if-no-files-found: error + retention-days: 5 + + ubuntu-x86: + name: ${{ matrix.btype }} Ubuntu ${{ matrix.arch }} + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + arch: [x86, x86_64] + cc: [gcc] + btype: [Release, Debug] + include: + - arch: x86 + cmake_arch: i686 + + - arch: x86_64 + cmake_arch: x86_64 + + steps: + + - name: Install tools + run: | + if [ ${{ matrix.arch }} == "x86" ]; then + sudo dpkg --add-architecture i386 + sudo apt-get -qq update + sudo apt-get -y install gcc-multilib g++-multilib cmake ninja-build libcurl4-openssl-dev:i386 mesa-common-dev:i386 libxxf86dga-dev:i386 libxrandr-dev:i386 libxxf86vm-dev:i386 libasound-dev:i386 libsdl2-dev:i386 + else + sudo apt-get -qq update + sudo apt-get -y install cmake ninja-build libcurl4-openssl-dev mesa-common-dev libxxf86dga-dev libxrandr-dev libxxf86vm-dev libasound-dev libsdl2-dev + fi + + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Build Vulkan + if: ${{ github.event_name != 'release' || matrix.btype != 'Debug' }} # skip in Release builds + env: + CFLAGS: "-DSKIP_IDPAK_CHECK=1 ${{ matrix.arch == 'x86' && '-m32' || '' }}" + CXXFLAGS: "-DSKIP_IDPAK_CHECK=1 ${{ matrix.arch == 'x86' && '-m32' || '' }}" + run: | + mkdir -p build-vk-${{ matrix.btype }} + cmake -S . -B build-vk-${{ matrix.btype }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.btype }} \ + -DUSE_STB_TRUETYPE=ON \ + -DENABLE_FORTIFY_SOURCE=OFF \ + -DENABLE_ASAN=OFF \ + -DBUILD_SERVER=OFF \ + -DUSE_VULKAN=ON \ + -DRENDERER_DEFAULT=vulkan \ + -DSKIP_IDPAK_CHECK=ON \ + -Wno-dev + cmake --build build-vk-${{ matrix.btype }} -j$(nproc) + mkdir -p bin + cp -f build-vk-${{ matrix.btype }}/idtech3* bin/ || true + + - name: Build OpenGL + if: ${{ github.event_name != 'release' || matrix.btype != 'Debug' }} # skip in Release builds + env: + CFLAGS: "-DSKIP_IDPAK_CHECK=1 ${{ matrix.arch == 'x86' && '-m32' || '' }}" + CXXFLAGS: "-DSKIP_IDPAK_CHECK=1 ${{ matrix.arch == 'x86' && '-m32' || '' }}" + run: | + mkdir -p build-gl-${{ matrix.btype }} + cmake -S . -B build-gl-${{ matrix.btype }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.btype }} \ + -DUSE_STB_TRUETYPE=ON \ + -DENABLE_FORTIFY_SOURCE=OFF \ + -DENABLE_ASAN=OFF \ + -DBUILD_SERVER=OFF \ + -DUSE_VULKAN=ON \ + -DRENDERER_DEFAULT=opengl \ + -DSKIP_IDPAK_CHECK=ON \ + -Wno-dev + cmake --build build-gl-${{ matrix.btype }} -j$(nproc) + cp -f build-gl-${{ matrix.btype }}/idtech3* bin/ || true + + - uses: actions/upload-artifact@v4 + if: matrix.cc == 'gcc' && matrix.btype == 'Release' + with: + name: linux-${{ matrix.arch }} + path: bin + if-no-files-found: error + retention-days: 5 + + ubuntu-arm: + name: ${{ matrix.btype }} Ubuntu [ARM] ${{ matrix.arch }} + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + arch: [aarch64, armv7] + cc: [gcc] + btype: [Release, Debug] + include: + - btype: Release + rule: install + + - btype: Debug + rule: debug + + steps: + + - uses: actions/checkout@v4 + if: false + with: + submodules: recursive + + - name: Build ${{ matrix.arch }} + #if: ${{ github.event_name != 'release' || matrix.btype != 'Debug' }} # skip Debug configuration in Release build + if: false + uses: uraimo/run-on-arch-action@v3 + with: + arch: ${{ matrix.arch }} + distro: ubuntu24.04 + githubToken: ${{ github.token }} + shell: /bin/sh + run: | + apt-get -qq update + apt-get install -y make gcc g++ + apt-get -y install libcurl4-openssl-dev mesa-common-dev libxxf86dga-dev libxrandr-dev libxxf86vm-dev libasound-dev + + make ${{ matrix.rule }} -j$(nproc) ARCH=${{ matrix.arch }} CC=${{ matrix.cc }} DESTDIR=bin MOUNT_DIR=src USE_SDL=0 USE_RENDERER_DLOPEN=0 RENDERER_DEFAULT=vulkan CNAME=idtech3-vulkan BUILD_SERVER=0 + make clean ARCH=${{ matrix.arch }} + make ${{ matrix.rule }} -j$(nproc) ARCH=${{ matrix.arch }} CC=${{ matrix.cc }} DESTDIR=bin MOUNT_DIR=src USE_SDL=0 USE_RENDERER_DLOPEN=0 RENDERER_DEFAULT=opengl + + - uses: actions/upload-artifact@v4 + if: false + #if: matrix.cc == 'gcc' && matrix.btype == 'Release' + with: + name: linux-${{ matrix.arch }} + path: bin + if-no-files-found: error + retention-days: 5 + + ubuntu-arm64: + name: ${{ matrix.btype }} Ubuntu ${{ matrix.arch }} + runs-on: ubuntu-22.04-arm + strategy: + fail-fast: false + matrix: + arch: [arm64] + cc: [gcc] + btype: [Release, Debug] + + steps: + + - name: Install tools + run: | + sudo apt-get -qq update + sudo apt-get install -y make gcc g++ cmake ninja-build + sudo apt-get -y install libcurl4-openssl-dev mesa-common-dev libxxf86dga-dev libxrandr-dev libxxf86vm-dev libasound-dev libsdl2-dev + + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Build Vulkan + if: ${{ github.event_name != 'release' || matrix.btype != 'Debug' }} # skip Debug configuration in Release build + env: + CFLAGS: "-DSKIP_IDPAK_CHECK=1" + run: | + mkdir -p build-vk-${{ matrix.btype }} + cmake -S . -B build-vk-${{ matrix.btype }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.btype }} \ + -DUSE_STB_TRUETYPE=ON \ + -DENABLE_FORTIFY_SOURCE=OFF \ + -DENABLE_ASAN=OFF \ + -DBUILD_SERVER=OFF \ + -DUSE_VULKAN=ON \ + -DRENDERER_DEFAULT=vulkan \ + -DSKIP_IDPAK_CHECK=ON \ + -Wno-dev + cmake --build build-vk-${{ matrix.btype }} -j$(nproc) + mkdir -p bin + cp -f build-vk-${{ matrix.btype }}/idtech3* bin/ || true + + - name: Build OpenGL + if: ${{ github.event_name != 'release' || matrix.btype != 'Debug' }} # skip Debug configuration in Release build + env: + CFLAGS: "-DSKIP_IDPAK_CHECK=1" + run: | + mkdir -p build-gl-${{ matrix.btype }} + cmake -S . -B build-gl-${{ matrix.btype }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.btype }} \ + -DUSE_STB_TRUETYPE=ON \ + -DENABLE_FORTIFY_SOURCE=OFF \ + -DENABLE_ASAN=OFF \ + -DBUILD_SERVER=OFF \ + -DUSE_VULKAN=ON \ + -DRENDERER_DEFAULT=opengl \ + -DSKIP_IDPAK_CHECK=ON \ + -Wno-dev + cmake --build build-gl-${{ matrix.btype }} -j$(nproc) + cp -f build-gl-${{ matrix.btype }}/idtech3* bin/ || true + + - uses: actions/upload-artifact@v4 + if: matrix.cc == 'gcc' && matrix.btype == 'Release' + with: + name: linux-${{ matrix.arch }} + path: bin + if-no-files-found: error + retention-days: 5 + + macos-x86: + name: ${{ matrix.btype }} macOS ${{ matrix.arch }} + runs-on: macos-14 + strategy: + fail-fast: false + matrix: + # Build only the native Apple Silicon architecture on macOS runners to avoid cross-arch Homebrew issues. + # Apple-provided runners are arm64 (aarch64); building x86_64 here pulls arm64 Homebrew libs and causes linker mismatches. + arch: [aarch64] + cc: [clang] + btype: [Release, Debug] + + steps: + + - name: Install tools + run: brew install coreutils sdl2 cmake ninja + + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Build Vulkan + if: ${{ github.event_name != 'release' || matrix.btype != 'Debug' }} # skip Debug configuration in Release build + env: + CFLAGS: "-DSKIP_IDPAK_CHECK=1" + run: | + # Set SDL2 path for Homebrew (Apple Silicon uses /opt/homebrew, Intel uses /usr/local) + SDL2_PREFIX=$(brew --prefix sdl2) + mkdir -p build-vk-${{ matrix.btype }} + cmake -S . -B build-vk-${{ matrix.btype }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.btype }} \ + -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch == 'aarch64' && 'arm64' || matrix.arch }} \ + -DSDL2_PATH="${SDL2_PREFIX}" \ + -DUSE_STB_TRUETYPE=ON \ + -DENABLE_FORTIFY_SOURCE=OFF \ + -DENABLE_ASAN=OFF \ + -DBUILD_SERVER=OFF \ + -DUSE_VULKAN=ON \ + -DRENDERER_DEFAULT=vulkan \ + -DSKIP_IDPAK_CHECK=ON \ + -Wno-dev + cmake --build build-vk-${{ matrix.btype }} -j$(sysctl -n hw.logicalcpu) + mkdir -p bin + cp -f build-vk-${{ matrix.btype }}/idtech3* bin/ || true + + - name: Build OpenGL + if: ${{ github.event_name != 'release' || matrix.btype != 'Debug' }} # skip Debug configuration in Release build + env: + CFLAGS: "-DSKIP_IDPAK_CHECK=1" + run: | + # Set SDL2 path for Homebrew (Apple Silicon uses /opt/homebrew, Intel uses /usr/local) + SDL2_PREFIX=$(brew --prefix sdl2) + mkdir -p build-gl-${{ matrix.btype }} + cmake -S . -B build-gl-${{ matrix.btype }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.btype }} \ + -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch == 'aarch64' && 'arm64' || matrix.arch }} \ + -DSDL2_PATH="${SDL2_PREFIX}" \ + -DUSE_STB_TRUETYPE=ON \ + -DENABLE_FORTIFY_SOURCE=OFF \ + -DENABLE_ASAN=OFF \ + -DBUILD_SERVER=OFF \ + -DUSE_VULKAN=ON \ + -DRENDERER_DEFAULT=opengl \ + -DSKIP_IDPAK_CHECK=ON \ + -Wno-dev + cmake --build build-gl-${{ matrix.btype }} -j$(sysctl -n hw.logicalcpu) + cp -f build-gl-${{ matrix.btype }}/idtech3* bin/ || true + + - uses: actions/upload-artifact@v4 + if: matrix.cc == 'clang' && matrix.btype == 'Release' + with: + name: macos-${{ matrix.arch }} + path: bin + if-no-files-found: error + retention-days: 5 + + create-testing: + if: github.ref == 'refs/heads/main' && github.event_name == 'push' || github.event_name == 'workflow_dispatch' + needs: [windows-msys, windows-msvc, ubuntu-x86, ubuntu-arm64, macos-x86] + runs-on: ubuntu-latest + steps: + - name: Download Artifacts + uses: actions/download-artifact@v4 + + - name: Create binary archives + run: | + if [ -d ./linux-x86 ]; then 7z a -r idtech3-linux-x86.zip ./linux-x86/*; else echo "skip linux-x86"; fi + if [ -d ./linux-x86_64 ]; then 7z a -r idtech3-linux-x86_64.zip ./linux-x86_64/*; else echo "skip linux-x86_64"; fi + if [ -d ./linux-arm64 ]; then 7z a -r idtech3-linux-arm64.zip ./linux-arm64/*; else echo "skip linux-arm64"; fi + if [ -d ./windows-gcc-x86 ]; then 7z a -r idtech3-windows-gcc-x86.zip ./windows-gcc-x86/*; else echo "skip windows-gcc-x86"; fi + if [ -d ./windows-gcc-x86_64 ]; then 7z a -r idtech3-windows-gcc-x86_64.zip ./windows-gcc-x86_64/*; else echo "skip windows-gcc-x86_64"; fi + if [ -d ./windows-msvc-arm64 ]; then 7z a -r idtech3-windows-msvc-arm64.zip ./windows-msvc-arm64/*; else echo "skip windows-msvc-arm64"; fi + if [ -d ./macos-aarch64 ]; then 7z a -r idtech3-macos-aarch64.zip ./macos-aarch64/*; else echo "skip macos-aarch64"; fi +# 7z a -r idtech3-linux-aarch64.zip ./linux-aarch64/* +# 7z a -r idtech3-linux-armv7.zip ./linux-armv7/* +# 7z a -r idtech3-windows-msvc-x86.zip ./windows-msvc-x86/* +# 7z a -r idtech3-windows-msvc-x86_64.zip ./windows-msvc-x86_64/* + + - name: Create latest build + uses: czietz/action-automatic-releases@latest + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + automatic_release_tag: "latest" + prerelease: false + title: Latest Build + files: | + *.zip + + update-release: + if: ${{ github.event_name == 'release' }} + needs: [windows-msys, windows-msvc, ubuntu-x86, ubuntu-arm, macos-x86] + runs-on: ubuntu-latest + + strategy: + matrix: + include: +# - artifact_dir: linux-aarch64 +# artifact_name: idtech3-linux-aarch64.zip + +# - artifact_dir: linux-armv7 +# artifact_name: idtech3-linux-armv7.zip + + - artifact_dir: linux-x86 + artifact_name: idtech3-linux-x86.zip + + - artifact_dir: linux-x86_64 + artifact_name: idtech3-linux-x86_64.zip + + - artifact_dir: linux-arm64 + artifact_name: idtech3-linux-arm64.zip + + - artifact_dir: windows-gcc-x86 + artifact_name: idtech3-windows-x86.zip + + - artifact_dir: windows-gcc-x86_64 + artifact_name: idtech3-windows-x86_64.zip + + - artifact_dir: windows-msvc-arm64 + artifact_name: idtech3-windows-arm64.zip + + - artifact_dir: macos-x86_64 + artifact_name: idtech3-macos-x86_64.zip + + - artifact_dir: macos-aarch64 + artifact_name: idtech3-macos-aarch64.zip + + steps: + - name: Download Artifacts + uses: actions/download-artifact@v4 + + - name: Create archive + run: 7z a -r ${{ matrix.artifact_name }} ./${{ matrix.artifact_dir }}/* + + - name: Upload archive + uses: "svenstaro/upload-release-action@latest" + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref }} + overwrite: true + file: ${{ matrix.artifact_name }} diff --git a/.gitignore b/.gitignore index 1fecdbd978..028452846e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,30 @@ build/ +build*/ output/ .vs/ .vscode/ *.user cmake-* .idea +usdinterop/ +release/ +blacksun/ +q3rtx/ +wolf/ +idtech3pbr/ +q3ios/ +logs/ +reference/ +mods/mymod/ +mods/base/ +mods/baseq3/ +base/ +baseq3/ +build +.cursor/debug.log +.cursor/trace.log +safe_mode.flag +enable_vulkan_patch1.flag +enable_vulkan_patch1_tiny.flag +.cursor/ +test-build/ diff --git a/BUILD.md b/BUILD.md index 5a4eba1b97..7ffd99eabb 100644 --- a/BUILD.md +++ b/BUILD.md @@ -4,9 +4,9 @@ Install Visual Studio Community Edition 2017 or later and compile `quake3e` project from solution -`code/win32/msvc2017/quake3e.sln` +`src/win32/msvc2017/quake3e.sln` -Copy resulting exe from `code/win32/msvc2017/output` directory +Copy resulting exe from `src/win32/msvc2017/output` directory To compile with Vulkan backend - clean solution, right click on `quake3e` project, find `Project Dependencies` and select `renderervk` instead of `renderer` diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000000..e553064f40 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,516 @@ +# idTech3 Project Constitution + +## Preamble + +This document serves as the **constitutional contract** for the idTech3 engine fork. It defines the project's goals, constraints, and operational rules. All contributors must adhere to these principles. This constitution protects the project's integrity and provides guidance for decision-making. + +**Last Updated**: January 18, 2026 +**Version**: 1.0 + +--- + +## 🎯 PROJECT GOALS + +### What "Done" Looks Like + +#### Vulkan Renderer (PRIMARY GOAL) +- ✅ **Hardware Acceleration**: Full Vulkan 1.4 + RTX support +- ✅ **Fallback Compatibility**: Automatic OpenGL fallback for all systems +- ✅ **Performance**: 2x+ FPS improvement over OpenGL baseline +- ✅ **Stability**: Zero crashes in production use +- ✅ **Validation**: Clean validation layers, no warnings +- ✅ **CI Coverage**: Automated testing across GCC/Clang, Debug/Release + +#### Physically Based Rendering (PBR) +- ✅ **Material System**: Metalness/roughness workflow +- ✅ **Lighting**: Image-based lighting + area lights +- ✅ **Backward Compatibility**: Classic materials still work +- ✅ **Performance**: Minimal overhead when disabled + +#### Ray Tracing (RTX) +- ✅ **Hardware Support**: NVIDIA RTX GPUs with automatic detection +- ✅ **Quality Levels**: Multiple quality presets (performance/balanced/quality) +- ✅ **Fallback**: Graceful degradation on non-RTX hardware +- ✅ **Integration**: Seamless blending with rasterization + +#### Modern C/C++ Standards +- ✅ **C23 Features**: Modern language constructs where beneficial +- ✅ **C++23 Integration**: Strategic C++ usage for complex systems +- ✅ **ABI Stability**: No breaking changes to mod compatibility +- ✅ **Performance**: Zero-cost abstractions + +#### Developer Experience +- ✅ **Build System**: One-command builds for all configurations +- ✅ **Testing**: Comprehensive automated test suite +- ✅ **Debugging**: Rich debugging tools and error reporting +- ✅ **Documentation**: Complete architectural documentation + +### Success Metrics +- **Compatibility**: 100% backward compatibility with Quake III Arena +- **Performance**: Measurable improvements in target use cases +- **Stability**: Zero crashes in CI-validated scenarios +- **Maintainability**: Code remains understandable and extensible + +--- + +## 🏗️ ARCHITECTURAL PRINCIPLES + +### Layer Cake Architecture + +#### Vanilla Layer (FOUNDATION) +**What**: Pure Id Tech 3 engine - never modified +**Purpose**: Eternal compatibility guarantee +**Rules**: +- Never change existing APIs without 100% backward compatibility +- Original Quake III Arena runs perfectly +- Core engine logic remains untouched +- Historical decisions are preserved + +#### Chocolate Layer (ENHANCEMENT) +**What**: Performance and quality improvements +**Purpose**: Better experience with zero breaking changes +**Rules**: +- All enhancements must have fallbacks +- Features can be disabled completely +- Performance improvements are measurable +- Compatibility is never sacrificed + +#### Layer Cake (ARCHITECTURE) +**What**: Modern abstractions and systems +**Purpose**: Technical foundation for future development +**Rules**: +- Clean separation of concerns +- Extensible plugin architecture +- Modern C/C++ patterns where beneficial +- API stability for long-term maintenance + +### Renderer Boundary (SACRED) +The renderer abstraction layer is **architecturally sensitive**: +- Public interfaces change only when absolutely necessary +- Renderer-specific code stays within renderer modules +- Cross-renderer compatibility maintained +- Fallback chains are robust and tested + +--- + +## 🌿 BRANCH STRATEGY + +### Main Branch (`main`) +**Purpose**: Production-ready code +**Rules**: +- Always buildable and testable +- Comprehensive CI validation +- Release candidate quality +- No experimental features + +### Development Branches +**Naming**: `feature/` +**Rules**: +- Feature-complete before merge +- Comprehensive testing included +- Documentation updated +- CI validation passes + +### Layer Branches (Conceptual) +**Vanilla Branches**: `vanilla/*` - Core engine changes +**Chocolate Branches**: `chocolate/*` - Enhancement features +**Layercake Branches**: `layercake/*` - Architectural changes + +### Release Branches +**Naming**: `release/v.` +**Purpose**: Stabilization for releases +**Rules**: +- Only bug fixes and documentation +- Extensive testing and validation +- Release notes prepared + +--- + +## 💻 CODING CONVENTIONS + +### Language Standards +- **C**: C23 with modern features (designated initializers, constexpr, etc.) +- **C++**: C++23 for complex systems (RAII, templates, smart pointers) +- **Compatibility**: Code must compile with GCC 15+ and Clang 18+ + +### Naming Conventions + +#### Functions and Variables +```c +// C style (preferred for engine core) +void R_InitRenderer(void); +cvar_t *r_vulkan_validation; + +// C++ style (for C++ code) +void MaterialSystem::Initialize(); +std::unique_ptr renderer; +``` + +#### Files and Directories +``` +src/ +├── client/ # Client-side systems +├── server/ # Server-side systems +├── renderers/ # Renderer implementations +│ ├── vulkan/ # Vulkan renderer +│ └── opengl/ # OpenGL renderer +├── common/ # Shared utilities +└── game/ # Game logic +``` + +#### Constants and Enums +```c +// C style +#define MAX_QPATH 64 +enum { + ERR_NONE, + ERR_FATAL, + ERR_WARNING +}; + +// C++ style (when using C++) +enum class ErrorCode { + None, + Fatal, + Warning +}; +``` + +### Code Organization + +#### File Structure +- **Headers** (.h): Interface declarations, no implementation +- **Implementation** (.c/.cpp): Function definitions +- **One responsibility** per file +- **Include guards** or `#pragma once` + +#### Function Organization +```c +/* +=============== +FunctionName +=============== +*/ +static void FunctionName(void) { + // Implementation +} +``` + +### Logging Standards + +#### Log Levels +```c +// Priority order (most to least important) +Com_Error(ERR_FATAL, "Critical failure"); // Crashes engine +Com_Printf(S_COLOR_RED "Error: %s\n", msg); // Error conditions +Com_Printf(S_COLOR_YELLOW "Warning: %s\n", msg); // Warning conditions +Com_Printf("Info: %s\n", msg); // General information +ri.Printf(PRINT_DEVELOPER, "Debug: %s\n"); // Development only +``` + +#### Log Categories +- **Startup**: Renderer initialization, feature detection +- **Performance**: FPS, memory usage, bottlenecks +- **Errors**: Clear error messages with recovery suggestions +- **Debug**: Detailed internal state for troubleshooting + +### Error Handling + +#### Error Recovery Hierarchy +1. **Silent Recovery**: Fix and continue (preferred) +2. **Warning Message**: Continue with degraded functionality +3. **Fallback Mode**: Use alternative implementation +4. **Safe Shutdown**: Clean exit with error report + +#### Error Patterns +```c +// Check and recover +if (!resource) { + Com_Printf(S_COLOR_YELLOW "Warning: Resource failed, using fallback\n"); + UseFallbackResource(); + return qtrue; // Continue execution +} + +// Fatal error - cannot continue +if (!critical_system) { + Com_Error(ERR_FATAL, "Critical system failed to initialize"); +} +``` + +### Memory Management + +#### Allocation Patterns +- **Pool Allocators**: For frequently allocated objects +- **Arena Allocators**: For level/map data +- **Stack Allocation**: For temporary buffers +- **RAII**: In C++ code where appropriate + +#### Memory Safety +- **Bounds Checking**: All array accesses validated +- **Null Checks**: Pointer validation before use +- **Leak Detection**: Automated testing with Valgrind +- **Corruption Detection**: Memory integrity validation + +--- + +## 🔨 BUILD TRUTH + +### Canonical Build Process + +#### Linux (Primary Development Platform) +```bash +# Prerequisites +sudo apt-get install cmake clang-18 gcc-15 ninja-build + +# Vulkan build (recommended) +./scripts/compile_engine.sh vulkan + +# OpenGL build (fallback) +./scripts/compile_engine.sh opengl + +# Debug build +./scripts/compile_engine.sh vulkan debug + +# Clean build +./scripts/compile_engine.sh clean vulkan +``` + +#### Windows (Cross-Platform Validation) +```bash +# Using MSYS2 +./scripts/compile_engine.sh vulkan + +# Visual Studio (alternative) +cmake -G "Visual Studio 17 2022" .. +cmake --build . --config Release +``` + +### Build System Requirements + +#### CMake Configuration +- **Minimum Version**: 3.20 +- **Generator**: Ninja (preferred) or Make +- **Build Types**: Debug, Release, RelWithDebInfo +- **Cross-Compilation**: Supported via toolchain files + +#### Compiler Requirements +- **GCC**: 15.0+ with C23/C++23 support +- **Clang**: 18.0+ with modern optimizations +- **MSVC**: 2022+ (Windows cross-compilation) + +#### Dependency Management +- **System Packages**: SDL2, Vulkan SDK, OpenEXR, etc. +- **Build Dependencies**: Automatically detected +- **Optional Features**: Gracefully disabled if dependencies missing + +### Build Validation + +#### CI Requirements +- **Matrix Builds**: GCC + Clang, Debug + Release +- **Warning Policy**: Errors for new/changed code only +- **Test Execution**: Smoke tests and basic validation +- **Artifact Upload**: Binaries and logs for verification + +#### Local Development +- **Incremental Builds**: Fast rebuilds for development +- **Clean Builds**: Full rebuilds for validation +- **Cross-Compilation**: Test Windows builds on Linux + +--- + +## 🚫 NON-GOALS + +### Things We Will NOT Do + +#### Architecture +- **No Engine-Wide C++ Rewrite**: Strategic C++ usage, not conversion +- **No Breaking Changes**: Existing mods always work +- **No Monolithic Architecture**: Modular design preserved +- **No Vendor Lock-in**: Multi-vendor GPU support maintained + +#### Compatibility +- **No API Breaking**: Public interfaces remain stable +- **No File Format Changes**: Existing assets always load +- **No Network Protocol Changes**: Compatible with existing servers +- **No License Changes**: GPL compatibility maintained + +#### Scope +- **No Game Development**: Engine only, no built-in games +- **No Platform Exclusivity**: Linux-first but cross-platform +- **No Feature Bloat**: Each feature must prove its value +- **No Experimental Dependencies**: Only stable, well-supported libraries + +#### Development Process +- **No Big Bang Rewrites**: Incremental, testable changes +- **No Unreviewed Code**: All changes go through review +- **No Undocumented Features**: Every feature documented +- **No Unmaintained Code**: Code must be maintainable long-term + +### Why These Constraints? + +#### Stability First +The engine serves **production games** that cannot break. Compatibility and stability take precedence over shiny new features. + +#### Long-Term Maintenance +This engine will be maintained for **decades**. Decisions must consider 10-year maintainability, not 6-month convenience. + +#### Ecosystem Health +Breaking changes harm the **entire modding ecosystem**. We protect the community by maintaining compatibility. + +#### Focus Preservation +Limited scope prevents **feature creep** and maintains focus on core engine excellence. + +--- + +## 📋 DEVELOPMENT WORKFLOW + +### Code Contribution Process + +#### 1. Planning +- Consult this constitution for architectural decisions +- Choose appropriate layer (vanilla/chocolate/layercake) +- Plan incremental implementation + +#### 2. Implementation +- Follow coding conventions +- Include comprehensive error handling +- Add logging for debugging +- Write tests for new functionality + +#### 3. Validation +- Build with all supported compilers +- Run full test suite +- Validate no regressions +- Update documentation + +#### 4. Review +- Clear commit messages +- Documentation updated +- CI validation passes +- Architectural compliance verified + +### Quality Gates + +#### Code Review Checklist +- [ ] Architectural compliance (layer assignment correct) +- [ ] Coding conventions followed +- [ ] Error handling comprehensive +- [ ] Logging appropriate +- [ ] Tests included +- [ ] Documentation updated + +#### CI Validation +- [ ] All compilers pass +- [ ] No new warnings +- [ ] Tests pass +- [ ] Smoke tests validate functionality + +#### Release Criteria +- [ ] All quality gates pass +- [ ] Documentation complete +- [ ] Backward compatibility verified +- [ ] Performance impact assessed + +--- + +## 🎯 DECISION FRAMEWORK + +### How to Decide What to Implement + +#### Questions to Ask +1. **Which Layer?** Does this fit vanilla/chocolate/layercake? +2. **Compatibility?** Will existing mods break? +3. **Maintainability?** Can this be maintained for 10+ years? +4. **Value?** Does this provide clear benefit to users? +5. **Scope?** Is this within our defined goals? + +#### Architectural Review +All significant changes require architectural review: +- Impact on renderer boundary +- Compatibility implications +- Maintenance burden assessment +- Performance impact analysis + +#### When to Say No +- **Breaking Changes**: If it breaks existing mods +- **Maintenance Burden**: If it creates unsustainable complexity +- **Scope Creep**: If it doesn't align with core goals +- **Risk**: If it introduces instability without clear benefit + +--- + +## 📚 REFERENCE + +### Key Documents +- **[ARCHITECTURE.md](docs/ARCHITECTURE.md)**: High-level architectural overview +- **[RENDERERS.md](docs/RENDERERS.md)**: Renderer architecture and features +- **[BRANCHES.md](docs/BRANCHES.md)**: Development philosophy +- **[ROADMAP.md](docs/ROADMAP.md)**: Development priorities +- **[DEVELOPMENT_SETUP.md](docs/DEVELOPMENT_SETUP.md)**: Development environment + +### Build Scripts +- `./scripts/compile_engine.sh` - Primary build script +- `./scripts/smoke_test.sh` - Basic validation +- `./scripts/validate_ci_build.sh` - Full CI validation + +### Quality Tools +- `./scripts/run_clang_tidy.sh` - Code quality analysis +- `./scripts/run_cppcheck.sh` - Static analysis +- `./scripts/test_engine.sh` - Comprehensive testing + +--- + +## AMENDMENT PROCESS + +This constitution can be amended through: +1. **Community Consensus**: Discussion and agreement +2. **Architectural Review**: Technical validation +3. **Documentation Update**: Clear record of changes +4. **Version Bumping**: Constitution version incremented + +**Rationale**: Project constraints evolve, but changes must be deliberate and well-considered. + +--- + +## USER RULES (Personal Defaults) + +These are my personal rules that apply to **all changes I make**, regardless of project. They prevent "AI drift" and keep modifications focused and safe. + +### Core Principles +- **Never change gameplay behavior unless explicitly requested** +- **Keep C ABI stable; wrap C++ in `#ifdef __cplusplus` guards only** +- **No new dependencies without explicit justification and approval** +- **Every new feature must include a toggle and startup log line** +- **Prefer small, reviewable commits over large refactoring** + +### Implementation Rules +- **Preserve existing APIs and interfaces** +- **Add logging for all new code paths** +- **Include error handling for edge cases** +- **Test changes before committing** +- **Document non-obvious design decisions** + +### Quality Standards +- **No code without tests (where applicable)** +- **No features without documentation** +- **No changes without backward compatibility** +- **No complexity without justification** +- **No "cleanup" commits without clear benefit** + +### Communication Rules +- **Explain reasoning for non-obvious changes** +- **Ask before making architectural changes** +- **Flag when I'm unsure about approach** +- **Provide context for design decisions** +- **Be explicit about tradeoffs and alternatives** + +### Boundaries +- **Don't rewrite working code "because it's ugly"** +- **Don't add features "because they're cool"** +- **Don't change patterns "to be more modern"** +- **Don't optimize "just in case"** +- **Don't abstract "for future flexibility"** + +--- + +*This constitution ensures the idTech3 engine remains a stable, maintainable, and extensible foundation for game development for decades to come.* diff --git a/CMakeLists.txt b/CMakeLists.txt index 45f69f01ed..93cf50cc1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,23 +1,25 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.12) +CMAKE_MINIMUM_REQUIRED(VERSION 3.24) -PROJECT(quake3e) +PROJECT(idtech3) -SET(CNAME "quake3e") -SET(DNAME "quake3e.ded") +SET(CNAME "idtech3") +SET(DNAME "idtech3_server") SET(RENDERER_PREFIX ${CNAME}) -SET(RENDERER_DEFAULT opengl) # valid options: opengl, vulkan, opengl2 +SET(RENDERER_DEFAULT vulkan) # valid options: opengl, vulkan, opengl2 OPTION(USE_SDL "" ON) OPTION(USE_CURL "" ON) OPTION(USE_LOCAL_HEADERS "" ON) OPTION(USE_VULKAN "" ON) +OPTION(USE_MP3 "Enable MP3 codec support" ON) OPTION(USE_SYSTEM_JPEG "" OFF) OPTION(USE_RENDERER_DLOPEN "" ON) +OPTION(SKIP_IDPAK_CHECK "Skip checking for original Quake III pak files (pak0.pk3)" OFF) SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules) -AUX_SOURCE_DIRECTORY(code/qcommon QCOMMON_SRCS) +AUX_SOURCE_DIRECTORY(src/qcommon QCOMMON_SRCS) # exclude platform-dependent QVM bytecode compilers list(FILTER QCOMMON_SRCS EXCLUDE REGEX ".*vm_[alx].*.c") # add platform-dependent QVM bytecode compilers @@ -33,27 +35,40 @@ IF(CMAKE_SYSTEM_PROCESSOR MATCHES AMD64|x86|i*86) #SET(BINEXT .x86) SET(RENDEXT _x86) ENDIF() - list(APPEND QCOMMON_SRCS code/qcommon/vm_x86.c) + list(APPEND QCOMMON_SRCS src/qcommon/vm_x86.c) ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES aarch64|arm64) SET(BINEXT .aarch64) SET(RENDEXT _aarch64) - list(APPEND QCOMMON_SRCS code/qcommon/vm_aarch64.c) + list(APPEND QCOMMON_SRCS src/qcommon/vm_aarch64.c) ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES arm*) SET(BINEXT .arm) SET(RENDEXT _arm) - list(APPEND QCOMMON_SRCS code/qcommon/vm_armv7l.c) + list(APPEND QCOMMON_SRCS src/qcommon/vm_armv7l.c) ELSE() TARGET_COMPILE_DEFINITIONS(qcommon PRIVATE -DNO_VM_COMPILED) TARGET_COMPILE_DEFINITIONS(qcommon_ded PRIVATE -DNO_VM_COMPILED) ENDIF() +# Normalize a simple arch identifier for renderer filenames (x86_64, x86, arm64, arm) +if(CMAKE_SYSTEM_PROCESSOR MATCHES AMD64|x86_64|X86_64) + set(TARGET_ARCH_NAME "x86_64") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES i.86|i386|i486|i586|i686) + set(TARGET_ARCH_NAME "x86") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES aarch64|arm64) + set(TARGET_ARCH_NAME "arm64") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES arm*) + set(TARGET_ARCH_NAME "arm") +else() + set(TARGET_ARCH_NAME "") +endif() + # botlib -AUX_SOURCE_DIRECTORY(code/botlib BOTLIB_SRCS) +AUX_SOURCE_DIRECTORY(src/botlib BOTLIB_SRCS) ADD_LIBRARY(botlib OBJECT ${BOTLIB_SRCS}) TARGET_COMPILE_DEFINITIONS(botlib PRIVATE BOTLIB) -AUX_SOURCE_DIRECTORY(code/server SERVER_SRCS) -list(REMOVE_ITEM SERVER_SRCS code/server/sv_rankings.c) +AUX_SOURCE_DIRECTORY(src/server SERVER_SRCS) +list(REMOVE_ITEM SERVER_SRCS src/server/sv_rankings.c) # universal binary ADD_LIBRARY(qcommon OBJECT ${QCOMMON_SRCS} ${SERVER_SRCS}) @@ -62,10 +77,52 @@ ADD_LIBRARY(qcommon OBJECT ${QCOMMON_SRCS} ${SERVER_SRCS}) ADD_LIBRARY(qcommon_ded OBJECT ${QCOMMON_SRCS} ${SERVER_SRCS}) TARGET_COMPILE_DEFINITIONS(qcommon_ded PUBLIC DEDICATED) +# Apply SKIP_IDPAK_CHECK to qcommon targets that compile files.c +if(SKIP_IDPAK_CHECK) + TARGET_COMPILE_DEFINITIONS(qcommon PRIVATE SKIP_IDPAK_CHECK=1) + TARGET_COMPILE_DEFINITIONS(qcommon_ded PRIVATE SKIP_IDPAK_CHECK=1) +endif() + # client + cURL -AUX_SOURCE_DIRECTORY(code/client CLIENT_SRCS) +# client sources +AUX_SOURCE_DIRECTORY(src/client CLIENT_SRCS) +# include architecture-specific assembly implementations (snd_mix etc) +# Only include x86/x86_64 assembly files on x86/x86_64 architectures on Unix-like systems +# Assembly is disabled on Windows due to preprocessor macro issues with MSYS2/MinGW +IF(UNIX AND CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64|x86|i.86|x86_64|X86_64") + # Only enable handwritten x86/x86_64 assembly when building a 64-bit target. + # 32-bit builds will use the portable C fallbacks to avoid assembler/arch mismatches. + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + file(GLOB ASM_SRCS "src/asm/*.S" "src/asm/*.s") + list(APPEND CLIENT_SRCS ${ASM_SRCS}) + # Ensure CMake knows how to compile assembly sources + enable_language(ASM) + if(ASM_SRCS) + set_source_files_properties(${ASM_SRCS} PROPERTIES LANGUAGE ASM) + # run assembler sources through the C preprocessor and use Intel syntax + # Note: -masm=intel is GCC-specific; Clang uses Intel syntax by default for .s files + set(ASM_FLAGS "-x assembler-with-cpp") + if(CMAKE_C_COMPILER_ID STREQUAL "GNU") + set(ASM_FLAGS "${ASM_FLAGS} -masm=intel") + endif() + set_source_files_properties(${ASM_SRCS} PROPERTIES COMPILE_FLAGS "${ASM_FLAGS}") + endif() + # Define USE_ASM to tell the code that assembly optimizations are available + ADD_COMPILE_DEFINITIONS(USE_ASM) + else() + # 32-bit: do not compile asm sources; rely on C implementations. + set(ASM_SRCS "") + endif() +ENDIF() IF(NOT USE_CURL) - list(REMOVE_ITEM CLIENT_SRCS code/client/cl_curl.c) + list(REMOVE_ITEM CLIENT_SRCS src/client/cl_curl.c) +ENDIF() +IF(NOT USE_MP3) + list(REMOVE_ITEM CLIENT_SRCS src/client/snd_codec_mp3.c) +ENDIF() +IF(USE_MP3) + AUX_SOURCE_DIRECTORY(src/client/mp3 MP3_SRCS) + list(APPEND CLIENT_SRCS ${MP3_SRCS}) ENDIF() #ADD_LIBRARY(client OBJECT ${CLIENT_SRCS}) @@ -77,22 +134,24 @@ IF(USE_SYSTEM_JPEG) TARGET_COMPILE_DEFINITIONS(client PRIVATE -DUSE_SYSTEM_JPEG) TARGET_LINK_LIBRARIES(client ${JPEG_LIBRARIES}) ELSE() - AUX_SOURCE_DIRECTORY(code/libjpeg JPEG_SRCS) + AUX_SOURCE_DIRECTORY(src/libjpeg JPEG_SRCS) #ADD_LIBRARY(jpeg ${JPEG_SRCS}) #TARGET_LINK_LIBRARIES(client jpeg) ADD_LIBRARY(client OBJECT ${CLIENT_SRCS} ${JPEG_SRCS}) + # Ensure client can find qcommon headers needed by some client-side modules (eg. mp3) + target_include_directories(client PRIVATE ${CMAKE_SOURCE_DIR}/src/qcommon) ENDIF() # renderers -AUX_SOURCE_DIRECTORY(code/renderercommon RENDERER_COMMON_SRCS) -AUX_SOURCE_DIRECTORY(code/renderer RENDERER_GL_SRCS) -AUX_SOURCE_DIRECTORY(code/renderervk RENDERER_VK_SRCS) +AUX_SOURCE_DIRECTORY(src/renderercommon RENDERER_COMMON_SRCS) +AUX_SOURCE_DIRECTORY(src/renderer RENDERER_GL_SRCS) +AUX_SOURCE_DIRECTORY(src/renderervk RENDERER_VK_SRCS) IF(USE_RENDERER_DLOPEN) SET(AUX_SRCS - code/qcommon/q_shared.c - code/qcommon/puff.c - code/qcommon/q_math.c + src/qcommon/q_shared.c + src/qcommon/puff.c + src/qcommon/q_math.c ) TARGET_COMPILE_DEFINITIONS(client PRIVATE USE_RENDERER_DLOPEN RENDERER_PREFIX="${RENDERER_PREFIX}" RENDERER_DEFAULT="${RENDERER_DEFAULT}") @@ -101,6 +160,23 @@ IF(USE_RENDERER_DLOPEN) ADD_LIBRARY(${RENDERER_PREFIX}_vulkan${RENDEXT} SHARED ${RENDERER_VK_SRCS} ${RENDERER_COMMON_SRCS} ${AUX_SRCS}) TARGET_COMPILE_DEFINITIONS(${RENDERER_PREFIX}_vulkan${RENDEXT} PRIVATE USE_RENDERER_DLOPEN) + # Ensure shared renderer libraries link to the math and dl libs so symbol versions + # (eg. powf@GLIBC_2.2.5) are resolved against the dynamic libm rather than a + # static libm which would break building shared objects. + TARGET_LINK_LIBRARIES(${RENDERER_PREFIX}_opengl${RENDEXT} m ${CMAKE_DL_LIBS}) + TARGET_LINK_LIBRARIES(${RENDERER_PREFIX}_vulkan${RENDEXT} m ${CMAKE_DL_LIBS}) + # Normalize target filenames for dlopen-friendly plugin names: + # set OUTPUT_NAME and remove default 'lib' PREFIX so filenames become: + # idtech3_opengl_x86_64.so (instead of libidtech3_opengl_x86_64.so) + if(TARGET_ARCH_NAME) + set(RENDERER_OUT_OPengl "idtech3_opengl_${TARGET_ARCH_NAME}") + set(RENDERER_OUT_Vulkan "idtech3_vulkan_${TARGET_ARCH_NAME}") + else() + set(RENDERER_OUT_OPengl "idtech3_opengl${RENDEXT}") + set(RENDERER_OUT_Vulkan "idtech3_vulkan${RENDEXT}") + endif() + set_target_properties(${RENDERER_PREFIX}_opengl${RENDEXT} PROPERTIES OUTPUT_NAME ${RENDERER_OUT_OPengl} PREFIX "") + set_target_properties(${RENDERER_PREFIX}_vulkan${RENDEXT} PROPERTIES OUTPUT_NAME ${RENDERER_OUT_Vulkan} PREFIX "") ELSE() IF(USE_VULKAN) ADD_LIBRARY(${RENDERER_PREFIX}_vulkan OBJECT ${RENDERER_VK_SRCS} ${RENDERER_COMMON_SRCS}) @@ -112,29 +188,29 @@ ENDIF() # common function, window system IF(UNIX) SET (Q3_SRCS - code/unix/unix_main.c - code/unix/unix_shared.c - code/unix/linux_signals.c) + src/unix/unix_main.c + src/unix/unix_shared.c + src/unix/linux_signals.c) IF(USE_SDL) - AUX_SOURCE_DIRECTORY(code/sdl Q3_UI_SRCS) + AUX_SOURCE_DIRECTORY(src/sdl Q3_UI_SRCS) ELSE() SET(Q3_UI_SRCS - code/unix/linux_glimp.c - code/unix/linux_qgl.c - code/unix/linux_snd.c - code/unix/x11_dga.c - code/unix/x11_randr.c - code/unix/x11_vidmode.c) + src/unix/linux_glimp.c + src/unix/linux_qgl.c + src/unix/linux_snd.c + src/unix/x11_dga.c + src/unix/x11_randr.c + src/unix/x11_vidmode.c) IF(USE_VULKAN) - list(APPEND Q3_UI_SRCS code/unix/linux_qvk.c) + list(APPEND Q3_UI_SRCS src/unix/linux_qvk.c) ENDIF() ENDIF() IF(APPLE) SET(EXE_TYPE MACOSX_BUNDLE) - list(APPEND Q3_SRCS code/unix/quake3_flat.icns) - set_source_files_properties(code/unix/quake3_flat.icns PROPERTIES + list(APPEND Q3_SRCS src/unix/quake3_flat.icns) + set_source_files_properties(src/unix/quake3_flat.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources) SET(MACOSX_BUNDLE_ICON_FILE quake3_flat.icns) ENDIF() @@ -146,21 +222,27 @@ ELSEIF(WIN32) ENDIF() SET(Q3_SRCS - code/win32/win_main.c - code/win32/win_shared.c - code/win32/win_syscon.c - code/win32/win_resource.rc) + src/win32/win_main.c + src/win32/win_shared.c + src/win32/win_syscon.c + src/win32/win_resource.rc) + + # Set include directory for resource compiler to find icon and manifest files + if(MINGW) + set_source_files_properties(src/win32/win_resource.rc PROPERTIES + COMPILE_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/src/win32") + endif() SET(Q3_UI_SRCS - code/win32/win_gamma.c - code/win32/win_glimp.c - code/win32/win_input.c - code/win32/win_minimize.c - code/win32/win_qgl.c - code/win32/win_snd.c - code/win32/win_wndproc.c) + src/win32/win_gamma.c + src/win32/win_glimp.c + src/win32/win_input.c + src/win32/win_minimize.c + src/win32/win_qgl.c + src/win32/win_snd.c + src/win32/win_wndproc.c) IF(USE_VULKAN) - list(APPEND Q3_UI_SRCS code/win32/win_qvk.c) + list(APPEND Q3_UI_SRCS src/win32/win_qvk.c) ENDIF() ENDIF(UNIX) @@ -169,6 +251,31 @@ ADD_LIBRARY(q3ui OBJECT ${Q3_UI_SRCS}) IF(NOT MSVC) IF(USE_SDL) find_package(SDL2 REQUIRED) + # Ensure compatibility: if the FindSDL2 module didn't create SDL2::Core/SDL2::Main/SDL2::SDL2 + # targets (varies between systems / config vs module mode), synthesize lightweight IMPORTED targets + if(NOT TARGET SDL2::Core) + if(DEFINED SDL2_LIBRARY AND SDL2_LIBRARY) + add_library(SDL2::Core UNKNOWN IMPORTED) + set_property(TARGET SDL2::Core PROPERTY IMPORTED_LOCATION "${SDL2_LIBRARY}") + if(DEFINED SDL2_INCLUDE_DIR AND SDL2_INCLUDE_DIR) + set_property(TARGET SDL2::Core PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}") + endif() + elseif(DEFINED SDL2_LIBRARIES AND SDL2_LIBRARIES) + add_library(SDL2::Core UNKNOWN IMPORTED) + set_property(TARGET SDL2::Core PROPERTY INTERFACE_LINK_LIBRARIES "${SDL2_LIBRARIES}") + if(DEFINED SDL2_INCLUDE_DIR AND SDL2_INCLUDE_DIR) + set_property(TARGET SDL2::Core PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}") + endif() + endif() + endif() + # Provide aliases expected by some FindSDL2 implementations + if(NOT TARGET SDL2::SDL2 AND TARGET SDL2::Core) + add_library(SDL2::SDL2 ALIAS SDL2::Core) + endif() + if(NOT TARGET SDL2::Main AND TARGET SDL2::Core) + add_library(SDL2::Main INTERFACE IMPORTED) + set_property(TARGET SDL2::Main PROPERTY INTERFACE_LINK_LIBRARIES SDL2::Core) + endif() TARGET_LINK_LIBRARIES(q3ui SDL2::Main) ELSEIF(UNIX) find_package (X11 REQUIRED) @@ -181,12 +288,32 @@ IF(USE_VULKAN) TARGET_COMPILE_DEFINITIONS(client PRIVATE USE_VULKAN_API) ENDIF() +IF(USE_MP3) + TARGET_COMPILE_DEFINITIONS(client PRIVATE USE_MP3) +ENDIF() + +# Ensure GNU-style --export-dynamic is not present in global linker flags on macOS +if(APPLE) + if(DEFINED CMAKE_EXE_LINKER_FLAGS) + string(REPLACE "-Wl,--export-dynamic" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") + endif() + if(DEFINED CMAKE_SHARED_LINKER_FLAGS) + string(REPLACE "-Wl,--export-dynamic" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") + endif() +endif() + # client executable ADD_EXECUTABLE(${CNAME}${BINEXT} ${EXE_TYPE} ${Q3_SRCS}) TARGET_LINK_LIBRARIES(${CNAME}${BINEXT} qcommon botlib client q3ui) #TARGET_LINK_OPTIONS(${CNAME} PRIVATE -fno-pie) # v3.13+ +if(UNIX AND NOT MSVC AND NOT APPLE) + # Ensure main executable exports symbols so dlopen'd renderer plugins can resolve engine symbols. + # --export-dynamic is a GNU ld option and should not be used on macOS (Darwin) where the linker rejects it. + target_link_options(${CNAME}${BINEXT} PRIVATE "-Wl,--export-dynamic") +endif() + IF(NOT USE_RENDERER_DLOPEN) IF(USE_VULKAN) TARGET_LINK_LIBRARIES(${CNAME}${BINEXT} ${RENDERER_PREFIX}_vulkan) @@ -201,10 +328,14 @@ ADD_EXECUTABLE(${DNAME}${BINEXT} ${EXE_TYPE} ${Q3_SRCS}) TARGET_LINK_LIBRARIES(${DNAME}${BINEXT} qcommon_ded botlib) #TARGET_LINK_OPTIONS(${DNAME} PRIVATE -fno-pie) # v3.13+ +if(UNIX AND NOT MSVC AND NOT APPLE) + target_link_options(${DNAME}${BINEXT} PRIVATE "-Wl,--export-dynamic") +endif() + IF(WIN32) TARGET_LINK_LIBRARIES(${CNAME}${BINEXT} winmm comctl32 ws2_32) TARGET_LINK_LIBRARIES(${DNAME}${BINEXT} winmm comctl32 ws2_32) ELSE() TARGET_LINK_LIBRARIES(${CNAME}${BINEXT} m ${CMAKE_DL_LIBS}) TARGET_LINK_LIBRARIES(${DNAME}${BINEXT} m ${CMAKE_DL_LIBS}) -ENDIF() +ENDIF() \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index b9a6ffe772..0000000000 --- a/Makefile +++ /dev/null @@ -1,1516 +0,0 @@ - -# Quake3 Unix Makefile -# -# Nov '98 by Zoid -# -# Loki Hacking by Bernd Kreimeier -# and a little more by Ryan C. Gordon. -# and a little more by Rafael Barrero -# and a little more by the ioq3 cr3w -# -# GNU Make required -# -COMPILE_PLATFORM=$(shell uname | sed -e 's/_.*//' | tr '[:upper:]' '[:lower:]' | sed -e 's/\//_/g') -COMPILE_ARCH=$(shell uname -m | sed -e 's/i.86/x86/' | sed -e 's/^arm.*/arm/') - -ifeq ($(shell uname -m),arm64) - COMPILE_ARCH=aarch64 -endif - -ifeq ($(COMPILE_PLATFORM),mingw32) - ifeq ($(COMPILE_ARCH),i386) - COMPILE_ARCH=x86 - endif -endif - -BUILD_CLIENT = 1 -BUILD_SERVER = 1 - -USE_SDL = 1 -USE_CURL = 1 -USE_LOCAL_HEADERS= 0 -USE_SYSTEM_JPEG = 0 - -USE_OGG_VORBIS = 1 -USE_SYSTEM_OGG = 0 -USE_SYSTEM_VORBIS = 0 - -USE_VULKAN = 1 -USE_OPENGL = 1 -USE_OPENGL2 = 0 -USE_OPENGL_API = 1 -USE_VULKAN_API = 1 -USE_RENDERER_DLOPEN = 1 - -# valid options: opengl, vulkan, opengl2 -RENDERER_DEFAULT = opengl - -CNAME = quake3e -DNAME = quake3e.ded - -RENDERER_PREFIX = $(CNAME) - - -ifeq ($(V),1) -echo_cmd=@: -Q= -else -echo_cmd=@echo -Q=@ -endif - -############################################################################# -# -# If you require a different configuration from the defaults below, create a -# new file named "Makefile.local" in the same directory as this file and define -# your parameters there. This allows you to change configuration without -# causing problems with keeping up to date with the repository. -# -############################################################################# --include Makefile.local - -ifeq ($(COMPILE_PLATFORM),darwin) - USE_SDL=1 - USE_LOCAL_HEADERS=1 - USE_RENDERER_DLOPEN = 0 -endif - -ifeq ($(COMPILE_PLATFORM),cygwin) - PLATFORM=mingw32 -endif - -ifndef PLATFORM -PLATFORM=$(COMPILE_PLATFORM) -endif -export PLATFORM - -ifeq ($(PLATFORM),mingw32) - MINGW=1 -endif -ifeq ($(PLATFORM),mingw64) - MINGW=1 -endif - -ifeq ($(COMPILE_ARCH),i86pc) - COMPILE_ARCH=x86 -endif - -ifeq ($(COMPILE_ARCH),amd64) - COMPILE_ARCH=x86_64 -endif -ifeq ($(COMPILE_ARCH),x64) - COMPILE_ARCH=x86_64 -endif - -ifndef ARCH -ARCH=$(COMPILE_ARCH) -endif -export ARCH - -ifneq ($(PLATFORM),$(COMPILE_PLATFORM)) - CROSS_COMPILING=1 -else - CROSS_COMPILING=0 - - ifneq ($(ARCH),$(COMPILE_ARCH)) - CROSS_COMPILING=1 - endif -endif -export CROSS_COMPILING - -ifndef DESTDIR -DESTDIR=/usr/local/games/quake3 -endif - -ifndef MOUNT_DIR -MOUNT_DIR=code -endif - -ifndef BUILD_DIR -BUILD_DIR=build -endif - -ifndef GENERATE_DEPENDENCIES -GENERATE_DEPENDENCIES=1 -endif - -ifndef USE_CCACHE -USE_CCACHE=0 -endif -export USE_CCACHE - -ifndef USE_LOCAL_HEADERS -USE_LOCAL_HEADERS=1 -endif - -ifndef USE_CURL -USE_CURL=1 -endif - -ifndef USE_CURL_DLOPEN - ifdef MINGW - USE_CURL_DLOPEN=0 - else - USE_CURL_DLOPEN=1 - endif -endif - -ifndef USE_OGG_VORBIS - USE_OGG_VORBIS=1 -endif - -ifndef USE_SYSTEM_OGG - USE_SYSTEM_OGG=1 -endif - -ifndef USE_SYSTEM_VORBIS - USE_SYSTEM_VORBIS=1 -endif - -ifeq ($(USE_RENDERER_DLOPEN),0) - ifeq ($(RENDERER_DEFAULT),opengl) - USE_OPENGL=1 - USE_OPENGL2=0 - USE_VULKAN=0 - USE_OPENGL_API=1 - USE_VULKAN_API=0 - endif - ifeq ($(RENDERER_DEFAULT),opengl2) - USE_OPENGL=0 - USE_OPENGL2=1 - USE_VULKAN=0 - USE_OPENGL_API=1 - USE_VULKAN_API=0 - endif - ifeq ($(RENDERER_DEFAULT),vulkan) - USE_OPENGL=0 - USE_OPENGL2=0 - USE_VULKAN=1 - USE_OPENGL_API=0 - endif -endif - -ifneq ($(USE_VULKAN),0) - USE_VULKAN_API=1 -endif - - -############################################################################# - -BD=$(BUILD_DIR)/debug-$(PLATFORM)-$(ARCH) -BR=$(BUILD_DIR)/release-$(PLATFORM)-$(ARCH) -ADIR=$(MOUNT_DIR)/asm -CDIR=$(MOUNT_DIR)/client -SDIR=$(MOUNT_DIR)/server -RCDIR=$(MOUNT_DIR)/renderercommon -R1DIR=$(MOUNT_DIR)/renderer -R2DIR=$(MOUNT_DIR)/renderer2 -RVDIR=$(MOUNT_DIR)/renderervk -SDLDIR=$(MOUNT_DIR)/sdl -SDLHDIR=$(MOUNT_DIR)/libsdl/include/SDL2 - -CMDIR=$(MOUNT_DIR)/qcommon -UDIR=$(MOUNT_DIR)/unix -W32DIR=$(MOUNT_DIR)/win32 -BLIBDIR=$(MOUNT_DIR)/botlib -JPDIR=$(MOUNT_DIR)/libjpeg -OGGDIR=$(MOUNT_DIR)/libogg -VORBISDIR=$(MOUNT_DIR)/libvorbis - -bin_path=$(shell which $(1) 2> /dev/null) - -STRIP ?= strip -PKG_CONFIG ?= pkg-config -INSTALL=install -MKDIR=mkdir -p - -ifneq ($(call bin_path, $(PKG_CONFIG)),) - ifneq ($(USE_SDL),0) - SDL_INCLUDE ?= $(shell $(PKG_CONFIG) --silence-errors --cflags-only-I sdl2) - SDL_LIBS ?= $(shell $(PKG_CONFIG) --silence-errors --libs sdl2) - else - X11_INCLUDE ?= $(shell $(PKG_CONFIG) --silence-errors --cflags-only-I x11) - X11_LIBS ?= $(shell $(PKG_CONFIG) --silence-errors --libs x11) - endif - ifeq ($(USE_SYSTEM_OGG),1) - OGG_CFLAGS ?= $(shell $(PKG_CONFIG) --silence-errors --cflags ogg || true) - OGG_LIBS ?= $(shell $(PKG_CONFIG) --silence-errors --libs ogg || echo -logg) - endif - ifeq ($(USE_SYSTEM_VORBIS),1) - VORBIS_CFLAGS ?= $(shell $(PKG_CONFIG) --silence-errors --cflags vorbisfile || true) - VORBIS_LIBS ?= $(shell $(PKG_CONFIG) --silence-errors --libs vorbisfile || echo -lvorbisfile) - endif -endif - -# supply some reasonable defaults for SDL/X11 -ifeq ($(X11_INCLUDE),) - X11_INCLUDE = -I/usr/X11R6/include -endif -ifeq ($(X11_LIBS),) - X11_LIBS = -lX11 -endif -ifeq ($(SDL_LIBS),) - SDL_LIBS = -lSDL2 -endif - -# supply some reasonable defaults for ogg/vorbis -ifeq ($(OGG_FLAGS),) - OGG_FLAGS = -I$(OGGDIR)/include -endif -ifeq ($(VORBIS_FLAGS),) - VORBIS_FLAGS = -I$(VORBISDIR)/include -I$(VORBISDIR)/lib -endif -ifeq ($(USE_SYSTEM_OGG),1) - ifeq ($(OGG_LIBS),) - OGG_LIBS = -logg - endif -endif -ifeq ($(USE_SYSTEM_VORBIS),1) - ifeq ($(VORBIS_LIBS),) - VORBIS_LIBS = -lvorbisfile - endif -endif - -# extract version info -ifneq ($(COMPILE_PLATFORM),darwin) -VERSION=$(shell grep ".\+define[ \t]\+Q3_VERSION[ \t]\+\+" $(CMDIR)/q_shared.h | \ - sed -e 's/.*".* \([^ ]*\)"/\1/') -else -VERSION=1.32e -endif - -# common qvm definition -ifeq ($(ARCH),x86_64) - HAVE_VM_COMPILED = true -else -ifeq ($(ARCH),x86) - HAVE_VM_COMPILED = true -else - HAVE_VM_COMPILED = false -endif -endif - -ifeq ($(ARCH),arm) - HAVE_VM_COMPILED = true -endif -ifeq ($(ARCH),aarch64) - HAVE_VM_COMPILED = true -endif - -BASE_CFLAGS = - -ifeq ($(USE_SYSTEM_JPEG),1) - BASE_CFLAGS += -DUSE_SYSTEM_JPEG -endif - -ifneq ($(HAVE_VM_COMPILED),true) - BASE_CFLAGS += -DNO_VM_COMPILED -endif - -ifneq ($(USE_RENDERER_DLOPEN),0) - BASE_CFLAGS += -DUSE_RENDERER_DLOPEN - BASE_CFLAGS += -DRENDERER_PREFIX=\\\"$(RENDERER_PREFIX)\\\" - BASE_CFLAGS += -DRENDERER_DEFAULT="$(RENDERER_DEFAULT)" -endif - -ifdef DEFAULT_BASEDIR - BASE_CFLAGS += -DDEFAULT_BASEDIR=\\\"$(DEFAULT_BASEDIR)\\\" -endif - -ifeq ($(USE_LOCAL_HEADERS),1) - BASE_CFLAGS += -DUSE_LOCAL_HEADERS=1 -endif - -ifeq ($(USE_CURL),1) - BASE_CFLAGS += -DUSE_CURL - ifeq ($(USE_CURL_DLOPEN),1) - BASE_CFLAGS += -DUSE_CURL_DLOPEN - else - ifeq ($(MINGW),1) - BASE_CFLAGS += -DCURL_STATICLIB - endif - endif -endif - -ifeq ($(USE_VULKAN_API),1) - BASE_CFLAGS += -DUSE_VULKAN_API -endif - -ifeq ($(USE_OPENGL_API),1) - BASE_CFLAGS += -DUSE_OPENGL_API -endif - -ifeq ($(GENERATE_DEPENDENCIES),1) - BASE_CFLAGS += -MMD -endif - - -ARCHEXT= - -CLIENT_EXTRA_FILES= - - -############################################################################# -# SETUP AND BUILD -- MINGW32 -############################################################################# - -ifdef MINGW - - ifeq ($(CROSS_COMPILING),1) - # If CC is already set to something generic, we probably want to use - # something more specific - ifneq ($(findstring $(strip $(CC)),cc gcc),) - override CC= - endif - - ifneq ($(findstring $(strip $(STRIP)),strip),) - override STRIP= - endif - - # We need to figure out the correct gcc and windres - ifeq ($(ARCH),x86_64) - MINGW_PREFIXES=x86_64-w64-mingw32 amd64-mingw32msvc - endif - ifeq ($(ARCH),x86) - MINGW_PREFIXES=i686-w64-mingw32 i586-mingw32msvc i686-pc-mingw32 - endif - - ifndef CC - override CC=$(firstword $(strip $(foreach MINGW_PREFIX, $(MINGW_PREFIXES), \ - $(call bin_path, $(MINGW_PREFIX)-gcc)))) - endif - - ifndef STRIP - override STRIP=$(firstword $(strip $(foreach MINGW_PREFIX, $(MINGW_PREFIXES), \ - $(call bin_path, $(MINGW_PREFIX)-strip)))) - endif - - ifndef WINDRES - WINDRES=$(firstword $(strip $(foreach MINGW_PREFIX, $(MINGW_PREFIXES), \ - $(call bin_path, $(MINGW_PREFIX)-windres)))) - endif - else - # Some MinGW installations define CC to cc, but don't actually provide cc, - # so check that CC points to a real binary and use gcc if it doesn't - ifeq ($(call bin_path, $(CC)),) - override CC=gcc - endif - - endif - - # using generic windres if specific one is not present - ifeq ($(WINDRES),) - WINDRES=windres - endif - - ifeq ($(CC),) - $(error Cannot find a suitable cross compiler for $(PLATFORM)) - endif - - BASE_CFLAGS += -Wall -Wimplicit -Wstrict-prototypes -DUSE_ICON -DMINGW=1 - - BASE_CFLAGS += -Wno-unused-result -fvisibility=hidden - BASE_CFLAGS += -ffunction-sections -flto - - ifeq ($(ARCH),x86_64) - ARCHEXT = .x64 - BASE_CFLAGS += -m64 - OPTIMIZE = -O2 -ffast-math - endif - ifeq ($(ARCH),x86) - BASE_CFLAGS += -m32 - OPTIMIZE = -O2 -march=i586 -mtune=i686 -ffast-math - endif - - SHLIBEXT = dll - SHLIBCFLAGS = -fPIC -fvisibility=hidden - SHLIBLDFLAGS = -shared $(LDFLAGS) - - BINEXT = .exe - - LDFLAGS += -mwindows -Wl,--dynamicbase -Wl,--nxcompat - LDFLAGS += -Wl,--gc-sections -fvisibility=hidden - LDFLAGS += -lwsock32 -lgdi32 -lwinmm -lole32 -lws2_32 -lpsapi -lcomctl32 - LDFLAGS += -flto - - CLIENT_LDFLAGS=$(LDFLAGS) - - ifeq ($(USE_SDL),1) - BASE_CFLAGS += -DUSE_LOCAL_HEADERS=1 -I$(SDLHDIR) - #CLIENT_CFLAGS += -DUSE_LOCAL_HEADERS=1 - ifeq ($(ARCH),x86) - CLIENT_LDFLAGS += -L$(MOUNT_DIR)/libsdl/windows/mingw/lib32 - CLIENT_LDFLAGS += -lSDL2 - CLIENT_EXTRA_FILES += $(MOUNT_DIR)/libsdl/windows/mingw/lib32/SDL2.dll - else - CLIENT_LDFLAGS += -L$(MOUNT_DIR)/libsdl/windows/mingw/lib64 - CLIENT_LDFLAGS += -lSDL264 - CLIENT_EXTRA_FILES += $(MOUNT_DIR)/libsdl/windows/mingw/lib64/SDL264.dll - endif - endif - - ifeq ($(USE_CURL),1) - BASE_CFLAGS += -I$(MOUNT_DIR)/libcurl/windows/include - ifeq ($(ARCH),x86) - CLIENT_LDFLAGS += -L$(MOUNT_DIR)/libcurl/windows/mingw/lib32 - else - CLIENT_LDFLAGS += -L$(MOUNT_DIR)/libcurl/windows/mingw/lib64 - endif - CLIENT_LDFLAGS += -lcurl -lz -lcrypt32 - endif - - ifeq ($(USE_OGG_VORBIS),1) - BASE_CFLAGS += -DUSE_OGG_VORBIS $(OGG_FLAGS) $(VORBIS_FLAGS) - CLIENT_LDFLAGS += $(OGG_LIBS) $(VORBIS_LIBS) - endif - - DEBUG_CFLAGS = $(BASE_CFLAGS) -DDEBUG -D_DEBUG -g -O0 - RELEASE_CFLAGS = $(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE) - -else # !MINGW - -ifeq ($(COMPILE_PLATFORM),darwin) - -############################################################################# -# SETUP AND BUILD -- MACOS -############################################################################# - - BASE_CFLAGS += -Wall -Wimplicit -Wstrict-prototypes -pipe - - BASE_CFLAGS += -Wno-unused-result - - BASE_CFLAGS += -DMACOS_X - - OPTIMIZE = -O2 -fvisibility=hidden - - SHLIBEXT = dylib - SHLIBCFLAGS = -fPIC -fvisibility=hidden - SHLIBLDFLAGS = -dynamiclib $(LDFLAGS) - - ARCHEXT = .$(ARCH) - - LDFLAGS += - - ifeq ($(ARCH),x86_64) - BASE_CFLAGS += -arch x86_64 - LDFLAGS += -arch x86_64 - endif - ifeq ($(ARCH),aarch64) - BASE_CFLAGS += -arch arm64 - LDFLAGS += -arch arm64 - endif - - ifeq ($(USE_LOCAL_HEADERS),1) - MACLIBSDIR=$(MOUNT_DIR)/libsdl/macosx - BASE_CFLAGS += -I$(SDLHDIR) - CLIENT_LDFLAGS += $(MACLIBSDIR)/libSDL2-2.0.0.dylib - CLIENT_EXTRA_FILES += $(MACLIBSDIR)/libSDL2-2.0.0.dylib - else - ifneq ($(SDL_INCLUDE),) - BASE_CFLAGS += $(SDL_INCLUDE) - CLIENT_LDFLAGS = $(SDL_LIBS) - else - BASE_CFLAGS += -I/Library/Frameworks/SDL2.framework/Headers - CLIENT_LDFLAGS += -F/Library/Frameworks -framework SDL2 - endif - endif - - ifeq ($(USE_SYSTEM_JPEG),1) - CLIENT_LDFLAGS += -ljpeg - endif - - ifeq ($(USE_OGG_VORBIS),1) - BASE_CFLAGS += -DUSE_OGG_VORBIS $(OGG_FLAGS) $(VORBIS_FLAGS) - CLIENT_LDFLAGS += $(OGG_LIBS) $(VORBIS_LIBS) - endif - - DEBUG_CFLAGS = $(BASE_CFLAGS) -DDEBUG -D_DEBUG -g -O0 - RELEASE_CFLAGS = $(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE) - -else - -############################################################################# -# SETUP AND BUILD -- *NIX PLATFORMS -############################################################################# - - BASE_CFLAGS += -Wall -Wimplicit -Wstrict-prototypes -pipe - - BASE_CFLAGS += -Wno-unused-result - - BASE_CFLAGS += -DUSE_ICON - - BASE_CFLAGS += -I/usr/include -I/usr/local/include - - OPTIMIZE = -O2 -fvisibility=hidden - - ifeq ($(ARCH),x86_64) - ARCHEXT = .x64 - else - ifeq ($(ARCH),x86) - OPTIMIZE += -march=i586 -mtune=i686 - endif - endif - - ifeq ($(ARCH),arm) - OPTIMIZE += -march=armv7-a - ARCHEXT = .arm - endif - - ifeq ($(ARCH),aarch64) - ARCHEXT = .aarch64 - endif - - SHLIBEXT = so - SHLIBCFLAGS = -fPIC -fvisibility=hidden - SHLIBLDFLAGS = -shared $(LDFLAGS) - - LDFLAGS += -lm - LDFLAGS += -Wl,--gc-sections -fvisibility=hidden - - ifeq ($(USE_SDL),1) - BASE_CFLAGS += $(SDL_INCLUDE) - CLIENT_LDFLAGS = $(SDL_LIBS) - else - BASE_CFLAGS += $(X11_INCLUDE) - CLIENT_LDFLAGS = $(X11_LIBS) - endif - - ifeq ($(USE_SYSTEM_JPEG),1) - CLIENT_LDFLAGS += -ljpeg - endif - - ifeq ($(USE_CURL),1) - ifeq ($(USE_CURL_DLOPEN),0) - CLIENT_LDFLAGS += -lcurl - endif - endif - - ifeq ($(USE_OGG_VORBIS),1) - BASE_CFLAGS += -DUSE_OGG_VORBIS $(OGG_FLAGS) $(VORBIS_FLAGS) - CLIENT_LDFLAGS += $(OGG_LIBS) $(VORBIS_LIBS) - endif - - ifeq ($(PLATFORM),linux) - LDFLAGS += -ldl -Wl,--hash-style=both - ifeq ($(ARCH),x86) - # linux32 make ... - BASE_CFLAGS += -m32 - LDFLAGS += -m32 - endif - endif - - DEBUG_CFLAGS = $(BASE_CFLAGS) -DDEBUG -D_DEBUG -g -O0 - RELEASE_CFLAGS = $(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE) - - DEBUG_LDFLAGS = -rdynamic - -endif # *NIX platforms - -endif # !MINGW - - -TARGET_CLIENT = $(CNAME)$(ARCHEXT)$(BINEXT) - -TARGET_REND1 = $(RENDERER_PREFIX)_opengl_$(SHLIBNAME) -TARGET_REND2 = $(RENDERER_PREFIX)_opengl2_$(SHLIBNAME) -TARGET_RENDV = $(RENDERER_PREFIX)_vulkan_$(SHLIBNAME) - -TARGET_SERVER = $(DNAME)$(ARCHEXT)$(BINEXT) - -STRINGIFY = $(B)/rend2/stringify$(BINEXT) - -TARGETS = - -ifneq ($(BUILD_SERVER),0) - TARGETS += $(B)/$(TARGET_SERVER) -endif - -ifneq ($(BUILD_CLIENT),0) - TARGETS += $(B)/$(TARGET_CLIENT) - ifneq ($(USE_RENDERER_DLOPEN),0) - ifeq ($(USE_OPENGL),1) - TARGETS += $(B)/$(TARGET_REND1) - endif - ifeq ($(USE_OPENGL2),1) - TARGETS += $(B)/$(TARGET_REND2) - endif - ifeq ($(USE_VULKAN),1) - TARGETS += $(B)/$(TARGET_RENDV) - endif - endif -endif - -ifeq ($(USE_CCACHE),1) - CC := ccache $(CC) -endif - -ifneq ($(USE_RENDERER_DLOPEN),0) - RENDCFLAGS=$(SHLIBCFLAGS) -else - RENDCFLAGS=$(NOTSHLIBCFLAGS) -endif - -define DO_CC -$(echo_cmd) "CC $<" -$(Q)$(CC) $(CFLAGS) -o $@ -c $< -endef - -define DO_CC_QVM -$(echo_cmd) "CC_QVM $<" -$(Q)$(CC) $(CFLAGS) -fno-fast-math -o $@ -c $< -endef - -define DO_REND_CC -$(echo_cmd) "REND_CC $<" -$(Q)$(CC) $(CFLAGS) $(RENDCFLAGS) -o $@ -c $< -endef - -define DO_REF_STR -$(echo_cmd) "REF_STR $<" -$(Q)rm -f $@ -$(Q)$(STRINGIFY) $< $@ -endef - -define DO_BOT_CC -$(echo_cmd) "BOT_CC $<" -$(Q)$(CC) $(CFLAGS) $(BOTCFLAGS) -DBOTLIB -o $@ -c $< -endef - -define DO_AS -$(echo_cmd) "AS $<" -$(Q)$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $< -endef - -define DO_DED_CC -$(echo_cmd) "DED_CC $<" -$(Q)$(CC) $(CFLAGS) -DDEDICATED -o $@ -c $< -endef - -define DO_DED_CC_QVM -$(echo_cmd) "DED_CC_QVM $<" -$(Q)$(CC) $(CFLAGS) -fno-fast-math -DDEDICATED -o $@ -c $< -endef - -define DO_WINDRES -$(echo_cmd) "WINDRES $<" -$(Q)$(WINDRES) -i $< -o $@ -endef - -ifndef SHLIBNAME - SHLIBNAME=$(ARCH).$(SHLIBEXT) -endif - -############################################################################# -# MAIN TARGETS -############################################################################# - -default: release -all: debug release - -debug: - @$(MAKE) targets B=$(BD) CFLAGS="$(CFLAGS) $(DEBUG_CFLAGS)" LDFLAGS="$(LDFLAGS) $(DEBUG_LDFLAGS)" V=$(V) - -release: - @$(MAKE) targets B=$(BR) CFLAGS="$(CFLAGS) $(RELEASE_CFLAGS)" V=$(V) - -define ADD_COPY_TARGET -TARGETS += $2 -$2: $1 - $(echo_cmd) "CP $$<" - @cp $1 $2 -endef - -# These functions allow us to generate rules for copying a list of files -# into the base directory of the build; this is useful for bundling libs, -# README files or whatever else -define GENERATE_COPY_TARGETS -$(foreach FILE,$1, \ - $(eval $(call ADD_COPY_TARGET, \ - $(FILE), \ - $(addprefix $(B)/,$(notdir $(FILE)))))) -endef - -ifneq ($(BUILD_CLIENT),0) - $(call GENERATE_COPY_TARGETS,$(CLIENT_EXTRA_FILES)) -endif - -# Create the build directories and tools, print out -# an informational message, then start building -targets: makedirs tools - @echo "" - @echo "Building quake3 in $(B):" - @echo "" - @echo " VERSION: $(VERSION)" - @echo " PLATFORM: $(PLATFORM)" - @echo " ARCH: $(ARCH)" - @echo " COMPILE_PLATFORM: $(COMPILE_PLATFORM)" - @echo " COMPILE_ARCH: $(COMPILE_ARCH)" -ifdef MINGW - @echo " WINDRES: $(WINDRES)" - @echo " STRIP: $(STRIP)" -endif - @echo " CC: $(CC)" - @echo "" - @echo " CFLAGS:" - @for i in $(CFLAGS); \ - do \ - echo " $$i"; \ - done - @echo "" - @echo " Output:" - @for i in $(TARGETS); \ - do \ - echo " $$i"; \ - done - @echo "" -ifneq ($(TARGETS),) - @$(MAKE) $(TARGETS) V=$(V) -endif - -makedirs: - @if [ ! -d $(BUILD_DIR) ];then $(MKDIR) $(BUILD_DIR);fi - @if [ ! -d $(B) ];then $(MKDIR) $(B);fi - @if [ ! -d $(B)/client ];then $(MKDIR) $(B)/client/qvm;fi - @if [ ! -d $(B)/client/jpeg ];then $(MKDIR) $(B)/client/jpeg;fi -ifeq ($(USE_SYSTEM_OGG),0) - @if [ ! -d $(B)/client/ogg ];then $(MKDIR) $(B)/client/ogg;fi -endif -ifeq ($(USE_SYSTEM_VORBIS),0) - @if [ ! -d $(B)/client/vorbis ];then $(MKDIR) $(B)/client/vorbis;fi -endif - @if [ ! -d $(B)/rend1 ];then $(MKDIR) $(B)/rend1;fi - @if [ ! -d $(B)/rend2 ];then $(MKDIR) $(B)/rend2;fi - @if [ ! -d $(B)/rend2/glsl ];then $(MKDIR) $(B)/rend2/glsl;fi - @if [ ! -d $(B)/rendv ];then $(MKDIR) $(B)/rendv;fi -ifneq ($(BUILD_SERVER),0) - @if [ ! -d $(B)/ded ];then $(MKDIR) $(B)/ded/qvm;fi -endif - -############################################################################# -# CLIENT/SERVER -############################################################################# - -Q3REND1OBJ = \ - $(B)/rend1/tr_animation.o \ - $(B)/rend1/tr_arb.o \ - $(B)/rend1/tr_backend.o \ - $(B)/rend1/tr_bsp.o \ - $(B)/rend1/tr_cmds.o \ - $(B)/rend1/tr_curve.o \ - $(B)/rend1/tr_flares.o \ - $(B)/rend1/tr_font.o \ - $(B)/rend1/tr_image.o \ - $(B)/rend1/tr_image_png.o \ - $(B)/rend1/tr_image_jpg.o \ - $(B)/rend1/tr_image_bmp.o \ - $(B)/rend1/tr_image_tga.o \ - $(B)/rend1/tr_image_pcx.o \ - $(B)/rend1/tr_init.o \ - $(B)/rend1/tr_light.o \ - $(B)/rend1/tr_main.o \ - $(B)/rend1/tr_marks.o \ - $(B)/rend1/tr_mesh.o \ - $(B)/rend1/tr_model.o \ - $(B)/rend1/tr_model_iqm.o \ - $(B)/rend1/tr_noise.o \ - $(B)/rend1/tr_scene.o \ - $(B)/rend1/tr_shade.o \ - $(B)/rend1/tr_shade_calc.o \ - $(B)/rend1/tr_shader.o \ - $(B)/rend1/tr_shadows.o \ - $(B)/rend1/tr_sky.o \ - $(B)/rend1/tr_surface.o \ - $(B)/rend1/tr_vbo.o \ - $(B)/rend1/tr_world.o - -ifneq ($(USE_RENDERER_DLOPEN), 0) - Q3REND1OBJ += \ - $(B)/rend1/q_shared.o \ - $(B)/rend1/puff.o \ - $(B)/rend1/q_math.o -endif - -Q3REND2OBJ = \ - $(B)/rend2/tr_animation.o \ - $(B)/rend2/tr_backend.o \ - $(B)/rend2/tr_bsp.o \ - $(B)/rend2/tr_cmds.o \ - $(B)/rend2/tr_curve.o \ - $(B)/rend2/tr_dsa.o \ - $(B)/rend2/tr_extramath.o \ - $(B)/rend2/tr_extensions.o \ - $(B)/rend2/tr_fbo.o \ - $(B)/rend2/tr_flares.o \ - $(B)/rend2/tr_font.o \ - $(B)/rend2/tr_glsl.o \ - $(B)/rend2/tr_image.o \ - $(B)/rend2/tr_image_bmp.o \ - $(B)/rend2/tr_image_jpg.o \ - $(B)/rend2/tr_image_pcx.o \ - $(B)/rend2/tr_image_png.o \ - $(B)/rend2/tr_image_tga.o \ - $(B)/rend2/tr_image_dds.o \ - $(B)/rend2/tr_init.o \ - $(B)/rend2/tr_light.o \ - $(B)/rend2/tr_main.o \ - $(B)/rend2/tr_marks.o \ - $(B)/rend2/tr_mesh.o \ - $(B)/rend2/tr_model.o \ - $(B)/rend2/tr_model_iqm.o \ - $(B)/rend2/tr_noise.o \ - $(B)/rend2/tr_postprocess.o \ - $(B)/rend2/tr_scene.o \ - $(B)/rend2/tr_shade.o \ - $(B)/rend2/tr_shade_calc.o \ - $(B)/rend2/tr_shader.o \ - $(B)/rend2/tr_shadows.o \ - $(B)/rend2/tr_sky.o \ - $(B)/rend2/tr_surface.o \ - $(B)/rend2/tr_vbo.o \ - $(B)/rend2/tr_world.o - -ifneq ($(USE_RENDERER_DLOPEN), 0) - Q3REND2OBJ += \ - $(B)/rend2/q_shared.o \ - $(B)/rend2/puff.o \ - $(B)/rend2/q_math.o -endif - -Q3REND2STROBJ = \ - $(B)/rend2/glsl/bokeh_fp.o \ - $(B)/rend2/glsl/bokeh_vp.o \ - $(B)/rend2/glsl/calclevels4x_fp.o \ - $(B)/rend2/glsl/calclevels4x_vp.o \ - $(B)/rend2/glsl/depthblur_fp.o \ - $(B)/rend2/glsl/depthblur_vp.o \ - $(B)/rend2/glsl/dlight_fp.o \ - $(B)/rend2/glsl/dlight_vp.o \ - $(B)/rend2/glsl/down4x_fp.o \ - $(B)/rend2/glsl/down4x_vp.o \ - $(B)/rend2/glsl/fogpass_fp.o \ - $(B)/rend2/glsl/fogpass_vp.o \ - $(B)/rend2/glsl/generic_fp.o \ - $(B)/rend2/glsl/generic_vp.o \ - $(B)/rend2/glsl/lightall_fp.o \ - $(B)/rend2/glsl/lightall_vp.o \ - $(B)/rend2/glsl/pshadow_fp.o \ - $(B)/rend2/glsl/pshadow_vp.o \ - $(B)/rend2/glsl/shadowfill_fp.o \ - $(B)/rend2/glsl/shadowfill_vp.o \ - $(B)/rend2/glsl/shadowmask_fp.o \ - $(B)/rend2/glsl/shadowmask_vp.o \ - $(B)/rend2/glsl/ssao_fp.o \ - $(B)/rend2/glsl/ssao_vp.o \ - $(B)/rend2/glsl/texturecolor_fp.o \ - $(B)/rend2/glsl/texturecolor_vp.o \ - $(B)/rend2/glsl/tonemap_fp.o \ - $(B)/rend2/glsl/tonemap_vp.o - -Q3RENDVOBJ = \ - $(B)/rendv/tr_animation.o \ - $(B)/rendv/tr_backend.o \ - $(B)/rendv/tr_bsp.o \ - $(B)/rendv/tr_cmds.o \ - $(B)/rendv/tr_curve.o \ - $(B)/rendv/tr_font.o \ - $(B)/rendv/tr_image.o \ - $(B)/rendv/tr_image_png.o \ - $(B)/rendv/tr_image_jpg.o \ - $(B)/rendv/tr_image_bmp.o \ - $(B)/rendv/tr_image_tga.o \ - $(B)/rendv/tr_image_pcx.o \ - $(B)/rendv/tr_init.o \ - $(B)/rendv/tr_light.o \ - $(B)/rendv/tr_main.o \ - $(B)/rendv/tr_marks.o \ - $(B)/rendv/tr_mesh.o \ - $(B)/rendv/tr_model.o \ - $(B)/rendv/tr_model_iqm.o \ - $(B)/rendv/tr_noise.o \ - $(B)/rendv/tr_scene.o \ - $(B)/rendv/tr_shade.o \ - $(B)/rendv/tr_shade_calc.o \ - $(B)/rendv/tr_shader.o \ - $(B)/rendv/tr_shadows.o \ - $(B)/rendv/tr_sky.o \ - $(B)/rendv/tr_surface.o \ - $(B)/rendv/tr_world.o \ - $(B)/rendv/vk.o \ - $(B)/rendv/vk_flares.o \ - $(B)/rendv/vk_vbo.o \ - -ifneq ($(USE_RENDERER_DLOPEN), 0) - Q3RENDVOBJ += \ - $(B)/rendv/q_shared.o \ - $(B)/rendv/puff.o \ - $(B)/rendv/q_math.o -endif - -JPGOBJ = \ - $(B)/client/jpeg/jaricom.o \ - $(B)/client/jpeg/jcapimin.o \ - $(B)/client/jpeg/jcapistd.o \ - $(B)/client/jpeg/jcarith.o \ - $(B)/client/jpeg/jccoefct.o \ - $(B)/client/jpeg/jccolor.o \ - $(B)/client/jpeg/jcdctmgr.o \ - $(B)/client/jpeg/jchuff.o \ - $(B)/client/jpeg/jcinit.o \ - $(B)/client/jpeg/jcmainct.o \ - $(B)/client/jpeg/jcmarker.o \ - $(B)/client/jpeg/jcmaster.o \ - $(B)/client/jpeg/jcomapi.o \ - $(B)/client/jpeg/jcparam.o \ - $(B)/client/jpeg/jcprepct.o \ - $(B)/client/jpeg/jcsample.o \ - $(B)/client/jpeg/jctrans.o \ - $(B)/client/jpeg/jdapimin.o \ - $(B)/client/jpeg/jdapistd.o \ - $(B)/client/jpeg/jdarith.o \ - $(B)/client/jpeg/jdatadst.o \ - $(B)/client/jpeg/jdatasrc.o \ - $(B)/client/jpeg/jdcoefct.o \ - $(B)/client/jpeg/jdcolor.o \ - $(B)/client/jpeg/jddctmgr.o \ - $(B)/client/jpeg/jdhuff.o \ - $(B)/client/jpeg/jdinput.o \ - $(B)/client/jpeg/jdmainct.o \ - $(B)/client/jpeg/jdmarker.o \ - $(B)/client/jpeg/jdmaster.o \ - $(B)/client/jpeg/jdmerge.o \ - $(B)/client/jpeg/jdpostct.o \ - $(B)/client/jpeg/jdsample.o \ - $(B)/client/jpeg/jdtrans.o \ - $(B)/client/jpeg/jerror.o \ - $(B)/client/jpeg/jfdctflt.o \ - $(B)/client/jpeg/jfdctfst.o \ - $(B)/client/jpeg/jfdctint.o \ - $(B)/client/jpeg/jidctflt.o \ - $(B)/client/jpeg/jidctfst.o \ - $(B)/client/jpeg/jidctint.o \ - $(B)/client/jpeg/jmemmgr.o \ - $(B)/client/jpeg/jmemnobs.o \ - $(B)/client/jpeg/jquant1.o \ - $(B)/client/jpeg/jquant2.o \ - $(B)/client/jpeg/jutils.o - -ifeq ($(USE_OGG_VORBIS),1) -ifeq ($(USE_SYSTEM_OGG),0) -OGGOBJ = \ - $(B)/client/ogg/bitwise.o \ - $(B)/client/ogg/framing.o -endif - -ifeq ($(USE_SYSTEM_VORBIS),0) -VORBISOBJ = \ - $(B)/client/vorbis/analysis.o \ - $(B)/client/vorbis/bitrate.o \ - $(B)/client/vorbis/block.o \ - $(B)/client/vorbis/codebook.o \ - $(B)/client/vorbis/envelope.o \ - $(B)/client/vorbis/floor0.o \ - $(B)/client/vorbis/floor1.o \ - $(B)/client/vorbis/info.o \ - $(B)/client/vorbis/lookup.o \ - $(B)/client/vorbis/lpc.o \ - $(B)/client/vorbis/lsp.o \ - $(B)/client/vorbis/mapping0.o \ - $(B)/client/vorbis/mdct.o \ - $(B)/client/vorbis/psy.o \ - $(B)/client/vorbis/registry.o \ - $(B)/client/vorbis/res0.o \ - $(B)/client/vorbis/smallft.o \ - $(B)/client/vorbis/sharedbook.o \ - $(B)/client/vorbis/synthesis.o \ - $(B)/client/vorbis/vorbisfile.o \ - $(B)/client/vorbis/window.o -endif -endif - -Q3OBJ = \ - $(B)/client/cl_cgame.o \ - $(B)/client/cl_cin.o \ - $(B)/client/cl_console.o \ - $(B)/client/cl_input.o \ - $(B)/client/cl_keys.o \ - $(B)/client/cl_main.o \ - $(B)/client/cl_net_chan.o \ - $(B)/client/cl_parse.o \ - $(B)/client/cl_scrn.o \ - $(B)/client/cl_ui.o \ - $(B)/client/cl_avi.o \ - $(B)/client/cl_jpeg.o \ - \ - $(B)/client/cm_load.o \ - $(B)/client/cm_patch.o \ - $(B)/client/cm_polylib.o \ - $(B)/client/cm_test.o \ - $(B)/client/cm_trace.o \ - \ - $(B)/client/cmd.o \ - $(B)/client/common.o \ - $(B)/client/cvar.o \ - $(B)/client/files.o \ - $(B)/client/history.o \ - $(B)/client/keys.o \ - $(B)/client/md4.o \ - $(B)/client/md5.o \ - $(B)/client/msg.o \ - $(B)/client/net_chan.o \ - $(B)/client/net_ip.o \ - $(B)/client/huffman.o \ - $(B)/client/huffman_static.o \ - \ - $(B)/client/snd_adpcm.o \ - $(B)/client/snd_dma.o \ - $(B)/client/snd_mem.o \ - $(B)/client/snd_mix.o \ - $(B)/client/snd_wavelet.o \ - \ - $(B)/client/snd_main.o \ - $(B)/client/snd_codec.o \ - $(B)/client/snd_codec_wav.o \ - \ - $(B)/client/sv_bot.o \ - $(B)/client/sv_ccmds.o \ - $(B)/client/sv_client.o \ - $(B)/client/sv_filter.o \ - $(B)/client/sv_game.o \ - $(B)/client/sv_init.o \ - $(B)/client/sv_main.o \ - $(B)/client/sv_net_chan.o \ - $(B)/client/sv_snapshot.o \ - $(B)/client/sv_world.o \ - \ - $(B)/client/q_math.o \ - $(B)/client/q_shared.o \ - \ - $(B)/client/unzip.o \ - $(B)/client/puff.o \ - \ - $(B)/client/be_aas_bspq3.o \ - $(B)/client/be_aas_cluster.o \ - $(B)/client/be_aas_debug.o \ - $(B)/client/be_aas_entity.o \ - $(B)/client/be_aas_file.o \ - $(B)/client/be_aas_main.o \ - $(B)/client/be_aas_move.o \ - $(B)/client/be_aas_optimize.o \ - $(B)/client/be_aas_reach.o \ - $(B)/client/be_aas_route.o \ - $(B)/client/be_aas_routealt.o \ - $(B)/client/be_aas_sample.o \ - $(B)/client/be_ai_char.o \ - $(B)/client/be_ai_chat.o \ - $(B)/client/be_ai_gen.o \ - $(B)/client/be_ai_goal.o \ - $(B)/client/be_ai_move.o \ - $(B)/client/be_ai_weap.o \ - $(B)/client/be_ai_weight.o \ - $(B)/client/be_ea.o \ - $(B)/client/be_interface.o \ - $(B)/client/l_crc.o \ - $(B)/client/l_libvar.o \ - $(B)/client/l_log.o \ - $(B)/client/l_memory.o \ - $(B)/client/l_precomp.o \ - $(B)/client/l_script.o \ - $(B)/client/l_struct.o - -ifneq ($(USE_SYSTEM_JPEG),1) - Q3OBJ += $(JPGOBJ) -endif - -ifeq ($(USE_OGG_VORBIS),1) - Q3OBJ += $(OGGOBJ) $(VORBISOBJ) \ - $(B)/client/snd_codec_ogg.o -endif - -ifneq ($(USE_RENDERER_DLOPEN),1) - ifeq ($(USE_VULKAN),1) - Q3OBJ += $(Q3RENDVOBJ) - else - ifeq ($(USE_OPENGL2),1) - Q3OBJ += $(Q3REND2OBJ) - Q3OBJ += $(Q3REND2STROBJ) - else - Q3OBJ += $(Q3REND1OBJ) - endif - endif -endif - -ifeq ($(ARCH),x86) -ifndef MINGW - Q3OBJ += \ - $(B)/client/snd_mix_mmx.o \ - $(B)/client/snd_mix_sse.o -endif -endif - -ifeq ($(ARCH),x86_64) - Q3OBJ += \ - $(B)/client/snd_mix_x86_64.o -endif - -Q3OBJ += \ - $(B)/client/qvm/vm.o \ - $(B)/client/qvm/vm_interpreted.o - -ifeq ($(HAVE_VM_COMPILED),true) - ifeq ($(ARCH),x86) - Q3OBJ += $(B)/client/qvm/vm_x86.o - endif - ifeq ($(ARCH),x86_64) - Q3OBJ += $(B)/client/qvm/vm_x86.o - endif - ifeq ($(ARCH),arm) - Q3OBJ += $(B)/client/qvm/vm_armv7l.o - endif - ifeq ($(ARCH),aarch64) - Q3OBJ += $(B)/client/qvm/vm_aarch64.o - endif -endif - -ifeq ($(USE_CURL),1) - Q3OBJ += $(B)/client/cl_curl.o -endif - -ifdef MINGW - - Q3OBJ += \ - $(B)/client/win_main.o \ - $(B)/client/win_shared.o \ - $(B)/client/win_syscon.o \ - $(B)/client/win_resource.o - -ifeq ($(USE_SDL),1) - Q3OBJ += \ - $(B)/client/sdl_glimp.o \ - $(B)/client/sdl_gamma.o \ - $(B)/client/sdl_input.o \ - $(B)/client/sdl_snd.o -else # !USE_SDL - Q3OBJ += \ - $(B)/client/win_gamma.o \ - $(B)/client/win_glimp.o \ - $(B)/client/win_input.o \ - $(B)/client/win_minimize.o \ - $(B)/client/win_snd.o \ - $(B)/client/win_wndproc.o - -ifeq ($(USE_OPENGL_API),1) - Q3OBJ += \ - $(B)/client/win_qgl.o -endif - -ifeq ($(USE_VULKAN_API),1) - Q3OBJ += \ - $(B)/client/win_qvk.o -endif -endif # !USE_SDL - -else # !MINGW - - Q3OBJ += \ - $(B)/client/unix_main.o \ - $(B)/client/unix_shared.o \ - $(B)/client/linux_signals.o - -ifeq ($(USE_SDL),1) - Q3OBJ += \ - $(B)/client/sdl_glimp.o \ - $(B)/client/sdl_gamma.o \ - $(B)/client/sdl_input.o \ - $(B)/client/sdl_snd.o -else # !USE_SDL - Q3OBJ += \ - $(B)/client/linux_glimp.o \ - $(B)/client/linux_snd.o \ - $(B)/client/x11_dga.o \ - $(B)/client/x11_randr.o \ - $(B)/client/x11_vidmode.o -ifeq ($(USE_OPENGL_API),1) - Q3OBJ += \ - $(B)/client/linux_qgl.o -endif -ifeq ($(USE_VULKAN_API),1) - Q3OBJ += \ - $(B)/client/linux_qvk.o -endif -endif # !USE_SDL - -endif # !MINGW - -# client binary - -$(B)/$(TARGET_CLIENT): $(Q3OBJ) - $(echo_cmd) "LD $@" - $(Q)$(CC) -o $@ $(Q3OBJ) $(CLIENT_LDFLAGS) $(LDFLAGS) - -# modular renderers - -$(B)/$(TARGET_REND1): $(Q3REND1OBJ) - $(echo_cmd) "LD $@" - $(Q)$(CC) -o $@ $(Q3REND1OBJ) $(SHLIBCFLAGS) $(SHLIBLDFLAGS) - -$(STRINGIFY): $(MOUNT_DIR)/renderer2/stringify.c - $(echo_cmd) "LD $@" - $(Q)$(CC) -o $@ $(MOUNT_DIR)/renderer2/stringify.c $(LDFLAGS) - -$(B)/$(TARGET_REND2): $(Q3REND2OBJ) $(Q3REND2STROBJ) - $(echo_cmd) "LD $@" - $(Q)$(CC) -o $@ $(Q3REND2OBJ) $(Q3REND2STROBJ) $(SHLIBCFLAGS) $(SHLIBLDFLAGS) - -$(B)/$(TARGET_RENDV): $(Q3RENDVOBJ) - $(echo_cmd) "LD $@" - $(Q)$(CC) -o $@ $(Q3RENDVOBJ) $(SHLIBCFLAGS) $(SHLIBLDFLAGS) - -############################################################################# -# DEDICATED SERVER -############################################################################# - -Q3DOBJ = \ - $(B)/ded/sv_bot.o \ - $(B)/ded/sv_client.o \ - $(B)/ded/sv_ccmds.o \ - $(B)/ded/sv_filter.o \ - $(B)/ded/sv_game.o \ - $(B)/ded/sv_init.o \ - $(B)/ded/sv_main.o \ - $(B)/ded/sv_net_chan.o \ - $(B)/ded/sv_snapshot.o \ - $(B)/ded/sv_world.o \ - \ - $(B)/ded/cm_load.o \ - $(B)/ded/cm_patch.o \ - $(B)/ded/cm_polylib.o \ - $(B)/ded/cm_test.o \ - $(B)/ded/cm_trace.o \ - $(B)/ded/cmd.o \ - $(B)/ded/common.o \ - $(B)/ded/cvar.o \ - $(B)/ded/files.o \ - $(B)/ded/history.o \ - $(B)/ded/keys.o \ - $(B)/ded/md4.o \ - $(B)/ded/md5.o \ - $(B)/ded/msg.o \ - $(B)/ded/net_chan.o \ - $(B)/ded/net_ip.o \ - $(B)/ded/huffman.o \ - $(B)/ded/huffman_static.o \ - \ - $(B)/ded/q_math.o \ - $(B)/ded/q_shared.o \ - \ - $(B)/ded/unzip.o \ - \ - $(B)/ded/be_aas_bspq3.o \ - $(B)/ded/be_aas_cluster.o \ - $(B)/ded/be_aas_debug.o \ - $(B)/ded/be_aas_entity.o \ - $(B)/ded/be_aas_file.o \ - $(B)/ded/be_aas_main.o \ - $(B)/ded/be_aas_move.o \ - $(B)/ded/be_aas_optimize.o \ - $(B)/ded/be_aas_reach.o \ - $(B)/ded/be_aas_route.o \ - $(B)/ded/be_aas_routealt.o \ - $(B)/ded/be_aas_sample.o \ - $(B)/ded/be_ai_char.o \ - $(B)/ded/be_ai_chat.o \ - $(B)/ded/be_ai_gen.o \ - $(B)/ded/be_ai_goal.o \ - $(B)/ded/be_ai_move.o \ - $(B)/ded/be_ai_weap.o \ - $(B)/ded/be_ai_weight.o \ - $(B)/ded/be_ea.o \ - $(B)/ded/be_interface.o \ - $(B)/ded/l_crc.o \ - $(B)/ded/l_libvar.o \ - $(B)/ded/l_log.o \ - $(B)/ded/l_memory.o \ - $(B)/ded/l_precomp.o \ - $(B)/ded/l_script.o \ - $(B)/ded/l_struct.o - -ifdef MINGW - Q3DOBJ += \ - $(B)/ded/win_main.o \ - $(B)/client/win_resource.o \ - $(B)/ded/win_shared.o \ - $(B)/ded/win_syscon.o -else - Q3DOBJ += \ - $(B)/ded/linux_signals.o \ - $(B)/ded/unix_main.o \ - $(B)/ded/unix_shared.o -endif - - Q3DOBJ += \ - $(B)/ded/qvm/vm.o \ - $(B)/ded/qvm/vm_interpreted.o - -ifeq ($(HAVE_VM_COMPILED),true) - ifeq ($(ARCH),x86) - Q3DOBJ += $(B)/ded/qvm/vm_x86.o - endif - ifeq ($(ARCH),x86_64) - Q3DOBJ += $(B)/ded/qvm/vm_x86.o - endif - ifeq ($(ARCH),arm) - Q3DOBJ += $(B)/ded/qvm/vm_armv7l.o - endif - ifeq ($(ARCH),aarch64) - Q3DOBJ += $(B)/ded/qvm/vm_aarch64.o - endif -endif - -$(B)/$(TARGET_SERVER): $(Q3DOBJ) - $(echo_cmd) $(Q3DOBJ) - $(echo_cmd) "LD $@" - $(Q)$(CC) -o $@ $(Q3DOBJ) $(LDFLAGS) - -############################################################################# -## CLIENT/SERVER RULES -############################################################################# - -$(B)/client/%.o: $(ADIR)/%.s - $(DO_AS) - -$(B)/client/%.o: $(CDIR)/%.c - $(DO_CC) - -$(B)/client/%.o: $(SDIR)/%.c - $(DO_CC) - -$(B)/client/%.o: $(CMDIR)/%.c - $(DO_CC) - -$(B)/client/qvm/%.o: $(CMDIR)/%.c - $(DO_CC_QVM) - -$(B)/client/%.o: $(BLIBDIR)/%.c - $(DO_BOT_CC) - -$(B)/client/jpeg/%.o: $(JPDIR)/%.c - $(DO_CC) - -$(B)/client/ogg/%.o: $(OGGDIR)/src/%.c - $(DO_CC) - -$(B)/client/vorbis/%.o: $(VORBISDIR)/lib/%.c - $(DO_CC) - -$(B)/client/%.o: $(SDLDIR)/%.c - $(DO_CC) - -$(B)/rend1/%.o: $(R1DIR)/%.c - $(DO_REND_CC) - -$(B)/rend1/%.o: $(RCDIR)/%.c - $(DO_REND_CC) - -$(B)/rend1/%.o: $(CMDIR)/%.c - $(DO_REND_CC) - -$(B)/rend2/glsl/%.c: $(R2DIR)/glsl/%.glsl $(STRINGIFY) - $(DO_REF_STR) - -$(B)/rend2/glsl/%.o: $(B)/renderer2/glsl/%.c - $(DO_REND_CC) - -$(B)/rend2/%.o: $(R2DIR)/%.c - $(DO_REND_CC) - -$(B)/rend2/%.o: $(RCDIR)/%.c - $(DO_REND_CC) - -$(B)/rend2/%.o: $(CMDIR)/%.c - $(DO_REND_CC) - -$(B)/rendv/%.o: $(RVDIR)/%.c - $(DO_REND_CC) - -$(B)/rendv/%.o: $(RCDIR)/%.c - $(DO_REND_CC) - -$(B)/rendv/%.o: $(CMDIR)/%.c - $(DO_REND_CC) - -$(B)/client/%.o: $(UDIR)/%.c - $(DO_CC) - -$(B)/client/%.o: $(W32DIR)/%.c - $(DO_CC) - -$(B)/client/%.o: $(W32DIR)/%.rc - $(DO_WINDRES) - -$(B)/ded/%.o: $(ADIR)/%.s - $(DO_AS) - -$(B)/ded/%.o: $(SDIR)/%.c - $(DO_DED_CC) - -$(B)/ded/%.o: $(CMDIR)/%.c - $(DO_DED_CC) - -$(B)/ded/qvm/%.o: $(CMDIR)/%.c - $(DO_DED_CC_QVM) - -$(B)/ded/%.o: $(BLIBDIR)/%.c - $(DO_BOT_CC) - -$(B)/ded/%.o: $(UDIR)/%.c - $(DO_DED_CC) - -$(B)/ded/%.o: $(W32DIR)/%.c - $(DO_DED_CC) - -$(B)/ded/%.o: $(W32DIR)/%.rc - $(DO_WINDRES) - -############################################################################# -# MISC -############################################################################# - -install: release - @for i in $(TARGETS); do \ - if [ -f $(BR)$$i ]; then \ - $(INSTALL) -D -m 0755 "$(BR)/$$i" "$(DESTDIR)$$i"; \ - $(STRIP) "$(DESTDIR)$$i"; \ - fi \ - done - -clean: clean-debug clean-release - -clean2: - @echo "CLEAN $(B)" - @if [ -d $(B) ];then (find $(B) -name '*.d' -exec rm {} \;)fi - @rm -f $(Q3OBJ) $(Q3DOBJ) - @rm -f $(TARGETS) - -clean-debug: - @rm -rf $(BD) - -clean-release: - @echo $(BR) - @rm -rf $(BR) - -distclean: clean - @rm -rf $(BUILD_DIR) - -############################################################################# -# DEPENDENCIES -############################################################################# - -D_FILES=$(shell find . -name '*.d') - -ifneq ($(strip $(D_FILES)),) - include $(D_FILES) -endif - -.PHONY: all clean clean2 clean-debug clean-release copyfiles \ - debug default dist distclean makedirs release \ - targets tools toolsclean diff --git a/README.md b/README.md index a1f9cc1480..34cae4150b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # id Tech 3 -[![build](../../workflows/build/badge.svg)](../../actions?query=workflow%3Abuild) * Discord server +[![build](../../workflows/build/badge.svg)](../../actions?query=workflow%3Abuild) -This is a modernized id Tech 3 engine aimed to be fast, secure and compatible with all existing Q3A mods. +This is a modernized id Tech 3 engine. Go to [Releases](../../releases) section to download latest binaries for your platform or follow [Build Instructions](#build-instructions) @@ -52,8 +52,6 @@ Based on [Quake-III-Arena-Kenny-Edition](https://github.com/kennyalive/Quake-III In general, not counting offscreen rendering features you might expect from 10% to 200%+ FPS increase comparing to KE's original version -Highly recommended to use on modern systems - ## OpenGL renderer Based on classic OpenGL renderers from [idq3](https://github.com/id-Software/Quake-III-Arena)/[ioquake3](https://github.com/ioquake/ioq3)/[cnq3](https://bitbucket.org/CPMADevs/cnq3)/[openarena](https://github.com/OpenArena/engine), features: @@ -65,22 +63,13 @@ Based on classic OpenGL renderers from [idq3](https://github.com/id-Software/Qua * all set of offscreen rendering features mentioned in Vulkan renderer, plus: * bloom reflection post-processing effect -Performance is usually greater or equal to other opengl1 renderers - -## OpenGL2 renderer - -Original ioquake3 renderer, performance is very poor on non-nvidia systems, unmaintained - -## [Build Instructions](BUILD.md) - -## Contacts - -Discord channel: https://discordapp.com/invite/X3Exs4C - ## Links +* https://idtech3.com * https://bitbucket.org/CPMADevs/cnq3 * https://github.com/ioquake/ioq3 * https://github.com/kennyalive/Quake-III-Arena-Kenny-Edition * https://github.com/OpenArena/engine + + diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000000..eb6cbb681d --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,72 @@ +# Security Policy + +Thanks for helping keep this project safe. If you believe you’ve found a security vulnerability, please report it responsibly so we can fix it. + +## Supported Versions + +Security fixes are provided for: + +- **Latest tagged release** (recommended) +- **`main`** (best-effort; may contain breaking changes) + +Older tags/branches may not receive security updates. If you’re unsure whether a version is supported, report the issue anyway and include the commit/tag you tested. + +> Tip: include the exact tag/commit hash and platform (Linux/Windows/macOS), since engine behavior can vary by build flags. + +## Reporting a Vulnerability + +### Preferred: GitHub Private Vulnerability Reporting +Please report vulnerabilities via **GitHub Security Advisories** (Private Vulnerability Reporting): +- Go to the repo → **Security** → **Report a vulnerability** + +### What to include +To help reproduce and fix quickly, include: + +- A clear description of the issue and why it’s security-relevant +- Affected version(s) / commit hash +- Platform + build configuration (compiler, CMake options, sanitizers, renderer, etc.) +- Repro steps or a minimal PoC (proof of concept) +- Any crash logs, backtraces, ASan/UBSan output, or screenshots +- If file-based: the smallest malicious asset/archive that triggers the issue (if safe to share) + +### Response expectations +- **Acknowledgement:** within **72 hours** +- **Initial assessment / triage:** within **7 days** +- **Fix timeline:** depends on severity and complexity (critical issues are prioritized) + +If the report is accepted, we’ll coordinate a disclosure timeline with you. If it’s declined, we’ll explain why. + +## Scope + +### In scope (examples) +- Remote code execution, sandbox escape, or privilege escalation +- Path traversal / arbitrary file write/read +- Unsafe parsing of network traffic (client/server protocol) +- Unsafe parsing of content archives/assets (e.g., `.pk3` or equivalent formats) +- Memory safety issues that appear exploitable (use-after-free, heap overflow, etc.) +- Supply-chain or update-related integrity issues (if applicable) + +### Out of scope (examples) +- Non-exploitable crashes with no realistic security impact +- General gameplay cheating, griefing, or balance exploits +- Vulnerabilities in third-party dependencies that do not affect this project’s builds +- Issues requiring physical access only (unless they enable meaningful escalation) + +If you’re not sure, report it anyway—better a false alarm than a silent RCE gremlin. + +## Coordinated Disclosure + +Please **do not publicly disclose** details (issues, PRs, social posts) until we’ve shipped a fix or agreed on a timeline. + +We aim to follow coordinated disclosure norms (often ~90 days for publicly disclosed reports), but we’ll adjust based on severity and real-world risk. + +## Safe Harbor / Testing Guidelines + +- Do not test against systems you don’t own or lack permission to test. +- Do not disrupt public/community servers (no scanning, flooding, or DoS). +- Keep PoCs minimal and avoid payloads that cause harm beyond demonstrating the issue. + +## Credit + +If you want, we’re happy to credit reporters in release notes / advisories. +Include your preferred name/handle in the report. diff --git a/code/renderer2/glext.h b/code/renderer2/glext.h deleted file mode 100644 index 907a5826d7..0000000000 --- a/code/renderer2/glext.h +++ /dev/null @@ -1,12051 +0,0 @@ -#ifndef __glext_h_ -#define __glext_h_ 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2013-2015 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ -/* -** This header is generated from the Khronos OpenGL / OpenGL ES XML -** API Registry. The current version of the Registry, generator scripts -** used to make the header, and the header can be found at -** http://www.opengl.org/registry/ -** -** Khronos $Revision: 31811 $ on $Date: 2015-08-10 17:01:11 +1000 (Mon, 10 Aug 2015) $ -*/ - -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN 1 -#endif -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -#define GL_GLEXT_VERSION 20150809 - -/* Generated C header for: - * API: gl - * Profile: compatibility - * Versions considered: .* - * Versions emitted: 1\.[2-9]|[234]\.[0-9] - * Default extensions included: gl - * Additional extensions included: _nomatch_^ - * Extensions removed: _nomatch_^ - */ - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#define GL_RESCALE_NORMAL 0x803A -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); -GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif -#endif /* GL_VERSION_1_2 */ - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define GL_COMPRESSED_RGB 0x84ED -#define GL_COMPRESSED_RGBA 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 -#define GL_TEXTURE_COMPRESSED 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_CLAMP_TO_BORDER 0x812D -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 -#define GL_MULTISAMPLE_BIT 0x20000000 -#define GL_NORMAL_MAP 0x8511 -#define GL_REFLECTION_MAP 0x8512 -#define GL_COMPRESSED_ALPHA 0x84E9 -#define GL_COMPRESSED_LUMINANCE 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB -#define GL_COMPRESSED_INTENSITY 0x84EC -#define GL_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_SOURCE0_RGB 0x8580 -#define GL_SOURCE1_RGB 0x8581 -#define GL_SOURCE2_RGB 0x8582 -#define GL_SOURCE0_ALPHA 0x8588 -#define GL_SOURCE1_ALPHA 0x8589 -#define GL_SOURCE2_ALPHA 0x858A -#define GL_OPERAND0_RGB 0x8590 -#define GL_OPERAND1_RGB 0x8591 -#define GL_OPERAND2_RGB 0x8592 -#define GL_OPERAND0_ALPHA 0x8598 -#define GL_OPERAND1_ALPHA 0x8599 -#define GL_OPERAND2_ALPHA 0x859A -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_SUBTRACT 0x84E7 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -#define GL_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTexture (GLenum texture); -GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); -GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, void *img); -GLAPI void APIENTRY glClientActiveTexture (GLenum texture); -GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); -GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); -GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); -GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); -GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); -GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); -GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); -GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); -GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); -GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); -GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); -GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); -GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); -GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); -GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); -GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); -GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); -#endif -#endif /* GL_VERSION_1_3 */ - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_GENERATE_MIPMAP 0x8191 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_FOG_COORDINATE_SOURCE 0x8450 -#define GL_FOG_COORDINATE 0x8451 -#define GL_FRAGMENT_DEPTH 0x8452 -#define GL_CURRENT_FOG_COORDINATE 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 -#define GL_FOG_COORDINATE_ARRAY 0x8457 -#define GL_COLOR_SUM 0x8458 -#define GL_CURRENT_SECONDARY_COLOR 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D -#define GL_SECONDARY_COLOR_ARRAY 0x845E -#define GL_TEXTURE_FILTER_CONTROL 0x8500 -#define GL_DEPTH_TEXTURE_MODE 0x884B -#define GL_COMPARE_R_TO_TEXTURE 0x884E -#define GL_FUNC_ADD 0x8006 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); -GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); -GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); -GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); -GLAPI void APIENTRY glFogCoordf (GLfloat coord); -GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); -GLAPI void APIENTRY glFogCoordd (GLdouble coord); -GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); -GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); -GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); -GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); -GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); -GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); -GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); -GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); -GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); -GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); -GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); -GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); -GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); -GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); -GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); -GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); -GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); -GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2iv (const GLint *v); -GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); -GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3iv (const GLint *v); -GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); -GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -GLAPI void APIENTRY glBlendEquation (GLenum mode); -#endif -#endif /* GL_VERSION_1_4 */ - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 -#include -typedef ptrdiff_t GLsizeiptr; -typedef ptrdiff_t GLintptr; -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_QUERY_COUNTER_BITS 0x8864 -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#define GL_BUFFER_ACCESS 0x88BB -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_SAMPLES_PASSED 0x8914 -#define GL_SRC1_ALPHA 0x8589 -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E -#define GL_FOG_COORD_SRC 0x8450 -#define GL_FOG_COORD 0x8451 -#define GL_CURRENT_FOG_COORD 0x8453 -#define GL_FOG_COORD_ARRAY_TYPE 0x8454 -#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORD_ARRAY_POINTER 0x8456 -#define GL_FOG_COORD_ARRAY 0x8457 -#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D -#define GL_SRC0_RGB 0x8580 -#define GL_SRC1_RGB 0x8581 -#define GL_SRC2_RGB 0x8582 -#define GL_SRC0_ALPHA 0x8588 -#define GL_SRC2_ALPHA 0x858A -typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void *data); -typedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsQuery (GLuint id); -GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); -GLAPI void APIENTRY glEndQuery (GLenum target); -GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); -GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); -GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); -GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); -GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); -GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); -GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); -GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, void *data); -GLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access); -GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); -GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); -#endif -#endif /* GL_VERSION_1_5 */ - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -typedef char GLchar; -#define GL_BLEND_EQUATION_RGB 0x8009 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_MAX_VARYING_FLOATS 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_SHADER_TYPE 0x8B4F -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_1D 0x8B5D -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_CUBE 0x8B60 -#define GL_SAMPLER_1D_SHADOW 0x8B61 -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_DELETE_STATUS 0x8B80 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 -#define GL_LOWER_LEFT 0x8CA1 -#define GL_UPPER_LEFT 0x8CA2 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 -#define GL_POINT_SPRITE 0x8861 -#define GL_COORD_REPLACE 0x8862 -#define GL_MAX_TEXTURE_COORDS 0x8871 -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); -GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); -GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); -GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); -GLAPI void APIENTRY glCompileShader (GLuint shader); -GLAPI GLuint APIENTRY glCreateProgram (void); -GLAPI GLuint APIENTRY glCreateShader (GLenum type); -GLAPI void APIENTRY glDeleteProgram (GLuint program); -GLAPI void APIENTRY glDeleteShader (GLuint shader); -GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); -GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); -GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); -GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); -GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); -GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); -GLAPI GLboolean APIENTRY glIsProgram (GLuint program); -GLAPI GLboolean APIENTRY glIsShader (GLuint shader); -GLAPI void APIENTRY glLinkProgram (GLuint program); -GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); -GLAPI void APIENTRY glUseProgram (GLuint program); -GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); -GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); -GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glValidateProgram (GLuint program); -GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); -#endif -#endif /* GL_VERSION_2_0 */ - -#ifndef GL_VERSION_2_1 -#define GL_VERSION_2_1 1 -#define GL_PIXEL_PACK_BUFFER 0x88EB -#define GL_PIXEL_UNPACK_BUFFER 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF -#define GL_FLOAT_MAT2x3 0x8B65 -#define GL_FLOAT_MAT2x4 0x8B66 -#define GL_FLOAT_MAT3x2 0x8B67 -#define GL_FLOAT_MAT3x4 0x8B68 -#define GL_FLOAT_MAT4x2 0x8B69 -#define GL_FLOAT_MAT4x3 0x8B6A -#define GL_SRGB 0x8C40 -#define GL_SRGB8 0x8C41 -#define GL_SRGB_ALPHA 0x8C42 -#define GL_SRGB8_ALPHA8 0x8C43 -#define GL_COMPRESSED_SRGB 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 -#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F -#define GL_SLUMINANCE_ALPHA 0x8C44 -#define GL_SLUMINANCE8_ALPHA8 0x8C45 -#define GL_SLUMINANCE 0x8C46 -#define GL_SLUMINANCE8 0x8C47 -#define GL_COMPRESSED_SLUMINANCE 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif -#endif /* GL_VERSION_2_1 */ - -#ifndef GL_VERSION_3_0 -#define GL_VERSION_3_0 1 -typedef unsigned short GLhalf; -#define GL_COMPARE_REF_TO_TEXTURE 0x884E -#define GL_CLIP_DISTANCE0 0x3000 -#define GL_CLIP_DISTANCE1 0x3001 -#define GL_CLIP_DISTANCE2 0x3002 -#define GL_CLIP_DISTANCE3 0x3003 -#define GL_CLIP_DISTANCE4 0x3004 -#define GL_CLIP_DISTANCE5 0x3005 -#define GL_CLIP_DISTANCE6 0x3006 -#define GL_CLIP_DISTANCE7 0x3007 -#define GL_MAX_CLIP_DISTANCES 0x0D32 -#define GL_MAJOR_VERSION 0x821B -#define GL_MINOR_VERSION 0x821C -#define GL_NUM_EXTENSIONS 0x821D -#define GL_CONTEXT_FLAGS 0x821E -#define GL_COMPRESSED_RED 0x8225 -#define GL_COMPRESSED_RG 0x8226 -#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 -#define GL_RGBA32F 0x8814 -#define GL_RGB32F 0x8815 -#define GL_RGBA16F 0x881A -#define GL_RGB16F 0x881B -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD -#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF -#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 -#define GL_CLAMP_READ_COLOR 0x891C -#define GL_FIXED_ONLY 0x891D -#define GL_MAX_VARYING_COMPONENTS 0x8B4B -#define GL_TEXTURE_1D_ARRAY 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 -#define GL_TEXTURE_2D_ARRAY 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D -#define GL_R11F_G11F_B10F 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B -#define GL_RGB9_E5 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E -#define GL_TEXTURE_SHARED_SIZE 0x8C3F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 -#define GL_PRIMITIVES_GENERATED 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 -#define GL_RASTERIZER_DISCARD 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B -#define GL_INTERLEAVED_ATTRIBS 0x8C8C -#define GL_SEPARATE_ATTRIBS 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F -#define GL_RGBA32UI 0x8D70 -#define GL_RGB32UI 0x8D71 -#define GL_RGBA16UI 0x8D76 -#define GL_RGB16UI 0x8D77 -#define GL_RGBA8UI 0x8D7C -#define GL_RGB8UI 0x8D7D -#define GL_RGBA32I 0x8D82 -#define GL_RGB32I 0x8D83 -#define GL_RGBA16I 0x8D88 -#define GL_RGB16I 0x8D89 -#define GL_RGBA8I 0x8D8E -#define GL_RGB8I 0x8D8F -#define GL_RED_INTEGER 0x8D94 -#define GL_GREEN_INTEGER 0x8D95 -#define GL_BLUE_INTEGER 0x8D96 -#define GL_RGB_INTEGER 0x8D98 -#define GL_RGBA_INTEGER 0x8D99 -#define GL_BGR_INTEGER 0x8D9A -#define GL_BGRA_INTEGER 0x8D9B -#define GL_SAMPLER_1D_ARRAY 0x8DC0 -#define GL_SAMPLER_2D_ARRAY 0x8DC1 -#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 -#define GL_UNSIGNED_INT_VEC2 0x8DC6 -#define GL_UNSIGNED_INT_VEC3 0x8DC7 -#define GL_UNSIGNED_INT_VEC4 0x8DC8 -#define GL_INT_SAMPLER_1D 0x8DC9 -#define GL_INT_SAMPLER_2D 0x8DCA -#define GL_INT_SAMPLER_3D 0x8DCB -#define GL_INT_SAMPLER_CUBE 0x8DCC -#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF -#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 -#define GL_QUERY_WAIT 0x8E13 -#define GL_QUERY_NO_WAIT 0x8E14 -#define GL_QUERY_BY_REGION_WAIT 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 -#define GL_BUFFER_ACCESS_FLAGS 0x911F -#define GL_BUFFER_MAP_LENGTH 0x9120 -#define GL_BUFFER_MAP_OFFSET 0x9121 -#define GL_DEPTH_COMPONENT32F 0x8CAC -#define GL_DEPTH32F_STENCIL8 0x8CAD -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 -#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 -#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 -#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 -#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 -#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 -#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 -#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 -#define GL_FRAMEBUFFER_DEFAULT 0x8218 -#define GL_FRAMEBUFFER_UNDEFINED 0x8219 -#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define GL_DEPTH_STENCIL 0x84F9 -#define GL_UNSIGNED_INT_24_8 0x84FA -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE 0x88F1 -#define GL_TEXTURE_RED_TYPE 0x8C10 -#define GL_TEXTURE_GREEN_TYPE 0x8C11 -#define GL_TEXTURE_BLUE_TYPE 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE 0x8C13 -#define GL_TEXTURE_DEPTH_TYPE 0x8C16 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_READ_FRAMEBUFFER 0x8CA8 -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA -#define GL_RENDERBUFFER_SAMPLES 0x8CAB -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_COLOR_ATTACHMENT1 0x8CE1 -#define GL_COLOR_ATTACHMENT2 0x8CE2 -#define GL_COLOR_ATTACHMENT3 0x8CE3 -#define GL_COLOR_ATTACHMENT4 0x8CE4 -#define GL_COLOR_ATTACHMENT5 0x8CE5 -#define GL_COLOR_ATTACHMENT6 0x8CE6 -#define GL_COLOR_ATTACHMENT7 0x8CE7 -#define GL_COLOR_ATTACHMENT8 0x8CE8 -#define GL_COLOR_ATTACHMENT9 0x8CE9 -#define GL_COLOR_ATTACHMENT10 0x8CEA -#define GL_COLOR_ATTACHMENT11 0x8CEB -#define GL_COLOR_ATTACHMENT12 0x8CEC -#define GL_COLOR_ATTACHMENT13 0x8CED -#define GL_COLOR_ATTACHMENT14 0x8CEE -#define GL_COLOR_ATTACHMENT15 0x8CEF -#define GL_COLOR_ATTACHMENT16 0x8CF0 -#define GL_COLOR_ATTACHMENT17 0x8CF1 -#define GL_COLOR_ATTACHMENT18 0x8CF2 -#define GL_COLOR_ATTACHMENT19 0x8CF3 -#define GL_COLOR_ATTACHMENT20 0x8CF4 -#define GL_COLOR_ATTACHMENT21 0x8CF5 -#define GL_COLOR_ATTACHMENT22 0x8CF6 -#define GL_COLOR_ATTACHMENT23 0x8CF7 -#define GL_COLOR_ATTACHMENT24 0x8CF8 -#define GL_COLOR_ATTACHMENT25 0x8CF9 -#define GL_COLOR_ATTACHMENT26 0x8CFA -#define GL_COLOR_ATTACHMENT27 0x8CFB -#define GL_COLOR_ATTACHMENT28 0x8CFC -#define GL_COLOR_ATTACHMENT29 0x8CFD -#define GL_COLOR_ATTACHMENT30 0x8CFE -#define GL_COLOR_ATTACHMENT31 0x8CFF -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_STENCIL_INDEX1 0x8D46 -#define GL_STENCIL_INDEX4 0x8D47 -#define GL_STENCIL_INDEX8 0x8D48 -#define GL_STENCIL_INDEX16 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define GL_MAX_SAMPLES 0x8D57 -#define GL_INDEX 0x8222 -#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 -#define GL_FRAMEBUFFER_SRGB 0x8DB9 -#define GL_HALF_FLOAT 0x140B -#define GL_MAP_READ_BIT 0x0001 -#define GL_MAP_WRITE_BIT 0x0002 -#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 -#define GL_COMPRESSED_RED_RGTC1 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC -#define GL_COMPRESSED_RG_RGTC2 0x8DBD -#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE -#define GL_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_R16 0x822A -#define GL_RG8 0x822B -#define GL_RG16 0x822C -#define GL_R16F 0x822D -#define GL_R32F 0x822E -#define GL_RG16F 0x822F -#define GL_RG32F 0x8230 -#define GL_R8I 0x8231 -#define GL_R8UI 0x8232 -#define GL_R16I 0x8233 -#define GL_R16UI 0x8234 -#define GL_R32I 0x8235 -#define GL_R32UI 0x8236 -#define GL_RG8I 0x8237 -#define GL_RG8UI 0x8238 -#define GL_RG16I 0x8239 -#define GL_RG16UI 0x823A -#define GL_RG32I 0x823B -#define GL_RG32UI 0x823C -#define GL_VERTEX_ARRAY_BINDING 0x85B5 -#define GL_CLAMP_VERTEX_COLOR 0x891A -#define GL_CLAMP_FRAGMENT_COLOR 0x891B -#define GL_ALPHA_INTEGER 0x8D97 -typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); -GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); -GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); -GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); -GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); -GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedback (void); -GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); -GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); -GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); -GLAPI void APIENTRY glEndConditionalRender (void); -GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); -GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); -GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); -GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); -GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); -GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); -GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); -GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); -GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); -GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); -GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); -GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); -GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); -GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); -GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); -GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); -GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); -GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); -GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); -GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); -GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateMipmap (GLenum target); -GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); -GLAPI void APIENTRY glBindVertexArray (GLuint array); -GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); -GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); -GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); -#endif -#endif /* GL_VERSION_3_0 */ - -#ifndef GL_VERSION_3_1 -#define GL_VERSION_3_1 1 -#define GL_SAMPLER_2D_RECT 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 -#define GL_SAMPLER_BUFFER 0x8DC2 -#define GL_INT_SAMPLER_2D_RECT 0x8DCD -#define GL_INT_SAMPLER_BUFFER 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 -#define GL_TEXTURE_BUFFER 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D -#define GL_TEXTURE_RECTANGLE 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 -#define GL_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGB8_SNORM 0x8F96 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_R16_SNORM 0x8F98 -#define GL_RG16_SNORM 0x8F99 -#define GL_RGB16_SNORM 0x8F9A -#define GL_RGBA16_SNORM 0x8F9B -#define GL_SIGNED_NORMALIZED 0x8F9C -#define GL_PRIMITIVE_RESTART 0x8F9D -#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E -#define GL_COPY_READ_BUFFER 0x8F36 -#define GL_COPY_WRITE_BUFFER 0x8F37 -#define GL_UNIFORM_BUFFER 0x8A11 -#define GL_UNIFORM_BUFFER_BINDING 0x8A28 -#define GL_UNIFORM_BUFFER_START 0x8A29 -#define GL_UNIFORM_BUFFER_SIZE 0x8A2A -#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B -#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C -#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D -#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E -#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F -#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 -#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 -#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 -#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 -#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 -#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 -#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 -#define GL_UNIFORM_TYPE 0x8A37 -#define GL_UNIFORM_SIZE 0x8A38 -#define GL_UNIFORM_NAME_LENGTH 0x8A39 -#define GL_UNIFORM_BLOCK_INDEX 0x8A3A -#define GL_UNIFORM_OFFSET 0x8A3B -#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C -#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D -#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E -#define GL_UNIFORM_BLOCK_BINDING 0x8A3F -#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 -#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 -#define GL_INVALID_INDEX 0xFFFFFFFFu -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); -typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); -typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); -GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); -GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); -GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); -GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); -GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#endif -#endif /* GL_VERSION_3_1 */ - -#ifndef GL_VERSION_3_2 -#define GL_VERSION_3_2 1 -typedef struct __GLsync *GLsync; -#ifndef GLEXT_64_TYPES_DEFINED -/* This code block is duplicated in glxext.h, so must be protected */ -#define GLEXT_64_TYPES_DEFINED -/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ -/* (as used in the GL_EXT_timer_query extension). */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#include -#elif defined(__sun__) || defined(__digital__) -#include -#if defined(__STDC__) -#if defined(__arch64__) || defined(_LP64) -typedef long int int64_t; -typedef unsigned long int uint64_t; -#else -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#endif /* __arch64__ */ -#endif /* __STDC__ */ -#elif defined( __VMS ) || defined(__sgi) -#include -#elif defined(__SCO__) || defined(__USLC__) -#include -#elif defined(__UNIXOS2__) || defined(__SOL64__) -typedef long int int32_t; -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#elif defined(_WIN32) && defined(__GNUC__) -#include -#elif defined(_WIN32) -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#else -/* Fallback if nothing above works */ -#include -#endif -#endif -typedef uint64_t GLuint64; -typedef int64_t GLint64; -#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 -#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 -#define GL_LINES_ADJACENCY 0x000A -#define GL_LINE_STRIP_ADJACENCY 0x000B -#define GL_TRIANGLES_ADJACENCY 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D -#define GL_PROGRAM_POINT_SIZE 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 -#define GL_GEOMETRY_SHADER 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT 0x8916 -#define GL_GEOMETRY_INPUT_TYPE 0x8917 -#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 -#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 -#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 -#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 -#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 -#define GL_CONTEXT_PROFILE_MASK 0x9126 -#define GL_DEPTH_CLAMP 0x864F -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION 0x8E4D -#define GL_LAST_VERTEX_CONVENTION 0x8E4E -#define GL_PROVOKING_VERTEX 0x8E4F -#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F -#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 -#define GL_OBJECT_TYPE 0x9112 -#define GL_SYNC_CONDITION 0x9113 -#define GL_SYNC_STATUS 0x9114 -#define GL_SYNC_FLAGS 0x9115 -#define GL_SYNC_FENCE 0x9116 -#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 -#define GL_UNSIGNALED 0x9118 -#define GL_SIGNALED 0x9119 -#define GL_ALREADY_SIGNALED 0x911A -#define GL_TIMEOUT_EXPIRED 0x911B -#define GL_CONDITION_SATISFIED 0x911C -#define GL_WAIT_FAILED 0x911D -#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull -#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 -#define GL_SAMPLE_POSITION 0x8E50 -#define GL_SAMPLE_MASK 0x8E51 -#define GL_SAMPLE_MASK_VALUE 0x8E52 -#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 -#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 -#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 -#define GL_TEXTURE_SAMPLES 0x9106 -#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 -#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 -#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A -#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B -#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D -#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E -#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F -#define GL_MAX_INTEGER_SAMPLES 0x9110 -typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); -typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); -typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); -typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); -typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); -typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); -GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); -GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); -GLAPI void APIENTRY glProvokingVertex (GLenum mode); -GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); -GLAPI GLboolean APIENTRY glIsSync (GLsync sync); -GLAPI void APIENTRY glDeleteSync (GLsync sync); -GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); -GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); -GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); -GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); -GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); -GLAPI void APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask); -#endif -#endif /* GL_VERSION_3_2 */ - -#ifndef GL_VERSION_3_3 -#define GL_VERSION_3_3 1 -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE -#define GL_SRC1_COLOR 0x88F9 -#define GL_ONE_MINUS_SRC1_COLOR 0x88FA -#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB -#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC -#define GL_ANY_SAMPLES_PASSED 0x8C2F -#define GL_SAMPLER_BINDING 0x8919 -#define GL_RGB10_A2UI 0x906F -#define GL_TEXTURE_SWIZZLE_R 0x8E42 -#define GL_TEXTURE_SWIZZLE_G 0x8E43 -#define GL_TEXTURE_SWIZZLE_B 0x8E44 -#define GL_TEXTURE_SWIZZLE_A 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 -#define GL_TIME_ELAPSED 0x88BF -#define GL_TIMESTAMP 0x8E28 -#define GL_INT_2_10_10_10_REV 0x8D9F -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); -typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); -typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); -typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); -GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); -GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); -GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); -GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); -GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); -GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); -GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); -GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); -GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); -GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); -GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); -GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); -GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); -GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); -GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); -GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); -GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); -#endif -#endif /* GL_VERSION_3_3 */ - -#ifndef GL_VERSION_4_0 -#define GL_VERSION_4_0 1 -#define GL_SAMPLE_SHADING 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F -#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B -#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F -#define GL_DRAW_INDIRECT_BUFFER 0x8F3F -#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 -#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F -#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C -#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D -#define GL_MAX_VERTEX_STREAMS 0x8E71 -#define GL_DOUBLE_VEC2 0x8FFC -#define GL_DOUBLE_VEC3 0x8FFD -#define GL_DOUBLE_VEC4 0x8FFE -#define GL_DOUBLE_MAT2 0x8F46 -#define GL_DOUBLE_MAT3 0x8F47 -#define GL_DOUBLE_MAT4 0x8F48 -#define GL_DOUBLE_MAT2x3 0x8F49 -#define GL_DOUBLE_MAT2x4 0x8F4A -#define GL_DOUBLE_MAT3x2 0x8F4B -#define GL_DOUBLE_MAT3x4 0x8F4C -#define GL_DOUBLE_MAT4x2 0x8F4D -#define GL_DOUBLE_MAT4x3 0x8F4E -#define GL_ACTIVE_SUBROUTINES 0x8DE5 -#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 -#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 -#define GL_MAX_SUBROUTINES 0x8DE7 -#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 -#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A -#define GL_COMPATIBLE_SUBROUTINES 0x8E4B -#define GL_PATCHES 0x000E -#define GL_PATCH_VERTICES 0x8E72 -#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 -#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 -#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 -#define GL_TESS_GEN_MODE 0x8E76 -#define GL_TESS_GEN_SPACING 0x8E77 -#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 -#define GL_TESS_GEN_POINT_MODE 0x8E79 -#define GL_ISOLINES 0x8E7A -#define GL_FRACTIONAL_ODD 0x8E7B -#define GL_FRACTIONAL_EVEN 0x8E7C -#define GL_MAX_PATCH_VERTICES 0x8E7D -#define GL_MAX_TESS_GEN_LEVEL 0x8E7E -#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F -#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 -#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 -#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 -#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 -#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 -#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 -#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 -#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 -#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A -#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C -#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D -#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E -#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 -#define GL_TESS_EVALUATION_SHADER 0x8E87 -#define GL_TESS_CONTROL_SHADER 0x8E88 -#define GL_TRANSFORM_FEEDBACK 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 -#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 -typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); -typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); -typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); -typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); -typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); -typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); -typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); -typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMinSampleShading (GLfloat value); -GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect); -GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect); -GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); -GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); -GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); -GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); -GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); -GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); -GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); -GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); -GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); -GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); -GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); -GLAPI void APIENTRY glPauseTransformFeedback (void); -GLAPI void APIENTRY glResumeTransformFeedback (void); -GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); -GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); -GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); -GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); -GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); -#endif -#endif /* GL_VERSION_4_0 */ - -#ifndef GL_VERSION_4_1 -#define GL_VERSION_4_1 1 -#define GL_FIXED 0x140C -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B -#define GL_LOW_FLOAT 0x8DF0 -#define GL_MEDIUM_FLOAT 0x8DF1 -#define GL_HIGH_FLOAT 0x8DF2 -#define GL_LOW_INT 0x8DF3 -#define GL_MEDIUM_INT 0x8DF4 -#define GL_HIGH_INT 0x8DF5 -#define GL_SHADER_COMPILER 0x8DFA -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#define GL_RGB565 0x8D62 -#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 -#define GL_PROGRAM_BINARY_LENGTH 0x8741 -#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE -#define GL_PROGRAM_BINARY_FORMATS 0x87FF -#define GL_VERTEX_SHADER_BIT 0x00000001 -#define GL_FRAGMENT_SHADER_BIT 0x00000002 -#define GL_GEOMETRY_SHADER_BIT 0x00000004 -#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 -#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 -#define GL_ALL_SHADER_BITS 0xFFFFFFFF -#define GL_PROGRAM_SEPARABLE 0x8258 -#define GL_ACTIVE_PROGRAM 0x8259 -#define GL_PROGRAM_PIPELINE_BINDING 0x825A -#define GL_MAX_VIEWPORTS 0x825B -#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C -#define GL_VIEWPORT_BOUNDS_RANGE 0x825D -#define GL_LAYER_PROVOKING_VERTEX 0x825E -#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F -#define GL_UNDEFINED_VERTEX 0x8260 -typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); -typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); -typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); -typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); -typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); -typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); -typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); -typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); -typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); -typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); -typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); -typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReleaseShaderCompiler (void); -GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); -GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); -GLAPI void APIENTRY glClearDepthf (GLfloat d); -GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); -GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); -GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); -GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); -GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); -GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); -GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); -GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); -GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); -GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); -GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); -GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); -GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); -GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); -GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); -GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); -GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); -GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); -GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); -#endif -#endif /* GL_VERSION_4_1 */ - -#ifndef GL_VERSION_4_2 -#define GL_VERSION_4_2 1 -#define GL_COPY_READ_BUFFER_BINDING 0x8F36 -#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 -#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 -#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 -#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 -#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 -#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 -#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A -#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B -#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C -#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D -#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E -#define GL_NUM_SAMPLE_COUNTS 0x9380 -#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC -#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 -#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 -#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 -#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 -#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB -#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE -#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF -#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 -#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 -#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 -#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 -#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 -#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC -#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 -#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA -#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB -#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 -#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 -#define GL_UNIFORM_BARRIER_BIT 0x00000004 -#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 -#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 -#define GL_COMMAND_BARRIER_BIT 0x00000040 -#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 -#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 -#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 -#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 -#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 -#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 -#define GL_ALL_BARRIER_BITS 0xFFFFFFFF -#define GL_MAX_IMAGE_UNITS 0x8F38 -#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 -#define GL_IMAGE_BINDING_NAME 0x8F3A -#define GL_IMAGE_BINDING_LEVEL 0x8F3B -#define GL_IMAGE_BINDING_LAYERED 0x8F3C -#define GL_IMAGE_BINDING_LAYER 0x8F3D -#define GL_IMAGE_BINDING_ACCESS 0x8F3E -#define GL_IMAGE_1D 0x904C -#define GL_IMAGE_2D 0x904D -#define GL_IMAGE_3D 0x904E -#define GL_IMAGE_2D_RECT 0x904F -#define GL_IMAGE_CUBE 0x9050 -#define GL_IMAGE_BUFFER 0x9051 -#define GL_IMAGE_1D_ARRAY 0x9052 -#define GL_IMAGE_2D_ARRAY 0x9053 -#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 -#define GL_IMAGE_2D_MULTISAMPLE 0x9055 -#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 -#define GL_INT_IMAGE_1D 0x9057 -#define GL_INT_IMAGE_2D 0x9058 -#define GL_INT_IMAGE_3D 0x9059 -#define GL_INT_IMAGE_2D_RECT 0x905A -#define GL_INT_IMAGE_CUBE 0x905B -#define GL_INT_IMAGE_BUFFER 0x905C -#define GL_INT_IMAGE_1D_ARRAY 0x905D -#define GL_INT_IMAGE_2D_ARRAY 0x905E -#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F -#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 -#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 -#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 -#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 -#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 -#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 -#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 -#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C -#define GL_MAX_IMAGE_SAMPLES 0x906D -#define GL_IMAGE_BINDING_FORMAT 0x906E -#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 -#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA -#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB -#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC -#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD -#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE -#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF -#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C -#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D -#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E -#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F -#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); -typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); -typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); -GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); -GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); -GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); -#endif -#endif /* GL_VERSION_4_2 */ - -#ifndef GL_VERSION_4_3 -#define GL_VERSION_4_3 1 -typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 -#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E -#define GL_COMPRESSED_RGB8_ETC2 0x9274 -#define GL_COMPRESSED_SRGB8_ETC2 0x9275 -#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 -#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 -#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 -#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 -#define GL_COMPRESSED_R11_EAC 0x9270 -#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 -#define GL_COMPRESSED_RG11_EAC 0x9272 -#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 -#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 -#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A -#define GL_MAX_ELEMENT_INDEX 0x8D6B -#define GL_COMPUTE_SHADER 0x91B9 -#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB -#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC -#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD -#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 -#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 -#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 -#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 -#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 -#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB -#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE -#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF -#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED -#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE -#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF -#define GL_COMPUTE_SHADER_BIT 0x00000020 -#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 -#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 -#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 -#define GL_DEBUG_SOURCE_API 0x8246 -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 -#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 -#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 -#define GL_DEBUG_SOURCE_APPLICATION 0x824A -#define GL_DEBUG_SOURCE_OTHER 0x824B -#define GL_DEBUG_TYPE_ERROR 0x824C -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E -#define GL_DEBUG_TYPE_PORTABILITY 0x824F -#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 -#define GL_DEBUG_TYPE_OTHER 0x8251 -#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES 0x9145 -#define GL_DEBUG_SEVERITY_HIGH 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 -#define GL_DEBUG_SEVERITY_LOW 0x9148 -#define GL_DEBUG_TYPE_MARKER 0x8268 -#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 -#define GL_DEBUG_TYPE_POP_GROUP 0x826A -#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B -#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C -#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D -#define GL_BUFFER 0x82E0 -#define GL_SHADER 0x82E1 -#define GL_PROGRAM 0x82E2 -#define GL_QUERY 0x82E3 -#define GL_PROGRAM_PIPELINE 0x82E4 -#define GL_SAMPLER 0x82E6 -#define GL_MAX_LABEL_LENGTH 0x82E8 -#define GL_DEBUG_OUTPUT 0x92E0 -#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 -#define GL_MAX_UNIFORM_LOCATIONS 0x826E -#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 -#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 -#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 -#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 -#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 -#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 -#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 -#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 -#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 -#define GL_INTERNALFORMAT_SUPPORTED 0x826F -#define GL_INTERNALFORMAT_PREFERRED 0x8270 -#define GL_INTERNALFORMAT_RED_SIZE 0x8271 -#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 -#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 -#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 -#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 -#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 -#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 -#define GL_INTERNALFORMAT_RED_TYPE 0x8278 -#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 -#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A -#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B -#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C -#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D -#define GL_MAX_WIDTH 0x827E -#define GL_MAX_HEIGHT 0x827F -#define GL_MAX_DEPTH 0x8280 -#define GL_MAX_LAYERS 0x8281 -#define GL_MAX_COMBINED_DIMENSIONS 0x8282 -#define GL_COLOR_COMPONENTS 0x8283 -#define GL_DEPTH_COMPONENTS 0x8284 -#define GL_STENCIL_COMPONENTS 0x8285 -#define GL_COLOR_RENDERABLE 0x8286 -#define GL_DEPTH_RENDERABLE 0x8287 -#define GL_STENCIL_RENDERABLE 0x8288 -#define GL_FRAMEBUFFER_RENDERABLE 0x8289 -#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A -#define GL_FRAMEBUFFER_BLEND 0x828B -#define GL_READ_PIXELS 0x828C -#define GL_READ_PIXELS_FORMAT 0x828D -#define GL_READ_PIXELS_TYPE 0x828E -#define GL_TEXTURE_IMAGE_FORMAT 0x828F -#define GL_TEXTURE_IMAGE_TYPE 0x8290 -#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 -#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 -#define GL_MIPMAP 0x8293 -#define GL_MANUAL_GENERATE_MIPMAP 0x8294 -#define GL_AUTO_GENERATE_MIPMAP 0x8295 -#define GL_COLOR_ENCODING 0x8296 -#define GL_SRGB_READ 0x8297 -#define GL_SRGB_WRITE 0x8298 -#define GL_FILTER 0x829A -#define GL_VERTEX_TEXTURE 0x829B -#define GL_TESS_CONTROL_TEXTURE 0x829C -#define GL_TESS_EVALUATION_TEXTURE 0x829D -#define GL_GEOMETRY_TEXTURE 0x829E -#define GL_FRAGMENT_TEXTURE 0x829F -#define GL_COMPUTE_TEXTURE 0x82A0 -#define GL_TEXTURE_SHADOW 0x82A1 -#define GL_TEXTURE_GATHER 0x82A2 -#define GL_TEXTURE_GATHER_SHADOW 0x82A3 -#define GL_SHADER_IMAGE_LOAD 0x82A4 -#define GL_SHADER_IMAGE_STORE 0x82A5 -#define GL_SHADER_IMAGE_ATOMIC 0x82A6 -#define GL_IMAGE_TEXEL_SIZE 0x82A7 -#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 -#define GL_IMAGE_PIXEL_FORMAT 0x82A9 -#define GL_IMAGE_PIXEL_TYPE 0x82AA -#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC -#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD -#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE -#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF -#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 -#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 -#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 -#define GL_CLEAR_BUFFER 0x82B4 -#define GL_TEXTURE_VIEW 0x82B5 -#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 -#define GL_FULL_SUPPORT 0x82B7 -#define GL_CAVEAT_SUPPORT 0x82B8 -#define GL_IMAGE_CLASS_4_X_32 0x82B9 -#define GL_IMAGE_CLASS_2_X_32 0x82BA -#define GL_IMAGE_CLASS_1_X_32 0x82BB -#define GL_IMAGE_CLASS_4_X_16 0x82BC -#define GL_IMAGE_CLASS_2_X_16 0x82BD -#define GL_IMAGE_CLASS_1_X_16 0x82BE -#define GL_IMAGE_CLASS_4_X_8 0x82BF -#define GL_IMAGE_CLASS_2_X_8 0x82C0 -#define GL_IMAGE_CLASS_1_X_8 0x82C1 -#define GL_IMAGE_CLASS_11_11_10 0x82C2 -#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 -#define GL_VIEW_CLASS_128_BITS 0x82C4 -#define GL_VIEW_CLASS_96_BITS 0x82C5 -#define GL_VIEW_CLASS_64_BITS 0x82C6 -#define GL_VIEW_CLASS_48_BITS 0x82C7 -#define GL_VIEW_CLASS_32_BITS 0x82C8 -#define GL_VIEW_CLASS_24_BITS 0x82C9 -#define GL_VIEW_CLASS_16_BITS 0x82CA -#define GL_VIEW_CLASS_8_BITS 0x82CB -#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC -#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD -#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE -#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF -#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 -#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 -#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 -#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 -#define GL_UNIFORM 0x92E1 -#define GL_UNIFORM_BLOCK 0x92E2 -#define GL_PROGRAM_INPUT 0x92E3 -#define GL_PROGRAM_OUTPUT 0x92E4 -#define GL_BUFFER_VARIABLE 0x92E5 -#define GL_SHADER_STORAGE_BLOCK 0x92E6 -#define GL_VERTEX_SUBROUTINE 0x92E8 -#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 -#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA -#define GL_GEOMETRY_SUBROUTINE 0x92EB -#define GL_FRAGMENT_SUBROUTINE 0x92EC -#define GL_COMPUTE_SUBROUTINE 0x92ED -#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE -#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF -#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 -#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 -#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 -#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 -#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 -#define GL_ACTIVE_RESOURCES 0x92F5 -#define GL_MAX_NAME_LENGTH 0x92F6 -#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 -#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 -#define GL_NAME_LENGTH 0x92F9 -#define GL_TYPE 0x92FA -#define GL_ARRAY_SIZE 0x92FB -#define GL_OFFSET 0x92FC -#define GL_BLOCK_INDEX 0x92FD -#define GL_ARRAY_STRIDE 0x92FE -#define GL_MATRIX_STRIDE 0x92FF -#define GL_IS_ROW_MAJOR 0x9300 -#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 -#define GL_BUFFER_BINDING 0x9302 -#define GL_BUFFER_DATA_SIZE 0x9303 -#define GL_NUM_ACTIVE_VARIABLES 0x9304 -#define GL_ACTIVE_VARIABLES 0x9305 -#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 -#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 -#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 -#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 -#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A -#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B -#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C -#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D -#define GL_LOCATION 0x930E -#define GL_LOCATION_INDEX 0x930F -#define GL_IS_PER_PATCH 0x92E7 -#define GL_SHADER_STORAGE_BUFFER 0x90D2 -#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 -#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 -#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 -#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 -#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 -#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 -#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 -#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA -#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB -#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC -#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD -#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE -#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF -#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 -#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 -#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA -#define GL_TEXTURE_BUFFER_OFFSET 0x919D -#define GL_TEXTURE_BUFFER_SIZE 0x919E -#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F -#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB -#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC -#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD -#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE -#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF -#define GL_VERTEX_ATTRIB_BINDING 0x82D4 -#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 -#define GL_VERTEX_BINDING_DIVISOR 0x82D6 -#define GL_VERTEX_BINDING_OFFSET 0x82D7 -#define GL_VERTEX_BINDING_STRIDE 0x82D8 -#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 -#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA -#define GL_VERTEX_BINDING_BUFFER 0x8F4F -#define GL_DISPLAY_LIST 0x82E7 -typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); -typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); -typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); -typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); -typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); -typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); -typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); -typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); -typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); -typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); -typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); -typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); -typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); -typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); -typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); -typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); -typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); -typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); -typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); -typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); -GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); -GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); -GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); -GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); -GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); -GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); -GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); -GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); -GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); -GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); -GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); -GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); -GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); -GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); -GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); -GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); -GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); -GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); -GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); -GLAPI void APIENTRY glPopDebugGroup (void); -GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); -GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); -GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); -GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); -#endif -#endif /* GL_VERSION_4_3 */ - -#ifndef GL_VERSION_4_4 -#define GL_VERSION_4_4 1 -#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 -#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 -#define GL_TEXTURE_BUFFER_BINDING 0x8C2A -#define GL_MAP_PERSISTENT_BIT 0x0040 -#define GL_MAP_COHERENT_BIT 0x0080 -#define GL_DYNAMIC_STORAGE_BIT 0x0100 -#define GL_CLIENT_STORAGE_BIT 0x0200 -#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 -#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F -#define GL_BUFFER_STORAGE_FLAGS 0x8220 -#define GL_CLEAR_TEXTURE 0x9365 -#define GL_LOCATION_COMPONENT 0x934A -#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B -#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C -#define GL_QUERY_BUFFER 0x9192 -#define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 -#define GL_QUERY_BUFFER_BINDING 0x9193 -#define GL_QUERY_RESULT_NO_WAIT 0x9194 -#define GL_MIRROR_CLAMP_TO_EDGE 0x8743 -typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); -typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); -typedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); -typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); -typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers); -typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); -typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferStorage (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); -GLAPI void APIENTRY glClearTexImage (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glClearTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glBindBuffersBase (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); -GLAPI void APIENTRY glBindBuffersRange (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); -GLAPI void APIENTRY glBindTextures (GLuint first, GLsizei count, const GLuint *textures); -GLAPI void APIENTRY glBindSamplers (GLuint first, GLsizei count, const GLuint *samplers); -GLAPI void APIENTRY glBindImageTextures (GLuint first, GLsizei count, const GLuint *textures); -GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); -#endif -#endif /* GL_VERSION_4_4 */ - -#ifndef GL_VERSION_4_5 -#define GL_VERSION_4_5 1 -#define GL_CONTEXT_LOST 0x0507 -#define GL_NEGATIVE_ONE_TO_ONE 0x935E -#define GL_ZERO_TO_ONE 0x935F -#define GL_CLIP_ORIGIN 0x935C -#define GL_CLIP_DEPTH_MODE 0x935D -#define GL_QUERY_WAIT_INVERTED 0x8E17 -#define GL_QUERY_NO_WAIT_INVERTED 0x8E18 -#define GL_QUERY_BY_REGION_WAIT_INVERTED 0x8E19 -#define GL_QUERY_BY_REGION_NO_WAIT_INVERTED 0x8E1A -#define GL_MAX_CULL_DISTANCES 0x82F9 -#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA -#define GL_TEXTURE_TARGET 0x1006 -#define GL_QUERY_TARGET 0x82EA -#define GL_GUILTY_CONTEXT_RESET 0x8253 -#define GL_INNOCENT_CONTEXT_RESET 0x8254 -#define GL_UNKNOWN_CONTEXT_RESET 0x8255 -#define GL_RESET_NOTIFICATION_STRATEGY 0x8256 -#define GL_LOSE_CONTEXT_ON_RESET 0x8252 -#define GL_NO_RESET_NOTIFICATION 0x8261 -#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004 -#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB -#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC -typedef void (APIENTRYP PFNGLCLIPCONTROLPROC) (GLenum origin, GLenum depth); -typedef void (APIENTRYP PFNGLCREATETRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC) (GLuint xfb, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC) (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKIVPROC) (GLuint xfb, GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint *param); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); -typedef void (APIENTRYP PFNGLCREATEBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); -typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); -typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); -typedef void (APIENTRYP PFNGLCOPYNAMEDBUFFERSUBDATAPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); -typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERPROC) (GLuint buffer, GLenum access); -typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFERPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERI64VPROC) (GLuint buffer, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVPROC) (GLuint buffer, GLenum pname, void **params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); -typedef void (APIENTRYP PFNGLCREATEFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC) (GLuint framebuffer, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC) (GLuint framebuffer, GLenum buf); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC) (GLuint framebuffer, GLenum src); -typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); -typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); -typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); -typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); -typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, const GLfloat depth, GLint stencil); -typedef void (APIENTRYP PFNGLBLITNAMEDFRAMEBUFFERPROC) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) (GLuint framebuffer, GLenum target); -typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) (GLuint framebuffer, GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCREATERENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC) (GLuint renderbuffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCREATETEXTURESPROC) (GLenum target, GLsizei n, GLuint *textures); -typedef void (APIENTRYP PFNGLTEXTUREBUFFERPROC) (GLuint texture, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEPROC) (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFPROC) (GLuint texture, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIPROC) (GLuint texture, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLBINDTEXTUREUNITPROC) (GLuint unit, GLuint texture); -typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLsizei bufSize, void *pixels); -typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVPROC) (GLuint texture, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVPROC) (GLuint texture, GLint level, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCREATEVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); -typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); -typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); -typedef void (APIENTRYP PFNGLVERTEXARRAYELEMENTBUFFERPROC) (GLuint vaobj, GLuint buffer); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERSPROC) (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); -typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBBINDINGPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); -typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBIFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBLFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXARRAYBINDINGDIVISORPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); -typedef void (APIENTRYP PFNGLGETVERTEXARRAYIVPROC) (GLuint vaobj, GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXEDIVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXED64IVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); -typedef void (APIENTRYP PFNGLCREATESAMPLERSPROC) (GLsizei n, GLuint *samplers); -typedef void (APIENTRYP PFNGLCREATEPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); -typedef void (APIENTRYP PFNGLCREATEQUERIESPROC) (GLenum target, GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); -typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); -typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); -typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); -typedef void (APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers); -typedef void (APIENTRYP PFNGLGETTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); -typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC) (void); -typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLsizei bufSize, void *pixels); -typedef void (APIENTRYP PFNGLGETNTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); -typedef void (APIENTRYP PFNGLGETNUNIFORMDVPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMFVPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMUIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -typedef void (APIENTRYP PFNGLREADNPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); -typedef void (APIENTRYP PFNGLGETNMAPDVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -typedef void (APIENTRYP PFNGLGETNMAPFVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -typedef void (APIENTRYP PFNGLGETNMAPIVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -typedef void (APIENTRYP PFNGLGETNPIXELMAPFVPROC) (GLenum map, GLsizei bufSize, GLfloat *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVPROC) (GLenum map, GLsizei bufSize, GLuint *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVPROC) (GLenum map, GLsizei bufSize, GLushort *values); -typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEPROC) (GLsizei bufSize, GLubyte *pattern); -typedef void (APIENTRYP PFNGLGETNCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); -typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); -typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); -typedef void (APIENTRYP PFNGLGETNHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); -typedef void (APIENTRYP PFNGLGETNMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); -typedef void (APIENTRYP PFNGLTEXTUREBARRIERPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClipControl (GLenum origin, GLenum depth); -GLAPI void APIENTRY glCreateTransformFeedbacks (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glTransformFeedbackBufferBase (GLuint xfb, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackBufferRange (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glGetTransformFeedbackiv (GLuint xfb, GLenum pname, GLint *param); -GLAPI void APIENTRY glGetTransformFeedbacki_v (GLuint xfb, GLenum pname, GLuint index, GLint *param); -GLAPI void APIENTRY glGetTransformFeedbacki64_v (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); -GLAPI void APIENTRY glCreateBuffers (GLsizei n, GLuint *buffers); -GLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); -GLAPI void APIENTRY glNamedBufferData (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); -GLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); -GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -GLAPI void APIENTRY glClearNamedBufferData (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); -GLAPI void *APIENTRY glMapNamedBuffer (GLuint buffer, GLenum access); -GLAPI void *APIENTRY glMapNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -GLAPI GLboolean APIENTRY glUnmapNamedBuffer (GLuint buffer); -GLAPI void APIENTRY glFlushMappedNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length); -GLAPI void APIENTRY glGetNamedBufferParameteriv (GLuint buffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetNamedBufferParameteri64v (GLuint buffer, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetNamedBufferPointerv (GLuint buffer, GLenum pname, void **params); -GLAPI void APIENTRY glGetNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); -GLAPI void APIENTRY glCreateFramebuffers (GLsizei n, GLuint *framebuffers); -GLAPI void APIENTRY glNamedFramebufferRenderbuffer (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glNamedFramebufferParameteri (GLuint framebuffer, GLenum pname, GLint param); -GLAPI void APIENTRY glNamedFramebufferTexture (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTextureLayer (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glNamedFramebufferDrawBuffer (GLuint framebuffer, GLenum buf); -GLAPI void APIENTRY glNamedFramebufferDrawBuffers (GLuint framebuffer, GLsizei n, const GLenum *bufs); -GLAPI void APIENTRY glNamedFramebufferReadBuffer (GLuint framebuffer, GLenum src); -GLAPI void APIENTRY glInvalidateNamedFramebufferData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); -GLAPI void APIENTRY glInvalidateNamedFramebufferSubData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glClearNamedFramebufferiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); -GLAPI void APIENTRY glClearNamedFramebufferuiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); -GLAPI void APIENTRY glClearNamedFramebufferfv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); -GLAPI void APIENTRY glClearNamedFramebufferfi (GLuint framebuffer, GLenum buffer, const GLfloat depth, GLint stencil); -GLAPI void APIENTRY glBlitNamedFramebuffer (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -GLAPI GLenum APIENTRY glCheckNamedFramebufferStatus (GLuint framebuffer, GLenum target); -GLAPI void APIENTRY glGetNamedFramebufferParameteriv (GLuint framebuffer, GLenum pname, GLint *param); -GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameteriv (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glCreateRenderbuffers (GLsizei n, GLuint *renderbuffers); -GLAPI void APIENTRY glNamedRenderbufferStorage (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisample (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetNamedRenderbufferParameteriv (GLuint renderbuffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glCreateTextures (GLenum target, GLsizei n, GLuint *textures); -GLAPI void APIENTRY glTextureBuffer (GLuint texture, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glTextureBufferRange (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glTextureStorage1D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTextureStorage2D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTextureStorage3D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -GLAPI void APIENTRY glTextureStorage2DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTextureStorage3DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glCompressedTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCopyTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glCopyTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTextureParameterf (GLuint texture, GLenum pname, GLfloat param); -GLAPI void APIENTRY glTextureParameterfv (GLuint texture, GLenum pname, const GLfloat *param); -GLAPI void APIENTRY glTextureParameteri (GLuint texture, GLenum pname, GLint param); -GLAPI void APIENTRY glTextureParameterIiv (GLuint texture, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTextureParameterIuiv (GLuint texture, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glTextureParameteriv (GLuint texture, GLenum pname, const GLint *param); -GLAPI void APIENTRY glGenerateTextureMipmap (GLuint texture); -GLAPI void APIENTRY glBindTextureUnit (GLuint unit, GLuint texture); -GLAPI void APIENTRY glGetTextureImage (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); -GLAPI void APIENTRY glGetCompressedTextureImage (GLuint texture, GLint level, GLsizei bufSize, void *pixels); -GLAPI void APIENTRY glGetTextureLevelParameterfv (GLuint texture, GLint level, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTextureLevelParameteriv (GLuint texture, GLint level, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTextureParameterfv (GLuint texture, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTextureParameterIiv (GLuint texture, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTextureParameterIuiv (GLuint texture, GLenum pname, GLuint *params); -GLAPI void APIENTRY glGetTextureParameteriv (GLuint texture, GLenum pname, GLint *params); -GLAPI void APIENTRY glCreateVertexArrays (GLsizei n, GLuint *arrays); -GLAPI void APIENTRY glDisableVertexArrayAttrib (GLuint vaobj, GLuint index); -GLAPI void APIENTRY glEnableVertexArrayAttrib (GLuint vaobj, GLuint index); -GLAPI void APIENTRY glVertexArrayElementBuffer (GLuint vaobj, GLuint buffer); -GLAPI void APIENTRY glVertexArrayVertexBuffer (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -GLAPI void APIENTRY glVertexArrayVertexBuffers (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); -GLAPI void APIENTRY glVertexArrayAttribBinding (GLuint vaobj, GLuint attribindex, GLuint bindingindex); -GLAPI void APIENTRY glVertexArrayAttribFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -GLAPI void APIENTRY glVertexArrayAttribIFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -GLAPI void APIENTRY glVertexArrayAttribLFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -GLAPI void APIENTRY glVertexArrayBindingDivisor (GLuint vaobj, GLuint bindingindex, GLuint divisor); -GLAPI void APIENTRY glGetVertexArrayiv (GLuint vaobj, GLenum pname, GLint *param); -GLAPI void APIENTRY glGetVertexArrayIndexediv (GLuint vaobj, GLuint index, GLenum pname, GLint *param); -GLAPI void APIENTRY glGetVertexArrayIndexed64iv (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); -GLAPI void APIENTRY glCreateSamplers (GLsizei n, GLuint *samplers); -GLAPI void APIENTRY glCreateProgramPipelines (GLsizei n, GLuint *pipelines); -GLAPI void APIENTRY glCreateQueries (GLenum target, GLsizei n, GLuint *ids); -GLAPI void APIENTRY glGetQueryBufferObjecti64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); -GLAPI void APIENTRY glGetQueryBufferObjectiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); -GLAPI void APIENTRY glGetQueryBufferObjectui64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); -GLAPI void APIENTRY glGetQueryBufferObjectuiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); -GLAPI void APIENTRY glMemoryBarrierByRegion (GLbitfield barriers); -GLAPI void APIENTRY glGetTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); -GLAPI void APIENTRY glGetCompressedTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); -GLAPI GLenum APIENTRY glGetGraphicsResetStatus (void); -GLAPI void APIENTRY glGetnCompressedTexImage (GLenum target, GLint lod, GLsizei bufSize, void *pixels); -GLAPI void APIENTRY glGetnTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); -GLAPI void APIENTRY glGetnUniformdv (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -GLAPI void APIENTRY glGetnUniformfv (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -GLAPI void APIENTRY glGetnUniformiv (GLuint program, GLint location, GLsizei bufSize, GLint *params); -GLAPI void APIENTRY glGetnUniformuiv (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -GLAPI void APIENTRY glReadnPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); -GLAPI void APIENTRY glGetnMapdv (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -GLAPI void APIENTRY glGetnMapfv (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -GLAPI void APIENTRY glGetnMapiv (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -GLAPI void APIENTRY glGetnPixelMapfv (GLenum map, GLsizei bufSize, GLfloat *values); -GLAPI void APIENTRY glGetnPixelMapuiv (GLenum map, GLsizei bufSize, GLuint *values); -GLAPI void APIENTRY glGetnPixelMapusv (GLenum map, GLsizei bufSize, GLushort *values); -GLAPI void APIENTRY glGetnPolygonStipple (GLsizei bufSize, GLubyte *pattern); -GLAPI void APIENTRY glGetnColorTable (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); -GLAPI void APIENTRY glGetnConvolutionFilter (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); -GLAPI void APIENTRY glGetnSeparableFilter (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); -GLAPI void APIENTRY glGetnHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); -GLAPI void APIENTRY glGetnMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); -GLAPI void APIENTRY glTextureBarrier (void); -#endif -#endif /* GL_VERSION_4_5 */ - -#ifndef GL_ARB_ES2_compatibility -#define GL_ARB_ES2_compatibility 1 -#endif /* GL_ARB_ES2_compatibility */ - -#ifndef GL_ARB_ES3_1_compatibility -#define GL_ARB_ES3_1_compatibility 1 -#endif /* GL_ARB_ES3_1_compatibility */ - -#ifndef GL_ARB_ES3_2_compatibility -#define GL_ARB_ES3_2_compatibility 1 -#define GL_PRIMITIVE_BOUNDING_BOX_ARB 0x92BE -#define GL_MULTISAMPLE_LINE_WIDTH_RANGE_ARB 0x9381 -#define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY_ARB 0x9382 -typedef void (APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXARBPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPrimitiveBoundingBoxARB (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); -#endif -#endif /* GL_ARB_ES3_2_compatibility */ - -#ifndef GL_ARB_ES3_compatibility -#define GL_ARB_ES3_compatibility 1 -#endif /* GL_ARB_ES3_compatibility */ - -#ifndef GL_ARB_arrays_of_arrays -#define GL_ARB_arrays_of_arrays 1 -#endif /* GL_ARB_arrays_of_arrays */ - -#ifndef GL_ARB_base_instance -#define GL_ARB_base_instance 1 -#endif /* GL_ARB_base_instance */ - -#ifndef GL_ARB_bindless_texture -#define GL_ARB_bindless_texture 1 -typedef uint64_t GLuint64EXT; -#define GL_UNSIGNED_INT64_ARB 0x140F -typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture); -typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler); -typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle); -typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access); -typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value); -typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); -typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint64 APIENTRY glGetTextureHandleARB (GLuint texture); -GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleARB (GLuint texture, GLuint sampler); -GLAPI void APIENTRY glMakeTextureHandleResidentARB (GLuint64 handle); -GLAPI void APIENTRY glMakeTextureHandleNonResidentARB (GLuint64 handle); -GLAPI GLuint64 APIENTRY glGetImageHandleARB (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -GLAPI void APIENTRY glMakeImageHandleResidentARB (GLuint64 handle, GLenum access); -GLAPI void APIENTRY glMakeImageHandleNonResidentARB (GLuint64 handle); -GLAPI void APIENTRY glUniformHandleui64ARB (GLint location, GLuint64 value); -GLAPI void APIENTRY glUniformHandleui64vARB (GLint location, GLsizei count, const GLuint64 *value); -GLAPI void APIENTRY glProgramUniformHandleui64ARB (GLuint program, GLint location, GLuint64 value); -GLAPI void APIENTRY glProgramUniformHandleui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *values); -GLAPI GLboolean APIENTRY glIsTextureHandleResidentARB (GLuint64 handle); -GLAPI GLboolean APIENTRY glIsImageHandleResidentARB (GLuint64 handle); -GLAPI void APIENTRY glVertexAttribL1ui64ARB (GLuint index, GLuint64EXT x); -GLAPI void APIENTRY glVertexAttribL1ui64vARB (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glGetVertexAttribLui64vARB (GLuint index, GLenum pname, GLuint64EXT *params); -#endif -#endif /* GL_ARB_bindless_texture */ - -#ifndef GL_ARB_blend_func_extended -#define GL_ARB_blend_func_extended 1 -#endif /* GL_ARB_blend_func_extended */ - -#ifndef GL_ARB_buffer_storage -#define GL_ARB_buffer_storage 1 -#endif /* GL_ARB_buffer_storage */ - -#ifndef GL_ARB_cl_event -#define GL_ARB_cl_event 1 -struct _cl_context; -struct _cl_event; -#define GL_SYNC_CL_EVENT_ARB 0x8240 -#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 -typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); -#endif -#endif /* GL_ARB_cl_event */ - -#ifndef GL_ARB_clear_buffer_object -#define GL_ARB_clear_buffer_object 1 -#endif /* GL_ARB_clear_buffer_object */ - -#ifndef GL_ARB_clear_texture -#define GL_ARB_clear_texture 1 -#endif /* GL_ARB_clear_texture */ - -#ifndef GL_ARB_clip_control -#define GL_ARB_clip_control 1 -#endif /* GL_ARB_clip_control */ - -#ifndef GL_ARB_color_buffer_float -#define GL_ARB_color_buffer_float 1 -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D -typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); -#endif -#endif /* GL_ARB_color_buffer_float */ - -#ifndef GL_ARB_compatibility -#define GL_ARB_compatibility 1 -#endif /* GL_ARB_compatibility */ - -#ifndef GL_ARB_compressed_texture_pixel_storage -#define GL_ARB_compressed_texture_pixel_storage 1 -#endif /* GL_ARB_compressed_texture_pixel_storage */ - -#ifndef GL_ARB_compute_shader -#define GL_ARB_compute_shader 1 -#endif /* GL_ARB_compute_shader */ - -#ifndef GL_ARB_compute_variable_group_size -#define GL_ARB_compute_variable_group_size 1 -#define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344 -#define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB -#define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345 -#define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF -typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDispatchComputeGroupSizeARB (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); -#endif -#endif /* GL_ARB_compute_variable_group_size */ - -#ifndef GL_ARB_conditional_render_inverted -#define GL_ARB_conditional_render_inverted 1 -#endif /* GL_ARB_conditional_render_inverted */ - -#ifndef GL_ARB_conservative_depth -#define GL_ARB_conservative_depth 1 -#endif /* GL_ARB_conservative_depth */ - -#ifndef GL_ARB_copy_buffer -#define GL_ARB_copy_buffer 1 -#endif /* GL_ARB_copy_buffer */ - -#ifndef GL_ARB_copy_image -#define GL_ARB_copy_image 1 -#endif /* GL_ARB_copy_image */ - -#ifndef GL_ARB_cull_distance -#define GL_ARB_cull_distance 1 -#endif /* GL_ARB_cull_distance */ - -#ifndef GL_ARB_debug_output -#define GL_ARB_debug_output 1 -typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 -#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 -#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 -#define GL_DEBUG_SOURCE_API_ARB 0x8246 -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 -#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 -#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 -#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A -#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B -#define GL_DEBUG_TYPE_ERROR_ARB 0x824C -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E -#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F -#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 -#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 -#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 -#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 -typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const void *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#endif -#endif /* GL_ARB_debug_output */ - -#ifndef GL_ARB_depth_buffer_float -#define GL_ARB_depth_buffer_float 1 -#endif /* GL_ARB_depth_buffer_float */ - -#ifndef GL_ARB_depth_clamp -#define GL_ARB_depth_clamp 1 -#endif /* GL_ARB_depth_clamp */ - -#ifndef GL_ARB_depth_texture -#define GL_ARB_depth_texture 1 -#define GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B -#endif /* GL_ARB_depth_texture */ - -#ifndef GL_ARB_derivative_control -#define GL_ARB_derivative_control 1 -#endif /* GL_ARB_derivative_control */ - -#ifndef GL_ARB_direct_state_access -#define GL_ARB_direct_state_access 1 -#endif /* GL_ARB_direct_state_access */ - -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers 1 -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 -typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); -#endif -#endif /* GL_ARB_draw_buffers */ - -#ifndef GL_ARB_draw_buffers_blend -#define GL_ARB_draw_buffers_blend 1 -typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif -#endif /* GL_ARB_draw_buffers_blend */ - -#ifndef GL_ARB_draw_elements_base_vertex -#define GL_ARB_draw_elements_base_vertex 1 -#endif /* GL_ARB_draw_elements_base_vertex */ - -#ifndef GL_ARB_draw_indirect -#define GL_ARB_draw_indirect 1 -#endif /* GL_ARB_draw_indirect */ - -#ifndef GL_ARB_draw_instanced -#define GL_ARB_draw_instanced 1 -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); -#endif -#endif /* GL_ARB_draw_instanced */ - -#ifndef GL_ARB_enhanced_layouts -#define GL_ARB_enhanced_layouts 1 -#endif /* GL_ARB_enhanced_layouts */ - -#ifndef GL_ARB_explicit_attrib_location -#define GL_ARB_explicit_attrib_location 1 -#endif /* GL_ARB_explicit_attrib_location */ - -#ifndef GL_ARB_explicit_uniform_location -#define GL_ARB_explicit_uniform_location 1 -#endif /* GL_ARB_explicit_uniform_location */ - -#ifndef GL_ARB_fragment_coord_conventions -#define GL_ARB_fragment_coord_conventions 1 -#endif /* GL_ARB_fragment_coord_conventions */ - -#ifndef GL_ARB_fragment_layer_viewport -#define GL_ARB_fragment_layer_viewport 1 -#endif /* GL_ARB_fragment_layer_viewport */ - -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_FORMAT_ARB 0x8876 -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define GL_MATRIX0_ARB 0x88C0 -#define GL_MATRIX1_ARB 0x88C1 -#define GL_MATRIX2_ARB 0x88C2 -#define GL_MATRIX3_ARB 0x88C3 -#define GL_MATRIX4_ARB 0x88C4 -#define GL_MATRIX5_ARB 0x88C5 -#define GL_MATRIX6_ARB 0x88C6 -#define GL_MATRIX7_ARB 0x88C7 -#define GL_MATRIX8_ARB 0x88C8 -#define GL_MATRIX9_ARB 0x88C9 -#define GL_MATRIX10_ARB 0x88CA -#define GL_MATRIX11_ARB 0x88CB -#define GL_MATRIX12_ARB 0x88CC -#define GL_MATRIX13_ARB 0x88CD -#define GL_MATRIX14_ARB 0x88CE -#define GL_MATRIX15_ARB 0x88CF -#define GL_MATRIX16_ARB 0x88D0 -#define GL_MATRIX17_ARB 0x88D1 -#define GL_MATRIX18_ARB 0x88D2 -#define GL_MATRIX19_ARB 0x88D3 -#define GL_MATRIX20_ARB 0x88D4 -#define GL_MATRIX21_ARB 0x88D5 -#define GL_MATRIX22_ARB 0x88D6 -#define GL_MATRIX23_ARB 0x88D7 -#define GL_MATRIX24_ARB 0x88D8 -#define GL_MATRIX25_ARB 0x88D9 -#define GL_MATRIX26_ARB 0x88DA -#define GL_MATRIX27_ARB 0x88DB -#define GL_MATRIX28_ARB 0x88DC -#define GL_MATRIX29_ARB 0x88DD -#define GL_MATRIX30_ARB 0x88DE -#define GL_MATRIX31_ARB 0x88DF -typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void *string); -typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void *string); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const void *string); -GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); -GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); -GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, void *string); -GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); -#endif -#endif /* GL_ARB_fragment_program */ - -#ifndef GL_ARB_fragment_program_shadow -#define GL_ARB_fragment_program_shadow 1 -#endif /* GL_ARB_fragment_program_shadow */ - -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif /* GL_ARB_fragment_shader */ - -#ifndef GL_ARB_fragment_shader_interlock -#define GL_ARB_fragment_shader_interlock 1 -#endif /* GL_ARB_fragment_shader_interlock */ - -#ifndef GL_ARB_framebuffer_no_attachments -#define GL_ARB_framebuffer_no_attachments 1 -#endif /* GL_ARB_framebuffer_no_attachments */ - -#ifndef GL_ARB_framebuffer_object -#define GL_ARB_framebuffer_object 1 -#endif /* GL_ARB_framebuffer_object */ - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_ARB_framebuffer_sRGB 1 -#endif /* GL_ARB_framebuffer_sRGB */ - -#ifndef GL_ARB_geometry_shader4 -#define GL_ARB_geometry_shader4 1 -#define GL_LINES_ADJACENCY_ARB 0x000A -#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B -#define GL_TRIANGLES_ADJACENCY_ARB 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D -#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 -#define GL_GEOMETRY_SHADER_ARB 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); -GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif -#endif /* GL_ARB_geometry_shader4 */ - -#ifndef GL_ARB_get_program_binary -#define GL_ARB_get_program_binary 1 -#endif /* GL_ARB_get_program_binary */ - -#ifndef GL_ARB_get_texture_sub_image -#define GL_ARB_get_texture_sub_image 1 -#endif /* GL_ARB_get_texture_sub_image */ - -#ifndef GL_ARB_gpu_shader5 -#define GL_ARB_gpu_shader5 1 -#endif /* GL_ARB_gpu_shader5 */ - -#ifndef GL_ARB_gpu_shader_fp64 -#define GL_ARB_gpu_shader_fp64 1 -#endif /* GL_ARB_gpu_shader_fp64 */ - -#ifndef GL_ARB_gpu_shader_int64 -#define GL_ARB_gpu_shader_int64 1 -#define GL_INT64_ARB 0x140E -#define GL_INT64_VEC2_ARB 0x8FE9 -#define GL_INT64_VEC3_ARB 0x8FEA -#define GL_INT64_VEC4_ARB 0x8FEB -#define GL_UNSIGNED_INT64_VEC2_ARB 0x8FF5 -#define GL_UNSIGNED_INT64_VEC3_ARB 0x8FF6 -#define GL_UNSIGNED_INT64_VEC4_ARB 0x8FF7 -typedef void (APIENTRYP PFNGLUNIFORM1I64ARBPROC) (GLint location, GLint64 x); -typedef void (APIENTRYP PFNGLUNIFORM2I64ARBPROC) (GLint location, GLint64 x, GLint64 y); -typedef void (APIENTRYP PFNGLUNIFORM3I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z); -typedef void (APIENTRYP PFNGLUNIFORM4I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); -typedef void (APIENTRYP PFNGLUNIFORM1I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); -typedef void (APIENTRYP PFNGLUNIFORM2I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); -typedef void (APIENTRYP PFNGLUNIFORM3I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); -typedef void (APIENTRYP PFNGLUNIFORM4I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); -typedef void (APIENTRYP PFNGLUNIFORM1UI64ARBPROC) (GLint location, GLuint64 x); -typedef void (APIENTRYP PFNGLUNIFORM2UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y); -typedef void (APIENTRYP PFNGLUNIFORM3UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); -typedef void (APIENTRYP PFNGLUNIFORM4UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); -typedef void (APIENTRYP PFNGLUNIFORM1UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); -typedef void (APIENTRYP PFNGLUNIFORM2UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); -typedef void (APIENTRYP PFNGLUNIFORM3UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); -typedef void (APIENTRYP PFNGLUNIFORM4UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); -typedef void (APIENTRYP PFNGLGETUNIFORMI64VARBPROC) (GLuint program, GLint location, GLint64 *params); -typedef void (APIENTRYP PFNGLGETUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLuint64 *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64ARBPROC) (GLuint program, GLint location, GLint64 x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64ARBPROC) (GLuint program, GLint location, GLuint64 x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniform1i64ARB (GLint location, GLint64 x); -GLAPI void APIENTRY glUniform2i64ARB (GLint location, GLint64 x, GLint64 y); -GLAPI void APIENTRY glUniform3i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z); -GLAPI void APIENTRY glUniform4i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); -GLAPI void APIENTRY glUniform1i64vARB (GLint location, GLsizei count, const GLint64 *value); -GLAPI void APIENTRY glUniform2i64vARB (GLint location, GLsizei count, const GLint64 *value); -GLAPI void APIENTRY glUniform3i64vARB (GLint location, GLsizei count, const GLint64 *value); -GLAPI void APIENTRY glUniform4i64vARB (GLint location, GLsizei count, const GLint64 *value); -GLAPI void APIENTRY glUniform1ui64ARB (GLint location, GLuint64 x); -GLAPI void APIENTRY glUniform2ui64ARB (GLint location, GLuint64 x, GLuint64 y); -GLAPI void APIENTRY glUniform3ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); -GLAPI void APIENTRY glUniform4ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); -GLAPI void APIENTRY glUniform1ui64vARB (GLint location, GLsizei count, const GLuint64 *value); -GLAPI void APIENTRY glUniform2ui64vARB (GLint location, GLsizei count, const GLuint64 *value); -GLAPI void APIENTRY glUniform3ui64vARB (GLint location, GLsizei count, const GLuint64 *value); -GLAPI void APIENTRY glUniform4ui64vARB (GLint location, GLsizei count, const GLuint64 *value); -GLAPI void APIENTRY glGetUniformi64vARB (GLuint program, GLint location, GLint64 *params); -GLAPI void APIENTRY glGetUniformui64vARB (GLuint program, GLint location, GLuint64 *params); -GLAPI void APIENTRY glGetnUniformi64vARB (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); -GLAPI void APIENTRY glGetnUniformui64vARB (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); -GLAPI void APIENTRY glProgramUniform1i64ARB (GLuint program, GLint location, GLint64 x); -GLAPI void APIENTRY glProgramUniform2i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y); -GLAPI void APIENTRY glProgramUniform3i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); -GLAPI void APIENTRY glProgramUniform4i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); -GLAPI void APIENTRY glProgramUniform1i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); -GLAPI void APIENTRY glProgramUniform2i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); -GLAPI void APIENTRY glProgramUniform3i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); -GLAPI void APIENTRY glProgramUniform4i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); -GLAPI void APIENTRY glProgramUniform1ui64ARB (GLuint program, GLint location, GLuint64 x); -GLAPI void APIENTRY glProgramUniform2ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y); -GLAPI void APIENTRY glProgramUniform3ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); -GLAPI void APIENTRY glProgramUniform4ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); -GLAPI void APIENTRY glProgramUniform1ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); -GLAPI void APIENTRY glProgramUniform2ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); -GLAPI void APIENTRY glProgramUniform3ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); -GLAPI void APIENTRY glProgramUniform4ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); -#endif -#endif /* GL_ARB_gpu_shader_int64 */ - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel 1 -typedef unsigned short GLhalfARB; -#define GL_HALF_FLOAT_ARB 0x140B -#endif /* GL_ARB_half_float_pixel */ - -#ifndef GL_ARB_half_float_vertex -#define GL_ARB_half_float_vertex 1 -#endif /* GL_ARB_half_float_vertex */ - -#ifndef GL_ARB_imaging -#define GL_ARB_imaging 1 -#define GL_BLEND_COLOR 0x8005 -#define GL_BLEND_EQUATION 0x8009 -#define GL_CONVOLUTION_1D 0x8010 -#define GL_CONVOLUTION_2D 0x8011 -#define GL_SEPARABLE_2D 0x8012 -#define GL_CONVOLUTION_BORDER_MODE 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define GL_REDUCE 0x8016 -#define GL_CONVOLUTION_FORMAT 0x8017 -#define GL_CONVOLUTION_WIDTH 0x8018 -#define GL_CONVOLUTION_HEIGHT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define GL_HISTOGRAM 0x8024 -#define GL_PROXY_HISTOGRAM 0x8025 -#define GL_HISTOGRAM_WIDTH 0x8026 -#define GL_HISTOGRAM_FORMAT 0x8027 -#define GL_HISTOGRAM_RED_SIZE 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define GL_HISTOGRAM_SINK 0x802D -#define GL_MINMAX 0x802E -#define GL_MINMAX_FORMAT 0x802F -#define GL_MINMAX_SINK 0x8030 -#define GL_TABLE_TOO_LARGE 0x8031 -#define GL_COLOR_MATRIX 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define GL_COLOR_TABLE 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define GL_PROXY_COLOR_TABLE 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define GL_COLOR_TABLE_SCALE 0x80D6 -#define GL_COLOR_TABLE_BIAS 0x80D7 -#define GL_COLOR_TABLE_FORMAT 0x80D8 -#define GL_COLOR_TABLE_WIDTH 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_CONSTANT_BORDER 0x8151 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 -typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, void *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, void *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); -GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, void *table); -GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); -GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); -GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); -GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); -GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, void *image); -GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); -GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); -GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glResetHistogram (GLenum target); -GLAPI void APIENTRY glResetMinmax (GLenum target); -#endif -#endif /* GL_ARB_imaging */ - -#ifndef GL_ARB_indirect_parameters -#define GL_ARB_indirect_parameters 1 -#define GL_PARAMETER_BUFFER_ARB 0x80EE -#define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -#endif -#endif /* GL_ARB_indirect_parameters */ - -#ifndef GL_ARB_instanced_arrays -#define GL_ARB_instanced_arrays 1 -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); -#endif -#endif /* GL_ARB_instanced_arrays */ - -#ifndef GL_ARB_internalformat_query -#define GL_ARB_internalformat_query 1 -#endif /* GL_ARB_internalformat_query */ - -#ifndef GL_ARB_internalformat_query2 -#define GL_ARB_internalformat_query2 1 -#define GL_SRGB_DECODE_ARB 0x8299 -#endif /* GL_ARB_internalformat_query2 */ - -#ifndef GL_ARB_invalidate_subdata -#define GL_ARB_invalidate_subdata 1 -#endif /* GL_ARB_invalidate_subdata */ - -#ifndef GL_ARB_map_buffer_alignment -#define GL_ARB_map_buffer_alignment 1 -#endif /* GL_ARB_map_buffer_alignment */ - -#ifndef GL_ARB_map_buffer_range -#define GL_ARB_map_buffer_range 1 -#endif /* GL_ARB_map_buffer_range */ - -#ifndef GL_ARB_matrix_palette -#define GL_ARB_matrix_palette 1 -#define GL_MATRIX_PALETTE_ARB 0x8840 -#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 -#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 -#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 -#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 -#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 -#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 -#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 -#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 -#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 -typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); -GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); -GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); -GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); -GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); -#endif -#endif /* GL_ARB_matrix_palette */ - -#ifndef GL_ARB_multi_bind -#define GL_ARB_multi_bind 1 -#endif /* GL_ARB_multi_bind */ - -#ifndef GL_ARB_multi_draw_indirect -#define GL_ARB_multi_draw_indirect 1 -#endif /* GL_ARB_multi_draw_indirect */ - -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); -#endif -#endif /* GL_ARB_multisample */ - -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 -typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTextureARB (GLenum texture); -GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); -GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); -GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); -GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); -GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); -GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); -GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); -GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); -GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); -GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); -GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); -GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); -GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); -GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); -GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); -#endif -#endif /* GL_ARB_multitexture */ - -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#define GL_SAMPLES_PASSED_ARB 0x8914 -typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); -GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); -GLAPI void APIENTRY glEndQueryARB (GLenum target); -GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); -#endif -#endif /* GL_ARB_occlusion_query */ - -#ifndef GL_ARB_occlusion_query2 -#define GL_ARB_occlusion_query2 1 -#endif /* GL_ARB_occlusion_query2 */ - -#ifndef GL_ARB_parallel_shader_compile -#define GL_ARB_parallel_shader_compile 1 -#define GL_MAX_SHADER_COMPILER_THREADS_ARB 0x91B0 -#define GL_COMPLETION_STATUS_ARB 0x91B1 -typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSARBPROC) (GLuint count); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMaxShaderCompilerThreadsARB (GLuint count); -#endif -#endif /* GL_ARB_parallel_shader_compile */ - -#ifndef GL_ARB_pipeline_statistics_query -#define GL_ARB_pipeline_statistics_query 1 -#define GL_VERTICES_SUBMITTED_ARB 0x82EE -#define GL_PRIMITIVES_SUBMITTED_ARB 0x82EF -#define GL_VERTEX_SHADER_INVOCATIONS_ARB 0x82F0 -#define GL_TESS_CONTROL_SHADER_PATCHES_ARB 0x82F1 -#define GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB 0x82F2 -#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB 0x82F3 -#define GL_FRAGMENT_SHADER_INVOCATIONS_ARB 0x82F4 -#define GL_COMPUTE_SHADER_INVOCATIONS_ARB 0x82F5 -#define GL_CLIPPING_INPUT_PRIMITIVES_ARB 0x82F6 -#define GL_CLIPPING_OUTPUT_PRIMITIVES_ARB 0x82F7 -#endif /* GL_ARB_pipeline_statistics_query */ - -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -#endif /* GL_ARB_pixel_buffer_object */ - -#ifndef GL_ARB_point_parameters -#define GL_ARB_point_parameters 1 -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 -typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); -#endif -#endif /* GL_ARB_point_parameters */ - -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 -#endif /* GL_ARB_point_sprite */ - -#ifndef GL_ARB_post_depth_coverage -#define GL_ARB_post_depth_coverage 1 -#endif /* GL_ARB_post_depth_coverage */ - -#ifndef GL_ARB_program_interface_query -#define GL_ARB_program_interface_query 1 -#endif /* GL_ARB_program_interface_query */ - -#ifndef GL_ARB_provoking_vertex -#define GL_ARB_provoking_vertex 1 -#endif /* GL_ARB_provoking_vertex */ - -#ifndef GL_ARB_query_buffer_object -#define GL_ARB_query_buffer_object 1 -#endif /* GL_ARB_query_buffer_object */ - -#ifndef GL_ARB_robust_buffer_access_behavior -#define GL_ARB_robust_buffer_access_behavior 1 -#endif /* GL_ARB_robust_buffer_access_behavior */ - -#ifndef GL_ARB_robustness -#define GL_ARB_robustness 1 -#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 -#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 -#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 -#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 -typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); -typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); -typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); -typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void *img); -typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); -typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); -typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); -typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); -typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); -typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); -typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); -GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); -GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); -GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, void *img); -GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); -GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); -GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); -GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); -GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); -GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); -GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); -GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); -GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); -GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); -#endif -#endif /* GL_ARB_robustness */ - -#ifndef GL_ARB_robustness_isolation -#define GL_ARB_robustness_isolation 1 -#endif /* GL_ARB_robustness_isolation */ - -#ifndef GL_ARB_sample_locations -#define GL_ARB_sample_locations 1 -#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D -#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E -#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F -#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340 -#define GL_SAMPLE_LOCATION_ARB 0x8E50 -#define GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341 -#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342 -#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343 -typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLEVALUATEDEPTHVALUESARBPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFramebufferSampleLocationsfvARB (GLenum target, GLuint start, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvARB (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glEvaluateDepthValuesARB (void); -#endif -#endif /* GL_ARB_sample_locations */ - -#ifndef GL_ARB_sample_shading -#define GL_ARB_sample_shading 1 -#define GL_SAMPLE_SHADING_ARB 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 -typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); -#endif -#endif /* GL_ARB_sample_shading */ - -#ifndef GL_ARB_sampler_objects -#define GL_ARB_sampler_objects 1 -#endif /* GL_ARB_sampler_objects */ - -#ifndef GL_ARB_seamless_cube_map -#define GL_ARB_seamless_cube_map 1 -#endif /* GL_ARB_seamless_cube_map */ - -#ifndef GL_ARB_seamless_cubemap_per_texture -#define GL_ARB_seamless_cubemap_per_texture 1 -#endif /* GL_ARB_seamless_cubemap_per_texture */ - -#ifndef GL_ARB_separate_shader_objects -#define GL_ARB_separate_shader_objects 1 -#endif /* GL_ARB_separate_shader_objects */ - -#ifndef GL_ARB_shader_atomic_counter_ops -#define GL_ARB_shader_atomic_counter_ops 1 -#endif /* GL_ARB_shader_atomic_counter_ops */ - -#ifndef GL_ARB_shader_atomic_counters -#define GL_ARB_shader_atomic_counters 1 -#endif /* GL_ARB_shader_atomic_counters */ - -#ifndef GL_ARB_shader_ballot -#define GL_ARB_shader_ballot 1 -#endif /* GL_ARB_shader_ballot */ - -#ifndef GL_ARB_shader_bit_encoding -#define GL_ARB_shader_bit_encoding 1 -#endif /* GL_ARB_shader_bit_encoding */ - -#ifndef GL_ARB_shader_clock -#define GL_ARB_shader_clock 1 -#endif /* GL_ARB_shader_clock */ - -#ifndef GL_ARB_shader_draw_parameters -#define GL_ARB_shader_draw_parameters 1 -#endif /* GL_ARB_shader_draw_parameters */ - -#ifndef GL_ARB_shader_group_vote -#define GL_ARB_shader_group_vote 1 -#endif /* GL_ARB_shader_group_vote */ - -#ifndef GL_ARB_shader_image_load_store -#define GL_ARB_shader_image_load_store 1 -#endif /* GL_ARB_shader_image_load_store */ - -#ifndef GL_ARB_shader_image_size -#define GL_ARB_shader_image_size 1 -#endif /* GL_ARB_shader_image_size */ - -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 -#ifdef __APPLE__ -#ifdef BUILDING_MESA -/* Avoid uint <-> void* warnings */ -typedef unsigned long GLhandleARB; -#else -typedef void *GLhandleARB; -#endif -#else -typedef unsigned int GLhandleARB; -#endif -typedef char GLcharARB; -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); -typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); -GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); -GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); -GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); -GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); -GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); -GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); -GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); -GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); -GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); -GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); -GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); -GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); -GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); -GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); -GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); -GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#endif -#endif /* GL_ARB_shader_objects */ - -#ifndef GL_ARB_shader_precision -#define GL_ARB_shader_precision 1 -#endif /* GL_ARB_shader_precision */ - -#ifndef GL_ARB_shader_stencil_export -#define GL_ARB_shader_stencil_export 1 -#endif /* GL_ARB_shader_stencil_export */ - -#ifndef GL_ARB_shader_storage_buffer_object -#define GL_ARB_shader_storage_buffer_object 1 -#endif /* GL_ARB_shader_storage_buffer_object */ - -#ifndef GL_ARB_shader_subroutine -#define GL_ARB_shader_subroutine 1 -#endif /* GL_ARB_shader_subroutine */ - -#ifndef GL_ARB_shader_texture_image_samples -#define GL_ARB_shader_texture_image_samples 1 -#endif /* GL_ARB_shader_texture_image_samples */ - -#ifndef GL_ARB_shader_texture_lod -#define GL_ARB_shader_texture_lod 1 -#endif /* GL_ARB_shader_texture_lod */ - -#ifndef GL_ARB_shader_viewport_layer_array -#define GL_ARB_shader_viewport_layer_array 1 -#endif /* GL_ARB_shader_viewport_layer_array */ - -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif /* GL_ARB_shading_language_100 */ - -#ifndef GL_ARB_shading_language_420pack -#define GL_ARB_shading_language_420pack 1 -#endif /* GL_ARB_shading_language_420pack */ - -#ifndef GL_ARB_shading_language_include -#define GL_ARB_shading_language_include 1 -#define GL_SHADER_INCLUDE_ARB 0x8DAE -#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 -#define GL_NAMED_STRING_TYPE_ARB 0x8DEA -typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); -typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); -typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); -typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); -GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); -GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); -GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#endif -#endif /* GL_ARB_shading_language_include */ - -#ifndef GL_ARB_shading_language_packing -#define GL_ARB_shading_language_packing 1 -#endif /* GL_ARB_shading_language_packing */ - -#ifndef GL_ARB_shadow -#define GL_ARB_shadow 1 -#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E -#endif /* GL_ARB_shadow */ - -#ifndef GL_ARB_shadow_ambient -#define GL_ARB_shadow_ambient 1 -#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF -#endif /* GL_ARB_shadow_ambient */ - -#ifndef GL_ARB_sparse_buffer -#define GL_ARB_sparse_buffer 1 -#define GL_SPARSE_STORAGE_BIT_ARB 0x0400 -#define GL_SPARSE_BUFFER_PAGE_SIZE_ARB 0x82F8 -typedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); -typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); -typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTARBPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferPageCommitmentARB (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); -GLAPI void APIENTRY glNamedBufferPageCommitmentEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); -GLAPI void APIENTRY glNamedBufferPageCommitmentARB (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); -#endif -#endif /* GL_ARB_sparse_buffer */ - -#ifndef GL_ARB_sparse_texture -#define GL_ARB_sparse_texture 1 -#define GL_TEXTURE_SPARSE_ARB 0x91A6 -#define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 -#define GL_NUM_SPARSE_LEVELS_ARB 0x91AA -#define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 -#define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 -#define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 -#define GL_VIRTUAL_PAGE_SIZE_Z_ARB 0x9197 -#define GL_MAX_SPARSE_TEXTURE_SIZE_ARB 0x9198 -#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 -#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A -#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 -typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); -#endif -#endif /* GL_ARB_sparse_texture */ - -#ifndef GL_ARB_sparse_texture2 -#define GL_ARB_sparse_texture2 1 -#endif /* GL_ARB_sparse_texture2 */ - -#ifndef GL_ARB_sparse_texture_clamp -#define GL_ARB_sparse_texture_clamp 1 -#endif /* GL_ARB_sparse_texture_clamp */ - -#ifndef GL_ARB_stencil_texturing -#define GL_ARB_stencil_texturing 1 -#endif /* GL_ARB_stencil_texturing */ - -#ifndef GL_ARB_sync -#define GL_ARB_sync 1 -#endif /* GL_ARB_sync */ - -#ifndef GL_ARB_tessellation_shader -#define GL_ARB_tessellation_shader 1 -#endif /* GL_ARB_tessellation_shader */ - -#ifndef GL_ARB_texture_barrier -#define GL_ARB_texture_barrier 1 -#endif /* GL_ARB_texture_barrier */ - -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 -#define GL_CLAMP_TO_BORDER_ARB 0x812D -#endif /* GL_ARB_texture_border_clamp */ - -#ifndef GL_ARB_texture_buffer_object -#define GL_ARB_texture_buffer_object 1 -#define GL_TEXTURE_BUFFER_ARB 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E -typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); -#endif -#endif /* GL_ARB_texture_buffer_object */ - -#ifndef GL_ARB_texture_buffer_object_rgb32 -#define GL_ARB_texture_buffer_object_rgb32 1 -#endif /* GL_ARB_texture_buffer_object_rgb32 */ - -#ifndef GL_ARB_texture_buffer_range -#define GL_ARB_texture_buffer_range 1 -#endif /* GL_ARB_texture_buffer_range */ - -#ifndef GL_ARB_texture_compression -#define GL_ARB_texture_compression 1 -#define GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define GL_COMPRESSED_RGB_ARB 0x84ED -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, void *img); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void *img); -#endif -#endif /* GL_ARB_texture_compression */ - -#ifndef GL_ARB_texture_compression_bptc -#define GL_ARB_texture_compression_bptc 1 -#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C -#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D -#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E -#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F -#endif /* GL_ARB_texture_compression_bptc */ - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_ARB_texture_compression_rgtc 1 -#endif /* GL_ARB_texture_compression_rgtc */ - -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C -#endif /* GL_ARB_texture_cube_map */ - -#ifndef GL_ARB_texture_cube_map_array -#define GL_ARB_texture_cube_map_array 1 -#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B -#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F -#endif /* GL_ARB_texture_cube_map_array */ - -#ifndef GL_ARB_texture_env_add -#define GL_ARB_texture_env_add 1 -#endif /* GL_ARB_texture_env_add */ - -#ifndef GL_ARB_texture_env_combine -#define GL_ARB_texture_env_combine 1 -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_SOURCE0_RGB_ARB 0x8580 -#define GL_SOURCE1_RGB_ARB 0x8581 -#define GL_SOURCE2_RGB_ARB 0x8582 -#define GL_SOURCE0_ALPHA_ARB 0x8588 -#define GL_SOURCE1_ALPHA_ARB 0x8589 -#define GL_SOURCE2_ALPHA_ARB 0x858A -#define GL_OPERAND0_RGB_ARB 0x8590 -#define GL_OPERAND1_RGB_ARB 0x8591 -#define GL_OPERAND2_RGB_ARB 0x8592 -#define GL_OPERAND0_ALPHA_ARB 0x8598 -#define GL_OPERAND1_ALPHA_ARB 0x8599 -#define GL_OPERAND2_ALPHA_ARB 0x859A -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#endif /* GL_ARB_texture_env_combine */ - -#ifndef GL_ARB_texture_env_crossbar -#define GL_ARB_texture_env_crossbar 1 -#endif /* GL_ARB_texture_env_crossbar */ - -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF -#endif /* GL_ARB_texture_env_dot3 */ - -#ifndef GL_ARB_texture_filter_minmax -#define GL_ARB_texture_filter_minmax 1 -#define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366 -#define GL_WEIGHTED_AVERAGE_ARB 0x9367 -#endif /* GL_ARB_texture_filter_minmax */ - -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#endif /* GL_ARB_texture_float */ - -#ifndef GL_ARB_texture_gather -#define GL_ARB_texture_gather 1 -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F -#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F -#endif /* GL_ARB_texture_gather */ - -#ifndef GL_ARB_texture_mirror_clamp_to_edge -#define GL_ARB_texture_mirror_clamp_to_edge 1 -#endif /* GL_ARB_texture_mirror_clamp_to_edge */ - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 -#define GL_MIRRORED_REPEAT_ARB 0x8370 -#endif /* GL_ARB_texture_mirrored_repeat */ - -#ifndef GL_ARB_texture_multisample -#define GL_ARB_texture_multisample 1 -#endif /* GL_ARB_texture_multisample */ - -#ifndef GL_ARB_texture_non_power_of_two -#define GL_ARB_texture_non_power_of_two 1 -#endif /* GL_ARB_texture_non_power_of_two */ - -#ifndef GL_ARB_texture_query_levels -#define GL_ARB_texture_query_levels 1 -#endif /* GL_ARB_texture_query_levels */ - -#ifndef GL_ARB_texture_query_lod -#define GL_ARB_texture_query_lod 1 -#endif /* GL_ARB_texture_query_lod */ - -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#endif /* GL_ARB_texture_rectangle */ - -#ifndef GL_ARB_texture_rg -#define GL_ARB_texture_rg 1 -#endif /* GL_ARB_texture_rg */ - -#ifndef GL_ARB_texture_rgb10_a2ui -#define GL_ARB_texture_rgb10_a2ui 1 -#endif /* GL_ARB_texture_rgb10_a2ui */ - -#ifndef GL_ARB_texture_stencil8 -#define GL_ARB_texture_stencil8 1 -#endif /* GL_ARB_texture_stencil8 */ - -#ifndef GL_ARB_texture_storage -#define GL_ARB_texture_storage 1 -#endif /* GL_ARB_texture_storage */ - -#ifndef GL_ARB_texture_storage_multisample -#define GL_ARB_texture_storage_multisample 1 -#endif /* GL_ARB_texture_storage_multisample */ - -#ifndef GL_ARB_texture_swizzle -#define GL_ARB_texture_swizzle 1 -#endif /* GL_ARB_texture_swizzle */ - -#ifndef GL_ARB_texture_view -#define GL_ARB_texture_view 1 -#endif /* GL_ARB_texture_view */ - -#ifndef GL_ARB_timer_query -#define GL_ARB_timer_query 1 -#endif /* GL_ARB_timer_query */ - -#ifndef GL_ARB_transform_feedback2 -#define GL_ARB_transform_feedback2 1 -#endif /* GL_ARB_transform_feedback2 */ - -#ifndef GL_ARB_transform_feedback3 -#define GL_ARB_transform_feedback3 1 -#endif /* GL_ARB_transform_feedback3 */ - -#ifndef GL_ARB_transform_feedback_instanced -#define GL_ARB_transform_feedback_instanced 1 -#endif /* GL_ARB_transform_feedback_instanced */ - -#ifndef GL_ARB_transform_feedback_overflow_query -#define GL_ARB_transform_feedback_overflow_query 1 -#define GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB 0x82EC -#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB 0x82ED -#endif /* GL_ARB_transform_feedback_overflow_query */ - -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 -#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); -GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); -GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); -GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); -#endif -#endif /* GL_ARB_transpose_matrix */ - -#ifndef GL_ARB_uniform_buffer_object -#define GL_ARB_uniform_buffer_object 1 -#endif /* GL_ARB_uniform_buffer_object */ - -#ifndef GL_ARB_vertex_array_bgra -#define GL_ARB_vertex_array_bgra 1 -#endif /* GL_ARB_vertex_array_bgra */ - -#ifndef GL_ARB_vertex_array_object -#define GL_ARB_vertex_array_object 1 -#endif /* GL_ARB_vertex_array_object */ - -#ifndef GL_ARB_vertex_attrib_64bit -#define GL_ARB_vertex_attrib_64bit 1 -#endif /* GL_ARB_vertex_attrib_64bit */ - -#ifndef GL_ARB_vertex_attrib_binding -#define GL_ARB_vertex_attrib_binding 1 -#endif /* GL_ARB_vertex_attrib_binding */ - -#ifndef GL_ARB_vertex_blend -#define GL_ARB_vertex_blend 1 -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F -typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); -typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); -typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); -typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); -typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); -typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); -typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); -GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); -GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); -GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); -GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); -GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); -GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); -GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); -GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glVertexBlendARB (GLint count); -#endif -#endif /* GL_ARB_vertex_blend */ - -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 -typedef ptrdiff_t GLsizeiptrARB; -typedef ptrdiff_t GLintptrARB; -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA -typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); -typedef void *(APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, void **params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); -GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); -GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); -GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); -GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); -GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); -GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); -GLAPI void *APIENTRY glMapBufferARB (GLenum target, GLenum access); -GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); -GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, void **params); -#endif -#endif /* GL_ARB_vertex_buffer_object */ - -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void **pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); -GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); -GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, void **pointer); -#endif -#endif /* GL_ARB_vertex_program */ - -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); -GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); -#endif -#endif /* GL_ARB_vertex_shader */ - -#ifndef GL_ARB_vertex_type_10f_11f_11f_rev -#define GL_ARB_vertex_type_10f_11f_11f_rev 1 -#endif /* GL_ARB_vertex_type_10f_11f_11f_rev */ - -#ifndef GL_ARB_vertex_type_2_10_10_10_rev -#define GL_ARB_vertex_type_2_10_10_10_rev 1 -#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ - -#ifndef GL_ARB_viewport_array -#define GL_ARB_viewport_array 1 -#endif /* GL_ARB_viewport_array */ - -#ifndef GL_ARB_window_pos -#define GL_ARB_window_pos 1 -typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); -GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); -GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); -GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); -#endif -#endif /* GL_ARB_window_pos */ - -#ifndef GL_KHR_blend_equation_advanced -#define GL_KHR_blend_equation_advanced 1 -#define GL_MULTIPLY_KHR 0x9294 -#define GL_SCREEN_KHR 0x9295 -#define GL_OVERLAY_KHR 0x9296 -#define GL_DARKEN_KHR 0x9297 -#define GL_LIGHTEN_KHR 0x9298 -#define GL_COLORDODGE_KHR 0x9299 -#define GL_COLORBURN_KHR 0x929A -#define GL_HARDLIGHT_KHR 0x929B -#define GL_SOFTLIGHT_KHR 0x929C -#define GL_DIFFERENCE_KHR 0x929E -#define GL_EXCLUSION_KHR 0x92A0 -#define GL_HSL_HUE_KHR 0x92AD -#define GL_HSL_SATURATION_KHR 0x92AE -#define GL_HSL_COLOR_KHR 0x92AF -#define GL_HSL_LUMINOSITY_KHR 0x92B0 -typedef void (APIENTRYP PFNGLBLENDBARRIERKHRPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendBarrierKHR (void); -#endif -#endif /* GL_KHR_blend_equation_advanced */ - -#ifndef GL_KHR_blend_equation_advanced_coherent -#define GL_KHR_blend_equation_advanced_coherent 1 -#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 -#endif /* GL_KHR_blend_equation_advanced_coherent */ - -#ifndef GL_KHR_context_flush_control -#define GL_KHR_context_flush_control 1 -#endif /* GL_KHR_context_flush_control */ - -#ifndef GL_KHR_debug -#define GL_KHR_debug 1 -#endif /* GL_KHR_debug */ - -#ifndef GL_KHR_no_error -#define GL_KHR_no_error 1 -#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 -#endif /* GL_KHR_no_error */ - -#ifndef GL_KHR_robust_buffer_access_behavior -#define GL_KHR_robust_buffer_access_behavior 1 -#endif /* GL_KHR_robust_buffer_access_behavior */ - -#ifndef GL_KHR_robustness -#define GL_KHR_robustness 1 -#define GL_CONTEXT_ROBUST_ACCESS 0x90F3 -#endif /* GL_KHR_robustness */ - -#ifndef GL_KHR_texture_compression_astc_hdr -#define GL_KHR_texture_compression_astc_hdr 1 -#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 -#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 -#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 -#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 -#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 -#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 -#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 -#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 -#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 -#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 -#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA -#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB -#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC -#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD -#endif /* GL_KHR_texture_compression_astc_hdr */ - -#ifndef GL_KHR_texture_compression_astc_ldr -#define GL_KHR_texture_compression_astc_ldr 1 -#endif /* GL_KHR_texture_compression_astc_ldr */ - -#ifndef GL_OES_byte_coordinates -#define GL_OES_byte_coordinates 1 -typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords); -typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s); -typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t); -typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); -typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); -typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x, GLbyte y); -typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y, GLbyte z); -typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z, GLbyte w); -typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s); -GLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords); -GLAPI void APIENTRY glMultiTexCoord2bOES (GLenum texture, GLbyte s, GLbyte t); -GLAPI void APIENTRY glMultiTexCoord2bvOES (GLenum texture, const GLbyte *coords); -GLAPI void APIENTRY glMultiTexCoord3bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r); -GLAPI void APIENTRY glMultiTexCoord3bvOES (GLenum texture, const GLbyte *coords); -GLAPI void APIENTRY glMultiTexCoord4bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); -GLAPI void APIENTRY glMultiTexCoord4bvOES (GLenum texture, const GLbyte *coords); -GLAPI void APIENTRY glTexCoord1bOES (GLbyte s); -GLAPI void APIENTRY glTexCoord1bvOES (const GLbyte *coords); -GLAPI void APIENTRY glTexCoord2bOES (GLbyte s, GLbyte t); -GLAPI void APIENTRY glTexCoord2bvOES (const GLbyte *coords); -GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r); -GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords); -GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q); -GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords); -GLAPI void APIENTRY glVertex2bOES (GLbyte x, GLbyte y); -GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); -GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y, GLbyte z); -GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); -GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z, GLbyte w); -GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); -#endif -#endif /* GL_OES_byte_coordinates */ - -#ifndef GL_OES_compressed_paletted_texture -#define GL_OES_compressed_paletted_texture 1 -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 -#endif /* GL_OES_compressed_paletted_texture */ - -#ifndef GL_OES_fixed_point -#define GL_OES_fixed_point 1 -typedef GLint GLfixed; -#define GL_FIXED_OES 0x140C -typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); -typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth); -typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); -typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f); -typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param); -typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); -typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation); -typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param); -typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); -typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); -typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param); -typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); -typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); -typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); -typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); -typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); -typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value); -typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); -typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue); -typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components); -typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u); -typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v); -typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v); -typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values); -typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component); -typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); -typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); -typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); -typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2); -typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords); -typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token); -typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values); -typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities); -typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y); -typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w); -typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); -typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2); -typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s); -typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t); -typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r); -typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q); -typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x); -typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y); -typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref); -GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -GLAPI void APIENTRY glClearDepthxOES (GLfixed depth); -GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); -GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f); -GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param); -GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param); -GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); -GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation); -GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param); -GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param); -GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); -GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glLineWidthxOES (GLfixed width); -GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m); -GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); -GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param); -GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m); -GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); -GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); -GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); -GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glPointSizexOES (GLfixed size); -GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); -GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); -GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); -GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); -GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); -GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); -GLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value); -GLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); -GLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -GLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -GLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue); -GLAPI void APIENTRY glColor3xvOES (const GLfixed *components); -GLAPI void APIENTRY glColor4xvOES (const GLfixed *components); -GLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param); -GLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glEvalCoord1xOES (GLfixed u); -GLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords); -GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v); -GLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords); -GLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer); -GLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v); -GLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param); -GLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values); -GLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glIndexxOES (GLfixed component); -GLAPI void APIENTRY glIndexxvOES (const GLfixed *component); -GLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m); -GLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); -GLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); -GLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2); -GLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); -GLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m); -GLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s); -GLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords); -GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t); -GLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords); -GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r); -GLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords); -GLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords); -GLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords); -GLAPI void APIENTRY glPassThroughxOES (GLfixed token); -GLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values); -GLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param); -GLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param); -GLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor); -GLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities); -GLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y); -GLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords); -GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z); -GLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords); -GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w); -GLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords); -GLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); -GLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2); -GLAPI void APIENTRY glTexCoord1xOES (GLfixed s); -GLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords); -GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t); -GLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords); -GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r); -GLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords); -GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q); -GLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords); -GLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); -GLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glVertex2xOES (GLfixed x); -GLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords); -GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y); -GLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords); -GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z); -GLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords); -#endif -#endif /* GL_OES_fixed_point */ - -#ifndef GL_OES_query_matrix -#define GL_OES_query_matrix 1 -typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent); -#endif -#endif /* GL_OES_query_matrix */ - -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#endif /* GL_OES_read_format */ - -#ifndef GL_OES_single_precision -#define GL_OES_single_precision 1 -typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); -typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); -typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); -typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation); -typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClearDepthfOES (GLclampf depth); -GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); -GLAPI void APIENTRY glDepthRangefOES (GLclampf n, GLclampf f); -GLAPI void APIENTRY glFrustumfOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); -GLAPI void APIENTRY glOrthofOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -#endif -#endif /* GL_OES_single_precision */ - -#ifndef GL_3DFX_multisample -#define GL_3DFX_multisample 1 -#define GL_MULTISAMPLE_3DFX 0x86B2 -#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define GL_SAMPLES_3DFX 0x86B4 -#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 -#endif /* GL_3DFX_multisample */ - -#ifndef GL_3DFX_tbuffer -#define GL_3DFX_tbuffer 1 -typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); -#endif -#endif /* GL_3DFX_tbuffer */ - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_3DFX_texture_compression_FXT1 1 -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 -#endif /* GL_3DFX_texture_compression_FXT1 */ - -#ifndef GL_AMD_blend_minmax_factor -#define GL_AMD_blend_minmax_factor 1 -#define GL_FACTOR_MIN_AMD 0x901C -#define GL_FACTOR_MAX_AMD 0x901D -#endif /* GL_AMD_blend_minmax_factor */ - -#ifndef GL_AMD_conservative_depth -#define GL_AMD_conservative_depth 1 -#endif /* GL_AMD_conservative_depth */ - -#ifndef GL_AMD_debug_output -#define GL_AMD_debug_output 1 -typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); -#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 -#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 -#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 -#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A -#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B -#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C -#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D -#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E -#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F -#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 -typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, void *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); -#endif -#endif /* GL_AMD_debug_output */ - -#ifndef GL_AMD_depth_clamp_separate -#define GL_AMD_depth_clamp_separate 1 -#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E -#define GL_DEPTH_CLAMP_FAR_AMD 0x901F -#endif /* GL_AMD_depth_clamp_separate */ - -#ifndef GL_AMD_draw_buffers_blend -#define GL_AMD_draw_buffers_blend 1 -typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -#endif -#endif /* GL_AMD_draw_buffers_blend */ - -#ifndef GL_AMD_gcn_shader -#define GL_AMD_gcn_shader 1 -#endif /* GL_AMD_gcn_shader */ - -#ifndef GL_AMD_gpu_shader_int64 -#define GL_AMD_gpu_shader_int64 1 -typedef int64_t GLint64EXT; -#define GL_INT64_NV 0x140E -#define GL_UNSIGNED_INT64_NV 0x140F -#define GL_INT8_NV 0x8FE0 -#define GL_INT8_VEC2_NV 0x8FE1 -#define GL_INT8_VEC3_NV 0x8FE2 -#define GL_INT8_VEC4_NV 0x8FE3 -#define GL_INT16_NV 0x8FE4 -#define GL_INT16_VEC2_NV 0x8FE5 -#define GL_INT16_VEC3_NV 0x8FE6 -#define GL_INT16_VEC4_NV 0x8FE7 -#define GL_INT64_VEC2_NV 0x8FE9 -#define GL_INT64_VEC3_NV 0x8FEA -#define GL_INT64_VEC4_NV 0x8FEB -#define GL_UNSIGNED_INT8_NV 0x8FEC -#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED -#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE -#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF -#define GL_UNSIGNED_INT16_NV 0x8FF0 -#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 -#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 -#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 -#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 -#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 -#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 -#define GL_FLOAT16_NV 0x8FF8 -#define GL_FLOAT16_VEC2_NV 0x8FF9 -#define GL_FLOAT16_VEC3_NV 0x8FFA -#define GL_FLOAT16_VEC4_NV 0x8FFB -typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); -typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); -typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); -GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); -GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); -GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); -GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); -GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); -GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif -#endif /* GL_AMD_gpu_shader_int64 */ - -#ifndef GL_AMD_interleaved_elements -#define GL_AMD_interleaved_elements 1 -#define GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4 -#define GL_VERTEX_ID_SWIZZLE_AMD 0x91A5 -typedef void (APIENTRYP PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribParameteriAMD (GLuint index, GLenum pname, GLint param); -#endif -#endif /* GL_AMD_interleaved_elements */ - -#ifndef GL_AMD_multi_draw_indirect -#define GL_AMD_multi_draw_indirect 1 -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); -#endif -#endif /* GL_AMD_multi_draw_indirect */ - -#ifndef GL_AMD_name_gen_delete -#define GL_AMD_name_gen_delete 1 -#define GL_DATA_BUFFER_AMD 0x9151 -#define GL_PERFORMANCE_MONITOR_AMD 0x9152 -#define GL_QUERY_OBJECT_AMD 0x9153 -#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 -#define GL_SAMPLER_OBJECT_AMD 0x9155 -typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); -typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); -typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); -GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); -GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); -#endif -#endif /* GL_AMD_name_gen_delete */ - -#ifndef GL_AMD_occlusion_query_event -#define GL_AMD_occlusion_query_event 1 -#define GL_OCCLUSION_QUERY_EVENT_MASK_AMD 0x874F -#define GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD 0x00000001 -#define GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD 0x00000002 -#define GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD 0x00000004 -#define GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD 0x00000008 -#define GL_QUERY_ALL_EVENT_BITS_AMD 0xFFFFFFFF -typedef void (APIENTRYP PFNGLQUERYOBJECTPARAMETERUIAMDPROC) (GLenum target, GLuint id, GLenum pname, GLuint param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glQueryObjectParameteruiAMD (GLenum target, GLuint id, GLenum pname, GLuint param); -#endif -#endif /* GL_AMD_occlusion_query_event */ - -#ifndef GL_AMD_performance_monitor -#define GL_AMD_performance_monitor 1 -#define GL_COUNTER_TYPE_AMD 0x8BC0 -#define GL_COUNTER_RANGE_AMD 0x8BC1 -#define GL_UNSIGNED_INT64_AMD 0x8BC2 -#define GL_PERCENTAGE_AMD 0x8BC3 -#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 -#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 -#define GL_PERFMON_RESULT_AMD 0x8BC6 -typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); -typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); -typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); -typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); -GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); -GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); -GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); -GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); -GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); -GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif -#endif /* GL_AMD_performance_monitor */ - -#ifndef GL_AMD_pinned_memory -#define GL_AMD_pinned_memory 1 -#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 -#endif /* GL_AMD_pinned_memory */ - -#ifndef GL_AMD_query_buffer_object -#define GL_AMD_query_buffer_object 1 -#define GL_QUERY_BUFFER_AMD 0x9192 -#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 -#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 -#endif /* GL_AMD_query_buffer_object */ - -#ifndef GL_AMD_sample_positions -#define GL_AMD_sample_positions 1 -#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F -typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); -#endif -#endif /* GL_AMD_sample_positions */ - -#ifndef GL_AMD_seamless_cubemap_per_texture -#define GL_AMD_seamless_cubemap_per_texture 1 -#endif /* GL_AMD_seamless_cubemap_per_texture */ - -#ifndef GL_AMD_shader_atomic_counter_ops -#define GL_AMD_shader_atomic_counter_ops 1 -#endif /* GL_AMD_shader_atomic_counter_ops */ - -#ifndef GL_AMD_shader_stencil_export -#define GL_AMD_shader_stencil_export 1 -#endif /* GL_AMD_shader_stencil_export */ - -#ifndef GL_AMD_shader_trinary_minmax -#define GL_AMD_shader_trinary_minmax 1 -#endif /* GL_AMD_shader_trinary_minmax */ - -#ifndef GL_AMD_sparse_texture -#define GL_AMD_sparse_texture 1 -#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 -#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 -#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 -#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 -#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 -#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A -#define GL_MIN_SPARSE_LEVEL_AMD 0x919B -#define GL_MIN_LOD_WARNING_AMD 0x919C -#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 -typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); -typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); -GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); -#endif -#endif /* GL_AMD_sparse_texture */ - -#ifndef GL_AMD_stencil_operation_extended -#define GL_AMD_stencil_operation_extended 1 -#define GL_SET_AMD 0x874A -#define GL_REPLACE_VALUE_AMD 0x874B -#define GL_STENCIL_OP_VALUE_AMD 0x874C -#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D -typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); -#endif -#endif /* GL_AMD_stencil_operation_extended */ - -#ifndef GL_AMD_texture_texture4 -#define GL_AMD_texture_texture4 1 -#endif /* GL_AMD_texture_texture4 */ - -#ifndef GL_AMD_transform_feedback3_lines_triangles -#define GL_AMD_transform_feedback3_lines_triangles 1 -#endif /* GL_AMD_transform_feedback3_lines_triangles */ - -#ifndef GL_AMD_transform_feedback4 -#define GL_AMD_transform_feedback4 1 -#define GL_STREAM_RASTERIZATION_AMD 0x91A0 -#endif /* GL_AMD_transform_feedback4 */ - -#ifndef GL_AMD_vertex_shader_layer -#define GL_AMD_vertex_shader_layer 1 -#endif /* GL_AMD_vertex_shader_layer */ - -#ifndef GL_AMD_vertex_shader_tessellator -#define GL_AMD_vertex_shader_tessellator 1 -#define GL_SAMPLER_BUFFER_AMD 0x9001 -#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 -#define GL_TESSELLATION_MODE_AMD 0x9004 -#define GL_TESSELLATION_FACTOR_AMD 0x9005 -#define GL_DISCRETE_AMD 0x9006 -#define GL_CONTINUOUS_AMD 0x9007 -typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); -GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); -#endif -#endif /* GL_AMD_vertex_shader_tessellator */ - -#ifndef GL_AMD_vertex_shader_viewport_index -#define GL_AMD_vertex_shader_viewport_index 1 -#endif /* GL_AMD_vertex_shader_viewport_index */ - -#ifndef GL_APPLE_aux_depth_stencil -#define GL_APPLE_aux_depth_stencil 1 -#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 -#endif /* GL_APPLE_aux_depth_stencil */ - -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#endif /* GL_APPLE_client_storage */ - -#ifndef GL_APPLE_element_array -#define GL_APPLE_element_array 1 -#define GL_ELEMENT_ARRAY_APPLE 0x8A0C -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E -typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const void *pointer); -GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); -GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#endif -#endif /* GL_APPLE_element_array */ - -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B -typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); -typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); -typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); -GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); -GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); -GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); -GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); -#endif -#endif /* GL_APPLE_fence */ - -#ifndef GL_APPLE_float_pixels -#define GL_APPLE_float_pixels 1 -#define GL_HALF_APPLE 0x140B -#define GL_RGBA_FLOAT32_APPLE 0x8814 -#define GL_RGB_FLOAT32_APPLE 0x8815 -#define GL_ALPHA_FLOAT32_APPLE 0x8816 -#define GL_INTENSITY_FLOAT32_APPLE 0x8817 -#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 -#define GL_RGBA_FLOAT16_APPLE 0x881A -#define GL_RGB_FLOAT16_APPLE 0x881B -#define GL_ALPHA_FLOAT16_APPLE 0x881C -#define GL_INTENSITY_FLOAT16_APPLE 0x881D -#define GL_LUMINANCE_FLOAT16_APPLE 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F -#define GL_COLOR_FLOAT_APPLE 0x8A0F -#endif /* GL_APPLE_float_pixels */ - -#ifndef GL_APPLE_flush_buffer_range -#define GL_APPLE_flush_buffer_range 1 -#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 -#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 -typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); -#endif -#endif /* GL_APPLE_flush_buffer_range */ - -#ifndef GL_APPLE_object_purgeable -#define GL_APPLE_object_purgeable 1 -#define GL_BUFFER_OBJECT_APPLE 0x85B3 -#define GL_RELEASED_APPLE 0x8A19 -#define GL_VOLATILE_APPLE 0x8A1A -#define GL_RETAINED_APPLE 0x8A1B -#define GL_UNDEFINED_APPLE 0x8A1C -#define GL_PURGEABLE_APPLE 0x8A1D -typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); -typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); -GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); -GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); -#endif -#endif /* GL_APPLE_object_purgeable */ - -#ifndef GL_APPLE_rgb_422 -#define GL_APPLE_rgb_422 1 -#define GL_RGB_422_APPLE 0x8A1F -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#define GL_RGB_RAW_422_APPLE 0x8A51 -#endif /* GL_APPLE_rgb_422 */ - -#ifndef GL_APPLE_row_bytes -#define GL_APPLE_row_bytes 1 -#define GL_PACK_ROW_BYTES_APPLE 0x8A15 -#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 -#endif /* GL_APPLE_row_bytes */ - -#ifndef GL_APPLE_specular_vector -#define GL_APPLE_specular_vector 1 -#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 -#endif /* GL_APPLE_specular_vector */ - -#ifndef GL_APPLE_texture_range -#define GL_APPLE_texture_range 1 -#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 -#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 -#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC -#define GL_STORAGE_PRIVATE_APPLE 0x85BD -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF -typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const void *pointer); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, void **params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const void *pointer); -GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, void **params); -#endif -#endif /* GL_APPLE_texture_range */ - -#ifndef GL_APPLE_transform_hint -#define GL_APPLE_transform_hint 1 -#define GL_TRANSFORM_HINT_APPLE 0x85B1 -#endif /* GL_APPLE_transform_hint */ - -#ifndef GL_APPLE_vertex_array_object -#define GL_APPLE_vertex_array_object 1 -#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); -GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); -GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); -GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); -#endif -#endif /* GL_APPLE_vertex_array_object */ - -#ifndef GL_APPLE_vertex_array_range -#define GL_APPLE_vertex_array_range 1 -#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E -#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F -#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define GL_STORAGE_CLIENT_APPLE 0x85B4 -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); -typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, void *pointer); -GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, void *pointer); -GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); -#endif -#endif /* GL_APPLE_vertex_array_range */ - -#ifndef GL_APPLE_vertex_program_evaluators -#define GL_APPLE_vertex_program_evaluators 1 -#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 -#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 -#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 -#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 -#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 -#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 -#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 -#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 -#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 -#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); -GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); -GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); -GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); -#endif -#endif /* GL_APPLE_vertex_program_evaluators */ - -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 -#define GL_YCBCR_422_APPLE 0x85B9 -#endif /* GL_APPLE_ycbcr_422 */ - -#ifndef GL_ATI_draw_buffers -#define GL_ATI_draw_buffers 1 -#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 -#define GL_DRAW_BUFFER0_ATI 0x8825 -#define GL_DRAW_BUFFER1_ATI 0x8826 -#define GL_DRAW_BUFFER2_ATI 0x8827 -#define GL_DRAW_BUFFER3_ATI 0x8828 -#define GL_DRAW_BUFFER4_ATI 0x8829 -#define GL_DRAW_BUFFER5_ATI 0x882A -#define GL_DRAW_BUFFER6_ATI 0x882B -#define GL_DRAW_BUFFER7_ATI 0x882C -#define GL_DRAW_BUFFER8_ATI 0x882D -#define GL_DRAW_BUFFER9_ATI 0x882E -#define GL_DRAW_BUFFER10_ATI 0x882F -#define GL_DRAW_BUFFER11_ATI 0x8830 -#define GL_DRAW_BUFFER12_ATI 0x8831 -#define GL_DRAW_BUFFER13_ATI 0x8832 -#define GL_DRAW_BUFFER14_ATI 0x8833 -#define GL_DRAW_BUFFER15_ATI 0x8834 -typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); -#endif -#endif /* GL_ATI_draw_buffers */ - -#ifndef GL_ATI_element_array -#define GL_ATI_element_array 1 -#define GL_ELEMENT_ARRAY_ATI 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A -typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerATI (GLenum type, const void *pointer); -GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); -GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); -#endif -#endif /* GL_ATI_element_array */ - -#ifndef GL_ATI_envmap_bumpmap -#define GL_ATI_envmap_bumpmap 1 -#define GL_BUMP_ROT_MATRIX_ATI 0x8775 -#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 -#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 -#define GL_BUMP_TEX_UNITS_ATI 0x8778 -#define GL_DUDV_ATI 0x8779 -#define GL_DU8DV8_ATI 0x877A -#define GL_BUMP_ENVMAP_ATI 0x877B -#define GL_BUMP_TARGET_ATI 0x877C -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); -GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); -GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); -GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); -#endif -#endif /* GL_ATI_envmap_bumpmap */ - -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader 1 -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_REG_6_ATI 0x8927 -#define GL_REG_7_ATI 0x8928 -#define GL_REG_8_ATI 0x8929 -#define GL_REG_9_ATI 0x892A -#define GL_REG_10_ATI 0x892B -#define GL_REG_11_ATI 0x892C -#define GL_REG_12_ATI 0x892D -#define GL_REG_13_ATI 0x892E -#define GL_REG_14_ATI 0x892F -#define GL_REG_15_ATI 0x8930 -#define GL_REG_16_ATI 0x8931 -#define GL_REG_17_ATI 0x8932 -#define GL_REG_18_ATI 0x8933 -#define GL_REG_19_ATI 0x8934 -#define GL_REG_20_ATI 0x8935 -#define GL_REG_21_ATI 0x8936 -#define GL_REG_22_ATI 0x8937 -#define GL_REG_23_ATI 0x8938 -#define GL_REG_24_ATI 0x8939 -#define GL_REG_25_ATI 0x893A -#define GL_REG_26_ATI 0x893B -#define GL_REG_27_ATI 0x893C -#define GL_REG_28_ATI 0x893D -#define GL_REG_29_ATI 0x893E -#define GL_REG_30_ATI 0x893F -#define GL_REG_31_ATI 0x8940 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_CON_8_ATI 0x8949 -#define GL_CON_9_ATI 0x894A -#define GL_CON_10_ATI 0x894B -#define GL_CON_11_ATI 0x894C -#define GL_CON_12_ATI 0x894D -#define GL_CON_13_ATI 0x894E -#define GL_CON_14_ATI 0x894F -#define GL_CON_15_ATI 0x8950 -#define GL_CON_16_ATI 0x8951 -#define GL_CON_17_ATI 0x8952 -#define GL_CON_18_ATI 0x8953 -#define GL_CON_19_ATI 0x8954 -#define GL_CON_20_ATI 0x8955 -#define GL_CON_21_ATI 0x8956 -#define GL_CON_22_ATI 0x8957 -#define GL_CON_23_ATI 0x8958 -#define GL_CON_24_ATI 0x8959 -#define GL_CON_25_ATI 0x895A -#define GL_CON_26_ATI 0x895B -#define GL_CON_27_ATI 0x895C -#define GL_CON_28_ATI 0x895D -#define GL_CON_29_ATI 0x895E -#define GL_CON_30_ATI 0x895F -#define GL_CON_31_ATI 0x8960 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E -#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F -#define GL_NUM_PASSES_ATI 0x8970 -#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 -#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 -#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 -#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 -#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_SWIZZLE_STRQ_ATI 0x897A -#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B -#define GL_RED_BIT_ATI 0x00000001 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); -typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); -GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); -GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); -GLAPI void APIENTRY glBeginFragmentShaderATI (void); -GLAPI void APIENTRY glEndFragmentShaderATI (void); -GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); -GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); -GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); -#endif -#endif /* GL_ATI_fragment_shader */ - -#ifndef GL_ATI_map_object_buffer -#define GL_ATI_map_object_buffer 1 -typedef void *(APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void *APIENTRY glMapObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); -#endif -#endif /* GL_ATI_map_object_buffer */ - -#ifndef GL_ATI_meminfo -#define GL_ATI_meminfo 1 -#define GL_VBO_FREE_MEMORY_ATI 0x87FB -#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC -#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD -#endif /* GL_ATI_meminfo */ - -#ifndef GL_ATI_pixel_format_float -#define GL_ATI_pixel_format_float 1 -#define GL_RGBA_FLOAT_MODE_ATI 0x8820 -#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 -#endif /* GL_ATI_pixel_format_float */ - -#ifndef GL_ATI_pn_triangles -#define GL_ATI_pn_triangles 1 -#define GL_PN_TRIANGLES_ATI 0x87F0 -#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 -#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 -#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 -#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 -#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 -#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 -#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 -#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 -typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); -GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); -#endif -#endif /* GL_ATI_pn_triangles */ - -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif -#endif /* GL_ATI_separate_stencil */ - -#ifndef GL_ATI_text_fragment_shader -#define GL_ATI_text_fragment_shader 1 -#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 -#endif /* GL_ATI_text_fragment_shader */ - -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 -#endif /* GL_ATI_texture_env_combine3 */ - -#ifndef GL_ATI_texture_float -#define GL_ATI_texture_float 1 -#define GL_RGBA_FLOAT32_ATI 0x8814 -#define GL_RGB_FLOAT32_ATI 0x8815 -#define GL_ALPHA_FLOAT32_ATI 0x8816 -#define GL_INTENSITY_FLOAT32_ATI 0x8817 -#define GL_LUMINANCE_FLOAT32_ATI 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 -#define GL_RGBA_FLOAT16_ATI 0x881A -#define GL_RGB_FLOAT16_ATI 0x881B -#define GL_ALPHA_FLOAT16_ATI 0x881C -#define GL_INTENSITY_FLOAT16_ATI 0x881D -#define GL_LUMINANCE_FLOAT16_ATI 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F -#endif /* GL_ATI_texture_float */ - -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 -#endif /* GL_ATI_texture_mirror_once */ - -#ifndef GL_ATI_vertex_array_object -#define GL_ATI_vertex_array_object 1 -#define GL_STATIC_ATI 0x8760 -#define GL_DYNAMIC_ATI 0x8761 -#define GL_PRESERVE_ATI 0x8762 -#define GL_DISCARD_ATI 0x8763 -#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 -#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 -#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 -#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 -typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void *pointer, GLenum usage); -typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const void *pointer, GLenum usage); -GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); -GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); -GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); -#endif -#endif /* GL_ATI_vertex_array_object */ - -#ifndef GL_ATI_vertex_attrib_array_object -#define GL_ATI_vertex_attrib_array_object 1 -typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); -#endif -#endif /* GL_ATI_vertex_attrib_array_object */ - -#ifndef GL_ATI_vertex_streams -#define GL_ATI_vertex_streams 1 -#define GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define GL_VERTEX_STREAM0_ATI 0x876C -#define GL_VERTEX_STREAM1_ATI 0x876D -#define GL_VERTEX_STREAM2_ATI 0x876E -#define GL_VERTEX_STREAM3_ATI 0x876F -#define GL_VERTEX_STREAM4_ATI 0x8770 -#define GL_VERTEX_STREAM5_ATI 0x8771 -#define GL_VERTEX_STREAM6_ATI 0x8772 -#define GL_VERTEX_STREAM7_ATI 0x8773 -#define GL_VERTEX_SOURCE_ATI 0x8774 -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); -GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); -GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); -GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); -GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); -GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); -GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); -GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); -GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); -GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); -#endif -#endif /* GL_ATI_vertex_streams */ - -#ifndef GL_EXT_422_pixels -#define GL_EXT_422_pixels 1 -#define GL_422_EXT 0x80CC -#define GL_422_REV_EXT 0x80CD -#define GL_422_AVERAGE_EXT 0x80CE -#define GL_422_REV_AVERAGE_EXT 0x80CF -#endif /* GL_EXT_422_pixels */ - -#ifndef GL_EXT_abgr -#define GL_EXT_abgr 1 -#define GL_ABGR_EXT 0x8000 -#endif /* GL_EXT_abgr */ - -#ifndef GL_EXT_bgra -#define GL_EXT_bgra 1 -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 -#endif /* GL_EXT_bgra */ - -#ifndef GL_EXT_bindable_uniform -#define GL_EXT_bindable_uniform 1 -#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 -#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 -#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 -#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED -#define GL_UNIFORM_BUFFER_EXT 0x8DEE -#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF -typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); -typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); -typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); -GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); -GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); -#endif -#endif /* GL_EXT_bindable_uniform */ - -#ifndef GL_EXT_blend_color -#define GL_EXT_blend_color 1 -#define GL_CONSTANT_COLOR_EXT 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define GL_CONSTANT_ALPHA_EXT 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define GL_BLEND_COLOR_EXT 0x8005 -typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -#endif -#endif /* GL_EXT_blend_color */ - -#ifndef GL_EXT_blend_equation_separate -#define GL_EXT_blend_equation_separate 1 -#define GL_BLEND_EQUATION_RGB_EXT 0x8009 -#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); -#endif -#endif /* GL_EXT_blend_equation_separate */ - -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif -#endif /* GL_EXT_blend_func_separate */ - -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 -#endif /* GL_EXT_blend_logic_op */ - -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_BLEND_EQUATION_EXT 0x8009 -typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); -#endif -#endif /* GL_EXT_blend_minmax */ - -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B -#endif /* GL_EXT_blend_subtract */ - -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 -#endif /* GL_EXT_clip_volume_hint */ - -#ifndef GL_EXT_cmyka -#define GL_EXT_cmyka 1 -#define GL_CMYK_EXT 0x800C -#define GL_CMYKA_EXT 0x800D -#define GL_PACK_CMYK_HINT_EXT 0x800E -#define GL_UNPACK_CMYK_HINT_EXT 0x800F -#endif /* GL_EXT_cmyka */ - -#ifndef GL_EXT_color_subtable -#define GL_EXT_color_subtable 1 -typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif -#endif /* GL_EXT_color_subtable */ - -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 -typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); -GLAPI void APIENTRY glUnlockArraysEXT (void); -#endif -#endif /* GL_EXT_compiled_vertex_array */ - -#ifndef GL_EXT_convolution -#define GL_EXT_convolution 1 -#define GL_CONVOLUTION_1D_EXT 0x8010 -#define GL_CONVOLUTION_2D_EXT 0x8011 -#define GL_SEPARABLE_2D_EXT 0x8012 -#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 -#define GL_REDUCE_EXT 0x8016 -#define GL_CONVOLUTION_FORMAT_EXT 0x8017 -#define GL_CONVOLUTION_WIDTH_EXT 0x8018 -#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); -GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); -GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); -GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); -GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, void *image); -GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); -GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); -#endif -#endif /* GL_EXT_convolution */ - -#ifndef GL_EXT_coordinate_frame -#define GL_EXT_coordinate_frame 1 -#define GL_TANGENT_ARRAY_EXT 0x8439 -#define GL_BINORMAL_ARRAY_EXT 0x843A -#define GL_CURRENT_TANGENT_EXT 0x843B -#define GL_CURRENT_BINORMAL_EXT 0x843C -#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E -#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F -#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 -#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 -#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 -#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 -#define GL_MAP1_TANGENT_EXT 0x8444 -#define GL_MAP2_TANGENT_EXT 0x8445 -#define GL_MAP1_BINORMAL_EXT 0x8446 -#define GL_MAP2_BINORMAL_EXT 0x8447 -typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); -typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); -typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); -typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); -typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); -typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); -typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); -typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); -typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); -typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); -typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); -GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); -GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); -GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); -GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); -GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); -GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); -GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); -GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); -GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); -GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); -GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); -GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); -GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); -GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const void *pointer); -#endif -#endif /* GL_EXT_coordinate_frame */ - -#ifndef GL_EXT_copy_texture -#define GL_EXT_copy_texture 1 -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif -#endif /* GL_EXT_copy_texture */ - -#ifndef GL_EXT_cull_vertex -#define GL_EXT_cull_vertex 1 -#define GL_CULL_VERTEX_EXT 0x81AA -#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB -#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC -typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); -GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); -#endif -#endif /* GL_EXT_cull_vertex */ - -#ifndef GL_EXT_debug_label -#define GL_EXT_debug_label 1 -#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F -#define GL_PROGRAM_OBJECT_EXT 0x8B40 -#define GL_SHADER_OBJECT_EXT 0x8B48 -#define GL_BUFFER_OBJECT_EXT 0x9151 -#define GL_QUERY_OBJECT_EXT 0x9153 -#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 -typedef void (APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); -typedef void (APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); -GLAPI void APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); -#endif -#endif /* GL_EXT_debug_label */ - -#ifndef GL_EXT_debug_marker -#define GL_EXT_debug_marker 1 -typedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); -typedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); -typedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); -GLAPI void APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); -GLAPI void APIENTRY glPopGroupMarkerEXT (void); -#endif -#endif /* GL_EXT_debug_marker */ - -#ifndef GL_EXT_depth_bounds_test -#define GL_EXT_depth_bounds_test 1 -#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define GL_DEPTH_BOUNDS_EXT 0x8891 -typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); -#endif -#endif /* GL_EXT_depth_bounds_test */ - -#ifndef GL_EXT_direct_state_access -#define GL_EXT_direct_state_access 1 -#define GL_PROGRAM_MATRIX_EXT 0x8E2D -#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E -#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F -typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); -typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); -typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); -typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); -typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void **data); -typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, void *img); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, void *img); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); -typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); -typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void **params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); -typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); -typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); -typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); -typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); -typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); -typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void **param); -typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param); -typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); -typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); -typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); -GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); -GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); -GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); -GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); -GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); -GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); -GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); -GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); -GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); -GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); -GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); -GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); -GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); -GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, void **data); -GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); -GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); -GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); -GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); -GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); -GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, void *img); -GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, void *img); -GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); -GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); -GLAPI void *APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); -GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); -GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, void **params); -GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); -GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); -GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); -GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); -GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); -GLAPI void APIENTRY glEnableClientStateiEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glDisableClientStateiEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glGetFloati_vEXT (GLenum pname, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetDoublei_vEXT (GLenum pname, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetPointeri_vEXT (GLenum pname, GLuint index, void **params); -GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); -GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, void *string); -GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); -GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); -GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); -GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); -GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); -GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); -GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); -GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glVertexArrayVertexOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayEdgeFlagOffsetEXT (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayIndexOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayNormalOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayMultiTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayFogCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArraySecondaryColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayVertexAttribOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayVertexAttribIOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glEnableVertexArrayEXT (GLuint vaobj, GLenum array); -GLAPI void APIENTRY glDisableVertexArrayEXT (GLuint vaobj, GLenum array); -GLAPI void APIENTRY glEnableVertexArrayAttribEXT (GLuint vaobj, GLuint index); -GLAPI void APIENTRY glDisableVertexArrayAttribEXT (GLuint vaobj, GLuint index); -GLAPI void APIENTRY glGetVertexArrayIntegervEXT (GLuint vaobj, GLenum pname, GLint *param); -GLAPI void APIENTRY glGetVertexArrayPointervEXT (GLuint vaobj, GLenum pname, void **param); -GLAPI void APIENTRY glGetVertexArrayIntegeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLint *param); -GLAPI void APIENTRY glGetVertexArrayPointeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, void **param); -GLAPI void *APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); -GLAPI void APIENTRY glNamedBufferStorageEXT (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); -GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); -GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); -GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); -GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); -GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); -GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glTexturePageCommitmentEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); -GLAPI void APIENTRY glVertexArrayVertexAttribDivisorEXT (GLuint vaobj, GLuint index, GLuint divisor); -#endif -#endif /* GL_EXT_direct_state_access */ - -#ifndef GL_EXT_draw_buffers2 -#define GL_EXT_draw_buffers2 1 -typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -#endif -#endif /* GL_EXT_draw_buffers2 */ - -#ifndef GL_EXT_draw_instanced -#define GL_EXT_draw_instanced 1 -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); -#endif -#endif /* GL_EXT_draw_instanced */ - -#ifndef GL_EXT_draw_range_elements -#define GL_EXT_draw_range_elements 1 -#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 -#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); -#endif -#endif /* GL_EXT_draw_range_elements */ - -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 -typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); -GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); -GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); -GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); -GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const void *pointer); -#endif -#endif /* GL_EXT_fog_coord */ - -#ifndef GL_EXT_framebuffer_blit -#define GL_EXT_framebuffer_blit 1 -#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif -#endif /* GL_EXT_framebuffer_blit */ - -#ifndef GL_EXT_framebuffer_multisample -#define GL_EXT_framebuffer_multisample 1 -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define GL_MAX_SAMPLES_EXT 0x8D57 -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif -#endif /* GL_EXT_framebuffer_multisample */ - -#ifndef GL_EXT_framebuffer_multisample_blit_scaled -#define GL_EXT_framebuffer_multisample_blit_scaled 1 -#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA -#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB -#endif /* GL_EXT_framebuffer_multisample_blit_scaled */ - -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); -GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); -GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); -GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); -GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); -GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); -GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); -GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); -GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); -#endif -#endif /* GL_EXT_framebuffer_object */ - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_EXT_framebuffer_sRGB 1 -#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 -#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA -#endif /* GL_EXT_framebuffer_sRGB */ - -#ifndef GL_EXT_geometry_shader4 -#define GL_EXT_geometry_shader4 1 -#define GL_GEOMETRY_SHADER_EXT 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE -#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 -#define GL_LINES_ADJACENCY_EXT 0x000A -#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B -#define GL_TRIANGLES_ADJACENCY_EXT 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 -#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); -#endif -#endif /* GL_EXT_geometry_shader4 */ - -#ifndef GL_EXT_gpu_program_parameters -#define GL_EXT_gpu_program_parameters 1 -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -#endif -#endif /* GL_EXT_gpu_program_parameters */ - -#ifndef GL_EXT_gpu_shader4 -#define GL_EXT_gpu_shader4 1 -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD -#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 -#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 -#define GL_SAMPLER_BUFFER_EXT 0x8DC2 -#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 -#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 -#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 -#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 -#define GL_INT_SAMPLER_1D_EXT 0x8DC9 -#define GL_INT_SAMPLER_2D_EXT 0x8DCA -#define GL_INT_SAMPLER_3D_EXT 0x8DCB -#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC -#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD -#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF -#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 -#define GL_MIN_PROGRAM_TEXEL_OFFSET_EXT 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET_EXT 0x8905 -typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); -GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); -GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); -GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); -#endif -#endif /* GL_EXT_gpu_shader4 */ - -#ifndef GL_EXT_histogram -#define GL_EXT_histogram 1 -#define GL_HISTOGRAM_EXT 0x8024 -#define GL_PROXY_HISTOGRAM_EXT 0x8025 -#define GL_HISTOGRAM_WIDTH_EXT 0x8026 -#define GL_HISTOGRAM_FORMAT_EXT 0x8027 -#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C -#define GL_HISTOGRAM_SINK_EXT 0x802D -#define GL_MINMAX_EXT 0x802E -#define GL_MINMAX_FORMAT_EXT 0x802F -#define GL_MINMAX_SINK_EXT 0x8030 -#define GL_TABLE_TOO_LARGE_EXT 0x8031 -typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glResetHistogramEXT (GLenum target); -GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); -#endif -#endif /* GL_EXT_histogram */ - -#ifndef GL_EXT_index_array_formats -#define GL_EXT_index_array_formats 1 -#define GL_IUI_V2F_EXT 0x81AD -#define GL_IUI_V3F_EXT 0x81AE -#define GL_IUI_N3F_V2F_EXT 0x81AF -#define GL_IUI_N3F_V3F_EXT 0x81B0 -#define GL_T2F_IUI_V2F_EXT 0x81B1 -#define GL_T2F_IUI_V3F_EXT 0x81B2 -#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 -#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 -#endif /* GL_EXT_index_array_formats */ - -#ifndef GL_EXT_index_func -#define GL_EXT_index_func 1 -#define GL_INDEX_TEST_EXT 0x81B5 -#define GL_INDEX_TEST_FUNC_EXT 0x81B6 -#define GL_INDEX_TEST_REF_EXT 0x81B7 -typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); -#endif -#endif /* GL_EXT_index_func */ - -#ifndef GL_EXT_index_material -#define GL_EXT_index_material 1 -#define GL_INDEX_MATERIAL_EXT 0x81B8 -#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 -#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA -typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); -#endif -#endif /* GL_EXT_index_material */ - -#ifndef GL_EXT_index_texture -#define GL_EXT_index_texture 1 -#endif /* GL_EXT_index_texture */ - -#ifndef GL_EXT_light_texture -#define GL_EXT_light_texture 1 -#define GL_FRAGMENT_MATERIAL_EXT 0x8349 -#define GL_FRAGMENT_NORMAL_EXT 0x834A -#define GL_FRAGMENT_COLOR_EXT 0x834C -#define GL_ATTENUATION_EXT 0x834D -#define GL_SHADOW_ATTENUATION_EXT 0x834E -#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F -#define GL_TEXTURE_LIGHT_EXT 0x8350 -#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 -#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 -typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); -GLAPI void APIENTRY glTextureLightEXT (GLenum pname); -GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); -#endif -#endif /* GL_EXT_light_texture */ - -#ifndef GL_EXT_misc_attribute -#define GL_EXT_misc_attribute 1 -#endif /* GL_EXT_misc_attribute */ - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); -#endif -#endif /* GL_EXT_multi_draw_arrays */ - -#ifndef GL_EXT_multisample -#define GL_EXT_multisample 1 -#define GL_MULTISAMPLE_EXT 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#define GL_SAMPLE_MASK_EXT 0x80A0 -#define GL_1PASS_EXT 0x80A1 -#define GL_2PASS_0_EXT 0x80A2 -#define GL_2PASS_1_EXT 0x80A3 -#define GL_4PASS_0_EXT 0x80A4 -#define GL_4PASS_1_EXT 0x80A5 -#define GL_4PASS_2_EXT 0x80A6 -#define GL_4PASS_3_EXT 0x80A7 -#define GL_SAMPLE_BUFFERS_EXT 0x80A8 -#define GL_SAMPLES_EXT 0x80A9 -#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA -#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB -#define GL_SAMPLE_PATTERN_EXT 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 -typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); -GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); -#endif -#endif /* GL_EXT_multisample */ - -#ifndef GL_EXT_packed_depth_stencil -#define GL_EXT_packed_depth_stencil 1 -#define GL_DEPTH_STENCIL_EXT 0x84F9 -#define GL_UNSIGNED_INT_24_8_EXT 0x84FA -#define GL_DEPTH24_STENCIL8_EXT 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 -#endif /* GL_EXT_packed_depth_stencil */ - -#ifndef GL_EXT_packed_float -#define GL_EXT_packed_float 1 -#define GL_R11F_G11F_B10F_EXT 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B -#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C -#endif /* GL_EXT_packed_float */ - -#ifndef GL_EXT_packed_pixels -#define GL_EXT_packed_pixels 1 -#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 -#endif /* GL_EXT_packed_pixels */ - -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void *data); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); -GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, void *data); -GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -#endif -#endif /* GL_EXT_paletted_texture */ - -#ifndef GL_EXT_pixel_buffer_object -#define GL_EXT_pixel_buffer_object 1 -#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF -#endif /* GL_EXT_pixel_buffer_object */ - -#ifndef GL_EXT_pixel_transform -#define GL_EXT_pixel_transform 1 -#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 -#define GL_PIXEL_MAG_FILTER_EXT 0x8331 -#define GL_PIXEL_MIN_FILTER_EXT 0x8332 -#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 -#define GL_CUBIC_EXT 0x8334 -#define GL_AVERAGE_EXT 0x8335 -#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 -#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 -#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -#endif -#endif /* GL_EXT_pixel_transform */ - -#ifndef GL_EXT_pixel_transform_color_table -#define GL_EXT_pixel_transform_color_table 1 -#endif /* GL_EXT_pixel_transform_color_table */ - -#ifndef GL_EXT_point_parameters -#define GL_EXT_point_parameters 1 -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 -typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); -#endif -#endif /* GL_EXT_point_parameters */ - -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 -typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); -#endif -#endif /* GL_EXT_polygon_offset */ - -#ifndef GL_EXT_polygon_offset_clamp -#define GL_EXT_polygon_offset_clamp 1 -#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B -typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPolygonOffsetClampEXT (GLfloat factor, GLfloat units, GLfloat clamp); -#endif -#endif /* GL_EXT_polygon_offset_clamp */ - -#ifndef GL_EXT_post_depth_coverage -#define GL_EXT_post_depth_coverage 1 -#endif /* GL_EXT_post_depth_coverage */ - -#ifndef GL_EXT_provoking_vertex -#define GL_EXT_provoking_vertex 1 -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D -#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E -#define GL_PROVOKING_VERTEX_EXT 0x8E4F -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); -#endif -#endif /* GL_EXT_provoking_vertex */ - -#ifndef GL_EXT_raster_multisample -#define GL_EXT_raster_multisample 1 -#define GL_RASTER_MULTISAMPLE_EXT 0x9327 -#define GL_RASTER_SAMPLES_EXT 0x9328 -#define GL_MAX_RASTER_SAMPLES_EXT 0x9329 -#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A -#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B -#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C -typedef void (APIENTRYP PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRasterSamplesEXT (GLuint samples, GLboolean fixedsamplelocations); -#endif -#endif /* GL_EXT_raster_multisample */ - -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 -#define GL_RESCALE_NORMAL_EXT 0x803A -#endif /* GL_EXT_rescale_normal */ - -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); -GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); -GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); -GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); -GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); -GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); -GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); -GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); -GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); -GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); -GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); -GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); -GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); -GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); -#endif -#endif /* GL_EXT_secondary_color */ - -#ifndef GL_EXT_separate_shader_objects -#define GL_EXT_separate_shader_objects 1 -#define GL_ACTIVE_PROGRAM_EXT 0x8B8D -typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); -typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); -GLAPI void APIENTRY glActiveProgramEXT (GLuint program); -GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); -#endif -#endif /* GL_EXT_separate_shader_objects */ - -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#endif /* GL_EXT_separate_specular_color */ - -#ifndef GL_EXT_shader_image_load_formatted -#define GL_EXT_shader_image_load_formatted 1 -#endif /* GL_EXT_shader_image_load_formatted */ - -#ifndef GL_EXT_shader_image_load_store -#define GL_EXT_shader_image_load_store 1 -#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 -#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 -#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A -#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B -#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C -#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D -#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E -#define GL_IMAGE_1D_EXT 0x904C -#define GL_IMAGE_2D_EXT 0x904D -#define GL_IMAGE_3D_EXT 0x904E -#define GL_IMAGE_2D_RECT_EXT 0x904F -#define GL_IMAGE_CUBE_EXT 0x9050 -#define GL_IMAGE_BUFFER_EXT 0x9051 -#define GL_IMAGE_1D_ARRAY_EXT 0x9052 -#define GL_IMAGE_2D_ARRAY_EXT 0x9053 -#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 -#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 -#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 -#define GL_INT_IMAGE_1D_EXT 0x9057 -#define GL_INT_IMAGE_2D_EXT 0x9058 -#define GL_INT_IMAGE_3D_EXT 0x9059 -#define GL_INT_IMAGE_2D_RECT_EXT 0x905A -#define GL_INT_IMAGE_CUBE_EXT 0x905B -#define GL_INT_IMAGE_BUFFER_EXT 0x905C -#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D -#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E -#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F -#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 -#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 -#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 -#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 -#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 -#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 -#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 -#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C -#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D -#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E -#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 -#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 -#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 -#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 -#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 -#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 -#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 -#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 -#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 -#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 -#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 -#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 -#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF -typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); -typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); -GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); -#endif -#endif /* GL_EXT_shader_image_load_store */ - -#ifndef GL_EXT_shader_integer_mix -#define GL_EXT_shader_integer_mix 1 -#endif /* GL_EXT_shader_integer_mix */ - -#ifndef GL_EXT_shadow_funcs -#define GL_EXT_shadow_funcs 1 -#endif /* GL_EXT_shadow_funcs */ - -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB -#endif /* GL_EXT_shared_texture_palette */ - -#ifndef GL_EXT_sparse_texture2 -#define GL_EXT_sparse_texture2 1 -#endif /* GL_EXT_sparse_texture2 */ - -#ifndef GL_EXT_stencil_clear_tag -#define GL_EXT_stencil_clear_tag 1 -#define GL_STENCIL_TAG_BITS_EXT 0x88F2 -#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 -typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); -#endif -#endif /* GL_EXT_stencil_clear_tag */ - -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 -typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); -#endif -#endif /* GL_EXT_stencil_two_side */ - -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 -#endif /* GL_EXT_stencil_wrap */ - -#ifndef GL_EXT_subtexture -#define GL_EXT_subtexture 1 -typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -#endif -#endif /* GL_EXT_subtexture */ - -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 -#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 -#endif /* GL_EXT_texture */ - -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 -typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -#endif -#endif /* GL_EXT_texture3D */ - -#ifndef GL_EXT_texture_array -#define GL_EXT_texture_array 1 -#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 -#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D -#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF -#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -#endif -#endif /* GL_EXT_texture_array */ - -#ifndef GL_EXT_texture_buffer_object -#define GL_EXT_texture_buffer_object 1 -#define GL_TEXTURE_BUFFER_EXT 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E -typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); -#endif -#endif /* GL_EXT_texture_buffer_object */ - -#ifndef GL_EXT_texture_compression_latc -#define GL_EXT_texture_compression_latc 1 -#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 -#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 -#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 -#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 -#endif /* GL_EXT_texture_compression_latc */ - -#ifndef GL_EXT_texture_compression_rgtc -#define GL_EXT_texture_compression_rgtc 1 -#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC -#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD -#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE -#endif /* GL_EXT_texture_compression_rgtc */ - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_EXT_texture_compression_s3tc 1 -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#endif /* GL_EXT_texture_compression_s3tc */ - -#ifndef GL_EXT_texture_cube_map -#define GL_EXT_texture_cube_map 1 -#define GL_NORMAL_MAP_EXT 0x8511 -#define GL_REFLECTION_MAP_EXT 0x8512 -#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C -#endif /* GL_EXT_texture_cube_map */ - -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 -#endif /* GL_EXT_texture_env_add */ - -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A -#endif /* GL_EXT_texture_env_combine */ - -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif /* GL_EXT_texture_env_dot3 */ - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif /* GL_EXT_texture_filter_anisotropic */ - -#ifndef GL_EXT_texture_filter_minmax -#define GL_EXT_texture_filter_minmax 1 -#endif /* GL_EXT_texture_filter_minmax */ - -#ifndef GL_EXT_texture_integer -#define GL_EXT_texture_integer 1 -#define GL_RGBA32UI_EXT 0x8D70 -#define GL_RGB32UI_EXT 0x8D71 -#define GL_ALPHA32UI_EXT 0x8D72 -#define GL_INTENSITY32UI_EXT 0x8D73 -#define GL_LUMINANCE32UI_EXT 0x8D74 -#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 -#define GL_RGBA16UI_EXT 0x8D76 -#define GL_RGB16UI_EXT 0x8D77 -#define GL_ALPHA16UI_EXT 0x8D78 -#define GL_INTENSITY16UI_EXT 0x8D79 -#define GL_LUMINANCE16UI_EXT 0x8D7A -#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B -#define GL_RGBA8UI_EXT 0x8D7C -#define GL_RGB8UI_EXT 0x8D7D -#define GL_ALPHA8UI_EXT 0x8D7E -#define GL_INTENSITY8UI_EXT 0x8D7F -#define GL_LUMINANCE8UI_EXT 0x8D80 -#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 -#define GL_RGBA32I_EXT 0x8D82 -#define GL_RGB32I_EXT 0x8D83 -#define GL_ALPHA32I_EXT 0x8D84 -#define GL_INTENSITY32I_EXT 0x8D85 -#define GL_LUMINANCE32I_EXT 0x8D86 -#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 -#define GL_RGBA16I_EXT 0x8D88 -#define GL_RGB16I_EXT 0x8D89 -#define GL_ALPHA16I_EXT 0x8D8A -#define GL_INTENSITY16I_EXT 0x8D8B -#define GL_LUMINANCE16I_EXT 0x8D8C -#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D -#define GL_RGBA8I_EXT 0x8D8E -#define GL_RGB8I_EXT 0x8D8F -#define GL_ALPHA8I_EXT 0x8D90 -#define GL_INTENSITY8I_EXT 0x8D91 -#define GL_LUMINANCE8I_EXT 0x8D92 -#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 -#define GL_RED_INTEGER_EXT 0x8D94 -#define GL_GREEN_INTEGER_EXT 0x8D95 -#define GL_BLUE_INTEGER_EXT 0x8D96 -#define GL_ALPHA_INTEGER_EXT 0x8D97 -#define GL_RGB_INTEGER_EXT 0x8D98 -#define GL_RGBA_INTEGER_EXT 0x8D99 -#define GL_BGR_INTEGER_EXT 0x8D9A -#define GL_BGRA_INTEGER_EXT 0x8D9B -#define GL_LUMINANCE_INTEGER_EXT 0x8D9C -#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D -#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); -typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); -GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); -#endif -#endif /* GL_EXT_texture_integer */ - -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#endif /* GL_EXT_texture_lod_bias */ - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_EXT_texture_mirror_clamp 1 -#define GL_MIRROR_CLAMP_EXT 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 -#endif /* GL_EXT_texture_mirror_clamp */ - -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 -#define GL_TEXTURE_PRIORITY_EXT 0x8066 -#define GL_TEXTURE_RESIDENT_EXT 0x8067 -#define GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define GL_TEXTURE_2D_BINDING_EXT 0x8069 -#define GL_TEXTURE_3D_BINDING_EXT 0x806A -typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); -GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); -GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); -GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); -GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); -GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif -#endif /* GL_EXT_texture_object */ - -#ifndef GL_EXT_texture_perturb_normal -#define GL_EXT_texture_perturb_normal 1 -#define GL_PERTURB_EXT 0x85AE -#define GL_TEXTURE_NORMAL_EXT 0x85AF -typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); -#endif -#endif /* GL_EXT_texture_perturb_normal */ - -#ifndef GL_EXT_texture_sRGB -#define GL_EXT_texture_sRGB 1 -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB8_EXT 0x8C41 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define GL_SLUMINANCE_EXT 0x8C46 -#define GL_SLUMINANCE8_EXT 0x8C47 -#define GL_COMPRESSED_SRGB_EXT 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F -#endif /* GL_EXT_texture_sRGB */ - -#ifndef GL_EXT_texture_sRGB_decode -#define GL_EXT_texture_sRGB_decode 1 -#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 -#define GL_DECODE_EXT 0x8A49 -#define GL_SKIP_DECODE_EXT 0x8A4A -#endif /* GL_EXT_texture_sRGB_decode */ - -#ifndef GL_EXT_texture_shared_exponent -#define GL_EXT_texture_shared_exponent 1 -#define GL_RGB9_E5_EXT 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E -#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F -#endif /* GL_EXT_texture_shared_exponent */ - -#ifndef GL_EXT_texture_snorm -#define GL_EXT_texture_snorm 1 -#define GL_ALPHA_SNORM 0x9010 -#define GL_LUMINANCE_SNORM 0x9011 -#define GL_LUMINANCE_ALPHA_SNORM 0x9012 -#define GL_INTENSITY_SNORM 0x9013 -#define GL_ALPHA8_SNORM 0x9014 -#define GL_LUMINANCE8_SNORM 0x9015 -#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 -#define GL_INTENSITY8_SNORM 0x9017 -#define GL_ALPHA16_SNORM 0x9018 -#define GL_LUMINANCE16_SNORM 0x9019 -#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A -#define GL_INTENSITY16_SNORM 0x901B -#define GL_RED_SNORM 0x8F90 -#define GL_RG_SNORM 0x8F91 -#define GL_RGB_SNORM 0x8F92 -#define GL_RGBA_SNORM 0x8F93 -#endif /* GL_EXT_texture_snorm */ - -#ifndef GL_EXT_texture_swizzle -#define GL_EXT_texture_swizzle 1 -#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 -#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 -#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 -#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 -#endif /* GL_EXT_texture_swizzle */ - -#ifndef GL_EXT_timer_query -#define GL_EXT_timer_query 1 -#define GL_TIME_ELAPSED_EXT 0x88BF -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); -#endif -#endif /* GL_EXT_timer_query */ - -#ifndef GL_EXT_transform_feedback -#define GL_EXT_transform_feedback 1 -#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F -#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C -#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D -#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 -#define GL_RASTERIZER_DISCARD_EXT 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedbackEXT (void); -GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); -GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -#endif -#endif /* GL_EXT_transform_feedback */ - -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 -typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); -typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, void **params); -typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glArrayElementEXT (GLint i); -GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); -GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); -GLAPI void APIENTRY glGetPointervEXT (GLenum pname, void **params); -GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); -GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); -GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -#endif -#endif /* GL_EXT_vertex_array */ - -#ifndef GL_EXT_vertex_array_bgra -#define GL_EXT_vertex_array_bgra 1 -#endif /* GL_EXT_vertex_array_bgra */ - -#ifndef GL_EXT_vertex_attrib_64bit -#define GL_EXT_vertex_attrib_64bit 1 -#define GL_DOUBLE_VEC2_EXT 0x8FFC -#define GL_DOUBLE_VEC3_EXT 0x8FFD -#define GL_DOUBLE_VEC4_EXT 0x8FFE -#define GL_DOUBLE_MAT2_EXT 0x8F46 -#define GL_DOUBLE_MAT3_EXT 0x8F47 -#define GL_DOUBLE_MAT4_EXT 0x8F48 -#define GL_DOUBLE_MAT2x3_EXT 0x8F49 -#define GL_DOUBLE_MAT2x4_EXT 0x8F4A -#define GL_DOUBLE_MAT3x2_EXT 0x8F4B -#define GL_DOUBLE_MAT3x4_EXT 0x8F4C -#define GL_DOUBLE_MAT4x2_EXT 0x8F4D -#define GL_DOUBLE_MAT4x3_EXT 0x8F4E -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); -#endif -#endif /* GL_EXT_vertex_attrib_64bit */ - -#ifndef GL_EXT_vertex_shader -#define GL_EXT_vertex_shader 1 -#define GL_VERTEX_SHADER_EXT 0x8780 -#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 -#define GL_OP_INDEX_EXT 0x8782 -#define GL_OP_NEGATE_EXT 0x8783 -#define GL_OP_DOT3_EXT 0x8784 -#define GL_OP_DOT4_EXT 0x8785 -#define GL_OP_MUL_EXT 0x8786 -#define GL_OP_ADD_EXT 0x8787 -#define GL_OP_MADD_EXT 0x8788 -#define GL_OP_FRAC_EXT 0x8789 -#define GL_OP_MAX_EXT 0x878A -#define GL_OP_MIN_EXT 0x878B -#define GL_OP_SET_GE_EXT 0x878C -#define GL_OP_SET_LT_EXT 0x878D -#define GL_OP_CLAMP_EXT 0x878E -#define GL_OP_FLOOR_EXT 0x878F -#define GL_OP_ROUND_EXT 0x8790 -#define GL_OP_EXP_BASE_2_EXT 0x8791 -#define GL_OP_LOG_BASE_2_EXT 0x8792 -#define GL_OP_POWER_EXT 0x8793 -#define GL_OP_RECIP_EXT 0x8794 -#define GL_OP_RECIP_SQRT_EXT 0x8795 -#define GL_OP_SUB_EXT 0x8796 -#define GL_OP_CROSS_PRODUCT_EXT 0x8797 -#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 -#define GL_OP_MOV_EXT 0x8799 -#define GL_OUTPUT_VERTEX_EXT 0x879A -#define GL_OUTPUT_COLOR0_EXT 0x879B -#define GL_OUTPUT_COLOR1_EXT 0x879C -#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D -#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E -#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F -#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 -#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 -#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 -#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 -#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 -#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 -#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 -#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 -#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 -#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 -#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA -#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB -#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC -#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD -#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE -#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF -#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 -#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 -#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 -#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 -#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 -#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 -#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 -#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 -#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 -#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 -#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA -#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB -#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC -#define GL_OUTPUT_FOG_EXT 0x87BD -#define GL_SCALAR_EXT 0x87BE -#define GL_VECTOR_EXT 0x87BF -#define GL_MATRIX_EXT 0x87C0 -#define GL_VARIANT_EXT 0x87C1 -#define GL_INVARIANT_EXT 0x87C2 -#define GL_LOCAL_CONSTANT_EXT 0x87C3 -#define GL_LOCAL_EXT 0x87C4 -#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 -#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 -#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 -#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 -#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE -#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF -#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 -#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 -#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 -#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 -#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 -#define GL_X_EXT 0x87D5 -#define GL_Y_EXT 0x87D6 -#define GL_Z_EXT 0x87D7 -#define GL_W_EXT 0x87D8 -#define GL_NEGATIVE_X_EXT 0x87D9 -#define GL_NEGATIVE_Y_EXT 0x87DA -#define GL_NEGATIVE_Z_EXT 0x87DB -#define GL_NEGATIVE_W_EXT 0x87DC -#define GL_ZERO_EXT 0x87DD -#define GL_ONE_EXT 0x87DE -#define GL_NEGATIVE_ONE_EXT 0x87DF -#define GL_NORMALIZED_RANGE_EXT 0x87E0 -#define GL_FULL_RANGE_EXT 0x87E1 -#define GL_CURRENT_VERTEX_EXT 0x87E2 -#define GL_MVP_MATRIX_EXT 0x87E3 -#define GL_VARIANT_VALUE_EXT 0x87E4 -#define GL_VARIANT_DATATYPE_EXT 0x87E5 -#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 -#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 -#define GL_VARIANT_ARRAY_EXT 0x87E8 -#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 -#define GL_INVARIANT_VALUE_EXT 0x87EA -#define GL_INVARIANT_DATATYPE_EXT 0x87EB -#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC -#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED -typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); -typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); -typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const void *addr); -typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const void *addr); -typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); -typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); -typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); -typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); -typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); -typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); -typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); -typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); -typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const void *addr); -typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); -typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); -typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, void **data); -typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVertexShaderEXT (void); -GLAPI void APIENTRY glEndVertexShaderEXT (void); -GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); -GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); -GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); -GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); -GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); -GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); -GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const void *addr); -GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const void *addr); -GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); -GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); -GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); -GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); -GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); -GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); -GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); -GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); -GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const void *addr); -GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); -GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); -GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); -GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); -GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); -GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); -GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); -GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); -GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, void **data); -GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -#endif -#endif /* GL_EXT_vertex_shader */ - -#ifndef GL_EXT_vertex_weighting -#define GL_EXT_vertex_weighting 1 -#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 -#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 -#define GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define GL_VERTEX_WEIGHTING_EXT 0x8509 -#define GL_MODELVIEW0_EXT 0x1700 -#define GL_MODELVIEW1_EXT 0x850A -#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B -#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C -#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D -#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E -#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F -#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); -GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); -GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); -#endif -#endif /* GL_EXT_vertex_weighting */ - -#ifndef GL_EXT_x11_sync_object -#define GL_EXT_x11_sync_object 1 -#define GL_SYNC_X11_FENCE_EXT 0x90E1 -typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); -#endif -#endif /* GL_EXT_x11_sync_object */ - -#ifndef GL_GREMEDY_frame_terminator -#define GL_GREMEDY_frame_terminator 1 -typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); -#endif -#endif /* GL_GREMEDY_frame_terminator */ - -#ifndef GL_GREMEDY_string_marker -#define GL_GREMEDY_string_marker 1 -typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const void *string); -#endif -#endif /* GL_GREMEDY_string_marker */ - -#ifndef GL_HP_convolution_border_modes -#define GL_HP_convolution_border_modes 1 -#define GL_IGNORE_BORDER_HP 0x8150 -#define GL_CONSTANT_BORDER_HP 0x8151 -#define GL_REPLICATE_BORDER_HP 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 -#endif /* GL_HP_convolution_border_modes */ - -#ifndef GL_HP_image_transform -#define GL_HP_image_transform 1 -#define GL_IMAGE_SCALE_X_HP 0x8155 -#define GL_IMAGE_SCALE_Y_HP 0x8156 -#define GL_IMAGE_TRANSLATE_X_HP 0x8157 -#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 -#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 -#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A -#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B -#define GL_IMAGE_MAG_FILTER_HP 0x815C -#define GL_IMAGE_MIN_FILTER_HP 0x815D -#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E -#define GL_CUBIC_HP 0x815F -#define GL_AVERAGE_HP 0x8160 -#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 -#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 -#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); -#endif -#endif /* GL_HP_image_transform */ - -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 -#endif /* GL_HP_occlusion_test */ - -#ifndef GL_HP_texture_lighting -#define GL_HP_texture_lighting 1 -#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 -#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 -#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 -#endif /* GL_HP_texture_lighting */ - -#ifndef GL_IBM_cull_vertex -#define GL_IBM_cull_vertex 1 -#define GL_CULL_VERTEX_IBM 103050 -#endif /* GL_IBM_cull_vertex */ - -#ifndef GL_IBM_multimode_draw_arrays -#define GL_IBM_multimode_draw_arrays 1 -typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); -#endif -#endif /* GL_IBM_multimode_draw_arrays */ - -#ifndef GL_IBM_rasterpos_clip -#define GL_IBM_rasterpos_clip 1 -#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 -#endif /* GL_IBM_rasterpos_clip */ - -#ifndef GL_IBM_static_data -#define GL_IBM_static_data 1 -#define GL_ALL_STATIC_DATA_IBM 103060 -#define GL_STATIC_VERTEX_ARRAY_IBM 103061 -typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target); -#endif -#endif /* GL_IBM_static_data */ - -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_IBM_texture_mirrored_repeat 1 -#define GL_MIRRORED_REPEAT_IBM 0x8370 -#endif /* GL_IBM_texture_mirrored_repeat */ - -#ifndef GL_IBM_vertex_array_lists -#define GL_IBM_vertex_array_lists 1 -#define GL_VERTEX_ARRAY_LIST_IBM 103070 -#define GL_NORMAL_ARRAY_LIST_IBM 103071 -#define GL_COLOR_ARRAY_LIST_IBM 103072 -#define GL_INDEX_ARRAY_LIST_IBM 103073 -#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 -#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 -#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 -#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 -#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 -#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 -#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 -#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 -#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 -#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 -#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 -#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 -typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean **pointer, GLint ptrstride); -GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); -GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); -GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); -GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -#endif -#endif /* GL_IBM_vertex_array_lists */ - -#ifndef GL_INGR_blend_func_separate -#define GL_INGR_blend_func_separate 1 -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif -#endif /* GL_INGR_blend_func_separate */ - -#ifndef GL_INGR_color_clamp -#define GL_INGR_color_clamp 1 -#define GL_RED_MIN_CLAMP_INGR 0x8560 -#define GL_GREEN_MIN_CLAMP_INGR 0x8561 -#define GL_BLUE_MIN_CLAMP_INGR 0x8562 -#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 -#define GL_RED_MAX_CLAMP_INGR 0x8564 -#define GL_GREEN_MAX_CLAMP_INGR 0x8565 -#define GL_BLUE_MAX_CLAMP_INGR 0x8566 -#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 -#endif /* GL_INGR_color_clamp */ - -#ifndef GL_INGR_interlace_read -#define GL_INGR_interlace_read 1 -#define GL_INTERLACE_READ_INGR 0x8568 -#endif /* GL_INGR_interlace_read */ - -#ifndef GL_INTEL_fragment_shader_ordering -#define GL_INTEL_fragment_shader_ordering 1 -#endif /* GL_INTEL_fragment_shader_ordering */ - -#ifndef GL_INTEL_framebuffer_CMAA -#define GL_INTEL_framebuffer_CMAA 1 -typedef void (APIENTRYP PFNGLAPPLYFRAMEBUFFERATTACHMENTCMAAINTELPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glApplyFramebufferAttachmentCMAAINTEL (void); -#endif -#endif /* GL_INTEL_framebuffer_CMAA */ - -#ifndef GL_INTEL_map_texture -#define GL_INTEL_map_texture 1 -#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF -#define GL_LAYOUT_DEFAULT_INTEL 0 -#define GL_LAYOUT_LINEAR_INTEL 1 -#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 -typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); -typedef void *(APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture); -GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level); -GLAPI void *APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); -#endif -#endif /* GL_INTEL_map_texture */ - -#ifndef GL_INTEL_parallel_arrays -#define GL_INTEL_parallel_arrays 1 -#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 -#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 -#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 -#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 -#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 -typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void **pointer); -typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const void **pointer); -GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const void **pointer); -GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const void **pointer); -GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const void **pointer); -#endif -#endif /* GL_INTEL_parallel_arrays */ - -#ifndef GL_INTEL_performance_query -#define GL_INTEL_performance_query 1 -#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 -#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 -#define GL_PERFQUERY_WAIT_INTEL 0x83FB -#define GL_PERFQUERY_FLUSH_INTEL 0x83FA -#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 -#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 -#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 -#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 -#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 -#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 -#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 -#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 -#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 -#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA -#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB -#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC -#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD -#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE -#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF -#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 -typedef void (APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); -typedef void (APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); -typedef void (APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); -typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); -typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); -typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); -typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); -typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); -typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); -typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); -GLAPI void APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); -GLAPI void APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); -GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); -GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); -GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); -GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); -GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); -GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); -GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); -#endif -#endif /* GL_INTEL_performance_query */ - -#ifndef GL_MESAX_texture_stack -#define GL_MESAX_texture_stack 1 -#define GL_TEXTURE_1D_STACK_MESAX 0x8759 -#define GL_TEXTURE_2D_STACK_MESAX 0x875A -#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B -#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C -#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D -#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E -#endif /* GL_MESAX_texture_stack */ - -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 -#define GL_PACK_INVERT_MESA 0x8758 -#endif /* GL_MESA_pack_invert */ - -#ifndef GL_MESA_resize_buffers -#define GL_MESA_resize_buffers 1 -typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glResizeBuffersMESA (void); -#endif -#endif /* GL_MESA_resize_buffers */ - -#ifndef GL_MESA_window_pos -#define GL_MESA_window_pos 1 -typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); -GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); -GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); -#endif -#endif /* GL_MESA_window_pos */ - -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define GL_YCBCR_MESA 0x8757 -#endif /* GL_MESA_ycbcr_texture */ - -#ifndef GL_NVX_conditional_render -#define GL_NVX_conditional_render 1 -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id); -GLAPI void APIENTRY glEndConditionalRenderNVX (void); -#endif -#endif /* GL_NVX_conditional_render */ - -#ifndef GL_NVX_gpu_memory_info -#define GL_NVX_gpu_memory_info 1 -#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 -#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 -#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 -#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A -#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B -#endif /* GL_NVX_gpu_memory_info */ - -#ifndef GL_NV_bindless_multi_draw_indirect -#define GL_NV_bindless_multi_draw_indirect 1 -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); -GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); -#endif -#endif /* GL_NV_bindless_multi_draw_indirect */ - -#ifndef GL_NV_bindless_multi_draw_indirect_count -#define GL_NV_bindless_multi_draw_indirect_count 1 -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessCountNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); -GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessCountNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); -#endif -#endif /* GL_NV_bindless_multi_draw_indirect_count */ - -#ifndef GL_NV_bindless_texture -#define GL_NV_bindless_texture 1 -typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); -typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); -typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); -typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); -typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); -typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); -typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); -GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); -GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); -GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); -GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); -GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); -GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); -GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); -GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); -GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); -GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); -GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); -#endif -#endif /* GL_NV_bindless_texture */ - -#ifndef GL_NV_blend_equation_advanced -#define GL_NV_blend_equation_advanced 1 -#define GL_BLEND_OVERLAP_NV 0x9281 -#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 -#define GL_BLUE_NV 0x1905 -#define GL_COLORBURN_NV 0x929A -#define GL_COLORDODGE_NV 0x9299 -#define GL_CONJOINT_NV 0x9284 -#define GL_CONTRAST_NV 0x92A1 -#define GL_DARKEN_NV 0x9297 -#define GL_DIFFERENCE_NV 0x929E -#define GL_DISJOINT_NV 0x9283 -#define GL_DST_ATOP_NV 0x928F -#define GL_DST_IN_NV 0x928B -#define GL_DST_NV 0x9287 -#define GL_DST_OUT_NV 0x928D -#define GL_DST_OVER_NV 0x9289 -#define GL_EXCLUSION_NV 0x92A0 -#define GL_GREEN_NV 0x1904 -#define GL_HARDLIGHT_NV 0x929B -#define GL_HARDMIX_NV 0x92A9 -#define GL_HSL_COLOR_NV 0x92AF -#define GL_HSL_HUE_NV 0x92AD -#define GL_HSL_LUMINOSITY_NV 0x92B0 -#define GL_HSL_SATURATION_NV 0x92AE -#define GL_INVERT_OVG_NV 0x92B4 -#define GL_INVERT_RGB_NV 0x92A3 -#define GL_LIGHTEN_NV 0x9298 -#define GL_LINEARBURN_NV 0x92A5 -#define GL_LINEARDODGE_NV 0x92A4 -#define GL_LINEARLIGHT_NV 0x92A7 -#define GL_MINUS_CLAMPED_NV 0x92B3 -#define GL_MINUS_NV 0x929F -#define GL_MULTIPLY_NV 0x9294 -#define GL_OVERLAY_NV 0x9296 -#define GL_PINLIGHT_NV 0x92A8 -#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 -#define GL_PLUS_CLAMPED_NV 0x92B1 -#define GL_PLUS_DARKER_NV 0x9292 -#define GL_PLUS_NV 0x9291 -#define GL_RED_NV 0x1903 -#define GL_SCREEN_NV 0x9295 -#define GL_SOFTLIGHT_NV 0x929C -#define GL_SRC_ATOP_NV 0x928E -#define GL_SRC_IN_NV 0x928A -#define GL_SRC_NV 0x9286 -#define GL_SRC_OUT_NV 0x928C -#define GL_SRC_OVER_NV 0x9288 -#define GL_UNCORRELATED_NV 0x9282 -#define GL_VIVIDLIGHT_NV 0x92A6 -#define GL_XOR_NV 0x1506 -typedef void (APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendParameteriNV (GLenum pname, GLint value); -GLAPI void APIENTRY glBlendBarrierNV (void); -#endif -#endif /* GL_NV_blend_equation_advanced */ - -#ifndef GL_NV_blend_equation_advanced_coherent -#define GL_NV_blend_equation_advanced_coherent 1 -#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 -#endif /* GL_NV_blend_equation_advanced_coherent */ - -#ifndef GL_NV_blend_square -#define GL_NV_blend_square 1 -#endif /* GL_NV_blend_square */ - -#ifndef GL_NV_command_list -#define GL_NV_command_list 1 -#define GL_TERMINATE_SEQUENCE_COMMAND_NV 0x0000 -#define GL_NOP_COMMAND_NV 0x0001 -#define GL_DRAW_ELEMENTS_COMMAND_NV 0x0002 -#define GL_DRAW_ARRAYS_COMMAND_NV 0x0003 -#define GL_DRAW_ELEMENTS_STRIP_COMMAND_NV 0x0004 -#define GL_DRAW_ARRAYS_STRIP_COMMAND_NV 0x0005 -#define GL_DRAW_ELEMENTS_INSTANCED_COMMAND_NV 0x0006 -#define GL_DRAW_ARRAYS_INSTANCED_COMMAND_NV 0x0007 -#define GL_ELEMENT_ADDRESS_COMMAND_NV 0x0008 -#define GL_ATTRIBUTE_ADDRESS_COMMAND_NV 0x0009 -#define GL_UNIFORM_ADDRESS_COMMAND_NV 0x000A -#define GL_BLEND_COLOR_COMMAND_NV 0x000B -#define GL_STENCIL_REF_COMMAND_NV 0x000C -#define GL_LINE_WIDTH_COMMAND_NV 0x000D -#define GL_POLYGON_OFFSET_COMMAND_NV 0x000E -#define GL_ALPHA_REF_COMMAND_NV 0x000F -#define GL_VIEWPORT_COMMAND_NV 0x0010 -#define GL_SCISSOR_COMMAND_NV 0x0011 -#define GL_FRONT_FACE_COMMAND_NV 0x0012 -typedef void (APIENTRYP PFNGLCREATESTATESNVPROC) (GLsizei n, GLuint *states); -typedef void (APIENTRYP PFNGLDELETESTATESNVPROC) (GLsizei n, const GLuint *states); -typedef GLboolean (APIENTRYP PFNGLISSTATENVPROC) (GLuint state); -typedef void (APIENTRYP PFNGLSTATECAPTURENVPROC) (GLuint state, GLenum mode); -typedef GLuint (APIENTRYP PFNGLGETCOMMANDHEADERNVPROC) (GLenum tokenID, GLuint size); -typedef GLushort (APIENTRYP PFNGLGETSTAGEINDEXNVPROC) (GLenum shadertype); -typedef void (APIENTRYP PFNGLDRAWCOMMANDSNVPROC) (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); -typedef void (APIENTRYP PFNGLDRAWCOMMANDSADDRESSNVPROC) (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); -typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESNVPROC) (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); -typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESADDRESSNVPROC) (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); -typedef void (APIENTRYP PFNGLCREATECOMMANDLISTSNVPROC) (GLsizei n, GLuint *lists); -typedef void (APIENTRYP PFNGLDELETECOMMANDLISTSNVPROC) (GLsizei n, const GLuint *lists); -typedef GLboolean (APIENTRYP PFNGLISCOMMANDLISTNVPROC) (GLuint list); -typedef void (APIENTRYP PFNGLLISTDRAWCOMMANDSSTATESCLIENTNVPROC) (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); -typedef void (APIENTRYP PFNGLCOMMANDLISTSEGMENTSNVPROC) (GLuint list, GLuint segments); -typedef void (APIENTRYP PFNGLCOMPILECOMMANDLISTNVPROC) (GLuint list); -typedef void (APIENTRYP PFNGLCALLCOMMANDLISTNVPROC) (GLuint list); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCreateStatesNV (GLsizei n, GLuint *states); -GLAPI void APIENTRY glDeleteStatesNV (GLsizei n, const GLuint *states); -GLAPI GLboolean APIENTRY glIsStateNV (GLuint state); -GLAPI void APIENTRY glStateCaptureNV (GLuint state, GLenum mode); -GLAPI GLuint APIENTRY glGetCommandHeaderNV (GLenum tokenID, GLuint size); -GLAPI GLushort APIENTRY glGetStageIndexNV (GLenum shadertype); -GLAPI void APIENTRY glDrawCommandsNV (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); -GLAPI void APIENTRY glDrawCommandsAddressNV (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); -GLAPI void APIENTRY glDrawCommandsStatesNV (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); -GLAPI void APIENTRY glDrawCommandsStatesAddressNV (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); -GLAPI void APIENTRY glCreateCommandListsNV (GLsizei n, GLuint *lists); -GLAPI void APIENTRY glDeleteCommandListsNV (GLsizei n, const GLuint *lists); -GLAPI GLboolean APIENTRY glIsCommandListNV (GLuint list); -GLAPI void APIENTRY glListDrawCommandsStatesClientNV (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); -GLAPI void APIENTRY glCommandListSegmentsNV (GLuint list, GLuint segments); -GLAPI void APIENTRY glCompileCommandListNV (GLuint list); -GLAPI void APIENTRY glCallCommandListNV (GLuint list); -#endif -#endif /* GL_NV_command_list */ - -#ifndef GL_NV_compute_program5 -#define GL_NV_compute_program5 1 -#define GL_COMPUTE_PROGRAM_NV 0x90FB -#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC -#endif /* GL_NV_compute_program5 */ - -#ifndef GL_NV_conditional_render -#define GL_NV_conditional_render 1 -#define GL_QUERY_WAIT_NV 0x8E13 -#define GL_QUERY_NO_WAIT_NV 0x8E14 -#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); -GLAPI void APIENTRY glEndConditionalRenderNV (void); -#endif -#endif /* GL_NV_conditional_render */ - -#ifndef GL_NV_conservative_raster -#define GL_NV_conservative_raster 1 -#define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 -#define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 -#define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 -#define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 -typedef void (APIENTRYP PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSubpixelPrecisionBiasNV (GLuint xbits, GLuint ybits); -#endif -#endif /* GL_NV_conservative_raster */ - -#ifndef GL_NV_conservative_raster_dilate -#define GL_NV_conservative_raster_dilate 1 -#define GL_CONSERVATIVE_RASTER_DILATE_NV 0x9379 -#define GL_CONSERVATIVE_RASTER_DILATE_RANGE_NV 0x937A -#define GL_CONSERVATIVE_RASTER_DILATE_GRANULARITY_NV 0x937B -typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERFNVPROC) (GLenum pname, GLfloat value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glConservativeRasterParameterfNV (GLenum pname, GLfloat value); -#endif -#endif /* GL_NV_conservative_raster_dilate */ - -#ifndef GL_NV_copy_depth_to_color -#define GL_NV_copy_depth_to_color 1 -#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F -#endif /* GL_NV_copy_depth_to_color */ - -#ifndef GL_NV_copy_image -#define GL_NV_copy_image 1 -typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -#endif -#endif /* GL_NV_copy_image */ - -#ifndef GL_NV_deep_texture3D -#define GL_NV_deep_texture3D 1 -#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 -#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 -#endif /* GL_NV_deep_texture3D */ - -#ifndef GL_NV_depth_buffer_float -#define GL_NV_depth_buffer_float 1 -#define GL_DEPTH_COMPONENT32F_NV 0x8DAB -#define GL_DEPTH32F_STENCIL8_NV 0x8DAC -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD -#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF -typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); -typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); -GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); -#endif -#endif /* GL_NV_depth_buffer_float */ - -#ifndef GL_NV_depth_clamp -#define GL_NV_depth_clamp 1 -#define GL_DEPTH_CLAMP_NV 0x864F -#endif /* GL_NV_depth_clamp */ - -#ifndef GL_NV_draw_texture -#define GL_NV_draw_texture 1 -typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); -#endif -#endif /* GL_NV_draw_texture */ - -#ifndef GL_NV_evaluators -#define GL_NV_evaluators 1 -#define GL_EVAL_2D_NV 0x86C0 -#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 -#define GL_MAP_TESSELLATION_NV 0x86C2 -#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 -#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 -#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 -#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 -#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 -#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 -#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 -#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA -#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB -#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC -#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD -#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE -#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF -#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 -#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 -#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 -#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 -#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 -#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 -#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 -#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 -typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); -typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); -GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); -GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); -#endif -#endif /* GL_NV_evaluators */ - -#ifndef GL_NV_explicit_multisample -#define GL_NV_explicit_multisample 1 -#define GL_SAMPLE_POSITION_NV 0x8E50 -#define GL_SAMPLE_MASK_NV 0x8E51 -#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 -#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 -#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 -#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 -#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 -#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 -#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 -#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); -typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); -GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); -GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); -#endif -#endif /* GL_NV_explicit_multisample */ - -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); -GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); -GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); -GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); -GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); -GLAPI void APIENTRY glFinishFenceNV (GLuint fence); -GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); -#endif -#endif /* GL_NV_fence */ - -#ifndef GL_NV_fill_rectangle -#define GL_NV_fill_rectangle 1 -#define GL_FILL_RECTANGLE_NV 0x933C -#endif /* GL_NV_fill_rectangle */ - -#ifndef GL_NV_float_buffer -#define GL_NV_float_buffer 1 -#define GL_FLOAT_R_NV 0x8880 -#define GL_FLOAT_RG_NV 0x8881 -#define GL_FLOAT_RGB_NV 0x8882 -#define GL_FLOAT_RGBA_NV 0x8883 -#define GL_FLOAT_R16_NV 0x8884 -#define GL_FLOAT_R32_NV 0x8885 -#define GL_FLOAT_RG16_NV 0x8886 -#define GL_FLOAT_RG32_NV 0x8887 -#define GL_FLOAT_RGB16_NV 0x8888 -#define GL_FLOAT_RGB32_NV 0x8889 -#define GL_FLOAT_RGBA16_NV 0x888A -#define GL_FLOAT_RGBA32_NV 0x888B -#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C -#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D -#define GL_FLOAT_RGBA_MODE_NV 0x888E -#endif /* GL_NV_float_buffer */ - -#ifndef GL_NV_fog_distance -#define GL_NV_fog_distance 1 -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C -#endif /* GL_NV_fog_distance */ - -#ifndef GL_NV_fragment_coverage_to_color -#define GL_NV_fragment_coverage_to_color 1 -#define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD -#define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE -typedef void (APIENTRYP PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFragmentCoverageColorNV (GLuint color); -#endif -#endif /* GL_NV_fragment_coverage_to_color */ - -#ifndef GL_NV_fragment_program -#define GL_NV_fragment_program 1 -#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 -#define GL_FRAGMENT_PROGRAM_NV 0x8870 -#define GL_MAX_TEXTURE_COORDS_NV 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 -#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 -#define GL_PROGRAM_ERROR_STRING_NV 0x8874 -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#endif -#endif /* GL_NV_fragment_program */ - -#ifndef GL_NV_fragment_program2 -#define GL_NV_fragment_program2 1 -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 -#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 -#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 -#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 -#endif /* GL_NV_fragment_program2 */ - -#ifndef GL_NV_fragment_program4 -#define GL_NV_fragment_program4 1 -#endif /* GL_NV_fragment_program4 */ - -#ifndef GL_NV_fragment_program_option -#define GL_NV_fragment_program_option 1 -#endif /* GL_NV_fragment_program_option */ - -#ifndef GL_NV_fragment_shader_interlock -#define GL_NV_fragment_shader_interlock 1 -#endif /* GL_NV_fragment_shader_interlock */ - -#ifndef GL_NV_framebuffer_mixed_samples -#define GL_NV_framebuffer_mixed_samples 1 -#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 -#define GL_COLOR_SAMPLES_NV 0x8E20 -#define GL_DEPTH_SAMPLES_NV 0x932D -#define GL_STENCIL_SAMPLES_NV 0x932E -#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F -#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 -#define GL_COVERAGE_MODULATION_NV 0x9332 -#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 -typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat *v); -typedef void (APIENTRYP PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufsize, GLfloat *v); -typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCoverageModulationTableNV (GLsizei n, const GLfloat *v); -GLAPI void APIENTRY glGetCoverageModulationTableNV (GLsizei bufsize, GLfloat *v); -GLAPI void APIENTRY glCoverageModulationNV (GLenum components); -#endif -#endif /* GL_NV_framebuffer_mixed_samples */ - -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_NV_framebuffer_multisample_coverage 1 -#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB -#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 -#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 -#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -#endif -#endif /* GL_NV_framebuffer_multisample_coverage */ - -#ifndef GL_NV_geometry_program4 -#define GL_NV_geometry_program4 1 -#define GL_GEOMETRY_PROGRAM_NV 0x8C26 -#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 -#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 -typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); -GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif -#endif /* GL_NV_geometry_program4 */ - -#ifndef GL_NV_geometry_shader4 -#define GL_NV_geometry_shader4 1 -#endif /* GL_NV_geometry_shader4 */ - -#ifndef GL_NV_geometry_shader_passthrough -#define GL_NV_geometry_shader_passthrough 1 -#endif /* GL_NV_geometry_shader_passthrough */ - -#ifndef GL_NV_gpu_program4 -#define GL_NV_gpu_program4 1 -#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 -#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 -#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 -#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 -#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 -#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 -#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); -GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); -#endif -#endif /* GL_NV_gpu_program4 */ - -#ifndef GL_NV_gpu_program5 -#define GL_NV_gpu_program5 1 -#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C -#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F -#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 -#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 -typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); -#endif -#endif /* GL_NV_gpu_program5 */ - -#ifndef GL_NV_gpu_program5_mem_extended -#define GL_NV_gpu_program5_mem_extended 1 -#endif /* GL_NV_gpu_program5_mem_extended */ - -#ifndef GL_NV_gpu_shader5 -#define GL_NV_gpu_shader5 1 -#endif /* GL_NV_gpu_shader5 */ - -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 -typedef unsigned short GLhalfNV; -#define GL_HALF_FLOAT_NV 0x140B -typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); -typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); -typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); -GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); -GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); -GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); -GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); -GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); -GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); -GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); -GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); -GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); -GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); -GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); -GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); -GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -#endif -#endif /* GL_NV_half_float */ - -#ifndef GL_NV_internalformat_sample_query -#define GL_NV_internalformat_sample_query 1 -#define GL_MULTISAMPLES_NV 0x9371 -#define GL_SUPERSAMPLE_SCALE_X_NV 0x9372 -#define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 -#define GL_CONFORMANT_NV 0x9374 -typedef void (APIENTRYP PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei bufSize, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetInternalformatSampleivNV (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei bufSize, GLint *params); -#endif -#endif /* GL_NV_internalformat_sample_query */ - -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent 1 -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 -#endif /* GL_NV_light_max_exponent */ - -#ifndef GL_NV_multisample_coverage -#define GL_NV_multisample_coverage 1 -#endif /* GL_NV_multisample_coverage */ - -#ifndef GL_NV_multisample_filter_hint -#define GL_NV_multisample_filter_hint 1 -#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 -#endif /* GL_NV_multisample_filter_hint */ - -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 -typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); -GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); -GLAPI void APIENTRY glEndOcclusionQueryNV (void); -GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); -#endif -#endif /* GL_NV_occlusion_query */ - -#ifndef GL_NV_packed_depth_stencil -#define GL_NV_packed_depth_stencil 1 -#define GL_DEPTH_STENCIL_NV 0x84F9 -#define GL_UNSIGNED_INT_24_8_NV 0x84FA -#endif /* GL_NV_packed_depth_stencil */ - -#ifndef GL_NV_parameter_buffer_object -#define GL_NV_parameter_buffer_object 1 -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 -#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 -#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 -#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); -#endif -#endif /* GL_NV_parameter_buffer_object */ - -#ifndef GL_NV_parameter_buffer_object2 -#define GL_NV_parameter_buffer_object2 1 -#endif /* GL_NV_parameter_buffer_object2 */ - -#ifndef GL_NV_path_rendering -#define GL_NV_path_rendering 1 -#define GL_PATH_FORMAT_SVG_NV 0x9070 -#define GL_PATH_FORMAT_PS_NV 0x9071 -#define GL_STANDARD_FONT_NAME_NV 0x9072 -#define GL_SYSTEM_FONT_NAME_NV 0x9073 -#define GL_FILE_NAME_NV 0x9074 -#define GL_PATH_STROKE_WIDTH_NV 0x9075 -#define GL_PATH_END_CAPS_NV 0x9076 -#define GL_PATH_INITIAL_END_CAP_NV 0x9077 -#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 -#define GL_PATH_JOIN_STYLE_NV 0x9079 -#define GL_PATH_MITER_LIMIT_NV 0x907A -#define GL_PATH_DASH_CAPS_NV 0x907B -#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C -#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D -#define GL_PATH_DASH_OFFSET_NV 0x907E -#define GL_PATH_CLIENT_LENGTH_NV 0x907F -#define GL_PATH_FILL_MODE_NV 0x9080 -#define GL_PATH_FILL_MASK_NV 0x9081 -#define GL_PATH_FILL_COVER_MODE_NV 0x9082 -#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 -#define GL_PATH_STROKE_MASK_NV 0x9084 -#define GL_COUNT_UP_NV 0x9088 -#define GL_COUNT_DOWN_NV 0x9089 -#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A -#define GL_CONVEX_HULL_NV 0x908B -#define GL_BOUNDING_BOX_NV 0x908D -#define GL_TRANSLATE_X_NV 0x908E -#define GL_TRANSLATE_Y_NV 0x908F -#define GL_TRANSLATE_2D_NV 0x9090 -#define GL_TRANSLATE_3D_NV 0x9091 -#define GL_AFFINE_2D_NV 0x9092 -#define GL_AFFINE_3D_NV 0x9094 -#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 -#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 -#define GL_UTF8_NV 0x909A -#define GL_UTF16_NV 0x909B -#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C -#define GL_PATH_COMMAND_COUNT_NV 0x909D -#define GL_PATH_COORD_COUNT_NV 0x909E -#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F -#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 -#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 -#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 -#define GL_SQUARE_NV 0x90A3 -#define GL_ROUND_NV 0x90A4 -#define GL_TRIANGULAR_NV 0x90A5 -#define GL_BEVEL_NV 0x90A6 -#define GL_MITER_REVERT_NV 0x90A7 -#define GL_MITER_TRUNCATE_NV 0x90A8 -#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 -#define GL_USE_MISSING_GLYPH_NV 0x90AA -#define GL_PATH_ERROR_POSITION_NV 0x90AB -#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD -#define GL_ADJACENT_PAIRS_NV 0x90AE -#define GL_FIRST_TO_REST_NV 0x90AF -#define GL_PATH_GEN_MODE_NV 0x90B0 -#define GL_PATH_GEN_COEFF_NV 0x90B1 -#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 -#define GL_PATH_STENCIL_FUNC_NV 0x90B7 -#define GL_PATH_STENCIL_REF_NV 0x90B8 -#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 -#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD -#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE -#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF -#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 -#define GL_MOVE_TO_RESETS_NV 0x90B5 -#define GL_MOVE_TO_CONTINUES_NV 0x90B6 -#define GL_CLOSE_PATH_NV 0x00 -#define GL_MOVE_TO_NV 0x02 -#define GL_RELATIVE_MOVE_TO_NV 0x03 -#define GL_LINE_TO_NV 0x04 -#define GL_RELATIVE_LINE_TO_NV 0x05 -#define GL_HORIZONTAL_LINE_TO_NV 0x06 -#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 -#define GL_VERTICAL_LINE_TO_NV 0x08 -#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 -#define GL_QUADRATIC_CURVE_TO_NV 0x0A -#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B -#define GL_CUBIC_CURVE_TO_NV 0x0C -#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D -#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E -#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F -#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 -#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 -#define GL_SMALL_CCW_ARC_TO_NV 0x12 -#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 -#define GL_SMALL_CW_ARC_TO_NV 0x14 -#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 -#define GL_LARGE_CCW_ARC_TO_NV 0x16 -#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 -#define GL_LARGE_CW_ARC_TO_NV 0x18 -#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 -#define GL_RESTART_PATH_NV 0xF0 -#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 -#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 -#define GL_RECT_NV 0xF6 -#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 -#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA -#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC -#define GL_ARC_TO_NV 0xFE -#define GL_RELATIVE_ARC_TO_NV 0xFF -#define GL_BOLD_BIT_NV 0x01 -#define GL_ITALIC_BIT_NV 0x02 -#define GL_GLYPH_WIDTH_BIT_NV 0x01 -#define GL_GLYPH_HEIGHT_BIT_NV 0x02 -#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 -#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 -#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 -#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 -#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 -#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 -#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 -#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 -#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 -#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 -#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 -#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 -#define GL_FONT_ASCENDER_BIT_NV 0x00200000 -#define GL_FONT_DESCENDER_BIT_NV 0x00400000 -#define GL_FONT_HEIGHT_BIT_NV 0x00800000 -#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 -#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 -#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 -#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 -#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 -#define GL_ROUNDED_RECT_NV 0xE8 -#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 -#define GL_ROUNDED_RECT2_NV 0xEA -#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB -#define GL_ROUNDED_RECT4_NV 0xEC -#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED -#define GL_ROUNDED_RECT8_NV 0xEE -#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF -#define GL_RELATIVE_RECT_NV 0xF7 -#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 -#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 -#define GL_FONT_UNAVAILABLE_NV 0x936A -#define GL_FONT_UNINTELLIGIBLE_NV 0x936B -#define GL_CONIC_CURVE_TO_NV 0x1A -#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B -#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 -#define GL_STANDARD_FONT_FORMAT_NV 0x936C -#define GL_2_BYTES_NV 0x1407 -#define GL_3_BYTES_NV 0x1408 -#define GL_4_BYTES_NV 0x1409 -#define GL_EYE_LINEAR_NV 0x2400 -#define GL_OBJECT_LINEAR_NV 0x2401 -#define GL_CONSTANT_NV 0x8576 -#define GL_PATH_FOG_GEN_MODE_NV 0x90AC -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 -#define GL_PATH_PROJECTION_NV 0x1701 -#define GL_PATH_MODELVIEW_NV 0x1700 -#define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3 -#define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6 -#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36 -#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3 -#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4 -#define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7 -#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38 -#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4 -#define GL_FRAGMENT_INPUT_NV 0x936D -typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); -typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); -typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); -typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); -typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); -typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); -typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); -typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); -typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); -typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); -typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); -typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); -typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); -typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); -typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); -typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); -typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); -typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); -typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); -typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); -typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); -typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); -typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); -typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); -typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); -typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); -typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); -typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); -typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); -typedef void (APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); -typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); -typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode); -typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]); -typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef GLenum (APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef void (APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); -typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLfloat *params); -typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); -typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); -typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); -typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); -typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); -typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); -typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); -GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); -GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); -GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); -GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); -GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); -GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); -GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); -GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); -GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); -GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); -GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); -GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); -GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); -GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); -GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); -GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); -GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); -GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); -GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); -GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); -GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); -GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); -GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); -GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); -GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); -GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); -GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); -GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); -GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); -GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); -GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); -GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); -GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); -GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); -GLAPI void APIENTRY glMatrixLoad3x2fNV (GLenum matrixMode, const GLfloat *m); -GLAPI void APIENTRY glMatrixLoad3x3fNV (GLenum matrixMode, const GLfloat *m); -GLAPI void APIENTRY glMatrixLoadTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); -GLAPI void APIENTRY glMatrixMult3x2fNV (GLenum matrixMode, const GLfloat *m); -GLAPI void APIENTRY glMatrixMult3x3fNV (GLenum matrixMode, const GLfloat *m); -GLAPI void APIENTRY glMatrixMultTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); -GLAPI void APIENTRY glStencilThenCoverFillPathNV (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); -GLAPI void APIENTRY glStencilThenCoverStrokePathNV (GLuint path, GLint reference, GLuint mask, GLenum coverMode); -GLAPI void APIENTRY glStencilThenCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glStencilThenCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -GLAPI GLenum APIENTRY glPathGlyphIndexRangeNV (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]); -GLAPI GLenum APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -GLAPI GLenum APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -GLAPI void APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); -GLAPI void APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLfloat *params); -GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); -GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); -GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); -GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); -GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); -GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); -GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); -#endif -#endif /* GL_NV_path_rendering */ - -#ifndef GL_NV_path_rendering_shared_edge -#define GL_NV_path_rendering_shared_edge 1 -#define GL_SHARED_EDGE_NV 0xC0 -#endif /* GL_NV_path_rendering_shared_edge */ - -#ifndef GL_NV_pixel_data_range -#define GL_NV_pixel_data_range 1 -#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 -#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 -#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A -#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B -#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C -#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D -typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const void *pointer); -typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const void *pointer); -GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); -#endif -#endif /* GL_NV_pixel_data_range */ - -#ifndef GL_NV_point_sprite -#define GL_NV_point_sprite 1 -#define GL_POINT_SPRITE_NV 0x8861 -#define GL_COORD_REPLACE_NV 0x8862 -#define GL_POINT_SPRITE_R_MODE_NV 0x8863 -typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); -GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); -#endif -#endif /* GL_NV_point_sprite */ - -#ifndef GL_NV_present_video -#define GL_NV_present_video 1 -#define GL_FRAME_NV 0x8E26 -#define GL_FIELDS_NV 0x8E27 -#define GL_CURRENT_TIME_NV 0x8E28 -#define GL_NUM_FILL_STREAMS_NV 0x8E29 -#define GL_PRESENT_TIME_NV 0x8E2A -#define GL_PRESENT_DURATION_NV 0x8E2B -typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); -typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); -typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); -GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); -GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); -GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); -#endif -#endif /* GL_NV_present_video */ - -#ifndef GL_NV_primitive_restart -#define GL_NV_primitive_restart 1 -#define GL_PRIMITIVE_RESTART_NV 0x8558 -#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPrimitiveRestartNV (void); -GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); -#endif -#endif /* GL_NV_primitive_restart */ - -#ifndef GL_NV_register_combiners -#define GL_NV_register_combiners 1 -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); -GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); -GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); -GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); -#endif -#endif /* GL_NV_register_combiners */ - -#ifndef GL_NV_register_combiners2 -#define GL_NV_register_combiners2 1 -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 -typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); -#endif -#endif /* GL_NV_register_combiners2 */ - -#ifndef GL_NV_sample_locations -#define GL_NV_sample_locations 1 -#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D -#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E -#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F -#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 -#define GL_SAMPLE_LOCATION_NV 0x8E50 -#define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 -#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 -#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 -typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLRESOLVEDEPTHVALUESNVPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFramebufferSampleLocationsfvNV (GLenum target, GLuint start, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvNV (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glResolveDepthValuesNV (void); -#endif -#endif /* GL_NV_sample_locations */ - -#ifndef GL_NV_sample_mask_override_coverage -#define GL_NV_sample_mask_override_coverage 1 -#endif /* GL_NV_sample_mask_override_coverage */ - -#ifndef GL_NV_shader_atomic_counters -#define GL_NV_shader_atomic_counters 1 -#endif /* GL_NV_shader_atomic_counters */ - -#ifndef GL_NV_shader_atomic_float -#define GL_NV_shader_atomic_float 1 -#endif /* GL_NV_shader_atomic_float */ - -#ifndef GL_NV_shader_atomic_fp16_vector -#define GL_NV_shader_atomic_fp16_vector 1 -#endif /* GL_NV_shader_atomic_fp16_vector */ - -#ifndef GL_NV_shader_atomic_int64 -#define GL_NV_shader_atomic_int64 1 -#endif /* GL_NV_shader_atomic_int64 */ - -#ifndef GL_NV_shader_buffer_load -#define GL_NV_shader_buffer_load 1 -#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D -#define GL_GPU_ADDRESS_NV 0x8F34 -#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 -typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); -typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); -typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); -typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); -typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); -typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); -typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); -typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); -GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); -GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); -GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); -GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); -GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); -GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); -GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); -GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); -GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif -#endif /* GL_NV_shader_buffer_load */ - -#ifndef GL_NV_shader_buffer_store -#define GL_NV_shader_buffer_store 1 -#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 -#endif /* GL_NV_shader_buffer_store */ - -#ifndef GL_NV_shader_storage_buffer_object -#define GL_NV_shader_storage_buffer_object 1 -#endif /* GL_NV_shader_storage_buffer_object */ - -#ifndef GL_NV_shader_thread_group -#define GL_NV_shader_thread_group 1 -#define GL_WARP_SIZE_NV 0x9339 -#define GL_WARPS_PER_SM_NV 0x933A -#define GL_SM_COUNT_NV 0x933B -#endif /* GL_NV_shader_thread_group */ - -#ifndef GL_NV_shader_thread_shuffle -#define GL_NV_shader_thread_shuffle 1 -#endif /* GL_NV_shader_thread_shuffle */ - -#ifndef GL_NV_tessellation_program5 -#define GL_NV_tessellation_program5 1 -#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 -#define GL_TESS_CONTROL_PROGRAM_NV 0x891E -#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F -#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 -#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 -#endif /* GL_NV_tessellation_program5 */ - -#ifndef GL_NV_texgen_emboss -#define GL_NV_texgen_emboss 1 -#define GL_EMBOSS_LIGHT_NV 0x855D -#define GL_EMBOSS_CONSTANT_NV 0x855E -#define GL_EMBOSS_MAP_NV 0x855F -#endif /* GL_NV_texgen_emboss */ - -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 -#endif /* GL_NV_texgen_reflection */ - -#ifndef GL_NV_texture_barrier -#define GL_NV_texture_barrier 1 -typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureBarrierNV (void); -#endif -#endif /* GL_NV_texture_barrier */ - -#ifndef GL_NV_texture_compression_vtc -#define GL_NV_texture_compression_vtc 1 -#endif /* GL_NV_texture_compression_vtc */ - -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B -#endif /* GL_NV_texture_env_combine4 */ - -#ifndef GL_NV_texture_expand_normal -#define GL_NV_texture_expand_normal 1 -#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F -#endif /* GL_NV_texture_expand_normal */ - -#ifndef GL_NV_texture_multisample -#define GL_NV_texture_multisample 1 -#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 -#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 -typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -#endif -#endif /* GL_NV_texture_multisample */ - -#ifndef GL_NV_texture_rectangle -#define GL_NV_texture_rectangle 1 -#define GL_TEXTURE_RECTANGLE_NV 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 -#endif /* GL_NV_texture_rectangle */ - -#ifndef GL_NV_texture_shader -#define GL_NV_texture_shader 1 -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F -#endif /* GL_NV_texture_shader */ - -#ifndef GL_NV_texture_shader2 -#define GL_NV_texture_shader2 1 -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#endif /* GL_NV_texture_shader2 */ - -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 -#endif /* GL_NV_texture_shader3 */ - -#ifndef GL_NV_transform_feedback -#define GL_NV_transform_feedback 1 -#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 -#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 -#define GL_TEXTURE_COORD_NV 0x8C79 -#define GL_CLIP_DISTANCE_NV 0x8C7A -#define GL_VERTEX_ID_NV 0x8C7B -#define GL_PRIMITIVE_ID_NV 0x8C7C -#define GL_GENERIC_ATTRIB_NV 0x8C7D -#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 -#define GL_ACTIVE_VARYINGS_NV 0x8C81 -#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 -#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 -#define GL_PRIMITIVES_GENERATED_NV 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 -#define GL_RASTERIZER_DISCARD_NV 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B -#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C -#define GL_SEPARATE_ATTRIBS_NV 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F -#define GL_LAYER_NV 0x8DAA -#define GL_NEXT_BUFFER_NV -2 -#define GL_SKIP_COMPONENTS4_NV -3 -#define GL_SKIP_COMPONENTS3_NV -4 -#define GL_SKIP_COMPONENTS2_NV -5 -#define GL_SKIP_COMPONENTS1_NV -6 -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLenum bufferMode); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedbackNV (void); -GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLsizei count, const GLint *attribs, GLenum bufferMode); -GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); -GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); -GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); -#endif -#endif /* GL_NV_transform_feedback */ - -#ifndef GL_NV_transform_feedback2 -#define GL_NV_transform_feedback2 1 -#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); -GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); -GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); -GLAPI void APIENTRY glPauseTransformFeedbackNV (void); -GLAPI void APIENTRY glResumeTransformFeedbackNV (void); -GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); -#endif -#endif /* GL_NV_transform_feedback2 */ - -#ifndef GL_NV_uniform_buffer_unified_memory -#define GL_NV_uniform_buffer_unified_memory 1 -#define GL_UNIFORM_BUFFER_UNIFIED_NV 0x936E -#define GL_UNIFORM_BUFFER_ADDRESS_NV 0x936F -#define GL_UNIFORM_BUFFER_LENGTH_NV 0x9370 -#endif /* GL_NV_uniform_buffer_unified_memory */ - -#ifndef GL_NV_vdpau_interop -#define GL_NV_vdpau_interop 1 -typedef GLintptr GLvdpauSurfaceNV; -#define GL_SURFACE_STATE_NV 0x86EB -#define GL_SURFACE_REGISTERED_NV 0x86FD -#define GL_SURFACE_MAPPED_NV 0x8700 -#define GL_WRITE_DISCARD_NV 0x88BE -typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const void *vdpDevice, const void *getProcAddress); -typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); -typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -typedef GLboolean (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); -typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); -typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); -typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); -typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVDPAUInitNV (const void *vdpDevice, const void *getProcAddress); -GLAPI void APIENTRY glVDPAUFiniNV (void); -GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -GLAPI GLboolean APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); -GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); -GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); -GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); -GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); -#endif -#endif /* GL_NV_vdpau_interop */ - -#ifndef GL_NV_vertex_array_range -#define GL_NV_vertex_array_range 1 -#define GL_VERTEX_ARRAY_RANGE_NV 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E -#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); -GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const void *pointer); -#endif -#endif /* GL_NV_vertex_array_range */ - -#ifndef GL_NV_vertex_array_range2 -#define GL_NV_vertex_array_range2 1 -#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 -#endif /* GL_NV_vertex_array_range2 */ - -#ifndef GL_NV_vertex_attrib_integer_64bit -#define GL_NV_vertex_attrib_integer_64bit 1 -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); -GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); -GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); -#endif -#endif /* GL_NV_vertex_attrib_integer_64bit */ - -#ifndef GL_NV_vertex_buffer_unified_memory -#define GL_NV_vertex_buffer_unified_memory 1 -#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E -#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F -#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 -#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 -#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 -#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 -#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 -#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 -#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 -#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 -#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 -#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 -#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A -#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B -#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C -#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D -#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E -#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F -#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 -#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 -#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 -#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 -#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 -#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 -#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 -typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); -typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); -GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); -GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); -GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); -#endif -#endif /* GL_NV_vertex_buffer_unified_memory */ - -#ifndef GL_NV_vertex_program -#define GL_NV_vertex_program 1 -#define GL_VERTEX_PROGRAM_NV 0x8620 -#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 -#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 -#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 -#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 -#define GL_CURRENT_ATTRIB_NV 0x8626 -#define GL_PROGRAM_LENGTH_NV 0x8627 -#define GL_PROGRAM_STRING_NV 0x8628 -#define GL_MODELVIEW_PROJECTION_NV 0x8629 -#define GL_IDENTITY_NV 0x862A -#define GL_INVERSE_NV 0x862B -#define GL_TRANSPOSE_NV 0x862C -#define GL_INVERSE_TRANSPOSE_NV 0x862D -#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E -#define GL_MAX_TRACK_MATRICES_NV 0x862F -#define GL_MATRIX0_NV 0x8630 -#define GL_MATRIX1_NV 0x8631 -#define GL_MATRIX2_NV 0x8632 -#define GL_MATRIX3_NV 0x8633 -#define GL_MATRIX4_NV 0x8634 -#define GL_MATRIX5_NV 0x8635 -#define GL_MATRIX6_NV 0x8636 -#define GL_MATRIX7_NV 0x8637 -#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 -#define GL_CURRENT_MATRIX_NV 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 -#define GL_PROGRAM_PARAMETER_NV 0x8644 -#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 -#define GL_PROGRAM_TARGET_NV 0x8646 -#define GL_PROGRAM_RESIDENT_NV 0x8647 -#define GL_TRACK_MATRIX_NV 0x8648 -#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 -#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A -#define GL_PROGRAM_ERROR_POSITION_NV 0x864B -#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 -#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 -#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 -#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 -#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 -#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 -#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 -#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 -#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 -#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 -#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A -#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B -#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C -#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D -#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E -#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F -#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 -#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 -#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 -#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 -#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 -#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 -#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 -#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 -#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 -#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 -#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A -#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B -#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C -#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D -#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E -#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F -#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 -#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 -#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 -#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 -#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 -#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 -#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 -#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 -#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 -#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 -#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A -#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B -#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C -#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D -#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E -#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F -typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); -typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); -typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, void **pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); -GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); -GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); -GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); -GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, void **pointer); -GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); -GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); -GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); -GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); -GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); -#endif -#endif /* GL_NV_vertex_program */ - -#ifndef GL_NV_vertex_program1_1 -#define GL_NV_vertex_program1_1 1 -#endif /* GL_NV_vertex_program1_1 */ - -#ifndef GL_NV_vertex_program2 -#define GL_NV_vertex_program2 1 -#endif /* GL_NV_vertex_program2 */ - -#ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option 1 -#endif /* GL_NV_vertex_program2_option */ - -#ifndef GL_NV_vertex_program3 -#define GL_NV_vertex_program3 1 -#endif /* GL_NV_vertex_program3 */ - -#ifndef GL_NV_vertex_program4 -#define GL_NV_vertex_program4 1 -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); -GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); -GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); -GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); -GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); -GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); -#endif -#endif /* GL_NV_vertex_program4 */ - -#ifndef GL_NV_video_capture -#define GL_NV_video_capture 1 -#define GL_VIDEO_BUFFER_NV 0x9020 -#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 -#define GL_FIELD_UPPER_NV 0x9022 -#define GL_FIELD_LOWER_NV 0x9023 -#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 -#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 -#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 -#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 -#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 -#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 -#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A -#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B -#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C -#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D -#define GL_PARTIAL_SUCCESS_NV 0x902E -#define GL_SUCCESS_NV 0x902F -#define GL_FAILURE_NV 0x9030 -#define GL_YCBYCR8_422_NV 0x9031 -#define GL_YCBAYCR8A_4224_NV 0x9032 -#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 -#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 -#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 -#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 -#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 -#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 -#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 -#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A -#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B -#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C -typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); -typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); -typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); -typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); -GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); -GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); -GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); -GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); -GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); -GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); -GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); -#endif -#endif /* GL_NV_video_capture */ - -#ifndef GL_NV_viewport_array2 -#define GL_NV_viewport_array2 1 -#endif /* GL_NV_viewport_array2 */ - -#ifndef GL_OML_interlace -#define GL_OML_interlace 1 -#define GL_INTERLACE_OML 0x8980 -#define GL_INTERLACE_READ_OML 0x8981 -#endif /* GL_OML_interlace */ - -#ifndef GL_OML_resample -#define GL_OML_resample 1 -#define GL_PACK_RESAMPLE_OML 0x8984 -#define GL_UNPACK_RESAMPLE_OML 0x8985 -#define GL_RESAMPLE_REPLICATE_OML 0x8986 -#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 -#define GL_RESAMPLE_AVERAGE_OML 0x8988 -#define GL_RESAMPLE_DECIMATE_OML 0x8989 -#endif /* GL_OML_resample */ - -#ifndef GL_OML_subsample -#define GL_OML_subsample 1 -#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 -#endif /* GL_OML_subsample */ - -#ifndef GL_OVR_multiview -#define GL_OVR_multiview 1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 -#define GL_MAX_VIEWS_OVR 0x9631 -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFramebufferTextureMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); -#endif -#endif /* GL_OVR_multiview */ - -#ifndef GL_OVR_multiview2 -#define GL_OVR_multiview2 1 -#endif /* GL_OVR_multiview2 */ - -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 -#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD -#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 -#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C -#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E -#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F -#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 -#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 -#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 -#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 -#define GL_CLIP_NEAR_HINT_PGI 0x1A220 -#define GL_CLIP_FAR_HINT_PGI 0x1A221 -#define GL_WIDE_LINE_HINT_PGI 0x1A222 -#define GL_BACK_NORMALS_HINT_PGI 0x1A223 -typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); -#endif -#endif /* GL_PGI_misc_hints */ - -#ifndef GL_PGI_vertex_hints -#define GL_PGI_vertex_hints 1 -#define GL_VERTEX_DATA_HINT_PGI 0x1A22A -#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B -#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C -#define GL_MAX_VERTEX_HINT_PGI 0x1A22D -#define GL_COLOR3_BIT_PGI 0x00010000 -#define GL_COLOR4_BIT_PGI 0x00020000 -#define GL_EDGEFLAG_BIT_PGI 0x00040000 -#define GL_INDEX_BIT_PGI 0x00080000 -#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 -#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 -#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 -#define GL_MAT_EMISSION_BIT_PGI 0x00800000 -#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 -#define GL_MAT_SHININESS_BIT_PGI 0x02000000 -#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 -#define GL_NORMAL_BIT_PGI 0x08000000 -#define GL_TEXCOORD1_BIT_PGI 0x10000000 -#define GL_TEXCOORD2_BIT_PGI 0x20000000 -#define GL_TEXCOORD3_BIT_PGI 0x40000000 -#define GL_TEXCOORD4_BIT_PGI 0x80000000 -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 -#endif /* GL_PGI_vertex_hints */ - -#ifndef GL_REND_screen_coordinates -#define GL_REND_screen_coordinates 1 -#define GL_SCREEN_COORDINATES_REND 0x8490 -#define GL_INVERTED_SCREEN_W_REND 0x8491 -#endif /* GL_REND_screen_coordinates */ - -#ifndef GL_S3_s3tc -#define GL_S3_s3tc 1 -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 -#define GL_RGBA_S3TC 0x83A2 -#define GL_RGBA4_S3TC 0x83A3 -#define GL_RGBA_DXT5_S3TC 0x83A4 -#define GL_RGBA4_DXT5_S3TC 0x83A5 -#endif /* GL_S3_s3tc */ - -#ifndef GL_SGIS_detail_texture -#define GL_SGIS_detail_texture 1 -#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 -#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 -#define GL_LINEAR_DETAIL_SGIS 0x8097 -#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 -#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 -#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A -#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B -#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C -typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); -#endif -#endif /* GL_SGIS_detail_texture */ - -#ifndef GL_SGIS_fog_function -#define GL_SGIS_fog_function 1 -#define GL_FOG_FUNC_SGIS 0x812A -#define GL_FOG_FUNC_POINTS_SGIS 0x812B -#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C -typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); -#endif -#endif /* GL_SGIS_fog_function */ - -#ifndef GL_SGIS_generate_mipmap -#define GL_SGIS_generate_mipmap 1 -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#endif /* GL_SGIS_generate_mipmap */ - -#ifndef GL_SGIS_multisample -#define GL_SGIS_multisample 1 -#define GL_MULTISAMPLE_SGIS 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F -#define GL_SAMPLE_MASK_SGIS 0x80A0 -#define GL_1PASS_SGIS 0x80A1 -#define GL_2PASS_0_SGIS 0x80A2 -#define GL_2PASS_1_SGIS 0x80A3 -#define GL_4PASS_0_SGIS 0x80A4 -#define GL_4PASS_1_SGIS 0x80A5 -#define GL_4PASS_2_SGIS 0x80A6 -#define GL_4PASS_3_SGIS 0x80A7 -#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 -#define GL_SAMPLES_SGIS 0x80A9 -#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA -#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB -#define GL_SAMPLE_PATTERN_SGIS 0x80AC -typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); -GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); -#endif -#endif /* GL_SGIS_multisample */ - -#ifndef GL_SGIS_pixel_texture -#define GL_SGIS_pixel_texture 1 -#define GL_PIXEL_TEXTURE_SGIS 0x8353 -#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 -#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 -#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); -GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); -GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); -GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); -#endif -#endif /* GL_SGIS_pixel_texture */ - -#ifndef GL_SGIS_point_line_texgen -#define GL_SGIS_point_line_texgen 1 -#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 -#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 -#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 -#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 -#define GL_EYE_POINT_SGIS 0x81F4 -#define GL_OBJECT_POINT_SGIS 0x81F5 -#define GL_EYE_LINE_SGIS 0x81F6 -#define GL_OBJECT_LINE_SGIS 0x81F7 -#endif /* GL_SGIS_point_line_texgen */ - -#ifndef GL_SGIS_point_parameters -#define GL_SGIS_point_parameters 1 -#define GL_POINT_SIZE_MIN_SGIS 0x8126 -#define GL_POINT_SIZE_MAX_SGIS 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 -#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 -typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); -#endif -#endif /* GL_SGIS_point_parameters */ - -#ifndef GL_SGIS_sharpen_texture -#define GL_SGIS_sharpen_texture 1 -#define GL_LINEAR_SHARPEN_SGIS 0x80AD -#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE -#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF -#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 -typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); -#endif -#endif /* GL_SGIS_sharpen_texture */ - -#ifndef GL_SGIS_texture4D -#define GL_SGIS_texture4D 1 -#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 -#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 -#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 -#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 -#define GL_TEXTURE_4D_SGIS 0x8134 -#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 -#define GL_TEXTURE_4DSIZE_SGIS 0x8136 -#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 -#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 -#define GL_TEXTURE_4D_BINDING_SGIS 0x814F -typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); -#endif -#endif /* GL_SGIS_texture4D */ - -#ifndef GL_SGIS_texture_border_clamp -#define GL_SGIS_texture_border_clamp 1 -#define GL_CLAMP_TO_BORDER_SGIS 0x812D -#endif /* GL_SGIS_texture_border_clamp */ - -#ifndef GL_SGIS_texture_color_mask -#define GL_SGIS_texture_color_mask 1 -#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF -typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif -#endif /* GL_SGIS_texture_color_mask */ - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 -#define GL_CLAMP_TO_EDGE_SGIS 0x812F -#endif /* GL_SGIS_texture_edge_clamp */ - -#ifndef GL_SGIS_texture_filter4 -#define GL_SGIS_texture_filter4 1 -#define GL_FILTER4_SGIS 0x8146 -#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 -typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); -typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); -GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#endif -#endif /* GL_SGIS_texture_filter4 */ - -#ifndef GL_SGIS_texture_lod -#define GL_SGIS_texture_lod 1 -#define GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D -#endif /* GL_SGIS_texture_lod */ - -#ifndef GL_SGIS_texture_select -#define GL_SGIS_texture_select 1 -#define GL_DUAL_ALPHA4_SGIS 0x8110 -#define GL_DUAL_ALPHA8_SGIS 0x8111 -#define GL_DUAL_ALPHA12_SGIS 0x8112 -#define GL_DUAL_ALPHA16_SGIS 0x8113 -#define GL_DUAL_LUMINANCE4_SGIS 0x8114 -#define GL_DUAL_LUMINANCE8_SGIS 0x8115 -#define GL_DUAL_LUMINANCE12_SGIS 0x8116 -#define GL_DUAL_LUMINANCE16_SGIS 0x8117 -#define GL_DUAL_INTENSITY4_SGIS 0x8118 -#define GL_DUAL_INTENSITY8_SGIS 0x8119 -#define GL_DUAL_INTENSITY12_SGIS 0x811A -#define GL_DUAL_INTENSITY16_SGIS 0x811B -#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C -#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D -#define GL_QUAD_ALPHA4_SGIS 0x811E -#define GL_QUAD_ALPHA8_SGIS 0x811F -#define GL_QUAD_LUMINANCE4_SGIS 0x8120 -#define GL_QUAD_LUMINANCE8_SGIS 0x8121 -#define GL_QUAD_INTENSITY4_SGIS 0x8122 -#define GL_QUAD_INTENSITY8_SGIS 0x8123 -#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 -#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 -#endif /* GL_SGIS_texture_select */ - -#ifndef GL_SGIX_async -#define GL_SGIX_async 1 -#define GL_ASYNC_MARKER_SGIX 0x8329 -typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); -typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); -typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); -GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); -GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); -GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); -GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); -GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); -#endif -#endif /* GL_SGIX_async */ - -#ifndef GL_SGIX_async_histogram -#define GL_SGIX_async_histogram 1 -#define GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D -#endif /* GL_SGIX_async_histogram */ - -#ifndef GL_SGIX_async_pixel -#define GL_SGIX_async_pixel 1 -#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C -#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D -#define GL_ASYNC_READ_PIXELS_SGIX 0x835E -#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F -#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 -#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 -#endif /* GL_SGIX_async_pixel */ - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_SGIX_blend_alpha_minmax 1 -#define GL_ALPHA_MIN_SGIX 0x8320 -#define GL_ALPHA_MAX_SGIX 0x8321 -#endif /* GL_SGIX_blend_alpha_minmax */ - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_SGIX_calligraphic_fragment 1 -#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 -#endif /* GL_SGIX_calligraphic_fragment */ - -#ifndef GL_SGIX_clipmap -#define GL_SGIX_clipmap 1 -#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 -#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 -#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 -#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 -#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 -#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 -#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 -#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 -#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 -#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D -#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E -#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F -#endif /* GL_SGIX_clipmap */ - -#ifndef GL_SGIX_convolution_accuracy -#define GL_SGIX_convolution_accuracy 1 -#define GL_CONVOLUTION_HINT_SGIX 0x8316 -#endif /* GL_SGIX_convolution_accuracy */ - -#ifndef GL_SGIX_depth_pass_instrument -#define GL_SGIX_depth_pass_instrument 1 -#endif /* GL_SGIX_depth_pass_instrument */ - -#ifndef GL_SGIX_depth_texture -#define GL_SGIX_depth_texture 1 -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 -#endif /* GL_SGIX_depth_texture */ - -#ifndef GL_SGIX_flush_raster -#define GL_SGIX_flush_raster 1 -typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushRasterSGIX (void); -#endif -#endif /* GL_SGIX_flush_raster */ - -#ifndef GL_SGIX_fog_offset -#define GL_SGIX_fog_offset 1 -#define GL_FOG_OFFSET_SGIX 0x8198 -#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 -#endif /* GL_SGIX_fog_offset */ - -#ifndef GL_SGIX_fragment_lighting -#define GL_SGIX_fragment_lighting 1 -#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 -#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 -#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 -#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 -#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 -#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 -#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 -#define GL_LIGHT_ENV_MODE_SGIX 0x8407 -#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 -#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 -#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A -#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B -#define GL_FRAGMENT_LIGHT0_SGIX 0x840C -#define GL_FRAGMENT_LIGHT1_SGIX 0x840D -#define GL_FRAGMENT_LIGHT2_SGIX 0x840E -#define GL_FRAGMENT_LIGHT3_SGIX 0x840F -#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 -#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 -#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 -#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 -typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); -GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); -GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); -GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); -GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); -GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); -#endif -#endif /* GL_SGIX_fragment_lighting */ - -#ifndef GL_SGIX_framezoom -#define GL_SGIX_framezoom 1 -#define GL_FRAMEZOOM_SGIX 0x818B -#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C -#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D -typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); -#endif -#endif /* GL_SGIX_framezoom */ - -#ifndef GL_SGIX_igloo_interface -#define GL_SGIX_igloo_interface 1 -typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const void *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const void *params); -#endif -#endif /* GL_SGIX_igloo_interface */ - -#ifndef GL_SGIX_instruments -#define GL_SGIX_instruments 1 -#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 -#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 -typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); -typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); -typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); -typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); -GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); -GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); -GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); -GLAPI void APIENTRY glStartInstrumentsSGIX (void); -GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); -#endif -#endif /* GL_SGIX_instruments */ - -#ifndef GL_SGIX_interlace -#define GL_SGIX_interlace 1 -#define GL_INTERLACE_SGIX 0x8094 -#endif /* GL_SGIX_interlace */ - -#ifndef GL_SGIX_ir_instrument1 -#define GL_SGIX_ir_instrument1 1 -#define GL_IR_INSTRUMENT1_SGIX 0x817F -#endif /* GL_SGIX_ir_instrument1 */ - -#ifndef GL_SGIX_list_priority -#define GL_SGIX_list_priority 1 -#define GL_LIST_PRIORITY_SGIX 0x8182 -typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); -GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); -GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); -GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); -#endif -#endif /* GL_SGIX_list_priority */ - -#ifndef GL_SGIX_pixel_texture -#define GL_SGIX_pixel_texture 1 -#define GL_PIXEL_TEX_GEN_SGIX 0x8139 -#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B -typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); -#endif -#endif /* GL_SGIX_pixel_texture */ - -#ifndef GL_SGIX_pixel_tiles -#define GL_SGIX_pixel_tiles 1 -#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E -#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F -#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 -#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 -#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 -#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 -#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 -#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 -#endif /* GL_SGIX_pixel_tiles */ - -#ifndef GL_SGIX_polynomial_ffd -#define GL_SGIX_polynomial_ffd 1 -#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 -#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 -#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 -#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 -#define GL_DEFORMATIONS_MASK_SGIX 0x8196 -#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); -GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); -#endif -#endif /* GL_SGIX_polynomial_ffd */ - -#ifndef GL_SGIX_reference_plane -#define GL_SGIX_reference_plane 1 -#define GL_REFERENCE_PLANE_SGIX 0x817D -#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E -typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); -#endif -#endif /* GL_SGIX_reference_plane */ - -#ifndef GL_SGIX_resample -#define GL_SGIX_resample 1 -#define GL_PACK_RESAMPLE_SGIX 0x842E -#define GL_UNPACK_RESAMPLE_SGIX 0x842F -#define GL_RESAMPLE_REPLICATE_SGIX 0x8433 -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434 -#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#endif /* GL_SGIX_resample */ - -#ifndef GL_SGIX_scalebias_hint -#define GL_SGIX_scalebias_hint 1 -#define GL_SCALEBIAS_HINT_SGIX 0x8322 -#endif /* GL_SGIX_scalebias_hint */ - -#ifndef GL_SGIX_shadow -#define GL_SGIX_shadow 1 -#define GL_TEXTURE_COMPARE_SGIX 0x819A -#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D -#endif /* GL_SGIX_shadow */ - -#ifndef GL_SGIX_shadow_ambient -#define GL_SGIX_shadow_ambient 1 -#define GL_SHADOW_AMBIENT_SGIX 0x80BF -#endif /* GL_SGIX_shadow_ambient */ - -#ifndef GL_SGIX_sprite -#define GL_SGIX_sprite 1 -#define GL_SPRITE_SGIX 0x8148 -#define GL_SPRITE_MODE_SGIX 0x8149 -#define GL_SPRITE_AXIS_SGIX 0x814A -#define GL_SPRITE_TRANSLATION_SGIX 0x814B -#define GL_SPRITE_AXIAL_SGIX 0x814C -#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D -#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); -GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); -GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); -#endif -#endif /* GL_SGIX_sprite */ - -#ifndef GL_SGIX_subsample -#define GL_SGIX_subsample 1 -#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 -#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 -#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 -#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 -#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 -#endif /* GL_SGIX_subsample */ - -#ifndef GL_SGIX_tag_sample_buffer -#define GL_SGIX_tag_sample_buffer 1 -typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTagSampleBufferSGIX (void); -#endif -#endif /* GL_SGIX_tag_sample_buffer */ - -#ifndef GL_SGIX_texture_add_env -#define GL_SGIX_texture_add_env 1 -#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE -#endif /* GL_SGIX_texture_add_env */ - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_SGIX_texture_coordinate_clamp 1 -#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B -#endif /* GL_SGIX_texture_coordinate_clamp */ - -#ifndef GL_SGIX_texture_lod_bias -#define GL_SGIX_texture_lod_bias 1 -#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E -#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F -#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 -#endif /* GL_SGIX_texture_lod_bias */ - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_SGIX_texture_multi_buffer 1 -#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E -#endif /* GL_SGIX_texture_multi_buffer */ - -#ifndef GL_SGIX_texture_scale_bias -#define GL_SGIX_texture_scale_bias 1 -#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 -#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A -#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B -#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C -#endif /* GL_SGIX_texture_scale_bias */ - -#ifndef GL_SGIX_vertex_preclip -#define GL_SGIX_vertex_preclip 1 -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF -#endif /* GL_SGIX_vertex_preclip */ - -#ifndef GL_SGIX_ycrcb -#define GL_SGIX_ycrcb 1 -#define GL_YCRCB_422_SGIX 0x81BB -#define GL_YCRCB_444_SGIX 0x81BC -#endif /* GL_SGIX_ycrcb */ - -#ifndef GL_SGIX_ycrcb_subsample -#define GL_SGIX_ycrcb_subsample 1 -#endif /* GL_SGIX_ycrcb_subsample */ - -#ifndef GL_SGIX_ycrcba -#define GL_SGIX_ycrcba 1 -#define GL_YCRCB_SGIX 0x8318 -#define GL_YCRCBA_SGIX 0x8319 -#endif /* GL_SGIX_ycrcba */ - -#ifndef GL_SGI_color_matrix -#define GL_SGI_color_matrix 1 -#define GL_COLOR_MATRIX_SGI 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB -#endif /* GL_SGI_color_matrix */ - -#ifndef GL_SGI_color_table -#define GL_SGI_color_table 1 -#define GL_COLOR_TABLE_SGI 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 -#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 -#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 -#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF -typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); -GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, void *table); -GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); -#endif -#endif /* GL_SGI_color_table */ - -#ifndef GL_SGI_texture_color_table -#define GL_SGI_texture_color_table 1 -#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD -#endif /* GL_SGI_texture_color_table */ - -#ifndef GL_SUNX_constant_data -#define GL_SUNX_constant_data 1 -#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 -typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFinishTextureSUNX (void); -#endif -#endif /* GL_SUNX_constant_data */ - -#ifndef GL_SUN_convolution_border_modes -#define GL_SUN_convolution_border_modes 1 -#define GL_WRAP_BORDER_SUN 0x81D4 -#endif /* GL_SUN_convolution_border_modes */ - -#ifndef GL_SUN_global_alpha -#define GL_SUN_global_alpha 1 -#define GL_GLOBAL_ALPHA_SUN 0x81D9 -#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); -GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); -GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); -GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); -GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); -GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); -GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); -GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); -#endif -#endif /* GL_SUN_global_alpha */ - -#ifndef GL_SUN_mesh_array -#define GL_SUN_mesh_array 1 -#define GL_QUAD_MESH_SUN 0x8614 -#define GL_TRIANGLE_MESH_SUN 0x8615 -typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); -#endif -#endif /* GL_SUN_mesh_array */ - -#ifndef GL_SUN_slice_accum -#define GL_SUN_slice_accum 1 -#define GL_SLICE_ACCUM_SUN 0x85CC -#endif /* GL_SUN_slice_accum */ - -#ifndef GL_SUN_triangle_list -#define GL_SUN_triangle_list 1 -#define GL_RESTART_SUN 0x0001 -#define GL_REPLACE_MIDDLE_SUN 0x0002 -#define GL_REPLACE_OLDEST_SUN 0x0003 -#define GL_TRIANGLE_LIST_SUN 0x81D7 -#define GL_REPLACEMENT_CODE_SUN 0x81D8 -#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 -#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 -#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 -#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 -#define GL_R1UI_V3F_SUN 0x85C4 -#define GL_R1UI_C4UB_V3F_SUN 0x85C5 -#define GL_R1UI_C3F_V3F_SUN 0x85C6 -#define GL_R1UI_N3F_V3F_SUN 0x85C7 -#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 -#define GL_R1UI_T2F_V3F_SUN 0x85C9 -#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA -#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void **pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); -GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); -GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); -GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); -GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); -GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); -GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const void **pointer); -#endif -#endif /* GL_SUN_triangle_list */ - -#ifndef GL_SUN_vertex -#define GL_SUN_vertex 1 -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#endif -#endif /* GL_SUN_vertex */ - -#ifndef GL_WIN_phong_shading -#define GL_WIN_phong_shading 1 -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB -#endif /* GL_WIN_phong_shading */ - -#ifndef GL_WIN_specular_fog -#define GL_WIN_specular_fog 1 -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC -#endif /* GL_WIN_specular_fog */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/code/renderer2/glsl/bokeh_fp.glsl b/code/renderer2/glsl/bokeh_fp.glsl deleted file mode 100644 index d2ec5b4b36..0000000000 --- a/code/renderer2/glsl/bokeh_fp.glsl +++ /dev/null @@ -1,84 +0,0 @@ -uniform sampler2D u_TextureMap; - -uniform vec4 u_Color; - -uniform vec2 u_InvTexRes; -varying vec2 var_TexCoords; - -void main() -{ - vec4 color; - vec2 tc; - -#if 0 - float c[7]; - - c[0] = 1.0; - c[1] = 0.9659258263; - c[2] = 0.8660254038; - c[3] = 0.7071067812; - c[4] = 0.5; - c[5] = 0.2588190451; - c[6] = 0.0; - - tc = var_TexCoords + u_InvTexRes * vec2( c[0], c[6]); color = texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[1], c[5]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[2], c[4]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[3], c[3]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[4], c[2]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[5], c[1]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[6], c[0]); color += texture2D(u_TextureMap, tc); - - tc = var_TexCoords + u_InvTexRes * vec2( c[1], -c[5]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[2], -c[4]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[3], -c[3]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[4], -c[2]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[5], -c[1]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[6], -c[0]); color += texture2D(u_TextureMap, tc); - - tc = var_TexCoords + u_InvTexRes * vec2( -c[0], c[6]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[1], c[5]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[2], c[4]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[3], c[3]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[4], c[2]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[5], c[1]); color += texture2D(u_TextureMap, tc); - - tc = var_TexCoords + u_InvTexRes * vec2( -c[1], -c[5]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[2], -c[4]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[3], -c[3]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[4], -c[2]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[5], -c[1]); color += texture2D(u_TextureMap, tc); - - gl_FragColor = color * 0.04166667 * u_Color; -#endif - - float c[5]; - - c[0] = 1.0; - c[1] = 0.9238795325; - c[2] = 0.7071067812; - c[3] = 0.3826834324; - c[4] = 0.0; - - tc = var_TexCoords + u_InvTexRes * vec2( c[0], c[4]); color = texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[1], c[3]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[2], c[2]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[3], c[1]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[4], c[0]); color += texture2D(u_TextureMap, tc); - - tc = var_TexCoords + u_InvTexRes * vec2( c[1], -c[3]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[2], -c[2]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[3], -c[1]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[4], -c[0]); color += texture2D(u_TextureMap, tc); - - tc = var_TexCoords + u_InvTexRes * vec2( -c[0], c[4]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[1], c[3]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[2], c[2]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[3], c[1]); color += texture2D(u_TextureMap, tc); - - tc = var_TexCoords + u_InvTexRes * vec2( -c[1], -c[3]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[2], -c[2]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[3], -c[1]); color += texture2D(u_TextureMap, tc); - - gl_FragColor = color * 0.0625 * u_Color; -} diff --git a/code/renderer2/glsl/bokeh_vp.glsl b/code/renderer2/glsl/bokeh_vp.glsl deleted file mode 100644 index bdaa74af8e..0000000000 --- a/code/renderer2/glsl/bokeh_vp.glsl +++ /dev/null @@ -1,13 +0,0 @@ -attribute vec3 attr_Position; -attribute vec4 attr_TexCoord0; - -uniform mat4 u_ModelViewProjectionMatrix; - -varying vec2 var_TexCoords; - - -void main() -{ - gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); - var_TexCoords = attr_TexCoord0.st; -} diff --git a/code/renderer2/glsl/calclevels4x_fp.glsl b/code/renderer2/glsl/calclevels4x_fp.glsl deleted file mode 100644 index c259768151..0000000000 --- a/code/renderer2/glsl/calclevels4x_fp.glsl +++ /dev/null @@ -1,60 +0,0 @@ -uniform sampler2D u_TextureMap; - -uniform vec4 u_Color; - -uniform vec2 u_InvTexRes; -varying vec2 var_TexCoords; - -const vec3 LUMINANCE_VECTOR = vec3(0.2125, 0.7154, 0.0721); //vec3(0.299, 0.587, 0.114); - -vec3 GetValues(vec2 offset, vec3 current) -{ - vec2 tc = var_TexCoords + u_InvTexRes * offset; - vec3 minAvgMax = texture2D(u_TextureMap, tc).rgb; - -#ifdef FIRST_PASS - - #if defined(USE_PBR) - minAvgMax *= minAvgMax; - #endif - - float lumi = max(dot(LUMINANCE_VECTOR, minAvgMax), 0.000001); - float loglumi = clamp(log2(lumi), -10.0, 10.0); - minAvgMax = vec3(loglumi * 0.05 + 0.5); -#endif - - return vec3(min(current.x, minAvgMax.x), current.y + minAvgMax.y, max(current.z, minAvgMax.z)); -} - -void main() -{ - vec3 current = vec3(1.0, 0.0, 0.0); - -#ifdef FIRST_PASS - current = GetValues(vec2( 0.0, 0.0), current); -#else - current = GetValues(vec2(-1.5, -1.5), current); - current = GetValues(vec2(-0.5, -1.5), current); - current = GetValues(vec2( 0.5, -1.5), current); - current = GetValues(vec2( 1.5, -1.5), current); - - current = GetValues(vec2(-1.5, -0.5), current); - current = GetValues(vec2(-0.5, -0.5), current); - current = GetValues(vec2( 0.5, -0.5), current); - current = GetValues(vec2( 1.5, -0.5), current); - - current = GetValues(vec2(-1.5, 0.5), current); - current = GetValues(vec2(-0.5, 0.5), current); - current = GetValues(vec2( 0.5, 0.5), current); - current = GetValues(vec2( 1.5, 0.5), current); - - current = GetValues(vec2(-1.5, 1.5), current); - current = GetValues(vec2(-0.5, 1.5), current); - current = GetValues(vec2( 0.5, 1.5), current); - current = GetValues(vec2( 1.5, 1.5), current); - - current.y *= 0.0625; -#endif - - gl_FragColor = vec4(current, 1.0); -} diff --git a/code/renderer2/glsl/calclevels4x_vp.glsl b/code/renderer2/glsl/calclevels4x_vp.glsl deleted file mode 100644 index bdaa74af8e..0000000000 --- a/code/renderer2/glsl/calclevels4x_vp.glsl +++ /dev/null @@ -1,13 +0,0 @@ -attribute vec3 attr_Position; -attribute vec4 attr_TexCoord0; - -uniform mat4 u_ModelViewProjectionMatrix; - -varying vec2 var_TexCoords; - - -void main() -{ - gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); - var_TexCoords = attr_TexCoord0.st; -} diff --git a/code/renderer2/glsl/depthblur_fp.glsl b/code/renderer2/glsl/depthblur_fp.glsl deleted file mode 100644 index d63df88a6a..0000000000 --- a/code/renderer2/glsl/depthblur_fp.glsl +++ /dev/null @@ -1,88 +0,0 @@ -uniform sampler2D u_ScreenImageMap; -uniform sampler2D u_ScreenDepthMap; - -uniform vec4 u_ViewInfo; // zfar / znear, zfar, 1/width, 1/height -varying vec2 var_ScreenTex; - -//float gauss[8] = float[8](0.17, 0.17, 0.16, 0.14, 0.12, 0.1, 0.08, 0.06); -//float gauss[5] = float[5](0.30, 0.23, 0.097, 0.024, 0.0033); -//float gauss[4] = float[4](0.40, 0.24, 0.054, 0.0044); -//float gauss[3] = float[3](0.60, 0.19, 0.0066); -#define BLUR_SIZE 4 - -#if !defined(USE_DEPTH) -//#define USE_GAUSS -#endif - -float getLinearDepth(sampler2D depthMap, const vec2 tex, const float zFarDivZNear) -{ - float sampleZDivW = texture2D(depthMap, tex).r; - return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW); -} - -vec4 depthGaussian1D(sampler2D imageMap, sampler2D depthMap, vec2 tex, float zFarDivZNear, float zFar, vec2 scale) -{ - float gauss[4]; - - gauss[0] = 0.40; - gauss[1] = 0.24; - gauss[2] = 0.054; - gauss[3] = 0.0044; - -#if defined(USE_DEPTH) - float depthCenter = getLinearDepth(depthMap, tex, zFarDivZNear); - vec2 slope = vec2(dFdx(depthCenter), dFdy(depthCenter)) / vec2(dFdx(tex.x), dFdy(tex.y)); - scale /= clamp(zFarDivZNear * depthCenter / 32.0, 1.0, 2.0); -#endif - -#if defined(USE_HORIZONTAL_BLUR) - vec2 direction = vec2(scale.x * 2.0, 0.0); - vec2 nudge = vec2(0.0, scale.y * 0.5); -#else // if defined(USE_VERTICAL_BLUR) - vec2 direction = vec2(0.0, scale.y * 2.0); - vec2 nudge = vec2(-scale.x * 0.5, 0.0); -#endif - -#if defined(USE_GAUSS) - vec4 result = texture2D(imageMap, tex) * gauss[0]; - float total = gauss[0]; -#else - vec4 result = texture2D(imageMap, tex); - float total = 1.0; -#endif - - float zLimit = 5.0 / zFar; - int i, j; - for (i = 0; i < 2; i++) - { - for (j = 1; j < BLUR_SIZE; j++) - { - vec2 offset = direction * (float(j) - 0.25) + nudge; -#if defined(USE_DEPTH) - float depthSample = getLinearDepth(depthMap, tex + offset, zFarDivZNear); - float depthExpected = depthCenter + dot(slope, offset); - float useSample = float(abs(depthSample - depthExpected) < zLimit); -#else - float useSample = 1.0; -#endif -#if defined(USE_GAUSS) - result += texture2D(imageMap, tex + offset) * (gauss[j] * useSample); - total += gauss[j] * useSample; -#else - result += texture2D(imageMap, tex + offset) * useSample; - total += useSample; -#endif - nudge = -nudge; - } - - direction = -direction; - nudge = -nudge; - } - - return result / total; -} - -void main() -{ - gl_FragColor = depthGaussian1D(u_ScreenImageMap, u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y, u_ViewInfo.zw); -} diff --git a/code/renderer2/glsl/depthblur_vp.glsl b/code/renderer2/glsl/depthblur_vp.glsl deleted file mode 100644 index 9c47660c01..0000000000 --- a/code/renderer2/glsl/depthblur_vp.glsl +++ /dev/null @@ -1,16 +0,0 @@ -attribute vec4 attr_Position; -attribute vec4 attr_TexCoord0; - -uniform vec4 u_ViewInfo; // zfar / znear, zfar, 1/width, 1/height - -varying vec2 var_ScreenTex; - -void main() -{ - gl_Position = attr_Position; - vec2 wh = vec2(1.0) / u_ViewInfo.zw - vec2(1.0); - var_ScreenTex = (floor(attr_TexCoord0.xy * wh) + vec2(0.5)) * u_ViewInfo.zw; - - //vec2 screenCoords = gl_Position.xy / gl_Position.w; - //var_ScreenTex = screenCoords * 0.5 + 0.5; -} diff --git a/code/renderer2/glsl/dlight_fp.glsl b/code/renderer2/glsl/dlight_fp.glsl deleted file mode 100644 index 41be0494fc..0000000000 --- a/code/renderer2/glsl/dlight_fp.glsl +++ /dev/null @@ -1,32 +0,0 @@ -uniform sampler2D u_DiffuseMap; - -uniform int u_AlphaTest; - -varying vec2 var_Tex1; -varying vec4 var_Color; - - -void main() -{ - vec4 color = texture2D(u_DiffuseMap, var_Tex1); - - float alpha = color.a * var_Color.a; - if (u_AlphaTest == 1) - { - if (alpha == 0.0) - discard; - } - else if (u_AlphaTest == 2) - { - if (alpha >= 0.5) - discard; - } - else if (u_AlphaTest == 3) - { - if (alpha < 0.5) - discard; - } - - gl_FragColor.rgb = color.rgb * var_Color.rgb; - gl_FragColor.a = alpha; -} diff --git a/code/renderer2/glsl/dlight_vp.glsl b/code/renderer2/glsl/dlight_vp.glsl deleted file mode 100644 index c326bd7894..0000000000 --- a/code/renderer2/glsl/dlight_vp.glsl +++ /dev/null @@ -1,92 +0,0 @@ -attribute vec3 attr_Position; -attribute vec4 attr_TexCoord0; -attribute vec3 attr_Normal; - -uniform vec4 u_DlightInfo; - -#if defined(USE_DEFORM_VERTEXES) -uniform int u_DeformGen; -uniform float u_DeformParams[5]; -uniform float u_Time; -#endif - -uniform vec4 u_Color; -uniform mat4 u_ModelViewProjectionMatrix; - -varying vec2 var_Tex1; -varying vec4 var_Color; - -#if defined(USE_DEFORM_VERTEXES) -vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) -{ - if (u_DeformGen == 0) - { - return pos; - } - - float base = u_DeformParams[0]; - float amplitude = u_DeformParams[1]; - float phase = u_DeformParams[2]; - float frequency = u_DeformParams[3]; - float spread = u_DeformParams[4]; - - if (u_DeformGen == DGEN_BULGE) - { - phase *= st.x; - } - else // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH) - { - phase += dot(pos.xyz, vec3(spread)); - } - - float value = phase + (u_Time * frequency); - float func; - - if (u_DeformGen == DGEN_WAVE_SIN) - { - func = sin(value * 2.0 * M_PI); - } - else if (u_DeformGen == DGEN_WAVE_SQUARE) - { - func = sign(0.5 - fract(value)); - } - else if (u_DeformGen == DGEN_WAVE_TRIANGLE) - { - func = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; - } - else if (u_DeformGen == DGEN_WAVE_SAWTOOTH) - { - func = fract(value); - } - else if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH) - { - func = (1.0 - fract(value)); - } - else // if (u_DeformGen == DGEN_BULGE) - { - func = sin(value); - } - - return pos + normal * (base + func * amplitude); -} -#endif - -void main() -{ - vec3 position = attr_Position; - vec3 normal = attr_Normal; - -#if defined(USE_DEFORM_VERTEXES) - position = DeformPosition(position, normal, attr_TexCoord0.st); -#endif - - gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); - - vec3 dist = u_DlightInfo.xyz - position; - - var_Tex1 = dist.xy * u_DlightInfo.a + vec2(0.5); - float dlightmod = step(0.0, dot(dist, normal)); - dlightmod *= clamp(2.0 * (1.0 - abs(dist.z) * u_DlightInfo.a), 0.0, 1.0); - - var_Color = u_Color * dlightmod; -} diff --git a/code/renderer2/glsl/down4x_fp.glsl b/code/renderer2/glsl/down4x_fp.glsl deleted file mode 100644 index 0f88fb2e34..0000000000 --- a/code/renderer2/glsl/down4x_fp.glsl +++ /dev/null @@ -1,34 +0,0 @@ -uniform sampler2D u_TextureMap; - -uniform vec2 u_InvTexRes; -varying vec2 var_TexCoords; - -void main() -{ - vec4 color; - vec2 tc; - - tc = var_TexCoords + u_InvTexRes * vec2(-1.5, -1.5); color = texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2(-0.5, -1.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( 0.5, -1.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( 1.5, -1.5); color += texture2D(u_TextureMap, tc); - - tc = var_TexCoords + u_InvTexRes * vec2(-1.5, -0.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2(-0.5, -0.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( 0.5, -0.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( 1.5, -0.5); color += texture2D(u_TextureMap, tc); - - tc = var_TexCoords + u_InvTexRes * vec2(-1.5, 0.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2(-0.5, 0.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( 0.5, 0.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( 1.5, 0.5); color += texture2D(u_TextureMap, tc); - - tc = var_TexCoords + u_InvTexRes * vec2(-1.5, 1.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2(-0.5, 1.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( 0.5, 1.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( 1.5, 1.5); color += texture2D(u_TextureMap, tc); - - color *= 0.0625; - - gl_FragColor = color; -} diff --git a/code/renderer2/glsl/down4x_vp.glsl b/code/renderer2/glsl/down4x_vp.glsl deleted file mode 100644 index bdaa74af8e..0000000000 --- a/code/renderer2/glsl/down4x_vp.glsl +++ /dev/null @@ -1,13 +0,0 @@ -attribute vec3 attr_Position; -attribute vec4 attr_TexCoord0; - -uniform mat4 u_ModelViewProjectionMatrix; - -varying vec2 var_TexCoords; - - -void main() -{ - gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); - var_TexCoords = attr_TexCoord0.st; -} diff --git a/code/renderer2/glsl/fogpass_fp.glsl b/code/renderer2/glsl/fogpass_fp.glsl deleted file mode 100644 index e2ad465ba3..0000000000 --- a/code/renderer2/glsl/fogpass_fp.glsl +++ /dev/null @@ -1,9 +0,0 @@ -uniform vec4 u_Color; - -varying float var_Scale; - -void main() -{ - gl_FragColor = u_Color; - gl_FragColor.a = sqrt(clamp(var_Scale, 0.0, 1.0)); -} diff --git a/code/renderer2/glsl/fogpass_vp.glsl b/code/renderer2/glsl/fogpass_vp.glsl deleted file mode 100644 index 72ea0af680..0000000000 --- a/code/renderer2/glsl/fogpass_vp.glsl +++ /dev/null @@ -1,131 +0,0 @@ -attribute vec3 attr_Position; -attribute vec3 attr_Normal; - -attribute vec4 attr_TexCoord0; - -#if defined(USE_VERTEX_ANIMATION) -attribute vec3 attr_Position2; -attribute vec3 attr_Normal2; -#elif defined(USE_BONE_ANIMATION) -attribute vec4 attr_BoneIndexes; -attribute vec4 attr_BoneWeights; -#endif - -uniform vec4 u_FogDistance; -uniform vec4 u_FogDepth; -uniform float u_FogEyeT; - -#if defined(USE_DEFORM_VERTEXES) -uniform int u_DeformGen; -uniform float u_DeformParams[5]; -#endif - -uniform float u_Time; -uniform mat4 u_ModelViewProjectionMatrix; - -#if defined(USE_VERTEX_ANIMATION) -uniform float u_VertexLerp; -#elif defined(USE_BONE_ANIMATION) -uniform mat4 u_BoneMatrix[MAX_GLSL_BONES]; -#endif - -uniform vec4 u_Color; - -varying float var_Scale; - -#if defined(USE_DEFORM_VERTEXES) -vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) -{ - if (u_DeformGen == 0) - { - return pos; - } - - float base = u_DeformParams[0]; - float amplitude = u_DeformParams[1]; - float phase = u_DeformParams[2]; - float frequency = u_DeformParams[3]; - float spread = u_DeformParams[4]; - - if (u_DeformGen == DGEN_BULGE) - { - phase *= st.x; - } - else // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH) - { - phase += dot(pos.xyz, vec3(spread)); - } - - float value = phase + (u_Time * frequency); - float func; - - if (u_DeformGen == DGEN_WAVE_SIN) - { - func = sin(value * 2.0 * M_PI); - } - else if (u_DeformGen == DGEN_WAVE_SQUARE) - { - func = sign(0.5 - fract(value)); - } - else if (u_DeformGen == DGEN_WAVE_TRIANGLE) - { - func = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; - } - else if (u_DeformGen == DGEN_WAVE_SAWTOOTH) - { - func = fract(value); - } - else if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH) - { - func = (1.0 - fract(value)); - } - else // if (u_DeformGen == DGEN_BULGE) - { - func = sin(value); - } - - return pos + normal * (base + func * amplitude); -} -#endif - -float CalcFog(vec3 position) -{ - float s = dot(vec4(position, 1.0), u_FogDistance) * 8.0; - float t = dot(vec4(position, 1.0), u_FogDepth); - - float eyeOutside = float(u_FogEyeT < 0.0); - float fogged = float(t >= eyeOutside); - - t += 1e-6; - t *= fogged / (t - u_FogEyeT * eyeOutside); - - return s * t; -} - -void main() -{ -#if defined(USE_VERTEX_ANIMATION) - vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp); - vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp); -#elif defined(USE_BONE_ANIMATION) - mat4 vtxMat = u_BoneMatrix[int(attr_BoneIndexes.x)] * attr_BoneWeights.x; - vtxMat += u_BoneMatrix[int(attr_BoneIndexes.y)] * attr_BoneWeights.y; - vtxMat += u_BoneMatrix[int(attr_BoneIndexes.z)] * attr_BoneWeights.z; - vtxMat += u_BoneMatrix[int(attr_BoneIndexes.w)] * attr_BoneWeights.w; - mat3 nrmMat = mat3(cross(vtxMat[1].xyz, vtxMat[2].xyz), cross(vtxMat[2].xyz, vtxMat[0].xyz), cross(vtxMat[0].xyz, vtxMat[1].xyz)); - - vec3 position = vec3(vtxMat * vec4(attr_Position, 1.0)); - vec3 normal = normalize(nrmMat * attr_Normal); -#else - vec3 position = attr_Position; - vec3 normal = attr_Normal; -#endif - -#if defined(USE_DEFORM_VERTEXES) - position.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st); -#endif - - gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); - - var_Scale = CalcFog(position) * u_Color.a * u_Color.a; -} diff --git a/code/renderer2/glsl/generic_fp.glsl b/code/renderer2/glsl/generic_fp.glsl deleted file mode 100644 index c0a49407c7..0000000000 --- a/code/renderer2/glsl/generic_fp.glsl +++ /dev/null @@ -1,33 +0,0 @@ -uniform sampler2D u_DiffuseMap; - -uniform int u_AlphaTest; - -varying vec2 var_DiffuseTex; - -varying vec4 var_Color; - - -void main() -{ - vec4 color = texture2D(u_DiffuseMap, var_DiffuseTex); - - float alpha = color.a * var_Color.a; - if (u_AlphaTest == 1) - { - if (alpha == 0.0) - discard; - } - else if (u_AlphaTest == 2) - { - if (alpha >= 0.5) - discard; - } - else if (u_AlphaTest == 3) - { - if (alpha < 0.5) - discard; - } - - gl_FragColor.rgb = color.rgb * var_Color.rgb; - gl_FragColor.a = alpha; -} diff --git a/code/renderer2/glsl/generic_vp.glsl b/code/renderer2/glsl/generic_vp.glsl deleted file mode 100644 index a005526371..0000000000 --- a/code/renderer2/glsl/generic_vp.glsl +++ /dev/null @@ -1,253 +0,0 @@ -attribute vec3 attr_Position; -attribute vec3 attr_Normal; - -#if defined(USE_VERTEX_ANIMATION) -attribute vec3 attr_Position2; -attribute vec3 attr_Normal2; -#elif defined(USE_BONE_ANIMATION) -attribute vec4 attr_BoneIndexes; -attribute vec4 attr_BoneWeights; -#endif - -attribute vec4 attr_Color; -attribute vec4 attr_TexCoord0; - -#if defined(USE_TCGEN) -attribute vec4 attr_TexCoord1; -#endif - -uniform vec4 u_DiffuseTexMatrix; -uniform vec4 u_DiffuseTexOffTurb; - -#if defined(USE_TCGEN) || defined(USE_RGBAGEN) -uniform vec3 u_LocalViewOrigin; -#endif - -#if defined(USE_TCGEN) -uniform int u_TCGen0; -uniform vec3 u_TCGen0Vector0; -uniform vec3 u_TCGen0Vector1; -#endif - -#if defined(USE_FOG) -uniform vec4 u_FogDistance; -uniform vec4 u_FogDepth; -uniform float u_FogEyeT; -uniform vec4 u_FogColorMask; -#endif - -#if defined(USE_DEFORM_VERTEXES) -uniform int u_DeformGen; -uniform float u_DeformParams[5]; -uniform float u_Time; -#endif - -uniform mat4 u_ModelViewProjectionMatrix; -uniform vec4 u_BaseColor; -uniform vec4 u_VertColor; - -#if defined(USE_RGBAGEN) -uniform int u_ColorGen; -uniform int u_AlphaGen; -uniform vec3 u_AmbientLight; -uniform vec3 u_DirectedLight; -uniform vec3 u_ModelLightDir; -uniform float u_PortalRange; -#endif - -#if defined(USE_VERTEX_ANIMATION) -uniform float u_VertexLerp; -#elif defined(USE_BONE_ANIMATION) -uniform mat4 u_BoneMatrix[MAX_GLSL_BONES]; -#endif - -varying vec2 var_DiffuseTex; -varying vec4 var_Color; - -#if defined(USE_DEFORM_VERTEXES) -vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) -{ - float base = u_DeformParams[0]; - float amplitude = u_DeformParams[1]; - float phase = u_DeformParams[2]; - float frequency = u_DeformParams[3]; - float spread = u_DeformParams[4]; - - if (u_DeformGen == DGEN_BULGE) - { - phase *= st.x; - } - else // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH) - { - phase += dot(pos.xyz, vec3(spread)); - } - - float value = phase + (u_Time * frequency); - float func; - - if (u_DeformGen == DGEN_WAVE_SIN) - { - func = sin(value * 2.0 * M_PI); - } - else if (u_DeformGen == DGEN_WAVE_SQUARE) - { - func = sign(fract(0.5 - value)); - } - else if (u_DeformGen == DGEN_WAVE_TRIANGLE) - { - func = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; - } - else if (u_DeformGen == DGEN_WAVE_SAWTOOTH) - { - func = fract(value); - } - else if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH) - { - func = (1.0 - fract(value)); - } - else // if (u_DeformGen == DGEN_BULGE) - { - func = sin(value); - } - - return pos + normal * (base + func * amplitude); -} -#endif - -#if defined(USE_TCGEN) -vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 TCGenVector1) -{ - vec2 tex = attr_TexCoord0.st; - - if (TCGen == TCGEN_LIGHTMAP) - { - tex = attr_TexCoord1.st; - } - else if (TCGen == TCGEN_ENVIRONMENT_MAPPED) - { - vec3 viewer = normalize(u_LocalViewOrigin - position); - vec2 ref = reflect(viewer, normal).yz; - tex.s = ref.x * -0.5 + 0.5; - tex.t = ref.y * 0.5 + 0.5; - } - else if (TCGen == TCGEN_VECTOR) - { - tex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1)); - } - - return tex; -} -#endif - -#if defined(USE_TCMOD) -vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) -{ - float amplitude = offTurb.z; - float phase = offTurb.w * 2.0 * M_PI; - vec2 st2; - st2.x = st.x * texMatrix.x + (st.y * texMatrix.z + offTurb.x); - st2.y = st.x * texMatrix.y + (st.y * texMatrix.w + offTurb.y); - - vec2 offsetPos = vec2(position.x + position.z, position.y); - - vec2 texOffset = sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(phase)); - - return st2 + texOffset * amplitude; -} -#endif - -#if defined(USE_RGBAGEN) -vec4 CalcColor(vec3 position, vec3 normal) -{ - vec4 color = u_VertColor * attr_Color + u_BaseColor; - - if (u_ColorGen == CGEN_LIGHTING_DIFFUSE) - { - float incoming = clamp(dot(normal, u_ModelLightDir), 0.0, 1.0); - - color.rgb = clamp(u_DirectedLight * incoming + u_AmbientLight, 0.0, 1.0); - } - - vec3 viewer = u_LocalViewOrigin - position; - - if (u_AlphaGen == AGEN_LIGHTING_SPECULAR) - { - vec3 lightDir = normalize(vec3(-960.0, 1980.0, 96.0) - position); - vec3 reflected = -reflect(lightDir, normal); - - color.a = clamp(dot(reflected, normalize(viewer)), 0.0, 1.0); - color.a *= color.a; - color.a *= color.a; - } - else if (u_AlphaGen == AGEN_PORTAL) - { - color.a = clamp(length(viewer) / u_PortalRange, 0.0, 1.0); - } - - return color; -} -#endif - -#if defined(USE_FOG) -float CalcFog(vec3 position) -{ - float s = dot(vec4(position, 1.0), u_FogDistance) * 8.0; - float t = dot(vec4(position, 1.0), u_FogDepth); - - float eyeOutside = float(u_FogEyeT < 0.0); - float fogged = float(t >= eyeOutside); - - t += 1e-6; - t *= fogged / (t - u_FogEyeT * eyeOutside); - - return s * t; -} -#endif - -void main() -{ -#if defined(USE_VERTEX_ANIMATION) - vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp); - vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp); -#elif defined(USE_BONE_ANIMATION) - mat4 vtxMat = u_BoneMatrix[int(attr_BoneIndexes.x)] * attr_BoneWeights.x; - vtxMat += u_BoneMatrix[int(attr_BoneIndexes.y)] * attr_BoneWeights.y; - vtxMat += u_BoneMatrix[int(attr_BoneIndexes.z)] * attr_BoneWeights.z; - vtxMat += u_BoneMatrix[int(attr_BoneIndexes.w)] * attr_BoneWeights.w; - mat3 nrmMat = mat3(cross(vtxMat[1].xyz, vtxMat[2].xyz), cross(vtxMat[2].xyz, vtxMat[0].xyz), cross(vtxMat[0].xyz, vtxMat[1].xyz)); - - vec3 position = vec3(vtxMat * vec4(attr_Position, 1.0)); - vec3 normal = normalize(nrmMat * attr_Normal); -#else - vec3 position = attr_Position; - vec3 normal = attr_Normal; -#endif - -#if defined(USE_DEFORM_VERTEXES) - position = DeformPosition(position, normal, attr_TexCoord0.st); -#endif - - gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); - -#if defined(USE_TCGEN) - vec2 tex = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1); -#else - vec2 tex = attr_TexCoord0.st; -#endif - -#if defined(USE_TCMOD) - var_DiffuseTex = ModTexCoords(tex, position, u_DiffuseTexMatrix, u_DiffuseTexOffTurb); -#else - var_DiffuseTex = tex; -#endif - -#if defined(USE_RGBAGEN) - var_Color = CalcColor(position, normal); -#else - var_Color = u_VertColor * attr_Color + u_BaseColor; -#endif - -#if defined(USE_FOG) - var_Color *= vec4(1.0) - u_FogColorMask * sqrt(clamp(CalcFog(position), 0.0, 1.0)); -#endif -} diff --git a/code/renderer2/glsl/lightall_fp.glsl b/code/renderer2/glsl/lightall_fp.glsl deleted file mode 100644 index f4fce3f476..0000000000 --- a/code/renderer2/glsl/lightall_fp.glsl +++ /dev/null @@ -1,516 +0,0 @@ -uniform sampler2D u_DiffuseMap; - -#if defined(USE_LIGHTMAP) -uniform sampler2D u_LightMap; -#endif - -#if defined(USE_NORMALMAP) -uniform sampler2D u_NormalMap; -#endif - -#if defined(USE_DELUXEMAP) -uniform sampler2D u_DeluxeMap; -#endif - -#if defined(USE_SPECULARMAP) -uniform sampler2D u_SpecularMap; -#endif - -#if defined(USE_SHADOWMAP) -uniform sampler2D u_ShadowMap; -#endif - -#if defined(USE_CUBEMAP) -uniform samplerCube u_CubeMap; -#endif - -#if defined(USE_NORMALMAP) || defined(USE_DELUXEMAP) || defined(USE_SPECULARMAP) || defined(USE_CUBEMAP) -// y = deluxe, w = cube -uniform vec4 u_EnableTextures; -#endif - -#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) -uniform vec3 u_PrimaryLightColor; -uniform vec3 u_PrimaryLightAmbient; -#endif - -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) -uniform vec4 u_NormalScale; -uniform vec4 u_SpecularScale; -#endif - -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) -#if defined(USE_CUBEMAP) -uniform vec4 u_CubeMapInfo; -#endif -#endif - -uniform int u_AlphaTest; - -varying vec4 var_TexCoords; - -varying vec4 var_Color; -#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) -varying vec4 var_ColorAmbient; -#endif - -#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) -varying vec4 var_Normal; -varying vec4 var_Tangent; -varying vec4 var_Bitangent; -#endif - -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) -varying vec4 var_LightDir; -#endif - -#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) -varying vec4 var_PrimaryLightDir; -#endif - - -#define EPSILON 0.00000001 - -#if defined(USE_PARALLAXMAP) -float SampleDepth(sampler2D normalMap, vec2 t) -{ - #if defined(SWIZZLE_NORMALMAP) - return 1.0 - texture2D(normalMap, t).r; - #else - return 1.0 - texture2D(normalMap, t).a; - #endif -} - -float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap) -{ - const int linearSearchSteps = 16; - const int binarySearchSteps = 6; - - // current size of search window - float size = 1.0 / float(linearSearchSteps); - - // adjust position if offset above surface - dp -= ds * r_parallaxMapOffset; - // current depth position - float depth = 0.0; - - // best match found (starts with last position 1.0) - float bestDepth = 1.0; - - // texture depth at best depth - float texDepth = 0.0; - - float prevT = SampleDepth(normalMap, dp); - float prevTexDepth = prevT; - - // search front to back for first point inside object - for(int i = 0; i < linearSearchSteps - 1; ++i) - { - depth += size; - - float t = SampleDepth(normalMap, dp + ds * depth); - - if(bestDepth > 0.996) // if no depth found yet - if(depth >= t) - { - bestDepth = depth; // store best depth - texDepth = t; - prevTexDepth = prevT; - } - prevT = t; - } - - depth = bestDepth; - -#if !defined (USE_RELIEFMAP) - float div = 1.0 / (1.0 + (prevTexDepth - texDepth) * float(linearSearchSteps)); - bestDepth -= (depth - size - prevTexDepth) * div; -#else - // recurse around first point (depth) for closest match - for(int i = 0; i < binarySearchSteps; ++i) - { - size *= 0.5; - - float t = SampleDepth(normalMap, dp + ds * depth); - - if(depth >= t) - { - bestDepth = depth; - depth -= 2.0 * size; - } - - depth += size; - } -#endif - - return bestDepth - r_parallaxMapOffset; -} - -float LightRay(vec2 dp, vec2 ds, sampler2D normalMap) -{ - const int linearSearchSteps = 16; - - // current height from initial texel depth - float height = 0.0; - - float startDepth = SampleDepth(normalMap, dp); - - // size of search window - float size = startDepth / float(linearSearchSteps); - - // find a collision or escape - for(int i = 0; i < linearSearchSteps - 1; ++i) - { - height += size; - - float t = SampleDepth(normalMap, dp + ds * height); - - if (startDepth > t + height) - return 0.0; - } - - return 1.0; -} -#endif - -vec3 CalcDiffuse(vec3 diffuseAlbedo, float NH, float EH, float roughness) -{ -#if defined(USE_BURLEY) - // modified from https://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_notes_v2.pdf - float fd90 = -0.5 + EH * EH * roughness; - float burley = 1.0 + fd90 * 0.04 / NH; - burley *= burley; - return diffuseAlbedo * burley; -#else - return diffuseAlbedo; -#endif -} - -vec3 EnvironmentBRDF(float roughness, float NE, vec3 specular) -{ - // from http://community.arm.com/servlet/JiveServlet/download/96891546-19496/siggraph2015-mmg-renaldas-slides.pdf - float v = 1.0 - max(roughness, NE); - v *= v * v; - return vec3(v) + specular; -} - -vec3 CalcSpecular(vec3 specular, float NH, float EH, float roughness) -{ - // from http://community.arm.com/servlet/JiveServlet/download/96891546-19496/siggraph2015-mmg-renaldas-slides.pdf - float rr = roughness*roughness; - float rrrr = rr*rr; - float d = (NH * NH) * (rrrr - 1.0) + 1.0; - float v = (EH * EH) * (roughness + 0.5) + EPSILON; - return specular * (rrrr / (4.0 * d * d * v)); -} - - -float CalcLightAttenuation(float point, float normDist) -{ - // zero light at 1.0, approximating q3 style - // also don't attenuate directional light - float attenuation = (0.5 * normDist - 1.5) * point + 1.0; - - // clamp attenuation - #if defined(NO_LIGHT_CLAMP) - attenuation = max(attenuation, 0.0); - #else - attenuation = clamp(attenuation, 0.0, 1.0); - #endif - - return attenuation; -} - -#if defined(USE_BOX_CUBEMAP_PARALLAX) -vec4 hitCube(vec3 ray, vec3 pos, vec3 invSize, float lod, samplerCube tex) -{ - // find any hits on cubemap faces facing the camera - vec3 scale = (sign(ray) - pos) / ray; - - // find the nearest hit - float minScale = min(min(scale.x, scale.y), scale.z); - - // if the nearest hit is behind the camera, ignore - // should not be necessary as long as pos is inside the cube - //if (minScale < 0.0) - //return vec4(0.0); - - // calculate the hit position, that's our texture coordinates - vec3 tc = pos + ray * minScale; - - // if the texture coordinates are outside the cube, ignore - // necessary since we're not fading out outside the cube - if (any(greaterThan(abs(tc), vec3(1.00001)))) - return vec4(0.0); - - // fade out when approaching the cubemap edges - //vec3 fade3 = abs(pos); - //float fade = max(max(fade3.x, fade3.y), fade3.z); - //fade = clamp(1.0 - fade, 0.0, 1.0); - - //return vec4(textureCubeLod(tex, tc, lod).rgb * fade, fade); - return vec4(textureCubeLod(tex, tc, lod).rgb, 1.0); -} -#endif - -void main() -{ - vec3 viewDir, lightColor, ambientColor, reflectance; - vec3 L, N, E, H; - float NL, NH, NE, EH, attenuation; - -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - mat3 tangentToWorld = mat3(var_Tangent.xyz, var_Bitangent.xyz, var_Normal.xyz); - viewDir = vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w); - E = normalize(viewDir); -#endif - - lightColor = var_Color.rgb; - -#if defined(USE_LIGHTMAP) - vec4 lightmapColor = texture2D(u_LightMap, var_TexCoords.zw); - #if defined(RGBM_LIGHTMAP) - lightmapColor.rgb *= lightmapColor.a; - #endif - #if defined(USE_PBR) && !defined(USE_FAST_LIGHT) - lightmapColor.rgb *= lightmapColor.rgb; - #endif - lightColor *= lightmapColor.rgb; -#endif - - vec2 texCoords = var_TexCoords.xy; - -#if defined(USE_PARALLAXMAP) - vec3 offsetDir = E * tangentToWorld; - - offsetDir.xy *= -u_NormalScale.a / offsetDir.z; - - texCoords += offsetDir.xy * RayIntersectDisplaceMap(texCoords, offsetDir.xy, u_NormalMap); -#endif - - vec4 diffuse = texture2D(u_DiffuseMap, texCoords); - - float alpha = diffuse.a * var_Color.a; - if (u_AlphaTest == 1) - { - if (alpha == 0.0) - discard; - } - else if (u_AlphaTest == 2) - { - if (alpha >= 0.5) - discard; - } - else if (u_AlphaTest == 3) - { - if (alpha < 0.5) - discard; - } - -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - L = var_LightDir.xyz; - #if defined(USE_DELUXEMAP) - L += (texture2D(u_DeluxeMap, var_TexCoords.zw).xyz - vec3(0.5)) * u_EnableTextures.y; - #endif - float sqrLightDist = dot(L, L); - L /= sqrt(sqrLightDist); - - #if defined(USE_LIGHT_VECTOR) - attenuation = CalcLightAttenuation(float(var_LightDir.w > 0.0), var_LightDir.w / sqrLightDist); - #else - attenuation = 1.0; - #endif - - #if defined(USE_NORMALMAP) - #if defined(SWIZZLE_NORMALMAP) - N.xy = texture2D(u_NormalMap, texCoords).ag - vec2(0.5); - #else - N.xy = texture2D(u_NormalMap, texCoords).rg - vec2(0.5); - #endif - N.xy *= u_NormalScale.xy; - N.z = sqrt(clamp((0.25 - N.x * N.x) - N.y * N.y, 0.0, 1.0)); - N = tangentToWorld * N; - #else - N = var_Normal.xyz; - #endif - - N = normalize(N); - - #if defined(USE_SHADOWMAP) - vec2 shadowTex = gl_FragCoord.xy * r_FBufScale; - float shadowValue = texture2D(u_ShadowMap, shadowTex).r; - - // surfaces not facing the light are always shadowed - shadowValue *= clamp(dot(N, var_PrimaryLightDir.xyz), 0.0, 1.0); - - #if defined(SHADOWMAP_MODULATE) - lightColor *= shadowValue * (1.0 - u_PrimaryLightAmbient.r) + u_PrimaryLightAmbient.r; - #endif - #endif - - #if defined(USE_PARALLAXMAP) && defined(USE_PARALLAXMAP_SHADOWS) - offsetDir = L * tangentToWorld; - offsetDir.xy *= u_NormalScale.a / offsetDir.z; - lightColor *= LightRay(texCoords, offsetDir.xy, u_NormalMap); - #endif - - - #if !defined(USE_LIGHT_VECTOR) - ambientColor = lightColor; - float surfNL = clamp(dot(var_Normal.xyz, L), 0.0, 1.0); - - // reserve 25% ambient to avoid black areas on normalmaps - lightColor *= 0.75; - - // Scale the incoming light to compensate for the baked-in light angle - // attenuation. - lightColor /= max(surfNL, 0.25); - - // Recover any unused light as ambient, in case attenuation is over 4x or - // light is below the surface - ambientColor = max(ambientColor - lightColor * surfNL, vec3(0.0)); - #else - ambientColor = var_ColorAmbient.rgb; - #endif - - NL = clamp(dot(N, L), 0.0, 1.0); - NE = clamp(dot(N, E), 0.0, 1.0); - H = normalize(L + E); - EH = clamp(dot(E, H), 0.0, 1.0); - NH = clamp(dot(N, H), 0.0, 1.0); - - #if defined(USE_SPECULARMAP) - vec4 specular = texture2D(u_SpecularMap, texCoords); - #else - vec4 specular = vec4(1.0); - #endif - specular *= u_SpecularScale; - - #if defined(USE_PBR) - diffuse.rgb *= diffuse.rgb; - #endif - - #if defined(USE_PBR) - // diffuse rgb is base color - // specular red is gloss - // specular green is metallicness - float gloss = specular.r; - float metal = specular.g; - specular.rgb = metal * diffuse.rgb + vec3(0.04 - 0.04 * metal); - diffuse.rgb *= 1.0 - metal; - #else - // diffuse rgb is diffuse - // specular rgb is specular reflectance at normal incidence - // specular alpha is gloss - float gloss = specular.a; - - // adjust diffuse by specular reflectance, to maintain energy conservation - diffuse.rgb *= vec3(1.0) - specular.rgb; - #endif - - #if defined(GLOSS_IS_GLOSS) - float roughness = exp2(-3.0 * gloss); - #elif defined(GLOSS_IS_SMOOTHNESS) - float roughness = 1.0 - gloss; - #elif defined(GLOSS_IS_ROUGHNESS) - float roughness = gloss; - #elif defined(GLOSS_IS_SHININESS) - float roughness = pow(2.0 / (8190.0 * gloss + 2.0), 0.25); - #endif - - reflectance = CalcDiffuse(diffuse.rgb, NH, EH, roughness); - - #if defined(r_deluxeSpecular) - #if defined(USE_LIGHT_VECTOR) - reflectance += CalcSpecular(specular.rgb, NH, EH, roughness) * r_deluxeSpecular; - #else - reflectance += CalcSpecular(specular.rgb, NH, EH, pow(roughness, r_deluxeSpecular)); - #endif - #endif - - gl_FragColor.rgb = lightColor * reflectance * (attenuation * NL); - gl_FragColor.rgb += ambientColor * diffuse.rgb; - - #if defined(USE_CUBEMAP) - reflectance = EnvironmentBRDF(roughness, NE, specular.rgb); - - vec3 R = reflect(E, N); - - // parallax corrected cubemap (cheaper trick) - // from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ - vec3 parallax = u_CubeMapInfo.xyz + u_CubeMapInfo.w * viewDir; - - #if defined(USE_BOX_CUBEMAP_PARALLAX) - vec3 cubeLightColor = hitCube(R * u_CubeMapInfo.w, parallax, u_CubeMapInfo.www, ROUGHNESS_MIPS * roughness, u_CubeMap).rgb * u_EnableTextures.w; - #else - vec3 cubeLightColor = textureCubeLod(u_CubeMap, R + parallax, ROUGHNESS_MIPS * roughness).rgb * u_EnableTextures.w; - #endif - - // normalize cubemap based on last roughness mip (~diffuse) - // multiplying cubemap values by lighting below depends on either this or the cubemap being normalized at generation - //vec3 cubeLightDiffuse = max(textureCubeLod(u_CubeMap, N, ROUGHNESS_MIPS).rgb, 0.5 / 255.0); - //cubeLightColor /= dot(cubeLightDiffuse, vec3(0.2125, 0.7154, 0.0721)); - - #if defined(USE_PBR) - cubeLightColor *= cubeLightColor; - #endif - - // multiply cubemap values by lighting - // not technically correct, but helps make reflections look less unnatural - //cubeLightColor *= lightColor * (attenuation * NL) + ambientColor; - - gl_FragColor.rgb += cubeLightColor * reflectance; - #endif - - #if defined(USE_PRIMARY_LIGHT) || defined(SHADOWMAP_MODULATE) - vec3 L2, H2; - float NL2, EH2, NH2; - - L2 = var_PrimaryLightDir.xyz; - - // enable when point lights are supported as primary lights - //sqrLightDist = dot(L2, L2); - //L2 /= sqrt(sqrLightDist); - - NL2 = clamp(dot(N, L2), 0.0, 1.0); - H2 = normalize(L2 + E); - EH2 = clamp(dot(E, H2), 0.0, 1.0); - NH2 = clamp(dot(N, H2), 0.0, 1.0); - - reflectance = CalcSpecular(specular.rgb, NH2, EH2, roughness); - - // bit of a hack, with modulated shadowmaps, ignore diffuse - #if !defined(SHADOWMAP_MODULATE) - reflectance += CalcDiffuse(diffuse.rgb, NH2, EH2, roughness); - #endif - - lightColor = u_PrimaryLightColor; - - #if defined(USE_SHADOWMAP) - lightColor *= shadowValue; - #endif - - // enable when point lights are supported as primary lights - //lightColor *= CalcLightAttenuation(float(u_PrimaryLightDir.w > 0.0), u_PrimaryLightDir.w / sqrLightDist); - - #if defined(USE_PARALLAXMAP) && defined(USE_PARALLAXMAP_SHADOWS) - offsetDir = L2 * tangentToWorld; - offsetDir.xy *= u_NormalScale.a / offsetDir.z; - lightColor *= LightRay(texCoords, offsetDir.xy, u_NormalMap); - #endif - - gl_FragColor.rgb += lightColor * reflectance * NL2; - #endif - - #if defined(USE_PBR) - gl_FragColor.rgb = sqrt(gl_FragColor.rgb); - #endif - -#else - - gl_FragColor.rgb = diffuse.rgb * lightColor; - -#endif - - gl_FragColor.a = alpha; -} diff --git a/code/renderer2/glsl/lightall_vp.glsl b/code/renderer2/glsl/lightall_vp.glsl deleted file mode 100644 index 428cf1e6d1..0000000000 --- a/code/renderer2/glsl/lightall_vp.glsl +++ /dev/null @@ -1,263 +0,0 @@ -attribute vec4 attr_TexCoord0; -#if defined(USE_LIGHTMAP) || defined(USE_TCGEN) -attribute vec4 attr_TexCoord1; -#endif -attribute vec4 attr_Color; - -attribute vec3 attr_Position; -attribute vec3 attr_Normal; -attribute vec4 attr_Tangent; - -#if defined(USE_VERTEX_ANIMATION) -attribute vec3 attr_Position2; -attribute vec3 attr_Normal2; -attribute vec4 attr_Tangent2; -#elif defined(USE_BONE_ANIMATION) -attribute vec4 attr_BoneIndexes; -attribute vec4 attr_BoneWeights; -#endif - -#if defined(USE_LIGHT) && !defined(USE_LIGHT_VECTOR) -attribute vec3 attr_LightDirection; -#endif - -#if defined(USE_DELUXEMAP) -uniform vec4 u_EnableTextures; // x = normal, y = deluxe, z = specular, w = cube -#endif - -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) -uniform vec3 u_ViewOrigin; -#endif - -#if defined(USE_TCGEN) -uniform int u_TCGen0; -uniform vec3 u_TCGen0Vector0; -uniform vec3 u_TCGen0Vector1; -uniform vec3 u_LocalViewOrigin; -#endif - -#if defined(USE_TCMOD) -uniform vec4 u_DiffuseTexMatrix; -uniform vec4 u_DiffuseTexOffTurb; -#endif - -uniform mat4 u_ModelViewProjectionMatrix; -uniform vec4 u_BaseColor; -uniform vec4 u_VertColor; - -#if defined(USE_MODELMATRIX) -uniform mat4 u_ModelMatrix; -#endif - -#if defined(USE_VERTEX_ANIMATION) -uniform float u_VertexLerp; -#elif defined(USE_BONE_ANIMATION) -uniform mat4 u_BoneMatrix[MAX_GLSL_BONES]; -#endif - -#if defined(USE_LIGHT_VECTOR) -uniform vec4 u_LightOrigin; -uniform float u_LightRadius; -uniform vec3 u_DirectedLight; -uniform vec3 u_AmbientLight; -#endif - -#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) -uniform vec4 u_PrimaryLightOrigin; -uniform float u_PrimaryLightRadius; -#endif - -varying vec4 var_TexCoords; - -varying vec4 var_Color; -#if defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT) -varying vec4 var_ColorAmbient; -#endif - -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) -varying vec4 var_Normal; -varying vec4 var_Tangent; -varying vec4 var_Bitangent; -#endif - -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) -varying vec4 var_LightDir; -#endif - -#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) -varying vec4 var_PrimaryLightDir; -#endif - -#if defined(USE_TCGEN) -vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 TCGenVector1) -{ - vec2 tex = attr_TexCoord0.st; - - if (TCGen == TCGEN_LIGHTMAP) - { - tex = attr_TexCoord1.st; - } - else if (TCGen == TCGEN_ENVIRONMENT_MAPPED) - { - vec3 viewer = normalize(u_LocalViewOrigin - position); - vec2 ref = reflect(viewer, normal).yz; - tex.s = ref.x * -0.5 + 0.5; - tex.t = ref.y * 0.5 + 0.5; - } - else if (TCGen == TCGEN_VECTOR) - { - tex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1)); - } - - return tex; -} -#endif - -#if defined(USE_TCMOD) -vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) -{ - float amplitude = offTurb.z; - float phase = offTurb.w * 2.0 * M_PI; - vec2 st2; - st2.x = st.x * texMatrix.x + (st.y * texMatrix.z + offTurb.x); - st2.y = st.x * texMatrix.y + (st.y * texMatrix.w + offTurb.y); - - vec2 offsetPos = vec2(position.x + position.z, position.y); - - vec2 texOffset = sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(phase)); - - return st2 + texOffset * amplitude; -} -#endif - - -float CalcLightAttenuation(float point, float normDist) -{ - // zero light at 1.0, approximating q3 style - // also don't attenuate directional light - float attenuation = (0.5 * normDist - 1.5) * point + 1.0; - - // clamp attenuation - #if defined(NO_LIGHT_CLAMP) - attenuation = max(attenuation, 0.0); - #else - attenuation = clamp(attenuation, 0.0, 1.0); - #endif - - return attenuation; -} - - -void main() -{ -#if defined(USE_VERTEX_ANIMATION) - vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp); - vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp); - #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - vec3 tangent = mix(attr_Tangent.xyz, attr_Tangent2.xyz, u_VertexLerp); - #endif -#elif defined(USE_BONE_ANIMATION) - mat4 vtxMat = u_BoneMatrix[int(attr_BoneIndexes.x)] * attr_BoneWeights.x; - vtxMat += u_BoneMatrix[int(attr_BoneIndexes.y)] * attr_BoneWeights.y; - vtxMat += u_BoneMatrix[int(attr_BoneIndexes.z)] * attr_BoneWeights.z; - vtxMat += u_BoneMatrix[int(attr_BoneIndexes.w)] * attr_BoneWeights.w; - mat3 nrmMat = mat3(cross(vtxMat[1].xyz, vtxMat[2].xyz), cross(vtxMat[2].xyz, vtxMat[0].xyz), cross(vtxMat[0].xyz, vtxMat[1].xyz)); - - vec3 position = vec3(vtxMat * vec4(attr_Position, 1.0)); - vec3 normal = normalize(nrmMat * attr_Normal); - #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - vec3 tangent = normalize(nrmMat * attr_Tangent.xyz); - #endif -#else - vec3 position = attr_Position; - vec3 normal = attr_Normal; - #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - vec3 tangent = attr_Tangent.xyz; - #endif -#endif - -#if defined(USE_TCGEN) - vec2 texCoords = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1); -#else - vec2 texCoords = attr_TexCoord0.st; -#endif - -#if defined(USE_TCMOD) - var_TexCoords.xy = ModTexCoords(texCoords, position, u_DiffuseTexMatrix, u_DiffuseTexOffTurb); -#else - var_TexCoords.xy = texCoords; -#endif - - gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); - -#if defined(USE_MODELMATRIX) - position = (u_ModelMatrix * vec4(position, 1.0)).xyz; - normal = (u_ModelMatrix * vec4(normal, 0.0)).xyz; - #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - tangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz; - #endif -#endif - -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - vec3 bitangent = cross(normal, tangent) * attr_Tangent.w; -#endif - -#if defined(USE_LIGHT_VECTOR) - vec3 L = u_LightOrigin.xyz - (position * u_LightOrigin.w); -#elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - vec3 L = attr_LightDirection; - #if defined(USE_MODELMATRIX) - L = (u_ModelMatrix * vec4(L, 0.0)).xyz; - #endif -#endif - -#if defined(USE_LIGHTMAP) - var_TexCoords.zw = attr_TexCoord1.st; -#endif - - var_Color = u_VertColor * attr_Color + u_BaseColor; - -#if defined(USE_LIGHT_VECTOR) - #if defined(USE_FAST_LIGHT) - float sqrLightDist = dot(L, L); - float NL = clamp(dot(normalize(normal), L) / sqrt(sqrLightDist), 0.0, 1.0); - float attenuation = CalcLightAttenuation(u_LightOrigin.w, u_LightRadius * u_LightRadius / sqrLightDist); - - var_Color.rgb *= u_DirectedLight * (attenuation * NL) + u_AmbientLight; - #else - var_ColorAmbient.rgb = u_AmbientLight * var_Color.rgb; - var_Color.rgb *= u_DirectedLight; - #if defined(USE_PBR) - var_ColorAmbient.rgb *= var_ColorAmbient.rgb; - #endif - #endif -#endif - -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) && defined(USE_PBR) - var_Color.rgb *= var_Color.rgb; -#endif - -#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) - var_PrimaryLightDir.xyz = u_PrimaryLightOrigin.xyz - (position * u_PrimaryLightOrigin.w); - var_PrimaryLightDir.w = u_PrimaryLightRadius * u_PrimaryLightRadius; -#endif - -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - #if defined(USE_LIGHT_VECTOR) - var_LightDir = vec4(L, u_LightRadius * u_LightRadius); - #else - var_LightDir = vec4(L, 0.0); - #endif - #if defined(USE_DELUXEMAP) - var_LightDir -= u_EnableTextures.y * var_LightDir; - #endif -#endif - -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - vec3 viewDir = u_ViewOrigin - position; - // store view direction in tangent space to save on varyings - var_Normal = vec4(normal, viewDir.x); - var_Tangent = vec4(tangent, viewDir.y); - var_Bitangent = vec4(bitangent, viewDir.z); -#endif -} diff --git a/code/renderer2/glsl/pshadow_fp.glsl b/code/renderer2/glsl/pshadow_fp.glsl deleted file mode 100644 index c196f4882b..0000000000 --- a/code/renderer2/glsl/pshadow_fp.glsl +++ /dev/null @@ -1,78 +0,0 @@ -uniform sampler2D u_ShadowMap; - -uniform vec3 u_LightForward; -uniform vec3 u_LightUp; -uniform vec3 u_LightRight; -uniform vec4 u_LightOrigin; -uniform float u_LightRadius; -varying vec3 var_Position; -varying vec3 var_Normal; - -void main() -{ - vec3 lightToPos = var_Position - u_LightOrigin.xyz; - vec2 st = vec2(-dot(u_LightRight, lightToPos), dot(u_LightUp, lightToPos)); - - float fade = length(st); - -#if defined(USE_DISCARD) - if (fade >= 1.0) - { - discard; - } -#endif - - fade = clamp(8.0 - fade * 8.0, 0.0, 1.0); - - st = st * 0.5 + vec2(0.5); - -#if defined(USE_SOLID_PSHADOWS) - float intensity = max(sign(u_LightRadius - length(lightToPos)), 0.0); -#else - float intensity = clamp((1.0 - dot(lightToPos, lightToPos) / (u_LightRadius * u_LightRadius)) * 2.0, 0.0, 1.0); -#endif - - float lightDist = length(lightToPos); - float dist; - -#if defined(USE_DISCARD) - if (dot(u_LightForward, lightToPos) <= 0.0) - { - discard; - } - - if (dot(var_Normal, lightToPos) > 0.0) - { - discard; - } -#else - intensity *= max(sign(dot(u_LightForward, lightToPos)), 0.0); - intensity *= max(sign(-dot(var_Normal, lightToPos)), 0.0); -#endif - - intensity *= fade; - - float part; -#if defined(USE_PCF) - part = float(texture2D(u_ShadowMap, st + vec2(-1.0/512.0, -1.0/512.0)).r != 1.0); - part += float(texture2D(u_ShadowMap, st + vec2( 1.0/512.0, -1.0/512.0)).r != 1.0); - part += float(texture2D(u_ShadowMap, st + vec2(-1.0/512.0, 1.0/512.0)).r != 1.0); - part += float(texture2D(u_ShadowMap, st + vec2( 1.0/512.0, 1.0/512.0)).r != 1.0); -#else - part = float(texture2D(u_ShadowMap, st).r != 1.0); -#endif - - if (part <= 0.0) - { - discard; - } - -#if defined(USE_PCF) - intensity *= part * 0.25; -#else - intensity *= part; -#endif - - gl_FragColor.rgb = vec3(0); - gl_FragColor.a = clamp(intensity, 0.0, 0.75); -} diff --git a/code/renderer2/glsl/pshadow_vp.glsl b/code/renderer2/glsl/pshadow_vp.glsl deleted file mode 100644 index 07a49855bd..0000000000 --- a/code/renderer2/glsl/pshadow_vp.glsl +++ /dev/null @@ -1,15 +0,0 @@ -attribute vec3 attr_Position; -attribute vec3 attr_Normal; - -uniform mat4 u_ModelViewProjectionMatrix; -varying vec3 var_Position; -varying vec3 var_Normal; - - -void main() -{ - gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); - - var_Position = attr_Position; - var_Normal = attr_Normal; -} diff --git a/code/renderer2/glsl/shadowfill_fp.glsl b/code/renderer2/glsl/shadowfill_fp.glsl deleted file mode 100644 index 150f3d1229..0000000000 --- a/code/renderer2/glsl/shadowfill_fp.glsl +++ /dev/null @@ -1,41 +0,0 @@ -uniform vec4 u_LightOrigin; -uniform float u_LightRadius; - -varying vec3 var_Position; - -void main() -{ -#if defined(USE_DEPTH) - float depth = length(u_LightOrigin.xyz - var_Position) / u_LightRadius; - #if 0 - // 32 bit precision - const vec4 bitSh = vec4( 256 * 256 * 256, 256 * 256, 256, 1); - const vec4 bitMsk = vec4( 0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); - - vec4 comp; - comp = depth * bitSh; - comp.xyz = fract(comp.xyz); - comp -= comp.xxyz * bitMsk; - gl_FragColor = comp; - #endif - - #if 1 - // 24 bit precision - const vec3 bitSh = vec3( 256 * 256, 256, 1); - const vec3 bitMsk = vec3( 0, 1.0 / 256.0, 1.0 / 256.0); - - vec3 comp; - comp = depth * bitSh; - comp.xy = fract(comp.xy); - comp -= comp.xxy * bitMsk; - gl_FragColor = vec4(comp, 1.0); - #endif - - #if 0 - // 8 bit precision - gl_FragColor = vec4(depth, depth, depth, 1); - #endif -#else - gl_FragColor = vec4(0, 0, 0, 1); -#endif -} diff --git a/code/renderer2/glsl/shadowfill_vp.glsl b/code/renderer2/glsl/shadowfill_vp.glsl deleted file mode 100644 index 03f8667c9b..0000000000 --- a/code/renderer2/glsl/shadowfill_vp.glsl +++ /dev/null @@ -1,108 +0,0 @@ -attribute vec3 attr_Position; -attribute vec3 attr_Normal; -attribute vec4 attr_TexCoord0; - -#if defined(USE_VERTEX_ANIMATION) -attribute vec3 attr_Position2; -attribute vec3 attr_Normal2; -#elif defined(USE_BONE_ANIMATION) -attribute vec4 attr_BoneIndexes; -attribute vec4 attr_BoneWeights; -#endif - -//#if defined(USE_DEFORM_VERTEXES) -uniform int u_DeformGen; -uniform float u_DeformParams[5]; -//#endif - -uniform float u_Time; -uniform mat4 u_ModelViewProjectionMatrix; - -uniform mat4 u_ModelMatrix; - -#if defined(USE_VERTEX_ANIMATION) -uniform float u_VertexLerp; -#elif defined(USE_BONE_ANIMATION) -uniform mat4 u_BoneMatrix[MAX_GLSL_BONES]; -#endif - -varying vec3 var_Position; - -vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) -{ - if (u_DeformGen == 0) - { - return pos; - } - - float base = u_DeformParams[0]; - float amplitude = u_DeformParams[1]; - float phase = u_DeformParams[2]; - float frequency = u_DeformParams[3]; - float spread = u_DeformParams[4]; - - if (u_DeformGen == DGEN_BULGE) - { - phase *= st.x; - } - else // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH) - { - phase += dot(pos.xyz, vec3(spread)); - } - - float value = phase + (u_Time * frequency); - float func; - - if (u_DeformGen == DGEN_WAVE_SIN) - { - func = sin(value * 2.0 * M_PI); - } - else if (u_DeformGen == DGEN_WAVE_SQUARE) - { - func = sign(0.5 - fract(value)); - } - else if (u_DeformGen == DGEN_WAVE_TRIANGLE) - { - func = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; - } - else if (u_DeformGen == DGEN_WAVE_SAWTOOTH) - { - func = fract(value); - } - else if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH) - { - func = (1.0 - fract(value)); - } - else // if (u_DeformGen == DGEN_BULGE) - { - func = sin(value); - } - - return pos + normal * (base + func * amplitude); -} - -void main() -{ -#if defined(USE_VERTEX_ANIMATION) - vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp); - vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp); -#elif defined(USE_BONE_ANIMATION) - mat4 vtxMat = u_BoneMatrix[int(attr_BoneIndexes.x)] * attr_BoneWeights.x; - vtxMat += u_BoneMatrix[int(attr_BoneIndexes.y)] * attr_BoneWeights.y; - vtxMat += u_BoneMatrix[int(attr_BoneIndexes.z)] * attr_BoneWeights.z; - vtxMat += u_BoneMatrix[int(attr_BoneIndexes.w)] * attr_BoneWeights.w; - mat3 nrmMat = mat3(cross(vtxMat[1].xyz, vtxMat[2].xyz), cross(vtxMat[2].xyz, vtxMat[0].xyz), cross(vtxMat[0].xyz, vtxMat[1].xyz)); - - vec3 position = vec3(vtxMat * vec4(attr_Position, 1.0)); - vec3 normal = normalize(nrmMat * attr_Normal); -#else - vec3 position = attr_Position; - vec3 normal = attr_Normal; -#endif - - position = DeformPosition(position, normal, attr_TexCoord0.st); - - gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); - - var_Position = (u_ModelMatrix * vec4(position, 1.0)).xyz; -} diff --git a/code/renderer2/glsl/shadowmask_fp.glsl b/code/renderer2/glsl/shadowmask_fp.glsl deleted file mode 100644 index 2b57e3ba4b..0000000000 --- a/code/renderer2/glsl/shadowmask_fp.glsl +++ /dev/null @@ -1,143 +0,0 @@ -uniform sampler2D u_ScreenDepthMap; - -uniform sampler2DShadow u_ShadowMap; -#if defined(USE_SHADOW_CASCADE) -uniform sampler2DShadow u_ShadowMap2; -uniform sampler2DShadow u_ShadowMap3; -uniform sampler2DShadow u_ShadowMap4; -#endif - -uniform mat4 u_ShadowMvp; -#if defined(USE_SHADOW_CASCADE) -uniform mat4 u_ShadowMvp2; -uniform mat4 u_ShadowMvp3; -uniform mat4 u_ShadowMvp4; -#endif - -uniform vec3 u_ViewOrigin; -uniform vec4 u_ViewInfo; // zfar / znear, zfar - -varying vec2 var_DepthTex; -varying vec3 var_ViewDir; - -// depth is GL_DEPTH_COMPONENT24 -// so the maximum error is 1.0 / 2^24 -#define DEPTH_MAX_ERROR 0.000000059604644775390625 - -// Input: It uses texture coords as the random number seed. -// Output: Random number: [0,1), that is between 0.0 and 0.999999... inclusive. -// Author: Michael Pohoreski -// Copyright: Copyleft 2012 :-) -// Source: http://stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader - -float random( const vec2 p ) -{ - // We need irrationals for pseudo randomness. - // Most (all?) known transcendental numbers will (generally) work. - const vec2 r = vec2( - 23.1406926327792690, // e^pi (Gelfond's constant) - 2.6651441426902251); // 2^sqrt(2) (Gelfond-Schneider constant) - //return fract( cos( mod( 123456789., 1e-7 + 256. * dot(p,r) ) ) ); - return mod( 123456789., 1e-7 + 256. * dot(p,r) ); -} - -float PCF(const sampler2DShadow shadowmap, const vec2 st, const float dist) -{ - float mult; - float scale = 2.0 / r_shadowMapSize; - -#if 0 - // from http://http.developer.nvidia.com/GPUGems/gpugems_ch11.html - vec2 offset = vec2(greaterThan(fract(var_DepthTex.xy * r_FBufScale * 0.5), vec2(0.25))); - offset.y += offset.x; - if (offset.y > 1.1) offset.y = 0.0; - - mult = shadow2D(shadowmap, vec3(st + (offset + vec2(-1.5, 0.5)) * scale, dist)) - + shadow2D(shadowmap, vec3(st + (offset + vec2( 0.5, 0.5)) * scale, dist)) - + shadow2D(shadowmap, vec3(st + (offset + vec2(-1.5, -1.5)) * scale, dist)) - + shadow2D(shadowmap, vec3(st + (offset + vec2( 0.5, -1.5)) * scale, dist)); - - mult *= 0.25; -#endif - -#if defined(USE_SHADOW_FILTER) - float r = random(var_DepthTex.xy); - float sinr = sin(r) * scale; - float cosr = cos(r) * scale; - mat2 rmat = mat2(cosr, sinr, -sinr, cosr); - - mult = shadow2D(shadowmap, vec3(st + rmat * vec2(-0.7055767, 0.196515), dist)); - mult += shadow2D(shadowmap, vec3(st + rmat * vec2(0.3524343, -0.7791386), dist)); - mult += shadow2D(shadowmap, vec3(st + rmat * vec2(0.2391056, 0.9189604), dist)); - #if defined(USE_SHADOW_FILTER2) - mult += shadow2D(shadowmap, vec3(st + rmat * vec2(-0.07580382, -0.09224417), dist)); - mult += shadow2D(shadowmap, vec3(st + rmat * vec2(0.5784913, -0.002528916), dist)); - mult += shadow2D(shadowmap, vec3(st + rmat * vec2(0.192888, 0.4064181), dist)); - mult += shadow2D(shadowmap, vec3(st + rmat * vec2(-0.6335801, -0.5247476), dist)); - mult += shadow2D(shadowmap, vec3(st + rmat * vec2(-0.5579782, 0.7491854), dist)); - mult += shadow2D(shadowmap, vec3(st + rmat * vec2(0.7320465, 0.6317794), dist)); - - mult *= 0.11111; - #else - mult *= 0.33333; - #endif -#else - mult = shadow2D(shadowmap, vec3(st, dist)); -#endif - - return mult; -} - -float getLinearDepth(sampler2D depthMap, vec2 tex, float zFarDivZNear) -{ - float sampleZDivW = texture2D(depthMap, tex).r - DEPTH_MAX_ERROR; - return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW); -} - -void main() -{ - float result; - - float depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x); - vec4 biasPos = vec4(u_ViewOrigin + var_ViewDir * (depth - 0.5 / u_ViewInfo.x), 1.0); - - vec4 shadowpos = u_ShadowMvp * biasPos; - -#if defined(USE_SHADOW_CASCADE) - if (all(lessThan(abs(shadowpos.xyz), vec3(abs(shadowpos.w))))) - { -#endif - shadowpos.xyz = shadowpos.xyz * (0.5 / shadowpos.w) + vec3(0.5); - result = PCF(u_ShadowMap, shadowpos.xy, shadowpos.z); -#if defined(USE_SHADOW_CASCADE) - } - else - { - shadowpos = u_ShadowMvp2 * biasPos; - - if (all(lessThan(abs(shadowpos.xyz), vec3(abs(shadowpos.w))))) - { - shadowpos.xyz = shadowpos.xyz * (0.5 / shadowpos.w) + vec3(0.5); - result = PCF(u_ShadowMap2, shadowpos.xy, shadowpos.z); - } - else - { - shadowpos = u_ShadowMvp3 * biasPos; - - if (all(lessThan(abs(shadowpos.xyz), vec3(abs(shadowpos.w))))) - { - shadowpos.xyz = shadowpos.xyz * (0.5 / shadowpos.w) + vec3(0.5); - result = PCF(u_ShadowMap3, shadowpos.xy, shadowpos.z); - } - else - { - shadowpos = u_ShadowMvp4 * biasPos; - shadowpos.xyz = shadowpos.xyz * (0.5 / shadowpos.w) + vec3(0.5); - result = PCF(u_ShadowMap4, shadowpos.xy, shadowpos.z); - } - } - } -#endif - - gl_FragColor = vec4(vec3(result), 1.0); -} diff --git a/code/renderer2/glsl/shadowmask_vp.glsl b/code/renderer2/glsl/shadowmask_vp.glsl deleted file mode 100644 index 13166a2400..0000000000 --- a/code/renderer2/glsl/shadowmask_vp.glsl +++ /dev/null @@ -1,18 +0,0 @@ -attribute vec4 attr_Position; -attribute vec4 attr_TexCoord0; - -uniform vec3 u_ViewForward; -uniform vec3 u_ViewLeft; -uniform vec3 u_ViewUp; -uniform vec4 u_ViewInfo; // zfar / znear - -varying vec2 var_DepthTex; -varying vec3 var_ViewDir; - -void main() -{ - gl_Position = attr_Position; - vec2 screenCoords = gl_Position.xy / gl_Position.w; - var_DepthTex = attr_TexCoord0.xy; - var_ViewDir = u_ViewForward + u_ViewLeft * -screenCoords.x + u_ViewUp * screenCoords.y; -} diff --git a/code/renderer2/glsl/ssao_fp.glsl b/code/renderer2/glsl/ssao_fp.glsl deleted file mode 100644 index f3054404fb..0000000000 --- a/code/renderer2/glsl/ssao_fp.glsl +++ /dev/null @@ -1,101 +0,0 @@ -uniform sampler2D u_ScreenDepthMap; - -uniform vec4 u_ViewInfo; // zfar / znear, zfar, 1/width, 1/height - -varying vec2 var_ScreenTex; - -#if 0 -vec2 poissonDisc[9] = vec2[9]( -vec2(-0.7055767, 0.196515), vec2(0.3524343, -0.7791386), -vec2(0.2391056, 0.9189604), vec2(-0.07580382, -0.09224417), -vec2(0.5784913, -0.002528916), vec2(0.192888, 0.4064181), -vec2(-0.6335801, -0.5247476), vec2(-0.5579782, 0.7491854), -vec2(0.7320465, 0.6317794) -); -#endif - -#define NUM_SAMPLES 3 - -// Input: It uses texture coords as the random number seed. -// Output: Random number: [0,1), that is between 0.0 and 0.999999... inclusive. -// Author: Michael Pohoreski -// Copyright: Copyleft 2012 :-) -// Source: http://stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader - -float random( const vec2 p ) -{ - // We need irrationals for pseudo randomness. - // Most (all?) known transcendental numbers will (generally) work. - const vec2 r = vec2( - 23.1406926327792690, // e^pi (Gelfond's constant) - 2.6651441426902251); // 2^sqrt(2) (Gelfond-Schneider constant) - //return fract( cos( mod( 123456789., 1e-7 + 256. * dot(p,r) ) ) ); - return mod( 123456789., 1e-7 + 256. * dot(p,r) ); -} - -mat2 randomRotation( const vec2 p ) -{ - float r = random(p); - float sinr = sin(r); - float cosr = cos(r); - return mat2(cosr, sinr, -sinr, cosr); -} - -float getLinearDepth(sampler2D depthMap, const vec2 tex, const float zFarDivZNear) -{ - float sampleZDivW = texture2D(depthMap, tex).r; - return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW); -} - -float ambientOcclusion(sampler2D depthMap, const vec2 tex, const float zFarDivZNear, const float zFar, const vec2 scale) -{ - vec2 poissonDisc[9]; - - poissonDisc[0] = vec2(-0.7055767, 0.196515); - poissonDisc[1] = vec2(0.3524343, -0.7791386); - poissonDisc[2] = vec2(0.2391056, 0.9189604); - poissonDisc[3] = vec2(-0.07580382, -0.09224417); - poissonDisc[4] = vec2(0.5784913, -0.002528916); - poissonDisc[5] = vec2(0.192888, 0.4064181); - poissonDisc[6] = vec2(-0.6335801, -0.5247476); - poissonDisc[7] = vec2(-0.5579782, 0.7491854); - poissonDisc[8] = vec2(0.7320465, 0.6317794); - - float result = 0.0; - - float sampleZ = getLinearDepth(depthMap, tex, zFarDivZNear); - float scaleZ = zFarDivZNear * sampleZ; - - vec2 slope = vec2(dFdx(sampleZ), dFdy(sampleZ)) / vec2(dFdx(tex.x), dFdy(tex.y)); - - if (length(slope) * zFar > 5000.0) - return 1.0; - - vec2 offsetScale = vec2(scale * 1024.0 / scaleZ); - - mat2 rmat = randomRotation(tex); - - float invZFar = 1.0 / zFar; - float zLimit = 20.0 * invZFar; - int i; - for (i = 0; i < NUM_SAMPLES; i++) - { - vec2 offset = rmat * poissonDisc[i] * offsetScale; - float sampleDiff = getLinearDepth(depthMap, tex + offset, zFarDivZNear) - sampleZ; - - bool s1 = abs(sampleDiff) > zLimit; - bool s2 = sampleDiff + invZFar > dot(slope, offset); - result += float(s1 || s2); - } - - result *= 1.0 / float(NUM_SAMPLES); - - return result; -} - -void main() -{ - float result = ambientOcclusion(u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y, u_ViewInfo.wz); - - gl_FragColor = vec4(vec3(result), 1.0); -} diff --git a/code/renderer2/glsl/ssao_vp.glsl b/code/renderer2/glsl/ssao_vp.glsl deleted file mode 100644 index 9c46a79f26..0000000000 --- a/code/renderer2/glsl/ssao_vp.glsl +++ /dev/null @@ -1,12 +0,0 @@ -attribute vec4 attr_Position; -attribute vec4 attr_TexCoord0; - -varying vec2 var_ScreenTex; - -void main() -{ - gl_Position = attr_Position; - var_ScreenTex = attr_TexCoord0.xy; - //vec2 screenCoords = gl_Position.xy / gl_Position.w; - //var_ScreenTex = screenCoords * 0.5 + 0.5; -} diff --git a/code/renderer2/glsl/texturecolor_fp.glsl b/code/renderer2/glsl/texturecolor_fp.glsl deleted file mode 100644 index 7c9046e18e..0000000000 --- a/code/renderer2/glsl/texturecolor_fp.glsl +++ /dev/null @@ -1,10 +0,0 @@ -uniform sampler2D u_DiffuseMap; -uniform vec4 u_Color; - -varying vec2 var_Tex1; - - -void main() -{ - gl_FragColor = texture2D(u_DiffuseMap, var_Tex1) * u_Color; -} diff --git a/code/renderer2/glsl/texturecolor_vp.glsl b/code/renderer2/glsl/texturecolor_vp.glsl deleted file mode 100644 index 552cd93837..0000000000 --- a/code/renderer2/glsl/texturecolor_vp.glsl +++ /dev/null @@ -1,13 +0,0 @@ -attribute vec3 attr_Position; -attribute vec4 attr_TexCoord0; - -uniform mat4 u_ModelViewProjectionMatrix; - -varying vec2 var_Tex1; - - -void main() -{ - gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); - var_Tex1 = attr_TexCoord0.st; -} diff --git a/code/renderer2/glsl/tonemap_fp.glsl b/code/renderer2/glsl/tonemap_fp.glsl deleted file mode 100644 index 9e24e24adb..0000000000 --- a/code/renderer2/glsl/tonemap_fp.glsl +++ /dev/null @@ -1,57 +0,0 @@ -uniform sampler2D u_TextureMap; -uniform sampler2D u_LevelsMap; - -uniform vec4 u_Color; - - -uniform vec2 u_AutoExposureMinMax; -uniform vec3 u_ToneMinAvgMaxLinear; - -varying vec2 var_TexCoords; -varying float var_InvWhite; - -const vec3 LUMINANCE_VECTOR = vec3(0.2125, 0.7154, 0.0721); //vec3(0.299, 0.587, 0.114); - -float FilmicTonemap(float x) -{ - const float SS = 0.22; // Shoulder Strength - const float LS = 0.30; // Linear Strength - const float LA = 0.10; // Linear Angle - const float TS = 0.20; // Toe Strength - const float TAN = 0.01; // Toe Angle Numerator - const float TAD = 0.30; // Toe Angle Denominator - - return ((x*(SS*x+LA*LS)+TS*TAN)/(x*(SS*x+LS)+TS*TAD)) - TAN/TAD; -} - -void main() -{ - vec4 color = texture2D(u_TextureMap, var_TexCoords) * u_Color; - -#if defined(USE_PBR) - color.rgb *= color.rgb; -#endif - - vec3 minAvgMax = texture2D(u_LevelsMap, var_TexCoords).rgb; - vec3 logMinAvgMaxLum = clamp(minAvgMax * 20.0 - 10.0, -u_AutoExposureMinMax.y, -u_AutoExposureMinMax.x); - - float invAvgLum = u_ToneMinAvgMaxLinear.y * exp2(-logMinAvgMaxLum.y); - - color.rgb = color.rgb * invAvgLum - u_ToneMinAvgMaxLinear.xxx; - color.rgb = max(vec3(0.0), color.rgb); - - color.r = FilmicTonemap(color.r); - color.g = FilmicTonemap(color.g); - color.b = FilmicTonemap(color.b); - - color.rgb = clamp(color.rgb * var_InvWhite, 0.0, 1.0); - -#if defined(USE_PBR) - color.rgb = sqrt(color.rgb); -#endif - - // add a bit of dither to reduce banding - color.rgb += vec3(1.0/510.0 * mod(gl_FragCoord.x + gl_FragCoord.y, 2.0) - 1.0/1020.0); - - gl_FragColor = color; -} diff --git a/code/renderer2/glsl/tonemap_vp.glsl b/code/renderer2/glsl/tonemap_vp.glsl deleted file mode 100644 index 577c0a1a9a..0000000000 --- a/code/renderer2/glsl/tonemap_vp.glsl +++ /dev/null @@ -1,27 +0,0 @@ -attribute vec3 attr_Position; -attribute vec4 attr_TexCoord0; - -uniform mat4 u_ModelViewProjectionMatrix; -uniform vec3 u_ToneMinAvgMaxLinear; - -varying vec2 var_TexCoords; -varying float var_InvWhite; - -float FilmicTonemap(float x) -{ - const float SS = 0.22; // Shoulder Strength - const float LS = 0.30; // Linear Strength - const float LA = 0.10; // Linear Angle - const float TS = 0.20; // Toe Strength - const float TAN = 0.01; // Toe Angle Numerator - const float TAD = 0.30; // Toe Angle Denominator - - return ((x*(SS*x+LA*LS)+TS*TAN)/(x*(SS*x+LS)+TS*TAD)) - TAN/TAD; -} - -void main() -{ - gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); - var_TexCoords = attr_TexCoord0.st; - var_InvWhite = 1.0 / FilmicTonemap(u_ToneMinAvgMaxLinear.z - u_ToneMinAvgMaxLinear.x); -} diff --git a/code/renderer2/qgl.h b/code/renderer2/qgl.h deleted file mode 100644 index 64b11ffab2..0000000000 --- a/code/renderer2/qgl.h +++ /dev/null @@ -1,402 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -/* -** QGL.H -*/ - -#ifndef __QGL_H__ -#define __QGL_H__ - -#if defined( _WIN32 ) -#if _MSC_VER -#pragma warning (disable: 4201) -#pragma warning (disable: 4214) -#pragma warning (disable: 4514) -#pragma warning (disable: 4032) -#pragma warning (disable: 4201) -#pragma warning (disable: 4214) -#endif -#include -#include -#elif defined( __linux__ ) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __sun ) -#include -#include -#elif defined(__APPLE__) -#define GL_NUM_EXTENSIONS 0x821D -#include -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif - -//=========================================================================== -// I hate this section so much - -/* -** multitexture extension definitions -*/ -#if !defined(__sun) - -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_ACTIVE_TEXTURES_ARB 0x84E2 - -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 - -#else - -#define GL_MAX_ACTIVE_TEXTURES_ARB 0x84E2 - -#endif /* defined(__sun) */ - -// anisotropic filtering constants -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF - -// define for skyboxes without black seams -#if !defined(GL_VERSION_1_2) && !defined(GL_CLAMP_TO_EDGE) - #define GL_CLAMP_TO_EDGE 0x812F -#endif - - -/* -** extension constants -*/ -// S3TC compression constants -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 - -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 - -#ifndef GL_EXT_texture_sRGB -#define GL_EXT_texture_sRGB -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB8_EXT 0x8C41 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define GL_SLUMINANCE_EXT 0x8C46 -#define GL_SLUMINANCE8_EXT 0x8C47 -#define GL_COMPRESSED_SRGB_EXT 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F -#endif - - -//=========================================================================== - -// renderer2 extensions -#include "glext.h" - -// GL function loader, based on https://gist.github.com/rygorous/16796a0c876cf8a5f542caddb55bce8a -// get missing functions from code/SDL2/include/SDL_opengl.h - -// OpenGL 1.0/1.1 and OpenGL ES 1.0 -#define QGL_1_1_PROCS \ - GLE(void, AlphaFunc, GLenum func, GLclampf ref) \ - GLE(void, BindTexture, GLenum target, GLuint texture) \ - GLE(void, BlendFunc, GLenum sfactor, GLenum dfactor) \ - GLE(void, ClearColor, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) \ - GLE(void, Clear, GLbitfield mask) \ - GLE(void, ClearStencil, GLint s) \ - GLE(void, Color4f, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) \ - GLE(void, ColorMask, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) \ - GLE(void, ColorPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) \ - GLE(void, CopyTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) \ - GLE(void, CullFace, GLenum mode) \ - GLE(void, DeleteTextures, GLsizei n, const GLuint *textures) \ - GLE(void, DepthFunc, GLenum func) \ - GLE(void, DepthMask, GLboolean flag) \ - GLE(void, DisableClientState, GLenum cap) \ - GLE(void, Disable, GLenum cap) \ - GLE(void, DrawArrays, GLenum mode, GLint first, GLsizei count) \ - GLE(void, DrawElements, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) \ - GLE(void, EnableClientState, GLenum cap) \ - GLE(void, Enable, GLenum cap) \ - GLE(void, Finish, void) \ - GLE(void, Flush, void) \ - GLE(void, GenTextures, GLsizei n, GLuint *textures ) \ - GLE(void, GetBooleanv, GLenum pname, GLboolean *params) \ - GLE(GLenum, GetError, void) \ - GLE(void, GetIntegerv, GLenum pname, GLint *params) \ - GLE(const GLubyte *, GetString, GLenum name) \ - GLE(void, LineWidth, GLfloat width) \ - GLE(void, LoadIdentity, void) \ - GLE(void, LoadMatrixf, const GLfloat *m) \ - GLE(void, MatrixMode, GLenum mode) \ - GLE(void, PolygonOffset, GLfloat factor, GLfloat units) \ - GLE(void, PopMatrix, void) \ - GLE(void, PushMatrix, void) \ - GLE(void, ReadPixels, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) \ - GLE(void, Scissor, GLint x, GLint y, GLsizei width, GLsizei height) \ - GLE(void, ShadeModel, GLenum mode) \ - GLE(void, StencilFunc, GLenum func, GLint ref, GLuint mask) \ - GLE(void, StencilMask, GLuint mask) \ - GLE(void, StencilOp, GLenum fail, GLenum zfail, GLenum zpass) \ - GLE(void, TexCoordPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) \ - GLE(void, TexEnvf, GLenum target, GLenum pname, GLfloat param) \ - GLE(void, TexImage2D, GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) \ - GLE(void, TexParameterf, GLenum target, GLenum pname, GLfloat param) \ - GLE(void, TexParameteri, GLenum target, GLenum pname, GLint param) \ - GLE(void, TexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) \ - GLE(void, Translatef, GLfloat x, GLfloat y, GLfloat z) \ - GLE(void, VertexPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) \ - GLE(void, Viewport, GLint x, GLint y, GLsizei width, GLsizei height) \ - -// OpenGL 1.0/1.1 but not OpenGL ES 1.x -#define QGL_DESKTOP_1_1_PROCS \ - GLE(void, ArrayElement, GLint i) \ - GLE(void, Begin, GLenum mode) \ - GLE(void, ClearDepth, GLclampd depth) \ - GLE(void, ClipPlane, GLenum plane, const GLdouble *equation) \ - GLE(void, Color3f, GLfloat red, GLfloat green, GLfloat blue) \ - GLE(void, Color4ubv, const GLubyte *v) \ - GLE(void, DepthRange, GLclampd near_val, GLclampd far_val) \ - GLE(void, DrawBuffer, GLenum mode) \ - GLE(void, End, void) \ - GLE(void, Frustum, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val) \ - GLE(void, Ortho, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val) \ - GLE(void, PolygonMode, GLenum face, GLenum mode) \ - GLE(void, TexCoord2f, GLfloat s, GLfloat t) \ - GLE(void, TexCoord2fv, const GLfloat *v) \ - GLE(void, Vertex2f, GLfloat x, GLfloat y) \ - GLE(void, Vertex3f, GLfloat x, GLfloat y, GLfloat z) \ - GLE(void, Vertex3fv, const GLfloat *v) \ - -// OpenGL ES 1.1 but not desktop OpenGL 1.x -#define QGL_ES_1_1_PROCS \ - GLE(void, ClearDepthf, GLclampf depth) \ - GLE(void, ClipPlanef, GLenum plane, const GLfloat *equation) \ - GLE(void, DepthRangef, GLclampf near_val, GLclampf far_val) \ - GLE(void, Frustumf, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat near_val, GLfloat far_val) \ - GLE(void, Orthof, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat near_val, GLfloat far_val) \ - -// OpenGL 1.3, was GL_ARB_texture_compression -#define QGL_1_3_PROCS \ - GLE(void, ActiveTexture, GLenum texture) \ - GLE(void, CompressedTexImage2D, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data) \ - GLE(void, CompressedTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data) \ - -// OpenGL 1.5, was GL_ARB_vertex_buffer_object and GL_ARB_occlusion_query -#define QGL_1_5_PROCS \ - GLE(void, GenQueries, GLsizei n, GLuint *ids) \ - GLE(void, DeleteQueries, GLsizei n, const GLuint *ids) \ - GLE(void, BeginQuery, GLenum target, GLuint id) \ - GLE(void, EndQuery, GLenum target) \ - GLE(void, GetQueryObjectiv, GLuint id, GLenum pname, GLint *params) \ - GLE(void, GetQueryObjectuiv, GLuint id, GLenum pname, GLuint *params) \ - GLE(void, BindBuffer, GLenum target, GLuint buffer) \ - GLE(void, DeleteBuffers, GLsizei n, const GLuint *buffers) \ - GLE(void, GenBuffers, GLsizei n, GLuint *buffers) \ - GLE(void, BufferData, GLenum target, GLsizeiptr size, const void *data, GLenum usage) \ - GLE(void, BufferSubData, GLenum target, GLintptr offset, GLsizeiptr size, const void *data) \ - -// OpenGL 2.0, was GL_ARB_shading_language_100, GL_ARB_vertex_program, GL_ARB_shader_objects, and GL_ARB_vertex_shader -#define QGL_2_0_PROCS \ - GLE(void, AttachShader, GLuint program, GLuint shader) \ - GLE(void, BindAttribLocation, GLuint program, GLuint index, const GLchar *name) \ - GLE(void, CompileShader, GLuint shader) \ - GLE(GLuint, CreateProgram, void) \ - GLE(GLuint, CreateShader, GLenum type) \ - GLE(void, DeleteProgram, GLuint program) \ - GLE(void, DeleteShader, GLuint shader) \ - GLE(void, DetachShader, GLuint program, GLuint shader) \ - GLE(void, DisableVertexAttribArray, GLuint index) \ - GLE(void, EnableVertexAttribArray, GLuint index) \ - GLE(void, GetActiveUniform, GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) \ - GLE(void, GetProgramiv, GLuint program, GLenum pname, GLint *params) \ - GLE(void, GetProgramInfoLog, GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog) \ - GLE(void, GetShaderiv, GLuint shader, GLenum pname, GLint *params) \ - GLE(void, GetShaderInfoLog, GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) \ - GLE(void, GetShaderSource, GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source) \ - GLE(GLint, GetUniformLocation, GLuint program, const GLchar *name) \ - GLE(void, LinkProgram, GLuint program) \ - GLE(void, ShaderSource, GLuint shader, GLsizei count, const GLchar* *string, const GLint *length) \ - GLE(void, UseProgram, GLuint program) \ - GLE(void, Uniform1f, GLint location, GLfloat v0) \ - GLE(void, Uniform2f, GLint location, GLfloat v0, GLfloat v1) \ - GLE(void, Uniform3f, GLint location, GLfloat v0, GLfloat v1, GLfloat v2) \ - GLE(void, Uniform4f, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) \ - GLE(void, Uniform1i, GLint location, GLint v0) \ - GLE(void, Uniform1fv, GLint location, GLsizei count, const GLfloat *value) \ - GLE(void, UniformMatrix4fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) \ - GLE(void, ValidateProgram, GLuint program) \ - GLE(void, VertexAttribPointer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer) \ - -// GL_NVX_gpu_memory_info -#ifndef GL_NVX_gpu_memory_info -#define GL_NVX_gpu_memory_info -#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 -#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 -#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 -#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A -#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B -#endif - -// GL_ATI_meminfo -#ifndef GL_ATI_meminfo -#define GL_ATI_meminfo -#define GL_VBO_FREE_MEMORY_ATI 0x87FB -#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC -#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD -#endif - -// GL_ARB_texture_float -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel -#define GL_HALF_FLOAT_ARB 0x140B -#endif - -// OpenGL 3.0 specific -#define QGL_3_0_PROCS \ - GLE(const GLubyte *, GetStringi, GLenum name, GLuint index) \ - -// GL_ARB_framebuffer_object, built-in to OpenGL 3.0 -#define QGL_ARB_framebuffer_object_PROCS \ - GLE(void, BindRenderbuffer, GLenum target, GLuint renderbuffer) \ - GLE(void, DeleteRenderbuffers, GLsizei n, const GLuint *renderbuffers) \ - GLE(void, GenRenderbuffers, GLsizei n, GLuint *renderbuffers) \ - GLE(void, RenderbufferStorage, GLenum target, GLenum internalformat, GLsizei width, GLsizei height) \ - GLE(void, BindFramebuffer, GLenum target, GLuint framebuffer) \ - GLE(void, DeleteFramebuffers, GLsizei n, const GLuint *framebuffers) \ - GLE(void, GenFramebuffers, GLsizei n, GLuint *framebuffers) \ - GLE(GLenum, CheckFramebufferStatus, GLenum target) \ - GLE(void, FramebufferTexture2D, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) \ - GLE(void, FramebufferRenderbuffer, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) \ - GLE(void, GenerateMipmap, GLenum target) \ - GLE(void, BlitFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) \ - GLE(void, RenderbufferStorageMultisample, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) \ - -// GL_ARB_vertex_array_object, built-in to OpenGL 3.0 -#define QGL_ARB_vertex_array_object_PROCS \ - GLE(void, BindVertexArray, GLuint array) \ - GLE(void, DeleteVertexArrays, GLsizei n, const GLuint *arrays) \ - GLE(void, GenVertexArrays, GLsizei n, GLuint *arrays) \ - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_ARB_texture_compression_rgtc -#define GL_COMPRESSED_RED_RGTC1 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC -#define GL_COMPRESSED_RG_RGTC2 0x8DBD -#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE -#endif - -#ifndef GL_ARB_texture_compression_bptc -#define GL_ARB_texture_compression_bptc -#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C -#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D -#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E -#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F -#endif - -#ifndef GL_ARB_depth_clamp -#define GL_ARB_depth_clamp -#define GL_DEPTH_CLAMP 0x864F -#endif - -#ifndef GL_ARB_seamless_cube_map -#define GL_ARB_seamless_cube_map -#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F -#endif - -// GL_EXT_direct_state_access -#define QGL_EXT_direct_state_access_PROCS \ - GLE(GLvoid, BindMultiTextureEXT, GLenum texunit, GLenum target, GLuint texture) \ - GLE(GLvoid, TextureParameterfEXT, GLuint texture, GLenum target, GLenum pname, GLfloat param) \ - GLE(GLvoid, TextureParameteriEXT, GLuint texture, GLenum target, GLenum pname, GLint param) \ - GLE(GLvoid, TextureImage2DEXT, GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) \ - GLE(GLvoid, TextureSubImage2DEXT, GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) \ - GLE(GLvoid, CopyTextureSubImage2DEXT, GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) \ - GLE(GLvoid, CompressedTextureImage2DEXT, GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) \ - GLE(GLvoid, CompressedTextureSubImage2DEXT, GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) \ - GLE(GLvoid, GenerateTextureMipmapEXT, GLuint texture, GLenum target) \ - GLE(GLvoid, ProgramUniform1iEXT, GLuint program, GLint location, GLint v0) \ - GLE(GLvoid, ProgramUniform1fEXT, GLuint program, GLint location, GLfloat v0) \ - GLE(GLvoid, ProgramUniform2fEXT, GLuint program, GLint location, GLfloat v0, GLfloat v1) \ - GLE(GLvoid, ProgramUniform3fEXT, GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2) \ - GLE(GLvoid, ProgramUniform4fEXT, GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) \ - GLE(GLvoid, ProgramUniform1fvEXT, GLuint program, GLint location, GLsizei count, const GLfloat *value) \ - GLE(GLvoid, ProgramUniformMatrix4fvEXT, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) \ - GLE(GLvoid, NamedRenderbufferStorageEXT, GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height) \ - GLE(GLvoid, NamedRenderbufferStorageMultisampleEXT, GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) \ - GLE(GLenum, CheckNamedFramebufferStatusEXT, GLuint framebuffer, GLenum target) \ - GLE(GLvoid, NamedFramebufferTexture2DEXT, GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level) \ - GLE(GLvoid, NamedFramebufferRenderbufferEXT, GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) \ - -#define GLE(ret, name, ...) typedef ret APIENTRY name##proc(__VA_ARGS__); extern name##proc * qgl##name; -QGL_1_1_PROCS; -QGL_DESKTOP_1_1_PROCS; -QGL_ES_1_1_PROCS; -QGL_1_3_PROCS; -QGL_1_5_PROCS; -QGL_2_0_PROCS; -QGL_3_0_PROCS; -QGL_ARB_framebuffer_object_PROCS; -QGL_ARB_vertex_array_object_PROCS; -QGL_EXT_direct_state_access_PROCS; -#undef GLE - -extern int qglMajorVersion, qglMinorVersion; -extern int qglesMajorVersion, qglesMinorVersion; -#define QGL_VERSION_ATLEAST( major, minor ) ( qglMajorVersion > major || ( qglMajorVersion == major && qglMinorVersion >= minor ) ) -#define QGLES_VERSION_ATLEAST( major, minor ) ( qglesMajorVersion > major || ( qglesMajorVersion == major && qglesMinorVersion >= minor ) ) - - -#endif // __QGL_H__ diff --git a/code/renderer2/stringify.c b/code/renderer2/stringify.c deleted file mode 100644 index a5ce84b0f0..0000000000 --- a/code/renderer2/stringify.c +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include -#include -#include - -int main(int argc, char **argv) -{ - FILE *ifp; - FILE *ofp; - char buffer[1024]; - - if(argc < 3) - return 1; - - char *inFile = argv[1]; - char *outFile = argv[2]; - - ifp = fopen(inFile, "r"); - if(!ifp) - return 2; - - ofp = fopen(outFile, "w"); - if(!ofp) - return 3; - - // Strip extension - char *base = basename(inFile); - *strrchr(base, '.') = '\0'; - - fprintf(ofp, "const char *fallbackShader_%s =\n", base); - - while(fgets(buffer, sizeof(buffer), ifp)) - { - // Strip trailing whitespace from line - char *end = buffer + strlen(buffer) - 1; - while(end >= buffer && isspace(*end)) - end--; - - end[1] = '\0'; - - // Write line enquoted, with a newline - fprintf(ofp, "\"%s\\n\"\n", buffer); - } - - fprintf(ofp, ";\n"); - - fclose(ifp); - fclose(ofp); - - return 0; -} diff --git a/code/renderer2/tr_animation.c b/code/renderer2/tr_animation.c deleted file mode 100644 index ed1fc0ce94..0000000000 --- a/code/renderer2/tr_animation.c +++ /dev/null @@ -1,523 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ - -#include "tr_local.h" - -/* - -All bones should be an identity orientation to display the mesh exactly -as it is specified. - -For all other frames, the bones represent the transformation from the -orientation of the bone in the base frame to the orientation in this -frame. - -*/ - - -// copied and adapted from tr_mesh.c - -/* -============= -R_MDRCullModel -============= -*/ - -static int R_MDRCullModel( mdrHeader_t *header, const trRefEntity_t *ent ) { - vec3_t bounds[2]; - mdrFrame_t *oldFrame, *newFrame; - int i, frameSize; - - frameSize = (size_t)( &((mdrFrame_t *)0)->bones[ header->numBones ] ); - - // compute frame pointers - newFrame = ( mdrFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.frame); - oldFrame = ( mdrFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.oldframe); - - // cull bounding sphere ONLY if this is not an upscaled entity - if ( !ent->e.nonNormalizedAxes ) - { - if ( ent->e.frame == ent->e.oldframe ) - { - switch ( R_CullLocalPointAndRadius( newFrame->localOrigin, newFrame->radius ) ) - { - // Ummm... yeah yeah I know we don't really have an md3 here.. but we pretend - // we do. After all, the purpose of mdrs are not that different, are they? - - case CULL_OUT: - tr.pc.c_sphere_cull_md3_out++; - return CULL_OUT; - - case CULL_IN: - tr.pc.c_sphere_cull_md3_in++; - return CULL_IN; - - case CULL_CLIP: - tr.pc.c_sphere_cull_md3_clip++; - break; - } - } - else - { - int sphereCull, sphereCullB; - - sphereCull = R_CullLocalPointAndRadius( newFrame->localOrigin, newFrame->radius ); - if ( newFrame == oldFrame ) { - sphereCullB = sphereCull; - } else { - sphereCullB = R_CullLocalPointAndRadius( oldFrame->localOrigin, oldFrame->radius ); - } - - if ( sphereCull == sphereCullB ) - { - if ( sphereCull == CULL_OUT ) - { - tr.pc.c_sphere_cull_md3_out++; - return CULL_OUT; - } - else if ( sphereCull == CULL_IN ) - { - tr.pc.c_sphere_cull_md3_in++; - return CULL_IN; - } - else - { - tr.pc.c_sphere_cull_md3_clip++; - } - } - } - } - - // calculate a bounding box in the current coordinate system - for (i = 0 ; i < 3 ; i++) { - bounds[0][i] = oldFrame->bounds[0][i] < newFrame->bounds[0][i] ? oldFrame->bounds[0][i] : newFrame->bounds[0][i]; - bounds[1][i] = oldFrame->bounds[1][i] > newFrame->bounds[1][i] ? oldFrame->bounds[1][i] : newFrame->bounds[1][i]; - } - - switch ( R_CullLocalBox( bounds ) ) - { - case CULL_IN: - tr.pc.c_box_cull_md3_in++; - return CULL_IN; - case CULL_CLIP: - tr.pc.c_box_cull_md3_clip++; - return CULL_CLIP; - case CULL_OUT: - default: - tr.pc.c_box_cull_md3_out++; - return CULL_OUT; - } -} - -/* -================= -R_MDRComputeFogNum - -================= -*/ - -static int R_MDRComputeFogNum( mdrHeader_t *header, const trRefEntity_t *ent ) { - int i, j; - const fog_t *fog; - mdrFrame_t *mdrFrame; - vec3_t localOrigin; - int frameSize; - - if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { - return 0; - } - - frameSize = (size_t)( &((mdrFrame_t *)0)->bones[ header->numBones ] ); - - // FIXME: non-normalized axis issues - mdrFrame = ( mdrFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.frame); - VectorAdd( ent->e.origin, mdrFrame->localOrigin, localOrigin ); - for ( i = 1 ; i < tr.world->numfogs ; i++ ) { - fog = &tr.world->fogs[i]; - for ( j = 0 ; j < 3 ; j++ ) { - if ( localOrigin[j] - mdrFrame->radius >= fog->bounds[1][j] ) { - break; - } - if ( localOrigin[j] + mdrFrame->radius <= fog->bounds[0][j] ) { - break; - } - } - if ( j == 3 ) { - return i; - } - } - - return 0; -} - - -/* -============== -R_MDRAddAnimSurfaces -============== -*/ - -// much stuff in there is just copied from R_AddMd3Surfaces in tr_mesh.c - -void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { - mdrHeader_t *header; - mdrSurface_t *surface; - mdrLOD_t *lod; - shader_t *shader; - skin_t *skin; - int i, j; - int lodnum = 0; - int fogNum = 0; - int cull; - int cubemapIndex; - qboolean personalModel; - - header = (mdrHeader_t *) tr.currentModel->modelData; - - personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal - || (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW))); - - if ( ent->e.renderfx & RF_WRAP_FRAMES ) - { - ent->e.frame %= header->numFrames; - ent->e.oldframe %= header->numFrames; - } - - // - // Validate the frames so there is no chance of a crash. - // This will write directly into the entity structure, so - // when the surfaces are rendered, they don't need to be - // range checked again. - // - if ((ent->e.frame >= header->numFrames) - || (ent->e.frame < 0) - || (ent->e.oldframe >= header->numFrames) - || (ent->e.oldframe < 0) ) - { - ri.Printf( PRINT_DEVELOPER, "R_MDRAddAnimSurfaces: no such frame %d to %d for '%s'\n", - ent->e.oldframe, ent->e.frame, tr.currentModel->name ); - ent->e.frame = 0; - ent->e.oldframe = 0; - } - - // - // cull the entire model if merged bounding box of both frames - // is outside the view frustum. - // - cull = R_MDRCullModel (header, ent); - if ( cull == CULL_OUT ) { - return; - } - - // figure out the current LOD of the model we're rendering, and set the lod pointer respectively. - lodnum = R_ComputeLOD(ent); - // check whether this model has as that many LODs at all. If not, try the closest thing we got. - if(header->numLODs <= 0) - return; - if(header->numLODs <= lodnum) - lodnum = header->numLODs - 1; - - lod = (mdrLOD_t *)( (byte *)header + header->ofsLODs); - for(i = 0; i < lodnum; i++) - { - lod = (mdrLOD_t *) ((byte *) lod + lod->ofsEnd); - } - - // set up lighting - if ( !personalModel || r_shadows->integer > 1 ) - { - R_SetupEntityLighting( &tr.refdef, ent ); - } - - // fogNum? - fogNum = R_MDRComputeFogNum( header, ent ); - - cubemapIndex = R_CubemapForPoint(ent->e.origin); - - surface = (mdrSurface_t *)( (byte *)lod + lod->ofsSurfaces ); - - for ( i = 0 ; i < lod->numSurfaces ; i++ ) - { - - if(ent->e.customShader) - shader = R_GetShaderByHandle(ent->e.customShader); - else if(ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins) - { - skin = R_GetSkinByHandle(ent->e.customSkin); - shader = tr.defaultShader; - - for(j = 0; j < skin->numSurfaces; j++) - { - if (!strcmp(skin->surfaces[j].name, surface->name)) - { - shader = skin->surfaces[j].shader; - break; - } - } - } - else if(surface->shaderIndex > 0) - shader = R_GetShaderByHandle( surface->shaderIndex ); - else - shader = tr.defaultShader; - - // we will add shadows even if the main object isn't visible in the view - - // stencil shadows can't do personal models unless I polyhedron clip - if ( !personalModel - && r_shadows->integer == 2 - && fogNum == 0 - && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) - && shader->sort == SS_OPAQUE ) - { - R_AddDrawSurf( (void *)surface, tr.shadowShader, 0, qfalse, qfalse, 0 ); - } - - // projection shadows work fine with personal models - if ( r_shadows->integer == 3 - && fogNum == 0 - && (ent->e.renderfx & RF_SHADOW_PLANE ) - && shader->sort == SS_OPAQUE ) - { - R_AddDrawSurf( (void *)surface, tr.projectionShadowShader, 0, qfalse, qfalse, 0 ); - } - - if (!personalModel) - R_AddDrawSurf( (void *)surface, shader, fogNum, qfalse, qfalse, cubemapIndex ); - - surface = (mdrSurface_t *)( (byte *)surface + surface->ofsEnd ); - } -} - -/* -============== -RB_MDRSurfaceAnim -============== -*/ -void RB_MDRSurfaceAnim( mdrSurface_t *surface ) -{ - int i, j, k; - float frontlerp, backlerp; - int *triangles; - int indexes; - int baseIndex, baseVertex; - int numVerts; - mdrVertex_t *v; - mdrHeader_t *header; - mdrFrame_t *frame; - mdrFrame_t *oldFrame; - mdrBone_t bones[MDR_MAX_BONES], *bonePtr, *bone; - - int frameSize; - - // don't lerp if lerping off, or this is the only frame, or the last frame... - // - if (backEnd.currentEntity->e.oldframe == backEnd.currentEntity->e.frame) - { - backlerp = 0; // if backlerp is 0, lerping is off and frontlerp is never used - frontlerp = 1; - } - else - { - backlerp = backEnd.currentEntity->e.backlerp; - frontlerp = 1.0f - backlerp; - } - - header = (mdrHeader_t *)((byte *)surface + surface->ofsHeader); - - frameSize = (size_t)( &((mdrFrame_t *)0)->bones[ header->numBones ] ); - - frame = (mdrFrame_t *)((byte *)header + header->ofsFrames + - backEnd.currentEntity->e.frame * frameSize ); - oldFrame = (mdrFrame_t *)((byte *)header + header->ofsFrames + - backEnd.currentEntity->e.oldframe * frameSize ); - - RB_CHECKOVERFLOW( surface->numVerts, surface->numTriangles * 3 ); - - triangles = (int *) ((byte *)surface + surface->ofsTriangles); - indexes = surface->numTriangles * 3; - baseIndex = tess.numIndexes; - baseVertex = tess.numVertexes; - - // Set up all triangles. - for (j = 0 ; j < indexes ; j++) - { - tess.indexes[baseIndex + j] = baseVertex + triangles[j]; - } - tess.numIndexes += indexes; - - // - // lerp all the needed bones - // - if ( !backlerp ) - { - // no lerping needed - bonePtr = frame->bones; - } - else - { - bonePtr = bones; - - for ( i = 0 ; i < header->numBones*12 ; i++ ) - { - ((float *)bonePtr)[i] = frontlerp * ((float *)frame->bones)[i] + backlerp * ((float *)oldFrame->bones)[i]; - } - } - - // - // deform the vertexes by the lerped bones - // - numVerts = surface->numVerts; - v = (mdrVertex_t *) ((byte *)surface + surface->ofsVerts); - for ( j = 0; j < numVerts; j++ ) - { - vec3_t tempVert, tempNormal; - mdrWeight_t *w; - - VectorClear( tempVert ); - VectorClear( tempNormal ); - w = v->weights; - for ( k = 0 ; k < v->numWeights ; k++, w++ ) - { - bone = bonePtr + w->boneIndex; - - tempVert[0] += w->boneWeight * ( DotProduct( bone->matrix[0], w->offset ) + bone->matrix[0][3] ); - tempVert[1] += w->boneWeight * ( DotProduct( bone->matrix[1], w->offset ) + bone->matrix[1][3] ); - tempVert[2] += w->boneWeight * ( DotProduct( bone->matrix[2], w->offset ) + bone->matrix[2][3] ); - - tempNormal[0] += w->boneWeight * DotProduct( bone->matrix[0], v->normal ); - tempNormal[1] += w->boneWeight * DotProduct( bone->matrix[1], v->normal ); - tempNormal[2] += w->boneWeight * DotProduct( bone->matrix[2], v->normal ); - } - - tess.xyz[baseVertex + j][0] = tempVert[0]; - tess.xyz[baseVertex + j][1] = tempVert[1]; - tess.xyz[baseVertex + j][2] = tempVert[2]; - - R_VaoPackNormal(tess.normal[baseVertex + j], tempNormal); - - tess.texCoords[baseVertex + j][0] = v->texCoords[0]; - tess.texCoords[baseVertex + j][1] = v->texCoords[1]; - - v = (mdrVertex_t *)&v->weights[v->numWeights]; - } - - tess.numVertexes += surface->numVerts; -} - - -#define MC_MASK_X ((1<<(MC_BITS_X))-1) -#define MC_MASK_Y ((1<<(MC_BITS_Y))-1) -#define MC_MASK_Z ((1<<(MC_BITS_Z))-1) -#define MC_MASK_VECT ((1<<(MC_BITS_VECT))-1) - -#define MC_SCALE_VECT (1.0f/(float)((1<<(MC_BITS_VECT-1))-2)) - -#define MC_POS_X (0) -#define MC_SHIFT_X (0) - -#define MC_POS_Y ((((MC_BITS_X))/8)) -#define MC_SHIFT_Y ((((MC_BITS_X)%8))) - -#define MC_POS_Z ((((MC_BITS_X+MC_BITS_Y))/8)) -#define MC_SHIFT_Z ((((MC_BITS_X+MC_BITS_Y)%8))) - -#define MC_POS_V11 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z))/8)) -#define MC_SHIFT_V11 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z)%8))) - -#define MC_POS_V12 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT))/8)) -#define MC_SHIFT_V12 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT)%8))) - -#define MC_POS_V13 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*2))/8)) -#define MC_SHIFT_V13 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*2)%8))) - -#define MC_POS_V21 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*3))/8)) -#define MC_SHIFT_V21 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*3)%8))) - -#define MC_POS_V22 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*4))/8)) -#define MC_SHIFT_V22 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*4)%8))) - -#define MC_POS_V23 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*5))/8)) -#define MC_SHIFT_V23 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*5)%8))) - -#define MC_POS_V31 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*6))/8)) -#define MC_SHIFT_V31 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*6)%8))) - -#define MC_POS_V32 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*7))/8)) -#define MC_SHIFT_V32 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*7)%8))) - -#define MC_POS_V33 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*8))/8)) -#define MC_SHIFT_V33 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*8)%8))) - -void MC_UnCompress(float mat[3][4],const unsigned char * comp) -{ - int val; - - val=(int)((unsigned short *)(comp))[0]; - val-=1<<(MC_BITS_X-1); - mat[0][3]=((float)(val))*MC_SCALE_X; - - val=(int)((unsigned short *)(comp))[1]; - val-=1<<(MC_BITS_Y-1); - mat[1][3]=((float)(val))*MC_SCALE_Y; - - val=(int)((unsigned short *)(comp))[2]; - val-=1<<(MC_BITS_Z-1); - mat[2][3]=((float)(val))*MC_SCALE_Z; - - val=(int)((unsigned short *)(comp))[3]; - val-=1<<(MC_BITS_VECT-1); - mat[0][0]=((float)(val))*MC_SCALE_VECT; - - val=(int)((unsigned short *)(comp))[4]; - val-=1<<(MC_BITS_VECT-1); - mat[0][1]=((float)(val))*MC_SCALE_VECT; - - val=(int)((unsigned short *)(comp))[5]; - val-=1<<(MC_BITS_VECT-1); - mat[0][2]=((float)(val))*MC_SCALE_VECT; - - - val=(int)((unsigned short *)(comp))[6]; - val-=1<<(MC_BITS_VECT-1); - mat[1][0]=((float)(val))*MC_SCALE_VECT; - - val=(int)((unsigned short *)(comp))[7]; - val-=1<<(MC_BITS_VECT-1); - mat[1][1]=((float)(val))*MC_SCALE_VECT; - - val=(int)((unsigned short *)(comp))[8]; - val-=1<<(MC_BITS_VECT-1); - mat[1][2]=((float)(val))*MC_SCALE_VECT; - - - val=(int)((unsigned short *)(comp))[9]; - val-=1<<(MC_BITS_VECT-1); - mat[2][0]=((float)(val))*MC_SCALE_VECT; - - val=(int)((unsigned short *)(comp))[10]; - val-=1<<(MC_BITS_VECT-1); - mat[2][1]=((float)(val))*MC_SCALE_VECT; - - val=(int)((unsigned short *)(comp))[11]; - val-=1<<(MC_BITS_VECT-1); - mat[2][2]=((float)(val))*MC_SCALE_VECT; -} diff --git a/code/renderer2/tr_backend.c b/code/renderer2/tr_backend.c deleted file mode 100644 index fccf5e7eeb..0000000000 --- a/code/renderer2/tr_backend.c +++ /dev/null @@ -1,1802 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -#include "tr_local.h" -#include "tr_fbo.h" -#include "tr_dsa.h" - -backEndData_t *backEndData; -backEndState_t backEnd; - - -static float s_flipMatrix[16] = { - // convert from our coordinate system (looking down X) - // to OpenGL's coordinate system (looking down -Z) - 0, 0, -1, 0, - -1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 0, 1 -}; - - -/* -** GL_BindToTMU -*/ -void GL_BindToTMU( image_t *image, int tmu ) -{ - GLuint texture = (tmu == TB_COLORMAP) ? tr.defaultImage->texnum : 0; - GLenum target = GL_TEXTURE_2D; - - if (image) - { - if (image->flags & IMGFLAG_CUBEMAP) - target = GL_TEXTURE_CUBE_MAP; - - image->frameUsed = tr.frameCount; - texture = image->texnum; - } - else - { - ri.Printf(PRINT_WARNING, "GL_BindToTMU: NULL image\n"); - } - - GL_BindMultiTexture(GL_TEXTURE0_ARB + tmu, target, texture); -} - - -/* -** GL_Cull -*/ -void GL_Cull( int cullType ) { - if ( glState.faceCulling == cullType ) { - return; - } - - if ( cullType == CT_TWO_SIDED ) - { - qglDisable( GL_CULL_FACE ); - } - else - { - qboolean cullFront = (cullType == CT_FRONT_SIDED); - - if ( glState.faceCulling == CT_TWO_SIDED ) - qglEnable( GL_CULL_FACE ); - - if ( glState.faceCullFront != cullFront ) - qglCullFace( cullFront ? GL_FRONT : GL_BACK ); - - glState.faceCullFront = cullFront; - } - - glState.faceCulling = cullType; -} - -/* -** GL_State -** -** This routine is responsible for setting the most commonly changed state -** in Q3. -*/ -void GL_State( unsigned long stateBits ) -{ - unsigned long diff = stateBits ^ glState.glStateBits; - - if ( !diff ) - { - return; - } - - // - // check depthFunc bits - // - if ( diff & GLS_DEPTHFUNC_BITS ) - { - if ( stateBits & GLS_DEPTHFUNC_EQUAL ) - { - qglDepthFunc( GL_EQUAL ); - } - else if ( stateBits & GLS_DEPTHFUNC_GREATER) - { - qglDepthFunc( GL_GREATER ); - } - else - { - qglDepthFunc( GL_LEQUAL ); - } - } - - // - // check blend bits - // - if ( diff & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) - { - uint32_t oldState = glState.glStateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ); - uint32_t newState = stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ); - uint32_t storedState = glState.storedGlState & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ); - - if (oldState == 0) - { - qglEnable( GL_BLEND ); - } - else if (newState == 0) - { - qglDisable( GL_BLEND ); - } - - if (newState != 0 && storedState != newState) - { - GLenum srcFactor = GL_ONE, dstFactor = GL_ONE; - - glState.storedGlState &= ~( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ); - glState.storedGlState |= newState; - - switch ( stateBits & GLS_SRCBLEND_BITS ) - { - case GLS_SRCBLEND_ZERO: - srcFactor = GL_ZERO; - break; - case GLS_SRCBLEND_ONE: - srcFactor = GL_ONE; - break; - case GLS_SRCBLEND_DST_COLOR: - srcFactor = GL_DST_COLOR; - break; - case GLS_SRCBLEND_ONE_MINUS_DST_COLOR: - srcFactor = GL_ONE_MINUS_DST_COLOR; - break; - case GLS_SRCBLEND_SRC_ALPHA: - srcFactor = GL_SRC_ALPHA; - break; - case GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA: - srcFactor = GL_ONE_MINUS_SRC_ALPHA; - break; - case GLS_SRCBLEND_DST_ALPHA: - srcFactor = GL_DST_ALPHA; - break; - case GLS_SRCBLEND_ONE_MINUS_DST_ALPHA: - srcFactor = GL_ONE_MINUS_DST_ALPHA; - break; - case GLS_SRCBLEND_ALPHA_SATURATE: - srcFactor = GL_SRC_ALPHA_SATURATE; - break; - default: - ri.Error( ERR_DROP, "GL_State: invalid src blend state bits" ); - break; - } - - switch ( stateBits & GLS_DSTBLEND_BITS ) - { - case GLS_DSTBLEND_ZERO: - dstFactor = GL_ZERO; - break; - case GLS_DSTBLEND_ONE: - dstFactor = GL_ONE; - break; - case GLS_DSTBLEND_SRC_COLOR: - dstFactor = GL_SRC_COLOR; - break; - case GLS_DSTBLEND_ONE_MINUS_SRC_COLOR: - dstFactor = GL_ONE_MINUS_SRC_COLOR; - break; - case GLS_DSTBLEND_SRC_ALPHA: - dstFactor = GL_SRC_ALPHA; - break; - case GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA: - dstFactor = GL_ONE_MINUS_SRC_ALPHA; - break; - case GLS_DSTBLEND_DST_ALPHA: - dstFactor = GL_DST_ALPHA; - break; - case GLS_DSTBLEND_ONE_MINUS_DST_ALPHA: - dstFactor = GL_ONE_MINUS_DST_ALPHA; - break; - default: - ri.Error( ERR_DROP, "GL_State: invalid dst blend state bits" ); - break; - } - - qglBlendFunc( srcFactor, dstFactor ); - } - } - - // - // check depthmask - // - if ( diff & GLS_DEPTHMASK_TRUE ) - { - if ( stateBits & GLS_DEPTHMASK_TRUE ) - { - qglDepthMask( GL_TRUE ); - } - else - { - qglDepthMask( GL_FALSE ); - } - } - - // - // fill/line mode - // - if ( diff & GLS_POLYMODE_LINE ) - { - if ( stateBits & GLS_POLYMODE_LINE ) - { - qglPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); - } - else - { - qglPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - } - } - - // - // depthtest - // - if ( diff & GLS_DEPTHTEST_DISABLE ) - { - if ( stateBits & GLS_DEPTHTEST_DISABLE ) - { - qglDisable( GL_DEPTH_TEST ); - } - else - { - qglEnable( GL_DEPTH_TEST ); - } - } - - glState.glStateBits = stateBits; -} - - -void GL_SetProjectionMatrix(mat4_t matrix) -{ - Mat4Copy(matrix, glState.projection); - Mat4Multiply(glState.projection, glState.modelview, glState.modelviewProjection); -} - - -void GL_SetModelviewMatrix(mat4_t matrix) -{ - Mat4Copy(matrix, glState.modelview); - Mat4Multiply(glState.projection, glState.modelview, glState.modelviewProjection); -} - - -/* -================ -RB_Hyperspace - -A player has predicted a teleport, but hasn't arrived yet -================ -*/ -static void RB_Hyperspace( void ) { - float c; - - if ( !backEnd.isHyperspace ) { - // do initialization shit - } - - if ( r_teleporterFlash->integer == 0 ) { - c = 0.0; // fade to black - } else { - c = ( backEnd.refdef.time & 255 ) / 255.0f; // fade to white - } - qglClearColor( c, c, c, 1 ); - qglClear( GL_COLOR_BUFFER_BIT ); - qglClearColor(0.0f, 0.0f, 0.0f, 1.0f); - - backEnd.isHyperspace = qtrue; -} - - -static void SetViewportAndScissor( void ) { - GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix ); - - // set the window clipping - qglViewport( backEnd.viewParms.viewportX, backEnd.viewParms.viewportY, - backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight ); - qglScissor( backEnd.viewParms.viewportX, backEnd.viewParms.viewportY, - backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight ); -} - -/* -================= -RB_BeginDrawingView - -Any mirrored or portaled views have already been drawn, so prepare -to actually render the visible surfaces for this view -================= -*/ -static void RB_BeginDrawingView (void) { - int clearBits = 0; - - // sync with gl if needed - if ( r_finish->integer == 1 && !glState.finishCalled ) { - qglFinish (); - glState.finishCalled = qtrue; - } - if ( r_finish->integer == 0 ) { - glState.finishCalled = qtrue; - } - - // we will need to change the projection matrix before drawing - // 2D images again - backEnd.projection2D = qfalse; - - if (glRefConfig.framebufferObject) - { - FBO_t *fbo = backEnd.viewParms.targetFbo; - - // FIXME: HUGE HACK: render to the screen fbo if we've already postprocessed the frame and aren't drawing more world - // drawing more world check is in case of double renders, such as skyportals - if (fbo == NULL && !(backEnd.framePostProcessed && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL))) - fbo = tr.renderFbo; - - if (tr.renderCubeFbo && fbo == tr.renderCubeFbo) - { - cubemap_t *cubemap = &tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex]; - FBO_AttachImage(fbo, cubemap->image, GL_COLOR_ATTACHMENT0_EXT, backEnd.viewParms.targetFboLayer); - } - - FBO_Bind(fbo); - } - - // - // set the modelview matrix for the viewer - // - SetViewportAndScissor(); - - // ensures that depth writes are enabled for the depth clear - GL_State( GLS_DEFAULT ); - // clear relevant buffers - clearBits = GL_DEPTH_BUFFER_BIT; - - if ( r_measureOverdraw->integer || r_shadows->integer == 2 ) - { - clearBits |= GL_STENCIL_BUFFER_BIT; - } - if ( r_fastsky->integer && !( backEnd.refdef.rdflags & RDF_NOWORLDMODEL ) ) - { - clearBits |= GL_COLOR_BUFFER_BIT; // FIXME: only if sky shaders have been used - } - - // clear to black for cube maps - if (tr.renderCubeFbo && backEnd.viewParms.targetFbo == tr.renderCubeFbo) - { - clearBits |= GL_COLOR_BUFFER_BIT; - } - - qglClear( clearBits ); - - if ( ( backEnd.refdef.rdflags & RDF_HYPERSPACE ) ) - { - RB_Hyperspace(); - return; - } - else - { - backEnd.isHyperspace = qfalse; - } - - // we will only draw a sun if there was sky rendered in this view - backEnd.skyRenderedThisView = qfalse; - - // clip to the plane of the portal - if ( backEnd.viewParms.isPortal ) { -#if 0 - float plane[4]; - GLdouble plane2[4]; - - plane[0] = backEnd.viewParms.portalPlane.normal[0]; - plane[1] = backEnd.viewParms.portalPlane.normal[1]; - plane[2] = backEnd.viewParms.portalPlane.normal[2]; - plane[3] = backEnd.viewParms.portalPlane.dist; - - plane2[0] = DotProduct (backEnd.viewParms.or.axis[0], plane); - plane2[1] = DotProduct (backEnd.viewParms.or.axis[1], plane); - plane2[2] = DotProduct (backEnd.viewParms.or.axis[2], plane); - plane2[3] = DotProduct (plane, backEnd.viewParms.or.origin) - plane[3]; -#endif - GL_SetModelviewMatrix( s_flipMatrix ); - } -} - - -/* -================== -RB_RenderDrawSurfList -================== -*/ -static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { - shader_t *shader, *oldShader; - int fogNum, oldFogNum; - int entityNum, oldEntityNum; - int dlighted, oldDlighted; - int pshadowed, oldPshadowed; - int cubemapIndex, oldCubemapIndex; - qboolean depthRange, oldDepthRange, isCrosshair, wasCrosshair; - int i; - drawSurf_t *drawSurf; - unsigned int oldSort; - double originalTime; - FBO_t* fbo = NULL; - - // save original time for entity shader offsets - originalTime = backEnd.refdef.floatTime; - - fbo = glState.currentFBO; - - // draw everything - oldEntityNum = -1; - backEnd.currentEntity = &tr.worldEntity; - oldShader = NULL; - oldFogNum = -1; - oldDepthRange = qfalse; - wasCrosshair = qfalse; - oldDlighted = qfalse; - oldPshadowed = qfalse; - oldCubemapIndex = -1; - oldSort = ~0U; - shader = NULL; - - backEnd.pc.c_surfaces += numDrawSurfs; - - for (i = 0, drawSurf = drawSurfs ; i < numDrawSurfs ; i++, drawSurf++) { - if ( drawSurf->sort == oldSort && drawSurf->cubemapIndex == oldCubemapIndex) { - if (backEnd.depthFill && shader && shader->sort != SS_OPAQUE) - continue; - - // fast path, same as previous sort - rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); - continue; - } - oldSort = drawSurf->sort; - R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlighted, &pshadowed ); - cubemapIndex = drawSurf->cubemapIndex; - - // - // change the tess parameters if needed - // a "entityMergable" shader is a shader that can have surfaces from separate - // entities merged into a single batch, like smoke and blood puff sprites - if ( shader != NULL && ( shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted || pshadowed != oldPshadowed || cubemapIndex != oldCubemapIndex - || ( entityNum != oldEntityNum && !shader->entityMergable ) ) ) { - if (oldShader != NULL) { - RB_EndSurface(); - } - RB_BeginSurface( shader, fogNum, cubemapIndex ); - backEnd.pc.c_surfBatches++; - oldShader = shader; - oldFogNum = fogNum; - oldDlighted = dlighted; - oldPshadowed = pshadowed; - oldCubemapIndex = cubemapIndex; - } - - if (backEnd.depthFill && shader && shader->sort != SS_OPAQUE) - continue; - - // - // change the modelview matrix if needed - // - if ( entityNum != oldEntityNum ) { - depthRange = isCrosshair = qfalse; - - if ( entityNum != REFENTITYNUM_WORLD ) { - backEnd.currentEntity = &backEnd.refdef.entities[entityNum]; - - if ( backEnd.currentEntity->intShaderTime ) - backEnd.refdef.floatTime = originalTime - (double)backEnd.currentEntity->e.shaderTime.i * 0.001; - else - backEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime.f; - - // we have to reset the shaderTime as well otherwise image animations start - // from the wrong frame - tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; - - // set up the transformation matrix - R_RotateForEntity( backEnd.currentEntity, &backEnd.viewParms, &backEnd.or ); - - // set up the dynamic lighting if needed - if ( backEnd.currentEntity->needDlights ) { - R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.or ); - } - - if(backEnd.currentEntity->e.renderfx & RF_DEPTHHACK) - { - // hack the depth range to prevent view model from poking into walls - depthRange = qtrue; - - if(backEnd.currentEntity->e.renderfx & RF_CROSSHAIR) - isCrosshair = qtrue; - } - } else { - backEnd.currentEntity = &tr.worldEntity; - backEnd.refdef.floatTime = originalTime; - backEnd.or = backEnd.viewParms.world; - // we have to reset the shaderTime as well otherwise image animations on - // the world (like water) continue with the wrong frame - tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; - R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.or ); - } - - GL_SetModelviewMatrix( backEnd.or.modelMatrix ); - - // - // change depthrange. Also change projection matrix so first person weapon does not look like coming - // out of the screen. - // - if (oldDepthRange != depthRange || wasCrosshair != isCrosshair) - { - if (depthRange) - { - if(backEnd.viewParms.stereoFrame != STEREO_CENTER) - { - if(isCrosshair) - { - if(oldDepthRange) - { - // was not a crosshair but now is, change back proj matrix - GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix ); - } - } - else - { - viewParms_t temp = backEnd.viewParms; - - R_SetupProjection(&temp, r_znear->value, 0, qfalse); - - GL_SetProjectionMatrix( temp.projectionMatrix ); - } - } - - if(!oldDepthRange) - qglDepthRange (0, 0.3); - } - else - { - if(!wasCrosshair && backEnd.viewParms.stereoFrame != STEREO_CENTER) - { - GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix ); - } - - qglDepthRange (0, 1); - } - - oldDepthRange = depthRange; - wasCrosshair = isCrosshair; - } - - oldEntityNum = entityNum; - } - - // add the triangles for this surface - rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); - } - - backEnd.refdef.floatTime = originalTime; - - // draw the contents of the last shader batch - if (oldShader != NULL) { - RB_EndSurface(); - } - - if (glRefConfig.framebufferObject) - FBO_Bind(fbo); - - // go back to the world modelview matrix - - GL_SetModelviewMatrix( backEnd.viewParms.world.modelMatrix ); - - qglDepthRange (0, 1); -} - - -/* -============================================================================ - -RENDER BACK END FUNCTIONS - -============================================================================ -*/ - -/* -================ -RB_SetGL2D - -================ -*/ -static void RB_SetGL2D (void) { - mat4_t matrix; - int width, height; - - if (backEnd.projection2D && backEnd.last2DFBO == glState.currentFBO) - return; - - backEnd.projection2D = qtrue; - backEnd.last2DFBO = glState.currentFBO; - - if (glState.currentFBO) - { - width = glState.currentFBO->width; - height = glState.currentFBO->height; - } - else - { - width = glConfig.vidWidth; - height = glConfig.vidHeight; - } - - // set 2D virtual screen size - qglViewport( 0, 0, width, height ); - qglScissor( 0, 0, width, height ); - - Mat4Ortho(0, width, height, 0, 0, 1, matrix); - GL_SetProjectionMatrix(matrix); - Mat4Identity(matrix); - GL_SetModelviewMatrix(matrix); - - GL_State( GLS_DEPTHTEST_DISABLE | - GLS_SRCBLEND_SRC_ALPHA | - GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); - - GL_Cull( CT_TWO_SIDED ); - - // set time for 2D shaders - backEnd.refdef.time = ri.Milliseconds(); - backEnd.refdef.floatTime = backEnd.refdef.time * 0.001; -} - - -/* -============= -RE_StretchRaw - -FIXME: not exactly backend -Stretches a raw 32 bit power of 2 bitmap image over the given screen rectangle. -Used for cinematics. -============= -*/ -void RE_StretchRaw( int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty ) { - int i, j; - int start, end; - vec4_t quadVerts[4]; - vec2_t texCoords[4]; - - if ( !tr.registered ) { - return; - } - R_IssuePendingRenderCommands(); - - if ( tess.numIndexes ) { - RB_EndSurface(); - } - - // we definitely want to sync every frame for the cinematics - qglFinish(); - - start = 0; - if ( r_speeds->integer ) { - start = ri.Milliseconds(); - } - - // make sure rows and cols are powers of 2 - for ( i = 0 ; ( 1 << i ) < cols ; i++ ) { - } - for ( j = 0 ; ( 1 << j ) < rows ; j++ ) { - } - if ( ( 1 << i ) != cols || ( 1 << j ) != rows) { - ri.Error (ERR_DROP, "Draw_StretchRaw: size not a power of 2: %i by %i", cols, rows); - } - - RE_UploadCinematic (w, h, cols, rows, data, client, dirty); - GL_BindToTMU(tr.scratchImage[client], TB_COLORMAP); - - if ( r_speeds->integer ) { - end = ri.Milliseconds(); - ri.Printf( PRINT_ALL, "qglTexSubImage2D %i, %i: %i msec\n", cols, rows, end - start ); - } - - // FIXME: HUGE hack - if (glRefConfig.framebufferObject) - { - FBO_Bind(backEnd.framePostProcessed ? NULL : tr.renderFbo); - } - - RB_SetGL2D(); - - VectorSet4(quadVerts[0], x, y, 0.0f, 1.0f); - VectorSet4(quadVerts[1], x + w, y, 0.0f, 1.0f); - VectorSet4(quadVerts[2], x + w, y + h, 0.0f, 1.0f); - VectorSet4(quadVerts[3], x, y + h, 0.0f, 1.0f); - - VectorSet2(texCoords[0], 0.5f / cols, 0.5f / rows); - VectorSet2(texCoords[1], (cols - 0.5f) / cols, 0.5f / rows); - VectorSet2(texCoords[2], (cols - 0.5f) / cols, (rows - 0.5f) / rows); - VectorSet2(texCoords[3], 0.5f / cols, (rows - 0.5f) / rows); - - GLSL_BindProgram(&tr.textureColorShader); - - GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite); - - RB_InstantQuad2(quadVerts, texCoords); -} - -void RE_UploadCinematic (int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty) { - GLuint texture; - - if (!tr.scratchImage[client]) - { - ri.Printf(PRINT_WARNING, "RE_UploadCinematic: scratch images not initialized\n"); - return; - } - - texture = tr.scratchImage[client]->texnum; - - // if the scratchImage isn't in the format we want, specify it as a new texture - if ( cols != tr.scratchImage[client]->width || rows != tr.scratchImage[client]->height ) { - tr.scratchImage[client]->width = tr.scratchImage[client]->uploadWidth = cols; - tr.scratchImage[client]->height = tr.scratchImage[client]->uploadHeight = rows; - qglTextureImage2DEXT(texture, GL_TEXTURE_2D, 0, GL_RGB8, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); - qglTextureParameterfEXT(texture, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - qglTextureParameterfEXT(texture, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - qglTextureParameterfEXT(texture, GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - qglTextureParameterfEXT(texture, GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - } else { - if (dirty) { - // otherwise, just subimage upload it so that drivers can tell we are going to be changing - // it and don't try and do a texture compression - qglTextureSubImage2DEXT(texture, GL_TEXTURE_2D, 0, 0, 0, cols, rows, GL_RGBA, GL_UNSIGNED_BYTE, data); - } - } -} - - -/* -============= -RB_SetColor - -============= -*/ -static const void *RB_SetColor( const void *data ) { - const setColorCommand_t *cmd; - - cmd = (const setColorCommand_t *)data; - - backEnd.color2D[0] = cmd->color[0] * 255; - backEnd.color2D[1] = cmd->color[1] * 255; - backEnd.color2D[2] = cmd->color[2] * 255; - backEnd.color2D[3] = cmd->color[3] * 255; - - return (const void *)(cmd + 1); -} - -/* -============= -RB_StretchPic -============= -*/ -static const void *RB_StretchPic ( const void *data ) { - const stretchPicCommand_t *cmd; - shader_t *shader; - int numVerts, numIndexes; - - cmd = (const stretchPicCommand_t *)data; - - // FIXME: HUGE hack - if (glRefConfig.framebufferObject) - FBO_Bind(backEnd.framePostProcessed ? NULL : tr.renderFbo); - - RB_SetGL2D(); - - shader = cmd->shader; - if ( shader != tess.shader ) { - if ( tess.numIndexes ) { - RB_EndSurface(); - } - backEnd.currentEntity = &backEnd.entity2D; - RB_BeginSurface( shader, 0, 0 ); - } - - RB_CHECKOVERFLOW( 4, 6 ); - numVerts = tess.numVertexes; - numIndexes = tess.numIndexes; - - tess.numVertexes += 4; - tess.numIndexes += 6; - - tess.indexes[ numIndexes ] = numVerts + 3; - tess.indexes[ numIndexes + 1 ] = numVerts + 0; - tess.indexes[ numIndexes + 2 ] = numVerts + 2; - tess.indexes[ numIndexes + 3 ] = numVerts + 2; - tess.indexes[ numIndexes + 4 ] = numVerts + 0; - tess.indexes[ numIndexes + 5 ] = numVerts + 1; - - { - uint16_t color[4]; - - VectorScale4(backEnd.color2D, 257, color); - - VectorCopy4(color, tess.color[ numVerts ]); - VectorCopy4(color, tess.color[ numVerts + 1]); - VectorCopy4(color, tess.color[ numVerts + 2]); - VectorCopy4(color, tess.color[ numVerts + 3 ]); - } - - tess.xyz[ numVerts ][0] = cmd->x; - tess.xyz[ numVerts ][1] = cmd->y; - tess.xyz[ numVerts ][2] = 0; - - tess.texCoords[ numVerts ][0] = cmd->s1; - tess.texCoords[ numVerts ][1] = cmd->t1; - - tess.xyz[ numVerts + 1 ][0] = cmd->x + cmd->w; - tess.xyz[ numVerts + 1 ][1] = cmd->y; - tess.xyz[ numVerts + 1 ][2] = 0; - - tess.texCoords[ numVerts + 1 ][0] = cmd->s2; - tess.texCoords[ numVerts + 1 ][1] = cmd->t1; - - tess.xyz[ numVerts + 2 ][0] = cmd->x + cmd->w; - tess.xyz[ numVerts + 2 ][1] = cmd->y + cmd->h; - tess.xyz[ numVerts + 2 ][2] = 0; - - tess.texCoords[ numVerts + 2 ][0] = cmd->s2; - tess.texCoords[ numVerts + 2 ][1] = cmd->t2; - - tess.xyz[ numVerts + 3 ][0] = cmd->x; - tess.xyz[ numVerts + 3 ][1] = cmd->y + cmd->h; - tess.xyz[ numVerts + 3 ][2] = 0; - - tess.texCoords[ numVerts + 3 ][0] = cmd->s1; - tess.texCoords[ numVerts + 3 ][1] = cmd->t2; - - return (const void *)(cmd + 1); -} - - -/* -============= -RB_DrawSurfs - -============= -*/ -static const void *RB_DrawSurfs( const void *data ) { - const drawSurfsCommand_t *cmd; - qboolean isShadowView; - - // finish any 2D drawing if needed - if ( tess.numIndexes ) { - RB_EndSurface(); - } - - cmd = (const drawSurfsCommand_t *)data; - - backEnd.refdef = cmd->refdef; - backEnd.viewParms = cmd->viewParms; - - isShadowView = !!(backEnd.viewParms.flags & VPF_DEPTHSHADOW); - - // clear the z buffer, set the modelview, etc - RB_BeginDrawingView (); - - if (glRefConfig.framebufferObject && (backEnd.viewParms.flags & VPF_DEPTHCLAMP) && glRefConfig.depthClamp) - { - qglEnable(GL_DEPTH_CLAMP); - } - - if (glRefConfig.framebufferObject && !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL) && (r_depthPrepass->integer || isShadowView)) - { - FBO_t *oldFbo = glState.currentFBO; - vec4_t viewInfo; - - VectorSet4(viewInfo, backEnd.viewParms.zFar / r_znear->value, backEnd.viewParms.zFar, 0.0, 0.0); - - backEnd.depthFill = qtrue; - qglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); - RB_RenderDrawSurfList( cmd->drawSurfs, cmd->numDrawSurfs ); - qglColorMask(!backEnd.colorMask[0], !backEnd.colorMask[1], !backEnd.colorMask[2], !backEnd.colorMask[3]); - backEnd.depthFill = qfalse; - - if (!isShadowView) - { - if (tr.msaaResolveFbo) - { - // If we're using multisampling, resolve the depth first - FBO_FastBlit(tr.renderFbo, NULL, tr.msaaResolveFbo, NULL, GL_DEPTH_BUFFER_BIT, GL_NEAREST); - } - else if (tr.renderFbo == NULL && tr.renderDepthImage) - { - // If we're rendering directly to the screen, copy the depth to a texture - // This is incredibly slow on Intel Graphics, so just skip it on there - if (!glRefConfig.intelGraphics) - qglCopyTextureSubImage2DEXT(tr.renderDepthImage->texnum, GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight); - } - - if (tr.hdrDepthFbo) - { - // need the depth in a texture we can do GL_LINEAR sampling on, so copy it to an HDR image - vec4_t srcTexCoords; - - VectorSet4(srcTexCoords, 0.0f, 0.0f, 1.0f, 1.0f); - - FBO_BlitFromTexture(tr.renderDepthImage, srcTexCoords, NULL, tr.hdrDepthFbo, NULL, NULL, NULL, 0); - } - - if (r_sunlightMode->integer && backEnd.viewParms.flags & VPF_USESUNLIGHT) - { - vec4_t quadVerts[4]; - vec2_t texCoords[4]; - vec4_t box; - - FBO_Bind(tr.screenShadowFbo); - - box[0] = backEnd.viewParms.viewportX * tr.screenShadowFbo->width / (float)glConfig.vidWidth; - box[1] = backEnd.viewParms.viewportY * tr.screenShadowFbo->height / (float)glConfig.vidHeight; - box[2] = backEnd.viewParms.viewportWidth * tr.screenShadowFbo->width / (float)glConfig.vidWidth; - box[3] = backEnd.viewParms.viewportHeight * tr.screenShadowFbo->height / (float)glConfig.vidHeight; - - qglViewport(box[0], box[1], box[2], box[3]); - qglScissor(box[0], box[1], box[2], box[3]); - - box[0] = backEnd.viewParms.viewportX / (float)glConfig.vidWidth; - box[1] = backEnd.viewParms.viewportY / (float)glConfig.vidHeight; - box[2] = box[0] + backEnd.viewParms.viewportWidth / (float)glConfig.vidWidth; - box[3] = box[1] + backEnd.viewParms.viewportHeight / (float)glConfig.vidHeight; - - texCoords[0][0] = box[0]; texCoords[0][1] = box[3]; - texCoords[1][0] = box[2]; texCoords[1][1] = box[3]; - texCoords[2][0] = box[2]; texCoords[2][1] = box[1]; - texCoords[3][0] = box[0]; texCoords[3][1] = box[1]; - - box[0] = -1.0f; - box[1] = -1.0f; - box[2] = 1.0f; - box[3] = 1.0f; - - VectorSet4(quadVerts[0], box[0], box[3], 0, 1); - VectorSet4(quadVerts[1], box[2], box[3], 0, 1); - VectorSet4(quadVerts[2], box[2], box[1], 0, 1); - VectorSet4(quadVerts[3], box[0], box[1], 0, 1); - - GL_State(GLS_DEPTHTEST_DISABLE); - - GLSL_BindProgram(&tr.shadowmaskShader); - - GL_BindToTMU(tr.renderDepthImage, TB_COLORMAP); - - if (r_shadowCascadeZFar->integer != 0) - { - GL_BindToTMU(tr.sunShadowDepthImage[0], TB_SHADOWMAP); - GL_BindToTMU(tr.sunShadowDepthImage[1], TB_SHADOWMAP2); - GL_BindToTMU(tr.sunShadowDepthImage[2], TB_SHADOWMAP3); - GL_BindToTMU(tr.sunShadowDepthImage[3], TB_SHADOWMAP4); - - GLSL_SetUniformMat4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP, backEnd.refdef.sunShadowMvp[0]); - GLSL_SetUniformMat4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP2, backEnd.refdef.sunShadowMvp[1]); - GLSL_SetUniformMat4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP3, backEnd.refdef.sunShadowMvp[2]); - GLSL_SetUniformMat4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP4, backEnd.refdef.sunShadowMvp[3]); - } - else - { - GL_BindToTMU(tr.sunShadowDepthImage[3], TB_SHADOWMAP); - GLSL_SetUniformMat4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP, backEnd.refdef.sunShadowMvp[3]); - } - - GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWORIGIN, backEnd.refdef.vieworg); - { - vec3_t viewVector; - - float zmax = backEnd.viewParms.zFar; - float ymax = zmax * tan(backEnd.viewParms.fovY * M_PI / 360.0f); - float xmax = zmax * tan(backEnd.viewParms.fovX * M_PI / 360.0f); - - VectorScale(backEnd.refdef.viewaxis[0], zmax, viewVector); - GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWFORWARD, viewVector); - VectorScale(backEnd.refdef.viewaxis[1], xmax, viewVector); - GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWLEFT, viewVector); - VectorScale(backEnd.refdef.viewaxis[2], ymax, viewVector); - GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWUP, viewVector); - - GLSL_SetUniformVec4(&tr.shadowmaskShader, UNIFORM_VIEWINFO, viewInfo); - } - - RB_InstantQuad2(quadVerts, texCoords); //, color, shaderProgram, invTexRes); - - if (r_shadowBlur->integer) - { - viewInfo[2] = 1.0f / (float)(tr.screenScratchFbo->width); - viewInfo[3] = 1.0f / (float)(tr.screenScratchFbo->height); - - FBO_Bind(tr.screenScratchFbo); - - GLSL_BindProgram(&tr.depthBlurShader[0]); - - GL_BindToTMU(tr.screenShadowImage, TB_COLORMAP); - GL_BindToTMU(tr.hdrDepthImage, TB_LIGHTMAP); - - GLSL_SetUniformVec4(&tr.depthBlurShader[0], UNIFORM_VIEWINFO, viewInfo); - - RB_InstantQuad2(quadVerts, texCoords); - - FBO_Bind(tr.screenShadowFbo); - - GLSL_BindProgram(&tr.depthBlurShader[1]); - - GL_BindToTMU(tr.screenScratchImage, TB_COLORMAP); - GL_BindToTMU(tr.hdrDepthImage, TB_LIGHTMAP); - - GLSL_SetUniformVec4(&tr.depthBlurShader[1], UNIFORM_VIEWINFO, viewInfo); - - RB_InstantQuad2(quadVerts, texCoords); - } - } - - if (r_ssao->integer) - { - vec4_t quadVerts[4]; - vec2_t texCoords[4]; - - viewInfo[2] = 1.0f / ((float)(tr.quarterImage[0]->width) * tan(backEnd.viewParms.fovX * M_PI / 360.0f) * 2.0f); - viewInfo[3] = 1.0f / ((float)(tr.quarterImage[0]->height) * tan(backEnd.viewParms.fovY * M_PI / 360.0f) * 2.0f); - viewInfo[3] *= (float)backEnd.viewParms.viewportHeight / (float)backEnd.viewParms.viewportWidth; - - FBO_Bind(tr.quarterFbo[0]); - - qglViewport(0, 0, tr.quarterFbo[0]->width, tr.quarterFbo[0]->height); - qglScissor(0, 0, tr.quarterFbo[0]->width, tr.quarterFbo[0]->height); - - VectorSet4(quadVerts[0], -1, 1, 0, 1); - VectorSet4(quadVerts[1], 1, 1, 0, 1); - VectorSet4(quadVerts[2], 1, -1, 0, 1); - VectorSet4(quadVerts[3], -1, -1, 0, 1); - - texCoords[0][0] = 0; texCoords[0][1] = 1; - texCoords[1][0] = 1; texCoords[1][1] = 1; - texCoords[2][0] = 1; texCoords[2][1] = 0; - texCoords[3][0] = 0; texCoords[3][1] = 0; - - GL_State( GLS_DEPTHTEST_DISABLE ); - - GLSL_BindProgram(&tr.ssaoShader); - - GL_BindToTMU(tr.hdrDepthImage, TB_COLORMAP); - - GLSL_SetUniformVec4(&tr.ssaoShader, UNIFORM_VIEWINFO, viewInfo); - - RB_InstantQuad2(quadVerts, texCoords); //, color, shaderProgram, invTexRes); - - - viewInfo[2] = 1.0f / (float)(tr.quarterImage[0]->width); - viewInfo[3] = 1.0f / (float)(tr.quarterImage[0]->height); - - FBO_Bind(tr.quarterFbo[1]); - - qglViewport(0, 0, tr.quarterFbo[1]->width, tr.quarterFbo[1]->height); - qglScissor(0, 0, tr.quarterFbo[1]->width, tr.quarterFbo[1]->height); - - GLSL_BindProgram(&tr.depthBlurShader[0]); - - GL_BindToTMU(tr.quarterImage[0], TB_COLORMAP); - GL_BindToTMU(tr.hdrDepthImage, TB_LIGHTMAP); - - GLSL_SetUniformVec4(&tr.depthBlurShader[0], UNIFORM_VIEWINFO, viewInfo); - - RB_InstantQuad2(quadVerts, texCoords); //, color, shaderProgram, invTexRes); - - - FBO_Bind(tr.screenSsaoFbo); - - qglViewport(0, 0, tr.screenSsaoFbo->width, tr.screenSsaoFbo->height); - qglScissor(0, 0, tr.screenSsaoFbo->width, tr.screenSsaoFbo->height); - - GLSL_BindProgram(&tr.depthBlurShader[1]); - - GL_BindToTMU(tr.quarterImage[1], TB_COLORMAP); - GL_BindToTMU(tr.hdrDepthImage, TB_LIGHTMAP); - - GLSL_SetUniformVec4(&tr.depthBlurShader[1], UNIFORM_VIEWINFO, viewInfo); - - - RB_InstantQuad2(quadVerts, texCoords); //, color, shaderProgram, invTexRes); - } - } - - // reset viewport and scissor - FBO_Bind(oldFbo); - SetViewportAndScissor(); - } - - if (glRefConfig.framebufferObject && (backEnd.viewParms.flags & VPF_DEPTHCLAMP) && glRefConfig.depthClamp) - { - qglDisable(GL_DEPTH_CLAMP); - } - - if (!isShadowView) - { - RB_RenderDrawSurfList( cmd->drawSurfs, cmd->numDrawSurfs ); - - if (r_drawSun->integer) - { - RB_DrawSun( 0.1f, tr.sunShader ); - } - - if (glRefConfig.framebufferObject && r_drawSunRays->integer) - { - FBO_t *oldFbo = glState.currentFBO; - FBO_Bind(tr.sunRaysFbo); - - qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); - qglClear( GL_COLOR_BUFFER_BIT ); - - if (glRefConfig.occlusionQuery) - { - tr.sunFlareQueryActive[tr.sunFlareQueryIndex] = qtrue; - qglBeginQuery(GL_SAMPLES_PASSED, tr.sunFlareQuery[tr.sunFlareQueryIndex]); - } - - RB_DrawSun(0.3f, tr.sunFlareShader); - - if (glRefConfig.occlusionQuery) - { - qglEndQuery(GL_SAMPLES_PASSED); - } - - FBO_Bind(oldFbo); - } - - // darken down any stencil shadows - RB_ShadowFinish(); - - // add light flares on lights that aren't obscured - RB_RenderFlares(); - } - - if (glRefConfig.framebufferObject && tr.renderCubeFbo && backEnd.viewParms.targetFbo == tr.renderCubeFbo) - { - cubemap_t *cubemap = &tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex]; - - FBO_Bind(NULL); - if (cubemap && cubemap->image) - qglGenerateTextureMipmapEXT(cubemap->image->texnum, GL_TEXTURE_CUBE_MAP); - } - - return (const void *)(cmd + 1); -} - - -/* -============= -RB_DrawBuffer - -============= -*/ -static const void *RB_DrawBuffer( const void *data ) { - const drawBufferCommand_t *cmd; - - cmd = (const drawBufferCommand_t *)data; - - // finish any 2D drawing if needed - if(tess.numIndexes) - RB_EndSurface(); - - if (glRefConfig.framebufferObject) - FBO_Bind(NULL); - - qglDrawBuffer( cmd->buffer ); - - // clear screen for debugging - if ( r_clear->integer ) { - qglClearColor( 1, 0, 0.5, 1 ); - qglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - } - - return (const void *)(cmd + 1); -} - -/* -=============== -RB_ShowImages - -Draw all the images to the screen, on top of whatever -was there. This is used to test for texture thrashing. - -Also called by RE_EndRegistration -=============== -*/ -void RB_ShowImages( void ) { - int i; - image_t *image; - float x, y, w, h; - int start, end; - - RB_SetGL2D(); - - qglClear( GL_COLOR_BUFFER_BIT ); - - qglFinish(); - - start = ri.Milliseconds(); - - for ( i=0 ; iinteger == 2 ) { - w *= image->uploadWidth / 512.0f; - h *= image->uploadHeight / 512.0f; - } - - { - vec4_t quadVerts[4]; - - GL_BindToTMU(image, TB_COLORMAP); - - VectorSet4(quadVerts[0], x, y, 0, 1); - VectorSet4(quadVerts[1], x + w, y, 0, 1); - VectorSet4(quadVerts[2], x + w, y + h, 0, 1); - VectorSet4(quadVerts[3], x, y + h, 0, 1); - - RB_InstantQuad(quadVerts); - } - } - - qglFinish(); - - end = ri.Milliseconds(); - ri.Printf( PRINT_ALL, "%i msec to draw all images\n", end - start ); - -} - -/* -============= -RB_ColorMask - -============= -*/ -static const void *RB_ColorMask(const void *data) -{ - const colorMaskCommand_t *cmd = data; - - // finish any 2D drawing if needed - if(tess.numIndexes) - RB_EndSurface(); - - if (glRefConfig.framebufferObject) - { - // reverse color mask, so 0 0 0 0 is the default - backEnd.colorMask[0] = !cmd->rgba[0]; - backEnd.colorMask[1] = !cmd->rgba[1]; - backEnd.colorMask[2] = !cmd->rgba[2]; - backEnd.colorMask[3] = !cmd->rgba[3]; - } - - qglColorMask(cmd->rgba[0], cmd->rgba[1], cmd->rgba[2], cmd->rgba[3]); - - return (const void *)(cmd + 1); -} - -/* -============= -RB_ClearDepth - -============= -*/ -static const void *RB_ClearDepth(const void *data) -{ - const clearDepthCommand_t *cmd = data; - - // finish any 2D drawing if needed - if(tess.numIndexes) - RB_EndSurface(); - - // texture swapping test - if (r_showImages->integer) - RB_ShowImages(); - - if (glRefConfig.framebufferObject) - { - if (!tr.renderFbo || backEnd.framePostProcessed) - { - FBO_Bind(NULL); - } - else - { - FBO_Bind(tr.renderFbo); - } - } - - qglClear(GL_DEPTH_BUFFER_BIT); - - // if we're doing MSAA, clear the depth texture for the resolve buffer - if (tr.msaaResolveFbo) - { - FBO_Bind(tr.msaaResolveFbo); - qglClear(GL_DEPTH_BUFFER_BIT); - } - - - return (const void *)(cmd + 1); -} - - -/* -============= -RB_SwapBuffers - -============= -*/ -static const void *RB_SwapBuffers( const void *data ) { - const swapBuffersCommand_t *cmd; - - // finish any 2D drawing if needed - if ( tess.numIndexes ) { - RB_EndSurface(); - } - - // texture swapping test - if ( r_showImages->integer ) { - RB_ShowImages(); - } - - cmd = (const swapBuffersCommand_t *)data; - - // we measure overdraw by reading back the stencil buffer and - // counting up the number of increments that have happened - if ( r_measureOverdraw->integer ) { - int i; - long sum = 0; - unsigned char *stencilReadback; - - stencilReadback = ri.Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight ); - qglReadPixels( 0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencilReadback ); - - for ( i = 0; i < glConfig.vidWidth * glConfig.vidHeight; i++ ) { - sum += stencilReadback[i]; - } - - backEnd.pc.c_overDraw += sum; - ri.Hunk_FreeTempMemory( stencilReadback ); - } - - if (glRefConfig.framebufferObject) - { - if (!backEnd.framePostProcessed) - { - if (tr.msaaResolveFbo && r_hdr->integer) - { - // Resolving an RGB16F MSAA FBO to the screen messes with the brightness, so resolve to an RGB16F FBO first - FBO_FastBlit(tr.renderFbo, NULL, tr.msaaResolveFbo, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); - FBO_FastBlit(tr.msaaResolveFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); - } - else if (tr.renderFbo) - { - FBO_FastBlit(tr.renderFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); - } - } - } - - if ( !glState.finishCalled ) { - qglFinish(); - } - -// GLimp_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" ); - - ri.GLimp_EndFrame(); - - backEnd.framePostProcessed = qfalse; - backEnd.projection2D = qfalse; - - return (const void *)(cmd + 1); -} - -/* -============= -RB_CapShadowMap - -============= -*/ -static const void *RB_CapShadowMap(const void *data) -{ - const capShadowmapCommand_t *cmd = data; - - // finish any 2D drawing if needed - if(tess.numIndexes) - RB_EndSurface(); - - if (cmd->map != -1) - { - if (cmd->cubeSide != -1) - { - if (tr.shadowCubemaps[cmd->map]) - { - qglCopyTextureSubImage2DEXT(tr.shadowCubemaps[cmd->map]->texnum, GL_TEXTURE_CUBE_MAP_POSITIVE_X + cmd->cubeSide, 0, 0, 0, backEnd.refdef.x, glConfig.vidHeight - ( backEnd.refdef.y + PSHADOW_MAP_SIZE ), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE); - } - } - else - { - if (tr.pshadowMaps[cmd->map]) - { - qglCopyTextureSubImage2DEXT(tr.pshadowMaps[cmd->map]->texnum, GL_TEXTURE_2D, 0, 0, 0, backEnd.refdef.x, glConfig.vidHeight - (backEnd.refdef.y + PSHADOW_MAP_SIZE), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE); - } - } - } - - return (const void *)(cmd + 1); -} - - -/* -============= -RB_PostProcess - -============= -*/ -static const void *RB_PostProcess(const void *data) -{ - const postProcessCommand_t *cmd = data; - FBO_t *srcFbo; - ivec4_t srcBox, dstBox; - qboolean autoExposure; - - // finish any 2D drawing if needed - if(tess.numIndexes) - RB_EndSurface(); - - if (!glRefConfig.framebufferObject || !r_postProcess->integer) - { - // do nothing - return (const void *)(cmd + 1); - } - - if (cmd) - { - backEnd.refdef = cmd->refdef; - backEnd.viewParms = cmd->viewParms; - } - - srcFbo = tr.renderFbo; - if (tr.msaaResolveFbo) - { - // Resolve the MSAA before anything else - // Can't resolve just part of the MSAA FBO, so multiple views will suffer a performance hit here - FBO_FastBlit(tr.renderFbo, NULL, tr.msaaResolveFbo, NULL, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); - srcFbo = tr.msaaResolveFbo; - } - - dstBox[0] = backEnd.viewParms.viewportX; - dstBox[1] = backEnd.viewParms.viewportY; - dstBox[2] = backEnd.viewParms.viewportWidth; - dstBox[3] = backEnd.viewParms.viewportHeight; - - if (r_ssao->integer) - { - srcBox[0] = backEnd.viewParms.viewportX * tr.screenSsaoImage->width / (float)glConfig.vidWidth; - srcBox[1] = backEnd.viewParms.viewportY * tr.screenSsaoImage->height / (float)glConfig.vidHeight; - srcBox[2] = backEnd.viewParms.viewportWidth * tr.screenSsaoImage->width / (float)glConfig.vidWidth; - srcBox[3] = backEnd.viewParms.viewportHeight * tr.screenSsaoImage->height / (float)glConfig.vidHeight; - - FBO_Blit(tr.screenSsaoFbo, srcBox, NULL, srcFbo, dstBox, NULL, NULL, GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO); - } - - srcBox[0] = backEnd.viewParms.viewportX; - srcBox[1] = backEnd.viewParms.viewportY; - srcBox[2] = backEnd.viewParms.viewportWidth; - srcBox[3] = backEnd.viewParms.viewportHeight; - - if (srcFbo) - { - if (r_hdr->integer && (r_toneMap->integer || r_forceToneMap->integer)) - { - autoExposure = r_autoExposure->integer || r_forceAutoExposure->integer; - RB_ToneMap(srcFbo, srcBox, NULL, dstBox, autoExposure); - } - else if (r_cameraExposure->value == 0.0f) - { - FBO_FastBlit(srcFbo, srcBox, NULL, dstBox, GL_COLOR_BUFFER_BIT, GL_NEAREST); - } - else - { - vec4_t color; - - color[0] = - color[1] = - color[2] = pow(2, r_cameraExposure->value); //exp2(r_cameraExposure->value); - color[3] = 1.0f; - - FBO_Blit(srcFbo, srcBox, NULL, NULL, dstBox, NULL, color, 0); - } - } - - if (r_drawSunRays->integer) - RB_SunRays(NULL, srcBox, NULL, dstBox); - - if (1) - RB_BokehBlur(NULL, srcBox, NULL, dstBox, backEnd.refdef.blurFactor); - else - RB_GaussianBlur(backEnd.refdef.blurFactor); - -#if 0 - if (0) - { - vec4_t quadVerts[4]; - vec2_t texCoords[4]; - ivec4_t iQtrBox; - vec4_t box; - vec4_t viewInfo; - static float scale = 5.0f; - - scale -= 0.005f; - if (scale < 0.01f) - scale = 5.0f; - - FBO_FastBlit(NULL, NULL, tr.quarterFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); - - iQtrBox[0] = backEnd.viewParms.viewportX * tr.quarterImage[0]->width / (float)glConfig.vidWidth; - iQtrBox[1] = backEnd.viewParms.viewportY * tr.quarterImage[0]->height / (float)glConfig.vidHeight; - iQtrBox[2] = backEnd.viewParms.viewportWidth * tr.quarterImage[0]->width / (float)glConfig.vidWidth; - iQtrBox[3] = backEnd.viewParms.viewportHeight * tr.quarterImage[0]->height / (float)glConfig.vidHeight; - - qglViewport(iQtrBox[0], iQtrBox[1], iQtrBox[2], iQtrBox[3]); - qglScissor(iQtrBox[0], iQtrBox[1], iQtrBox[2], iQtrBox[3]); - - VectorSet4(box, 0.0f, 0.0f, 1.0f, 1.0f); - - texCoords[0][0] = box[0]; texCoords[0][1] = box[3]; - texCoords[1][0] = box[2]; texCoords[1][1] = box[3]; - texCoords[2][0] = box[2]; texCoords[2][1] = box[1]; - texCoords[3][0] = box[0]; texCoords[3][1] = box[1]; - - VectorSet4(box, -1.0f, -1.0f, 1.0f, 1.0f); - - VectorSet4(quadVerts[0], box[0], box[3], 0, 1); - VectorSet4(quadVerts[1], box[2], box[3], 0, 1); - VectorSet4(quadVerts[2], box[2], box[1], 0, 1); - VectorSet4(quadVerts[3], box[0], box[1], 0, 1); - - GL_State(GLS_DEPTHTEST_DISABLE); - - - VectorSet4(viewInfo, backEnd.viewParms.zFar / r_znear->value, backEnd.viewParms.zFar, 0.0, 0.0); - - viewInfo[2] = scale / (float)(tr.quarterImage[0]->width); - viewInfo[3] = scale / (float)(tr.quarterImage[0]->height); - - FBO_Bind(tr.quarterFbo[1]); - GLSL_BindProgram(&tr.depthBlurShader[2]); - GL_BindToTMU(tr.quarterImage[0], TB_COLORMAP); - GLSL_SetUniformVec4(&tr.depthBlurShader[2], UNIFORM_VIEWINFO, viewInfo); - RB_InstantQuad2(quadVerts, texCoords); - - FBO_Bind(tr.quarterFbo[0]); - GLSL_BindProgram(&tr.depthBlurShader[3]); - GL_BindToTMU(tr.quarterImage[1], TB_COLORMAP); - GLSL_SetUniformVec4(&tr.depthBlurShader[3], UNIFORM_VIEWINFO, viewInfo); - RB_InstantQuad2(quadVerts, texCoords); - - SetViewportAndScissor(); - - FBO_FastBlit(tr.quarterFbo[1], NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); - FBO_Bind(NULL); - } -#endif - - if (0 && r_sunlightMode->integer) - { - ivec4_t dstBox; - VectorSet4(dstBox, 0, glConfig.vidHeight - 128, 128, 128); - FBO_BlitFromTexture(tr.sunShadowDepthImage[0], NULL, NULL, NULL, dstBox, NULL, NULL, 0); - VectorSet4(dstBox, 128, glConfig.vidHeight - 128, 128, 128); - FBO_BlitFromTexture(tr.sunShadowDepthImage[1], NULL, NULL, NULL, dstBox, NULL, NULL, 0); - VectorSet4(dstBox, 256, glConfig.vidHeight - 128, 128, 128); - FBO_BlitFromTexture(tr.sunShadowDepthImage[2], NULL, NULL, NULL, dstBox, NULL, NULL, 0); - VectorSet4(dstBox, 384, glConfig.vidHeight - 128, 128, 128); - FBO_BlitFromTexture(tr.sunShadowDepthImage[3], NULL, NULL, NULL, dstBox, NULL, NULL, 0); - } - - if (0 && r_shadows->integer == 4) - { - ivec4_t dstBox; - VectorSet4(dstBox, 512 + 0, glConfig.vidHeight - 128, 128, 128); - FBO_BlitFromTexture(tr.pshadowMaps[0], NULL, NULL, NULL, dstBox, NULL, NULL, 0); - VectorSet4(dstBox, 512 + 128, glConfig.vidHeight - 128, 128, 128); - FBO_BlitFromTexture(tr.pshadowMaps[1], NULL, NULL, NULL, dstBox, NULL, NULL, 0); - VectorSet4(dstBox, 512 + 256, glConfig.vidHeight - 128, 128, 128); - FBO_BlitFromTexture(tr.pshadowMaps[2], NULL, NULL, NULL, dstBox, NULL, NULL, 0); - VectorSet4(dstBox, 512 + 384, glConfig.vidHeight - 128, 128, 128); - FBO_BlitFromTexture(tr.pshadowMaps[3], NULL, NULL, NULL, dstBox, NULL, NULL, 0); - } - - if (0) - { - ivec4_t dstBox; - VectorSet4(dstBox, 256, glConfig.vidHeight - 256, 256, 256); - FBO_BlitFromTexture(tr.renderDepthImage, NULL, NULL, NULL, dstBox, NULL, NULL, 0); - VectorSet4(dstBox, 512, glConfig.vidHeight - 256, 256, 256); - FBO_BlitFromTexture(tr.screenShadowImage, NULL, NULL, NULL, dstBox, NULL, NULL, 0); - } - - if (0) - { - ivec4_t dstBox; - VectorSet4(dstBox, 256, glConfig.vidHeight - 256, 256, 256); - FBO_BlitFromTexture(tr.sunRaysImage, NULL, NULL, NULL, dstBox, NULL, NULL, 0); - } - -#if 0 - if (r_cubeMapping->integer && tr.numCubemaps) - { - ivec4_t dstBox; - int cubemapIndex = R_CubemapForPoint( backEnd.viewParms.or.origin ); - - if (cubemapIndex) - { - VectorSet4(dstBox, 0, glConfig.vidHeight - 256, 256, 256); - //FBO_BlitFromTexture(tr.renderCubeImage, NULL, NULL, NULL, dstBox, &tr.testcubeShader, NULL, 0); - FBO_BlitFromTexture(tr.cubemaps[cubemapIndex - 1].image, NULL, NULL, NULL, dstBox, &tr.testcubeShader, NULL, 0); - } - } -#endif - - backEnd.framePostProcessed = qtrue; - - return (const void *)(cmd + 1); -} - -// FIXME: put this function declaration elsewhere -void R_SaveDDS(const char *filename, byte *pic, int width, int height, int depth); - -/* -============= -RB_ExportCubemaps - -============= -*/ -static const void *RB_ExportCubemaps(const void *data) -{ - const exportCubemapsCommand_t *cmd = data; - - // finish any 2D drawing if needed - if (tess.numIndexes) - RB_EndSurface(); - - if (!glRefConfig.framebufferObject || !tr.world || tr.numCubemaps == 0) - { - // do nothing - ri.Printf(PRINT_ALL, "Nothing to export!\n"); - return (const void *)(cmd + 1); - } - - if (cmd) - { - FBO_t *oldFbo = glState.currentFBO; - int sideSize = r_cubemapSize->integer * r_cubemapSize->integer * 4; - byte *cubemapPixels = ri.Malloc(sideSize * 6); - int i, j; - - FBO_Bind(tr.renderCubeFbo); - - for (i = 0; i < tr.numCubemaps; i++) - { - char filename[MAX_QPATH]; - cubemap_t *cubemap = &tr.cubemaps[i]; - byte *p = cubemapPixels; - - for (j = 0; j < 6; j++) - { - FBO_AttachImage(tr.renderCubeFbo, cubemap->image, GL_COLOR_ATTACHMENT0_EXT, j); - qglReadPixels(0, 0, r_cubemapSize->integer, r_cubemapSize->integer, GL_RGBA, GL_UNSIGNED_BYTE, p); - p += sideSize; - } - - if (cubemap->name[0]) - { - COM_StripExtension(cubemap->name, filename, MAX_QPATH); - Q_strcat(filename, MAX_QPATH, ".dds"); - } - else - { - Com_sprintf(filename, MAX_QPATH, "cubemaps/%s/%03d.dds", tr.world->baseName, i); - } - - R_SaveDDS(filename, cubemapPixels, r_cubemapSize->integer, r_cubemapSize->integer, 6); - ri.Printf(PRINT_ALL, "Saved cubemap %d as %s\n", i, filename); - } - - FBO_Bind(oldFbo); - - ri.Free(cubemapPixels); - } - - return (const void *)(cmd + 1); -} - - -/* -==================== -RB_ExecuteRenderCommands -==================== -*/ -void RB_ExecuteRenderCommands( const void *data ) { - int t1, t2; - - t1 = ri.Milliseconds (); - - while ( 1 ) { - data = PADP(data, sizeof(void *)); - - switch ( *(const int *)data ) { - case RC_SET_COLOR: - data = RB_SetColor( data ); - break; - case RC_STRETCH_PIC: - data = RB_StretchPic( data ); - break; - case RC_DRAW_SURFS: - data = RB_DrawSurfs( data ); - break; - case RC_DRAW_BUFFER: - data = RB_DrawBuffer( data ); - break; - case RC_SWAP_BUFFERS: - data = RB_SwapBuffers( data ); - break; - case RC_SCREENSHOT: - data = RB_TakeScreenshotCmd( data ); - break; - case RC_VIDEOFRAME: - data = RB_TakeVideoFrameCmd( data ); - break; - case RC_COLORMASK: - data = RB_ColorMask(data); - break; - case RC_CLEARDEPTH: - data = RB_ClearDepth(data); - break; - case RC_CAPSHADOWMAP: - data = RB_CapShadowMap(data); - break; - case RC_POSTPROCESS: - data = RB_PostProcess(data); - break; - case RC_EXPORT_CUBEMAPS: - data = RB_ExportCubemaps(data); - break; - case RC_END_OF_LIST: - default: - // finish any 2D drawing if needed - if(tess.numIndexes) - RB_EndSurface(); - - // stop rendering - t2 = ri.Milliseconds (); - backEnd.pc.msec = t2 - t1; - return; - } - } - -} diff --git a/code/renderer2/tr_bsp.c b/code/renderer2/tr_bsp.c deleted file mode 100644 index 99c1a412af..0000000000 --- a/code/renderer2/tr_bsp.c +++ /dev/null @@ -1,3022 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_map.c - -#include "tr_local.h" - -#define JSON_IMPLEMENTATION -#include "../qcommon/json.h" -#undef JSON_IMPLEMENTATION - -/* - -Loads and prepares a map file for scene rendering. - -A single entry point: - -void RE_LoadWorldMap( const char *name ); - -*/ - -static world_t s_worldData; -static byte *fileBase; - -static int c_gridVerts; - -//=============================================================================== - -static void HSVtoRGB( float h, float s, float v, float rgb[3] ) -{ - int i; - float f; - float p, q, t; - - h *= 5; - - i = floor( h ); - f = h - i; - - p = v * ( 1 - s ); - q = v * ( 1 - s * f ); - t = v * ( 1 - s * ( 1 - f ) ); - - switch ( i ) - { - case 0: - rgb[0] = v; - rgb[1] = t; - rgb[2] = p; - break; - case 1: - rgb[0] = q; - rgb[1] = v; - rgb[2] = p; - break; - case 2: - rgb[0] = p; - rgb[1] = v; - rgb[2] = t; - break; - case 3: - rgb[0] = p; - rgb[1] = q; - rgb[2] = v; - break; - case 4: - rgb[0] = t; - rgb[1] = p; - rgb[2] = v; - break; - case 5: - rgb[0] = v; - rgb[1] = p; - rgb[2] = q; - break; - } -} - -/* -=============== -R_ColorShiftLightingBytes - -=============== -*/ -static void R_ColorShiftLightingBytes( const byte in[4], byte out[4] ) { - int shift, r, g, b; - - // shift the color data based on overbright range - shift = r_mapOverBrightBits->integer - tr.overbrightBits; - - // shift the data based on overbright range - r = in[0] << shift; - g = in[1] << shift; - b = in[2] << shift; - - // normalize by color instead of saturating to white - if ( ( r | g | b ) > 255 ) { - int max; - - max = r > g ? r : g; - max = max > b ? max : b; - r = r * 255 / max; - g = g * 255 / max; - b = b * 255 / max; - } - - out[0] = r; - out[1] = g; - out[2] = b; - out[3] = in[3]; -} - - -/* -=============== -R_ColorShiftLightingFloats - -=============== -*/ -static void R_ColorShiftLightingFloats(const float in[4], float out[4]) -{ - float r, g, b; - float scale = (1 << (r_mapOverBrightBits->integer - tr.overbrightBits)) / 255.0f; - - r = in[0] * scale; - g = in[1] * scale; - b = in[2] * scale; - - // normalize by color instead of saturating to white - if ( r > 1 || g > 1 || b > 1 ) { - float max; - - max = r > g ? r : g; - max = max > b ? max : b; - r = r / max; - g = g / max; - b = b / max; - } - - out[0] = r; - out[1] = g; - out[2] = b; - out[3] = in[3]; -} - -// Modified from http://graphicrants.blogspot.jp/2009/04/rgbm-color-encoding.html -void ColorToRGBM(const vec3_t color, unsigned char rgbm[4]) -{ - vec3_t sample; - float maxComponent; - - VectorCopy(color, sample); - - maxComponent = MAX(sample[0], sample[1]); - maxComponent = MAX(maxComponent, sample[2]); - maxComponent = CLAMP(maxComponent, 1.0f/255.0f, 1.0f); - - rgbm[3] = (unsigned char) ceil(maxComponent * 255.0f); - maxComponent = 255.0f / rgbm[3]; - - VectorScale(sample, maxComponent, sample); - - rgbm[0] = (unsigned char) (sample[0] * 255); - rgbm[1] = (unsigned char) (sample[1] * 255); - rgbm[2] = (unsigned char) (sample[2] * 255); -} - -static void ColorToRGB16(const vec3_t color, uint16_t rgb16[3]) -{ - rgb16[0] = color[0] * 65535.0f + 0.5f; - rgb16[1] = color[1] * 65535.0f + 0.5f; - rgb16[2] = color[2] * 65535.0f + 0.5f; -} - - -/* -=============== -R_LoadLightmaps - -=============== -*/ -#define DEFAULT_LIGHTMAP_SIZE 128 -static void R_LoadLightmaps( const lump_t *l, const lump_t *surfs ) { - imgFlags_t imgFlags = IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE; - byte *buf, *buf_p; - dsurface_t *surf; - int len; - byte *image; - int i, j, numLightmaps, textureInternalFormat = 0; - int numLightmapsPerPage = 16; - float maxIntensity = 0; - double sumIntensity = 0; - - // if we are in r_vertexLight mode, we don't need the lightmaps at all - if ( ( r_vertexLight->integer && tr.vertexLightingAllowed ) || glConfig.hardwareType == GLHW_PERMEDIA2 ) { - return; - } - - len = l->filelen; - if ( !len ) { - return; - } - buf = fileBase + l->fileofs; - - // we are about to upload textures - R_IssuePendingRenderCommands(); - - tr.lightmapSize = DEFAULT_LIGHTMAP_SIZE; - numLightmaps = len / (tr.lightmapSize * tr.lightmapSize * 3); - - // check for deluxe mapping - if (numLightmaps <= 1) - { - tr.worldDeluxeMapping = qfalse; - } - else - { - tr.worldDeluxeMapping = qtrue; - for( i = 0, surf = (dsurface_t *)(fileBase + surfs->fileofs); - i < surfs->filelen / sizeof(dsurface_t); i++, surf++ ) { - int lightmapNum = LittleLong( surf->lightmapNum ); - - if ( lightmapNum >= 0 && (lightmapNum & 1) != 0 ) { - tr.worldDeluxeMapping = qfalse; - break; - } - } - } - - image = ri.Malloc(tr.lightmapSize * tr.lightmapSize * 4 * 2); - - if (tr.worldDeluxeMapping) - numLightmaps >>= 1; - - // Use fat lightmaps of an appropriate size. - if (r_mergeLightmaps->integer) - { - int maxLightmapsPerAxis = glConfig.maxTextureSize / tr.lightmapSize; - int lightmapCols = 4, lightmapRows = 4; - - // Increase width at first, then height. - while (lightmapCols * lightmapRows < numLightmaps && lightmapCols != maxLightmapsPerAxis) - lightmapCols <<= 1; - - while (lightmapCols * lightmapRows < numLightmaps && lightmapRows != maxLightmapsPerAxis) - lightmapRows <<= 1; - - tr.fatLightmapCols = lightmapCols; - tr.fatLightmapRows = lightmapRows; - numLightmapsPerPage = lightmapCols * lightmapRows; - - tr.numLightmaps = (numLightmaps + (numLightmapsPerPage - 1)) / numLightmapsPerPage; - } - else - { - tr.numLightmaps = numLightmaps; - } - - tr.lightmaps = ri.Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); - - if (tr.worldDeluxeMapping) - tr.deluxemaps = ri.Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); - - textureInternalFormat = GL_RGBA8; - if (r_hdr->integer) - { - // Check for the first hdr lightmap, if it exists, use GL_RGBA16 for textures. - char filename[MAX_QPATH]; - - Com_sprintf(filename, sizeof(filename), "maps/%s/lm_0000.hdr", s_worldData.baseName); - if (ri.FS_FileExists(filename)) - textureInternalFormat = GL_RGBA16; - } - - if (r_mergeLightmaps->integer) - { - int width = tr.fatLightmapCols * tr.lightmapSize; - int height = tr.fatLightmapRows * tr.lightmapSize; - - for (i = 0; i < tr.numLightmaps; i++) - { - tr.lightmaps[i] = R_CreateImage(va("_fatlightmap%d", i), NULL, width, height, IMGTYPE_COLORALPHA, imgFlags, textureInternalFormat); - - if (tr.worldDeluxeMapping) - tr.deluxemaps[i] = R_CreateImage(va("_fatdeluxemap%d", i), NULL, width, height, IMGTYPE_DELUXE, imgFlags, 0); - } - } - - for(i = 0; i < numLightmaps; i++) - { - int xoff = 0, yoff = 0; - int lightmapnum = i; - // expand the 24 bit on-disk to 32 bit - - if (r_mergeLightmaps->integer) - { - int lightmaponpage = i % numLightmapsPerPage; - xoff = (lightmaponpage % tr.fatLightmapCols) * tr.lightmapSize; - yoff = (lightmaponpage / tr.fatLightmapCols) * tr.lightmapSize; - - lightmapnum /= numLightmapsPerPage; - } - - // if (tr.worldLightmapping) - { - char filename[MAX_QPATH]; - byte *hdrLightmap = NULL; - int size = 0; - - // look for hdr lightmaps - if (textureInternalFormat == GL_RGBA16) - { - Com_sprintf( filename, sizeof( filename ), "maps/%s/lm_%04d.hdr", s_worldData.baseName, i * (tr.worldDeluxeMapping ? 2 : 1) ); - //ri.Printf(PRINT_ALL, "looking for %s\n", filename); - - size = ri.FS_ReadFile(filename, (void **)&hdrLightmap); - } - - if (hdrLightmap) - { - byte *p = hdrLightmap, *end = hdrLightmap + size; - //ri.Printf(PRINT_ALL, "found!\n"); - - /* FIXME: don't just skip over this header and actually parse it */ - while (p < end && !(*p == '\n' && *(p+1) == '\n')) - p++; - - p += 2; - - while (p < end && !(*p == '\n')) - p++; - - p++; - - if (p >= end) - ri.Error(ERR_DROP, "Bad header for %s!", filename); - - buf_p = p; - -#if 0 // HDRFILE_RGBE - if ((int)(end - hdrLightmap) != tr.lightmapSize * tr.lightmapSize * 4) - ri.Error(ERR_DROP, "Bad size for %s (%i)!", filename, size); -#else // HDRFILE_FLOAT - if ((int)(end - hdrLightmap) != tr.lightmapSize * tr.lightmapSize * 12) - ri.Error(ERR_DROP, "Bad size for %s (%i)!", filename, size); -#endif - } - else - { - int imgOffset = tr.worldDeluxeMapping ? i * 2 : i; - buf_p = buf + imgOffset * tr.lightmapSize * tr.lightmapSize * 3; - } - - for ( j = 0 ; j < tr.lightmapSize * tr.lightmapSize; j++ ) - { - if (hdrLightmap) - { - vec4_t color; - -#if 0 // HDRFILE_RGBE - float exponent = exp2(buf_p[j*4+3] - 128); - - color[0] = buf_p[j*4+0] * exponent; - color[1] = buf_p[j*4+1] * exponent; - color[2] = buf_p[j*4+2] * exponent; -#else // HDRFILE_FLOAT - memcpy(color, &buf_p[j*12], 12); - - color[0] = LittleFloat(color[0]); - color[1] = LittleFloat(color[1]); - color[2] = LittleFloat(color[2]); -#endif - color[3] = 1.0f; - - R_ColorShiftLightingFloats(color, color); - - ColorToRGB16(color, (uint16_t *)(&image[j * 8])); - ((uint16_t *)(&image[j * 8]))[3] = 65535; - } - else if (textureInternalFormat == GL_RGBA16) - { - vec4_t color; - - //hack: convert LDR lightmap to HDR one - color[0] = MAX(buf_p[j*3+0], 0.499f); - color[1] = MAX(buf_p[j*3+1], 0.499f); - color[2] = MAX(buf_p[j*3+2], 0.499f); - - // if under an arbitrary value (say 12) grey it out - // this prevents weird splotches in dimly lit areas - if (color[0] + color[1] + color[2] < 12.0f) - { - float avg = (color[0] + color[1] + color[2]) * 0.3333f; - color[0] = avg; - color[1] = avg; - color[2] = avg; - } - color[3] = 1.0f; - - R_ColorShiftLightingFloats(color, color); - - ColorToRGB16(color, (uint16_t *)(&image[j * 8])); - ((uint16_t *)(&image[j * 8]))[3] = 65535; - } - else - { - if ( r_lightmap->integer == 2 ) - { // color code by intensity as development tool (FIXME: check range) - float r = buf_p[j*3+0]; - float g = buf_p[j*3+1]; - float b = buf_p[j*3+2]; - float intensity; - float out[3] = {0.0, 0.0, 0.0}; - - intensity = 0.33f * r + 0.685f * g + 0.063f * b; - - if ( intensity > 255 ) - intensity = 1.0f; - else - intensity /= 255.0f; - - if ( intensity > maxIntensity ) - maxIntensity = intensity; - - HSVtoRGB( intensity, 1.00, 0.50, out ); - - image[j*4+0] = out[0] * 255; - image[j*4+1] = out[1] * 255; - image[j*4+2] = out[2] * 255; - image[j*4+3] = 255; - - sumIntensity += intensity; - } - else - { - R_ColorShiftLightingBytes( &buf_p[j*3], &image[j*4] ); - image[j*4+3] = 255; - } - } - } - - if (r_mergeLightmaps->integer) - R_UpdateSubImage(tr.lightmaps[lightmapnum], image, xoff, yoff, tr.lightmapSize, tr.lightmapSize, textureInternalFormat); - else - tr.lightmaps[i] = R_CreateImage(va("*lightmap%d", i), image, tr.lightmapSize, tr.lightmapSize, IMGTYPE_COLORALPHA, imgFlags, textureInternalFormat ); - - if (hdrLightmap) - ri.FS_FreeFile(hdrLightmap); - } - - if (tr.worldDeluxeMapping) - { - buf_p = buf + (i * 2 + 1) * tr.lightmapSize * tr.lightmapSize * 3; - - for ( j = 0 ; j < tr.lightmapSize * tr.lightmapSize; j++ ) { - image[j*4+0] = buf_p[j*3+0]; - image[j*4+1] = buf_p[j*3+1]; - image[j*4+2] = buf_p[j*3+2]; - - // make 0,0,0 into 127,127,127 - if ((image[j*4+0] == 0) && (image[j*4+1] == 0) && (image[j*4+2] == 0)) - { - image[j*4+0] = - image[j*4+1] = - image[j*4+2] = 127; - } - - image[j*4+3] = 255; - } - - if (r_mergeLightmaps->integer) - R_UpdateSubImage(tr.deluxemaps[lightmapnum], image, xoff, yoff, tr.lightmapSize, tr.lightmapSize, GL_RGBA8 ); - else - tr.deluxemaps[i] = R_CreateImage(va("*deluxemap%d", i), image, tr.lightmapSize, tr.lightmapSize, IMGTYPE_DELUXE, imgFlags, 0 ); - } - } - - if ( r_lightmap->integer == 2 ) { - ri.Printf( PRINT_ALL, "Brightest lightmap value: %d\n", ( int ) ( maxIntensity * 255 ) ); - } - - ri.Free(image); -} - - -static float FatPackU(float input, int lightmapnum) -{ - if (lightmapnum < 0) - return input; - - if (tr.worldDeluxeMapping) - lightmapnum >>= 1; - - if (tr.fatLightmapCols > 0) - { - lightmapnum %= (tr.fatLightmapCols * tr.fatLightmapRows); - return (input + (lightmapnum % tr.fatLightmapCols)) / (float)(tr.fatLightmapCols); - } - - return input; -} - -static float FatPackV(float input, int lightmapnum) -{ - if (lightmapnum < 0) - return input; - - if (tr.worldDeluxeMapping) - lightmapnum >>= 1; - - if (tr.fatLightmapCols > 0) - { - lightmapnum %= (tr.fatLightmapCols * tr.fatLightmapRows); - return (input + (lightmapnum / tr.fatLightmapCols)) / (float)(tr.fatLightmapRows); - } - - return input; -} - - -static int FatLightmap(int lightmapnum) -{ - if (lightmapnum < 0) - return lightmapnum; - - if (tr.worldDeluxeMapping) - lightmapnum >>= 1; - - if (tr.fatLightmapCols > 0) - return lightmapnum / (tr.fatLightmapCols * tr.fatLightmapRows); - - return lightmapnum; -} - -/* -================= -RE_SetWorldVisData - -This is called by the clipmodel subsystem so we can share the 1.8 megs of -space in big maps... -================= -*/ -void RE_SetWorldVisData( const byte *vis ) { - tr.externalVisData = vis; -} - - -/* -================= -R_LoadVisibility -================= -*/ -static void R_LoadVisibility( const lump_t *l ) { - int len; - byte *buf; - - len = l->filelen; - if ( !len ) { - return; - } - buf = fileBase + l->fileofs; - - s_worldData.numClusters = LittleLong( ((int *)buf)[0] ); - s_worldData.clusterBytes = LittleLong( ((int *)buf)[1] ); - - // CM_Load should have given us the vis data to share, so - // we don't need to allocate another copy - if ( tr.externalVisData ) { - s_worldData.vis = tr.externalVisData; - } else { - byte *dest; - - dest = ri.Hunk_Alloc( len - 8, h_low ); - Com_Memcpy( dest, buf + 8, len - 8 ); - s_worldData.vis = dest; - } -} - -//=============================================================================== - - -/* -=============== -ShaderForShaderNum -=============== -*/ -static shader_t *ShaderForShaderNum( int shaderNum, int lightmapNum ) { - shader_t *shader; - dshader_t *dsh; - - int _shaderNum = LittleLong( shaderNum ); - if ( _shaderNum < 0 || _shaderNum >= s_worldData.numShaders ) { - ri.Error( ERR_DROP, "ShaderForShaderNum: bad num %i", _shaderNum ); - } - dsh = &s_worldData.shaders[ _shaderNum ]; - - - if ( ( r_vertexLight->integer && tr.vertexLightingAllowed ) || glConfig.hardwareType == GLHW_PERMEDIA2 ) { - lightmapNum = LIGHTMAP_BY_VERTEX; - } - - if ( r_fullbright->integer ) { - lightmapNum = LIGHTMAP_WHITEIMAGE; - } - - shader = R_FindShader( dsh->shader, lightmapNum, qtrue ); - - // if the shader had errors, just use default shader - if ( shader->defaultShader ) { - return tr.defaultShader; - } - - return shader; -} - -static void LoadDrawVertToSrfVert(srfVert_t *s, const drawVert_t *d, int realLightmapNum, float hdrVertColors[3], vec3_t *bounds) -{ - vec4_t v; - - s->xyz[0] = LittleFloat(d->xyz[0]); - s->xyz[1] = LittleFloat(d->xyz[1]); - s->xyz[2] = LittleFloat(d->xyz[2]); - - if (bounds) - AddPointToBounds(s->xyz, bounds[0], bounds[1]); - - s->st[0] = LittleFloat(d->st[0]); - s->st[1] = LittleFloat(d->st[1]); - - if (realLightmapNum >= 0) - { - s->lightmap[0] = FatPackU(LittleFloat(d->lightmap[0]), realLightmapNum); - s->lightmap[1] = FatPackV(LittleFloat(d->lightmap[1]), realLightmapNum); - } - else - { - s->lightmap[0] = LittleFloat(d->lightmap[0]); - s->lightmap[1] = LittleFloat(d->lightmap[1]); - } - - v[0] = LittleFloat(d->normal[0]); - v[1] = LittleFloat(d->normal[1]); - v[2] = LittleFloat(d->normal[2]); - - R_VaoPackNormal(s->normal, v); - - if (hdrVertColors) - { - v[0] = hdrVertColors[0]; - v[1] = hdrVertColors[1]; - v[2] = hdrVertColors[2]; - } - else - { - //hack: convert LDR vertex colors to HDR - if (r_hdr->integer) - { - v[0] = MAX(d->color.rgba[0], 0.499f); - v[1] = MAX(d->color.rgba[1], 0.499f); - v[2] = MAX(d->color.rgba[2], 0.499f); - } - else - { - v[0] = d->color.rgba[0]; - v[1] = d->color.rgba[1]; - v[2] = d->color.rgba[2]; - } - - } - v[3] = d->color.rgba[3] / 255.0f; - - R_ColorShiftLightingFloats(v, v); - R_VaoPackColor(s->color, v); -} - - -/* -=============== -ParseFace -=============== -*/ -static void ParseFace( const dsurface_t *ds, const drawVert_t *verts, float *hdrVertColors, msurface_t *surf, int *indexes ) { - int i, j; - srfBspSurface_t *cv; - glIndex_t *tri; - int numVerts, numIndexes, badTriangles; - int realLightmapNum; - - realLightmapNum = LittleLong( ds->lightmapNum ); - - // get fog volume - surf->fogIndex = LittleLong( ds->fogNum ) + 1; - - // get shader value - surf->shader = ShaderForShaderNum( ds->shaderNum, FatLightmap(realLightmapNum) ); - if ( r_singleShader->integer && !surf->shader->isSky ) { - surf->shader = tr.defaultShader; - } - - numVerts = LittleLong(ds->numVerts); - if (numVerts > MAX_FACE_POINTS) { - ri.Printf( PRINT_WARNING, "WARNING: MAX_FACE_POINTS exceeded: %i\n", numVerts); - numVerts = MAX_FACE_POINTS; - surf->shader = tr.defaultShader; - } - - numIndexes = LittleLong(ds->numIndexes); - - //cv = ri.Hunk_Alloc(sizeof(*cv), h_low); - cv = (void *)surf->data; - cv->surfaceType = SF_FACE; - - cv->numIndexes = numIndexes; - cv->indexes = ri.Hunk_Alloc(numIndexes * sizeof(cv->indexes[0]), h_low); - - cv->numVerts = numVerts; - cv->verts = ri.Hunk_Alloc(numVerts * sizeof(cv->verts[0]), h_low); - - // copy vertexes - surf->cullinfo.type = CULLINFO_PLANE | CULLINFO_BOX; - ClearBounds(surf->cullinfo.bounds[0], surf->cullinfo.bounds[1]); - verts += LittleLong(ds->firstVert); - for(i = 0; i < numVerts; i++) - LoadDrawVertToSrfVert(&cv->verts[i], &verts[i], realLightmapNum, hdrVertColors ? hdrVertColors + (ds->firstVert + i) * 3 : NULL, surf->cullinfo.bounds); - - // copy triangles - badTriangles = 0; - indexes += LittleLong(ds->firstIndex); - for(i = 0, tri = cv->indexes; i < numIndexes; i += 3, tri += 3) - { - for(j = 0; j < 3; j++) - { - tri[j] = LittleLong(indexes[i + j]); - - if(tri[j] >= numVerts) - { - ri.Error(ERR_DROP, "Bad index in face surface"); - } - } - - if ((tri[0] == tri[1]) || (tri[1] == tri[2]) || (tri[0] == tri[2])) - { - tri -= 3; - badTriangles++; - } - } - - if (badTriangles) - { - ri.Printf(PRINT_WARNING, "Face has bad triangles, originally shader %s %d tris %d verts, now %d tris\n", surf->shader->name, numIndexes / 3, numVerts, numIndexes / 3 - badTriangles); - cv->numIndexes -= badTriangles * 3; - } - - // take the plane information from the lightmap vector - for ( i = 0 ; i < 3 ; i++ ) { - cv->cullPlane.normal[i] = LittleFloat( ds->lightmapVecs[2][i] ); - } - cv->cullPlane.dist = DotProduct( cv->verts[0].xyz, cv->cullPlane.normal ); - SetPlaneSignbits( &cv->cullPlane ); - cv->cullPlane.type = PlaneTypeForNormal( cv->cullPlane.normal ); - surf->cullinfo.plane = cv->cullPlane; - - surf->data = (surfaceType_t *)cv; - - // Calculate tangent spaces - { - srfVert_t *dv[3]; - - for(i = 0, tri = cv->indexes; i < numIndexes; i += 3, tri += 3) - { - dv[0] = &cv->verts[tri[0]]; - dv[1] = &cv->verts[tri[1]]; - dv[2] = &cv->verts[tri[2]]; - - R_CalcTangentVectors(dv); - } - } -} - - -/* -=============== -ParseMesh -=============== -*/ -static void ParseMesh ( const dsurface_t *ds, const drawVert_t *verts, float *hdrVertColors, msurface_t *surf ) { - srfBspSurface_t *grid = (srfBspSurface_t *)surf->data; - int i; - int width, height, numPoints; - srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE]; - vec3_t bounds[2]; - vec3_t tmpVec; - static surfaceType_t skipData = SF_SKIP; - int realLightmapNum; - - realLightmapNum = LittleLong( ds->lightmapNum ); - - // get fog volume - surf->fogIndex = LittleLong( ds->fogNum ) + 1; - - // get shader value - surf->shader = ShaderForShaderNum( ds->shaderNum, FatLightmap(realLightmapNum) ); - if ( r_singleShader->integer && !surf->shader->isSky ) { - surf->shader = tr.defaultShader; - } - - // we may have a nodraw surface, because they might still need to - // be around for movement clipping - if ( s_worldData.shaders[ LittleLong( ds->shaderNum ) ].surfaceFlags & SURF_NODRAW ) { - surf->data = &skipData; - return; - } - - width = LittleLong( ds->patchWidth ); - height = LittleLong( ds->patchHeight ); - - if(width < 0 || width > MAX_PATCH_SIZE || height < 0 || height > MAX_PATCH_SIZE) - ri.Error(ERR_DROP, "ParseMesh: bad size"); - - verts += LittleLong( ds->firstVert ); - numPoints = width * height; - for(i = 0; i < numPoints; i++) - LoadDrawVertToSrfVert(&points[i], &verts[i], realLightmapNum, hdrVertColors ? hdrVertColors + (ds->firstVert + i) * 3 : NULL, NULL); - - // pre-tesseleate - R_SubdividePatchToGrid( grid, width, height, points ); - - // copy the level of detail origin, which is the center - // of the group of all curves that must subdivide the same - // to avoid cracking - for ( i = 0 ; i < 3 ; i++ ) { - bounds[0][i] = LittleFloat( ds->lightmapVecs[0][i] ); - bounds[1][i] = LittleFloat( ds->lightmapVecs[1][i] ); - } - VectorAdd( bounds[0], bounds[1], bounds[1] ); - VectorScale( bounds[1], 0.5f, grid->lodOrigin ); - VectorSubtract( bounds[0], grid->lodOrigin, tmpVec ); - grid->lodRadius = VectorLength( tmpVec ); - - surf->cullinfo.type = CULLINFO_BOX | CULLINFO_SPHERE; - VectorCopy(grid->cullBounds[0], surf->cullinfo.bounds[0]); - VectorCopy(grid->cullBounds[1], surf->cullinfo.bounds[1]); - VectorCopy(grid->cullOrigin, surf->cullinfo.localOrigin); - surf->cullinfo.radius = grid->cullRadius; -} - -/* -=============== -ParseTriSurf -=============== -*/ -static void ParseTriSurf( const dsurface_t *ds, const drawVert_t *verts, float *hdrVertColors, msurface_t *surf, int *indexes ) { - srfBspSurface_t *cv; - glIndex_t *tri; - int i, j; - int numVerts, numIndexes, badTriangles; - - // get fog volume - surf->fogIndex = LittleLong( ds->fogNum ) + 1; - - // get shader - surf->shader = ShaderForShaderNum( ds->shaderNum, LIGHTMAP_BY_VERTEX ); - if ( r_singleShader->integer && !surf->shader->isSky ) { - surf->shader = tr.defaultShader; - } - - numVerts = LittleLong(ds->numVerts); - numIndexes = LittleLong(ds->numIndexes); - - //cv = ri.Hunk_Alloc(sizeof(*cv), h_low); - cv = (void *)surf->data; - cv->surfaceType = SF_TRIANGLES; - - cv->numIndexes = numIndexes; - cv->indexes = ri.Hunk_Alloc(numIndexes * sizeof(cv->indexes[0]), h_low); - - cv->numVerts = numVerts; - cv->verts = ri.Hunk_Alloc(numVerts * sizeof(cv->verts[0]), h_low); - - surf->data = (surfaceType_t *) cv; - - // copy vertexes - surf->cullinfo.type = CULLINFO_BOX; - ClearBounds(surf->cullinfo.bounds[0], surf->cullinfo.bounds[1]); - verts += LittleLong(ds->firstVert); - for(i = 0; i < numVerts; i++) - LoadDrawVertToSrfVert(&cv->verts[i], &verts[i], -1, hdrVertColors ? hdrVertColors + (ds->firstVert + i) * 3 : NULL, surf->cullinfo.bounds); - - // copy triangles - badTriangles = 0; - indexes += LittleLong(ds->firstIndex); - for(i = 0, tri = cv->indexes; i < numIndexes; i += 3, tri += 3) - { - for(j = 0; j < 3; j++) - { - tri[j] = LittleLong(indexes[i + j]); - - if(tri[j] >= numVerts) - { - ri.Error(ERR_DROP, "Bad index in face surface"); - } - } - - if ((tri[0] == tri[1]) || (tri[1] == tri[2]) || (tri[0] == tri[2])) - { - tri -= 3; - badTriangles++; - } - } - - if (badTriangles) - { - ri.Printf(PRINT_WARNING, "Trisurf has bad triangles, originally shader %s %d tris %d verts, now %d tris\n", surf->shader->name, numIndexes / 3, numVerts, numIndexes / 3 - badTriangles); - cv->numIndexes -= badTriangles * 3; - } - - // Calculate tangent spaces - { - srfVert_t *dv[3]; - - for(i = 0, tri = cv->indexes; i < numIndexes; i += 3, tri += 3) - { - dv[0] = &cv->verts[tri[0]]; - dv[1] = &cv->verts[tri[1]]; - dv[2] = &cv->verts[tri[2]]; - - R_CalcTangentVectors(dv); - } - } -} - -/* -=============== -ParseFlare -=============== -*/ -static void ParseFlare( const dsurface_t *ds, const drawVert_t *verts, msurface_t *surf, int *indexes ) { - srfFlare_t *flare; - int i; - - // get fog volume - surf->fogIndex = LittleLong( ds->fogNum ) + 1; - - // get shader - surf->shader = ShaderForShaderNum( ds->shaderNum, LIGHTMAP_BY_VERTEX ); - if ( r_singleShader->integer && !surf->shader->isSky ) { - surf->shader = tr.defaultShader; - } - - //flare = ri.Hunk_Alloc( sizeof( *flare ), h_low ); - flare = (void *)surf->data; - flare->surfaceType = SF_FLARE; - - surf->data = (surfaceType_t *)flare; - - for ( i = 0 ; i < 3 ; i++ ) { - flare->origin[i] = LittleFloat( ds->lightmapOrigin[i] ); - flare->color[i] = LittleFloat( ds->lightmapVecs[0][i] ); - flare->normal[i] = LittleFloat( ds->lightmapVecs[2][i] ); - } - - surf->cullinfo.type = CULLINFO_NONE; -} - - -/* -================= -R_MergedWidthPoints - -returns qtrue if there are grid points merged on a width edge -================= -*/ -static int R_MergedWidthPoints( const srfBspSurface_t *grid, int offset) { - int i, j; - - for (i = 1; i < grid->width-1; i++) { - for (j = i + 1; j < grid->width-1; j++) { - if ( fabs(grid->verts[i + offset].xyz[0] - grid->verts[j + offset].xyz[0]) > .1) continue; - if ( fabs(grid->verts[i + offset].xyz[1] - grid->verts[j + offset].xyz[1]) > .1) continue; - if ( fabs(grid->verts[i + offset].xyz[2] - grid->verts[j + offset].xyz[2]) > .1) continue; - return qtrue; - } - } - return qfalse; -} - -/* -================= -R_MergedHeightPoints - -returns qtrue if there are grid points merged on a height edge -================= -*/ -static int R_MergedHeightPoints(const srfBspSurface_t *grid, int offset) { - int i, j; - - for (i = 1; i < grid->height-1; i++) { - for (j = i + 1; j < grid->height-1; j++) { - if ( fabs(grid->verts[grid->width * i + offset].xyz[0] - grid->verts[grid->width * j + offset].xyz[0]) > .1) continue; - if ( fabs(grid->verts[grid->width * i + offset].xyz[1] - grid->verts[grid->width * j + offset].xyz[1]) > .1) continue; - if ( fabs(grid->verts[grid->width * i + offset].xyz[2] - grid->verts[grid->width * j + offset].xyz[2]) > .1) continue; - return qtrue; - } - } - return qfalse; -} - -/* -================= -R_FixSharedVertexLodError_r - -NOTE: never sync LoD through grid edges with merged points! - -FIXME: write generalized version that also avoids cracks between a patch and one that meets half way? -================= -*/ -static void R_FixSharedVertexLodError_r( int start, srfBspSurface_t *grid1 ) { - int j, k, l, m, n, offset1, offset2, touch; - srfBspSurface_t *grid2; - - for ( j = start; j < s_worldData.numsurfaces; j++ ) { - // - grid2 = (srfBspSurface_t *) s_worldData.surfaces[j].data; - // if this surface is not a grid - if ( grid2->surfaceType != SF_GRID ) continue; - // if the LOD errors are already fixed for this patch - if ( grid2->lodFixed == 2 ) continue; - // grids in the same LOD group should have the exact same lod radius - if ( grid1->lodRadius != grid2->lodRadius ) continue; - // grids in the same LOD group should have the exact same lod origin - if ( grid1->lodOrigin[0] != grid2->lodOrigin[0] ) continue; - if ( grid1->lodOrigin[1] != grid2->lodOrigin[1] ) continue; - if ( grid1->lodOrigin[2] != grid2->lodOrigin[2] ) continue; - // - touch = qfalse; - for (n = 0; n < 2; n++) { - // - if (n) offset1 = (grid1->height-1) * grid1->width; - else offset1 = 0; - if (R_MergedWidthPoints(grid1, offset1)) continue; - for (k = 1; k < grid1->width-1; k++) { - for (m = 0; m < 2; m++) { - - if (m) offset2 = (grid2->height-1) * grid2->width; - else offset2 = 0; - if (R_MergedWidthPoints(grid2, offset2)) continue; - for ( l = 1; l < grid2->width-1; l++) { - // - if ( fabs(grid1->verts[k + offset1].xyz[0] - grid2->verts[l + offset2].xyz[0]) > .1) continue; - if ( fabs(grid1->verts[k + offset1].xyz[1] - grid2->verts[l + offset2].xyz[1]) > .1) continue; - if ( fabs(grid1->verts[k + offset1].xyz[2] - grid2->verts[l + offset2].xyz[2]) > .1) continue; - // ok the points are equal and should have the same lod error - grid2->widthLodError[l] = grid1->widthLodError[k]; - touch = qtrue; - } - } - for (m = 0; m < 2; m++) { - - if (m) offset2 = grid2->width-1; - else offset2 = 0; - if (R_MergedHeightPoints(grid2, offset2)) continue; - for ( l = 1; l < grid2->height-1; l++) { - // - if ( fabs(grid1->verts[k + offset1].xyz[0] - grid2->verts[grid2->width * l + offset2].xyz[0]) > .1) continue; - if ( fabs(grid1->verts[k + offset1].xyz[1] - grid2->verts[grid2->width * l + offset2].xyz[1]) > .1) continue; - if ( fabs(grid1->verts[k + offset1].xyz[2] - grid2->verts[grid2->width * l + offset2].xyz[2]) > .1) continue; - // ok the points are equal and should have the same lod error - grid2->heightLodError[l] = grid1->widthLodError[k]; - touch = qtrue; - } - } - } - } - for (n = 0; n < 2; n++) { - // - if (n) offset1 = grid1->width-1; - else offset1 = 0; - if (R_MergedHeightPoints(grid1, offset1)) continue; - for (k = 1; k < grid1->height-1; k++) { - for (m = 0; m < 2; m++) { - - if (m) offset2 = (grid2->height-1) * grid2->width; - else offset2 = 0; - if (R_MergedWidthPoints(grid2, offset2)) continue; - for ( l = 1; l < grid2->width-1; l++) { - // - if ( fabs(grid1->verts[grid1->width * k + offset1].xyz[0] - grid2->verts[l + offset2].xyz[0]) > .1) continue; - if ( fabs(grid1->verts[grid1->width * k + offset1].xyz[1] - grid2->verts[l + offset2].xyz[1]) > .1) continue; - if ( fabs(grid1->verts[grid1->width * k + offset1].xyz[2] - grid2->verts[l + offset2].xyz[2]) > .1) continue; - // ok the points are equal and should have the same lod error - grid2->widthLodError[l] = grid1->heightLodError[k]; - touch = qtrue; - } - } - for (m = 0; m < 2; m++) { - - if (m) offset2 = grid2->width-1; - else offset2 = 0; - if (R_MergedHeightPoints(grid2, offset2)) continue; - for ( l = 1; l < grid2->height-1; l++) { - // - if ( fabs(grid1->verts[grid1->width * k + offset1].xyz[0] - grid2->verts[grid2->width * l + offset2].xyz[0]) > .1) continue; - if ( fabs(grid1->verts[grid1->width * k + offset1].xyz[1] - grid2->verts[grid2->width * l + offset2].xyz[1]) > .1) continue; - if ( fabs(grid1->verts[grid1->width * k + offset1].xyz[2] - grid2->verts[grid2->width * l + offset2].xyz[2]) > .1) continue; - // ok the points are equal and should have the same lod error - grid2->heightLodError[l] = grid1->heightLodError[k]; - touch = qtrue; - } - } - } - } - if (touch) { - grid2->lodFixed = 2; - R_FixSharedVertexLodError_r ( start, grid2 ); - //NOTE: this would be correct but makes things really slow - //grid2->lodFixed = 1; - } - } -} - -/* -================= -R_FixSharedVertexLodError - -This function assumes that all patches in one group are nicely stitched together for the highest LoD. -If this is not the case this function will still do its job but won't fix the highest LoD cracks. -================= -*/ -static void R_FixSharedVertexLodError( void ) { - int i; - srfBspSurface_t *grid1; - - for ( i = 0; i < s_worldData.numsurfaces; i++ ) { - // - grid1 = (srfBspSurface_t *) s_worldData.surfaces[i].data; - // if this surface is not a grid - if ( grid1->surfaceType != SF_GRID ) - continue; - // - if ( grid1->lodFixed ) - continue; - // - grid1->lodFixed = 2; - // recursively fix other patches in the same LOD group - R_FixSharedVertexLodError_r( i + 1, grid1); - } -} - - -/* -=============== -R_StitchPatches -=============== -*/ -static int R_StitchPatches( int grid1num, int grid2num ) { - float *v1, *v2; - srfBspSurface_t *grid1, *grid2; - int k, l, m, n, offset1, offset2, row, column; - - grid1 = (srfBspSurface_t *) s_worldData.surfaces[grid1num].data; - grid2 = (srfBspSurface_t *) s_worldData.surfaces[grid2num].data; - for (n = 0; n < 2; n++) { - // - if (n) offset1 = (grid1->height-1) * grid1->width; - else offset1 = 0; - if (R_MergedWidthPoints(grid1, offset1)) - continue; - for (k = 0; k < grid1->width-2; k += 2) { - - for (m = 0; m < 2; m++) { - - if ( grid2->width >= MAX_GRID_SIZE ) - break; - if (m) offset2 = (grid2->height-1) * grid2->width; - else offset2 = 0; - for ( l = 0; l < grid2->width-1; l++) { - // - v1 = grid1->verts[k + offset1].xyz; - v2 = grid2->verts[l + offset2].xyz; - if ( fabs(v1[0] - v2[0]) > .1) - continue; - if ( fabs(v1[1] - v2[1]) > .1) - continue; - if ( fabs(v1[2] - v2[2]) > .1) - continue; - - v1 = grid1->verts[k + 2 + offset1].xyz; - v2 = grid2->verts[l + 1 + offset2].xyz; - if ( fabs(v1[0] - v2[0]) > .1) - continue; - if ( fabs(v1[1] - v2[1]) > .1) - continue; - if ( fabs(v1[2] - v2[2]) > .1) - continue; - // - v1 = grid2->verts[l + offset2].xyz; - v2 = grid2->verts[l + 1 + offset2].xyz; - if ( fabs(v1[0] - v2[0]) < .01 && - fabs(v1[1] - v2[1]) < .01 && - fabs(v1[2] - v2[2]) < .01) - continue; - // - //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); - // insert column into grid2 right after column l - if (m) row = grid2->height-1; - else row = 0; - R_GridInsertColumn( grid2, l+1, row, - grid1->verts[k + 1 + offset1].xyz, grid1->widthLodError[k+1]); - grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (void *) grid2; - return qtrue; - } - } - for (m = 0; m < 2; m++) { - - if (grid2->height >= MAX_GRID_SIZE) - break; - if (m) offset2 = grid2->width-1; - else offset2 = 0; - for ( l = 0; l < grid2->height-1; l++) { - // - v1 = grid1->verts[k + offset1].xyz; - v2 = grid2->verts[grid2->width * l + offset2].xyz; - if ( fabs(v1[0] - v2[0]) > .1) - continue; - if ( fabs(v1[1] - v2[1]) > .1) - continue; - if ( fabs(v1[2] - v2[2]) > .1) - continue; - - v1 = grid1->verts[k + 2 + offset1].xyz; - v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz; - if ( fabs(v1[0] - v2[0]) > .1) - continue; - if ( fabs(v1[1] - v2[1]) > .1) - continue; - if ( fabs(v1[2] - v2[2]) > .1) - continue; - // - v1 = grid2->verts[grid2->width * l + offset2].xyz; - v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz; - if ( fabs(v1[0] - v2[0]) < .01 && - fabs(v1[1] - v2[1]) < .01 && - fabs(v1[2] - v2[2]) < .01) - continue; - // - //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); - // insert row into grid2 right after row l - if (m) column = grid2->width-1; - else column = 0; - R_GridInsertRow( grid2, l+1, column, - grid1->verts[k + 1 + offset1].xyz, grid1->widthLodError[k+1]); - grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (void *) grid2; - return qtrue; - } - } - } - } - for (n = 0; n < 2; n++) { - // - if (n) offset1 = grid1->width-1; - else offset1 = 0; - if (R_MergedHeightPoints(grid1, offset1)) - continue; - for (k = 0; k < grid1->height-2; k += 2) { - for (m = 0; m < 2; m++) { - - if ( grid2->width >= MAX_GRID_SIZE ) - break; - if (m) offset2 = (grid2->height-1) * grid2->width; - else offset2 = 0; - for ( l = 0; l < grid2->width-1; l++) { - // - v1 = grid1->verts[grid1->width * k + offset1].xyz; - v2 = grid2->verts[l + offset2].xyz; - if ( fabs(v1[0] - v2[0]) > .1) - continue; - if ( fabs(v1[1] - v2[1]) > .1) - continue; - if ( fabs(v1[2] - v2[2]) > .1) - continue; - - v1 = grid1->verts[grid1->width * (k + 2) + offset1].xyz; - v2 = grid2->verts[l + 1 + offset2].xyz; - if ( fabs(v1[0] - v2[0]) > .1) - continue; - if ( fabs(v1[1] - v2[1]) > .1) - continue; - if ( fabs(v1[2] - v2[2]) > .1) - continue; - // - v1 = grid2->verts[l + offset2].xyz; - v2 = grid2->verts[(l + 1) + offset2].xyz; - if ( fabs(v1[0] - v2[0]) < .01 && - fabs(v1[1] - v2[1]) < .01 && - fabs(v1[2] - v2[2]) < .01) - continue; - // - //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); - // insert column into grid2 right after column l - if (m) row = grid2->height-1; - else row = 0; - R_GridInsertColumn( grid2, l+1, row, - grid1->verts[grid1->width * (k + 1) + offset1].xyz, grid1->heightLodError[k+1]); - grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (void *) grid2; - return qtrue; - } - } - for (m = 0; m < 2; m++) { - - if (grid2->height >= MAX_GRID_SIZE) - break; - if (m) offset2 = grid2->width-1; - else offset2 = 0; - for ( l = 0; l < grid2->height-1; l++) { - // - v1 = grid1->verts[grid1->width * k + offset1].xyz; - v2 = grid2->verts[grid2->width * l + offset2].xyz; - if ( fabs(v1[0] - v2[0]) > .1) - continue; - if ( fabs(v1[1] - v2[1]) > .1) - continue; - if ( fabs(v1[2] - v2[2]) > .1) - continue; - - v1 = grid1->verts[grid1->width * (k + 2) + offset1].xyz; - v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz; - if ( fabs(v1[0] - v2[0]) > .1) - continue; - if ( fabs(v1[1] - v2[1]) > .1) - continue; - if ( fabs(v1[2] - v2[2]) > .1) - continue; - // - v1 = grid2->verts[grid2->width * l + offset2].xyz; - v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz; - if ( fabs(v1[0] - v2[0]) < .01 && - fabs(v1[1] - v2[1]) < .01 && - fabs(v1[2] - v2[2]) < .01) - continue; - // - //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); - // insert row into grid2 right after row l - if (m) column = grid2->width-1; - else column = 0; - R_GridInsertRow( grid2, l+1, column, - grid1->verts[grid1->width * (k + 1) + offset1].xyz, grid1->heightLodError[k+1]); - grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (void *) grid2; - return qtrue; - } - } - } - } - for (n = 0; n < 2; n++) { - // - if (n) offset1 = (grid1->height-1) * grid1->width; - else offset1 = 0; - if (R_MergedWidthPoints(grid1, offset1)) - continue; - for (k = grid1->width-1; k > 1; k -= 2) { - - for (m = 0; m < 2; m++) { - - if ( !grid2 || grid2->width >= MAX_GRID_SIZE ) - break; - if (m) offset2 = (grid2->height-1) * grid2->width; - else offset2 = 0; - for ( l = 0; l < grid2->width-1; l++) { - // - v1 = grid1->verts[k + offset1].xyz; - v2 = grid2->verts[l + offset2].xyz; - if ( fabs(v1[0] - v2[0]) > .1) - continue; - if ( fabs(v1[1] - v2[1]) > .1) - continue; - if ( fabs(v1[2] - v2[2]) > .1) - continue; - - v1 = grid1->verts[k - 2 + offset1].xyz; - v2 = grid2->verts[l + 1 + offset2].xyz; - if ( fabs(v1[0] - v2[0]) > .1) - continue; - if ( fabs(v1[1] - v2[1]) > .1) - continue; - if ( fabs(v1[2] - v2[2]) > .1) - continue; - // - v1 = grid2->verts[l + offset2].xyz; - v2 = grid2->verts[(l + 1) + offset2].xyz; - if ( fabs(v1[0] - v2[0]) < .01 && - fabs(v1[1] - v2[1]) < .01 && - fabs(v1[2] - v2[2]) < .01) - continue; - // - //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); - // insert column into grid2 right after column l - if (m) row = grid2->height-1; - else row = 0; - R_GridInsertColumn( grid2, l+1, row, - grid1->verts[k - 1 + offset1].xyz, grid1->widthLodError[k+1]); - grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (void *) grid2; - return qtrue; - } - } - for (m = 0; m < 2; m++) { - - if (!grid2 || grid2->height >= MAX_GRID_SIZE) - break; - if (m) offset2 = grid2->width-1; - else offset2 = 0; - for ( l = 0; l < grid2->height-1; l++) { - // - v1 = grid1->verts[k + offset1].xyz; - v2 = grid2->verts[grid2->width * l + offset2].xyz; - if ( fabs(v1[0] - v2[0]) > .1) - continue; - if ( fabs(v1[1] - v2[1]) > .1) - continue; - if ( fabs(v1[2] - v2[2]) > .1) - continue; - - v1 = grid1->verts[k - 2 + offset1].xyz; - v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz; - if ( fabs(v1[0] - v2[0]) > .1) - continue; - if ( fabs(v1[1] - v2[1]) > .1) - continue; - if ( fabs(v1[2] - v2[2]) > .1) - continue; - // - v1 = grid2->verts[grid2->width * l + offset2].xyz; - v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz; - if ( fabs(v1[0] - v2[0]) < .01 && - fabs(v1[1] - v2[1]) < .01 && - fabs(v1[2] - v2[2]) < .01) - continue; - // - //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); - // insert row into grid2 right after row l - if (m) column = grid2->width-1; - else column = 0; - R_GridInsertRow( grid2, l+1, column, - grid1->verts[k - 1 + offset1].xyz, grid1->widthLodError[k+1]); - if (!grid2) - break; - grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (void *) grid2; - return qtrue; - } - } - } - } - for (n = 0; n < 2; n++) { - // - if (n) offset1 = grid1->width-1; - else offset1 = 0; - if (R_MergedHeightPoints(grid1, offset1)) - continue; - for (k = grid1->height-1; k > 1; k -= 2) { - for (m = 0; m < 2; m++) { - - if (!grid2 || grid2->width >= MAX_GRID_SIZE ) - break; - if (m) offset2 = (grid2->height-1) * grid2->width; - else offset2 = 0; - for ( l = 0; l < grid2->width-1; l++) { - // - v1 = grid1->verts[grid1->width * k + offset1].xyz; - v2 = grid2->verts[l + offset2].xyz; - if ( fabs(v1[0] - v2[0]) > .1) - continue; - if ( fabs(v1[1] - v2[1]) > .1) - continue; - if ( fabs(v1[2] - v2[2]) > .1) - continue; - - v1 = grid1->verts[grid1->width * (k - 2) + offset1].xyz; - v2 = grid2->verts[l + 1 + offset2].xyz; - if ( fabs(v1[0] - v2[0]) > .1) - continue; - if ( fabs(v1[1] - v2[1]) > .1) - continue; - if ( fabs(v1[2] - v2[2]) > .1) - continue; - // - v1 = grid2->verts[l + offset2].xyz; - v2 = grid2->verts[(l + 1) + offset2].xyz; - if ( fabs(v1[0] - v2[0]) < .01 && - fabs(v1[1] - v2[1]) < .01 && - fabs(v1[2] - v2[2]) < .01) - continue; - // - //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); - // insert column into grid2 right after column l - if (m) row = grid2->height-1; - else row = 0; - R_GridInsertColumn( grid2, l+1, row, - grid1->verts[grid1->width * (k - 1) + offset1].xyz, grid1->heightLodError[k+1]); - grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (void *) grid2; - return qtrue; - } - } - for (m = 0; m < 2; m++) { - - if (!grid2 || grid2->height >= MAX_GRID_SIZE) - break; - if (m) offset2 = grid2->width-1; - else offset2 = 0; - for ( l = 0; l < grid2->height-1; l++) { - // - v1 = grid1->verts[grid1->width * k + offset1].xyz; - v2 = grid2->verts[grid2->width * l + offset2].xyz; - if ( fabs(v1[0] - v2[0]) > .1) - continue; - if ( fabs(v1[1] - v2[1]) > .1) - continue; - if ( fabs(v1[2] - v2[2]) > .1) - continue; - - v1 = grid1->verts[grid1->width * (k - 2) + offset1].xyz; - v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz; - if ( fabs(v1[0] - v2[0]) > .1) - continue; - if ( fabs(v1[1] - v2[1]) > .1) - continue; - if ( fabs(v1[2] - v2[2]) > .1) - continue; - // - v1 = grid2->verts[grid2->width * l + offset2].xyz; - v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz; - if ( fabs(v1[0] - v2[0]) < .01 && - fabs(v1[1] - v2[1]) < .01 && - fabs(v1[2] - v2[2]) < .01) - continue; - // - //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); - // insert row into grid2 right after row l - if (m) column = grid2->width-1; - else column = 0; - R_GridInsertRow( grid2, l+1, column, - grid1->verts[grid1->width * (k - 1) + offset1].xyz, grid1->heightLodError[k+1]); - grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (void *) grid2; - return qtrue; - } - } - } - } - return qfalse; -} - -/* -=============== -R_TryStitchPatch - -This function will try to stitch patches in the same LoD group together for the highest LoD. - -Only single missing vertex cracks will be fixed. - -Vertices will be joined at the patch side a crack is first found, at the other side -of the patch (on the same row or column) the vertices will not be joined and cracks -might still appear at that side. -=============== -*/ -static int R_TryStitchingPatch( int grid1num ) { - int j, numstitches; - srfBspSurface_t *grid1, *grid2; - - numstitches = 0; - grid1 = (srfBspSurface_t *) s_worldData.surfaces[grid1num].data; - for ( j = 0; j < s_worldData.numsurfaces; j++ ) { - // - grid2 = (srfBspSurface_t *) s_worldData.surfaces[j].data; - // if this surface is not a grid - if ( grid2->surfaceType != SF_GRID ) continue; - // grids in the same LOD group should have the exact same lod radius - if ( grid1->lodRadius != grid2->lodRadius ) continue; - // grids in the same LOD group should have the exact same lod origin - if ( grid1->lodOrigin[0] != grid2->lodOrigin[0] ) continue; - if ( grid1->lodOrigin[1] != grid2->lodOrigin[1] ) continue; - if ( grid1->lodOrigin[2] != grid2->lodOrigin[2] ) continue; - // - while (R_StitchPatches(grid1num, j)) - { - numstitches++; - } - } - return numstitches; -} - -/* -=============== -R_StitchAllPatches -=============== -*/ -static void R_StitchAllPatches( void ) { - int i, stitched, numstitches; - srfBspSurface_t *grid1; - - numstitches = 0; - do - { - stitched = qfalse; - for ( i = 0; i < s_worldData.numsurfaces; i++ ) { - // - grid1 = (srfBspSurface_t *) s_worldData.surfaces[i].data; - // if this surface is not a grid - if ( grid1->surfaceType != SF_GRID ) - continue; - // - if ( grid1->lodStitched ) - continue; - // - grid1->lodStitched = qtrue; - stitched = qtrue; - // - numstitches += R_TryStitchingPatch( i ); - } - } - while (stitched); - ri.Printf( PRINT_ALL, "stitched %d LoD cracks\n", numstitches ); -} - -/* -=============== -R_MovePatchSurfacesToHunk -=============== -*/ -static void R_MovePatchSurfacesToHunk(void) { - int i; - srfBspSurface_t *grid; - - for ( i = 0; i < s_worldData.numsurfaces; i++ ) { - void *copyFrom; - // - grid = (srfBspSurface_t *) s_worldData.surfaces[i].data; - // if this surface is not a grid - if ( grid->surfaceType != SF_GRID ) - continue; - // - - copyFrom = grid->widthLodError; - grid->widthLodError = ri.Hunk_Alloc( grid->width * 4, h_low ); - Com_Memcpy(grid->widthLodError, copyFrom, grid->width * 4); - ri.Free(copyFrom); - - copyFrom = grid->heightLodError; - grid->heightLodError = ri.Hunk_Alloc(grid->height * 4, h_low); - Com_Memcpy(grid->heightLodError, copyFrom, grid->height * 4); - ri.Free(copyFrom); - - copyFrom = grid->indexes; - grid->indexes = ri.Hunk_Alloc(grid->numIndexes * sizeof(glIndex_t), h_low); - Com_Memcpy(grid->indexes, copyFrom, grid->numIndexes * sizeof(glIndex_t)); - ri.Free(copyFrom); - - copyFrom = grid->verts; - grid->verts = ri.Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low); - Com_Memcpy(grid->verts, copyFrom, grid->numVerts * sizeof(srfVert_t)); - ri.Free(copyFrom); - } -} - - -/* -=============== -R_LoadSurfaces -=============== -*/ -static void R_LoadSurfaces( const lump_t *surfs, const lump_t *verts, const lump_t *indexLump ) { - const dsurface_t *in; - msurface_t *out; - const drawVert_t *dv; - int *indexes; - int count; - int numFaces, numMeshes, numTriSurfs, numFlares; - int i; - float *hdrVertColors = NULL; - - numFaces = 0; - numMeshes = 0; - numTriSurfs = 0; - numFlares = 0; - - if (surfs->filelen % sizeof(*in)) - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); - count = surfs->filelen / sizeof(*in); - - dv = (void *)(fileBase + verts->fileofs); - if (verts->filelen % sizeof(*dv)) - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); - - indexes = (void *)(fileBase + indexLump->fileofs); - if ( indexLump->filelen % sizeof(*indexes)) - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); - - out = ri.Hunk_Alloc ( count * sizeof(*out), h_low ); - - s_worldData.surfaces = out; - s_worldData.numsurfaces = count; - s_worldData.surfacesViewCount = ri.Hunk_Alloc ( count * sizeof(*s_worldData.surfacesViewCount), h_low ); - s_worldData.surfacesDlightBits = ri.Hunk_Alloc ( count * sizeof(*s_worldData.surfacesDlightBits), h_low ); - s_worldData.surfacesPshadowBits = ri.Hunk_Alloc ( count * sizeof(*s_worldData.surfacesPshadowBits), h_low ); - - // load hdr vertex colors - if (r_hdr->integer) - { - char filename[MAX_QPATH]; - int size; - - Com_sprintf( filename, sizeof( filename ), "maps/%s/vertlight.raw", s_worldData.baseName); - //ri.Printf(PRINT_ALL, "looking for %s\n", filename); - - size = ri.FS_ReadFile(filename, (void **)&hdrVertColors); - - if (hdrVertColors) - { - //ri.Printf(PRINT_ALL, "Found!\n"); - if (size != sizeof(float) * 3 * (verts->filelen / sizeof(*dv))) - ri.Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)((sizeof(float)) * 3 * (verts->filelen / sizeof(*dv)))); - } - } - - - // Two passes, allocate surfaces first, then load them full of data - // This ensures surfaces are close together to reduce L2 cache misses when using VAOs, - // which don't actually use the verts and indexes - in = (void *)(fileBase + surfs->fileofs); - out = s_worldData.surfaces; - for ( i = 0 ; i < count ; i++, in++, out++ ) { - switch ( LittleLong( in->surfaceType ) ) { - case MST_PATCH: - out->data = ri.Hunk_Alloc( sizeof(srfBspSurface_t), h_low); - break; - case MST_TRIANGLE_SOUP: - out->data = ri.Hunk_Alloc( sizeof(srfBspSurface_t), h_low); - break; - case MST_PLANAR: - out->data = ri.Hunk_Alloc( sizeof(srfBspSurface_t), h_low); - break; - case MST_FLARE: - out->data = ri.Hunk_Alloc( sizeof(srfFlare_t), h_low); - break; - default: - break; - } - } - - in = (void *)(fileBase + surfs->fileofs); - out = s_worldData.surfaces; - for ( i = 0 ; i < count ; i++, in++, out++ ) { - switch ( LittleLong( in->surfaceType ) ) { - case MST_PATCH: - ParseMesh ( in, dv, hdrVertColors, out ); - numMeshes++; - break; - case MST_TRIANGLE_SOUP: - ParseTriSurf( in, dv, hdrVertColors, out, indexes ); - numTriSurfs++; - break; - case MST_PLANAR: - ParseFace( in, dv, hdrVertColors, out, indexes ); - numFaces++; - break; - case MST_FLARE: - ParseFlare( in, dv, out, indexes ); - numFlares++; - break; - default: - ri.Error( ERR_DROP, "Bad surfaceType" ); - } - } - - if (hdrVertColors) - { - ri.FS_FreeFile(hdrVertColors); - } - -#ifdef PATCH_STITCHING - R_StitchAllPatches(); -#endif - - R_FixSharedVertexLodError(); - -#ifdef PATCH_STITCHING - R_MovePatchSurfacesToHunk(); -#endif - - ri.Printf( PRINT_ALL, "...loaded %d faces, %i meshes, %i trisurfs, %i flares\n", - numFaces, numMeshes, numTriSurfs, numFlares ); -} - - - -/* -================= -R_LoadSubmodels -================= -*/ -static void R_LoadSubmodels( const lump_t *l ) { - const dmodel_t *in; - bmodel_t *out; - int i, j, count; - - in = (void *)(fileBase + l->fileofs); - if (l->filelen % sizeof(*in)) - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); - count = l->filelen / sizeof(*in); - - s_worldData.numBModels = count; - s_worldData.bmodels = out = ri.Hunk_Alloc( count * sizeof(*out), h_low ); - - for ( i=0 ; itype = MOD_BRUSH; - model->bmodel = out; - Com_sprintf( model->name, sizeof( model->name ), "*%d", i ); - - for (j=0 ; j<3 ; j++) { - out->bounds[0][j] = LittleFloat (in->mins[j]); - out->bounds[1][j] = LittleFloat (in->maxs[j]); - } - - out->firstSurface = LittleLong( in->firstSurface ); - out->numSurfaces = LittleLong( in->numSurfaces ); - - if(i == 0) - { - // Add this for limiting VAO surface creation - s_worldData.numWorldSurfaces = out->numSurfaces; - } - } -} - - - -//================================================================== - -/* -================= -R_SetParent -================= -*/ -static void R_SetParent (mnode_t *node, mnode_t *parent) -{ - node->parent = parent; - if (node->contents != -1) - return; - R_SetParent (node->children[0], node); - R_SetParent (node->children[1], node); -} - -/* -================= -R_LoadNodesAndLeafs -================= -*/ -static void R_LoadNodesAndLeafs (const lump_t *nodeLump, const lump_t *leafLump) { - int i, j, p; - const dnode_t *in; - dleaf_t *inLeaf; - mnode_t *out; - int numNodes, numLeafs; - - in = (void *)(fileBase + nodeLump->fileofs); - if (nodeLump->filelen % sizeof(dnode_t) || - leafLump->filelen % sizeof(dleaf_t) ) { - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); - } - numNodes = nodeLump->filelen / sizeof(dnode_t); - numLeafs = leafLump->filelen / sizeof(dleaf_t); - - out = ri.Hunk_Alloc ( (numNodes + numLeafs) * sizeof(*out), h_low); - - s_worldData.nodes = out; - s_worldData.numnodes = numNodes + numLeafs; - s_worldData.numDecisionNodes = numNodes; - - // load nodes - for ( i=0 ; imins[j] = LittleLong (in->mins[j]); - out->maxs[j] = LittleLong (in->maxs[j]); - } - - p = LittleLong(in->planeNum); - out->plane = s_worldData.planes + p; - - out->contents = CONTENTS_NODE; // differentiate from leafs - - for (j=0 ; j<2 ; j++) - { - p = LittleLong (in->children[j]); - if (p >= 0) - out->children[j] = s_worldData.nodes + p; - else - out->children[j] = s_worldData.nodes + numNodes + (-1 - p); - } - } - - // load leafs - inLeaf = (void *)(fileBase + leafLump->fileofs); - for ( i=0 ; imins[j] = LittleLong (inLeaf->mins[j]); - out->maxs[j] = LittleLong (inLeaf->maxs[j]); - } - - out->cluster = LittleLong(inLeaf->cluster); - out->area = LittleLong(inLeaf->area); - - if ( out->cluster >= s_worldData.numClusters ) { - s_worldData.numClusters = out->cluster + 1; - } - - out->firstmarksurface = LittleLong(inLeaf->firstLeafSurface); - out->nummarksurfaces = LittleLong(inLeaf->numLeafSurfaces); - } - - // chain descendants - R_SetParent (s_worldData.nodes, NULL); -} - -//============================================================================= - -/* -================= -R_LoadShaders -================= -*/ -static void R_LoadShaders( const lump_t *l ) { - int i, count; - dshader_t *in, *out; - - in = (void *)(fileBase + l->fileofs); - if (l->filelen % sizeof(*in)) - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); - count = l->filelen / sizeof(*in); - out = ri.Hunk_Alloc ( count*sizeof(*out), h_low ); - - s_worldData.shaders = out; - s_worldData.numShaders = count; - - Com_Memcpy( out, in, count*sizeof(*out) ); - - for ( i=0 ; ifileofs); - if (l->filelen % sizeof(*in)) - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); - count = l->filelen / sizeof(*in); - out = ri.Hunk_Alloc ( count*sizeof(*out), h_low); - - s_worldData.marksurfaces = out; - s_worldData.nummarksurfaces = count; - - for ( i=0 ; ifileofs); - if (l->filelen % sizeof(*in)) - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); - count = l->filelen / sizeof(*in); - out = ri.Hunk_Alloc ( count*2*sizeof(*out), h_low); - - s_worldData.planes = out; - s_worldData.numplanes = count; - - for ( i=0 ; inormal[j] = LittleFloat (in->normal[j]); - if (out->normal[j] < 0) { - bits |= 1<dist = LittleFloat (in->dist); - out->type = PlaneTypeForNormal( out->normal ); - out->signbits = bits; - } -} - -/* -================= -R_LoadFogs - -================= -*/ -static void R_LoadFogs( const lump_t *l, const lump_t *brushesLump, const lump_t *sidesLump ) { - int i; - fog_t *out; - const dfog_t *fogs; - const dbrush_t *brushes, *brush; - const dbrushside_t *sides; - int count, brushesCount, sidesCount; - int sideNum; - int planeNum; - shader_t *shader; - float d; - int firstSide; - - fogs = (void *)(fileBase + l->fileofs); - if (l->filelen % sizeof(*fogs)) { - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); - } - count = l->filelen / sizeof(*fogs); - - // create fog structures for them - s_worldData.numfogs = count + 1; - s_worldData.fogs = ri.Hunk_Alloc ( s_worldData.numfogs*sizeof(*out), h_low); - out = s_worldData.fogs + 1; - - if ( !count ) { - return; - } - - brushes = (void *)(fileBase + brushesLump->fileofs); - if (brushesLump->filelen % sizeof(*brushes)) { - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); - } - brushesCount = brushesLump->filelen / sizeof(*brushes); - - sides = (void *)(fileBase + sidesLump->fileofs); - if (sidesLump->filelen % sizeof(*sides)) { - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); - } - sidesCount = sidesLump->filelen / sizeof(*sides); - - for ( i=0 ; ioriginalBrushNumber = LittleLong( fogs->brushNum ); - - if ( (unsigned)out->originalBrushNumber >= brushesCount ) { - ri.Error( ERR_DROP, "fog brushNumber out of range" ); - } - brush = brushes + out->originalBrushNumber; - - firstSide = LittleLong( brush->firstSide ); - - if ( (unsigned)firstSide > sidesCount - 6 ) { - ri.Error( ERR_DROP, "fog brush sideNumber out of range" ); - } - - // brushes are always sorted with the axial sides first - sideNum = firstSide + 0; - planeNum = LittleLong( sides[ sideNum ].planeNum ); - out->bounds[0][0] = -s_worldData.planes[ planeNum ].dist; - - sideNum = firstSide + 1; - planeNum = LittleLong( sides[ sideNum ].planeNum ); - out->bounds[1][0] = s_worldData.planes[ planeNum ].dist; - - sideNum = firstSide + 2; - planeNum = LittleLong( sides[ sideNum ].planeNum ); - out->bounds[0][1] = -s_worldData.planes[ planeNum ].dist; - - sideNum = firstSide + 3; - planeNum = LittleLong( sides[ sideNum ].planeNum ); - out->bounds[1][1] = s_worldData.planes[ planeNum ].dist; - - sideNum = firstSide + 4; - planeNum = LittleLong( sides[ sideNum ].planeNum ); - out->bounds[0][2] = -s_worldData.planes[ planeNum ].dist; - - sideNum = firstSide + 5; - planeNum = LittleLong( sides[ sideNum ].planeNum ); - out->bounds[1][2] = s_worldData.planes[ planeNum ].dist; - - // get information from the shader for fog parameters - shader = R_FindShader( fogs->shader, LIGHTMAP_NONE, qtrue ); - - out->parms = shader->fogParms; - - out->colorInt = ColorBytes4 ( shader->fogParms.color[0], - shader->fogParms.color[1], - shader->fogParms.color[2], 1.0 ); - - d = shader->fogParms.depthForOpaque < 1 ? 1 : shader->fogParms.depthForOpaque; - out->tcScale = 1.0f / ( d * 8 ); - - // set the gradient vector - sideNum = LittleLong( fogs->visibleSide ); - - if ( sideNum == -1 ) { - out->hasSurface = qfalse; - } else { - out->hasSurface = qtrue; - planeNum = LittleLong( sides[ firstSide + sideNum ].planeNum ); - VectorSubtract( vec3_origin, s_worldData.planes[ planeNum ].normal, out->surface ); - out->surface[3] = -s_worldData.planes[ planeNum ].dist; - } - - out++; - } - -} - - -/* -================ -R_LoadLightGrid - -================ -*/ -static void R_LoadLightGrid( const lump_t *l ) { - int i; - vec3_t maxs; - int numGridPoints; - world_t *w; - float *wMins, *wMaxs; - - w = &s_worldData; - - w->lightGridInverseSize[0] = 1.0f / w->lightGridSize[0]; - w->lightGridInverseSize[1] = 1.0f / w->lightGridSize[1]; - w->lightGridInverseSize[2] = 1.0f / w->lightGridSize[2]; - - wMins = w->bmodels[0].bounds[0]; - wMaxs = w->bmodels[0].bounds[1]; - - for ( i = 0 ; i < 3 ; i++ ) { - w->lightGridOrigin[i] = w->lightGridSize[i] * ceil( wMins[i] / w->lightGridSize[i] ); - maxs[i] = w->lightGridSize[i] * floor( wMaxs[i] / w->lightGridSize[i] ); - w->lightGridBounds[i] = (maxs[i] - w->lightGridOrigin[i])/w->lightGridSize[i] + 1; - } - - numGridPoints = w->lightGridBounds[0] * w->lightGridBounds[1] * w->lightGridBounds[2]; - - if ( l->filelen != numGridPoints * 8 ) { - ri.Printf( PRINT_WARNING, "WARNING: light grid mismatch\n" ); - w->lightGridData = NULL; - return; - } - - w->lightGridData = ri.Hunk_Alloc( l->filelen, h_low ); - Com_Memcpy( w->lightGridData, (void *)(fileBase + l->fileofs), l->filelen ); - - // deal with overbright bits - for ( i = 0 ; i < numGridPoints ; i++ ) { - R_ColorShiftLightingBytes( &w->lightGridData[i*8], &w->lightGridData[i*8] ); - R_ColorShiftLightingBytes( &w->lightGridData[i*8+3], &w->lightGridData[i*8+3] ); - } - - // load hdr lightgrid - if (r_hdr->integer) - { - char filename[MAX_QPATH]; - float *hdrLightGrid; - int size; - - Com_sprintf( filename, sizeof( filename ), "maps/%s/lightgrid.raw", s_worldData.baseName); - //ri.Printf(PRINT_ALL, "looking for %s\n", filename); - - size = ri.FS_ReadFile(filename, (void **)&hdrLightGrid); - - if (hdrLightGrid) - { - //ri.Printf(PRINT_ALL, "found!\n"); - - if (size != sizeof(float) * 6 * numGridPoints) - ri.Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)(sizeof(float)) * 6 * numGridPoints); - - w->lightGrid16 = ri.Hunk_Alloc(sizeof(w->lightGrid16) * 6 * numGridPoints, h_low); - - for (i = 0; i < numGridPoints ; i++) - { - vec4_t c; - - c[0] = hdrLightGrid[i * 6]; - c[1] = hdrLightGrid[i * 6 + 1]; - c[2] = hdrLightGrid[i * 6 + 2]; - c[3] = 1.0f; - - R_ColorShiftLightingFloats(c, c); - ColorToRGB16(c, &w->lightGrid16[i * 6]); - - c[0] = hdrLightGrid[i * 6 + 3]; - c[1] = hdrLightGrid[i * 6 + 4]; - c[2] = hdrLightGrid[i * 6 + 5]; - c[3] = 1.0f; - - R_ColorShiftLightingFloats(c, c); - ColorToRGB16(c, &w->lightGrid16[i * 6 + 3]); - } - } - else if (0) - { - // promote 8-bit lightgrid to 16-bit - w->lightGrid16 = ri.Hunk_Alloc(sizeof(w->lightGrid16) * 6 * numGridPoints, h_low); - - for (i = 0; i < numGridPoints; i++) - { - w->lightGrid16[i * 6] = w->lightGridData[i * 8] * 257; - w->lightGrid16[i * 6 + 1] = w->lightGridData[i * 8 + 1] * 257; - w->lightGrid16[i * 6 + 2] = w->lightGridData[i * 8 + 2] * 257; - w->lightGrid16[i * 6 + 3] = w->lightGridData[i * 8 + 3] * 257; - w->lightGrid16[i * 6 + 4] = w->lightGridData[i * 8 + 4] * 257; - w->lightGrid16[i * 6 + 5] = w->lightGridData[i * 8 + 5] * 257; - } - } - - if (hdrLightGrid) - ri.FS_FreeFile(hdrLightGrid); - } -} - -/* -================ -R_LoadEntities -================ -*/ -static void R_LoadEntities( const lump_t *l ) { - const char *p, *token, *s; - char keyname[MAX_TOKEN_CHARS]; - char value[MAX_TOKEN_CHARS]; - world_t *w; - - w = &s_worldData; - w->lightGridSize[0] = 64; - w->lightGridSize[1] = 64; - w->lightGridSize[2] = 128; - - p = (const char *)(fileBase + l->fileofs); - - // store for reference by the cgame - w->entityString = ri.Hunk_Alloc( l->filelen + 1, h_low ); - strcpy( w->entityString, p ); - w->entityParsePoint = w->entityString; - - token = COM_ParseExt( &p, qtrue ); - if (!*token || *token != '{') { - return; - } - - // only parse the world spawn - while ( 1 ) { - // parse key - token = COM_ParseExt( &p, qtrue ); - - if ( !*token || *token == '}' ) { - break; - } - Q_strncpyz(keyname, token, sizeof(keyname)); - - // parse value - token = COM_ParseExt( &p, qtrue ); - - if ( !*token || *token == '}' ) { - break; - } - Q_strncpyz(value, token, sizeof(value)); - - // check for remapping of shaders for vertex lighting - s = "vertexremapshader"; - if (!Q_strncmp(keyname, s, strlen(s)) ) { - char *vs = strchr(value, ';'); - if (!vs) { - ri.Printf( PRINT_WARNING, "WARNING: no semi colon in vertexshaderremap '%s'\n", value ); - break; - } - *vs++ = 0; - if ( r_vertexLight->integer && tr.vertexLightingAllowed ) { - R_RemapShader(value, s, "0"); - } - continue; - } - // check for remapping of shaders - s = "remapshader"; - if (!Q_strncmp(keyname, s, strlen(s)) ) { - char *vs = strchr(value, ';'); - if (!vs) { - ri.Printf( PRINT_WARNING, "WARNING: no semi colon in shaderremap '%s'\n", value ); - break; - } - *vs++ = 0; - R_RemapShader(value, s, "0"); - continue; - } - // check for a different grid size - if (!Q_stricmp(keyname, "gridsize")) { - sscanf(value, "%f %f %f", &w->lightGridSize[0], &w->lightGridSize[1], &w->lightGridSize[2] ); - continue; - } - - // check for auto exposure - if (!Q_stricmp(keyname, "autoExposureMinMax")) { - sscanf(value, "%f %f", &tr.autoExposureMinMax[0], &tr.autoExposureMinMax[1]); - continue; - } - } -} - -/* -================= -R_GetEntityToken -================= -*/ -qboolean R_GetEntityToken( char *buffer, int size ) { - const char *s; - - s = COM_Parse( &s_worldData.entityParsePoint ); - Q_strncpyz( buffer, s, size ); - if ( !s_worldData.entityParsePoint && !s[0] ) { - s_worldData.entityParsePoint = s_worldData.entityString; - return qfalse; - } else { - return qtrue; - } -} - -#ifndef MAX_SPAWN_VARS -#define MAX_SPAWN_VARS 64 -#endif - -// derived from G_ParseSpawnVars() in g_spawn.c -static qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int *numSpawnVars, const char *spawnVars[MAX_SPAWN_VARS][2] ) -{ - char keyname[MAX_TOKEN_CHARS]; - char com_token[MAX_TOKEN_CHARS]; - int numSpawnVarChars = 0; - - *numSpawnVars = 0; - - // parse the opening brace - if ( !R_GetEntityToken( com_token, sizeof( com_token ) ) ) { - // end of spawn string - return qfalse; - } - if ( com_token[0] != '{' ) { - ri.Printf( PRINT_ALL, "R_ParseSpawnVars: found %s when expecting {\n",com_token ); - return qfalse; - } - - // go through all the key / value pairs - while ( 1 ) { - int keyLength, tokenLength; - - // parse key - if ( !R_GetEntityToken( keyname, sizeof( keyname ) ) ) { - ri.Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace\n" ); - return qfalse; - } - - if ( keyname[0] == '}' ) { - break; - } - - // parse value - if ( !R_GetEntityToken( com_token, sizeof( com_token ) ) ) { - ri.Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace\n" ); - return qfalse; - } - - if ( com_token[0] == '}' ) { - ri.Printf( PRINT_ALL, "R_ParseSpawnVars: closing brace without data\n" ); - return qfalse; - } - - if ( *numSpawnVars == MAX_SPAWN_VARS ) { - ri.Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VARS\n" ); - return qfalse; - } - - keyLength = strlen(keyname) + 1; - tokenLength = strlen(com_token) + 1; - - if (numSpawnVarChars + keyLength + tokenLength > maxSpawnVarChars) - { - ri.Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VAR_CHARS\n" ); - return qfalse; - } - - strcpy(spawnVarChars + numSpawnVarChars, keyname); - spawnVars[ *numSpawnVars ][0] = spawnVarChars + numSpawnVarChars; - numSpawnVarChars += keyLength; - - strcpy(spawnVarChars + numSpawnVarChars, com_token); - spawnVars[ *numSpawnVars ][1] = spawnVarChars + numSpawnVarChars; - numSpawnVarChars += tokenLength; - - (*numSpawnVars)++; - } - - return qtrue; -} - -static void R_LoadEnvironmentJson(const char *baseName) -{ - char filename[MAX_QPATH]; - - union { - char *c; - void *v; - } buffer; - char *bufferEnd; - - const char *cubemapArrayJson; - int filelen, i; - - Com_sprintf(filename, MAX_QPATH, "cubemaps/%s/env.json", baseName); - - filelen = ri.FS_ReadFile(filename, &buffer.v); - if (!buffer.c) - return; - bufferEnd = buffer.c + filelen; - - if (JSON_ValueGetType(buffer.c, bufferEnd) != JSONTYPE_OBJECT) - { - ri.Printf(PRINT_ALL, "Bad %s: does not start with a object\n", filename); - ri.FS_FreeFile(buffer.v); - return; - } - - cubemapArrayJson = JSON_ObjectGetNamedValue(buffer.c, bufferEnd, "Cubemaps"); - if (!cubemapArrayJson) - { - ri.Printf(PRINT_ALL, "Bad %s: no Cubemaps\n", filename); - ri.FS_FreeFile(buffer.v); - return; - } - - if (JSON_ValueGetType(cubemapArrayJson, bufferEnd) != JSONTYPE_ARRAY) - { - ri.Printf(PRINT_ALL, "Bad %s: Cubemaps not an array\n", filename); - ri.FS_FreeFile(buffer.v); - return; - } - - tr.numCubemaps = JSON_ArrayGetIndex(cubemapArrayJson, bufferEnd, NULL, 0); - tr.cubemaps = ri.Hunk_Alloc(tr.numCubemaps * sizeof(*tr.cubemaps), h_low); - memset(tr.cubemaps, 0, tr.numCubemaps * sizeof(*tr.cubemaps)); - - for (i = 0; i < tr.numCubemaps; i++) - { - cubemap_t *cubemap = &tr.cubemaps[i]; - const char *cubemapJson, *keyValueJson, *indexes[3]; - int j; - - cubemapJson = JSON_ArrayGetValue(cubemapArrayJson, bufferEnd, i); - - keyValueJson = JSON_ObjectGetNamedValue(cubemapJson, bufferEnd, "Name"); - if (!JSON_ValueGetString(keyValueJson, bufferEnd, cubemap->name, MAX_QPATH)) - cubemap->name[0] = '\0'; - - keyValueJson = JSON_ObjectGetNamedValue(cubemapJson, bufferEnd, "Position"); - JSON_ArrayGetIndex(keyValueJson, bufferEnd, indexes, 3); - for (j = 0; j < 3; j++) - cubemap->origin[j] = JSON_ValueGetFloat(indexes[j], bufferEnd); - - cubemap->parallaxRadius = 1000.0f; - keyValueJson = JSON_ObjectGetNamedValue(cubemapJson, bufferEnd, "Radius"); - if (keyValueJson) - cubemap->parallaxRadius = JSON_ValueGetFloat(keyValueJson, bufferEnd); - } - - ri.FS_FreeFile(buffer.v); -} - -static void R_LoadCubemapEntities(char *cubemapEntityName) -{ - char spawnVarChars[2048]; - int numSpawnVars; - const char *spawnVars[MAX_SPAWN_VARS][2]; - int numCubemaps = 0; - - // count cubemaps - numCubemaps = 0; - while(R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) - { - int i; - - for (i = 0; i < numSpawnVars; i++) - { - if (!Q_stricmp(spawnVars[i][0], "classname") && !Q_stricmp(spawnVars[i][1], cubemapEntityName)) - numCubemaps++; - } - } - - if (!numCubemaps) - return; - - tr.numCubemaps = numCubemaps; - tr.cubemaps = ri.Hunk_Alloc(tr.numCubemaps * sizeof(*tr.cubemaps), h_low); - memset(tr.cubemaps, 0, tr.numCubemaps * sizeof(*tr.cubemaps)); - - numCubemaps = 0; - while(R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) - { - int i; - char name[MAX_QPATH]; - qboolean isCubemap = qfalse; - qboolean originSet = qfalse; - vec3_t origin; - float parallaxRadius = 1000.0f; - - name[0] = '\0'; - for (i = 0; i < numSpawnVars; i++) - { - if (!Q_stricmp(spawnVars[i][0], "classname") && !Q_stricmp(spawnVars[i][1], cubemapEntityName)) - isCubemap = qtrue; - - if (!Q_stricmp(spawnVars[i][0], "name")) - Q_strncpyz(name, spawnVars[i][1], sizeof(name)); - - if (!Q_stricmp(spawnVars[i][0], "origin")) - { - sscanf(spawnVars[i][1], "%f %f %f", &origin[0], &origin[1], &origin[2]); - originSet = qtrue; - } - else if (!Q_stricmp(spawnVars[i][0], "radius")) - { - sscanf(spawnVars[i][1], "%f", ¶llaxRadius); - } - } - - if (isCubemap && originSet) - { - cubemap_t *cubemap = &tr.cubemaps[numCubemaps]; - Q_strncpyz(cubemap->name, name, sizeof(cubemap->name)); - VectorCopy(origin, cubemap->origin); - cubemap->parallaxRadius = parallaxRadius; - numCubemaps++; - } - } -} - -static void R_AssignCubemapsToWorldSurfaces(void) -{ - world_t *w; - int i; - - w = &s_worldData; - - for (i = 0; i < w->numsurfaces; i++) - { - msurface_t *surf = &w->surfaces[i]; - vec3_t surfOrigin; - - if (surf->cullinfo.type & CULLINFO_SPHERE) - { - VectorCopy(surf->cullinfo.localOrigin, surfOrigin); - } - else if (surf->cullinfo.type & CULLINFO_BOX) - { - surfOrigin[0] = (surf->cullinfo.bounds[0][0] + surf->cullinfo.bounds[1][0]) * 0.5f; - surfOrigin[1] = (surf->cullinfo.bounds[0][1] + surf->cullinfo.bounds[1][1]) * 0.5f; - surfOrigin[2] = (surf->cullinfo.bounds[0][2] + surf->cullinfo.bounds[1][2]) * 0.5f; - } - else - { - //ri.Printf(PRINT_ALL, "surface %d has no cubemap\n", i); - continue; - } - - surf->cubemapIndex = R_CubemapForPoint(surfOrigin); - //ri.Printf(PRINT_ALL, "surface %d has cubemap %d\n", i, surf->cubemapIndex); - } -} - - -static void R_LoadCubemaps(void) -{ - int i; - imgFlags_t flags = IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_NOLIGHTSCALE | IMGFLAG_CUBEMAP; - - for (i = 0; i < tr.numCubemaps; i++) - { - char filename[MAX_QPATH]; - cubemap_t *cubemap = &tr.cubemaps[i]; - - Com_sprintf(filename, MAX_QPATH, "cubemaps/%s/%03d.dds", tr.world->baseName, i); - - cubemap->image = R_FindImageFile(filename, IMGTYPE_COLORALPHA, flags); - } -} - - -static void R_RenderMissingCubemaps(void) -{ - int i, j; - imgFlags_t flags = IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_NOLIGHTSCALE | IMGFLAG_CUBEMAP; - - for (i = 0; i < tr.numCubemaps; i++) - { - if (!tr.cubemaps[i].image) - { - tr.cubemaps[i].image = R_CreateImage(va("*cubeMap%d", i), NULL, r_cubemapSize->integer, r_cubemapSize->integer, IMGTYPE_COLORALPHA, flags, GL_RGBA8); - - for (j = 0; j < 6; j++) - { - RE_ClearScene(); - R_RenderCubemapSide(i, j, qfalse); - R_IssuePendingRenderCommands(); - R_InitNextFrame(); - } - } - } -} - - -static void R_CalcVertexLightDirs( void ) -{ - int i, k; - msurface_t *surface; - - for(k = 0, surface = &s_worldData.surfaces[0]; k < s_worldData.numsurfaces /* s_worldData.numWorldSurfaces */; k++, surface++) - { - srfBspSurface_t *bspSurf = (srfBspSurface_t *) surface->data; - - switch(bspSurf->surfaceType) - { - case SF_FACE: - case SF_GRID: - case SF_TRIANGLES: - for(i = 0; i < bspSurf->numVerts; i++) - { - vec3_t lightDir; - vec3_t normal; - - R_VaoUnpackNormal(normal, bspSurf->verts[i].normal); - R_LightDirForPoint( bspSurf->verts[i].xyz, lightDir, normal, &s_worldData ); - R_VaoPackNormal(bspSurf->verts[i].lightdir, lightDir); - } - - break; - - default: - break; - } - } -} - - -/* -================= -RE_LoadWorldMap - -Called directly from cgame -================= -*/ -void RE_LoadWorldMap( const char *name ) { - int i; - dheader_t *header; - union { - byte *b; - void *v; - } buffer; - byte *startMarker; - - if ( tr.worldMapLoaded ) { - ri.Error( ERR_DROP, "ERROR: attempted to redundantly load world map" ); - } - - // set default map light scale - tr.sunShadowScale = 0.5f; - - // set default sun direction to be used if it isn't - // overridden by a shader - tr.sunDirection[0] = 0.45f; - tr.sunDirection[1] = 0.3f; - tr.sunDirection[2] = 0.9f; - - VectorNormalize( tr.sunDirection ); - - // set default autoexposure settings - tr.autoExposureMinMax[0] = -2.0f; - tr.autoExposureMinMax[1] = 2.0f; - - // set default tone mapping settings - tr.toneMinAvgMaxLevel[0] = -8.0f; - tr.toneMinAvgMaxLevel[1] = -2.0f; - tr.toneMinAvgMaxLevel[2] = 0.0f; - - // reset last cascade sun direction so last shadow cascade is rerendered - VectorClear(tr.lastCascadeSunDirection); - - tr.worldMapLoaded = qtrue; - - // load it - ri.FS_ReadFile( name, &buffer.v ); - if ( !buffer.b ) { - ri.Error (ERR_DROP, "RE_LoadWorldMap: %s not found", name); - } - - // clear tr.world so if the level fails to load, the next - // try will not look at the partially loaded version - tr.world = NULL; - - Com_Memset( &s_worldData, 0, sizeof( s_worldData ) ); - Q_strncpyz( s_worldData.name, name, sizeof( s_worldData.name ) ); - - Q_strncpyz( s_worldData.baseName, COM_SkipPath( s_worldData.name ), sizeof( s_worldData.name ) ); - COM_StripExtension(s_worldData.baseName, s_worldData.baseName, sizeof(s_worldData.baseName)); - - startMarker = ri.Hunk_Alloc(0, h_low); - c_gridVerts = 0; - - header = (dheader_t *)buffer.b; - fileBase = (byte *)header; - - i = LittleLong (header->version); - if ( i != BSP_VERSION ) { - ri.Error (ERR_DROP, "RE_LoadWorldMap: %s has wrong version number (%i should be %i)", - name, i, BSP_VERSION); - } - - // swap all the lumps - for (i=0 ; ilumps[LUMP_ENTITIES] ); - R_LoadShaders( &header->lumps[LUMP_SHADERS] ); - R_LoadLightmaps( &header->lumps[LUMP_LIGHTMAPS], &header->lumps[LUMP_SURFACES] ); - R_LoadPlanes (&header->lumps[LUMP_PLANES]); - R_LoadFogs( &header->lumps[LUMP_FOGS], &header->lumps[LUMP_BRUSHES], &header->lumps[LUMP_BRUSHSIDES] ); - R_LoadSurfaces( &header->lumps[LUMP_SURFACES], &header->lumps[LUMP_DRAWVERTS], &header->lumps[LUMP_DRAWINDEXES] ); - R_LoadMarksurfaces (&header->lumps[LUMP_LEAFSURFACES]); - R_LoadNodesAndLeafs (&header->lumps[LUMP_NODES], &header->lumps[LUMP_LEAFS]); - R_LoadSubmodels (&header->lumps[LUMP_MODELS]); - R_LoadVisibility( &header->lumps[LUMP_VISIBILITY] ); - R_LoadLightGrid( &header->lumps[LUMP_LIGHTGRID] ); - - // determine vertex light directions - R_CalcVertexLightDirs(); - - // determine which parts of the map are in sunlight - if (0) - { - world_t *w; - uint8_t *primaryLightGrid, *data; - int lightGridSize; - int i; - - w = &s_worldData; - - lightGridSize = w->lightGridBounds[0] * w->lightGridBounds[1] * w->lightGridBounds[2]; - primaryLightGrid = ri.Malloc(lightGridSize * sizeof(*primaryLightGrid)); - - memset(primaryLightGrid, 0, lightGridSize * sizeof(*primaryLightGrid)); - - data = w->lightGridData; - for (i = 0; i < lightGridSize; i++, data += 8) - { - int lat, lng; - vec3_t gridLightDir, gridLightCol; - - // skip samples in wall - if (!(data[0]+data[1]+data[2]+data[3]+data[4]+data[5]) ) - continue; - - gridLightCol[0] = ByteToFloat(data[3]); - gridLightCol[1] = ByteToFloat(data[4]); - gridLightCol[2] = ByteToFloat(data[5]); - (void)gridLightCol; // Suppress unused-but-set-variable warning - - lat = data[7]; - lng = data[6]; - lat *= (FUNCTABLE_SIZE/256); - lng *= (FUNCTABLE_SIZE/256); - - // decode X as cos( lat ) * sin( long ) - // decode Y as sin( lat ) * sin( long ) - // decode Z as cos( long ) - - gridLightDir[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng]; - gridLightDir[1] = tr.sinTable[lat] * tr.sinTable[lng]; - gridLightDir[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK]; - - // FIXME: magic number for determining if light direction is close enough to sunlight - if (DotProduct(gridLightDir, tr.sunDirection) > 0.75f) - { - primaryLightGrid[i] = 1; - } - else - { - primaryLightGrid[i] = 255; - } - } - - if (0) - { - int i; - byte *buffer = ri.Malloc(w->lightGridBounds[0] * w->lightGridBounds[1] * 3 + 18); - byte *out; - uint8_t *in; - char fileName[MAX_QPATH]; - - Com_Memset (buffer, 0, 18); - buffer[2] = 2; // uncompressed type - buffer[12] = w->lightGridBounds[0] & 255; - buffer[13] = w->lightGridBounds[0] >> 8; - buffer[14] = w->lightGridBounds[1] & 255; - buffer[15] = w->lightGridBounds[1] >> 8; - buffer[16] = 24; // pixel size - - in = primaryLightGrid; - for (i = 0; i < w->lightGridBounds[2]; i++) - { - int j; - - sprintf(fileName, "primarylg%d.tga", i); - - out = buffer + 18; - for (j = 0; j < w->lightGridBounds[0] * w->lightGridBounds[1]; j++) - { - if (*in == 1) - { - *out++ = 255; - *out++ = 255; - *out++ = 255; - } - else if (*in == 255) - { - *out++ = 64; - *out++ = 64; - *out++ = 64; - } - else - { - *out++ = 0; - *out++ = 0; - *out++ = 0; - } - in++; - } - - ri.FS_WriteFile(fileName, buffer, w->lightGridBounds[0] * w->lightGridBounds[1] * 3 + 18); - } - - ri.Free(buffer); - } - - for (i = 0; i < w->numWorldSurfaces; i++) - { - msurface_t *surf = w->surfaces + i; - cullinfo_t *ci = &surf->cullinfo; - - if(ci->type & CULLINFO_PLANE) - { - if (DotProduct(ci->plane.normal, tr.sunDirection) <= 0.0f) - { - //ri.Printf(PRINT_ALL, "surface %d is not oriented towards sunlight\n", i); - continue; - } - } - - if(ci->type & CULLINFO_BOX) - { - int ibounds[2][3], x, y, z, goodSamples, numSamples; - vec3_t lightOrigin; - - VectorSubtract( ci->bounds[0], w->lightGridOrigin, lightOrigin ); - - ibounds[0][0] = floor(lightOrigin[0] * w->lightGridInverseSize[0]); - ibounds[0][1] = floor(lightOrigin[1] * w->lightGridInverseSize[1]); - ibounds[0][2] = floor(lightOrigin[2] * w->lightGridInverseSize[2]); - - VectorSubtract( ci->bounds[1], w->lightGridOrigin, lightOrigin ); - - ibounds[1][0] = ceil(lightOrigin[0] * w->lightGridInverseSize[0]); - ibounds[1][1] = ceil(lightOrigin[1] * w->lightGridInverseSize[1]); - ibounds[1][2] = ceil(lightOrigin[2] * w->lightGridInverseSize[2]); - - ibounds[0][0] = CLAMP(ibounds[0][0], 0, w->lightGridSize[0]); - ibounds[0][1] = CLAMP(ibounds[0][1], 0, w->lightGridSize[1]); - ibounds[0][2] = CLAMP(ibounds[0][2], 0, w->lightGridSize[2]); - - ibounds[1][0] = CLAMP(ibounds[1][0], 0, w->lightGridSize[0]); - ibounds[1][1] = CLAMP(ibounds[1][1], 0, w->lightGridSize[1]); - ibounds[1][2] = CLAMP(ibounds[1][2], 0, w->lightGridSize[2]); - - /* - ri.Printf(PRINT_ALL, "surf %d bounds (%f %f %f)-(%f %f %f) ibounds (%d %d %d)-(%d %d %d)\n", i, - ci->bounds[0][0], ci->bounds[0][1], ci->bounds[0][2], - ci->bounds[1][0], ci->bounds[1][1], ci->bounds[1][2], - ibounds[0][0], ibounds[0][1], ibounds[0][2], - ibounds[1][0], ibounds[1][1], ibounds[1][2]); - */ - - goodSamples = 0; - numSamples = 0; - for (x = ibounds[0][0]; x <= ibounds[1][0]; x++) - { - for (y = ibounds[0][1]; y <= ibounds[1][1]; y++) - { - for (z = ibounds[0][2]; z <= ibounds[1][2]; z++) - { - uint8_t primaryLight = primaryLightGrid[x * 8 + y * 8 * w->lightGridBounds[0] + z * 8 * w->lightGridBounds[0] * w->lightGridBounds[2]]; - - if (primaryLight == 0) - continue; - - numSamples++; - - if (primaryLight == 1) - goodSamples++; - } - } - } - - // FIXME: magic number for determining whether object is mostly in sunlight - if (goodSamples > numSamples * 0.75f) - { - //ri.Printf(PRINT_ALL, "surface %d is in sunlight\n", i); - //surf->primaryLight = 1; - } - } - } - - ri.Free(primaryLightGrid); - } - - // load cubemaps - if (r_cubeMapping->integer) - { - // Try loading an env.json file first - R_LoadEnvironmentJson(s_worldData.baseName); - - if (!tr.numCubemaps) - { - R_LoadCubemapEntities("misc_cubemap"); - } - - if (!tr.numCubemaps) - { - // use deathmatch spawn points as cubemaps - R_LoadCubemapEntities("info_player_deathmatch"); - } - - if (tr.numCubemaps) - { - R_AssignCubemapsToWorldSurfaces(); - } - } - - s_worldData.dataSize = (byte *)ri.Hunk_Alloc(0, h_low) - startMarker; - - // only set tr.world now that we know the entire level has loaded properly - tr.world = &s_worldData; - - // make sure the VAO glState entry is safe - R_BindNullVao(); - - // Render or load all cubemaps - if (r_cubeMapping->integer && tr.numCubemaps && glRefConfig.framebufferObject) - { - R_LoadCubemaps(); - R_RenderMissingCubemaps(); - } - - ri.FS_FreeFile( buffer.v ); -} diff --git a/code/renderer2/tr_cmds.c b/code/renderer2/tr_cmds.c deleted file mode 100644 index 0c84fb11cf..0000000000 --- a/code/renderer2/tr_cmds.c +++ /dev/null @@ -1,606 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -#include "tr_local.h" - -/* -===================== -R_PerformanceCounters -===================== -*/ -static void R_PerformanceCounters( void ) { - if ( !r_speeds->integer ) { - // clear the counters even if we aren't printing - Com_Memset( &tr.pc, 0, sizeof( tr.pc ) ); - Com_Memset( &backEnd.pc, 0, sizeof( backEnd.pc ) ); - return; - } - - if (r_speeds->integer == 1) { - ri.Printf (PRINT_ALL, "%i/%i/%i shaders/batches/surfs %i leafs %i verts %i/%i tris %.2f mtex %.2f dc\n", - backEnd.pc.c_shaders, backEnd.pc.c_surfBatches, backEnd.pc.c_surfaces, tr.pc.c_leafs, backEnd.pc.c_vertexes, - backEnd.pc.c_indexes/3, backEnd.pc.c_totalIndexes/3, - R_SumOfUsedImages()/(1000000.0f), backEnd.pc.c_overDraw / (float)(glConfig.vidWidth * glConfig.vidHeight) ); - } else if (r_speeds->integer == 2) { - ri.Printf (PRINT_ALL, "(patch) %i sin %i sclip %i sout %i bin %i bclip %i bout\n", - tr.pc.c_sphere_cull_patch_in, tr.pc.c_sphere_cull_patch_clip, tr.pc.c_sphere_cull_patch_out, - tr.pc.c_box_cull_patch_in, tr.pc.c_box_cull_patch_clip, tr.pc.c_box_cull_patch_out ); - ri.Printf (PRINT_ALL, "(md3) %i sin %i sclip %i sout %i bin %i bclip %i bout\n", - tr.pc.c_sphere_cull_md3_in, tr.pc.c_sphere_cull_md3_clip, tr.pc.c_sphere_cull_md3_out, - tr.pc.c_box_cull_md3_in, tr.pc.c_box_cull_md3_clip, tr.pc.c_box_cull_md3_out ); - } else if (r_speeds->integer == 3) { - ri.Printf (PRINT_ALL, "viewcluster: %i\n", tr.viewCluster ); - } else if (r_speeds->integer == 4) { - if ( backEnd.pc.c_dlightVertexes ) { - ri.Printf (PRINT_ALL, "dlight srf:%i culled:%i verts:%i tris:%i\n", - tr.pc.c_dlightSurfaces, tr.pc.c_dlightSurfacesCulled, - backEnd.pc.c_dlightVertexes, backEnd.pc.c_dlightIndexes / 3 ); - } - } - else if (r_speeds->integer == 5 ) - { - ri.Printf( PRINT_ALL, "zFar: %.0f\n", tr.viewParms.zFar ); - } - else if (r_speeds->integer == 6 ) - { - ri.Printf( PRINT_ALL, "flare adds:%i tests:%i renders:%i\n", - backEnd.pc.c_flareAdds, backEnd.pc.c_flareTests, backEnd.pc.c_flareRenders ); - } - else if (r_speeds->integer == 7 ) - { - ri.Printf( PRINT_ALL, "VAO draws: static %i dynamic %i\n", - backEnd.pc.c_staticVaoDraws, backEnd.pc.c_dynamicVaoDraws); - ri.Printf( PRINT_ALL, "GLSL binds: %i draws: gen %i light %i fog %i dlight %i\n", - backEnd.pc.c_glslShaderBinds, backEnd.pc.c_genericDraws, backEnd.pc.c_lightallDraws, backEnd.pc.c_fogDraws, backEnd.pc.c_dlightDraws); - } - - Com_Memset( &tr.pc, 0, sizeof( tr.pc ) ); - Com_Memset( &backEnd.pc, 0, sizeof( backEnd.pc ) ); -} - - -/* -==================== -R_IssueRenderCommands -==================== -*/ -static void R_IssueRenderCommands( qboolean runPerformanceCounters ) { - renderCommandList_t *cmdList; - - cmdList = &backEndData->commands; - assert(cmdList); - // add an end-of-list command - *(int *)(cmdList->cmds + cmdList->used) = RC_END_OF_LIST; - - // clear it out, in case this is a sync and not a buffer flip - cmdList->used = 0; - - if ( runPerformanceCounters ) { - R_PerformanceCounters(); - } - - // actually start the commands going - if ( !r_skipBackEnd->integer ) { - // let it start on the new batch - RB_ExecuteRenderCommands( cmdList->cmds ); - } -} - - -/* -==================== -R_IssuePendingRenderCommands - -Issue any pending commands and wait for them to complete. -==================== -*/ -void R_IssuePendingRenderCommands( void ) { - if ( !tr.registered ) { - return; - } - R_IssueRenderCommands( qfalse ); -} - -/* -============ -R_GetCommandBufferReserved - -make sure there is enough command space -============ -*/ -static void *R_GetCommandBufferReserved( int bytes, int reservedBytes ) { - renderCommandList_t *cmdList; - - cmdList = &backEndData->commands; - bytes = PAD(bytes, sizeof(void *)); - - // always leave room for the end of list command - if ( cmdList->used + bytes + sizeof( int ) + reservedBytes > MAX_RENDER_COMMANDS ) { - if ( bytes > MAX_RENDER_COMMANDS - sizeof( int ) ) { - ri.Error( ERR_FATAL, "R_GetCommandBuffer: bad size %i", bytes ); - } - // if we run out of room, just start dropping commands - return NULL; - } - - cmdList->used += bytes; - - return cmdList->cmds + cmdList->used - bytes; -} - -/* -============= -R_GetCommandBuffer - -returns NULL if there is not enough space for important commands -============= -*/ -void *R_GetCommandBuffer( int bytes ) { - return R_GetCommandBufferReserved( bytes, PAD( sizeof( swapBuffersCommand_t ), sizeof(void *) ) ); -} - - -/* -============= -R_AddDrawSurfCmd - -============= -*/ -void R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs ) { - drawSurfsCommand_t *cmd; - - cmd = R_GetCommandBuffer( sizeof( *cmd ) ); - if ( !cmd ) { - return; - } - cmd->commandId = RC_DRAW_SURFS; - - cmd->drawSurfs = drawSurfs; - cmd->numDrawSurfs = numDrawSurfs; - - cmd->refdef = tr.refdef; - cmd->viewParms = tr.viewParms; -} - - -/* -============= -R_AddCapShadowmapCmd - -============= -*/ -void R_AddCapShadowmapCmd( int map, int cubeSide ) { - capShadowmapCommand_t *cmd; - - cmd = R_GetCommandBuffer( sizeof( *cmd ) ); - if ( !cmd ) { - return; - } - cmd->commandId = RC_CAPSHADOWMAP; - - cmd->map = map; - cmd->cubeSide = cubeSide; -} - - -/* -============= -R_AddPostProcessCmd - -============= -*/ -void R_AddPostProcessCmd( void ) { - postProcessCommand_t *cmd; - - cmd = R_GetCommandBuffer( sizeof( *cmd ) ); - if ( !cmd ) { - return; - } - cmd->commandId = RC_POSTPROCESS; - - cmd->refdef = tr.refdef; - cmd->viewParms = tr.viewParms; -} - -/* -============= -RE_SetColor - -Passing NULL will set the color to white -============= -*/ -void RE_SetColor( const float *rgba ) { - setColorCommand_t *cmd; - - if ( !tr.registered ) { - return; - } - cmd = R_GetCommandBuffer( sizeof( *cmd ) ); - if ( !cmd ) { - return; - } - cmd->commandId = RC_SET_COLOR; - if ( !rgba ) { - static float colorWhite[4] = { 1, 1, 1, 1 }; - - rgba = colorWhite; - } - - cmd->color[0] = rgba[0]; - cmd->color[1] = rgba[1]; - cmd->color[2] = rgba[2]; - cmd->color[3] = rgba[3]; -} - - -/* -============= -RE_StretchPic -============= -*/ -void RE_StretchPic ( float x, float y, float w, float h, - float s1, float t1, float s2, float t2, qhandle_t hShader ) { - stretchPicCommand_t *cmd; - - if (!tr.registered) { - return; - } - cmd = R_GetCommandBuffer( sizeof( *cmd ) ); - if ( !cmd ) { - return; - } - cmd->commandId = RC_STRETCH_PIC; - cmd->shader = R_GetShaderByHandle( hShader ); - cmd->x = x; - cmd->y = y; - cmd->w = w; - cmd->h = h; - cmd->s1 = s1; - cmd->t1 = t1; - cmd->s2 = s2; - cmd->t2 = t2; -} - -#define MODE_RED_CYAN 1 -#define MODE_RED_BLUE 2 -#define MODE_RED_GREEN 3 -#define MODE_GREEN_MAGENTA 4 -#define MODE_MAX MODE_GREEN_MAGENTA - -static void R_SetColorMode(GLboolean *rgba, stereoFrame_t stereoFrame, int colormode) -{ - rgba[0] = rgba[1] = rgba[2] = rgba[3] = GL_TRUE; - - if(colormode > MODE_MAX) - { - if(stereoFrame == STEREO_LEFT) - stereoFrame = STEREO_RIGHT; - else if(stereoFrame == STEREO_RIGHT) - stereoFrame = STEREO_LEFT; - - colormode -= MODE_MAX; - } - - if(colormode == MODE_GREEN_MAGENTA) - { - if(stereoFrame == STEREO_LEFT) - rgba[0] = rgba[2] = GL_FALSE; - else if(stereoFrame == STEREO_RIGHT) - rgba[1] = GL_FALSE; - } - else - { - if(stereoFrame == STEREO_LEFT) - rgba[1] = rgba[2] = GL_FALSE; - else if(stereoFrame == STEREO_RIGHT) - { - rgba[0] = GL_FALSE; - - if(colormode == MODE_RED_BLUE) - rgba[1] = GL_FALSE; - else if(colormode == MODE_RED_GREEN) - rgba[2] = GL_FALSE; - } - } -} - - -/* -==================== -RE_BeginFrame - -If running in stereo, RE_BeginFrame will be called twice -for each RE_EndFrame -==================== -*/ -void RE_BeginFrame( stereoFrame_t stereoFrame ) { - drawBufferCommand_t *cmd = NULL; - colorMaskCommand_t *colcmd = NULL; - - if ( !tr.registered ) { - return; - } - glState.finishCalled = qfalse; - - tr.frameCount++; - tr.frameSceneNum = 0; - - // - // do overdraw measurement - // - if ( r_measureOverdraw->integer ) - { - if ( glConfig.stencilBits < 4 ) - { - ri.Printf( PRINT_ALL, "Warning: not enough stencil bits to measure overdraw: %d\n", glConfig.stencilBits ); - ri.Cvar_Set( "r_measureOverdraw", "0" ); - r_measureOverdraw->modified = qfalse; - } - else if ( r_shadows->integer == 2 ) - { - ri.Printf( PRINT_ALL, "Warning: stencil shadows and overdraw measurement are mutually exclusive\n" ); - ri.Cvar_Set( "r_measureOverdraw", "0" ); - r_measureOverdraw->modified = qfalse; - } - else - { - R_IssuePendingRenderCommands(); - qglEnable( GL_STENCIL_TEST ); - qglStencilMask( ~0U ); - qglClearStencil( 0U ); - qglStencilFunc( GL_ALWAYS, 0U, ~0U ); - qglStencilOp( GL_KEEP, GL_INCR, GL_INCR ); - } - r_measureOverdraw->modified = qfalse; - } - else - { - // this is only reached if it was on and is now off - if ( r_measureOverdraw->modified ) { - R_IssuePendingRenderCommands(); - qglDisable( GL_STENCIL_TEST ); - } - r_measureOverdraw->modified = qfalse; - } - - // - // texturemode stuff - // - if ( r_textureMode->modified ) { - R_IssuePendingRenderCommands(); - GL_TextureMode( r_textureMode->string ); - r_textureMode->modified = qfalse; - } - - // - // gamma stuff - // - if ( r_gamma->modified ) { - r_gamma->modified = qfalse; - - R_IssuePendingRenderCommands(); - R_SetColorMappings(); - } - - // check for errors - if ( !r_ignoreGLErrors->integer ) - { - int err; - - R_IssuePendingRenderCommands(); - if ((err = qglGetError()) != GL_NO_ERROR) - ri.Error(ERR_FATAL, "RE_BeginFrame() - glGetError() failed (0x%x)!", err); - } - - if (glConfig.stereoEnabled) { - if( !(cmd = R_GetCommandBuffer(sizeof(*cmd))) ) - return; - - cmd->commandId = RC_DRAW_BUFFER; - - if ( stereoFrame == STEREO_LEFT ) { - cmd->buffer = (int)GL_BACK_LEFT; - } else if ( stereoFrame == STEREO_RIGHT ) { - cmd->buffer = (int)GL_BACK_RIGHT; - } else { - ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame ); - } - } - else - { - if(r_anaglyphMode->integer) - { - if(r_anaglyphMode->modified) - { - // clear both, front and backbuffer. - qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - backEnd.colorMask[0] = GL_FALSE; - backEnd.colorMask[1] = GL_FALSE; - backEnd.colorMask[2] = GL_FALSE; - backEnd.colorMask[3] = GL_FALSE; - - if (glRefConfig.framebufferObject) - { - // clear all framebuffers - if (tr.msaaResolveFbo) - { - FBO_Bind(tr.msaaResolveFbo); - qglClear(GL_COLOR_BUFFER_BIT); - } - - if (tr.renderFbo) - { - FBO_Bind(tr.renderFbo); - qglClear(GL_COLOR_BUFFER_BIT); - } - - FBO_Bind(NULL); - } - - qglDrawBuffer(GL_FRONT); - qglClear(GL_COLOR_BUFFER_BIT); - qglDrawBuffer(GL_BACK); - qglClear(GL_COLOR_BUFFER_BIT); - - r_anaglyphMode->modified = qfalse; - } - - if(stereoFrame == STEREO_LEFT) - { - if( !(cmd = R_GetCommandBuffer(sizeof(*cmd))) ) - return; - - if( !(colcmd = R_GetCommandBuffer(sizeof(*colcmd))) ) - return; - } - else if(stereoFrame == STEREO_RIGHT) - { - clearDepthCommand_t *cldcmd; - - if( !(cldcmd = R_GetCommandBuffer(sizeof(*cldcmd))) ) - return; - - cldcmd->commandId = RC_CLEARDEPTH; - - if( !(colcmd = R_GetCommandBuffer(sizeof(*colcmd))) ) - return; - } - else - ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame ); - - R_SetColorMode(colcmd->rgba, stereoFrame, r_anaglyphMode->integer); - colcmd->commandId = RC_COLORMASK; - } - else - { - if(stereoFrame != STEREO_CENTER) - ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is disabled, but stereoFrame was %i", stereoFrame ); - - if( !(cmd = R_GetCommandBuffer(sizeof(*cmd))) ) - return; - } - - if(cmd) - { - cmd->commandId = RC_DRAW_BUFFER; - - if(r_anaglyphMode->modified) - { - qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - backEnd.colorMask[0] = 0; - backEnd.colorMask[1] = 0; - backEnd.colorMask[2] = 0; - backEnd.colorMask[3] = 0; - r_anaglyphMode->modified = qfalse; - } - - if (!Q_stricmp(r_drawBuffer->string, "GL_FRONT")) - cmd->buffer = (int)GL_FRONT; - else - cmd->buffer = (int)GL_BACK; - } - } - - tr.refdef.stereoFrame = stereoFrame; -} - - -/* -============= -RE_EndFrame - -Returns the number of msec spent in the back end -============= -*/ -void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) { - swapBuffersCommand_t *cmd; - - if ( !tr.registered ) { - return; - } - cmd = R_GetCommandBufferReserved( sizeof( *cmd ), 0 ); - if ( !cmd ) { - return; - } - cmd->commandId = RC_SWAP_BUFFERS; - - R_IssueRenderCommands( qtrue ); - - R_InitNextFrame(); - - if ( frontEndMsec ) { - *frontEndMsec = tr.frontEndMsec; - } - tr.frontEndMsec = 0; - if ( backEndMsec ) { - *backEndMsec = backEnd.pc.msec; - } - backEnd.pc.msec = 0; -} - -/* -============= -RE_TakeVideoFrame -============= -*/ -void RE_TakeVideoFrame( int width, int height, - byte *captureBuffer, byte *encodeBuffer, qboolean motionJpeg ) -{ - videoFrameCommand_t *cmd; - - if( !tr.registered ) { - return; - } - - cmd = R_GetCommandBuffer( sizeof( *cmd ) ); - if( !cmd ) { - return; - } - - cmd->commandId = RC_VIDEOFRAME; - - cmd->width = width; - cmd->height = height; - cmd->captureBuffer = captureBuffer; - cmd->encodeBuffer = encodeBuffer; - cmd->motionJpeg = motionJpeg; -} - -void RE_ThrottleBackend( void ) -{ - // -} - -qboolean RE_CanMinimize( void ) -{ - return qfalse; -} - - -const glconfig_t *RE_GetConfig( void ) -{ - return &glConfig; -} - -void RE_VertexLighting( qboolean allowed ) -{ - tr.vertexLightingAllowed = allowed; -} diff --git a/code/renderer2/tr_common.h b/code/renderer2/tr_common.h deleted file mode 100644 index 5e03103173..0000000000 --- a/code/renderer2/tr_common.h +++ /dev/null @@ -1,154 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -#ifndef TR_COMMON_H -#define TR_COMMON_H - -#include "../qcommon/q_shared.h" -#include "../renderercommon/tr_public.h" -#include "qgl.h" -#include - -typedef enum -{ - IMGTYPE_COLORALPHA, // for color, lightmap, diffuse, and specular - IMGTYPE_NORMAL, - IMGTYPE_NORMALHEIGHT, - IMGTYPE_DELUXE, // normals are swizzled, deluxe are not -} imgType_t; - -typedef enum -{ - IMGFLAG_NONE = 0x0000, - IMGFLAG_MIPMAP = 0x0001, - IMGFLAG_PICMIP = 0x0002, - IMGFLAG_CUBEMAP = 0x0004, - IMGFLAG_NO_COMPRESSION = 0x0010, - IMGFLAG_NOLIGHTSCALE = 0x0020, - IMGFLAG_CLAMPTOEDGE = 0x0040, - IMGFLAG_GENNORMALMAP = 0x0080, - IMGFLAG_LIGHTMAP = 0x0100, - IMGFLAG_NOSCALE = 0x0200, - IMGFLAG_CLAMPTOBORDER = 0x0400, -} imgFlags_t; - -typedef struct image_s { - char *imgName; // image path, including extension - struct image_s *next; // for hash search - struct image_s *list; // for listing - int width, height; // source image - int uploadWidth; // after power of two and picmip but not including clamp to MAX_TEXTURE_SIZE - int uploadHeight; - GLuint texnum; // gl texture binding - - int frameUsed; // for texture usage in frame statistics - - GLint internalFormat; - int TMU; // only needed for voodoo2 - - uint32_t index; - - imgType_t type; - imgFlags_t flags; -} image_t; - -// any change in the LIGHTMAP_* defines here MUST be reflected in -// R_FindShader() in tr_bsp.c -#define LIGHTMAP_2D -4 // shader is for 2D rendering -#define LIGHTMAP_BY_VERTEX -3 // pre-lit triangle models -#define LIGHTMAP_WHITEIMAGE -2 -#define LIGHTMAP_NONE -1 - -extern refimport_t ri; -extern glconfig_t glConfig; // outside of TR since it shouldn't be cleared during ref re-init - -// These variables should live inside glConfig but can't because of -// compatibility issues to the original ID vms. If you release a stand-alone -// game and your mod uses tr_types.h from this build you can safely move them -// to the glconfig_t struct. -extern qboolean textureFilterAnisotropic; -extern int maxAnisotropy; -extern int gl_version; -// -// cvars -// -extern cvar_t *r_stencilbits; // number of desired stencil bits -extern cvar_t *r_texturebits; // number of desired texture bits - // 0 = use framebuffer depth - // 16 = use 16-bit textures - // 32 = use 32-bit textures - // all else = error - -extern cvar_t *r_ignorehwgamma; // overrides hardware gamma capabilities -extern cvar_t *r_drawBuffer; - -extern cvar_t *r_allowExtensions; // global enable/disable of OpenGL extensions -extern cvar_t *r_ext_compressed_textures; // these control use of specific extensions -extern cvar_t *r_ext_multitexture; -extern cvar_t *r_ext_compiled_vertex_array; -extern cvar_t *r_ext_texture_env_add; - -extern cvar_t *r_ext_texture_filter_anisotropic; -extern cvar_t *r_ext_max_anisotropy; - -extern cvar_t *r_saveFontData; - -float R_NoiseGet4f( float x, float y, float z, double t ); -void R_NoiseInit( void ); - -image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags ); -image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgType_t type, imgFlags_t flags, GLint internalFormat ); -void R_UploadSubImage( unsigned *data, int x, int y, int width, int height, image_t *image ); - -void R_IssuePendingRenderCommands( void ); -qhandle_t RE_RegisterShaderLightMap( const char *name, int lightmapIndex ); -qhandle_t RE_RegisterShader( const char *name ); -qhandle_t RE_RegisterShaderNoMip( const char *name ); -qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_t *image, qboolean mipRawImage); - -// font stuff -void R_InitFreeType( void ); -void R_DoneFreeType( void ); -void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font); - -/* -============================================================= - -IMAGE LOADERS - -============================================================= -*/ - -void R_LoadBMP( const char *name, byte **pic, int *width, int *height ); -void R_LoadJPG( const char *name, byte **pic, int *width, int *height ); -void R_LoadPCX( const char *name, byte **pic, int *width, int *height ); -void R_LoadPNG( const char *name, byte **pic, int *width, int *height ); -void R_LoadTGA( const char *name, byte **pic, int *width, int *height ); - -/* -==================================================================== - -IMPLEMENTATION SPECIFIC FUNCTIONS - -==================================================================== -*/ - -#endif diff --git a/code/renderer2/tr_curve.c b/code/renderer2/tr_curve.c deleted file mode 100644 index 76786f8792..0000000000 --- a/code/renderer2/tr_curve.c +++ /dev/null @@ -1,739 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ - -#include "tr_local.h" - -/* - -This file does all of the processing necessary to turn a raw grid of points -read from the map file into a srfBspSurface_t ready for rendering. - -The level of detail solution is direction independent, based only on subdivided -distance from the true curve. - -Only a single entry point: - -srfBspSurface_t *R_SubdividePatchToGrid( int width, int height, - srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ) { - -*/ - - -/* -============ -LerpDrawVert -============ -*/ -static void LerpDrawVert( srfVert_t *a, srfVert_t *b, srfVert_t *out ) { - out->xyz[0] = 0.5f * (a->xyz[0] + b->xyz[0]); - out->xyz[1] = 0.5f * (a->xyz[1] + b->xyz[1]); - out->xyz[2] = 0.5f * (a->xyz[2] + b->xyz[2]); - - out->st[0] = 0.5f * (a->st[0] + b->st[0]); - out->st[1] = 0.5f * (a->st[1] + b->st[1]); - - out->lightmap[0] = 0.5f * (a->lightmap[0] + b->lightmap[0]); - out->lightmap[1] = 0.5f * (a->lightmap[1] + b->lightmap[1]); - - out->color[0] = ((int)a->color[0] + (int)b->color[0]) >> 1; - out->color[1] = ((int)a->color[1] + (int)b->color[1]) >> 1; - out->color[2] = ((int)a->color[2] + (int)b->color[2]) >> 1; - out->color[3] = ((int)a->color[3] + (int)b->color[3]) >> 1; -} - -/* -============ -Transpose -============ -*/ -static void Transpose( int width, int height, srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE] ) { - int i, j; - srfVert_t temp; - - if ( width > height ) { - for ( i = 0 ; i < height ; i++ ) { - for ( j = i + 1 ; j < width ; j++ ) { - if ( j < height ) { - // swap the value - temp = ctrl[j][i]; - ctrl[j][i] = ctrl[i][j]; - ctrl[i][j] = temp; - } else { - // just copy - ctrl[j][i] = ctrl[i][j]; - } - } - } - } else { - for ( i = 0 ; i < width ; i++ ) { - for ( j = i + 1 ; j < height ; j++ ) { - if ( j < width ) { - // swap the value - temp = ctrl[i][j]; - ctrl[i][j] = ctrl[j][i]; - ctrl[j][i] = temp; - } else { - // just copy - ctrl[i][j] = ctrl[j][i]; - } - } - } - } - -} - - -/* -================= -MakeMeshNormals - -Handles all the complicated wrapping and degenerate cases -================= -*/ -static void MakeMeshNormals( int width, int height, srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE] ) { - int i, j, k, dist; - vec3_t normal; - vec3_t sum; - int count = 0; - vec3_t base; - vec3_t delta; - int x, y; - srfVert_t *dv; - vec3_t around[8], temp; - qboolean good[8]; - qboolean wrapWidth, wrapHeight; - float len; -static int neighbors[8][2] = { - {0,1}, {1,1}, {1,0}, {1,-1}, {0,-1}, {-1,-1}, {-1,0}, {-1,1} - }; - - wrapWidth = qfalse; - for ( i = 0 ; i < height ; i++ ) { - VectorSubtract( ctrl[i][0].xyz, ctrl[i][width-1].xyz, delta ); - len = VectorLengthSquared( delta ); - if ( len > 1.0 ) { - break; - } - } - if ( i == height ) { - wrapWidth = qtrue; - } - - wrapHeight = qfalse; - for ( i = 0 ; i < width ; i++ ) { - VectorSubtract( ctrl[0][i].xyz, ctrl[height-1][i].xyz, delta ); - len = VectorLengthSquared( delta ); - if ( len > 1.0 ) { - break; - } - } - if ( i == width) { - wrapHeight = qtrue; - } - - - for ( i = 0 ; i < width ; i++ ) { - for ( j = 0 ; j < height ; j++ ) { - count = 0; - dv = &ctrl[j][i]; - VectorCopy( dv->xyz, base ); - for ( k = 0 ; k < 8 ; k++ ) { - VectorClear( around[k] ); - good[k] = qfalse; - - for ( dist = 1 ; dist <= 3 ; dist++ ) { - x = i + neighbors[k][0] * dist; - y = j + neighbors[k][1] * dist; - if ( wrapWidth ) { - if ( x < 0 ) { - x = width - 1 + x; - } else if ( x >= width ) { - x = 1 + x - width; - } - } - if ( wrapHeight ) { - if ( y < 0 ) { - y = height - 1 + y; - } else if ( y >= height ) { - y = 1 + y - height; - } - } - - if ( x < 0 || x >= width || y < 0 || y >= height ) { - break; // edge of patch - } - VectorSubtract( ctrl[y][x].xyz, base, temp ); - if ( VectorNormalize( temp ) < 0.001f ) { - continue; // degenerate edge, get more dist - } else { - good[k] = qtrue; - VectorCopy( temp, around[k] ); - break; // good edge - } - } - } - - VectorClear( sum ); - for ( k = 0 ; k < 8 ; k++ ) { - if ( !good[k] || !good[(k+1)&7] ) { - continue; // didn't get two points - } - CrossProduct( around[(k+1)&7], around[k], normal ); - if ( VectorNormalize( normal ) < 0.001f ) { - continue; - } - VectorAdd( normal, sum, sum ); - count++; - } - //if ( count == 0 ) { - // printf("bad normal\n"); - //} - { - vec3_t fNormal; - VectorNormalize2(sum, fNormal); - R_VaoPackNormal(dv->normal, fNormal); - } - } - } -} - -static void MakeMeshTangentVectors(int width, int height, srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], int numIndexes, - glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3]) -{ - int i, j; - srfVert_t *dv[3]; - static srfVert_t ctrl2[MAX_GRID_SIZE * MAX_GRID_SIZE]; - glIndex_t *tri; - - // FIXME: use more elegant way - for(i = 0; i < width; i++) - { - for(j = 0; j < height; j++) - { - dv[0] = &ctrl2[j * width + i]; - *dv[0] = ctrl[j][i]; - } - } - - for(i = 0, tri = indexes; i < numIndexes; i += 3, tri += 3) - { - dv[0] = &ctrl2[tri[0]]; - dv[1] = &ctrl2[tri[1]]; - dv[2] = &ctrl2[tri[2]]; - - R_CalcTangentVectors(dv); - } - - for(i = 0; i < width; i++) - { - for(j = 0; j < height; j++) - { - dv[0] = &ctrl2[j * width + i]; - dv[1] = &ctrl[j][i]; - - VectorCopy4(dv[0]->tangent, dv[1]->tangent); - } - } -} - - -static int MakeMeshIndexes(int width, int height, glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3]) -{ - int i, j; - int numIndexes; - int w, h; - - h = height - 1; - w = width - 1; - numIndexes = 0; - for(i = 0; i < h; i++) - { - for(j = 0; j < w; j++) - { - int v1, v2, v3, v4; - - // vertex order to be reckognized as tristrips - v1 = i * width + j + 1; - v2 = v1 - 1; - v3 = v2 + width; - v4 = v3 + 1; - - indexes[numIndexes++] = v2; - indexes[numIndexes++] = v3; - indexes[numIndexes++] = v1; - - indexes[numIndexes++] = v1; - indexes[numIndexes++] = v3; - indexes[numIndexes++] = v4; - } - } - - return numIndexes; -} - - -/* -============ -InvertCtrl -============ -*/ -static void InvertCtrl( int width, int height, srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE] ) { - int i, j; - srfVert_t temp; - - for ( i = 0 ; i < height ; i++ ) { - for ( j = 0 ; j < width/2 ; j++ ) { - temp = ctrl[i][j]; - ctrl[i][j] = ctrl[i][width-1-j]; - ctrl[i][width-1-j] = temp; - } - } -} - - -/* -================= -InvertErrorTable -================= -*/ -static void InvertErrorTable( float errorTable[2][MAX_GRID_SIZE], int width, int height ) { - int i; - float copy[2][MAX_GRID_SIZE]; - - Com_Memcpy( copy, errorTable, sizeof( copy ) ); - - for ( i = 0 ; i < width ; i++ ) { - errorTable[1][i] = copy[0][i]; //[width-1-i]; - } - - for ( i = 0 ; i < height ; i++ ) { - errorTable[0][i] = copy[1][height-1-i]; - } - -} - -/* -================== -PutPointsOnCurve -================== -*/ -static void PutPointsOnCurve( srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], - int width, int height ) { - int i, j; - srfVert_t prev, next; - - for ( i = 0 ; i < width ; i++ ) { - for ( j = 1 ; j < height ; j += 2 ) { - LerpDrawVert( &ctrl[j][i], &ctrl[j+1][i], &prev ); - LerpDrawVert( &ctrl[j][i], &ctrl[j-1][i], &next ); - LerpDrawVert( &prev, &next, &ctrl[j][i] ); - } - } - - - for ( j = 0 ; j < height ; j++ ) { - for ( i = 1 ; i < width ; i += 2 ) { - LerpDrawVert( &ctrl[j][i], &ctrl[j][i+1], &prev ); - LerpDrawVert( &ctrl[j][i], &ctrl[j][i-1], &next ); - LerpDrawVert( &prev, &next, &ctrl[j][i] ); - } - } -} - -/* -================= -R_CreateSurfaceGridMesh -================= -*/ -static void R_CreateSurfaceGridMesh(srfBspSurface_t *grid, int width, int height, - srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], float errorTable[2][MAX_GRID_SIZE], - int numIndexes, glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3]) { - int i, j; - srfVert_t *vert; - vec3_t tmpVec; - - // copy the results out to a grid - Com_Memset(grid, 0, sizeof(*grid)); - -#ifdef PATCH_STITCHING - grid->widthLodError = /*ri.Hunk_Alloc*/ ri.Malloc( width * 4 ); - Com_Memcpy( grid->widthLodError, errorTable[0], width * 4 ); - - grid->heightLodError = /*ri.Hunk_Alloc*/ ri.Malloc( height * 4 ); - Com_Memcpy( grid->heightLodError, errorTable[1], height * 4 ); - - grid->numIndexes = numIndexes; - grid->indexes = ri.Malloc(grid->numIndexes * sizeof(glIndex_t)); - Com_Memcpy(grid->indexes, indexes, numIndexes * sizeof(glIndex_t)); - - grid->numVerts = (width * height); - grid->verts = ri.Malloc(grid->numVerts * sizeof(srfVert_t)); -#else - grid->widthLodError = ri.Hunk_Alloc( width * 4 ); - Com_Memcpy( grid->widthLodError, errorTable[0], width * 4 ); - - grid->heightLodError = ri.Hunk_Alloc( height * 4 ); - Com_Memcpy( grid->heightLodError, errorTable[1], height * 4 ); - - grid->numIndexes = numIndexes; - grid->indexes = ri.Hunk_Alloc(grid->numIndexes * sizeof(glIndex_t), h_low); - Com_Memcpy(grid->indexes, indexes, numIndexes * sizeof(glIndex_t)); - - grid->numVerts = (width * height); - grid->verts = ri.Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low); -#endif - - grid->width = width; - grid->height = height; - grid->surfaceType = SF_GRID; - ClearBounds( grid->cullBounds[0], grid->cullBounds[1] ); - for ( i = 0 ; i < width ; i++ ) { - for ( j = 0 ; j < height ; j++ ) { - vert = &grid->verts[j*width+i]; - *vert = ctrl[j][i]; - AddPointToBounds( vert->xyz, grid->cullBounds[0], grid->cullBounds[1] ); - } - } - - // compute local origin and bounds - VectorAdd( grid->cullBounds[0], grid->cullBounds[1], grid->cullOrigin ); - VectorScale( grid->cullOrigin, 0.5f, grid->cullOrigin ); - VectorSubtract( grid->cullBounds[0], grid->cullOrigin, tmpVec ); - grid->cullRadius = VectorLength( tmpVec ); - - VectorCopy( grid->cullOrigin, grid->lodOrigin ); - grid->lodRadius = grid->cullRadius; - // -} - -/* -================= -R_FreeSurfaceGridMesh -================= -*/ -static void R_FreeSurfaceGridMeshData( srfBspSurface_t *grid ) { - ri.Free(grid->widthLodError); - ri.Free(grid->heightLodError); - ri.Free(grid->indexes); - ri.Free(grid->verts); -} - -/* -================= -R_SubdividePatchToGrid -================= -*/ -void R_SubdividePatchToGrid( srfBspSurface_t *grid, int width, int height, - srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ) { - int i, j, k, l; - srfVert_t_cleared( prev ); - srfVert_t_cleared( next ); - srfVert_t_cleared( mid ); - float len, maxLen; - int dir; - int t; - srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE]; - float errorTable[2][MAX_GRID_SIZE]; - int numIndexes; - static glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3]; - int consecutiveComplete; - - for ( i = 0 ; i < width ; i++ ) { - for ( j = 0 ; j < height ; j++ ) { - ctrl[j][i] = points[j*width+i]; - } - } - - for ( dir = 0 ; dir < 2 ; dir++ ) { - - for ( j = 0 ; j < MAX_GRID_SIZE ; j++ ) { - errorTable[dir][j] = 0; - } - - consecutiveComplete = 0; - - // horizontal subdivisions - for ( j = 0 ; ; j = (j + 2) % (width - 1) ) { - // check subdivided midpoints against control points - - // FIXME: also check midpoints of adjacent patches against the control points - // this would basically stitch all patches in the same LOD group together. - - maxLen = 0; - for ( i = 0 ; i < height ; i++ ) { - vec3_t midxyz; - vec3_t midxyz2; - vec3_t dir; - vec3_t projected; - float d; - - // calculate the point on the curve - for ( l = 0 ; l < 3 ; l++ ) { - midxyz[l] = (ctrl[i][j].xyz[l] + ctrl[i][j+1].xyz[l] * 2 - + ctrl[i][j+2].xyz[l] ) * 0.25f; - } - - // see how far off the line it is - // using dist-from-line will not account for internal - // texture warping, but it gives a lot less polygons than - // dist-from-midpoint - VectorSubtract( midxyz, ctrl[i][j].xyz, midxyz ); - VectorSubtract( ctrl[i][j+2].xyz, ctrl[i][j].xyz, dir ); - VectorNormalize( dir ); - - d = DotProduct( midxyz, dir ); - VectorScale( dir, d, projected ); - VectorSubtract( midxyz, projected, midxyz2); - len = VectorLengthSquared( midxyz2 ); // we will do the sqrt later - if ( len > maxLen ) { - maxLen = len; - } - } - - maxLen = sqrt(maxLen); - - // if all the points are on the lines, remove the entire columns - if ( maxLen < 0.1f ) { - errorTable[dir][j+1] = 999; - // if we go over the whole grid twice without adding any columns, stop - if (++consecutiveComplete >= width) - break; - continue; - } - - // see if we want to insert subdivided columns - if ( width + 2 > MAX_GRID_SIZE ) { - errorTable[dir][j+1] = 1.0f/maxLen; - break; // can't subdivide any more - } - - if ( maxLen <= r_subdivisions->value ) { - errorTable[dir][j+1] = 1.0f/maxLen; - // if we go over the whole grid twice without adding any columns, stop - if (++consecutiveComplete >= width) - break; - continue; // didn't need subdivision - } - - errorTable[dir][j+2] = 1.0f/maxLen; - - consecutiveComplete = 0; - - // insert two columns and replace the peak - width += 2; - for ( i = 0 ; i < height ; i++ ) { - LerpDrawVert( &ctrl[i][j], &ctrl[i][j+1], &prev ); - LerpDrawVert( &ctrl[i][j+1], &ctrl[i][j+2], &next ); - LerpDrawVert( &prev, &next, &mid ); - - for ( k = width - 1 ; k > j + 3 ; k-- ) { - ctrl[i][k] = ctrl[i][k-2]; - } - ctrl[i][j + 1] = prev; - ctrl[i][j + 2] = mid; - ctrl[i][j + 3] = next; - } - - // skip the new one, we'll get it on the next pass - j += 2; - } - - Transpose( width, height, ctrl ); - t = width; - width = height; - height = t; - } - - - // put all the approximating points on the curve - PutPointsOnCurve( ctrl, width, height ); - - // cull out any rows or columns that are colinear - for ( i = 1 ; i < width-1 ; i++ ) { - if ( errorTable[0][i] != 999 ) { - continue; - } - for ( j = i+1 ; j < width ; j++ ) { - for ( k = 0 ; k < height ; k++ ) { - ctrl[k][j-1] = ctrl[k][j]; - } - errorTable[0][j-1] = errorTable[0][j]; - } - width--; - } - - for ( i = 1 ; i < height-1 ; i++ ) { - if ( errorTable[1][i] != 999 ) { - continue; - } - for ( j = i+1 ; j < height ; j++ ) { - for ( k = 0 ; k < width ; k++ ) { - ctrl[j-1][k] = ctrl[j][k]; - } - errorTable[1][j-1] = errorTable[1][j]; - } - height--; - } - -#if 1 - // flip for longest tristrips as an optimization - // the results should be visually identical with or - // without this step - if ( height > width ) { - Transpose( width, height, ctrl ); - InvertErrorTable( errorTable, width, height ); - t = width; - width = height; - height = t; - InvertCtrl( width, height, ctrl ); - } -#endif - - // calculate indexes - numIndexes = MakeMeshIndexes(width, height, indexes); - - // calculate normals - MakeMeshNormals( width, height, ctrl ); - MakeMeshTangentVectors(width, height, ctrl, numIndexes, indexes); - - R_CreateSurfaceGridMesh(grid, width, height, ctrl, errorTable, numIndexes, indexes); -} - -/* -=============== -R_GridInsertColumn -=============== -*/ -void R_GridInsertColumn( srfBspSurface_t *grid, int column, int row, vec3_t point, float loderror ) { - int i, j; - int width, height, oldwidth; - srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE]; - float errorTable[2][MAX_GRID_SIZE]; - float lodRadius; - vec3_t lodOrigin; - int numIndexes; - static glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3]; - - oldwidth = 0; - width = grid->width + 1; - if (width > MAX_GRID_SIZE) - return; - height = grid->height; - for (i = 0; i < width; i++) { - if (i == column) { - //insert new column - for (j = 0; j < grid->height; j++) { - LerpDrawVert( &grid->verts[j * grid->width + i-1], &grid->verts[j * grid->width + i], &ctrl[j][i] ); - if (j == row) - VectorCopy(point, ctrl[j][i].xyz); - } - errorTable[0][i] = loderror; - continue; - } - errorTable[0][i] = grid->widthLodError[oldwidth]; - for (j = 0; j < grid->height; j++) { - ctrl[j][i] = grid->verts[j * grid->width + oldwidth]; - } - oldwidth++; - } - for (j = 0; j < grid->height; j++) { - errorTable[1][j] = grid->heightLodError[j]; - } - // put all the approximating points on the curve - //PutPointsOnCurve( ctrl, width, height ); - - // calculate indexes - numIndexes = MakeMeshIndexes(width, height, indexes); - - // calculate normals - MakeMeshNormals( width, height, ctrl ); - MakeMeshTangentVectors(width, height, ctrl, numIndexes, indexes); - - VectorCopy(grid->lodOrigin, lodOrigin); - lodRadius = grid->lodRadius; - // free the old grid - R_FreeSurfaceGridMeshData(grid); - // create a new grid - R_CreateSurfaceGridMesh(grid, width, height, ctrl, errorTable, numIndexes, indexes); - grid->lodRadius = lodRadius; - VectorCopy(lodOrigin, grid->lodOrigin); -} - -/* -=============== -R_GridInsertRow -=============== -*/ -void R_GridInsertRow( srfBspSurface_t *grid, int row, int column, vec3_t point, float loderror ) { - int i, j; - int width, height, oldheight; - srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE]; - float errorTable[2][MAX_GRID_SIZE]; - float lodRadius; - vec3_t lodOrigin; - int numIndexes; - static glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3]; - - oldheight = 0; - width = grid->width; - height = grid->height + 1; - if (height > MAX_GRID_SIZE) - return; - for (i = 0; i < height; i++) { - if (i == row) { - //insert new row - for (j = 0; j < grid->width; j++) { - LerpDrawVert( &grid->verts[(i-1) * grid->width + j], &grid->verts[i * grid->width + j], &ctrl[i][j] ); - if (j == column) - VectorCopy(point, ctrl[i][j].xyz); - } - errorTable[1][i] = loderror; - continue; - } - errorTable[1][i] = grid->heightLodError[oldheight]; - for (j = 0; j < grid->width; j++) { - ctrl[i][j] = grid->verts[oldheight * grid->width + j]; - } - oldheight++; - } - for (j = 0; j < grid->width; j++) { - errorTable[0][j] = grid->widthLodError[j]; - } - // put all the approximating points on the curve - //PutPointsOnCurve( ctrl, width, height ); - - // calculate indexes - numIndexes = MakeMeshIndexes(width, height, indexes); - - // calculate normals - MakeMeshNormals( width, height, ctrl ); - MakeMeshTangentVectors(width, height, ctrl, numIndexes, indexes); - - VectorCopy(grid->lodOrigin, lodOrigin); - lodRadius = grid->lodRadius; - // free the old grid - R_FreeSurfaceGridMeshData(grid); - // create a new grid - R_CreateSurfaceGridMesh(grid, width, height, ctrl, errorTable, numIndexes, indexes); - grid->lodRadius = lodRadius; - VectorCopy(lodOrigin, grid->lodOrigin); -} diff --git a/code/renderer2/tr_dsa.c b/code/renderer2/tr_dsa.c deleted file mode 100644 index 76d0cf4321..0000000000 --- a/code/renderer2/tr_dsa.c +++ /dev/null @@ -1,287 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2016 James Canete - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -=========================================================================== -*/ - -#include "tr_local.h" - -#include "tr_dsa.h" - -static struct -{ - GLuint textures[NUM_TEXTURE_BUNDLES]; - GLenum texunit; - - GLuint program; - - GLuint drawFramebuffer; - GLuint readFramebuffer; - GLuint renderbuffer; -} -glDsaState; - -void GL_BindNullTextures(void) -{ - int i; - - if (glRefConfig.directStateAccess) - { - for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) - { - qglBindMultiTextureEXT(GL_TEXTURE0 + i, GL_TEXTURE_2D, 0); - glDsaState.textures[i] = 0; - } - } - else - { - for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) - { - qglActiveTexture(GL_TEXTURE0 + i); - qglBindTexture(GL_TEXTURE_2D, 0); - glDsaState.textures[i] = 0; - } - - qglActiveTexture(GL_TEXTURE0); - glDsaState.texunit = GL_TEXTURE0; - } -} - -int GL_BindMultiTexture(GLenum texunit, GLenum target, GLuint texture) -{ - GLuint tmu = texunit - GL_TEXTURE0; - - if (glDsaState.textures[tmu] == texture) - return 0; - - if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z) - target = GL_TEXTURE_CUBE_MAP; - - qglBindMultiTextureEXT(texunit, target, texture); - glDsaState.textures[tmu] = texture; - return 1; -} - -GLvoid APIENTRY GLDSA_BindMultiTextureEXT(GLenum texunit, GLenum target, GLuint texture) -{ - if (glDsaState.texunit != texunit) - { - qglActiveTexture(texunit); - glDsaState.texunit = texunit; - } - - qglBindTexture(target, texture); -} - -GLvoid APIENTRY GLDSA_TextureParameterfEXT(GLuint texture, GLenum target, GLenum pname, GLfloat param) -{ - GL_BindMultiTexture(glDsaState.texunit, target, texture); - qglTexParameterf(target, pname, param); -} - -GLvoid APIENTRY GLDSA_TextureParameteriEXT(GLuint texture, GLenum target, GLenum pname, GLint param) -{ - GL_BindMultiTexture(glDsaState.texunit, target, texture); - qglTexParameteri(target, pname, param); -} - -GLvoid APIENTRY GLDSA_TextureImage2DEXT(GLuint texture, GLenum target, GLint level, GLint internalformat, - GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) -{ - GL_BindMultiTexture(glDsaState.texunit, target, texture); - qglTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); -} - -GLvoid APIENTRY GLDSA_TextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) -{ - GL_BindMultiTexture(glDsaState.texunit, target, texture); - qglTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); -} - -GLvoid APIENTRY GLDSA_CopyTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLsizei height) -{ - GL_BindMultiTexture(glDsaState.texunit, target, texture); - qglCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); -} - -GLvoid APIENTRY GLDSA_CompressedTextureImage2DEXT(GLuint texture, GLenum target, GLint level, GLenum internalformat, - GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) -{ - GL_BindMultiTexture(glDsaState.texunit, target, texture); - qglCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); -} - -GLvoid APIENTRY GLDSA_CompressedTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, - GLsizei imageSize, const GLvoid *data) -{ - GL_BindMultiTexture(glDsaState.texunit, target, texture); - qglCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); -} - -GLvoid APIENTRY GLDSA_GenerateTextureMipmapEXT(GLuint texture, GLenum target) -{ - GL_BindMultiTexture(glDsaState.texunit, target, texture); - qglGenerateMipmap(target); -} - -void GL_BindNullProgram(void) -{ - qglUseProgram((unsigned)0); - glDsaState.program = 0; -} - -int GL_UseProgram(GLuint program) -{ - if (glDsaState.program == program) - return 0; - - qglUseProgram(program); - glDsaState.program = program; - return 1; -} - -GLvoid APIENTRY GLDSA_ProgramUniform1iEXT(GLuint program, GLint location, GLint v0) -{ - GL_UseProgram(program); - qglUniform1i(location, v0); -} - -GLvoid APIENTRY GLDSA_ProgramUniform1fEXT(GLuint program, GLint location, GLfloat v0) -{ - GL_UseProgram(program); - qglUniform1f(location, v0); -} - -GLvoid APIENTRY GLDSA_ProgramUniform2fEXT(GLuint program, GLint location, - GLfloat v0, GLfloat v1) -{ - GL_UseProgram(program); - qglUniform2f(location, v0, v1); -} - -GLvoid APIENTRY GLDSA_ProgramUniform3fEXT(GLuint program, GLint location, - GLfloat v0, GLfloat v1, GLfloat v2) -{ - GL_UseProgram(program); - qglUniform3f(location, v0, v1, v2); -} - -GLvoid APIENTRY GLDSA_ProgramUniform4fEXT(GLuint program, GLint location, - GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) -{ - GL_UseProgram(program); - qglUniform4f(location, v0, v1, v2, v3); -} - -GLvoid APIENTRY GLDSA_ProgramUniform1fvEXT(GLuint program, GLint location, - GLsizei count, const GLfloat *value) -{ - GL_UseProgram(program); - qglUniform1fv(location, count, value); -} - -GLvoid APIENTRY GLDSA_ProgramUniformMatrix4fvEXT(GLuint program, GLint location, - GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GL_UseProgram(program); - qglUniformMatrix4fv(location, count, transpose, value); -} - -void GL_BindNullFramebuffers(void) -{ - qglBindFramebuffer(GL_FRAMEBUFFER, 0); - glDsaState.drawFramebuffer = glDsaState.readFramebuffer = 0; - qglBindRenderbuffer(GL_RENDERBUFFER, 0); - glDsaState.renderbuffer = 0; -} - -void GL_BindFramebuffer(GLenum target, GLuint framebuffer) -{ - switch (target) - { - case GL_FRAMEBUFFER: - if (framebuffer != glDsaState.drawFramebuffer || framebuffer != glDsaState.readFramebuffer) - { - qglBindFramebuffer(target, framebuffer); - glDsaState.drawFramebuffer = glDsaState.readFramebuffer = framebuffer; - } - break; - - case GL_DRAW_FRAMEBUFFER: - if (framebuffer != glDsaState.drawFramebuffer) - { - qglBindFramebuffer(target, framebuffer); - glDsaState.drawFramebuffer = framebuffer; - } - break; - - case GL_READ_FRAMEBUFFER: - if (framebuffer != glDsaState.readFramebuffer) - { - qglBindFramebuffer(target, framebuffer); - glDsaState.readFramebuffer = framebuffer; - } - break; - } -} - -void GL_BindRenderbuffer(GLuint renderbuffer) -{ - if (renderbuffer != glDsaState.renderbuffer) - { - qglBindRenderbuffer(GL_RENDERBUFFER, renderbuffer); - glDsaState.renderbuffer = renderbuffer; - } -} - -GLvoid APIENTRY GLDSA_NamedRenderbufferStorageEXT(GLuint renderbuffer, - GLenum internalformat, GLsizei width, GLsizei height) -{ - GL_BindRenderbuffer(renderbuffer); - qglRenderbufferStorage(GL_RENDERBUFFER, internalformat, width, height); -} - -GLvoid APIENTRY GLDSA_NamedRenderbufferStorageMultisampleEXT(GLuint renderbuffer, - GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) -{ - GL_BindRenderbuffer(renderbuffer); - qglRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, internalformat, width, height); -} - -GLenum APIENTRY GLDSA_CheckNamedFramebufferStatusEXT(GLuint framebuffer, GLenum target) -{ - GL_BindFramebuffer(target, framebuffer); - return qglCheckFramebufferStatus(target); -} - -GLvoid APIENTRY GLDSA_NamedFramebufferTexture2DEXT(GLuint framebuffer, - GLenum attachment, GLenum textarget, GLuint texture, GLint level) -{ - GL_BindFramebuffer(GL_FRAMEBUFFER, framebuffer); - qglFramebufferTexture2D(GL_FRAMEBUFFER, attachment, textarget, texture, level); -} - -GLvoid APIENTRY GLDSA_NamedFramebufferRenderbufferEXT(GLuint framebuffer, - GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) -{ - GL_BindFramebuffer(GL_FRAMEBUFFER, framebuffer); - qglFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, renderbuffertarget, renderbuffer); -} diff --git a/code/renderer2/tr_dsa.h b/code/renderer2/tr_dsa.h deleted file mode 100644 index 9248a88341..0000000000 --- a/code/renderer2/tr_dsa.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2016 James Canete - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -=========================================================================== -*/ - -#ifndef __TR_DSA_H__ -#define __TR_DSA_H__ - -#include "qgl.h" - -void GL_BindNullTextures(void); -int GL_BindMultiTexture(GLenum texunit, GLenum target, GLuint texture); - -GLvoid APIENTRY GLDSA_BindMultiTextureEXT(GLenum texunit, GLenum target, GLuint texture); -GLvoid APIENTRY GLDSA_TextureParameterfEXT(GLuint texture, GLenum target, GLenum pname, GLfloat param); -GLvoid APIENTRY GLDSA_TextureParameteriEXT(GLuint texture, GLenum target, GLenum pname, GLint param); -GLvoid APIENTRY GLDSA_TextureImage2DEXT(GLuint texture, GLenum target, GLint level, GLint internalformat, - GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLvoid APIENTRY GLDSA_TextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -GLvoid APIENTRY GLDSA_CopyTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLsizei height); -GLvoid APIENTRY GLDSA_CompressedTextureImage2DEXT(GLuint texture, GLenum target, GLint level, GLenum internalformat, - GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -GLvoid APIENTRY GLDSA_CompressedTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, - GLsizei imageSize, const GLvoid *data); - -GLvoid APIENTRY GLDSA_GenerateTextureMipmapEXT(GLuint texture, GLenum target); - -void GL_BindNullProgram(void); -int GL_UseProgram(GLuint program); - -GLvoid APIENTRY GLDSA_ProgramUniform1iEXT(GLuint program, GLint location, GLint v0); -GLvoid APIENTRY GLDSA_ProgramUniform1fEXT(GLuint program, GLint location, GLfloat v0); -GLvoid APIENTRY GLDSA_ProgramUniform2fEXT(GLuint program, GLint location, - GLfloat v0, GLfloat v1); -GLvoid APIENTRY GLDSA_ProgramUniform3fEXT(GLuint program, GLint location, - GLfloat v0, GLfloat v1, GLfloat v2); -GLvoid APIENTRY GLDSA_ProgramUniform4fEXT(GLuint program, GLint location, - GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLvoid APIENTRY GLDSA_ProgramUniform1fvEXT(GLuint program, GLint location, - GLsizei count, const GLfloat *value); -GLvoid APIENTRY GLDSA_ProgramUniformMatrix4fvEXT(GLuint program, GLint location, - GLsizei count, GLboolean transpose, - const GLfloat *value); - -void GL_BindNullFramebuffers(void); -void GL_BindFramebuffer(GLenum target, GLuint framebuffer); -void GL_BindRenderbuffer(GLuint renderbuffer); - -GLvoid APIENTRY GLDSA_NamedRenderbufferStorageEXT(GLuint renderbuffer, - GLenum internalformat, GLsizei width, GLsizei height); - -GLvoid APIENTRY GLDSA_NamedRenderbufferStorageMultisampleEXT(GLuint renderbuffer, - GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); - -GLenum APIENTRY GLDSA_CheckNamedFramebufferStatusEXT(GLuint framebuffer, GLenum target); -GLvoid APIENTRY GLDSA_NamedFramebufferTexture2DEXT(GLuint framebuffer, - GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLvoid APIENTRY GLDSA_NamedFramebufferRenderbufferEXT(GLuint framebuffer, - GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); - - -#endif diff --git a/code/renderer2/tr_extensions.c b/code/renderer2/tr_extensions.c deleted file mode 100644 index ec4c878fd0..0000000000 --- a/code/renderer2/tr_extensions.c +++ /dev/null @@ -1,326 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2011 James Canete (use.less01@gmail.com) - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_extensions.c - extensions needed by the renderer not in sdl_glimp.c - - -#ifdef _MSC_VER -#pragma warning (disable : 4054 ) -#endif - -#define SDL_GL_GetProcAddress( a ) ri.GL_GetProcAddress( a ) - -#include "tr_local.h" -#include "tr_dsa.h" - -#define GLE(ret, name, ...) name##proc * qgl##name; -QGL_1_1_PROCS; -QGL_DESKTOP_1_1_PROCS; -QGL_1_3_PROCS; -QGL_1_5_PROCS; -QGL_2_0_PROCS; -QGL_3_0_PROCS; -QGL_ARB_framebuffer_object_PROCS; -QGL_ARB_vertex_array_object_PROCS; -QGL_EXT_direct_state_access_PROCS; -#undef GLE - -int qglMajorVersion = 2, qglMinorVersion = 0; -int qglesMajorVersion, qglesMinorVersion; - -/* -** GLimp_HaveExtension -*/ -static char gl_extensions[ 32768 ]; -static qboolean GLimp_HaveExtension( const char *ext ) -{ - const char *ptr = Q_stristr( gl_extensions, ext ); - if (ptr == NULL) - return qfalse; - ptr += strlen(ext); - return ((*ptr == ' ') || (*ptr == '\0')); // verify its complete string. -} - - -void GLimp_InitExtraExtensions( void ) -{ - int len; - char *extension; - const char* result[3] = { "...ignoring %s\n", "...using %s\n", "...%s not found\n" }; - qboolean q_gl_version_at_least_3_0; - qboolean q_gl_version_at_least_3_2; - - // set DSA fallbacks -#define GLE(ret, name, ...) qgl##name = GLDSA_##name; - QGL_EXT_direct_state_access_PROCS; -#undef GLE - - // GL function loader, based on https://gist.github.com/rygorous/16796a0c876cf8a5f542caddb55bce8a -#define GLE(ret, name, ...) qgl##name = (name##proc *) ri.GL_GetProcAddress( "gl" #name ); - - QGL_1_1_PROCS; - QGL_DESKTOP_1_1_PROCS; - - // OpenGL 1.3, was GL_ARB_texture_compression - QGL_1_3_PROCS; - - // OpenGL 1.5, was GL_ARB_vertex_buffer_object and GL_ARB_occlusion_query - QGL_1_5_PROCS; - glRefConfig.occlusionQuery = qtrue; - - // OpenGL 2.0, was GL_ARB_shading_language_100, GL_ARB_vertex_program, GL_ARB_shader_objects, and GL_ARB_vertex_shader - QGL_2_0_PROCS; - - QGL_3_0_PROCS; - - if ( !qglGetString ) { - ri.Error( ERR_FATAL, "glGetString is NULL" ); - } - - // get our config strings - Q_strncpyz( glConfig.vendor_string, (char *)qglGetString (GL_VENDOR), sizeof( glConfig.vendor_string ) ); - Q_strncpyz( glConfig.renderer_string, (char *)qglGetString (GL_RENDERER), sizeof( glConfig.renderer_string ) ); - len = strlen( glConfig.renderer_string ); - if ( len && glConfig.renderer_string[ len - 1 ] == '\n' ) - glConfig.renderer_string[ len - 1 ] = '\0'; - Q_strncpyz( glConfig.version_string, (char *)qglGetString( GL_VERSION ), sizeof( glConfig.version_string ) ); - - Q_strncpyz( gl_extensions, (char *)qglGetString( GL_EXTENSIONS ), sizeof( gl_extensions ) ); - Q_strncpyz( glConfig.extensions_string, gl_extensions, sizeof( glConfig.extensions_string ) ); - - sscanf( glConfig.version_string, "%d.%d", &qglMajorVersion, &qglMinorVersion ); - - // Check OpenGL version - if ( !QGL_VERSION_ATLEAST( 2, 0 ) ) - ri.Error( ERR_FATAL, "OpenGL 2.0 required!" ); - ri.Printf( PRINT_ALL, "...using OpenGL %s\n", glConfig.version_string ); - - if ( !r_ignorehwgamma->integer ) - { - ri.GLimp_InitGamma( &glConfig ); - } - - q_gl_version_at_least_3_0 = QGL_VERSION_ATLEAST( 3, 0 ); - q_gl_version_at_least_3_2 = QGL_VERSION_ATLEAST( 3, 2 ); - - // Check if we need Intel graphics specific fixes. - glRefConfig.intelGraphics = qfalse; - if ( strstr((char *)qglGetString(GL_RENDERER), "Intel") ) - glRefConfig.intelGraphics = qtrue; - - // OpenGL 3.0 - GL_ARB_framebuffer_object - extension = "GL_ARB_framebuffer_object"; - glRefConfig.framebufferObject = qfalse; - glRefConfig.framebufferBlit = qfalse; - glRefConfig.framebufferMultisample = qfalse; - - if (q_gl_version_at_least_3_0 || GLimp_HaveExtension(extension)) - { - glRefConfig.framebufferObject = !!r_ext_framebuffer_object->integer; - glRefConfig.framebufferBlit = qtrue; - glRefConfig.framebufferMultisample = qtrue; - - qglGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &glRefConfig.maxRenderbufferSize); - qglGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &glRefConfig.maxColorAttachments); - - QGL_ARB_framebuffer_object_PROCS; - - ri.Printf(PRINT_ALL, result[glRefConfig.framebufferObject], extension); - } - else - { - ri.Printf(PRINT_ALL, result[2], extension); - } - - // OpenGL 3.0 - GL_ARB_vertex_array_object - extension = "GL_ARB_vertex_array_object"; - glRefConfig.vertexArrayObject = qfalse; - if (q_gl_version_at_least_3_0 || GLimp_HaveExtension(extension)) - { - if (q_gl_version_at_least_3_0) - { - // force VAO, core context requires it - glRefConfig.vertexArrayObject = qtrue; - } - else - { - glRefConfig.vertexArrayObject = !!r_arb_vertex_array_object->integer; - } - - QGL_ARB_vertex_array_object_PROCS; - - ri.Printf(PRINT_ALL, result[glRefConfig.vertexArrayObject], extension); - } - else - { - ri.Printf(PRINT_ALL, result[2], extension); - } - - // OpenGL 3.0 - GL_ARB_texture_float - extension = "GL_ARB_texture_float"; - glRefConfig.textureFloat = qfalse; - if (q_gl_version_at_least_3_0 || GLimp_HaveExtension(extension)) - { - glRefConfig.textureFloat = !!r_ext_texture_float->integer; - - ri.Printf(PRINT_ALL, result[glRefConfig.textureFloat], extension); - } - else - { - ri.Printf(PRINT_ALL, result[2], extension); - } - - // OpenGL 3.2 - GL_ARB_depth_clamp - extension = "GL_ARB_depth_clamp"; - glRefConfig.depthClamp = qfalse; - if (q_gl_version_at_least_3_2 || GLimp_HaveExtension(extension)) - { - glRefConfig.depthClamp = qtrue; - - ri.Printf(PRINT_ALL, result[glRefConfig.depthClamp], extension); - } - else - { - ri.Printf(PRINT_ALL, result[2], extension); - } - - // OpenGL 3.2 - GL_ARB_seamless_cube_map - extension = "GL_ARB_seamless_cube_map"; - glRefConfig.seamlessCubeMap = qfalse; - if (q_gl_version_at_least_3_2 || GLimp_HaveExtension(extension)) - { - glRefConfig.seamlessCubeMap = !!r_arb_seamless_cube_map->integer; - - ri.Printf(PRINT_ALL, result[glRefConfig.seamlessCubeMap], extension); - } - else - { - ri.Printf(PRINT_ALL, result[2], extension); - } - - // Determine GLSL version - if (1) - { - char version[256]; - - Q_strncpyz(version, (char *)qglGetString(GL_SHADING_LANGUAGE_VERSION), sizeof(version)); - - sscanf(version, "%d.%d", &glRefConfig.glslMajorVersion, &glRefConfig.glslMinorVersion); - - ri.Printf(PRINT_ALL, "...using GLSL version %s\n", version); - } - - glRefConfig.memInfo = MI_NONE; - - // GL_NVX_gpu_memory_info - extension = "GL_NVX_gpu_memory_info"; - if( GLimp_HaveExtension( extension ) ) - { - glRefConfig.memInfo = MI_NVX; - - ri.Printf(PRINT_ALL, result[1], extension); - } - else - { - ri.Printf(PRINT_ALL, result[2], extension); - } - - // GL_ATI_meminfo - extension = "GL_ATI_meminfo"; - if( GLimp_HaveExtension( extension ) ) - { - if (glRefConfig.memInfo == MI_NONE) - { - glRefConfig.memInfo = MI_ATI; - - ri.Printf(PRINT_ALL, result[1], extension); - } - else - { - ri.Printf(PRINT_ALL, result[0], extension); - } - } - else - { - ri.Printf(PRINT_ALL, result[2], extension); - } - - glRefConfig.textureCompression = TCR_NONE; - - // GL_ARB_texture_compression_rgtc - extension = "GL_ARB_texture_compression_rgtc"; - if (GLimp_HaveExtension(extension)) - { - qboolean useRgtc = r_ext_compressed_textures->integer >= 1; - - if (useRgtc) - glRefConfig.textureCompression |= TCR_RGTC; - - ri.Printf(PRINT_ALL, result[useRgtc], extension); - } - else - { - ri.Printf(PRINT_ALL, result[2], extension); - } - - glRefConfig.swizzleNormalmap = r_ext_compressed_textures->integer && !(glRefConfig.textureCompression & TCR_RGTC); - - // GL_ARB_texture_compression_bptc - extension = "GL_ARB_texture_compression_bptc"; - if (GLimp_HaveExtension(extension)) - { - qboolean useBptc = r_ext_compressed_textures->integer >= 2; - - if (useBptc) - glRefConfig.textureCompression |= TCR_BPTC; - - ri.Printf(PRINT_ALL, result[useBptc], extension); - } - else - { - ri.Printf(PRINT_ALL, result[2], extension); - } - - // GL_EXT_direct_state_access - extension = "GL_EXT_direct_state_access"; - glRefConfig.directStateAccess = qfalse; - if (GLimp_HaveExtension(extension)) - { - glRefConfig.directStateAccess = !!r_ext_direct_state_access->integer; - - // QGL_*_PROCS becomes several functions, do not remove {} - if (glRefConfig.directStateAccess) - { - QGL_EXT_direct_state_access_PROCS; - } - - ri.Printf(PRINT_ALL, result[glRefConfig.directStateAccess], extension); - } - else - { - ri.Printf(PRINT_ALL, result[2], extension); - } - -#undef GLE -} -#ifdef _MSC_VER -#pragma warning (default : 4054 ) -#endif diff --git a/code/renderer2/tr_extramath.c b/code/renderer2/tr_extramath.c deleted file mode 100644 index a6c2a0db39..0000000000 --- a/code/renderer2/tr_extramath.c +++ /dev/null @@ -1,247 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2010 James Canete (use.less01@gmail.com) - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_extramath.c - extra math needed by the renderer not in qmath.c - -#include "tr_local.h" - -// Some matrix helper functions -// FIXME: do these already exist in ioq3 and I don't know about them? - -void Mat4Zero( mat4_t out ) -{ - out[ 0] = 0.0f; out[ 4] = 0.0f; out[ 8] = 0.0f; out[12] = 0.0f; - out[ 1] = 0.0f; out[ 5] = 0.0f; out[ 9] = 0.0f; out[13] = 0.0f; - out[ 2] = 0.0f; out[ 6] = 0.0f; out[10] = 0.0f; out[14] = 0.0f; - out[ 3] = 0.0f; out[ 7] = 0.0f; out[11] = 0.0f; out[15] = 0.0f; -} - -void Mat4Identity( mat4_t out ) -{ - out[ 0] = 1.0f; out[ 4] = 0.0f; out[ 8] = 0.0f; out[12] = 0.0f; - out[ 1] = 0.0f; out[ 5] = 1.0f; out[ 9] = 0.0f; out[13] = 0.0f; - out[ 2] = 0.0f; out[ 6] = 0.0f; out[10] = 1.0f; out[14] = 0.0f; - out[ 3] = 0.0f; out[ 7] = 0.0f; out[11] = 0.0f; out[15] = 1.0f; -} - -void Mat4Copy( const mat4_t in, mat4_t out ) -{ - out[ 0] = in[ 0]; out[ 4] = in[ 4]; out[ 8] = in[ 8]; out[12] = in[12]; - out[ 1] = in[ 1]; out[ 5] = in[ 5]; out[ 9] = in[ 9]; out[13] = in[13]; - out[ 2] = in[ 2]; out[ 6] = in[ 6]; out[10] = in[10]; out[14] = in[14]; - out[ 3] = in[ 3]; out[ 7] = in[ 7]; out[11] = in[11]; out[15] = in[15]; -} - -void Mat4Multiply( const mat4_t in1, const mat4_t in2, mat4_t out ) -{ - out[ 0] = in1[ 0] * in2[ 0] + in1[ 4] * in2[ 1] + in1[ 8] * in2[ 2] + in1[12] * in2[ 3]; - out[ 1] = in1[ 1] * in2[ 0] + in1[ 5] * in2[ 1] + in1[ 9] * in2[ 2] + in1[13] * in2[ 3]; - out[ 2] = in1[ 2] * in2[ 0] + in1[ 6] * in2[ 1] + in1[10] * in2[ 2] + in1[14] * in2[ 3]; - out[ 3] = in1[ 3] * in2[ 0] + in1[ 7] * in2[ 1] + in1[11] * in2[ 2] + in1[15] * in2[ 3]; - - out[ 4] = in1[ 0] * in2[ 4] + in1[ 4] * in2[ 5] + in1[ 8] * in2[ 6] + in1[12] * in2[ 7]; - out[ 5] = in1[ 1] * in2[ 4] + in1[ 5] * in2[ 5] + in1[ 9] * in2[ 6] + in1[13] * in2[ 7]; - out[ 6] = in1[ 2] * in2[ 4] + in1[ 6] * in2[ 5] + in1[10] * in2[ 6] + in1[14] * in2[ 7]; - out[ 7] = in1[ 3] * in2[ 4] + in1[ 7] * in2[ 5] + in1[11] * in2[ 6] + in1[15] * in2[ 7]; - - out[ 8] = in1[ 0] * in2[ 8] + in1[ 4] * in2[ 9] + in1[ 8] * in2[10] + in1[12] * in2[11]; - out[ 9] = in1[ 1] * in2[ 8] + in1[ 5] * in2[ 9] + in1[ 9] * in2[10] + in1[13] * in2[11]; - out[10] = in1[ 2] * in2[ 8] + in1[ 6] * in2[ 9] + in1[10] * in2[10] + in1[14] * in2[11]; - out[11] = in1[ 3] * in2[ 8] + in1[ 7] * in2[ 9] + in1[11] * in2[10] + in1[15] * in2[11]; - - out[12] = in1[ 0] * in2[12] + in1[ 4] * in2[13] + in1[ 8] * in2[14] + in1[12] * in2[15]; - out[13] = in1[ 1] * in2[12] + in1[ 5] * in2[13] + in1[ 9] * in2[14] + in1[13] * in2[15]; - out[14] = in1[ 2] * in2[12] + in1[ 6] * in2[13] + in1[10] * in2[14] + in1[14] * in2[15]; - out[15] = in1[ 3] * in2[12] + in1[ 7] * in2[13] + in1[11] * in2[14] + in1[15] * in2[15]; -} - -void Mat4Transform( const mat4_t in1, const vec4_t in2, vec4_t out ) -{ - out[ 0] = in1[ 0] * in2[ 0] + in1[ 4] * in2[ 1] + in1[ 8] * in2[ 2] + in1[12] * in2[ 3]; - out[ 1] = in1[ 1] * in2[ 0] + in1[ 5] * in2[ 1] + in1[ 9] * in2[ 2] + in1[13] * in2[ 3]; - out[ 2] = in1[ 2] * in2[ 0] + in1[ 6] * in2[ 1] + in1[10] * in2[ 2] + in1[14] * in2[ 3]; - out[ 3] = in1[ 3] * in2[ 0] + in1[ 7] * in2[ 1] + in1[11] * in2[ 2] + in1[15] * in2[ 3]; -} - -qboolean Mat4Compare( const mat4_t a, const mat4_t b ) -{ - return !(a[ 0] != b[ 0] || a[ 4] != b[ 4] || a[ 8] != b[ 8] || a[12] != b[12] || - a[ 1] != b[ 1] || a[ 5] != b[ 5] || a[ 9] != b[ 9] || a[13] != b[13] || - a[ 2] != b[ 2] || a[ 6] != b[ 6] || a[10] != b[10] || a[14] != b[14] || - a[ 3] != b[ 3] || a[ 7] != b[ 7] || a[11] != b[11] || a[15] != b[15]); -} - -void Mat4Dump( const mat4_t in ) -{ - ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 0], in[ 4], in[ 8], in[12]); - ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 1], in[ 5], in[ 9], in[13]); - ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 2], in[ 6], in[10], in[14]); - ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 3], in[ 7], in[11], in[15]); -} - -void Mat4Translation( vec3_t vec, mat4_t out ) -{ - out[ 0] = 1.0f; out[ 4] = 0.0f; out[ 8] = 0.0f; out[12] = vec[0]; - out[ 1] = 0.0f; out[ 5] = 1.0f; out[ 9] = 0.0f; out[13] = vec[1]; - out[ 2] = 0.0f; out[ 6] = 0.0f; out[10] = 1.0f; out[14] = vec[2]; - out[ 3] = 0.0f; out[ 7] = 0.0f; out[11] = 0.0f; out[15] = 1.0f; -} - -void Mat4Ortho( float left, float right, float bottom, float top, float znear, float zfar, mat4_t out ) -{ - out[ 0] = 2.0f / (right - left); out[ 4] = 0.0f; out[ 8] = 0.0f; out[12] = -(right + left) / (right - left); - out[ 1] = 0.0f; out[ 5] = 2.0f / (top - bottom); out[ 9] = 0.0f; out[13] = -(top + bottom) / (top - bottom); - out[ 2] = 0.0f; out[ 6] = 0.0f; out[10] = 2.0f / (zfar - znear); out[14] = -(zfar + znear) / (zfar - znear); - out[ 3] = 0.0f; out[ 7] = 0.0f; out[11] = 0.0f; out[15] = 1.0f; -} - -void Mat4View(vec3_t axes[3], vec3_t origin, mat4_t out) -{ - out[0] = axes[0][0]; - out[1] = axes[1][0]; - out[2] = axes[2][0]; - out[3] = 0; - - out[4] = axes[0][1]; - out[5] = axes[1][1]; - out[6] = axes[2][1]; - out[7] = 0; - - out[8] = axes[0][2]; - out[9] = axes[1][2]; - out[10] = axes[2][2]; - out[11] = 0; - - out[12] = -DotProduct(origin, axes[0]); - out[13] = -DotProduct(origin, axes[1]); - out[14] = -DotProduct(origin, axes[2]); - out[15] = 1; -} - -void Mat4SimpleInverse( const mat4_t in, mat4_t out) -{ - vec3_t v; - float invSqrLen; - - VectorCopy(in + 0, v); - invSqrLen = 1.0f / DotProduct(v, v); VectorScale(v, invSqrLen, v); - out[ 0] = v[0]; out[ 4] = v[1]; out[ 8] = v[2]; out[12] = -DotProduct(v, &in[12]); - - VectorCopy(in + 4, v); - invSqrLen = 1.0f / DotProduct(v, v); VectorScale(v, invSqrLen, v); - out[ 1] = v[0]; out[ 5] = v[1]; out[ 9] = v[2]; out[13] = -DotProduct(v, &in[12]); - - VectorCopy(in + 8, v); - invSqrLen = 1.0f / DotProduct(v, v); VectorScale(v, invSqrLen, v); - out[ 2] = v[0]; out[ 6] = v[1]; out[10] = v[2]; out[14] = -DotProduct(v, &in[12]); - - out[ 3] = 0.0f; out[ 7] = 0.0f; out[11] = 0.0f; out[15] = 1.0f; -} - -void VectorLerp( vec3_t a, vec3_t b, float lerp, vec3_t c) -{ - c[0] = a[0] * (1.0f - lerp) + b[0] * lerp; - c[1] = a[1] * (1.0f - lerp) + b[1] * lerp; - c[2] = a[2] * (1.0f - lerp) + b[2] * lerp; -} - -qboolean SpheresIntersect(vec3_t origin1, float radius1, vec3_t origin2, float radius2) -{ - float radiusSum = radius1 + radius2; - vec3_t diff; - - VectorSubtract(origin1, origin2, diff); - - if (DotProduct(diff, diff) <= radiusSum * radiusSum) - { - return qtrue; - } - - return qfalse; -} - -void BoundingSphereOfSpheres(vec3_t origin1, float radius1, vec3_t origin2, float radius2, vec3_t origin3, float *radius3) -{ - vec3_t diff; - - VectorScale(origin1, 0.5f, origin3); - VectorMA(origin3, 0.5f, origin2, origin3); - - VectorSubtract(origin1, origin2, diff); - *radius3 = VectorLength(diff) * 0.5f + MAX(radius1, radius2); -} - -int NextPowerOfTwo(int in) -{ - int out; - - for (out = 1; out < in; out <<= 1) - ; - - return out; -} - -union f32_u { - float f; - uint32_t ui; - struct { - unsigned int fraction:23; - unsigned int exponent:8; - unsigned int sign:1; - } pack; -}; - -union f16_u { - uint16_t ui; - struct { - unsigned int fraction:10; - unsigned int exponent:5; - unsigned int sign:1; - } pack; -}; - -uint16_t FloatToHalf(float in) -{ - union f32_u f32; - union f16_u f16; - - f32.f = in; - - f16.pack.exponent = CLAMP((int)(f32.pack.exponent) - 112, 0, 31); - f16.pack.fraction = f32.pack.fraction >> 13; - f16.pack.sign = f32.pack.sign; - - return f16.ui; -} - -float HalfToFloat(uint16_t in) -{ - union f32_u f32; - union f16_u f16; - - f16.ui = in; - - f32.pack.exponent = (int)(f16.pack.exponent) + 112; - f32.pack.fraction = f16.pack.fraction << 13; - f32.pack.sign = f16.pack.sign; - - return f32.f; -} diff --git a/code/renderer2/tr_extramath.h b/code/renderer2/tr_extramath.h deleted file mode 100644 index d9ce170c26..0000000000 --- a/code/renderer2/tr_extramath.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2010 James Canete (use.less01@gmail.com) - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_extramath.h - -#ifndef __TR_EXTRAMATH_H__ -#define __TR_EXTRAMATH_H__ - -typedef vec_t mat4_t[16]; -typedef int ivec2_t[2]; -typedef int ivec3_t[3]; -typedef int ivec4_t[4]; - -void Mat4Zero( mat4_t out ); -void Mat4Identity( mat4_t out ); -void Mat4Copy( const mat4_t in, mat4_t out ); -void Mat4Multiply( const mat4_t in1, const mat4_t in2, mat4_t out ); -void Mat4Transform( const mat4_t in1, const vec4_t in2, vec4_t out ); -qboolean Mat4Compare(const mat4_t a, const mat4_t b); -void Mat4Dump( const mat4_t in ); -void Mat4Translation( vec3_t vec, mat4_t out ); -void Mat4Ortho( float left, float right, float bottom, float top, float znear, float zfar, mat4_t out ); -void Mat4View(vec3_t axes[3], vec3_t origin, mat4_t out); -void Mat4SimpleInverse( const mat4_t in, mat4_t out); - -#define VectorCopy2(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1]) -#define VectorSet2(v,x,y) ((v)[0]=(x),(v)[1]=(y)); - -#define VectorCopy4(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3]) -#define VectorSet4(v,x,y,z,w) ((v)[0]=(x),(v)[1]=(y),(v)[2]=(z),(v)[3]=(w)) -#define DotProduct4(a,b) ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2] + (a)[3]*(b)[3]) -#define VectorScale4(a,b,c) ((c)[0]=(a)[0]*(b),(c)[1]=(a)[1]*(b),(c)[2]=(a)[2]*(b),(c)[3]=(a)[3]*(b)) - -#define VectorCopy5(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3],(b)[4]=(a)[4]) - -#define OffsetByteToFloat(a) ((float)(a) * 1.0f/127.5f - 1.0f) -#define FloatToOffsetByte(a) (byte)((a) * 127.5f + 128.0f) -#define ByteToFloat(a) ((float)(a) * 1.0f/255.0f) -#define FloatToByte(a) (byte)((a) * 255.0f) - -static ID_INLINE int VectorCompare4(const vec4_t v1, const vec4_t v2) -{ - if(v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2] || v1[3] != v2[3]) - { - return 0; - } - return 1; -} - -static ID_INLINE int VectorCompare5(const vec5_t v1, const vec5_t v2) -{ - if(v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2] || v1[3] != v2[3] || v1[4] != v2[4]) - { - return 0; - } - return 1; -} - -void VectorLerp( vec3_t a, vec3_t b, float lerp, vec3_t c); - - -qboolean SpheresIntersect(vec3_t origin1, float radius1, vec3_t origin2, float radius2); -void BoundingSphereOfSpheres(vec3_t origin1, float radius1, vec3_t origin2, float radius2, vec3_t origin3, float *radius3); - -#ifndef SGN -#define SGN(x) (((x) >= 0) ? !!(x) : -1) -#endif - -#ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif - -#ifndef CLAMP -#define CLAMP(a,b,c) MIN(MAX((a),(b)),(c)) -#endif - -int NextPowerOfTwo(int in); -unsigned short FloatToHalf(float in); -float HalfToFloat(unsigned short in); - -#endif diff --git a/code/renderer2/tr_extratypes.h b/code/renderer2/tr_extratypes.h deleted file mode 100644 index 84e39a76ef..0000000000 --- a/code/renderer2/tr_extratypes.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2009-2011 Andrei Drexler, Richard Allen, James Canete - -This file is part of Reaction source code. - -Reaction source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Reaction source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Reaction source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ - -#ifndef __TR_EXTRATYPES_H__ -#define __TR_EXTRATYPES_H__ - -// tr_extratypes.h, for mods that want to extend tr_types.h without losing compatibility with original VMs - -// extra refdef flags start at 0x0008 -#define RDF_NOFOG 0x0008 // don't apply fog to polys added using RE_AddPolyToScene -#define RDF_EXTRA 0x0010 // Makro - refdefex_t to follow after refdef_t -#define RDF_SUNLIGHT 0x0020 // SmileTheory - render sunlight and shadows - -typedef struct { - float blurFactor; - float sunDir[3]; - float sunCol[3]; - float sunAmbCol[3]; -} refdefex_t; - -#endif diff --git a/code/renderer2/tr_fbo.c b/code/renderer2/tr_fbo.c deleted file mode 100644 index cf5d0e75b0..0000000000 --- a/code/renderer2/tr_fbo.c +++ /dev/null @@ -1,662 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2006 Kirk Barnes -Copyright (C) 2006-2008 Robert Beckebans - -This file is part of XreaL source code. - -XreaL source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -XreaL source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with XreaL source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_fbo.c -#include "tr_local.h" - -#include "tr_dsa.h" - -/* -============= -R_CheckFBO -============= -*/ -static qboolean R_CheckFBO(const FBO_t * fbo) -{ - GLenum code = qglCheckNamedFramebufferStatusEXT(fbo->frameBuffer, GL_FRAMEBUFFER); - - if(code == GL_FRAMEBUFFER_COMPLETE) - return qtrue; - - // an error occurred - switch (code) - { - case GL_FRAMEBUFFER_UNSUPPORTED: - ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Unsupported framebuffer format\n", fbo->name); - break; - - case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: - ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete attachment\n", fbo->name); - break; - - case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: - ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing attachment\n", fbo->name); - break; - - case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: - ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing draw buffer\n", fbo->name); - break; - - case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: - ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing read buffer\n", fbo->name); - break; - - case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: - ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete multisample\n", fbo->name); - break; - - default: - ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) unknown error 0x%X\n", fbo->name, code); - break; - } - - return qfalse; -} - -/* -============ -FBO_Create -============ -*/ -static FBO_t *FBO_Create(const char *name, int width, int height) -{ - FBO_t *fbo; - - if(strlen(name) >= MAX_QPATH) - { - ri.Error(ERR_DROP, "FBO_Create: \"%s\" is too long", name); - } - - if(width <= 0 || width > glRefConfig.maxRenderbufferSize) - { - ri.Error(ERR_DROP, "FBO_Create: bad width %i", width); - } - - if(height <= 0 || height > glRefConfig.maxRenderbufferSize) - { - ri.Error(ERR_DROP, "FBO_Create: bad height %i", height); - } - - if(tr.numFBOs == MAX_FBOS) - { - ri.Error(ERR_DROP, "FBO_Create: MAX_FBOS hit"); - } - - fbo = tr.fbos[tr.numFBOs] = ri.Hunk_Alloc(sizeof(*fbo), h_low); - Q_strncpyz(fbo->name, name, sizeof(fbo->name)); - fbo->index = tr.numFBOs++; - fbo->width = width; - fbo->height = height; - - qglGenFramebuffers(1, &fbo->frameBuffer); - - return fbo; -} - -/* -================= -FBO_CreateBuffer -================= -*/ -static void FBO_CreateBuffer(FBO_t *fbo, int format, int index, int multisample) -{ - uint32_t *pRenderBuffer; - GLenum attachment; - qboolean absent; - - switch(format) - { - case GL_RGB: - case GL_RGBA: - case GL_RGB8: - case GL_RGBA8: - case GL_RGB16F_ARB: - case GL_RGBA16F_ARB: - case GL_RGB32F_ARB: - case GL_RGBA32F_ARB: - fbo->colorFormat = format; - pRenderBuffer = &fbo->colorBuffers[index]; - attachment = GL_COLOR_ATTACHMENT0 + index; - break; - - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16_ARB: - case GL_DEPTH_COMPONENT24_ARB: - case GL_DEPTH_COMPONENT32_ARB: - fbo->depthFormat = format; - pRenderBuffer = &fbo->depthBuffer; - attachment = GL_DEPTH_ATTACHMENT; - break; - - case GL_STENCIL_INDEX: - case GL_STENCIL_INDEX1: - case GL_STENCIL_INDEX4: - case GL_STENCIL_INDEX8: - case GL_STENCIL_INDEX16: - fbo->stencilFormat = format; - pRenderBuffer = &fbo->stencilBuffer; - attachment = GL_STENCIL_ATTACHMENT; - break; - - case GL_DEPTH_STENCIL: - case GL_DEPTH24_STENCIL8: - fbo->packedDepthStencilFormat = format; - pRenderBuffer = &fbo->packedDepthStencilBuffer; - attachment = 0; // special for stencil and depth - break; - - default: - ri.Printf(PRINT_WARNING, "FBO_CreateBuffer: invalid format %d\n", format); - return; - } - - absent = *pRenderBuffer == 0; - if (absent) - qglGenRenderbuffers(1, pRenderBuffer); - - if (multisample && glRefConfig.framebufferMultisample) - qglNamedRenderbufferStorageMultisampleEXT(*pRenderBuffer, multisample, format, fbo->width, fbo->height); - else - qglNamedRenderbufferStorageEXT(*pRenderBuffer, format, fbo->width, fbo->height); - - if(absent) - { - if (attachment == 0) - { - qglNamedFramebufferRenderbufferEXT(fbo->frameBuffer, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, *pRenderBuffer); - qglNamedFramebufferRenderbufferEXT(fbo->frameBuffer, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, *pRenderBuffer); - } - else - { - qglNamedFramebufferRenderbufferEXT(fbo->frameBuffer, attachment, GL_RENDERBUFFER, *pRenderBuffer); - } - } -} - - -/* -================= -FBO_AttachImage -================= -*/ -void FBO_AttachImage(FBO_t *fbo, image_t *image, GLenum attachment, GLuint cubemapside) -{ - GLenum target = GL_TEXTURE_2D; - int index; - - if (image->flags & IMGFLAG_CUBEMAP) - target = GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + cubemapside; - - qglNamedFramebufferTexture2DEXT(fbo->frameBuffer, attachment, target, image->texnum, 0); - index = attachment - GL_COLOR_ATTACHMENT0; - if (index >= 0 && index <= 15) - fbo->colorImage[index] = image; -} - - -/* -============ -FBO_Bind -============ -*/ -void FBO_Bind(FBO_t * fbo) -{ - if (!glRefConfig.framebufferObject) - { - ri.Printf(PRINT_WARNING, "FBO_Bind() called without framebuffers enabled!\n"); - return; - } - - if (glState.currentFBO == fbo) - return; - - //if (r_logFile->integer) - //{ - // don't just call LogComment, or we will get a call to va() every frame! - //GLimp_LogComment(va("--- FBO_Bind( %s ) ---\n", fbo ? fbo->name : "NULL")); - //} - - GL_BindFramebuffer(GL_FRAMEBUFFER, fbo ? fbo->frameBuffer : 0); - glState.currentFBO = fbo; -} - -/* -============ -FBO_Init -============ -*/ -void FBO_Init(void) -{ - int i; - int hdrFormat, multisample = 0; - - ri.Printf(PRINT_ALL, "------- FBO_Init -------\n"); - - if(!glRefConfig.framebufferObject) - return; - - tr.numFBOs = 0; - - GL_CheckErrors(); - - R_IssuePendingRenderCommands(); - - hdrFormat = GL_RGBA8; - if (r_hdr->integer && glRefConfig.textureFloat) - hdrFormat = GL_RGBA16F_ARB; - - if (glRefConfig.framebufferMultisample) - qglGetIntegerv(GL_MAX_SAMPLES, &multisample); - - if (r_ext_framebuffer_multisample->integer < multisample) - multisample = r_ext_framebuffer_multisample->integer; - - if (multisample < 2 || !glRefConfig.framebufferBlit) - multisample = 0; - - if (multisample != r_ext_framebuffer_multisample->integer) - ri.Cvar_SetValue("r_ext_framebuffer_multisample", (float)multisample); - - // only create a render FBO if we need to resolve MSAA or do HDR - // otherwise just render straight to the screen (tr.renderFbo = NULL) - if (multisample && glRefConfig.framebufferMultisample) - { - tr.renderFbo = FBO_Create("_render", tr.renderDepthImage->width, tr.renderDepthImage->height); - FBO_CreateBuffer(tr.renderFbo, hdrFormat, 0, multisample); - FBO_CreateBuffer(tr.renderFbo, GL_DEPTH_COMPONENT24, 0, multisample); - R_CheckFBO(tr.renderFbo); - - tr.msaaResolveFbo = FBO_Create("_msaaResolve", tr.renderDepthImage->width, tr.renderDepthImage->height); - FBO_AttachImage(tr.msaaResolveFbo, tr.renderImage, GL_COLOR_ATTACHMENT0, 0); - FBO_AttachImage(tr.msaaResolveFbo, tr.renderDepthImage, GL_DEPTH_ATTACHMENT, 0); - R_CheckFBO(tr.msaaResolveFbo); - } - else if (r_hdr->integer) - { - tr.renderFbo = FBO_Create("_render", tr.renderDepthImage->width, tr.renderDepthImage->height); - FBO_AttachImage(tr.renderFbo, tr.renderImage, GL_COLOR_ATTACHMENT0, 0); - FBO_AttachImage(tr.renderFbo, tr.renderDepthImage, GL_DEPTH_ATTACHMENT, 0); - R_CheckFBO(tr.renderFbo); - } - - // clear render buffer - // this fixes the corrupt screen bug with r_hdr 1 on older hardware - if (tr.renderFbo) - { - GL_BindFramebuffer(GL_FRAMEBUFFER, tr.renderFbo->frameBuffer); - qglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - } - - if (tr.screenScratchImage) - { - tr.screenScratchFbo = FBO_Create("screenScratch", tr.screenScratchImage->width, tr.screenScratchImage->height); - FBO_AttachImage(tr.screenScratchFbo, tr.screenScratchImage, GL_COLOR_ATTACHMENT0, 0); - FBO_AttachImage(tr.screenScratchFbo, tr.renderDepthImage, GL_DEPTH_ATTACHMENT, 0); - R_CheckFBO(tr.screenScratchFbo); - } - - if (tr.sunRaysImage) - { - tr.sunRaysFbo = FBO_Create("_sunRays", tr.renderDepthImage->width, tr.renderDepthImage->height); - FBO_AttachImage(tr.sunRaysFbo, tr.sunRaysImage, GL_COLOR_ATTACHMENT0, 0); - FBO_AttachImage(tr.sunRaysFbo, tr.renderDepthImage, GL_DEPTH_ATTACHMENT, 0); - R_CheckFBO(tr.sunRaysFbo); - } - - if (MAX_DRAWN_PSHADOWS && tr.pshadowMaps[0]) - { - for( i = 0; i < MAX_DRAWN_PSHADOWS; i++) - { - tr.pshadowFbos[i] = FBO_Create(va("_shadowmap%d", i), tr.pshadowMaps[i]->width, tr.pshadowMaps[i]->height); - // FIXME: this next line wastes 16mb with 16x512x512 sun shadow maps, skip if OpenGL 4.3+ or ARB_framebuffer_no_attachments - FBO_CreateBuffer(tr.pshadowFbos[i], GL_RGBA8, 0, 0); - FBO_AttachImage(tr.pshadowFbos[i], tr.pshadowMaps[i], GL_DEPTH_ATTACHMENT, 0); - R_CheckFBO(tr.pshadowFbos[i]); - } - } - - if (tr.sunShadowDepthImage[0]) - { - for (i = 0; i < 4; i++) - { - tr.sunShadowFbo[i] = FBO_Create("_sunshadowmap", tr.sunShadowDepthImage[i]->width, tr.sunShadowDepthImage[i]->height); - // FIXME: this next line wastes 16mb with 4x1024x1024 sun shadow maps, skip if OpenGL 4.3+ or ARB_framebuffer_no_attachments - // This at least gets sun shadows working on older GPUs (Intel) - FBO_CreateBuffer(tr.sunShadowFbo[i], GL_RGBA8, 0, 0); - FBO_AttachImage(tr.sunShadowFbo[i], tr.sunShadowDepthImage[i], GL_DEPTH_ATTACHMENT, 0); - R_CheckFBO(tr.sunShadowFbo[i]); - } - } - - if (tr.screenShadowImage) - { - tr.screenShadowFbo = FBO_Create("_screenshadow", tr.screenShadowImage->width, tr.screenShadowImage->height); - FBO_AttachImage(tr.screenShadowFbo, tr.screenShadowImage, GL_COLOR_ATTACHMENT0, 0); - R_CheckFBO(tr.screenShadowFbo); - } - - if (tr.textureScratchImage[0]) - { - for (i = 0; i < 2; i++) - { - tr.textureScratchFbo[i] = FBO_Create(va("_texturescratch%d", i), tr.textureScratchImage[i]->width, tr.textureScratchImage[i]->height); - FBO_AttachImage(tr.textureScratchFbo[i], tr.textureScratchImage[i], GL_COLOR_ATTACHMENT0, 0); - R_CheckFBO(tr.textureScratchFbo[i]); - } - } - - if (tr.calcLevelsImage) - { - tr.calcLevelsFbo = FBO_Create("_calclevels", tr.calcLevelsImage->width, tr.calcLevelsImage->height); - FBO_AttachImage(tr.calcLevelsFbo, tr.calcLevelsImage, GL_COLOR_ATTACHMENT0, 0); - R_CheckFBO(tr.calcLevelsFbo); - } - - if (tr.targetLevelsImage) - { - tr.targetLevelsFbo = FBO_Create("_targetlevels", tr.targetLevelsImage->width, tr.targetLevelsImage->height); - FBO_AttachImage(tr.targetLevelsFbo, tr.targetLevelsImage, GL_COLOR_ATTACHMENT0, 0); - R_CheckFBO(tr.targetLevelsFbo); - } - - if (tr.quarterImage[0]) - { - for (i = 0; i < 2; i++) - { - tr.quarterFbo[i] = FBO_Create(va("_quarter%d", i), tr.quarterImage[i]->width, tr.quarterImage[i]->height); - FBO_AttachImage(tr.quarterFbo[i], tr.quarterImage[i], GL_COLOR_ATTACHMENT0, 0); - R_CheckFBO(tr.quarterFbo[i]); - } - } - - if (tr.hdrDepthImage) - { - tr.hdrDepthFbo = FBO_Create("_hdrDepth", tr.hdrDepthImage->width, tr.hdrDepthImage->height); - FBO_AttachImage(tr.hdrDepthFbo, tr.hdrDepthImage, GL_COLOR_ATTACHMENT0, 0); - R_CheckFBO(tr.hdrDepthFbo); - } - - if (tr.screenSsaoImage) - { - tr.screenSsaoFbo = FBO_Create("_screenssao", tr.screenSsaoImage->width, tr.screenSsaoImage->height); - FBO_AttachImage(tr.screenSsaoFbo, tr.screenSsaoImage, GL_COLOR_ATTACHMENT0, 0); - R_CheckFBO(tr.screenSsaoFbo); - } - - if (tr.renderCubeImage) - { - tr.renderCubeFbo = FBO_Create("_renderCubeFbo", tr.renderCubeImage->width, tr.renderCubeImage->height); - FBO_AttachImage(tr.renderCubeFbo, tr.renderCubeImage, GL_COLOR_ATTACHMENT0, 0); - FBO_CreateBuffer(tr.renderCubeFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); - R_CheckFBO(tr.renderCubeFbo); - } - - GL_CheckErrors(); - - GL_BindFramebuffer(GL_FRAMEBUFFER, 0); - glState.currentFBO = NULL; -} - -/* -============ -FBO_Shutdown -============ -*/ -void FBO_Shutdown(void) -{ - int i, j; - FBO_t *fbo; - - ri.Printf(PRINT_ALL, "------- FBO_Shutdown -------\n"); - - if(!glRefConfig.framebufferObject) - return; - - FBO_Bind(NULL); - - for(i = 0; i < tr.numFBOs; i++) - { - fbo = tr.fbos[i]; - - for(j = 0; j < glRefConfig.maxColorAttachments; j++) - { - if(fbo->colorBuffers[j]) - qglDeleteRenderbuffers(1, &fbo->colorBuffers[j]); - } - - if(fbo->depthBuffer) - qglDeleteRenderbuffers(1, &fbo->depthBuffer); - - if(fbo->stencilBuffer) - qglDeleteRenderbuffers(1, &fbo->stencilBuffer); - - if(fbo->frameBuffer) - qglDeleteFramebuffers(1, &fbo->frameBuffer); - } -} -#if 0 -/* -============ -R_FBOList_f -============ -*/ -static void R_FBOList_f(void) -{ - int i; - FBO_t *fbo; - - if(!glRefConfig.framebufferObject) - { - ri.Printf(PRINT_ALL, "GL_EXT_framebuffer_object is not available.\n"); - return; - } - - ri.Printf(PRINT_ALL, " size name\n"); - ri.Printf(PRINT_ALL, "----------------------------------------------------------\n"); - - for(i = 0; i < tr.numFBOs; i++) - { - fbo = tr.fbos[i]; - - ri.Printf(PRINT_ALL, " %4i: %4i %4i %s\n", i, fbo->width, fbo->height, fbo->name); - } - - ri.Printf(PRINT_ALL, " %i FBOs\n", tr.numFBOs); -} -#endif -void FBO_BlitFromTexture(struct image_s *src, vec4_t inSrcTexCorners, vec2_t inSrcTexScale, FBO_t *dst, ivec4_t inDstBox, struct shaderProgram_s *shaderProgram, const vec4_t inColor, int blend) -{ - ivec4_t dstBox; - vec4_t color; - vec4_t quadVerts[4]; - vec2_t texCoords[4]; - vec2_t invTexRes; - FBO_t *oldFbo = glState.currentFBO; - mat4_t projection; - int width, height; - - if (!src) - { - ri.Printf(PRINT_WARNING, "Tried to blit from a NULL texture!\n"); - return; - } - - width = dst ? dst->width : glConfig.vidWidth; - height = dst ? dst->height : glConfig.vidHeight; - - if (inSrcTexCorners) - { - VectorSet2(texCoords[0], inSrcTexCorners[0], inSrcTexCorners[1]); - VectorSet2(texCoords[1], inSrcTexCorners[2], inSrcTexCorners[1]); - VectorSet2(texCoords[2], inSrcTexCorners[2], inSrcTexCorners[3]); - VectorSet2(texCoords[3], inSrcTexCorners[0], inSrcTexCorners[3]); - } - else - { - VectorSet2(texCoords[0], 0.0f, 1.0f); - VectorSet2(texCoords[1], 1.0f, 1.0f); - VectorSet2(texCoords[2], 1.0f, 0.0f); - VectorSet2(texCoords[3], 0.0f, 0.0f); - } - - // framebuffers are 0 bottom, Y up. - if (inDstBox) - { - dstBox[0] = inDstBox[0]; - dstBox[1] = height - inDstBox[1] - inDstBox[3]; - dstBox[2] = inDstBox[0] + inDstBox[2]; - dstBox[3] = height - inDstBox[1]; - } - else - { - VectorSet4(dstBox, 0, height, width, 0); - } - - if (inSrcTexScale) - { - VectorCopy2(inSrcTexScale, invTexRes); - } - else - { - VectorSet2(invTexRes, 1.0f, 1.0f); - } - - if (inColor) - { - VectorCopy4(inColor, color); - } - else - { - VectorCopy4(colorWhite, color); - } - - if (!shaderProgram) - { - shaderProgram = &tr.textureColorShader; - } - - FBO_Bind(dst); - - qglViewport( 0, 0, width, height ); - qglScissor( 0, 0, width, height ); - - Mat4Ortho(0, width, height, 0, 0, 1, projection); - - GL_Cull( CT_TWO_SIDED ); - - GL_BindToTMU(src, TB_COLORMAP); - - VectorSet4(quadVerts[0], dstBox[0], dstBox[1], 0.0f, 1.0f); - VectorSet4(quadVerts[1], dstBox[2], dstBox[1], 0.0f, 1.0f); - VectorSet4(quadVerts[2], dstBox[2], dstBox[3], 0.0f, 1.0f); - VectorSet4(quadVerts[3], dstBox[0], dstBox[3], 0.0f, 1.0f); - - invTexRes[0] /= src->width; - invTexRes[1] /= src->height; - - GL_State( blend ); - - GLSL_BindProgram(shaderProgram); - - GLSL_SetUniformMat4(shaderProgram, UNIFORM_MODELVIEWPROJECTIONMATRIX, projection); - GLSL_SetUniformVec4(shaderProgram, UNIFORM_COLOR, color); - GLSL_SetUniformVec2(shaderProgram, UNIFORM_INVTEXRES, invTexRes); - GLSL_SetUniformVec2(shaderProgram, UNIFORM_AUTOEXPOSUREMINMAX, tr.refdef.autoExposureMinMax); - GLSL_SetUniformVec3(shaderProgram, UNIFORM_TONEMINAVGMAXLINEAR, tr.refdef.toneMinAvgMaxLinear); - - RB_InstantQuad2(quadVerts, texCoords); - - FBO_Bind(oldFbo); -} - -void FBO_Blit(FBO_t *src, ivec4_t inSrcBox, vec2_t srcTexScale, FBO_t *dst, ivec4_t dstBox, struct shaderProgram_s *shaderProgram, const vec4_t color, int blend) -{ - vec4_t srcTexCorners; - - if (!src) - { - ri.Printf(PRINT_WARNING, "Tried to blit from a NULL FBO!\n"); - return; - } - - if (inSrcBox) - { - srcTexCorners[0] = inSrcBox[0] / (float)src->width; - srcTexCorners[1] = (inSrcBox[1] + inSrcBox[3]) / (float)src->height; - srcTexCorners[2] = (inSrcBox[0] + inSrcBox[2]) / (float)src->width; - srcTexCorners[3] = inSrcBox[1] / (float)src->height; - } - else - { - VectorSet4(srcTexCorners, 0.0f, 0.0f, 1.0f, 1.0f); - } - - FBO_BlitFromTexture(src->colorImage[0], srcTexCorners, srcTexScale, dst, dstBox, shaderProgram, color, blend | GLS_DEPTHTEST_DISABLE); -} - -void FBO_FastBlit(FBO_t *src, ivec4_t srcBox, FBO_t *dst, ivec4_t dstBox, int buffers, int filter) -{ - ivec4_t srcBoxFinal, dstBoxFinal; - GLuint srcFb, dstFb; - - if (!glRefConfig.framebufferBlit) - { - FBO_Blit(src, srcBox, NULL, dst, dstBox, NULL, NULL, 0); - return; - } - - srcFb = src ? src->frameBuffer : 0; - dstFb = dst ? dst->frameBuffer : 0; - - if (!srcBox) - { - int width = src ? src->width : glConfig.vidWidth; - int height = src ? src->height : glConfig.vidHeight; - - VectorSet4(srcBoxFinal, 0, 0, width, height); - } - else - { - VectorSet4(srcBoxFinal, srcBox[0], srcBox[1], srcBox[0] + srcBox[2], srcBox[1] + srcBox[3]); - } - - if (!dstBox) - { - int width = dst ? dst->width : glConfig.vidWidth; - int height = dst ? dst->height : glConfig.vidHeight; - - VectorSet4(dstBoxFinal, 0, 0, width, height); - } - else - { - VectorSet4(dstBoxFinal, dstBox[0], dstBox[1], dstBox[0] + dstBox[2], dstBox[1] + dstBox[3]); - } - - GL_BindFramebuffer(GL_READ_FRAMEBUFFER, srcFb); - GL_BindFramebuffer(GL_DRAW_FRAMEBUFFER, dstFb); - qglBlitFramebuffer(srcBoxFinal[0], srcBoxFinal[1], srcBoxFinal[2], srcBoxFinal[3], - dstBoxFinal[0], dstBoxFinal[1], dstBoxFinal[2], dstBoxFinal[3], - buffers, filter); - - GL_BindFramebuffer(GL_FRAMEBUFFER, 0); - glState.currentFBO = NULL; -} diff --git a/code/renderer2/tr_fbo.h b/code/renderer2/tr_fbo.h deleted file mode 100644 index e5b3bb8b42..0000000000 --- a/code/renderer2/tr_fbo.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2010 James Canete (use.less01@gmail.com) - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_fbo.h - -#ifndef __TR_FBO_H__ -#define __TR_FBO_H__ - -struct image_s; -struct shaderProgram_s; - -typedef struct FBO_s -{ - char name[MAX_QPATH]; - - int index; - - uint32_t frameBuffer; - - uint32_t colorBuffers[16]; - int colorFormat; - struct image_s *colorImage[16]; - - uint32_t depthBuffer; - int depthFormat; - - uint32_t stencilBuffer; - int stencilFormat; - - uint32_t packedDepthStencilBuffer; - int packedDepthStencilFormat; - - int width; - int height; -} FBO_t; - -void FBO_AttachImage(FBO_t *fbo, image_t *image, GLenum attachment, GLuint cubemapside); -void FBO_Bind(FBO_t *fbo); -void FBO_Init(void); -void FBO_Shutdown(void); - -void FBO_BlitFromTexture(struct image_s *src, vec4_t inSrcTexCorners, vec2_t inSrcTexScale, FBO_t *dst, ivec4_t inDstBox, struct shaderProgram_s *shaderProgram, const vec4_t inColor, int blend); -void FBO_Blit(FBO_t *src, ivec4_t srcBox, vec2_t srcTexScale, FBO_t *dst, ivec4_t dstBox, struct shaderProgram_s *shaderProgram, const vec4_t color, int blend); -void FBO_FastBlit(FBO_t *src, ivec4_t srcBox, FBO_t *dst, ivec4_t dstBox, int buffers, int filter); - - -#endif diff --git a/code/renderer2/tr_flares.c b/code/renderer2/tr_flares.c deleted file mode 100644 index f7a55069d4..0000000000 --- a/code/renderer2/tr_flares.c +++ /dev/null @@ -1,557 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_flares.c - -#include "tr_local.h" - -/* -============================================================================= - -LIGHT FLARES - -A light flare is an effect that takes place inside the eye when bright light -sources are visible. The size of the flare relative to the screen is nearly -constant, irrespective of distance, but the intensity should be proportional to the -projected area of the light source. - -A surface that has been flagged as having a light flare will calculate the depth -buffer value that its midpoint should have when the surface is added. - -After all opaque surfaces have been rendered, the depth buffer is read back for -each flare in view. If the point has not been obscured by a closer surface, the -flare should be drawn. - -Surfaces that have a repeated texture should never be flagged as flaring, because -there will only be a single flare added at the midpoint of the polygon. - -To prevent abrupt popping, the intensity of the flare is interpolated up and -down as it changes visibility. This involves scene to scene state, unlike almost -all other aspects of the renderer, and is complicated by the fact that a single -frame may have multiple scenes. - -RB_RenderFlares() will be called once per view (twice in a mirrored scene, potentially -up to five or more times in a frame with 3D status bar icons). - -============================================================================= -*/ - - -// flare states maintain visibility over multiple frames for fading -// layers: view, mirror, menu -typedef struct flare_s { - struct flare_s *next; // for active chain - - int addedFrame; - - qboolean inPortal; // true if in a portal view of the scene - int frameSceneNum; - void *surface; - int fogNum; - - int fadeTime; - - qboolean visible; // state of last test - float drawIntensity; // may be non 0 even if !visible due to fading - - int windowX, windowY; - float eyeZ; - - vec3_t origin; - vec3_t color; -} flare_t; - -#define MAX_FLARES 128 - -flare_t r_flareStructs[MAX_FLARES]; -flare_t *r_activeFlares, *r_inactiveFlares; - -static float flareCoeff; - -/* -================== -R_SetFlareCoeff -================== -*/ -static void R_SetFlareCoeff( void ) { - - if(r_flareCoeff->value == 0.0f) - flareCoeff = atof(FLARE_STDCOEFF); - else - flareCoeff = r_flareCoeff->value; -} - -/* -================== -R_ClearFlares -================== -*/ -void R_ClearFlares( void ) { - int i; - - Com_Memset( r_flareStructs, 0, sizeof( r_flareStructs ) ); - r_activeFlares = NULL; - r_inactiveFlares = NULL; - - for ( i = 0 ; i < MAX_FLARES ; i++ ) { - r_flareStructs[i].next = r_inactiveFlares; - r_inactiveFlares = &r_flareStructs[i]; - } - - R_SetFlareCoeff(); -} - - -/* -================== -RB_AddFlare - -This is called at surface tesselation time -================== -*/ -void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t normal ) { - int i; - flare_t *f; - vec3_t local; - float d = 1; - vec4_t eye, clip, normalized, window; - - backEnd.pc.c_flareAdds++; - - if(normal && (normal[0] || normal[1] || normal[2])) - { - VectorSubtract( backEnd.viewParms.or.origin, point, local ); - VectorNormalizeFast(local); - d = DotProduct(local, normal); - - // If the viewer is behind the flare don't add it. - if(d < 0) - return; - } - - // if the point is off the screen, don't bother adding it - // calculate screen coordinates and depth - R_TransformModelToClip( point, backEnd.or.modelMatrix, - backEnd.viewParms.projectionMatrix, eye, clip ); - - // check to see if the point is completely off screen - for ( i = 0 ; i < 3 ; i++ ) { - if ( clip[i] >= clip[3] || clip[i] <= -clip[3] ) { - return; - } - } - - R_TransformClipToWindow( clip, &backEnd.viewParms, normalized, window ); - - if ( window[0] < 0 || window[0] >= backEnd.viewParms.viewportWidth - || window[1] < 0 || window[1] >= backEnd.viewParms.viewportHeight ) { - return; // shouldn't happen, since we check the clip[] above, except for FP rounding - } - - // see if a flare with a matching surface, scene, and view exists - for ( f = r_activeFlares ; f ; f = f->next ) { - if ( f->surface == surface && f->frameSceneNum == backEnd.viewParms.frameSceneNum - && f->inPortal == backEnd.viewParms.isPortal ) { - break; - } - } - - // allocate a new one - if (!f ) { - if ( !r_inactiveFlares ) { - // the list is completely full - return; - } - f = r_inactiveFlares; - r_inactiveFlares = r_inactiveFlares->next; - f->next = r_activeFlares; - r_activeFlares = f; - - f->surface = surface; - f->frameSceneNum = backEnd.viewParms.frameSceneNum; - f->inPortal = backEnd.viewParms.isPortal; - f->addedFrame = -1; - } - - if ( f->addedFrame != backEnd.viewParms.frameCount - 1 ) { - f->visible = qfalse; - f->fadeTime = backEnd.refdef.time - 2000; - } - - f->addedFrame = backEnd.viewParms.frameCount; - f->fogNum = fogNum; - - VectorCopy(point, f->origin); - VectorCopy( color, f->color ); - - // fade the intensity of the flare down as the - // light surface turns away from the viewer - VectorScale( f->color, d, f->color ); - - // save info needed to test - f->windowX = backEnd.viewParms.viewportX + window[0]; - f->windowY = backEnd.viewParms.viewportY + window[1]; - - f->eyeZ = eye[2]; -} - -/* -================== -RB_AddDlightFlares -================== -*/ -void RB_AddDlightFlares( void ) { - dlight_t *l; - int i, j, k; - fog_t *fog = NULL; - - if ( !r_flares->integer ) { - return; - } - - l = backEnd.refdef.dlights; - - if(tr.world) - fog = tr.world->fogs; - - for (i=0 ; inumfogs ; j++ ) { - fog = &tr.world->fogs[j]; - for ( k = 0 ; k < 3 ; k++ ) { - if ( l->origin[k] < fog->bounds[0][k] || l->origin[k] > fog->bounds[1][k] ) { - break; - } - } - if ( k == 3 ) { - break; - } - } - if ( j == tr.world->numfogs ) { - j = 0; - } - } - else - j = 0; - - RB_AddFlare( (void *)l, j, l->origin, l->color, NULL ); - } -} - -/* -=============================================================================== - -FLARE BACK END - -=============================================================================== -*/ - -/* -================== -RB_TestFlare -================== -*/ -static void RB_TestFlare( flare_t *f ) { - float depth; - qboolean visible; - float fade; - float screenZ; - FBO_t *oldFbo; - - backEnd.pc.c_flareTests++; - - // doing a readpixels is as good as doing a glFinish(), so - // don't bother with another sync - glState.finishCalled = qfalse; - - // if we're doing multisample rendering, read from the correct FBO - oldFbo = glState.currentFBO; - if (tr.msaaResolveFbo) - { - FBO_Bind(tr.msaaResolveFbo); - } - - // read back the z buffer contents - qglReadPixels( f->windowX, f->windowY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth ); - - // if we're doing multisample rendering, switch to the old FBO - if (tr.msaaResolveFbo) - { - FBO_Bind(oldFbo); - } - - screenZ = backEnd.viewParms.projectionMatrix[14] / - ( ( 2*depth - 1 ) * backEnd.viewParms.projectionMatrix[11] - backEnd.viewParms.projectionMatrix[10] ); - - visible = ( -f->eyeZ - -screenZ ) < 24; - - if ( visible ) { - if ( !f->visible ) { - f->visible = qtrue; - f->fadeTime = backEnd.refdef.time - 1; - } - fade = ( ( backEnd.refdef.time - f->fadeTime ) /1000.0f ) * r_flareFade->value; - } else { - if ( f->visible ) { - f->visible = qfalse; - f->fadeTime = backEnd.refdef.time - 1; - } - fade = 1.0f - ( ( backEnd.refdef.time - f->fadeTime ) / 1000.0f ) * r_flareFade->value; - } - - if ( fade < 0 ) { - fade = 0; - } - if ( fade > 1 ) { - fade = 1; - } - - f->drawIntensity = fade; -} - - -/* -================== -RB_RenderFlare -================== -*/ -static void RB_RenderFlare( flare_t *f ) { - float size; - vec3_t color; - int iColor[3]; - float distance, intensity, factor; - byte fogFactors[3] = {255, 255, 255}; - - backEnd.pc.c_flareRenders++; - - // We don't want too big values anyways when dividing by distance. - if(f->eyeZ > -1.0f) - distance = 1.0f; - else - distance = -f->eyeZ; - - // calculate the flare size.. - size = backEnd.viewParms.viewportWidth * ( r_flareSize->value/640.0f + 8 / distance ); - -/* - * This is an alternative to intensity scaling. It changes the size of the flare on screen instead - * with growing distance. See in the description at the top why this is not the way to go. - // size will change ~ 1/r. - size = backEnd.viewParms.viewportWidth * (r_flareSize->value / (distance * -2.0f)); -*/ - -/* - * As flare sizes stay nearly constant with increasing distance we must decrease the intensity - * to achieve a reasonable visual result. The intensity is ~ (size^2 / distance^2) which can be - * got by considering the ratio of - * (flaresurface on screen) : (Surface of sphere defined by flare origin and distance from flare) - * An important requirement is: - * intensity <= 1 for all distances. - * - * The formula used here to compute the intensity is as follows: - * intensity = flareCoeff * size^2 / (distance + size*sqrt(flareCoeff))^2 - * As you can see, the intensity will have a max. of 1 when the distance is 0. - * The coefficient flareCoeff will determine the falloff speed with increasing distance. - */ - - factor = distance + size * sqrt(flareCoeff); - - intensity = flareCoeff * size * size / (factor * factor); - - VectorScale(f->color, f->drawIntensity * intensity, color); - - // Calculations for fogging - if(tr.world && f->fogNum > 0 && f->fogNum < tr.world->numfogs) - { - tess.numVertexes = 1; - VectorCopy(f->origin, tess.xyz[0]); - tess.fogNum = f->fogNum; - - RB_CalcModulateColorsByFog(fogFactors); - - // We don't need to render the flare if colors are 0 anyways. - if(!(fogFactors[0] || fogFactors[1] || fogFactors[2])) - return; - } - - iColor[0] = color[0] * fogFactors[0] * 257; - iColor[1] = color[1] * fogFactors[1] * 257; - iColor[2] = color[2] * fogFactors[2] * 257; - - RB_BeginSurface( tr.flareShader, f->fogNum, 0 ); - - // FIXME: use quadstamp? - tess.xyz[tess.numVertexes][0] = f->windowX - size; - tess.xyz[tess.numVertexes][1] = f->windowY - size; - tess.texCoords[tess.numVertexes][0] = 0; - tess.texCoords[tess.numVertexes][1] = 0; - tess.color[tess.numVertexes][0] = iColor[0]; - tess.color[tess.numVertexes][1] = iColor[1]; - tess.color[tess.numVertexes][2] = iColor[2]; - tess.color[tess.numVertexes][3] = 65535; - tess.numVertexes++; - - tess.xyz[tess.numVertexes][0] = f->windowX - size; - tess.xyz[tess.numVertexes][1] = f->windowY + size; - tess.texCoords[tess.numVertexes][0] = 0; - tess.texCoords[tess.numVertexes][1] = 1; - tess.color[tess.numVertexes][0] = iColor[0]; - tess.color[tess.numVertexes][1] = iColor[1]; - tess.color[tess.numVertexes][2] = iColor[2]; - tess.color[tess.numVertexes][3] = 65535; - tess.numVertexes++; - - tess.xyz[tess.numVertexes][0] = f->windowX + size; - tess.xyz[tess.numVertexes][1] = f->windowY + size; - tess.texCoords[tess.numVertexes][0] = 1; - tess.texCoords[tess.numVertexes][1] = 1; - tess.color[tess.numVertexes][0] = iColor[0]; - tess.color[tess.numVertexes][1] = iColor[1]; - tess.color[tess.numVertexes][2] = iColor[2]; - tess.color[tess.numVertexes][3] = 65535; - tess.numVertexes++; - - tess.xyz[tess.numVertexes][0] = f->windowX + size; - tess.xyz[tess.numVertexes][1] = f->windowY - size; - tess.texCoords[tess.numVertexes][0] = 1; - tess.texCoords[tess.numVertexes][1] = 0; - tess.color[tess.numVertexes][0] = iColor[0]; - tess.color[tess.numVertexes][1] = iColor[1]; - tess.color[tess.numVertexes][2] = iColor[2]; - tess.color[tess.numVertexes][3] = 65535; - tess.numVertexes++; - - tess.indexes[tess.numIndexes++] = 0; - tess.indexes[tess.numIndexes++] = 1; - tess.indexes[tess.numIndexes++] = 2; - tess.indexes[tess.numIndexes++] = 0; - tess.indexes[tess.numIndexes++] = 2; - tess.indexes[tess.numIndexes++] = 3; - - RB_EndSurface(); -} - -/* -================== -RB_RenderFlares - -Because flares are simulating an occular effect, they should be drawn after -everything (all views) in the entire frame has been drawn. - -Because of the way portals use the depth buffer to mark off areas, the -needed information would be lost after each view, so we are forced to draw -flares after each view. - -The resulting artifact is that flares in mirrors or portals don't dim properly -when occluded by something in the main view, and portal flares that should -extend past the portal edge will be overwritten. -================== -*/ -void RB_RenderFlares (void) { - flare_t *f; - flare_t **prev; - qboolean draw; - mat4_t oldmodelview, oldprojection, matrix; - - if ( !r_flares->integer ) { - return; - } - - if ( backEnd.isHyperspace ) { - return; - } - - if(r_flareCoeff->modified) - { - R_SetFlareCoeff(); - r_flareCoeff->modified = qfalse; - } - - // Reset currentEntity to world so that any previously referenced entities - // don't have influence on the rendering of these flares (i.e. RF_ renderer flags). - backEnd.currentEntity = &tr.worldEntity; - backEnd.or = backEnd.viewParms.world; - -// RB_AddDlightFlares(); - - // perform z buffer readback on each flare in this view - draw = qfalse; - prev = &r_activeFlares; - while ( ( f = *prev ) != NULL ) { - // throw out any flares that weren't added last frame - if ( f->addedFrame < backEnd.viewParms.frameCount - 1 ) { - *prev = f->next; - f->next = r_inactiveFlares; - r_inactiveFlares = f; - continue; - } - - // don't draw any here that aren't from this scene / portal - f->drawIntensity = 0; - if ( f->frameSceneNum == backEnd.viewParms.frameSceneNum - && f->inPortal == backEnd.viewParms.isPortal ) { - RB_TestFlare( f ); - if ( f->drawIntensity ) { - draw = qtrue; - } else { - // this flare has completely faded out, so remove it from the chain - *prev = f->next; - f->next = r_inactiveFlares; - r_inactiveFlares = f; - continue; - } - } - - prev = &f->next; - } - - if ( !draw ) { - return; // none visible - } - - Mat4Copy(glState.projection, oldprojection); - Mat4Copy(glState.modelview, oldmodelview); - Mat4Identity(matrix); - GL_SetModelviewMatrix(matrix); - Mat4Ortho( backEnd.viewParms.viewportX, backEnd.viewParms.viewportX + backEnd.viewParms.viewportWidth, - backEnd.viewParms.viewportY, backEnd.viewParms.viewportY + backEnd.viewParms.viewportHeight, - -99999, 99999, matrix ); - GL_SetProjectionMatrix(matrix); - - for ( f = r_activeFlares ; f ; f = f->next ) { - if ( f->frameSceneNum == backEnd.viewParms.frameSceneNum - && f->inPortal == backEnd.viewParms.isPortal - && f->drawIntensity ) { - RB_RenderFlare( f ); - } - } - - GL_SetProjectionMatrix(oldprojection); - GL_SetModelviewMatrix(oldmodelview); -} - - - - - diff --git a/code/renderer2/tr_glsl.c b/code/renderer2/tr_glsl.c deleted file mode 100644 index 182fde7f4e..0000000000 --- a/code/renderer2/tr_glsl.c +++ /dev/null @@ -1,1561 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2006-2009 Robert Beckebans - -This file is part of XreaL source code. - -XreaL source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -XreaL source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with XreaL source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_glsl.c -#include "tr_local.h" - -#include "tr_dsa.h" - -extern const char *fallbackShader_bokeh_vp; -extern const char *fallbackShader_bokeh_fp; -extern const char *fallbackShader_calclevels4x_vp; -extern const char *fallbackShader_calclevels4x_fp; -extern const char *fallbackShader_depthblur_vp; -extern const char *fallbackShader_depthblur_fp; -extern const char *fallbackShader_dlight_vp; -extern const char *fallbackShader_dlight_fp; -extern const char *fallbackShader_down4x_vp; -extern const char *fallbackShader_down4x_fp; -extern const char *fallbackShader_fogpass_vp; -extern const char *fallbackShader_fogpass_fp; -extern const char *fallbackShader_generic_vp; -extern const char *fallbackShader_generic_fp; -extern const char *fallbackShader_lightall_vp; -extern const char *fallbackShader_lightall_fp; -extern const char *fallbackShader_pshadow_vp; -extern const char *fallbackShader_pshadow_fp; -extern const char *fallbackShader_shadowfill_vp; -extern const char *fallbackShader_shadowfill_fp; -extern const char *fallbackShader_shadowmask_vp; -extern const char *fallbackShader_shadowmask_fp; -extern const char *fallbackShader_ssao_vp; -extern const char *fallbackShader_ssao_fp; -extern const char *fallbackShader_texturecolor_vp; -extern const char *fallbackShader_texturecolor_fp; -extern const char *fallbackShader_tonemap_vp; -extern const char *fallbackShader_tonemap_fp; - -typedef struct uniformInfo_s -{ - char *name; - int type; -} -uniformInfo_t; - -// These must be in the same order as in uniform_t in tr_local.h. -static uniformInfo_t uniformsInfo[] = -{ - { "u_DiffuseMap", GLSL_INT }, - { "u_LightMap", GLSL_INT }, - { "u_NormalMap", GLSL_INT }, - { "u_DeluxeMap", GLSL_INT }, - { "u_SpecularMap", GLSL_INT }, - - { "u_TextureMap", GLSL_INT }, - { "u_LevelsMap", GLSL_INT }, - { "u_CubeMap", GLSL_INT }, - - { "u_ScreenImageMap", GLSL_INT }, - { "u_ScreenDepthMap", GLSL_INT }, - - { "u_ShadowMap", GLSL_INT }, - { "u_ShadowMap2", GLSL_INT }, - { "u_ShadowMap3", GLSL_INT }, - { "u_ShadowMap4", GLSL_INT }, - - { "u_ShadowMvp", GLSL_MAT16 }, - { "u_ShadowMvp2", GLSL_MAT16 }, - { "u_ShadowMvp3", GLSL_MAT16 }, - { "u_ShadowMvp4", GLSL_MAT16 }, - - { "u_EnableTextures", GLSL_VEC4 }, - - { "u_DiffuseTexMatrix", GLSL_VEC4 }, - { "u_DiffuseTexOffTurb", GLSL_VEC4 }, - - { "u_TCGen0", GLSL_INT }, - { "u_TCGen0Vector0", GLSL_VEC3 }, - { "u_TCGen0Vector1", GLSL_VEC3 }, - - { "u_DeformGen", GLSL_INT }, - { "u_DeformParams", GLSL_FLOAT5 }, - - { "u_ColorGen", GLSL_INT }, - { "u_AlphaGen", GLSL_INT }, - { "u_Color", GLSL_VEC4 }, - { "u_BaseColor", GLSL_VEC4 }, - { "u_VertColor", GLSL_VEC4 }, - - { "u_DlightInfo", GLSL_VEC4 }, - { "u_LightForward", GLSL_VEC3 }, - { "u_LightUp", GLSL_VEC3 }, - { "u_LightRight", GLSL_VEC3 }, - { "u_LightOrigin", GLSL_VEC4 }, - { "u_ModelLightDir", GLSL_VEC3 }, - { "u_LightRadius", GLSL_FLOAT }, - { "u_AmbientLight", GLSL_VEC3 }, - { "u_DirectedLight", GLSL_VEC3 }, - - { "u_PortalRange", GLSL_FLOAT }, - - { "u_FogDistance", GLSL_VEC4 }, - { "u_FogDepth", GLSL_VEC4 }, - { "u_FogEyeT", GLSL_FLOAT }, - { "u_FogColorMask", GLSL_VEC4 }, - - { "u_ModelMatrix", GLSL_MAT16 }, - { "u_ModelViewProjectionMatrix", GLSL_MAT16 }, - - { "u_Time", GLSL_FLOAT }, - { "u_VertexLerp" , GLSL_FLOAT }, - { "u_NormalScale", GLSL_VEC4 }, - { "u_SpecularScale", GLSL_VEC4 }, - - { "u_ViewInfo", GLSL_VEC4 }, - { "u_ViewOrigin", GLSL_VEC3 }, - { "u_LocalViewOrigin", GLSL_VEC3 }, - { "u_ViewForward", GLSL_VEC3 }, - { "u_ViewLeft", GLSL_VEC3 }, - { "u_ViewUp", GLSL_VEC3 }, - - { "u_InvTexRes", GLSL_VEC2 }, - { "u_AutoExposureMinMax", GLSL_VEC2 }, - { "u_ToneMinAvgMaxLinear", GLSL_VEC3 }, - - { "u_PrimaryLightOrigin", GLSL_VEC4 }, - { "u_PrimaryLightColor", GLSL_VEC3 }, - { "u_PrimaryLightAmbient", GLSL_VEC3 }, - { "u_PrimaryLightRadius", GLSL_FLOAT }, - - { "u_CubeMapInfo", GLSL_VEC4 }, - - { "u_AlphaTest", GLSL_INT }, - - { "u_BoneMatrix", GLSL_MAT16_BONEMATRIX }, -}; - -typedef enum -{ - GLSL_PRINTLOG_PROGRAM_INFO, - GLSL_PRINTLOG_SHADER_INFO, - GLSL_PRINTLOG_SHADER_SOURCE -} -glslPrintLog_t; - -static void GLSL_PrintLog(GLuint programOrShader, glslPrintLog_t type, qboolean developerOnly) -{ - char *msg; - static char msgPart[1024]; - int maxLength = 0; - int i; - int printLevel = developerOnly ? PRINT_DEVELOPER : PRINT_ALL; - - switch (type) - { - case GLSL_PRINTLOG_PROGRAM_INFO: - ri.Printf(printLevel, "Program info log:\n"); - qglGetProgramiv(programOrShader, GL_INFO_LOG_LENGTH, &maxLength); - break; - - case GLSL_PRINTLOG_SHADER_INFO: - ri.Printf(printLevel, "Shader info log:\n"); - qglGetShaderiv(programOrShader, GL_INFO_LOG_LENGTH, &maxLength); - break; - - case GLSL_PRINTLOG_SHADER_SOURCE: - ri.Printf(printLevel, "Shader source:\n"); - qglGetShaderiv(programOrShader, GL_SHADER_SOURCE_LENGTH, &maxLength); - break; - } - - if (maxLength <= 0) - { - ri.Printf(printLevel, "None.\n"); - return; - } - - if (maxLength < 1023) - msg = msgPart; - else - msg = ri.Malloc(maxLength); - - switch (type) - { - case GLSL_PRINTLOG_PROGRAM_INFO: - qglGetProgramInfoLog(programOrShader, maxLength, &maxLength, msg); - break; - - case GLSL_PRINTLOG_SHADER_INFO: - qglGetShaderInfoLog(programOrShader, maxLength, &maxLength, msg); - break; - - case GLSL_PRINTLOG_SHADER_SOURCE: - qglGetShaderSource(programOrShader, maxLength, &maxLength, msg); - break; - } - - if (maxLength < 1023) - { - msgPart[maxLength + 1] = '\0'; - - ri.Printf(printLevel, "%s\n", msgPart); - } - else - { - for(i = 0; i < maxLength; i += 1023) - { - Q_strncpyz(msgPart, msg + i, sizeof(msgPart)); - - ri.Printf(printLevel, "%s", msgPart); - } - - ri.Printf(printLevel, "\n"); - - ri.Free(msg); - } - -} - -static void GLSL_GetShaderHeader( GLenum shaderType, const GLchar *extra, char *dest, int size ) -{ - float fbufWidthScale, fbufHeightScale; - - dest[0] = '\0'; - - // HACK: abuse the GLSL preprocessor to turn GLSL 1.20 shaders into 1.30 ones - if(glRefConfig.glslMajorVersion > 1 || (glRefConfig.glslMajorVersion == 1 && glRefConfig.glslMinorVersion >= 30)) - { - if (glRefConfig.glslMajorVersion > 1 || (glRefConfig.glslMajorVersion == 1 && glRefConfig.glslMinorVersion >= 50)) - Q_strcat(dest, size, "#version 150\n"); - else - Q_strcat(dest, size, "#version 130\n"); - - if(shaderType == GL_VERTEX_SHADER) - { - Q_strcat(dest, size, "#define attribute in\n"); - Q_strcat(dest, size, "#define varying out\n"); - } - else - { - Q_strcat(dest, size, "#define varying in\n"); - - Q_strcat(dest, size, "out vec4 out_Color;\n"); - Q_strcat(dest, size, "#define gl_FragColor out_Color\n"); - Q_strcat(dest, size, "#define texture2D texture\n"); - Q_strcat(dest, size, "#define textureCubeLod textureLod\n"); - Q_strcat(dest, size, "#define shadow2D texture\n"); - } - } - else - { - Q_strcat(dest, size, "#version 120\n"); - Q_strcat(dest, size, "#define shadow2D(a,b) shadow2D(a,b).r \n"); - } - - // HACK: add some macros to avoid extra uniforms and save speed and code maintenance - //Q_strcat(dest, size, - // va("#ifndef r_SpecularExponent\n#define r_SpecularExponent %f\n#endif\n", r_specularExponent->value)); - //Q_strcat(dest, size, - // va("#ifndef r_SpecularScale\n#define r_SpecularScale %f\n#endif\n", r_specularScale->value)); - //Q_strcat(dest, size, - // va("#ifndef r_NormalScale\n#define r_NormalScale %f\n#endif\n", r_normalScale->value)); - - - Q_strcat(dest, size, "#ifndef M_PI\n#define M_PI 3.14159265358979323846\n#endif\n"); - - //Q_strcat(dest, size, va("#ifndef MAX_SHADOWMAPS\n#define MAX_SHADOWMAPS %i\n#endif\n", MAX_SHADOWMAPS)); - - Q_strcat(dest, size, - va("#ifndef deformGen_t\n" - "#define deformGen_t\n" - "#define DGEN_WAVE_SIN %i\n" - "#define DGEN_WAVE_SQUARE %i\n" - "#define DGEN_WAVE_TRIANGLE %i\n" - "#define DGEN_WAVE_SAWTOOTH %i\n" - "#define DGEN_WAVE_INVERSE_SAWTOOTH %i\n" - "#define DGEN_BULGE %i\n" - "#define DGEN_MOVE %i\n" - "#endif\n", - DGEN_WAVE_SIN, - DGEN_WAVE_SQUARE, - DGEN_WAVE_TRIANGLE, - DGEN_WAVE_SAWTOOTH, - DGEN_WAVE_INVERSE_SAWTOOTH, - DGEN_BULGE, - DGEN_MOVE)); - - Q_strcat(dest, size, - va("#ifndef tcGen_t\n" - "#define tcGen_t\n" - "#define TCGEN_LIGHTMAP %i\n" - "#define TCGEN_TEXTURE %i\n" - "#define TCGEN_ENVIRONMENT_MAPPED %i\n" - "#define TCGEN_FOG %i\n" - "#define TCGEN_VECTOR %i\n" - "#endif\n", - TCGEN_LIGHTMAP, - TCGEN_TEXTURE, - TCGEN_ENVIRONMENT_MAPPED, - TCGEN_FOG, - TCGEN_VECTOR)); - - Q_strcat(dest, size, - va("#ifndef colorGen_t\n" - "#define colorGen_t\n" - "#define CGEN_LIGHTING_DIFFUSE %i\n" - "#endif\n", - CGEN_LIGHTING_DIFFUSE)); - - Q_strcat(dest, size, - va("#ifndef alphaGen_t\n" - "#define alphaGen_t\n" - "#define AGEN_LIGHTING_SPECULAR %i\n" - "#define AGEN_PORTAL %i\n" - "#endif\n", - AGEN_LIGHTING_SPECULAR, - AGEN_PORTAL)); - - fbufWidthScale = 1.0f / ((float)glConfig.vidWidth); - fbufHeightScale = 1.0f / ((float)glConfig.vidHeight); - Q_strcat(dest, size, - va("#ifndef r_FBufScale\n#define r_FBufScale vec2(%f, %f)\n#endif\n", fbufWidthScale, fbufHeightScale)); - - if (r_pbr->integer) - Q_strcat(dest, size, "#define USE_PBR\n"); - - if (r_cubeMapping->integer) - { - int cubeMipSize = r_cubemapSize->integer; - int numRoughnessMips = 0; - - while (cubeMipSize) - { - cubeMipSize >>= 1; - numRoughnessMips++; - } - numRoughnessMips = MAX(1, numRoughnessMips - 2); - Q_strcat(dest, size, va("#define ROUGHNESS_MIPS float(%d)\n", numRoughnessMips)); - } - - if (extra) - { - Q_strcat(dest, size, extra); - } - - // OK we added a lot of stuff but if we do something bad in the GLSL shaders then we want the proper line - // so we have to reset the line counting - Q_strcat(dest, size, "#line 0\n"); -} - -static int GLSL_CompileGPUShader(GLuint program, GLuint *prevShader, const GLchar *buffer, int size, GLenum shaderType) -{ - GLint compiled; - GLuint shader; - - shader = qglCreateShader(shaderType); - - qglShaderSource(shader, 1, (const GLchar **)&buffer, &size); - - // compile shader - qglCompileShader(shader); - - // check if shader compiled - qglGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); - if(!compiled) - { - GLSL_PrintLog(shader, GLSL_PRINTLOG_SHADER_SOURCE, qfalse); - GLSL_PrintLog(shader, GLSL_PRINTLOG_SHADER_INFO, qfalse); - ri.Error(ERR_DROP, "Couldn't compile shader"); - return 0; - } - - if (*prevShader) - { - qglDetachShader(program, *prevShader); - qglDeleteShader(*prevShader); - } - - // attach shader to program - qglAttachShader(program, shader); - - *prevShader = shader; - - return 1; -} - -static int GLSL_LoadGPUShaderText(const char *name, const char *fallback, - GLenum shaderType, char *dest, int destSize) -{ - char filename[MAX_QPATH]; - GLchar *buffer = NULL; - const GLchar *shaderText = NULL; - int size; - int result; - - if(shaderType == GL_VERTEX_SHADER) - { - Com_sprintf(filename, sizeof(filename), "glsl/%s_vp.glsl", name); - } - else - { - Com_sprintf(filename, sizeof(filename), "glsl/%s_fp.glsl", name); - } - - if ( r_externalGLSL->integer ) { - size = ri.FS_ReadFile(filename, (void **)&buffer); - } else { - size = 0; - buffer = NULL; - } - - if(!buffer) - { - if (fallback) - { - ri.Printf(PRINT_DEVELOPER, "...loading built-in '%s'\n", filename); - shaderText = fallback; - size = strlen(shaderText); - } - else - { - ri.Printf(PRINT_DEVELOPER, "couldn't load '%s'\n", filename); - return 0; - } - } - else - { - ri.Printf(PRINT_DEVELOPER, "...loading '%s'\n", filename); - shaderText = buffer; - } - - if (size > destSize) - { - result = 0; - } - else - { - Q_strncpyz(dest, shaderText, size + 1); - result = 1; - } - - if (buffer) - { - ri.FS_FreeFile(buffer); - } - - return result; -} - -static void GLSL_LinkProgram(GLuint program) -{ - GLint linked; - - qglLinkProgram(program); - - qglGetProgramiv(program, GL_LINK_STATUS, &linked); - if(!linked) - { - GLSL_PrintLog(program, GLSL_PRINTLOG_PROGRAM_INFO, qfalse); - ri.Error(ERR_DROP, "shaders failed to link"); - } -} - -static void GLSL_ShowProgramUniforms(GLuint program) -{ - int i, count, size; - GLenum type; - char uniformName[1000]; - - // query the number of active uniforms - qglGetProgramiv(program, GL_ACTIVE_UNIFORMS, &count); - - // Loop over each of the active uniforms, and set their value - for(i = 0; i < count; i++) - { - qglGetActiveUniform(program, i, sizeof(uniformName), NULL, &size, &type, uniformName); - - ri.Printf(PRINT_DEVELOPER, "active uniform: '%s'\n", uniformName); - } -} - -static int GLSL_InitGPUShader2(shaderProgram_t * program, const char *name, int attribs, const char *vpCode, const char *fpCode) -{ - ri.Printf(PRINT_DEVELOPER, "------- GPU shader -------\n"); - - if(strlen(name) >= MAX_QPATH) - { - ri.Error(ERR_DROP, "GLSL_InitGPUShader2: \"%s\" is too long", name); - } - - Q_strncpyz(program->name, name, sizeof(program->name)); - - program->program = qglCreateProgram(); - program->attribs = attribs; - - if (!(GLSL_CompileGPUShader(program->program, &program->vertexShader, vpCode, strlen(vpCode), GL_VERTEX_SHADER))) - { - ri.Printf(PRINT_ALL, "GLSL_InitGPUShader2: Unable to load \"%s\" as GL_VERTEX_SHADER\n", name); - qglDeleteProgram(program->program); - return 0; - } - - if(fpCode) - { - if(!(GLSL_CompileGPUShader(program->program, &program->fragmentShader, fpCode, strlen(fpCode), GL_FRAGMENT_SHADER))) - { - ri.Printf(PRINT_ALL, "GLSL_InitGPUShader2: Unable to load \"%s\" as GL_FRAGMENT_SHADER\n", name); - qglDeleteProgram(program->program); - return 0; - } - } - - if(attribs & ATTR_POSITION) - qglBindAttribLocation(program->program, ATTR_INDEX_POSITION, "attr_Position"); - - if(attribs & ATTR_TEXCOORD) - qglBindAttribLocation(program->program, ATTR_INDEX_TEXCOORD, "attr_TexCoord0"); - - if(attribs & ATTR_LIGHTCOORD) - qglBindAttribLocation(program->program, ATTR_INDEX_LIGHTCOORD, "attr_TexCoord1"); - -// if(attribs & ATTR_TEXCOORD2) -// qglBindAttribLocation(program->program, ATTR_INDEX_TEXCOORD2, "attr_TexCoord2"); - -// if(attribs & ATTR_TEXCOORD3) -// qglBindAttribLocation(program->program, ATTR_INDEX_TEXCOORD3, "attr_TexCoord3"); - - if(attribs & ATTR_TANGENT) - qglBindAttribLocation(program->program, ATTR_INDEX_TANGENT, "attr_Tangent"); - - if(attribs & ATTR_NORMAL) - qglBindAttribLocation(program->program, ATTR_INDEX_NORMAL, "attr_Normal"); - - if(attribs & ATTR_COLOR) - qglBindAttribLocation(program->program, ATTR_INDEX_COLOR, "attr_Color"); - - if(attribs & ATTR_PAINTCOLOR) - qglBindAttribLocation(program->program, ATTR_INDEX_PAINTCOLOR, "attr_PaintColor"); - - if(attribs & ATTR_LIGHTDIRECTION) - qglBindAttribLocation(program->program, ATTR_INDEX_LIGHTDIRECTION, "attr_LightDirection"); - - if(attribs & ATTR_BONE_INDEXES) - qglBindAttribLocation(program->program, ATTR_INDEX_BONE_INDEXES, "attr_BoneIndexes"); - - if(attribs & ATTR_BONE_WEIGHTS) - qglBindAttribLocation(program->program, ATTR_INDEX_BONE_WEIGHTS, "attr_BoneWeights"); - - if(attribs & ATTR_POSITION2) - qglBindAttribLocation(program->program, ATTR_INDEX_POSITION2, "attr_Position2"); - - if(attribs & ATTR_NORMAL2) - qglBindAttribLocation(program->program, ATTR_INDEX_NORMAL2, "attr_Normal2"); - - if(attribs & ATTR_TANGENT2) - qglBindAttribLocation(program->program, ATTR_INDEX_TANGENT2, "attr_Tangent2"); - - GLSL_LinkProgram(program->program); - - return 1; -} - -static int GLSL_InitGPUShader(shaderProgram_t * program, const char *name, - int attribs, qboolean fragmentShader, const GLchar *extra, qboolean addHeader, - const char *fallback_vp, const char *fallback_fp) -{ - char vpCode[32000]; - char fpCode[32000]; - char *postHeader; - int size; - int result; - - size = sizeof(vpCode); - if (addHeader) - { - GLSL_GetShaderHeader(GL_VERTEX_SHADER, extra, vpCode, size); - postHeader = &vpCode[strlen(vpCode)]; - size -= strlen(vpCode); - } - else - { - postHeader = &vpCode[0]; - } - - if (!GLSL_LoadGPUShaderText(name, fallback_vp, GL_VERTEX_SHADER, postHeader, size)) - { - return 0; - } - - if (fragmentShader) - { - size = sizeof(fpCode); - if (addHeader) - { - GLSL_GetShaderHeader(GL_FRAGMENT_SHADER, extra, fpCode, size); - postHeader = &fpCode[strlen(fpCode)]; - size -= strlen(fpCode); - } - else - { - postHeader = &fpCode[0]; - } - - if (!GLSL_LoadGPUShaderText(name, fallback_fp, GL_FRAGMENT_SHADER, postHeader, size)) - { - return 0; - } - } - - result = GLSL_InitGPUShader2(program, name, attribs, vpCode, fragmentShader ? fpCode : NULL); - - return result; -} - -static void GLSL_InitUniforms(shaderProgram_t *program) -{ - int i, size; - - GLint *uniforms = program->uniforms; - - size = 0; - for (i = 0; i < UNIFORM_COUNT; i++) - { - uniforms[i] = qglGetUniformLocation(program->program, uniformsInfo[i].name); - - if (uniforms[i] == -1) - continue; - - program->uniformBufferOffsets[i] = size; - - switch(uniformsInfo[i].type) - { - case GLSL_INT: - size += sizeof(GLint); - break; - case GLSL_FLOAT: - size += sizeof(GLfloat); - break; - case GLSL_FLOAT5: - size += sizeof(vec_t) * 5; - break; - case GLSL_VEC2: - size += sizeof(vec_t) * 2; - break; - case GLSL_VEC3: - size += sizeof(vec_t) * 3; - break; - case GLSL_VEC4: - size += sizeof(vec_t) * 4; - break; - case GLSL_MAT16: - size += sizeof(vec_t) * 16; - break; - case GLSL_MAT16_BONEMATRIX: - size += sizeof(vec_t) * 16 * glRefConfig.glslMaxAnimatedBones; - break; - default: - break; - } - } - - program->uniformBuffer = ri.Malloc(size); -} - -static void GLSL_FinishGPUShader(shaderProgram_t *program) -{ - GLSL_ShowProgramUniforms(program->program); - GL_CheckErrors(); -} - -void GLSL_SetUniformInt(shaderProgram_t *program, int uniformNum, GLint value) -{ - GLint *uniforms = program->uniforms; - GLint *compare = (GLint *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); - - if (uniforms[uniformNum] == -1) - return; - - if (uniformsInfo[uniformNum].type != GLSL_INT) - { - ri.Printf( PRINT_WARNING, "GLSL_SetUniformInt: wrong type for uniform %i in program %s\n", uniformNum, program->name); - return; - } - - if (value == *compare) - { - return; - } - - *compare = value; - - qglProgramUniform1iEXT(program->program, uniforms[uniformNum], value); -} - -void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat value) -{ - GLint *uniforms = program->uniforms; - GLfloat *compare = (GLfloat *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); - - if (uniforms[uniformNum] == -1) - return; - - if (uniformsInfo[uniformNum].type != GLSL_FLOAT) - { - ri.Printf( PRINT_WARNING, "GLSL_SetUniformFloat: wrong type for uniform %i in program %s\n", uniformNum, program->name); - return; - } - - if (value == *compare) - { - return; - } - - *compare = value; - - qglProgramUniform1fEXT(program->program, uniforms[uniformNum], value); -} - -void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t v) -{ - GLint *uniforms = program->uniforms; - vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); - - if (uniforms[uniformNum] == -1) - return; - - if (uniformsInfo[uniformNum].type != GLSL_VEC2) - { - ri.Printf( PRINT_WARNING, "GLSL_SetUniformVec2: wrong type for uniform %i in program %s\n", uniformNum, program->name); - return; - } - - if (v[0] == compare[0] && v[1] == compare[1]) - { - return; - } - - compare[0] = v[0]; - compare[1] = v[1]; - - qglProgramUniform2fEXT(program->program, uniforms[uniformNum], v[0], v[1]); -} - -void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t v) -{ - GLint *uniforms = program->uniforms; - vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); - - if (uniforms[uniformNum] == -1) - return; - - if (uniformsInfo[uniformNum].type != GLSL_VEC3) - { - ri.Printf( PRINT_WARNING, "GLSL_SetUniformVec3: wrong type for uniform %i in program %s\n", uniformNum, program->name); - return; - } - - if (VectorCompare(v, compare)) - { - return; - } - - VectorCopy(v, compare); - - qglProgramUniform3fEXT(program->program, uniforms[uniformNum], v[0], v[1], v[2]); -} - -void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t v) -{ - GLint *uniforms = program->uniforms; - vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); - - if (uniforms[uniformNum] == -1) - return; - - if (uniformsInfo[uniformNum].type != GLSL_VEC4) - { - ri.Printf( PRINT_WARNING, "GLSL_SetUniformVec4: wrong type for uniform %i in program %s\n", uniformNum, program->name); - return; - } - - if (VectorCompare4(v, compare)) - { - return; - } - - VectorCopy4(v, compare); - - qglProgramUniform4fEXT(program->program, uniforms[uniformNum], v[0], v[1], v[2], v[3]); -} - -void GLSL_SetUniformFloat5(shaderProgram_t *program, int uniformNum, const vec5_t v) -{ - GLint *uniforms = program->uniforms; - vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); - - if (uniforms[uniformNum] == -1) - return; - - if (uniformsInfo[uniformNum].type != GLSL_FLOAT5) - { - ri.Printf( PRINT_WARNING, "GLSL_SetUniformFloat5: wrong type for uniform %i in program %s\n", uniformNum, program->name); - return; - } - - if (VectorCompare5(v, compare)) - { - return; - } - - VectorCopy5(v, compare); - - qglProgramUniform1fvEXT(program->program, uniforms[uniformNum], 5, v); -} - -void GLSL_SetUniformMat4(shaderProgram_t *program, int uniformNum, const mat4_t matrix) -{ - GLint *uniforms = program->uniforms; - vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); - - if (uniforms[uniformNum] == -1) - return; - - if (uniformsInfo[uniformNum].type != GLSL_MAT16) - { - ri.Printf( PRINT_WARNING, "GLSL_SetUniformMat4: wrong type for uniform %i in program %s\n", uniformNum, program->name); - return; - } - - if (Mat4Compare(matrix, compare)) - { - return; - } - - Mat4Copy(matrix, compare); - - qglProgramUniformMatrix4fvEXT(program->program, uniforms[uniformNum], 1, GL_FALSE, matrix); -} - -void GLSL_SetUniformMat4BoneMatrix(shaderProgram_t *program, int uniformNum, /*const*/ mat4_t *matrix, int numMatricies) -{ - GLint *uniforms = program->uniforms; - vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); - - if (uniforms[uniformNum] == -1) { - return; - } - - if (uniformsInfo[uniformNum].type != GLSL_MAT16_BONEMATRIX) - { - ri.Printf( PRINT_WARNING, "GLSL_SetUniformMat4BoneMatrix: wrong type for uniform %i in program %s\n", uniformNum, program->name); - return; - } - - if (numMatricies > glRefConfig.glslMaxAnimatedBones) - { - ri.Printf( PRINT_WARNING, "GLSL_SetUniformMat4BoneMatrix: too many matricies (%d/%d) for uniform %i in program %s\n", - numMatricies, glRefConfig.glslMaxAnimatedBones, uniformNum, program->name); - return; - } - - if (!memcmp(matrix, compare, numMatricies * sizeof(mat4_t))) - { - return; - } - - Com_Memcpy(compare, matrix, numMatricies * sizeof(mat4_t)); - - qglProgramUniformMatrix4fvEXT(program->program, uniforms[uniformNum], numMatricies, GL_FALSE, &matrix[0][0]); -} - -static void GLSL_DeleteGPUShader(shaderProgram_t *program) -{ - if(program->program) - { - if (program->vertexShader) - { - qglDetachShader(program->program, program->vertexShader); - qglDeleteShader(program->vertexShader); - } - - if (program->fragmentShader) - { - qglDetachShader(program->program, program->fragmentShader); - qglDeleteShader(program->fragmentShader); - } - - qglDeleteProgram(program->program); - - if (program->uniformBuffer) - { - ri.Free(program->uniformBuffer); - } - - Com_Memset(program, 0, sizeof(*program)); - } -} - -void GLSL_InitGPUShaders(void) -{ - int startTime, endTime; - int i; - char extradefines[1024]; - int attribs; - int numGenShaders = 0, numLightShaders = 0, numEtcShaders = 0; - - ri.Printf(PRINT_ALL, "------- GLSL_InitGPUShaders -------\n"); - - R_IssuePendingRenderCommands(); - - startTime = ri.Milliseconds(); - - for (i = 0; i < GENERICDEF_COUNT; i++) - { - if ((i & GENERICDEF_USE_VERTEX_ANIMATION) && (i & GENERICDEF_USE_BONE_ANIMATION)) - continue; - - if ((i & GENERICDEF_USE_BONE_ANIMATION) && !glRefConfig.glslMaxAnimatedBones) - continue; - - attribs = ATTR_POSITION | ATTR_TEXCOORD | ATTR_LIGHTCOORD | ATTR_NORMAL | ATTR_COLOR; - extradefines[0] = '\0'; - - if (i & GENERICDEF_USE_DEFORM_VERTEXES) - Q_strcat(extradefines, 1024, "#define USE_DEFORM_VERTEXES\n"); - - if (i & GENERICDEF_USE_TCGEN_AND_TCMOD) - { - Q_strcat(extradefines, 1024, "#define USE_TCGEN\n"); - Q_strcat(extradefines, 1024, "#define USE_TCMOD\n"); - } - - if (i & GENERICDEF_USE_VERTEX_ANIMATION) - { - Q_strcat(extradefines, 1024, "#define USE_VERTEX_ANIMATION\n"); - attribs |= ATTR_POSITION2 | ATTR_NORMAL2; - } - else if (i & GENERICDEF_USE_BONE_ANIMATION) - { - Q_strcat(extradefines, 1024, va("#define USE_BONE_ANIMATION\n#define MAX_GLSL_BONES %d\n", glRefConfig.glslMaxAnimatedBones)); - attribs |= ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS; - } - - if (i & GENERICDEF_USE_FOG) - Q_strcat(extradefines, 1024, "#define USE_FOG\n"); - - if (i & GENERICDEF_USE_RGBAGEN) - Q_strcat(extradefines, 1024, "#define USE_RGBAGEN\n"); - - if (!GLSL_InitGPUShader(&tr.genericShader[i], "generic", attribs, qtrue, extradefines, qtrue, fallbackShader_generic_vp, fallbackShader_generic_fp)) - { - ri.Error(ERR_FATAL, "Could not load generic shader!"); - } - - GLSL_InitUniforms(&tr.genericShader[i]); - - GLSL_SetUniformInt(&tr.genericShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); - GLSL_SetUniformInt(&tr.genericShader[i], UNIFORM_LIGHTMAP, TB_LIGHTMAP); - - GLSL_FinishGPUShader(&tr.genericShader[i]); - - numGenShaders++; - } - - - attribs = ATTR_POSITION | ATTR_TEXCOORD; - - if (!GLSL_InitGPUShader(&tr.textureColorShader, "texturecolor", attribs, qtrue, extradefines, qtrue, fallbackShader_texturecolor_vp, fallbackShader_texturecolor_fp)) - { - ri.Error(ERR_FATAL, "Could not load texturecolor shader!"); - } - - GLSL_InitUniforms(&tr.textureColorShader); - - GLSL_SetUniformInt(&tr.textureColorShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); - - GLSL_FinishGPUShader(&tr.textureColorShader); - - numEtcShaders++; - - for (i = 0; i < FOGDEF_COUNT; i++) - { - if ((i & FOGDEF_USE_VERTEX_ANIMATION) && (i & FOGDEF_USE_BONE_ANIMATION)) - continue; - - if ((i & FOGDEF_USE_BONE_ANIMATION) && !glRefConfig.glslMaxAnimatedBones) - continue; - - attribs = ATTR_POSITION | ATTR_NORMAL | ATTR_TEXCOORD; - extradefines[0] = '\0'; - - if (i & FOGDEF_USE_DEFORM_VERTEXES) - Q_strcat(extradefines, 1024, "#define USE_DEFORM_VERTEXES\n"); - - if (i & FOGDEF_USE_VERTEX_ANIMATION) - { - Q_strcat(extradefines, 1024, "#define USE_VERTEX_ANIMATION\n"); - attribs |= ATTR_POSITION2 | ATTR_NORMAL2; - } - else if (i & FOGDEF_USE_BONE_ANIMATION) - { - Q_strcat(extradefines, 1024, va("#define USE_BONE_ANIMATION\n#define MAX_GLSL_BONES %d\n", glRefConfig.glslMaxAnimatedBones)); - attribs |= ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS; - } - - if (!GLSL_InitGPUShader(&tr.fogShader[i], "fogpass", attribs, qtrue, extradefines, qtrue, fallbackShader_fogpass_vp, fallbackShader_fogpass_fp)) - { - ri.Error(ERR_FATAL, "Could not load fogpass shader!"); - } - - GLSL_InitUniforms(&tr.fogShader[i]); - GLSL_FinishGPUShader(&tr.fogShader[i]); - - numEtcShaders++; - } - - - for (i = 0; i < DLIGHTDEF_COUNT; i++) - { - attribs = ATTR_POSITION | ATTR_NORMAL | ATTR_TEXCOORD; - extradefines[0] = '\0'; - - if (i & DLIGHTDEF_USE_DEFORM_VERTEXES) - { - Q_strcat(extradefines, 1024, "#define USE_DEFORM_VERTEXES\n"); - } - - if (!GLSL_InitGPUShader(&tr.dlightShader[i], "dlight", attribs, qtrue, extradefines, qtrue, fallbackShader_dlight_vp, fallbackShader_dlight_fp)) - { - ri.Error(ERR_FATAL, "Could not load dlight shader!"); - } - - GLSL_InitUniforms(&tr.dlightShader[i]); - - GLSL_SetUniformInt(&tr.dlightShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); - - GLSL_FinishGPUShader(&tr.dlightShader[i]); - - numEtcShaders++; - } - - - for (i = 0; i < LIGHTDEF_COUNT; i++) - { - int lightType = i & LIGHTDEF_LIGHTTYPE_MASK; - qboolean fastLight = !(r_normalMapping->integer || r_specularMapping->integer); - - // skip impossible combos - if ((i & LIGHTDEF_USE_PARALLAXMAP) && !r_parallaxMapping->integer) - continue; - - if ((i & LIGHTDEF_USE_SHADOWMAP) && (!lightType || !r_sunlightMode->integer)) - continue; - - if ((i & LIGHTDEF_ENTITY_VERTEX_ANIMATION) && (i & LIGHTDEF_ENTITY_BONE_ANIMATION)) - continue; - - if ((i & LIGHTDEF_ENTITY_BONE_ANIMATION) && !glRefConfig.glslMaxAnimatedBones) - continue; - - attribs = ATTR_POSITION | ATTR_TEXCOORD | ATTR_COLOR | ATTR_NORMAL; - - extradefines[0] = '\0'; - - if (r_dlightMode->integer >= 2) - Q_strcat(extradefines, 1024, "#define USE_SHADOWMAP\n"); - - if (glRefConfig.swizzleNormalmap) - Q_strcat(extradefines, 1024, "#define SWIZZLE_NORMALMAP\n"); - - if (lightType) - { - Q_strcat(extradefines, 1024, "#define USE_LIGHT\n"); - - if (fastLight) - Q_strcat(extradefines, 1024, "#define USE_FAST_LIGHT\n"); - - switch (lightType) - { - case LIGHTDEF_USE_LIGHTMAP: - Q_strcat(extradefines, 1024, "#define USE_LIGHTMAP\n"); - if (r_deluxeMapping->integer && !fastLight) - Q_strcat(extradefines, 1024, "#define USE_DELUXEMAP\n"); - attribs |= ATTR_LIGHTCOORD | ATTR_LIGHTDIRECTION; - break; - case LIGHTDEF_USE_LIGHT_VECTOR: - Q_strcat(extradefines, 1024, "#define USE_LIGHT_VECTOR\n"); - break; - case LIGHTDEF_USE_LIGHT_VERTEX: - Q_strcat(extradefines, 1024, "#define USE_LIGHT_VERTEX\n"); - attribs |= ATTR_LIGHTDIRECTION; - break; - default: - break; - } - - if (r_normalMapping->integer) - { - Q_strcat(extradefines, 1024, "#define USE_NORMALMAP\n"); - - attribs |= ATTR_TANGENT; - - if ((i & LIGHTDEF_USE_PARALLAXMAP) && !(i & LIGHTDEF_ENTITY_VERTEX_ANIMATION) && !(i & LIGHTDEF_ENTITY_BONE_ANIMATION) && r_parallaxMapping->integer) - { - Q_strcat(extradefines, 1024, "#define USE_PARALLAXMAP\n"); - if (r_parallaxMapping->integer > 1) - Q_strcat(extradefines, 1024, "#define USE_RELIEFMAP\n"); - - if (r_parallaxMapShadows->integer) - Q_strcat(extradefines, 1024, "#define USE_PARALLAXMAP_SHADOWS\n"); - - Q_strcat(extradefines, 1024, va("#define r_parallaxMapOffset %f\n", r_parallaxMapOffset->value)); - } - } - - if (r_specularMapping->integer) - Q_strcat(extradefines, 1024, "#define USE_SPECULARMAP\n"); - - if (r_cubeMapping->integer) - { - Q_strcat(extradefines, 1024, "#define USE_CUBEMAP\n"); - if (r_cubeMapping->integer == 2) - Q_strcat(extradefines, 1024, "#define USE_BOX_CUBEMAP_PARALLAX\n"); - } - else if (r_deluxeSpecular->value > 0.000001f) - { - Q_strcat(extradefines, 1024, va("#define r_deluxeSpecular %f\n", r_deluxeSpecular->value)); - } - - switch (r_glossType->integer) - { - case 0: - default: - Q_strcat(extradefines, 1024, "#define GLOSS_IS_GLOSS\n"); - break; - case 1: - Q_strcat(extradefines, 1024, "#define GLOSS_IS_SMOOTHNESS\n"); - break; - case 2: - Q_strcat(extradefines, 1024, "#define GLOSS_IS_ROUGHNESS\n"); - break; - case 3: - Q_strcat(extradefines, 1024, "#define GLOSS_IS_SHININESS\n"); - break; - } - } - - if (i & LIGHTDEF_USE_SHADOWMAP) - { - Q_strcat(extradefines, 1024, "#define USE_SHADOWMAP\n"); - - if (r_sunlightMode->integer == 1) - Q_strcat(extradefines, 1024, "#define SHADOWMAP_MODULATE\n"); - else if (r_sunlightMode->integer == 2) - Q_strcat(extradefines, 1024, "#define USE_PRIMARY_LIGHT\n"); - } - - if (i & LIGHTDEF_USE_TCGEN_AND_TCMOD) - { - Q_strcat(extradefines, 1024, "#define USE_TCGEN\n"); - Q_strcat(extradefines, 1024, "#define USE_TCMOD\n"); - } - - if (i & LIGHTDEF_ENTITY_VERTEX_ANIMATION) - { - Q_strcat(extradefines, 1024, "#define USE_VERTEX_ANIMATION\n#define USE_MODELMATRIX\n"); - attribs |= ATTR_POSITION2 | ATTR_NORMAL2; - - if (r_normalMapping->integer) - { - attribs |= ATTR_TANGENT2; - } - } - else if (i & LIGHTDEF_ENTITY_BONE_ANIMATION) - { - Q_strcat(extradefines, 1024, "#define USE_MODELMATRIX\n"); - Q_strcat(extradefines, 1024, va("#define USE_BONE_ANIMATION\n#define MAX_GLSL_BONES %d\n", glRefConfig.glslMaxAnimatedBones)); - attribs |= ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS; - } - - if (!GLSL_InitGPUShader(&tr.lightallShader[i], "lightall", attribs, qtrue, extradefines, qtrue, fallbackShader_lightall_vp, fallbackShader_lightall_fp)) - { - ri.Error(ERR_FATAL, "Could not load lightall shader!"); - } - - GLSL_InitUniforms(&tr.lightallShader[i]); - - GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); - GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_LIGHTMAP, TB_LIGHTMAP); - GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_NORMALMAP, TB_NORMALMAP); - GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_DELUXEMAP, TB_DELUXEMAP); - GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SPECULARMAP, TB_SPECULARMAP); - GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SHADOWMAP, TB_SHADOWMAP); - GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_CUBEMAP, TB_CUBEMAP); - - GLSL_FinishGPUShader(&tr.lightallShader[i]); - - numLightShaders++; - } - - for (i = 0; i < SHADOWMAPDEF_COUNT; i++) - { - if ((i & SHADOWMAPDEF_USE_VERTEX_ANIMATION) && (i & SHADOWMAPDEF_USE_BONE_ANIMATION)) - continue; - - if ((i & SHADOWMAPDEF_USE_BONE_ANIMATION) && !glRefConfig.glslMaxAnimatedBones) - continue; - - attribs = ATTR_POSITION | ATTR_NORMAL | ATTR_TEXCOORD; - - extradefines[0] = '\0'; - - if (i & SHADOWMAPDEF_USE_VERTEX_ANIMATION) - { - Q_strcat(extradefines, 1024, "#define USE_VERTEX_ANIMATION\n"); - attribs |= ATTR_POSITION2 | ATTR_NORMAL2; - } - - if (i & SHADOWMAPDEF_USE_BONE_ANIMATION) - { - Q_strcat(extradefines, 1024, va("#define USE_BONE_ANIMATION\n#define MAX_GLSL_BONES %d\n", glRefConfig.glslMaxAnimatedBones)); - attribs |= ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS; - } - - if (!GLSL_InitGPUShader(&tr.shadowmapShader[i], "shadowfill", attribs, qtrue, extradefines, qtrue, fallbackShader_shadowfill_vp, fallbackShader_shadowfill_fp)) - { - ri.Error(ERR_FATAL, "Could not load shadowfill shader!"); - } - - GLSL_InitUniforms(&tr.shadowmapShader[i]); - GLSL_FinishGPUShader(&tr.shadowmapShader[i]); - - numEtcShaders++; - } - - attribs = ATTR_POSITION | ATTR_NORMAL; - extradefines[0] = '\0'; - - Q_strcat(extradefines, 1024, "#define USE_PCF\n#define USE_DISCARD\n"); - - if (!GLSL_InitGPUShader(&tr.pshadowShader, "pshadow", attribs, qtrue, extradefines, qtrue, fallbackShader_pshadow_vp, fallbackShader_pshadow_fp)) - { - ri.Error(ERR_FATAL, "Could not load pshadow shader!"); - } - - GLSL_InitUniforms(&tr.pshadowShader); - - GLSL_SetUniformInt(&tr.pshadowShader, UNIFORM_SHADOWMAP, TB_DIFFUSEMAP); - - GLSL_FinishGPUShader(&tr.pshadowShader); - - numEtcShaders++; - - - attribs = ATTR_POSITION | ATTR_TEXCOORD; - extradefines[0] = '\0'; - - if (!GLSL_InitGPUShader(&tr.down4xShader, "down4x", attribs, qtrue, extradefines, qtrue, fallbackShader_down4x_vp, fallbackShader_down4x_fp)) - { - ri.Error(ERR_FATAL, "Could not load down4x shader!"); - } - - GLSL_InitUniforms(&tr.down4xShader); - - GLSL_SetUniformInt(&tr.down4xShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); - - GLSL_FinishGPUShader(&tr.down4xShader); - - numEtcShaders++; - - - attribs = ATTR_POSITION | ATTR_TEXCOORD; - extradefines[0] = '\0'; - - if (!GLSL_InitGPUShader(&tr.bokehShader, "bokeh", attribs, qtrue, extradefines, qtrue, fallbackShader_bokeh_vp, fallbackShader_bokeh_fp)) - { - ri.Error(ERR_FATAL, "Could not load bokeh shader!"); - } - - GLSL_InitUniforms(&tr.bokehShader); - - GLSL_SetUniformInt(&tr.bokehShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); - - GLSL_FinishGPUShader(&tr.bokehShader); - - numEtcShaders++; - - - attribs = ATTR_POSITION | ATTR_TEXCOORD; - extradefines[0] = '\0'; - - if (!GLSL_InitGPUShader(&tr.tonemapShader, "tonemap", attribs, qtrue, extradefines, qtrue, fallbackShader_tonemap_vp, fallbackShader_tonemap_fp)) - { - ri.Error(ERR_FATAL, "Could not load tonemap shader!"); - } - - GLSL_InitUniforms(&tr.tonemapShader); - - GLSL_SetUniformInt(&tr.tonemapShader, UNIFORM_TEXTUREMAP, TB_COLORMAP); - GLSL_SetUniformInt(&tr.tonemapShader, UNIFORM_LEVELSMAP, TB_LEVELSMAP); - - GLSL_FinishGPUShader(&tr.tonemapShader); - - numEtcShaders++; - - - for (i = 0; i < 2; i++) - { - attribs = ATTR_POSITION | ATTR_TEXCOORD; - extradefines[0] = '\0'; - - if (!i) - Q_strcat(extradefines, 1024, "#define FIRST_PASS\n"); - - if (!GLSL_InitGPUShader(&tr.calclevels4xShader[i], "calclevels4x", attribs, qtrue, extradefines, qtrue, fallbackShader_calclevels4x_vp, fallbackShader_calclevels4x_fp)) - { - ri.Error(ERR_FATAL, "Could not load calclevels4x shader!"); - } - - GLSL_InitUniforms(&tr.calclevels4xShader[i]); - - GLSL_SetUniformInt(&tr.calclevels4xShader[i], UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); - - GLSL_FinishGPUShader(&tr.calclevels4xShader[i]); - - numEtcShaders++; - } - - - attribs = ATTR_POSITION | ATTR_TEXCOORD; - extradefines[0] = '\0'; - - if (r_shadowFilter->integer >= 1) - Q_strcat(extradefines, 1024, "#define USE_SHADOW_FILTER\n"); - - if (r_shadowFilter->integer >= 2) - Q_strcat(extradefines, 1024, "#define USE_SHADOW_FILTER2\n"); - - if (r_shadowCascadeZFar->integer != 0) - Q_strcat(extradefines, 1024, "#define USE_SHADOW_CASCADE\n"); - - Q_strcat(extradefines, 1024, va("#define r_shadowMapSize %f\n", r_shadowMapSize->value)); - Q_strcat(extradefines, 1024, va("#define r_shadowCascadeZFar %f\n", r_shadowCascadeZFar->value)); - - - if (!GLSL_InitGPUShader(&tr.shadowmaskShader, "shadowmask", attribs, qtrue, extradefines, qtrue, fallbackShader_shadowmask_vp, fallbackShader_shadowmask_fp)) - { - ri.Error(ERR_FATAL, "Could not load shadowmask shader!"); - } - - GLSL_InitUniforms(&tr.shadowmaskShader); - - GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SCREENDEPTHMAP, TB_COLORMAP); - GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP, TB_SHADOWMAP); - GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP2, TB_SHADOWMAP2); - GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP3, TB_SHADOWMAP3); - GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP4, TB_SHADOWMAP4); - - GLSL_FinishGPUShader(&tr.shadowmaskShader); - - numEtcShaders++; - - - attribs = ATTR_POSITION | ATTR_TEXCOORD; - extradefines[0] = '\0'; - - if (!GLSL_InitGPUShader(&tr.ssaoShader, "ssao", attribs, qtrue, extradefines, qtrue, fallbackShader_ssao_vp, fallbackShader_ssao_fp)) - { - ri.Error(ERR_FATAL, "Could not load ssao shader!"); - } - - GLSL_InitUniforms(&tr.ssaoShader); - - GLSL_SetUniformInt(&tr.ssaoShader, UNIFORM_SCREENDEPTHMAP, TB_COLORMAP); - - GLSL_FinishGPUShader(&tr.ssaoShader); - - numEtcShaders++; - - - for (i = 0; i < 4; i++) - { - attribs = ATTR_POSITION | ATTR_TEXCOORD; - extradefines[0] = '\0'; - - if (i & 1) - Q_strcat(extradefines, 1024, "#define USE_VERTICAL_BLUR\n"); - else - Q_strcat(extradefines, 1024, "#define USE_HORIZONTAL_BLUR\n"); - - if (!(i & 2)) - Q_strcat(extradefines, 1024, "#define USE_DEPTH\n"); - - - if (!GLSL_InitGPUShader(&tr.depthBlurShader[i], "depthBlur", attribs, qtrue, extradefines, qtrue, fallbackShader_depthblur_vp, fallbackShader_depthblur_fp)) - { - ri.Error(ERR_FATAL, "Could not load depthBlur shader!"); - } - - GLSL_InitUniforms(&tr.depthBlurShader[i]); - - GLSL_SetUniformInt(&tr.depthBlurShader[i], UNIFORM_SCREENIMAGEMAP, TB_COLORMAP); - GLSL_SetUniformInt(&tr.depthBlurShader[i], UNIFORM_SCREENDEPTHMAP, TB_LIGHTMAP); - - GLSL_FinishGPUShader(&tr.depthBlurShader[i]); - - numEtcShaders++; - } - -#if 0 - attribs = ATTR_POSITION | ATTR_TEXCOORD; - extradefines[0] = '\0'; - - if (!GLSL_InitGPUShader(&tr.testcubeShader, "testcube", attribs, qtrue, extradefines, qtrue, NULL, NULL)) - { - ri.Error(ERR_FATAL, "Could not load testcube shader!"); - } - - GLSL_InitUniforms(&tr.testcubeShader); - - GLSL_SetUniformInt(&tr.testcubeShader, UNIFORM_TEXTUREMAP, TB_COLORMAP); - - GLSL_FinishGPUShader(&tr.testcubeShader); - - numEtcShaders++; -#endif - - - endTime = ri.Milliseconds(); - - ri.Printf(PRINT_ALL, "loaded %i GLSL shaders (%i gen %i light %i etc) in %5.2f seconds\n", - numGenShaders + numLightShaders + numEtcShaders, numGenShaders, numLightShaders, - numEtcShaders, (endTime - startTime) / 1000.0); -} - -void GLSL_ShutdownGPUShaders(void) -{ - int i; - - ri.Printf(PRINT_ALL, "------- GLSL_ShutdownGPUShaders -------\n"); - - for (i = 0; i < ATTR_INDEX_COUNT; i++) - qglDisableVertexAttribArray(i); - - GL_BindNullProgram(); - - for ( i = 0; i < GENERICDEF_COUNT; i++) - GLSL_DeleteGPUShader(&tr.genericShader[i]); - - GLSL_DeleteGPUShader(&tr.textureColorShader); - - for ( i = 0; i < FOGDEF_COUNT; i++) - GLSL_DeleteGPUShader(&tr.fogShader[i]); - - for ( i = 0; i < DLIGHTDEF_COUNT; i++) - GLSL_DeleteGPUShader(&tr.dlightShader[i]); - - for ( i = 0; i < LIGHTDEF_COUNT; i++) - GLSL_DeleteGPUShader(&tr.lightallShader[i]); - - for ( i = 0; i < SHADOWMAPDEF_COUNT; i++) - GLSL_DeleteGPUShader(&tr.shadowmapShader[i]); - - GLSL_DeleteGPUShader(&tr.pshadowShader); - GLSL_DeleteGPUShader(&tr.down4xShader); - GLSL_DeleteGPUShader(&tr.bokehShader); - GLSL_DeleteGPUShader(&tr.tonemapShader); - - for ( i = 0; i < 2; i++) - GLSL_DeleteGPUShader(&tr.calclevels4xShader[i]); - - GLSL_DeleteGPUShader(&tr.shadowmaskShader); - GLSL_DeleteGPUShader(&tr.ssaoShader); - - for ( i = 0; i < 4; i++) - GLSL_DeleteGPUShader(&tr.depthBlurShader[i]); -} - - -void GLSL_BindProgram(shaderProgram_t * program) -{ - GLuint programObject = program ? program->program : 0; - //char *name = program ? program->name : "NULL"; - - if (GL_UseProgram(programObject)) - backEnd.pc.c_glslShaderBinds++; -} - - -shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) -{ - const shaderStage_t *pStage = tess.xstages[stage]; - int shaderAttribs = 0; - - if (tess.fogNum && pStage->adjustColorsForFog) - { - shaderAttribs |= GENERICDEF_USE_FOG; - } - - switch (pStage->rgbGen) - { - case CGEN_LIGHTING_DIFFUSE: - shaderAttribs |= GENERICDEF_USE_RGBAGEN; - break; - default: - break; - } - - switch (pStage->alphaGen) - { - case AGEN_LIGHTING_SPECULAR: - case AGEN_PORTAL: - shaderAttribs |= GENERICDEF_USE_RGBAGEN; - break; - default: - break; - } - - if (pStage->bundle[0].tcGen != TCGEN_TEXTURE) - { - shaderAttribs |= GENERICDEF_USE_TCGEN_AND_TCMOD; - } - - if (tess.shader->numDeforms && !ShaderRequiresCPUDeforms(tess.shader)) - { - shaderAttribs |= GENERICDEF_USE_DEFORM_VERTEXES; - } - - if (glState.vertexAnimation) - { - shaderAttribs |= GENERICDEF_USE_VERTEX_ANIMATION; - } - else if (glState.boneAnimation) - { - shaderAttribs |= GENERICDEF_USE_BONE_ANIMATION; - } - - if (pStage->bundle[0].numTexMods) - { - shaderAttribs |= GENERICDEF_USE_TCGEN_AND_TCMOD; - } - - return &tr.genericShader[shaderAttribs]; -} diff --git a/code/renderer2/tr_image.c b/code/renderer2/tr_image.c deleted file mode 100644 index b90012098d..0000000000 --- a/code/renderer2/tr_image.c +++ /dev/null @@ -1,3224 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_image.c -#include "tr_local.h" - -#include "tr_dsa.h" - -static byte s_intensitytable[256]; -static unsigned char s_gammatable[256]; - -int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST; -int gl_filter_max = GL_LINEAR; - -#define FILE_HASH_SIZE 1024 -static image_t* hashTable[FILE_HASH_SIZE]; - -/* -** R_GammaCorrect -*/ -void R_GammaCorrect( byte *buffer, int bufSize ) { - int i; - - for ( i = 0; i < bufSize; i++ ) { - buffer[i] = s_gammatable[buffer[i]]; - } -} - -typedef struct { - const char *name; - int minimize, maximize; -} textureMode_t; - -static const textureMode_t modes[] = { - {"GL_NEAREST", GL_NEAREST, GL_NEAREST}, - {"GL_LINEAR", GL_LINEAR, GL_LINEAR}, - {"GL_NEAREST_MIPMAP_NEAREST", GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST}, - {"GL_LINEAR_MIPMAP_NEAREST", GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR}, - {"GL_NEAREST_MIPMAP_LINEAR", GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST}, - {"GL_LINEAR_MIPMAP_LINEAR", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR} -}; - -/* -================ -return a hash value for the filename -================ -*/ -static long generateHashValue( const char *fname ) { - int i; - long hash; - char letter; - - hash = 0; - i = 0; - while (fname[i] != '\0') { - letter = tolower(fname[i]); - if (letter =='.') break; // don't include extension - if (letter =='\\') letter = '/'; // damn path names - hash+=(long)(letter)*(i+119); - i++; - } - hash &= (FILE_HASH_SIZE-1); - return hash; -} - -/* -=============== -GL_TextureMode -=============== -*/ -void GL_TextureMode( const char *string ) { - int i; - image_t *glt; - - for ( i=0 ; i< 6 ; i++ ) { - if ( !Q_stricmp( modes[i].name, string ) ) { - break; - } - } - - // hack to prevent trilinear from being set on voodoo, - // because their driver freaks... - if ( i == 5 && glConfig.hardwareType == GLHW_3DFX_2D3D ) { - ri.Printf( PRINT_ALL, "Refusing to set trilinear on a voodoo.\n" ); - i = 3; - } - - - if ( i == 6 ) { - ri.Printf (PRINT_ALL, "bad filter name\n"); - return; - } - - gl_filter_min = modes[i].minimize; - gl_filter_max = modes[i].maximize; - - // change all the existing mipmap texture objects - for ( i = 0 ; i < tr.numImages ; i++ ) { - glt = tr.images[ i ]; - if ( glt->flags & IMGFLAG_MIPMAP && !(glt->flags & IMGFLAG_CUBEMAP)) { - qglTextureParameterfEXT(glt->texnum, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); - qglTextureParameterfEXT(glt->texnum, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); - } - } -} - -/* -=============== -R_SumOfUsedImages -=============== -*/ -int R_SumOfUsedImages( void ) { - int total; - int i; - - total = 0; - for ( i = 0; i < tr.numImages; i++ ) { - if ( tr.images[i]->frameUsed == tr.frameCount ) { - total += tr.images[i]->uploadWidth * tr.images[i]->uploadHeight; - } - } - - return total; -} - -/* -=============== -R_ImageList_f -=============== -*/ -void R_ImageList_f( void ) { - int i; - int estTotalSize = 0; - - ri.Printf(PRINT_ALL, "\n -w-- -h-- -type-- -size- --name-------\n"); - - for ( i = 0 ; i < tr.numImages ; i++ ) - { - image_t *image = tr.images[i]; - const char *format = "???? "; - const char *sizeSuffix; - int estSize; - int displaySize; - - estSize = image->uploadHeight * image->uploadWidth; - - switch(image->internalFormat) - { - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: - format = "sDXT1 "; - // 64 bits per 16 pixels, so 4 bits per pixel - estSize /= 2; - break; - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: - format = "sDXT5 "; - // 128 bits per 16 pixels, so 1 byte per pixel - break; - case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB: - format = "sBPTC "; - // 128 bits per 16 pixels, so 1 byte per pixel - break; - case GL_COMPRESSED_RG_RGTC2: - format = "RGTC2 "; - // 128 bits per 16 pixels, so 1 byte per pixel - break; - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - format = "DXT1 "; - // 64 bits per 16 pixels, so 4 bits per pixel - estSize /= 2; - break; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - format = "DXT1a "; - // 64 bits per 16 pixels, so 4 bits per pixel - estSize /= 2; - break; - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - format = "DXT5 "; - // 128 bits per 16 pixels, so 1 byte per pixel - break; - case GL_COMPRESSED_RGBA_BPTC_UNORM_ARB: - format = "BPTC "; - // 128 bits per 16 pixels, so 1 byte per pixel - break; - case GL_RGB4_S3TC: - format = "S3TC "; - // same as DXT1? - estSize /= 2; - break; - case GL_RGBA16F_ARB: - format = "RGBA16F"; - // 8 bytes per pixel - estSize *= 8; - break; - case GL_RGBA16: - format = "RGBA16 "; - // 8 bytes per pixel - estSize *= 8; - break; - case GL_RGBA4: - case GL_RGBA8: - case GL_RGBA: - format = "RGBA "; - // 4 bytes per pixel - estSize *= 4; - break; - case GL_LUMINANCE8: - case GL_LUMINANCE: - format = "L "; - // 1 byte per pixel? - break; - case GL_RGB5: - case GL_RGB8: - case GL_RGB: - format = "RGB "; - // 3 bytes per pixel? - estSize *= 3; - break; - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE_ALPHA: - format = "LA "; - // 2 bytes per pixel? - estSize *= 2; - break; - case GL_SRGB_EXT: - case GL_SRGB8_EXT: - format = "sRGB "; - // 3 bytes per pixel? - estSize *= 3; - break; - case GL_SRGB_ALPHA_EXT: - case GL_SRGB8_ALPHA8_EXT: - format = "sRGBA "; - // 4 bytes per pixel? - estSize *= 4; - break; - case GL_SLUMINANCE_EXT: - case GL_SLUMINANCE8_EXT: - format = "sL "; - // 1 byte per pixel? - break; - case GL_SLUMINANCE_ALPHA_EXT: - case GL_SLUMINANCE8_ALPHA8_EXT: - format = "sLA "; - // 2 byte per pixel? - estSize *= 2; - break; - case GL_DEPTH_COMPONENT16: - format = "Depth16"; - // 2 bytes per pixel - estSize *= 2; - break; - case GL_DEPTH_COMPONENT24: - format = "Depth24"; - // 3 bytes per pixel - estSize *= 3; - break; - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT32: - format = "Depth32"; - // 4 bytes per pixel - estSize *= 4; - break; - } - - // mipmap adds about 50% - if (image->flags & IMGFLAG_MIPMAP) - estSize += estSize / 2; - - sizeSuffix = "b "; - displaySize = estSize; - - if (displaySize > 1024) - { - displaySize /= 1024; - sizeSuffix = "kb"; - } - - if (displaySize > 1024) - { - displaySize /= 1024; - sizeSuffix = "Mb"; - } - - if (displaySize > 1024) - { - displaySize /= 1024; - sizeSuffix = "Gb"; - } - - ri.Printf(PRINT_ALL, "%4i: %4ix%4i %s %4i%s %s\n", i, image->uploadWidth, image->uploadHeight, format, displaySize, sizeSuffix, image->imgName); - estTotalSize += estSize; - } - - ri.Printf (PRINT_ALL, " ---------\n"); - ri.Printf (PRINT_ALL, " approx %i bytes\n", estTotalSize); - ri.Printf (PRINT_ALL, " %i total images\n\n", tr.numImages ); -} - -//======================================================================= - -/* -================ -ResampleTexture - -Used to resample images in a more general than quartering fashion. - -This will only be filtered properly if the resampled size -is greater than half the original size. - -If a larger shrinking is needed, use the mipmap function -before or after. -================ -*/ -static void ResampleTexture( byte *in, int inwidth, int inheight, byte *out, - int outwidth, int outheight ) { - int i, j; - byte *inrow, *inrow2; - int frac, fracstep; - int p1[2048], p2[2048]; - byte *pix1, *pix2, *pix3, *pix4; - - if (outwidth>2048) - ri.Error(ERR_DROP, "ResampleTexture: max width"); - - fracstep = inwidth*0x10000/outwidth; - - frac = fracstep>>2; - for ( i=0 ; i>16); - frac += fracstep; - } - frac = 3*(fracstep>>2); - for ( i=0 ; i>16); - frac += fracstep; - } - - for (i=0 ; i>2; - *out++ = (pix1[1] + pix2[1] + pix3[1] + pix4[1])>>2; - *out++ = (pix1[2] + pix2[2] + pix3[2] + pix4[2])>>2; - *out++ = (pix1[3] + pix2[3] + pix3[3] + pix4[3])>>2; - } - } -} - -static void RGBAtoYCoCgA(const byte *in, byte *out, int width, int height) -{ - int x, y; - - for (y = 0; y < height; y++) - { - const byte *inbyte = in + y * width * 4; - byte *outbyte = out + y * width * 4; - - for (x = 0; x < width; x++) - { - byte r, g, b, a, rb2; - - r = *inbyte++; - g = *inbyte++; - b = *inbyte++; - a = *inbyte++; - rb2 = (r + b) >> 1; - - *outbyte++ = (g + rb2) >> 1; // Y = R/4 + G/2 + B/4 - *outbyte++ = (r - b + 256) >> 1; // Co = R/2 - B/2 - *outbyte++ = (g - rb2 + 256) >> 1; // Cg = -R/4 + G/2 - B/4 - *outbyte++ = a; - } - } -} - -static void YCoCgAtoRGBA(const byte *in, byte *out, int width, int height) -{ - int x, y; - - for (y = 0; y < height; y++) - { - const byte *inbyte = in + y * width * 4; - byte *outbyte = out + y * width * 4; - - for (x = 0; x < width; x++) - { - byte _Y, Co, Cg, a; - - _Y = *inbyte++; - Co = *inbyte++; - Cg = *inbyte++; - a = *inbyte++; - - *outbyte++ = CLAMP(_Y + Co - Cg, 0, 255); // R = Y + Co - Cg - *outbyte++ = CLAMP(_Y + Cg - 128, 0, 255); // G = Y + Cg - *outbyte++ = CLAMP(_Y - Co - Cg + 256, 0, 255); // B = Y - Co - Cg - *outbyte++ = a; - } - } -} - - -// uses a sobel filter to change a texture to a normal map -static void RGBAtoNormal(const byte *in, byte *out, int width, int height, qboolean clampToEdge) -{ - int x, y, max; - - // convert to heightmap, storing in alpha - // same as converting to Y in YCoCg - max = 1; - for (y = 0; y < height; y++) - { - const byte *inbyte = in + y * width * 4; - byte *outbyte = out + y * width * 4 + 3; - - for (x = 0; x < width; x++) - { - byte result = (inbyte[0] >> 2) + (inbyte[1] >> 1) + (inbyte[2] >> 2); - result = result * result / 255; // Make linear - *outbyte = result; - max = MAX(max, *outbyte); - outbyte += 4; - inbyte += 4; - } - } - - // level out heights - if (max < 255) - { - for (y = 0; y < height; y++) - { - byte *outbyte = out + y * width * 4 + 3; - - for (x = 0; x < width; x++) - { - *outbyte = *outbyte + (255 - max); - outbyte += 4; - } - } - } - - - // now run sobel filter over height values to generate X and Y - // then normalize - for (y = 0; y < height; y++) - { - byte *outbyte = out + y * width * 4; - - for (x = 0; x < width; x++) - { - // 0 1 2 - // 3 4 5 - // 6 7 8 - - byte s[9]; - int x2, y2, i; - vec3_t normal; - - i = 0; - for (y2 = -1; y2 <= 1; y2++) - { - int src_y = y + y2; - - if (clampToEdge) - { - src_y = CLAMP(src_y, 0, height - 1); - } - else - { - src_y = (src_y + height) % height; - } - - - for (x2 = -1; x2 <= 1; x2++) - { - int src_x = x + x2; - - if (clampToEdge) - { - src_x = CLAMP(src_x, 0, width - 1); - } - else - { - src_x = (src_x + width) % width; - } - - s[i++] = *(out + (src_y * width + src_x) * 4 + 3); - } - } - - normal[0] = s[0] - s[2] - + 2 * s[3] - 2 * s[5] - + s[6] - s[8]; - - normal[1] = s[0] + 2 * s[1] + s[2] - - - s[6] - 2 * s[7] - s[8]; - - normal[2] = s[4] * 4; - - if (!VectorNormalize2(normal, normal)) - { - VectorSet(normal, 0, 0, 1); - } - - *outbyte++ = FloatToOffsetByte(normal[0]); - *outbyte++ = FloatToOffsetByte(normal[1]); - *outbyte++ = FloatToOffsetByte(normal[2]); - outbyte++; - } - } -} - -#define COPYSAMPLE(a,b) *(unsigned int *)(a) = *(unsigned int *)(b) - -// based on Fast Curve Based Interpolation -// from Fast Artifacts-Free Image Interpolation (http://www.andreagiachetti.it/icbi/) -// assumes data has a 2 pixel thick border of clamped or wrapped data -// expects data to be a grid with even (0, 0), (2, 0), (0, 2), (2, 2) etc pixels filled -// only performs FCBI on specified component -static void DoFCBI(byte *in, byte *out, int width, int height, int component) -{ - int x, y; - byte *outbyte, *inbyte; - - // copy in to out - for (y = 2; y < height - 2; y += 2) - { - inbyte = in + (y * width + 2) * 4 + component; - outbyte = out + (y * width + 2) * 4 + component; - - for (x = 2; x < width - 2; x += 2) - { - *outbyte = *inbyte; - outbyte += 8; - inbyte += 8; - } - } - - for (y = 3; y < height - 3; y += 2) - { - // diagonals - // - // NWp - northwest interpolated pixel - // NEp - northeast interpolated pixel - // NWd - northwest first derivative - // NEd - northeast first derivative - // NWdd - northwest second derivative - // NEdd - northeast second derivative - // - // Uses these samples: - // - // 0 - // - - a - b - - - // - - - - - - - - // c - d - e - f - // 0 - - - - - - - - // g - h - i - j - // - - - - - - - - // - - k - l - - - // - // x+2 uses these samples: - // - // 0 - // - - - - a - b - - - // - - - - - - - - - - // - - c - d - e - f - // 0 - - - - - - - - - - // - - g - h - i - j - // - - - - - - - - - - // - - - - k - l - - - // - // so we can reuse 8 of them on next iteration - // - // a=b, c=d, d=e, e=f, g=h, h=i, i=j, k=l - // - // only b, f, j, and l need to be sampled on next iteration - - byte sa, sb, sc, sd, se, sf, sg, sh, si, sj, sk, sl; - byte *line1, *line2, *line3, *line4; - - x = 3; - - // optimization one - // SAMPLE2(sa, x-1, y-3); - //SAMPLE2(sc, x-3, y-1); SAMPLE2(sd, x-1, y-1); SAMPLE2(se, x+1, y-1); - //SAMPLE2(sg, x-3, y+1); SAMPLE2(sh, x-1, y+1); SAMPLE2(si, x+1, y+1); - // SAMPLE2(sk, x-1, y+3); - - // optimization two - line1 = in + ((y - 3) * width + (x - 1)) * 4 + component; - line2 = in + ((y - 1) * width + (x - 3)) * 4 + component; - line3 = in + ((y + 1) * width + (x - 3)) * 4 + component; - line4 = in + ((y + 3) * width + (x - 1)) * 4 + component; - - // COPYSAMPLE(sa, line1); line1 += 8; - //COPYSAMPLE(sc, line2); line2 += 8; COPYSAMPLE(sd, line2); line2 += 8; COPYSAMPLE(se, line2); line2 += 8; - //COPYSAMPLE(sg, line3); line3 += 8; COPYSAMPLE(sh, line3); line3 += 8; COPYSAMPLE(si, line3); line3 += 8; - // COPYSAMPLE(sk, line4); line4 += 8; - - sa = *line1; line1 += 8; - sc = *line2; line2 += 8; sd = *line2; line2 += 8; se = *line2; line2 += 8; - sg = *line3; line3 += 8; sh = *line3; line3 += 8; si = *line3; line3 += 8; - sk = *line4; line4 += 8; - - outbyte = out + (y * width + x) * 4 + component; - - for ( ; x < width - 3; x += 2) - { - int NWd, NEd, NWp, NEp; - - // original - // SAMPLE2(sa, x-1, y-3); SAMPLE2(sb, x+1, y-3); - //SAMPLE2(sc, x-3, y-1); SAMPLE2(sd, x-1, y-1); SAMPLE2(se, x+1, y-1); SAMPLE2(sf, x+3, y-1); - //SAMPLE2(sg, x-3, y+1); SAMPLE2(sh, x-1, y+1); SAMPLE2(si, x+1, y+1); SAMPLE2(sj, x+3, y+1); - // SAMPLE2(sk, x-1, y+3); SAMPLE2(sl, x+1, y+3); - - // optimization one - //SAMPLE2(sb, x+1, y-3); - //SAMPLE2(sf, x+3, y-1); - //SAMPLE2(sj, x+3, y+1); - //SAMPLE2(sl, x+1, y+3); - - // optimization two - //COPYSAMPLE(sb, line1); line1 += 8; - //COPYSAMPLE(sf, line2); line2 += 8; - //COPYSAMPLE(sj, line3); line3 += 8; - //COPYSAMPLE(sl, line4); line4 += 8; - - sb = *line1; line1 += 8; - sf = *line2; line2 += 8; - sj = *line3; line3 += 8; - sl = *line4; line4 += 8; - - NWp = sd + si; - NEp = se + sh; - NWd = abs(sd - si); - NEd = abs(se - sh); - - if (NWd > 100 || NEd > 100 || abs(NWp-NEp) > 200) - { - if (NWd < NEd) - *outbyte = NWp >> 1; - else - *outbyte = NEp >> 1; - } - else - { - int NWdd, NEdd; - - //NEdd = abs(sg + sd + sb - 3 * (se + sh) + sk + si + sf); - //NWdd = abs(sa + se + sj - 3 * (sd + si) + sc + sh + sl); - NEdd = abs(sg + sb - 3 * NEp + sk + sf + NWp); - NWdd = abs(sa + sj - 3 * NWp + sc + sl + NEp); - - if (NWdd > NEdd) - *outbyte = NWp >> 1; - else - *outbyte = NEp >> 1; - } - - outbyte += 8; - - // COPYSAMPLE(sa, sb); - //COPYSAMPLE(sc, sd); COPYSAMPLE(sd, se); COPYSAMPLE(se, sf); - //COPYSAMPLE(sg, sh); COPYSAMPLE(sh, si); COPYSAMPLE(si, sj); - // COPYSAMPLE(sk, sl); - - sa = sb; - sc = sd; sd = se; se = sf; - sg = sh; sh = si; si = sj; - sk = sl; - } - } - - // hack: copy out to in again - for (y = 3; y < height - 3; y += 2) - { - inbyte = out + (y * width + 3) * 4 + component; - outbyte = in + (y * width + 3) * 4 + component; - - for (x = 3; x < width - 3; x += 2) - { - *outbyte = *inbyte; - outbyte += 8; - inbyte += 8; - } - } - - for (y = 2; y < height - 3; y++) - { - // horizontal & vertical - // - // hp - horizontally interpolated pixel - // vp - vertically interpolated pixel - // hd - horizontal first derivative - // vd - vertical first derivative - // hdd - horizontal second derivative - // vdd - vertical second derivative - // Uses these samples: - // - // 0 - // - a - b - - // c - d - e - // 0 - f - g - - // h - i - j - // - k - l - - // - // x+2 uses these samples: - // - // 0 - // - - - a - b - - // - - c - d - e - // 0 - - - f - g - - // - - h - i - j - // - - - k - l - - // - // so we can reuse 7 of them on next iteration - // - // a=b, c=d, d=e, f=g, h=i, i=j, k=l - // - // only b, e, g, j, and l need to be sampled on next iteration - - byte sa, sb, sc, sd, se, sf, sg, sh, si, sj, sk, sl; - byte *line1, *line2, *line3, *line4, *line5; - - //x = (y + 1) % 2; - x = (y + 1) % 2 + 2; - - // optimization one - // SAMPLE2(sa, x-1, y-2); - //SAMPLE2(sc, x-2, y-1); SAMPLE2(sd, x, y-1); - // SAMPLE2(sf, x-1, y ); - //SAMPLE2(sh, x-2, y+1); SAMPLE2(si, x, y+1); - // SAMPLE2(sk, x-1, y+2); - - line1 = in + ((y - 2) * width + (x - 1)) * 4 + component; - line2 = in + ((y - 1) * width + (x - 2)) * 4 + component; - line3 = in + ((y ) * width + (x - 1)) * 4 + component; - line4 = in + ((y + 1) * width + (x - 2)) * 4 + component; - line5 = in + ((y + 2) * width + (x - 1)) * 4 + component; - - // COPYSAMPLE(sa, line1); line1 += 8; - //COPYSAMPLE(sc, line2); line2 += 8; COPYSAMPLE(sd, line2); line2 += 8; - // COPYSAMPLE(sf, line3); line3 += 8; - //COPYSAMPLE(sh, line4); line4 += 8; COPYSAMPLE(si, line4); line4 += 8; - // COPYSAMPLE(sk, line5); line5 += 8; - - sa = *line1; line1 += 8; - sc = *line2; line2 += 8; sd = *line2; line2 += 8; - sf = *line3; line3 += 8; - sh = *line4; line4 += 8; si = *line4; line4 += 8; - sk = *line5; line5 += 8; - - outbyte = out + (y * width + x) * 4 + component; - - for ( ; x < width - 3; x+=2) - { - int hd, vd, hp, vp; - - // SAMPLE2(sa, x-1, y-2); SAMPLE2(sb, x+1, y-2); - //SAMPLE2(sc, x-2, y-1); SAMPLE2(sd, x, y-1); SAMPLE2(se, x+2, y-1); - // SAMPLE2(sf, x-1, y ); SAMPLE2(sg, x+1, y ); - //SAMPLE2(sh, x-2, y+1); SAMPLE2(si, x, y+1); SAMPLE2(sj, x+2, y+1); - // SAMPLE2(sk, x-1, y+2); SAMPLE2(sl, x+1, y+2); - - // optimization one - //SAMPLE2(sb, x+1, y-2); - //SAMPLE2(se, x+2, y-1); - //SAMPLE2(sg, x+1, y ); - //SAMPLE2(sj, x+2, y+1); - //SAMPLE2(sl, x+1, y+2); - - //COPYSAMPLE(sb, line1); line1 += 8; - //COPYSAMPLE(se, line2); line2 += 8; - //COPYSAMPLE(sg, line3); line3 += 8; - //COPYSAMPLE(sj, line4); line4 += 8; - //COPYSAMPLE(sl, line5); line5 += 8; - - sb = *line1; line1 += 8; - se = *line2; line2 += 8; - sg = *line3; line3 += 8; - sj = *line4; line4 += 8; - sl = *line5; line5 += 8; - - hp = sf + sg; - vp = sd + si; - hd = abs(sf - sg); - vd = abs(sd - si); - - if (hd > 100 || vd > 100 || abs(hp-vp) > 200) - { - if (hd < vd) - *outbyte = hp >> 1; - else - *outbyte = vp >> 1; - } - else - { - int hdd, vdd; - - //hdd = abs(sc[i] + sd[i] + se[i] - 3 * (sf[i] + sg[i]) + sh[i] + si[i] + sj[i]); - //vdd = abs(sa[i] + sf[i] + sk[i] - 3 * (sd[i] + si[i]) + sb[i] + sg[i] + sl[i]); - - hdd = abs(sc + se - 3 * hp + sh + sj + vp); - vdd = abs(sa + sk - 3 * vp + sb + sl + hp); - - if (hdd > vdd) - *outbyte = hp >> 1; - else - *outbyte = vp >> 1; - } - - outbyte += 8; - - // COPYSAMPLE(sa, sb); - //COPYSAMPLE(sc, sd); COPYSAMPLE(sd, se); - // COPYSAMPLE(sf, sg); - //COPYSAMPLE(sh, si); COPYSAMPLE(si, sj); - // COPYSAMPLE(sk, sl); - sa = sb; - sc = sd; sd = se; - sf = sg; - sh = si; si = sj; - sk = sl; - } - } -} - -// Similar to FCBI, but throws out the second order derivatives for speed -static void DoFCBIQuick(byte *in, byte *out, int width, int height, int component) -{ - int x, y; - byte *outbyte, *inbyte; - - // copy in to out - for (y = 2; y < height - 2; y += 2) - { - inbyte = in + (y * width + 2) * 4 + component; - outbyte = out + (y * width + 2) * 4 + component; - - for (x = 2; x < width - 2; x += 2) - { - *outbyte = *inbyte; - outbyte += 8; - inbyte += 8; - } - } - - for (y = 3; y < height - 4; y += 2) - { - byte sd, se, sh, si; - byte *line2, *line3; - - x = 3; - - line2 = in + ((y - 1) * width + (x - 1)) * 4 + component; - line3 = in + ((y + 1) * width + (x - 1)) * 4 + component; - - sd = *line2; line2 += 8; - sh = *line3; line3 += 8; - - outbyte = out + (y * width + x) * 4 + component; - - for ( ; x < width - 4; x += 2) - { - int NWd, NEd, NWp, NEp; - - se = *line2; line2 += 8; - si = *line3; line3 += 8; - - NWp = sd + si; - NEp = se + sh; - NWd = abs(sd - si); - NEd = abs(se - sh); - - if (NWd < NEd) - *outbyte = NWp >> 1; - else - *outbyte = NEp >> 1; - - outbyte += 8; - - sd = se; - sh = si; - } - } - - // hack: copy out to in again - for (y = 3; y < height - 3; y += 2) - { - inbyte = out + (y * width + 3) * 4 + component; - outbyte = in + (y * width + 3) * 4 + component; - - for (x = 3; x < width - 3; x += 2) - { - *outbyte = *inbyte; - outbyte += 8; - inbyte += 8; - } - } - - for (y = 2; y < height - 3; y++) - { - byte sd, sf, sg, si; - byte *line2, *line3, *line4; - - x = (y + 1) % 2 + 2; - - line2 = in + ((y - 1) * width + (x )) * 4 + component; - line3 = in + ((y ) * width + (x - 1)) * 4 + component; - line4 = in + ((y + 1) * width + (x )) * 4 + component; - - outbyte = out + (y * width + x) * 4 + component; - - sf = *line3; line3 += 8; - - for ( ; x < width - 3; x+=2) - { - int hd, vd, hp, vp; - - sd = *line2; line2 += 8; - sg = *line3; line3 += 8; - si = *line4; line4 += 8; - - hp = sf + sg; - vp = sd + si; - hd = abs(sf - sg); - vd = abs(sd - si); - - if (hd < vd) - *outbyte = hp >> 1; - else - *outbyte = vp >> 1; - - outbyte += 8; - - sf = sg; - } - } -} - -// Similar to DoFCBIQuick, but just takes the average instead of checking derivatives -// as well, this operates on all four components -static void DoLinear(byte *in, byte *out, int width, int height) -{ - int x, y, i; - byte *outbyte, *inbyte; - - // copy in to out - for (y = 2; y < height - 2; y += 2) - { - x = 2; - - inbyte = in + (y * width + x) * 4; - outbyte = out + (y * width + x) * 4; - - for ( ; x < width - 2; x += 2) - { - COPYSAMPLE(outbyte, inbyte); - outbyte += 8; - inbyte += 8; - } - } - - for (y = 1; y < height - 1; y += 2) - { - byte sd[4] = {0}, se[4] = {0}, sh[4] = {0}, si[4] = {0}; - byte *line2, *line3; - - x = 1; - - line2 = in + ((y - 1) * width + (x - 1)) * 4; - line3 = in + ((y + 1) * width + (x - 1)) * 4; - - COPYSAMPLE(sd, line2); line2 += 8; - COPYSAMPLE(sh, line3); line3 += 8; - - outbyte = out + (y * width + x) * 4; - - for ( ; x < width - 1; x += 2) - { - COPYSAMPLE(se, line2); line2 += 8; - COPYSAMPLE(si, line3); line3 += 8; - - for (i = 0; i < 4; i++) - { - *outbyte++ = (sd[i] + si[i] + se[i] + sh[i]) >> 2; - } - - outbyte += 4; - - COPYSAMPLE(sd, se); - COPYSAMPLE(sh, si); - } - } - - // hack: copy out to in again - for (y = 1; y < height - 1; y += 2) - { - x = 1; - - inbyte = out + (y * width + x) * 4; - outbyte = in + (y * width + x) * 4; - - for ( ; x < width - 1; x += 2) - { - COPYSAMPLE(outbyte, inbyte); - outbyte += 8; - inbyte += 8; - } - } - - for (y = 1; y < height - 1; y++) - { - byte sd[4], sf[4], sg[4], si[4]; - byte *line2, *line3, *line4; - - x = y % 2 + 1; - - line2 = in + ((y - 1) * width + (x )) * 4; - line3 = in + ((y ) * width + (x - 1)) * 4; - line4 = in + ((y + 1) * width + (x )) * 4; - - COPYSAMPLE(sf, line3); line3 += 8; - - outbyte = out + (y * width + x) * 4; - - for ( ; x < width - 1; x += 2) - { - COPYSAMPLE(sd, line2); line2 += 8; - COPYSAMPLE(sg, line3); line3 += 8; - COPYSAMPLE(si, line4); line4 += 8; - - for (i = 0; i < 4; i++) - { - *outbyte++ = (sf[i] + sg[i] + sd[i] + si[i]) >> 2; - } - - outbyte += 4; - - COPYSAMPLE(sf, sg); - } - } -} - - -static void ExpandHalfTextureToGrid( byte *data, int width, int height) -{ - int x, y; - - for (y = height / 2; y > 0; y--) - { - byte *outbyte = data + ((y * 2 - 1) * (width) - 2) * 4; - byte *inbyte = data + (y * (width / 2) - 1) * 4; - - for (x = width / 2; x > 0; x--) - { - COPYSAMPLE(outbyte, inbyte); - - outbyte -= 8; - inbyte -= 4; - } - } -} - -static void FillInNormalizedZ(const byte *in, byte *out, int width, int height) -{ - int x, y; - - for (y = 0; y < height; y++) - { - const byte *inbyte = in + y * width * 4; - byte *outbyte = out + y * width * 4; - - for (x = 0; x < width; x++) - { - byte nx, ny, nz, h; - float fnx, fny, fll, fnz; - - nx = *inbyte++; - ny = *inbyte++; - inbyte++; - h = *inbyte++; - - fnx = OffsetByteToFloat(nx); - fny = OffsetByteToFloat(ny); - fll = 1.0f - fnx * fnx - fny * fny; - if (fll >= 0.0f) - fnz = (float)sqrt(fll); - else - fnz = 0.0f; - - nz = FloatToOffsetByte(fnz); - - *outbyte++ = nx; - *outbyte++ = ny; - *outbyte++ = nz; - *outbyte++ = h; - } - } -} - - -// size must be even -#define WORKBLOCK_SIZE 128 -#define WORKBLOCK_BORDER 4 -#define WORKBLOCK_REALSIZE (WORKBLOCK_SIZE + WORKBLOCK_BORDER * 2) - -// assumes that data has already been expanded into a 2x2 grid -static void FCBIByBlock(byte *data, int width, int height, qboolean clampToEdge, qboolean normalized) -{ - byte workdata[WORKBLOCK_REALSIZE * WORKBLOCK_REALSIZE * 4]; - byte outdata[WORKBLOCK_REALSIZE * WORKBLOCK_REALSIZE * 4]; - byte *inbyte, *outbyte; - int x, y; - int srcx, srcy; - - ExpandHalfTextureToGrid(data, width, height); - - for (y = 0; y < height; y += WORKBLOCK_SIZE) - { - for (x = 0; x < width; x += WORKBLOCK_SIZE) - { - int x2, y2; - int workwidth, workheight, fullworkwidth, fullworkheight; - - workwidth = MIN(WORKBLOCK_SIZE, width - x); - workheight = MIN(WORKBLOCK_SIZE, height - y); - - fullworkwidth = workwidth + WORKBLOCK_BORDER * 2; - fullworkheight = workheight + WORKBLOCK_BORDER * 2; - - //memset(workdata, 0, WORKBLOCK_REALSIZE * WORKBLOCK_REALSIZE * 4); - - // fill in work block - for (y2 = 0; y2 < fullworkheight; y2 += 2) - { - srcy = y + y2 - WORKBLOCK_BORDER; - - if (clampToEdge) - { - srcy = CLAMP(srcy, 0, height - 2); - } - else - { - srcy = (srcy + height) % height; - } - - outbyte = workdata + y2 * fullworkwidth * 4; - inbyte = data + srcy * width * 4; - - for (x2 = 0; x2 < fullworkwidth; x2 += 2) - { - srcx = x + x2 - WORKBLOCK_BORDER; - - if (clampToEdge) - { - srcx = CLAMP(srcx, 0, width - 2); - } - else - { - srcx = (srcx + width) % width; - } - - COPYSAMPLE(outbyte, inbyte + srcx * 4); - outbyte += 8; - } - } - - // submit work block - DoLinear(workdata, outdata, fullworkwidth, fullworkheight); - - if (!normalized) - { - switch (r_imageUpsampleType->integer) - { - case 0: - break; - case 1: - DoFCBIQuick(workdata, outdata, fullworkwidth, fullworkheight, 0); - break; - case 2: - default: - DoFCBI(workdata, outdata, fullworkwidth, fullworkheight, 0); - break; - } - } - else - { - switch (r_imageUpsampleType->integer) - { - case 0: - break; - case 1: - DoFCBIQuick(workdata, outdata, fullworkwidth, fullworkheight, 0); - DoFCBIQuick(workdata, outdata, fullworkwidth, fullworkheight, 1); - break; - case 2: - default: - DoFCBI(workdata, outdata, fullworkwidth, fullworkheight, 0); - DoFCBI(workdata, outdata, fullworkwidth, fullworkheight, 1); - break; - } - } - - // copy back work block - for (y2 = 0; y2 < workheight; y2++) - { - inbyte = outdata + ((y2 + WORKBLOCK_BORDER) * fullworkwidth + WORKBLOCK_BORDER) * 4; - outbyte = data + ((y + y2) * width + x) * 4; - for (x2 = 0; x2 < workwidth; x2++) - { - COPYSAMPLE(outbyte, inbyte); - outbyte += 4; - inbyte += 4; - } - } - } - } -} -#undef COPYSAMPLE - -/* -================ -R_LightScaleTexture - -Scale up the pixel values in a texture to increase the -lighting range -================ -*/ -static void R_LightScaleTexture (byte *in, int inwidth, int inheight, qboolean only_gamma ) -{ - if ( only_gamma ) - { - if ( !glConfig.deviceSupportsGamma ) - { - int i, c; - byte *p; - - p = in; - - c = inwidth*inheight; - for (i=0 ; i> 1; x; x--) { - for (c = 3; c; c--, in++) { - total = (downmipSrgbLookup[*(in)] + downmipSrgbLookup[*(in + 4)]) * 2.0f; - - *out++ = (byte)(powf(total, 1.0f / 2.2f) * 255.0f); - } - *out++ = (*(in) + *(in + 4)) >> 1; in += 5; - } - - return; - } - - stride = inWidth * 4; - inWidth >>= 1; inHeight >>= 1; - - in2 = in + stride; - for (y = inHeight; y; y--, in += stride, in2 += stride) { - for (x = inWidth; x; x--) { - for (c = 3; c; c--, in++, in2++) { - total = downmipSrgbLookup[*(in)] + downmipSrgbLookup[*(in + 4)] - + downmipSrgbLookup[*(in2)] + downmipSrgbLookup[*(in2 + 4)]; - - *out++ = (byte)(powf(total, 1.0f / 2.2f) * 255.0f); - } - - *out++ = (*(in) + *(in + 4) + *(in2) + *(in2 + 4)) >> 2; in += 5, in2 += 5; - } - } -} - - -static void R_MipMapNormalHeight (const byte *in, byte *out, int width, int height, qboolean swizzle) -{ - int i, j; - int row; - int sx = swizzle ? 3 : 0; - int sa = swizzle ? 0 : 3; - - if ( width == 1 && height == 1 ) { - return; - } - - row = width * 4; - width >>= 1; - height >>= 1; - - for (i=0 ; i> 9; - data[1] = ( data[1] * inverseAlpha + premult[1] ) >> 9; - data[2] = ( data[2] * inverseAlpha + premult[2] ) >> 9; - } -} - -static const byte mipBlendColors[16][4] = { - {0,0,0,0}, - {255,0,0,128}, - {0,255,0,128}, - {0,0,255,128}, - {255,0,0,128}, - {0,255,0,128}, - {0,0,255,128}, - {255,0,0,128}, - {0,255,0,128}, - {0,0,255,128}, - {255,0,0,128}, - {0,255,0,128}, - {0,0,255,128}, - {255,0,0,128}, - {0,255,0,128}, - {0,0,255,128}, -}; - -static void RawImage_SwizzleRA( byte *data, int width, int height ) -{ - int i; - byte *ptr = data, swap; - - for (i=0; iinteger && scaled_width > width ) - scaled_width >>= 1; - if ( r_roundImagesDown->integer && scaled_height > height ) - scaled_height >>= 1; - - if ( picmip && data && resampledBuffer && r_imageUpsample->integer && - scaled_width < r_imageUpsampleMaxSize->integer && scaled_height < r_imageUpsampleMaxSize->integer) - { - int finalwidth, finalheight; - //int startTime, endTime; - - //startTime = ri.Milliseconds(); - - finalwidth = scaled_width << r_imageUpsample->integer; - finalheight = scaled_height << r_imageUpsample->integer; - - while ( finalwidth > r_imageUpsampleMaxSize->integer - || finalheight > r_imageUpsampleMaxSize->integer ) { - finalwidth >>= 1; - finalheight >>= 1; - } - - while ( finalwidth > glConfig.maxTextureSize - || finalheight > glConfig.maxTextureSize ) { - finalwidth >>= 1; - finalheight >>= 1; - } - - *resampledBuffer = ri.Hunk_AllocateTempMemory( finalwidth * finalheight * 4 ); - - if (scaled_width != width || scaled_height != height) - ResampleTexture (*data, width, height, *resampledBuffer, scaled_width, scaled_height); - else - Com_Memcpy(*resampledBuffer, *data, width * height * 4); - - if (type == IMGTYPE_COLORALPHA) - RGBAtoYCoCgA(*resampledBuffer, *resampledBuffer, scaled_width, scaled_height); - - while (scaled_width < finalwidth || scaled_height < finalheight) - { - scaled_width <<= 1; - scaled_height <<= 1; - - FCBIByBlock(*resampledBuffer, scaled_width, scaled_height, clampToEdge, (type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT)); - } - - if (type == IMGTYPE_COLORALPHA) - YCoCgAtoRGBA(*resampledBuffer, *resampledBuffer, scaled_width, scaled_height); - else if (type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT) - FillInNormalizedZ(*resampledBuffer, *resampledBuffer, scaled_width, scaled_height); - - //endTime = ri.Milliseconds(); - - //ri.Printf(PRINT_ALL, "upsampled %dx%d to %dx%d in %dms\n", width, height, scaled_width, scaled_height, endTime - startTime); - - *data = *resampledBuffer; - } - else if ( scaled_width != width || scaled_height != height ) - { - if (data && resampledBuffer) - { - *resampledBuffer = ri.Hunk_AllocateTempMemory( scaled_width * scaled_height * 4 ); - ResampleTexture (*data, width, height, *resampledBuffer, scaled_width, scaled_height); - *data = *resampledBuffer; - } - } - - width = scaled_width; - height = scaled_height; - - // - // perform optional picmip operation - // - if ( picmip ) { - scaled_width >>= r_picmip->integer; - scaled_height >>= r_picmip->integer; - } - - // - // clamp to the current upper OpenGL limit - // scale both axis down equally so we don't have to - // deal with a half mip resampling - // - while ( scaled_width > glConfig.maxTextureSize - || scaled_height > glConfig.maxTextureSize ) { - scaled_width >>= 1; - scaled_height >>= 1; - } - - // - // clamp to minimum size - // - scaled_width = MAX(1, scaled_width); - scaled_height = MAX(1, scaled_height); - - scaled = (width != scaled_width) || (height != scaled_height); - - // - // rescale texture to new size using existing mipmap functions - // - if (data) - { - while (width > scaled_width || height > scaled_height) - { - if (type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT) - R_MipMapNormalHeight(*data, *data, width, height, qfalse); - else - R_MipMapsRGB(*data, width, height); - - width = MAX(1, width >> 1); - height = MAX(1, height >> 1); - } - } - - *inout_width = width; - *inout_height = height; - - return scaled; -} - - -static qboolean RawImage_HasAlpha(const byte *scan, int numPixels) -{ - int i; - - if (!scan) - return qtrue; - - for ( i = 0; i < numPixels; i++ ) - { - if ( scan[i*4 + 3] != 255 ) - { - return qtrue; - } - } - - return qfalse; -} - -static GLenum RawImage_GetFormat(const byte *data, int numPixels, GLenum picFormat, qboolean lightMap, imgType_t type, imgFlags_t flags) -{ - int samples = 3; - GLenum internalFormat = GL_RGB; - qboolean forceNoCompression = (flags & IMGFLAG_NO_COMPRESSION); - qboolean normalmap = (type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT); - - if (picFormat != GL_RGBA8) - return picFormat; - - if(normalmap) - { - if ((type == IMGTYPE_NORMALHEIGHT) && RawImage_HasAlpha(data, numPixels) && r_parallaxMapping->integer) - { - if (!forceNoCompression && glRefConfig.textureCompression & TCR_BPTC) - { - internalFormat = GL_COMPRESSED_RGBA_BPTC_UNORM_ARB; - } - else if (!forceNoCompression && glConfig.textureCompression == TC_S3TC_ARB) - { - internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - } - else if ( r_texturebits->integer == 16 ) - { - internalFormat = GL_RGBA4; - } - else if ( r_texturebits->integer == 32 ) - { - internalFormat = GL_RGBA8; - } - else - { - internalFormat = GL_RGBA; - } - } - else - { - if (!forceNoCompression && glRefConfig.textureCompression & TCR_RGTC) - { - internalFormat = GL_COMPRESSED_RG_RGTC2; - } - else if (!forceNoCompression && glRefConfig.textureCompression & TCR_BPTC) - { - internalFormat = GL_COMPRESSED_RGBA_BPTC_UNORM_ARB; - } - else if (!forceNoCompression && glConfig.textureCompression == TC_S3TC_ARB) - { - internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - } - else if (r_texturebits->integer == 16) - { - internalFormat = GL_RGB5; - } - else if (r_texturebits->integer == 32) - { - internalFormat = GL_RGB8; - } - else - { - internalFormat = GL_RGB; - } - } - } - else if(lightMap) - { - if(r_greyscale->integer) - internalFormat = GL_LUMINANCE; - else - internalFormat = GL_RGBA; - } - else - { - if (RawImage_HasAlpha(data, numPixels)) - { - samples = 4; - } - - // select proper internal format - if ( samples == 3 ) - { - if(r_greyscale->integer) - { - if(r_texturebits->integer == 16 || r_texturebits->integer == 32) - internalFormat = GL_LUMINANCE8; - else - internalFormat = GL_LUMINANCE; - } - else - { - if ( !forceNoCompression && (glRefConfig.textureCompression & TCR_BPTC) ) - { - internalFormat = GL_COMPRESSED_RGBA_BPTC_UNORM_ARB; - } - else if ( !forceNoCompression && glConfig.textureCompression == TC_S3TC_ARB ) - { - internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - } - else if ( !forceNoCompression && glConfig.textureCompression == TC_S3TC ) - { - internalFormat = GL_RGB4_S3TC; - } - else if ( r_texturebits->integer == 16 ) - { - internalFormat = GL_RGB5; - } - else if ( r_texturebits->integer == 32 ) - { - internalFormat = GL_RGB8; - } - else - { - internalFormat = GL_RGB; - } - } - } - else if ( samples == 4 ) - { - if(r_greyscale->integer) - { - if(r_texturebits->integer == 16 || r_texturebits->integer == 32) - internalFormat = GL_LUMINANCE8_ALPHA8; - else - internalFormat = GL_LUMINANCE_ALPHA; - } - else - { - if ( !forceNoCompression && (glRefConfig.textureCompression & TCR_BPTC) ) - { - internalFormat = GL_COMPRESSED_RGBA_BPTC_UNORM_ARB; - } - else if ( !forceNoCompression && glConfig.textureCompression == TC_S3TC_ARB ) - { - internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - } - else if ( r_texturebits->integer == 16 ) - { - internalFormat = GL_RGBA4; - } - else if ( r_texturebits->integer == 32 ) - { - internalFormat = GL_RGBA8; - } - else - { - internalFormat = GL_RGBA; - } - } - } - } - - return internalFormat; -} - -static void CompressMonoBlock(byte outdata[8], const byte indata[16]) -{ - int hi, lo, diff, bias, outbyte, shift, i; - byte *p = outdata; - - hi = lo = indata[0]; - for (i = 1; i < 16; i++) - { - hi = MAX(indata[i], hi); - lo = MIN(indata[i], lo); - } - - *p++ = hi; - *p++ = lo; - - diff = hi - lo; - - if (diff == 0) - { - outbyte = (hi == 255) ? 255 : 0; - - for (i = 0; i < 6; i++) - *p++ = outbyte; - - return; - } - - bias = diff / 2 - lo * 7; - outbyte = shift = 0; - for (i = 0; i < 16; i++) - { - const byte fixIndex[8] = { 1, 7, 6, 5, 4, 3, 2, 0 }; - byte index = fixIndex[(indata[i] * 7 + bias) / diff]; - - outbyte |= index << shift; - shift += 3; - if (shift >= 8) - { - *p++ = outbyte & 0xff; - shift -= 8; - outbyte >>= 8; - } - } -} - -static void RawImage_UploadToRgtc2Texture(GLuint texture, int miplevel, int x, int y, int width, int height, byte *data) -{ - int wBlocks, hBlocks, iy, ix, size; - byte *compressedData, *p; - - wBlocks = (width + 3) / 4; - hBlocks = (height + 3) / 4; - size = wBlocks * hBlocks * 16; - - p = compressedData = ri.Hunk_AllocateTempMemory(size); - for (iy = 0; iy < height; iy += 4) - { - int oh = MIN(4, height - iy); - - for (ix = 0; ix < width; ix += 4) - { - byte workingData[16]; - int component; - - int ow = MIN(4, width - ix); - - for (component = 0; component < 2; component++) - { - int ox, oy; - - for (oy = 0; oy < oh; oy++) - for (ox = 0; ox < ow; ox++) - workingData[oy * 4 + ox] = data[((iy + oy) * width + ix + ox) * 4 + component]; - - // dupe data to fill - for (oy = 0; oy < 4; oy++) - for (ox = (oy < oh) ? ow : 0; ox < 4; ox++) - workingData[oy * 4 + ox] = workingData[(oy % oh) * 4 + ox % ow]; - - CompressMonoBlock(p, workingData); - p += 8; - } - } - } - - // FIXME: Won't work for x/y that aren't multiples of 4. - qglCompressedTextureSubImage2DEXT(texture, GL_TEXTURE_2D, miplevel, x, y, width, height, GL_COMPRESSED_RG_RGTC2, size, compressedData); - - ri.Hunk_FreeTempMemory(compressedData); -} - -static int CalculateMipSize(int width, int height, GLenum picFormat) -{ - int numBlocks = ((width + 3) / 4) * ((height + 3) / 4); - int numPixels = width * height; - - switch (picFormat) - { - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: - case GL_COMPRESSED_RED_RGTC1: - case GL_COMPRESSED_SIGNED_RED_RGTC1: - return numBlocks * 8; - - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: - case GL_COMPRESSED_RG_RGTC2: - case GL_COMPRESSED_SIGNED_RG_RGTC2: - case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB: - case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB: - case GL_COMPRESSED_RGBA_BPTC_UNORM_ARB: - case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB: - return numBlocks * 16; - - case GL_RGBA8: - case GL_SRGB8_ALPHA8_EXT: - return numPixels * 4; - - case GL_RGBA16: - return numPixels * 8; - - default: - ri.Printf(PRINT_ALL, "Unsupported texture format %08x\n", picFormat); - return 0; - } - - return 0; -} - - -static GLenum PixelDataFormatFromInternalFormat(GLenum internalFormat) -{ - switch (internalFormat) - { - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16_ARB: - case GL_DEPTH_COMPONENT24_ARB: - case GL_DEPTH_COMPONENT32_ARB: - return GL_DEPTH_COMPONENT; - default: - return GL_RGBA; - break; - } -} - -static void RawImage_UploadTexture(GLuint texture, byte *data, int x, int y, int width, int height, GLenum target, GLenum picFormat, int numMips, GLenum internalFormat, imgType_t type, imgFlags_t flags, qboolean subtexture ) -{ - GLenum dataFormat, dataType; - qboolean rgtc = internalFormat == GL_COMPRESSED_RG_RGTC2; - qboolean rgba8 = picFormat == GL_RGBA8 || picFormat == GL_SRGB8_ALPHA8_EXT; - qboolean rgba = rgba8 || picFormat == GL_RGBA16; - qboolean mipmap = !!(flags & IMGFLAG_MIPMAP); - int size, miplevel; - qboolean lastMip = qfalse; - - dataFormat = PixelDataFormatFromInternalFormat(internalFormat); - dataType = picFormat == GL_RGBA16 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE; - - miplevel = 0; - do - { - lastMip = (width == 1 && height == 1) || !mipmap; - size = CalculateMipSize(width, height, picFormat); - - if (!rgba) - { - qglCompressedTextureSubImage2DEXT(texture, target, miplevel, x, y, width, height, picFormat, size, data); - } - else - { - if (rgba8 && miplevel != 0 && r_colorMipLevels->integer) - R_BlendOverTexture((byte *)data, width * height, mipBlendColors[miplevel]); - - if (rgba8 && rgtc) - RawImage_UploadToRgtc2Texture(texture, miplevel, x, y, width, height, data); - else - qglTextureSubImage2DEXT(texture, target, miplevel, x, y, width, height, dataFormat, dataType, data); - } - - if (!lastMip && numMips < 2) - { - if (glRefConfig.framebufferObject) - { - qglGenerateTextureMipmapEXT(texture, target); - break; - } - else if (rgba8) - { - if (type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT) - R_MipMapNormalHeight(data, data, width, height, glRefConfig.swizzleNormalmap); - else - R_MipMapsRGB(data, width, height); - } - } - - x >>= 1; - y >>= 1; - width = MAX(1, width >> 1); - height = MAX(1, height >> 1); - miplevel++; - - if (numMips > 1) - { - data += size; - numMips--; - } - } - while (!lastMip); -} - - -/* -=============== -Upload32 - -=============== -*/ -static void Upload32(byte *data, int x, int y, int width, int height, GLenum picFormat, int numMips, image_t *image, qboolean scaled) -{ - int i, c; - byte *scan; - - imgType_t type = image->type; - imgFlags_t flags = image->flags; - GLenum internalFormat = image->internalFormat; - qboolean rgba8 = picFormat == GL_RGBA8 || picFormat == GL_SRGB8_ALPHA8_EXT; - qboolean mipmap = !!(flags & IMGFLAG_MIPMAP) && (rgba8 || numMips > 1); - qboolean cubemap = !!(flags & IMGFLAG_CUBEMAP); - - // These operations cannot be performed on non-rgba8 images. - if (rgba8 && !cubemap) - { - c = width*height; - scan = data; - - if (type == IMGTYPE_COLORALPHA) - { - if( r_greyscale->integer ) - { - for ( i = 0; i < c; i++ ) - { - byte luma = LUMA(scan[i*4], scan[i*4 + 1], scan[i*4 + 2]); - scan[i*4] = luma; - scan[i*4 + 1] = luma; - scan[i*4 + 2] = luma; - } - } - else if( r_greyscale->value ) - { - for ( i = 0; i < c; i++ ) - { - float luma = LUMA(scan[i*4], scan[i*4 + 1], scan[i*4 + 2]); - scan[i*4] = LERP(scan[i*4], luma, r_greyscale->value); - scan[i*4 + 1] = LERP(scan[i*4 + 1], luma, r_greyscale->value); - scan[i*4 + 2] = LERP(scan[i*4 + 2], luma, r_greyscale->value); - } - } - - // This corresponds to what the OpenGL1 renderer does. - if (!(flags & IMGFLAG_NOLIGHTSCALE) && (scaled || mipmap)) - R_LightScaleTexture(data, width, height, !mipmap); - } - - if (glRefConfig.swizzleNormalmap && (type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT)) - RawImage_SwizzleRA(data, width, height); - } - - if (cubemap) - { - for (i = 0; i < 6; i++) - { - int w2 = width, h2 = height; - RawImage_UploadTexture(image->texnum, data, x, y, width, height, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, picFormat, numMips, internalFormat, type, flags, qfalse); - for (c = numMips; c; c--) - { - data += CalculateMipSize(w2, h2, picFormat); - w2 = MAX(1, w2 >> 1); - h2 = MAX(1, h2 >> 1); - } - } - } - else - { - RawImage_UploadTexture(image->texnum, data, x, y, width, height, GL_TEXTURE_2D, picFormat, numMips, internalFormat, type, flags, qfalse); - } - - GL_CheckErrors(); -} - - -/* -================ -R_CreateImage2 - -This is the only way any image_t are created -================ -*/ -static image_t *R_CreateImage2( const char *name, byte *pic, int width, int height, GLenum picFormat, int numMips, imgType_t type, imgFlags_t flags, int internalFormat ) { - byte *resampledBuffer = NULL; - image_t *image; - qboolean isLightmap = qfalse, scaled = qfalse; - long hash; - int glWrapClampMode, mipWidth, mipHeight, miplevel; - qboolean rgba8 = picFormat == GL_RGBA8 || picFormat == GL_SRGB8_ALPHA8_EXT; - qboolean mipmap = !!(flags & IMGFLAG_MIPMAP); - qboolean cubemap = !!(flags & IMGFLAG_CUBEMAP); - qboolean picmip = !!(flags & IMGFLAG_PICMIP); - qboolean lastMip; - GLenum textureTarget = cubemap ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D; - GLenum dataFormat; - size_t namelen; - - namelen = strlen( name ); - if ( namelen >= MAX_QPATH ) { - ri.Error (ERR_DROP, "R_CreateImage: \"%s\" is too long", name); - } - if ( !strncmp( name, "*lightmap", 9 ) ) { - isLightmap = qtrue; - } - - if ( tr.numImages == MAX_DRAWIMAGES ) { - ri.Error( ERR_DROP, "R_CreateImage: MAX_DRAWIMAGES hit"); - } - - image = tr.images[tr.numImages] = ri.Hunk_Alloc( sizeof( *image ) + namelen + 1, h_low ); - qglGenTextures(1, &image->texnum); - tr.numImages++; - - image->type = type; - image->flags = flags; - - image->imgName = (char *)( image + 1 ); - strcpy( image->imgName, name ); - - image->width = width; - image->height = height; - if (flags & IMGFLAG_CLAMPTOEDGE) - glWrapClampMode = GL_CLAMP_TO_EDGE; - else - glWrapClampMode = GL_REPEAT; - - if (!internalFormat) - internalFormat = RawImage_GetFormat(pic, width * height, picFormat, isLightmap, image->type, image->flags); - - image->internalFormat = internalFormat; - - // Possibly scale image before uploading. - // if not rgba8 and uploading an image, skip picmips. - if (!cubemap) - { - if (rgba8) - scaled = RawImage_ScaleToPower2(&pic, &width, &height, type, flags, &resampledBuffer); - else if (pic && picmip) - { - for (miplevel = r_picmip->integer; miplevel > 0 && numMips > 1; miplevel--, numMips--) - { - int size = CalculateMipSize(width, height, picFormat); - width = MAX(1, width >> 1); - height = MAX(1, height >> 1); - pic += size; - } - } - } - - image->uploadWidth = width; - image->uploadHeight = height; - - // Allocate texture storage so we don't have to worry about it later. - dataFormat = PixelDataFormatFromInternalFormat(internalFormat); - mipWidth = width; - mipHeight = height; - miplevel = 0; - do - { - lastMip = !mipmap || (mipWidth == 1 && mipHeight == 1); - if (cubemap) - { - int i; - - for (i = 0; i < 6; i++) - qglTextureImage2DEXT(image->texnum, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, miplevel, internalFormat, mipWidth, mipHeight, 0, dataFormat, GL_UNSIGNED_BYTE, NULL); - } - else - { - qglTextureImage2DEXT(image->texnum, GL_TEXTURE_2D, miplevel, internalFormat, mipWidth, mipHeight, 0, dataFormat, GL_UNSIGNED_BYTE, NULL); - } - - mipWidth = MAX(1, mipWidth >> 1); - mipHeight = MAX(1, mipHeight >> 1); - miplevel++; - } - while (!lastMip); - - // Upload data. - if (pic) - Upload32(pic, 0, 0, width, height, picFormat, numMips, image, scaled); - - if (resampledBuffer != NULL) - ri.Hunk_FreeTempMemory(resampledBuffer); - - // Set all necessary texture parameters. - qglTextureParameterfEXT(image->texnum, textureTarget, GL_TEXTURE_WRAP_S, glWrapClampMode); - qglTextureParameterfEXT(image->texnum, textureTarget, GL_TEXTURE_WRAP_T, glWrapClampMode); - - if (cubemap) - qglTextureParameteriEXT(image->texnum, textureTarget, GL_TEXTURE_WRAP_R, glWrapClampMode); - - if (textureFilterAnisotropic && !cubemap) - qglTextureParameteriEXT(image->texnum, textureTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, - mipmap ? (GLint)Com_Clamp(1, maxAnisotropy, r_ext_max_anisotropy->integer) : 1); - - switch(internalFormat) - { - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16_ARB: - case GL_DEPTH_COMPONENT24_ARB: - case GL_DEPTH_COMPONENT32_ARB: - // Fix for sampling depth buffer on old nVidia cards. - // from http://www.idevgames.com/forums/thread-4141-post-34844.html#pid34844 - qglTextureParameterfEXT(image->texnum, textureTarget, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE); - qglTextureParameterfEXT(image->texnum, textureTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - qglTextureParameterfEXT(image->texnum, textureTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - break; - default: - qglTextureParameterfEXT(image->texnum, textureTarget, GL_TEXTURE_MIN_FILTER, mipmap ? gl_filter_min : GL_LINEAR); - qglTextureParameterfEXT(image->texnum, textureTarget, GL_TEXTURE_MAG_FILTER, mipmap ? gl_filter_max : GL_LINEAR); - break; - } - - GL_CheckErrors(); - - hash = generateHashValue(name); - image->next = hashTable[hash]; - hashTable[hash] = image; - - return image; -} - - -/* -================ -R_CreateImage - -Wrapper for R_CreateImage2(), for the old parameters. -================ -*/ -image_t *R_CreateImage(const char *name, byte *pic, int width, int height, imgType_t type, imgFlags_t flags, int internalFormat) -{ - return R_CreateImage2(name, pic, width, height, GL_RGBA8, 0, type, flags, internalFormat); -} - - -void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int height, GLenum picFormat ) -{ - Upload32(pic, x, y, width, height, picFormat, 0, image, qfalse); -} - -//=================================================================== - -// Prototype for dds loader function which isn't common to both renderers -void R_LoadDDS(const char *filename, byte **pic, int *width, int *height, GLenum *picFormat, int *numMips); - -typedef struct -{ - const char *ext; - void (*ImageLoader)( const char *, unsigned char **, int *, int * ); -} imageExtToLoaderMap_t; - -// Note that the ordering indicates the order of preference used -// when there are multiple images of different formats available -static const imageExtToLoaderMap_t imageLoaders[ ] = -{ - { "png", R_LoadPNG }, - { "tga", R_LoadTGA }, - { "jpg", R_LoadJPG }, - { "jpeg", R_LoadJPG }, - { "pcx", R_LoadPCX }, - { "bmp", R_LoadBMP } -}; - -static const int numImageLoaders = ARRAY_LEN( imageLoaders ); - -/* -================= -R_LoadImage - -Loads any of the supported image types into a canonical -32 bit format. -================= -*/ -static void R_LoadImage( const char *name, byte **pic, int *width, int *height, GLenum *picFormat, int *numMips ) -{ - qboolean orgNameFailed = qfalse; - int orgLoader = -1; - int i; - char localName[ MAX_QPATH ]; - const char *ext; - const char *altName; - - *pic = NULL; - *width = 0; - *height = 0; - *picFormat = GL_RGBA8; - *numMips = 0; - - Q_strncpyz( localName, name, sizeof( localName ) ); - - ext = COM_GetExtension( localName ); - - // If compressed textures are enabled, try loading a DDS first, it'll load fastest - if (r_ext_compressed_textures->integer) - { - char ddsName[MAX_QPATH]; - - COM_StripExtension(name, ddsName, MAX_QPATH); - Q_strcat(ddsName, MAX_QPATH, ".dds"); - - R_LoadDDS(ddsName, pic, width, height, picFormat, numMips); - - // If loaded, we're done. - if (*pic) - return; - } - - if( *ext ) - { - // Look for the correct loader and use it - for( i = 0; i < numImageLoaders; i++ ) - { - if( !Q_stricmp( ext, imageLoaders[ i ].ext ) ) - { - // Load - imageLoaders[ i ].ImageLoader( localName, pic, width, height ); - break; - } - } - - // A loader was found - if( i < numImageLoaders ) - { - if( *pic == NULL ) - { - // Loader failed, most likely because the file isn't there; - // try again without the extension - orgNameFailed = qtrue; - orgLoader = i; - COM_StripExtension( name, localName, MAX_QPATH ); - } - else - { - // Something loaded - return; - } - } - } - - // Try and find a suitable match using all - // the image formats supported - for( i = 0; i < numImageLoaders; i++ ) - { - if (i == orgLoader) - continue; - - altName = va( "%s.%s", localName, imageLoaders[ i ].ext ); - - // Load - imageLoaders[ i ].ImageLoader( altName, pic, width, height ); - - if( *pic ) - { - if( orgNameFailed ) - { - ri.Printf( PRINT_DEVELOPER, "WARNING: %s not present, using %s instead\n", - name, altName ); - } - - break; - } - } -} - - -/* -=============== -R_FindImageFile - -Finds or loads the given image. -Returns NULL if it fails, not a default image. -============== -*/ -image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags ) -{ - image_t *image; - int width, height; - byte *pic; - GLenum picFormat; - int picNumMips; - long hash; - imgFlags_t checkFlagsTrue, checkFlagsFalse; - - if (!name) { - return NULL; - } - - hash = generateHashValue(name); - - // - // see if the image is already loaded - // - for (image=hashTable[hash]; image; image=image->next) { - if ( !strcmp( name, image->imgName ) ) { - // the white image can be used with any set of parms, but other mismatches are errors - if ( strcmp( name, "*white" ) ) { - if ( image->flags != flags ) { - ri.Printf( PRINT_DEVELOPER, "WARNING: reused image %s with mixed flags (%i vs %i)\n", name, image->flags, flags ); - } - } - return image; - } - } - - // - // load the pic from disk - // - R_LoadImage( name, &pic, &width, &height, &picFormat, &picNumMips ); - if ( pic == NULL ) { - return NULL; - } - - checkFlagsTrue = IMGFLAG_PICMIP | IMGFLAG_MIPMAP | IMGFLAG_GENNORMALMAP; - checkFlagsFalse = IMGFLAG_CUBEMAP; - if (r_normalMapping->integer && (picFormat == GL_RGBA8) && (type == IMGTYPE_COLORALPHA) && - ((flags & checkFlagsTrue) == checkFlagsTrue) && !(flags & checkFlagsFalse)) - { - char normalName[MAX_QPATH]; - image_t *normalImage; - int normalWidth, normalHeight; - imgFlags_t normalFlags; - - normalFlags = (flags & ~IMGFLAG_GENNORMALMAP) | IMGFLAG_NOLIGHTSCALE; - - COM_StripExtension(name, normalName, MAX_QPATH); - Q_strcat(normalName, MAX_QPATH, "_n"); - - // find normalmap in case it's there - normalImage = R_FindImageFile(normalName, IMGTYPE_NORMAL, normalFlags); - - // if not, generate it - if (normalImage == NULL) - { - byte *normalPic; - int x, y; - - normalWidth = width; - normalHeight = height; - normalPic = ri.Malloc(width * height * 4); - RGBAtoNormal(pic, normalPic, width, height, flags & IMGFLAG_CLAMPTOEDGE); - -#if 1 - // Brighten up the original image to work with the normal map - RGBAtoYCoCgA(pic, pic, width, height); - for (y = 0; y < height; y++) - { - byte *picbyte = pic + y * width * 4; - byte *normbyte = normalPic + y * width * 4; - for (x = 0; x < width; x++) - { - int div = MAX(normbyte[2] - 127, 16); - picbyte[0] = CLAMP(picbyte[0] * 128 / div, 0, 255); - picbyte += 4; - normbyte += 4; - } - } - YCoCgAtoRGBA(pic, pic, width, height); -#else - // Blur original image's luma to work with the normal map - { - byte *blurPic; - - RGBAtoYCoCgA(pic, pic, width, height); - blurPic = ri.Malloc(width * height); - - for (y = 1; y < height - 1; y++) - { - byte *picbyte = pic + y * width * 4; - byte *blurbyte = blurPic + y * width; - - picbyte += 4; - blurbyte += 1; - - for (x = 1; x < width - 1; x++) - { - int result; - - result = *(picbyte - (width + 1) * 4) + *(picbyte - width * 4) + *(picbyte - (width - 1) * 4) + - *(picbyte - 1 * 4) + *(picbyte ) + *(picbyte + 1 * 4) + - *(picbyte + (width - 1) * 4) + *(picbyte + width * 4) + *(picbyte + (width + 1) * 4); - - result /= 9; - - *blurbyte = result; - picbyte += 4; - blurbyte += 1; - } - } - - // FIXME: do borders - - for (y = 1; y < height - 1; y++) - { - byte *picbyte = pic + y * width * 4; - byte *blurbyte = blurPic + y * width; - - picbyte += 4; - blurbyte += 1; - - for (x = 1; x < width - 1; x++) - { - picbyte[0] = *blurbyte; - picbyte += 4; - blurbyte += 1; - } - } - - ri.Free(blurPic); - - YCoCgAtoRGBA(pic, pic, width, height); - } -#endif - - R_CreateImage( normalName, normalPic, normalWidth, normalHeight, IMGTYPE_NORMAL, normalFlags, 0 ); - ri.Free( normalPic ); - } - } - - // force mipmaps off if image is compressed but doesn't have enough mips - if ((flags & IMGFLAG_MIPMAP) && picFormat != GL_RGBA8 && picFormat != GL_SRGB8_ALPHA8_EXT) - { - int wh = MAX(width, height); - int neededMips = 0; - while (wh) - { - neededMips++; - wh >>= 1; - } - if (neededMips > picNumMips) - flags &= ~IMGFLAG_MIPMAP; - } - - image = R_CreateImage2( ( char * ) name, pic, width, height, picFormat, picNumMips, type, flags, 0 ); - ri.Free( pic ); - return image; -} - - -/* -================ -R_CreateDlightImage -================ -*/ -#define DLIGHT_SIZE 16 -static void R_CreateDlightImage( void ) { - int x,y; - byte data[DLIGHT_SIZE][DLIGHT_SIZE][4]; - int b; - - // make a centered inverse-square falloff blob for dynamic lighting - for (x=0 ; x 255) { - b = 255; - } else if ( b < 75 ) { - b = 0; - } - data[y][x][0] = - data[y][x][1] = - data[y][x][2] = b; - data[y][x][3] = 255; - } - } - tr.dlightImage = R_CreateImage("*dlight", (byte *)data, DLIGHT_SIZE, DLIGHT_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_CLAMPTOEDGE, 0 ); -} - - -/* -================= -R_InitFogTable -================= -*/ -void R_InitFogTable( void ) { - int i; - float d; - float exp; - - exp = 0.5; - - for ( i = 0 ; i < FOG_TABLE_SIZE ; i++ ) { - d = powf( (float)i/(FOG_TABLE_SIZE-1), exp ); - - tr.fogTable[i] = d; - } -} - -/* -================ -R_FogFactor - -Returns a 0.0 to 1.0 fog density value -This is called for each texel of the fog texture on startup -and for each vertex of transparent shaders in fog dynamically -================ -*/ -float R_FogFactor( float s, float t ) { - float d; - - s -= 1.0/512; - if ( s < 0 ) { - return 0; - } - if ( t < 1.0/32 ) { - return 0; - } - if ( t < 31.0/32 ) { - s *= (t - 1.0f/32.0f) / (30.0f/32.0f); - } - - // we need to leave a lot of clamp range - s *= 8; - - if ( s > 1.0 ) { - s = 1.0; - } - - d = tr.fogTable[ (uint32_t)(s * (FOG_TABLE_SIZE-1)) ]; - - return d; -} - -/* -================ -R_CreateFogImage -================ -*/ -#define FOG_S 256 -#define FOG_T 32 -static void R_CreateFogImage( void ) { - int x,y; - byte *data; - float d; - - data = ri.Hunk_AllocateTempMemory( FOG_S * FOG_T * 4 ); - - // S is distance, T is depth - for (x=0 ; xinteger >= 2) - { - for( x = 0; x < MAX_DLIGHTS; x++) - { - tr.shadowCubemaps[x] = R_CreateImage(va("*shadowcubemap%i", x), NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_CLAMPTOEDGE | IMGFLAG_CUBEMAP, 0); - } - } - - // with overbright bits active, we need an image which is some fraction of full color, - // for default lightmaps, etc - for (x=0 ; xinteger && glRefConfig.textureFloat) - hdrFormat = GL_RGBA16F_ARB; - - rgbFormat = GL_RGBA8; - - tr.renderImage = R_CreateImage("_render", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - - if (r_shadowBlur->integer) - tr.screenScratchImage = R_CreateImage("screenScratch", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat); - - if (r_shadowBlur->integer || r_ssao->integer) - tr.hdrDepthImage = R_CreateImage("*hdrDepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_R32F); - - if (r_drawSunRays->integer) - tr.sunRaysImage = R_CreateImage("*sunRays", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat); - - tr.renderDepthImage = R_CreateImage("*renderdepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24); - tr.textureDepthImage = R_CreateImage("*texturedepth", NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24); - - { - void *p; - - data[0][0][0] = 0; - data[0][0][1] = 0.45f * 255; - data[0][0][2] = 255; - data[0][0][3] = 255; - p = data; - - tr.calcLevelsImage = R_CreateImage("*calcLevels", p, 1, 1, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - tr.targetLevelsImage = R_CreateImage("*targetLevels", p, 1, 1, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - tr.fixedLevelsImage = R_CreateImage("*fixedLevels", p, 1, 1, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - } - - for (x = 0; x < 2; x++) - { - tr.textureScratchImage[x] = R_CreateImage(va("*textureScratch%d", x), NULL, 256, 256, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); - } - for (x = 0; x < 2; x++) - { - tr.quarterImage[x] = R_CreateImage(va("*quarter%d", x), NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); - } - - if (r_ssao->integer) - { - tr.screenSsaoImage = R_CreateImage("*screenSsao", NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); - } - - for( x = 0; x < MAX_DRAWN_PSHADOWS; x++) - { - tr.pshadowMaps[x] = R_CreateImage(va("*shadowmap%i", x), NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24); - //qglTextureParameterfEXT(tr.pshadowMaps[x]->texnum, GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); - //qglTextureParameterfEXT(tr.pshadowMaps[x]->texnum, GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); - } - - if (r_sunlightMode->integer) - { - for ( x = 0; x < 4; x++) - { - tr.sunShadowDepthImage[x] = R_CreateImage(va("*sunshadowdepth%i", x), NULL, r_shadowMapSize->integer, r_shadowMapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24); - qglTextureParameterfEXT(tr.sunShadowDepthImage[x]->texnum, GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); - qglTextureParameterfEXT(tr.sunShadowDepthImage[x]->texnum, GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); - } - - tr.screenShadowImage = R_CreateImage("*screenShadow", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); - } - - if (r_cubeMapping->integer) - { - tr.renderCubeImage = R_CreateImage("*renderCube", NULL, r_cubemapSize->integer, r_cubemapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, rgbFormat); - } - } -} - - -/* -=============== -R_SetColorMappings -=============== -*/ -void R_SetColorMappings( void ) { - int i, j; - float g; - int inf; - - // setup the overbright lighting - tr.overbrightBits = r_overBrightBits->integer; - - // allow 2 overbright bits - if ( tr.overbrightBits > 2 ) { - tr.overbrightBits = 2; - } else if ( tr.overbrightBits < 0 ) { - tr.overbrightBits = 0; - } - - // don't allow more overbright bits than map overbright bits - if ( tr.overbrightBits > r_mapOverBrightBits->integer ) { - tr.overbrightBits = r_mapOverBrightBits->integer; - } - - tr.identityLight = 1.0f / ( 1 << tr.overbrightBits ); - tr.identityLightByte = 255 * tr.identityLight; - - - if ( r_intensity->value <= 1 ) { - ri.Cvar_Set( "r_intensity", "1" ); - } - - g = r_gamma->value; - - for ( i = 0; i < 256; i++ ) { - if ( g == 1 ) { - inf = i; - } else { - inf = 255 * powf( i/255.0f, 1.0f / g ) + 0.5f; - } - - if (inf < 0) { - inf = 0; - } - if (inf > 255) { - inf = 255; - } - s_gammatable[i] = inf; - } - - for (i=0 ; i<256 ; i++) { - j = i * r_intensity->value; - if (j > 255) { - j = 255; - } - s_intensitytable[i] = j; - } - - if ( glConfig.deviceSupportsGamma ) - { - ri.GLimp_SetGamma( s_gammatable, s_gammatable, s_gammatable ); - } -} - - -/* -=============== -R_InitImages -=============== -*/ -void R_InitImages( void ) { - Com_Memset(hashTable, 0, sizeof(hashTable)); - // build brightness translation tables - R_SetColorMappings(); - - // create default texture and white texture - R_CreateBuiltinImages(); -} - - -/* -=============== -R_DeleteTextures -=============== -*/ -void R_DeleteTextures( void ) { - int i; - - for ( i=0; itexnum ); - } - Com_Memset( tr.images, 0, sizeof( tr.images ) ); - - tr.numImages = 0; - - GL_BindNullTextures(); -} - -/* -============================================================================ - -SKINS - -============================================================================ -*/ - -/* -================== -CommaParse - -This is unfortunate, but the skin files aren't -compatible with our normal parsing rules. -================== -*/ -static char *CommaParse( const char **data_p ) { - int c = 0, len; - const char *data; - static char com_token[MAX_TOKEN_CHARS]; - - data = *data_p; - len = 0; - com_token[0] = 0; - - // make sure incoming data is valid - if ( !data ) { - *data_p = NULL; - return com_token; - } - - while ( 1 ) { - // skip whitespace - while( (c = *data) <= ' ') { - if( !c ) { - break; - } - data++; - } - - - c = *data; - - // skip double slash comments - if ( c == '/' && data[1] == '/' ) - { - data += 2; - while (*data && *data != '\n') { - data++; - } - } - // skip /* */ comments - else if ( c=='/' && data[1] == '*' ) - { - data += 2; - while ( *data && ( *data != '*' || data[1] != '/' ) ) - { - data++; - } - if ( *data ) - { - data += 2; - } - } - else - { - break; - } - } - - if ( c == 0 ) { - return ""; - } - - // handle quoted strings - if (c == '\"') - { - data++; - while (1) - { - c = *data++; - if (c=='\"' || !c) - { - com_token[len] = 0; - *data_p = ( char * ) data; - return com_token; - } - if (len < MAX_TOKEN_CHARS - 1) - { - com_token[len] = c; - len++; - } - } - } - - // parse a regular word - do - { - if (len < MAX_TOKEN_CHARS - 1) - { - com_token[len] = c; - len++; - } - data++; - c = *data; - } while (c>32 && c != ',' ); - - com_token[len] = 0; - - *data_p = ( char * ) data; - return com_token; -} - - -/* -=============== -RE_RegisterSkin - -=============== -*/ -qhandle_t RE_RegisterSkin( const char *name ) { - skinSurface_t parseSurfaces[MAX_SKIN_SURFACES]; - qhandle_t hSkin; - skin_t *skin; - skinSurface_t *surf; - union { - char *c; - void *v; - } text; - const char *text_p; - const char *token; - char surfName[MAX_QPATH]; - int totalSurfaces; - - if ( !name || !name[0] ) { - ri.Printf( PRINT_DEVELOPER, "Empty name passed to RE_RegisterSkin\n" ); - return 0; - } - - if ( strlen( name ) >= MAX_QPATH ) { - ri.Printf( PRINT_DEVELOPER, "Skin name exceeds MAX_QPATH\n" ); - return 0; - } - - - // see if the skin is already loaded - for ( hSkin = 1; hSkin < tr.numSkins ; hSkin++ ) { - skin = tr.skins[hSkin]; - if ( !Q_stricmp( skin->name, name ) ) { - if( skin->numSurfaces == 0 ) { - return 0; // default skin - } - return hSkin; - } - } - - // allocate a new skin - if ( tr.numSkins == MAX_SKINS ) { - ri.Printf( PRINT_WARNING, "WARNING: RE_RegisterSkin( '%s' ) MAX_SKINS hit\n", name ); - return 0; - } - tr.numSkins++; - skin = ri.Hunk_Alloc( sizeof( skin_t ), h_low ); - tr.skins[hSkin] = skin; - Q_strncpyz( skin->name, name, sizeof( skin->name ) ); - skin->numSurfaces = 0; - - R_IssuePendingRenderCommands(); - - // If not a .skin file, load as a single shader - if ( strcmp( name + strlen( name ) - 5, ".skin" ) ) { - skin->numSurfaces = 1; - skin->surfaces = ri.Hunk_Alloc( sizeof( skinSurface_t ), h_low ); - skin->surfaces[0].shader = R_FindShader( name, LIGHTMAP_NONE, qtrue ); - return hSkin; - } - - // load and parse the skin file - ri.FS_ReadFile( name, &text.v ); - if ( !text.c ) { - return 0; - } - - totalSurfaces = 0; - text_p = text.c; - while ( text_p && *text_p ) { - // get surface name - token = CommaParse( &text_p ); - Q_strncpyz( surfName, token, sizeof( surfName ) ); - - if ( !token[0] ) { - break; - } - // lowercase the surface name so skin compares are faster - Q_strlwr( surfName ); - - if ( *text_p == ',' ) { - text_p++; - } - - if ( strstr( token, "tag_" ) ) { - continue; - } - - // parse the shader name - token = CommaParse( &text_p ); - - if ( skin->numSurfaces < MAX_SKIN_SURFACES ) { - surf = &parseSurfaces[skin->numSurfaces]; - Q_strncpyz( surf->name, surfName, sizeof( surf->name ) ); - surf->shader = R_FindShader( token, LIGHTMAP_NONE, qtrue ); - skin->numSurfaces++; - } - - totalSurfaces++; - } - - ri.FS_FreeFile( text.v ); - - if ( totalSurfaces > MAX_SKIN_SURFACES ) { - ri.Printf( PRINT_WARNING, "WARNING: Ignoring excess surfaces (found %d, max is %d) in skin '%s'!\n", - totalSurfaces, MAX_SKIN_SURFACES, name ); - } - - // never let a skin have 0 shaders - if ( skin->numSurfaces == 0 ) { - return 0; // use default skin - } - - // copy surfaces to skin - skin->surfaces = ri.Hunk_Alloc( skin->numSurfaces * sizeof( skinSurface_t ), h_low ); - memcpy( skin->surfaces, parseSurfaces, skin->numSurfaces * sizeof( skinSurface_t ) ); - - return hSkin; -} - - -/* -=============== -R_InitSkins -=============== -*/ -void R_InitSkins( void ) { - skin_t *skin; - - tr.numSkins = 1; - - // make the default skin have all default shaders - skin = tr.skins[0] = ri.Hunk_Alloc( sizeof( skin_t ), h_low ); - Q_strncpyz( skin->name, "", sizeof( skin->name ) ); - skin->numSurfaces = 1; - skin->surfaces = ri.Hunk_Alloc( sizeof( skinSurface_t ), h_low ); - skin->surfaces[0].shader = tr.defaultShader; -} - -/* -=============== -R_GetSkinByHandle -=============== -*/ -skin_t *R_GetSkinByHandle( qhandle_t hSkin ) { - if ( hSkin < 1 || hSkin >= tr.numSkins ) { - return tr.skins[0]; - } - return tr.skins[ hSkin ]; -} - -/* -=============== -R_SkinList_f -=============== -*/ -void R_SkinList_f( void ) { - int i, j; - skin_t *skin; - - ri.Printf (PRINT_ALL, "------------------\n"); - - for ( i = 0 ; i < tr.numSkins ; i++ ) { - skin = tr.skins[i]; - - ri.Printf( PRINT_ALL, "%3i:%s (%d surfaces)\n", i, skin->name, skin->numSurfaces ); - for ( j = 0 ; j < skin->numSurfaces ; j++ ) { - ri.Printf( PRINT_ALL, " %s = %s\n", - skin->surfaces[j].name, skin->surfaces[j].shader->name ); - } - } - ri.Printf (PRINT_ALL, "------------------\n"); -} - - diff --git a/code/renderer2/tr_image_dds.c b/code/renderer2/tr_image_dds.c deleted file mode 100644 index 9cc0f67059..0000000000 --- a/code/renderer2/tr_image_dds.c +++ /dev/null @@ -1,498 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - 2015 James Canete - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ - -#include "tr_common.h" - -typedef unsigned int ui32_t; - -typedef struct ddsHeader_s -{ - ui32_t headerSize; - ui32_t flags; - ui32_t height; - ui32_t width; - ui32_t pitchOrFirstMipSize; - ui32_t volumeDepth; - ui32_t numMips; - ui32_t reserved1[11]; - ui32_t always_0x00000020; - ui32_t pixelFormatFlags; - ui32_t fourCC; - ui32_t rgbBitCount; - ui32_t rBitMask; - ui32_t gBitMask; - ui32_t bBitMask; - ui32_t aBitMask; - ui32_t caps; - ui32_t caps2; - ui32_t caps3; - ui32_t caps4; - ui32_t reserved2; -} -ddsHeader_t; - -// flags: -#define _DDSFLAGS_REQUIRED 0x001007 -#define _DDSFLAGS_PITCH 0x8 -#define _DDSFLAGS_MIPMAPCOUNT 0x20000 -#define _DDSFLAGS_FIRSTMIPSIZE 0x80000 -#define _DDSFLAGS_VOLUMEDEPTH 0x800000 - -// pixelFormatFlags: -#define DDSPF_ALPHAPIXELS 0x1 -#define DDSPF_ALPHA 0x2 -#define DDSPF_FOURCC 0x4 -#define DDSPF_RGB 0x40 -#define DDSPF_YUV 0x200 -#define DDSPF_LUMINANCE 0x20000 - -// caps: -#define DDSCAPS_COMPLEX 0x8 -#define DDSCAPS_MIPMAP 0x400000 -#define DDSCAPS_REQUIRED 0x1000 - -// caps2: -#define DDSCAPS2_CUBEMAP 0xFE00 -#define DDSCAPS2_VOLUME 0x200000 - -typedef struct ddsHeaderDxt10_s -{ - ui32_t dxgiFormat; - ui32_t dimensions; - ui32_t miscFlags; - ui32_t arraySize; - ui32_t miscFlags2; -} -ddsHeaderDxt10_t; - -// dxgiFormat -// from http://msdn.microsoft.com/en-us/library/windows/desktop/bb173059%28v=vs.85%29.aspx -typedef enum DXGI_FORMAT { - DXGI_FORMAT_UNKNOWN = 0, - DXGI_FORMAT_R32G32B32A32_TYPELESS = 1, - DXGI_FORMAT_R32G32B32A32_FLOAT = 2, - DXGI_FORMAT_R32G32B32A32_UINT = 3, - DXGI_FORMAT_R32G32B32A32_SINT = 4, - DXGI_FORMAT_R32G32B32_TYPELESS = 5, - DXGI_FORMAT_R32G32B32_FLOAT = 6, - DXGI_FORMAT_R32G32B32_UINT = 7, - DXGI_FORMAT_R32G32B32_SINT = 8, - DXGI_FORMAT_R16G16B16A16_TYPELESS = 9, - DXGI_FORMAT_R16G16B16A16_FLOAT = 10, - DXGI_FORMAT_R16G16B16A16_UNORM = 11, - DXGI_FORMAT_R16G16B16A16_UINT = 12, - DXGI_FORMAT_R16G16B16A16_SNORM = 13, - DXGI_FORMAT_R16G16B16A16_SINT = 14, - DXGI_FORMAT_R32G32_TYPELESS = 15, - DXGI_FORMAT_R32G32_FLOAT = 16, - DXGI_FORMAT_R32G32_UINT = 17, - DXGI_FORMAT_R32G32_SINT = 18, - DXGI_FORMAT_R32G8X24_TYPELESS = 19, - DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20, - DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21, - DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22, - DXGI_FORMAT_R10G10B10A2_TYPELESS = 23, - DXGI_FORMAT_R10G10B10A2_UNORM = 24, - DXGI_FORMAT_R10G10B10A2_UINT = 25, - DXGI_FORMAT_R11G11B10_FLOAT = 26, - DXGI_FORMAT_R8G8B8A8_TYPELESS = 27, - DXGI_FORMAT_R8G8B8A8_UNORM = 28, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29, - DXGI_FORMAT_R8G8B8A8_UINT = 30, - DXGI_FORMAT_R8G8B8A8_SNORM = 31, - DXGI_FORMAT_R8G8B8A8_SINT = 32, - DXGI_FORMAT_R16G16_TYPELESS = 33, - DXGI_FORMAT_R16G16_FLOAT = 34, - DXGI_FORMAT_R16G16_UNORM = 35, - DXGI_FORMAT_R16G16_UINT = 36, - DXGI_FORMAT_R16G16_SNORM = 37, - DXGI_FORMAT_R16G16_SINT = 38, - DXGI_FORMAT_R32_TYPELESS = 39, - DXGI_FORMAT_D32_FLOAT = 40, - DXGI_FORMAT_R32_FLOAT = 41, - DXGI_FORMAT_R32_UINT = 42, - DXGI_FORMAT_R32_SINT = 43, - DXGI_FORMAT_R24G8_TYPELESS = 44, - DXGI_FORMAT_D24_UNORM_S8_UINT = 45, - DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46, - DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47, - DXGI_FORMAT_R8G8_TYPELESS = 48, - DXGI_FORMAT_R8G8_UNORM = 49, - DXGI_FORMAT_R8G8_UINT = 50, - DXGI_FORMAT_R8G8_SNORM = 51, - DXGI_FORMAT_R8G8_SINT = 52, - DXGI_FORMAT_R16_TYPELESS = 53, - DXGI_FORMAT_R16_FLOAT = 54, - DXGI_FORMAT_D16_UNORM = 55, - DXGI_FORMAT_R16_UNORM = 56, - DXGI_FORMAT_R16_UINT = 57, - DXGI_FORMAT_R16_SNORM = 58, - DXGI_FORMAT_R16_SINT = 59, - DXGI_FORMAT_R8_TYPELESS = 60, - DXGI_FORMAT_R8_UNORM = 61, - DXGI_FORMAT_R8_UINT = 62, - DXGI_FORMAT_R8_SNORM = 63, - DXGI_FORMAT_R8_SINT = 64, - DXGI_FORMAT_A8_UNORM = 65, - DXGI_FORMAT_R1_UNORM = 66, - DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67, - DXGI_FORMAT_R8G8_B8G8_UNORM = 68, - DXGI_FORMAT_G8R8_G8B8_UNORM = 69, - DXGI_FORMAT_BC1_TYPELESS = 70, - DXGI_FORMAT_BC1_UNORM = 71, - DXGI_FORMAT_BC1_UNORM_SRGB = 72, - DXGI_FORMAT_BC2_TYPELESS = 73, - DXGI_FORMAT_BC2_UNORM = 74, - DXGI_FORMAT_BC2_UNORM_SRGB = 75, - DXGI_FORMAT_BC3_TYPELESS = 76, - DXGI_FORMAT_BC3_UNORM = 77, - DXGI_FORMAT_BC3_UNORM_SRGB = 78, - DXGI_FORMAT_BC4_TYPELESS = 79, - DXGI_FORMAT_BC4_UNORM = 80, - DXGI_FORMAT_BC4_SNORM = 81, - DXGI_FORMAT_BC5_TYPELESS = 82, - DXGI_FORMAT_BC5_UNORM = 83, - DXGI_FORMAT_BC5_SNORM = 84, - DXGI_FORMAT_B5G6R5_UNORM = 85, - DXGI_FORMAT_B5G5R5A1_UNORM = 86, - DXGI_FORMAT_B8G8R8A8_UNORM = 87, - DXGI_FORMAT_B8G8R8X8_UNORM = 88, - DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89, - DXGI_FORMAT_B8G8R8A8_TYPELESS = 90, - DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91, - DXGI_FORMAT_B8G8R8X8_TYPELESS = 92, - DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93, - DXGI_FORMAT_BC6H_TYPELESS = 94, - DXGI_FORMAT_BC6H_UF16 = 95, - DXGI_FORMAT_BC6H_SF16 = 96, - DXGI_FORMAT_BC7_TYPELESS = 97, - DXGI_FORMAT_BC7_UNORM = 98, - DXGI_FORMAT_BC7_UNORM_SRGB = 99, - DXGI_FORMAT_AYUV = 100, - DXGI_FORMAT_Y410 = 101, - DXGI_FORMAT_Y416 = 102, - DXGI_FORMAT_NV12 = 103, - DXGI_FORMAT_P010 = 104, - DXGI_FORMAT_P016 = 105, - DXGI_FORMAT_420_OPAQUE = 106, - DXGI_FORMAT_YUY2 = 107, - DXGI_FORMAT_Y210 = 108, - DXGI_FORMAT_Y216 = 109, - DXGI_FORMAT_NV11 = 110, - DXGI_FORMAT_AI44 = 111, - DXGI_FORMAT_IA44 = 112, - DXGI_FORMAT_P8 = 113, - DXGI_FORMAT_A8P8 = 114, - DXGI_FORMAT_B4G4R4A4_UNORM = 115, - DXGI_FORMAT_FORCE_UINT = 0xffffffffUL -} DXGI_FORMAT; - -#define EncodeFourCC(x) ((((ui32_t)((x)[0])) ) | \ - (((ui32_t)((x)[1])) << 8 ) | \ - (((ui32_t)((x)[2])) << 16) | \ - (((ui32_t)((x)[3])) << 24) ) - - -void R_LoadDDS ( const char *filename, byte **pic, int *width, int *height, GLenum *picFormat, int *numMips ) -{ - union { - byte *b; - void *v; - } buffer; - int len; - ddsHeader_t *ddsHeader = NULL; - ddsHeaderDxt10_t *ddsHeaderDxt10 = NULL; - byte *data; - - if (!picFormat) - { - ri.Printf(PRINT_ERROR, "R_LoadDDS() called without picFormat parameter!"); - return; - } - - if (width) - *width = 0; - if (height) - *height = 0; - if (picFormat) - *picFormat = GL_RGBA8; - if (numMips) - *numMips = 1; - - *pic = NULL; - - // - // load the file - // - len = ri.FS_ReadFile( ( char * ) filename, &buffer.v); - if (!buffer.b || len < 0) { - return; - } - - // - // reject files that are too small to hold even a header - // - if (len < 4 + sizeof(*ddsHeader)) - { - ri.Printf(PRINT_ALL, "File %s is too small to be a DDS file.\n", filename); - ri.FS_FreeFile(buffer.v); - return; - } - - // - // reject files that don't start with "DDS " - // - if (*((ui32_t *)(buffer.b)) != EncodeFourCC("DDS ")) - { - ri.Printf(PRINT_ALL, "File %s is not a DDS file.\n", filename); - ri.FS_FreeFile(buffer.v); - return; - } - - // - // parse header and dx10 header if available - // - ddsHeader = (ddsHeader_t *)(buffer.b + 4); - if ((ddsHeader->pixelFormatFlags & DDSPF_FOURCC) && ddsHeader->fourCC == EncodeFourCC("DX10")) - { - if (len < 4 + sizeof(*ddsHeader) + sizeof(*ddsHeaderDxt10)) - { - ri.Printf(PRINT_ALL, "File %s indicates a DX10 header it is too small to contain.\n", filename); - ri.FS_FreeFile(buffer.v); - return; - } - - ddsHeaderDxt10 = (ddsHeaderDxt10_t *)(buffer.b + 4 + sizeof(ddsHeader_t)); - data = buffer.b + 4 + sizeof(*ddsHeader) + sizeof(*ddsHeaderDxt10); - len -= 4 + sizeof(*ddsHeader) + sizeof(*ddsHeaderDxt10); - } - else - { - data = buffer.b + 4 + sizeof(*ddsHeader); - len -= 4 + sizeof(*ddsHeader); - } - - if (width) - *width = ddsHeader->width; - if (height) - *height = ddsHeader->height; - - if (numMips) - { - if (ddsHeader->flags & _DDSFLAGS_MIPMAPCOUNT) - *numMips = ddsHeader->numMips; - else - *numMips = 1; - } - - // FIXME: handle cube map - //if ((ddsHeader->caps2 & DDSCAPS2_CUBEMAP) == DDSCAPS2_CUBEMAP) - - // - // Convert DXGI format/FourCC into OpenGL format - // - if (ddsHeaderDxt10) - { - switch (ddsHeaderDxt10->dxgiFormat) - { - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - // FIXME: check for GL_COMPRESSED_RGBA_S3TC_DXT1_EXT - *picFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; - break; - - case DXGI_FORMAT_BC1_UNORM_SRGB: - // FIXME: check for GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT - *picFormat = GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; - break; - - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - *picFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - break; - - case DXGI_FORMAT_BC2_UNORM_SRGB: - *picFormat = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; - break; - - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - *picFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - break; - - case DXGI_FORMAT_BC3_UNORM_SRGB: - *picFormat = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; - break; - - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - *picFormat = GL_COMPRESSED_RED_RGTC1; - break; - - case DXGI_FORMAT_BC4_SNORM: - *picFormat = GL_COMPRESSED_SIGNED_RED_RGTC1; - break; - - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - *picFormat = GL_COMPRESSED_RG_RGTC2; - break; - - case DXGI_FORMAT_BC5_SNORM: - *picFormat = GL_COMPRESSED_SIGNED_RG_RGTC2; - break; - - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - *picFormat = GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB; - break; - - case DXGI_FORMAT_BC6H_SF16: - *picFormat = GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB; - break; - - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - *picFormat = GL_COMPRESSED_RGBA_BPTC_UNORM_ARB; - break; - - case DXGI_FORMAT_BC7_UNORM_SRGB: - *picFormat = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB; - break; - - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - *picFormat = GL_SRGB8_ALPHA8_EXT; - break; - - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_SNORM: - *picFormat = GL_RGBA8; - break; - - default: - ri.Printf(PRINT_ALL, "DDS File %s has unsupported DXGI format %d.", filename, ddsHeaderDxt10->dxgiFormat); - ri.FS_FreeFile(buffer.v); - return; - break; - } - } - else - { - if (ddsHeader->pixelFormatFlags & DDSPF_FOURCC) - { - if (ddsHeader->fourCC == EncodeFourCC("DXT1")) - *picFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; - else if (ddsHeader->fourCC == EncodeFourCC("DXT2")) - *picFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - else if (ddsHeader->fourCC == EncodeFourCC("DXT3")) - *picFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - else if (ddsHeader->fourCC == EncodeFourCC("DXT4")) - *picFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - else if (ddsHeader->fourCC == EncodeFourCC("DXT5")) - *picFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - else if (ddsHeader->fourCC == EncodeFourCC("ATI1")) - *picFormat = GL_COMPRESSED_RED_RGTC1; - else if (ddsHeader->fourCC == EncodeFourCC("BC4U")) - *picFormat = GL_COMPRESSED_RED_RGTC1; - else if (ddsHeader->fourCC == EncodeFourCC("BC4S")) - *picFormat = GL_COMPRESSED_SIGNED_RED_RGTC1; - else if (ddsHeader->fourCC == EncodeFourCC("ATI2")) - *picFormat = GL_COMPRESSED_RG_RGTC2; - else if (ddsHeader->fourCC == EncodeFourCC("BC5U")) - *picFormat = GL_COMPRESSED_RG_RGTC2; - else if (ddsHeader->fourCC == EncodeFourCC("BC5S")) - *picFormat = GL_COMPRESSED_SIGNED_RG_RGTC2; - else - { - ri.Printf(PRINT_ALL, "DDS File %s has unsupported FourCC.", filename); - ri.FS_FreeFile(buffer.v); - return; - } - } - else if (ddsHeader->pixelFormatFlags == (DDSPF_RGB | DDSPF_ALPHAPIXELS) - && ddsHeader->rgbBitCount == 32 - && ddsHeader->rBitMask == 0x000000ff - && ddsHeader->gBitMask == 0x0000ff00 - && ddsHeader->bBitMask == 0x00ff0000 - && ddsHeader->aBitMask == 0xff000000) - { - *picFormat = GL_RGBA8; - } - else - { - ri.Printf(PRINT_ALL, "DDS File %s has unsupported RGBA format.", filename); - ri.FS_FreeFile(buffer.v); - return; - } - } - - *pic = ri.Malloc(len); - Com_Memcpy(*pic, data, len); - - ri.FS_FreeFile(buffer.v); -} - -void R_SaveDDS(const char *filename, byte *pic, int width, int height, int depth) -{ - byte *data; - ddsHeader_t *ddsHeader; - int picSize, size; - - if (!depth) - depth = 1; - - picSize = width * height * depth * 4; - size = 4 + sizeof(*ddsHeader) + picSize; - data = ri.Malloc(size); - - data[0] = 'D'; - data[1] = 'D'; - data[2] = 'S'; - data[3] = ' '; - - ddsHeader = (ddsHeader_t *)(data + 4); - memset(ddsHeader, 0, sizeof(ddsHeader_t)); - - ddsHeader->headerSize = 0x7c; - ddsHeader->flags = _DDSFLAGS_REQUIRED; - ddsHeader->height = height; - ddsHeader->width = width; - ddsHeader->always_0x00000020 = 0x00000020; - ddsHeader->caps = DDSCAPS_COMPLEX | DDSCAPS_REQUIRED; - - if (depth == 6) - ddsHeader->caps2 = DDSCAPS2_CUBEMAP; - - ddsHeader->pixelFormatFlags = DDSPF_RGB | DDSPF_ALPHAPIXELS; - ddsHeader->rgbBitCount = 32; - ddsHeader->rBitMask = 0x000000ff; - ddsHeader->gBitMask = 0x0000ff00; - ddsHeader->bBitMask = 0x00ff0000; - ddsHeader->aBitMask = 0xff000000; - - Com_Memcpy(data + 4 + sizeof(*ddsHeader), pic, picSize); - - ri.FS_WriteFile(filename, data, size); - - ri.Free(data); -} diff --git a/code/renderer2/tr_init.c b/code/renderer2/tr_init.c deleted file mode 100644 index b212997e2c..0000000000 --- a/code/renderer2/tr_init.c +++ /dev/null @@ -1,1677 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_init.c -- functions that are not called every frame - -#include "tr_local.h" - -#include "tr_dsa.h" - -glconfig_t glConfig; -glRefConfig_t glRefConfig; -qboolean textureFilterAnisotropic = qfalse; -int maxAnisotropy = 0; - -glstate_t glState; - -static void GfxInfo_f( void ); -static void GfxMemInfo_f( void ); - -cvar_t *r_flareSize; -cvar_t *r_flareFade; -cvar_t *r_flareCoeff; - -cvar_t *r_railWidth; -cvar_t *r_railCoreWidth; -cvar_t *r_railSegmentLength; - -cvar_t *r_ignore; - -cvar_t *r_detailTextures; - -cvar_t *r_znear; -cvar_t *r_zproj; -cvar_t *r_stereoSeparation; - -cvar_t *r_skipBackEnd; - -cvar_t *r_anaglyphMode; - -cvar_t *r_greyscale; - -cvar_t *r_ignorehwgamma; -cvar_t *r_measureOverdraw; - -cvar_t *r_teleporterFlash; - -cvar_t *r_fastsky; -cvar_t *r_drawSun; -cvar_t *r_dynamiclight; -cvar_t *r_dlightBacks; - -cvar_t *r_lodbias; -cvar_t *r_lodscale; - -cvar_t *r_norefresh; -cvar_t *r_drawentities; -cvar_t *r_drawworld; -cvar_t *r_speeds; -cvar_t *r_fullbright; -cvar_t *r_novis; -cvar_t *r_nocull; -cvar_t *r_facePlaneCull; -cvar_t *r_showcluster; -cvar_t *r_nocurves; - -cvar_t *r_allowExtensions; - -cvar_t *r_ext_compressed_textures; -cvar_t *r_ext_multitexture; -cvar_t *r_ext_compiled_vertex_array; -cvar_t *r_ext_texture_env_add; -cvar_t *r_ext_texture_filter_anisotropic; -cvar_t *r_ext_max_anisotropy; - -cvar_t *r_ext_framebuffer_object; -cvar_t *r_ext_texture_float; -cvar_t *r_ext_framebuffer_multisample; -cvar_t *r_arb_seamless_cube_map; -cvar_t *r_arb_vertex_array_object; -cvar_t *r_ext_direct_state_access; - -cvar_t *r_cameraExposure; - -cvar_t *r_externalGLSL; - -cvar_t *r_hdr; -cvar_t *r_floatLightmap; -cvar_t *r_postProcess; - -cvar_t *r_toneMap; -cvar_t *r_forceToneMap; -cvar_t *r_forceToneMapMin; -cvar_t *r_forceToneMapAvg; -cvar_t *r_forceToneMapMax; - -cvar_t *r_autoExposure; -cvar_t *r_forceAutoExposure; -cvar_t *r_forceAutoExposureMin; -cvar_t *r_forceAutoExposureMax; - -cvar_t *r_depthPrepass; -cvar_t *r_ssao; - -cvar_t *r_normalMapping; -cvar_t *r_specularMapping; -cvar_t *r_deluxeMapping; -cvar_t *r_parallaxMapping; -cvar_t *r_parallaxMapOffset; -cvar_t *r_parallaxMapShadows; -cvar_t *r_cubeMapping; -cvar_t *r_cubemapSize; -cvar_t *r_deluxeSpecular; -cvar_t *r_pbr; -cvar_t *r_baseNormalX; -cvar_t *r_baseNormalY; -cvar_t *r_baseParallax; -cvar_t *r_baseSpecular; -cvar_t *r_baseGloss; -cvar_t *r_glossType; -cvar_t *r_mergeLightmaps; -cvar_t *r_dlightMode; -cvar_t *r_pshadowDist; -cvar_t *r_imageUpsample; -cvar_t *r_imageUpsampleMaxSize; -cvar_t *r_imageUpsampleType; -cvar_t *r_genNormalMaps; -cvar_t *r_forceSun; -cvar_t *r_forceSunLightScale; -cvar_t *r_forceSunAmbientScale; -cvar_t *r_sunlightMode; -cvar_t *r_drawSunRays; -cvar_t *r_sunShadows; -cvar_t *r_shadowFilter; -cvar_t *r_shadowBlur; -cvar_t *r_shadowMapSize; -cvar_t *r_shadowCascadeZNear; -cvar_t *r_shadowCascadeZFar; -cvar_t *r_shadowCascadeZBias; -cvar_t *r_ignoreDstAlpha; - -cvar_t *r_ignoreGLErrors; -cvar_t *r_logFile; - -//cvar_t *r_stencilbits; -cvar_t *r_texturebits; -cvar_t *r_ext_multisample; - -cvar_t *r_drawBuffer; -cvar_t *r_lightmap; -cvar_t *r_vertexLight; -cvar_t *r_shadows; -cvar_t *r_flares; -cvar_t *r_nobind; -cvar_t *r_singleShader; -cvar_t *r_roundImagesDown; -cvar_t *r_colorMipLevels; -cvar_t *r_picmip; -cvar_t *r_showtris; -cvar_t *r_showsky; -cvar_t *r_shownormals; -cvar_t *r_finish; -cvar_t *r_clear; -cvar_t *r_textureMode; -cvar_t *r_offsetFactor; -cvar_t *r_offsetUnits; -cvar_t *r_gamma; -cvar_t *r_intensity; -cvar_t *r_lockpvs; -cvar_t *r_noportals; -cvar_t *r_portalOnly; - -cvar_t *r_subdivisions; -cvar_t *r_lodCurveError; - -cvar_t *r_overBrightBits; -cvar_t *r_mapOverBrightBits; - -cvar_t *r_debugSurface; -cvar_t *r_simpleMipMaps; - -cvar_t *r_showImages; - -cvar_t *r_ambientScale; -cvar_t *r_directedScale; -cvar_t *r_debugLight; -cvar_t *r_debugSort; -cvar_t *r_printShaders; -cvar_t *r_saveFontData; - -cvar_t *r_marksOnTriangleMeshes; - -cvar_t *r_aviMotionJpegQuality; -cvar_t *r_screenshotJpegQuality; - -static cvar_t *r_maxpolys; -static cvar_t* r_maxpolyverts; -int max_polys; -int max_polyverts; - - -// for modular renderer -#ifdef USE_RENDERER_DLOPEN -void QDECL Com_Error( errorParm_t code, const char *fmt, ... ) -{ - char buf[ 4096 ]; - va_list argptr; - va_start( argptr, fmt ); - Q_vsnprintf( buf, sizeof( buf ), fmt, argptr ); - va_end( argptr ); - ri.Error( code, "%s", buf ); -} - -void QDECL Com_Printf( const char *fmt, ... ) -{ - char buf[ MAXPRINTMSG ]; - va_list argptr; - va_start( argptr, fmt ); - Q_vsnprintf( buf, sizeof( buf ), fmt, argptr ); - va_end( argptr ); - - ri.Printf( PRINT_ALL, "%s", buf ); -} -#endif - - -/* -** InitOpenGL -** -** This function is responsible for initializing a valid OpenGL subsystem. This -** is done by calling GLimp_Init (which gives us a working OGL subsystem) then -** setting variables, checking GL constants, and reporting the gfx system config -** to the user. -*/ -static void InitOpenGL( void ) -{ - char renderer_buffer[1024]; - - // - // initialize OS specific portions of the renderer - // - // GLimp_Init directly or indirectly references the following cvars: - // - r_fullscreen - // - r_mode - // - r_(color|depth|stencil)bits - // - r_ignorehwgamma - // - r_gamma - // - - if ( glConfig.vidWidth == 0 ) - { - GLint temp; - - if ( !ri.GLimp_Init ) - { - ri.Error( ERR_FATAL, "OpenGL interface is not initialized" ); - } - - ri.GLimp_Init( &glConfig ); - GLimp_InitExtraExtensions(); - - glConfig.textureEnvAddAvailable = qtrue; - - strcpy( renderer_buffer, glConfig.renderer_string ); - Q_strlwr( renderer_buffer ); - - // OpenGL driver constants - qglGetIntegerv( GL_MAX_TEXTURE_SIZE, &temp ); - glConfig.maxTextureSize = temp; - - // stubbed or broken drivers may have reported 0... - if ( glConfig.maxTextureSize <= 0 ) - { - glConfig.maxTextureSize = 0; - } - - ri.CL_SetScaling( 1.0, glConfig.vidWidth, glConfig.vidHeight ); - - qglGetIntegerv( GL_MAX_TEXTURE_IMAGE_UNITS, &temp ); - glConfig.numTextureUnits = temp; - - // reserve 160 components for other uniforms - qglGetIntegerv( GL_MAX_VERTEX_UNIFORM_COMPONENTS, &temp ); - glRefConfig.glslMaxAnimatedBones = Com_Clamp( 0, IQM_MAX_JOINTS, ( temp - 160 ) / 16 ); - if ( glRefConfig.glslMaxAnimatedBones < 12 ) { - glRefConfig.glslMaxAnimatedBones = 0; - } - } - - // check for GLSL function textureCubeLod() - if ( r_cubeMapping->integer && !QGL_VERSION_ATLEAST( 3, 0 ) ) { - ri.Printf( PRINT_WARNING, "WARNING: Disabled r_cubeMapping because it requires OpenGL 3.0\n" ); - ri.Cvar_Set( "r_cubeMapping", "0" ); - } - - // set default state - GL_SetDefaultState(); -} - - -/* -================== -GL_CheckErrors -================== -*/ -void GL_CheckErrs( char *file, int line ) { - int err; - char s[64]; - - err = qglGetError(); - if ( err == GL_NO_ERROR ) { - return; - } - if ( r_ignoreGLErrors->integer ) { - return; - } - switch( err ) { - case GL_INVALID_ENUM: - strcpy( s, "GL_INVALID_ENUM" ); - break; - case GL_INVALID_VALUE: - strcpy( s, "GL_INVALID_VALUE" ); - break; - case GL_INVALID_OPERATION: - strcpy( s, "GL_INVALID_OPERATION" ); - break; - case GL_STACK_OVERFLOW: - strcpy( s, "GL_STACK_OVERFLOW" ); - break; - case GL_STACK_UNDERFLOW: - strcpy( s, "GL_STACK_UNDERFLOW" ); - break; - case GL_OUT_OF_MEMORY: - strcpy( s, "GL_OUT_OF_MEMORY" ); - break; - default: - Com_sprintf( s, sizeof(s), "%i", err); - break; - } - - ri.Error( ERR_FATAL, "GL_CheckErrors: %s in %s at line %d", s , file, line); -} - - -/* -============================================================================== - - SCREEN SHOTS - -NOTE TTimo -some thoughts about the screenshots system: -screenshots get written in fs_homepath + fs_gamedir -vanilla q3 .. baseq3/screenshots/ *.tga -team arena .. missionpack/screenshots/ *.tga - -two commands: "screenshot" and "screenshotJPEG" -we use statics to store a count and start writing the first screenshot/screenshot????.tga (.jpg) available -(with FS_FileExists / FS_FOpenFileWrite calls) -FIXME: the statics don't get a reinit between fs_game changes - -============================================================================== -*/ - -/* -================== -RB_ReadPixels - -Reads an image but takes care of alignment issues for reading RGB images. - -Reads a minimum offset for where the RGB data starts in the image from -integer stored at pointer offset. When the function has returned the actual -offset was written back to address offset. This address will always have an -alignment of packAlign to ensure efficient copying. - -Stores the length of padding after a line of pixels to address padlen - -Return value must be freed with ri.Hunk_FreeTempMemory() -================== -*/ - -static byte *RB_ReadPixels(int x, int y, int width, int height, size_t *offset, int *padlen) -{ - byte *buffer, *bufstart; - int padwidth, linelen; - GLint packAlign; - - qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign); - - linelen = width * 3; - padwidth = PAD(linelen, packAlign); - - // Allocate a few more bytes so that we can choose an alignment we like - buffer = ri.Hunk_AllocateTempMemory(padwidth * height + *offset + packAlign - 1); - - bufstart = PADP((intptr_t) buffer + *offset, packAlign); - - qglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, bufstart); - - *offset = bufstart - buffer; - *padlen = padwidth - linelen; - - return buffer; -} - -/* -================== -RB_TakeScreenshot -================== -*/ -static void RB_TakeScreenshot(int x, int y, int width, int height, const char *fileName) -{ - byte *allbuf, *buffer; - byte *srcptr, *destptr; - byte *endline, *endmem; - byte temp; - - int linelen, padlen; - size_t offset = 18, memcount; - - allbuf = RB_ReadPixels(x, y, width, height, &offset, &padlen); - buffer = allbuf + offset - 18; - - Com_Memset (buffer, 0, 18); - buffer[2] = 2; // uncompressed type - buffer[12] = width & 255; - buffer[13] = width >> 8; - buffer[14] = height & 255; - buffer[15] = height >> 8; - buffer[16] = 24; // pixel size - - // swap rgb to bgr and remove padding from line endings - linelen = width * 3; - - srcptr = destptr = allbuf + offset; - endmem = srcptr + (linelen + padlen) * height; - - while(srcptr < endmem) - { - endline = srcptr + linelen; - - while(srcptr < endline) - { - temp = srcptr[0]; - *destptr++ = srcptr[2]; - *destptr++ = srcptr[1]; - *destptr++ = temp; - - srcptr += 3; - } - - // Skip the pad - srcptr += padlen; - } - - memcount = linelen * height; - - // gamma correction - if(glConfig.deviceSupportsGamma) - R_GammaCorrect(allbuf + offset, memcount); - - ri.FS_WriteFile(fileName, buffer, memcount + 18); - - ri.Hunk_FreeTempMemory(allbuf); -} - -/* -================== -RB_TakeScreenshotJPEG -================== -*/ - -static void RB_TakeScreenshotJPEG(int x, int y, int width, int height, const char *fileName) -{ - byte *buffer; - size_t offset = 0, memcount; - int padlen; - - buffer = RB_ReadPixels(x, y, width, height, &offset, &padlen); - memcount = (width * 3 + padlen) * height; - - // gamma correction - if(glConfig.deviceSupportsGamma) - R_GammaCorrect(buffer + offset, memcount); - - ri.CL_SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, buffer + offset, padlen); - ri.Hunk_FreeTempMemory(buffer); -} - -/* -================== -RB_TakeScreenshotCmd -================== -*/ -const void *RB_TakeScreenshotCmd( const void *data ) { - const screenshotCommand_t *cmd; - - cmd = (const screenshotCommand_t *)data; - - // finish any 2D drawing if needed - if(tess.numIndexes) - RB_EndSurface(); - - if (cmd->jpeg) - RB_TakeScreenshotJPEG( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName); - else - RB_TakeScreenshot( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName); - - return (const void *)(cmd + 1); -} - -/* -================== -R_TakeScreenshot -================== -*/ -static void R_TakeScreenshot( int x, int y, int width, int height, char *name, qboolean jpeg ) { - static char fileName[MAX_OSPATH]; // bad things if two screenshots per frame? - screenshotCommand_t *cmd; - - cmd = R_GetCommandBuffer( sizeof( *cmd ) ); - if ( !cmd ) { - return; - } - cmd->commandId = RC_SCREENSHOT; - - cmd->x = x; - cmd->y = y; - cmd->width = width; - cmd->height = height; - Q_strncpyz( fileName, name, sizeof(fileName) ); - cmd->fileName = fileName; - cmd->jpeg = jpeg; -} - -/* -================== -R_ScreenshotFilename -================== -*/ -static void R_ScreenshotFilename( int lastNumber, char *fileName ) { - int a,b,c,d; - - if ( lastNumber < 0 || lastNumber > 9999 ) { - Com_sprintf( fileName, MAX_OSPATH, "screenshots/shot9999.tga" ); - return; - } - - a = lastNumber / 1000; - lastNumber -= a*1000; - b = lastNumber / 100; - lastNumber -= b*100; - c = lastNumber / 10; - lastNumber -= c*10; - d = lastNumber; - - Com_sprintf( fileName, MAX_OSPATH, "screenshots/shot%i%i%i%i.tga" - , a, b, c, d ); -} - -/* -================== -R_ScreenshotFilename -================== -*/ -static void R_ScreenshotFilenameJPEG( int lastNumber, char *fileName ) { - int a,b,c,d; - - if ( lastNumber < 0 || lastNumber > 9999 ) { - Com_sprintf( fileName, MAX_OSPATH, "screenshots/shot9999.jpg" ); - return; - } - - a = lastNumber / 1000; - lastNumber -= a*1000; - b = lastNumber / 100; - lastNumber -= b*100; - c = lastNumber / 10; - lastNumber -= c*10; - d = lastNumber; - - Com_sprintf( fileName, MAX_OSPATH, "screenshots/shot%i%i%i%i.jpg" - , a, b, c, d ); -} - -/* -==================== -R_LevelShot - -levelshots are specialized 128*128 thumbnails for -the menu system, sampled down from full screen distorted images -==================== -*/ -static void R_LevelShot( void ) { - char checkname[MAX_OSPATH]; - byte *buffer; - byte *source, *allsource; - byte *src, *dst; - size_t offset = 0; - int padlen; - int x, y; - int r, g, b; - float xScale, yScale; - int xx, yy; - - Com_sprintf(checkname, sizeof(checkname), "levelshots/%s.tga", tr.world->baseName); - - allsource = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &padlen); - source = allsource + offset; - - buffer = ri.Hunk_AllocateTempMemory(128 * 128*3 + 18); - Com_Memset (buffer, 0, 18); - buffer[2] = 2; // uncompressed type - buffer[12] = 128; - buffer[14] = 128; - buffer[16] = 24; // pixel size - - // resample from source - xScale = glConfig.vidWidth / 512.0f; - yScale = glConfig.vidHeight / 384.0f; - for ( y = 0 ; y < 128 ; y++ ) { - for ( x = 0 ; x < 128 ; x++ ) { - r = g = b = 0; - for ( yy = 0 ; yy < 3 ; yy++ ) { - for ( xx = 0 ; xx < 4 ; xx++ ) { - src = source + (3 * glConfig.vidWidth + padlen) * (int)((y*3 + yy) * yScale) + - 3 * (int) ((x*4 + xx) * xScale); - r += src[0]; - g += src[1]; - b += src[2]; - } - } - dst = buffer + 18 + 3 * ( y * 128 + x ); - dst[0] = b / 12; - dst[1] = g / 12; - dst[2] = r / 12; - } - } - - // gamma correction - if ( glConfig.deviceSupportsGamma ) { - R_GammaCorrect( buffer + 18, 128 * 128 * 3 ); - } - - ri.FS_WriteFile( checkname, buffer, 128 * 128*3 + 18 ); - - ri.Hunk_FreeTempMemory(buffer); - ri.Hunk_FreeTempMemory(allsource); - - ri.Printf( PRINT_ALL, "Wrote %s\n", checkname ); -} - -/* -================== -R_ScreenShot_f - -screenshot -screenshot [silent] -screenshot [levelshot] -screenshot [filename] - -Doesn't print the pacifier message if there is a second arg -================== -*/ -static void R_ScreenShot_f (void) { - char checkname[MAX_OSPATH]; - static int lastNumber = -1; - qboolean silent; - - if ( !strcmp( ri.Cmd_Argv(1), "levelshot" ) ) { - R_LevelShot(); - return; - } - - if ( !strcmp( ri.Cmd_Argv(1), "silent" ) ) { - silent = qtrue; - } else { - silent = qfalse; - } - - if ( ri.Cmd_Argc() == 2 && !silent ) { - // explicit filename - Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.tga", ri.Cmd_Argv( 1 ) ); - } else { - // scan for a free filename - - // if we have saved a previous screenshot, don't scan - // again, because recording demo avis can involve - // thousands of shots - if ( lastNumber == -1 ) { - lastNumber = 0; - } - // scan for a free number - for ( ; lastNumber <= 9999 ; lastNumber++ ) { - R_ScreenshotFilename( lastNumber, checkname ); - - if (!ri.FS_FileExists( checkname )) - { - break; // file doesn't exist - } - } - - if ( lastNumber >= 9999 ) { - ri.Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n"); - return; - } - - lastNumber++; - } - - R_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, qfalse ); - - if ( !silent ) { - ri.Printf (PRINT_ALL, "Wrote %s\n", checkname); - } -} - -static void R_ScreenShotJPEG_f (void) { - char checkname[MAX_OSPATH]; - static int lastNumber = -1; - qboolean silent; - - if ( !strcmp( ri.Cmd_Argv(1), "levelshot" ) ) { - R_LevelShot(); - return; - } - - if ( !strcmp( ri.Cmd_Argv(1), "silent" ) ) { - silent = qtrue; - } else { - silent = qfalse; - } - - if ( ri.Cmd_Argc() == 2 && !silent ) { - // explicit filename - Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.jpg", ri.Cmd_Argv( 1 ) ); - } else { - // scan for a free filename - - // if we have saved a previous screenshot, don't scan - // again, because recording demo avis can involve - // thousands of shots - if ( lastNumber == -1 ) { - lastNumber = 0; - } - // scan for a free number - for ( ; lastNumber <= 9999 ; lastNumber++ ) { - R_ScreenshotFilenameJPEG( lastNumber, checkname ); - - if (!ri.FS_FileExists( checkname )) - { - break; // file doesn't exist - } - } - - if ( lastNumber == 10000 ) { - ri.Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n"); - return; - } - - lastNumber++; - } - - R_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, qtrue ); - - if ( !silent ) { - ri.Printf (PRINT_ALL, "Wrote %s\n", checkname); - } -} - -//============================================================================ - -/* -================== -R_ExportCubemaps -================== -*/ -static void R_ExportCubemaps(void) -{ - exportCubemapsCommand_t *cmd; - - cmd = R_GetCommandBuffer(sizeof(*cmd)); - if (!cmd) { - return; - } - cmd->commandId = RC_EXPORT_CUBEMAPS; -} - - -/* -================== -R_ExportCubemaps_f -================== -*/ -static void R_ExportCubemaps_f(void) -{ - R_ExportCubemaps(); -} - -//============================================================================ - -/* -================== -RB_TakeVideoFrameCmd -================== -*/ -const void *RB_TakeVideoFrameCmd( const void *data ) -{ - const videoFrameCommand_t *cmd; - byte *cBuf; - size_t memcount, linelen; - int padwidth, avipadwidth, padlen, avipadlen; - GLint packAlign; - - // finish any 2D drawing if needed - if(tess.numIndexes) - RB_EndSurface(); - - cmd = (const videoFrameCommand_t *)data; - - qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign); - - linelen = cmd->width * 3; - - // Alignment stuff for glReadPixels - padwidth = PAD(linelen, packAlign); - padlen = padwidth - linelen; - // AVI line padding - avipadwidth = PAD(linelen, AVI_LINE_PADDING); - avipadlen = avipadwidth - linelen; - - cBuf = PADP(cmd->captureBuffer, packAlign); - - qglReadPixels(0, 0, cmd->width, cmd->height, GL_RGB, - GL_UNSIGNED_BYTE, cBuf); - - memcount = padwidth * cmd->height; - - // gamma correction - if(glConfig.deviceSupportsGamma) - R_GammaCorrect(cBuf, memcount); - - if(cmd->motionJpeg) - { - memcount = ri.CL_SaveJPGToBuffer(cmd->encodeBuffer, linelen * cmd->height, - r_aviMotionJpegQuality->integer, - cmd->width, cmd->height, cBuf, padlen); - ri.CL_WriteAVIVideoFrame(cmd->encodeBuffer, memcount); - } - else - { - byte *lineend, *memend; - byte *srcptr, *destptr; - - srcptr = cBuf; - destptr = cmd->encodeBuffer; - memend = srcptr + memcount; - - // swap R and B and remove line paddings - while(srcptr < memend) - { - lineend = srcptr + linelen; - while(srcptr < lineend) - { - *destptr++ = srcptr[2]; - *destptr++ = srcptr[1]; - *destptr++ = srcptr[0]; - srcptr += 3; - } - - Com_Memset(destptr, '\0', avipadlen); - destptr += avipadlen; - - srcptr += padlen; - } - - ri.CL_WriteAVIVideoFrame(cmd->encodeBuffer, avipadwidth * cmd->height); - } - - return (const void *)(cmd + 1); -} - -//============================================================================ - -/* -** GL_SetDefaultState -*/ -void GL_SetDefaultState( void ) -{ - qglClearDepth( 1.0f ); - - qglCullFace(GL_FRONT); - - GL_BindNullTextures(); - - if (glRefConfig.framebufferObject) - GL_BindNullFramebuffers(); - - GL_TextureMode( r_textureMode->string ); - - //qglShadeModel( GL_SMOOTH ); - qglDepthFunc( GL_LEQUAL ); - - // - // make sure our GL state vector is set correctly - // - glState.glStateBits = GLS_DEPTHTEST_DISABLE | GLS_DEPTHMASK_TRUE; - glState.storedGlState = 0; - glState.faceCulling = CT_TWO_SIDED; - glState.faceCullFront = qtrue; - - GL_BindNullProgram(); - - if (glRefConfig.vertexArrayObject) - qglBindVertexArray(0); - - qglBindBuffer(GL_ARRAY_BUFFER, 0); - qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glState.currentVao = NULL; - glState.vertexAttribsEnabled = 0; - - qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL); - qglDepthMask( GL_TRUE ); - qglDisable( GL_DEPTH_TEST ); - qglEnable( GL_SCISSOR_TEST ); - qglDisable( GL_CULL_FACE ); - qglDisable( GL_BLEND ); - - if (glRefConfig.seamlessCubeMap) - qglEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); - - // GL_POLYGON_OFFSET_FILL will be glEnable()d when this is used - qglPolygonOffset( r_offsetFactor->value, r_offsetUnits->value ); - - qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); // FIXME: get color of sky -} - -/* -================ -R_PrintLongString - -Workaround for ri.Printf's 1024 characters buffer limit. -================ -*/ -static void R_PrintLongString(const char *string) { - char buffer[1024]; - const char *p; - int size = strlen(string); - - p = string; - while(size > 0) - { - Q_strncpyz(buffer, p, sizeof (buffer) ); - ri.Printf( PRINT_DEVELOPER, "%s", buffer ); - p += 1023; - size -= 1023; - } -} - -/* -================ -GfxInfo_f -================ -*/ -static void GfxInfo_f( void ) -{ - const char *enablestrings[] = - { - "disabled", - "enabled" - }; - const char *fsstrings[] = - { - "windowed", - "fullscreen" - }; - - ri.Printf( PRINT_ALL, "\nGL_VENDOR: %s\n", glConfig.vendor_string ); - ri.Printf( PRINT_ALL, "GL_RENDERER: %s\n", glConfig.renderer_string ); - ri.Printf( PRINT_ALL, "GL_VERSION: %s\n", glConfig.version_string ); - ri.Printf( PRINT_ALL, "GL_EXTENSIONS: " ); - if ( qglGetStringi ) - { - GLint numExtensions; - int i; - - qglGetIntegerv( GL_NUM_EXTENSIONS, &numExtensions ); - for ( i = 0; i < numExtensions; i++ ) - { - ri.Printf( PRINT_ALL, "%s ", qglGetStringi( GL_EXTENSIONS, i ) ); - } - } - else - { - R_PrintLongString( glConfig.extensions_string ); - } - ri.Printf( PRINT_ALL, "\n" ); - ri.Printf( PRINT_ALL, "GL_MAX_TEXTURE_SIZE: %d\n", glConfig.maxTextureSize ); - ri.Printf( PRINT_ALL, "GL_MAX_TEXTURE_IMAGE_UNITS: %d\n", glConfig.numTextureUnits ); - ri.Printf( PRINT_ALL, "\nPIXELFORMAT: color(%d-bits) Z(%d-bit) stencil(%d-bits)\n", glConfig.colorBits, glConfig.depthBits, glConfig.stencilBits ); - ri.Printf( PRINT_ALL, "MODE: %d, %d x %d %s hz:", ri.Cvar_VariableIntegerValue( "r_mode" ), glConfig.vidWidth, glConfig.vidHeight, fsstrings[ glConfig.isFullscreen != 0 ] ); - if ( glConfig.displayFrequency ) - { - ri.Printf( PRINT_ALL, "%d\n", glConfig.displayFrequency ); - } - else - { - ri.Printf( PRINT_ALL, "N/A\n" ); - } - if ( glConfig.deviceSupportsGamma ) - { - ri.Printf( PRINT_ALL, "GAMMA: hardware w/ %d overbright bits\n", tr.overbrightBits ); - } - else - { - ri.Printf( PRINT_ALL, "GAMMA: software w/ %d overbright bits\n", tr.overbrightBits ); - } - - ri.Printf( PRINT_ALL, "texturemode: %s\n", r_textureMode->string ); - ri.Printf( PRINT_ALL, "picmip: %d\n", r_picmip->integer ); - ri.Printf( PRINT_ALL, "texture bits: %d\n", r_texturebits->integer ); - ri.Printf( PRINT_ALL, "texenv add: %s\n", enablestrings[glConfig.textureEnvAddAvailable != 0] ); - ri.Printf( PRINT_ALL, "compressed textures: %s\n", enablestrings[glConfig.textureCompression!=TC_NONE] ); - - if ( r_finish->integer ) { - ri.Printf( PRINT_ALL, "Forcing glFinish\n" ); - } -} - - -/* -================ -GfxMemInfo_f -================ -*/ -static void GfxMemInfo_f( void ) -{ - switch (glRefConfig.memInfo) - { - case MI_NONE: - { - ri.Printf(PRINT_ALL, "No extension found for GPU memory info.\n"); - } - break; - case MI_NVX: - { - int value; - - qglGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &value); - ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX: %ikb\n", value); - - qglGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &value); - ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX: %ikb\n", value); - - qglGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &value); - ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX: %ikb\n", value); - - qglGetIntegerv(GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX, &value); - ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_EVICTION_COUNT_NVX: %i\n", value); - - qglGetIntegerv(GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX, &value); - ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_EVICTED_MEMORY_NVX: %ikb\n", value); - } - break; - case MI_ATI: - { - // GL_ATI_meminfo - int value[4]; - - qglGetIntegerv(GL_VBO_FREE_MEMORY_ATI, &value[0]); - ri.Printf(PRINT_ALL, "VBO_FREE_MEMORY_ATI: %ikb total %ikb largest aux: %ikb total %ikb largest\n", value[0], value[1], value[2], value[3]); - - qglGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, &value[0]); - ri.Printf(PRINT_ALL, "TEXTURE_FREE_MEMORY_ATI: %ikb total %ikb largest aux: %ikb total %ikb largest\n", value[0], value[1], value[2], value[3]); - - qglGetIntegerv(GL_RENDERBUFFER_FREE_MEMORY_ATI, &value[0]); - ri.Printf(PRINT_ALL, "RENDERBUFFER_FREE_MEMORY_ATI: %ikb total %ikb largest aux: %ikb total %ikb largest\n", value[0], value[1], value[2], value[3]); - } - break; - } -} - - -/* -=============== -R_Register -=============== -*/ -static void R_Register( void ) -{ - // - // latched and archived variables - // - r_allowExtensions = ri.Cvar_Get( "r_allowExtensions", "1", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_allowExtensions, "Use all of the OpenGL extensions your card is capable of." ); - r_ext_compressed_textures = ri.Cvar_Get( "r_ext_compressed_textures", "0", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_ext_compressed_textures, "Enables texture compression." ); - r_ext_multitexture = ri.Cvar_Get( "r_ext_multitexture", "1", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_ext_multitexture, "Enables hardware multi-texturing (0: off, 1: on)." ); - r_ext_compiled_vertex_array = ri.Cvar_Get( "r_ext_compiled_vertex_array", "1", CVAR_ARCHIVE | CVAR_LATCH); - ri.Cvar_SetDescription( r_ext_compiled_vertex_array, "Enables hardware-compiled vertex array rendering method." ); - r_ext_texture_env_add = ri.Cvar_Get( "r_ext_texture_env_add", "1", CVAR_ARCHIVE | CVAR_LATCH); - ri.Cvar_SetDescription( r_ext_texture_env_add, "Enables additive blending in multitexturing. Requires \\r_ext_multitexture 1." ); - - r_ext_framebuffer_object = ri.Cvar_Get( "r_ext_framebuffer_object", "1", CVAR_ARCHIVE | CVAR_LATCH); - r_ext_texture_float = ri.Cvar_Get( "r_ext_texture_float", "1", CVAR_ARCHIVE | CVAR_LATCH); - r_ext_framebuffer_multisample = ri.Cvar_Get( "r_ext_framebuffer_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH); - ri.Cvar_SetDescription( r_ext_framebuffer_multisample, "For anti-aliasing geometry edges (FBO)." ); - r_arb_seamless_cube_map = ri.Cvar_Get( "r_arb_seamless_cube_map", "0", CVAR_ARCHIVE | CVAR_LATCH); - r_arb_vertex_array_object = ri.Cvar_Get( "r_arb_vertex_array_object", "1", CVAR_ARCHIVE | CVAR_LATCH); - r_ext_direct_state_access = ri.Cvar_Get("r_ext_direct_state_access", "1", CVAR_ARCHIVE | CVAR_LATCH); - - r_ext_texture_filter_anisotropic = ri.Cvar_Get( "r_ext_texture_filter_anisotropic", "1", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_ext_texture_filter_anisotropic, "Allow anisotropic filtering." ); - r_ext_max_anisotropy = ri.Cvar_Get( "r_ext_max_anisotropy", "8", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_ext_max_anisotropy, "Sets maximum anisotropic level for your graphics driver. Requires \\r_ext_texture_filter_anisotropic." ); - - r_picmip = ri.Cvar_Get ("r_picmip", "0", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_CheckRange( r_picmip, "0", "16", CV_INTEGER ); - ri.Cvar_SetDescription( r_picmip, "Set texture quality, lower is better." ); - r_roundImagesDown = ri.Cvar_Get ("r_roundImagesDown", "1", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_roundImagesDown, "When images are scaled, round images down instead of up." ); - r_colorMipLevels = ri.Cvar_Get ("r_colorMipLevels", "0", CVAR_LATCH ); - ri.Cvar_SetDescription( r_colorMipLevels, "Debugging tool to artificially color different mipmap levels so that they are more apparent." ); - r_detailTextures = ri.Cvar_Get( "r_detailtextures", "1", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_detailTextures, "Enables usage of shader stages flagged as detail." ); - r_texturebits = ri.Cvar_Get( "r_texturebits", "0", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_texturebits, "Number of texture bits per texture." ); -// r_stencilbits = ri.Cvar_Get( "r_stencilbits", "8", CVAR_ARCHIVE | CVAR_LATCH ); - r_ext_multisample = ri.Cvar_Get( "r_ext_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_CheckRange( r_ext_multisample, "0", "8", CV_INTEGER ); - ri.Cvar_SetDescription( r_ext_multisample, "For anti-aliasing geometry edges." ); - r_overBrightBits = ri.Cvar_Get ("r_overBrightBits", "1", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_overBrightBits, "Sets the intensity of overall brightness of texture pixels." ); - r_ignorehwgamma = ri.Cvar_Get( "r_ignorehwgamma", "0", CVAR_ARCHIVE | CVAR_LATCH); - ri.Cvar_SetDescription( r_ignorehwgamma, "Overrides hardware gamma capabilities." ); - r_simpleMipMaps = ri.Cvar_Get( "r_simpleMipMaps", "1", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_simpleMipMaps, "Whether or not to use a simple mipmapping algorithm or a more correct one:\n 0: off (proper linear filter)\n 1: on (for slower machines)" ); - r_vertexLight = ri.Cvar_Get( "r_vertexLight", "0", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_vertexLight, "Set to 1 to use vertex light instead of lightmaps, collapse all multi-stage shaders into single-stage ones, might cause rendering artifacts." ); - r_subdivisions = ri.Cvar_Get ("r_subdivisions", "1", CVAR_ARCHIVE | CVAR_LATCH); - ri.Cvar_SetDescription(r_subdivisions, "Distance to subdivide bezier curved surfaces. Higher values mean less subdivision and less geometric complexity."); - r_greyscale = ri.Cvar_Get("r_greyscale", "0", CVAR_ARCHIVE | CVAR_LATCH); - ri.Cvar_CheckRange( r_greyscale, "0", "1", CV_FLOAT ); - ri.Cvar_SetDescription( r_greyscale, "Desaturates rendered frame." ); - - r_externalGLSL = ri.Cvar_Get( "r_externalGLSL", "0", CVAR_LATCH ); - - r_hdr = ri.Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_hdr, "Do scene rendering in a framebuffer with high dynamic range." ); - r_floatLightmap = ri.Cvar_Get( "r_floatLightmap", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_postProcess = ri.Cvar_Get( "r_postProcess", "1", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_postProcess, "Enable post-processing." ); - - r_toneMap = ri.Cvar_Get( "r_toneMap", "1", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_toneMap, "Enable tone mapping. Requires r_hdr and r_postProcess." ); - r_forceToneMap = ri.Cvar_Get( "r_forceToneMap", "0", CVAR_CHEAT ); - r_forceToneMapMin = ri.Cvar_Get( "r_forceToneMapMin", "-8.0", CVAR_CHEAT ); - r_forceToneMapAvg = ri.Cvar_Get( "r_forceToneMapAvg", "-2.0", CVAR_CHEAT ); - r_forceToneMapMax = ri.Cvar_Get( "r_forceToneMapMax", "0.0", CVAR_CHEAT ); - - r_autoExposure = ri.Cvar_Get( "r_autoExposure", "1", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_autoExposure, "Do automatic exposure based on scene brightness. Hardcoded to -2 to 2 on maps that don't specify otherwise. Requires r_hdr, r_postProcess, and r_toneMap." ); - r_forceAutoExposure = ri.Cvar_Get( "r_forceAutoExposure", "0", CVAR_CHEAT ); - r_forceAutoExposureMin = ri.Cvar_Get( "r_forceAutoExposureMin", "-2.0", CVAR_CHEAT ); - r_forceAutoExposureMax = ri.Cvar_Get( "r_forceAutoExposureMax", "2.0", CVAR_CHEAT ); - - r_cameraExposure = ri.Cvar_Get( "r_cameraExposure", "1", CVAR_CHEAT ); - - r_depthPrepass = ri.Cvar_Get( "r_depthPrepass", "1", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_depthPrepass, "Do a depth-only pass before rendering. Speeds up rendering in cases where advanced features are used. Required for r_sunShadows." ); - r_ssao = ri.Cvar_Get( "r_ssao", "0", CVAR_LATCH | CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_ssao, "Enable screen-space ambient occlusion." ); - - r_normalMapping = ri.Cvar_Get( "r_normalMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_normalMapping, "Enable normal maps for materials that support it." ); - r_specularMapping = ri.Cvar_Get( "r_specularMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_specularMapping, "Enable specular maps for materials that support it." ); - r_deluxeMapping = ri.Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_deluxeMapping, "Enable deluxe mapping (map is compiled with light directions). Even if the map doesn't have deluxe mapping compiled in, an approximation based on the lightgrid will be used." ); - r_parallaxMapping = ri.Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_parallaxMapping, "Enable parallax mapping for materials that support it.\n 0: No\n 1: Use parallax occlusion mapping\n 2: Use relief mapping" ); - r_parallaxMapOffset = ri.Cvar_Get( "r_parallaxMapOffset", "0", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_parallaxMapOffset, "Set the parallax height offset." ); - r_parallaxMapShadows = ri.Cvar_Get( "r_parallaxMapShadows", "0", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_parallaxMapShadows, "Enable self-shadowing on parallax map supported materials." ); - r_cubeMapping = ri.Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_cubemapSize = ri.Cvar_Get( "r_cubemapSize", "128", CVAR_ARCHIVE | CVAR_LATCH ); - r_deluxeSpecular = ri.Cvar_Get("r_deluxeSpecular", "0.3", CVAR_ARCHIVE | CVAR_LATCH); - r_pbr = ri.Cvar_Get("r_pbr", "0", CVAR_ARCHIVE | CVAR_LATCH); - ri.Cvar_SetDescription( r_pbr, "Enable physically based rendering." ); - r_baseNormalX = ri.Cvar_Get( "r_baseNormalX", "1.0", CVAR_ARCHIVE | CVAR_LATCH ); - r_baseNormalY = ri.Cvar_Get( "r_baseNormalY", "1.0", CVAR_ARCHIVE | CVAR_LATCH ); - r_baseParallax = ri.Cvar_Get( "r_baseParallax", "0.05", CVAR_ARCHIVE | CVAR_LATCH ); - r_baseSpecular = ri.Cvar_Get( "r_baseSpecular", "0.04", CVAR_ARCHIVE | CVAR_LATCH ); - r_baseGloss = ri.Cvar_Get( "r_baseGloss", "0.3", CVAR_ARCHIVE | CVAR_LATCH ); - r_glossType = ri.Cvar_Get("r_glossType", "1", CVAR_ARCHIVE | CVAR_LATCH); - r_dlightMode = ri.Cvar_Get( "r_dlightMode", "0", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_dlightMode, "Dynamic light mode:\n 0: VQ3 'fake' dynamic lights\n 1: High-quality per-pixel dynamic lights, slightly faster than VQ3's on modern hardware\n 2: Same as 1 but applies to all MD3 models too" ); - r_pshadowDist = ri.Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE ); - r_mergeLightmaps = ri.Cvar_Get( "r_mergeLightmaps", "1", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_mergeLightmaps, "Merge small lightmaps into 2 or fewer giant lightmaps." ); - r_imageUpsample = ri.Cvar_Get( "r_imageUpsample", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_imageUpsampleMaxSize = ri.Cvar_Get( "r_imageUpsampleMaxSize", "1024", CVAR_ARCHIVE | CVAR_LATCH ); - r_imageUpsampleType = ri.Cvar_Get( "r_imageUpsampleType", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_genNormalMaps = ri.Cvar_Get( "r_genNormalMaps", "0", CVAR_ARCHIVE | CVAR_LATCH ); - - r_forceSun = ri.Cvar_Get( "r_forceSun", "0", CVAR_CHEAT ); - r_forceSunLightScale = ri.Cvar_Get( "r_forceSunLightScale", "1.0", CVAR_CHEAT ); - r_forceSunAmbientScale = ri.Cvar_Get( "r_forceSunAmbientScale", "0.5", CVAR_CHEAT ); - r_drawSunRays = ri.Cvar_Get( "r_drawSunRays", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_sunlightMode = ri.Cvar_Get( "r_sunlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH ); - - r_sunShadows = ri.Cvar_Get( "r_sunShadows", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_shadowFilter = ri.Cvar_Get( "r_shadowFilter", "1", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_shadowFilter, "Enable filtering shadows for a smoother look (0 - No. 1 - Some. 2 - Much)." ); - r_shadowBlur = ri.Cvar_Get("r_shadowBlur", "0", CVAR_ARCHIVE | CVAR_LATCH); - r_shadowMapSize = ri.Cvar_Get("r_shadowMapSize", "1024", CVAR_ARCHIVE | CVAR_LATCH); - ri.Cvar_SetDescription( r_shadowMapSize, "Size of each cascaded shadow map." ); - r_shadowCascadeZNear = ri.Cvar_Get( "r_shadowCascadeZNear", "8", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_shadowCascadeZNear, "Near plane for shadow cascade frustums." ); - r_shadowCascadeZFar = ri.Cvar_Get( "r_shadowCascadeZFar", "1024", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_shadowCascadeZFar, "Far plane for shadow cascade frustums." ); - r_shadowCascadeZBias = ri.Cvar_Get( "r_shadowCascadeZBias", "0", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_SetDescription( r_shadowCascadeZBias, "Z-bias for shadow cascade frustums." ); - r_ignoreDstAlpha = ri.Cvar_Get( "r_ignoreDstAlpha", "1", CVAR_ARCHIVE | CVAR_LATCH ); - - // - // temporary latched variables that can only change over a restart - // - r_fullbright = ri.Cvar_Get ("r_fullbright", "0", CVAR_LATCH|CVAR_CHEAT ); - ri.Cvar_SetDescription( r_fullbright, "Debugging tool to render the entire level without lighting." ); - r_mapOverBrightBits = ri.Cvar_Get ("r_mapOverBrightBits", "2", CVAR_LATCH ); - ri.Cvar_SetDescription( r_mapOverBrightBits, "Sets the number of overbright bits baked into all lightmaps and map data." ); - r_intensity = ri.Cvar_Get ("r_intensity", "1", CVAR_LATCH ); - ri.Cvar_SetDescription( r_intensity, "Global texture lighting scale." ); - r_singleShader = ri.Cvar_Get ("r_singleShader", "0", CVAR_CHEAT | CVAR_LATCH ); - ri.Cvar_SetDescription( r_singleShader, "Debugging tool that only uses the default shader for all rendering." ); - - // - // archived variables that can change at any time - // - r_lodCurveError = ri.Cvar_Get( "r_lodCurveError", "250", CVAR_ARCHIVE ); - ri.Cvar_CheckRange( r_lodCurveError, "-1", "8192", CV_FLOAT ); - ri.Cvar_SetDescription( r_lodCurveError, "Level of detail error on curved surface grids. Higher values result in better quality at a distance." ); - r_lodbias = ri.Cvar_Get( "r_lodbias", "-2", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_lodbias, "Sets the level of detail of in-game models:\n -2: Ultra (further delays LOD transition in the distance)\n -1: Very High (delays LOD transition in the distance)\n 0: High\n 1: Medium\n 2: Low" ); - r_flares = ri.Cvar_Get ("r_flares", "0", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_flares, "Enables corona effects on light sources." ); - r_znear = ri.Cvar_Get( "r_znear", "4", CVAR_CHEAT ); - ri.Cvar_CheckRange( r_znear, "0.001", "200", CV_FLOAT ); - ri.Cvar_SetDescription( r_znear, "Viewport distance from view origin (how close objects can be to the player before they're clipped out of the scene)." ); - r_zproj = ri.Cvar_Get( "r_zproj", "64", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_zproj, "Projected viewport frustum." ); - r_stereoSeparation = ri.Cvar_Get( "r_stereoSeparation", "64", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_stereoSeparation, "Control eye separation. Resulting separation is \\r_zproj divided by this value in standard units." ); - r_ignoreGLErrors = ri.Cvar_Get( "r_ignoreGLErrors", "1", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_ignoreGLErrors, "Ignore OpenGL errors." ); - r_teleporterFlash = ri.Cvar_Get( "r_teleporterFlash", "1", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_teleporterFlash, "Show a white screen instead of a black screen when being teleported in hyperspace." ); - r_fastsky = ri.Cvar_Get( "r_fastsky", "0", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_fastsky, "Draw flat colored skies." ); - r_drawSun = ri.Cvar_Get( "r_drawSun", "0", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_drawSun, "Draw sun shader in skies." ); - r_dynamiclight = ri.Cvar_Get( "r_dynamiclight", "1", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_dynamiclight, "Enables dynamic lighting." ); - r_dlightBacks = ri.Cvar_Get( "r_dlightBacks", "1", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_dlightBacks, "Whether or not dynamic lights should light up back-face culled geometry." ); - r_finish = ri.Cvar_Get ("r_finish", "0", CVAR_ARCHIVE); - ri.Cvar_SetDescription( r_finish, "Force a glFinish call after rendering a scene." ); - r_textureMode = ri.Cvar_Get( "r_textureMode", "GL_LINEAR_MIPMAP_LINEAR", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_textureMode, "Texture interpolation mode:\n GL_NEAREST: Nearest neighbor interpolation and will therefore appear similar to Quake II except with the added colored lighting\n GL_LINEAR: Linear interpolation and will appear to blend in objects that are closer than the resolution that the textures are set as\n GL_NEAREST_MIPMAP_NEAREST: Nearest neighbor interpolation with mipmapping for bilinear hardware, mipmapping will blend objects that are farther away than the resolution that they are set as\n GL_LINEAR_MIPMAP_NEAREST: Linear interpolation with mipmapping for bilinear hardware\n GL_NEAREST_MIPMAP_LINEAR: Nearest neighbor interpolation with mipmapping for trilinear hardware\n GL_LINEAR_MIPMAP_LINEAR: Linear interpolation with mipmapping for trilinear hardware" ); - r_gamma = ri.Cvar_Get( "r_gamma", "1", CVAR_ARCHIVE ); - ri.Cvar_CheckRange( r_gamma, "0.5", "3", CV_FLOAT ); - ri.Cvar_SetDescription( r_gamma, "Gamma correction factor." ); - r_facePlaneCull = ri.Cvar_Get ("r_facePlaneCull", "1", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_facePlaneCull, "Enables culling of planar surfaces with back side test." ); - r_railWidth = ri.Cvar_Get( "r_railWidth", "16", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_railWidth, "Radius of railgun trails." ); - r_railCoreWidth = ri.Cvar_Get( "r_railCoreWidth", "6", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_railCoreWidth, "Size of railgun trail rings when enabled in game code (normally \\cg_oldRail 0)." ); - r_railSegmentLength = ri.Cvar_Get( "r_railSegmentLength", "32", CVAR_ARCHIVE ); - ri.Cvar_SetDescription( r_railSegmentLength, "Length of segments in railgun trails." ); - - r_ambientScale = ri.Cvar_Get( "r_ambientScale", "0.6", CVAR_CHEAT ); - ri.Cvar_SetDescription( r_ambientScale, "Light grid ambient light scaling on entity models." ); - r_directedScale = ri.Cvar_Get( "r_directedScale", "1", CVAR_CHEAT ); - ri.Cvar_SetDescription( r_directedScale, "Light grid direct light scaling on entity models." ); - - r_anaglyphMode = ri.Cvar_Get("r_anaglyphMode", "0", CVAR_ARCHIVE); - ri.Cvar_SetDescription( r_anaglyphMode, "Enable rendering of anaglyph images. Valid options for 3D glasses types:\n 0: Disabled\n 1: Red-cyan\n 2: Red-blue\n 3: Red-green\n 4: Green-magenta" ); - - // - // temporary variables that can change at any time - // - r_showImages = ri.Cvar_Get( "r_showImages", "0", CVAR_TEMP ); - ri.Cvar_SetDescription( r_showImages, "Draw all images currently loaded into memory:\n 0: Disabled\n 1: Show images set to uniform size\n 2: Show images with scaled relative to largest image" ); - - r_debugLight = ri.Cvar_Get( "r_debuglight", "0", CVAR_TEMP ); - ri.Cvar_SetDescription( r_debugLight, "Debugging tool to print ambient and directed lighting information." ); - r_debugSort = ri.Cvar_Get( "r_debugSort", "0", CVAR_CHEAT ); - ri.Cvar_SetDescription( r_debugSort, "Debugging tool to filter out shaders with depth sorting order values higher than the set value." ); - r_printShaders = ri.Cvar_Get( "r_printShaders", "0", 0 ); - ri.Cvar_SetDescription( r_printShaders, "Debugging tool to print on console of the number of shaders used." ); - r_saveFontData = ri.Cvar_Get( "r_saveFontData", "0", 0 ); - - r_nocurves = ri.Cvar_Get ("r_nocurves", "0", CVAR_CHEAT ); - ri.Cvar_SetDescription( r_nocurves, "Set to 1 to disable drawing world bezier curves. Set to 0 to enable." ); - r_drawworld = ri.Cvar_Get ("r_drawworld", "1", CVAR_CHEAT ); - ri.Cvar_SetDescription( r_drawworld, "Set to 0 to disable drawing the world. Set to 1 to enable." ); - r_lightmap = ri.Cvar_Get ("r_lightmap", "0", 0 ); - ri.Cvar_SetDescription( r_lightmap, "Show only lightmaps on all world surfaces." ); - r_portalOnly = ri.Cvar_Get ("r_portalOnly", "0", CVAR_CHEAT ); - ri.Cvar_SetDescription( r_portalOnly, "Set to 1 to render only first mirror/portal view if it is present on the scene." ); - - r_flareSize = ri.Cvar_Get ("r_flareSize", "40", CVAR_CHEAT); - ri.Cvar_SetDescription( r_flareSize, "Radius of light flares. Requires \\r_flares 1." ); - r_flareFade = ri.Cvar_Get ("r_flareFade", "7", CVAR_CHEAT); - ri.Cvar_SetDescription( r_flareFade, "Distance to fade out light flares. Requires \\r_flares 1." ); - r_flareCoeff = ri.Cvar_Get ("r_flareCoeff", FLARE_STDCOEFF, CVAR_CHEAT); - ri.Cvar_SetDescription( r_flareCoeff, "Coefficient for the light flare intensity falloff function. Requires \\r_flares 1." ); - - r_skipBackEnd = ri.Cvar_Get ("r_skipBackEnd", "0", CVAR_CHEAT); - ri.Cvar_SetDescription( r_skipBackEnd, "Skips loading rendering backend." ); - - r_measureOverdraw = ri.Cvar_Get( "r_measureOverdraw", "0", CVAR_CHEAT ); - r_lodscale = ri.Cvar_Get( "r_lodscale", "5", CVAR_CHEAT ); - ri.Cvar_SetDescription( r_lodscale, "Set scale for level of detail adjustment." ); - r_norefresh = ri.Cvar_Get ("r_norefresh", "0", CVAR_CHEAT); - ri.Cvar_SetDescription( r_norefresh, "Bypasses refreshing of the rendered scene." ); - r_drawentities = ri.Cvar_Get ("r_drawentities", "1", CVAR_CHEAT ); - ri.Cvar_SetDescription( r_drawentities, "Draw all world entities." ); - r_ignore = ri.Cvar_Get( "r_ignore", "1", CVAR_CHEAT ); - r_nocull = ri.Cvar_Get ("r_nocull", "0", CVAR_CHEAT); - ri.Cvar_SetDescription( r_nocull, "Draw all culled objects." ); - r_novis = ri.Cvar_Get ("r_novis", "0", CVAR_CHEAT); - ri.Cvar_SetDescription( r_novis, "Disables usage of PVS." ); - r_showcluster = ri.Cvar_Get ("r_showcluster", "0", CVAR_CHEAT); - ri.Cvar_SetDescription( r_showcluster, "Shows current cluster index." ); - r_speeds = ri.Cvar_Get ("r_speeds", "0", CVAR_CHEAT); - ri.Cvar_SetDescription( r_speeds, "Prints out various debugging stats from PVS:\n 0: Disabled\n 1: Backend BSP\n 2: Frontend grid culling\n 3: Current view cluster index\n 4: Dynamic lighting\n 5: zFar clipping\n 6: Flares" ); - r_debugSurface = ri.Cvar_Get ("r_debugSurface", "0", CVAR_CHEAT); - ri.Cvar_SetDescription( r_debugSurface, "Backend visual debugging tool for bezier mesh surfaces." ); - r_nobind = ri.Cvar_Get ("r_nobind", "0", CVAR_CHEAT); - ri.Cvar_SetDescription( r_nobind, "Backend debugging tool: Disables texture binding." ); - r_showtris = ri.Cvar_Get ("r_showtris", "0", CVAR_CHEAT); - ri.Cvar_SetDescription( r_showtris, "Debugging tool: Wireframe rendering of polygon triangles in the world." ); - r_showsky = ri.Cvar_Get ("r_showsky", "0", CVAR_CHEAT); - ri.Cvar_SetDescription( r_showsky, "Forces sky in front of all surfaces." ); - r_shownormals = ri.Cvar_Get ("r_shownormals", "0", CVAR_CHEAT); - ri.Cvar_SetDescription( r_shownormals, "Debugging tool: Show wireframe surface normals." ); - r_clear = ri.Cvar_Get ("r_clear", "0", CVAR_CHEAT); - ri.Cvar_SetDescription( r_clear, "Forces screen buffer clearing every frame, removing any hall of mirrors effect in void.\n Use \\r_clearColor to set color." ); - r_offsetFactor = ri.Cvar_Get( "r_offsetFactor", "-1", CVAR_CHEAT ); - ri.Cvar_SetDescription( r_offsetFactor, "Offset factor for shaders with polygonOffset stages." ); - r_offsetUnits = ri.Cvar_Get( "r_offsetunits", "-2", CVAR_CHEAT ); - ri.Cvar_SetDescription( r_offsetUnits, "Offset units for shaders with polygonOffset stages." ); - r_drawBuffer = ri.Cvar_Get( "r_drawBuffer", "GL_BACK", CVAR_CHEAT ); - ri.Cvar_SetDescription( r_drawBuffer, "Sets which frame buffer to draw into." ); - r_lockpvs = ri.Cvar_Get ("r_lockpvs", "0", CVAR_CHEAT); - ri.Cvar_SetDescription( r_lockpvs, "Debugging tool: Locks to current potentially visible set. Useful for testing vis-culling in maps." ); - r_noportals = ri.Cvar_Get ("r_noportals", "0", CVAR_CHEAT); - ri.Cvar_SetDescription(r_noportals, "Disables in-game portals, valid values: 0: Portals enabled\n 1: Portals disabled\n 2: Portals and mirrors disabled" ); - r_shadows = ri.Cvar_Get( "cg_shadows", "1", 0 ); - - r_marksOnTriangleMeshes = ri.Cvar_Get("r_marksOnTriangleMeshes", "0", CVAR_ARCHIVE); - ri.Cvar_SetDescription( r_marksOnTriangleMeshes, "Enables impact marks on triangle mesh surfaces (ie: MD3 models.) Requires impact marks to be enabled in the game code." ); - - r_aviMotionJpegQuality = ri.Cvar_Get("r_aviMotionJpegQuality", "90", CVAR_ARCHIVE); - ri.Cvar_SetDescription( r_aviMotionJpegQuality, "Controls quality of Jpeg video capture when \\cl_aviMotionJpeg 1." ); - r_screenshotJpegQuality = ri.Cvar_Get("r_screenshotJpegQuality", "90", CVAR_ARCHIVE); - ri.Cvar_SetDescription( r_screenshotJpegQuality, "Controls quality of Jpeg screenshots when using screenshotJpeg." ); - - r_maxpolys = ri.Cvar_Get( "r_maxpolys", va("%d", MAX_POLYS), 0); - ri.Cvar_SetDescription( r_maxpolys, "Maximum number of polygons to draw in a scene." ); - r_maxpolyverts = ri.Cvar_Get( "r_maxpolyverts", va("%d", MAX_POLYVERTS), 0); - ri.Cvar_SetDescription( r_maxpolyverts, "Maximum number of polygon vertices to draw in a scene." ); - - // make sure all the commands added here are also - // removed in R_Shutdown - ri.Cmd_AddCommand( "imagelist", R_ImageList_f ); - ri.Cmd_AddCommand( "shaderlist", R_ShaderList_f ); - ri.Cmd_AddCommand( "skinlist", R_SkinList_f ); - ri.Cmd_AddCommand( "modellist", R_Modellist_f ); - ri.Cmd_AddCommand( "screenshot", R_ScreenShot_f ); - ri.Cmd_AddCommand( "screenshotJPEG", R_ScreenShotJPEG_f ); - ri.Cmd_AddCommand( "gfxinfo", GfxInfo_f ); - ri.Cmd_AddCommand( "gfxmeminfo", GfxMemInfo_f ); - ri.Cmd_AddCommand( "exportCubemaps", R_ExportCubemaps_f ); -} - -static void R_InitQueries(void) -{ - if (!glRefConfig.occlusionQuery) - return; - - if (r_drawSunRays->integer) - qglGenQueries(ARRAY_LEN(tr.sunFlareQuery), tr.sunFlareQuery); -} - -static void R_ShutDownQueries(void) -{ - if (!glRefConfig.occlusionQuery) - return; - - if (r_drawSunRays->integer) - qglDeleteQueries(ARRAY_LEN(tr.sunFlareQuery), tr.sunFlareQuery); -} - - -static void RE_SyncRender( void ) -{ - -} - - -/* -=============== -R_Init -=============== -*/ -void R_Init( void ) { - int err; - int i; - byte *ptr; - - ri.Printf( PRINT_ALL, "----- R_Init -----\n" ); - - // clear all our internal state - Com_Memset( &tr, 0, sizeof( tr ) ); - Com_Memset( &backEnd, 0, sizeof( backEnd ) ); - Com_Memset( &tess, 0, sizeof( tess ) ); - - if(sizeof(glconfig_t) != 11332) - ri.Error( ERR_FATAL, "Mod ABI incompatible: sizeof(glconfig_t) == %u != 11332", (unsigned int) sizeof(glconfig_t)); - - if ( (intptr_t)tess.xyz & 15 ) { - ri.Printf( PRINT_WARNING, "tess.xyz not 16 byte aligned\n" ); - } - //Com_Memset( tess.constantColor255, 255, sizeof( tess.constantColor255 ) ); - - // - // init function tables - // - for ( i = 0; i < FUNCTABLE_SIZE; i++ ) - { - tr.sinTable[i] = sin( DEG2RAD( i * 360.0f / ( ( float ) ( FUNCTABLE_SIZE - 1 ) ) ) ); - tr.squareTable[i] = ( i < FUNCTABLE_SIZE/2 ) ? 1.0f : -1.0f; - tr.sawToothTable[i] = (float)i / FUNCTABLE_SIZE; - tr.inverseSawToothTable[i] = 1.0f - tr.sawToothTable[i]; - - if ( i < FUNCTABLE_SIZE / 2 ) - { - if ( i < FUNCTABLE_SIZE / 4 ) - { - tr.triangleTable[i] = ( float ) i / ( FUNCTABLE_SIZE / 4 ); - } - else - { - tr.triangleTable[i] = 1.0f - tr.triangleTable[i-FUNCTABLE_SIZE / 4]; - } - } - else - { - tr.triangleTable[i] = -tr.triangleTable[i-FUNCTABLE_SIZE/2]; - } - } - - R_InitFogTable(); - - R_NoiseInit(); - - R_Register(); - - max_polys = r_maxpolys->integer; - if (max_polys < MAX_POLYS) - max_polys = MAX_POLYS; - - max_polyverts = r_maxpolyverts->integer; - if (max_polyverts < MAX_POLYVERTS) - max_polyverts = MAX_POLYVERTS; - - ptr = ri.Hunk_Alloc( sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low); - backEndData = (backEndData_t *) ptr; - backEndData->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData )); - backEndData->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys); - R_InitNextFrame(); - - InitOpenGL(); - - R_InitImages(); - - if (glRefConfig.framebufferObject) - FBO_Init(); - - GLSL_InitGPUShaders(); - - R_InitVaos(); - - R_InitShaders(); - - R_InitSkins(); - - R_ModelInit(); - - R_InitFreeType(); - - R_InitQueries(); - - - err = qglGetError(); - if ( err != GL_NO_ERROR ) - ri.Printf (PRINT_ALL, "glGetError() = 0x%x\n", err); - - // print info - GfxInfo_f(); - ri.Printf( PRINT_ALL, "----- finished R_Init -----\n" ); -} - - -/* -=============== -RE_Shutdown -=============== -*/ -static void RE_Shutdown( refShutdownCode_t code ) { - - ri.Printf( PRINT_ALL, "RE_Shutdown( %i )\n", code ); - - ri.Cmd_RemoveCommand( "imagelist" ); - ri.Cmd_RemoveCommand( "shaderlist" ); - ri.Cmd_RemoveCommand( "skinlist" ); - ri.Cmd_RemoveCommand( "modellist" ); - ri.Cmd_RemoveCommand( "modelist" ); - ri.Cmd_RemoveCommand( "screenshot" ); - ri.Cmd_RemoveCommand( "screenshotJPEG" ); - ri.Cmd_RemoveCommand( "gfxinfo" ); - ri.Cmd_RemoveCommand( "minimize" ); - ri.Cmd_RemoveCommand( "gfxmeminfo" ); - ri.Cmd_RemoveCommand( "exportCubemaps" ); - - - if ( tr.registered ) { - R_IssuePendingRenderCommands(); - R_ShutDownQueries(); - if (glRefConfig.framebufferObject) - FBO_Shutdown(); - R_DeleteTextures(); - R_ShutdownVaos(); - GLSL_ShutdownGPUShaders(); - } - - R_DoneFreeType(); - - // shut down platform specific OpenGL stuff - if ( code != REF_KEEP_CONTEXT ) { - ri.GLimp_Shutdown( code == REF_UNLOAD_DLL ? qtrue: qfalse ); - - Com_Memset( &glConfig, 0, sizeof( glConfig ) ); - Com_Memset( &glRefConfig, 0, sizeof( glRefConfig ) ); - - textureFilterAnisotropic = qfalse; - maxAnisotropy = 0; - - Com_Memset( &glState, 0, sizeof( glState ) ); - } - - ri.FreeAll(); - - tr.registered = qfalse; -} - - -/* -============= -RE_EndRegistration - -Touch all images to make sure they are resident -============= -*/ -static void RE_EndRegistration( void ) { - R_IssuePendingRenderCommands(); - if ( !ri.Sys_LowPhysicalMemory() ) { - RB_ShowImages(); - } -} - - -/* -@@@@@@@@@@@@@@@@@@@@@ -GetRefAPI - -@@@@@@@@@@@@@@@@@@@@@ -*/ -#ifdef USE_RENDERER_DLOPEN -Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { -#else -refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) { -#endif - - static refexport_t re; - - ri = *rimp; - - Com_Memset( &re, 0, sizeof( re ) ); - - if ( apiVersion != REF_API_VERSION ) { - ri.Printf(PRINT_ALL, "Mismatched REF_API_VERSION: expected %i, got %i\n", - REF_API_VERSION, apiVersion ); - return NULL; - } - - // the RE_ functions are Renderer Entry points - - re.Shutdown = RE_Shutdown; - - re.BeginRegistration = RE_BeginRegistration; - re.RegisterModel = RE_RegisterModel; - re.RegisterSkin = RE_RegisterSkin; - re.RegisterShader = RE_RegisterShader; - re.RegisterShaderNoMip = RE_RegisterShaderNoMip; - re.LoadWorld = RE_LoadWorldMap; - re.SetWorldVisData = RE_SetWorldVisData; - re.EndRegistration = RE_EndRegistration; - - re.BeginFrame = RE_BeginFrame; - re.EndFrame = RE_EndFrame; - - re.MarkFragments = R_MarkFragments; - re.LerpTag = R_LerpTag; - re.ModelBounds = R_ModelBounds; - - re.ClearScene = RE_ClearScene; - re.AddRefEntityToScene = RE_AddRefEntityToScene; - re.AddPolyToScene = RE_AddPolyToScene; - re.LightForPoint = R_LightForPoint; - re.AddLightToScene = RE_AddLightToScene; - re.AddAdditiveLightToScene = RE_AddAdditiveLightToScene; - re.RenderScene = RE_RenderScene; - - re.SetColor = RE_SetColor; - re.DrawStretchPic = RE_StretchPic; - re.DrawStretchRaw = RE_StretchRaw; - re.UploadCinematic = RE_UploadCinematic; - - re.RegisterFont = RE_RegisterFont; - re.RemapShader = R_RemapShader; - re.GetEntityToken = R_GetEntityToken; - re.inPVS = R_inPVS; - - re.TakeVideoFrame = RE_TakeVideoFrame; - re.SetColorMappings = R_SetColorMappings; - - re.ThrottleBackend = RE_ThrottleBackend; - re.CanMinimize = RE_CanMinimize; - re.GetConfig = RE_GetConfig; - re.VertexLighting = RE_VertexLighting; - re.SyncRender = RE_SyncRender; - - return &re; -} diff --git a/code/renderer2/tr_light.c b/code/renderer2/tr_light.c deleted file mode 100644 index ba7a3f6cf7..0000000000 --- a/code/renderer2/tr_light.c +++ /dev/null @@ -1,510 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_light.c - -#include "tr_local.h" - -#define DLIGHT_AT_RADIUS 16 -// at the edge of a dlight's influence, this amount of light will be added - -#define DLIGHT_MINIMUM_RADIUS 16 -// never calculate a range less than this to prevent huge light numbers - - -/* -=============== -R_TransformDlights - -Transforms the origins of an array of dlights. -Used by both the front end (for DlightBmodel) and -the back end (before doing the lighting calculation) -=============== -*/ -void R_TransformDlights( int count, dlight_t *dl, orientationr_t *or) { - int i; - vec3_t temp; - - for ( i = 0 ; i < count ; i++, dl++ ) { - VectorSubtract( dl->origin, or->origin, temp ); - dl->transformed[0] = DotProduct( temp, or->axis[0] ); - dl->transformed[1] = DotProduct( temp, or->axis[1] ); - dl->transformed[2] = DotProduct( temp, or->axis[2] ); - } -} - -/* -============= -R_DlightBmodel - -Determine which dynamic lights may effect this bmodel -============= -*/ -void R_DlightBmodel( bmodel_t *bmodel ) { - int i, j; - const dlight_t *dl; - int mask; - msurface_t *surf; - - // transform all the lights - R_TransformDlights( tr.refdef.num_dlights, tr.refdef.dlights, &tr.or ); - - mask = 0; - for ( i=0 ; itransformed[j] - bmodel->bounds[1][j] > dl->radius ) { - break; - } - if ( bmodel->bounds[0][j] - dl->transformed[j] > dl->radius ) { - break; - } - } - if ( j < 3 ) { - continue; - } - - // we need to check this light - mask |= 1 << i; - } - - tr.currentEntity->needDlights = (mask != 0); - - // set the dlight bits in all the surfaces - for ( i = 0 ; i < bmodel->numSurfaces ; i++ ) { - surf = tr.world->surfaces + bmodel->firstSurface + i; - - switch(*surf->data) - { - case SF_FACE: - case SF_GRID: - case SF_TRIANGLES: - ((srfBspSurface_t *)surf->data)->dlightBits = mask; - break; - - default: - break; - } - } -} - - -/* -============================================================================= - -LIGHT SAMPLING - -============================================================================= -*/ - -extern cvar_t *r_ambientScale; -extern cvar_t *r_directedScale; -extern cvar_t *r_debugLight; - -/* -================= -R_SetupEntityLightingGrid - -================= -*/ -static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) { - vec3_t lightOrigin; - int pos[3]; - int i, j; - byte *gridData; - float frac[3]; - int gridStep[3]; - vec3_t direction; - float totalFactor; - - if ( ent->e.renderfx & RF_LIGHTING_ORIGIN ) { - // separate lightOrigins are needed so an object that is - // sinking into the ground can still be lit, and so - // multi-part models can be lit identically - VectorCopy( ent->e.lightingOrigin, lightOrigin ); - } else { - VectorCopy( ent->e.origin, lightOrigin ); - } - - VectorSubtract( lightOrigin, world->lightGridOrigin, lightOrigin ); - for ( i = 0 ; i < 3 ; i++ ) { - float v; - - v = lightOrigin[i]*world->lightGridInverseSize[i]; - pos[i] = floor( v ); - frac[i] = v - pos[i]; - if ( pos[i] < 0 ) { - pos[i] = 0; - } else if ( pos[i] > world->lightGridBounds[i] - 1 ) { - pos[i] = world->lightGridBounds[i] - 1; - } - } - - VectorClear( ent->ambientLight ); - VectorClear( ent->directedLight ); - VectorClear( direction ); - - assert( world->lightGridData ); // NULL with -nolight maps - - // trilerp the light value - gridStep[0] = 8; - gridStep[1] = 8 * world->lightGridBounds[0]; - gridStep[2] = 8 * world->lightGridBounds[0] * world->lightGridBounds[1]; - gridData = world->lightGridData + pos[0] * gridStep[0] - + pos[1] * gridStep[1] + pos[2] * gridStep[2]; - - totalFactor = 0; - for ( i = 0 ; i < 8 ; i++ ) { - float factor; - byte *data; - int lat, lng; - vec3_t normal; - #if idppc - float d0, d1, d2, d3, d4, d5; - #endif - factor = 1.0; - data = gridData; - for ( j = 0 ; j < 3 ; j++ ) { - if ( i & (1< world->lightGridBounds[j] - 1 ) { - break; // ignore values outside lightgrid - } - factor *= frac[j]; - data += gridStep[j]; - } else { - factor *= (1.0f - frac[j]); - } - } - - if ( j != 3 ) { - continue; - } - - if (world->lightGrid16) - { - uint16_t *data16 = world->lightGrid16 + (int)(data - world->lightGridData) / 8 * 6; - if (!(data16[0]+data16[1]+data16[2]+data16[3]+data16[4]+data16[5])) { - continue; // ignore samples in walls - } - } - else - { - if (!(data[0]+data[1]+data[2]+data[3]+data[4]+data[5]) ) { - continue; // ignore samples in walls - } - } - totalFactor += factor; - #if idppc - d0 = data[0]; d1 = data[1]; d2 = data[2]; - d3 = data[3]; d4 = data[4]; d5 = data[5]; - - ent->ambientLight[0] += factor * d0; - ent->ambientLight[1] += factor * d1; - ent->ambientLight[2] += factor * d2; - - ent->directedLight[0] += factor * d3; - ent->directedLight[1] += factor * d4; - ent->directedLight[2] += factor * d5; - #else - if (world->lightGrid16) - { - // FIXME: this is hideous - uint16_t *data16 = world->lightGrid16 + (int)(data - world->lightGridData) / 8 * 6; - - ent->ambientLight[0] += factor * data16[0] / 257.0f; - ent->ambientLight[1] += factor * data16[1] / 257.0f; - ent->ambientLight[2] += factor * data16[2] / 257.0f; - - ent->directedLight[0] += factor * data16[3] / 257.0f; - ent->directedLight[1] += factor * data16[4] / 257.0f; - ent->directedLight[2] += factor * data16[5] / 257.0f; - } - else - { - ent->ambientLight[0] += factor * data[0]; - ent->ambientLight[1] += factor * data[1]; - ent->ambientLight[2] += factor * data[2]; - - ent->directedLight[0] += factor * data[3]; - ent->directedLight[1] += factor * data[4]; - ent->directedLight[2] += factor * data[5]; - } - #endif - lat = data[7]; - lng = data[6]; - lat *= (FUNCTABLE_SIZE/256); - lng *= (FUNCTABLE_SIZE/256); - - // decode X as cos( lat ) * sin( long ) - // decode Y as sin( lat ) * sin( long ) - // decode Z as cos( long ) - - normal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng]; - normal[1] = tr.sinTable[lat] * tr.sinTable[lng]; - normal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK]; - - VectorMA( direction, factor, normal, direction ); - } - - if ( totalFactor > 0 && totalFactor < 0.99 ) { - totalFactor = 1.0f / totalFactor; - VectorScale( ent->ambientLight, totalFactor, ent->ambientLight ); - VectorScale( ent->directedLight, totalFactor, ent->directedLight ); - } - - VectorScale( ent->ambientLight, r_ambientScale->value, ent->ambientLight ); - VectorScale( ent->directedLight, r_directedScale->value, ent->directedLight ); - - VectorNormalize2( direction, ent->lightDir ); -} - - -/* -=============== -LogLight -=============== -*/ -static void LogLight( const trRefEntity_t *ent ) { - int max1, max2; - - if ( !(ent->e.renderfx & RF_FIRST_PERSON ) ) { - return; - } - - max1 = ent->ambientLight[0]; - if ( ent->ambientLight[1] > max1 ) { - max1 = ent->ambientLight[1]; - } else if ( ent->ambientLight[2] > max1 ) { - max1 = ent->ambientLight[2]; - } - - max2 = ent->directedLight[0]; - if ( ent->directedLight[1] > max2 ) { - max2 = ent->directedLight[1]; - } else if ( ent->directedLight[2] > max2 ) { - max2 = ent->directedLight[2]; - } - - ri.Printf( PRINT_ALL, "amb:%i dir:%i\n", max1, max2 ); -} - -/* -================= -R_SetupEntityLighting - -Calculates all the lighting values that will be used -by the Calc_* functions -================= -*/ -void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { - int i; - const dlight_t *dl; - float power; - vec3_t dir; - float d; - vec3_t lightDir; - vec3_t lightOrigin; - - // lighting calculations - if ( ent->lightingCalculated ) { - return; - } - ent->lightingCalculated = qtrue; - - // - // trace a sample point down to find ambient light - // - if ( ent->e.renderfx & RF_LIGHTING_ORIGIN ) { - // separate lightOrigins are needed so an object that is - // sinking into the ground can still be lit, and so - // multi-part models can be lit identically - VectorCopy( ent->e.lightingOrigin, lightOrigin ); - } else { - VectorCopy( ent->e.origin, lightOrigin ); - } - - // if NOWORLDMODEL, only use dynamic lights (menu system, etc) - if ( !(refdef->rdflags & RDF_NOWORLDMODEL ) - && tr.world->lightGridData ) { - R_SetupEntityLightingGrid( ent, tr.world ); - } else { - ent->ambientLight[0] = ent->ambientLight[1] = - ent->ambientLight[2] = tr.identityLight * 150; - ent->directedLight[0] = ent->directedLight[1] = - ent->directedLight[2] = tr.identityLight * 150; - VectorCopy( tr.sunDirection, ent->lightDir ); - } - - // bonus items and view weapons have a fixed minimum add - if ( 1 /* ent->e.renderfx & RF_MINLIGHT */ ) { - // give everything a minimum light add - ent->ambientLight[0] += tr.identityLight * 32; - ent->ambientLight[1] += tr.identityLight * 32; - ent->ambientLight[2] += tr.identityLight * 32; - } - - // - // modify the light by dynamic lights - // - d = VectorLength( ent->directedLight ); - VectorScale( ent->lightDir, d, lightDir ); - - for ( i = 0 ; i < refdef->num_dlights ; i++ ) { - dl = &refdef->dlights[i]; - VectorSubtract( dl->origin, lightOrigin, dir ); - d = VectorNormalize( dir ); - - power = DLIGHT_AT_RADIUS * ( dl->radius * dl->radius ); - if ( d < DLIGHT_MINIMUM_RADIUS ) { - d = DLIGHT_MINIMUM_RADIUS; - } - d = power / ( d * d ); - - VectorMA( ent->directedLight, d, dl->color, ent->directedLight ); - VectorMA( lightDir, d, dir, lightDir ); - } - - // clamp lights - // FIXME: old renderer clamps (ambient + NL * directed) per vertex - // check if that's worth implementing - { - float r, g, b, max; - - r = ent->ambientLight[0]; - g = ent->ambientLight[1]; - b = ent->ambientLight[2]; - - max = MAX(MAX(r, g), b); - - if (max > 255.0f) - { - max = 255.0f / max; - ent->ambientLight[0] *= max; - ent->ambientLight[1] *= max; - ent->ambientLight[2] *= max; - } - - r = ent->directedLight[0]; - g = ent->directedLight[1]; - b = ent->directedLight[2]; - - max = MAX(MAX(r, g), b); - - if (max > 255.0f) - { - max = 255.0f / max; - ent->directedLight[0] *= max; - ent->directedLight[1] *= max; - ent->directedLight[2] *= max; - } - } - - if ( r_debugLight->integer ) { - LogLight( ent ); - } - - // save out the byte packet version - ((byte *)&ent->ambientLightInt)[0] = myftol(ent->ambientLight[0]); - ((byte *)&ent->ambientLightInt)[1] = myftol(ent->ambientLight[1]); - ((byte *)&ent->ambientLightInt)[2] = myftol(ent->ambientLight[2]); - ((byte *)&ent->ambientLightInt)[3] = 0xff; - - // transform the direction to local space - VectorNormalize( lightDir ); - ent->modelLightDir[0] = DotProduct( lightDir, ent->e.axis[0] ); - ent->modelLightDir[1] = DotProduct( lightDir, ent->e.axis[1] ); - ent->modelLightDir[2] = DotProduct( lightDir, ent->e.axis[2] ); - - VectorCopy(lightDir, ent->lightDir); -} - -/* -================= -R_LightForPoint -================= -*/ -int R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir ) -{ - trRefEntity_t ent; - - if ( tr.world->lightGridData == NULL ) - return qfalse; - - Com_Memset(&ent, 0, sizeof(ent)); - VectorCopy( point, ent.e.origin ); - R_SetupEntityLightingGrid( &ent, tr.world ); - VectorCopy(ent.ambientLight, ambientLight); - VectorCopy(ent.directedLight, directedLight); - VectorCopy(ent.lightDir, lightDir); - - return qtrue; -} - - -int R_LightDirForPoint( vec3_t point, vec3_t lightDir, vec3_t normal, world_t *world ) -{ - trRefEntity_t ent; - - if ( world->lightGridData == NULL ) - return qfalse; - - Com_Memset(&ent, 0, sizeof(ent)); - VectorCopy( point, ent.e.origin ); - R_SetupEntityLightingGrid( &ent, world ); - - if (DotProduct(ent.lightDir, normal) > 0.2f) - VectorCopy(ent.lightDir, lightDir); - else - VectorCopy(normal, lightDir); - - return qtrue; -} - - -int R_CubemapForPoint( vec3_t point ) -{ - int cubemapIndex = -1; - - if (r_cubeMapping->integer && tr.numCubemaps) - { - int i; - vec_t shortest = (float)WORLD_SIZE * (float)WORLD_SIZE; - - for (i = 0; i < tr.numCubemaps; i++) - { - vec3_t diff; - vec_t length; - - VectorSubtract(point, tr.cubemaps[i].origin, diff); - length = DotProduct(diff, diff); - - if (shortest > length) - { - shortest = length; - cubemapIndex = i; - } - } - } - - return cubemapIndex + 1; -} diff --git a/code/renderer2/tr_local.h b/code/renderer2/tr_local.h deleted file mode 100644 index 9f765eda47..0000000000 --- a/code/renderer2/tr_local.h +++ /dev/null @@ -1,2492 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ - - -#ifndef TR_LOCAL_H -#define TR_LOCAL_H - -#include "../qcommon/q_shared.h" -#include "../qcommon/qfiles.h" -#include "../qcommon/qcommon.h" -#include "../renderercommon/tr_public.h" -#include "tr_common.h" -#include "tr_extratypes.h" -#include "tr_extramath.h" -#include "tr_fbo.h" -#include "tr_postprocess.h" -#include "../renderer/iqm.h" -#include "qgl.h" - -#define GL_INDEX_TYPE GL_UNSIGNED_INT -typedef unsigned int glIndex_t; - -#define BUFFER_OFFSET(i) ((char *)NULL + (i)) - -#define REFENTITYNUM_BITS 11 // can't be increased without changing drawsurf bit packing -#define REFENTITYNUM_MASK ((1<or.origin in local coordinates - float modelMatrix[16]; - float transformMatrix[16]; -} orientationr_t; - -// Ensure this is >= the ATTR_INDEX_COUNT enum below -#define VAO_MAX_ATTRIBS 16 - -typedef enum -{ - VAO_USAGE_STATIC, - VAO_USAGE_DYNAMIC -} vaoUsage_t; - -typedef struct vaoAttrib_s -{ - uint32_t enabled; - uint32_t count; - uint32_t type; - uint32_t normalized; - uint32_t stride; - uint32_t offset; -} -vaoAttrib_t; - -typedef struct vao_s -{ - char name[MAX_QPATH]; - - uint32_t vao; - - uint32_t vertexesVBO; - int vertexesSize; // amount of memory data allocated for all vertices in bytes - vaoAttrib_t attribs[VAO_MAX_ATTRIBS]; - - uint32_t frameSize; // bytes to skip per frame when doing vertex animation - - uint32_t indexesIBO; - int indexesSize; // amount of memory data allocated for all triangles in bytes -} vao_t; - -//=============================================================================== - -typedef enum { - SS_BAD, - SS_PORTAL, // mirrors, portals, viewscreens - SS_ENVIRONMENT, // sky box - SS_OPAQUE, // opaque - - SS_DECAL, // scorch marks, etc. - SS_SEE_THROUGH, // ladders, grates, grills that may have small blended edges - // in addition to alpha test - SS_BANNER, - - SS_FOG, - - SS_UNDERWATER, // for items that should be drawn in front of the water plane - - SS_BLEND0, // regular transparency and filters - SS_BLEND1, // generally only used for additive type effects - SS_BLEND2, - SS_BLEND3, - - SS_BLEND6, - SS_STENCIL_SHADOW, - SS_ALMOST_NEAREST, // gun smoke puffs - - SS_NEAREST // blood blobs -} shaderSort_t; - - -#define MAX_SHADER_STAGES 8 - -typedef enum { - GF_NONE, - - GF_SIN, - GF_SQUARE, - GF_TRIANGLE, - GF_SAWTOOTH, - GF_INVERSE_SAWTOOTH, - - GF_NOISE - -} genFunc_t; - - -typedef enum { - DEFORM_NONE, - DEFORM_WAVE, - DEFORM_NORMALS, - DEFORM_BULGE, - DEFORM_MOVE, - DEFORM_PROJECTION_SHADOW, - DEFORM_AUTOSPRITE, - DEFORM_AUTOSPRITE2, - DEFORM_TEXT0, - DEFORM_TEXT1, - DEFORM_TEXT2, - DEFORM_TEXT3, - DEFORM_TEXT4, - DEFORM_TEXT5, - DEFORM_TEXT6, - DEFORM_TEXT7 -} deform_t; - -// deformVertexes types that can be handled by the GPU -typedef enum -{ - // do not edit: same as genFunc_t - - DGEN_NONE, - DGEN_WAVE_SIN, - DGEN_WAVE_SQUARE, - DGEN_WAVE_TRIANGLE, - DGEN_WAVE_SAWTOOTH, - DGEN_WAVE_INVERSE_SAWTOOTH, - DGEN_WAVE_NOISE, - - // do not edit until this line - - DGEN_BULGE, - DGEN_MOVE -} deformGen_t; - -typedef enum { - AGEN_IDENTITY, - AGEN_SKIP, - AGEN_ENTITY, - AGEN_ONE_MINUS_ENTITY, - AGEN_VERTEX, - AGEN_ONE_MINUS_VERTEX, - AGEN_LIGHTING_SPECULAR, - AGEN_WAVEFORM, - AGEN_PORTAL, - AGEN_CONST, -} alphaGen_t; - -typedef enum { - CGEN_BAD, - CGEN_IDENTITY_LIGHTING, // tr.identityLight - CGEN_IDENTITY, // always (1,1,1,1) - CGEN_ENTITY, // grabbed from entity's modulate field - CGEN_ONE_MINUS_ENTITY, // grabbed from 1 - entity.modulate - CGEN_EXACT_VERTEX, // tess.vertexColors - CGEN_VERTEX, // tess.vertexColors * tr.identityLight - CGEN_EXACT_VERTEX_LIT, // like CGEN_EXACT_VERTEX but takes a light direction from the lightgrid - CGEN_VERTEX_LIT, // like CGEN_VERTEX but takes a light direction from the lightgrid - CGEN_ONE_MINUS_VERTEX, - CGEN_WAVEFORM, // programmatically generated - CGEN_LIGHTING_DIFFUSE, - CGEN_FOG, // standard fog - CGEN_CONST // fixed color -} colorGen_t; - -typedef enum { - TCGEN_BAD, - TCGEN_IDENTITY, // clear to 0,0 - TCGEN_LIGHTMAP, - TCGEN_TEXTURE, - TCGEN_ENVIRONMENT_MAPPED, - TCGEN_ENVIRONMENT_MAPPED_FP, // with correct first-person mapping - TCGEN_FOG, - TCGEN_VECTOR // S and T from world coordinates -} texCoordGen_t; - -typedef enum { - ACFF_NONE, - ACFF_MODULATE_RGB, - ACFF_MODULATE_RGBA, - ACFF_MODULATE_ALPHA -} acff_t; - -typedef struct { - float base; - float amplitude; - float phase; - float frequency; - - genFunc_t func; -} waveForm_t; - -#define TR_MAX_TEXMODS 4 - -typedef enum { - TMOD_NONE, - TMOD_TRANSFORM, - TMOD_TURBULENT, - TMOD_SCROLL, - TMOD_SCALE, - TMOD_STRETCH, - TMOD_ROTATE, - TMOD_ENTITY_TRANSLATE -} texMod_t; - -#define MAX_SHADER_DEFORMS 3 -typedef struct { - deform_t deformation; // vertex coordinate modification type - - vec3_t moveVector; - waveForm_t deformationWave; - float deformationSpread; - - float bulgeWidth; - float bulgeHeight; - float bulgeSpeed; -} deformStage_t; - - -typedef struct { - texMod_t type; - - // used for TMOD_TURBULENT and TMOD_STRETCH - waveForm_t wave; - - // used for TMOD_TRANSFORM - float matrix[2][2]; // s' = s * m[0][0] + t * m[1][0] + trans[0] - float translate[2]; // t' = s * m[0][1] + t * m[0][1] + trans[1] - - // used for TMOD_SCALE - float scale[2]; // s *= scale[0] - // t *= scale[1] - - // used for TMOD_SCROLL - float scroll[2]; // s' = s + scroll[0] * time - // t' = t + scroll[1] * time - - // + = clockwise - // - = counterclockwise - float rotateSpeed; - -} texModInfo_t; - - -#define MAX_IMAGE_ANIMATIONS 24 -#define MAX_IMAGE_ANIMATIONS_VQ3 8 - -typedef struct { - image_t *image[MAX_IMAGE_ANIMATIONS]; - int numImageAnimations; - double imageAnimationSpeed; - - texCoordGen_t tcGen; - vec3_t tcGenVectors[2]; - - int numTexMods; - texModInfo_t *texMods; - - int videoMapHandle; - qboolean isLightmap; - qboolean isVideoMap; -} textureBundle_t; - - -enum -{ - TB_COLORMAP = 0, - TB_DIFFUSEMAP = 0, - TB_LIGHTMAP = 1, - TB_LEVELSMAP = 1, - TB_SHADOWMAP3 = 1, - TB_NORMALMAP = 2, - TB_DELUXEMAP = 3, - TB_SHADOWMAP2 = 3, - TB_SPECULARMAP = 4, - TB_SHADOWMAP = 5, - TB_CUBEMAP = 6, - TB_SHADOWMAP4 = 6, - NUM_TEXTURE_BUNDLES = 7 -}; - -typedef enum -{ - // material shader stage types - ST_COLORMAP = 0, // vanilla Q3A style shader treatening - ST_DIFFUSEMAP = 0, // treat color and diffusemap the same - ST_NORMALMAP, - ST_NORMALPARALLAXMAP, - ST_SPECULARMAP, - ST_GLSL -} stageType_t; - -typedef struct { - qboolean active; - - textureBundle_t bundle[NUM_TEXTURE_BUNDLES]; - - waveForm_t rgbWave; - colorGen_t rgbGen; - - waveForm_t alphaWave; - alphaGen_t alphaGen; - - byte constantColor[4]; // for CGEN_CONST and AGEN_CONST - - unsigned stateBits; // GLS_xxxx mask - - acff_t adjustColorsForFog; - - qboolean isDetail; - - stageType_t type; - struct shaderProgram_s *glslShaderGroup; - int glslShaderIndex; - - vec4_t normalScale; - vec4_t specularScale; - -} shaderStage_t; - -struct shaderCommands_s; - -typedef enum { - CT_FRONT_SIDED, - CT_BACK_SIDED, - CT_TWO_SIDED -} cullType_t; - -typedef enum { - FP_NONE, // surface is translucent and will just be adjusted properly - FP_EQUAL, // surface is opaque but possibly alpha tested - FP_LE // surface is translucent, but still needs a fog pass (fog surface) -} fogPass_t; - -typedef struct { - float cloudHeight; - image_t *outerbox[6], *innerbox[6]; -} skyParms_t; - -typedef struct { - vec3_t color; - float depthForOpaque; -} fogParms_t; - -typedef struct shader_s { - char name[MAX_QPATH]; // game path, including extension - int lightmapSearchIndex; // for a shader to match, both name and lightmapIndex must match - int lightmapIndex; // for rendering - - int index; // this shader == tr.shaders[index] - int sortedIndex; // this shader == tr.sortedShaders[sortedIndex] - - float sort; // lower numbered shaders draw before higher numbered - - qboolean defaultShader; // we want to return index 0 if the shader failed to - // load for some reason, but R_FindShader should - // still keep a name allocated for it, so if - // something calls RE_RegisterShader again with - // the same name, we don't try looking for it again - - qboolean explicitlyDefined; // found in a .shader file - - int surfaceFlags; // if explicitlyDefined, this will have SURF_* flags - int contentFlags; - - qboolean entityMergable; // merge across entites optimizable (smoke, blood) - - qboolean isSky; - skyParms_t sky; - fogParms_t fogParms; - - float portalRange; // distance to fog out at - qboolean isPortal; - - cullType_t cullType; // CT_FRONT_SIDED, CT_BACK_SIDED, or CT_TWO_SIDED - qboolean polygonOffset; // set for decals and other items that must be offset - qboolean noMipMaps; // for console fonts, 2D elements, etc. - qboolean noPicMip; // for images that must always be full resolution - - fogPass_t fogPass; // draw a blended pass, possibly with depth test equals - - int vertexAttribs; // not all shaders will need all data to be gathered - - int numDeforms; - deformStage_t deforms[MAX_SHADER_DEFORMS]; - - int numUnfoggedPasses; - shaderStage_t *stages[MAX_SHADER_STAGES]; - - int lightingStage; - - void (*optimalStageIteratorFunc)( void ); - - double clampTime; // time this shader is clamped to - set to double for frameloss fix -EC- - double timeOffset; // current time offset for this shader - set to double for frameloss fix -EC- - - struct shader_s *remappedShader; // current shader this one is remapped too - - struct shader_s *next; -} shader_t; - -enum -{ - ATTR_INDEX_POSITION = 0, - ATTR_INDEX_TEXCOORD = 1, - ATTR_INDEX_LIGHTCOORD = 2, - ATTR_INDEX_TANGENT = 3, - ATTR_INDEX_NORMAL = 4, - ATTR_INDEX_COLOR = 5, - ATTR_INDEX_PAINTCOLOR = 6, - ATTR_INDEX_LIGHTDIRECTION = 7, - ATTR_INDEX_BONE_INDEXES = 8, - ATTR_INDEX_BONE_WEIGHTS = 9, - - // GPU vertex animations - ATTR_INDEX_POSITION2 = 10, - ATTR_INDEX_TANGENT2 = 11, - ATTR_INDEX_NORMAL2 = 12, - - ATTR_INDEX_COUNT = 13 -}; - -enum -{ - ATTR_POSITION = 1 << ATTR_INDEX_POSITION, - ATTR_TEXCOORD = 1 << ATTR_INDEX_TEXCOORD, - ATTR_LIGHTCOORD = 1 << ATTR_INDEX_LIGHTCOORD, - ATTR_TANGENT = 1 << ATTR_INDEX_TANGENT, - ATTR_NORMAL = 1 << ATTR_INDEX_NORMAL, - ATTR_COLOR = 1 << ATTR_INDEX_COLOR, - ATTR_PAINTCOLOR = 1 << ATTR_INDEX_PAINTCOLOR, - ATTR_LIGHTDIRECTION = 1 << ATTR_INDEX_LIGHTDIRECTION, - ATTR_BONE_INDEXES = 1 << ATTR_INDEX_BONE_INDEXES, - ATTR_BONE_WEIGHTS = 1 << ATTR_INDEX_BONE_WEIGHTS, - - // for .md3 interpolation - ATTR_POSITION2 = 1 << ATTR_INDEX_POSITION2, - ATTR_TANGENT2 = 1 << ATTR_INDEX_TANGENT2, - ATTR_NORMAL2 = 1 << ATTR_INDEX_NORMAL2, - - ATTR_DEFAULT = ATTR_POSITION, - ATTR_BITS = ATTR_POSITION | - ATTR_TEXCOORD | - ATTR_LIGHTCOORD | - ATTR_TANGENT | - ATTR_NORMAL | - ATTR_COLOR | - ATTR_PAINTCOLOR | - ATTR_LIGHTDIRECTION | - ATTR_BONE_INDEXES | - ATTR_BONE_WEIGHTS | - ATTR_POSITION2 | - ATTR_TANGENT2 | - ATTR_NORMAL2 -}; - -enum -{ - GENERICDEF_USE_DEFORM_VERTEXES = 0x0001, - GENERICDEF_USE_TCGEN_AND_TCMOD = 0x0002, - GENERICDEF_USE_VERTEX_ANIMATION = 0x0004, - GENERICDEF_USE_FOG = 0x0008, - GENERICDEF_USE_RGBAGEN = 0x0010, - GENERICDEF_USE_BONE_ANIMATION = 0x0020, - GENERICDEF_ALL = 0x003F, - GENERICDEF_COUNT = 0x0040, -}; - -enum -{ - FOGDEF_USE_DEFORM_VERTEXES = 0x0001, - FOGDEF_USE_VERTEX_ANIMATION = 0x0002, - FOGDEF_USE_BONE_ANIMATION = 0x0004, - FOGDEF_ALL = 0x0007, - FOGDEF_COUNT = 0x0008, -}; - -enum -{ - DLIGHTDEF_USE_DEFORM_VERTEXES = 0x0001, - DLIGHTDEF_ALL = 0x0001, - DLIGHTDEF_COUNT = 0x0002, -}; - -enum -{ - LIGHTDEF_USE_LIGHTMAP = 0x0001, - LIGHTDEF_USE_LIGHT_VECTOR = 0x0002, - LIGHTDEF_USE_LIGHT_VERTEX = 0x0003, - LIGHTDEF_LIGHTTYPE_MASK = 0x0003, - LIGHTDEF_ENTITY_VERTEX_ANIMATION = 0x0004, - LIGHTDEF_USE_TCGEN_AND_TCMOD = 0x0008, - LIGHTDEF_USE_PARALLAXMAP = 0x0010, - LIGHTDEF_USE_SHADOWMAP = 0x0020, - LIGHTDEF_ENTITY_BONE_ANIMATION = 0x0040, - LIGHTDEF_ALL = 0x007F, - LIGHTDEF_COUNT = 0x0080 -}; - -enum -{ - SHADOWMAPDEF_USE_VERTEX_ANIMATION = 0x0001, - SHADOWMAPDEF_USE_BONE_ANIMATION = 0x0002, - SHADOWMAPDEF_ALL = 0x0003, - SHADOWMAPDEF_COUNT = 0x0004 -}; - -enum -{ - GLSL_INT, - GLSL_FLOAT, - GLSL_FLOAT5, - GLSL_VEC2, - GLSL_VEC3, - GLSL_VEC4, - GLSL_MAT16, - GLSL_MAT16_BONEMATRIX -}; - -typedef enum -{ - UNIFORM_DIFFUSEMAP = 0, - UNIFORM_LIGHTMAP, - UNIFORM_NORMALMAP, - UNIFORM_DELUXEMAP, - UNIFORM_SPECULARMAP, - - UNIFORM_TEXTUREMAP, - UNIFORM_LEVELSMAP, - UNIFORM_CUBEMAP, - - UNIFORM_SCREENIMAGEMAP, - UNIFORM_SCREENDEPTHMAP, - - UNIFORM_SHADOWMAP, - UNIFORM_SHADOWMAP2, - UNIFORM_SHADOWMAP3, - UNIFORM_SHADOWMAP4, - - UNIFORM_SHADOWMVP, - UNIFORM_SHADOWMVP2, - UNIFORM_SHADOWMVP3, - UNIFORM_SHADOWMVP4, - - UNIFORM_ENABLETEXTURES, - - UNIFORM_DIFFUSETEXMATRIX, - UNIFORM_DIFFUSETEXOFFTURB, - - UNIFORM_TCGEN0, - UNIFORM_TCGEN0VECTOR0, - UNIFORM_TCGEN0VECTOR1, - - UNIFORM_DEFORMGEN, - UNIFORM_DEFORMPARAMS, - - UNIFORM_COLORGEN, - UNIFORM_ALPHAGEN, - UNIFORM_COLOR, - UNIFORM_BASECOLOR, - UNIFORM_VERTCOLOR, - - UNIFORM_DLIGHTINFO, - UNIFORM_LIGHTFORWARD, - UNIFORM_LIGHTUP, - UNIFORM_LIGHTRIGHT, - UNIFORM_LIGHTORIGIN, - UNIFORM_MODELLIGHTDIR, - UNIFORM_LIGHTRADIUS, - UNIFORM_AMBIENTLIGHT, - UNIFORM_DIRECTEDLIGHT, - - UNIFORM_PORTALRANGE, - - UNIFORM_FOGDISTANCE, - UNIFORM_FOGDEPTH, - UNIFORM_FOGEYET, - UNIFORM_FOGCOLORMASK, - - UNIFORM_MODELMATRIX, - UNIFORM_MODELVIEWPROJECTIONMATRIX, - - UNIFORM_TIME, - UNIFORM_VERTEXLERP, - UNIFORM_NORMALSCALE, - UNIFORM_SPECULARSCALE, - - UNIFORM_VIEWINFO, // znear, zfar, width/2, height/2 - UNIFORM_VIEWORIGIN, - UNIFORM_LOCALVIEWORIGIN, - UNIFORM_VIEWFORWARD, - UNIFORM_VIEWLEFT, - UNIFORM_VIEWUP, - - UNIFORM_INVTEXRES, - UNIFORM_AUTOEXPOSUREMINMAX, - UNIFORM_TONEMINAVGMAXLINEAR, - - UNIFORM_PRIMARYLIGHTORIGIN, - UNIFORM_PRIMARYLIGHTCOLOR, - UNIFORM_PRIMARYLIGHTAMBIENT, - UNIFORM_PRIMARYLIGHTRADIUS, - - UNIFORM_CUBEMAPINFO, - - UNIFORM_ALPHATEST, - - UNIFORM_BONEMATRIX, - - UNIFORM_COUNT -} uniform_t; - -// shaderProgram_t represents a pair of one -// GLSL vertex and one GLSL fragment shader -typedef struct shaderProgram_s -{ - char name[MAX_QPATH]; - - GLuint program; - GLuint vertexShader; - GLuint fragmentShader; - uint32_t attribs; // vertex array attributes - - // uniform parameters - GLint uniforms[UNIFORM_COUNT]; - short uniformBufferOffsets[UNIFORM_COUNT]; // max 32767/64=511 uniforms - char *uniformBuffer; -} shaderProgram_t; - -// trRefdef_t holds everything that comes in refdef_t, -// as well as the locally generated scene information -typedef struct { - int x, y, width, height; - float fov_x, fov_y; - vec3_t vieworg; - vec3_t viewaxis[3]; // transformation matrix - - stereoFrame_t stereoFrame; - - int time; // time in milliseconds for shader effects and other time dependent rendering issues - int rdflags; // RDF_NOWORLDMODEL, etc - - // 1 bits will prevent the associated area from rendering at all - byte areamask[MAX_MAP_AREA_BYTES]; - qboolean areamaskModified; // qtrue if areamask changed since last scene - - double floatTime; // tr.refdef.time / 1000.0 - - float blurFactor; - - // text messages for deform text shaders - char text[MAX_RENDER_STRINGS][MAX_RENDER_STRING_LENGTH]; - - int num_entities; - trRefEntity_t *entities; - - int num_dlights; - struct dlight_s *dlights; - - int numPolys; - struct srfPoly_s *polys; - - int numDrawSurfs; - struct drawSurf_s *drawSurfs; - - unsigned int dlightMask; - int num_pshadows; - struct pshadow_s *pshadows; - - float sunShadowMvp[4][16]; - float sunDir[4]; - float sunCol[4]; - float sunAmbCol[4]; - - float autoExposureMinMax[2]; - float toneMinAvgMaxLinear[3]; -} trRefdef_t; - - -//================================================================================= - -// max surfaces per-skin -// This is an arbitrary limit. Vanilla Q3 only supported 32 surfaces in skins but failed to -// enforce the maximum limit when reading skin files. It was possile to use more than 32 -// surfaces which accessed out of bounds memory past end of skin->surfaces hunk block. -#define MAX_SKIN_SURFACES 256 - -// skins allow models to be retextured without modifying the model file -typedef struct { - char name[MAX_QPATH]; - shader_t *shader; -} skinSurface_t; - -typedef struct skin_s { - char name[MAX_QPATH]; // game path, including extension - int numSurfaces; - skinSurface_t *surfaces; // dynamically allocated array of surfaces -} skin_t; - - -typedef struct { - int originalBrushNumber; - vec3_t bounds[2]; - - unsigned colorInt; // in packed byte format - float tcScale; // texture coordinate vector scales - fogParms_t parms; - - // for clipping distance in fog when outside - qboolean hasSurface; - float surface[4]; -} fog_t; - -typedef enum { - VPF_NONE = 0x00, - VPF_NOVIEWMODEL = 0x01, - VPF_SHADOWMAP = 0x02, - VPF_DEPTHSHADOW = 0x04, - VPF_DEPTHCLAMP = 0x08, - VPF_ORTHOGRAPHIC = 0x10, - VPF_USESUNLIGHT = 0x20, - VPF_FARPLANEFRUSTUM = 0x40, - VPF_NOCUBEMAPS = 0x80 -} viewParmFlags_t; - -typedef struct { - orientationr_t or; - orientationr_t world; - vec3_t pvsOrigin; // may be different than or.origin for portals - qboolean isPortal; // true if this view is through a portal - qboolean isMirror; // the portal is a mirror, invert the face culling - viewParmFlags_t flags; - int frameSceneNum; // copied from tr.frameSceneNum - int frameCount; // copied from tr.frameCount - cplane_t portalPlane; // clip anything behind this if mirroring - int viewportX, viewportY, viewportWidth, viewportHeight; - FBO_t *targetFbo; - int targetFboLayer; - int targetFboCubemapIndex; - float fovX, fovY; - float projectionMatrix[16]; - cplane_t frustum[5]; - vec3_t visBounds[2]; - float zFar; - float zNear; - stereoFrame_t stereoFrame; -} viewParms_t; - - -/* -============================================================================== - -SURFACES - -============================================================================== -*/ - -// any changes in surfaceType must be mirrored in rb_surfaceTable[] -typedef enum { - SF_BAD, - SF_SKIP, // ignore - SF_FACE, - SF_GRID, - SF_TRIANGLES, - SF_POLY, - SF_MDV, - SF_MDR, - SF_IQM, - SF_FLARE, - SF_ENTITY, // beams, rails, lightning, etc that can be determined by entity - SF_VAO_MDVMESH, - SF_VAO_IQM, - - SF_NUM_SURFACE_TYPES, - SF_MAX = 0x7fffffff // ensures that sizeof( surfaceType_t ) == sizeof( int ) -} surfaceType_t; - -typedef struct drawSurf_s { - unsigned int sort; // bit combination for fast compares - int cubemapIndex; - surfaceType_t *surface; // any of surface*_t -} drawSurf_t; - -#define MAX_FACE_POINTS 64 - -#define MAX_PATCH_SIZE 32 // max dimensions of a patch mesh in map file -#define MAX_GRID_SIZE 65 // max dimensions of a grid mesh in memory - -// when cgame directly specifies a polygon, it becomes a srfPoly_t -// as soon as it is called -typedef struct srfPoly_s { - surfaceType_t surfaceType; - qhandle_t hShader; - int fogIndex; - int numVerts; - polyVert_t *verts; -} srfPoly_t; - - -typedef struct srfFlare_s { - surfaceType_t surfaceType; - vec3_t origin; - vec3_t normal; - vec3_t color; -} srfFlare_t; - -typedef struct -{ - vec3_t xyz; - vec2_t st; - vec2_t lightmap; - int16_t normal[4]; - int16_t tangent[4]; - int16_t lightdir[4]; - uint16_t color[4]; - -#if DEBUG_OPTIMIZEVERTICES - unsigned int id; -#endif -} srfVert_t; - -#define srfVert_t_cleared(x) srfVert_t (x) = {{0, 0, 0}, {0, 0}, {0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}} - -// srfBspSurface_t covers SF_GRID, SF_TRIANGLES, and SF_POLY -typedef struct srfBspSurface_s -{ - surfaceType_t surfaceType; - - // dynamic lighting information - int dlightBits; - int pshadowBits; - - // culling information - vec3_t cullBounds[2]; - vec3_t cullOrigin; - float cullRadius; - cplane_t cullPlane; - - // indexes - int numIndexes; - glIndex_t *indexes; - - // vertexes - int numVerts; - srfVert_t *verts; - - // SF_GRID specific variables after here - - // lod information, which may be different - // than the culling information to allow for - // groups of curves that LOD as a unit - vec3_t lodOrigin; - float lodRadius; - int lodFixed; - int lodStitched; - - // vertexes - int width, height; - float *widthLodError; - float *heightLodError; -} srfBspSurface_t; - -typedef struct { - vec3_t translate; - quat_t rotate; - vec3_t scale; -} iqmTransform_t; - -// inter-quake-model -typedef struct { - int num_vertexes; - int num_triangles; - int num_frames; - int num_surfaces; - int num_joints; - int num_poses; - struct srfIQModel_s *surfaces; - - int *triangles; - - // vertex arrays - float *positions; - float *texcoords; - float *normals; - float *tangents; - byte *colors; - int *influences; // [num_vertexes] indexes into influenceBlendVertexes - - // unique list of vertex blend indexes/weights for faster CPU vertex skinning - byte *influenceBlendIndexes; // [num_influences] - union { - float *f; - byte *b; - } influenceBlendWeights; // [num_influences] - - // depending upon the exporter, blend indices and weights might be int/float - // as opposed to the recommended byte/byte, for example Noesis exports - // int/float whereas the official IQM tool exports byte/byte - int blendWeightsType; // IQM_UBYTE or IQM_FLOAT - - char *jointNames; - int *jointParents; - float *bindJoints; // [num_joints * 12] - float *invBindJoints; // [num_joints * 12] - iqmTransform_t *poses; // [num_frames * num_poses] - float *bounds; - - int numVaoSurfaces; - struct srfVaoIQModel_s *vaoSurfaces; -} iqmData_t; - -// inter-quake-model surface -typedef struct srfIQModel_s { - surfaceType_t surfaceType; - char name[MAX_QPATH]; - shader_t *shader; - iqmData_t *data; - int first_vertex, num_vertexes; - int first_triangle, num_triangles; - int first_influence, num_influences; -} srfIQModel_t; - -typedef struct srfVaoIQModel_s -{ - surfaceType_t surfaceType; - - iqmData_t *iqmData; - struct srfIQModel_s *iqmSurface; - - // backEnd stats - int numIndexes; - int numVerts; - - // static render data - vao_t *vao; -} srfVaoIQModel_t; - -typedef struct srfVaoMdvMesh_s -{ - surfaceType_t surfaceType; - - struct mdvModel_s *mdvModel; - struct mdvSurface_s *mdvSurface; - - // backEnd stats - int numIndexes; - int numVerts; - - // static render data - vao_t *vao; -} srfVaoMdvMesh_t; - -extern void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])(void *); - -/* -============================================================================== - -SHADOWS - -============================================================================== -*/ - -typedef struct pshadow_s -{ - float sort; - - int numEntities; - int entityNums[8]; - vec3_t entityOrigins[8]; - float entityRadiuses[8]; - - float viewRadius; - vec3_t viewOrigin; - - vec3_t lightViewAxis[3]; - vec3_t lightOrigin; - float lightRadius; - cplane_t cullPlane; -} pshadow_t; - - -/* -============================================================================== - -BRUSH MODELS - -============================================================================== -*/ - - -// -// in memory representation -// - -#define SIDE_FRONT 0 -#define SIDE_BACK 1 -#define SIDE_ON 2 - -#define CULLINFO_NONE 0 -#define CULLINFO_BOX 1 -#define CULLINFO_SPHERE 2 -#define CULLINFO_PLANE 4 - -typedef struct cullinfo_s { - int type; - vec3_t bounds[2]; - vec3_t localOrigin; - float radius; - cplane_t plane; -} cullinfo_t; - -typedef struct msurface_s { - //int viewCount; // if == tr.viewCount, already added - struct shader_s *shader; - int fogIndex; - int cubemapIndex; - cullinfo_t cullinfo; - - surfaceType_t *data; // any of srf*_t -} msurface_t; - - -typedef struct mnode_s { - // common with leaf and node - int contents; // -1 for nodes, to differentiate from leafs - int visCounts[MAX_VISCOUNTS]; // node needs to be traversed if current - vec3_t mins, maxs; // for bounding box culling - struct mnode_s *parent; - - // node specific - cplane_t *plane; - struct mnode_s *children[2]; - - // leaf specific - int cluster; - int area; - - int firstmarksurface; - int nummarksurfaces; -} mnode_t; - -typedef struct { - vec3_t bounds[2]; // for culling - int firstSurface; - int numSurfaces; -} bmodel_t; - -typedef struct { - char name[MAX_QPATH]; // ie: maps/tim_dm2.bsp - char baseName[MAX_QPATH]; // ie: tim_dm2 - - int dataSize; - - int numShaders; - dshader_t *shaders; - - int numBModels; - bmodel_t *bmodels; - - int numplanes; - cplane_t *planes; - - int numnodes; // includes leafs - int numDecisionNodes; - mnode_t *nodes; - - int numWorldSurfaces; - - int numsurfaces; - msurface_t *surfaces; - int *surfacesViewCount; - int *surfacesDlightBits; - int *surfacesPshadowBits; - - int nummarksurfaces; - int *marksurfaces; - - int numfogs; - fog_t *fogs; - - vec3_t lightGridOrigin; - vec3_t lightGridSize; - vec3_t lightGridInverseSize; - int lightGridBounds[3]; - byte *lightGridData; - uint16_t *lightGrid16; - - - int numClusters; - int clusterBytes; - const byte *vis; // may be passed in by CM_LoadMap to save space - - char *entityString; - const char *entityParsePoint; -} world_t; - - -/* -============================================================================== -MDV MODELS - meta format for vertex animation models like .md2, .md3, .mdc -============================================================================== -*/ -typedef struct -{ - float bounds[2][3]; - float localOrigin[3]; - float radius; -} mdvFrame_t; - -typedef struct -{ - float origin[3]; - float axis[3][3]; -} mdvTag_t; - -typedef struct -{ - char name[MAX_QPATH]; // tag name -} mdvTagName_t; - -typedef struct -{ - vec3_t xyz; - int16_t normal[4]; - int16_t tangent[4]; -} mdvVertex_t; - -typedef struct -{ - float st[2]; -} mdvSt_t; - -typedef struct mdvSurface_s -{ - surfaceType_t surfaceType; - - char name[MAX_QPATH]; // polyset name - - int numShaderIndexes; - int *shaderIndexes; - - int numVerts; - mdvVertex_t *verts; - mdvSt_t *st; - - int numIndexes; - glIndex_t *indexes; - - struct mdvModel_s *model; -} mdvSurface_t; - -typedef struct mdvModel_s -{ - int numFrames; - mdvFrame_t *frames; - - int numTags; - mdvTag_t *tags; - mdvTagName_t *tagNames; - - int numSurfaces; - mdvSurface_t *surfaces; - - int numVaoSurfaces; - srfVaoMdvMesh_t *vaoSurfaces; - - int numSkins; -} mdvModel_t; - - -//====================================================================== - -typedef enum { - MOD_BAD, - MOD_BRUSH, - MOD_MESH, - MOD_MDR, - MOD_IQM -} modtype_t; - -typedef struct model_s { - char name[MAX_QPATH]; - modtype_t type; - int index; // model = tr.models[model->index] - - int dataSize; // just for listing purposes - bmodel_t *bmodel; // only if type == MOD_BRUSH - mdvModel_t *mdv[MD3_MAX_LODS]; // only if type == MOD_MESH - void *modelData; // only if type == (MOD_MDR | MOD_IQM) - - int numLods; -} model_t; - - -#define MAX_MOD_KNOWN 1024 - -void R_ModelInit (void); -model_t *R_GetModelByHandle( qhandle_t hModel ); -int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFrame, - float frac, const char *tagName ); -void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ); - -void R_Modellist_f (void); - -//==================================================== - -#define MAX_DRAWIMAGES 2048 -#define MAX_SKINS 1024 - - -#define MAX_DRAWSURFS 0x10000 -#define DRAWSURF_MASK (MAX_DRAWSURFS-1) - -/* - -the drawsurf sort data is packed into a single 32 bit value so it can be -compared quickly during the qsorting process - -the bits are allocated as follows: - -0 - 1 : dlightmap index -//2 : used to be clipped flag REMOVED - 03.21.00 rad -2 - 6 : fog index -11 - 20 : entity index -21 - 31 : sorted shader index - - TTimo - 1.32 -0-1 : dlightmap index -2-6 : fog index -7-16 : entity index -17-30 : sorted shader index - - SmileTheory - for pshadows -17-31 : sorted shader index -7-16 : entity index -2-6 : fog index -1 : pshadow flag -0 : dlight flag -*/ -#define QSORT_FOGNUM_SHIFT 2 -#define QSORT_REFENTITYNUM_SHIFT 7 -#define QSORT_SHADERNUM_SHIFT (QSORT_REFENTITYNUM_SHIFT+REFENTITYNUM_BITS) -#if (QSORT_SHADERNUM_SHIFT+SHADERNUM_BITS) > 32 - #error "Need to update sorting, too many bits." -#endif -#define QSORT_PSHADOW_SHIFT 1 - -extern int gl_filter_min, gl_filter_max; - -/* -** performanceCounters_t -*/ -typedef struct { - int c_sphere_cull_patch_in, c_sphere_cull_patch_clip, c_sphere_cull_patch_out; - int c_box_cull_patch_in, c_box_cull_patch_clip, c_box_cull_patch_out; - int c_sphere_cull_md3_in, c_sphere_cull_md3_clip, c_sphere_cull_md3_out; - int c_box_cull_md3_in, c_box_cull_md3_clip, c_box_cull_md3_out; - - int c_leafs; - int c_dlightSurfaces; - int c_dlightSurfacesCulled; -} frontEndCounters_t; - -#define FOG_TABLE_SIZE 256 -#define FUNCTABLE_SIZE 1024 -#define FUNCTABLE_SIZE2 10 -#define FUNCTABLE_MASK (FUNCTABLE_SIZE-1) - - -// the renderer front end should never modify glstate_t -typedef struct { - qboolean finishCalled; - int texEnv[2]; - int faceCulling; - int faceCullFront; - uint32_t glStateBits; - uint32_t storedGlState; - float vertexAttribsInterpolation; - qboolean vertexAnimation; - int boneAnimation; // number of bones - mat4_t boneMatrix[IQM_MAX_JOINTS]; - uint32_t vertexAttribsEnabled; // global if no VAOs, tess only otherwise - FBO_t *currentFBO; - vao_t *currentVao; - mat4_t modelview; - mat4_t projection; - mat4_t modelviewProjection; -} glstate_t; - -typedef enum { - MI_NONE, - MI_NVX, - MI_ATI -} memInfo_t; - -typedef enum { - TCR_NONE = 0x0000, - TCR_RGTC = 0x0001, - TCR_BPTC = 0x0002, -} textureCompressionRef_t; - -// We can't change glConfig_t without breaking DLL/vms compatibility, so -// store extensions we have here. -typedef struct { - qboolean intelGraphics; - - qboolean occlusionQuery; - - int glslMajorVersion; - int glslMinorVersion; - int glslMaxAnimatedBones; - - memInfo_t memInfo; - - qboolean framebufferObject; - int maxRenderbufferSize; - int maxColorAttachments; - - qboolean textureFloat; - textureCompressionRef_t textureCompression; - qboolean swizzleNormalmap; - - qboolean framebufferMultisample; - qboolean framebufferBlit; - - qboolean depthClamp; - qboolean seamlessCubeMap; - - qboolean vertexArrayObject; - qboolean directStateAccess; -} glRefConfig_t; - - -typedef struct { - int c_surfaces, c_shaders, c_vertexes, c_indexes, c_totalIndexes; - int c_surfBatches; - float c_overDraw; - - int c_vaoBinds; - int c_vaoVertexes; - int c_vaoIndexes; - - int c_staticVaoDraws; - int c_dynamicVaoDraws; - - int c_dlightVertexes; - int c_dlightIndexes; - - int c_flareAdds; - int c_flareTests; - int c_flareRenders; - - int c_glslShaderBinds; - int c_genericDraws; - int c_lightallDraws; - int c_fogDraws; - int c_dlightDraws; - - int msec; // total msec for backend run -} backEndCounters_t; - -// all state modified by the back end is separated -// from the front end state -typedef struct { - trRefdef_t refdef; - viewParms_t viewParms; - orientationr_t or; - backEndCounters_t pc; - qboolean isHyperspace; - const trRefEntity_t *currentEntity; - qboolean skyRenderedThisView; // flag for drawing sun - - qboolean projection2D; // if qtrue, drawstretchpic doesn't need to change modes - byte color2D[4]; - qboolean vertexes2D; // shader needs to be finished - trRefEntity_t entity2D; // currentEntity will point at this when doing 2D rendering - - FBO_t *last2DFBO; - qboolean colorMask[4]; - qboolean framePostProcessed; - qboolean depthFill; -} backEndState_t; - -/* -** trGlobals_t -** -** Most renderer globals are defined here. -** backend functions should never modify any of these fields, -** but may read fields that aren't dynamically modified -** by the frontend. -*/ -typedef struct { - qboolean registered; // cleared at shutdown, set at beginRegistration - - int visIndex; - int visClusters[MAX_VISCOUNTS]; - int visCounts[MAX_VISCOUNTS]; // incremented every time a new vis cluster is entered - - int frameCount; // incremented every frame - int sceneCount; // incremented every scene - int viewCount; // incremented every view (twice a scene if portaled) - // and every R_MarkFragments call - - int frameSceneNum; // zeroed at RE_BeginFrame - - qboolean worldMapLoaded; - qboolean worldDeluxeMapping; - vec2_t autoExposureMinMax; - vec3_t toneMinAvgMaxLevel; - world_t *world; - - const byte *externalVisData; // from RE_SetWorldVisData, shared with CM_Load - - image_t *defaultImage; - image_t *scratchImage[ MAX_VIDEO_HANDLES ]; - image_t *fogImage; - image_t *dlightImage; // inverse-quare highlight for projective adding - image_t *flareImage; - image_t *whiteImage; // full of 0xff - image_t *identityLightImage; // full of tr.identityLightByte - - image_t *shadowCubemaps[MAX_DLIGHTS]; - - - image_t *renderImage; - image_t *sunRaysImage; - image_t *renderDepthImage; - image_t *pshadowMaps[MAX_DRAWN_PSHADOWS]; - image_t *screenScratchImage; - image_t *textureScratchImage[2]; - image_t *quarterImage[2]; - image_t *calcLevelsImage; - image_t *targetLevelsImage; - image_t *fixedLevelsImage; - image_t *sunShadowDepthImage[4]; - image_t *screenShadowImage; - image_t *screenSsaoImage; - image_t *hdrDepthImage; - image_t *renderCubeImage; - - image_t *textureDepthImage; - - FBO_t *renderFbo; - FBO_t *msaaResolveFbo; - FBO_t *sunRaysFbo; - FBO_t *depthFbo; - FBO_t *pshadowFbos[MAX_DRAWN_PSHADOWS]; - FBO_t *screenScratchFbo; - FBO_t *textureScratchFbo[2]; - FBO_t *quarterFbo[2]; - FBO_t *calcLevelsFbo; - FBO_t *targetLevelsFbo; - FBO_t *sunShadowFbo[4]; - FBO_t *screenShadowFbo; - FBO_t *screenSsaoFbo; - FBO_t *hdrDepthFbo; - FBO_t *renderCubeFbo; - - shader_t *defaultShader; - shader_t *shadowShader; - shader_t *projectionShadowShader; - - shader_t *flareShader; - shader_t *sunShader; - shader_t *sunFlareShader; - - int numLightmaps; - int lightmapSize; - image_t **lightmaps; - image_t **deluxemaps; - - int fatLightmapCols; - int fatLightmapRows; - - int numCubemaps; - cubemap_t *cubemaps; - - trRefEntity_t *currentEntity; - trRefEntity_t worldEntity; // point currentEntity at this when rendering world - int currentEntityNum; - int shiftedEntityNum; // currentEntityNum << QSORT_REFENTITYNUM_SHIFT - model_t *currentModel; - - // - // GPU shader programs - // - shaderProgram_t genericShader[GENERICDEF_COUNT]; - shaderProgram_t textureColorShader; - shaderProgram_t fogShader[FOGDEF_COUNT]; - shaderProgram_t dlightShader[DLIGHTDEF_COUNT]; - shaderProgram_t lightallShader[LIGHTDEF_COUNT]; - shaderProgram_t shadowmapShader[SHADOWMAPDEF_COUNT]; - shaderProgram_t pshadowShader; - shaderProgram_t down4xShader; - shaderProgram_t bokehShader; - shaderProgram_t tonemapShader; - shaderProgram_t calclevels4xShader[2]; - shaderProgram_t shadowmaskShader; - shaderProgram_t ssaoShader; - shaderProgram_t depthBlurShader[4]; - shaderProgram_t testcubeShader; - - - // ----------------------------------------- - - viewParms_t viewParms; - - float identityLight; // 1.0 / ( 1 << overbrightBits ) - int identityLightByte; // identityLight * 255 - int overbrightBits; // r_overbrightBits->integer, but set to 0 if no hw gamma - - orientationr_t or; // for current entity - - trRefdef_t refdef; - - int viewCluster; - - float sunShadowScale; - - qboolean sunShadows; - vec3_t sunLight; // from the sky shader for this level - vec3_t sunDirection; - vec3_t lastCascadeSunDirection; - float lastCascadeSunMvp[16]; - - frontEndCounters_t pc; - int frontEndMsec; // not in pc due to clearing issue - - // - // put large tables at the end, so most elements will be - // within the +/32K indexed range on risc processors - // - model_t *models[MAX_MOD_KNOWN]; - int numModels; - - int numImages; - image_t *images[MAX_DRAWIMAGES]; - - int numFBOs; - FBO_t *fbos[MAX_FBOS]; - - int numVaos; - vao_t *vaos[MAX_VAOS]; - - // shader indexes from other modules will be looked up in tr.shaders[] - // shader indexes from drawsurfs will be looked up in sortedShaders[] - // lower indexed sortedShaders must be rendered first (opaque surfaces before translucent) - int numShaders; - shader_t *shaders[MAX_SHADERS]; - shader_t *sortedShaders[MAX_SHADERS]; - - int numSkins; - skin_t *skins[MAX_SKINS]; - - GLuint sunFlareQuery[2]; - int sunFlareQueryIndex; - qboolean sunFlareQueryActive[2]; - - float sinTable[FUNCTABLE_SIZE]; - float squareTable[FUNCTABLE_SIZE]; - float triangleTable[FUNCTABLE_SIZE]; - float sawToothTable[FUNCTABLE_SIZE]; - float inverseSawToothTable[FUNCTABLE_SIZE]; - float fogTable[FOG_TABLE_SIZE]; - qboolean vertexLightingAllowed; -} trGlobals_t; - -extern backEndState_t backEnd; -extern trGlobals_t tr; -extern glstate_t glState; // outside of TR since it shouldn't be cleared during ref re-init -extern glRefConfig_t glRefConfig; - -// -// cvars -// -extern cvar_t *r_flareSize; -extern cvar_t *r_flareFade; -// coefficient for the flare intensity falloff function. -#define FLARE_STDCOEFF "150" -extern cvar_t *r_flareCoeff; - -extern cvar_t *r_railWidth; -extern cvar_t *r_railCoreWidth; -extern cvar_t *r_railSegmentLength; - -extern cvar_t *r_ignore; // used for debugging anything - -extern cvar_t *r_znear; // near Z clip plane -extern cvar_t *r_zproj; // z distance of projection plane -extern cvar_t *r_stereoSeparation; // separation of cameras for stereo rendering - -extern cvar_t *r_measureOverdraw; // enables stencil buffer overdraw measurement - -extern cvar_t *r_lodbias; // push/pull LOD transitions -extern cvar_t *r_lodscale; - -extern cvar_t *r_teleporterFlash; // teleport hyperspace visual - -extern cvar_t *r_fastsky; // controls whether sky should be cleared or drawn -extern cvar_t *r_drawSun; // controls drawing of sun quad -extern cvar_t *r_dynamiclight; // dynamic lights enabled/disabled -extern cvar_t *r_dlightBacks; // dlight non-facing surfaces for continuity - -extern cvar_t *r_norefresh; // bypasses the ref rendering -extern cvar_t *r_drawentities; // disable/enable entity rendering -extern cvar_t *r_drawworld; // disable/enable world rendering -extern cvar_t *r_speeds; // various levels of information display -extern cvar_t *r_detailTextures; // enables/disables detail texturing stages -extern cvar_t *r_novis; // disable/enable usage of PVS -extern cvar_t *r_nocull; -extern cvar_t *r_facePlaneCull; // enables culling of planar surfaces with back side test -extern cvar_t *r_nocurves; -extern cvar_t *r_showcluster; - -extern cvar_t *r_gamma; - -extern cvar_t *r_ext_framebuffer_object; -extern cvar_t *r_ext_texture_float; -extern cvar_t *r_ext_framebuffer_multisample; -extern cvar_t *r_arb_seamless_cube_map; -extern cvar_t *r_arb_vertex_array_object; -extern cvar_t *r_ext_direct_state_access; - -extern cvar_t *r_nobind; // turns off binding to appropriate textures -extern cvar_t *r_singleShader; // make most world faces use default shader -extern cvar_t *r_roundImagesDown; -extern cvar_t *r_colorMipLevels; // development aid to see texture mip usage -extern cvar_t *r_picmip; // controls picmip values -extern cvar_t *r_finish; -extern cvar_t *r_textureMode; -extern cvar_t *r_offsetFactor; -extern cvar_t *r_offsetUnits; - -extern cvar_t *r_fullbright; // avoid lightmap pass -extern cvar_t *r_lightmap; // render lightmaps only -extern cvar_t *r_vertexLight; // vertex lighting mode for better performance - -extern cvar_t *r_showtris; // enables wireframe rendering of the world -extern cvar_t *r_showsky; // forces sky in front of all surfaces -extern cvar_t *r_shownormals; // draws wireframe normals -extern cvar_t *r_clear; // force screen clear every frame - -extern cvar_t *r_shadows; // controls shadows: 0 = none, 1 = blur, 2 = stencil, 3 = black planar projection -extern cvar_t *r_flares; // light flares - -extern cvar_t *r_intensity; - -extern cvar_t *r_lockpvs; -extern cvar_t *r_noportals; -extern cvar_t *r_portalOnly; - -extern cvar_t *r_subdivisions; -extern cvar_t *r_lodCurveError; -extern cvar_t *r_skipBackEnd; - -extern cvar_t *r_anaglyphMode; - -extern cvar_t *r_externalGLSL; - -extern cvar_t *r_hdr; -extern cvar_t *r_floatLightmap; -extern cvar_t *r_postProcess; - -extern cvar_t *r_toneMap; -extern cvar_t *r_forceToneMap; -extern cvar_t *r_forceToneMapMin; -extern cvar_t *r_forceToneMapAvg; -extern cvar_t *r_forceToneMapMax; - -extern cvar_t *r_autoExposure; -extern cvar_t *r_forceAutoExposure; -extern cvar_t *r_forceAutoExposureMin; -extern cvar_t *r_forceAutoExposureMax; - -extern cvar_t *r_cameraExposure; - -extern cvar_t *r_depthPrepass; -extern cvar_t *r_ssao; - -extern cvar_t *r_normalMapping; -extern cvar_t *r_specularMapping; -extern cvar_t *r_deluxeMapping; -extern cvar_t *r_parallaxMapping; -extern cvar_t *r_parallaxMapOffset; -extern cvar_t *r_parallaxMapShadows; -extern cvar_t *r_cubeMapping; -extern cvar_t *r_cubemapSize; -extern cvar_t *r_deluxeSpecular; -extern cvar_t *r_pbr; -extern cvar_t *r_baseNormalX; -extern cvar_t *r_baseNormalY; -extern cvar_t *r_baseParallax; -extern cvar_t *r_baseSpecular; -extern cvar_t *r_baseGloss; -extern cvar_t *r_glossType; -extern cvar_t *r_dlightMode; -extern cvar_t *r_pshadowDist; -extern cvar_t *r_mergeLightmaps; -extern cvar_t *r_imageUpsample; -extern cvar_t *r_imageUpsampleMaxSize; -extern cvar_t *r_imageUpsampleType; -extern cvar_t *r_genNormalMaps; -extern cvar_t *r_forceSun; -extern cvar_t *r_forceSunLightScale; -extern cvar_t *r_forceSunAmbientScale; -extern cvar_t *r_sunlightMode; -extern cvar_t *r_drawSunRays; -extern cvar_t *r_sunShadows; -extern cvar_t *r_shadowFilter; -extern cvar_t *r_shadowBlur; -extern cvar_t *r_shadowMapSize; -extern cvar_t *r_shadowCascadeZNear; -extern cvar_t *r_shadowCascadeZFar; -extern cvar_t *r_shadowCascadeZBias; -extern cvar_t *r_ignoreDstAlpha; - -extern cvar_t *r_greyscale; - -extern cvar_t *r_ignoreGLErrors; - -extern cvar_t *r_overBrightBits; -extern cvar_t *r_mapOverBrightBits; - -extern cvar_t *r_debugSurface; -extern cvar_t *r_simpleMipMaps; - -extern cvar_t *r_showImages; -extern cvar_t *r_debugSort; - -extern cvar_t *r_printShaders; - -extern cvar_t *r_marksOnTriangleMeshes; - -//==================================================================== - -static ID_INLINE qboolean ShaderRequiresCPUDeforms(const shader_t * shader) -{ - if(shader->numDeforms) - { - const deformStage_t *ds = &shader->deforms[0]; - - if (shader->numDeforms > 1) - return qtrue; - - switch (ds->deformation) - { - case DEFORM_WAVE: - case DEFORM_BULGE: - // need CPU deforms at high level-times to avoid floating point precision loss - return ( backEnd.refdef.floatTime != (float)backEnd.refdef.floatTime ); - - default: - return qtrue; - } - } - - return qfalse; -} - -//==================================================================== - -void R_SwapBuffers( int ); - -void R_RenderView( const viewParms_t *parms ); -void R_RenderDlightCubemaps(const refdef_t *fd); -void R_RenderPshadowMaps(const refdef_t *fd); -void R_RenderSunShadowMaps(const refdef_t *fd, int level); -void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ); - -void R_AddMD3Surfaces( trRefEntity_t *e ); -void R_AddNullModelSurfaces( trRefEntity_t *e ); -void R_AddBeamSurfaces( trRefEntity_t *e ); -void R_AddRailSurfaces( trRefEntity_t *e, qboolean isUnderwater ); -void R_AddLightningBoltSurfaces( trRefEntity_t *e ); - -void R_AddPolygonSurfaces( void ); - -void R_DecomposeSort( unsigned sort, int *entityNum, shader_t **shader, - int *fogNum, int *dlightMap, int *pshadowMap ); - -void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, - int fogIndex, int dlightMap, int pshadowMap, int cubemap ); - -void R_CalcTexDirs(vec3_t sdir, vec3_t tdir, const vec3_t v1, const vec3_t v2, - const vec3_t v3, const vec2_t w1, const vec2_t w2, const vec2_t w3); -vec_t R_CalcTangentSpace(vec3_t tangent, vec3_t bitangent, const vec3_t normal, const vec3_t sdir, const vec3_t tdir); -qboolean R_CalcTangentVectors(srfVert_t * dv[3]); - -#define CULL_IN 0 // completely unclipped -#define CULL_CLIP 1 // clipped by one or more planes -#define CULL_OUT 2 // completely outside the clipping planes - -void R_LocalPointToWorld (const vec3_t local, vec3_t world); -int R_CullBox (vec3_t bounds[2]); -int R_CullLocalBox( const vec3_t bounds[2] ); -int R_CullPointAndRadiusEx( const vec3_t origin, float radius, const cplane_t* frustum, int numPlanes ); -int R_CullPointAndRadius( const vec3_t origin, float radius ); -int R_CullLocalPointAndRadius( const vec3_t origin, float radius ); - -void R_SetupProjection(viewParms_t *dest, float zProj, float zFar, qboolean computeFrustum); -void R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms, orientationr_t *or ); - -/* -** GL wrapper/helper functions -*/ -void GL_BindToTMU( image_t *image, int tmu ); -void GL_SetDefaultState (void); -void GL_TextureMode( const char *string ); -void GL_CheckErrs( char *file, int line ); -#define GL_CheckErrors(...) GL_CheckErrs(__FILE__, __LINE__) -void GL_State( unsigned long stateVector ); -void GL_SetProjectionMatrix(mat4_t matrix); -void GL_SetModelviewMatrix(mat4_t matrix); -void GL_Cull( int cullType ); - -#define GLS_SRCBLEND_ZERO 0x00000001 -#define GLS_SRCBLEND_ONE 0x00000002 -#define GLS_SRCBLEND_DST_COLOR 0x00000003 -#define GLS_SRCBLEND_ONE_MINUS_DST_COLOR 0x00000004 -#define GLS_SRCBLEND_SRC_ALPHA 0x00000005 -#define GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA 0x00000006 -#define GLS_SRCBLEND_DST_ALPHA 0x00000007 -#define GLS_SRCBLEND_ONE_MINUS_DST_ALPHA 0x00000008 -#define GLS_SRCBLEND_ALPHA_SATURATE 0x00000009 -#define GLS_SRCBLEND_BITS 0x0000000f - -#define GLS_DSTBLEND_ZERO 0x00000010 -#define GLS_DSTBLEND_ONE 0x00000020 -#define GLS_DSTBLEND_SRC_COLOR 0x00000030 -#define GLS_DSTBLEND_ONE_MINUS_SRC_COLOR 0x00000040 -#define GLS_DSTBLEND_SRC_ALPHA 0x00000050 -#define GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA 0x00000060 -#define GLS_DSTBLEND_DST_ALPHA 0x00000070 -#define GLS_DSTBLEND_ONE_MINUS_DST_ALPHA 0x00000080 -#define GLS_DSTBLEND_BITS 0x000000f0 - -#define GLS_DEPTHMASK_TRUE 0x00000100 - -#define GLS_POLYMODE_LINE 0x00001000 - -#define GLS_DEPTHTEST_DISABLE 0x00010000 -#define GLS_DEPTHFUNC_EQUAL 0x00020000 -#define GLS_DEPTHFUNC_GREATER 0x00040000 -#define GLS_DEPTHFUNC_BITS 0x00060000 - -#define GLS_ATEST_GT_0 0x10000000 -#define GLS_ATEST_LT_80 0x20000000 -#define GLS_ATEST_GE_80 0x40000000 -#define GLS_ATEST_BITS 0x70000000 - -#define GLS_DEFAULT GLS_DEPTHMASK_TRUE - -void RE_StretchRaw( int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty ); -void RE_UploadCinematic( int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty ); - -void RE_BeginFrame( stereoFrame_t stereoFrame ); -void RE_BeginRegistration( glconfig_t *glconfig ); -void RE_LoadWorldMap( const char *mapname ); -void RE_SetWorldVisData( const byte *vis ); -qhandle_t RE_RegisterModel( const char *name ); -qhandle_t RE_RegisterSkin( const char *name ); - -qboolean R_GetEntityToken( char *buffer, int size ); - -model_t *R_AllocModel( void ); - -void R_Init( void ); -void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int height, GLenum picFormat ); - -void R_SetColorMappings( void ); -void R_GammaCorrect( byte *buffer, int bufSize ); - -void R_ImageList_f( void ); -void R_SkinList_f( void ); -// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=516 -const void *RB_TakeScreenshotCmd( const void *data ); - -void R_InitFogTable( void ); -float R_FogFactor( float s, float t ); -void R_InitImages( void ); -void R_DeleteTextures( void ); -int R_SumOfUsedImages( void ); -void R_InitSkins( void ); -skin_t *R_GetSkinByHandle( qhandle_t hSkin ); - -int R_ComputeLOD( trRefEntity_t *ent ); - -const void *RB_TakeVideoFrameCmd( const void *data ); - -// -// tr_shader.c -// -shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImage ); -shader_t *R_GetShaderByHandle( qhandle_t hShader ); -shader_t *R_GetShaderByState( int index, long *cycleTime ); -shader_t *R_FindShaderByName( const char *name ); -void R_InitShaders( void ); -void R_ShaderList_f( void ); -void R_RemapShader(const char *oldShader, const char *newShader, const char *timeOffset); - -/* -==================================================================== - -IMPLEMENTATION SPECIFIC FUNCTIONS - -==================================================================== -*/ - -void GLimp_InitExtraExtensions( void ); - -/* -==================================================================== - -TESSELATOR/SHADER DECLARATIONS - -==================================================================== -*/ - -typedef struct stageVars -{ - color4ub_t colors[SHADER_MAX_VERTEXES]; - vec2_t texcoords[NUM_TEXTURE_BUNDLES][SHADER_MAX_VERTEXES]; -} stageVars_t; - -typedef struct shaderCommands_s -{ - glIndex_t indexes[SHADER_MAX_INDEXES] QALIGN(16); - vec4_t xyz[SHADER_MAX_VERTEXES] QALIGN(16); - int16_t normal[SHADER_MAX_VERTEXES][4] QALIGN(16); - int16_t tangent[SHADER_MAX_VERTEXES][4] QALIGN(16); - vec2_t texCoords[SHADER_MAX_VERTEXES] QALIGN(16); - vec2_t lightCoords[SHADER_MAX_VERTEXES] QALIGN(16); - uint16_t color[SHADER_MAX_VERTEXES][4] QALIGN(16); - int16_t lightdir[SHADER_MAX_VERTEXES][4] QALIGN(16); - //int vertexDlightBits[SHADER_MAX_VERTEXES] QALIGN(16); - - void *attribPointers[ATTR_INDEX_COUNT]; - vao_t *vao; - qboolean useInternalVao; - qboolean useCacheVao; - - stageVars_t svars QALIGN(16); - - //color4ub_t constantColor255[SHADER_MAX_VERTEXES] QALIGN(16); - - shader_t *shader; - double shaderTime; // -EC- set to double for frameloss fix - int fogNum; - int cubemapIndex; - - int dlightBits; // or together of all vertexDlightBits - int pshadowBits; - - int firstIndex; - int numIndexes; - int numVertexes; - - // info extracted from current shader - int numPasses; - void (*currentStageIteratorFunc)( void ); - shaderStage_t **xstages; -} shaderCommands_t; - -extern shaderCommands_t tess; - -void RB_BeginSurface(shader_t *shader, int fogNum, int cubemapIndex ); -void RB_EndSurface(void); -void RB_CheckOverflow( int verts, int indexes ); -#define RB_CHECKOVERFLOW(v,i) if (tess.numVertexes + (v) >= SHADER_MAX_VERTEXES || tess.numIndexes + (i) >= SHADER_MAX_INDEXES ) {RB_CheckOverflow(v,i);} - -void R_DrawElements( int numIndexes, glIndex_t firstIndex ); -void RB_StageIteratorGeneric( void ); -void RB_StageIteratorSky( void ); -void RB_StageIteratorVertexLitTexture( void ); -void RB_StageIteratorLightmappedMultitexture( void ); - -void RB_AddQuadStamp( const vec3_t origin, const vec3_t left, const vec3_t up, const float color[4] ); -void RB_AddQuadStampExt( const vec3_t origin, const vec3_t left, const vec3_t up, const float color[4], float s1, float t1, float s2, float t2 ); -void RB_InstantQuad( vec4_t quadVerts[4] ); -//void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4], vec4_t color, shaderProgram_t *sp, vec2_t invTexRes); -void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4]); - -void RB_ShowImages( void ); - - -/* -============================================================ - -WORLD MAP - -============================================================ -*/ - -void R_AddBrushModelSurfaces( trRefEntity_t *e ); -void R_AddWorldSurfaces( void ); -qboolean R_inPVS( const vec3_t p1, const vec3_t p2 ); - - -/* -============================================================ - -FLARES - -============================================================ -*/ - -void R_ClearFlares( void ); - -void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t normal ); -void RB_AddDlightFlares( void ); -void RB_RenderFlares (void); - -/* -============================================================ - -LIGHTS - -============================================================ -*/ - -void R_DlightBmodel( bmodel_t *bmodel ); -void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ); -void R_TransformDlights( int count, dlight_t *dl, orientationr_t *or ); -int R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir ); -int R_LightDirForPoint( vec3_t point, vec3_t lightDir, vec3_t normal, world_t *world ); -int R_CubemapForPoint( vec3_t point ); - - -/* -============================================================ - -SHADOWS - -============================================================ -*/ - -void RB_ShadowTessEnd( void ); -void RB_ShadowFinish( void ); -void RB_ProjectionShadowDeform( void ); - -/* -============================================================ - -SKIES - -============================================================ -*/ - -void R_InitSkyTexCoords( float cloudLayerHeight ); -void R_DrawSkyBox( const shaderCommands_t *shader ); -void RB_DrawSun( float scale, shader_t *shader ); - -/* -============================================================ - -CURVE TESSELATION - -============================================================ -*/ - -#define PATCH_STITCHING - -void R_SubdividePatchToGrid( srfBspSurface_t *grid, int width, int height, - srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ); -void R_GridInsertColumn( srfBspSurface_t *grid, int column, int row, vec3_t point, float loderror ); -void R_GridInsertRow( srfBspSurface_t *grid, int row, int column, vec3_t point, float loderror ); - -/* -============================================================ - -MARKERS, POLYGON PROJECTION ON WORLD POLYGONS - -============================================================ -*/ - -int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection, - int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ); - - -/* -============================================================ - -VERTEX BUFFER OBJECTS - -============================================================ -*/ - -void R_VaoPackTangent(int16_t *out, vec4_t v); -void R_VaoPackNormal(int16_t *out, vec3_t v); -void R_VaoPackColor(uint16_t *out, const vec4_t c); -void R_VaoUnpackTangent(vec4_t v, int16_t *pack); -void R_VaoUnpackNormal(vec3_t v, int16_t *pack); - -vao_t *R_CreateVao(const char *name, byte *vertexes, int vertexesSize, byte *indexes, int indexesSize, vaoUsage_t usage); -vao_t *R_CreateVao2(const char *name, int numVertexes, srfVert_t *verts, int numIndexes, glIndex_t *inIndexes); - -void R_BindVao(vao_t *vao); -void R_BindNullVao(void); - -void Vao_SetVertexPointers(vao_t *vao); - -void R_InitVaos(void); -void R_ShutdownVaos(void); -void R_VaoList_f(void); - -void RB_UpdateTessVao(unsigned int attribBits); - -void VaoCache_Commit(void); -void VaoCache_Init(void); -void VaoCache_BindVao(void); -void VaoCache_CheckAdd(qboolean *endSurface, qboolean *recycleVertexBuffer, qboolean *recycleIndexBuffer, int numVerts, int numIndexes); -void VaoCache_RecycleVertexBuffer(void); -void VaoCache_RecycleIndexBuffer(void); -void VaoCache_InitQueue(void); -void VaoCache_AddSurface(srfVert_t *verts, int numVerts, glIndex_t *indexes, int numIndexes); - -/* -============================================================ - -GLSL - -============================================================ -*/ - -void GLSL_InitGPUShaders(void); -void GLSL_ShutdownGPUShaders(void); -void GLSL_VertexAttribPointers(uint32_t attribBits); -void GLSL_BindProgram(shaderProgram_t * program); - -void GLSL_SetUniformInt(shaderProgram_t *program, int uniformNum, GLint value); -void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat value); -void GLSL_SetUniformFloat5(shaderProgram_t *program, int uniformNum, const vec5_t v); -void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t v); -void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t v); -void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t v); -void GLSL_SetUniformMat4(shaderProgram_t *program, int uniformNum, const mat4_t matrix); -void GLSL_SetUniformMat4BoneMatrix(shaderProgram_t *program, int uniformNum, /*const*/ mat4_t *matrix, int numMatricies); - -shaderProgram_t *GLSL_GetGenericShaderProgram(int stage); - -/* -============================================================ - -SCENE GENERATION - -============================================================ -*/ - -void R_InitNextFrame( void ); - -void RE_ClearScene( void ); -void RE_AddRefEntityToScene( const refEntity_t *ent, qboolean intShaderTime ); -void RE_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num ); -void RE_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ); -void RE_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b ); -void RE_BeginScene( const refdef_t *fd ); -void RE_RenderScene( const refdef_t *fd ); -void RE_EndScene( void ); - -/* -============================================================= - -UNCOMPRESSING BONES - -============================================================= -*/ - -#define MC_BITS_X (16) -#define MC_BITS_Y (16) -#define MC_BITS_Z (16) -#define MC_BITS_VECT (16) - -#define MC_SCALE_X (1.0f/64) -#define MC_SCALE_Y (1.0f/64) -#define MC_SCALE_Z (1.0f/64) - -void MC_UnCompress(float mat[3][4],const unsigned char * comp); - -/* -============================================================= - -ANIMATED MODELS - -============================================================= -*/ - -void R_MDRAddAnimSurfaces( trRefEntity_t *ent ); -void RB_MDRSurfaceAnim( mdrSurface_t *surface ); -qboolean R_LoadIQM (model_t *mod, void *buffer, int filesize, const char *name ); -void R_AddIQMSurfaces( trRefEntity_t *ent ); -void RB_IQMSurfaceAnim( const surfaceType_t *surface ); -void RB_IQMSurfaceAnimVao( const srfVaoIQModel_t *surface ); -int R_IQMLerpTag( orientation_t *tag, iqmData_t *data, - int startFrame, int endFrame, - float frac, const char *tagName ); - -/* -============================================================= -============================================================= -*/ -void R_TransformModelToClip( const vec3_t src, const float *modelMatrix, const float *projectionMatrix, - vec4_t eye, vec4_t dst ); -void R_TransformClipToWindow( const vec4_t clip, const viewParms_t *view, vec4_t normalized, vec4_t window ); - -void RB_DeformTessGeometry( void ); - -void RB_CalcFogTexCoords( float *dstTexCoords ); - -void RB_CalcScaleTexMatrix( const float scale[2], float *matrix ); -void RB_CalcScrollTexMatrix( const float scrollSpeed[2], float *matrix ); -void RB_CalcRotateTexMatrix( float degsPerSecond, float *matrix ); -void RB_CalcTurbulentFactors( const waveForm_t *wf, float *amplitude, float *now ); -void RB_CalcTransformTexMatrix( const texModInfo_t *tmi, float *matrix ); -void RB_CalcStretchTexMatrix( const waveForm_t *wf, float *matrix ); - -void RB_CalcModulateColorsByFog( unsigned char *dstColors ); -float RB_CalcWaveAlphaSingle( const waveForm_t *wf ); -float RB_CalcWaveColorSingle( const waveForm_t *wf ); - -/* -============================================================= - -RENDERER BACK END FUNCTIONS - -============================================================= -*/ - -void RB_ExecuteRenderCommands( const void *data ); - -/* -============================================================= - -RENDERER BACK END COMMAND QUEUE - -============================================================= -*/ - -#define MAX_RENDER_COMMANDS 0x40000 - -typedef struct { - byte cmds[MAX_RENDER_COMMANDS]; - int used; -} renderCommandList_t; - -typedef struct { - int commandId; - float color[4]; -} setColorCommand_t; - -typedef struct { - int commandId; - int buffer; -} drawBufferCommand_t; - -typedef struct { - int commandId; - image_t *image; - int width; - int height; - void *data; -} subImageCommand_t; - -typedef struct { - int commandId; -} swapBuffersCommand_t; - -typedef struct { - int commandId; - int buffer; -} endFrameCommand_t; - -typedef struct { - int commandId; - shader_t *shader; - float x, y; - float w, h; - float s1, t1; - float s2, t2; -} stretchPicCommand_t; - -typedef struct { - int commandId; - trRefdef_t refdef; - viewParms_t viewParms; - drawSurf_t *drawSurfs; - int numDrawSurfs; -} drawSurfsCommand_t; - -typedef struct { - int commandId; - int x; - int y; - int width; - int height; - const char *fileName; - qboolean jpeg; -} screenshotCommand_t; - -typedef struct { - int commandId; - int width; - int height; - byte *captureBuffer; - byte *encodeBuffer; - qboolean motionJpeg; -} videoFrameCommand_t; - -typedef struct -{ - int commandId; - - GLboolean rgba[4]; -} colorMaskCommand_t; - -typedef struct -{ - int commandId; -} clearDepthCommand_t; - -typedef struct { - int commandId; - int map; - int cubeSide; -} capShadowmapCommand_t; - -typedef struct { - int commandId; - trRefdef_t refdef; - viewParms_t viewParms; -} postProcessCommand_t; - -typedef struct { - int commandId; -} exportCubemapsCommand_t; - -typedef enum { - RC_END_OF_LIST, - RC_SET_COLOR, - RC_STRETCH_PIC, - RC_DRAW_SURFS, - RC_DRAW_BUFFER, - RC_SWAP_BUFFERS, - RC_SCREENSHOT, - RC_VIDEOFRAME, - RC_COLORMASK, - RC_CLEARDEPTH, - RC_CAPSHADOWMAP, - RC_POSTPROCESS, - RC_EXPORT_CUBEMAPS -} renderCommand_t; - - -// these are sort of arbitrary limits. -// the limits apply to the sum of all scenes in a frame -- -// the main view, all the 3D icons, etc -#define MAX_POLYS 600 -#define MAX_POLYVERTS 3000 - -// all of the information needed by the back end must be -// contained in a backEndData_t -typedef struct { - drawSurf_t drawSurfs[MAX_DRAWSURFS]; - dlight_t dlights[MAX_DLIGHTS]; - trRefEntity_t entities[MAX_REFENTITIES]; - srfPoly_t *polys;//[MAX_POLYS]; - polyVert_t *polyVerts;//[MAX_POLYVERTS]; - pshadow_t pshadows[MAX_CALC_PSHADOWS]; - renderCommandList_t commands; -} backEndData_t; - -extern int max_polys; -extern int max_polyverts; - -extern backEndData_t *backEndData; // the second one may not be allocated - - -void *R_GetCommandBuffer( int bytes ); -void RB_ExecuteRenderCommands( const void *data ); - -void R_IssuePendingRenderCommands( void ); - -void R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs ); -void R_AddCapShadowmapCmd( int dlight, int cubeSide ); -void R_AddPostProcessCmd (void); - -void RE_SetColor( const float *rgba ); -void RE_StretchPic ( float x, float y, float w, float h, - float s1, float t1, float s2, float t2, qhandle_t hShader ); -void RE_BeginFrame( stereoFrame_t stereoFrame ); -void RE_EndFrame( int *frontEndMsec, int *backEndMsec ); -void RE_TakeVideoFrame( int width, int height, - byte *captureBuffer, byte *encodeBuffer, qboolean motionJpeg ); - -void RE_FinishBloom( void ); -void RE_ThrottleBackend( void ); -qboolean RE_CanMinimize( void ); -const glconfig_t *RE_GetConfig( void ); -void RE_VertexLighting( qboolean allowed ); - -#endif //TR_LOCAL_H diff --git a/code/renderer2/tr_main.c b/code/renderer2/tr_main.c deleted file mode 100644 index 27498f7436..0000000000 --- a/code/renderer2/tr_main.c +++ /dev/null @@ -1,2672 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_main.c -- main control flow for each frame - -#include "tr_local.h" - -#include // memcpy - -trGlobals_t tr; - -static const float s_flipMatrix[16] = { - // convert from our coordinate system (looking down X) - // to OpenGL's coordinate system (looking down -Z) - 0, 0, -1, 0, - -1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 0, 1 -}; - - -refimport_t ri; - -// entities that will have procedurally generated surfaces will just -// point at this for their sorting surface -static surfaceType_t entitySurface = SF_ENTITY; -#if 0 -/* -================ -R_CompareVert -================ -*/ -static qboolean R_CompareVert(srfVert_t * v1, srfVert_t * v2, qboolean checkST) -{ - int i; - - for(i = 0; i < 3; i++) - { - if(floor(v1->xyz[i] + 0.1) != floor(v2->xyz[i] + 0.1)) - { - return qfalse; - } - - if(checkST && ((v1->st[0] != v2->st[0]) || (v1->st[1] != v2->st[1]))) - { - return qfalse; - } - } - - return qtrue; -} -#endif -/* -============= -R_CalcTexDirs - -Lengyel, Eric. Computing Tangent Space Basis Vectors for an Arbitrary Mesh. Terathon Software 3D Graphics Library, 2001. http://www.terathon.com/code/tangent.html -============= -*/ -void R_CalcTexDirs(vec3_t sdir, vec3_t tdir, const vec3_t v1, const vec3_t v2, - const vec3_t v3, const vec2_t w1, const vec2_t w2, const vec2_t w3) -{ - float x1, x2, y1, y2, z1, z2; - float s1, s2, t1, t2, r; - - x1 = v2[0] - v1[0]; - x2 = v3[0] - v1[0]; - y1 = v2[1] - v1[1]; - y2 = v3[1] - v1[1]; - z1 = v2[2] - v1[2]; - z2 = v3[2] - v1[2]; - - s1 = w2[0] - w1[0]; - s2 = w3[0] - w1[0]; - t1 = w2[1] - w1[1]; - t2 = w3[1] - w1[1]; - - r = s1 * t2 - s2 * t1; - if (r) r = 1.0f / r; - - VectorSet(sdir, (t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, (t2 * z1 - t1 * z2) * r); - VectorSet(tdir, (s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, (s1 * z2 - s2 * z1) * r); -} - -/* -============= -R_CalcTangentSpace - -Lengyel, Eric. Computing Tangent Space Basis Vectors for an Arbitrary Mesh. Terathon Software 3D Graphics Library, 2001. http://www.terathon.com/code/tangent.html -============= -*/ -vec_t R_CalcTangentSpace(vec3_t tangent, vec3_t bitangent, const vec3_t normal, const vec3_t sdir, const vec3_t tdir) -{ - vec3_t n_cross_t; - vec_t n_dot_t, handedness; - - // Gram-Schmidt orthogonalize - n_dot_t = DotProduct(normal, sdir); - VectorMA(sdir, -n_dot_t, normal, tangent); - VectorNormalize(tangent); - - // Calculate handedness - CrossProduct(normal, sdir, n_cross_t); - handedness = (DotProduct(n_cross_t, tdir) < 0.0f) ? -1.0f : 1.0f; - - // Calculate orthogonal bitangent, if necessary - if (bitangent) - CrossProduct(normal, tangent, bitangent); - - return handedness; -} - -qboolean R_CalcTangentVectors(srfVert_t * dv[3]) -{ - int i; - float bb, s, t; - vec3_t bary; - - - /* calculate barycentric basis for the triangle */ - bb = (dv[1]->st[0] - dv[0]->st[0]) * (dv[2]->st[1] - dv[0]->st[1]) - (dv[2]->st[0] - dv[0]->st[0]) * (dv[1]->st[1] - dv[0]->st[1]); - if(fabs(bb) < 0.00000001f) - return qfalse; - - /* do each vertex */ - for(i = 0; i < 3; i++) - { - vec4_t tangent; - vec3_t normal, bitangent, nxt; - - // calculate s tangent vector - s = dv[i]->st[0] + 10.0f; - t = dv[i]->st[1]; - bary[0] = ((dv[1]->st[0] - s) * (dv[2]->st[1] - t) - (dv[2]->st[0] - s) * (dv[1]->st[1] - t)) / bb; - bary[1] = ((dv[2]->st[0] - s) * (dv[0]->st[1] - t) - (dv[0]->st[0] - s) * (dv[2]->st[1] - t)) / bb; - bary[2] = ((dv[0]->st[0] - s) * (dv[1]->st[1] - t) - (dv[1]->st[0] - s) * (dv[0]->st[1] - t)) / bb; - - tangent[0] = bary[0] * dv[0]->xyz[0] + bary[1] * dv[1]->xyz[0] + bary[2] * dv[2]->xyz[0]; - tangent[1] = bary[0] * dv[0]->xyz[1] + bary[1] * dv[1]->xyz[1] + bary[2] * dv[2]->xyz[1]; - tangent[2] = bary[0] * dv[0]->xyz[2] + bary[1] * dv[1]->xyz[2] + bary[2] * dv[2]->xyz[2]; - - VectorSubtract(tangent, dv[i]->xyz, tangent); - VectorNormalize(tangent); - - // calculate t tangent vector - s = dv[i]->st[0]; - t = dv[i]->st[1] + 10.0f; - bary[0] = ((dv[1]->st[0] - s) * (dv[2]->st[1] - t) - (dv[2]->st[0] - s) * (dv[1]->st[1] - t)) / bb; - bary[1] = ((dv[2]->st[0] - s) * (dv[0]->st[1] - t) - (dv[0]->st[0] - s) * (dv[2]->st[1] - t)) / bb; - bary[2] = ((dv[0]->st[0] - s) * (dv[1]->st[1] - t) - (dv[1]->st[0] - s) * (dv[0]->st[1] - t)) / bb; - - bitangent[0] = bary[0] * dv[0]->xyz[0] + bary[1] * dv[1]->xyz[0] + bary[2] * dv[2]->xyz[0]; - bitangent[1] = bary[0] * dv[0]->xyz[1] + bary[1] * dv[1]->xyz[1] + bary[2] * dv[2]->xyz[1]; - bitangent[2] = bary[0] * dv[0]->xyz[2] + bary[1] * dv[1]->xyz[2] + bary[2] * dv[2]->xyz[2]; - - VectorSubtract(bitangent, dv[i]->xyz, bitangent); - VectorNormalize(bitangent); - - // store bitangent handedness - R_VaoUnpackNormal(normal, dv[i]->normal); - CrossProduct(normal, tangent, nxt); - tangent[3] = (DotProduct(nxt, bitangent) < 0.0f) ? -1.0f : 1.0f; - - R_VaoPackTangent(dv[i]->tangent, tangent); - - // debug code - //% Sys_FPrintf( SYS_VRB, "%d S: (%f %f %f) T: (%f %f %f)\n", i, - //% stv[ i ][ 0 ], stv[ i ][ 1 ], stv[ i ][ 2 ], ttv[ i ][ 0 ], ttv[ i ][ 1 ], ttv[ i ][ 2 ] ); - } - - return qtrue; -} - - -/* -================= -R_CullLocalBox - -Returns CULL_IN, CULL_CLIP, or CULL_OUT -================= -*/ -int R_CullLocalBox( const vec3_t localBounds[2] ) { -#if 0 - int i, j; - vec3_t transformed[8]; - float dists[8]; - vec3_t v; - cplane_t *frust; - int anyBack; - int front, back; - - if ( r_nocull->integer ) { - return CULL_CLIP; - } - - // transform into world space - for (i = 0 ; i < 8 ; i++) { - v[0] = bounds[i&1][0]; - v[1] = bounds[(i>>1)&1][1]; - v[2] = bounds[(i>>2)&1][2]; - - VectorCopy( tr.or.origin, transformed[i] ); - VectorMA( transformed[i], v[0], tr.or.axis[0], transformed[i] ); - VectorMA( transformed[i], v[1], tr.or.axis[1], transformed[i] ); - VectorMA( transformed[i], v[2], tr.or.axis[2], transformed[i] ); - } - - // check against frustum planes - anyBack = 0; - for (i = 0 ; i < 4 ; i++) { - frust = &tr.viewParms.frustum[i]; - - front = back = 0; - for (j = 0 ; j < 8 ; j++) { - dists[j] = DotProduct(transformed[j], frust->normal); - if ( dists[j] > frust->dist ) { - front = 1; - if ( back ) { - break; // a point is in front - } - } else { - back = 1; - } - } - if ( !front ) { - // all points were behind one of the planes - return CULL_OUT; - } - anyBack |= back; - } - - if ( !anyBack ) { - return CULL_IN; // completely inside frustum - } - - return CULL_CLIP; // partially clipped -#else - int j; - vec3_t transformed; - vec3_t v; - vec3_t worldBounds[2]; - - if(r_nocull->integer) - { - return CULL_CLIP; - } - - // transform into world space - ClearBounds(worldBounds[0], worldBounds[1]); - - for(j = 0; j < 8; j++) - { - v[0] = localBounds[j & 1][0]; - v[1] = localBounds[(j >> 1) & 1][1]; - v[2] = localBounds[(j >> 2) & 1][2]; - - R_LocalPointToWorld(v, transformed); - - AddPointToBounds(transformed, worldBounds[0], worldBounds[1]); - } - - return R_CullBox(worldBounds); -#endif -} - -/* -================= -R_CullBox - -Returns CULL_IN, CULL_CLIP, or CULL_OUT -================= -*/ -int R_CullBox(vec3_t worldBounds[2]) { - int i; - cplane_t *frust; - qboolean anyClip; - int r, numPlanes; - - numPlanes = (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 5 : 4; - - // check against frustum planes - anyClip = qfalse; - for(i = 0; i < numPlanes; i++) - { - frust = &tr.viewParms.frustum[i]; - - r = BoxOnPlaneSide(worldBounds[0], worldBounds[1], frust); - - if(r == 2) - { - // completely outside frustum - return CULL_OUT; - } - if(r == 3) - { - anyClip = qtrue; - } - } - - if(!anyClip) - { - // completely inside frustum - return CULL_IN; - } - - // partially clipped - return CULL_CLIP; -} - -/* -** R_CullLocalPointAndRadius -*/ -int R_CullLocalPointAndRadius( const vec3_t pt, float radius ) -{ - vec3_t transformed; - - R_LocalPointToWorld( pt, transformed ); - - return R_CullPointAndRadius( transformed, radius ); -} - -/* -** R_CullPointAndRadius -*/ -int R_CullPointAndRadiusEx( const vec3_t pt, float radius, const cplane_t* frustum, int numPlanes ) -{ - int i; - float dist; - const cplane_t *frust; - qboolean mightBeClipped = qfalse; - - if ( r_nocull->integer ) { - return CULL_CLIP; - } - - // check against frustum planes - for (i = 0 ; i < numPlanes ; i++) - { - frust = &frustum[i]; - - dist = DotProduct( pt, frust->normal) - frust->dist; - if ( dist < -radius ) - { - return CULL_OUT; - } - else if ( dist <= radius ) - { - mightBeClipped = qtrue; - } - } - - if ( mightBeClipped ) - { - return CULL_CLIP; - } - - return CULL_IN; // completely inside frustum -} - -/* -** R_CullPointAndRadius -*/ -int R_CullPointAndRadius( const vec3_t pt, float radius ) -{ - return R_CullPointAndRadiusEx(pt, radius, tr.viewParms.frustum, (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 5 : 4); -} - -/* -================= -R_LocalNormalToWorld - -================= -*/ -static void R_LocalNormalToWorld (const vec3_t local, vec3_t world) { - world[0] = local[0] * tr.or.axis[0][0] + local[1] * tr.or.axis[1][0] + local[2] * tr.or.axis[2][0]; - world[1] = local[0] * tr.or.axis[0][1] + local[1] * tr.or.axis[1][1] + local[2] * tr.or.axis[2][1]; - world[2] = local[0] * tr.or.axis[0][2] + local[1] * tr.or.axis[1][2] + local[2] * tr.or.axis[2][2]; -} - -/* -================= -R_LocalPointToWorld - -================= -*/ -void R_LocalPointToWorld (const vec3_t local, vec3_t world) { - world[0] = local[0] * tr.or.axis[0][0] + local[1] * tr.or.axis[1][0] + local[2] * tr.or.axis[2][0] + tr.or.origin[0]; - world[1] = local[0] * tr.or.axis[0][1] + local[1] * tr.or.axis[1][1] + local[2] * tr.or.axis[2][1] + tr.or.origin[1]; - world[2] = local[0] * tr.or.axis[0][2] + local[1] * tr.or.axis[1][2] + local[2] * tr.or.axis[2][2] + tr.or.origin[2]; -} - -/* -================= -R_WorldToLocal - -================= -*/ -void R_WorldToLocal (const vec3_t world, vec3_t local) { - local[0] = DotProduct(world, tr.or.axis[0]); - local[1] = DotProduct(world, tr.or.axis[1]); - local[2] = DotProduct(world, tr.or.axis[2]); -} - -/* -========================== -R_TransformModelToClip - -========================== -*/ -void R_TransformModelToClip( const vec3_t src, const float *modelMatrix, const float *projectionMatrix, - vec4_t eye, vec4_t dst ) { - int i; - - for ( i = 0 ; i < 4 ; i++ ) { - eye[i] = - src[0] * modelMatrix[ i + 0 * 4 ] + - src[1] * modelMatrix[ i + 1 * 4 ] + - src[2] * modelMatrix[ i + 2 * 4 ] + - 1 * modelMatrix[ i + 3 * 4 ]; - } - - for ( i = 0 ; i < 4 ; i++ ) { - dst[i] = - eye[0] * projectionMatrix[ i + 0 * 4 ] + - eye[1] * projectionMatrix[ i + 1 * 4 ] + - eye[2] * projectionMatrix[ i + 2 * 4 ] + - eye[3] * projectionMatrix[ i + 3 * 4 ]; - } -} - -/* -========================== -R_TransformClipToWindow - -========================== -*/ -void R_TransformClipToWindow( const vec4_t clip, const viewParms_t *view, vec4_t normalized, vec4_t window ) { - normalized[0] = clip[0] / clip[3]; - normalized[1] = clip[1] / clip[3]; - normalized[2] = ( clip[2] + clip[3] ) / ( 2 * clip[3] ); - - window[0] = 0.5f * ( 1.0f + normalized[0] ) * view->viewportWidth; - window[1] = 0.5f * ( 1.0f + normalized[1] ) * view->viewportHeight; - window[2] = normalized[2]; - - window[0] = (int) ( window[0] + 0.5 ); - window[1] = (int) ( window[1] + 0.5 ); -} - - -/* -========================== -myGlMultMatrix - -========================== -*/ -static void myGlMultMatrix( const float *a, const float *b, float *out ) { - int i, j; - - for ( i = 0 ; i < 4 ; i++ ) { - for ( j = 0 ; j < 4 ; j++ ) { - out[ i * 4 + j ] = - a [ i * 4 + 0 ] * b [ 0 * 4 + j ] - + a [ i * 4 + 1 ] * b [ 1 * 4 + j ] - + a [ i * 4 + 2 ] * b [ 2 * 4 + j ] - + a [ i * 4 + 3 ] * b [ 3 * 4 + j ]; - } - } -} - -/* -================= -R_RotateForEntity - -Generates an orientation for an entity and viewParms -Does NOT produce any GL calls -Called by both the front end and the back end -================= -*/ -void R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms, - orientationr_t *or ) { - float glMatrix[16]; - vec3_t delta; - float axisLength; - - if ( ent->e.reType != RT_MODEL ) { - *or = viewParms->world; - return; - } - - VectorCopy( ent->e.origin, or->origin ); - - VectorCopy( ent->e.axis[0], or->axis[0] ); - VectorCopy( ent->e.axis[1], or->axis[1] ); - VectorCopy( ent->e.axis[2], or->axis[2] ); - - glMatrix[0] = or->axis[0][0]; - glMatrix[4] = or->axis[1][0]; - glMatrix[8] = or->axis[2][0]; - glMatrix[12] = or->origin[0]; - - glMatrix[1] = or->axis[0][1]; - glMatrix[5] = or->axis[1][1]; - glMatrix[9] = or->axis[2][1]; - glMatrix[13] = or->origin[1]; - - glMatrix[2] = or->axis[0][2]; - glMatrix[6] = or->axis[1][2]; - glMatrix[10] = or->axis[2][2]; - glMatrix[14] = or->origin[2]; - - glMatrix[3] = 0; - glMatrix[7] = 0; - glMatrix[11] = 0; - glMatrix[15] = 1; - - Mat4Copy(glMatrix, or->transformMatrix); - myGlMultMatrix( glMatrix, viewParms->world.modelMatrix, or->modelMatrix ); - - // calculate the viewer origin in the model's space - // needed for fog, specular, and environment mapping - VectorSubtract( viewParms->or.origin, or->origin, delta ); - - // compensate for scale in the axes if necessary - if ( ent->e.nonNormalizedAxes ) { - axisLength = VectorLength( ent->e.axis[0] ); - if ( !axisLength ) { - axisLength = 0; - } else { - axisLength = 1.0f / axisLength; - } - } else { - axisLength = 1.0f; - } - - or->viewOrigin[0] = DotProduct( delta, or->axis[0] ) * axisLength; - or->viewOrigin[1] = DotProduct( delta, or->axis[1] ) * axisLength; - or->viewOrigin[2] = DotProduct( delta, or->axis[2] ) * axisLength; -} - -/* -================= -R_RotateForViewer - -Sets up the modelview matrix for a given viewParm -================= -*/ -static void R_RotateForViewer (void) -{ - float viewerMatrix[16]; - vec3_t origin; - - Com_Memset (&tr.or, 0, sizeof(tr.or)); - tr.or.axis[0][0] = 1; - tr.or.axis[1][1] = 1; - tr.or.axis[2][2] = 1; - VectorCopy (tr.viewParms.or.origin, tr.or.viewOrigin); - - // transform by the camera placement - VectorCopy( tr.viewParms.or.origin, origin ); - - viewerMatrix[0] = tr.viewParms.or.axis[0][0]; - viewerMatrix[4] = tr.viewParms.or.axis[0][1]; - viewerMatrix[8] = tr.viewParms.or.axis[0][2]; - viewerMatrix[12] = -origin[0] * viewerMatrix[0] + -origin[1] * viewerMatrix[4] + -origin[2] * viewerMatrix[8]; - - viewerMatrix[1] = tr.viewParms.or.axis[1][0]; - viewerMatrix[5] = tr.viewParms.or.axis[1][1]; - viewerMatrix[9] = tr.viewParms.or.axis[1][2]; - viewerMatrix[13] = -origin[0] * viewerMatrix[1] + -origin[1] * viewerMatrix[5] + -origin[2] * viewerMatrix[9]; - - viewerMatrix[2] = tr.viewParms.or.axis[2][0]; - viewerMatrix[6] = tr.viewParms.or.axis[2][1]; - viewerMatrix[10] = tr.viewParms.or.axis[2][2]; - viewerMatrix[14] = -origin[0] * viewerMatrix[2] + -origin[1] * viewerMatrix[6] + -origin[2] * viewerMatrix[10]; - - viewerMatrix[3] = 0; - viewerMatrix[7] = 0; - viewerMatrix[11] = 0; - viewerMatrix[15] = 1; - - // convert from our coordinate system (looking down X) - // to OpenGL's coordinate system (looking down -Z) - myGlMultMatrix( viewerMatrix, s_flipMatrix, tr.or.modelMatrix ); - - tr.viewParms.world = tr.or; - -} - -/* -** SetFarClip -*/ -static void R_SetFarClip( void ) -{ - float farthestCornerDistance = 0; - int i; - - // if not rendering the world (icons, menus, etc) - // set a 2k far clip plane - if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { - tr.viewParms.zFar = 2048; - return; - } - - // - // set far clipping planes dynamically - // - farthestCornerDistance = 0; - for ( i = 0; i < 8; i++ ) - { - vec3_t v; - vec3_t vecTo; - float distance; - - if ( i & 1 ) - { - v[0] = tr.viewParms.visBounds[0][0]; - } - else - { - v[0] = tr.viewParms.visBounds[1][0]; - } - - if ( i & 2 ) - { - v[1] = tr.viewParms.visBounds[0][1]; - } - else - { - v[1] = tr.viewParms.visBounds[1][1]; - } - - if ( i & 4 ) - { - v[2] = tr.viewParms.visBounds[0][2]; - } - else - { - v[2] = tr.viewParms.visBounds[1][2]; - } - - VectorSubtract( v, tr.viewParms.or.origin, vecTo ); - - distance = vecTo[0] * vecTo[0] + vecTo[1] * vecTo[1] + vecTo[2] * vecTo[2]; - - if ( distance > farthestCornerDistance ) - { - farthestCornerDistance = distance; - } - } - tr.viewParms.zFar = sqrt( farthestCornerDistance ); -} - -/* -================= -R_SetupFrustum - -Set up the culling frustum planes for the current view using the results we got from computing the first two rows of -the projection matrix. -================= -*/ -static void R_SetupFrustum (viewParms_t *dest, float xmin, float xmax, float ymax, float zProj, float zFar, float stereoSep) -{ - vec3_t ofsorigin; - float oppleg, adjleg, length; - int i; - - if(stereoSep == 0 && xmin == -xmax) - { - // symmetric case can be simplified - VectorCopy(dest->or.origin, ofsorigin); - - length = sqrt(xmax * xmax + zProj * zProj); - oppleg = xmax / length; - adjleg = zProj / length; - - VectorScale(dest->or.axis[0], oppleg, dest->frustum[0].normal); - VectorMA(dest->frustum[0].normal, adjleg, dest->or.axis[1], dest->frustum[0].normal); - - VectorScale(dest->or.axis[0], oppleg, dest->frustum[1].normal); - VectorMA(dest->frustum[1].normal, -adjleg, dest->or.axis[1], dest->frustum[1].normal); - } - else - { - // In stereo rendering, due to the modification of the projection matrix, dest->or.origin is not the - // actual origin that we're rendering so offset the tip of the view pyramid. - VectorMA(dest->or.origin, stereoSep, dest->or.axis[1], ofsorigin); - - oppleg = xmax + stereoSep; - length = sqrt(oppleg * oppleg + zProj * zProj); - VectorScale(dest->or.axis[0], oppleg / length, dest->frustum[0].normal); - VectorMA(dest->frustum[0].normal, zProj / length, dest->or.axis[1], dest->frustum[0].normal); - - oppleg = xmin + stereoSep; - length = sqrt(oppleg * oppleg + zProj * zProj); - VectorScale(dest->or.axis[0], -oppleg / length, dest->frustum[1].normal); - VectorMA(dest->frustum[1].normal, -zProj / length, dest->or.axis[1], dest->frustum[1].normal); - } - - length = sqrt(ymax * ymax + zProj * zProj); - oppleg = ymax / length; - adjleg = zProj / length; - - VectorScale(dest->or.axis[0], oppleg, dest->frustum[2].normal); - VectorMA(dest->frustum[2].normal, adjleg, dest->or.axis[2], dest->frustum[2].normal); - - VectorScale(dest->or.axis[0], oppleg, dest->frustum[3].normal); - VectorMA(dest->frustum[3].normal, -adjleg, dest->or.axis[2], dest->frustum[3].normal); - - for (i=0 ; i<4 ; i++) { - dest->frustum[i].type = PLANE_NON_AXIAL; - dest->frustum[i].dist = DotProduct (ofsorigin, dest->frustum[i].normal); - SetPlaneSignbits( &dest->frustum[i] ); - } - - if (zFar != 0.0f) - { - vec3_t farpoint; - - VectorMA(ofsorigin, zFar, dest->or.axis[0], farpoint); - VectorScale(dest->or.axis[0], -1.0f, dest->frustum[4].normal); - - dest->frustum[4].type = PLANE_NON_AXIAL; - dest->frustum[4].dist = DotProduct (farpoint, dest->frustum[4].normal); - SetPlaneSignbits( &dest->frustum[4] ); - dest->flags |= VPF_FARPLANEFRUSTUM; - } -} - -/* -=============== -R_SetupProjection -=============== -*/ -void R_SetupProjection(viewParms_t *dest, float zProj, float zFar, qboolean computeFrustum) -{ - float xmin, xmax, ymin, ymax; - float width, height, stereoSep = r_stereoSeparation->value; - - /* - * offset the view origin of the viewer for stereo rendering - * by setting the projection matrix appropriately. - */ - - if(stereoSep != 0) - { - if(dest->stereoFrame == STEREO_LEFT) - stereoSep = zProj / stereoSep; - else if(dest->stereoFrame == STEREO_RIGHT) - stereoSep = zProj / -stereoSep; - else - stereoSep = 0; - } - - ymax = zProj * tan(dest->fovY * M_PI / 360.0f); - ymin = -ymax; - - xmax = zProj * tan(dest->fovX * M_PI / 360.0f); - xmin = -xmax; - - width = xmax - xmin; - height = ymax - ymin; - - dest->projectionMatrix[0] = 2 * zProj / width; - dest->projectionMatrix[4] = 0; - dest->projectionMatrix[8] = (xmax + xmin + 2 * stereoSep) / width; - dest->projectionMatrix[12] = 2 * zProj * stereoSep / width; - - dest->projectionMatrix[1] = 0; - dest->projectionMatrix[5] = 2 * zProj / height; - dest->projectionMatrix[9] = ( ymax + ymin ) / height; // normally 0 - dest->projectionMatrix[13] = 0; - - dest->projectionMatrix[3] = 0; - dest->projectionMatrix[7] = 0; - dest->projectionMatrix[11] = -1; - dest->projectionMatrix[15] = 0; - - // Now that we have all the data for the projection matrix we can also setup the view frustum. - if(computeFrustum) - R_SetupFrustum(dest, xmin, xmax, ymax, zProj, zFar, stereoSep); -} - -/* -=============== -R_SetupProjectionZ - -Sets the z-component transformation part in the projection matrix -=============== -*/ -static void R_SetupProjectionZ(viewParms_t *dest) -{ - const float zNear = r_znear->value; - const float zFar = dest->zFar; - - const float depth = zFar - zNear; - - dest->projectionMatrix[2] = 0; - dest->projectionMatrix[6] = 0; - dest->projectionMatrix[10] = -( zFar + zNear ) / depth; - dest->projectionMatrix[14] = -2 * zFar * zNear / depth; - - if (dest->isPortal) - { - float plane[4]; - float plane2[4]; - vec4_t q, c; - - // transform portal plane into camera space - plane[0] = dest->portalPlane.normal[0]; - plane[1] = dest->portalPlane.normal[1]; - plane[2] = dest->portalPlane.normal[2]; - plane[3] = dest->portalPlane.dist; - - plane2[0] = -DotProduct (dest->or.axis[1], plane); - plane2[1] = DotProduct (dest->or.axis[2], plane); - plane2[2] = -DotProduct (dest->or.axis[0], plane); - plane2[3] = DotProduct (plane, dest->or.origin) - plane[3]; - - // Lengyel, Eric. "Modifying the Projection Matrix to Perform Oblique Near-plane Clipping". - // Terathon Software 3D Graphics Library, 2004. http://www.terathon.com/code/oblique.html - q[0] = (SGN(plane2[0]) + dest->projectionMatrix[8]) / dest->projectionMatrix[0]; - q[1] = (SGN(plane2[1]) + dest->projectionMatrix[9]) / dest->projectionMatrix[5]; - q[2] = -1.0f; - q[3] = (1.0f + dest->projectionMatrix[10]) / dest->projectionMatrix[14]; - - VectorScale4(plane2, 2.0f / DotProduct4(plane2, q), c); - - dest->projectionMatrix[2] = c[0]; - dest->projectionMatrix[6] = c[1]; - dest->projectionMatrix[10] = c[2] + 1.0f; - dest->projectionMatrix[14] = c[3]; - - } - -} - -/* -=============== -R_SetupProjectionOrtho -=============== -*/ -static void R_SetupProjectionOrtho(viewParms_t *dest, vec3_t viewBounds[2]) -{ - float xmin, xmax, ymin, ymax, znear, zfar; - //viewParms_t *dest = &tr.viewParms; - int i; - vec3_t pop; - - // Quake3: Projection: - // - // Z X Y Z - // | / | / - // |/ |/ - // Y--+ +--X - - xmin = viewBounds[0][1]; - xmax = viewBounds[1][1]; - ymin = -viewBounds[1][2]; - ymax = -viewBounds[0][2]; - znear = viewBounds[0][0]; - zfar = viewBounds[1][0]; - - dest->projectionMatrix[0] = 2 / (xmax - xmin); - dest->projectionMatrix[4] = 0; - dest->projectionMatrix[8] = 0; - dest->projectionMatrix[12] = (xmax + xmin) / (xmax - xmin); - - dest->projectionMatrix[1] = 0; - dest->projectionMatrix[5] = 2 / (ymax - ymin); - dest->projectionMatrix[9] = 0; - dest->projectionMatrix[13] = (ymax + ymin) / (ymax - ymin); - - dest->projectionMatrix[2] = 0; - dest->projectionMatrix[6] = 0; - dest->projectionMatrix[10] = -2 / (zfar - znear); - dest->projectionMatrix[14] = -(zfar + znear) / (zfar - znear); - - dest->projectionMatrix[3] = 0; - dest->projectionMatrix[7] = 0; - dest->projectionMatrix[11] = 0; - dest->projectionMatrix[15] = 1; - - VectorScale(dest->or.axis[1], 1.0f, dest->frustum[0].normal); - VectorMA(dest->or.origin, viewBounds[0][1], dest->frustum[0].normal, pop); - dest->frustum[0].dist = DotProduct(pop, dest->frustum[0].normal); - - VectorScale(dest->or.axis[1], -1.0f, dest->frustum[1].normal); - VectorMA(dest->or.origin, -viewBounds[1][1], dest->frustum[1].normal, pop); - dest->frustum[1].dist = DotProduct(pop, dest->frustum[1].normal); - - VectorScale(dest->or.axis[2], 1.0f, dest->frustum[2].normal); - VectorMA(dest->or.origin, viewBounds[0][2], dest->frustum[2].normal, pop); - dest->frustum[2].dist = DotProduct(pop, dest->frustum[2].normal); - - VectorScale(dest->or.axis[2], -1.0f, dest->frustum[3].normal); - VectorMA(dest->or.origin, -viewBounds[1][2], dest->frustum[3].normal, pop); - dest->frustum[3].dist = DotProduct(pop, dest->frustum[3].normal); - - VectorScale(dest->or.axis[0], -1.0f, dest->frustum[4].normal); - VectorMA(dest->or.origin, -viewBounds[1][0], dest->frustum[4].normal, pop); - dest->frustum[4].dist = DotProduct(pop, dest->frustum[4].normal); - - for (i = 0; i < 5; i++) - { - dest->frustum[i].type = PLANE_NON_AXIAL; - SetPlaneSignbits (&dest->frustum[i]); - } - - dest->flags |= VPF_FARPLANEFRUSTUM; -} - -/* -================= -R_MirrorPoint -================= -*/ -static void R_MirrorPoint (const vec3_t in, const orientation_t *surface, const orientation_t *camera, vec3_t out) { - int i; - vec3_t local; - vec3_t transformed; - float d; - - VectorSubtract( in, surface->origin, local ); - - VectorClear( transformed ); - for ( i = 0 ; i < 3 ; i++ ) { - d = DotProduct(local, surface->axis[i]); - VectorMA( transformed, d, camera->axis[i], transformed ); - } - - VectorAdd( transformed, camera->origin, out ); -} - -static void R_MirrorVector (const vec3_t in, const orientation_t *surface, const orientation_t *camera, vec3_t out) { - int i; - float d; - - VectorClear( out ); - for ( i = 0 ; i < 3 ; i++ ) { - d = DotProduct(in, surface->axis[i]); - VectorMA( out, d, camera->axis[i], out ); - } -} - - -/* -============= -R_PlaneForSurface -============= -*/ -static void R_PlaneForSurface (const surfaceType_t *surfType, cplane_t *plane) { - srfBspSurface_t *tri; - srfPoly_t *poly; - srfVert_t *v1, *v2, *v3; - vec4_t plane4; - - if (!surfType) { - Com_Memset (plane, 0, sizeof(*plane)); - plane->normal[0] = 1; - return; - } - switch (*surfType) { - case SF_FACE: - *plane = ((srfBspSurface_t *)surfType)->cullPlane; - return; - case SF_TRIANGLES: - tri = (srfBspSurface_t *)surfType; - v1 = tri->verts + tri->indexes[0]; - v2 = tri->verts + tri->indexes[1]; - v3 = tri->verts + tri->indexes[2]; - PlaneFromPoints( plane4, v1->xyz, v2->xyz, v3->xyz ); - VectorCopy( plane4, plane->normal ); - plane->dist = plane4[3]; - return; - case SF_POLY: - poly = (srfPoly_t *)surfType; - PlaneFromPoints( plane4, poly->verts[0].xyz, poly->verts[1].xyz, poly->verts[2].xyz ); - VectorCopy( plane4, plane->normal ); - plane->dist = plane4[3]; - return; - default: - Com_Memset (plane, 0, sizeof(*plane)); - plane->normal[0] = 1; - return; - } -} - -/* -================= -R_GetPortalOrientation - -entityNum is the entity that the portal surface is a part of, which may -be moving and rotating. - -Returns qtrue if it should be mirrored -================= -*/ -static qboolean R_GetPortalOrientations( const drawSurf_t *drawSurf, int entityNum, - orientation_t *surface, orientation_t *camera, - vec3_t pvsOrigin, qboolean *mirror ) { - int i; - cplane_t originalPlane, plane; - trRefEntity_t *e; - float d; - vec3_t transformed; - - // create plane axis for the portal we are seeing - R_PlaneForSurface( drawSurf->surface, &originalPlane ); - - // rotate the plane if necessary - if ( entityNum != REFENTITYNUM_WORLD ) { - tr.currentEntityNum = entityNum; - tr.currentEntity = &tr.refdef.entities[entityNum]; - - // get the orientation of the entity - R_RotateForEntity( tr.currentEntity, &tr.viewParms, &tr.or ); - - // rotate the plane, but keep the non-rotated version for matching - // against the portalSurface entities - R_LocalNormalToWorld( originalPlane.normal, plane.normal ); - plane.dist = originalPlane.dist + DotProduct( plane.normal, tr.or.origin ); - - // translate the original plane - originalPlane.dist = originalPlane.dist + DotProduct( originalPlane.normal, tr.or.origin ); - } else { - plane = originalPlane; - } - - VectorCopy( plane.normal, surface->axis[0] ); - PerpendicularVector( surface->axis[1], surface->axis[0] ); - CrossProduct( surface->axis[0], surface->axis[1], surface->axis[2] ); - - // locate the portal entity closest to this plane. - // origin will be the origin of the portal, origin2 will be - // the origin of the camera - for ( i = 0 ; i < tr.refdef.num_entities ; i++ ) { - e = &tr.refdef.entities[i]; - if ( e->e.reType != RT_PORTALSURFACE ) { - continue; - } - - d = DotProduct( e->e.origin, originalPlane.normal ) - originalPlane.dist; - if ( d > 64 || d < -64) { - continue; - } - - // get the pvsOrigin from the entity - VectorCopy( e->e.oldorigin, pvsOrigin ); - - // if the entity is just a mirror, don't use as a camera point - if ( e->e.oldorigin[0] == e->e.origin[0] && - e->e.oldorigin[1] == e->e.origin[1] && - e->e.oldorigin[2] == e->e.origin[2] ) { - VectorScale( plane.normal, plane.dist, surface->origin ); - VectorCopy( surface->origin, camera->origin ); - VectorSubtract( vec3_origin, surface->axis[0], camera->axis[0] ); - VectorCopy( surface->axis[1], camera->axis[1] ); - VectorCopy( surface->axis[2], camera->axis[2] ); - - *mirror = qtrue; - return qtrue; - } - - // project the origin onto the surface plane to get - // an origin point we can rotate around - d = DotProduct( e->e.origin, plane.normal ) - plane.dist; - VectorMA( e->e.origin, -d, surface->axis[0], surface->origin ); - - // now get the camera origin and orientation - VectorCopy( e->e.oldorigin, camera->origin ); - AxisCopy( e->e.axis, camera->axis ); - VectorSubtract( vec3_origin, camera->axis[0], camera->axis[0] ); - VectorSubtract( vec3_origin, camera->axis[1], camera->axis[1] ); - - // optionally rotate - if ( e->e.oldframe ) { - // if a speed is specified - if ( e->e.frame ) { - // continuous rotate - d = (tr.refdef.time/1000.0f) * e->e.frame; - VectorCopy( camera->axis[1], transformed ); - RotatePointAroundVector( camera->axis[1], camera->axis[0], transformed, d ); - CrossProduct( camera->axis[0], camera->axis[1], camera->axis[2] ); - } else { - // bobbing rotate, with skinNum being the rotation offset - d = sin( tr.refdef.time * 0.003f ); - d = e->e.skinNum + d * 4; - VectorCopy( camera->axis[1], transformed ); - RotatePointAroundVector( camera->axis[1], camera->axis[0], transformed, d ); - CrossProduct( camera->axis[0], camera->axis[1], camera->axis[2] ); - } - } - else if ( e->e.skinNum ) { - d = e->e.skinNum; - VectorCopy( camera->axis[1], transformed ); - RotatePointAroundVector( camera->axis[1], camera->axis[0], transformed, d ); - CrossProduct( camera->axis[0], camera->axis[1], camera->axis[2] ); - } - *mirror = qfalse; - return qtrue; - } - - // if we didn't locate a portal entity, don't render anything. - // We don't want to just treat it as a mirror, because without a - // portal entity the server won't have communicated a proper entity set - // in the snapshot - - // unfortunately, with local movement prediction it is easily possible - // to see a surface before the server has communicated the matching - // portal surface entity, so we don't want to print anything here... - - //ri.Printf( PRINT_ALL, "Portal surface without a portal entity\n" ); - - return qfalse; -} - -static qboolean IsMirror( const drawSurf_t *drawSurf, int entityNum ) -{ - int i; - cplane_t originalPlane, plane; - trRefEntity_t *e; - float d; - - // create plane axis for the portal we are seeing - R_PlaneForSurface( drawSurf->surface, &originalPlane ); - - // rotate the plane if necessary - if ( entityNum != REFENTITYNUM_WORLD ) - { - tr.currentEntityNum = entityNum; - tr.currentEntity = &tr.refdef.entities[entityNum]; - - // get the orientation of the entity - R_RotateForEntity( tr.currentEntity, &tr.viewParms, &tr.or ); - - // rotate the plane, but keep the non-rotated version for matching - // against the portalSurface entities - R_LocalNormalToWorld( originalPlane.normal, plane.normal ); - plane.dist = originalPlane.dist + DotProduct( plane.normal, tr.or.origin ); - - // translate the original plane - originalPlane.dist = originalPlane.dist + DotProduct( originalPlane.normal, tr.or.origin ); - } - - // locate the portal entity closest to this plane. - // origin will be the origin of the portal, origin2 will be - // the origin of the camera - for ( i = 0 ; i < tr.refdef.num_entities ; i++ ) - { - e = &tr.refdef.entities[i]; - if ( e->e.reType != RT_PORTALSURFACE ) { - continue; - } - - d = DotProduct( e->e.origin, originalPlane.normal ) - originalPlane.dist; - if ( d > 64 || d < -64) { - continue; - } - - // if the entity is just a mirror, don't use as a camera point - if ( e->e.oldorigin[0] == e->e.origin[0] && - e->e.oldorigin[1] == e->e.origin[1] && - e->e.oldorigin[2] == e->e.origin[2] ) - { - return qtrue; - } - - return qfalse; - } - return qfalse; -} - -/* -** SurfIsOffscreen -** -** Determines if a surface is completely offscreen. -*/ -static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128] ) { - float shortest = 100000000; - int entityNum; - int numTriangles; - shader_t *shader; - int fogNum; - int dlighted; - int pshadowed; - vec4_t clip, eye; - int i; - unsigned int pointOr = 0; - unsigned int pointAnd = (unsigned int)~0; - - R_RotateForViewer(); - - R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlighted, &pshadowed ); - RB_BeginSurface( shader, fogNum, drawSurf->cubemapIndex); - rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); - - assert( tess.numVertexes < 128 ); - - for ( i = 0; i < tess.numVertexes; i++ ) - { - int j; - unsigned int pointFlags = 0; - - R_TransformModelToClip( tess.xyz[i], tr.or.modelMatrix, tr.viewParms.projectionMatrix, eye, clip ); - - for ( j = 0; j < 3; j++ ) - { - if ( clip[j] >= clip[3] ) - { - pointFlags |= (1 << (j*2)); - } - else if ( clip[j] <= -clip[3] ) - { - pointFlags |= ( 1 << (j*2+1)); - } - } - pointAnd &= pointFlags; - pointOr |= pointFlags; - } - - // trivially reject - if ( pointAnd ) - { - return qtrue; - } - - // determine if this surface is backfaced and also determine the distance - // to the nearest vertex so we can cull based on portal range. Culling - // based on vertex distance isn't 100% correct (we should be checking for - // range to the surface), but it's good enough for the types of portals - // we have in the game right now. - numTriangles = tess.numIndexes / 3; - - for ( i = 0; i < tess.numIndexes; i += 3 ) - { - vec3_t normal, tNormal; - - float len; - - VectorSubtract( tess.xyz[tess.indexes[i]], tr.viewParms.or.origin, normal ); - - len = VectorLengthSquared( normal ); // lose the sqrt - if ( len < shortest ) - { - shortest = len; - } - - R_VaoUnpackNormal(tNormal, tess.normal[tess.indexes[i]]); - - if ( DotProduct( normal, tNormal ) >= 0 ) - { - numTriangles--; - } - } - if ( !numTriangles ) - { - return qtrue; - } - - // mirrors can early out at this point, since we don't do a fade over distance - // with them (although we could) - if ( IsMirror( drawSurf, entityNum ) ) - { - return qfalse; - } - - if ( shortest > (tess.shader->portalRange*tess.shader->portalRange) ) - { - return qtrue; - } - - return qfalse; -} - -/* -======================== -R_MirrorViewBySurface - -Returns qtrue if another view has been rendered -======================== -*/ -static qboolean R_MirrorViewBySurface (const drawSurf_t *drawSurf, int entityNum) { - vec4_t clipDest[128]; - viewParms_t newParms; - viewParms_t oldParms; - orientation_t surface, camera; - - // don't recursively mirror - if (tr.viewParms.isPortal) { - ri.Printf( PRINT_DEVELOPER, "WARNING: recursive mirror/portal found\n" ); - return qfalse; - } - - if ( r_noportals->integer || (r_fastsky->integer == 1) ) { - return qfalse; - } - - // trivially reject portal/mirror - if ( SurfIsOffscreen( drawSurf, clipDest ) ) { - return qfalse; - } - - // save old viewParms so we can return to it after the mirror view - oldParms = tr.viewParms; - - newParms = tr.viewParms; - newParms.isPortal = qtrue; - newParms.zFar = 0.0f; - newParms.flags &= ~VPF_FARPLANEFRUSTUM; - if ( !R_GetPortalOrientations( drawSurf, entityNum, &surface, &camera, - newParms.pvsOrigin, &newParms.isMirror ) ) { - return qfalse; // bad portal, no portalentity - } - - // Never draw viewmodels in portal or mirror views. - newParms.flags |= VPF_NOVIEWMODEL; - - R_MirrorPoint (oldParms.or.origin, &surface, &camera, newParms.or.origin ); - - VectorSubtract( vec3_origin, camera.axis[0], newParms.portalPlane.normal ); - newParms.portalPlane.dist = DotProduct( camera.origin, newParms.portalPlane.normal ); - - R_MirrorVector (oldParms.or.axis[0], &surface, &camera, newParms.or.axis[0]); - R_MirrorVector (oldParms.or.axis[1], &surface, &camera, newParms.or.axis[1]); - R_MirrorVector (oldParms.or.axis[2], &surface, &camera, newParms.or.axis[2]); - - // OPTIMIZE: restrict the viewport on the mirrored view - - // render the mirror view - R_RenderView (&newParms); - - tr.viewParms = oldParms; - - return qtrue; -} - -/* -================= -R_SpriteFogNum - -See if a sprite is inside a fog volume -================= -*/ -static int R_SpriteFogNum( const trRefEntity_t *ent ) { - int i, j; - const fog_t *fog; - - if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { - return 0; - } - - if ( ent->e.renderfx & RF_CROSSHAIR ) { - return 0; - } - - for ( i = 1 ; i < tr.world->numfogs ; i++ ) { - fog = &tr.world->fogs[i]; - for ( j = 0 ; j < 3 ; j++ ) { - if ( ent->e.origin[j] - ent->e.radius >= fog->bounds[1][j] ) { - break; - } - if ( ent->e.origin[j] + ent->e.radius <= fog->bounds[0][j] ) { - break; - } - } - if ( j == 3 ) { - return i; - } - } - - return 0; -} - -/* -========================================================================================== - -DRAWSURF SORTING - -========================================================================================== -*/ - -/* -=============== -R_Radix -=============== -*/ -static ID_INLINE void R_Radix( int byte, int size, const drawSurf_t *source, drawSurf_t *dest ) -{ - int count[ 256 ] = { 0 }; - int index[ 256 ]; - int i; - unsigned char *sortKey = NULL; - unsigned char *end = NULL; - - sortKey = ( (unsigned char *)&source[ 0 ].sort ) + byte; - end = sortKey + ( size * sizeof( drawSurf_t ) ); - for( ; sortKey < end; sortKey += sizeof( drawSurf_t ) ) - ++count[ *sortKey ]; - - index[ 0 ] = 0; - - for( i = 1; i < 256; ++i ) - index[ i ] = index[ i - 1 ] + count[ i - 1 ]; - - sortKey = ( (unsigned char *)&source[ 0 ].sort ) + byte; - for( i = 0; i < size; ++i, sortKey += sizeof( drawSurf_t ) ) - dest[ index[ *sortKey ]++ ] = source[ i ]; -} - -/* -=============== -R_RadixSort - -Radix sort with 4 byte size buckets -=============== -*/ -static void R_RadixSort( drawSurf_t *source, int size ) -{ - static drawSurf_t scratch[ MAX_DRAWSURFS ]; -#ifdef Q3_LITTLE_ENDIAN - R_Radix( 0, size, source, scratch ); - R_Radix( 1, size, scratch, source ); - R_Radix( 2, size, source, scratch ); - R_Radix( 3, size, scratch, source ); -#else - R_Radix( 3, size, source, scratch ); - R_Radix( 2, size, scratch, source ); - R_Radix( 1, size, source, scratch ); - R_Radix( 0, size, scratch, source ); -#endif //Q3_LITTLE_ENDIAN -} - -//========================================================================================== - -/* -================= -R_AddDrawSurf -================= -*/ -void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, - int fogIndex, int dlightMap, int pshadowMap, int cubemap ) { - int index; - - // instead of checking for overflow, we just mask the index - // so it wraps around - index = tr.refdef.numDrawSurfs & DRAWSURF_MASK; - // the sort data is packed into a single 32 bit value so it can be - // compared quickly during the qsorting process - tr.refdef.drawSurfs[index].sort = (shader->sortedIndex << QSORT_SHADERNUM_SHIFT) - | tr.shiftedEntityNum | ( fogIndex << QSORT_FOGNUM_SHIFT ) - | ((int)pshadowMap << QSORT_PSHADOW_SHIFT) | (int)dlightMap; - tr.refdef.drawSurfs[index].cubemapIndex = cubemap; - tr.refdef.drawSurfs[index].surface = surface; - tr.refdef.numDrawSurfs++; -} - -/* -================= -R_DecomposeSort -================= -*/ -void R_DecomposeSort( unsigned sort, int *entityNum, shader_t **shader, - int *fogNum, int *dlightMap, int *pshadowMap ) { - *fogNum = ( sort >> QSORT_FOGNUM_SHIFT ) & 31; - *shader = tr.sortedShaders[ ( sort >> QSORT_SHADERNUM_SHIFT ) & (MAX_SHADERS-1) ]; - *entityNum = ( sort >> QSORT_REFENTITYNUM_SHIFT ) & REFENTITYNUM_MASK; - *pshadowMap = (sort >> QSORT_PSHADOW_SHIFT ) & 1; - *dlightMap = sort & 1; -} - -/* -================= -R_SortDrawSurfs -================= -*/ -static void R_SortDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { - shader_t *shader; - int fogNum; - int entityNum; - int dlighted; - int pshadowed; - int i; - - //ri.Printf(PRINT_ALL, "firstDrawSurf %d numDrawSurfs %d\n", (int)(drawSurfs - tr.refdef.drawSurfs), numDrawSurfs); - - // it is possible for some views to not have any surfaces - if ( numDrawSurfs < 1 ) { - // we still need to add it for hyperspace cases - R_AddDrawSurfCmd( drawSurfs, numDrawSurfs ); - return; - } - - // sort the drawsurfs by sort type, then orientation, then shader - R_RadixSort( drawSurfs, numDrawSurfs ); - - // skip pass through drawing if rendering a shadow map - if (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)) - { - R_AddDrawSurfCmd( drawSurfs, numDrawSurfs ); - return; - } - - // check for any pass through drawing, which - // may cause another view to be rendered first - for ( i = 0 ; i < numDrawSurfs ; i++ ) { - R_DecomposeSort( (drawSurfs+i)->sort, &entityNum, &shader, &fogNum, &dlighted, &pshadowed ); - - if ( shader->sort > SS_PORTAL ) { - break; - } - - // no shader should ever have this sort type - if ( shader->sort == SS_BAD ) { - ri.Error (ERR_DROP, "Shader '%s'with sort == SS_BAD", shader->name ); - } - - // if the mirror was completely clipped away, we may need to check another surface - if ( R_MirrorViewBySurface( (drawSurfs+i), entityNum) ) { - // this is a debug option to see exactly what is being mirrored - if ( r_portalOnly->integer ) { - return; - } - break; // only one mirror view at a time - } - } - - R_AddDrawSurfCmd( drawSurfs, numDrawSurfs ); -} - -static void R_AddEntitySurface (int entityNum) -{ - trRefEntity_t *ent; - shader_t *shader; - - tr.currentEntityNum = entityNum; - - ent = tr.currentEntity = &tr.refdef.entities[tr.currentEntityNum]; - - ent->needDlights = qfalse; - - // preshift the value we are going to OR into the drawsurf sort - tr.shiftedEntityNum = tr.currentEntityNum << QSORT_REFENTITYNUM_SHIFT; - - // - // the weapon model must be handled special -- - // we don't want the hacked first person weapon position showing in - // mirrors, because the true body position will already be drawn - // - if ( (ent->e.renderfx & RF_FIRST_PERSON) && (tr.viewParms.flags & VPF_NOVIEWMODEL)) { - return; - } - - // simple generated models, like sprites and beams, are not culled - switch ( ent->e.reType ) { - case RT_PORTALSURFACE: - break; // don't draw anything - case RT_SPRITE: - case RT_BEAM: - case RT_LIGHTNING: - case RT_RAIL_CORE: - case RT_RAIL_RINGS: - // self blood sprites, talk balloons, etc should not be drawn in the primary - // view. We can't just do this check for all entities, because md3 - // entities may still want to cast shadows from them - if ( (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal) { - return; - } - shader = R_GetShaderByHandle( ent->e.customShader ); - R_AddDrawSurf( &entitySurface, shader, R_SpriteFogNum( ent ), 0, 0, 0 /*cubeMap*/ ); - break; - - case RT_MODEL: - // we must set up parts of tr.or for model culling - R_RotateForEntity( ent, &tr.viewParms, &tr.or ); - - tr.currentModel = R_GetModelByHandle( ent->e.hModel ); - if (!tr.currentModel) { - R_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0, 0, 0 /*cubeMap*/ ); - } else { - switch ( tr.currentModel->type ) { - case MOD_MESH: - R_AddMD3Surfaces( ent ); - break; - case MOD_MDR: - R_MDRAddAnimSurfaces( ent ); - break; - case MOD_IQM: - R_AddIQMSurfaces( ent ); - break; - case MOD_BRUSH: - R_AddBrushModelSurfaces( ent ); - break; - case MOD_BAD: // null model axis - if ( (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal) { - break; - } - R_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0, 0, 0 ); - break; - default: - ri.Error( ERR_DROP, "R_AddEntitySurfaces: Bad modeltype" ); - break; - } - } - break; - default: - ri.Error( ERR_DROP, "R_AddEntitySurfaces: Bad reType" ); - } -} - -/* -============= -R_AddEntitySurfaces -============= -*/ -static void R_AddEntitySurfaces (void) { - int i; - - if ( !r_drawentities->integer ) { - return; - } - - for ( i = 0; i < tr.refdef.num_entities; i++) - R_AddEntitySurface(i); -} - - -/* -==================== -R_GenerateDrawSurfs -==================== -*/ -static void R_GenerateDrawSurfs( void ) { - R_AddWorldSurfaces (); - - R_AddPolygonSurfaces(); - - // set the projection matrix with the minimum zfar - // now that we have the world bounded - // this needs to be done before entities are - // added, because they use the projection - // matrix for lod calculation - - // dynamically compute far clip plane distance - if (!(tr.viewParms.flags & VPF_SHADOWMAP)) - { - R_SetFarClip(); - } - - // we know the size of the clipping volume. Now set the rest of the projection matrix. - R_SetupProjectionZ (&tr.viewParms); - - R_AddEntitySurfaces (); -} - -/* -================ -R_DebugPolygon -================ -*/ -static void R_DebugPolygon( int color, int numPoints, float *points ) { - // FIXME: implement this -#if 0 - int i; - - GL_State( GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); - - // draw solid shade - - qglColor3f( color&1, (color>>1)&1, (color>>2)&1 ); - qglBegin( GL_POLYGON ); - for ( i = 0 ; i < numPoints ; i++ ) { - qglVertex3fv( points + i * 3 ); - } - qglEnd(); - - // draw wireframe outline - GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); - qglDepthRange( 0, 0 ); - qglColor3f( 1, 1, 1 ); - qglBegin( GL_POLYGON ); - for ( i = 0 ; i < numPoints ; i++ ) { - qglVertex3fv( points + i * 3 ); - } - qglEnd(); - qglDepthRange( 0, 1 ); -#endif -} - -/* -==================== -R_DebugGraphics - -Visualization aid for movement clipping debugging -==================== -*/ -static void R_DebugGraphics( void ) { - if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { - return; - } - if ( !r_debugSurface->integer ) { - return; - } - - R_IssuePendingRenderCommands(); - - GL_BindToTMU(tr.whiteImage, TB_COLORMAP); - GL_Cull( CT_FRONT_SIDED ); - ri.CM_DrawDebugSurface( R_DebugPolygon ); -} - - -/* -================ -R_RenderView - -A view may be either the actual camera view, -or a mirror / remote location -================ -*/ -void R_RenderView (const viewParms_t *parms) { - int firstDrawSurf; - int numDrawSurfs; - - if ( parms->viewportWidth <= 0 || parms->viewportHeight <= 0 ) { - return; - } - - tr.viewCount++; - - tr.viewParms = *parms; - tr.viewParms.frameSceneNum = tr.frameSceneNum; - tr.viewParms.frameCount = tr.frameCount; - - firstDrawSurf = tr.refdef.numDrawSurfs; - - tr.viewCount++; - - // set viewParms.world - R_RotateForViewer (); - - R_SetupProjection(&tr.viewParms, r_zproj->value, tr.viewParms.zFar, qtrue); - - R_GenerateDrawSurfs(); - - // if we overflowed MAX_DRAWSURFS, the drawsurfs - // wrapped around in the buffer and we will be missing - // the first surfaces, not the last ones - numDrawSurfs = tr.refdef.numDrawSurfs; - if ( numDrawSurfs > MAX_DRAWSURFS ) { - numDrawSurfs = MAX_DRAWSURFS; - } - - R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, numDrawSurfs - firstDrawSurf ); - - // draw main system development information (surface outlines, etc) - R_DebugGraphics(); -} - - -void R_RenderDlightCubemaps(const refdef_t *fd) -{ - int i; - - for (i = 0; i < tr.refdef.num_dlights; i++) - { - viewParms_t shadowParms; - int j; - - // use previous frame to determine visible dlights - if ((1 << i) & tr.refdef.dlightMask) - continue; - - Com_Memset( &shadowParms, 0, sizeof( shadowParms ) ); - - shadowParms.viewportX = tr.refdef.x; - shadowParms.viewportY = glConfig.vidHeight - ( tr.refdef.y + PSHADOW_MAP_SIZE ); - shadowParms.viewportWidth = PSHADOW_MAP_SIZE; - shadowParms.viewportHeight = PSHADOW_MAP_SIZE; - shadowParms.isPortal = qfalse; - shadowParms.isMirror = qtrue; // because it is - - shadowParms.fovX = 90; - shadowParms.fovY = 90; - - shadowParms.flags = VPF_SHADOWMAP | VPF_DEPTHSHADOW | VPF_NOVIEWMODEL; - shadowParms.zFar = tr.refdef.dlights[i].radius; - - VectorCopy( tr.refdef.dlights[i].origin, shadowParms.or.origin ); - - for (j = 0; j < 6; j++) - { - switch(j) - { - case 0: - // -X - VectorSet( shadowParms.or.axis[0], -1, 0, 0); - VectorSet( shadowParms.or.axis[1], 0, 0, -1); - VectorSet( shadowParms.or.axis[2], 0, 1, 0); - break; - case 1: - // +X - VectorSet( shadowParms.or.axis[0], 1, 0, 0); - VectorSet( shadowParms.or.axis[1], 0, 0, 1); - VectorSet( shadowParms.or.axis[2], 0, 1, 0); - break; - case 2: - // -Y - VectorSet( shadowParms.or.axis[0], 0, -1, 0); - VectorSet( shadowParms.or.axis[1], 1, 0, 0); - VectorSet( shadowParms.or.axis[2], 0, 0, -1); - break; - case 3: - // +Y - VectorSet( shadowParms.or.axis[0], 0, 1, 0); - VectorSet( shadowParms.or.axis[1], 1, 0, 0); - VectorSet( shadowParms.or.axis[2], 0, 0, 1); - break; - case 4: - // -Z - VectorSet( shadowParms.or.axis[0], 0, 0, -1); - VectorSet( shadowParms.or.axis[1], 1, 0, 0); - VectorSet( shadowParms.or.axis[2], 0, 1, 0); - break; - case 5: - // +Z - VectorSet( shadowParms.or.axis[0], 0, 0, 1); - VectorSet( shadowParms.or.axis[1], -1, 0, 0); - VectorSet( shadowParms.or.axis[2], 0, 1, 0); - break; - } - - R_RenderView(&shadowParms); - R_AddCapShadowmapCmd( i, j ); - } - } -} - - -void R_RenderPshadowMaps(const refdef_t *fd) -{ - viewParms_t shadowParms; - int i; - - // first, make a list of shadows - for ( i = 0; i < tr.refdef.num_entities; i++) - { - trRefEntity_t *ent = &tr.refdef.entities[i]; - - if((ent->e.renderfx & (RF_FIRST_PERSON | RF_NOSHADOW))) - continue; - - //if((ent->e.renderfx & RF_THIRD_PERSON)) - //continue; - - if (ent->e.reType == RT_MODEL) - { - model_t *model = R_GetModelByHandle( ent->e.hModel ); - pshadow_t shadow; - float radius = 0.0f; - float scale = 1.0f; - vec3_t diff; - int j; - - if (!model) - continue; - - if (ent->e.nonNormalizedAxes) - { - scale = VectorLength( ent->e.axis[0] ); - } - - switch (model->type) - { - case MOD_MESH: - { - mdvFrame_t *frame = &model->mdv[0]->frames[ent->e.frame]; - - radius = frame->radius * scale; - } - break; - - case MOD_MDR: - { - // FIXME: never actually tested this - mdrHeader_t *header = model->modelData; - int frameSize = (size_t)( &((mdrFrame_t *)0)->bones[ header->numBones ] ); - mdrFrame_t *frame = ( mdrFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.frame); - - radius = frame->radius; - } - break; - case MOD_IQM: - { - // FIXME: never actually tested this - iqmData_t *data = model->modelData; - vec3_t diag; - float *framebounds; - - framebounds = data->bounds + 6*ent->e.frame; - VectorSubtract( framebounds+3, framebounds, diag ); - radius = 0.5f * VectorLength( diag ); - } - break; - - default: - break; - } - - if (!radius) - continue; - - // Cull entities that are behind the viewer by more than lightRadius - VectorSubtract(ent->e.origin, fd->vieworg, diff); - if (DotProduct(diff, fd->viewaxis[0]) < -r_pshadowDist->value) - continue; - - memset(&shadow, 0, sizeof(shadow)); - - shadow.numEntities = 1; - shadow.entityNums[0] = i; - shadow.viewRadius = radius; - shadow.lightRadius = r_pshadowDist->value; - VectorCopy(ent->e.origin, shadow.viewOrigin); - shadow.sort = DotProduct(diff, diff) / (radius * radius); - VectorCopy(ent->e.origin, shadow.entityOrigins[0]); - shadow.entityRadiuses[0] = radius; - - for (j = 0; j < MAX_CALC_PSHADOWS; j++) - { - pshadow_t swap; - - if (j + 1 > tr.refdef.num_pshadows) - { - tr.refdef.num_pshadows = j + 1; - tr.refdef.pshadows[j] = shadow; - break; - } - - // sort shadows by distance from camera divided by radius - // FIXME: sort better - if (tr.refdef.pshadows[j].sort <= shadow.sort) - continue; - - swap = tr.refdef.pshadows[j]; - tr.refdef.pshadows[j] = shadow; - shadow = swap; - } - } - } - - // next, merge touching pshadows - for ( i = 0; i < tr.refdef.num_pshadows; i++) - { - pshadow_t *ps1 = &tr.refdef.pshadows[i]; - int j; - - for (j = i + 1; j < tr.refdef.num_pshadows; j++) - { - pshadow_t *ps2 = &tr.refdef.pshadows[j]; - int k; - qboolean touch; - - if (ps1->numEntities == 8) - break; - - touch = qfalse; - if (SpheresIntersect(ps1->viewOrigin, ps1->viewRadius, ps2->viewOrigin, ps2->viewRadius)) - { - for (k = 0; k < ps1->numEntities; k++) - { - if (SpheresIntersect(ps1->entityOrigins[k], ps1->entityRadiuses[k], ps2->viewOrigin, ps2->viewRadius)) - { - touch = qtrue; - break; - } - } - } - - if (touch) - { - vec3_t newOrigin; - float newRadius; - - BoundingSphereOfSpheres(ps1->viewOrigin, ps1->viewRadius, ps2->viewOrigin, ps2->viewRadius, newOrigin, &newRadius); - VectorCopy(newOrigin, ps1->viewOrigin); - ps1->viewRadius = newRadius; - - ps1->entityNums[ps1->numEntities] = ps2->entityNums[0]; - VectorCopy(ps2->viewOrigin, ps1->entityOrigins[ps1->numEntities]); - ps1->entityRadiuses[ps1->numEntities] = ps2->viewRadius; - - ps1->numEntities++; - - for (k = j; k < tr.refdef.num_pshadows - 1; k++) - { - tr.refdef.pshadows[k] = tr.refdef.pshadows[k + 1]; - } - - j--; - tr.refdef.num_pshadows--; - } - } - } - - // cap number of drawn pshadows - if (tr.refdef.num_pshadows > MAX_DRAWN_PSHADOWS) - { - tr.refdef.num_pshadows = MAX_DRAWN_PSHADOWS; - } - - // next, fill up the rest of the shadow info - for ( i = 0; i < tr.refdef.num_pshadows; i++) - { - pshadow_t *shadow = &tr.refdef.pshadows[i]; - vec3_t up; - vec3_t ambientLight, directedLight, lightDir; - - VectorSet(lightDir, 0.57735f, 0.57735f, 0.57735f); -#if 1 - R_LightForPoint(shadow->viewOrigin, ambientLight, directedLight, lightDir); - - // sometimes there's no light - if (DotProduct(lightDir, lightDir) < 0.9f) - VectorSet(lightDir, 0.0f, 0.0f, 1.0f); -#endif - - if (shadow->viewRadius * 3.0f > shadow->lightRadius) - { - shadow->lightRadius = shadow->viewRadius * 3.0f; - } - - VectorMA(shadow->viewOrigin, shadow->viewRadius, lightDir, shadow->lightOrigin); - - // make up a projection, up doesn't matter - VectorScale(lightDir, -1.0f, shadow->lightViewAxis[0]); - VectorSet(up, 0, 0, -1); - - if ( fabsf(DotProduct(up, shadow->lightViewAxis[0])) > 0.9f ) - { - VectorSet(up, -1, 0, 0); - } - - CrossProduct(shadow->lightViewAxis[0], up, shadow->lightViewAxis[1]); - VectorNormalize(shadow->lightViewAxis[1]); - CrossProduct(shadow->lightViewAxis[0], shadow->lightViewAxis[1], shadow->lightViewAxis[2]); - - VectorCopy(shadow->lightViewAxis[0], shadow->cullPlane.normal); - shadow->cullPlane.dist = DotProduct(shadow->cullPlane.normal, shadow->lightOrigin); - shadow->cullPlane.type = PLANE_NON_AXIAL; - SetPlaneSignbits(&shadow->cullPlane); - } - - // next, render shadowmaps - for ( i = 0; i < tr.refdef.num_pshadows; i++) - { - int firstDrawSurf; - pshadow_t *shadow = &tr.refdef.pshadows[i]; - int j; - - Com_Memset( &shadowParms, 0, sizeof( shadowParms ) ); - - if (glRefConfig.framebufferObject) - { - shadowParms.viewportX = 0; - shadowParms.viewportY = 0; - } - else - { - shadowParms.viewportX = tr.refdef.x; - shadowParms.viewportY = glConfig.vidHeight - ( tr.refdef.y + PSHADOW_MAP_SIZE ); - } - shadowParms.viewportWidth = PSHADOW_MAP_SIZE; - shadowParms.viewportHeight = PSHADOW_MAP_SIZE; - shadowParms.isPortal = qfalse; - shadowParms.isMirror = qfalse; - - shadowParms.fovX = 90; - shadowParms.fovY = 90; - - if (glRefConfig.framebufferObject) - shadowParms.targetFbo = tr.pshadowFbos[i]; - - shadowParms.flags = VPF_DEPTHSHADOW | VPF_NOVIEWMODEL; - shadowParms.zFar = shadow->lightRadius; - - VectorCopy(shadow->lightOrigin, shadowParms.or.origin); - - VectorCopy(shadow->lightViewAxis[0], shadowParms.or.axis[0]); - VectorCopy(shadow->lightViewAxis[1], shadowParms.or.axis[1]); - VectorCopy(shadow->lightViewAxis[2], shadowParms.or.axis[2]); - - { - tr.viewCount++; - - tr.viewParms = shadowParms; - tr.viewParms.frameSceneNum = tr.frameSceneNum; - tr.viewParms.frameCount = tr.frameCount; - - firstDrawSurf = tr.refdef.numDrawSurfs; - - tr.viewCount++; - - // set viewParms.world - R_RotateForViewer (); - - { - float xmin, xmax, ymin, ymax, znear, zfar; - viewParms_t *dest = &tr.viewParms; - vec3_t pop; - - xmin = ymin = -shadow->viewRadius; - xmax = ymax = shadow->viewRadius; - znear = 0; - zfar = shadow->lightRadius; - - dest->projectionMatrix[0] = 2 / (xmax - xmin); - dest->projectionMatrix[4] = 0; - dest->projectionMatrix[8] = (xmax + xmin) / (xmax - xmin); - dest->projectionMatrix[12] =0; - - dest->projectionMatrix[1] = 0; - dest->projectionMatrix[5] = 2 / (ymax - ymin); - dest->projectionMatrix[9] = ( ymax + ymin ) / (ymax - ymin); // normally 0 - dest->projectionMatrix[13] = 0; - - dest->projectionMatrix[2] = 0; - dest->projectionMatrix[6] = 0; - dest->projectionMatrix[10] = 2 / (zfar - znear); - dest->projectionMatrix[14] = 0; - - dest->projectionMatrix[3] = 0; - dest->projectionMatrix[7] = 0; - dest->projectionMatrix[11] = 0; - dest->projectionMatrix[15] = 1; - - VectorScale(dest->or.axis[1], 1.0f, dest->frustum[0].normal); - VectorMA(dest->or.origin, -shadow->viewRadius, dest->frustum[0].normal, pop); - dest->frustum[0].dist = DotProduct(pop, dest->frustum[0].normal); - - VectorScale(dest->or.axis[1], -1.0f, dest->frustum[1].normal); - VectorMA(dest->or.origin, -shadow->viewRadius, dest->frustum[1].normal, pop); - dest->frustum[1].dist = DotProduct(pop, dest->frustum[1].normal); - - VectorScale(dest->or.axis[2], 1.0f, dest->frustum[2].normal); - VectorMA(dest->or.origin, -shadow->viewRadius, dest->frustum[2].normal, pop); - dest->frustum[2].dist = DotProduct(pop, dest->frustum[2].normal); - - VectorScale(dest->or.axis[2], -1.0f, dest->frustum[3].normal); - VectorMA(dest->or.origin, -shadow->viewRadius, dest->frustum[3].normal, pop); - dest->frustum[3].dist = DotProduct(pop, dest->frustum[3].normal); - - VectorScale(dest->or.axis[0], -1.0f, dest->frustum[4].normal); - VectorMA(dest->or.origin, -shadow->lightRadius, dest->frustum[4].normal, pop); - dest->frustum[4].dist = DotProduct(pop, dest->frustum[4].normal); - - for (j = 0; j < 5; j++) - { - dest->frustum[j].type = PLANE_NON_AXIAL; - SetPlaneSignbits (&dest->frustum[j]); - } - - dest->flags |= VPF_FARPLANEFRUSTUM; - } - - for (j = 0; j < shadow->numEntities; j++) - { - R_AddEntitySurface(shadow->entityNums[j]); - } - - R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); - - if (!glRefConfig.framebufferObject) - R_AddCapShadowmapCmd( i, -1 ); - } - } -} - -static float CalcSplit(float n, float f, float i, float m) -{ - return (n * pow(f / n, i / m) + (f - n) * i / m) / 2.0f; -} - - -void R_RenderSunShadowMaps(const refdef_t *fd, int level) -{ - viewParms_t shadowParms; - vec4_t lightDir, lightCol; - vec3_t lightViewAxis[3]; - vec3_t lightOrigin; - float splitZNear, splitZFar, splitBias; - float viewZNear, viewZFar; - vec3_t lightviewBounds[2]; - qboolean lightViewIndependentOfCameraView = qfalse; - - if (r_forceSun->integer == 2) - { - int scale = 32768; - float angle = (fd->time % scale) / (float)scale * M_PI; - lightDir[0] = cos(angle); - lightDir[1] = sin(35.0f * M_PI / 180.0f); - lightDir[2] = sin(angle) * cos(35.0f * M_PI / 180.0f); - lightDir[3] = 0.0f; - - if (1) //((fd->time % (scale * 2)) < scale) - { - lightCol[0] = - lightCol[1] = - lightCol[2] = CLAMP(sin(angle) * 2.0f, 0.0f, 1.0f) * 2.0f; - lightCol[3] = 1.0f; - } - else - { - lightCol[0] = - lightCol[1] = - lightCol[2] = CLAMP(sin(angle) * 2.0f * 0.1f, 0.0f, 0.1f); - lightCol[3] = 1.0f; - } - - VectorCopy4(lightDir, tr.refdef.sunDir); - VectorCopy4(lightCol, tr.refdef.sunCol); - VectorScale4(lightCol, 0.2f, tr.refdef.sunAmbCol); - } - else - { - VectorCopy4(tr.refdef.sunDir, lightDir); - } - - viewZNear = r_shadowCascadeZNear->value; - viewZFar = r_shadowCascadeZFar->value; - splitBias = r_shadowCascadeZBias->value; - - switch(level) - { - case 0: - default: - //splitZNear = r_znear->value; - //splitZFar = 256; - splitZNear = viewZNear; - splitZFar = CalcSplit(viewZNear, viewZFar, 1, 3) + splitBias; - break; - case 1: - splitZNear = CalcSplit(viewZNear, viewZFar, 1, 3) + splitBias; - splitZFar = CalcSplit(viewZNear, viewZFar, 2, 3) + splitBias; - //splitZNear = 256; - //splitZFar = 896; - break; - case 2: - splitZNear = CalcSplit(viewZNear, viewZFar, 2, 3) + splitBias; - splitZFar = viewZFar; - //splitZNear = 896; - //splitZFar = 3072; - break; - } - - if (level != 3) - VectorCopy(fd->vieworg, lightOrigin); - else - VectorCopy(tr.world->lightGridOrigin, lightOrigin); - - // Make up a projection - VectorScale(lightDir, -1.0f, lightViewAxis[0]); - - if (level == 3 || lightViewIndependentOfCameraView) - { - // Use world up as light view up - VectorSet(lightViewAxis[2], 0, 0, 1); - } - else if (level == 0) - { - // Level 0 tries to use a diamond texture orientation relative to camera view - // Use halfway between camera view forward and left for light view up - VectorAdd(fd->viewaxis[0], fd->viewaxis[1], lightViewAxis[2]); - } - else - { - // Use camera view up as light view up - VectorCopy(fd->viewaxis[2], lightViewAxis[2]); - } - - // Check if too close to parallel to light direction - if (fabsf(DotProduct(lightViewAxis[2], lightViewAxis[0])) > 0.9f) - { - if (level == 3 || lightViewIndependentOfCameraView) - { - // Use world left as light view up - VectorSet(lightViewAxis[2], 0, 1, 0); - } - else if (level == 0) - { - // Level 0 tries to use a diamond texture orientation relative to camera view - // Use halfway between camera view forward and up for light view up - VectorAdd(fd->viewaxis[0], fd->viewaxis[2], lightViewAxis[2]); - } - else - { - // Use camera view left as light view up - VectorCopy(fd->viewaxis[1], lightViewAxis[2]); - } - } - - // clean axes - CrossProduct(lightViewAxis[2], lightViewAxis[0], lightViewAxis[1]); - VectorNormalize(lightViewAxis[1]); - CrossProduct(lightViewAxis[0], lightViewAxis[1], lightViewAxis[2]); - - // Create bounds for light projection using slice of view projection - { - mat4_t lightViewMatrix; - vec4_t point, base, lightViewPoint; - float lx, ly; - - base[3] = 1; - point[3] = 1; - lightViewPoint[3] = 1; - - Mat4View(lightViewAxis, lightOrigin, lightViewMatrix); - - ClearBounds(lightviewBounds[0], lightviewBounds[1]); - - if (level != 3) - { - // add view near plane - lx = splitZNear * tan(fd->fov_x * M_PI / 360.0f); - ly = splitZNear * tan(fd->fov_y * M_PI / 360.0f); - VectorMA(fd->vieworg, splitZNear, fd->viewaxis[0], base); - - VectorMA(base, lx, fd->viewaxis[1], point); - VectorMA(point, ly, fd->viewaxis[2], point); - Mat4Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - - VectorMA(base, -lx, fd->viewaxis[1], point); - VectorMA(point, ly, fd->viewaxis[2], point); - Mat4Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - - VectorMA(base, lx, fd->viewaxis[1], point); - VectorMA(point, -ly, fd->viewaxis[2], point); - Mat4Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - - VectorMA(base, -lx, fd->viewaxis[1], point); - VectorMA(point, -ly, fd->viewaxis[2], point); - Mat4Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - - - // add view far plane - lx = splitZFar * tan(fd->fov_x * M_PI / 360.0f); - ly = splitZFar * tan(fd->fov_y * M_PI / 360.0f); - VectorMA(fd->vieworg, splitZFar, fd->viewaxis[0], base); - - VectorMA(base, lx, fd->viewaxis[1], point); - VectorMA(point, ly, fd->viewaxis[2], point); - Mat4Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - - VectorMA(base, -lx, fd->viewaxis[1], point); - VectorMA(point, ly, fd->viewaxis[2], point); - Mat4Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - - VectorMA(base, lx, fd->viewaxis[1], point); - VectorMA(point, -ly, fd->viewaxis[2], point); - Mat4Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - - VectorMA(base, -lx, fd->viewaxis[1], point); - VectorMA(point, -ly, fd->viewaxis[2], point); - Mat4Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - } - else - { - // use light grid size as level size - // FIXME: could be tighter - vec3_t bounds; - - bounds[0] = tr.world->lightGridSize[0] * tr.world->lightGridBounds[0]; - bounds[1] = tr.world->lightGridSize[1] * tr.world->lightGridBounds[1]; - bounds[2] = tr.world->lightGridSize[2] * tr.world->lightGridBounds[2]; - - point[0] = tr.world->lightGridOrigin[0]; - point[1] = tr.world->lightGridOrigin[1]; - point[2] = tr.world->lightGridOrigin[2]; - Mat4Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - - point[0] = tr.world->lightGridOrigin[0] + bounds[0]; - point[1] = tr.world->lightGridOrigin[1]; - point[2] = tr.world->lightGridOrigin[2]; - Mat4Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - - point[0] = tr.world->lightGridOrigin[0]; - point[1] = tr.world->lightGridOrigin[1] + bounds[1]; - point[2] = tr.world->lightGridOrigin[2]; - Mat4Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - - point[0] = tr.world->lightGridOrigin[0] + bounds[0]; - point[1] = tr.world->lightGridOrigin[1] + bounds[1]; - point[2] = tr.world->lightGridOrigin[2]; - Mat4Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - - point[0] = tr.world->lightGridOrigin[0]; - point[1] = tr.world->lightGridOrigin[1]; - point[2] = tr.world->lightGridOrigin[2] + bounds[2]; - Mat4Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - - point[0] = tr.world->lightGridOrigin[0] + bounds[0]; - point[1] = tr.world->lightGridOrigin[1]; - point[2] = tr.world->lightGridOrigin[2] + bounds[2]; - Mat4Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - - point[0] = tr.world->lightGridOrigin[0]; - point[1] = tr.world->lightGridOrigin[1] + bounds[1]; - point[2] = tr.world->lightGridOrigin[2] + bounds[2]; - Mat4Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - - point[0] = tr.world->lightGridOrigin[0] + bounds[0]; - point[1] = tr.world->lightGridOrigin[1] + bounds[1]; - point[2] = tr.world->lightGridOrigin[2] + bounds[2]; - Mat4Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - } - - if (!glRefConfig.depthClamp) - lightviewBounds[0][0] = lightviewBounds[1][0] - 8192; - - // Moving the Light in Texel-Sized Increments - // from http://msdn.microsoft.com/en-us/library/windows/desktop/ee416324%28v=vs.85%29.aspx - // - if (lightViewIndependentOfCameraView) - { - float cascadeBound, worldUnitsPerTexel, invWorldUnitsPerTexel; - - cascadeBound = MAX(lightviewBounds[1][0] - lightviewBounds[0][0], lightviewBounds[1][1] - lightviewBounds[0][1]); - cascadeBound = MAX(cascadeBound, lightviewBounds[1][2] - lightviewBounds[0][2]); - worldUnitsPerTexel = cascadeBound / tr.sunShadowFbo[level]->width; - invWorldUnitsPerTexel = 1.0f / worldUnitsPerTexel; - - VectorScale(lightviewBounds[0], invWorldUnitsPerTexel, lightviewBounds[0]); - lightviewBounds[0][0] = floor(lightviewBounds[0][0]); - lightviewBounds[0][1] = floor(lightviewBounds[0][1]); - lightviewBounds[0][2] = floor(lightviewBounds[0][2]); - VectorScale(lightviewBounds[0], worldUnitsPerTexel, lightviewBounds[0]); - - VectorScale(lightviewBounds[1], invWorldUnitsPerTexel, lightviewBounds[1]); - lightviewBounds[1][0] = floor(lightviewBounds[1][0]); - lightviewBounds[1][1] = floor(lightviewBounds[1][1]); - lightviewBounds[1][2] = floor(lightviewBounds[1][2]); - VectorScale(lightviewBounds[1], worldUnitsPerTexel, lightviewBounds[1]); - } - - //ri.Printf(PRINT_ALL, "level %d znear %f zfar %f\n", level, lightviewBounds[0][0], lightviewBounds[1][0]); - //ri.Printf(PRINT_ALL, "xmin %f xmax %f ymin %f ymax %f\n", lightviewBounds[0][1], lightviewBounds[1][1], -lightviewBounds[1][2], -lightviewBounds[0][2]); - } - - { - int firstDrawSurf; - - Com_Memset( &shadowParms, 0, sizeof( shadowParms ) ); - - if (glRefConfig.framebufferObject) - { - shadowParms.viewportX = 0; - shadowParms.viewportY = 0; - } - else - { - shadowParms.viewportX = tr.refdef.x; - shadowParms.viewportY = glConfig.vidHeight - ( tr.refdef.y + tr.sunShadowFbo[level]->height ); - } - shadowParms.viewportWidth = tr.sunShadowFbo[level]->width; - shadowParms.viewportHeight = tr.sunShadowFbo[level]->height; - shadowParms.isPortal = qfalse; - shadowParms.isMirror = qfalse; - - shadowParms.fovX = 90; - shadowParms.fovY = 90; - - if (glRefConfig.framebufferObject) - shadowParms.targetFbo = tr.sunShadowFbo[level]; - - shadowParms.flags = VPF_DEPTHSHADOW | VPF_DEPTHCLAMP | VPF_ORTHOGRAPHIC | VPF_NOVIEWMODEL; - shadowParms.zFar = lightviewBounds[1][0]; - - VectorCopy(lightOrigin, shadowParms.or.origin); - - VectorCopy(lightViewAxis[0], shadowParms.or.axis[0]); - VectorCopy(lightViewAxis[1], shadowParms.or.axis[1]); - VectorCopy(lightViewAxis[2], shadowParms.or.axis[2]); - - VectorCopy(lightOrigin, shadowParms.pvsOrigin ); - - { - tr.viewCount++; - - tr.viewParms = shadowParms; - tr.viewParms.frameSceneNum = tr.frameSceneNum; - tr.viewParms.frameCount = tr.frameCount; - - firstDrawSurf = tr.refdef.numDrawSurfs; - - tr.viewCount++; - - // set viewParms.world - R_RotateForViewer (); - - R_SetupProjectionOrtho(&tr.viewParms, lightviewBounds); - - R_AddWorldSurfaces (); - - R_AddPolygonSurfaces(); - - R_AddEntitySurfaces (); - - R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); - } - - Mat4Multiply(tr.viewParms.projectionMatrix, tr.viewParms.world.modelMatrix, tr.refdef.sunShadowMvp[level]); - } -} - -void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ) -{ - refdef_t refdef; - viewParms_t parms; - - memset( &refdef, 0, sizeof( refdef ) ); - refdef.rdflags = 0; - VectorCopy(tr.cubemaps[cubemapIndex].origin, refdef.vieworg); - - switch(cubemapSide) - { - case 0: - // -X - VectorSet( refdef.viewaxis[0], -1, 0, 0); - VectorSet( refdef.viewaxis[1], 0, 0, -1); - VectorSet( refdef.viewaxis[2], 0, 1, 0); - break; - case 1: - // +X - VectorSet( refdef.viewaxis[0], 1, 0, 0); - VectorSet( refdef.viewaxis[1], 0, 0, 1); - VectorSet( refdef.viewaxis[2], 0, 1, 0); - break; - case 2: - // -Y - VectorSet( refdef.viewaxis[0], 0, -1, 0); - VectorSet( refdef.viewaxis[1], 1, 0, 0); - VectorSet( refdef.viewaxis[2], 0, 0, -1); - break; - case 3: - // +Y - VectorSet( refdef.viewaxis[0], 0, 1, 0); - VectorSet( refdef.viewaxis[1], 1, 0, 0); - VectorSet( refdef.viewaxis[2], 0, 0, 1); - break; - case 4: - // -Z - VectorSet( refdef.viewaxis[0], 0, 0, -1); - VectorSet( refdef.viewaxis[1], 1, 0, 0); - VectorSet( refdef.viewaxis[2], 0, 1, 0); - break; - case 5: - // +Z - VectorSet( refdef.viewaxis[0], 0, 0, 1); - VectorSet( refdef.viewaxis[1], -1, 0, 0); - VectorSet( refdef.viewaxis[2], 0, 1, 0); - break; - } - - refdef.fov_x = 90; - refdef.fov_y = 90; - - refdef.x = 0; - refdef.y = 0; - refdef.width = tr.renderCubeFbo->width; - refdef.height = tr.renderCubeFbo->height; - - refdef.time = 0; - - if (!subscene) - { - RE_BeginScene(&refdef); - - // FIXME: sun shadows aren't rendered correctly in cubemaps - // fix involves changing r_FBufScale to fit smaller cubemap image size, or rendering cubemap to framebuffer first - if(0) //(glRefConfig.framebufferObject && r_sunlightMode->integer && (r_forceSun->integer || tr.sunShadows)) - { - R_RenderSunShadowMaps(&refdef, 0); - R_RenderSunShadowMaps(&refdef, 1); - R_RenderSunShadowMaps(&refdef, 2); - R_RenderSunShadowMaps(&refdef, 3); - } - } - - { - vec3_t ambient, directed, lightDir; - float scale; - - R_LightForPoint(tr.refdef.vieworg, ambient, directed, lightDir); - scale = directed[0] + directed[1] + directed[2] + ambient[0] + ambient[1] + ambient[2] + 1.0f; - - // only print message for first side - if (scale < 1.0001f && cubemapSide == 0) - { - ri.Printf(PRINT_ALL, "cubemap %d %s (%f, %f, %f) is outside the lightgrid or inside a wall!\n", cubemapIndex, tr.cubemaps[cubemapIndex].name, tr.refdef.vieworg[0], tr.refdef.vieworg[1], tr.refdef.vieworg[2]); - } - } - - Com_Memset( &parms, 0, sizeof( parms ) ); - - parms.viewportX = 0; - parms.viewportY = 0; - parms.viewportWidth = tr.renderCubeFbo->width; - parms.viewportHeight = tr.renderCubeFbo->height; - parms.isPortal = qfalse; - parms.isMirror = qtrue; - parms.flags = VPF_NOVIEWMODEL | VPF_NOCUBEMAPS; - - parms.fovX = 90; - parms.fovY = 90; - - VectorCopy( refdef.vieworg, parms.or.origin ); - VectorCopy( refdef.viewaxis[0], parms.or.axis[0] ); - VectorCopy( refdef.viewaxis[1], parms.or.axis[1] ); - VectorCopy( refdef.viewaxis[2], parms.or.axis[2] ); - - VectorCopy( refdef.vieworg, parms.pvsOrigin ); - - // FIXME: sun shadows aren't rendered correctly in cubemaps - // fix involves changing r_FBufScale to fit smaller cubemap image size, or rendering cubemap to framebuffer first - if (0) //(r_depthPrepass->value && ((r_forceSun->integer) || tr.sunShadows)) - { - parms.flags = VPF_USESUNLIGHT; - } - - parms.targetFbo = tr.renderCubeFbo; - parms.targetFboLayer = cubemapSide; - parms.targetFboCubemapIndex = cubemapIndex; - - R_RenderView(&parms); - - if (!subscene) - RE_EndScene(); -} diff --git a/code/renderer2/tr_marks.c b/code/renderer2/tr_marks.c deleted file mode 100644 index 5b37b57f42..0000000000 --- a/code/renderer2/tr_marks.c +++ /dev/null @@ -1,473 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_marks.c -- polygon projection on the world polygons - -#include "tr_local.h" -//#include "assert.h" - -#define MAX_VERTS_ON_POLY 64 - -#define MARKER_OFFSET 0 // 1 - -/* -============= -R_ChopPolyBehindPlane - -Out must have space for two more vertexes than in -============= -*/ -#define SIDE_FRONT 0 -#define SIDE_BACK 1 -#define SIDE_ON 2 -static void R_ChopPolyBehindPlane( int numInPoints, vec3_t inPoints[MAX_VERTS_ON_POLY], - int *numOutPoints, vec3_t outPoints[MAX_VERTS_ON_POLY], - vec3_t normal, vec_t dist, vec_t epsilon) { - float dists[MAX_VERTS_ON_POLY+4]; - int sides[MAX_VERTS_ON_POLY+4]; - int counts[3]; - float dot; - int i, j; - float *p1, *p2, *clip; - float d; - - // don't clip if it might overflow - if ( numInPoints >= MAX_VERTS_ON_POLY - 2 ) { - *numOutPoints = 0; - return; - } - - counts[0] = counts[1] = counts[2] = 0; - dists[0] = 0.0; - sides[0] = 0; - - // determine sides for each point - for ( i = 0 ; i < numInPoints ; i++ ) { - dot = DotProduct( inPoints[i], normal ); - dot -= dist; - dists[i] = dot; - if ( dot > epsilon ) { - sides[i] = SIDE_FRONT; - } else if ( dot < -epsilon ) { - sides[i] = SIDE_BACK; - } else { - sides[i] = SIDE_ON; - } - counts[sides[i]]++; - } - sides[i] = sides[0]; - dists[i] = dists[0]; - - *numOutPoints = 0; - - if ( !counts[0] ) { - return; - } - if ( !counts[1] ) { - *numOutPoints = numInPoints; - Com_Memcpy( outPoints, inPoints, numInPoints * sizeof(vec3_t) ); - return; - } - - for ( i = 0 ; i < numInPoints ; i++ ) { - p1 = inPoints[i]; - clip = outPoints[ *numOutPoints ]; - - if ( sides[i] == SIDE_ON ) { - VectorCopy( p1, clip ); - (*numOutPoints)++; - continue; - } - - if ( sides[i] == SIDE_FRONT ) { - VectorCopy( p1, clip ); - (*numOutPoints)++; - clip = outPoints[ *numOutPoints ]; - } - - if ( sides[i+1] == SIDE_ON || sides[i+1] == sides[i] ) { - continue; - } - - // generate a split point - p2 = inPoints[ (i+1) % numInPoints ]; - - d = dists[i] - dists[i+1]; - if ( d == 0 ) { - dot = 0; - } else { - dot = dists[i] / d; - } - - // clip xyz - - for (j=0 ; j<3 ; j++) { - clip[j] = p1[j] + dot * ( p2[j] - p1[j] ); - } - - (*numOutPoints)++; - } -} - -/* -================= -R_BoxSurfaces_r - -================= -*/ -static void R_BoxSurfaces_r(mnode_t *node, vec3_t mins, vec3_t maxs, surfaceType_t **list, int listsize, int *listlength, vec3_t dir) { - - int s, c; - msurface_t *surf; - int *mark; - - // do the tail recursion in a loop - while ( node->contents == -1 ) { - s = BoxOnPlaneSide( mins, maxs, node->plane ); - if (s == 1) { - node = node->children[0]; - } else if (s == 2) { - node = node->children[1]; - } else { - R_BoxSurfaces_r(node->children[0], mins, maxs, list, listsize, listlength, dir); - node = node->children[1]; - } - } - - // add the individual surfaces - mark = tr.world->marksurfaces + node->firstmarksurface; - c = node->nummarksurfaces; - while (c--) { - int *surfViewCount; - // - if (*listlength >= listsize) break; - // - surfViewCount = &tr.world->surfacesViewCount[*mark]; - surf = tr.world->surfaces + *mark; - // check if the surface has NOIMPACT or NOMARKS set - if ( ( surf->shader->surfaceFlags & ( SURF_NOIMPACT | SURF_NOMARKS ) ) - || ( surf->shader->contentFlags & CONTENTS_FOG ) ) { - *surfViewCount = tr.viewCount; - } - // extra check for surfaces to avoid list overflows - else if (*(surf->data) == SF_FACE) { - // the face plane should go through the box - s = BoxOnPlaneSide( mins, maxs, &surf->cullinfo.plane ); - if (s == 1 || s == 2) { - *surfViewCount = tr.viewCount; - } else if (DotProduct(surf->cullinfo.plane.normal, dir) > -0.5) { - // don't add faces that make sharp angles with the projection direction - *surfViewCount = tr.viewCount; - } - } - else if (*(surf->data) != SF_GRID && - *(surf->data) != SF_TRIANGLES) - *surfViewCount = tr.viewCount; - // check the viewCount because the surface may have - // already been added if it spans multiple leafs - if (*surfViewCount != tr.viewCount) { - *surfViewCount = tr.viewCount; - list[*listlength] = surf->data; - (*listlength)++; - } - mark++; - } -} - -/* -================= -R_AddMarkFragments - -================= -*/ -static void R_AddMarkFragments(int numClipPoints, vec3_t clipPoints[2][MAX_VERTS_ON_POLY], - int numPlanes, vec3_t *normals, float *dists, - int maxPoints, vec3_t pointBuffer, - int maxFragments, markFragment_t *fragmentBuffer, - int *returnedPoints, int *returnedFragments, - vec3_t mins, vec3_t maxs) { - int pingPong, i; - markFragment_t *mf; - - // chop the surface by all the bounding planes of the to be projected polygon - pingPong = 0; - - for ( i = 0 ; i < numPlanes ; i++ ) { - - R_ChopPolyBehindPlane( numClipPoints, clipPoints[pingPong], - &numClipPoints, clipPoints[!pingPong], - normals[i], dists[i], 0.5 ); - pingPong ^= 1; - if ( numClipPoints == 0 ) { - break; - } - } - // completely clipped away? - if ( numClipPoints == 0 ) { - return; - } - - // add this fragment to the returned list - if ( numClipPoints + (*returnedPoints) > maxPoints ) { - return; // not enough space for this polygon - } - /* - // all the clip points should be within the bounding box - for ( i = 0 ; i < numClipPoints ; i++ ) { - int j; - for ( j = 0 ; j < 3 ; j++ ) { - if (clipPoints[pingPong][i][j] < mins[j] - 0.5) break; - if (clipPoints[pingPong][i][j] > maxs[j] + 0.5) break; - } - if (j < 3) break; - } - if (i < numClipPoints) return; - */ - - mf = fragmentBuffer + (*returnedFragments); - mf->firstPoint = (*returnedPoints); - mf->numPoints = numClipPoints; - Com_Memcpy( pointBuffer + (*returnedPoints) * 3, clipPoints[pingPong], numClipPoints * sizeof(vec3_t) ); - - (*returnedPoints) += numClipPoints; - (*returnedFragments)++; -} - -/* -================= -R_MarkFragments - -================= -*/ -int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection, - int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ) { - int numsurfaces, numPlanes; - int i, j, k, m, n; - surfaceType_t *surfaces[64]; - vec3_t mins, maxs; - int returnedFragments; - int returnedPoints; - vec3_t normals[MAX_VERTS_ON_POLY+2]; - float dists[MAX_VERTS_ON_POLY+2]; - vec3_t clipPoints[2][MAX_VERTS_ON_POLY]; - int numClipPoints; - float *v; - const srfBspSurface_t *cv; - glIndex_t *tri; - srfVert_t *dv; - vec3_t normal; - vec3_t projectionDir; - vec3_t v1, v2; - - if (numPoints <= 0) { - return 0; - } - - //increment view count for double check prevention - tr.viewCount++; - - // - VectorNormalize2( projection, projectionDir ); - // find all the brushes that are to be considered - ClearBounds( mins, maxs ); - for ( i = 0 ; i < numPoints ; i++ ) { - vec3_t temp; - - AddPointToBounds( points[i], mins, maxs ); - VectorAdd( points[i], projection, temp ); - AddPointToBounds( temp, mins, maxs ); - // make sure we get all the leafs (also the one(s) in front of the hit surface) - VectorMA( points[i], -20, projectionDir, temp ); - AddPointToBounds( temp, mins, maxs ); - } - - if (numPoints > MAX_VERTS_ON_POLY) numPoints = MAX_VERTS_ON_POLY; - // create the bounding planes for the to be projected polygon - for ( i = 0 ; i < numPoints ; i++ ) { - VectorSubtract(points[(i+1)%numPoints], points[i], v1); - VectorAdd(points[i], projection, v2); - VectorSubtract(points[i], v2, v2); - CrossProduct(v1, v2, normals[i]); - VectorNormalizeFast(normals[i]); - dists[i] = DotProduct(normals[i], points[i]); - } - // add near and far clipping planes for projection - VectorCopy(projectionDir, normals[numPoints]); - dists[numPoints] = DotProduct(normals[numPoints], points[0]) - 32; - VectorCopy(projectionDir, normals[numPoints+1]); - VectorInverse(normals[numPoints+1]); - dists[numPoints+1] = DotProduct(normals[numPoints+1], points[0]) - 20; - numPlanes = numPoints + 2; - - numsurfaces = 0; - R_BoxSurfaces_r(tr.world->nodes, mins, maxs, surfaces, 64, &numsurfaces, projectionDir); - //assert(numsurfaces <= 64); - //assert(numsurfaces != 64); - - returnedPoints = 0; - returnedFragments = 0; - - for ( i = 0 ; i < numsurfaces ; i++ ) { - - if (*surfaces[i] == SF_GRID) { - - cv = (srfBspSurface_t *) surfaces[i]; - for ( m = 0 ; m < cv->height - 1 ; m++ ) { - for ( n = 0 ; n < cv->width - 1 ; n++ ) { - // We triangulate the grid and chop all triangles within - // the bounding planes of the to be projected polygon. - // LOD is not taken into account, not such a big deal though. - // - // It's probably much nicer to chop the grid itself and deal - // with this grid as a normal SF_GRID surface so LOD will - // be applied. However the LOD of that chopped grid must - // be synced with the LOD of the original curve. - // One way to do this; the chopped grid shares vertices with - // the original curve. When LOD is applied to the original - // curve the unused vertices are flagged. Now the chopped curve - // should skip the flagged vertices. This still leaves the - // problems with the vertices at the chopped grid edges. - // - // To avoid issues when LOD applied to "hollow curves" (like - // the ones around many jump pads) we now just add a 2 unit - // offset to the triangle vertices. - // The offset is added in the vertex normal vector direction - // so all triangles will still fit together. - // The 2 unit offset should avoid pretty much all LOD problems. - vec3_t fNormal; - - numClipPoints = 3; - - dv = cv->verts + m * cv->width + n; - - VectorCopy(dv[0].xyz, clipPoints[0][0]); - R_VaoUnpackNormal(fNormal, dv[0].normal); - VectorMA(clipPoints[0][0], MARKER_OFFSET, fNormal, clipPoints[0][0]); - VectorCopy(dv[cv->width].xyz, clipPoints[0][1]); - R_VaoUnpackNormal(fNormal, dv[cv->width].normal); - VectorMA(clipPoints[0][1], MARKER_OFFSET, fNormal, clipPoints[0][1]); - VectorCopy(dv[1].xyz, clipPoints[0][2]); - R_VaoUnpackNormal(fNormal, dv[1].normal); - VectorMA(clipPoints[0][2], MARKER_OFFSET, fNormal, clipPoints[0][2]); - // check the normal of this triangle - VectorSubtract(clipPoints[0][0], clipPoints[0][1], v1); - VectorSubtract(clipPoints[0][2], clipPoints[0][1], v2); - CrossProduct(v1, v2, normal); - VectorNormalizeFast(normal); - if (DotProduct(normal, projectionDir) < -0.1) { - // add the fragments of this triangle - R_AddMarkFragments(numClipPoints, clipPoints, - numPlanes, normals, dists, - maxPoints, pointBuffer, - maxFragments, fragmentBuffer, - &returnedPoints, &returnedFragments, mins, maxs); - - if ( returnedFragments == maxFragments ) { - return returnedFragments; // not enough space for more fragments - } - } - - VectorCopy(dv[1].xyz, clipPoints[0][0]); - R_VaoUnpackNormal(fNormal, dv[1].normal); - VectorMA(clipPoints[0][0], MARKER_OFFSET, fNormal, clipPoints[0][0]); - VectorCopy(dv[cv->width].xyz, clipPoints[0][1]); - R_VaoUnpackNormal(fNormal, dv[cv->width].normal); - VectorMA(clipPoints[0][1], MARKER_OFFSET, fNormal, clipPoints[0][1]); - VectorCopy(dv[cv->width+1].xyz, clipPoints[0][2]); - R_VaoUnpackNormal(fNormal, dv[cv->width + 1].normal); - VectorMA(clipPoints[0][2], MARKER_OFFSET, fNormal, clipPoints[0][2]); - // check the normal of this triangle - VectorSubtract(clipPoints[0][0], clipPoints[0][1], v1); - VectorSubtract(clipPoints[0][2], clipPoints[0][1], v2); - CrossProduct(v1, v2, normal); - VectorNormalizeFast(normal); - if (DotProduct(normal, projectionDir) < -0.05) { - // add the fragments of this triangle - R_AddMarkFragments(numClipPoints, clipPoints, - numPlanes, normals, dists, - maxPoints, pointBuffer, - maxFragments, fragmentBuffer, - &returnedPoints, &returnedFragments, mins, maxs); - - if ( returnedFragments == maxFragments ) { - return returnedFragments; // not enough space for more fragments - } - } - } - } - } - else if (*surfaces[i] == SF_FACE) { - - srfBspSurface_t *surf = ( srfBspSurface_t * ) surfaces[i]; - - // check the normal of this face - if (DotProduct(surf->cullPlane.normal, projectionDir) > -0.5) { - continue; - } - - for(k = 0, tri = surf->indexes; k < surf->numIndexes; k += 3, tri += 3) - { - for(j = 0; j < 3; j++) - { - v = surf->verts[tri[j]].xyz; - VectorMA(v, MARKER_OFFSET, surf->cullPlane.normal, clipPoints[0][j]); - } - - // add the fragments of this face - R_AddMarkFragments( 3 , clipPoints, - numPlanes, normals, dists, - maxPoints, pointBuffer, - maxFragments, fragmentBuffer, - &returnedPoints, &returnedFragments, mins, maxs); - if ( returnedFragments == maxFragments ) { - return returnedFragments; // not enough space for more fragments - } - } - } - else if(*surfaces[i] == SF_TRIANGLES && r_marksOnTriangleMeshes->integer) { - - srfBspSurface_t *surf = (srfBspSurface_t *) surfaces[i]; - - for(k = 0, tri = surf->indexes; k < surf->numIndexes; k += 3, tri += 3) - { - for(j = 0; j < 3; j++) - { - vec3_t fNormal; - v = surf->verts[tri[j]].xyz; - R_VaoUnpackNormal(fNormal, surf->verts[tri[j]].normal); - VectorMA(v, MARKER_OFFSET, fNormal, clipPoints[0][j]); - } - - // add the fragments of this face - R_AddMarkFragments(3, clipPoints, - numPlanes, normals, dists, - maxPoints, pointBuffer, - maxFragments, fragmentBuffer, &returnedPoints, &returnedFragments, mins, maxs); - if(returnedFragments == maxFragments) - { - return returnedFragments; // not enough space for more fragments - } - } - } - } - return returnedFragments; -} - diff --git a/code/renderer2/tr_mesh.c b/code/renderer2/tr_mesh.c deleted file mode 100644 index 268c64c370..0000000000 --- a/code/renderer2/tr_mesh.c +++ /dev/null @@ -1,417 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_mesh.c: triangle model functions - -#include "tr_local.h" - -static float ProjectRadius( float r, vec3_t location ) -{ - float pr; - float dist; - float c; - vec3_t p; - float projected[4]; - - c = DotProduct( tr.viewParms.or.axis[0], tr.viewParms.or.origin ); - dist = DotProduct( tr.viewParms.or.axis[0], location ) - c; - - if ( dist <= 0 ) - return 0; - - p[0] = 0; - p[1] = fabs( r ); - p[2] = -dist; - - projected[0] = p[0] * tr.viewParms.projectionMatrix[0] + - p[1] * tr.viewParms.projectionMatrix[4] + - p[2] * tr.viewParms.projectionMatrix[8] + - tr.viewParms.projectionMatrix[12]; - - projected[1] = p[0] * tr.viewParms.projectionMatrix[1] + - p[1] * tr.viewParms.projectionMatrix[5] + - p[2] * tr.viewParms.projectionMatrix[9] + - tr.viewParms.projectionMatrix[13]; - - projected[2] = p[0] * tr.viewParms.projectionMatrix[2] + - p[1] * tr.viewParms.projectionMatrix[6] + - p[2] * tr.viewParms.projectionMatrix[10] + - tr.viewParms.projectionMatrix[14]; - - projected[3] = p[0] * tr.viewParms.projectionMatrix[3] + - p[1] * tr.viewParms.projectionMatrix[7] + - p[2] * tr.viewParms.projectionMatrix[11] + - tr.viewParms.projectionMatrix[15]; - - - pr = projected[1] / projected[3]; - - if ( pr > 1.0f ) - pr = 1.0f; - - return pr; -} - -/* -============= -R_CullModel -============= -*/ -static int R_CullModel( mdvModel_t *model, const trRefEntity_t *ent ) { - vec3_t bounds[2]; - mdvFrame_t *oldFrame, *newFrame; - int i; - - // compute frame pointers - newFrame = model->frames + ent->e.frame; - oldFrame = model->frames + ent->e.oldframe; - - // cull bounding sphere ONLY if this is not an upscaled entity - if ( !ent->e.nonNormalizedAxes ) - { - if ( ent->e.frame == ent->e.oldframe ) - { - switch ( R_CullLocalPointAndRadius( newFrame->localOrigin, newFrame->radius ) ) - { - case CULL_OUT: - tr.pc.c_sphere_cull_md3_out++; - return CULL_OUT; - - case CULL_IN: - tr.pc.c_sphere_cull_md3_in++; - return CULL_IN; - - case CULL_CLIP: - tr.pc.c_sphere_cull_md3_clip++; - break; - } - } - else - { - int sphereCull, sphereCullB; - - sphereCull = R_CullLocalPointAndRadius( newFrame->localOrigin, newFrame->radius ); - if ( newFrame == oldFrame ) { - sphereCullB = sphereCull; - } else { - sphereCullB = R_CullLocalPointAndRadius( oldFrame->localOrigin, oldFrame->radius ); - } - - if ( sphereCull == sphereCullB ) - { - if ( sphereCull == CULL_OUT ) - { - tr.pc.c_sphere_cull_md3_out++; - return CULL_OUT; - } - else if ( sphereCull == CULL_IN ) - { - tr.pc.c_sphere_cull_md3_in++; - return CULL_IN; - } - else - { - tr.pc.c_sphere_cull_md3_clip++; - } - } - } - } - - // calculate a bounding box in the current coordinate system - for (i = 0 ; i < 3 ; i++) { - bounds[0][i] = oldFrame->bounds[0][i] < newFrame->bounds[0][i] ? oldFrame->bounds[0][i] : newFrame->bounds[0][i]; - bounds[1][i] = oldFrame->bounds[1][i] > newFrame->bounds[1][i] ? oldFrame->bounds[1][i] : newFrame->bounds[1][i]; - } - - switch ( R_CullLocalBox( bounds ) ) - { - case CULL_IN: - tr.pc.c_box_cull_md3_in++; - return CULL_IN; - case CULL_CLIP: - tr.pc.c_box_cull_md3_clip++; - return CULL_CLIP; - case CULL_OUT: - default: - tr.pc.c_box_cull_md3_out++; - return CULL_OUT; - } -} - - -/* -================= -R_ComputeLOD - -================= -*/ -int R_ComputeLOD( trRefEntity_t *ent ) { - float radius; - float flod, lodscale; - float projectedRadius; - mdvFrame_t *frame; - mdrHeader_t *mdr; - mdrFrame_t *mdrframe; - int lod; - - if ( tr.currentModel->numLods < 2 ) - { - // model has only 1 LOD level, skip computations and bias - lod = 0; - } - else - { - // multiple LODs exist, so compute projected bounding sphere - // and use that as a criteria for selecting LOD - - if(tr.currentModel->type == MOD_MDR) - { - int frameSize; - mdr = (mdrHeader_t *) tr.currentModel->modelData; - frameSize = (size_t) (&((mdrFrame_t *)0)->bones[mdr->numBones]); - - mdrframe = (mdrFrame_t *) ((byte *) mdr + mdr->ofsFrames + frameSize * ent->e.frame); - - radius = RadiusFromBounds(mdrframe->bounds[0], mdrframe->bounds[1]); - } - else - { - //frame = ( md3Frame_t * ) ( ( ( unsigned char * ) tr.currentModel->md3[0] ) + tr.currentModel->md3[0]->ofsFrames ); - frame = tr.currentModel->mdv[0]->frames; - - frame += ent->e.frame; - - radius = RadiusFromBounds( frame->bounds[0], frame->bounds[1] ); - } - - if ( ( projectedRadius = ProjectRadius( radius, ent->e.origin ) ) != 0 ) - { - lodscale = r_lodscale->value; - if (lodscale > 20) lodscale = 20; - flod = 1.0f - projectedRadius * lodscale; - } - else - { - // object intersects near view plane, e.g. view weapon - flod = 0; - } - - flod *= tr.currentModel->numLods; - lod = myftol(flod); - - if ( lod < 0 ) - { - lod = 0; - } - else if ( lod >= tr.currentModel->numLods ) - { - lod = tr.currentModel->numLods - 1; - } - } - - lod += r_lodbias->integer; - - if ( lod >= tr.currentModel->numLods ) - lod = tr.currentModel->numLods - 1; - if ( lod < 0 ) - lod = 0; - - return lod; -} - -/* -================= -R_ComputeFogNum - -================= -*/ -static int R_ComputeFogNum( mdvModel_t *model, const trRefEntity_t *ent ) { - int i, j; - const fog_t *fog; - mdvFrame_t *mdvFrame; - vec3_t localOrigin; - - if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { - return 0; - } - - // FIXME: non-normalized axis issues - mdvFrame = model->frames + ent->e.frame; - VectorAdd( ent->e.origin, mdvFrame->localOrigin, localOrigin ); - for ( i = 1 ; i < tr.world->numfogs ; i++ ) { - fog = &tr.world->fogs[i]; - for ( j = 0 ; j < 3 ; j++ ) { - if ( localOrigin[j] - mdvFrame->radius >= fog->bounds[1][j] ) { - break; - } - if ( localOrigin[j] + mdvFrame->radius <= fog->bounds[0][j] ) { - break; - } - } - if ( j == 3 ) { - return i; - } - } - - return 0; -} - -/* -================= -R_AddMD3Surfaces - -================= -*/ -void R_AddMD3Surfaces( trRefEntity_t *ent ) { - int i; - mdvModel_t *model = NULL; - mdvSurface_t *surface = NULL; - shader_t *shader = NULL; - int cull; - int lod; - int fogNum; - int cubemapIndex; - qboolean personalModel; - - // don't add third_person objects if not in a portal - personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal - || (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW))); - - if ( ent->e.renderfx & RF_WRAP_FRAMES ) { - ent->e.frame %= tr.currentModel->mdv[0]->numFrames; - ent->e.oldframe %= tr.currentModel->mdv[0]->numFrames; - } - - // - // Validate the frames so there is no chance of a crash. - // This will write directly into the entity structure, so - // when the surfaces are rendered, they don't need to be - // range checked again. - // - if ( (ent->e.frame >= tr.currentModel->mdv[0]->numFrames) - || (ent->e.frame < 0) - || (ent->e.oldframe >= tr.currentModel->mdv[0]->numFrames) - || (ent->e.oldframe < 0) ) { - ri.Printf( PRINT_DEVELOPER, "R_AddMD3Surfaces: no such frame %d to %d for '%s'\n", - ent->e.oldframe, ent->e.frame, - tr.currentModel->name ); - ent->e.frame = 0; - ent->e.oldframe = 0; - } - - // - // compute LOD - // - lod = R_ComputeLOD( ent ); - - model = tr.currentModel->mdv[lod]; - - // - // cull the entire model if merged bounding box of both frames - // is outside the view frustum. - // - cull = R_CullModel ( model, ent ); - if ( cull == CULL_OUT ) { - return; - } - - // - // set up lighting now that we know we aren't culled - // - if ( !personalModel || r_shadows->integer > 1 ) { - R_SetupEntityLighting( &tr.refdef, ent ); - } - - // - // see if we are in a fog volume - // - fogNum = R_ComputeFogNum( model, ent ); - - cubemapIndex = R_CubemapForPoint(ent->e.origin); - - // - // draw all surfaces - // - surface = model->surfaces; - for ( i = 0 ; i < model->numSurfaces ; i++ ) { - - if ( ent->e.customShader ) { - shader = R_GetShaderByHandle( ent->e.customShader ); - } else if ( ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins ) { - const skin_t *skin; - int j; - - skin = R_GetSkinByHandle( ent->e.customSkin ); - - // match the surface name to something in the skin file - shader = tr.defaultShader; - for ( j = 0 ; j < skin->numSurfaces ; j++ ) { - // the names have both been lowercased - if ( !strcmp( skin->surfaces[j].name, surface->name ) ) { - shader = skin->surfaces[j].shader; - break; - } - } - if (shader == tr.defaultShader) { - ri.Printf( PRINT_DEVELOPER, "WARNING: no shader for surface %s in skin %s\n", surface->name, skin->name); - } - else if (shader->defaultShader) { - ri.Printf( PRINT_DEVELOPER, "WARNING: shader %s in skin %s not found\n", shader->name, skin->name); - } - } else if ( surface->numShaderIndexes <= 0 ) { - shader = tr.defaultShader; - } else { - shader = tr.shaders[ surface->shaderIndexes[ ent->e.skinNum % surface->numShaderIndexes ] ]; - } - - // we will add shadows even if the main object isn't visible in the view - - // stencil shadows can't do personal models unless I polyhedron clip - if ( !personalModel - && r_shadows->integer == 2 - && fogNum == 0 - && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) - && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (void *)&model->vaoSurfaces[i], tr.shadowShader, 0, qfalse, qfalse, 0 ); - } - - // projection shadows work fine with personal models - if ( r_shadows->integer == 3 - && fogNum == 0 - && (ent->e.renderfx & RF_SHADOW_PLANE ) - && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (void *)&model->vaoSurfaces[i], tr.projectionShadowShader, 0, qfalse, qfalse, 0 ); - } - - // don't add third_person objects if not viewing through a portal - if ( !personalModel ) { - R_AddDrawSurf((void *)&model->vaoSurfaces[i], shader, fogNum, qfalse, qfalse, cubemapIndex ); - } - - surface++; - } - -} - - - - - diff --git a/code/renderer2/tr_model.c b/code/renderer2/tr_model.c deleted file mode 100644 index db0f0f22fb..0000000000 --- a/code/renderer2/tr_model.c +++ /dev/null @@ -1,1418 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_models.c -- model loading and caching - -#include "tr_local.h" - -#define LL(x) x=LittleLong(x) - -static qboolean R_LoadMD3(model_t *mod, int lod, void *buffer, int bufferSize, const char *modName); -static qboolean R_LoadMDR(model_t *mod, void *buffer, int filesize, const char *name ); - -/* -==================== -R_RegisterMD3 -==================== -*/ -static qhandle_t R_RegisterMD3(const char *name, model_t *mod) -{ - union { - unsigned *u; - void *v; - } buf; - int size; - int lod; - int ident; - qboolean loaded = qfalse; - int numLoaded; - char filename[MAX_QPATH], namebuf[MAX_QPATH+20]; - char *fext, defex[] = "md3"; - - numLoaded = 0; - - strcpy(filename, name); - - fext = strchr(filename, '.'); - if(!fext) - fext = defex; - else - { - *fext = '\0'; - fext++; - } - - for (lod = MD3_MAX_LODS - 1 ; lod >= 0 ; lod--) - { - if(lod) - Com_sprintf(namebuf, sizeof(namebuf), "%s_%d.%s", filename, lod, fext); - else - Com_sprintf(namebuf, sizeof(namebuf), "%s.%s", filename, fext); - - size = ri.FS_ReadFile( namebuf, &buf.v ); - if(!buf.u) - continue; - - ident = LittleLong(* (unsigned *) buf.u); - if (ident == MD3_IDENT) - loaded = R_LoadMD3(mod, lod, buf.u, size, name); - else - ri.Printf(PRINT_WARNING,"R_RegisterMD3: unknown fileid for %s\n", name); - - ri.FS_FreeFile(buf.v); - - if(loaded) - { - mod->numLods++; - numLoaded++; - } - else - break; - } - - if(numLoaded) - { - // duplicate into higher lod spots that weren't - // loaded, in case the user changes r_lodbias on the fly - for(lod--; lod >= 0; lod--) - { - mod->numLods++; - mod->mdv[lod] = mod->mdv[lod + 1]; - } - - return mod->index; - } - -#ifdef _DEBUG - ri.Printf(PRINT_WARNING,"R_RegisterMD3: couldn't load %s\n", name); -#endif - - mod->type = MOD_BAD; - return 0; -} - -/* -==================== -R_RegisterMDR -==================== -*/ -static qhandle_t R_RegisterMDR(const char *name, model_t *mod) -{ - union { - unsigned *u; - void *v; - } buf; - int ident; - qboolean loaded = qfalse; - int filesize; - - filesize = ri.FS_ReadFile(name, (void **) &buf.v); - if(!buf.u) - { - mod->type = MOD_BAD; - return 0; - } - - ident = LittleLong(*(unsigned *)buf.u); - if(ident == MDR_IDENT) - loaded = R_LoadMDR(mod, buf.u, filesize, name); - - ri.FS_FreeFile (buf.v); - - if(!loaded) - { - ri.Printf(PRINT_WARNING,"R_RegisterMDR: couldn't load mdr file %s\n", name); - mod->type = MOD_BAD; - return 0; - } - - return mod->index; -} - -/* -==================== -R_RegisterIQM -==================== -*/ -static qhandle_t R_RegisterIQM(const char *name, model_t *mod) -{ - union { - unsigned *u; - void *v; - } buf; - qboolean loaded = qfalse; - int filesize; - - filesize = ri.FS_ReadFile(name, (void **) &buf.v); - if(!buf.u) - { - mod->type = MOD_BAD; - return 0; - } - - loaded = R_LoadIQM(mod, buf.u, filesize, name); - - ri.FS_FreeFile (buf.v); - - if(!loaded) - { - ri.Printf(PRINT_WARNING,"R_RegisterIQM: couldn't load iqm file %s\n", name); - mod->type = MOD_BAD; - return 0; - } - - return mod->index; -} - - -typedef struct -{ - const char *ext; - qhandle_t (*ModelLoader)( const char *, model_t * ); -} modelExtToLoaderMap_t; - -// Note that the ordering indicates the order of preference used -// when there are multiple models of different formats available -static modelExtToLoaderMap_t modelLoaders[ ] = -{ - { "iqm", R_RegisterIQM }, - { "mdr", R_RegisterMDR }, - { "md3", R_RegisterMD3 } -}; - -static int numModelLoaders = ARRAY_LEN(modelLoaders); - -//=============================================================================== - -/* -** R_GetModelByHandle -*/ -model_t *R_GetModelByHandle( qhandle_t index ) { - model_t *mod; - - // out of range gets the default model - if ( index < 1 || index >= tr.numModels ) { - return tr.models[0]; - } - - mod = tr.models[index]; - - return mod; -} - -//=============================================================================== - -/* -** R_AllocModel -*/ -model_t *R_AllocModel( void ) { - model_t *mod; - - if ( tr.numModels == MAX_MOD_KNOWN ) { - return NULL; - } - - mod = ri.Hunk_Alloc( sizeof( *tr.models[tr.numModels] ), h_low ); - mod->index = tr.numModels; - tr.models[tr.numModels] = mod; - tr.numModels++; - - return mod; -} - -/* -==================== -RE_RegisterModel - -Loads in a model for the given name - -Zero will be returned if the model fails to load. -An entry will be retained for failed models as an -optimization to prevent disk rescanning if they are -asked for again. -==================== -*/ -qhandle_t RE_RegisterModel( const char *name ) { - model_t *mod; - qhandle_t hModel; - qboolean orgNameFailed = qfalse; - int orgLoader = -1; - int i; - char localName[ MAX_QPATH ]; - const char *ext; - char altName[ MAX_QPATH ]; - - if ( !name || !name[0] ) { - ri.Printf( PRINT_ALL, "RE_RegisterModel: NULL name\n" ); - return 0; - } - - if ( strlen( name ) >= MAX_QPATH ) { - ri.Printf( PRINT_ALL, "Model name exceeds MAX_QPATH\n" ); - return 0; - } - - // - // search the currently loaded models - // - for ( hModel = 1 ; hModel < tr.numModels; hModel++ ) { - mod = tr.models[hModel]; - if ( !strcmp( mod->name, name ) ) { - if( mod->type == MOD_BAD ) { - return 0; - } - return hModel; - } - } - - // allocate a new model_t - - if ( ( mod = R_AllocModel() ) == NULL ) { - ri.Printf( PRINT_WARNING, "RE_RegisterModel: R_AllocModel() failed for '%s'\n", name); - return 0; - } - - // only set the name after the model has been successfully loaded - Q_strncpyz( mod->name, name, sizeof( mod->name ) ); - - - R_IssuePendingRenderCommands(); - - mod->type = MOD_BAD; - mod->numLods = 0; - - // - // load the files - // - Q_strncpyz( localName, name, sizeof( localName ) ); - - ext = COM_GetExtension( localName ); - - if( *ext ) - { - // Look for the correct loader and use it - for( i = 0; i < numModelLoaders; i++ ) - { - if( !Q_stricmp( ext, modelLoaders[ i ].ext ) ) - { - // Load - hModel = modelLoaders[ i ].ModelLoader( localName, mod ); - break; - } - } - - // A loader was found - if( i < numModelLoaders ) - { - if( !hModel ) - { - // Loader failed, most likely because the file isn't there; - // try again without the extension - orgNameFailed = qtrue; - orgLoader = i; - COM_StripExtension( name, localName, MAX_QPATH ); - } - else - { - // Something loaded - return mod->index; - } - } - } - - // Try and find a suitable match using all - // the model formats supported - for( i = 0; i < numModelLoaders; i++ ) - { - if (i == orgLoader) - continue; - - Com_sprintf( altName, sizeof (altName), "%s.%s", localName, modelLoaders[ i ].ext ); - - // Load - hModel = modelLoaders[ i ].ModelLoader( altName, mod ); - - if( hModel ) - { - if( orgNameFailed ) - { - ri.Printf( PRINT_DEVELOPER, "WARNING: %s not present, using %s instead\n", - name, altName ); - } - - break; - } - } - - return hModel; -} - -/* -================= -R_LoadMD3 -================= -*/ -static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, const char *modName) -{ - int f, i, j; - - md3Header_t *md3Model; - md3Frame_t *md3Frame; - md3Surface_t *md3Surf; - md3Shader_t *md3Shader; - md3Triangle_t *md3Tri; - md3St_t *md3st; - md3XyzNormal_t *md3xyz; - md3Tag_t *md3Tag; - - mdvModel_t *mdvModel; - mdvFrame_t *frame; - mdvSurface_t *surf;//, *surface; - int *shaderIndex; - glIndex_t *tri; - mdvVertex_t *v; - mdvSt_t *st; - mdvTag_t *tag; - mdvTagName_t *tagName; - - int version; - int size; - - md3Model = (md3Header_t *) buffer; - - version = LittleLong(md3Model->version); - if(version != MD3_VERSION) - { - ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has wrong version (%i should be %i)\n", modName, version, MD3_VERSION); - return qfalse; - } - - mod->type = MOD_MESH; - size = LittleLong(md3Model->ofsEnd); - mod->dataSize += size; - mdvModel = mod->mdv[lod] = ri.Hunk_Alloc(sizeof(mdvModel_t), h_low); - -// Com_Memcpy(mod->md3[lod], buffer, LittleLong(md3Model->ofsEnd)); - - LL(md3Model->ident); - LL(md3Model->version); - LL(md3Model->numFrames); - LL(md3Model->numTags); - LL(md3Model->numSurfaces); - LL(md3Model->ofsFrames); - LL(md3Model->ofsTags); - LL(md3Model->ofsSurfaces); - LL(md3Model->ofsEnd); - - if(md3Model->numFrames < 1) - { - ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has no frames\n", modName); - return qfalse; - } - - // swap all the frames - mdvModel->numFrames = md3Model->numFrames; - mdvModel->frames = frame = ri.Hunk_Alloc(sizeof(*frame) * md3Model->numFrames, h_low); - - md3Frame = (md3Frame_t *) ((byte *) md3Model + md3Model->ofsFrames); - for(i = 0; i < md3Model->numFrames; i++, frame++, md3Frame++) - { - frame->radius = LittleFloat(md3Frame->radius); - for(j = 0; j < 3; j++) - { - frame->bounds[0][j] = LittleFloat(md3Frame->bounds[0][j]); - frame->bounds[1][j] = LittleFloat(md3Frame->bounds[1][j]); - frame->localOrigin[j] = LittleFloat(md3Frame->localOrigin[j]); - } - } - - // swap all the tags - mdvModel->numTags = md3Model->numTags; - mdvModel->tags = tag = ri.Hunk_Alloc(sizeof(*tag) * (md3Model->numTags * md3Model->numFrames), h_low); - - md3Tag = (md3Tag_t *) ((byte *) md3Model + md3Model->ofsTags); - for(i = 0; i < md3Model->numTags * md3Model->numFrames; i++, tag++, md3Tag++) - { - for(j = 0; j < 3; j++) - { - tag->origin[j] = LittleFloat(md3Tag->origin[j]); - tag->axis[0][j] = LittleFloat(md3Tag->axis[0][j]); - tag->axis[1][j] = LittleFloat(md3Tag->axis[1][j]); - tag->axis[2][j] = LittleFloat(md3Tag->axis[2][j]); - } - } - - - mdvModel->tagNames = tagName = ri.Hunk_Alloc(sizeof(*tagName) * (md3Model->numTags), h_low); - - md3Tag = (md3Tag_t *) ((byte *) md3Model + md3Model->ofsTags); - for(i = 0; i < md3Model->numTags; i++, tagName++, md3Tag++) - { - Q_strncpyz(tagName->name, md3Tag->name, sizeof(tagName->name)); - } - - // swap all the surfaces - mdvModel->numSurfaces = md3Model->numSurfaces; - mdvModel->surfaces = surf = ri.Hunk_Alloc(sizeof(*surf) * md3Model->numSurfaces, h_low); - - md3Surf = (md3Surface_t *) ((byte *) md3Model + md3Model->ofsSurfaces); - for(i = 0; i < md3Model->numSurfaces; i++) - { - LL(md3Surf->ident); - LL(md3Surf->flags); - LL(md3Surf->numFrames); - LL(md3Surf->numShaders); - LL(md3Surf->numTriangles); - LL(md3Surf->ofsTriangles); - LL(md3Surf->numVerts); - LL(md3Surf->ofsShaders); - LL(md3Surf->ofsSt); - LL(md3Surf->ofsXyzNormals); - LL(md3Surf->ofsEnd); - - if(md3Surf->numVerts >= SHADER_MAX_VERTEXES) - { - ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i verts on %s (%i).\n", - modName, SHADER_MAX_VERTEXES - 1, md3Surf->name[0] ? md3Surf->name : "a surface", - md3Surf->numVerts ); - return qfalse; - } - if(md3Surf->numTriangles * 3 >= SHADER_MAX_INDEXES) - { - ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i triangles on %s (%i).\n", - modName, ( SHADER_MAX_INDEXES / 3 ) - 1, md3Surf->name[0] ? md3Surf->name : "a surface", - md3Surf->numTriangles ); - return qfalse; - } - - // change to surface identifier - surf->surfaceType = SF_MDV; - - // give pointer to model for Tess_SurfaceMDX - surf->model = mdvModel; - - // copy surface name - Q_strncpyz(surf->name, md3Surf->name, sizeof(surf->name)); - - // lowercase the surface name so skin compares are faster - Q_strlwr(surf->name); - - // strip off a trailing _1 or _2 - // this is a crutch for q3data being a mess - j = strlen(surf->name); - if(j > 2 && surf->name[j - 2] == '_') - { - surf->name[j - 2] = 0; - } - - // register the shaders - surf->numShaderIndexes = md3Surf->numShaders; - surf->shaderIndexes = shaderIndex = ri.Hunk_Alloc(sizeof(*shaderIndex) * md3Surf->numShaders, h_low); - - md3Shader = (md3Shader_t *) ((byte *) md3Surf + md3Surf->ofsShaders); - for(j = 0; j < md3Surf->numShaders; j++, shaderIndex++, md3Shader++) - { - shader_t *sh; - - sh = R_FindShader(md3Shader->name, LIGHTMAP_NONE, qtrue); - if(sh->defaultShader) - { - *shaderIndex = 0; - } - else - { - *shaderIndex = sh->index; - } - } - - // swap all the triangles - surf->numIndexes = md3Surf->numTriangles * 3; - surf->indexes = tri = ri.Hunk_Alloc(sizeof(*tri) * 3 * md3Surf->numTriangles, h_low); - - md3Tri = (md3Triangle_t *) ((byte *) md3Surf + md3Surf->ofsTriangles); - for(j = 0; j < md3Surf->numTriangles; j++, tri += 3, md3Tri++) - { - tri[0] = LittleLong(md3Tri->indexes[0]); - tri[1] = LittleLong(md3Tri->indexes[1]); - tri[2] = LittleLong(md3Tri->indexes[2]); - } - - // swap all the XyzNormals - surf->numVerts = md3Surf->numVerts; - surf->verts = v = ri.Hunk_Alloc(sizeof(*v) * (md3Surf->numVerts * md3Surf->numFrames), h_low); - - md3xyz = (md3XyzNormal_t *) ((byte *) md3Surf + md3Surf->ofsXyzNormals); - for(j = 0; j < md3Surf->numVerts * md3Surf->numFrames; j++, md3xyz++, v++) - { - unsigned lat, lng; - unsigned short normal; - vec3_t fNormal; - - v->xyz[0] = LittleShort(md3xyz->xyz[0]) * MD3_XYZ_SCALE; - v->xyz[1] = LittleShort(md3xyz->xyz[1]) * MD3_XYZ_SCALE; - v->xyz[2] = LittleShort(md3xyz->xyz[2]) * MD3_XYZ_SCALE; - - normal = LittleShort(md3xyz->normal); - - lat = ( normal >> 8 ) & 0xff; - lng = ( normal & 0xff ); - lat *= (FUNCTABLE_SIZE/256); - lng *= (FUNCTABLE_SIZE/256); - - // decode X as cos( lat ) * sin( long ) - // decode Y as sin( lat ) * sin( long ) - // decode Z as cos( long ) - - fNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng]; - fNormal[1] = tr.sinTable[lat] * tr.sinTable[lng]; - fNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK]; - - R_VaoPackNormal(v->normal, fNormal); - } - - // swap all the ST - surf->st = st = ri.Hunk_Alloc(sizeof(*st) * md3Surf->numVerts, h_low); - - md3st = (md3St_t *) ((byte *) md3Surf + md3Surf->ofsSt); - for(j = 0; j < md3Surf->numVerts; j++, md3st++, st++) - { - st->st[0] = LittleFloat(md3st->st[0]); - st->st[1] = LittleFloat(md3st->st[1]); - } - - // calc tangent spaces - { - vec3_t *sdirs = ri.Malloc(sizeof(*sdirs) * surf->numVerts * mdvModel->numFrames); - vec3_t *tdirs = ri.Malloc(sizeof(*tdirs) * surf->numVerts * mdvModel->numFrames); - - for(j = 0, v = surf->verts; j < (surf->numVerts * mdvModel->numFrames); j++, v++) - { - VectorClear(sdirs[j]); - VectorClear(tdirs[j]); - } - - for(f = 0; f < mdvModel->numFrames; f++) - { - for(j = 0, tri = surf->indexes; j < surf->numIndexes; j += 3, tri += 3) - { - vec3_t sdir, tdir; - const float *v0, *v1, *v2, *t0, *t1, *t2; - glIndex_t index0, index1, index2; - - index0 = surf->numVerts * f + tri[0]; - index1 = surf->numVerts * f + tri[1]; - index2 = surf->numVerts * f + tri[2]; - - v0 = surf->verts[index0].xyz; - v1 = surf->verts[index1].xyz; - v2 = surf->verts[index2].xyz; - - t0 = surf->st[tri[0]].st; - t1 = surf->st[tri[1]].st; - t2 = surf->st[tri[2]].st; - - R_CalcTexDirs(sdir, tdir, v0, v1, v2, t0, t1, t2); - - VectorAdd(sdir, sdirs[index0], sdirs[index0]); - VectorAdd(sdir, sdirs[index1], sdirs[index1]); - VectorAdd(sdir, sdirs[index2], sdirs[index2]); - VectorAdd(tdir, tdirs[index0], tdirs[index0]); - VectorAdd(tdir, tdirs[index1], tdirs[index1]); - VectorAdd(tdir, tdirs[index2], tdirs[index2]); - } - } - - for(j = 0, v = surf->verts; j < (surf->numVerts * mdvModel->numFrames); j++, v++) - { - vec3_t normal; - vec4_t tangent; - - VectorNormalize(sdirs[j]); - VectorNormalize(tdirs[j]); - - R_VaoUnpackNormal(normal, v->normal); - - tangent[3] = R_CalcTangentSpace(tangent, NULL, normal, sdirs[j], tdirs[j]); - - R_VaoPackTangent(v->tangent, tangent); - } - - ri.Free(sdirs); - ri.Free(tdirs); - } - - // find the next surface - md3Surf = (md3Surface_t *) ((byte *) md3Surf + md3Surf->ofsEnd); - surf++; - } - - { - srfVaoMdvMesh_t *vaoSurf; - - mdvModel->numVaoSurfaces = mdvModel->numSurfaces; - mdvModel->vaoSurfaces = ri.Hunk_Alloc(sizeof(*mdvModel->vaoSurfaces) * mdvModel->numSurfaces, h_low); - - vaoSurf = mdvModel->vaoSurfaces; - surf = mdvModel->surfaces; - for (i = 0; i < mdvModel->numSurfaces; i++, vaoSurf++, surf++) - { - uint32_t offset_xyz, offset_st, offset_normal, offset_tangent; - uint32_t stride_xyz, stride_st, stride_normal, stride_tangent; - uint32_t dataSize, dataOfs; - uint8_t *data; - - if (mdvModel->numFrames > 1) - { - // vertex animation, store texcoords first, then position/normal/tangents - offset_st = 0; - offset_xyz = surf->numVerts * sizeof(vec2_t); - offset_normal = offset_xyz + sizeof(vec3_t); - offset_tangent = offset_normal + sizeof(int16_t) * 4; - stride_st = sizeof(vec2_t); - stride_xyz = sizeof(vec3_t) + sizeof(int16_t) * 4; - stride_xyz += sizeof(int16_t) * 4; - stride_normal = stride_tangent = stride_xyz; - - dataSize = offset_xyz + surf->numVerts * mdvModel->numFrames * stride_xyz; - } - else - { - // no animation, interleave everything - offset_xyz = 0; - offset_st = offset_xyz + sizeof(vec3_t); - offset_normal = offset_st + sizeof(vec2_t); - offset_tangent = offset_normal + sizeof(int16_t) * 4; - stride_xyz = offset_tangent + sizeof(int16_t) * 4; - stride_st = stride_normal = stride_tangent = stride_xyz; - - dataSize = surf->numVerts * stride_xyz; - } - - - data = ri.Malloc(dataSize); - dataOfs = 0; - - if (mdvModel->numFrames > 1) - { - st = surf->st; - for ( j = 0 ; j < surf->numVerts ; j++, st++ ) { - memcpy(data + dataOfs, &st->st, sizeof(vec2_t)); - dataOfs += sizeof(st->st); - } - - v = surf->verts; - for ( j = 0; j < surf->numVerts * mdvModel->numFrames ; j++, v++ ) - { - // xyz - memcpy(data + dataOfs, &v->xyz, sizeof(vec3_t)); - dataOfs += sizeof(vec3_t); - - // normal - memcpy(data + dataOfs, &v->normal, sizeof(int16_t) * 4); - dataOfs += sizeof(int16_t) * 4; - - // tangent - memcpy(data + dataOfs, &v->tangent, sizeof(int16_t) * 4); - dataOfs += sizeof(int16_t) * 4; - } - } - else - { - v = surf->verts; - st = surf->st; - for ( j = 0; j < surf->numVerts; j++, v++, st++ ) - { - // xyz - memcpy(data + dataOfs, &v->xyz, sizeof(vec3_t)); - dataOfs += sizeof(v->xyz); - - // st - memcpy(data + dataOfs, &st->st, sizeof(vec2_t)); - dataOfs += sizeof(st->st); - - // normal - memcpy(data + dataOfs, &v->normal, sizeof(int16_t) * 4); - dataOfs += sizeof(int16_t) * 4; - - // tangent - memcpy(data + dataOfs, &v->tangent, sizeof(int16_t) * 4); - dataOfs += sizeof(int16_t) * 4; - } - } - - vaoSurf->surfaceType = SF_VAO_MDVMESH; - vaoSurf->mdvModel = mdvModel; - vaoSurf->mdvSurface = surf; - vaoSurf->numIndexes = surf->numIndexes; - vaoSurf->numVerts = surf->numVerts; - - vaoSurf->vao = R_CreateVao(va("staticMD3Mesh_VAO '%s'", surf->name), data, dataSize, (byte *)surf->indexes, surf->numIndexes * sizeof(*surf->indexes), VAO_USAGE_STATIC); - - vaoSurf->vao->attribs[ATTR_INDEX_POSITION].enabled = 1; - vaoSurf->vao->attribs[ATTR_INDEX_TEXCOORD].enabled = 1; - vaoSurf->vao->attribs[ATTR_INDEX_NORMAL ].enabled = 1; - vaoSurf->vao->attribs[ATTR_INDEX_TANGENT ].enabled = 1; - - vaoSurf->vao->attribs[ATTR_INDEX_POSITION].count = 3; - vaoSurf->vao->attribs[ATTR_INDEX_TEXCOORD].count = 2; - vaoSurf->vao->attribs[ATTR_INDEX_NORMAL ].count = 4; - vaoSurf->vao->attribs[ATTR_INDEX_TANGENT ].count = 4; - - vaoSurf->vao->attribs[ATTR_INDEX_POSITION].type = GL_FLOAT; - vaoSurf->vao->attribs[ATTR_INDEX_TEXCOORD].type = GL_FLOAT; - vaoSurf->vao->attribs[ATTR_INDEX_NORMAL ].type = GL_SHORT; - vaoSurf->vao->attribs[ATTR_INDEX_TANGENT ].type = GL_SHORT; - - vaoSurf->vao->attribs[ATTR_INDEX_POSITION].normalized = GL_FALSE; - vaoSurf->vao->attribs[ATTR_INDEX_TEXCOORD].normalized = GL_FALSE; - vaoSurf->vao->attribs[ATTR_INDEX_NORMAL ].normalized = GL_TRUE; - vaoSurf->vao->attribs[ATTR_INDEX_TANGENT ].normalized = GL_TRUE; - - vaoSurf->vao->attribs[ATTR_INDEX_POSITION].offset = offset_xyz; - vaoSurf->vao->attribs[ATTR_INDEX_TEXCOORD].offset = offset_st; - vaoSurf->vao->attribs[ATTR_INDEX_NORMAL ].offset = offset_normal; - vaoSurf->vao->attribs[ATTR_INDEX_TANGENT ].offset = offset_tangent; - - vaoSurf->vao->attribs[ATTR_INDEX_POSITION].stride = stride_xyz; - vaoSurf->vao->attribs[ATTR_INDEX_TEXCOORD].stride = stride_st; - vaoSurf->vao->attribs[ATTR_INDEX_NORMAL ].stride = stride_normal; - vaoSurf->vao->attribs[ATTR_INDEX_TANGENT ].stride = stride_tangent; - - if (mdvModel->numFrames > 1) - { - vaoSurf->vao->attribs[ATTR_INDEX_POSITION2] = vaoSurf->vao->attribs[ATTR_INDEX_POSITION]; - vaoSurf->vao->attribs[ATTR_INDEX_NORMAL2 ] = vaoSurf->vao->attribs[ATTR_INDEX_NORMAL ]; - vaoSurf->vao->attribs[ATTR_INDEX_TANGENT2 ] = vaoSurf->vao->attribs[ATTR_INDEX_TANGENT ]; - - vaoSurf->vao->frameSize = stride_xyz * surf->numVerts; - } - - Vao_SetVertexPointers(vaoSurf->vao); - - ri.Free(data); - } - } - - return qtrue; -} - - - -/* -================= -R_LoadMDR -================= -*/ -static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char *mod_name ) -{ - int i, j, k, l; - mdrHeader_t *pinmodel, *mdr; - mdrFrame_t *frame; - mdrLOD_t *lod, *curlod; - mdrSurface_t *surf, *cursurf; - mdrTriangle_t *tri, *curtri; - mdrVertex_t *v, *curv; - mdrWeight_t *weight, *curweight; - mdrTag_t *tag, *curtag; - int size; - shader_t *sh; - - pinmodel = (mdrHeader_t *)buffer; - - pinmodel->version = LittleLong(pinmodel->version); - if (pinmodel->version != MDR_VERSION) - { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has wrong version (%i should be %i)\n", mod_name, pinmodel->version, MDR_VERSION); - return qfalse; - } - - size = LittleLong(pinmodel->ofsEnd); - - if(size > filesize) - { - ri.Printf(PRINT_WARNING, "R_LoadMDR: Header of %s is broken. Wrong filesize declared!\n", mod_name); - return qfalse; - } - - mod->type = MOD_MDR; - - LL(pinmodel->numFrames); - LL(pinmodel->numBones); - LL(pinmodel->ofsFrames); - - // This is a model that uses some type of compressed Bones. We don't want to uncompress every bone for each rendered frame - // over and over again, we'll uncompress it in this function already, so we must adjust the size of the target mdr. - if(pinmodel->ofsFrames < 0) - { - // mdrFrame_t is larger than mdrCompFrame_t: - size += pinmodel->numFrames * sizeof(frame->name); - // now add enough space for the uncompressed bones. - size += pinmodel->numFrames * pinmodel->numBones * ((sizeof(mdrBone_t) - sizeof(mdrCompBone_t))); - } - - // simple bounds check - if(pinmodel->numBones < 0 || - sizeof(*mdr) + pinmodel->numFrames * (sizeof(*frame) + (pinmodel->numBones - 1) * sizeof(*frame->bones)) > size) - { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); - return qfalse; - } - - mod->dataSize += size; - mod->modelData = mdr = ri.Hunk_Alloc( size, h_low ); - - // Copy all the values over from the file and fix endian issues in the process, if necessary. - - mdr->ident = LittleLong(pinmodel->ident); - mdr->version = pinmodel->version; // Don't need to swap byte order on this one, we already did above. - Q_strncpyz(mdr->name, pinmodel->name, sizeof(mdr->name)); - mdr->numFrames = pinmodel->numFrames; - mdr->numBones = pinmodel->numBones; - mdr->numLODs = LittleLong(pinmodel->numLODs); - mdr->numTags = LittleLong(pinmodel->numTags); - // We don't care about the other offset values, we'll generate them ourselves while loading. - - mod->numLods = mdr->numLODs; - - if ( mdr->numFrames < 1 ) - { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has no frames\n", mod_name); - return qfalse; - } - - /* The first frame will be put into the first free space after the header */ - frame = (mdrFrame_t *)(mdr + 1); - mdr->ofsFrames = (int)((byte *) frame - (byte *) mdr); - - if (pinmodel->ofsFrames < 0) - { - mdrCompFrame_t *cframe; - - // compressed model... - cframe = (mdrCompFrame_t *)((byte *) pinmodel - pinmodel->ofsFrames); - - for(i = 0; i < mdr->numFrames; i++) - { - for(j = 0; j < 3; j++) - { - frame->bounds[0][j] = LittleFloat(cframe->bounds[0][j]); - frame->bounds[1][j] = LittleFloat(cframe->bounds[1][j]); - frame->localOrigin[j] = LittleFloat(cframe->localOrigin[j]); - } - - frame->radius = LittleFloat(cframe->radius); - frame->name[0] = '\0'; // No name supplied in the compressed version. - - for(j = 0; j < mdr->numBones; j++) - { - for(k = 0; k < (sizeof(cframe->bones[j].Comp) / 2); k++) - { - // Do swapping for the uncompressing functions. They seem to use shorts - // values only, so I assume this will work. Never tested it on other - // platforms, though. - - ((unsigned short *)(cframe->bones[j].Comp))[k] = - LittleShort( ((unsigned short *)(cframe->bones[j].Comp))[k] ); - } - - /* Now do the actual uncompressing */ - MC_UnCompress(frame->bones[j].matrix, cframe->bones[j].Comp); - } - - // Next Frame... - cframe = (mdrCompFrame_t *) &cframe->bones[j]; - frame = (mdrFrame_t *) &frame->bones[j]; - } - } - else - { - mdrFrame_t *curframe; - - // uncompressed model... - // - - curframe = (mdrFrame_t *)((byte *) pinmodel + pinmodel->ofsFrames); - - // swap all the frames - for ( i = 0 ; i < mdr->numFrames ; i++) - { - for(j = 0; j < 3; j++) - { - frame->bounds[0][j] = LittleFloat(curframe->bounds[0][j]); - frame->bounds[1][j] = LittleFloat(curframe->bounds[1][j]); - frame->localOrigin[j] = LittleFloat(curframe->localOrigin[j]); - } - - frame->radius = LittleFloat(curframe->radius); - Q_strncpyz(frame->name, curframe->name, sizeof(frame->name)); - - for (j = 0; j < (int) (mdr->numBones * sizeof(mdrBone_t) / 4); j++) - { - ((float *)frame->bones)[j] = LittleFloat( ((float *)curframe->bones)[j] ); - } - - curframe = (mdrFrame_t *) &curframe->bones[mdr->numBones]; - frame = (mdrFrame_t *) &frame->bones[mdr->numBones]; - } - } - - // frame should now point to the first free address after all frames. - lod = (mdrLOD_t *) frame; - mdr->ofsLODs = (int) ((byte *) lod - (byte *)mdr); - - curlod = (mdrLOD_t *)((byte *) pinmodel + LittleLong(pinmodel->ofsLODs)); - - // swap all the LOD's - for ( l = 0 ; l < mdr->numLODs ; l++) - { - // simple bounds check - if((byte *) (lod + 1) > (byte *) mdr + size) - { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); - return qfalse; - } - - lod->numSurfaces = LittleLong(curlod->numSurfaces); - - // swap all the surfaces - surf = (mdrSurface_t *) (lod + 1); - lod->ofsSurfaces = (int)((byte *) surf - (byte *) lod); - cursurf = (mdrSurface_t *) ((byte *)curlod + LittleLong(curlod->ofsSurfaces)); - - for ( i = 0 ; i < lod->numSurfaces ; i++) - { - // simple bounds check - if((byte *) (surf + 1) > (byte *) mdr + size) - { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); - return qfalse; - } - - // first do some copying stuff - - surf->ident = SF_MDR; - Q_strncpyz(surf->name, cursurf->name, sizeof(surf->name)); - Q_strncpyz(surf->shader, cursurf->shader, sizeof(surf->shader)); - - surf->ofsHeader = (byte *) mdr - (byte *) surf; - - surf->numVerts = LittleLong(cursurf->numVerts); - surf->numTriangles = LittleLong(cursurf->numTriangles); - // numBoneReferences and BoneReferences generally seem to be unused - - // now do the checks that may fail. - if ( surf->numVerts >= SHADER_MAX_VERTEXES ) - { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i verts on %s (%i).\n", - mod_name, SHADER_MAX_VERTEXES - 1, surf->name[0] ? surf->name : "a surface", - surf->numVerts ); - return qfalse; - } - if ( surf->numTriangles*3 >= SHADER_MAX_INDEXES ) - { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i triangles on %s (%i).\n", - mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, surf->name[0] ? surf->name : "a surface", - surf->numTriangles ); - return qfalse; - } - // lowercase the surface name so skin compares are faster - Q_strlwr( surf->name ); - - // register the shaders - sh = R_FindShader(surf->shader, LIGHTMAP_NONE, qtrue); - if ( sh->defaultShader ) { - surf->shaderIndex = 0; - } else { - surf->shaderIndex = sh->index; - } - - // now copy the vertexes. - v = (mdrVertex_t *) (surf + 1); - surf->ofsVerts = (int)((byte *) v - (byte *) surf); - curv = (mdrVertex_t *) ((byte *)cursurf + LittleLong(cursurf->ofsVerts)); - - for(j = 0; j < surf->numVerts; j++) - { - LL(curv->numWeights); - - // simple bounds check - if(curv->numWeights < 0 || (byte *) (v + 1) + (curv->numWeights - 1) * sizeof(*weight) > (byte *) mdr + size) - { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); - return qfalse; - } - - v->normal[0] = LittleFloat(curv->normal[0]); - v->normal[1] = LittleFloat(curv->normal[1]); - v->normal[2] = LittleFloat(curv->normal[2]); - - v->texCoords[0] = LittleFloat(curv->texCoords[0]); - v->texCoords[1] = LittleFloat(curv->texCoords[1]); - - v->numWeights = curv->numWeights; - weight = &v->weights[0]; - curweight = &curv->weights[0]; - - // Now copy all the weights - for(k = 0; k < v->numWeights; k++) - { - weight->boneIndex = LittleLong(curweight->boneIndex); - weight->boneWeight = LittleFloat(curweight->boneWeight); - - weight->offset[0] = LittleFloat(curweight->offset[0]); - weight->offset[1] = LittleFloat(curweight->offset[1]); - weight->offset[2] = LittleFloat(curweight->offset[2]); - - weight++; - curweight++; - } - - v = (mdrVertex_t *) weight; - curv = (mdrVertex_t *) curweight; - } - - // we know the offset to the triangles now: - tri = (mdrTriangle_t *) v; - surf->ofsTriangles = (int)((byte *) tri - (byte *) surf); - curtri = (mdrTriangle_t *)((byte *) cursurf + LittleLong(cursurf->ofsTriangles)); - - // simple bounds check - if(surf->numTriangles < 0 || (byte *) (tri + surf->numTriangles) > (byte *) mdr + size) - { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); - return qfalse; - } - - for(j = 0; j < surf->numTriangles; j++) - { - tri->indexes[0] = LittleLong(curtri->indexes[0]); - tri->indexes[1] = LittleLong(curtri->indexes[1]); - tri->indexes[2] = LittleLong(curtri->indexes[2]); - - tri++; - curtri++; - } - - // tri now points to the end of the surface. - surf->ofsEnd = (byte *) tri - (byte *) surf; - surf = (mdrSurface_t *) tri; - - // find the next surface. - cursurf = (mdrSurface_t *) ((byte *) cursurf + LittleLong(cursurf->ofsEnd)); - } - - // surf points to the next lod now. - lod->ofsEnd = (int)((byte *) surf - (byte *) lod); - lod = (mdrLOD_t *) surf; - - // find the next LOD. - curlod = (mdrLOD_t *)((byte *) curlod + LittleLong(curlod->ofsEnd)); - } - - // lod points to the first tag now, so update the offset too. - tag = (mdrTag_t *) lod; - mdr->ofsTags = (int)((byte *) tag - (byte *) mdr); - curtag = (mdrTag_t *) ((byte *)pinmodel + LittleLong(pinmodel->ofsTags)); - - // simple bounds check - if(mdr->numTags < 0 || (byte *) (tag + mdr->numTags) > (byte *) mdr + size) - { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); - return qfalse; - } - - for (i = 0 ; i < mdr->numTags ; i++) - { - tag->boneIndex = LittleLong(curtag->boneIndex); - Q_strncpyz(tag->name, curtag->name, sizeof(tag->name)); - - tag++; - curtag++; - } - - // And finally we know the real offset to the end. - mdr->ofsEnd = (int)((byte *) tag - (byte *) mdr); - - // phew! we're done. - - return qtrue; -} - - - -//============================================================================= - -/* -** RE_BeginRegistration -*/ -void RE_BeginRegistration( glconfig_t *glconfigOut ) { - int i; - - R_Init(); - - *glconfigOut = glConfig; - - R_IssuePendingRenderCommands(); - - tr.visIndex = 0; - // force markleafs to regenerate - for(i = 0; i < MAX_VISCOUNTS; i++) { - tr.visClusters[i] = -2; - } - - R_ClearFlares(); - RE_ClearScene(); - - tr.registered = qtrue; -} - -//============================================================================= - -/* -=============== -R_ModelInit -=============== -*/ -void R_ModelInit( void ) { - model_t *mod; - - // leave a space for NULL model - tr.numModels = 0; - - mod = R_AllocModel(); - mod->type = MOD_BAD; -} - - -/* -================ -R_Modellist_f -================ -*/ -void R_Modellist_f( void ) { - int i, j; - model_t *mod; - int total; - int lods; - - total = 0; - for ( i = 1 ; i < tr.numModels; i++ ) { - mod = tr.models[i]; - lods = 1; - for ( j = 1 ; j < MD3_MAX_LODS ; j++ ) { - if ( mod->mdv[j] && mod->mdv[j] != mod->mdv[j-1] ) { - lods++; - } - } - ri.Printf( PRINT_ALL, "%8i : (%i) %s\n",mod->dataSize, lods, mod->name ); - total += mod->dataSize; - } - ri.Printf( PRINT_ALL, "%8i : Total models\n", total ); - -#if 0 // not working right with new hunk - if ( tr.world ) { - ri.Printf( PRINT_ALL, "\n%8i : %s\n", tr.world->dataSize, tr.world->name ); - } -#endif -} - - -//============================================================================= - - -/* -================ -R_GetTag -================ -*/ -static mdvTag_t *R_GetTag( mdvModel_t *mod, int frame, const char *_tagName ) { - int i; - mdvTag_t *tag; - mdvTagName_t *tagName; - - if ( frame >= mod->numFrames ) { - // it is possible to have a bad frame while changing models, so don't error - frame = mod->numFrames - 1; - } - - tag = mod->tags + frame * mod->numTags; - tagName = mod->tagNames; - for(i = 0; i < mod->numTags; i++, tag++, tagName++) - { - if(!strcmp(tagName->name, _tagName)) - { - return tag; - } - } - - return NULL; -} - -static mdvTag_t *R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, mdvTag_t * dest) -{ - int i, j, k; - int frameSize; - mdrFrame_t *frame; - mdrTag_t *tag; - - if ( framenum >= mod->numFrames ) - { - // it is possible to have a bad frame while changing models, so don't error - framenum = mod->numFrames - 1; - } - - tag = (mdrTag_t *)((byte *)mod + mod->ofsTags); - for ( i = 0 ; i < mod->numTags ; i++, tag++ ) - { - if ( !strcmp( tag->name, tagName ) ) - { - // uncompressed model... - // - frameSize = (intptr_t)( &((mdrFrame_t *)0)->bones[ mod->numBones ] ); - frame = (mdrFrame_t *)((byte *)mod + mod->ofsFrames + framenum * frameSize ); - - for (j = 0; j < 3; j++) - { - for (k = 0; k < 3; k++) - dest->axis[j][k]=frame->bones[tag->boneIndex].matrix[k][j]; - } - - dest->origin[0]=frame->bones[tag->boneIndex].matrix[0][3]; - dest->origin[1]=frame->bones[tag->boneIndex].matrix[1][3]; - dest->origin[2]=frame->bones[tag->boneIndex].matrix[2][3]; - - return dest; - } - } - - return NULL; -} - -/* -================ -R_LerpTag -================ -*/ -int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFrame, - float frac, const char *tagName ) { - mdvTag_t *start, *end; - mdvTag_t start_space, end_space; - int i; - float frontLerp, backLerp; - const model_t *model; - - model = R_GetModelByHandle( handle ); - if ( !model->mdv[0] ) - { - if(model->type == MOD_MDR) - { - start = R_GetAnimTag((mdrHeader_t *) model->modelData, startFrame, tagName, &start_space); - end = R_GetAnimTag((mdrHeader_t *) model->modelData, endFrame, tagName, &end_space); - } - else if( model->type == MOD_IQM ) { - return R_IQMLerpTag( tag, model->modelData, - startFrame, endFrame, - frac, tagName ); - } else { - start = end = NULL; - } - } - else - { - start = R_GetTag( model->mdv[0], startFrame, tagName ); - end = R_GetTag( model->mdv[0], endFrame, tagName ); - } - - if ( !start || !end ) { - AxisClear( tag->axis ); - VectorClear( tag->origin ); - return qfalse; - } - - frontLerp = frac; - backLerp = 1.0f - frac; - - for ( i = 0 ; i < 3 ; i++ ) { - tag->origin[i] = start->origin[i] * backLerp + end->origin[i] * frontLerp; - tag->axis[0][i] = start->axis[0][i] * backLerp + end->axis[0][i] * frontLerp; - tag->axis[1][i] = start->axis[1][i] * backLerp + end->axis[1][i] * frontLerp; - tag->axis[2][i] = start->axis[2][i] * backLerp + end->axis[2][i] * frontLerp; - } - VectorNormalize( tag->axis[0] ); - VectorNormalize( tag->axis[1] ); - VectorNormalize( tag->axis[2] ); - return qtrue; -} - - -/* -==================== -R_ModelBounds -==================== -*/ -void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ) { - const model_t *model; - - model = R_GetModelByHandle( handle ); - - if(model->type == MOD_BRUSH) { - VectorCopy( model->bmodel->bounds[0], mins ); - VectorCopy( model->bmodel->bounds[1], maxs ); - - return; - } else if (model->type == MOD_MESH) { - mdvModel_t *header; - mdvFrame_t *frame; - - header = model->mdv[0]; - frame = header->frames; - - VectorCopy( frame->bounds[0], mins ); - VectorCopy( frame->bounds[1], maxs ); - - return; - } else if (model->type == MOD_MDR) { - mdrHeader_t *header; - mdrFrame_t *frame; - - header = (mdrHeader_t *)model->modelData; - frame = (mdrFrame_t *) ((byte *)header + header->ofsFrames); - - VectorCopy( frame->bounds[0], mins ); - VectorCopy( frame->bounds[1], maxs ); - - return; - } else if(model->type == MOD_IQM) { - iqmData_t *iqmData; - - iqmData = model->modelData; - - if(iqmData->bounds) - { - VectorCopy(iqmData->bounds, mins); - VectorCopy(iqmData->bounds + 3, maxs); - return; - } - } - - VectorClear( mins ); - VectorClear( maxs ); -} diff --git a/code/renderer2/tr_model_iqm.c b/code/renderer2/tr_model_iqm.c deleted file mode 100644 index 4f27e9eb1c..0000000000 --- a/code/renderer2/tr_model_iqm.c +++ /dev/null @@ -1,1760 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2011 Thilo Schulz -Copyright (C) 2011 Matthias Bentrup -Copyright (C) 2011-2019 Zack Middleton - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ - -#include "tr_local.h" - -#define LL(x) x=LittleLong(x) - -// 3x4 identity matrix -static float identityMatrix[12] = { - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0 -}; - -static qboolean IQM_CheckRange( iqmHeader_t *header, int offset, - int count, int size ) { - // return true if the range specified by offset, count and size - // doesn't fit into the file - return ( count <= 0 || - offset <= 0 || - offset > header->filesize || - offset + count * size < 0 || - offset + count * size > header->filesize ); -} -// "multiply" 3x4 matrices, these are assumed to be the top 3 rows -// of a 4x4 matrix with the last row = (0 0 0 1) -static void Matrix34Multiply( const float *a, const float *b, float *out ) { - out[ 0] = a[0] * b[0] + a[1] * b[4] + a[ 2] * b[ 8]; - out[ 1] = a[0] * b[1] + a[1] * b[5] + a[ 2] * b[ 9]; - out[ 2] = a[0] * b[2] + a[1] * b[6] + a[ 2] * b[10]; - out[ 3] = a[0] * b[3] + a[1] * b[7] + a[ 2] * b[11] + a[ 3]; - out[ 4] = a[4] * b[0] + a[5] * b[4] + a[ 6] * b[ 8]; - out[ 5] = a[4] * b[1] + a[5] * b[5] + a[ 6] * b[ 9]; - out[ 6] = a[4] * b[2] + a[5] * b[6] + a[ 6] * b[10]; - out[ 7] = a[4] * b[3] + a[5] * b[7] + a[ 6] * b[11] + a[ 7]; - out[ 8] = a[8] * b[0] + a[9] * b[4] + a[10] * b[ 8]; - out[ 9] = a[8] * b[1] + a[9] * b[5] + a[10] * b[ 9]; - out[10] = a[8] * b[2] + a[9] * b[6] + a[10] * b[10]; - out[11] = a[8] * b[3] + a[9] * b[7] + a[10] * b[11] + a[11]; -} -static void JointToMatrix( const quat_t rot, const vec3_t scale, const vec3_t trans, - float *mat ) { - float xx = 2.0f * rot[0] * rot[0]; - float yy = 2.0f * rot[1] * rot[1]; - float zz = 2.0f * rot[2] * rot[2]; - float xy = 2.0f * rot[0] * rot[1]; - float xz = 2.0f * rot[0] * rot[2]; - float yz = 2.0f * rot[1] * rot[2]; - float wx = 2.0f * rot[3] * rot[0]; - float wy = 2.0f * rot[3] * rot[1]; - float wz = 2.0f * rot[3] * rot[2]; - - mat[ 0] = scale[0] * (1.0f - (yy + zz)); - mat[ 1] = scale[0] * (xy - wz); - mat[ 2] = scale[0] * (xz + wy); - mat[ 3] = trans[0]; - mat[ 4] = scale[1] * (xy + wz); - mat[ 5] = scale[1] * (1.0f - (xx + zz)); - mat[ 6] = scale[1] * (yz - wx); - mat[ 7] = trans[1]; - mat[ 8] = scale[2] * (xz - wy); - mat[ 9] = scale[2] * (yz + wx); - mat[10] = scale[2] * (1.0f - (xx + yy)); - mat[11] = trans[2]; -} -static void Matrix34Invert( const float *inMat, float *outMat ) { - vec3_t trans; - float invSqrLen, *v; - - outMat[ 0] = inMat[ 0]; outMat[ 1] = inMat[ 4]; outMat[ 2] = inMat[ 8]; - outMat[ 4] = inMat[ 1]; outMat[ 5] = inMat[ 5]; outMat[ 6] = inMat[ 9]; - outMat[ 8] = inMat[ 2]; outMat[ 9] = inMat[ 6]; outMat[10] = inMat[10]; - - v = outMat + 0; invSqrLen = 1.0f / DotProduct(v, v); VectorScale(v, invSqrLen, v); - v = outMat + 4; invSqrLen = 1.0f / DotProduct(v, v); VectorScale(v, invSqrLen, v); - v = outMat + 8; invSqrLen = 1.0f / DotProduct(v, v); VectorScale(v, invSqrLen, v); - - trans[0] = inMat[ 3]; - trans[1] = inMat[ 7]; - trans[2] = inMat[11]; - - outMat[ 3] = -DotProduct(outMat + 0, trans); - outMat[ 7] = -DotProduct(outMat + 4, trans); - outMat[11] = -DotProduct(outMat + 8, trans); -} -static void QuatSlerp(const quat_t from, const quat_t _to, float fraction, quat_t out) { - float angle, cosAngle, sinAngle, backlerp, lerp; - quat_t to; - - // cos() of angle - cosAngle = from[0] * _to[0] + from[1] * _to[1] + from[2] * _to[2] + from[3] * _to[3]; - - // negative handling is needed for taking shortest path (required for model joints) - if ( cosAngle < 0.0f ) { - cosAngle = -cosAngle; - to[0] = - _to[0]; - to[1] = - _to[1]; - to[2] = - _to[2]; - to[3] = - _to[3]; - } else { - QuatCopy( _to, to ); - } - - if ( cosAngle < 0.999999f ) { - // spherical lerp (slerp) - angle = acosf( cosAngle ); - sinAngle = sinf( angle ); - backlerp = sinf( ( 1.0f - fraction ) * angle ) / sinAngle; - lerp = sinf( fraction * angle ) / sinAngle; - } else { - // linear lerp - backlerp = 1.0f - fraction; - lerp = fraction; - } - - out[0] = from[0] * backlerp + to[0] * lerp; - out[1] = from[1] * backlerp + to[1] * lerp; - out[2] = from[2] * backlerp + to[2] * lerp; - out[3] = from[3] * backlerp + to[3] * lerp; -} - - -static vec_t QuatNormalize2( const quat_t v, quat_t out) { - float length; - - length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2] + v[3]*v[3]; - - if (length) { - /* writing it this way allows gcc to recognize that rsqrt can be used with -ffast-math */ - const float ilength = 1.0f / sqrtf( length ); - /* sqrt(length) = length * (1 / sqrt(length)) */ - length *= ilength; - out[0] = v[0]*ilength; - out[1] = v[1]*ilength; - out[2] = v[2]*ilength; - out[3] = v[3]*ilength; - } else { - out[0] = out[1] = out[2] = 0; - out[3] = -1; - } - - return length; -} - -/* -================= -R_LoadIQM - -Load an IQM model and compute the joint matrices for every frame. -================= -*/ -qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_name ) { - iqmHeader_t *header; - iqmVertexArray_t *vertexarray; - iqmTriangle_t *triangle; - iqmMesh_t *mesh; - iqmJoint_t *joint; - iqmPose_t *pose; - iqmBounds_t *bounds; - unsigned short *framedata; - char *str; - int i, j, k; - iqmTransform_t *transform; - float *mat, *matInv; - size_t size, joint_names; - byte *dataPtr; - iqmData_t *iqmData; - srfIQModel_t *surface; - char meshName[MAX_QPATH]; - int vertexArrayFormat[IQM_COLOR+1]; - int allocateInfluences; - byte *blendIndexes; - union { - byte *b; - float *f; - } blendWeights; - - if( filesize < sizeof(iqmHeader_t) ) { - return qfalse; - } - - header = (iqmHeader_t *)buffer; - if( Q_strncmp( header->magic, IQM_MAGIC, sizeof(header->magic) ) ) { - return qfalse; - } - - LL( header->version ); - if( header->version != IQM_VERSION ) { - ri.Printf(PRINT_WARNING, "R_LoadIQM: %s is a unsupported IQM version (%d), only version %d is supported.\n", - mod_name, header->version, IQM_VERSION); - return qfalse; - } - - LL( header->filesize ); - if( header->filesize > filesize || header->filesize > 16<<20 ) { - return qfalse; - } - - LL( header->flags ); - LL( header->num_text ); - LL( header->ofs_text ); - LL( header->num_meshes ); - LL( header->ofs_meshes ); - LL( header->num_vertexarrays ); - LL( header->num_vertexes ); - LL( header->ofs_vertexarrays ); - LL( header->num_triangles ); - LL( header->ofs_triangles ); - LL( header->ofs_adjacency ); - LL( header->num_joints ); - LL( header->ofs_joints ); - LL( header->num_poses ); - LL( header->ofs_poses ); - LL( header->num_anims ); - LL( header->ofs_anims ); - LL( header->num_frames ); - LL( header->num_framechannels ); - LL( header->ofs_frames ); - LL( header->ofs_bounds ); - LL( header->num_comment ); - LL( header->ofs_comment ); - LL( header->num_extensions ); - LL( header->ofs_extensions ); - - // check ioq3 joint limit - if ( header->num_joints > IQM_MAX_JOINTS ) { - ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %d joints (%d).\n", - mod_name, IQM_MAX_JOINTS, header->num_joints); - return qfalse; - } - - for ( i = 0; i < ARRAY_LEN( vertexArrayFormat ); i++ ) { - vertexArrayFormat[i] = -1; - } - - blendIndexes = NULL; - blendWeights.b = NULL; - - allocateInfluences = 0; - - if ( header->num_meshes ) - { - // check and swap vertex arrays - if( IQM_CheckRange( header, header->ofs_vertexarrays, - header->num_vertexarrays, - sizeof(iqmVertexArray_t) ) ) { - return qfalse; - } - vertexarray = (iqmVertexArray_t *)((byte *)header + header->ofs_vertexarrays); - for( i = 0; i < header->num_vertexarrays; i++, vertexarray++ ) { - int n, *intPtr; - - if( vertexarray->size <= 0 || vertexarray->size > 4 ) { - return qfalse; - } - - // total number of values - n = header->num_vertexes * vertexarray->size; - - switch( vertexarray->format ) { - case IQM_BYTE: - case IQM_UBYTE: - // 1 byte, no swapping necessary - if( IQM_CheckRange( header, vertexarray->offset, - n, sizeof(byte) ) ) { - return qfalse; - } - break; - case IQM_INT: - case IQM_UINT: - case IQM_FLOAT: - // 4-byte swap - if( IQM_CheckRange( header, vertexarray->offset, - n, sizeof(float) ) ) { - return qfalse; - } - intPtr = (int *)((byte *)header + vertexarray->offset); - for( j = 0; j < n; j++, intPtr++ ) { - LL( *intPtr ); - } - break; - default: - // not supported - return qfalse; - break; - } - - if( vertexarray->type < ARRAY_LEN( vertexArrayFormat ) ) { - vertexArrayFormat[vertexarray->type] = vertexarray->format; - } - - switch( vertexarray->type ) { - case IQM_POSITION: - case IQM_NORMAL: - if( vertexarray->format != IQM_FLOAT || - vertexarray->size != 3 ) { - return qfalse; - } - break; - case IQM_TANGENT: - if( vertexarray->format != IQM_FLOAT || - vertexarray->size != 4 ) { - return qfalse; - } - break; - case IQM_TEXCOORD: - if( vertexarray->format != IQM_FLOAT || - vertexarray->size != 2 ) { - return qfalse; - } - break; - case IQM_BLENDINDEXES: - if( (vertexarray->format != IQM_INT && - vertexarray->format != IQM_UBYTE) || - vertexarray->size != 4 ) { - return qfalse; - } - blendIndexes = (byte*)header + vertexarray->offset; - break; - case IQM_BLENDWEIGHTS: - if( (vertexarray->format != IQM_FLOAT && - vertexarray->format != IQM_UBYTE) || - vertexarray->size != 4 ) { - return qfalse; - } - if( vertexarray->format == IQM_FLOAT ) { - blendWeights.f = (float*)( (byte*)header + vertexarray->offset ); - } else { - blendWeights.b = (byte*)header + vertexarray->offset; - } - break; - case IQM_COLOR: - if( vertexarray->format != IQM_UBYTE || - vertexarray->size != 4 ) { - return qfalse; - } - break; - } - } - - // check for required vertex arrays - if( vertexArrayFormat[IQM_POSITION] == -1 || vertexArrayFormat[IQM_NORMAL] == -1 || vertexArrayFormat[IQM_TEXCOORD] == -1 ) { - ri.Printf( PRINT_WARNING, "R_LoadIQM: %s is missing IQM_POSITION, IQM_NORMAL, and/or IQM_TEXCOORD array.\n", mod_name ); - return qfalse; - } - - if( header->num_joints ) { - if( vertexArrayFormat[IQM_BLENDINDEXES] == -1 || vertexArrayFormat[IQM_BLENDWEIGHTS] == -1 ) { - ri.Printf( PRINT_WARNING, "R_LoadIQM: %s is missing IQM_BLENDINDEXES and/or IQM_BLENDWEIGHTS array.\n", mod_name ); - return qfalse; - } - } else { - // ignore blend arrays if present - vertexArrayFormat[IQM_BLENDINDEXES] = -1; - vertexArrayFormat[IQM_BLENDWEIGHTS] = -1; - } - - // opengl2 renderer requires tangents - if( vertexArrayFormat[IQM_TANGENT] == -1 ) { - ri.Printf( PRINT_WARNING, "R_LoadIQM: %s is missing IQM_TANGENT array.\n", mod_name ); - return qfalse; - } - - // check and swap triangles - if( IQM_CheckRange( header, header->ofs_triangles, - header->num_triangles, sizeof(iqmTriangle_t) ) ) { - return qfalse; - } - triangle = (iqmTriangle_t *)((byte *)header + header->ofs_triangles); - for( i = 0; i < header->num_triangles; i++, triangle++ ) { - LL( triangle->vertex[0] ); - LL( triangle->vertex[1] ); - LL( triangle->vertex[2] ); - - if( triangle->vertex[0] > header->num_vertexes || - triangle->vertex[1] > header->num_vertexes || - triangle->vertex[2] > header->num_vertexes ) { - return qfalse; - } - } - - // check and swap meshes - if( IQM_CheckRange( header, header->ofs_meshes, - header->num_meshes, sizeof(iqmMesh_t) ) ) { - return qfalse; - } - mesh = (iqmMesh_t *)((byte *)header + header->ofs_meshes); - for( i = 0; i < header->num_meshes; i++, mesh++) { - LL( mesh->name ); - LL( mesh->material ); - LL( mesh->first_vertex ); - LL( mesh->num_vertexes ); - LL( mesh->first_triangle ); - LL( mesh->num_triangles ); - - if ( mesh->name < header->num_text ) { - Q_strncpyz( meshName, (char*)header + header->ofs_text + mesh->name, sizeof (meshName) ); - } else { - meshName[0] = '\0'; - } - - // check ioq3 limits - if ( mesh->num_vertexes >= SHADER_MAX_VERTEXES ) { - ri.Printf( PRINT_WARNING, "R_LoadIQM: %s has more than %i verts on %s (%i).\n", - mod_name, SHADER_MAX_VERTEXES - 1, meshName[0] ? meshName : "a surface", - mesh->num_vertexes ); - return qfalse; - } - if ( mesh->num_triangles*3 >= SHADER_MAX_INDEXES ) { - ri.Printf( PRINT_WARNING, "R_LoadIQM: %s has more than %i triangles on %s (%i).\n", - mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, meshName[0] ? meshName : "a surface", - mesh->num_triangles ); - return qfalse; - } - - if( mesh->first_vertex >= header->num_vertexes || - mesh->first_vertex + mesh->num_vertexes > header->num_vertexes || - mesh->first_triangle >= header->num_triangles || - mesh->first_triangle + mesh->num_triangles > header->num_triangles || - mesh->name >= header->num_text || - mesh->material >= header->num_text ) { - return qfalse; - } - - // find number of unique blend influences per mesh - if( header->num_joints ) { - for( j = 0; j < mesh->num_vertexes; j++ ) { - int vtx = mesh->first_vertex + j; - - for( k = 0; k < j; k++ ) { - int influence = mesh->first_vertex + k; - - if( *(int*)&blendIndexes[4*influence] != *(int*)&blendIndexes[4*vtx] ) { - continue; - } - - if( vertexArrayFormat[IQM_BLENDWEIGHTS] == IQM_FLOAT ) { - if ( blendWeights.f[4*influence+0] == blendWeights.f[4*vtx+0] && - blendWeights.f[4*influence+1] == blendWeights.f[4*vtx+1] && - blendWeights.f[4*influence+2] == blendWeights.f[4*vtx+2] && - blendWeights.f[4*influence+3] == blendWeights.f[4*vtx+3] ) { - break; - } - } else { - if ( *(int*)&blendWeights.b[4*influence] == *(int*)&blendWeights.b[4*vtx] ) { - break; - } - } - } - - if ( k == j ) { - allocateInfluences++; - } - } - } - } - } - - if( header->num_poses != header->num_joints && header->num_poses != 0 ) { - ri.Printf( PRINT_WARNING, "R_LoadIQM: %s has %d poses and %d joints, must have the same number or 0 poses\n", - mod_name, header->num_poses, header->num_joints ); - return qfalse; - } - - joint_names = 0; - - if ( header->num_joints ) - { - // check and swap joints - if( IQM_CheckRange( header, header->ofs_joints, - header->num_joints, sizeof(iqmJoint_t) ) ) { - return qfalse; - } - joint = (iqmJoint_t *)((byte *)header + header->ofs_joints); - for( i = 0; i < header->num_joints; i++, joint++ ) { - LL( joint->name ); - LL( joint->parent ); - LL( joint->translate[0] ); - LL( joint->translate[1] ); - LL( joint->translate[2] ); - LL( joint->rotate[0] ); - LL( joint->rotate[1] ); - LL( joint->rotate[2] ); - LL( joint->rotate[3] ); - LL( joint->scale[0] ); - LL( joint->scale[1] ); - LL( joint->scale[2] ); - - if( joint->parent < -1 || - joint->parent >= (int)header->num_joints || - joint->name >= (int)header->num_text ) { - return qfalse; - } - joint_names += strlen( (char *)header + header->ofs_text + - joint->name ) + 1; - } - } - - if ( header->num_poses ) - { - // check and swap poses - if( IQM_CheckRange( header, header->ofs_poses, - header->num_poses, sizeof(iqmPose_t) ) ) { - return qfalse; - } - pose = (iqmPose_t *)((byte *)header + header->ofs_poses); - for( i = 0; i < header->num_poses; i++, pose++ ) { - LL( pose->parent ); - LL( pose->mask ); - LL( pose->channeloffset[0] ); - LL( pose->channeloffset[1] ); - LL( pose->channeloffset[2] ); - LL( pose->channeloffset[3] ); - LL( pose->channeloffset[4] ); - LL( pose->channeloffset[5] ); - LL( pose->channeloffset[6] ); - LL( pose->channeloffset[7] ); - LL( pose->channeloffset[8] ); - LL( pose->channeloffset[9] ); - LL( pose->channelscale[0] ); - LL( pose->channelscale[1] ); - LL( pose->channelscale[2] ); - LL( pose->channelscale[3] ); - LL( pose->channelscale[4] ); - LL( pose->channelscale[5] ); - LL( pose->channelscale[6] ); - LL( pose->channelscale[7] ); - LL( pose->channelscale[8] ); - LL( pose->channelscale[9] ); - } - } - - if (header->ofs_bounds) - { - // check and swap model bounds - if(IQM_CheckRange(header, header->ofs_bounds, - header->num_frames, sizeof(*bounds))) - { - return qfalse; - } - bounds = (iqmBounds_t *) ((byte *) header + header->ofs_bounds); - for(i = 0; i < header->num_frames; i++) - { - LL(bounds->bbmin[0]); - LL(bounds->bbmin[1]); - LL(bounds->bbmin[2]); - LL(bounds->bbmax[0]); - LL(bounds->bbmax[1]); - LL(bounds->bbmax[2]); - - bounds++; - } - } - - // allocate the model and copy the data - size = sizeof(iqmData_t); - if( header->num_meshes ) { - size += header->num_meshes * sizeof( srfIQModel_t ); // surfaces - size += header->num_triangles * 3 * sizeof(int); // triangles - size += header->num_vertexes * 3 * sizeof(float); // positions - size += header->num_vertexes * 2 * sizeof(float); // texcoords - size += header->num_vertexes * 3 * sizeof(float); // normals - - if ( vertexArrayFormat[IQM_TANGENT] != -1 ) { - size += header->num_vertexes * 4 * sizeof(float); // tangents - } - - if ( vertexArrayFormat[IQM_COLOR] != -1 ) { - size += header->num_vertexes * 4 * sizeof(byte); // colors - } - - if ( allocateInfluences ) { - size += header->num_vertexes * sizeof(int); // influences - size += allocateInfluences * 4 * sizeof(byte); // influenceBlendIndexes - - if( vertexArrayFormat[IQM_BLENDWEIGHTS] == IQM_UBYTE ) { - size += allocateInfluences * 4 * sizeof(byte); // influenceBlendWeights - } else if( vertexArrayFormat[IQM_BLENDWEIGHTS] == IQM_FLOAT ) { - size += allocateInfluences * 4 * sizeof(float); // influenceBlendWeights - } - } - } - if( header->num_joints ) { - size += joint_names; // joint names - size += header->num_joints * sizeof(int); // joint parents - size += header->num_joints * 12 * sizeof(float); // bind joint matricies - size += header->num_joints * 12 * sizeof(float); // inverse bind joint matricies - } - if( header->num_poses ) { - size += header->num_poses * header->num_frames * sizeof(iqmTransform_t); // pose transforms - } - if( header->ofs_bounds ) { - size += header->num_frames * 6 * sizeof(float); // model bounds - } else if( header->num_meshes && header->num_frames == 0 ) { - size += 6 * sizeof(float); // model bounds - } - - mod->type = MOD_IQM; - iqmData = (iqmData_t *)ri.Hunk_Alloc( size, h_low ); - mod->modelData = iqmData; - - // fill header - iqmData->num_vertexes = ( header->num_meshes > 0 ) ? header->num_vertexes : 0; - iqmData->num_triangles = ( header->num_meshes > 0 ) ? header->num_triangles : 0; - iqmData->num_frames = header->num_frames; - iqmData->num_surfaces = header->num_meshes; - iqmData->num_joints = header->num_joints; - iqmData->num_poses = header->num_poses; - iqmData->blendWeightsType = vertexArrayFormat[IQM_BLENDWEIGHTS]; - - dataPtr = (byte*)iqmData + sizeof(iqmData_t); - if( header->num_meshes ) { - iqmData->surfaces = (struct srfIQModel_s*)dataPtr; - dataPtr += header->num_meshes * sizeof( srfIQModel_t ); - - iqmData->triangles = (int*)dataPtr; - dataPtr += header->num_triangles * 3 * sizeof(int); // triangles - - iqmData->positions = (float*)dataPtr; - dataPtr += header->num_vertexes * 3 * sizeof(float); // positions - - iqmData->texcoords = (float*)dataPtr; - dataPtr += header->num_vertexes * 2 * sizeof(float); // texcoords - - iqmData->normals = (float*)dataPtr; - dataPtr += header->num_vertexes * 3 * sizeof(float); // normals - - if ( vertexArrayFormat[IQM_TANGENT] != -1 ) { - iqmData->tangents = (float*)dataPtr; - dataPtr += header->num_vertexes * 4 * sizeof(float); // tangents - } - - if ( vertexArrayFormat[IQM_COLOR] != -1 ) { - iqmData->colors = (byte*)dataPtr; - dataPtr += header->num_vertexes * 4 * sizeof(byte); // colors - } - - if ( allocateInfluences ) { - iqmData->influences = (int*)dataPtr; - dataPtr += header->num_vertexes * sizeof(int); // influences - - iqmData->influenceBlendIndexes = (byte*)dataPtr; - dataPtr += allocateInfluences * 4 * sizeof(byte); // influenceBlendIndexes - - if( vertexArrayFormat[IQM_BLENDWEIGHTS] == IQM_UBYTE ) { - iqmData->influenceBlendWeights.b = (byte*)dataPtr; - dataPtr += allocateInfluences * 4 * sizeof(byte); // influenceBlendWeights - } else if( vertexArrayFormat[IQM_BLENDWEIGHTS] == IQM_FLOAT ) { - iqmData->influenceBlendWeights.f = (float*)dataPtr; - dataPtr += allocateInfluences * 4 * sizeof(float); // influenceBlendWeights - } - } - } - if( header->num_joints ) { - iqmData->jointNames = (char*)dataPtr; - dataPtr += joint_names; // joint names - - iqmData->jointParents = (int*)dataPtr; - dataPtr += header->num_joints * sizeof(int); // joint parents - - iqmData->bindJoints = (float*)dataPtr; - dataPtr += header->num_joints * 12 * sizeof(float); // bind joint matricies - - iqmData->invBindJoints = (float*)dataPtr; - dataPtr += header->num_joints * 12 * sizeof(float); // inverse bind joint matricies - } - if( header->num_poses ) { - iqmData->poses = (iqmTransform_t*)dataPtr; - dataPtr += header->num_poses * header->num_frames * sizeof(iqmTransform_t); // pose transforms - } - if( header->ofs_bounds ) { - iqmData->bounds = (float*)dataPtr; - dataPtr += header->num_frames * 6 * sizeof(float); // model bounds - } else if( header->num_meshes && header->num_frames == 0 ) { - iqmData->bounds = (float*)dataPtr; - dataPtr += 6 * sizeof(float); // model bounds - } - - if( header->num_meshes ) - { - // register shaders - // overwrite the material offset with the shader index - mesh = (iqmMesh_t *)((byte *)header + header->ofs_meshes); - surface = iqmData->surfaces; - str = (char *)header + header->ofs_text; - for( i = 0; i < header->num_meshes; i++, mesh++, surface++ ) { - surface->surfaceType = SF_IQM; - Q_strncpyz(surface->name, str + mesh->name, sizeof (surface->name)); - Q_strlwr(surface->name); // lowercase the surface name so skin compares are faster - surface->shader = R_FindShader( str + mesh->material, LIGHTMAP_NONE, qtrue ); - if( surface->shader->defaultShader ) - surface->shader = tr.defaultShader; - surface->data = iqmData; - surface->first_vertex = mesh->first_vertex; - surface->num_vertexes = mesh->num_vertexes; - surface->first_triangle = mesh->first_triangle; - surface->num_triangles = mesh->num_triangles; - } - - // copy triangles - triangle = (iqmTriangle_t *)((byte *)header + header->ofs_triangles); - for( i = 0; i < header->num_triangles; i++, triangle++ ) { - iqmData->triangles[3*i+0] = triangle->vertex[0]; - iqmData->triangles[3*i+1] = triangle->vertex[1]; - iqmData->triangles[3*i+2] = triangle->vertex[2]; - } - - // copy vertexarrays and indexes - vertexarray = (iqmVertexArray_t *)((byte *)header + header->ofs_vertexarrays); - for( i = 0; i < header->num_vertexarrays; i++, vertexarray++ ) { - int n; - - // skip disabled arrays - if( vertexarray->type < ARRAY_LEN( vertexArrayFormat ) - && vertexArrayFormat[vertexarray->type] == -1 ) - continue; - - // total number of values - n = header->num_vertexes * vertexarray->size; - - switch( vertexarray->type ) { - case IQM_POSITION: - Com_Memcpy( iqmData->positions, - (byte *)header + vertexarray->offset, - n * sizeof(float) ); - break; - case IQM_NORMAL: - Com_Memcpy( iqmData->normals, - (byte *)header + vertexarray->offset, - n * sizeof(float) ); - break; - case IQM_TANGENT: - Com_Memcpy( iqmData->tangents, - (byte *)header + vertexarray->offset, - n * sizeof(float) ); - break; - case IQM_TEXCOORD: - Com_Memcpy( iqmData->texcoords, - (byte *)header + vertexarray->offset, - n * sizeof(float) ); - break; - case IQM_BLENDINDEXES: - case IQM_BLENDWEIGHTS: - break; - case IQM_COLOR: - Com_Memcpy( iqmData->colors, - (byte *)header + vertexarray->offset, - n * sizeof(byte) ); - break; - } - } - - // find unique blend influences per mesh - if( allocateInfluences ) { - int vtx, influence, totalInfluences = 0; - - surface = iqmData->surfaces; - for( i = 0; i < header->num_meshes; i++, surface++ ) { - surface->first_influence = totalInfluences; - surface->num_influences = 0; - - for( j = 0; j < surface->num_vertexes; j++ ) { - vtx = surface->first_vertex + j; - - for( k = 0; k < surface->num_influences; k++ ) { - influence = surface->first_influence + k; - - if( *(int*)&iqmData->influenceBlendIndexes[4*influence] != *(int*)&blendIndexes[4*vtx] ) { - continue; - } - - if( vertexArrayFormat[IQM_BLENDWEIGHTS] == IQM_FLOAT ) { - if ( iqmData->influenceBlendWeights.f[4*influence+0] == blendWeights.f[4*vtx+0] && - iqmData->influenceBlendWeights.f[4*influence+1] == blendWeights.f[4*vtx+1] && - iqmData->influenceBlendWeights.f[4*influence+2] == blendWeights.f[4*vtx+2] && - iqmData->influenceBlendWeights.f[4*influence+3] == blendWeights.f[4*vtx+3] ) { - break; - } - } else { - if ( *(int*)&iqmData->influenceBlendWeights.b[4*influence] == *(int*)&blendWeights.b[4*vtx] ) { - break; - } - } - } - - iqmData->influences[vtx] = surface->first_influence + k; - - if( k == surface->num_influences ) { - influence = surface->first_influence + k; - - iqmData->influenceBlendIndexes[4*influence+0] = blendIndexes[4*vtx+0]; - iqmData->influenceBlendIndexes[4*influence+1] = blendIndexes[4*vtx+1]; - iqmData->influenceBlendIndexes[4*influence+2] = blendIndexes[4*vtx+2]; - iqmData->influenceBlendIndexes[4*influence+3] = blendIndexes[4*vtx+3]; - - if( vertexArrayFormat[IQM_BLENDWEIGHTS] == IQM_FLOAT ) { - iqmData->influenceBlendWeights.f[4*influence+0] = blendWeights.f[4*vtx+0]; - iqmData->influenceBlendWeights.f[4*influence+1] = blendWeights.f[4*vtx+1]; - iqmData->influenceBlendWeights.f[4*influence+2] = blendWeights.f[4*vtx+2]; - iqmData->influenceBlendWeights.f[4*influence+3] = blendWeights.f[4*vtx+3]; - } else { - iqmData->influenceBlendWeights.b[4*influence+0] = blendWeights.b[4*vtx+0]; - iqmData->influenceBlendWeights.b[4*influence+1] = blendWeights.b[4*vtx+1]; - iqmData->influenceBlendWeights.b[4*influence+2] = blendWeights.b[4*vtx+2]; - iqmData->influenceBlendWeights.b[4*influence+3] = blendWeights.b[4*vtx+3]; - } - - totalInfluences++; - surface->num_influences++; - } - } - } - } - } - - if( header->num_joints ) - { - // copy joint names - str = iqmData->jointNames; - joint = (iqmJoint_t *)((byte *)header + header->ofs_joints); - for( i = 0; i < header->num_joints; i++, joint++ ) { - char *name = (char *)header + header->ofs_text + - joint->name; - int len = strlen( name ) + 1; - Com_Memcpy( str, name, len ); - str += len; - } - - // copy joint parents - joint = (iqmJoint_t *)((byte *)header + header->ofs_joints); - for( i = 0; i < header->num_joints; i++, joint++ ) { - iqmData->jointParents[i] = joint->parent; - } - - // calculate bind joint matrices and their inverses - mat = iqmData->bindJoints; - matInv = iqmData->invBindJoints; - joint = (iqmJoint_t *)((byte *)header + header->ofs_joints); - for( i = 0; i < header->num_joints; i++, joint++ ) { - float baseFrame[12], invBaseFrame[12]; - - QuatNormalize2( joint->rotate, joint->rotate ); - - JointToMatrix( joint->rotate, joint->scale, joint->translate, baseFrame ); - Matrix34Invert( baseFrame, invBaseFrame ); - - if ( joint->parent >= 0 ) - { - Matrix34Multiply( iqmData->bindJoints + 12 * joint->parent, baseFrame, mat ); - mat += 12; - Matrix34Multiply( invBaseFrame, iqmData->invBindJoints + 12 * joint->parent, matInv ); - matInv += 12; - } - else - { - Com_Memcpy( mat, baseFrame, sizeof(baseFrame) ); - mat += 12; - Com_Memcpy( matInv, invBaseFrame, sizeof(invBaseFrame) ); - matInv += 12; - } - } - } - - if( header->num_poses ) - { - // calculate pose transforms - transform = iqmData->poses; - framedata = (unsigned short *)((byte *)header + header->ofs_frames); - for( i = 0; i < header->num_frames; i++ ) { - pose = (iqmPose_t *)((byte *)header + header->ofs_poses); - for( j = 0; j < header->num_poses; j++, pose++, transform++ ) { - vec3_t translate; - quat_t rotate; - vec3_t scale; - - translate[0] = pose->channeloffset[0]; - if( pose->mask & 0x001) - translate[0] += *framedata++ * pose->channelscale[0]; - translate[1] = pose->channeloffset[1]; - if( pose->mask & 0x002) - translate[1] += *framedata++ * pose->channelscale[1]; - translate[2] = pose->channeloffset[2]; - if( pose->mask & 0x004) - translate[2] += *framedata++ * pose->channelscale[2]; - - rotate[0] = pose->channeloffset[3]; - if( pose->mask & 0x008) - rotate[0] += *framedata++ * pose->channelscale[3]; - rotate[1] = pose->channeloffset[4]; - if( pose->mask & 0x010) - rotate[1] += *framedata++ * pose->channelscale[4]; - rotate[2] = pose->channeloffset[5]; - if( pose->mask & 0x020) - rotate[2] += *framedata++ * pose->channelscale[5]; - rotate[3] = pose->channeloffset[6]; - if( pose->mask & 0x040) - rotate[3] += *framedata++ * pose->channelscale[6]; - - scale[0] = pose->channeloffset[7]; - if( pose->mask & 0x080) - scale[0] += *framedata++ * pose->channelscale[7]; - scale[1] = pose->channeloffset[8]; - if( pose->mask & 0x100) - scale[1] += *framedata++ * pose->channelscale[8]; - scale[2] = pose->channeloffset[9]; - if( pose->mask & 0x200) - scale[2] += *framedata++ * pose->channelscale[9]; - - VectorCopy( translate, transform->translate ); - QuatNormalize2( rotate, transform->rotate ); - VectorCopy( scale, transform->scale ); - } - } - } - - // copy model bounds - if(header->ofs_bounds) - { - mat = iqmData->bounds; - bounds = (iqmBounds_t *) ((byte *) header + header->ofs_bounds); - for(i = 0; i < header->num_frames; i++) - { - mat[0] = bounds->bbmin[0]; - mat[1] = bounds->bbmin[1]; - mat[2] = bounds->bbmin[2]; - mat[3] = bounds->bbmax[0]; - mat[4] = bounds->bbmax[1]; - mat[5] = bounds->bbmax[2]; - - mat += 6; - bounds++; - } - } - else if( header->num_meshes && header->num_frames == 0 ) - { - mat = iqmData->bounds; - - ClearBounds( &iqmData->bounds[0], &iqmData->bounds[3] ); - for ( i = 0 ; i < header->num_vertexes ; i++ ) { - AddPointToBounds( &iqmData->positions[i*3], &iqmData->bounds[0], &iqmData->bounds[3] ); - } - } - - // Create VAO surfaces - if ( iqmData->num_surfaces && iqmData->num_joints <= glRefConfig.glslMaxAnimatedBones ) - { - srfVaoIQModel_t *vaoSurf; - srfIQModel_t *surf; - - iqmData->numVaoSurfaces = iqmData->num_surfaces; - iqmData->vaoSurfaces = ri.Hunk_Alloc(sizeof(*iqmData->vaoSurfaces) * iqmData->numVaoSurfaces, h_low); - - vaoSurf = iqmData->vaoSurfaces; - surf = iqmData->surfaces; - for (i = 0; i < iqmData->num_surfaces; i++, vaoSurf++, surf++) - { - uint32_t offset_xyz, offset_st, offset_normal, offset_tangent; - uint32_t offset_blendindexes, offset_blendweights, stride; - uint32_t dataSize, dataOfs; - uint8_t *data; - glIndex_t indexes[SHADER_MAX_INDEXES]; - glIndex_t *ptr; - int *tri; - - offset_xyz = 0; - offset_st = offset_xyz + sizeof(float) * 3; - offset_normal = offset_st + sizeof(float) * 2; - offset_tangent = offset_normal + sizeof(int16_t) * 4; - - if ( iqmData->num_joints ) - { - offset_blendindexes = offset_tangent + sizeof(int16_t) * 4; - offset_blendweights = offset_blendindexes + sizeof(byte) * 4; - - if ( vertexArrayFormat[IQM_BLENDWEIGHTS] == IQM_FLOAT ) { - stride = offset_blendweights + sizeof(float) * 4; - } else { - stride = offset_blendweights + sizeof(byte) * 4; - } - } - else - { - stride = offset_tangent + sizeof(int16_t) * 4; - } - - dataSize = surf->num_vertexes * stride; - - data = ri.Malloc(dataSize); - dataOfs = 0; - - for ( j = 0; j < surf->num_vertexes; j++ ) - { - int vtx = surf->first_vertex + j; - - // xyz - memcpy(data + dataOfs, &iqmData->positions[vtx*3], sizeof(float) * 3); - dataOfs += sizeof(float) * 3; - - // st - memcpy(data + dataOfs, &iqmData->texcoords[vtx*2], sizeof(float) * 2); - dataOfs += sizeof(float) * 2; - - // normal - R_VaoPackNormal((int16_t*)(data + dataOfs), &iqmData->normals[vtx*3]); - dataOfs += sizeof(int16_t) * 4; - - // tangent - R_VaoPackTangent((int16_t*)(data + dataOfs), &iqmData->tangents[vtx*4]); - dataOfs += sizeof(int16_t) * 4; - - if ( iqmData->num_joints ) - { - // blendindexes - memcpy(data + dataOfs, &blendIndexes[vtx*4], sizeof(byte) * 4); - dataOfs += sizeof(byte) * 4; - - // blendweights - if ( vertexArrayFormat[IQM_BLENDWEIGHTS] == IQM_FLOAT ) { - memcpy(data + dataOfs, &blendWeights.f[vtx*4], sizeof(float) * 4); - dataOfs += sizeof(float) * 4; - } else { - memcpy(data + dataOfs, &blendWeights.b[vtx*4], sizeof(byte) * 4); - dataOfs += sizeof(byte) * 4; - } - } - } - - tri = iqmData->triangles + 3 * surf->first_triangle; - ptr = indexes; - - for( j = 0; j < surf->num_triangles; j++ ) { - *ptr++ = (*tri++ - surf->first_vertex); - *ptr++ = (*tri++ - surf->first_vertex); - *ptr++ = (*tri++ - surf->first_vertex); - } - - vaoSurf->surfaceType = SF_VAO_IQM; - vaoSurf->iqmData = iqmData; - vaoSurf->iqmSurface = surf; - vaoSurf->numIndexes = surf->num_triangles * 3; - vaoSurf->numVerts = surf->num_vertexes; - - vaoSurf->vao = R_CreateVao(va("staticIQMMesh_VAO '%s'", surf->name), data, dataSize, (byte *)indexes, surf->num_triangles * 3 * sizeof(indexes[0]), VAO_USAGE_STATIC); - - vaoSurf->vao->attribs[ATTR_INDEX_POSITION].enabled = 1; - vaoSurf->vao->attribs[ATTR_INDEX_POSITION].enabled = 1; - vaoSurf->vao->attribs[ATTR_INDEX_TEXCOORD].enabled = 1; - vaoSurf->vao->attribs[ATTR_INDEX_NORMAL ].enabled = 1; - vaoSurf->vao->attribs[ATTR_INDEX_TANGENT ].enabled = 1; - - vaoSurf->vao->attribs[ATTR_INDEX_POSITION].count = 3; - vaoSurf->vao->attribs[ATTR_INDEX_TEXCOORD].count = 2; - vaoSurf->vao->attribs[ATTR_INDEX_NORMAL ].count = 4; - vaoSurf->vao->attribs[ATTR_INDEX_TANGENT ].count = 4; - - vaoSurf->vao->attribs[ATTR_INDEX_POSITION].type = GL_FLOAT; - vaoSurf->vao->attribs[ATTR_INDEX_TEXCOORD].type = GL_FLOAT; - vaoSurf->vao->attribs[ATTR_INDEX_NORMAL ].type = GL_SHORT; - vaoSurf->vao->attribs[ATTR_INDEX_TANGENT ].type = GL_SHORT; - - vaoSurf->vao->attribs[ATTR_INDEX_POSITION].normalized = GL_FALSE; - vaoSurf->vao->attribs[ATTR_INDEX_TEXCOORD].normalized = GL_FALSE; - vaoSurf->vao->attribs[ATTR_INDEX_NORMAL ].normalized = GL_TRUE; - vaoSurf->vao->attribs[ATTR_INDEX_TANGENT ].normalized = GL_TRUE; - - vaoSurf->vao->attribs[ATTR_INDEX_POSITION].offset = offset_xyz; - vaoSurf->vao->attribs[ATTR_INDEX_TEXCOORD].offset = offset_st; - vaoSurf->vao->attribs[ATTR_INDEX_NORMAL ].offset = offset_normal; - vaoSurf->vao->attribs[ATTR_INDEX_TANGENT ].offset = offset_tangent; - - vaoSurf->vao->attribs[ATTR_INDEX_POSITION].stride = stride; - vaoSurf->vao->attribs[ATTR_INDEX_TEXCOORD].stride = stride; - vaoSurf->vao->attribs[ATTR_INDEX_NORMAL ].stride = stride; - vaoSurf->vao->attribs[ATTR_INDEX_TANGENT ].stride = stride; - - if ( iqmData->num_joints ) - { - vaoSurf->vao->attribs[ATTR_INDEX_BONE_INDEXES].enabled = 1; - vaoSurf->vao->attribs[ATTR_INDEX_BONE_WEIGHTS].enabled = 1; - - vaoSurf->vao->attribs[ATTR_INDEX_BONE_INDEXES].count = 4; - vaoSurf->vao->attribs[ATTR_INDEX_BONE_WEIGHTS].count = 4; - - vaoSurf->vao->attribs[ATTR_INDEX_BONE_INDEXES].type = GL_UNSIGNED_BYTE; - vaoSurf->vao->attribs[ATTR_INDEX_BONE_INDEXES].normalized = GL_FALSE; - - if ( vertexArrayFormat[IQM_BLENDWEIGHTS] == IQM_FLOAT ) { - vaoSurf->vao->attribs[ATTR_INDEX_BONE_WEIGHTS].type = GL_FLOAT; - vaoSurf->vao->attribs[ATTR_INDEX_BONE_WEIGHTS].normalized = GL_FALSE; - } else { - vaoSurf->vao->attribs[ATTR_INDEX_BONE_WEIGHTS].type = GL_UNSIGNED_BYTE; - vaoSurf->vao->attribs[ATTR_INDEX_BONE_WEIGHTS].normalized = GL_TRUE; - } - - vaoSurf->vao->attribs[ATTR_INDEX_BONE_INDEXES].offset = offset_blendindexes; - vaoSurf->vao->attribs[ATTR_INDEX_BONE_WEIGHTS].offset = offset_blendweights; - - vaoSurf->vao->attribs[ATTR_INDEX_BONE_INDEXES].stride = stride; - vaoSurf->vao->attribs[ATTR_INDEX_BONE_WEIGHTS].stride = stride; - } - - Vao_SetVertexPointers(vaoSurf->vao); - - ri.Free(data); - } - } - - return qtrue; -} - -/* -============= -R_CullIQM -============= -*/ -static int R_CullIQM( const iqmData_t *data, const trRefEntity_t *ent ) { - vec3_t bounds[2]; - vec_t *oldBounds, *newBounds; - int i; - - if (!data->bounds) { - tr.pc.c_box_cull_md3_clip++; - return CULL_CLIP; - } - - // compute bounds pointers - oldBounds = data->bounds + 6*ent->e.oldframe; - newBounds = data->bounds + 6*ent->e.frame; - - // calculate a bounding box in the current coordinate system - for (i = 0 ; i < 3 ; i++) { - bounds[0][i] = oldBounds[i] < newBounds[i] ? oldBounds[i] : newBounds[i]; - bounds[1][i] = oldBounds[i+3] > newBounds[i+3] ? oldBounds[i+3] : newBounds[i+3]; - } - - switch ( R_CullLocalBox( bounds ) ) - { - case CULL_IN: - tr.pc.c_box_cull_md3_in++; - return CULL_IN; - case CULL_CLIP: - tr.pc.c_box_cull_md3_clip++; - return CULL_CLIP; - case CULL_OUT: - default: - tr.pc.c_box_cull_md3_out++; - return CULL_OUT; - } -} - -/* -================= -R_ComputeIQMFogNum - -================= -*/ -static int R_ComputeIQMFogNum( const iqmData_t *data, const trRefEntity_t *ent ) { - int i, j; - const fog_t *fog; - const vec_t *bounds; - const vec_t defaultBounds[6] = { -8, -8, -8, 8, 8, 8 }; - vec3_t diag, center; - vec3_t localOrigin; - vec_t radius; - - if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { - return 0; - } - - // FIXME: non-normalized axis issues - if (data->bounds) { - bounds = data->bounds + 6*ent->e.frame; - } else { - bounds = defaultBounds; - } - VectorSubtract( bounds+3, bounds, diag ); - VectorMA( bounds, 0.5f, diag, center ); - VectorAdd( ent->e.origin, center, localOrigin ); - radius = 0.5f * VectorLength( diag ); - - for ( i = 1 ; i < tr.world->numfogs ; i++ ) { - fog = &tr.world->fogs[i]; - for ( j = 0 ; j < 3 ; j++ ) { - if ( localOrigin[j] - radius >= fog->bounds[1][j] ) { - break; - } - if ( localOrigin[j] + radius <= fog->bounds[0][j] ) { - break; - } - } - if ( j == 3 ) { - return i; - } - } - - return 0; -} - -/* -================= -R_AddIQMSurfaces - -Add all surfaces of this model -================= -*/ -void R_AddIQMSurfaces( trRefEntity_t *ent ) { - iqmData_t *data; - srfIQModel_t *surface; - void *drawSurf; - int i, j; - qboolean personalModel; - int cull; - int fogNum; - int cubemapIndex; - shader_t *shader; - const skin_t *skin; - - data = tr.currentModel->modelData; - surface = data->surfaces; - - // don't add third_person objects if not in a portal - personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal - || (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW))); - - if ( ent->e.renderfx & RF_WRAP_FRAMES ) { - ent->e.frame %= data->num_frames; - ent->e.oldframe %= data->num_frames; - } - - // - // Validate the frames so there is no chance of a crash. - // This will write directly into the entity structure, so - // when the surfaces are rendered, they don't need to be - // range checked again. - // - if ( (ent->e.frame >= data->num_frames) - || (ent->e.frame < 0) - || (ent->e.oldframe >= data->num_frames) - || (ent->e.oldframe < 0) ) { - ri.Printf( PRINT_DEVELOPER, "R_AddIQMSurfaces: no such frame %d to %d for '%s'\n", - ent->e.oldframe, ent->e.frame, - tr.currentModel->name ); - ent->e.frame = 0; - ent->e.oldframe = 0; - } - - // - // cull the entire model if merged bounding box of both frames - // is outside the view frustum. - // - cull = R_CullIQM ( data, ent ); - if ( cull == CULL_OUT ) { - return; - } - - // - // set up lighting now that we know we aren't culled - // - if ( !personalModel || r_shadows->integer > 1 ) { - R_SetupEntityLighting( &tr.refdef, ent ); - } - - // - // see if we are in a fog volume - // - fogNum = R_ComputeIQMFogNum( data, ent ); - - cubemapIndex = R_CubemapForPoint(ent->e.origin); - - for ( i = 0 ; i < data->num_surfaces ; i++ ) { - if(ent->e.customShader) - shader = R_GetShaderByHandle( ent->e.customShader ); - else if(ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins) - { - skin = R_GetSkinByHandle(ent->e.customSkin); - shader = tr.defaultShader; - - for(j = 0; j < skin->numSurfaces; j++) - { - if (!strcmp(skin->surfaces[j].name, surface->name)) - { - shader = skin->surfaces[j].shader; - break; - } - } - } else { - shader = surface->shader; - } - - if ( data->numVaoSurfaces ) { - drawSurf = &data->vaoSurfaces[i]; - } else { - drawSurf = surface; - } - - // we will add shadows even if the main object isn't visible in the view - - // stencil shadows can't do personal models unless I polyhedron clip - if ( !personalModel - && r_shadows->integer == 2 - && fogNum == 0 - && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) - && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( drawSurf, tr.shadowShader, 0, 0, 0, 0 ); - } - - // projection shadows work fine with personal models - if ( r_shadows->integer == 3 - && fogNum == 0 - && (ent->e.renderfx & RF_SHADOW_PLANE ) - && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( drawSurf, tr.projectionShadowShader, 0, 0, 0, 0 ); - } - - if( !personalModel ) { - R_AddDrawSurf( drawSurf, shader, fogNum, 0, 0, cubemapIndex ); - } - - surface++; - } -} - - -static void ComputePoseMats( iqmData_t *data, int frame, int oldframe, - float backlerp, float *poseMats ) { - iqmTransform_t relativeJoints[IQM_MAX_JOINTS]; - iqmTransform_t *relativeJoint; - const iqmTransform_t *pose; - const iqmTransform_t *oldpose; - const int *jointParent; - const float *invBindMat; - float *poseMat, lerp; - int i; - - relativeJoint = relativeJoints; - - // copy or lerp animation frame pose - if ( oldframe == frame ) { - pose = &data->poses[frame * data->num_poses]; - for ( i = 0; i < data->num_poses; i++, pose++, relativeJoint++ ) { - VectorCopy( pose->translate, relativeJoint->translate ); - QuatCopy( pose->rotate, relativeJoint->rotate ); - VectorCopy( pose->scale, relativeJoint->scale ); - } - } else { - lerp = 1.0f - backlerp; - pose = &data->poses[frame * data->num_poses]; - oldpose = &data->poses[oldframe * data->num_poses]; - for ( i = 0; i < data->num_poses; i++, oldpose++, pose++, relativeJoint++ ) { - relativeJoint->translate[0] = oldpose->translate[0] * backlerp + pose->translate[0] * lerp; - relativeJoint->translate[1] = oldpose->translate[1] * backlerp + pose->translate[1] * lerp; - relativeJoint->translate[2] = oldpose->translate[2] * backlerp + pose->translate[2] * lerp; - - relativeJoint->scale[0] = oldpose->scale[0] * backlerp + pose->scale[0] * lerp; - relativeJoint->scale[1] = oldpose->scale[1] * backlerp + pose->scale[1] * lerp; - relativeJoint->scale[2] = oldpose->scale[2] * backlerp + pose->scale[2] * lerp; - - QuatSlerp( oldpose->rotate, pose->rotate, lerp, relativeJoint->rotate ); - } - } - - // multiply by inverse of bind pose and parent 'pose mat' (bind pose transform matrix) - relativeJoint = relativeJoints; - jointParent = data->jointParents; - invBindMat = data->invBindJoints; - poseMat = poseMats; - for ( i = 0; i < data->num_poses; i++, relativeJoint++, jointParent++, invBindMat += 12, poseMat += 12 ) { - float mat1[12], mat2[12]; - - JointToMatrix( relativeJoint->rotate, relativeJoint->scale, relativeJoint->translate, mat1 ); - - if ( *jointParent >= 0 ) { - Matrix34Multiply( &data->bindJoints[(*jointParent)*12], mat1, mat2 ); - Matrix34Multiply( mat2, invBindMat, mat1 ); - Matrix34Multiply( &poseMats[(*jointParent)*12], mat1, poseMat ); - } else { - Matrix34Multiply( mat1, invBindMat, poseMat ); - } - } -} - -static void ComputeJointMats( iqmData_t *data, int frame, int oldframe, - float backlerp, float *mat ) { - float *mat1; - int i; - - if ( data->num_poses == 0 ) { - Com_Memcpy( mat, data->bindJoints, data->num_joints * 12 * sizeof(float) ); - return; - } - - ComputePoseMats( data, frame, oldframe, backlerp, mat ); - - for( i = 0; i < data->num_joints; i++ ) { - float outmat[12]; - mat1 = mat + 12 * i; - - Com_Memcpy(outmat, mat1, sizeof(outmat)); - - Matrix34Multiply( outmat, data->bindJoints + 12*i, mat1 ); - } -} - - -/* -================= -RB_AddIQMSurfaces - -Compute vertices for this model surface -================= -*/ -void RB_IQMSurfaceAnim( const surfaceType_t *surface ) { - srfIQModel_t *surf = (srfIQModel_t *)surface; - iqmData_t *data = surf->data; - float poseMats[IQM_MAX_JOINTS * 12]; - float influenceVtxMat[SHADER_MAX_VERTEXES * 12]; - float influenceNrmMat[SHADER_MAX_VERTEXES * 9]; - int i; - - float *xyz; - float *normal; - float *tangent; - float *texCoords; - byte *color; - vec4_t *outXYZ; - int16_t *outNormal; - int16_t *outTangent; - vec2_t *outTexCoord; - uint16_t *outColor; - - int frame = data->num_frames ? backEnd.currentEntity->e.frame % data->num_frames : 0; - int oldframe = data->num_frames ? backEnd.currentEntity->e.oldframe % data->num_frames : 0; - float backlerp = backEnd.currentEntity->e.backlerp; - - int *tri; - glIndex_t *ptr; - glIndex_t base; - - RB_CHECKOVERFLOW( surf->num_vertexes, surf->num_triangles * 3 ); - - xyz = &data->positions[surf->first_vertex * 3]; - normal = &data->normals[surf->first_vertex * 3]; - tangent = &data->tangents[surf->first_vertex * 4]; - texCoords = &data->texcoords[surf->first_vertex * 2]; - - if ( data->colors ) { - color = &data->colors[surf->first_vertex * 4]; - } else { - color = NULL; - } - - outXYZ = &tess.xyz[tess.numVertexes]; - outNormal = tess.normal[tess.numVertexes]; - outTangent = tess.tangent[tess.numVertexes]; - outTexCoord = &tess.texCoords[tess.numVertexes]; - outColor = tess.color[tess.numVertexes]; - - if ( data->num_poses > 0 ) { - // compute interpolated joint matrices - ComputePoseMats( data, frame, oldframe, backlerp, poseMats ); - - // compute vertex blend influence matricies - for( i = 0; i < surf->num_influences; i++ ) { - int influence = surf->first_influence + i; - float *vtxMat = &influenceVtxMat[12*i]; - float *nrmMat = &influenceNrmMat[9*i]; - int j; - float blendWeights[4]; - - if ( data->blendWeightsType == IQM_FLOAT ) { - blendWeights[0] = data->influenceBlendWeights.f[4*influence + 0]; - blendWeights[1] = data->influenceBlendWeights.f[4*influence + 1]; - blendWeights[2] = data->influenceBlendWeights.f[4*influence + 2]; - blendWeights[3] = data->influenceBlendWeights.f[4*influence + 3]; - } else { - blendWeights[0] = (float)data->influenceBlendWeights.b[4*influence + 0] / 255.0f; - blendWeights[1] = (float)data->influenceBlendWeights.b[4*influence + 1] / 255.0f; - blendWeights[2] = (float)data->influenceBlendWeights.b[4*influence + 2] / 255.0f; - blendWeights[3] = (float)data->influenceBlendWeights.b[4*influence + 3] / 255.0f; - } - - if ( blendWeights[0] <= 0.0f ) { - // no blend joint, use identity matrix. - vtxMat[0] = identityMatrix[0]; - vtxMat[1] = identityMatrix[1]; - vtxMat[2] = identityMatrix[2]; - vtxMat[3] = identityMatrix[3]; - vtxMat[4] = identityMatrix[4]; - vtxMat[5] = identityMatrix[5]; - vtxMat[6] = identityMatrix[6]; - vtxMat[7] = identityMatrix[7]; - vtxMat[8] = identityMatrix[8]; - vtxMat[9] = identityMatrix[9]; - vtxMat[10] = identityMatrix[10]; - vtxMat[11] = identityMatrix[11]; - } else { - // compute the vertex matrix by blending the up to - // four blend weights - vtxMat[0] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 0]; - vtxMat[1] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 1]; - vtxMat[2] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 2]; - vtxMat[3] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 3]; - vtxMat[4] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 4]; - vtxMat[5] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 5]; - vtxMat[6] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 6]; - vtxMat[7] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 7]; - vtxMat[8] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 8]; - vtxMat[9] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 9]; - vtxMat[10] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 10]; - vtxMat[11] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 11]; - - for ( j = 1; j < ARRAY_LEN( blendWeights ); j++ ) { - if ( blendWeights[j] <= 0.0f ) { - break; - } - - vtxMat[0] += blendWeights[j] * poseMats[12 * data->influenceBlendIndexes[4*influence + j] + 0]; - vtxMat[1] += blendWeights[j] * poseMats[12 * data->influenceBlendIndexes[4*influence + j] + 1]; - vtxMat[2] += blendWeights[j] * poseMats[12 * data->influenceBlendIndexes[4*influence + j] + 2]; - vtxMat[3] += blendWeights[j] * poseMats[12 * data->influenceBlendIndexes[4*influence + j] + 3]; - vtxMat[4] += blendWeights[j] * poseMats[12 * data->influenceBlendIndexes[4*influence + j] + 4]; - vtxMat[5] += blendWeights[j] * poseMats[12 * data->influenceBlendIndexes[4*influence + j] + 5]; - vtxMat[6] += blendWeights[j] * poseMats[12 * data->influenceBlendIndexes[4*influence + j] + 6]; - vtxMat[7] += blendWeights[j] * poseMats[12 * data->influenceBlendIndexes[4*influence + j] + 7]; - vtxMat[8] += blendWeights[j] * poseMats[12 * data->influenceBlendIndexes[4*influence + j] + 8]; - vtxMat[9] += blendWeights[j] * poseMats[12 * data->influenceBlendIndexes[4*influence + j] + 9]; - vtxMat[10] += blendWeights[j] * poseMats[12 * data->influenceBlendIndexes[4*influence + j] + 10]; - vtxMat[11] += blendWeights[j] * poseMats[12 * data->influenceBlendIndexes[4*influence + j] + 11]; - } - } - - // compute the normal matrix as transpose of the adjoint - // of the vertex matrix - nrmMat[ 0] = vtxMat[ 5]*vtxMat[10] - vtxMat[ 6]*vtxMat[ 9]; - nrmMat[ 1] = vtxMat[ 6]*vtxMat[ 8] - vtxMat[ 4]*vtxMat[10]; - nrmMat[ 2] = vtxMat[ 4]*vtxMat[ 9] - vtxMat[ 5]*vtxMat[ 8]; - nrmMat[ 3] = vtxMat[ 2]*vtxMat[ 9] - vtxMat[ 1]*vtxMat[10]; - nrmMat[ 4] = vtxMat[ 0]*vtxMat[10] - vtxMat[ 2]*vtxMat[ 8]; - nrmMat[ 5] = vtxMat[ 1]*vtxMat[ 8] - vtxMat[ 0]*vtxMat[ 9]; - nrmMat[ 6] = vtxMat[ 1]*vtxMat[ 6] - vtxMat[ 2]*vtxMat[ 5]; - nrmMat[ 7] = vtxMat[ 2]*vtxMat[ 4] - vtxMat[ 0]*vtxMat[ 6]; - nrmMat[ 8] = vtxMat[ 0]*vtxMat[ 5] - vtxMat[ 1]*vtxMat[ 4]; - } - - // transform vertexes and fill other data - for( i = 0; i < surf->num_vertexes; - i++, xyz+=3, normal+=3, tangent+=4, texCoords+=2, - outXYZ++, outNormal+=4, outTangent+=4, outTexCoord++ ) { - int influence = data->influences[surf->first_vertex + i] - surf->first_influence; - float *vtxMat = &influenceVtxMat[12*influence]; - float *nrmMat = &influenceNrmMat[9*influence]; - - (*outTexCoord)[0] = texCoords[0]; - (*outTexCoord)[1] = texCoords[1]; - - (*outXYZ)[0] = - vtxMat[ 0] * xyz[0] + - vtxMat[ 1] * xyz[1] + - vtxMat[ 2] * xyz[2] + - vtxMat[ 3]; - (*outXYZ)[1] = - vtxMat[ 4] * xyz[0] + - vtxMat[ 5] * xyz[1] + - vtxMat[ 6] * xyz[2] + - vtxMat[ 7]; - (*outXYZ)[2] = - vtxMat[ 8] * xyz[0] + - vtxMat[ 9] * xyz[1] + - vtxMat[10] * xyz[2] + - vtxMat[11]; - - { - vec3_t unpackedNormal; - vec4_t unpackedTangent; - - unpackedNormal[0] = DotProduct(&nrmMat[0], normal); - unpackedNormal[1] = DotProduct(&nrmMat[3], normal); - unpackedNormal[2] = DotProduct(&nrmMat[6], normal); - - R_VaoPackNormal(outNormal, unpackedNormal); - - unpackedTangent[0] = DotProduct(&nrmMat[0], tangent); - unpackedTangent[1] = DotProduct(&nrmMat[3], tangent); - unpackedTangent[2] = DotProduct(&nrmMat[6], tangent); - unpackedTangent[3] = tangent[3]; - - R_VaoPackTangent(outTangent, unpackedTangent); - } - } - } else { - // copy vertexes and fill other data - for( i = 0; i < surf->num_vertexes; - i++, xyz+=3, normal+=3, tangent+=4, texCoords+=2, - outXYZ++, outNormal+=4, outTangent+=4, outTexCoord++ ) { - (*outTexCoord)[0] = texCoords[0]; - (*outTexCoord)[1] = texCoords[1]; - - (*outXYZ)[0] = xyz[0]; - (*outXYZ)[1] = xyz[1]; - (*outXYZ)[2] = xyz[2]; - - R_VaoPackNormal(outNormal, normal); - R_VaoPackTangent(outTangent, tangent); - } - } - - if ( color ) { - for( i = 0; i < surf->num_vertexes; i++, color+=4, outColor+=4 ) { - outColor[0] = color[0] * 257; - outColor[1] = color[1] * 257; - outColor[2] = color[2] * 257; - outColor[3] = color[3] * 257; - } - } else { - for( i = 0; i < surf->num_vertexes; i++, outColor+=4 ) { - outColor[0] = 0; - outColor[1] = 0; - outColor[2] = 0; - outColor[3] = 0; - } - } - - tri = data->triangles + 3 * surf->first_triangle; - ptr = &tess.indexes[tess.numIndexes]; - base = tess.numVertexes; - - for( i = 0; i < surf->num_triangles; i++ ) { - *ptr++ = base + (*tri++ - surf->first_vertex); - *ptr++ = base + (*tri++ - surf->first_vertex); - *ptr++ = base + (*tri++ - surf->first_vertex); - } - - tess.numIndexes += 3 * surf->num_triangles; - tess.numVertexes += surf->num_vertexes; -} - -/* -================= -RB_IQMSurfaceAnimVao -================= -*/ -void RB_IQMSurfaceAnimVao(const srfVaoIQModel_t * surface) -{ - iqmData_t *data = surface->iqmData; - - if (ShaderRequiresCPUDeforms(tess.shader)) - { - RB_IQMSurfaceAnim((surfaceType_t*)surface->iqmSurface); - return; - } - - if(!surface->vao) - return; - - //RB_CheckVao(surface->vao); - RB_EndSurface(); - RB_BeginSurface(tess.shader, tess.fogNum, tess.cubemapIndex); - - R_BindVao(surface->vao); - - tess.useInternalVao = qfalse; - - tess.numIndexes = surface->numIndexes; - tess.numVertexes = surface->numVerts; - - glState.boneAnimation = data->num_poses; - - if ( glState.boneAnimation ) { - float jointMats[IQM_MAX_JOINTS * 12]; - int frame = data->num_frames ? backEnd.currentEntity->e.frame % data->num_frames : 0; - int oldframe = data->num_frames ? backEnd.currentEntity->e.oldframe % data->num_frames : 0; - float backlerp = backEnd.currentEntity->e.backlerp; - int i; - - // compute interpolated joint matrices - ComputePoseMats( surface->iqmData, frame, oldframe, backlerp, jointMats ); - - // convert row-major order 3x4 matrix to column-major order 4x4 matrix - for ( i = 0; i < data->num_poses; i++ ) { - glState.boneMatrix[i][0] = jointMats[i*12+0]; - glState.boneMatrix[i][1] = jointMats[i*12+4]; - glState.boneMatrix[i][2] = jointMats[i*12+8]; - glState.boneMatrix[i][3] = 0.0f; - glState.boneMatrix[i][4] = jointMats[i*12+1]; - glState.boneMatrix[i][5] = jointMats[i*12+5]; - glState.boneMatrix[i][6] = jointMats[i*12+9]; - glState.boneMatrix[i][7] = 0.0f; - glState.boneMatrix[i][8] = jointMats[i*12+2]; - glState.boneMatrix[i][9] = jointMats[i*12+6]; - glState.boneMatrix[i][10] = jointMats[i*12+10]; - glState.boneMatrix[i][11] = 0.0f; - glState.boneMatrix[i][12] = jointMats[i*12+3]; - glState.boneMatrix[i][13] = jointMats[i*12+7]; - glState.boneMatrix[i][14] = jointMats[i*12+11]; - glState.boneMatrix[i][15] = 1.0f; - } - } - - RB_EndSurface(); - - glState.boneAnimation = 0; -} - -int R_IQMLerpTag( orientation_t *tag, iqmData_t *data, - int startFrame, int endFrame, - float frac, const char *tagName ) { - float jointMats[IQM_MAX_JOINTS * 12]; - int joint; - char *names = data->jointNames; - - // get joint number by reading the joint names - for( joint = 0; joint < data->num_joints; joint++ ) { - if( !strcmp( tagName, names ) ) - break; - names += strlen( names ) + 1; - } - if( joint >= data->num_joints ) { - AxisClear( tag->axis ); - VectorClear( tag->origin ); - return qfalse; - } - - ComputeJointMats( data, startFrame, endFrame, frac, jointMats ); - - tag->axis[0][0] = jointMats[12 * joint + 0]; - tag->axis[1][0] = jointMats[12 * joint + 1]; - tag->axis[2][0] = jointMats[12 * joint + 2]; - tag->origin[0] = jointMats[12 * joint + 3]; - tag->axis[0][1] = jointMats[12 * joint + 4]; - tag->axis[1][1] = jointMats[12 * joint + 5]; - tag->axis[2][1] = jointMats[12 * joint + 6]; - tag->origin[1] = jointMats[12 * joint + 7]; - tag->axis[0][2] = jointMats[12 * joint + 8]; - tag->axis[1][2] = jointMats[12 * joint + 9]; - tag->axis[2][2] = jointMats[12 * joint + 10]; - tag->origin[2] = jointMats[12 * joint + 11]; - - return qtrue; -} diff --git a/code/renderer2/tr_postprocess.c b/code/renderer2/tr_postprocess.c deleted file mode 100644 index 9931757b82..0000000000 --- a/code/renderer2/tr_postprocess.c +++ /dev/null @@ -1,483 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2011 Andrei Drexler, Richard Allen, James Canete - -This file is part of Reaction source code. - -Reaction source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Reaction source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Reaction source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ - -#include "tr_local.h" - -void RB_ToneMap(FBO_t *hdrFbo, ivec4_t hdrBox, FBO_t *ldrFbo, ivec4_t ldrBox, int autoExposure) -{ - ivec4_t srcBox, dstBox; - vec4_t color; - static int lastFrameCount = 0; - - if (autoExposure) - { - if (lastFrameCount == 0 || tr.frameCount < lastFrameCount || tr.frameCount - lastFrameCount > 5) - { - // determine average log luminance - FBO_t *srcFbo, *dstFbo, *tmp; - int size = 256; - - lastFrameCount = tr.frameCount; - - VectorSet4(dstBox, 0, 0, size, size); - - FBO_Blit(hdrFbo, hdrBox, NULL, tr.textureScratchFbo[0], dstBox, &tr.calclevels4xShader[0], NULL, 0); - - srcFbo = tr.textureScratchFbo[0]; - dstFbo = tr.textureScratchFbo[1]; - - // downscale to 1x1 texture - while (size > 1) - { - VectorSet4(srcBox, 0, 0, size, size); - //size >>= 2; - size >>= 1; - VectorSet4(dstBox, 0, 0, size, size); - - if (size == 1) - dstFbo = tr.targetLevelsFbo; - - //FBO_Blit(targetFbo, srcBox, NULL, tr.textureScratchFbo[nextScratch], dstBox, &tr.calclevels4xShader[1], NULL, 0); - FBO_FastBlit(srcFbo, srcBox, dstFbo, dstBox, GL_COLOR_BUFFER_BIT, GL_LINEAR); - - tmp = srcFbo; - srcFbo = dstFbo; - dstFbo = tmp; - } - } - - // blend with old log luminance for gradual change - VectorSet4(srcBox, 0, 0, 0, 0); - - color[0] = - color[1] = - color[2] = 1.0f; - if (glRefConfig.textureFloat) - color[3] = 0.03f; - else - color[3] = 0.1f; - - FBO_Blit(tr.targetLevelsFbo, srcBox, NULL, tr.calcLevelsFbo, NULL, NULL, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); - } - - // tonemap - color[0] = - color[1] = - color[2] = pow(2, r_cameraExposure->value - autoExposure); //exp2(r_cameraExposure->value); - color[3] = 1.0f; - - if (autoExposure) - GL_BindToTMU(tr.calcLevelsImage, TB_LEVELSMAP); - else - GL_BindToTMU(tr.fixedLevelsImage, TB_LEVELSMAP); - - FBO_Blit(hdrFbo, hdrBox, NULL, ldrFbo, ldrBox, &tr.tonemapShader, color, 0); -} - -/* -============= -RB_BokehBlur - - -Blurs a part of one framebuffer to another. - -Framebuffers can be identical. -============= -*/ -void RB_BokehBlur(FBO_t *src, ivec4_t srcBox, FBO_t *dst, ivec4_t dstBox, float blur) -{ -// ivec4_t srcBox, dstBox; - vec4_t color; - - blur *= 10.0f; - - if (blur < 0.004f) - return; - - if (glRefConfig.framebufferObject) - { - // bokeh blur - if (blur > 0.0f) - { - ivec4_t quarterBox; - - quarterBox[0] = 0; - quarterBox[1] = tr.quarterFbo[0]->height; - quarterBox[2] = tr.quarterFbo[0]->width; - quarterBox[3] = -tr.quarterFbo[0]->height; - - // create a quarter texture - //FBO_Blit(NULL, NULL, NULL, tr.quarterFbo[0], NULL, NULL, NULL, 0); - FBO_FastBlit(src, srcBox, tr.quarterFbo[0], quarterBox, GL_COLOR_BUFFER_BIT, GL_LINEAR); - } - -#ifndef HQ_BLUR - if (blur > 1.0f) - { - // create a 1/16th texture - //FBO_Blit(tr.quarterFbo[0], NULL, NULL, tr.textureScratchFbo[0], NULL, NULL, NULL, 0); - FBO_FastBlit(tr.quarterFbo[0], NULL, tr.textureScratchFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); - } -#endif - - if (blur > 0.0f && blur <= 1.0f) - { - // Crossfade original with quarter texture - VectorSet4(color, 1, 1, 1, blur); - - FBO_Blit(tr.quarterFbo[0], NULL, NULL, dst, dstBox, NULL, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); - } -#ifndef HQ_BLUR - // ok blur, but can see some pixelization - else if (blur > 1.0f && blur <= 2.0f) - { - // crossfade quarter texture with 1/16th texture - FBO_Blit(tr.quarterFbo[0], NULL, NULL, dst, dstBox, NULL, NULL, 0); - - VectorSet4(color, 1, 1, 1, blur - 1.0f); - - FBO_Blit(tr.textureScratchFbo[0], NULL, NULL, dst, dstBox, NULL, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); - } - else if (blur > 2.0f) - { - // blur 1/16th texture then replace - int i; - - for (i = 0; i < 2; i++) - { - vec2_t blurTexScale; - float subblur; - - subblur = ((blur - 2.0f) / 2.0f) / 3.0f * (float)(i + 1); - - blurTexScale[0] = - blurTexScale[1] = subblur; - - color[0] = - color[1] = - color[2] = 0.5f; - color[3] = 1.0f; - - if (i != 0) - FBO_Blit(tr.textureScratchFbo[0], NULL, blurTexScale, tr.textureScratchFbo[1], NULL, &tr.bokehShader, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE); - else - FBO_Blit(tr.textureScratchFbo[0], NULL, blurTexScale, tr.textureScratchFbo[1], NULL, &tr.bokehShader, color, 0); - } - - FBO_Blit(tr.textureScratchFbo[1], NULL, NULL, dst, dstBox, NULL, NULL, 0); - } -#else // higher quality blur, but slower - else if (blur > 1.0f) - { - // blur quarter texture then replace - int i; - - src = tr.quarterFbo[0]; - dst = tr.quarterFbo[1]; - - VectorSet4(color, 0.5f, 0.5f, 0.5f, 1); - - for (i = 0; i < 2; i++) - { - vec2_t blurTexScale; - float subblur; - - subblur = (blur - 1.0f) / 2.0f * (float)(i + 1); - - blurTexScale[0] = - blurTexScale[1] = subblur; - - color[0] = - color[1] = - color[2] = 1.0f; - if (i != 0) - color[3] = 1.0f; - else - color[3] = 0.5f; - - FBO_Blit(tr.quarterFbo[0], NULL, blurTexScale, tr.quarterFbo[1], NULL, &tr.bokehShader, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); - } - - FBO_Blit(tr.quarterFbo[1], NULL, NULL, dst, dstBox, NULL, NULL, 0); - } -#endif - } -} - - -static void RB_RadialBlur(FBO_t *srcFbo, FBO_t *dstFbo, int passes, float stretch, float x, float y, float w, float h, float xcenter, float ycenter, float alpha) -{ - ivec4_t srcBox, dstBox; - int srcWidth, srcHeight; - vec4_t color; - const float inc = 1.f / passes; - const float mul = powf(stretch, inc); - float scale; - - alpha *= inc; - VectorSet4(color, alpha, alpha, alpha, 1.0f); - - srcWidth = srcFbo ? srcFbo->width : glConfig.vidWidth; - srcHeight = srcFbo ? srcFbo->height : glConfig.vidHeight; - - VectorSet4(srcBox, 0, 0, srcWidth, srcHeight); - - VectorSet4(dstBox, x, y, w, h); - FBO_Blit(srcFbo, srcBox, NULL, dstFbo, dstBox, NULL, color, 0); - - --passes; - scale = mul; - while (passes > 0) - { - float iscale = 1.f / scale; - float s0 = xcenter * (1.f - iscale); - float t0 = (1.0f - ycenter) * (1.f - iscale); - - srcBox[0] = s0 * srcWidth; - srcBox[1] = t0 * srcHeight; - srcBox[2] = iscale * srcWidth; - srcBox[3] = iscale * srcHeight; - - FBO_Blit(srcFbo, srcBox, NULL, dstFbo, dstBox, NULL, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); - - scale *= mul; - --passes; - } -} - - -static qboolean RB_UpdateSunFlareVis(void) -{ - GLuint sampleCount = 0; - if (!glRefConfig.occlusionQuery) - return qtrue; - - tr.sunFlareQueryIndex ^= 1; - if (!tr.sunFlareQueryActive[tr.sunFlareQueryIndex]) - return qtrue; - - /* debug code */ - if (0) - { - int iter; - for (iter=0 ; ; ++iter) - { - GLint available = 0; - qglGetQueryObjectiv(tr.sunFlareQuery[tr.sunFlareQueryIndex], GL_QUERY_RESULT_AVAILABLE, &available); - if (available) - break; - } - - ri.Printf(PRINT_DEVELOPER, "Waited %d iterations\n", iter); - } - - qglGetQueryObjectuiv(tr.sunFlareQuery[tr.sunFlareQueryIndex], GL_QUERY_RESULT, &sampleCount); - return sampleCount > 0; -} - -void RB_SunRays(FBO_t *srcFbo, ivec4_t srcBox, FBO_t *dstFbo, ivec4_t dstBox) -{ - vec4_t color; - float dot; - const float cutoff = 0.25f; - qboolean colorize = qtrue; - -// float w, h, w2, h2; - mat4_t mvp; - vec4_t pos, hpos; - - dot = DotProduct(tr.sunDirection, backEnd.viewParms.or.axis[0]); - if (dot < cutoff) - return; - - if (!RB_UpdateSunFlareVis()) - return; - - // From RB_DrawSun() - { - float dist; - mat4_t trans, model; - - Mat4Translation( backEnd.viewParms.or.origin, trans ); - Mat4Multiply( backEnd.viewParms.world.modelMatrix, trans, model ); - Mat4Multiply(backEnd.viewParms.projectionMatrix, model, mvp); - - dist = backEnd.viewParms.zFar / 1.75; // div sqrt(3) - - VectorScale( tr.sunDirection, dist, pos ); - } - - // project sun point - //Mat4Multiply(backEnd.viewParms.projectionMatrix, backEnd.viewParms.world.modelMatrix, mvp); - Mat4Transform(mvp, pos, hpos); - - // transform to UV coords - hpos[3] = 0.5f / hpos[3]; - - pos[0] = 0.5f + hpos[0] * hpos[3]; - pos[1] = 0.5f + hpos[1] * hpos[3]; - - // initialize quarter buffers - { - float mul = 1.f; - ivec4_t rayBox, quarterBox; - int srcWidth = srcFbo ? srcFbo->width : glConfig.vidWidth; - int srcHeight = srcFbo ? srcFbo->height : glConfig.vidHeight; - - VectorSet4(color, mul, mul, mul, 1); - - rayBox[0] = srcBox[0] * tr.sunRaysFbo->width / srcWidth; - rayBox[1] = srcBox[1] * tr.sunRaysFbo->height / srcHeight; - rayBox[2] = srcBox[2] * tr.sunRaysFbo->width / srcWidth; - rayBox[3] = srcBox[3] * tr.sunRaysFbo->height / srcHeight; - - quarterBox[0] = 0; - quarterBox[1] = tr.quarterFbo[0]->height; - quarterBox[2] = tr.quarterFbo[0]->width; - quarterBox[3] = -tr.quarterFbo[0]->height; - - // first, downsample the framebuffer - if (colorize) - { - FBO_FastBlit(srcFbo, srcBox, tr.quarterFbo[0], quarterBox, GL_COLOR_BUFFER_BIT, GL_LINEAR); - FBO_Blit(tr.sunRaysFbo, rayBox, NULL, tr.quarterFbo[0], quarterBox, NULL, color, GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO); - } - else - { - FBO_FastBlit(tr.sunRaysFbo, rayBox, tr.quarterFbo[0], quarterBox, GL_COLOR_BUFFER_BIT, GL_LINEAR); - } - } - - // radial blur passes, ping-ponging between the two quarter-size buffers - { - const float stretch_add = 2.f/3.f; - float stretch = 1.f + stretch_add; - int i; - for (i=0; i<2; ++i) - { - RB_RadialBlur(tr.quarterFbo[i&1], tr.quarterFbo[(~i) & 1], 5, stretch, 0.f, 0.f, tr.quarterFbo[0]->width, tr.quarterFbo[0]->height, pos[0], pos[1], 1.125f); - stretch += stretch_add; - } - } - - // add result back on top of the main buffer - { - float mul = 1.f; - - VectorSet4(color, mul, mul, mul, 1); - - FBO_Blit(tr.quarterFbo[0], NULL, NULL, dstFbo, dstBox, NULL, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE); - } -} - -static void RB_BlurAxis(FBO_t *srcFbo, FBO_t *dstFbo, float strength, qboolean horizontal) -{ - float dx, dy; - float xmul, ymul; - float weights[3] = { - 0.227027027f, - 0.316216216f, - 0.070270270f, - }; - float offsets[3] = { - 0.f, - 1.3846153846f, - 3.2307692308f, - }; - - xmul = horizontal; - ymul = 1.f - xmul; - - xmul *= strength; - ymul *= strength; - - { - ivec4_t srcBox, dstBox; - vec4_t color; - - VectorSet4(color, weights[0], weights[0], weights[0], 1.0f); - VectorSet4(srcBox, 0, 0, srcFbo->width, srcFbo->height); - VectorSet4(dstBox, 0, 0, dstFbo->width, dstFbo->height); - FBO_Blit(srcFbo, srcBox, NULL, dstFbo, dstBox, NULL, color, 0); - - VectorSet4(color, weights[1], weights[1], weights[1], 1.0f); - dx = offsets[1] * xmul; - dy = offsets[1] * ymul; - VectorSet4(srcBox, dx, dy, srcFbo->width, srcFbo->height); - FBO_Blit(srcFbo, srcBox, NULL, dstFbo, dstBox, NULL, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE); - VectorSet4(srcBox, -dx, -dy, srcFbo->width, srcFbo->height); - FBO_Blit(srcFbo, srcBox, NULL, dstFbo, dstBox, NULL, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE); - - VectorSet4(color, weights[2], weights[2], weights[2], 1.0f); - dx = offsets[2] * xmul; - dy = offsets[2] * ymul; - VectorSet4(srcBox, dx, dy, srcFbo->width, srcFbo->height); - FBO_Blit(srcFbo, srcBox, NULL, dstFbo, dstBox, NULL, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE); - VectorSet4(srcBox, -dx, -dy, srcFbo->width, srcFbo->height); - FBO_Blit(srcFbo, srcBox, NULL, dstFbo, dstBox, NULL, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE); - } -} - -static void RB_HBlur(FBO_t *srcFbo, FBO_t *dstFbo, float strength) -{ - RB_BlurAxis(srcFbo, dstFbo, strength, qtrue); -} - -static void RB_VBlur(FBO_t *srcFbo, FBO_t *dstFbo, float strength) -{ - RB_BlurAxis(srcFbo, dstFbo, strength, qfalse); -} - -void RB_GaussianBlur(float blur) -{ - //float mul = 1.f; - float factor = Com_Clamp(0.f, 1.f, blur); - - if (factor <= 0.f) - return; - - { - ivec4_t srcBox, dstBox; - vec4_t color; - - VectorSet4(color, 1, 1, 1, 1); - - // first, downsample the framebuffer - FBO_FastBlit(NULL, NULL, tr.quarterFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); - FBO_FastBlit(tr.quarterFbo[0], NULL, tr.textureScratchFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); - - // set the alpha channel - qglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); - FBO_BlitFromTexture(tr.whiteImage, NULL, NULL, tr.textureScratchFbo[0], NULL, NULL, color, GLS_DEPTHTEST_DISABLE); - qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - - // blur the tiny buffer horizontally and vertically - RB_HBlur(tr.textureScratchFbo[0], tr.textureScratchFbo[1], factor); - RB_VBlur(tr.textureScratchFbo[1], tr.textureScratchFbo[0], factor); - - // finally, merge back to framebuffer - VectorSet4(srcBox, 0, 0, tr.textureScratchFbo[0]->width, tr.textureScratchFbo[0]->height); - VectorSet4(dstBox, 0, 0, glConfig.vidWidth, glConfig.vidHeight); - color[3] = factor; - FBO_Blit(tr.textureScratchFbo[0], srcBox, NULL, NULL, dstBox, NULL, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); - } -} diff --git a/code/renderer2/tr_postprocess.h b/code/renderer2/tr_postprocess.h deleted file mode 100644 index 09daf13465..0000000000 --- a/code/renderer2/tr_postprocess.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2011 Andrei Drexler, Richard Allen, James Canete - -This file is part of Reaction source code. - -Reaction source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Reaction source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Reaction source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ - -#ifndef TR_POSTPROCESS_H -#define TR_POSTPROCESS_H - -#include "tr_fbo.h" - -void RB_ToneMap(FBO_t *hdrFbo, ivec4_t hdrBox, FBO_t *ldrFbo, ivec4_t ldrBox, int autoExposure); -void RB_BokehBlur(FBO_t *src, ivec4_t srcBox, FBO_t *dst, ivec4_t dstBox, float blur); -void RB_SunRays(FBO_t *srcFbo, ivec4_t srcBox, FBO_t *dstFbo, ivec4_t dstBox); -void RB_GaussianBlur(float blur); - -#endif diff --git a/code/renderer2/tr_scene.c b/code/renderer2/tr_scene.c deleted file mode 100644 index ee66f826ce..0000000000 --- a/code/renderer2/tr_scene.c +++ /dev/null @@ -1,574 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ - -#include "tr_local.h" - -static int r_firstSceneDrawSurf; - -static int r_numdlights; -static int r_firstSceneDlight; - -static int r_numentities; -static int r_firstSceneEntity; - -static int r_numpolys; -static int r_firstScenePoly; - -static int r_numpolyverts; - - -/* -==================== -R_InitNextFrame - -==================== -*/ -void R_InitNextFrame( void ) { - backEndData->commands.used = 0; - - r_firstSceneDrawSurf = 0; - - r_numdlights = 0; - r_firstSceneDlight = 0; - - r_numentities = 0; - r_firstSceneEntity = 0; - - r_numpolys = 0; - r_firstScenePoly = 0; - - r_numpolyverts = 0; -} - - -/* -==================== -RE_ClearScene - -==================== -*/ -void RE_ClearScene( void ) { - r_firstSceneDlight = r_numdlights; - r_firstSceneEntity = r_numentities; - r_firstScenePoly = r_numpolys; -} - -/* -=========================================================================== - -DISCRETE POLYS - -=========================================================================== -*/ - -/* -===================== -R_AddPolygonSurfaces - -Adds all the scene's polys into this view's drawsurf list -===================== -*/ -void R_AddPolygonSurfaces( void ) { - int i; - shader_t *sh; - const srfPoly_t *poly; - int fogMask; - - tr.currentEntityNum = REFENTITYNUM_WORLD; - tr.shiftedEntityNum = tr.currentEntityNum << QSORT_REFENTITYNUM_SHIFT; - fogMask = -((tr.refdef.rdflags & RDF_NOFOG) == 0); - - for ( i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys ; i++, poly++ ) { - sh = R_GetShaderByHandle( poly->hShader ); - R_AddDrawSurf( ( void * )poly, sh, poly->fogIndex & fogMask, qfalse, qfalse, 0 /*cubeMap*/ ); - } -} - -/* -===================== -RE_AddPolyToScene - -===================== -*/ -void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys ) { - srfPoly_t *poly; - int i, j; - int fogIndex; - const fog_t *fog; - vec3_t bounds[2]; - - if ( !tr.registered ) { - return; - } - - if ( !hShader ) { - // This isn't a useful warning, and an hShader of zero isn't a null shader, it's - // the default shader. - //ri.Printf( PRINT_WARNING, "WARNING: RE_AddPolyToScene: NULL poly shader\n"); - //return; - } - - for ( j = 0; j < numPolys; j++ ) { - if ( r_numpolyverts + numVerts > max_polyverts || r_numpolys >= max_polys ) { - /* - NOTE TTimo this was initially a PRINT_WARNING - but it happens a lot with high fighting scenes and particles - since we don't plan on changing the const and making for room for those effects - simply cut this message to developer only - */ - ri.Printf( PRINT_DEVELOPER, "WARNING: RE_AddPolyToScene: r_max_polys or r_max_polyverts reached\n"); - return; - } - - poly = &backEndData->polys[r_numpolys]; - poly->surfaceType = SF_POLY; - poly->hShader = hShader; - poly->numVerts = numVerts; - poly->verts = &backEndData->polyVerts[r_numpolyverts]; - - Com_Memcpy( poly->verts, &verts[numVerts*j], numVerts * sizeof( *verts ) ); - - if ( glConfig.hardwareType == GLHW_RAGEPRO ) { - poly->verts->modulate.rgba[0] = 255; - poly->verts->modulate.rgba[1] = 255; - poly->verts->modulate.rgba[2] = 255; - poly->verts->modulate.rgba[3] = 255; - } - // done. - r_numpolys++; - r_numpolyverts += numVerts; - - // if no world is loaded - if ( tr.world == NULL ) { - fogIndex = 0; - } - // see if it is in a fog volume - else if ( tr.world->numfogs == 1 ) { - fogIndex = 0; - } else { - // find which fog volume the poly is in - VectorCopy( poly->verts[0].xyz, bounds[0] ); - VectorCopy( poly->verts[0].xyz, bounds[1] ); - for ( i = 1 ; i < poly->numVerts ; i++ ) { - AddPointToBounds( poly->verts[i].xyz, bounds[0], bounds[1] ); - } - for ( fogIndex = 1 ; fogIndex < tr.world->numfogs ; fogIndex++ ) { - fog = &tr.world->fogs[fogIndex]; - if ( bounds[1][0] >= fog->bounds[0][0] - && bounds[1][1] >= fog->bounds[0][1] - && bounds[1][2] >= fog->bounds[0][2] - && bounds[0][0] <= fog->bounds[1][0] - && bounds[0][1] <= fog->bounds[1][1] - && bounds[0][2] <= fog->bounds[1][2] ) { - break; - } - } - if ( fogIndex == tr.world->numfogs ) { - fogIndex = 0; - } - } - poly->fogIndex = fogIndex; - } -} - - -//================================================================================= - - -/* -===================== -RE_AddRefEntityToScene - -===================== -*/ -void RE_AddRefEntityToScene( const refEntity_t *ent, qboolean intShaderTime ) { - vec3_t cross; - - if ( !tr.registered ) { - return; - } - if ( r_numentities >= MAX_REFENTITIES ) { - ri.Printf(PRINT_DEVELOPER, "RE_AddRefEntityToScene: Dropping refEntity, reached MAX_REFENTITIES\n"); - return; - } - if ( Q_isnan(ent->origin[0]) || Q_isnan(ent->origin[1]) || Q_isnan(ent->origin[2]) ) { - static qboolean firstTime = qtrue; - if (firstTime) { - firstTime = qfalse; - ri.Printf( PRINT_WARNING, "RE_AddRefEntityToScene passed a refEntity which has an origin with a NaN component\n"); - } - return; - } - if ( (int)ent->reType < 0 || ent->reType >= RT_MAX_REF_ENTITY_TYPE ) { - ri.Error( ERR_DROP, "RE_AddRefEntityToScene: bad reType %i", ent->reType ); - } - - backEndData->entities[r_numentities].e = *ent; - backEndData->entities[r_numentities].lightingCalculated = qfalse; - backEndData->entities[r_numentities].intShaderTime = intShaderTime; - - CrossProduct(ent->axis[0], ent->axis[1], cross); - backEndData->entities[r_numentities].mirrored = (DotProduct(ent->axis[2], cross) < 0.f); - - r_numentities++; -} - - -/* -===================== -RE_AddDynamicLightToScene - -===================== -*/ -static void RE_AddDynamicLightToScene( const vec3_t org, float intensity, float r, float g, float b, int additive ) { - dlight_t *dl; - - if ( !tr.registered ) { - return; - } - if ( r_numdlights >= MAX_DLIGHTS ) { - return; - } - if ( intensity <= 0 ) { - return; - } - // these cards don't have the correct blend mode - if ( glConfig.hardwareType == GLHW_RIVA128 || glConfig.hardwareType == GLHW_PERMEDIA2 ) { - return; - } - dl = &backEndData->dlights[r_numdlights++]; - VectorCopy (org, dl->origin); - dl->radius = intensity; - dl->color[0] = r; - dl->color[1] = g; - dl->color[2] = b; - dl->additive = additive; -} - -/* -===================== -RE_AddLightToScene - -===================== -*/ -void RE_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ) { - RE_AddDynamicLightToScene( org, intensity, r, g, b, qfalse ); -} - -/* -===================== -RE_AddAdditiveLightToScene - -===================== -*/ -void RE_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b ) { - RE_AddDynamicLightToScene( org, intensity, r, g, b, qtrue ); -} - - -void RE_BeginScene(const refdef_t *fd) -{ - Com_Memcpy( tr.refdef.text, fd->text, sizeof( tr.refdef.text ) ); - - tr.refdef.x = fd->x; - tr.refdef.y = fd->y; - tr.refdef.width = fd->width; - tr.refdef.height = fd->height; - tr.refdef.fov_x = fd->fov_x; - tr.refdef.fov_y = fd->fov_y; - - VectorCopy( fd->vieworg, tr.refdef.vieworg ); - VectorCopy( fd->viewaxis[0], tr.refdef.viewaxis[0] ); - VectorCopy( fd->viewaxis[1], tr.refdef.viewaxis[1] ); - VectorCopy( fd->viewaxis[2], tr.refdef.viewaxis[2] ); - - tr.refdef.time = fd->time; - tr.refdef.rdflags = fd->rdflags; - - // copy the areamask data over and note if it has changed, which - // will force a reset of the visible leafs even if the view hasn't moved - tr.refdef.areamaskModified = qfalse; - if ( ! (tr.refdef.rdflags & RDF_NOWORLDMODEL) ) { - int areaDiff; - int i; - - // compare the area bits - areaDiff = 0; - for ( i = 0; i < MAX_MAP_AREA_BYTES/sizeof(int); i++ ) { - areaDiff |= ((int *)tr.refdef.areamask)[i] ^ ((int *)fd->areamask)[i]; - ((int *)tr.refdef.areamask)[i] = ((int *)fd->areamask)[i]; - } - - if ( areaDiff ) { - // a door just opened or something - tr.refdef.areamaskModified = qtrue; - } - } - - tr.refdef.sunDir[3] = 0.0f; - tr.refdef.sunCol[3] = 1.0f; - tr.refdef.sunAmbCol[3] = 1.0f; - - VectorCopy(tr.sunDirection, tr.refdef.sunDir); - if ( (tr.refdef.rdflags & RDF_NOWORLDMODEL) || !(r_depthPrepass->value) ){ - VectorSet(tr.refdef.sunCol, 0, 0, 0); - VectorSet(tr.refdef.sunAmbCol, 0, 0, 0); - } - else - { - float scale = (1 << r_mapOverBrightBits->integer) / 255.0f; - - if (r_forceSun->integer) - VectorScale(tr.sunLight, scale * r_forceSunLightScale->value, tr.refdef.sunCol); - else - VectorScale(tr.sunLight, scale, tr.refdef.sunCol); - - if (r_sunlightMode->integer == 1) - { - tr.refdef.sunAmbCol[0] = - tr.refdef.sunAmbCol[1] = - tr.refdef.sunAmbCol[2] = r_forceSun->integer ? r_forceSunAmbientScale->value : tr.sunShadowScale; - } - else - { - if (r_forceSun->integer) - VectorScale(tr.sunLight, scale * r_forceSunAmbientScale->value, tr.refdef.sunAmbCol); - else - VectorScale(tr.sunLight, scale * tr.sunShadowScale, tr.refdef.sunAmbCol); - } - } - - if (r_forceAutoExposure->integer) - { - tr.refdef.autoExposureMinMax[0] = r_forceAutoExposureMin->value; - tr.refdef.autoExposureMinMax[1] = r_forceAutoExposureMax->value; - } - else - { - tr.refdef.autoExposureMinMax[0] = tr.autoExposureMinMax[0]; - tr.refdef.autoExposureMinMax[1] = tr.autoExposureMinMax[1]; - } - - if (r_forceToneMap->integer) - { - tr.refdef.toneMinAvgMaxLinear[0] = pow(2, r_forceToneMapMin->value); - tr.refdef.toneMinAvgMaxLinear[1] = pow(2, r_forceToneMapAvg->value); - tr.refdef.toneMinAvgMaxLinear[2] = pow(2, r_forceToneMapMax->value); - } - else - { - tr.refdef.toneMinAvgMaxLinear[0] = pow(2, tr.toneMinAvgMaxLevel[0]); - tr.refdef.toneMinAvgMaxLinear[1] = pow(2, tr.toneMinAvgMaxLevel[1]); - tr.refdef.toneMinAvgMaxLinear[2] = pow(2, tr.toneMinAvgMaxLevel[2]); - } - - // Makro - copy exta info if present - if (fd->rdflags & RDF_EXTRA) { - const refdefex_t* extra = (const refdefex_t*) (fd+1); - - tr.refdef.blurFactor = extra->blurFactor; - - if (fd->rdflags & RDF_SUNLIGHT) - { - VectorCopy(extra->sunDir, tr.refdef.sunDir); - VectorCopy(extra->sunCol, tr.refdef.sunCol); - VectorCopy(extra->sunAmbCol, tr.refdef.sunAmbCol); - } - } - else - { - tr.refdef.blurFactor = 0.0f; - } - - // derived info - - tr.refdef.floatTime = (double)tr.refdef.time * 0.001; // -EC-: cast to double - - tr.refdef.numDrawSurfs = r_firstSceneDrawSurf; - tr.refdef.drawSurfs = backEndData->drawSurfs; - - tr.refdef.num_entities = r_numentities - r_firstSceneEntity; - tr.refdef.entities = &backEndData->entities[r_firstSceneEntity]; - - tr.refdef.num_dlights = r_numdlights - r_firstSceneDlight; - tr.refdef.dlights = &backEndData->dlights[r_firstSceneDlight]; - - tr.refdef.numPolys = r_numpolys - r_firstScenePoly; - tr.refdef.polys = &backEndData->polys[r_firstScenePoly]; - - tr.refdef.num_pshadows = 0; - tr.refdef.pshadows = &backEndData->pshadows[0]; - - // turn off dynamic lighting globally by clearing all the - // dlights if it needs to be disabled or if vertex lighting is enabled - if ( r_dynamiclight->integer == 0 || - r_vertexLight->integer == 1 || - glConfig.hardwareType == GLHW_PERMEDIA2 ) { - tr.refdef.num_dlights = 0; - } - - // a single frame may have multiple scenes draw inside it -- - // a 3D game view, 3D status bar renderings, 3D menus, etc. - // They need to be distinguished by the light flare code, because - // the visibility state for a given surface may be different in - // each scene / view. - tr.frameSceneNum++; - tr.sceneCount++; -} - - -void RE_EndScene(void) -{ - // the next scene rendered in this frame will tack on after this one - r_firstSceneDrawSurf = tr.refdef.numDrawSurfs; - r_firstSceneEntity = r_numentities; - r_firstSceneDlight = r_numdlights; - r_firstScenePoly = r_numpolys; -} - -/* -@@@@@@@@@@@@@@@@@@@@@ -RE_RenderScene - -Draw a 3D view into a part of the window, then return -to 2D drawing. - -Rendering a scene may require multiple views to be rendered -to handle mirrors, -@@@@@@@@@@@@@@@@@@@@@ -*/ -void RE_RenderScene( const refdef_t *fd ) { - viewParms_t parms; - int startTime; - - if ( !tr.registered ) { - return; - } -// GLimp_LogComment( "====== RE_RenderScene =====\n" ); - - if ( r_norefresh->integer ) { - return; - } - - startTime = ri.Milliseconds(); - - if (!tr.world && !( fd->rdflags & RDF_NOWORLDMODEL ) ) { - ri.Error (ERR_DROP, "R_RenderScene: NULL worldmodel"); - } - - RE_BeginScene(fd); - - // SmileTheory: playing with shadow mapping - if (!( fd->rdflags & RDF_NOWORLDMODEL ) && tr.refdef.num_dlights && r_dlightMode->integer >= 2) - { - R_RenderDlightCubemaps(fd); - } - - /* playing with more shadows */ - if(glRefConfig.framebufferObject && !( fd->rdflags & RDF_NOWORLDMODEL ) && r_shadows->integer == 4) - { - R_RenderPshadowMaps(fd); - } - - // playing with even more shadows - if(glRefConfig.framebufferObject && r_sunlightMode->integer && !( fd->rdflags & RDF_NOWORLDMODEL ) && (r_forceSun->integer || tr.sunShadows)) - { - if (r_shadowCascadeZFar->integer != 0) - { - R_RenderSunShadowMaps(fd, 0); - R_RenderSunShadowMaps(fd, 1); - R_RenderSunShadowMaps(fd, 2); - } - else - { - Mat4Zero(tr.refdef.sunShadowMvp[0]); - Mat4Zero(tr.refdef.sunShadowMvp[1]); - Mat4Zero(tr.refdef.sunShadowMvp[2]); - } - - // only rerender last cascade if sun has changed position - if (r_forceSun->integer == 2 || !VectorCompare(tr.refdef.sunDir, tr.lastCascadeSunDirection)) - { - VectorCopy(tr.refdef.sunDir, tr.lastCascadeSunDirection); - R_RenderSunShadowMaps(fd, 3); - Mat4Copy(tr.refdef.sunShadowMvp[3], tr.lastCascadeSunMvp); - } - else - { - Mat4Copy(tr.lastCascadeSunMvp, tr.refdef.sunShadowMvp[3]); - } - } - - // playing with cube maps - // this is where dynamic cubemaps would be rendered - if (0) //(glRefConfig.framebufferObject && !( fd->rdflags & RDF_NOWORLDMODEL )) - { - int i, j; - - for (i = 0; i < tr.numCubemaps; i++) - { - for (j = 0; j < 6; j++) - { - R_RenderCubemapSide(i, j, qtrue); - } - } - } - - // setup view parms for the initial view - // - // set up viewport - // The refdef takes 0-at-the-top y coordinates, so - // convert to GL's 0-at-the-bottom space - // - Com_Memset( &parms, 0, sizeof( parms ) ); - parms.viewportX = tr.refdef.x; - parms.viewportY = glConfig.vidHeight - ( tr.refdef.y + tr.refdef.height ); - parms.viewportWidth = tr.refdef.width; - parms.viewportHeight = tr.refdef.height; - parms.isPortal = qfalse; - - parms.fovX = tr.refdef.fov_x; - parms.fovY = tr.refdef.fov_y; - - parms.stereoFrame = tr.refdef.stereoFrame; - - VectorCopy( fd->vieworg, parms.or.origin ); - VectorCopy( fd->viewaxis[0], parms.or.axis[0] ); - VectorCopy( fd->viewaxis[1], parms.or.axis[1] ); - VectorCopy( fd->viewaxis[2], parms.or.axis[2] ); - - VectorCopy( fd->vieworg, parms.pvsOrigin ); - - if(!( fd->rdflags & RDF_NOWORLDMODEL ) && r_depthPrepass->value && ((r_forceSun->integer) || tr.sunShadows)) - { - parms.flags = VPF_USESUNLIGHT; - } - - R_RenderView( &parms ); - - if(!( fd->rdflags & RDF_NOWORLDMODEL )) - R_AddPostProcessCmd(); - - RE_EndScene(); - - tr.frontEndMsec += ri.Milliseconds() - startTime; -} diff --git a/code/renderer2/tr_shade.c b/code/renderer2/tr_shade.c deleted file mode 100644 index 66eda017e5..0000000000 --- a/code/renderer2/tr_shade.c +++ /dev/null @@ -1,1668 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_shade.c - -#include "tr_local.h" -#if idppc_altivec && !defined(__APPLE__) -#include -#endif - -/* - - THIS ENTIRE FILE IS BACK END - - This file deals with applying shaders to surface data in the tess struct. -*/ - - -/* -================== -R_DrawElements - -================== -*/ - -void R_DrawElements( int numIndexes, glIndex_t firstIndex) -{ - qglDrawElements(GL_TRIANGLES, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(glIndex_t))); -} - - -/* -============================================================= - -SURFACE SHADERS - -============================================================= -*/ - -shaderCommands_t tess; - - -/* -================= -R_BindAnimatedImageToTMU - -================= -*/ -static void R_BindAnimatedImageToTMU( const textureBundle_t *bundle, int tmu ) { - int64_t index; - double v; - - if ( bundle->isVideoMap ) { - ri.CIN_RunCinematic(bundle->videoMapHandle); - ri.CIN_UploadCinematic(bundle->videoMapHandle); - GL_BindToTMU(tr.scratchImage[bundle->videoMapHandle], tmu); - return; - } - - if ( bundle->numImageAnimations <= 1 ) { - GL_BindToTMU( bundle->image[0], tmu); - return; - } - - // it is necessary to do this messy calc to make sure animations line up - // exactly with waveforms of the same frequency - //index = myftol(tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE); - //index >>= FUNCTABLE_SIZE2; - v = tess.shaderTime * bundle->imageAnimationSpeed; // fix for frameloss bug -EC- - index = v; - - if ( index < 0 ) { - index = 0; // may happen with shader time offsets - } - index %= bundle->numImageAnimations; - - GL_BindToTMU( bundle->image[ index ], tmu ); -} - - -/* -================ -DrawTris - -Draws triangle outlines for debugging -================ -*/ -static void DrawTris (const shaderCommands_t *input) { - GL_BindToTMU( tr.whiteImage, TB_COLORMAP ); - - GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE ); - qglDepthRange( 0, 0 ); - - { - shaderProgram_t *sp = &tr.textureColorShader; - vec4_t color; - - GLSL_BindProgram(sp); - - GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - VectorSet4(color, 1, 1, 1, 1); - GLSL_SetUniformVec4(sp, UNIFORM_COLOR, color); - GLSL_SetUniformInt(sp, UNIFORM_ALPHATEST, 0); - - R_DrawElements(input->numIndexes, input->firstIndex); - } - - qglDepthRange( 0, 1 ); -} - - -/* -================ -DrawNormals - -Draws vertex normals for debugging -================ -*/ -static void DrawNormals (const shaderCommands_t *input) { - //FIXME: implement this -} - -/* -============== -RB_BeginSurface - -We must set some things up before beginning any tesselation, -because a surface may be forced to perform a RB_End due -to overflow. -============== -*/ -void RB_BeginSurface( shader_t *shader, int fogNum, int cubemapIndex ) { - - shader_t *state = (shader->remappedShader) ? shader->remappedShader : shader; - - tess.numIndexes = 0; - tess.firstIndex = 0; - tess.numVertexes = 0; - tess.shader = state; - tess.fogNum = fogNum; - tess.cubemapIndex = cubemapIndex; - tess.dlightBits = 0; // will be OR'd in by surface functions - tess.pshadowBits = 0; // will be OR'd in by surface functions - tess.xstages = state->stages; - tess.numPasses = state->numUnfoggedPasses; - tess.currentStageIteratorFunc = state->optimalStageIteratorFunc; - tess.useInternalVao = qtrue; - tess.useCacheVao = qfalse; - - tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; - if (tess.shader->clampTime && tess.shaderTime >= tess.shader->clampTime) { - tess.shaderTime = tess.shader->clampTime; - } - - if (backEnd.viewParms.flags & VPF_SHADOWMAP) - { - tess.currentStageIteratorFunc = RB_StageIteratorGeneric; - } -} - - - -extern float EvalWaveForm( const waveForm_t *wf ); -extern float EvalWaveFormClamped( const waveForm_t *wf ); - - -static void ComputeTexMods( shaderStage_t *pStage, int bundleNum, float *outMatrix, float *outOffTurb) -{ - int tm; - float matrix[6], currentmatrix[6]; - textureBundle_t *bundle = &pStage->bundle[bundleNum]; - - matrix[0] = 1.0f; matrix[2] = 0.0f; matrix[4] = 0.0f; - matrix[1] = 0.0f; matrix[3] = 1.0f; matrix[5] = 0.0f; - - currentmatrix[0] = 1.0f; currentmatrix[2] = 0.0f; currentmatrix[4] = 0.0f; - currentmatrix[1] = 0.0f; currentmatrix[3] = 1.0f; currentmatrix[5] = 0.0f; - - outMatrix[0] = 1.0f; outMatrix[2] = 0.0f; - outMatrix[1] = 0.0f; outMatrix[3] = 1.0f; - - outOffTurb[0] = 0.0f; outOffTurb[1] = 0.0f; outOffTurb[2] = 0.0f; outOffTurb[3] = 0.0f; - - for ( tm = 0; tm < bundle->numTexMods ; tm++ ) { - switch ( bundle->texMods[tm].type ) - { - - case TMOD_NONE: - tm = TR_MAX_TEXMODS; // break out of for loop - break; - - case TMOD_TURBULENT: - RB_CalcTurbulentFactors(&bundle->texMods[tm].wave, &outOffTurb[2], &outOffTurb[3]); - break; - - case TMOD_ENTITY_TRANSLATE: - RB_CalcScrollTexMatrix( backEnd.currentEntity->e.shaderTexCoord, matrix ); - break; - - case TMOD_SCROLL: - RB_CalcScrollTexMatrix( bundle->texMods[tm].scroll, - matrix ); - break; - - case TMOD_SCALE: - RB_CalcScaleTexMatrix( bundle->texMods[tm].scale, - matrix ); - break; - - case TMOD_STRETCH: - RB_CalcStretchTexMatrix( &bundle->texMods[tm].wave, - matrix ); - break; - - case TMOD_TRANSFORM: - RB_CalcTransformTexMatrix( &bundle->texMods[tm], - matrix ); - break; - - case TMOD_ROTATE: - RB_CalcRotateTexMatrix( bundle->texMods[tm].rotateSpeed, - matrix ); - break; - - default: - ri.Error( ERR_DROP, "ERROR: unknown texmod '%d' in shader '%s'", bundle->texMods[tm].type, tess.shader->name ); - break; - } - - switch ( bundle->texMods[tm].type ) - { - case TMOD_NONE: - case TMOD_TURBULENT: - default: - break; - - case TMOD_ENTITY_TRANSLATE: - case TMOD_SCROLL: - case TMOD_SCALE: - case TMOD_STRETCH: - case TMOD_TRANSFORM: - case TMOD_ROTATE: - outMatrix[0] = matrix[0] * currentmatrix[0] + matrix[2] * currentmatrix[1]; - outMatrix[1] = matrix[1] * currentmatrix[0] + matrix[3] * currentmatrix[1]; - - outMatrix[2] = matrix[0] * currentmatrix[2] + matrix[2] * currentmatrix[3]; - outMatrix[3] = matrix[1] * currentmatrix[2] + matrix[3] * currentmatrix[3]; - - outOffTurb[0] = matrix[0] * currentmatrix[4] + matrix[2] * currentmatrix[5] + matrix[4]; - outOffTurb[1] = matrix[1] * currentmatrix[4] + matrix[3] * currentmatrix[5] + matrix[5]; - - currentmatrix[0] = outMatrix[0]; - currentmatrix[1] = outMatrix[1]; - currentmatrix[2] = outMatrix[2]; - currentmatrix[3] = outMatrix[3]; - currentmatrix[4] = outOffTurb[0]; - currentmatrix[5] = outOffTurb[1]; - break; - } - } -} - - -static void ComputeDeformValues(int *deformGen, vec5_t deformParams) -{ - // u_DeformGen - *deformGen = DGEN_NONE; - if(!ShaderRequiresCPUDeforms(tess.shader)) - { - deformStage_t *ds; - - // only support the first one - ds = &tess.shader->deforms[0]; - - switch (ds->deformation) - { - case DEFORM_WAVE: - *deformGen = ds->deformationWave.func; - - deformParams[0] = ds->deformationWave.base; - deformParams[1] = ds->deformationWave.amplitude; - deformParams[2] = ds->deformationWave.phase; - deformParams[3] = ds->deformationWave.frequency; - deformParams[4] = ds->deformationSpread; - break; - - case DEFORM_BULGE: - *deformGen = DGEN_BULGE; - - deformParams[0] = 0; - deformParams[1] = ds->bulgeHeight; // amplitude - deformParams[2] = ds->bulgeWidth; // phase - deformParams[3] = ds->bulgeSpeed; // frequency - deformParams[4] = 0; - break; - - default: - break; - } - } -} - - -static void ProjectDlightTexture( void ) { - int l; - vec3_t origin; - float scale; - float radius; - int deformGen; - vec5_t deformParams; - - if ( !backEnd.refdef.num_dlights ) { - return; - } - - ComputeDeformValues(&deformGen, deformParams); - - for ( l = 0 ; l < backEnd.refdef.num_dlights ; l++ ) { - const dlight_t *dl; - shaderProgram_t *sp; - vec4_t vector; - - if ( !( tess.dlightBits & ( 1 << l ) ) ) { - continue; // this surface definitely doesn't have any of this light - } - - dl = &backEnd.refdef.dlights[l]; - VectorCopy( dl->transformed, origin ); - radius = dl->radius; - scale = 1.0f / radius; - - sp = &tr.dlightShader[deformGen == DGEN_NONE ? 0 : 1]; - - backEnd.pc.c_dlightDraws++; - - GLSL_BindProgram(sp); - - GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - - GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - - GLSL_SetUniformInt(sp, UNIFORM_DEFORMGEN, deformGen); - if (deformGen != DGEN_NONE) - { - GLSL_SetUniformFloat5(sp, UNIFORM_DEFORMPARAMS, deformParams); - GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); - } - - vector[0] = dl->color[0]; - vector[1] = dl->color[1]; - vector[2] = dl->color[2]; - vector[3] = 1.0f; - GLSL_SetUniformVec4(sp, UNIFORM_COLOR, vector); - - vector[0] = origin[0]; - vector[1] = origin[1]; - vector[2] = origin[2]; - vector[3] = scale; - GLSL_SetUniformVec4(sp, UNIFORM_DLIGHTINFO, vector); - - GL_BindToTMU( tr.dlightImage, TB_COLORMAP ); - - // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light - // where they aren't rendered - if ( dl->additive ) { - GL_State( GLS_ATEST_GT_0 | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL ); - } - else { - GL_State( GLS_ATEST_GT_0 | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL ); - } - - GLSL_SetUniformInt(sp, UNIFORM_ALPHATEST, 1); - - R_DrawElements(tess.numIndexes, tess.firstIndex); - - backEnd.pc.c_totalIndexes += tess.numIndexes; - backEnd.pc.c_dlightIndexes += tess.numIndexes; - backEnd.pc.c_dlightVertexes += tess.numVertexes; - } -} - - -static void ComputeShaderColors( const shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor, int blend ) -{ - qboolean isBlend = ((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_DST_COLOR) - || ((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_ONE_MINUS_DST_COLOR) - || ((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_SRC_COLOR) - || ((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_ONE_MINUS_SRC_COLOR); - - qboolean is2DDraw = backEnd.currentEntity == &backEnd.entity2D; - - float overbright = (isBlend || is2DDraw) ? 1.0f : (float)(1 << tr.overbrightBits); - - const fog_t *fog; - - baseColor[0] = - baseColor[1] = - baseColor[2] = - baseColor[3] = 1.0f; - - vertColor[0] = - vertColor[1] = - vertColor[2] = - vertColor[3] = 0.0f; - - // - // rgbGen - // - switch ( pStage->rgbGen ) - { - case CGEN_EXACT_VERTEX: - case CGEN_EXACT_VERTEX_LIT: - baseColor[0] = - baseColor[1] = - baseColor[2] = - baseColor[3] = 0.0f; - - vertColor[0] = - vertColor[1] = - vertColor[2] = overbright; - vertColor[3] = 1.0f; - break; - case CGEN_CONST: - baseColor[0] = pStage->constantColor[0] / 255.0f; - baseColor[1] = pStage->constantColor[1] / 255.0f; - baseColor[2] = pStage->constantColor[2] / 255.0f; - baseColor[3] = pStage->constantColor[3] / 255.0f; - break; - case CGEN_VERTEX: - case CGEN_VERTEX_LIT: - baseColor[0] = - baseColor[1] = - baseColor[2] = - baseColor[3] = 0.0f; - - vertColor[0] = - vertColor[1] = - vertColor[2] = - vertColor[3] = 1.0f; - break; - case CGEN_ONE_MINUS_VERTEX: - baseColor[0] = - baseColor[1] = - baseColor[2] = 1.0f; - - vertColor[0] = - vertColor[1] = - vertColor[2] = -1.0f; - break; - case CGEN_FOG: - fog = tr.world->fogs + tess.fogNum; - - baseColor[0] = ((unsigned char *)(&fog->colorInt))[0] / 255.0f; - baseColor[1] = ((unsigned char *)(&fog->colorInt))[1] / 255.0f; - baseColor[2] = ((unsigned char *)(&fog->colorInt))[2] / 255.0f; - baseColor[3] = ((unsigned char *)(&fog->colorInt))[3] / 255.0f; - break; - case CGEN_WAVEFORM: - baseColor[0] = - baseColor[1] = - baseColor[2] = RB_CalcWaveColorSingle( &pStage->rgbWave ); - break; - case CGEN_ENTITY: - if (backEnd.currentEntity) - { - baseColor[0] = backEnd.currentEntity->e.shader.rgba[0] / 255.0f; - baseColor[1] = backEnd.currentEntity->e.shader.rgba[1] / 255.0f; - baseColor[2] = backEnd.currentEntity->e.shader.rgba[2] / 255.0f; - baseColor[3] = backEnd.currentEntity->e.shader.rgba[3] / 255.0f; - } - break; - case CGEN_ONE_MINUS_ENTITY: - if (backEnd.currentEntity) - { - baseColor[0] = 1.0f - backEnd.currentEntity->e.shader.rgba[0] / 255.0f; - baseColor[1] = 1.0f - backEnd.currentEntity->e.shader.rgba[1] / 255.0f; - baseColor[2] = 1.0f - backEnd.currentEntity->e.shader.rgba[2] / 255.0f; - baseColor[3] = 1.0f - backEnd.currentEntity->e.shader.rgba[3] / 255.0f; - } - break; - case CGEN_IDENTITY: - case CGEN_LIGHTING_DIFFUSE: - baseColor[0] = - baseColor[1] = - baseColor[2] = overbright; - break; - case CGEN_IDENTITY_LIGHTING: - case CGEN_BAD: - break; - } - - // - // alphaGen - // - switch ( pStage->alphaGen ) - { - case AGEN_SKIP: - break; - case AGEN_CONST: - baseColor[3] = pStage->constantColor[3] / 255.0f; - vertColor[3] = 0.0f; - break; - case AGEN_WAVEFORM: - baseColor[3] = RB_CalcWaveAlphaSingle( &pStage->alphaWave ); - vertColor[3] = 0.0f; - break; - case AGEN_ENTITY: - if (backEnd.currentEntity) - { - baseColor[3] = backEnd.currentEntity->e.shader.rgba[3] / 255.0f; - } - vertColor[3] = 0.0f; - break; - case AGEN_ONE_MINUS_ENTITY: - if (backEnd.currentEntity) - { - baseColor[3] = 1.0f - backEnd.currentEntity->e.shader.rgba[3] / 255.0f; - } - vertColor[3] = 0.0f; - break; - case AGEN_VERTEX: - baseColor[3] = 0.0f; - vertColor[3] = 1.0f; - break; - case AGEN_ONE_MINUS_VERTEX: - baseColor[3] = 1.0f; - vertColor[3] = -1.0f; - break; - case AGEN_IDENTITY: - case AGEN_LIGHTING_SPECULAR: - case AGEN_PORTAL: - // Done entirely in vertex program - baseColor[3] = 1.0f; - vertColor[3] = 0.0f; - break; - } - - // FIXME: find some way to implement this. -#if 0 - // if in greyscale rendering mode turn all color values into greyscale. - if(r_greyscale->integer) - { - int scale; - - for(i = 0; i < tess.numVertexes; i++) - { - scale = (tess.svars.colors[i][0] + tess.svars.colors[i][1] + tess.svars.colors[i][2]) / 3; - tess.svars.colors[i][0] = tess.svars.colors[i][1] = tess.svars.colors[i][2] = scale; - } - } -#endif -} - - -static void ComputeFogValues(vec4_t fogDistanceVector, vec4_t fogDepthVector, float *eyeT) -{ - // from RB_CalcFogTexCoords() - const fog_t *fog; - vec3_t local; - - if (!tess.fogNum) - return; - - fog = tr.world->fogs + tess.fogNum; - - VectorSubtract( backEnd.or.origin, backEnd.viewParms.or.origin, local ); - fogDistanceVector[0] = -backEnd.or.modelMatrix[2]; - fogDistanceVector[1] = -backEnd.or.modelMatrix[6]; - fogDistanceVector[2] = -backEnd.or.modelMatrix[10]; - fogDistanceVector[3] = DotProduct( local, backEnd.viewParms.or.axis[0] ); - - // scale the fog vectors based on the fog's thickness - VectorScale4(fogDistanceVector, fog->tcScale, fogDistanceVector); - - // rotate the gradient vector for this orientation - if ( fog->hasSurface ) { - fogDepthVector[0] = fog->surface[0] * backEnd.or.axis[0][0] + - fog->surface[1] * backEnd.or.axis[0][1] + fog->surface[2] * backEnd.or.axis[0][2]; - fogDepthVector[1] = fog->surface[0] * backEnd.or.axis[1][0] + - fog->surface[1] * backEnd.or.axis[1][1] + fog->surface[2] * backEnd.or.axis[1][2]; - fogDepthVector[2] = fog->surface[0] * backEnd.or.axis[2][0] + - fog->surface[1] * backEnd.or.axis[2][1] + fog->surface[2] * backEnd.or.axis[2][2]; - fogDepthVector[3] = -fog->surface[3] + DotProduct( backEnd.or.origin, fog->surface ); - - *eyeT = DotProduct( backEnd.or.viewOrigin, fogDepthVector ) + fogDepthVector[3]; - } else { - *eyeT = 1; // non-surface fog always has eye inside - } -} - - -static void ComputeFogColorMask( const shaderStage_t *pStage, vec4_t fogColorMask ) -{ - switch(pStage->adjustColorsForFog) - { - case ACFF_MODULATE_RGB: - fogColorMask[0] = - fogColorMask[1] = - fogColorMask[2] = 1.0f; - fogColorMask[3] = 0.0f; - break; - case ACFF_MODULATE_ALPHA: - fogColorMask[0] = - fogColorMask[1] = - fogColorMask[2] = 0.0f; - fogColorMask[3] = 1.0f; - break; - case ACFF_MODULATE_RGBA: - fogColorMask[0] = - fogColorMask[1] = - fogColorMask[2] = - fogColorMask[3] = 1.0f; - break; - default: - fogColorMask[0] = - fogColorMask[1] = - fogColorMask[2] = - fogColorMask[3] = 0.0f; - break; - } -} - - -static void ForwardDlight( void ) { - int l; - //vec3_t origin; - //float scale; - float radius; - - int deformGen; - vec5_t deformParams; - - vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; - float eyeT = 0; - - const shaderCommands_t *input = &tess; - shaderStage_t *pStage = tess.xstages[ tess.shader->lightingStage ]; - - if ( !backEnd.refdef.num_dlights ) { - return; - } - - ComputeDeformValues(&deformGen, deformParams); - - ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); - - for ( l = 0 ; l < backEnd.refdef.num_dlights ; l++ ) { - const dlight_t *dl; - shaderProgram_t *sp; - vec4_t vector; - vec4_t texMatrix; - vec4_t texOffTurb; - - if ( !( tess.dlightBits & ( 1 << l ) ) ) { - continue; // this surface definitely doesn't have any of this light - } - - dl = &backEnd.refdef.dlights[l]; - //VectorCopy( dl->transformed, origin ); - radius = dl->radius; - //scale = 1.0f / radius; - - //if (pStage->glslShaderGroup == tr.lightallShader) - { - int index = pStage->glslShaderIndex; - - index &= ~LIGHTDEF_LIGHTTYPE_MASK; - index |= LIGHTDEF_USE_LIGHT_VECTOR; - - sp = &tr.lightallShader[index]; - } - - backEnd.pc.c_lightallDraws++; - - GLSL_BindProgram(sp); - - GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.or.origin); - GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.or.viewOrigin); - - GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - - GLSL_SetUniformInt(sp, UNIFORM_DEFORMGEN, deformGen); - if (deformGen != DGEN_NONE) - { - GLSL_SetUniformFloat5(sp, UNIFORM_DEFORMPARAMS, deformParams); - GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); - } - - if ( input->fogNum ) { - vec4_t fogColorMask; - - GLSL_SetUniformVec4(sp, UNIFORM_FOGDISTANCE, fogDistanceVector); - GLSL_SetUniformVec4(sp, UNIFORM_FOGDEPTH, fogDepthVector); - GLSL_SetUniformFloat(sp, UNIFORM_FOGEYET, eyeT); - - ComputeFogColorMask(pStage, fogColorMask); - - GLSL_SetUniformVec4(sp, UNIFORM_FOGCOLORMASK, fogColorMask); - } - - { - vec4_t baseColor; - vec4_t vertColor; - - ComputeShaderColors(pStage, baseColor, vertColor, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE); - - GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, baseColor); - GLSL_SetUniformVec4(sp, UNIFORM_VERTCOLOR, vertColor); - } - - if (pStage->alphaGen == AGEN_PORTAL) - { - GLSL_SetUniformFloat(sp, UNIFORM_PORTALRANGE, tess.shader->portalRange); - } - - GLSL_SetUniformInt(sp, UNIFORM_COLORGEN, pStage->rgbGen); - GLSL_SetUniformInt(sp, UNIFORM_ALPHAGEN, pStage->alphaGen); - - GLSL_SetUniformVec3(sp, UNIFORM_DIRECTEDLIGHT, dl->color); - - VectorSet(vector, 0, 0, 0); - GLSL_SetUniformVec3(sp, UNIFORM_AMBIENTLIGHT, vector); - - VectorCopy(dl->origin, vector); - vector[3] = 1.0f; - GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vector); - - GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, radius); - - GLSL_SetUniformVec4(sp, UNIFORM_NORMALSCALE, pStage->normalScale); - GLSL_SetUniformVec4(sp, UNIFORM_SPECULARSCALE, pStage->specularScale); - - // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light - // where they aren't rendered - GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL ); - GLSL_SetUniformInt(sp, UNIFORM_ALPHATEST, 0); - - GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix); - - if (pStage->bundle[TB_DIFFUSEMAP].image[0]) - R_BindAnimatedImageToTMU( &pStage->bundle[TB_DIFFUSEMAP], TB_DIFFUSEMAP); - - // bind textures that are sampled and used in the glsl shader, and - // bind whiteImage to textures that are sampled but zeroed in the glsl shader - // - // alternatives: - // - use the last bound texture - // -> costs more to sample a higher res texture then throw out the result - // - disable texture sampling in glsl shader with #ifdefs, as before - // -> increases the number of shaders that must be compiled - // - - if (pStage->bundle[TB_NORMALMAP].image[0]) - { - R_BindAnimatedImageToTMU( &pStage->bundle[TB_NORMALMAP], TB_NORMALMAP); - } - else if (r_normalMapping->integer) - GL_BindToTMU( tr.whiteImage, TB_NORMALMAP ); - - if (pStage->bundle[TB_SPECULARMAP].image[0]) - { - R_BindAnimatedImageToTMU( &pStage->bundle[TB_SPECULARMAP], TB_SPECULARMAP); - } - else if (r_specularMapping->integer) - GL_BindToTMU( tr.whiteImage, TB_SPECULARMAP ); - - { - vec4_t enableTextures; - - VectorSet4(enableTextures, 0.0f, 0.0f, 0.0f, 0.0f); - GLSL_SetUniformVec4(sp, UNIFORM_ENABLETEXTURES, enableTextures); - } - - if (r_dlightMode->integer >= 2) - GL_BindToTMU(tr.shadowCubemaps[l], TB_SHADOWMAP); - - ComputeTexMods( pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb ); - GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXMATRIX, texMatrix); - GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXOFFTURB, texOffTurb); - - GLSL_SetUniformInt(sp, UNIFORM_TCGEN0, pStage->bundle[0].tcGen); - - // - // draw - // - - R_DrawElements(input->numIndexes, input->firstIndex); - - backEnd.pc.c_totalIndexes += tess.numIndexes; - backEnd.pc.c_dlightIndexes += tess.numIndexes; - backEnd.pc.c_dlightVertexes += tess.numVertexes; - } -} - - -static void ProjectPshadowVBOGLSL( void ) { - int l; - vec3_t origin; - float radius; - - int deformGen; - vec5_t deformParams; - - const shaderCommands_t *input = &tess; - - if ( !backEnd.refdef.num_pshadows ) { - return; - } - - ComputeDeformValues(&deformGen, deformParams); - - for ( l = 0 ; l < backEnd.refdef.num_pshadows ; l++ ) { - pshadow_t *ps; - shaderProgram_t *sp; - vec4_t vector; - - if ( !( tess.pshadowBits & ( 1 << l ) ) ) { - continue; // this surface definitely doesn't have any of this shadow - } - - ps = &backEnd.refdef.pshadows[l]; - VectorCopy( ps->lightOrigin, origin ); - radius = ps->lightRadius; - - sp = &tr.pshadowShader; - - GLSL_BindProgram(sp); - - GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - - VectorCopy(origin, vector); - vector[3] = 1.0f; - GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vector); - - VectorScale(ps->lightViewAxis[0], 1.0f / ps->viewRadius, vector); - GLSL_SetUniformVec3(sp, UNIFORM_LIGHTFORWARD, vector); - - VectorScale(ps->lightViewAxis[1], 1.0f / ps->viewRadius, vector); - GLSL_SetUniformVec3(sp, UNIFORM_LIGHTRIGHT, vector); - - VectorScale(ps->lightViewAxis[2], 1.0f / ps->viewRadius, vector); - GLSL_SetUniformVec3(sp, UNIFORM_LIGHTUP, vector); - - GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, radius); - - // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light - // where they aren't rendered - GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL ); - GLSL_SetUniformInt(sp, UNIFORM_ALPHATEST, 0); - - GL_BindToTMU( tr.pshadowMaps[l], TB_DIFFUSEMAP ); - - // - // draw - // - - R_DrawElements(input->numIndexes, input->firstIndex); - - backEnd.pc.c_totalIndexes += tess.numIndexes; - //backEnd.pc.c_dlightIndexes += tess.numIndexes; - } -} - - - -/* -=================== -RB_FogPass - -Blends a fog texture on top of everything else -=================== -*/ -static void RB_FogPass( void ) { - const fog_t *fog; - vec4_t color; - vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; - float eyeT = 0; - shaderProgram_t *sp; - - int deformGen; - vec5_t deformParams; - - ComputeDeformValues(&deformGen, deformParams); - - { - int index = 0; - - if (deformGen != DGEN_NONE) - index |= FOGDEF_USE_DEFORM_VERTEXES; - - if (glState.vertexAnimation) - index |= FOGDEF_USE_VERTEX_ANIMATION; - else if (glState.boneAnimation) - index |= FOGDEF_USE_BONE_ANIMATION; - - sp = &tr.fogShader[index]; - } - - backEnd.pc.c_fogDraws++; - - GLSL_BindProgram(sp); - - fog = tr.world->fogs + tess.fogNum; - - GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - - GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - - if (glState.boneAnimation) - { - GLSL_SetUniformMat4BoneMatrix(sp, UNIFORM_BONEMATRIX, glState.boneMatrix, glState.boneAnimation); - } - - GLSL_SetUniformInt(sp, UNIFORM_DEFORMGEN, deformGen); - if (deformGen != DGEN_NONE) - { - GLSL_SetUniformFloat5(sp, UNIFORM_DEFORMPARAMS, deformParams); - GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); - } - - color[0] = ((unsigned char *)(&fog->colorInt))[0] / 255.0f; - color[1] = ((unsigned char *)(&fog->colorInt))[1] / 255.0f; - color[2] = ((unsigned char *)(&fog->colorInt))[2] / 255.0f; - color[3] = ((unsigned char *)(&fog->colorInt))[3] / 255.0f; - GLSL_SetUniformVec4(sp, UNIFORM_COLOR, color); - - ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); - - GLSL_SetUniformVec4(sp, UNIFORM_FOGDISTANCE, fogDistanceVector); - GLSL_SetUniformVec4(sp, UNIFORM_FOGDEPTH, fogDepthVector); - GLSL_SetUniformFloat(sp, UNIFORM_FOGEYET, eyeT); - - if ( tess.shader->fogPass == FP_EQUAL ) { - GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL ); - } else { - GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); - } - GLSL_SetUniformInt(sp, UNIFORM_ALPHATEST, 0); - - R_DrawElements(tess.numIndexes, tess.firstIndex); -} - - -static unsigned int RB_CalcShaderVertexAttribs( const shaderCommands_t *input ) -{ - unsigned int vertexAttribs = input->shader->vertexAttribs; - - if(glState.vertexAnimation) - { - vertexAttribs |= ATTR_POSITION2; - if (vertexAttribs & ATTR_NORMAL) - { - vertexAttribs |= ATTR_NORMAL2; - vertexAttribs |= ATTR_TANGENT2; - } - } - - return vertexAttribs; -} - -static void RB_IterateStagesGeneric( const shaderCommands_t *input ) -{ - int stage; - - vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; - float eyeT = 0; - - int deformGen; - vec5_t deformParams; - - qboolean renderToCubemap = tr.renderCubeFbo && glState.currentFBO == tr.renderCubeFbo; - - ComputeDeformValues(&deformGen, deformParams); - - ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); - - for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ ) - { - shaderStage_t *pStage = input->xstages[stage]; - shaderProgram_t *sp; - vec4_t texMatrix; - vec4_t texOffTurb; - - if ( !pStage ) - { - break; - } - - if (backEnd.depthFill) - { - if (pStage->glslShaderGroup == tr.lightallShader) - { - int index = 0; - - if (backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) - { - if (glState.boneAnimation) - { - index |= LIGHTDEF_ENTITY_BONE_ANIMATION; - } - else - { - index |= LIGHTDEF_ENTITY_VERTEX_ANIMATION; - } - } - - if (pStage->stateBits & GLS_ATEST_BITS) - { - index |= LIGHTDEF_USE_TCGEN_AND_TCMOD; - } - - sp = &pStage->glslShaderGroup[index]; - } - else - { - int shaderAttribs = 0; - - if (tess.shader->numDeforms && !ShaderRequiresCPUDeforms(tess.shader)) - { - shaderAttribs |= GENERICDEF_USE_DEFORM_VERTEXES; - } - - if (glState.vertexAnimation) - { - shaderAttribs |= GENERICDEF_USE_VERTEX_ANIMATION; - } - else if (glState.boneAnimation) - { - shaderAttribs |= GENERICDEF_USE_BONE_ANIMATION; - } - - if (pStage->stateBits & GLS_ATEST_BITS) - { - shaderAttribs |= GENERICDEF_USE_TCGEN_AND_TCMOD; - } - - sp = &tr.genericShader[shaderAttribs]; - } - } - else if (pStage->glslShaderGroup == tr.lightallShader) - { - int index = pStage->glslShaderIndex; - - if (backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) - { - if (glState.boneAnimation) - { - index |= LIGHTDEF_ENTITY_BONE_ANIMATION; - } - else - { - index |= LIGHTDEF_ENTITY_VERTEX_ANIMATION; - } - } - - if (r_sunlightMode->integer && (backEnd.viewParms.flags & VPF_USESUNLIGHT) && (index & LIGHTDEF_LIGHTTYPE_MASK)) - { - index |= LIGHTDEF_USE_SHADOWMAP; - } - - if (r_lightmap->integer && ((index & LIGHTDEF_LIGHTTYPE_MASK) == LIGHTDEF_USE_LIGHTMAP)) - { - index = LIGHTDEF_USE_TCGEN_AND_TCMOD; - } - - sp = &pStage->glslShaderGroup[index]; - - backEnd.pc.c_lightallDraws++; - } - else - { - sp = GLSL_GetGenericShaderProgram(stage); - - backEnd.pc.c_genericDraws++; - } - - GLSL_BindProgram(sp); - - GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.or.origin); - GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.or.viewOrigin); - - GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - - if (glState.boneAnimation) - { - GLSL_SetUniformMat4BoneMatrix(sp, UNIFORM_BONEMATRIX, glState.boneMatrix, glState.boneAnimation); - } - - GLSL_SetUniformInt(sp, UNIFORM_DEFORMGEN, deformGen); - if (deformGen != DGEN_NONE) - { - GLSL_SetUniformFloat5(sp, UNIFORM_DEFORMPARAMS, deformParams); - GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); - } - - if ( input->fogNum ) { - GLSL_SetUniformVec4(sp, UNIFORM_FOGDISTANCE, fogDistanceVector); - GLSL_SetUniformVec4(sp, UNIFORM_FOGDEPTH, fogDepthVector); - GLSL_SetUniformFloat(sp, UNIFORM_FOGEYET, eyeT); - } - - GL_State( pStage->stateBits ); - if ((pStage->stateBits & GLS_ATEST_BITS) == GLS_ATEST_GT_0) - { - GLSL_SetUniformInt(sp, UNIFORM_ALPHATEST, 1); - } - else if ((pStage->stateBits & GLS_ATEST_BITS) == GLS_ATEST_LT_80) - { - GLSL_SetUniformInt(sp, UNIFORM_ALPHATEST, 2); - } - else if ((pStage->stateBits & GLS_ATEST_BITS) == GLS_ATEST_GE_80) - { - GLSL_SetUniformInt(sp, UNIFORM_ALPHATEST, 3); - } - else - { - GLSL_SetUniformInt(sp, UNIFORM_ALPHATEST, 0); - } - - - { - vec4_t baseColor; - vec4_t vertColor; - - ComputeShaderColors(pStage, baseColor, vertColor, pStage->stateBits); - - GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, baseColor); - GLSL_SetUniformVec4(sp, UNIFORM_VERTCOLOR, vertColor); - } - - if (pStage->rgbGen == CGEN_LIGHTING_DIFFUSE) - { - vec4_t vec; - - VectorScale(backEnd.currentEntity->ambientLight, 1.0f / 255.0f, vec); - GLSL_SetUniformVec3(sp, UNIFORM_AMBIENTLIGHT, vec); - - VectorScale(backEnd.currentEntity->directedLight, 1.0f / 255.0f, vec); - GLSL_SetUniformVec3(sp, UNIFORM_DIRECTEDLIGHT, vec); - - VectorCopy(backEnd.currentEntity->lightDir, vec); - vec[3] = 0.0f; - GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vec); - GLSL_SetUniformVec3(sp, UNIFORM_MODELLIGHTDIR, backEnd.currentEntity->modelLightDir); - - GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, 0.0f); - } - - if (pStage->alphaGen == AGEN_PORTAL) - { - GLSL_SetUniformFloat(sp, UNIFORM_PORTALRANGE, tess.shader->portalRange); - } - - GLSL_SetUniformInt(sp, UNIFORM_COLORGEN, pStage->rgbGen); - GLSL_SetUniformInt(sp, UNIFORM_ALPHAGEN, pStage->alphaGen); - - if ( input->fogNum ) - { - vec4_t fogColorMask; - - ComputeFogColorMask(pStage, fogColorMask); - - GLSL_SetUniformVec4(sp, UNIFORM_FOGCOLORMASK, fogColorMask); - } - - if (r_lightmap->integer) - { - vec4_t v; - VectorSet4(v, 1.0f, 0.0f, 0.0f, 1.0f); - GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXMATRIX, v); - VectorSet4(v, 0.0f, 0.0f, 0.0f, 0.0f); - GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXOFFTURB, v); - - GLSL_SetUniformInt(sp, UNIFORM_TCGEN0, TCGEN_LIGHTMAP); - } - else - { - ComputeTexMods(pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb); - GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXMATRIX, texMatrix); - GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXOFFTURB, texOffTurb); - - GLSL_SetUniformInt(sp, UNIFORM_TCGEN0, pStage->bundle[0].tcGen); - if (pStage->bundle[0].tcGen == TCGEN_VECTOR) - { - vec3_t vec; - - VectorCopy(pStage->bundle[0].tcGenVectors[0], vec); - GLSL_SetUniformVec3(sp, UNIFORM_TCGEN0VECTOR0, vec); - VectorCopy(pStage->bundle[0].tcGenVectors[1], vec); - GLSL_SetUniformVec3(sp, UNIFORM_TCGEN0VECTOR1, vec); - } - } - - GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix); - - GLSL_SetUniformVec4(sp, UNIFORM_NORMALSCALE, pStage->normalScale); - - { - vec4_t specularScale; - Vector4Copy(pStage->specularScale, specularScale); - - if (renderToCubemap) - { - // force specular to nonmetal if rendering cubemaps - if (r_pbr->integer) - specularScale[1] = 0.0f; - } - - GLSL_SetUniformVec4(sp, UNIFORM_SPECULARSCALE, specularScale); - } - - //GLSL_SetUniformFloat(sp, UNIFORM_MAPLIGHTSCALE, backEnd.refdef.mapLightScale); - - // - // do multitexture - // - if ( backEnd.depthFill ) - { - if (!(pStage->stateBits & GLS_ATEST_BITS)) - GL_BindToTMU( tr.whiteImage, TB_COLORMAP ); - else if ( pStage->bundle[TB_COLORMAP].image[0] != 0 ) - R_BindAnimatedImageToTMU( &pStage->bundle[TB_COLORMAP], TB_COLORMAP ); - } - else if ( pStage->glslShaderGroup == tr.lightallShader ) - { - int i; - vec4_t enableTextures; - - if (r_sunlightMode->integer && (backEnd.viewParms.flags & VPF_USESUNLIGHT) && (pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK)) - { - // FIXME: screenShadowImage is NULL if no framebuffers - if (tr.screenShadowImage) - GL_BindToTMU(tr.screenShadowImage, TB_SHADOWMAP); - GLSL_SetUniformVec3(sp, UNIFORM_PRIMARYLIGHTAMBIENT, backEnd.refdef.sunAmbCol); - if (r_pbr->integer) - { - vec3_t color; - - color[0] = backEnd.refdef.sunCol[0] * backEnd.refdef.sunCol[0]; - color[1] = backEnd.refdef.sunCol[1] * backEnd.refdef.sunCol[1]; - color[2] = backEnd.refdef.sunCol[2] * backEnd.refdef.sunCol[2]; - GLSL_SetUniformVec3(sp, UNIFORM_PRIMARYLIGHTCOLOR, color); - } - else - { - GLSL_SetUniformVec3(sp, UNIFORM_PRIMARYLIGHTCOLOR, backEnd.refdef.sunCol); - } - GLSL_SetUniformVec4(sp, UNIFORM_PRIMARYLIGHTORIGIN, backEnd.refdef.sunDir); - } - - VectorSet4(enableTextures, 0, 0, 0, 0); - if ((r_lightmap->integer == 1 || r_lightmap->integer == 2) && pStage->bundle[TB_LIGHTMAP].image[0]) - { - for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) - { - if (i == TB_COLORMAP) - R_BindAnimatedImageToTMU( &pStage->bundle[TB_LIGHTMAP], i); - else - GL_BindToTMU( tr.whiteImage, i ); - } - } - else if (r_lightmap->integer == 3 && pStage->bundle[TB_DELUXEMAP].image[0]) - { - for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) - { - if (i == TB_COLORMAP) - R_BindAnimatedImageToTMU( &pStage->bundle[TB_DELUXEMAP], i); - else - GL_BindToTMU( tr.whiteImage, i ); - } - } - else - { - qboolean light = (pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) != 0; - qboolean fastLight = !(r_normalMapping->integer || r_specularMapping->integer); - - if (pStage->bundle[TB_DIFFUSEMAP].image[0]) - R_BindAnimatedImageToTMU( &pStage->bundle[TB_DIFFUSEMAP], TB_DIFFUSEMAP); - - if (pStage->bundle[TB_LIGHTMAP].image[0]) - R_BindAnimatedImageToTMU( &pStage->bundle[TB_LIGHTMAP], TB_LIGHTMAP); - - // bind textures that are sampled and used in the glsl shader, and - // bind whiteImage to textures that are sampled but zeroed in the glsl shader - // - // alternatives: - // - use the last bound texture - // -> costs more to sample a higher res texture then throw out the result - // - disable texture sampling in glsl shader with #ifdefs, as before - // -> increases the number of shaders that must be compiled - // - if (light && !fastLight) - { - if (pStage->bundle[TB_NORMALMAP].image[0]) - { - R_BindAnimatedImageToTMU( &pStage->bundle[TB_NORMALMAP], TB_NORMALMAP); - enableTextures[0] = 1.0f; - } - else if (r_normalMapping->integer) - GL_BindToTMU( tr.whiteImage, TB_NORMALMAP ); - - if (pStage->bundle[TB_DELUXEMAP].image[0]) - { - R_BindAnimatedImageToTMU( &pStage->bundle[TB_DELUXEMAP], TB_DELUXEMAP); - enableTextures[1] = 1.0f; - } - else if (r_deluxeMapping->integer) - GL_BindToTMU( tr.whiteImage, TB_DELUXEMAP ); - - if (pStage->bundle[TB_SPECULARMAP].image[0]) - { - R_BindAnimatedImageToTMU( &pStage->bundle[TB_SPECULARMAP], TB_SPECULARMAP); - enableTextures[2] = 1.0f; - } - else if (r_specularMapping->integer) - GL_BindToTMU( tr.whiteImage, TB_SPECULARMAP ); - } - - enableTextures[3] = (r_cubeMapping->integer && !(tr.viewParms.flags & VPF_NOCUBEMAPS) && input->cubemapIndex) ? 1.0f : 0.0f; - } - - GLSL_SetUniformVec4(sp, UNIFORM_ENABLETEXTURES, enableTextures); - } - else if ( pStage->bundle[1].image[0] != 0 ) - { - R_BindAnimatedImageToTMU( &pStage->bundle[0], 0 ); - R_BindAnimatedImageToTMU( &pStage->bundle[1], 1 ); - } - else - { - // - // set state - // - R_BindAnimatedImageToTMU( &pStage->bundle[0], 0 ); - } - - // - // testing cube map - // - if (!(tr.viewParms.flags & VPF_NOCUBEMAPS) && input->cubemapIndex && r_cubeMapping->integer) - { - vec4_t vec; - cubemap_t *cubemap = &tr.cubemaps[input->cubemapIndex - 1]; - - // FIXME: cubemap image could be NULL if cubemap isn't renderer or loaded - if (cubemap->image) - GL_BindToTMU( cubemap->image, TB_CUBEMAP); - - VectorSubtract(cubemap->origin, backEnd.viewParms.or.origin, vec); - vec[3] = 1.0f; - - VectorScale4(vec, 1.0f / cubemap->parallaxRadius, vec); - - GLSL_SetUniformVec4(sp, UNIFORM_CUBEMAPINFO, vec); - } - - // - // draw - // - R_DrawElements(input->numIndexes, input->firstIndex); - - // allow skipping out to show just lightmaps during development - if ( r_lightmap->integer && ( pStage->bundle[0].isLightmap || pStage->bundle[1].isLightmap ) ) - { - break; - } - - if (backEnd.depthFill) - break; - } -} - - -static void RB_RenderShadowmap( const shaderCommands_t *input ) -{ - int deformGen; - vec5_t deformParams; - - ComputeDeformValues(&deformGen, deformParams); - - { - shaderProgram_t *sp = &tr.shadowmapShader[0]; - vec4_t vector; - - if (glState.vertexAnimation) - { - sp = &tr.shadowmapShader[SHADOWMAPDEF_USE_VERTEX_ANIMATION]; - } - else if (glState.boneAnimation) - { - sp = &tr.shadowmapShader[SHADOWMAPDEF_USE_BONE_ANIMATION]; - } - - GLSL_BindProgram(sp); - - GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - - GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix); - - GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - - if (glState.boneAnimation) - { - GLSL_SetUniformMat4BoneMatrix(sp, UNIFORM_BONEMATRIX, glState.boneMatrix, glState.boneAnimation); - } - - GLSL_SetUniformInt(sp, UNIFORM_DEFORMGEN, deformGen); - if (deformGen != DGEN_NONE) - { - GLSL_SetUniformFloat5(sp, UNIFORM_DEFORMPARAMS, deformParams); - GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); - } - - VectorCopy(backEnd.viewParms.or.origin, vector); - vector[3] = 1.0f; - GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vector); - GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, backEnd.viewParms.zFar); - - GL_State( 0 ); - GLSL_SetUniformInt(sp, UNIFORM_ALPHATEST, 0); - - // - // do multitexture - // - //if ( pStage->glslShaderGroup ) - { - // - // draw - // - - R_DrawElements(input->numIndexes, input->firstIndex); - } - } -} - - - -/* -** RB_StageIteratorGeneric -*/ -void RB_StageIteratorGeneric( void ) -{ - const shaderCommands_t *input; - unsigned int vertexAttribs = 0; - - input = &tess; - - if (!input->numVertexes || !input->numIndexes) - { - return; - } - - if (tess.useInternalVao) - { - RB_DeformTessGeometry(); - } - - vertexAttribs = RB_CalcShaderVertexAttribs( input ); - - if (tess.useInternalVao) - { - RB_UpdateTessVao(vertexAttribs); - } - else - { - backEnd.pc.c_staticVaoDraws++; - } - - // - // set face culling appropriately - // - if (input->shader->cullType == CT_TWO_SIDED) - { - GL_Cull( CT_TWO_SIDED ); - } - else - { - qboolean cullFront = (input->shader->cullType == CT_FRONT_SIDED); - - if ( backEnd.viewParms.flags & VPF_DEPTHSHADOW ) - cullFront = !cullFront; - - if ( backEnd.viewParms.isMirror ) - cullFront = !cullFront; - - if ( backEnd.currentEntity && backEnd.currentEntity->mirrored ) - cullFront = !cullFront; - - if (cullFront) - GL_Cull( CT_FRONT_SIDED ); - else - GL_Cull( CT_BACK_SIDED ); - } - - // set polygon offset if necessary - if ( input->shader->polygonOffset ) - { - qglEnable( GL_POLYGON_OFFSET_FILL ); - } - - // - // render depth if in depthfill mode - // - if (backEnd.depthFill) - { - RB_IterateStagesGeneric( input ); - - // - // reset polygon offset - // - if ( input->shader->polygonOffset ) - { - qglDisable( GL_POLYGON_OFFSET_FILL ); - } - - return; - } - - // - // render shadowmap if in shadowmap mode - // - if (backEnd.viewParms.flags & VPF_SHADOWMAP) - { - if ( input->shader->sort == SS_OPAQUE ) - { - RB_RenderShadowmap( input ); - } - // - // reset polygon offset - // - if ( input->shader->polygonOffset ) - { - qglDisable( GL_POLYGON_OFFSET_FILL ); - } - - return; - } - - // - // - // call shader function - // - RB_IterateStagesGeneric( input ); - - // - // pshadows! - // - if (glRefConfig.framebufferObject && r_shadows->integer == 4 && tess.pshadowBits - && tess.shader->sort <= SS_OPAQUE && !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) { - ProjectPshadowVBOGLSL(); - } - - - // - // now do any dynamic lighting needed - // - if ( tess.dlightBits && tess.shader->lightingStage >= 0 ) { - if ( r_dlightMode->integer ) - { - ForwardDlight(); - } - else - { - ProjectDlightTexture(); - } - } - - // - // now do fog - // - if ( tess.fogNum && tess.shader->fogPass ) { - RB_FogPass(); - } - - // - // reset polygon offset - // - if ( input->shader->polygonOffset ) - { - qglDisable( GL_POLYGON_OFFSET_FILL ); - } -} - - -/* -** RB_EndSurface -*/ -void RB_EndSurface( void ) { - const shaderCommands_t *input; - - input = &tess; - - if (input->numIndexes == 0 || input->numVertexes == 0) { - return; - } - - if (input->indexes[SHADER_MAX_INDEXES-1] != 0) { - ri.Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_INDEXES hit"); - } - if (input->xyz[SHADER_MAX_VERTEXES-1][0] != 0) { - ri.Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_VERTEXES hit"); - } - - if ( tess.shader == tr.shadowShader ) { - RB_ShadowTessEnd(); - return; - } - - // for debugging of sort order issues, stop rendering after a given sort value - if ( r_debugSort->integer && r_debugSort->integer < tess.shader->sort ) { - return; - } - - if (tess.useCacheVao) - { - // upload indexes now - VaoCache_Commit(); - } - - // - // update performance counters - // - backEnd.pc.c_shaders++; - backEnd.pc.c_vertexes += tess.numVertexes; - backEnd.pc.c_indexes += tess.numIndexes; - backEnd.pc.c_totalIndexes += tess.numIndexes * tess.numPasses; - - // - // call off to shader specific tess end function - // - tess.currentStageIteratorFunc(); - - // - // draw debugging stuff - // - if ( r_showtris->integer ) { - DrawTris (input); - } - if ( r_shownormals->integer ) { - DrawNormals (input); - } - // clear shader so we can tell we don't have any unclosed surfaces - tess.numIndexes = 0; - tess.numVertexes = 0; - tess.firstIndex = 0; - -// GLimp_LogComment( "----------\n" ); -} diff --git a/code/renderer2/tr_shade_calc.c b/code/renderer2/tr_shade_calc.c deleted file mode 100644 index 60d30eb4ce..0000000000 --- a/code/renderer2/tr_shade_calc.c +++ /dev/null @@ -1,818 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_shade_calc.c - -#include "tr_local.h" - - -#define WAVEVALUE( table, base, amplitude, phase, freq ) ((base) + table[ (int64_t)( ( ( (phase) + tess.shaderTime * (freq) ) * FUNCTABLE_SIZE ) ) & FUNCTABLE_MASK ] * (amplitude)) - -static float *TableForFunc( genFunc_t func ) -{ - switch ( func ) - { - case GF_SIN: - return tr.sinTable; - case GF_TRIANGLE: - return tr.triangleTable; - case GF_SQUARE: - return tr.squareTable; - case GF_SAWTOOTH: - return tr.sawToothTable; - case GF_INVERSE_SAWTOOTH: - return tr.inverseSawToothTable; - case GF_NONE: - default: - break; - } - - ri.Error( ERR_DROP, "TableForFunc called with invalid function '%d' in shader '%s'", func, tess.shader->name ); - return NULL; -} - -/* -** EvalWaveForm -** -** Evaluates a given waveForm_t, referencing backEnd.refdef.time directly -*/ -static float EvalWaveForm( const waveForm_t *wf ) -{ - float *table; - - table = TableForFunc( wf->func ); - - return WAVEVALUE( table, wf->base, wf->amplitude, wf->phase, wf->frequency ); -} - -static float EvalWaveFormClamped( const waveForm_t *wf ) -{ - float glow = EvalWaveForm( wf ); - - if ( glow < 0 ) - { - return 0; - } - - if ( glow > 1 ) - { - return 1; - } - - return glow; -} - -/* -** RB_CalcStretchTexMatrix -*/ -void RB_CalcStretchTexMatrix( const waveForm_t *wf, float *matrix ) -{ - float p; - - p = 1.0f / EvalWaveForm( wf ); - - matrix[0] = p; matrix[2] = 0; matrix[4] = 0.5f - 0.5f * p; - matrix[1] = 0; matrix[3] = p; matrix[5] = 0.5f - 0.5f * p; -} - -/* -==================================================================== - -DEFORMATIONS - -==================================================================== -*/ - -/* -======================== -RB_CalcDeformVertexes - -======================== -*/ -static void RB_CalcDeformVertexes( deformStage_t *ds ) -{ - int i; - vec3_t offset; - float scale; - float *xyz = ( float * ) tess.xyz; - int16_t *normal = tess.normal[0]; - float *table; - - if ( ds->deformationWave.frequency == 0 ) - { - scale = EvalWaveForm( &ds->deformationWave ); - - for ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal += 4 ) - { - R_VaoUnpackNormal(offset, normal); - - xyz[0] += offset[0] * scale; - xyz[1] += offset[1] * scale; - xyz[2] += offset[2] * scale; - } - } - else - { - table = TableForFunc( ds->deformationWave.func ); - - for ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal += 4 ) - { - float off = ( xyz[0] + xyz[1] + xyz[2] ) * ds->deformationSpread; - - scale = WAVEVALUE( table, ds->deformationWave.base, - ds->deformationWave.amplitude, - ds->deformationWave.phase + off, - ds->deformationWave.frequency ); - - R_VaoUnpackNormal(offset, normal); - - xyz[0] += offset[0] * scale; - xyz[1] += offset[1] * scale; - xyz[2] += offset[2] * scale; - } - } -} - -/* -========================= -RB_CalcDeformNormals - -Wiggle the normals for wavy environment mapping -========================= -*/ -static void RB_CalcDeformNormals( deformStage_t *ds ) { - int i; - float scale; - float *xyz = ( float * ) tess.xyz; - int16_t *normal = tess.normal[0]; - - for ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal += 4 ) { - vec3_t fNormal; - - R_VaoUnpackNormal(fNormal, normal); - - scale = 0.98f; - scale = R_NoiseGet4f( xyz[0] * scale, xyz[1] * scale, xyz[2] * scale, - tess.shaderTime * ds->deformationWave.frequency ); - fNormal[ 0 ] += ds->deformationWave.amplitude * scale; - - scale = 0.98f; - scale = R_NoiseGet4f( 100 + xyz[0] * scale, xyz[1] * scale, xyz[2] * scale, - tess.shaderTime * ds->deformationWave.frequency ); - fNormal[ 1 ] += ds->deformationWave.amplitude * scale; - - scale = 0.98f; - scale = R_NoiseGet4f( 200 + xyz[0] * scale, xyz[1] * scale, xyz[2] * scale, - tess.shaderTime * ds->deformationWave.frequency ); - fNormal[ 2 ] += ds->deformationWave.amplitude * scale; - - VectorNormalizeFast( fNormal ); - - R_VaoPackNormal(normal, fNormal); - } -} - -/* -======================== -RB_CalcBulgeVertexes - -======================== -*/ -static void RB_CalcBulgeVertexes( deformStage_t *ds ) { - int i; - const float *st = ( const float * ) tess.texCoords[0]; - float *xyz = ( float * ) tess.xyz; - int16_t *normal = tess.normal[0]; - float now; - - now = backEnd.refdef.time * ds->bulgeSpeed * 0.001; - - for ( i = 0; i < tess.numVertexes; i++, xyz += 4, st += 2, normal += 4 ) { - int64_t off; - float scale; - vec3_t fNormal; - - R_VaoUnpackNormal(fNormal, normal); - - off = (float)( FUNCTABLE_SIZE / (M_PI*2) ) * ( st[0] * ds->bulgeWidth + now ); - - scale = tr.sinTable[ off & FUNCTABLE_MASK ] * ds->bulgeHeight; - - xyz[0] += fNormal[0] * scale; - xyz[1] += fNormal[1] * scale; - xyz[2] += fNormal[2] * scale; - } -} - - -/* -====================== -RB_CalcMoveVertexes - -A deformation that can move an entire surface along a wave path -====================== -*/ -static void RB_CalcMoveVertexes( deformStage_t *ds ) { - int i; - float *xyz; - float *table; - float scale; - vec3_t offset; - - table = TableForFunc( ds->deformationWave.func ); - - scale = WAVEVALUE( table, ds->deformationWave.base, - ds->deformationWave.amplitude, - ds->deformationWave.phase, - ds->deformationWave.frequency ); - - VectorScale( ds->moveVector, scale, offset ); - - xyz = ( float * ) tess.xyz; - for ( i = 0; i < tess.numVertexes; i++, xyz += 4 ) { - VectorAdd( xyz, offset, xyz ); - } -} - - -/* -============= -DeformText - -Change a polygon into a bunch of text polygons -============= -*/ -static void DeformText( const char *text ) { - int i; - vec3_t origin, width, height; - int len; - int ch; - float color[4]; - float bottom, top; - vec3_t mid; - vec3_t fNormal; - - height[0] = 0; - height[1] = 0; - height[2] = -1; - - R_VaoUnpackNormal(fNormal, tess.normal[0]); - CrossProduct( fNormal, height, width ); - - // find the midpoint of the box - VectorClear( mid ); - bottom = 999999; - top = -999999; - for ( i = 0 ; i < 4 ; i++ ) { - VectorAdd( tess.xyz[i], mid, mid ); - if ( tess.xyz[i][2] < bottom ) { - bottom = tess.xyz[i][2]; - } - if ( tess.xyz[i][2] > top ) { - top = tess.xyz[i][2]; - } - } - VectorScale( mid, 0.25f, origin ); - - // determine the individual character size - height[0] = 0; - height[1] = 0; - height[2] = ( top - bottom ) * 0.5f; - - VectorScale( width, height[2] * -0.75f, width ); - - // determine the starting position - len = strlen( text ); - VectorMA( origin, (len-1), width, origin ); - - // clear the shader indexes - tess.numIndexes = 0; - tess.numVertexes = 0; - tess.firstIndex = 0; - - color[0] = color[1] = color[2] = color[3] = 1.0f; - - // draw each character - for ( i = 0 ; i < len ; i++ ) { - ch = text[i]; - ch &= 255; - - if ( ch != ' ' ) { - int row, col; - float frow, fcol, size; - - row = ch>>4; - col = ch&15; - - frow = row*0.0625f; - fcol = col*0.0625f; - size = 0.0625f; - - RB_AddQuadStampExt( origin, width, height, color, fcol, frow, fcol + size, frow + size ); - } - VectorMA( origin, -2, width, origin ); - } -} - -/* -================== -GlobalVectorToLocal -================== -*/ -static void GlobalVectorToLocal( const vec3_t in, vec3_t out ) { - out[0] = DotProduct( in, backEnd.or.axis[0] ); - out[1] = DotProduct( in, backEnd.or.axis[1] ); - out[2] = DotProduct( in, backEnd.or.axis[2] ); -} - -/* -===================== -AutospriteDeform - -Assuming all the triangles for this shader are independent -quads, rebuild them as forward facing sprites -===================== -*/ -static void AutospriteDeform( void ) { - int i; - int oldVerts; - float *xyz; - vec3_t mid, delta; - float radius; - vec3_t left, up; - vec3_t leftDir, upDir; - - if ( tess.numVertexes & 3 ) { - ri.Printf( PRINT_WARNING, "Autosprite shader %s had odd vertex count\n", tess.shader->name ); - } - if ( tess.numIndexes != ( tess.numVertexes >> 2 ) * 6 ) { - ri.Printf( PRINT_WARNING, "Autosprite shader %s had odd index count\n", tess.shader->name ); - } - - oldVerts = tess.numVertexes; - tess.numVertexes = 0; - tess.numIndexes = 0; - tess.firstIndex = 0; - - if ( backEnd.currentEntity != &tr.worldEntity ) { - GlobalVectorToLocal( backEnd.viewParms.or.axis[1], leftDir ); - GlobalVectorToLocal( backEnd.viewParms.or.axis[2], upDir ); - } else { - VectorCopy( backEnd.viewParms.or.axis[1], leftDir ); - VectorCopy( backEnd.viewParms.or.axis[2], upDir ); - } - - for ( i = 0 ; i < oldVerts ; i+=4 ) { - vec4_t color; - // find the midpoint - xyz = tess.xyz[i]; - - mid[0] = 0.25f * (xyz[0] + xyz[4] + xyz[8] + xyz[12]); - mid[1] = 0.25f * (xyz[1] + xyz[5] + xyz[9] + xyz[13]); - mid[2] = 0.25f * (xyz[2] + xyz[6] + xyz[10] + xyz[14]); - - VectorSubtract( xyz, mid, delta ); - radius = VectorLength( delta ) * 0.707f; // / sqrt(2) - - VectorScale( leftDir, radius, left ); - VectorScale( upDir, radius, up ); - - if ( backEnd.viewParms.isMirror ) { - VectorSubtract( vec3_origin, left, left ); - } - - // compensate for scale in the axes if necessary - if ( backEnd.currentEntity->e.nonNormalizedAxes ) { - float axisLength; - axisLength = VectorLength( backEnd.currentEntity->e.axis[0] ); - if ( !axisLength ) { - axisLength = 0; - } else { - axisLength = 1.0f / axisLength; - } - VectorScale(left, axisLength, left); - VectorScale(up, axisLength, up); - } - - VectorScale4(tess.color[i], 1.0f / 65535.0f, color); - RB_AddQuadStamp( mid, left, up, color ); - } -} - - -/* -===================== -Autosprite2Deform - -Autosprite2 will pivot a rectangular quad along the center of its long axis -===================== -*/ -static const unsigned int edgeVerts[6][2] = { - { 0, 1 }, - { 0, 2 }, - { 0, 3 }, - { 1, 2 }, - { 1, 3 }, - { 2, 3 } -}; - -static void Autosprite2Deform( void ) { - int i, j, k; - int indexes; - float *xyz; - vec3_t forward; - - if ( tess.numVertexes & 3 ) { - ri.Printf( PRINT_WARNING, "Autosprite2 shader %s had odd vertex count\n", tess.shader->name ); - } - if ( tess.numIndexes != ( tess.numVertexes >> 2 ) * 6 ) { - ri.Printf( PRINT_WARNING, "Autosprite2 shader %s had odd index count\n", tess.shader->name ); - } - - if ( backEnd.currentEntity != &tr.worldEntity ) { - GlobalVectorToLocal( backEnd.viewParms.or.axis[0], forward ); - } else { - VectorCopy( backEnd.viewParms.or.axis[0], forward ); - } - - // this is a lot of work for two triangles... - // we could precalculate a lot of it is an issue, but it would mess up - // the shader abstraction - for ( i = 0, indexes = 0 ; i < tess.numVertexes ; i+=4, indexes+=6 ) { - float lengths[2]; - int nums[2]; - vec3_t mid[2]; - vec3_t major, minor; - float *v1, *v2; - - // find the midpoint - xyz = tess.xyz[i]; - - // identify the two shortest edges - nums[0] = nums[1] = 0; - lengths[0] = lengths[1] = 999999; - - for ( j = 0 ; j < 6 ; j++ ) { - float l; - vec3_t temp; - - v1 = xyz + 4 * edgeVerts[j][0]; - v2 = xyz + 4 * edgeVerts[j][1]; - - VectorSubtract( v1, v2, temp ); - - l = DotProduct( temp, temp ); - if ( l < lengths[0] ) { - nums[1] = nums[0]; - lengths[1] = lengths[0]; - nums[0] = j; - lengths[0] = l; - } else if ( l < lengths[1] ) { - nums[1] = j; - lengths[1] = l; - } - } - - for ( j = 0 ; j < 2 ; j++ ) { - v1 = xyz + 4 * edgeVerts[nums[j]][0]; - v2 = xyz + 4 * edgeVerts[nums[j]][1]; - - mid[j][0] = 0.5f * (v1[0] + v2[0]); - mid[j][1] = 0.5f * (v1[1] + v2[1]); - mid[j][2] = 0.5f * (v1[2] + v2[2]); - } - - // find the vector of the major axis - VectorSubtract( mid[1], mid[0], major ); - - // cross this with the view direction to get minor axis - CrossProduct( major, forward, minor ); - VectorNormalize( minor ); - - // re-project the points - for ( j = 0 ; j < 2 ; j++ ) { - float l; - - v1 = xyz + 4 * edgeVerts[nums[j]][0]; - v2 = xyz + 4 * edgeVerts[nums[j]][1]; - - l = 0.5 * sqrt( lengths[j] ); - - // we need to see which direction this edge - // is used to determine direction of projection - for ( k = 0 ; k < 5 ; k++ ) { - if ( tess.indexes[ indexes + k ] == i + edgeVerts[nums[j]][0] - && tess.indexes[ indexes + k + 1 ] == i + edgeVerts[nums[j]][1] ) { - break; - } - } - - if ( k == 5 ) { - VectorMA( mid[j], l, minor, v1 ); - VectorMA( mid[j], -l, minor, v2 ); - } else { - VectorMA( mid[j], -l, minor, v1 ); - VectorMA( mid[j], l, minor, v2 ); - } - } - } -} - - -/* -===================== -RB_DeformTessGeometry - -===================== -*/ -void RB_DeformTessGeometry( void ) { - int i; - deformStage_t *ds; - - if(!ShaderRequiresCPUDeforms(tess.shader)) - { - // we don't need the following CPU deforms - return; - } - - for ( i = 0 ; i < tess.shader->numDeforms ; i++ ) { - ds = &tess.shader->deforms[ i ]; - - switch ( ds->deformation ) { - case DEFORM_NONE: - break; - case DEFORM_NORMALS: - RB_CalcDeformNormals( ds ); - break; - case DEFORM_WAVE: - RB_CalcDeformVertexes( ds ); - break; - case DEFORM_BULGE: - RB_CalcBulgeVertexes( ds ); - break; - case DEFORM_MOVE: - RB_CalcMoveVertexes( ds ); - break; - case DEFORM_PROJECTION_SHADOW: - RB_ProjectionShadowDeform(); - break; - case DEFORM_AUTOSPRITE: - AutospriteDeform(); - break; - case DEFORM_AUTOSPRITE2: - Autosprite2Deform(); - break; - case DEFORM_TEXT0: - case DEFORM_TEXT1: - case DEFORM_TEXT2: - case DEFORM_TEXT3: - case DEFORM_TEXT4: - case DEFORM_TEXT5: - case DEFORM_TEXT6: - case DEFORM_TEXT7: - DeformText( backEnd.refdef.text[ds->deformation - DEFORM_TEXT0] ); - break; - } - } -} - -/* -==================================================================== - -COLORS - -==================================================================== -*/ - - -/* -** RB_CalcWaveColorSingle -*/ -float RB_CalcWaveColorSingle( const waveForm_t *wf ) -{ - float glow; - - if ( wf->func == GF_NOISE ) { - glow = wf->base + R_NoiseGet4f( 0, 0, 0, ( tess.shaderTime + wf->phase ) * wf->frequency ) * wf->amplitude; - } else { - glow = EvalWaveForm( wf ) * tr.identityLight; - } - - if ( glow < 0 ) { - glow = 0; - } - else if ( glow > 1 ) { - glow = 1; - } - - return glow; -} - -/* -** RB_CalcWaveAlphaSingle -*/ -float RB_CalcWaveAlphaSingle( const waveForm_t *wf ) -{ - return EvalWaveFormClamped( wf ); -} - -/* -** RB_CalcModulateColorsByFog -*/ -void RB_CalcModulateColorsByFog( unsigned char *colors ) { - int i; - float texCoords[SHADER_MAX_VERTEXES][2] = {{0.0f}}; - - // calculate texcoords so we can derive density - // this is not wasted, because it would only have - // been previously called if the surface was opaque - RB_CalcFogTexCoords( texCoords[0] ); - - for ( i = 0; i < tess.numVertexes; i++, colors += 4 ) { - float f = 1.0 - R_FogFactor( texCoords[i][0], texCoords[i][1] ); - colors[0] *= f; - colors[1] *= f; - colors[2] *= f; - } -} - - -/* -==================================================================== - -TEX COORDS - -==================================================================== -*/ - -/* -======================== -RB_CalcFogTexCoords - -To do the clipped fog plane really correctly, we should use -projected textures, but I don't trust the drivers and it -doesn't fit our shader data. -======================== -*/ -void RB_CalcFogTexCoords( float *st ) { - int i; - float *v; - float s, t; - float eyeT; - qboolean eyeOutside; - const fog_t *fog; - vec3_t local; - vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; - - fog = tr.world->fogs + tess.fogNum; - - // all fogging distance is based on world Z units - VectorSubtract( backEnd.or.origin, backEnd.viewParms.or.origin, local ); - fogDistanceVector[0] = -backEnd.or.modelMatrix[2]; - fogDistanceVector[1] = -backEnd.or.modelMatrix[6]; - fogDistanceVector[2] = -backEnd.or.modelMatrix[10]; - fogDistanceVector[3] = DotProduct( local, backEnd.viewParms.or.axis[0] ); - - // scale the fog vectors based on the fog's thickness - fogDistanceVector[0] *= fog->tcScale; - fogDistanceVector[1] *= fog->tcScale; - fogDistanceVector[2] *= fog->tcScale; - fogDistanceVector[3] *= fog->tcScale; - - // rotate the gradient vector for this orientation - if ( fog->hasSurface ) { - fogDepthVector[0] = fog->surface[0] * backEnd.or.axis[0][0] + - fog->surface[1] * backEnd.or.axis[0][1] + fog->surface[2] * backEnd.or.axis[0][2]; - fogDepthVector[1] = fog->surface[0] * backEnd.or.axis[1][0] + - fog->surface[1] * backEnd.or.axis[1][1] + fog->surface[2] * backEnd.or.axis[1][2]; - fogDepthVector[2] = fog->surface[0] * backEnd.or.axis[2][0] + - fog->surface[1] * backEnd.or.axis[2][1] + fog->surface[2] * backEnd.or.axis[2][2]; - fogDepthVector[3] = -fog->surface[3] + DotProduct( backEnd.or.origin, fog->surface ); - - eyeT = DotProduct( backEnd.or.viewOrigin, fogDepthVector ) + fogDepthVector[3]; - } else { - eyeT = 1; // non-surface fog always has eye inside - } - - // see if the viewpoint is outside - // this is needed for clipping distance even for constant fog - - if ( eyeT < 0 ) { - eyeOutside = qtrue; - } else { - eyeOutside = qfalse; - } - - fogDistanceVector[3] += 1.0/512; - - // calculate density for each point - for (i = 0, v = tess.xyz[0] ; i < tess.numVertexes ; i++, v += 4) { - // calculate the length in fog - s = DotProduct( v, fogDistanceVector ) + fogDistanceVector[3]; - t = DotProduct( v, fogDepthVector ) + fogDepthVector[3]; - - // partially clipped fogs use the T axis - if ( eyeOutside ) { - if ( t < 1.0 ) { - t = 1.0/32; // point is outside, so no fogging - } else { - t = 1.0/32 + 30.0/32 * t / ( t - eyeT ); // cut the distance at the fog plane - } - } else { - if ( t < 0 ) { - t = 1.0/32; // point is outside, so no fogging - } else { - t = 31.0/32; - } - } - - st[0] = s; - st[1] = t; - st += 2; - } -} - -/* -** RB_CalcTurbulentFactors -*/ -void RB_CalcTurbulentFactors( const waveForm_t *wf, float *amplitude, float *now ) -{ - *now = wf->phase + tess.shaderTime * wf->frequency; - *amplitude = wf->amplitude; -} - -/* -** RB_CalcScaleTexMatrix -*/ -void RB_CalcScaleTexMatrix( const float scale[2], float *matrix ) -{ - matrix[0] = scale[0]; matrix[2] = 0.0f; matrix[4] = 0.0f; - matrix[1] = 0.0f; matrix[3] = scale[1]; matrix[5] = 0.0f; -} - -/* -** RB_CalcScrollTexMatrix -*/ -void RB_CalcScrollTexMatrix( const float scrollSpeed[2], float *matrix ) -{ - double timeScale = tess.shaderTime; - double adjustedScrollS, adjustedScrollT; - - adjustedScrollS = scrollSpeed[0] * timeScale; - adjustedScrollT = scrollSpeed[1] * timeScale; - - // clamp so coordinates don't continuously get larger, causing problems - // with hardware limits - adjustedScrollS = adjustedScrollS - floor( adjustedScrollS ); - adjustedScrollT = adjustedScrollT - floor( adjustedScrollT ); - - matrix[0] = 1.0f; matrix[2] = 0.0f; matrix[4] = adjustedScrollS; - matrix[1] = 0.0f; matrix[3] = 1.0f; matrix[5] = adjustedScrollT; -} - -/* -** RB_CalcTransformTexMatrix -*/ -void RB_CalcTransformTexMatrix( const texModInfo_t *tmi, float *matrix ) -{ - matrix[0] = tmi->matrix[0][0]; matrix[2] = tmi->matrix[1][0]; matrix[4] = tmi->translate[0]; - matrix[1] = tmi->matrix[0][1]; matrix[3] = tmi->matrix[1][1]; matrix[5] = tmi->translate[1]; -} - -/* -** RB_CalcRotateTexMatrix -*/ -void RB_CalcRotateTexMatrix( float degsPerSecond, float *matrix ) -{ - double timeScale = tess.shaderTime; // -EC- set to double - double degs; // -EC- set to double - int64_t index; - float sinValue, cosValue; - - degs = -degsPerSecond * timeScale; - index = degs * ( FUNCTABLE_SIZE / 360.0f ); - - sinValue = tr.sinTable[ index & FUNCTABLE_MASK ]; - cosValue = tr.sinTable[ ( index + FUNCTABLE_SIZE / 4 ) & FUNCTABLE_MASK ]; - - matrix[0] = cosValue; matrix[2] = -sinValue; matrix[4] = 0.5 - 0.5 * cosValue + 0.5 * sinValue; - matrix[1] = sinValue; matrix[3] = cosValue; matrix[5] = 0.5 - 0.5 * sinValue - 0.5 * cosValue; -} diff --git a/code/renderer2/tr_shader.c b/code/renderer2/tr_shader.c deleted file mode 100644 index 34c8cb9d9a..0000000000 --- a/code/renderer2/tr_shader.c +++ /dev/null @@ -1,4218 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -#include "tr_local.h" - -// tr_shader.c -- this file deals with the parsing and definition of shaders - -static char *s_shaderText; - -static const char *s_extensionOffset; -static int s_extendedShader; - -// the shader is parsed into these global variables, then copied into -// dynamically allocated memory if it is valid. -static shaderStage_t stages[MAX_SHADER_STAGES]; -static shader_t shader; -static texModInfo_t texMods[MAX_SHADER_STAGES][TR_MAX_TEXMODS]; - -#define FILE_HASH_SIZE 1024 -static shader_t* hashTable[FILE_HASH_SIZE]; - -#define MAX_SHADERTEXT_HASH 2048 -static const char **shaderTextHashTable[MAX_SHADERTEXT_HASH]; - -/* -================ -return a hash value for the filename -================ -*/ -#ifdef __GNUCC__ - #warning TODO: check if long is ok here -#endif - -#define generateHashValue Com_GenerateHashValue - -void R_RemapShader(const char *shaderName, const char *newShaderName, const char *timeOffset) { - char strippedName[MAX_QPATH]; - int hash; - shader_t *sh, *sh2; - qhandle_t h; - - sh = R_FindShaderByName( shaderName ); - if (sh == NULL || sh == tr.defaultShader) { - h = RE_RegisterShaderLightMap(shaderName, 0); - sh = R_GetShaderByHandle(h); - } - if (sh == NULL || sh == tr.defaultShader) { - ri.Printf( PRINT_WARNING, "WARNING: R_RemapShader: shader %s not found\n", shaderName ); - return; - } - - sh2 = R_FindShaderByName( newShaderName ); - if (sh2 == NULL || sh2 == tr.defaultShader) { - h = RE_RegisterShaderLightMap(newShaderName, 0); - sh2 = R_GetShaderByHandle(h); - } - - if (sh2 == NULL || sh2 == tr.defaultShader) { - ri.Printf( PRINT_WARNING, "WARNING: R_RemapShader: new shader %s not found\n", newShaderName ); - return; - } - - // remap all the shaders with the given name - // even tho they might have different lightmaps - COM_StripExtension(shaderName, strippedName, sizeof(strippedName)); - hash = generateHashValue(strippedName, FILE_HASH_SIZE); - for (sh = hashTable[hash]; sh; sh = sh->next) { - if (Q_stricmp(sh->name, strippedName) == 0) { - if (sh != sh2) { - sh->remappedShader = sh2; - } else { - sh->remappedShader = NULL; - } - } - } - - if ( timeOffset ) { - sh2->timeOffset = Q_atof( timeOffset ); - } -} - -/* -=============== -ParseVector -=============== -*/ -static qboolean ParseVector( const char **text, int count, float *v ) { - const char *token; - int i; - - // FIXME: spaces are currently required after parens, should change parseext... - token = COM_ParseExt( text, qfalse ); - if ( strcmp( token, "(" ) ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parenthesis in shader '%s'\n", shader.name ); - return qfalse; - } - - for ( i = 0 ; i < count ; i++ ) { - token = COM_ParseExt( text, qfalse ); - if ( !token[0] ) { - ri.Printf( PRINT_WARNING, "WARNING: missing vector element in shader '%s'\n", shader.name ); - return qfalse; - } - v[i] = Q_atof( token ); - } - - token = COM_ParseExt( text, qfalse ); - if ( strcmp( token, ")" ) ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parenthesis in shader '%s'\n", shader.name ); - return qfalse; - } - - return qtrue; -} - - -/* -=============== -NameToAFunc -=============== -*/ -static unsigned NameToAFunc( const char *funcname ) -{ - if ( !Q_stricmp( funcname, "GT0" ) ) - { - return GLS_ATEST_GT_0; - } - else if ( !Q_stricmp( funcname, "LT128" ) ) - { - return GLS_ATEST_LT_80; - } - else if ( !Q_stricmp( funcname, "GE128" ) ) - { - return GLS_ATEST_GE_80; - } - - ri.Printf( PRINT_WARNING, "WARNING: invalid alphaFunc name '%s' in shader '%s'\n", funcname, shader.name ); - return 0; -} - - -/* -=============== -NameToSrcBlendMode -=============== -*/ -static int NameToSrcBlendMode( const char *name ) -{ - if ( !Q_stricmp( name, "GL_ONE" ) ) - { - return GLS_SRCBLEND_ONE; - } - else if ( !Q_stricmp( name, "GL_ZERO" ) ) - { - return GLS_SRCBLEND_ZERO; - } - else if ( !Q_stricmp( name, "GL_DST_COLOR" ) ) - { - return GLS_SRCBLEND_DST_COLOR; - } - else if ( !Q_stricmp( name, "GL_ONE_MINUS_DST_COLOR" ) ) - { - return GLS_SRCBLEND_ONE_MINUS_DST_COLOR; - } - else if ( !Q_stricmp( name, "GL_SRC_ALPHA" ) ) - { - return GLS_SRCBLEND_SRC_ALPHA; - } - else if ( !Q_stricmp( name, "GL_ONE_MINUS_SRC_ALPHA" ) ) - { - return GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA; - } - else if ( !Q_stricmp( name, "GL_DST_ALPHA" ) ) - { - if (r_ignoreDstAlpha->integer) - return GLS_SRCBLEND_ONE; - - return GLS_SRCBLEND_DST_ALPHA; - } - else if ( !Q_stricmp( name, "GL_ONE_MINUS_DST_ALPHA" ) ) - { - if (r_ignoreDstAlpha->integer) - return GLS_SRCBLEND_ZERO; - - return GLS_SRCBLEND_ONE_MINUS_DST_ALPHA; - } - else if ( !Q_stricmp( name, "GL_SRC_ALPHA_SATURATE" ) ) - { - return GLS_SRCBLEND_ALPHA_SATURATE; - } - - ri.Printf( PRINT_WARNING, "WARNING: unknown blend mode '%s' in shader '%s', substituting GL_ONE\n", name, shader.name ); - return GLS_SRCBLEND_ONE; -} - -/* -=============== -NameToDstBlendMode -=============== -*/ -static int NameToDstBlendMode( const char *name ) -{ - if ( !Q_stricmp( name, "GL_ONE" ) ) - { - return GLS_DSTBLEND_ONE; - } - else if ( !Q_stricmp( name, "GL_ZERO" ) ) - { - return GLS_DSTBLEND_ZERO; - } - else if ( !Q_stricmp( name, "GL_SRC_ALPHA" ) ) - { - return GLS_DSTBLEND_SRC_ALPHA; - } - else if ( !Q_stricmp( name, "GL_ONE_MINUS_SRC_ALPHA" ) ) - { - return GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; - } - else if ( !Q_stricmp( name, "GL_DST_ALPHA" ) ) - { - if (r_ignoreDstAlpha->integer) - return GLS_DSTBLEND_ONE; - - return GLS_DSTBLEND_DST_ALPHA; - } - else if ( !Q_stricmp( name, "GL_ONE_MINUS_DST_ALPHA" ) ) - { - if (r_ignoreDstAlpha->integer) - return GLS_DSTBLEND_ZERO; - - return GLS_DSTBLEND_ONE_MINUS_DST_ALPHA; - } - else if ( !Q_stricmp( name, "GL_SRC_COLOR" ) ) - { - return GLS_DSTBLEND_SRC_COLOR; - } - else if ( !Q_stricmp( name, "GL_ONE_MINUS_SRC_COLOR" ) ) - { - return GLS_DSTBLEND_ONE_MINUS_SRC_COLOR; - } - - ri.Printf( PRINT_WARNING, "WARNING: unknown blend mode '%s' in shader '%s', substituting GL_ONE\n", name, shader.name ); - return GLS_DSTBLEND_ONE; -} - -/* -=============== -NameToGenFunc -=============== -*/ -static genFunc_t NameToGenFunc( const char *funcname ) -{ - if ( !Q_stricmp( funcname, "sin" ) ) - { - return GF_SIN; - } - else if ( !Q_stricmp( funcname, "square" ) ) - { - return GF_SQUARE; - } - else if ( !Q_stricmp( funcname, "triangle" ) ) - { - return GF_TRIANGLE; - } - else if ( !Q_stricmp( funcname, "sawtooth" ) ) - { - return GF_SAWTOOTH; - } - else if ( !Q_stricmp( funcname, "inversesawtooth" ) ) - { - return GF_INVERSE_SAWTOOTH; - } - else if ( !Q_stricmp( funcname, "noise" ) ) - { - return GF_NOISE; - } - - ri.Printf( PRINT_WARNING, "WARNING: invalid genfunc name '%s' in shader '%s'\n", funcname, shader.name ); - return GF_SIN; -} - - -/* -=================== -ParseWaveForm -=================== -*/ -static void ParseWaveForm( const char **text, waveForm_t *wave ) -{ - const char *token; - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); - return; - } - wave->func = NameToGenFunc( token ); - - // BASE, AMP, PHASE, FREQ - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); - return; - } - wave->base = Q_atof( token ); - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); - return; - } - wave->amplitude = Q_atof( token ); - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); - return; - } - wave->phase = Q_atof( token ); - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); - return; - } - wave->frequency = Q_atof( token ); -} - - -/* -=================== -ParseTexMod -=================== -*/ -static void ParseTexMod( const char *_text, shaderStage_t *stage ) -{ - const char *token; - const char **text = &_text; - texModInfo_t *tmi; - - if ( stage->bundle[0].numTexMods == TR_MAX_TEXMODS ) { - ri.Error( ERR_DROP, "ERROR: too many tcMod stages in shader '%s'", shader.name ); - return; - } - - tmi = &stage->bundle[0].texMods[stage->bundle[0].numTexMods]; - stage->bundle[0].numTexMods++; - - token = COM_ParseExt( text, qfalse ); - - // - // turb - // - if ( !Q_stricmp( token, "turb" ) ) - { - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing tcMod turb parms in shader '%s'\n", shader.name ); - return; - } - tmi->wave.base = Q_atof( token ); - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing tcMod turb in shader '%s'\n", shader.name ); - return; - } - tmi->wave.amplitude = Q_atof( token ); - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing tcMod turb in shader '%s'\n", shader.name ); - return; - } - tmi->wave.phase = Q_atof( token ); - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing tcMod turb in shader '%s'\n", shader.name ); - return; - } - tmi->wave.frequency = Q_atof( token ); - - tmi->type = TMOD_TURBULENT; - } - // - // scale - // - else if ( !Q_stricmp( token, "scale" ) ) - { - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing scale parms in shader '%s'\n", shader.name ); - return; - } - tmi->scale[0] = Q_atof( token ); - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing scale parms in shader '%s'\n", shader.name ); - return; - } - tmi->scale[1] = Q_atof( token ); - tmi->type = TMOD_SCALE; - } - // - // scroll - // - else if ( !Q_stricmp( token, "scroll" ) ) - { - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing scale scroll parms in shader '%s'\n", shader.name ); - return; - } - tmi->scroll[0] = Q_atof( token ); - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing scale scroll parms in shader '%s'\n", shader.name ); - return; - } - tmi->scroll[1] = Q_atof( token ); - tmi->type = TMOD_SCROLL; - } - // - // stretch - // - else if ( !Q_stricmp( token, "stretch" ) ) - { - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); - return; - } - tmi->wave.func = NameToGenFunc( token ); - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); - return; - } - tmi->wave.base = atof( token ); - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); - return; - } - tmi->wave.amplitude = Q_atof( token ); - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); - return; - } - tmi->wave.phase = Q_atof( token ); - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); - return; - } - tmi->wave.frequency = Q_atof( token ); - - tmi->type = TMOD_STRETCH; - } - // - // transform - // - else if ( !Q_stricmp( token, "transform" ) ) - { - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); - return; - } - tmi->matrix[0][0] = Q_atof( token ); - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); - return; - } - tmi->matrix[0][1] = Q_atof( token ); - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); - return; - } - tmi->matrix[1][0] = Q_atof( token ); - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); - return; - } - tmi->matrix[1][1] = Q_atof( token ); - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); - return; - } - tmi->translate[0] = Q_atof( token ); - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); - return; - } - tmi->translate[1] = Q_atof( token ); - - tmi->type = TMOD_TRANSFORM; - } - // - // rotate - // - else if ( !Q_stricmp( token, "rotate" ) ) - { - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing tcMod rotate parms in shader '%s'\n", shader.name ); - return; - } - tmi->rotateSpeed = Q_atof( token ); - tmi->type = TMOD_ROTATE; - } - // - // entityTranslate - // - else if ( !Q_stricmp( token, "entityTranslate" ) ) - { - tmi->type = TMOD_ENTITY_TRANSLATE; - } - else - { - ri.Printf( PRINT_WARNING, "WARNING: unknown tcMod '%s' in shader '%s'\n", token, shader.name ); - } -} - - -/* -=================== -ParseStage -=================== -*/ -static qboolean ParseStage( shaderStage_t *stage, const char **text ) -{ - const char *token; - int depthMaskBits = GLS_DEPTHMASK_TRUE, blendSrcBits = 0, blendDstBits = 0, atestBits = 0, depthFuncBits = 0; - qboolean depthMaskExplicit = qfalse; - - stage->active = qtrue; - - while ( 1 ) - { - token = COM_ParseExt( text, qtrue ); - if ( !token[0] ) - { - ri.Printf( PRINT_WARNING, "WARNING: no matching '}' found\n" ); - return qfalse; - } - - if ( token[0] == '}' ) - { - break; - } - // - // map - // - else if ( !Q_stricmp( token, "map" ) ) - { - token = COM_ParseExt( text, qfalse ); - if ( !token[0] ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'map' keyword in shader '%s'\n", shader.name ); - return qfalse; - } - - if ( !Q_stricmp( token, "$whiteimage" ) ) - { - stage->bundle[0].image[0] = tr.whiteImage; - continue; - } - else if ( !Q_stricmp( token, "$lightmap" ) ) - { - stage->bundle[0].isLightmap = qtrue; - if ( shader.lightmapIndex < 0 || !tr.lightmaps ) { - stage->bundle[0].image[0] = tr.whiteImage; - } else { - stage->bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex]; - } - continue; - } - else if ( !Q_stricmp( token, "$deluxemap" ) ) - { - if (!tr.worldDeluxeMapping) - { - ri.Printf( PRINT_WARNING, "WARNING: shader '%s' wants a deluxe map in a map compiled without them\n", shader.name ); - return qfalse; - } - - stage->bundle[0].isLightmap = qtrue; - if ( shader.lightmapIndex < 0 ) { - stage->bundle[0].image[0] = tr.whiteImage; - } else { - stage->bundle[0].image[0] = tr.deluxemaps[shader.lightmapIndex]; - } - continue; - } - else - { - imgType_t type = IMGTYPE_COLORALPHA; - imgFlags_t flags = IMGFLAG_NONE; - - if (!shader.noMipMaps) - flags |= IMGFLAG_MIPMAP; - - if (!shader.noPicMip) - flags |= IMGFLAG_PICMIP; - - if (stage->type == ST_NORMALMAP || stage->type == ST_NORMALPARALLAXMAP) - { - type = IMGTYPE_NORMAL; - flags |= IMGFLAG_NOLIGHTSCALE; - - if (stage->type == ST_NORMALPARALLAXMAP) - type = IMGTYPE_NORMALHEIGHT; - } - else - { - if (r_genNormalMaps->integer) - flags |= IMGFLAG_GENNORMALMAP; - } - - stage->bundle[0].image[0] = R_FindImageFile( token, type, flags ); - - if ( !stage->bundle[0].image[0] ) - { - ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); - return qfalse; - } - } - } - // - // clampmap - // - else if ( !Q_stricmp( token, "clampmap" ) ) - { - imgType_t type = IMGTYPE_COLORALPHA; - imgFlags_t flags = IMGFLAG_CLAMPTOEDGE; - - token = COM_ParseExt( text, qfalse ); - if ( !token[0] ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'clampmap' keyword in shader '%s'\n", shader.name ); - return qfalse; - } - - if (!shader.noMipMaps) - flags |= IMGFLAG_MIPMAP; - - if (!shader.noPicMip) - flags |= IMGFLAG_PICMIP; - - if (stage->type == ST_NORMALMAP || stage->type == ST_NORMALPARALLAXMAP) - { - type = IMGTYPE_NORMAL; - flags |= IMGFLAG_NOLIGHTSCALE; - - if (stage->type == ST_NORMALPARALLAXMAP) - type = IMGTYPE_NORMALHEIGHT; - } - else - { - if (r_genNormalMaps->integer) - flags |= IMGFLAG_GENNORMALMAP; - } - - - stage->bundle[0].image[0] = R_FindImageFile( token, type, flags ); - if ( !stage->bundle[0].image[0] ) - { - ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); - return qfalse; - } - } - // - // animMap .... - // - else if ( !Q_stricmp( token, "animMap" ) ) - { - int totalImages = 0; - int maxAnimations = s_extendedShader ? MAX_IMAGE_ANIMATIONS : MAX_IMAGE_ANIMATIONS_VQ3; - - token = COM_ParseExt( text, qfalse ); - if ( !token[0] ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'animMap' keyword in shader '%s'\n", shader.name ); - return qfalse; - } - stage->bundle[0].imageAnimationSpeed = Q_atof( token ); - - // parse up to MAX_IMAGE_ANIMATIONS animations - while ( 1 ) { - int num; - - token = COM_ParseExt( text, qfalse ); - if ( !token[0] ) { - break; - } - num = stage->bundle[0].numImageAnimations; - if ( num < maxAnimations ) { - imgFlags_t flags = IMGFLAG_NONE; - - if (!shader.noMipMaps) - flags |= IMGFLAG_MIPMAP; - - if (!shader.noPicMip) - flags |= IMGFLAG_PICMIP; - - stage->bundle[0].image[num] = R_FindImageFile( token, IMGTYPE_COLORALPHA, flags ); - if ( !stage->bundle[0].image[num] ) - { - ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); - return qfalse; - } - stage->bundle[0].numImageAnimations++; - } - totalImages++; - } - - if ( totalImages > maxAnimations ) { - ri.Printf( PRINT_WARNING, "WARNING: ignoring excess images for 'animMap' (found %d, max is %d) in shader '%s'\n", - totalImages, maxAnimations, shader.name ); - } - } - else if ( !Q_stricmp( token, "videoMap" ) ) - { - token = COM_ParseExt( text, qfalse ); - if ( !token[0] ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'videoMap' keyword in shader '%s'\n", shader.name ); - return qfalse; - } - stage->bundle[0].videoMapHandle = ri.CIN_PlayCinematic( token, 0, 0, 256, 256, (CIN_loop | CIN_silent | CIN_shader)); - if (stage->bundle[0].videoMapHandle != -1) { - stage->bundle[0].isVideoMap = qtrue; - stage->bundle[0].image[0] = tr.scratchImage[stage->bundle[0].videoMapHandle]; - } else { - ri.Printf( PRINT_WARNING, "WARNING: could not load '%s' for 'videoMap' keyword in shader '%s'\n", token, shader.name ); - } - } - // - // alphafunc - // - else if ( !Q_stricmp( token, "alphaFunc" ) ) - { - token = COM_ParseExt( text, qfalse ); - if ( !token[0] ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'alphaFunc' keyword in shader '%s'\n", shader.name ); - return qfalse; - } - - atestBits = NameToAFunc( token ); - } - // - // depthFunc - // - else if ( !Q_stricmp( token, "depthfunc" ) ) - { - token = COM_ParseExt( text, qfalse ); - - if ( !token[0] ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'depthfunc' keyword in shader '%s'\n", shader.name ); - return qfalse; - } - - if ( !Q_stricmp( token, "lequal" ) ) - { - depthFuncBits = 0; - } - else if ( !Q_stricmp( token, "equal" ) ) - { - depthFuncBits = GLS_DEPTHFUNC_EQUAL; - } - else - { - ri.Printf( PRINT_WARNING, "WARNING: unknown depthfunc '%s' in shader '%s'\n", token, shader.name ); - continue; - } - } - // - // detail - // - else if ( !Q_stricmp( token, "detail" ) ) - { - stage->isDetail = qtrue; - } - // - // blendfunc - // or blendfunc - // - else if ( !Q_stricmp( token, "blendfunc" ) ) - { - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing parm for blendFunc in shader '%s'\n", shader.name ); - continue; - } - // check for "simple" blends first - if ( !Q_stricmp( token, "add" ) ) { - blendSrcBits = GLS_SRCBLEND_ONE; - blendDstBits = GLS_DSTBLEND_ONE; - } else if ( !Q_stricmp( token, "filter" ) ) { - blendSrcBits = GLS_SRCBLEND_DST_COLOR; - blendDstBits = GLS_DSTBLEND_ZERO; - } else if ( !Q_stricmp( token, "blend" ) ) { - blendSrcBits = GLS_SRCBLEND_SRC_ALPHA; - blendDstBits = GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; - } else { - // complex double blends - blendSrcBits = NameToSrcBlendMode( token ); - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing parm for blendFunc in shader '%s'\n", shader.name ); - continue; - } - blendDstBits = NameToDstBlendMode( token ); - } - - // clear depth mask for blended surfaces - if ( !depthMaskExplicit ) - { - depthMaskBits = 0; - } - } - // - // stage - // - else if(!Q_stricmp(token, "stage")) - { - token = COM_ParseExt(text, qfalse); - if(token[0] == 0) - { - ri.Printf(PRINT_WARNING, "WARNING: missing parameters for stage in shader '%s'\n", shader.name); - continue; - } - - if(!Q_stricmp(token, "diffuseMap")) - { - stage->type = ST_DIFFUSEMAP; - } - else if(!Q_stricmp(token, "normalMap") || !Q_stricmp(token, "bumpMap")) - { - stage->type = ST_NORMALMAP; - VectorSet4(stage->normalScale, r_baseNormalX->value, r_baseNormalY->value, 1.0f, r_baseParallax->value); - } - else if(!Q_stricmp(token, "normalParallaxMap") || !Q_stricmp(token, "bumpParallaxMap")) - { - if (r_parallaxMapping->integer) - stage->type = ST_NORMALPARALLAXMAP; - else - stage->type = ST_NORMALMAP; - VectorSet4(stage->normalScale, r_baseNormalX->value, r_baseNormalY->value, 1.0f, r_baseParallax->value); - } - else if(!Q_stricmp(token, "specularMap")) - { - stage->type = ST_SPECULARMAP; - VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); - } - else - { - ri.Printf(PRINT_WARNING, "WARNING: unknown stage parameter '%s' in shader '%s'\n", token, shader.name); - continue; - } - } - // - // specularReflectance - // - else if (!Q_stricmp(token, "specularreflectance")) - { - token = COM_ParseExt(text, qfalse); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for specular reflectance in shader '%s'\n", shader.name ); - continue; - } - - if (r_pbr->integer) - { - // interpret specularReflectance < 0.5 as nonmetal - stage->specularScale[1] = (atof(token) < 0.5f) ? 0.0f : 1.0f; - } - else - { - stage->specularScale[0] = - stage->specularScale[1] = - stage->specularScale[2] = atof( token ); - } - } - // - // specularExponent - // - else if (!Q_stricmp(token, "specularexponent")) - { - float exponent; - - token = COM_ParseExt(text, qfalse); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for specular exponent in shader '%s'\n", shader.name ); - continue; - } - - exponent = atof( token ); - - if (r_pbr->integer) - stage->specularScale[0] = 1.0f - powf(2.0f / (exponent + 2.0), 0.25); - else - { - // Change shininess to gloss - // Assumes max exponent of 8190 and min of 0, must change here if altered in lightall_fp.glsl - exponent = CLAMP(exponent, 0.0f, 8190.0f); - stage->specularScale[3] = (Q_log2f(exponent + 2.0f) - 1.0f) / 12.0f; - } - } - // - // gloss - // - else if (!Q_stricmp(token, "gloss")) - { - float gloss; - - token = COM_ParseExt(text, qfalse); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for gloss in shader '%s'\n", shader.name ); - continue; - } - - gloss = atof(token); - - if (r_pbr->integer) - stage->specularScale[0] = 1.0f - Q_exp2f(-3.0f * gloss); - else - stage->specularScale[3] = gloss; - } - // - // roughness - // - else if (!Q_stricmp(token, "roughness")) - { - float roughness; - - token = COM_ParseExt(text, qfalse); - if (token[0] == 0) - { - ri.Printf(PRINT_WARNING, "WARNING: missing parameter for roughness in shader '%s'\n", shader.name); - continue; - } - - roughness = atof(token); - - if (r_pbr->integer) - stage->specularScale[0] = 1.0 - roughness; - else - { - if (roughness >= 0.125) - stage->specularScale[3] = Q_log2f(1.0f / roughness) / 3.0f; - else - stage->specularScale[3] = 1.0f; - } - } - // - // parallaxDepth - // - else if (!Q_stricmp(token, "parallaxdepth")) - { - token = COM_ParseExt(text, qfalse); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for parallaxDepth in shader '%s'\n", shader.name ); - continue; - } - - stage->normalScale[3] = atof( token ); - } - // - // normalScale - // or normalScale - // or normalScale - // - else if (!Q_stricmp(token, "normalscale")) - { - token = COM_ParseExt(text, qfalse); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for normalScale in shader '%s'\n", shader.name ); - continue; - } - - stage->normalScale[0] = atof( token ); - - token = COM_ParseExt(text, qfalse); - if ( token[0] == 0 ) - { - // one value, applies to X/Y - stage->normalScale[1] = stage->normalScale[0]; - continue; - } - - stage->normalScale[1] = atof( token ); - - token = COM_ParseExt(text, qfalse); - if ( token[0] == 0 ) - { - // two values, no height - continue; - } - - stage->normalScale[3] = atof( token ); - } - // - // specularScale - // or specularScale with r_pbr 1 - // or specularScale - // or specularScale - // - else if (!Q_stricmp(token, "specularscale")) - { - token = COM_ParseExt(text, qfalse); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for specularScale in shader '%s'\n", shader.name ); - continue; - } - - stage->specularScale[0] = atof( token ); - - token = COM_ParseExt(text, qfalse); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for specularScale in shader '%s'\n", shader.name ); - continue; - } - - stage->specularScale[1] = atof( token ); - - token = COM_ParseExt(text, qfalse); - if ( token[0] == 0 ) - { - if (r_pbr->integer) - { - // two values, metallic then smoothness - float smoothness = stage->specularScale[1]; - stage->specularScale[1] = (stage->specularScale[0] < 0.5f) ? 0.0f : 1.0f; - stage->specularScale[0] = smoothness; - } - else - { - // two values, rgb then gloss - stage->specularScale[3] = stage->specularScale[1]; - stage->specularScale[1] = - stage->specularScale[2] = stage->specularScale[0]; - } - continue; - } - - stage->specularScale[2] = atof( token ); - - token = COM_ParseExt(text, qfalse); - if ( token[0] == 0 ) - { - // three values, rgb - continue; - } - - stage->specularScale[3] = atof( token ); - - } - // - // rgbGen - // - else if ( !Q_stricmp( token, "rgbGen" ) ) - { - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing parameters for rgbGen in shader '%s'\n", shader.name ); - continue; - } - - if ( !Q_stricmp( token, "wave" ) ) - { - ParseWaveForm( text, &stage->rgbWave ); - stage->rgbGen = CGEN_WAVEFORM; - } - else if ( !Q_stricmp( token, "const" ) ) - { - vec3_t color; - - VectorClear( color ); - - ParseVector( text, 3, color ); - stage->constantColor[0] = 255 * color[0]; - stage->constantColor[1] = 255 * color[1]; - stage->constantColor[2] = 255 * color[2]; - - stage->rgbGen = CGEN_CONST; - } - else if ( !Q_stricmp( token, "identity" ) ) - { - stage->rgbGen = CGEN_IDENTITY; - } - else if ( !Q_stricmp( token, "identityLighting" ) ) - { - stage->rgbGen = CGEN_IDENTITY_LIGHTING; - } - else if ( !Q_stricmp( token, "entity" ) ) - { - stage->rgbGen = CGEN_ENTITY; - } - else if ( !Q_stricmp( token, "oneMinusEntity" ) ) - { - stage->rgbGen = CGEN_ONE_MINUS_ENTITY; - } - else if ( !Q_stricmp( token, "vertex" ) ) - { - stage->rgbGen = CGEN_VERTEX; - if ( stage->alphaGen == 0 ) { - stage->alphaGen = AGEN_VERTEX; - } - } - else if ( !Q_stricmp( token, "exactVertex" ) ) - { - stage->rgbGen = CGEN_EXACT_VERTEX; - } - else if ( !Q_stricmp( token, "vertexLit" ) ) - { - stage->rgbGen = CGEN_VERTEX_LIT; - if ( stage->alphaGen == 0 ) { - stage->alphaGen = AGEN_VERTEX; - } - } - else if ( !Q_stricmp( token, "exactVertexLit" ) ) - { - stage->rgbGen = CGEN_EXACT_VERTEX_LIT; - } - else if ( !Q_stricmp( token, "lightingDiffuse" ) ) - { - stage->rgbGen = CGEN_LIGHTING_DIFFUSE; - } - else if ( !Q_stricmp( token, "oneMinusVertex" ) ) - { - stage->rgbGen = CGEN_ONE_MINUS_VERTEX; - } - else - { - ri.Printf( PRINT_WARNING, "WARNING: unknown rgbGen parameter '%s' in shader '%s'\n", token, shader.name ); - continue; - } - } - // - // alphaGen - // - else if ( !Q_stricmp( token, "alphaGen" ) ) - { - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing parameters for alphaGen in shader '%s'\n", shader.name ); - continue; - } - - if ( !Q_stricmp( token, "wave" ) ) - { - ParseWaveForm( text, &stage->alphaWave ); - stage->alphaGen = AGEN_WAVEFORM; - } - else if ( !Q_stricmp( token, "const" ) ) - { - token = COM_ParseExt( text, qfalse ); - stage->constantColor[3] = 255 * Q_atof( token ); - stage->alphaGen = AGEN_CONST; - } - else if ( !Q_stricmp( token, "identity" ) ) - { - stage->alphaGen = AGEN_IDENTITY; - } - else if ( !Q_stricmp( token, "entity" ) ) - { - stage->alphaGen = AGEN_ENTITY; - } - else if ( !Q_stricmp( token, "oneMinusEntity" ) ) - { - stage->alphaGen = AGEN_ONE_MINUS_ENTITY; - } - else if ( !Q_stricmp( token, "vertex" ) ) - { - stage->alphaGen = AGEN_VERTEX; - } - else if ( !Q_stricmp( token, "lightingSpecular" ) ) - { - stage->alphaGen = AGEN_LIGHTING_SPECULAR; - } - else if ( !Q_stricmp( token, "oneMinusVertex" ) ) - { - stage->alphaGen = AGEN_ONE_MINUS_VERTEX; - } - else if ( !Q_stricmp( token, "portal" ) ) - { - stage->alphaGen = AGEN_PORTAL; - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - shader.portalRange = 256; - ri.Printf( PRINT_WARNING, "WARNING: missing range parameter for alphaGen portal in shader '%s', defaulting to 256\n", shader.name ); - } - else - { - shader.portalRange = Q_atof( token ); - } - } - else - { - ri.Printf( PRINT_WARNING, "WARNING: unknown alphaGen parameter '%s' in shader '%s'\n", token, shader.name ); - continue; - } - } - // - // tcGen - // - else if ( !Q_stricmp(token, "texgen") || !Q_stricmp( token, "tcGen" ) ) - { - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing texgen parm in shader '%s'\n", shader.name ); - continue; - } - - if ( !Q_stricmp( token, "environment" ) ) - { - const char *t = *text; - stage->bundle[0].tcGen = TCGEN_ENVIRONMENT_MAPPED; - token = COM_ParseExt( text, qfalse ); - if ( Q_stricmp( token, "firstPerson" ) == 0 ) - { - //stage->bundle[0].tcGen = TCGEN_ENVIRONMENT_MAPPED_FP; - } - else - { - *text = t; // rewind - } - } - else if ( !Q_stricmp( token, "lightmap" ) ) - { - stage->bundle[0].tcGen = TCGEN_LIGHTMAP; - } - else if ( !Q_stricmp( token, "texture" ) || !Q_stricmp( token, "base" ) ) - { - stage->bundle[0].tcGen = TCGEN_TEXTURE; - } - else if ( !Q_stricmp( token, "vector" ) ) - { - ParseVector( text, 3, stage->bundle[0].tcGenVectors[0] ); - ParseVector( text, 3, stage->bundle[0].tcGenVectors[1] ); - - stage->bundle[0].tcGen = TCGEN_VECTOR; - } - else - { - ri.Printf( PRINT_WARNING, "WARNING: unknown texgen parm in shader '%s'\n", shader.name ); - } - } - // - // tcMod <...> - // - else if ( !Q_stricmp( token, "tcMod" ) ) - { - char buffer[1024] = ""; - - while ( 1 ) - { - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - break; - Q_strcat( buffer, sizeof (buffer), token ); - Q_strcat( buffer, sizeof (buffer), " " ); - } - - ParseTexMod( buffer, stage ); - - continue; - } - // - // depthmask - // - else if ( !Q_stricmp( token, "depthwrite" ) ) - { - depthMaskBits = GLS_DEPTHMASK_TRUE; - depthMaskExplicit = qtrue; - - continue; - } - else if ( !Q_stricmp( token, "depthFragment" ) ) - { - continue; - } - else - { - ri.Printf( PRINT_WARNING, "WARNING: unknown parameter '%s' in shader '%s'\n", token, shader.name ); - return qfalse; - } - } - - // - // if cgen isn't explicitly specified, use either identity or identitylighting - // - if ( stage->rgbGen == CGEN_BAD ) { - if ( blendSrcBits == 0 || - blendSrcBits == GLS_SRCBLEND_ONE || - blendSrcBits == GLS_SRCBLEND_SRC_ALPHA ) { - stage->rgbGen = CGEN_IDENTITY_LIGHTING; - } else { - stage->rgbGen = CGEN_IDENTITY; - } - } - - - // - // implicitly assume that a GL_ONE GL_ZERO blend mask disables blending - // - if ( ( blendSrcBits == GLS_SRCBLEND_ONE ) && - ( blendDstBits == GLS_DSTBLEND_ZERO ) ) - { - blendDstBits = blendSrcBits = 0; - depthMaskBits = GLS_DEPTHMASK_TRUE; - } - - // decide which agens we can skip - if ( stage->alphaGen == AGEN_IDENTITY ) { - if ( stage->rgbGen == CGEN_IDENTITY - || stage->rgbGen == CGEN_LIGHTING_DIFFUSE ) { - stage->alphaGen = AGEN_SKIP; - } - } - - // - // compute state bits - // - stage->stateBits = depthMaskBits | - blendSrcBits | blendDstBits | - atestBits | - depthFuncBits; - - return qtrue; -} - - -/* -=============== -ParseDeform - -deformVertexes wave -deformVertexes normal -deformVertexes move -deformVertexes bulge -deformVertexes projectionShadow -deformVertexes autoSprite -deformVertexes autoSprite2 -deformVertexes text[0-7] -=============== -*/ -static void ParseDeform( const char **text ) { - const char *token; - deformStage_t *ds; - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing deform parm in shader '%s'\n", shader.name ); - return; - } - - if ( shader.numDeforms == MAX_SHADER_DEFORMS ) { - ri.Printf( PRINT_WARNING, "WARNING: MAX_SHADER_DEFORMS in '%s'\n", shader.name ); - return; - } - - ds = &shader.deforms[ shader.numDeforms ]; - shader.numDeforms++; - - if ( !Q_stricmp( token, "projectionShadow" ) ) { - ds->deformation = DEFORM_PROJECTION_SHADOW; - return; - } - - if ( !Q_stricmp( token, "autosprite" ) ) { - ds->deformation = DEFORM_AUTOSPRITE; - return; - } - - if ( !Q_stricmp( token, "autosprite2" ) ) { - ds->deformation = DEFORM_AUTOSPRITE2; - return; - } - - if ( !Q_stricmpn( token, "text", 4 ) ) { - int n; - - n = token[4] - '0'; - if ( n < 0 || n > 7 ) { - n = 0; - } - ds->deformation = DEFORM_TEXT0 + n; - return; - } - - if ( !Q_stricmp( token, "bulge" ) ) { - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes bulge parm in shader '%s'\n", shader.name ); - return; - } - ds->bulgeWidth = Q_atof( token ); - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes bulge parm in shader '%s'\n", shader.name ); - return; - } - ds->bulgeHeight = Q_atof( token ); - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes bulge parm in shader '%s'\n", shader.name ); - return; - } - ds->bulgeSpeed = Q_atof( token ); - - ds->deformation = DEFORM_BULGE; - return; - } - - if ( !Q_stricmp( token, "wave" ) ) - { - float f; - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); - return; - } - - f = Q_atof( token ); - if ( f != 0.0f ) - { - ds->deformationSpread = 1.0f / f; - } - else - { - ds->deformationSpread = 100.0f; - ri.Printf( PRINT_WARNING, "WARNING: illegal div value of 0 in deformVertexes command for shader '%s'\n", shader.name ); - } - - ParseWaveForm( text, &ds->deformationWave ); - ds->deformation = DEFORM_WAVE; - return; - } - - if ( !Q_stricmp( token, "normal" ) ) - { - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); - return; - } - ds->deformationWave.amplitude = Q_atof( token ); - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); - return; - } - ds->deformationWave.frequency = Q_atof( token ); - - ds->deformation = DEFORM_NORMALS; - return; - } - - if ( !Q_stricmp( token, "move" ) ) { - int i; - - for ( i = 0 ; i < 3 ; i++ ) { - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); - return; - } - ds->moveVector[i] = Q_atof( token ); - } - - ParseWaveForm( text, &ds->deformationWave ); - ds->deformation = DEFORM_MOVE; - return; - } - - ri.Printf( PRINT_WARNING, "WARNING: unknown deformVertexes subtype '%s' found in shader '%s'\n", token, shader.name ); -} - - -/* -=============== -ParseSkyParms - -skyParms -=============== -*/ -static void ParseSkyParms( const char **text ) { - const char *token; - static const char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"}; - char pathname[MAX_QPATH]; - int i; - imgFlags_t imgFlags = IMGFLAG_MIPMAP | IMGFLAG_PICMIP; - - // outerbox - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: 'skyParms' missing parameter in shader '%s'\n", shader.name ); - return; - } - if ( strcmp( token, "-" ) ) { - for (i=0 ; i<6 ; i++) { - Com_sprintf( pathname, sizeof(pathname), "%s_%s.tga" - , token, suf[i] ); - shader.sky.outerbox[i] = R_FindImageFile( pathname, IMGTYPE_COLORALPHA, imgFlags | IMGFLAG_CLAMPTOEDGE ); - - if ( !shader.sky.outerbox[i] ) { - shader.sky.outerbox[i] = tr.defaultImage; - } - } - } - - // cloudheight - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: 'skyParms' missing parameter in shader '%s'\n", shader.name ); - return; - } - shader.sky.cloudHeight = Q_atof( token ); - if ( shader.sky.cloudHeight == 0.0 ) { - shader.sky.cloudHeight = 512.0; - } - R_InitSkyTexCoords( shader.sky.cloudHeight ); - - // innerbox - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: 'skyParms' missing parameter in shader '%s'\n", shader.name ); - return; - } - if ( strcmp( token, "-" ) ) { - for (i=0 ; i<6 ; i++) { - Com_sprintf( pathname, sizeof(pathname), "%s_%s.tga" - , token, suf[i] ); - shader.sky.innerbox[i] = R_FindImageFile( pathname, IMGTYPE_COLORALPHA, imgFlags ); - if ( !shader.sky.innerbox[i] ) { - shader.sky.innerbox[i] = tr.defaultImage; - } - } - } - - shader.isSky = qtrue; -} - - -/* -================= -ParseSort -================= -*/ -static void ParseSort( const char **text ) { - const char *token; - - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing sort parameter in shader '%s'\n", shader.name ); - return; - } - - if ( !Q_stricmp( token, "portal" ) ) { - shader.sort = SS_PORTAL; - } else if ( !Q_stricmp( token, "sky" ) ) { - shader.sort = SS_ENVIRONMENT; - } else if ( !Q_stricmp( token, "opaque" ) ) { - shader.sort = SS_OPAQUE; - } else if ( !Q_stricmp( token, "decal" ) ) { - shader.sort = SS_DECAL; - } else if ( !Q_stricmp( token, "seeThrough" ) ) { - shader.sort = SS_SEE_THROUGH; - } else if ( !Q_stricmp( token, "banner" ) ) { - shader.sort = SS_BANNER; - } else if ( !Q_stricmp( token, "additive" ) ) { - shader.sort = SS_BLEND1; - } else if ( !Q_stricmp( token, "nearest" ) ) { - shader.sort = SS_NEAREST; - } else if ( !Q_stricmp( token, "underwater" ) ) { - shader.sort = SS_UNDERWATER; - } else { - shader.sort = Q_atof( token ); - } -} - - -// this table is also present in q3map - -typedef struct { - const char *name; - int clearSolid, surfaceFlags, contents; -} infoParm_t; - -static const infoParm_t infoParms[] = { - // server relevant contents - {"water", 1, 0, CONTENTS_WATER }, - {"slime", 1, 0, CONTENTS_SLIME }, // mildly damaging - {"lava", 1, 0, CONTENTS_LAVA }, // very damaging - {"playerclip", 1, 0, CONTENTS_PLAYERCLIP }, - {"monsterclip", 1, 0, CONTENTS_MONSTERCLIP }, - {"nodrop", 1, 0, CONTENTS_NODROP }, // don't drop items or leave bodies (death fog, lava, etc) - {"nonsolid", 1, SURF_NONSOLID, 0}, // clears the solid flag - - // utility relevant attributes - {"origin", 1, 0, CONTENTS_ORIGIN }, // center of rotating brushes - {"trans", 0, 0, CONTENTS_TRANSLUCENT }, // don't eat contained surfaces - {"detail", 0, 0, CONTENTS_DETAIL }, // don't include in structural bsp - {"structural", 0, 0, CONTENTS_STRUCTURAL }, // force into structural bsp even if trans - {"areaportal", 1, 0, CONTENTS_AREAPORTAL }, // divides areas - {"clusterportal", 1,0, CONTENTS_CLUSTERPORTAL }, // for bots - {"donotenter", 1, 0, CONTENTS_DONOTENTER }, // for bots - - {"fog", 1, 0, CONTENTS_FOG}, // carves surfaces entering - {"sky", 0, SURF_SKY, 0 }, // emit light from an environment map - {"lightfilter", 0, SURF_LIGHTFILTER, 0 }, // filter light going through it - {"alphashadow", 0, SURF_ALPHASHADOW, 0 }, // test light on a per-pixel basis - {"hint", 0, SURF_HINT, 0 }, // use as a primary splitter - - // server attributes - {"slick", 0, SURF_SLICK, 0 }, - {"noimpact", 0, SURF_NOIMPACT, 0 }, // don't make impact explosions or marks - {"nomarks", 0, SURF_NOMARKS, 0 }, // don't make impact marks, but still explode - {"ladder", 0, SURF_LADDER, 0 }, - {"nodamage", 0, SURF_NODAMAGE, 0 }, - {"metalsteps", 0, SURF_METALSTEPS,0 }, - {"flesh", 0, SURF_FLESH, 0 }, - {"nosteps", 0, SURF_NOSTEPS, 0 }, - - // drawsurf attributes - {"nodraw", 0, SURF_NODRAW, 0 }, // don't generate a drawsurface (or a lightmap) - {"pointlight", 0, SURF_POINTLIGHT, 0 }, // sample lighting at vertexes - {"nolightmap", 0, SURF_NOLIGHTMAP,0 }, // don't generate a lightmap - {"nodlight", 0, SURF_NODLIGHT, 0 }, // don't ever add dynamic lights - {"dust", 0, SURF_DUST, 0} // leave a dust trail when walking on this surface -}; - - -/* -=============== -ParseSurfaceParm - -surfaceparm -=============== -*/ -static void ParseSurfaceParm( const char **text ) { - const char *token; - int numInfoParms = ARRAY_LEN( infoParms ); - int i; - - token = COM_ParseExt( text, qfalse ); - for ( i = 0 ; i < numInfoParms ; i++ ) { - if ( !Q_stricmp( token, infoParms[i].name ) ) { - shader.surfaceFlags |= infoParms[i].surfaceFlags; - shader.contentFlags |= infoParms[i].contents; -#if 0 - if ( infoParms[i].clearSolid ) { - si->contents &= ~CONTENTS_SOLID; - } -#endif - break; - } - } -} - - -typedef enum { - res_invalid = -1, - res_false = 0, - res_true = 1 -} resultType; - -typedef enum { - brIF, - brELIF, - brELSE -} branchType; - -typedef enum { - maskOR, - maskAND -} resultMask; - - -static void derefVariable( const char *name, char *buf, int size ) -{ - if ( !Q_stricmp( name, "vid_width" ) ) { - Com_sprintf( buf, size, "%i", glConfig.vidWidth ); - return; - } - if ( !Q_stricmp( name, "vid_height" ) ) { - Com_sprintf( buf, size, "%i", glConfig.vidHeight ); - return; - } - ri.Cvar_VariableStringBuffer( name, buf, size ); -} - - -/* -=============== -ParseCondition - -if ( $cvar| [ $cvar| [ [ || .. ] && .. ] ] ) -{ shader stage } -[ else -{ shader stage } ] -=============== -*/ -static qboolean ParseCondition( const char **text, resultType *res ) -{ - char lval_str[ MAX_CVAR_VALUE_STRING ]; - char rval_str[ MAX_CVAR_VALUE_STRING ]; - tokenType_t lval_type; - tokenType_t rval_type; - const char *token; - tokenType_t op; - resultMask rm; - qboolean str; - int r, r0; - - r = 0; // resulting value - rm = maskOR; // default mask - - for ( ;; ) - { - rval_str[0] = '\0'; - rval_type = TK_GENEGIC; - - // expect l-value at least - token = COM_ParseComplex( text, qfalse ); - if ( token[0] == '\0' ) { - ri.Printf( PRINT_WARNING, "WARNING: expecting lvalue for condition in shader %s\n", shader.name ); - return qfalse; - } - - Q_strncpyz( lval_str, token, sizeof( lval_str ) ); - lval_type = com_tokentype; - - // get operator - token = COM_ParseComplex( text, qfalse ); - if ( com_tokentype >= TK_EQ && com_tokentype <= TK_LTE ) - { - op = com_tokentype; - - // expect r-value - token = COM_ParseComplex( text, qfalse ); - if ( token[0] == '\0' ) { - ri.Printf( PRINT_WARNING, "WARNING: expecting rvalue for condition in shader %s\n", shader.name ); - return qfalse; - } - - Q_strncpyz( rval_str, token, sizeof( rval_str ) ); - rval_type = com_tokentype; - - // read next token, expect '||', '&&' or ')', allow newlines - /*token =*/ COM_ParseComplex( text, qtrue ); - } - else if ( com_tokentype == TK_SCOPE_CLOSE || com_tokentype == TK_OR || com_tokentype == TK_AND ) - { - // no r-value, assume 'not zero' comparison - op = TK_NEQ; - } - else - { - ri.Printf( PRINT_WARNING, "WARNING: unexpected operator '%s' for comparison in shader %s\n", token, shader.name ); - return qfalse; - } - - str = qfalse; - - if ( lval_type == TK_QUOTED ) { - str = qtrue; - } else { - // dereference l-value - if ( lval_str[0] == '$' ) { - derefVariable( lval_str + 1, lval_str, sizeof( lval_str ) ); - } - } - - if ( rval_type == TK_QUOTED ) { - str = qtrue; - } else { - // dereference r-value - if ( rval_str[0] == '$' ) { - derefVariable( rval_str + 1, rval_str, sizeof( rval_str ) ); - } - } - - // evaluate expression - if ( str ) { - // string comparison - switch ( op ) { - case TK_EQ: r0 = strcmp( lval_str, rval_str ) == 0; break; - case TK_NEQ: r0 = strcmp( lval_str, rval_str ) != 0; break; - case TK_GT: r0 = strcmp( lval_str, rval_str ) > 0; break; - case TK_GTE: r0 = strcmp( lval_str, rval_str ) >= 0; break; - case TK_LT: r0 = strcmp( lval_str, rval_str ) < 0; break; - case TK_LTE: r0 = strcmp( lval_str, rval_str ) <= 0; break; - default: r0 = 0; break; - } - } else { - // integer comparison - int lval = atoi( lval_str ); - int rval = atoi( rval_str ); - switch ( op ) { - case TK_EQ: r0 = ( lval == rval ); break; - case TK_NEQ: r0 = ( lval != rval ); break; - case TK_GT: r0 = ( lval > rval ); break; - case TK_GTE: r0 = ( lval >= rval ); break; - case TK_LT: r0 = ( lval < rval ); break; - case TK_LTE: r0 = ( lval <= rval ); break; - default: r0 = 0; break; - } - } - - if ( rm == maskOR ) - r |= r0; - else - r &= r0; - - if ( com_tokentype == TK_OR ) { - rm = maskOR; - continue; - } - - if ( com_tokentype == TK_AND ) { - rm = maskAND; - continue; - } - - if ( com_tokentype != TK_SCOPE_CLOSE ) { - ri.Printf( PRINT_WARNING, "WARNING: expecting ')' in shader %s\n", shader.name ); - return qfalse; - } - - break; - } - - if ( res ) - *res = r ? res_true : res_false; - - return qtrue; -} - - -/* -================= -ParseShader - -The current text pointer is at the explicit text definition of the -shader. Parse it into the global shader variable. Later functions -will optimize it. -================= -*/ -static qboolean ParseShader( const char **text ) -{ - resultType res; - branchType branch; - const char *token; - int s; - - s = 0; - - s_extendedShader = (*text >= s_extensionOffset); - - token = COM_ParseExt( text, qtrue ); - if ( token[0] != '{' ) - { - ri.Printf( PRINT_WARNING, "WARNING: expecting '{', found '%s' instead in shader '%s'\n", token, shader.name ); - return qfalse; - } - - res = res_invalid; - - while ( 1 ) - { - //token = COM_ParseExt( text, qtrue ); - token = COM_ParseComplex( text, qtrue ); - if ( !token[0] ) - { - ri.Printf( PRINT_WARNING, "WARNING: no concluding '}' in shader %s\n", shader.name ); - return qfalse; - } - // end of shader definition - if ( token[0] == '}' ) - { - break; - } - // stage definition - else if ( token[0] == '{' ) - { - if ( s >= MAX_SHADER_STAGES ) { - ri.Printf( PRINT_WARNING, "WARNING: too many stages in shader %s (max is %i)\n", shader.name, MAX_SHADER_STAGES ); - return qfalse; - } - - if ( !ParseStage( &stages[s], text ) ) - { - return qfalse; - } - stages[s].active = qtrue; - s++; - - continue; - } - // skip stuff that only the QuakeEdRadient needs - else if ( !Q_stricmpn( token, "qer", 3 ) ) { - SkipRestOfLine( text ); - continue; - } - // sun parms - else if ( !Q_stricmp( token, "q3map_sun" ) || !Q_stricmp( token, "q3map_sunExt" ) || !Q_stricmp( token, "q3gl2_sun" ) ) { - float a, b; - qboolean isGL2Sun = qfalse; - - if (!Q_stricmp( token, "q3gl2_sun" ) && r_sunShadows->integer ) - { - isGL2Sun = qtrue; - tr.sunShadows = qtrue; - } - - token = COM_ParseExt( text, qfalse ); - tr.sunLight[0] = Q_atof( token ); - token = COM_ParseExt( text, qfalse ); - tr.sunLight[1] = Q_atof( token ); - token = COM_ParseExt( text, qfalse ); - tr.sunLight[2] = Q_atof( token ); - - VectorNormalize( tr.sunLight ); - - token = COM_ParseExt( text, qfalse ); - a = Q_atof( token ); - VectorScale( tr.sunLight, a, tr.sunLight ); - - token = COM_ParseExt( text, qfalse ); - a = Q_atof( token ); - a = a / 180 * M_PI; - - token = COM_ParseExt( text, qfalse ); - b = Q_atof( token ); - b = b / 180 * M_PI; - - tr.sunDirection[0] = cos( a ) * cos( b ); - tr.sunDirection[1] = sin( a ) * cos( b ); - tr.sunDirection[2] = sin( b ); - - if (isGL2Sun) - { - token = COM_ParseExt( text, qfalse ); - tr.sunShadowScale = Q_atof(token); - - // parse twice, since older shaders may include mapLightScale before sunShadowScale - token = COM_ParseExt( text, qfalse ); - if (token[0]) - tr.sunShadowScale = Q_atof(token); - } - - SkipRestOfLine( text ); - continue; - } - // tonemap parms - else if ( !Q_stricmp( token, "q3gl2_tonemap" ) ) { - token = COM_ParseExt( text, qfalse ); - tr.toneMinAvgMaxLevel[0] = Q_atof( token ); - token = COM_ParseExt( text, qfalse ); - tr.toneMinAvgMaxLevel[1] = Q_atof( token ); - token = COM_ParseExt( text, qfalse ); - tr.toneMinAvgMaxLevel[2] = Q_atof( token ); - - token = COM_ParseExt( text, qfalse ); - tr.autoExposureMinMax[0] = Q_atof( token ); - token = COM_ParseExt( text, qfalse ); - tr.autoExposureMinMax[1] = Q_atof( token ); - - SkipRestOfLine( text ); - continue; - } - else if ( !Q_stricmp( token, "deformVertexes" ) ) { - ParseDeform( text ); - continue; - } - else if ( !Q_stricmp( token, "tesssize" ) ) { - SkipRestOfLine( text ); - continue; - } - else if ( !Q_stricmp( token, "clampTime" ) ) { - token = COM_ParseExt( text, qfalse ); - if ( token[0] ) { - shader.clampTime = Q_atof( token ); - } - } - // skip stuff that only the q3map needs - else if ( !Q_stricmpn( token, "q3map", 5 ) ) { - SkipRestOfLine( text ); - continue; - } - // skip stuff that only q3map or the server needs - else if ( !Q_stricmp( token, "surfaceParm" ) ) { - ParseSurfaceParm( text ); - continue; - } - // no mip maps - else if ( !Q_stricmp( token, "nomipmaps" ) ) - { - shader.noMipMaps = qtrue; - shader.noPicMip = qtrue; - continue; - } - // no picmip adjustment - else if ( !Q_stricmp( token, "nopicmip" ) ) - { - shader.noPicMip = qtrue; - continue; - } - // polygonOffset - else if ( !Q_stricmp( token, "polygonOffset" ) ) - { - shader.polygonOffset = qtrue; - continue; - } - // entityMergable, allowing sprite surfaces from multiple entities - // to be merged into one batch. This is a savings for smoke - // puffs and blood, but can't be used for anything where the - // shader calcs (not the surface function) reference the entity color or scroll - else if ( !Q_stricmp( token, "entityMergable" ) ) - { - shader.entityMergable = qtrue; - continue; - } - // fogParms - else if ( !Q_stricmp( token, "fogParms" ) ) - { - if ( !ParseVector( text, 3, shader.fogParms.color ) ) { - return qfalse; - } - - if ( r_greyscale->integer ) - { - float luminance; - - luminance = LUMA( shader.fogParms.color[0], shader.fogParms.color[1], shader.fogParms.color[2] ); - VectorSet( shader.fogParms.color, luminance, luminance, luminance ); - } - else if ( r_greyscale->value ) - { - float luminance; - - luminance = LUMA( shader.fogParms.color[0], shader.fogParms.color[1], shader.fogParms.color[2] ); - shader.fogParms.color[0] = LERP( shader.fogParms.color[0], luminance, r_greyscale->value ); - shader.fogParms.color[1] = LERP( shader.fogParms.color[1], luminance, r_greyscale->value ); - shader.fogParms.color[2] = LERP( shader.fogParms.color[2], luminance, r_greyscale->value ); - } - - token = COM_ParseExt( text, qfalse ); - if ( !token[0] ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing parm for 'fogParms' keyword in shader '%s'\n", shader.name ); - continue; - } - shader.fogParms.depthForOpaque = Q_atof( token ); - - // skip any old gradient directions - SkipRestOfLine( text ); - continue; - } - // portal - else if ( !Q_stricmp( token, "portal" ) ) - { - shader.sort = SS_PORTAL; - shader.isPortal = qtrue; - continue; - } - // skyparms - else if ( !Q_stricmp( token, "skyparms" ) ) - { - ParseSkyParms( text ); - continue; - } - // light determines flaring in q3map, not needed here - else if ( !Q_stricmp(token, "light") ) - { - COM_ParseExt( text, qfalse ); - continue; - } - // cull - else if ( !Q_stricmp( token, "cull") ) - { - token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) - { - ri.Printf( PRINT_WARNING, "WARNING: missing cull parms in shader '%s'\n", shader.name ); - continue; - } - - if ( !Q_stricmp( token, "none" ) || !Q_stricmp( token, "twosided" ) || !Q_stricmp( token, "disable" ) ) - { - shader.cullType = CT_TWO_SIDED; - } - else if ( !Q_stricmp( token, "back" ) || !Q_stricmp( token, "backside" ) || !Q_stricmp( token, "backsided" ) ) - { - shader.cullType = CT_BACK_SIDED; - } - else - { - ri.Printf( PRINT_WARNING, "WARNING: invalid cull parm '%s' in shader '%s'\n", token, shader.name ); - } - continue; - } - // sort - else if ( !Q_stricmp( token, "sort" ) ) - { - ParseSort( text ); - continue; - } - // conditional stage definition - else if ( ( !Q_stricmp( token, "if" ) || !Q_stricmp( token, "else" ) || !Q_stricmp( token, "elif" ) ) && s_extendedShader ) - { - if ( Q_stricmp( token, "if" ) == 0 ) { - branch = brIF; - } else { - if ( res == res_invalid ) { - // we don't have any previous 'if' statements - ri.Printf( PRINT_WARNING, "WARNING: unexpected '%s' in '%s'\n", token, shader.name ); - return qfalse; - } - if ( Q_stricmp( token, "else" ) == 0 ) - branch = brELSE; - else - branch = brELIF; - } - - if ( branch != brELSE ) { // we can set/update result - token = COM_ParseComplex( text, qfalse ); - if ( com_tokentype != TK_SCOPE_OPEN ) { - ri.Printf( PRINT_WARNING, "WARNING: expecting '(' in '%s'\n", shader.name ); - return qfalse; - } - if ( !ParseCondition( text, (branch == brIF || res == res_true) ? &res : NULL ) ) { - ri.Printf( PRINT_WARNING, "WARNING: error parsing condition in '%s'\n", shader.name ); - return qfalse; - } - } - - if ( res == res_false ) { - // skip next stage or keyword until newline - token = COM_ParseExt( text, qtrue ); - if ( token[0] == '{' ) - SkipBracedSection( text, 1 ); - else - SkipRestOfLine( text ); - } else { - // parse next tokens as usual - } - - if ( branch == brELSE ) - res = res_invalid; // finalize branch - else - res ^= 1; // or toggle for possible "elif" / "else" statements - - continue; - } - else - { - ri.Printf( PRINT_WARNING, "WARNING: unknown general shader parameter '%s' in '%s'\n", token, shader.name ); - return qfalse; - } - } - - // - // ignore shaders that don't have any stages, unless it is a sky or fog - // - if ( s == 0 && !shader.isSky && !(shader.contentFlags & CONTENTS_FOG ) ) { - return qfalse; - } - - shader.explicitlyDefined = qtrue; - - return qtrue; -} - -/* -======================================================================================== - -SHADER OPTIMIZATION AND FOGGING - -======================================================================================== -*/ - -/* -=================== -ComputeStageIteratorFunc - -See if we can use on of the simple fastpath stage functions, -otherwise set to the generic stage function -=================== -*/ -static void ComputeStageIteratorFunc( void ) -{ - shader.optimalStageIteratorFunc = RB_StageIteratorGeneric; - - // - // see if this should go into the sky path - // - if ( shader.isSky ) - { - shader.optimalStageIteratorFunc = RB_StageIteratorSky; - return; - } -} - -/* -=================== -ComputeVertexAttribs - -Check which vertex attributes we only need, so we -don't need to submit/copy all of them. -=================== -*/ -static void ComputeVertexAttribs(void) -{ - int i, stage; - - // dlights always need ATTR_NORMAL - shader.vertexAttribs = ATTR_POSITION | ATTR_NORMAL; - - // portals always need normals, for SurfIsOffscreen() - if (shader.isPortal) - { - shader.vertexAttribs |= ATTR_NORMAL; - } - - if (shader.defaultShader) - { - shader.vertexAttribs |= ATTR_TEXCOORD; - return; - } - - if(shader.numDeforms) - { - for ( i = 0; i < shader.numDeforms; i++) - { - deformStage_t *ds = &shader.deforms[i]; - - switch (ds->deformation) - { - case DEFORM_BULGE: - shader.vertexAttribs |= ATTR_NORMAL | ATTR_TEXCOORD; - break; - - case DEFORM_AUTOSPRITE: - shader.vertexAttribs |= ATTR_NORMAL | ATTR_COLOR; - break; - - case DEFORM_WAVE: - case DEFORM_NORMALS: - case DEFORM_TEXT0: - case DEFORM_TEXT1: - case DEFORM_TEXT2: - case DEFORM_TEXT3: - case DEFORM_TEXT4: - case DEFORM_TEXT5: - case DEFORM_TEXT6: - case DEFORM_TEXT7: - shader.vertexAttribs |= ATTR_NORMAL; - break; - - default: - case DEFORM_NONE: - case DEFORM_MOVE: - case DEFORM_PROJECTION_SHADOW: - case DEFORM_AUTOSPRITE2: - break; - } - } - } - - for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ ) - { - shaderStage_t *pStage = &stages[stage]; - - if ( !pStage->active ) - { - break; - } - - if (pStage->glslShaderGroup == tr.lightallShader) - { - shader.vertexAttribs |= ATTR_NORMAL; - - if ((pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) && !(r_normalMapping->integer == 0 && r_specularMapping->integer == 0)) - { - shader.vertexAttribs |= ATTR_TANGENT; - } - - switch (pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) - { - case LIGHTDEF_USE_LIGHTMAP: - case LIGHTDEF_USE_LIGHT_VERTEX: - shader.vertexAttribs |= ATTR_LIGHTDIRECTION; - break; - default: - break; - } - } - - for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) - { - if ( pStage->bundle[i].image[0] == 0 ) - { - continue; - } - - switch(pStage->bundle[i].tcGen) - { - case TCGEN_TEXTURE: - shader.vertexAttribs |= ATTR_TEXCOORD; - break; - case TCGEN_LIGHTMAP: - shader.vertexAttribs |= ATTR_LIGHTCOORD; - break; - case TCGEN_ENVIRONMENT_MAPPED: - shader.vertexAttribs |= ATTR_NORMAL; - break; - - default: - break; - } - } - - switch(pStage->rgbGen) - { - case CGEN_EXACT_VERTEX: - case CGEN_VERTEX: - case CGEN_EXACT_VERTEX_LIT: - case CGEN_VERTEX_LIT: - case CGEN_ONE_MINUS_VERTEX: - shader.vertexAttribs |= ATTR_COLOR; - break; - - case CGEN_LIGHTING_DIFFUSE: - shader.vertexAttribs |= ATTR_NORMAL; - break; - - default: - break; - } - - switch(pStage->alphaGen) - { - case AGEN_LIGHTING_SPECULAR: - shader.vertexAttribs |= ATTR_NORMAL; - break; - - case AGEN_VERTEX: - case AGEN_ONE_MINUS_VERTEX: - shader.vertexAttribs |= ATTR_COLOR; - break; - - default: - break; - } - } -} - - -static void CollapseStagesToLightall(shaderStage_t *diffuse, - shaderStage_t *normal, shaderStage_t *specular, shaderStage_t *lightmap, - qboolean useLightVector, qboolean useLightVertex, qboolean parallax, qboolean tcgen) -{ - int defs = 0; - - //ri.Printf(PRINT_ALL, "shader %s has diffuse %s", shader.name, diffuse->bundle[0].image[0]->imgName); - - // reuse diffuse, mark others inactive - diffuse->type = ST_GLSL; - - if (lightmap) - { - //ri.Printf(PRINT_ALL, ", lightmap"); - diffuse->bundle[TB_LIGHTMAP] = lightmap->bundle[0]; - defs |= LIGHTDEF_USE_LIGHTMAP; - } - else if (useLightVector) - { - defs |= LIGHTDEF_USE_LIGHT_VECTOR; - } - else if (useLightVertex) - { - defs |= LIGHTDEF_USE_LIGHT_VERTEX; - } - - if (r_deluxeMapping->integer && tr.worldDeluxeMapping && lightmap && shader.lightmapIndex >= 0) - { - //ri.Printf(PRINT_ALL, ", deluxemap"); - diffuse->bundle[TB_DELUXEMAP] = lightmap->bundle[0]; - diffuse->bundle[TB_DELUXEMAP].image[0] = tr.deluxemaps[shader.lightmapIndex]; - } - - if (r_normalMapping->integer) - { - image_t *diffuseImg; - if (normal) - { - //ri.Printf(PRINT_ALL, ", normalmap %s", normal->bundle[0].image[0]->imgName); - diffuse->bundle[TB_NORMALMAP] = normal->bundle[0]; - if (parallax && r_parallaxMapping->integer) - defs |= LIGHTDEF_USE_PARALLAXMAP; - - VectorCopy4(normal->normalScale, diffuse->normalScale); - } - else if ((lightmap || useLightVector || useLightVertex) && (diffuseImg = diffuse->bundle[TB_DIFFUSEMAP].image[0]) != NULL) - { - char normalName[MAX_QPATH]; - image_t *normalImg; - imgFlags_t normalFlags = (diffuseImg->flags & ~IMGFLAG_GENNORMALMAP) | IMGFLAG_NOLIGHTSCALE; - - // try a normalheight image first - COM_StripExtension(diffuseImg->imgName, normalName, MAX_QPATH); - Q_strcat(normalName, MAX_QPATH, "_nh"); - - normalImg = R_FindImageFile(normalName, IMGTYPE_NORMALHEIGHT, normalFlags); - - if (normalImg) - { - parallax = qtrue; - } - else - { - // try a normal image ("_n" suffix) - normalName[strlen(normalName) - 1] = '\0'; - normalImg = R_FindImageFile(normalName, IMGTYPE_NORMAL, normalFlags); - } - - if (normalImg) - { - diffuse->bundle[TB_NORMALMAP] = diffuse->bundle[0]; - diffuse->bundle[TB_NORMALMAP].numImageAnimations = 0; - diffuse->bundle[TB_NORMALMAP].image[0] = normalImg; - - if (parallax && r_parallaxMapping->integer) - defs |= LIGHTDEF_USE_PARALLAXMAP; - - VectorSet4(diffuse->normalScale, r_baseNormalX->value, r_baseNormalY->value, 1.0f, r_baseParallax->value); - } - } - } - - if (r_specularMapping->integer) - { - image_t *diffuseImg; - if (specular) - { - //ri.Printf(PRINT_ALL, ", specularmap %s", specular->bundle[0].image[0]->imgName); - diffuse->bundle[TB_SPECULARMAP] = specular->bundle[0]; - VectorCopy4(specular->specularScale, diffuse->specularScale); - } - else if ((lightmap || useLightVector || useLightVertex) && (diffuseImg = diffuse->bundle[TB_DIFFUSEMAP].image[0]) != NULL) - { - char specularName[MAX_QPATH]; - image_t *specularImg; - imgFlags_t specularFlags = (diffuseImg->flags & ~IMGFLAG_GENNORMALMAP) | IMGFLAG_NOLIGHTSCALE; - - COM_StripExtension(diffuseImg->imgName, specularName, MAX_QPATH); - Q_strcat(specularName, MAX_QPATH, "_s"); - - specularImg = R_FindImageFile(specularName, IMGTYPE_COLORALPHA, specularFlags); - - if (specularImg) - { - diffuse->bundle[TB_SPECULARMAP] = diffuse->bundle[0]; - diffuse->bundle[TB_SPECULARMAP].numImageAnimations = 0; - diffuse->bundle[TB_SPECULARMAP].image[0] = specularImg; - - VectorSet4(diffuse->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); - } - } - } - - if (tcgen || diffuse->bundle[0].numTexMods) - { - defs |= LIGHTDEF_USE_TCGEN_AND_TCMOD; - } - - //ri.Printf(PRINT_ALL, ".\n"); - - diffuse->glslShaderGroup = tr.lightallShader; - diffuse->glslShaderIndex = defs; -} - - -static int CollapseStagesToGLSL(void) -{ - int i, j, numStages; - qboolean skip = qfalse; - - // skip shaders with deforms - if (shader.numDeforms != 0) - { - skip = qtrue; - } - - if (!skip) - { - // if 2+ stages and first stage is lightmap, switch them - // this makes it easier for the later bits to process - if (stages[0].active && stages[0].bundle[0].tcGen == TCGEN_LIGHTMAP && stages[1].active) - { - int blendBits = stages[1].stateBits & ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); - - if (blendBits == (GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO) - || blendBits == (GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR)) - { - int stateBits0 = stages[0].stateBits; - int stateBits1 = stages[1].stateBits; - shaderStage_t swapStage; - - swapStage = stages[0]; - stages[0] = stages[1]; - stages[1] = swapStage; - - stages[0].stateBits = stateBits0; - stages[1].stateBits = stateBits1; - } - } - } - - if (!skip) - { - // scan for shaders that aren't supported - for (i = 0; i < MAX_SHADER_STAGES; i++) - { - shaderStage_t *pStage = &stages[i]; - - if (!pStage->active) - continue; - - //if (pStage->adjustColorsForFog) - //{ - // skip = qtrue; - // break; - //} - - if (pStage->bundle[0].tcGen == TCGEN_LIGHTMAP) - { - int blendBits = pStage->stateBits & ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); - - if (blendBits != (GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO) - && blendBits != (GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR)) - { - skip = qtrue; - break; - } - } - - switch(pStage->bundle[0].tcGen) - { - case TCGEN_TEXTURE: - case TCGEN_LIGHTMAP: - case TCGEN_ENVIRONMENT_MAPPED: - case TCGEN_VECTOR: - break; - default: - skip = qtrue; - break; - } - - switch(pStage->alphaGen) - { - case AGEN_LIGHTING_SPECULAR: - case AGEN_PORTAL: - skip = qtrue; - break; - default: - break; - } - } - } - - if (!skip) - { - qboolean usedLightmap = qfalse; - - for (i = 0; i < MAX_SHADER_STAGES; i++) - { - shaderStage_t *pStage = &stages[i]; - shaderStage_t *diffuse, *normal, *specular, *lightmap; - qboolean parallax, tcgen, diffuselit, vertexlit; - - if (!pStage->active) - continue; - - // skip normal and specular maps - if (pStage->type != ST_COLORMAP) - continue; - - // skip lightmaps - if (pStage->bundle[0].tcGen == TCGEN_LIGHTMAP) - continue; - - diffuse = pStage; - normal = NULL; - parallax = qfalse; - specular = NULL; - lightmap = NULL; - - // we have a diffuse map, find matching normal, specular, and lightmap - for (j = i + 1; j < MAX_SHADER_STAGES; j++) - { - shaderStage_t *pStage2 = &stages[j]; - - if (!pStage2->active) - continue; - - switch(pStage2->type) - { - case ST_NORMALMAP: - if (!normal) - { - normal = pStage2; - } - break; - - case ST_NORMALPARALLAXMAP: - if (!normal) - { - normal = pStage2; - parallax = qtrue; - } - break; - - case ST_SPECULARMAP: - if (!specular) - { - specular = pStage2; - } - break; - - case ST_COLORMAP: - if (pStage2->bundle[0].tcGen == TCGEN_LIGHTMAP) - { - int blendBits = pStage->stateBits & ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); - - // Only add lightmap to blendfunc filter stage if it's the first time lightmap is used - // otherwise it will cause the shader to be darkened by the lightmap multiple times. - if (!usedLightmap || (blendBits != (GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO) - && blendBits != (GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR))) - { - lightmap = pStage2; - usedLightmap = qtrue; - } - } - break; - - default: - break; - } - } - - tcgen = qfalse; - if (diffuse->bundle[0].tcGen == TCGEN_ENVIRONMENT_MAPPED - || diffuse->bundle[0].tcGen == TCGEN_LIGHTMAP - || diffuse->bundle[0].tcGen == TCGEN_VECTOR) - { - tcgen = qtrue; - } - - diffuselit = qfalse; - if (diffuse->rgbGen == CGEN_LIGHTING_DIFFUSE) - { - diffuselit = qtrue; - } - - vertexlit = qfalse; - if (diffuse->rgbGen == CGEN_VERTEX_LIT || diffuse->rgbGen == CGEN_EXACT_VERTEX_LIT) - { - vertexlit = qtrue; - } - - CollapseStagesToLightall(diffuse, normal, specular, lightmap, diffuselit, vertexlit, parallax, tcgen); - } - - // deactivate lightmap stages - for (i = 0; i < MAX_SHADER_STAGES; i++) - { - shaderStage_t *pStage = &stages[i]; - - if (!pStage->active) - continue; - - if (pStage->bundle[0].tcGen == TCGEN_LIGHTMAP) - { - pStage->active = qfalse; - } - } - } - - // deactivate normal and specular stages - for (i = 0; i < MAX_SHADER_STAGES; i++) - { - shaderStage_t *pStage = &stages[i]; - - if (!pStage->active) - continue; - - if (pStage->type == ST_NORMALMAP) - { - pStage->active = qfalse; - } - - if (pStage->type == ST_NORMALPARALLAXMAP) - { - pStage->active = qfalse; - } - - if (pStage->type == ST_SPECULARMAP) - { - pStage->active = qfalse; - } - } - - // remove inactive stages - numStages = 0; - for (i = 0; i < MAX_SHADER_STAGES; i++) - { - if (!stages[i].active) - continue; - - if (i == numStages) - { - numStages++; - continue; - } - - stages[numStages] = stages[i]; - stages[i].active = qfalse; - numStages++; - } - - // convert any remaining lightmap stages to a lighting pass with a white texture - // only do this with r_sunlightMode non-zero, as it's only for correct shadows. - if (r_sunlightMode->integer && shader.numDeforms == 0) - { - for (i = 0; i < MAX_SHADER_STAGES; i++) - { - shaderStage_t *pStage = &stages[i]; - - if (!pStage->active) - continue; - - if (pStage->adjustColorsForFog) - continue; - - if (pStage->bundle[TB_DIFFUSEMAP].tcGen == TCGEN_LIGHTMAP) - { - pStage->glslShaderGroup = tr.lightallShader; - pStage->glslShaderIndex = LIGHTDEF_USE_LIGHTMAP; - pStage->bundle[TB_LIGHTMAP] = pStage->bundle[TB_DIFFUSEMAP]; - pStage->bundle[TB_DIFFUSEMAP].image[0] = tr.whiteImage; - pStage->bundle[TB_DIFFUSEMAP].isLightmap = qfalse; - pStage->bundle[TB_DIFFUSEMAP].tcGen = TCGEN_TEXTURE; - } - } - } - - // convert any remaining lightingdiffuse stages to a lighting pass - if (shader.numDeforms == 0) - { - for (i = 0; i < MAX_SHADER_STAGES; i++) - { - shaderStage_t *pStage = &stages[i]; - - if (!pStage->active) - continue; - - if (pStage->adjustColorsForFog) - continue; - - if (pStage->rgbGen == CGEN_LIGHTING_DIFFUSE) - { - pStage->glslShaderGroup = tr.lightallShader; - pStage->glslShaderIndex = LIGHTDEF_USE_LIGHT_VECTOR; - - if (pStage->bundle[0].tcGen != TCGEN_TEXTURE || pStage->bundle[0].numTexMods != 0) - pStage->glslShaderIndex |= LIGHTDEF_USE_TCGEN_AND_TCMOD; - } - } - } - - return numStages; -} - -/* -============= - -FixRenderCommandList -https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=493 -Arnout: this is a nasty issue. Shaders can be registered after drawsurfaces are generated -but before the frame is rendered. This will, for the duration of one frame, cause drawsurfaces -to be rendered with bad shaders. To fix this, need to go through all render commands and fix -sortedIndex. -============== -*/ -static void FixRenderCommandList( int newShader ) { - renderCommandList_t *cmdList = &backEndData->commands; - - if( cmdList ) { - const void *curCmd = cmdList->cmds; - - while ( 1 ) { - curCmd = PADP(curCmd, sizeof(void *)); - - switch ( *(const int *)curCmd ) { - case RC_SET_COLOR: - { - const setColorCommand_t *sc_cmd = (const setColorCommand_t *)curCmd; - curCmd = (const void *)(sc_cmd + 1); - break; - } - case RC_STRETCH_PIC: - { - const stretchPicCommand_t *sp_cmd = (const stretchPicCommand_t *)curCmd; - curCmd = (const void *)(sp_cmd + 1); - break; - } - case RC_DRAW_SURFS: - { - int i; - drawSurf_t *drawSurf; - shader_t *sh; - int fogNum; - int entityNum; - int dlightMap; - int pshadowMap; - int sortedIndex; - const drawSurfsCommand_t *ds_cmd = (const drawSurfsCommand_t *)curCmd; - - for( i = 0, drawSurf = ds_cmd->drawSurfs; i < ds_cmd->numDrawSurfs; i++, drawSurf++ ) { - R_DecomposeSort( drawSurf->sort, &entityNum, &sh, &fogNum, &dlightMap, &pshadowMap ); - sortedIndex = (( drawSurf->sort >> QSORT_SHADERNUM_SHIFT ) & (MAX_SHADERS-1)); - if( sortedIndex >= newShader ) { - sortedIndex = sh->sortedIndex; - drawSurf->sort = (sortedIndex << QSORT_SHADERNUM_SHIFT) | (entityNum << QSORT_REFENTITYNUM_SHIFT) | ( fogNum << QSORT_FOGNUM_SHIFT ) | ( (int)pshadowMap << QSORT_PSHADOW_SHIFT) | (int)dlightMap; - } - } - curCmd = (const void *)(ds_cmd + 1); - break; - } - case RC_DRAW_BUFFER: - { - const drawBufferCommand_t *db_cmd = (const drawBufferCommand_t *)curCmd; - curCmd = (const void *)(db_cmd + 1); - break; - } - case RC_SWAP_BUFFERS: - { - const swapBuffersCommand_t *sb_cmd = (const swapBuffersCommand_t *)curCmd; - curCmd = (const void *)(sb_cmd + 1); - break; - } - case RC_END_OF_LIST: - default: - return; - } - } - } -} - -/* -============== -SortNewShader - -Positions the most recently created shader in the tr.sortedShaders[] -array so that the shader->sort key is sorted relative to the other -shaders. - -Sets shader->sortedIndex -============== -*/ -static void SortNewShader( void ) { - int i; - float sort; - shader_t *newShader; - - newShader = tr.shaders[ tr.numShaders - 1 ]; - sort = newShader->sort; - - for ( i = tr.numShaders - 2 ; i >= 0 ; i-- ) { - if ( tr.sortedShaders[ i ]->sort <= sort ) { - break; - } - tr.sortedShaders[i+1] = tr.sortedShaders[i]; - tr.sortedShaders[i+1]->sortedIndex++; - } - - // Arnout: fix rendercommandlist - // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=493 - FixRenderCommandList( i+1 ); - - newShader->sortedIndex = i+1; - tr.sortedShaders[i+1] = newShader; -} - - -/* -==================== -GeneratePermanentShader -==================== -*/ -static shader_t *GeneratePermanentShader( void ) { - shader_t *newShader; - int i, b; - int size, hash; - - if ( tr.numShaders >= MAX_SHADERS ) { - ri.Printf( PRINT_WARNING, "WARNING: GeneratePermanentShader - MAX_SHADERS hit\n"); - return tr.defaultShader; - } - - newShader = ri.Hunk_Alloc( sizeof( shader_t ), h_low ); - - *newShader = shader; - - if ( shader.sort <= SS_OPAQUE ) { - newShader->fogPass = FP_EQUAL; - } else if ( shader.contentFlags & CONTENTS_FOG ) { - newShader->fogPass = FP_LE; - } - - tr.shaders[ tr.numShaders ] = newShader; - newShader->index = tr.numShaders; - - tr.sortedShaders[ tr.numShaders ] = newShader; - newShader->sortedIndex = tr.numShaders; - - tr.numShaders++; - - for ( i = 0 ; i < newShader->numUnfoggedPasses ; i++ ) { - if ( !stages[i].active ) { - break; - } - newShader->stages[i] = ri.Hunk_Alloc( sizeof( stages[i] ), h_low ); - *newShader->stages[i] = stages[i]; - - for ( b = 0 ; b < NUM_TEXTURE_BUNDLES ; b++ ) { - size = newShader->stages[i]->bundle[b].numTexMods * sizeof( texModInfo_t ); - if ( size ) { - newShader->stages[i]->bundle[b].texMods = ri.Hunk_Alloc( size, h_low ); - Com_Memcpy( newShader->stages[i]->bundle[b].texMods, stages[i].bundle[b].texMods, size ); - } - } - } - - SortNewShader(); - - hash = generateHashValue(newShader->name, FILE_HASH_SIZE); - newShader->next = hashTable[hash]; - hashTable[hash] = newShader; - - return newShader; -} - - -/* -==================== -FindLightingStages - -Find proper stage for dlight pass -==================== -*/ -#define GLS_BLEND_BITS (GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS) -static void FindLightingStages( void ) -{ - int i; - shader.lightingStage = -1; - - if ( shader.isSky || ( shader.surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) || shader.sort > SS_OPAQUE ) - return; - - for ( i = 0; i < shader.numUnfoggedPasses; i++ ) { - if ( !stages[i].bundle[0].isLightmap ) { - if ( stages[i].bundle[0].tcGen != TCGEN_TEXTURE ) - continue; - if ( (stages[i].stateBits & GLS_BLEND_BITS) == (GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE) ) - continue; - if ( stages[i].rgbGen == CGEN_IDENTITY && (stages[i].stateBits & GLS_BLEND_BITS) == (GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO) ) { - if ( shader.lightingStage >= 0 ) { - continue; - } - } - shader.lightingStage = i; - } - } -} - - -/* -================= -VertexLightingCollapse - -If vertex lighting is enabled, only render a single -pass, trying to guess which is the correct one to best approximate -what it is supposed to look like. -================= -*/ -static void VertexLightingCollapse( void ) { - int stage; - shaderStage_t *bestStage; - int bestImageRank; - int rank; - - // if we aren't opaque, just use the first pass - if ( shader.sort == SS_OPAQUE ) { - - // pick the best texture for the single pass - bestStage = &stages[0]; - bestImageRank = -999999; - - for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ ) { - shaderStage_t *pStage = &stages[stage]; - - if ( !pStage->active ) { - break; - } - rank = 0; - - if ( pStage->bundle[0].isLightmap ) { - rank -= 100; - } - if ( pStage->bundle[0].tcGen != TCGEN_TEXTURE ) { - rank -= 5; - } - if ( pStage->bundle[0].numTexMods ) { - rank -= 5; - } - if ( pStage->rgbGen != CGEN_IDENTITY && pStage->rgbGen != CGEN_IDENTITY_LIGHTING ) { - rank -= 3; - } - - if ( rank > bestImageRank ) { - bestImageRank = rank; - bestStage = pStage; - } - } - - stages[0].bundle[0] = bestStage->bundle[0]; - stages[0].stateBits &= ~( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); - stages[0].stateBits |= GLS_DEPTHMASK_TRUE; - if ( shader.lightmapIndex == LIGHTMAP_NONE ) { - stages[0].rgbGen = CGEN_LIGHTING_DIFFUSE; - } else { - stages[0].rgbGen = CGEN_EXACT_VERTEX; - } - stages[0].alphaGen = AGEN_SKIP; - } else { - // don't use a lightmap (tesla coils) - if ( stages[0].bundle[0].isLightmap ) { - stages[0] = stages[1]; - } - - // if we were in a cross-fade cgen, hack it to normal - if ( stages[0].rgbGen == CGEN_ONE_MINUS_ENTITY || stages[1].rgbGen == CGEN_ONE_MINUS_ENTITY ) { - stages[0].rgbGen = CGEN_IDENTITY_LIGHTING; - } - if ( ( stages[0].rgbGen == CGEN_WAVEFORM && stages[0].rgbWave.func == GF_SAWTOOTH ) - && ( stages[1].rgbGen == CGEN_WAVEFORM && stages[1].rgbWave.func == GF_INVERSE_SAWTOOTH ) ) { - stages[0].rgbGen = CGEN_IDENTITY_LIGHTING; - } - if ( ( stages[0].rgbGen == CGEN_WAVEFORM && stages[0].rgbWave.func == GF_INVERSE_SAWTOOTH ) - && ( stages[1].rgbGen == CGEN_WAVEFORM && stages[1].rgbWave.func == GF_SAWTOOTH ) ) { - stages[0].rgbGen = CGEN_IDENTITY_LIGHTING; - } - } - - for ( stage = 1; stage < MAX_SHADER_STAGES; stage++ ) { - shaderStage_t *pStage = &stages[stage]; - - if ( !pStage->active ) { - break; - } - - Com_Memset( pStage, 0, sizeof( *pStage ) ); - } -} - - -/* -=============== -InitShader -=============== -*/ -static void InitShader( const char *name, int lightmapIndex ) { - int i; - - // clear the global shader - Com_Memset( &shader, 0, sizeof( shader ) ); - Com_Memset( &stages, 0, sizeof( stages ) ); - - Q_strncpyz( shader.name, name, sizeof( shader.name ) ); - shader.lightmapIndex = lightmapIndex; - - // we need to know original (unmodified) lightmap index - // because shader search functions expects this - // otherwise they will fail and cause massive duplication - shader.lightmapSearchIndex = shader.lightmapIndex; - - for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) { - stages[i].bundle[0].texMods = texMods[i]; - - // default normal/specular - VectorSet4(stages[i].normalScale, 0.0f, 0.0f, 0.0f, 0.0f); - if (r_pbr->integer) - { - stages[i].specularScale[0] = r_baseGloss->value; - } - else - { - stages[i].specularScale[0] = - stages[i].specularScale[1] = - stages[i].specularScale[2] = r_baseSpecular->value; - stages[i].specularScale[3] = r_baseGloss->value; - } - } -} - -/* -========================= -FinishShader - -Returns a freshly allocated shader with all the needed info -from the current global working shader -========================= -*/ -static shader_t *FinishShader( void ) { - int stage; - qboolean hasLightmapStage; - qboolean vertexLightmap; - - hasLightmapStage = qfalse; - vertexLightmap = qfalse; - - // - // set sky stuff appropriate - // - if ( shader.isSky ) { - shader.sort = SS_ENVIRONMENT; - } - - // - // set polygon offset - // - if ( shader.polygonOffset && shader.sort == SS_BAD ) { - shader.sort = SS_DECAL; - } - - // - // set appropriate stage information - // - for ( stage = 0; stage < MAX_SHADER_STAGES; ) { - shaderStage_t *pStage = &stages[stage]; - - if ( !pStage->active ) { - break; - } - - // check for a missing texture - if ( !pStage->bundle[0].image[0] ) { - ri.Printf( PRINT_WARNING, "Shader %s has a stage with no image\n", shader.name ); - pStage->active = qfalse; - stage++; - continue; - } - - // - // ditch this stage if it's detail and detail textures are disabled - // - if ( pStage->isDetail && !r_detailTextures->integer ) - { - int index; - - for(index = stage + 1; index < MAX_SHADER_STAGES; index++) - { - if(!stages[index].active) - break; - } - - if(index < MAX_SHADER_STAGES) - memmove(pStage, pStage + 1, sizeof(*pStage) * (index - stage)); - else - { - if(stage + 1 < MAX_SHADER_STAGES) - memmove(pStage, pStage + 1, sizeof(*pStage) * (index - stage - 1)); - - Com_Memset(&stages[index - 1], 0, sizeof(*stages)); - } - - continue; - } - - // - // default texture coordinate generation - // - if ( pStage->bundle[0].isLightmap ) { - if ( pStage->bundle[0].tcGen == TCGEN_BAD ) { - pStage->bundle[0].tcGen = TCGEN_LIGHTMAP; - } - hasLightmapStage = qtrue; - } else { - if ( pStage->bundle[0].tcGen == TCGEN_BAD ) { - pStage->bundle[0].tcGen = TCGEN_TEXTURE; - } - } - - // not a true lightmap but we want to leave existing - // behaviour in place and not print out a warning - //if (pStage->rgbGen == CGEN_VERTEX) { - // vertexLightmap = qtrue; - //} - - // - // determine sort order and fog color adjustment - // - if ( ( pStage->stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) && - ( stages[0].stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) ) { - int blendSrcBits = pStage->stateBits & GLS_SRCBLEND_BITS; - int blendDstBits = pStage->stateBits & GLS_DSTBLEND_BITS; - - // fog color adjustment only works for blend modes that have a contribution - // that aproaches 0 as the modulate values aproach 0 -- - // GL_ONE, GL_ONE - // GL_ZERO, GL_ONE_MINUS_SRC_COLOR - // GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA - - // modulate, additive - if ( ( ( blendSrcBits == GLS_SRCBLEND_ONE ) && ( blendDstBits == GLS_DSTBLEND_ONE ) ) || - ( ( blendSrcBits == GLS_SRCBLEND_ZERO ) && ( blendDstBits == GLS_DSTBLEND_ONE_MINUS_SRC_COLOR ) ) ) { - pStage->adjustColorsForFog = ACFF_MODULATE_RGB; - } - // strict blend - else if ( ( blendSrcBits == GLS_SRCBLEND_SRC_ALPHA ) && ( blendDstBits == GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ) ) - { - pStage->adjustColorsForFog = ACFF_MODULATE_ALPHA; - } - // premultiplied alpha - else if ( ( blendSrcBits == GLS_SRCBLEND_ONE ) && ( blendDstBits == GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ) ) - { - pStage->adjustColorsForFog = ACFF_MODULATE_RGBA; - } else { - // we can't adjust this one correctly, so it won't be exactly correct in fog - } - - // don't screw with sort order if this is a portal or environment - if ( shader.sort == SS_BAD ) { - // see through item, like a grill or grate - if ( pStage->stateBits & GLS_DEPTHMASK_TRUE ) { - shader.sort = SS_SEE_THROUGH; - } else { - shader.sort = SS_BLEND0; - } - } - } - - stage++; - } - - // there are times when you will need to manually apply a sort to - // opaque alpha tested shaders that have later blend passes - if ( shader.sort == SS_BAD ) { - shader.sort = SS_OPAQUE; - } - - // - // if we are in r_vertexLight mode, never use a lightmap texture - // - if ( stage > 1 && ( (r_vertexLight->integer && tr.vertexLightingAllowed) || glConfig.hardwareType == GLHW_PERMEDIA2 ) ) { - VertexLightingCollapse(); - hasLightmapStage = qfalse; - } - - // - // look for multitexture potential - // - stage = CollapseStagesToGLSL(); - - if ( shader.lightmapIndex >= 0 && !hasLightmapStage ) { - if (vertexLightmap) { - ri.Printf( PRINT_DEVELOPER, "WARNING: shader '%s' has VERTEX forced lightmap!\n", shader.name ); - } else { - ri.Printf( PRINT_DEVELOPER, "WARNING: shader '%s' has lightmap but no lightmap stage!\n", shader.name ); - shader.lightmapIndex = LIGHTMAP_NONE; - } - } - - - // - // compute number of passes - // - shader.numUnfoggedPasses = stage; - - FindLightingStages(); - - // fogonly shaders don't have any normal passes - if (stage == 0 && !shader.isSky) - shader.sort = SS_FOG; - - // determine which stage iterator function is appropriate - ComputeStageIteratorFunc(); - - // determine which vertex attributes this shader needs - ComputeVertexAttribs(); - - return GeneratePermanentShader(); -} - -//======================================================================================== - -/* -==================== -FindShaderInShaderText - -Scans the combined text description of all the shader files for -the given shader name. - -return NULL if not found - -If found, it will return a valid shader -===================== -*/ -static const char *FindShaderInShaderText( const char *shadername ) { - - const char *token, *p; - - int i, hash; - - hash = generateHashValue(shadername, MAX_SHADERTEXT_HASH); - - if(shaderTextHashTable[hash]) - { - for (i = 0; shaderTextHashTable[hash][i]; i++) - { - p = shaderTextHashTable[hash][i]; - token = COM_ParseExt(&p, qtrue); - if(!Q_stricmp(token, shadername)) - return p; - } - } - - return NULL; -} - - -/* -================== -R_FindShaderByName - -Will always return a valid shader, but it might be the -default shader if the real one can't be found. -================== -*/ -shader_t *R_FindShaderByName( const char *name ) { - char strippedName[MAX_QPATH]; - int hash; - shader_t *sh; - - if ( (name==NULL) || (name[0] == 0) ) { - return tr.defaultShader; - } - - COM_StripExtension(name, strippedName, sizeof(strippedName)); - - hash = generateHashValue(strippedName, FILE_HASH_SIZE); - - // - // see if the shader is already loaded - // - for (sh=hashTable[hash]; sh; sh=sh->next) { - // NOTE: if there was no shader or image available with the name strippedName - // then a default shader is created with lightmapIndex == LIGHTMAP_NONE, so we - // have to check all default shaders otherwise for every call to R_FindShader - // with that same strippedName a new default shader is created. - if (Q_stricmp(sh->name, strippedName) == 0) { - // match found - return sh; - } - } - - return tr.defaultShader; -} - - -/* -=============== -R_FindShader - -Will always return a valid shader, but it might be the -default shader if the real one can't be found. - -In the interest of not requiring an explicit shader text entry to -be defined for every single image used in the game, three default -shader behaviors can be auto-created for any image: - -If lightmapIndex == LIGHTMAP_NONE, then the image will have -dynamic diffuse lighting applied to it, as appropriate for most -entity skin surfaces. - -If lightmapIndex == LIGHTMAP_2D, then the image will be used -for 2D rendering unless an explicit shader is found - -If lightmapIndex == LIGHTMAP_BY_VERTEX, then the image will use -the vertex rgba modulate values, as appropriate for misc_model -pre-lit surfaces. - -Other lightmapIndex values will have a lightmap stage created -and src*dest blending applied with the texture, as appropriate for -most world construction surfaces. - -=============== -*/ -shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImage ) { - char strippedName[MAX_QPATH]; - unsigned long hash; - const char *shaderText; - image_t *image; - shader_t *sh; - - if ( name[0] == '\0' ) { - return tr.defaultShader; - } - - // use (fullbright) vertex lighting if the bsp file doesn't have - // lightmaps - if ( lightmapIndex >= 0 && lightmapIndex >= tr.numLightmaps ) { - lightmapIndex = LIGHTMAP_BY_VERTEX; - } else if ( lightmapIndex < LIGHTMAP_2D ) { - // negative lightmap indexes cause stray pointers (think tr.lightmaps[lightmapIndex]) - ri.Printf( PRINT_WARNING, "WARNING: shader '%s' has invalid lightmap index of %d\n", name, lightmapIndex ); - lightmapIndex = LIGHTMAP_BY_VERTEX; - } - - COM_StripExtension(name, strippedName, sizeof(strippedName)); - - hash = generateHashValue(strippedName, FILE_HASH_SIZE); - - // - // see if the shader is already loaded - // - for (sh = hashTable[hash]; sh; sh = sh->next) { - // NOTE: if there was no shader or image available with the name strippedName - // then a default shader is created with lightmapIndex == LIGHTMAP_NONE, so we - // have to check all default shaders otherwise for every call to R_FindShader - // with that same strippedName a new default shader is created. - if ( (sh->lightmapSearchIndex == lightmapIndex || sh->defaultShader) && !Q_stricmp(sh->name, strippedName)) { - // match found - return sh; - } - } - - InitShader( strippedName, lightmapIndex ); - - // - // attempt to define shader from an explicit parameter file - // - shaderText = FindShaderInShaderText( strippedName ); - if ( shaderText ) { - // enable this when building a pak file to get a global list - // of all explicit shaders - if ( r_printShaders->integer ) { - ri.Printf( PRINT_ALL, "*SHADER* %s\n", name ); - } - - if ( !ParseShader( &shaderText ) ) { - // had errors, so use default shader - shader.defaultShader = qtrue; - } - sh = FinishShader(); - return sh; - } - - // - // if not defined in the in-memory shader descriptions, - // look for a single supported image file - // - { - imgFlags_t flags; - - flags = IMGFLAG_NONE; - - if (mipRawImage) - { - flags |= IMGFLAG_MIPMAP | IMGFLAG_PICMIP; - - if (r_genNormalMaps->integer) - flags |= IMGFLAG_GENNORMALMAP; - } - else - { - flags |= IMGFLAG_CLAMPTOEDGE; - } - - image = R_FindImageFile( name, IMGTYPE_COLORALPHA, flags ); - if ( !image ) { - ri.Printf( PRINT_DEVELOPER, "Couldn't find image file for shader %s\n", name ); - shader.defaultShader = qtrue; - return FinishShader(); - } - } - - // - // create the default shading commands - // - if ( shader.lightmapIndex == LIGHTMAP_NONE ) { - // dynamic colors at vertexes - stages[0].bundle[0].image[0] = image; - stages[0].active = qtrue; - stages[0].rgbGen = CGEN_LIGHTING_DIFFUSE; - stages[0].stateBits = GLS_DEFAULT; - } else if ( shader.lightmapIndex == LIGHTMAP_BY_VERTEX ) { - // explicit colors at vertexes - stages[0].bundle[0].image[0] = image; - stages[0].active = qtrue; - stages[0].rgbGen = CGEN_EXACT_VERTEX; - stages[0].alphaGen = AGEN_SKIP; - stages[0].stateBits = GLS_DEFAULT; - } else if ( shader.lightmapIndex == LIGHTMAP_2D ) { - // GUI elements - stages[0].bundle[0].image[0] = image; - stages[0].active = qtrue; - stages[0].rgbGen = CGEN_VERTEX; - stages[0].alphaGen = AGEN_VERTEX; - stages[0].stateBits = GLS_DEPTHTEST_DISABLE | - GLS_SRCBLEND_SRC_ALPHA | - GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; - } else if ( shader.lightmapIndex == LIGHTMAP_WHITEIMAGE ) { - // fullbright level - stages[0].bundle[0].image[0] = tr.whiteImage; - stages[0].active = qtrue; - stages[0].rgbGen = CGEN_IDENTITY_LIGHTING; - stages[0].stateBits = GLS_DEFAULT; - - stages[1].bundle[0].image[0] = image; - stages[1].active = qtrue; - stages[1].rgbGen = CGEN_IDENTITY; - stages[1].stateBits |= GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO; - } else { - // two pass lightmap - stages[0].bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex]; - stages[0].bundle[0].isLightmap = qtrue; - stages[0].active = qtrue; - stages[0].rgbGen = CGEN_IDENTITY; // lightmaps are scaled on creation - // for identitylight - stages[0].stateBits = GLS_DEFAULT; - - stages[1].bundle[0].image[0] = image; - stages[1].active = qtrue; - stages[1].rgbGen = CGEN_IDENTITY; - stages[1].stateBits |= GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO; - } - - return FinishShader(); -} - - -qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_t *image, qboolean mipRawImage) { - unsigned long hash; - shader_t *sh; - - hash = generateHashValue(name, FILE_HASH_SIZE); - - // probably not necessary since this function - // only gets called from tr_font.c with lightmapIndex == LIGHTMAP_2D - // but better safe than sorry. - if ( lightmapIndex >= tr.numLightmaps ) { - lightmapIndex = LIGHTMAP_WHITEIMAGE; - } - - // - // see if the shader is already loaded - // - for (sh=hashTable[hash]; sh; sh=sh->next) { - // NOTE: if there was no shader or image available with the name strippedName - // then a default shader is created with lightmapIndex == LIGHTMAP_NONE, so we - // have to check all default shaders otherwise for every call to R_FindShader - // with that same strippedName a new default shader is created. - if ( (sh->lightmapSearchIndex == lightmapIndex || sh->defaultShader) && !Q_stricmp(sh->name, name)) { - // match found - return sh->index; - } - } - - InitShader( name, lightmapIndex ); - - // - // create the default shading commands - // - if ( shader.lightmapIndex == LIGHTMAP_NONE ) { - // dynamic colors at vertexes - stages[0].bundle[0].image[0] = image; - stages[0].active = qtrue; - stages[0].rgbGen = CGEN_LIGHTING_DIFFUSE; - stages[0].stateBits = GLS_DEFAULT; - } else if ( shader.lightmapIndex == LIGHTMAP_BY_VERTEX ) { - // explicit colors at vertexes - stages[0].bundle[0].image[0] = image; - stages[0].active = qtrue; - stages[0].rgbGen = CGEN_EXACT_VERTEX; - stages[0].alphaGen = AGEN_SKIP; - stages[0].stateBits = GLS_DEFAULT; - } else if ( shader.lightmapIndex == LIGHTMAP_2D ) { - // GUI elements - stages[0].bundle[0].image[0] = image; - stages[0].active = qtrue; - stages[0].rgbGen = CGEN_VERTEX; - stages[0].alphaGen = AGEN_VERTEX; - stages[0].stateBits = GLS_DEPTHTEST_DISABLE | - GLS_SRCBLEND_SRC_ALPHA | - GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; - } else if ( shader.lightmapIndex == LIGHTMAP_WHITEIMAGE ) { - // fullbright level - stages[0].bundle[0].image[0] = tr.whiteImage; - stages[0].active = qtrue; - stages[0].rgbGen = CGEN_IDENTITY_LIGHTING; - stages[0].stateBits = GLS_DEFAULT; - - stages[1].bundle[0].image[0] = image; - stages[1].active = qtrue; - stages[1].rgbGen = CGEN_IDENTITY; - stages[1].stateBits |= GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO; - } else { - // two pass lightmap - stages[0].bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex]; - stages[0].bundle[0].isLightmap = qtrue; - stages[0].active = qtrue; - stages[0].rgbGen = CGEN_IDENTITY; // lightmaps are scaled on creation - // for identitylight - stages[0].stateBits = GLS_DEFAULT; - - stages[1].bundle[0].image[0] = image; - stages[1].active = qtrue; - stages[1].rgbGen = CGEN_IDENTITY; - stages[1].stateBits |= GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO; - } - - sh = FinishShader(); - return sh->index; -} - - -/* -==================== -RE_RegisterShaderLightMap - -This is the exported shader entry point for the rest of the system -It will always return an index that will be valid. - -This should really only be used for explicit shaders, because there is no -way to ask for different implicit lighting modes (vertex, lightmap, etc) -==================== -*/ -qhandle_t RE_RegisterShaderLightMap( const char *name, int lightmapIndex ) { - shader_t *sh; - - if ( strlen( name ) >= MAX_QPATH ) { - ri.Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); - return 0; - } - - sh = R_FindShader( name, lightmapIndex, qtrue ); - - // we want to return 0 if the shader failed to - // load for some reason, but R_FindShader should - // still keep a name allocated for it, so if - // something calls RE_RegisterShader again with - // the same name, we don't try looking for it again - if ( sh->defaultShader ) { - return 0; - } - - return sh->index; -} - - -/* -==================== -RE_RegisterShader - -This is the exported shader entry point for the rest of the system -It will always return an index that will be valid. - -This should really only be used for explicit shaders, because there is no -way to ask for different implicit lighting modes (vertex, lightmap, etc) -==================== -*/ -qhandle_t RE_RegisterShader( const char *name ) { - shader_t *sh; - - if ( !name ) { - ri.Printf( PRINT_ALL, "NULL shader\n" ); - return 0; - } - - if ( strlen( name ) >= MAX_QPATH ) { - ri.Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); - return 0; - } - - sh = R_FindShader( name, LIGHTMAP_2D, qtrue ); - - // we want to return 0 if the shader failed to - // load for some reason, but R_FindShader should - // still keep a name allocated for it, so if - // something calls RE_RegisterShader again with - // the same name, we don't try looking for it again - if ( sh->defaultShader ) { - return 0; - } - - return sh->index; -} - - -/* -==================== -RE_RegisterShaderNoMip - -For menu graphics that should never be picmiped -==================== -*/ -qhandle_t RE_RegisterShaderNoMip( const char *name ) { - shader_t *sh; - - if ( strlen( name ) >= MAX_QPATH ) { - ri.Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); - return 0; - } - - sh = R_FindShader( name, LIGHTMAP_2D, qfalse ); - - // we want to return 0 if the shader failed to - // load for some reason, but R_FindShader should - // still keep a name allocated for it, so if - // something calls RE_RegisterShader again with - // the same name, we don't try looking for it again - if ( sh->defaultShader ) { - return 0; - } - - return sh->index; -} - -/* -==================== -R_GetShaderByHandle - -When a handle is passed in by another module, this range checks -it and returns a valid (possibly default) shader_t to be used internally. -==================== -*/ -shader_t *R_GetShaderByHandle( qhandle_t hShader ) { - if ( hShader < 0 ) { - ri.Printf( PRINT_WARNING, "R_GetShaderByHandle: out of range hShader '%d'\n", hShader ); - return tr.defaultShader; - } - if ( hShader >= tr.numShaders ) { - ri.Printf( PRINT_WARNING, "R_GetShaderByHandle: out of range hShader '%d'\n", hShader ); - return tr.defaultShader; - } - return tr.shaders[hShader]; -} - -/* -=============== -R_ShaderList_f - -Dump information on all valid shaders to the console -A second parameter will cause it to print in sorted order -=============== -*/ -void R_ShaderList_f (void) { - int i; - int count; - const shader_t *sh; - - ri.Printf (PRINT_ALL, "-----------------------\n"); - - count = 0; - for ( i = 0 ; i < tr.numShaders ; i++ ) { - if ( ri.Cmd_Argc() > 1 ) { - sh = tr.sortedShaders[i]; - } else { - sh = tr.shaders[i]; - } - - ri.Printf( PRINT_ALL, "%i ", sh->numUnfoggedPasses ); - - if ( sh->lightmapIndex >= 0 ) { - ri.Printf (PRINT_ALL, "L "); - } else { - ri.Printf (PRINT_ALL, " "); - } - if ( sh->explicitlyDefined ) { - ri.Printf( PRINT_ALL, "E " ); - } else { - ri.Printf( PRINT_ALL, " " ); - } - - if ( sh->optimalStageIteratorFunc == RB_StageIteratorGeneric ) { - ri.Printf( PRINT_ALL, "gen " ); - } else if ( sh->optimalStageIteratorFunc == RB_StageIteratorSky ) { - ri.Printf( PRINT_ALL, "sky " ); - } else { - ri.Printf( PRINT_ALL, " " ); - } - - if ( sh->defaultShader ) { - ri.Printf (PRINT_ALL, ": %s (DEFAULTED)\n", sh->name); - } else { - ri.Printf (PRINT_ALL, ": %s\n", sh->name); - } - count++; - } - ri.Printf (PRINT_ALL, "%i total shaders\n", count); - ri.Printf (PRINT_ALL, "------------------\n"); -} - - -#define MAX_SHADER_FILES 16384 - -static int loadShaderBuffers( char **shaderFiles, const int numShaderFiles, char **buffers ) -{ - char filename[MAX_QPATH+8]; - char shaderName[MAX_QPATH]; - const char *p, *token; - long summand, sum = 0; - int shaderLine; - int i; - const char *shaderStart; - qboolean denyErrors; - - // load and parse shader files - for ( i = 0; i < numShaderFiles; i++ ) - { - Com_sprintf( filename, sizeof( filename ), "scripts/%s", shaderFiles[i] ); - //ri.Printf( PRINT_DEVELOPER, "...loading '%s'\n", filename ); - summand = ri.FS_ReadFile( filename, (void **)&buffers[i] ); - - if ( !buffers[i] ) - ri.Error( ERR_DROP, "Couldn't load %s", filename ); - - // comment some buggy shaders from pak0 - if ( summand == 35910 && strcmp( shaderFiles[i], "sky.shader" ) == 0 ) - { - if ( memcmp( buffers[i] + 0x3D3E, "\tcloudparms ", 12 ) == 0 ) - { - memcpy( buffers[i] + 0x27D7, "/*", 2 ); - memcpy( buffers[i] + 0x2A93, "*/", 2 ); - - memcpy( buffers[i] + 0x3CA9, "/*", 2 ); - memcpy( buffers[i] + 0x3FC2, "*/", 2 ); - } - } - else if ( summand == 116073 && strcmp( shaderFiles[i], "sfx.shader" ) == 0 ) - { - if ( memcmp( buffers[i] + 93457, "textures/sfx/xfinalfog\r\n", 24 ) == 0 ) - { - memcpy( buffers[i] + 93457, "/*", 2 ); - memcpy( buffers[i] + 93663, "*/", 2 ); - } - } - - p = buffers[i]; - COM_BeginParseSession( filename ); - - shaderStart = NULL; - denyErrors = qfalse; - - while ( 1 ) - { - token = COM_ParseExt( &p, qtrue ); - - if ( !*token ) - break; - - Q_strncpyz( shaderName, token, sizeof( shaderName ) ); - shaderLine = COM_GetCurrentParseLine(); - - token = COM_ParseExt( &p, qtrue ); - if ( token[0] != '{' || token[1] != '\0' ) - { - ri.Printf( PRINT_DEVELOPER, "File %s: shader \"%s\" " \ - "on line %d missing opening brace", filename, shaderName, shaderLine ); - if ( token[0] ) - ri.Printf( PRINT_DEVELOPER, " (found \"%s\" on line %d)\n", token, COM_GetCurrentParseLine() ); - else - ri.Printf( PRINT_DEVELOPER, "\n" ); - - if ( denyErrors || !p ) - { - ri.Printf( PRINT_WARNING, "Ignoring entire file '%s' due to error.\n", filename ); - ri.FS_FreeFile( buffers[i] ); - buffers[i] = NULL; - break; - } - - SkipRestOfLine( &p ); - shaderStart = p; - continue; - } - - if ( !SkipBracedSection( &p, 1 ) ) - { - ri.Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" " \ - "on line %d missing closing brace.\n", filename, shaderName, shaderLine ); - ri.FS_FreeFile( buffers[i] ); - buffers[i] = NULL; - break; - } - - denyErrors = qtrue; - } - - if ( buffers[ i ] ) { - if ( shaderStart ) { - summand -= (shaderStart - buffers[i]); - if ( summand >= 0 ) { - memmove( buffers[i], shaderStart, summand + 1 ); - } - } - //sum += summand; - sum += COM_Compress( buffers[ i ] ); - } - } - - return sum; -} - - -/* -==================== -ScanAndLoadShaderFiles - -Finds and loads all .shader files, combining them into -a single large text block that can be scanned for shader names -===================== -*/ -static void ScanAndLoadShaderFiles( void ) -{ - char **shaderFiles, **mtrFiles; - char *buffers[MAX_SHADER_FILES]; - char *xbuffers[MAX_SHADER_FILES]; - int numShaderFiles, numMtrFiles; - int i; - const char *token, *hashMem; - char *textEnd; - const char *p, *oldp; - int shaderTextHashTableSizes[MAX_SHADERTEXT_HASH], hash, size; - - long sum = 0; - - // scan for legacy shader files - shaderFiles = ri.FS_ListFiles( "scripts", ".shader", &numShaderFiles ); - mtrFiles = ri.FS_ListFiles( "scripts", ".mtrx", &numMtrFiles ); - - if ( (!shaderFiles || !numShaderFiles) && (!mtrFiles || !numMtrFiles) ) { - ri.Printf( PRINT_WARNING, "WARNING: no shader files found\n" ); - return; - } - - if ( numShaderFiles > MAX_SHADER_FILES ) { - numShaderFiles = MAX_SHADER_FILES; - } - if ( numMtrFiles > MAX_SHADER_FILES ) { - numMtrFiles = MAX_SHADER_FILES; - } - - sum = 0; - sum += loadShaderBuffers( mtrFiles, numMtrFiles, xbuffers ); - sum += loadShaderBuffers( shaderFiles, numShaderFiles, buffers ); - - // build single large buffer - s_shaderText = ri.Hunk_Alloc( sum + numMtrFiles*2 + numShaderFiles*2 + 1, h_low ); - s_shaderText[ 0 ] = s_shaderText[ sum + numMtrFiles*2 + numShaderFiles*2 ] = '\0'; - - textEnd = s_shaderText; - - // free in reverse order, so the temp files are all dumped - // legacy shaders - for ( i = numShaderFiles - 1; i >= 0 ; i-- ) { - if ( buffers[ i ] ) { - textEnd = Q_stradd( textEnd, buffers[ i ] ); - textEnd = Q_stradd( textEnd, "\n" ); - ri.FS_FreeFile( buffers[ i ] ); - } - } - - // if shader text >= s_extensionOffset then it is an extended shader - // normal shaders will never encounter that - s_extensionOffset = textEnd; - - // extended shaders - for ( i = numMtrFiles - 1; i >= 0 ; i-- ) { - if ( xbuffers[ i ] ) { - textEnd = Q_stradd( textEnd, xbuffers[ i ] ); - textEnd = Q_stradd( textEnd, "\n" ); - ri.FS_FreeFile( xbuffers[ i ] ); - } - } - - // free up memory - if ( mtrFiles ) - ri.FS_FreeFileList( mtrFiles ); - if ( shaderFiles ) - ri.FS_FreeFileList( shaderFiles ); - - //COM_Compress( s_shaderText ); - Com_Memset( shaderTextHashTableSizes, 0, sizeof( shaderTextHashTableSizes ) ); - size = 0; - - p = s_shaderText; - // look for shader names - while ( 1 ) { - token = COM_ParseExt( &p, qtrue ); - if ( token[0] == 0 ) { - break; - } - hash = generateHashValue(token, MAX_SHADERTEXT_HASH); - shaderTextHashTableSizes[hash]++; - size++; - SkipBracedSection(&p, 0); - } - - size += MAX_SHADERTEXT_HASH; - - hashMem = ri.Hunk_Alloc( size * sizeof(char *), h_low ); - - for (i = 0; i < MAX_SHADERTEXT_HASH; i++) { - shaderTextHashTable[i] = (const char **) hashMem; - hashMem = ((char *) hashMem) + ((shaderTextHashTableSizes[i] + 1) * sizeof(char *)); - } - - p = s_shaderText; - // look for shader names - while ( 1 ) { - oldp = p; - token = COM_ParseExt( &p, qtrue ); - if ( token[0] == 0 ) { - break; - } - - hash = generateHashValue(token, MAX_SHADERTEXT_HASH); - shaderTextHashTable[hash][--shaderTextHashTableSizes[hash]] = (char*)oldp; - - SkipBracedSection(&p, 0); - } -} - - -/* -==================== -CreateInternalShaders -==================== -*/ -static void CreateInternalShaders( void ) { - tr.numShaders = 0; - - // init the default shader - InitShader( "", LIGHTMAP_NONE ); - stages[0].bundle[0].image[0] = tr.defaultImage; - stages[0].active = qtrue; - stages[0].stateBits = GLS_DEFAULT; - tr.defaultShader = FinishShader(); - - // shadow shader is just a marker - Q_strncpyz( shader.name, "", sizeof( shader.name ) ); - shader.sort = SS_STENCIL_SHADOW; - tr.shadowShader = FinishShader(); -} - - -/* -==================== -CreateExternalShaders -==================== -*/ -static void CreateExternalShaders( void ) { - tr.projectionShadowShader = R_FindShader( "projectionShadow", LIGHTMAP_NONE, qtrue ); - tr.flareShader = R_FindShader( "flareShader", LIGHTMAP_NONE, qtrue ); - - // Hack to make fogging work correctly on flares. Fog colors are calculated - // in tr_flare.c already. - if(!tr.flareShader->defaultShader) - { - int index; - - for(index = 0; index < tr.flareShader->numUnfoggedPasses; index++) - { - tr.flareShader->stages[index]->adjustColorsForFog = ACFF_NONE; - tr.flareShader->stages[index]->stateBits |= GLS_DEPTHTEST_DISABLE; - } - } - - tr.sunShader = R_FindShader( "sun", LIGHTMAP_NONE, qtrue ); - - tr.sunFlareShader = R_FindShader( "gfx/2d/sunflare", LIGHTMAP_NONE, qtrue); - - // HACK: if sunflare is missing, make one using the flare image or dlight image - if (tr.sunFlareShader->defaultShader) - { - image_t *image; - - if (!tr.flareShader->defaultShader && tr.flareShader->stages[0] && tr.flareShader->stages[0]->bundle[0].image[0]) - image = tr.flareShader->stages[0]->bundle[0].image[0]; - else - image = tr.dlightImage; - - InitShader( "gfx/2d/sunflare", LIGHTMAP_NONE ); - stages[0].bundle[0].image[0] = image; - stages[0].active = qtrue; - stages[0].stateBits = GLS_DEFAULT; - tr.sunFlareShader = FinishShader(); - } - -} - -/* -================== -R_InitShaders -================== -*/ -void R_InitShaders( void ) { - ri.Printf( PRINT_ALL, "Initializing Shaders\n" ); - - Com_Memset(hashTable, 0, sizeof(hashTable)); - - CreateInternalShaders(); - - ScanAndLoadShaderFiles(); - - CreateExternalShaders(); -} diff --git a/code/renderer2/tr_shadows.c b/code/renderer2/tr_shadows.c deleted file mode 100644 index 84a256b1ad..0000000000 --- a/code/renderer2/tr_shadows.c +++ /dev/null @@ -1,333 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -#include "tr_local.h" - - -/* - - for a projection shadow: - - point[x] += light vector * ( z - shadow plane ) - point[y] += - point[z] = shadow plane - - 1 0 light[x] / light[z] - -*/ - -typedef struct { - int i2; - int facing; -} edgeDef_t; - -#define MAX_EDGE_DEFS 32 - -static edgeDef_t edgeDefs[SHADER_MAX_VERTEXES][MAX_EDGE_DEFS]; -static int numEdgeDefs[SHADER_MAX_VERTEXES]; -//static int facing[SHADER_MAX_INDEXES/3]; -//static vec3_t shadowXyz[SHADER_MAX_VERTEXES]; - -void R_AddEdgeDef( int i1, int i2, int facing ) { - int c; - - c = numEdgeDefs[ i1 ]; - if ( c == MAX_EDGE_DEFS ) { - return; // overflow - } - edgeDefs[ i1 ][ c ].i2 = i2; - edgeDefs[ i1 ][ c ].facing = facing; - - numEdgeDefs[ i1 ]++; -} - -void R_RenderShadowEdges( void ) { - // FIXME: implement this -#if 0 - int i; - -#if 0 - int numTris; - - // dumb way -- render every triangle's edges - numTris = tess.numIndexes / 3; - - for ( i = 0 ; i < numTris ; i++ ) { - int i1, i2, i3; - - if ( !facing[i] ) { - continue; - } - - i1 = tess.indexes[ i*3 + 0 ]; - i2 = tess.indexes[ i*3 + 1 ]; - i3 = tess.indexes[ i*3 + 2 ]; - - qglBegin( GL_TRIANGLE_STRIP ); - qglVertex3fv( tess.xyz[ i1 ] ); - qglVertex3fv( shadowXyz[ i1 ] ); - qglVertex3fv( tess.xyz[ i2 ] ); - qglVertex3fv( shadowXyz[ i2 ] ); - qglVertex3fv( tess.xyz[ i3 ] ); - qglVertex3fv( shadowXyz[ i3 ] ); - qglVertex3fv( tess.xyz[ i1 ] ); - qglVertex3fv( shadowXyz[ i1 ] ); - qglEnd(); - } -#else - int c, c2; - int j, k; - int i2; - int c_edges, c_rejected; - int hit[2]; - - // an edge is NOT a silhouette edge if its face doesn't face the light, - // or if it has a reverse paired edge that also faces the light. - // A well behaved polyhedron would have exactly two faces for each edge, - // but lots of models have dangling edges or overfanned edges - c_edges = 0; - c_rejected = 0; - - for ( i = 0 ; i < tess.numVertexes ; i++ ) { - c = numEdgeDefs[ i ]; - for ( j = 0 ; j < c ; j++ ) { - if ( !edgeDefs[ i ][ j ].facing ) { - continue; - } - - hit[0] = 0; - hit[1] = 0; - - i2 = edgeDefs[ i ][ j ].i2; - c2 = numEdgeDefs[ i2 ]; - for ( k = 0 ; k < c2 ; k++ ) { - if ( edgeDefs[ i2 ][ k ].i2 == i ) { - hit[ edgeDefs[ i2 ][ k ].facing ]++; - } - } - - // if it doesn't share the edge with another front facing - // triangle, it is a sil edge - if ( hit[ 1 ] == 0 ) { - qglBegin( GL_TRIANGLE_STRIP ); - qglVertex3fv( tess.xyz[ i ] ); - qglVertex3fv( shadowXyz[ i ] ); - qglVertex3fv( tess.xyz[ i2 ] ); - qglVertex3fv( shadowXyz[ i2 ] ); - qglEnd(); - c_edges++; - } else { - c_rejected++; - } - } - } -#endif -#endif -} - -/* -================= -RB_ShadowTessEnd - -triangleFromEdge[ v1 ][ v2 ] - - - set triangle from edge( v1, v2, tri ) - if ( facing[ triangleFromEdge[ v1 ][ v2 ] ] && !facing[ triangleFromEdge[ v2 ][ v1 ] ) { - } -================= -*/ -void RB_ShadowTessEnd( void ) { - // FIXME: implement this -#if 0 - int i; - int numTris; - vec3_t lightDir; - GLboolean rgba[4]; - - if ( glConfig.stencilBits < 4 ) { - return; - } - - VectorCopy( backEnd.currentEntity->modelLightDir, lightDir ); - - // project vertexes away from light direction - for ( i = 0 ; i < tess.numVertexes ; i++ ) { - VectorMA( tess.xyz[i], -512, lightDir, shadowXyz[i] ); - } - - // decide which triangles face the light - Com_Memset( numEdgeDefs, 0, 4 * tess.numVertexes ); - - numTris = tess.numIndexes / 3; - for ( i = 0 ; i < numTris ; i++ ) { - int i1, i2, i3; - vec3_t d1, d2, normal; - float *v1, *v2, *v3; - float d; - - i1 = tess.indexes[ i*3 + 0 ]; - i2 = tess.indexes[ i*3 + 1 ]; - i3 = tess.indexes[ i*3 + 2 ]; - - v1 = tess.xyz[ i1 ]; - v2 = tess.xyz[ i2 ]; - v3 = tess.xyz[ i3 ]; - - VectorSubtract( v2, v1, d1 ); - VectorSubtract( v3, v1, d2 ); - CrossProduct( d1, d2, normal ); - - d = DotProduct( normal, lightDir ); - if ( d > 0 ) { - facing[ i ] = 1; - } else { - facing[ i ] = 0; - } - - // create the edges - R_AddEdgeDef( i1, i2, facing[ i ] ); - R_AddEdgeDef( i2, i3, facing[ i ] ); - R_AddEdgeDef( i3, i1, facing[ i ] ); - } - - // draw the silhouette edges - - GL_BindToTMU( tr.whiteImage, TB_COLORMAP ); - GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); - qglColor3f( 0.2f, 0.2f, 0.2f ); - - // don't write to the color buffer - qglGetBooleanv(GL_COLOR_WRITEMASK, rgba); - qglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); - - qglEnable( GL_STENCIL_TEST ); - qglStencilFunc( GL_ALWAYS, 1, 255 ); - - GL_Cull( CT_BACK_SIDED ); - qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR ); - - R_RenderShadowEdges(); - - GL_Cull( CT_FRONT_SIDED ); - qglStencilOp( GL_KEEP, GL_KEEP, GL_DECR ); - - R_RenderShadowEdges(); - - - // re-enable writing to the color buffer - qglColorMask(rgba[0], rgba[1], rgba[2], rgba[3]); -#endif -} - - -/* -================= -RB_ShadowFinish - -Darken everything that is is a shadow volume. -We have to delay this until everything has been shadowed, -because otherwise shadows from different body parts would -overlap and double darken. -================= -*/ -void RB_ShadowFinish( void ) { - // FIXME: implement this -#if 0 - if ( r_shadows->integer != 2 ) { - return; - } - if ( glConfig.stencilBits < 4 ) { - return; - } - qglEnable( GL_STENCIL_TEST ); - qglStencilFunc( GL_NOTEQUAL, 0, 255 ); - - GL_Cull( CT_TWO_SIDED ); - - GL_BindToTMU( tr.whiteImage, TB_COLORMAP ); - - qglLoadIdentity (); - - qglColor3f( 0.6f, 0.6f, 0.6f ); - GL_State( GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO ); - -// qglColor3f( 1, 0, 0 ); -// GL_State( GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); - - qglBegin( GL_QUADS ); - qglVertex3f( -100, 100, -10 ); - qglVertex3f( 100, 100, -10 ); - qglVertex3f( 100, -100, -10 ); - qglVertex3f( -100, -100, -10 ); - qglEnd (); - - qglColor4f(1,1,1,1); - qglDisable( GL_STENCIL_TEST ); -#endif -} - - -/* -================= -RB_ProjectionShadowDeform - -================= -*/ -void RB_ProjectionShadowDeform( void ) { - float *xyz; - int i; - float h; - vec3_t ground; - vec3_t light; - float groundDist; - float d; - vec3_t lightDir; - - xyz = ( float * ) tess.xyz; - - ground[0] = backEnd.or.axis[0][2]; - ground[1] = backEnd.or.axis[1][2]; - ground[2] = backEnd.or.axis[2][2]; - - groundDist = backEnd.or.origin[2] - backEnd.currentEntity->e.shadowPlane; - - VectorCopy( backEnd.currentEntity->modelLightDir, lightDir ); - d = DotProduct( lightDir, ground ); - // don't let the shadows get too long or go negative - if ( d < 0.5 ) { - VectorMA( lightDir, (0.5 - d), ground, lightDir ); - d = DotProduct( lightDir, ground ); - } - d = 1.0 / d; - - light[0] = lightDir[0] * d; - light[1] = lightDir[1] * d; - light[2] = lightDir[2] * d; - - for ( i = 0; i < tess.numVertexes; i++, xyz += 4 ) { - h = DotProduct( xyz, ground ) + groundDist; - - xyz[0] -= light[0] * h; - xyz[1] -= light[1] * h; - xyz[2] -= light[2] * h; - } -} diff --git a/code/renderer2/tr_sky.c b/code/renderer2/tr_sky.c deleted file mode 100644 index b140ec0b61..0000000000 --- a/code/renderer2/tr_sky.c +++ /dev/null @@ -1,907 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_sky.c -#include "tr_local.h" - -#define SKY_SUBDIVISIONS 8 -#define HALF_SKY_SUBDIVISIONS (SKY_SUBDIVISIONS/2) - -static float s_cloudTexCoords[6][SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1][2]; -static float s_cloudTexP[6][SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1]; - -/* -=================================================================================== - -POLYGON TO BOX SIDE PROJECTION - -=================================================================================== -*/ - -static const vec3_t sky_clip[6] = -{ - {1,1,0}, - {1,-1,0}, - {0,-1,1}, - {0,1,1}, - {1,0,1}, - {-1,0,1} -}; - -static float sky_mins[2][6], sky_maxs[2][6]; -static float sky_min, sky_max; - -/* -================ -AddSkyPolygon -================ -*/ -static void AddSkyPolygon (int nump, vec3_t vecs) -{ - int i,j; - vec3_t v, av; - float s, t, dv; - int axis; - float *vp; - // s = [0]/[2], t = [1]/[2] - static const int vec_to_st[6][3] = - { - {-2,3,1}, - {2,3,-1}, - - {1,3,2}, - {-1,3,-2}, - - {-2,-1,3}, - {-2,1,-3} - - // {-1,2,3}, - // {1,2,-3} - }; - - // decide which face it maps to - VectorCopy (vec3_origin, v); - for (i=0, vp=vecs ; i av[1] && av[0] > av[2]) - { - if (v[0] < 0) - axis = 1; - else - axis = 0; - } - else if (av[1] > av[2] && av[1] > av[0]) - { - if (v[1] < 0) - axis = 3; - else - axis = 2; - } - else - { - if (v[2] < 0) - axis = 5; - else - axis = 4; - } - - // project new texture coords - for (i=0 ; i 0) - dv = vecs[j - 1]; - else - dv = -vecs[-j - 1]; - if (dv < 0.001) - continue; // don't divide by zero - j = vec_to_st[axis][0]; - if (j < 0) - s = -vecs[-j -1] / dv; - else - s = vecs[j-1] / dv; - j = vec_to_st[axis][1]; - if (j < 0) - t = -vecs[-j -1] / dv; - else - t = vecs[j-1] / dv; - - if (s < sky_mins[0][axis]) - sky_mins[0][axis] = s; - if (t < sky_mins[1][axis]) - sky_mins[1][axis] = t; - if (s > sky_maxs[0][axis]) - sky_maxs[0][axis] = s; - if (t > sky_maxs[1][axis]) - sky_maxs[1][axis] = t; - } -} - -#define ON_EPSILON 0.1f // point on plane side epsilon -#define MAX_CLIP_VERTS 64 -/* -================ -ClipSkyPolygon -================ -*/ -static void ClipSkyPolygon (int nump, vec3_t vecs, int stage) -{ - const float *norm; - float *v; - qboolean front, back; - float d, e; - float dists[MAX_CLIP_VERTS]; - int sides[MAX_CLIP_VERTS]; - vec3_t newv[2][MAX_CLIP_VERTS]; - int newc[2]; - int i, j; - - if (nump > MAX_CLIP_VERTS-2) - ri.Error (ERR_DROP, "ClipSkyPolygon: MAX_CLIP_VERTS"); - if (stage == 6) - { // fully clipped, so draw it - AddSkyPolygon (nump, vecs); - return; - } - - front = back = qfalse; - norm = sky_clip[stage]; - for (i=0, v = vecs ; i ON_EPSILON) - { - front = qtrue; - sides[i] = SIDE_FRONT; - } - else if (d < -ON_EPSILON) - { - back = qtrue; - sides[i] = SIDE_BACK; - } - else - sides[i] = SIDE_ON; - dists[i] = d; - } - - if (!front || !back) - { // not clipped - ClipSkyPolygon (nump, vecs, stage+1); - return; - } - - // clip it - sides[i] = sides[0]; - dists[i] = dists[0]; - VectorCopy (vecs, (vecs+(i*3)) ); - newc[0] = newc[1] = 0; - - for (i=0, v = vecs ; inumIndexes; i += 3 ) - { - for (j = 0 ; j < 3 ; j++) - { - VectorSubtract( input->xyz[input->indexes[i+j]], - backEnd.viewParms.or.origin, - p[j] ); - } - ClipSkyPolygon( 3, p[0], 0 ); - } -} - -/* -=================================================================================== - -CLOUD VERTEX GENERATION - -=================================================================================== -*/ - -/* -** MakeSkyVec -** -** Parms: s, t range from -1 to 1 -*/ -static void MakeSkyVec( float s, float t, int axis, float outSt[2], vec3_t outXYZ ) -{ - // 1 = s, 2 = t, 3 = 2048 - static const int st_to_vec[6][3] = - { - {3,-1,2}, - {-3,1,2}, - - {1,3,2}, - {-1,-3,2}, - - {-2,-1,3}, // 0 degrees yaw, look straight up - {2,-1,-3} // look straight down - }; - - vec3_t b; - int j, k; - float boxSize; - - boxSize = backEnd.viewParms.zFar / 1.75; // div sqrt(3) - b[0] = s*boxSize; - b[1] = t*boxSize; - b[2] = boxSize; - - for (j=0 ; j<3 ; j++) - { - k = st_to_vec[axis][j]; - if (k < 0) - { - outXYZ[j] = -b[-k - 1]; - } - else - { - outXYZ[j] = b[k - 1]; - } - } - - // avoid bilerp seam - s = (s+1)*0.5; - t = (t+1)*0.5; - if (s < sky_min) - { - s = sky_min; - } - else if (s > sky_max) - { - s = sky_max; - } - - if (t < sky_min) - { - t = sky_min; - } - else if (t > sky_max) - { - t = sky_max; - } - - t = 1.0 - t; - - - if ( outSt ) - { - outSt[0] = s; - outSt[1] = t; - } -} - -static const int sky_texorder[6] = {0,2,1,3,4,5}; -static vec3_t s_skyPoints[SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1]; -static float s_skyTexCoords[SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1][2]; - -static void DrawSkySide( struct image_s *image, const int mins[2], const int maxs[2] ) -{ - int s, t; - int firstVertex = tess.numVertexes; - //int firstIndex = tess.numIndexes; - vec4_t color; - - //tess.numVertexes = 0; - //tess.numIndexes = 0; - tess.firstIndex = tess.numIndexes; - - GL_BindToTMU( image, TB_COLORMAP ); - GL_Cull( CT_TWO_SIDED ); - - for ( t = mins[1]+HALF_SKY_SUBDIVISIONS; t <= maxs[1]+HALF_SKY_SUBDIVISIONS; t++ ) - { - for ( s = mins[0]+HALF_SKY_SUBDIVISIONS; s <= maxs[0]+HALF_SKY_SUBDIVISIONS; s++ ) - { - tess.xyz[tess.numVertexes][0] = s_skyPoints[t][s][0]; - tess.xyz[tess.numVertexes][1] = s_skyPoints[t][s][1]; - tess.xyz[tess.numVertexes][2] = s_skyPoints[t][s][2]; - tess.xyz[tess.numVertexes][3] = 1.0; - - tess.texCoords[tess.numVertexes][0] = s_skyTexCoords[t][s][0]; - tess.texCoords[tess.numVertexes][1] = s_skyTexCoords[t][s][1]; - - tess.numVertexes++; - - if(tess.numVertexes >= SHADER_MAX_VERTEXES) - { - ri.Error(ERR_DROP, "SHADER_MAX_VERTEXES hit in DrawSkySideVBO()"); - } - } - } - - for ( t = 0; t < maxs[1] - mins[1]; t++ ) - { - for ( s = 0; s < maxs[0] - mins[0]; s++ ) - { - if (tess.numIndexes + 6 >= SHADER_MAX_INDEXES) - { - ri.Error(ERR_DROP, "SHADER_MAX_INDEXES hit in DrawSkySideVBO()"); - } - - tess.indexes[tess.numIndexes++] = s + t * (maxs[0] - mins[0] + 1) + firstVertex; - tess.indexes[tess.numIndexes++] = s + (t + 1) * (maxs[0] - mins[0] + 1) + firstVertex; - tess.indexes[tess.numIndexes++] = (s + 1) + t * (maxs[0] - mins[0] + 1) + firstVertex; - - tess.indexes[tess.numIndexes++] = (s + 1) + t * (maxs[0] - mins[0] + 1) + firstVertex; - tess.indexes[tess.numIndexes++] = s + (t + 1) * (maxs[0] - mins[0] + 1) + firstVertex; - tess.indexes[tess.numIndexes++] = (s + 1) + (t + 1) * (maxs[0] - mins[0] + 1) + firstVertex; - } - } - - // FIXME: A lot of this can probably be removed for speed, and refactored into a more convenient function - RB_UpdateTessVao(ATTR_POSITION | ATTR_TEXCOORD); -/* - { - shaderProgram_t *sp = &tr.textureColorShader; - - GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD); - GLSL_BindProgram(sp); - - GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - - color[0] = - color[1] = - color[2] = tr.identityLight; - color[3] = 1.0f; - GLSL_SetUniformVec4(sp, UNIFORM_COLOR, color); - } -*/ - { - shaderProgram_t *sp = &tr.lightallShader[0]; - vec4_t vector; - - GLSL_BindProgram(sp); - - GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - - color[0] = - color[1] = - color[2] = - color[3] = 1.0f; - GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, color); - - color[0] = - color[1] = - color[2] = - color[3] = 0.0f; - GLSL_SetUniformVec4(sp, UNIFORM_VERTCOLOR, color); - - VectorSet4(vector, 1.0, 0.0, 0.0, 1.0); - GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXMATRIX, vector); - - VectorSet4(vector, 0.0, 0.0, 0.0, 0.0); - GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXOFFTURB, vector); - - GLSL_SetUniformInt(sp, UNIFORM_ALPHATEST, 0); - } - - R_DrawElements(tess.numIndexes - tess.firstIndex, tess.firstIndex); - - //qglDrawElements(GL_TRIANGLES, tess.numIndexes - tess.firstIndex, GL_INDEX_TYPE, BUFFER_OFFSET(tess.firstIndex * sizeof(glIndex_t))); - - //R_BindNullVBO(); - //R_BindNullIBO(); - - tess.numIndexes = tess.firstIndex; - tess.numVertexes = firstVertex; - tess.firstIndex = 0; -} - -static void DrawSkyBox( const shader_t *shader ) -{ - int i; - - sky_min = 0; - sky_max = 1; - - Com_Memset( s_skyTexCoords, 0, sizeof( s_skyTexCoords ) ); - - for (i=0 ; i<6 ; i++) - { - int sky_mins_subd[2], sky_maxs_subd[2]; - int s, t; - - sky_mins[0][i] = floor( sky_mins[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; - sky_mins[1][i] = floor( sky_mins[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; - sky_maxs[0][i] = ceil( sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; - sky_maxs[1][i] = ceil( sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; - - if ( ( sky_mins[0][i] >= sky_maxs[0][i] ) || - ( sky_mins[1][i] >= sky_maxs[1][i] ) ) - { - continue; - } - - sky_mins_subd[0] = sky_mins[0][i] * HALF_SKY_SUBDIVISIONS; - sky_mins_subd[1] = sky_mins[1][i] * HALF_SKY_SUBDIVISIONS; - sky_maxs_subd[0] = sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS; - sky_maxs_subd[1] = sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS; - - if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) - sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS; - else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS ) - sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS; - if ( sky_mins_subd[1] < -HALF_SKY_SUBDIVISIONS ) - sky_mins_subd[1] = -HALF_SKY_SUBDIVISIONS; - else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS ) - sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS; - - if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS ) - sky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS; - else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS ) - sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS; - if ( sky_maxs_subd[1] < -HALF_SKY_SUBDIVISIONS ) - sky_maxs_subd[1] = -HALF_SKY_SUBDIVISIONS; - else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS ) - sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS; - - // - // iterate through the subdivisions - // - for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ ) - { - for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ ) - { - MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, - ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, - i, - s_skyTexCoords[t][s], - s_skyPoints[t][s] ); - } - } - - DrawSkySide( shader->sky.outerbox[sky_texorder[i]], - sky_mins_subd, - sky_maxs_subd ); - } - -} - -static void FillCloudySkySide( const int mins[2], const int maxs[2], qboolean addIndexes ) -{ - int s, t; - int vertexStart = tess.numVertexes; - int tHeight, sWidth; - - tHeight = maxs[1] - mins[1] + 1; - sWidth = maxs[0] - mins[0] + 1; - - for ( t = mins[1]+HALF_SKY_SUBDIVISIONS; t <= maxs[1]+HALF_SKY_SUBDIVISIONS; t++ ) - { - for ( s = mins[0]+HALF_SKY_SUBDIVISIONS; s <= maxs[0]+HALF_SKY_SUBDIVISIONS; s++ ) - { - VectorAdd( s_skyPoints[t][s], backEnd.viewParms.or.origin, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0] = s_skyTexCoords[t][s][0]; - tess.texCoords[tess.numVertexes][1] = s_skyTexCoords[t][s][1]; - - tess.numVertexes++; - - if ( tess.numVertexes >= SHADER_MAX_VERTEXES ) - { - ri.Error( ERR_DROP, "SHADER_MAX_VERTEXES hit in FillCloudySkySide()" ); - } - } - } - - // only add indexes for one pass, otherwise it would draw multiple times for each pass - if ( addIndexes ) { - for ( t = 0; t < tHeight-1; t++ ) - { - for ( s = 0; s < sWidth-1; s++ ) - { - tess.indexes[tess.numIndexes] = vertexStart + s + t * ( sWidth ); - tess.numIndexes++; - tess.indexes[tess.numIndexes] = vertexStart + s + ( t + 1 ) * ( sWidth ); - tess.numIndexes++; - tess.indexes[tess.numIndexes] = vertexStart + s + 1 + t * ( sWidth ); - tess.numIndexes++; - - tess.indexes[tess.numIndexes] = vertexStart + s + ( t + 1 ) * ( sWidth ); - tess.numIndexes++; - tess.indexes[tess.numIndexes] = vertexStart + s + 1 + ( t + 1 ) * ( sWidth ); - tess.numIndexes++; - tess.indexes[tess.numIndexes] = vertexStart + s + 1 + t * ( sWidth ); - tess.numIndexes++; - } - } - } -} - -static void FillCloudBox( const shader_t *shader, int stage ) -{ - int i; - - for ( i =0; i < 6; i++ ) - { - int sky_mins_subd[2], sky_maxs_subd[2]; - int s, t; - float MIN_T; - - if ( 1 ) // FIXME? shader->sky.fullClouds ) - { - MIN_T = -HALF_SKY_SUBDIVISIONS; - - // still don't want to draw the bottom, even if fullClouds - if ( i == 5 ) - continue; - } - else - { - switch( i ) - { - case 0: - case 1: - case 2: - case 3: - MIN_T = -1; - break; - case 5: - // don't draw clouds beneath you - continue; - case 4: // top - default: - MIN_T = -HALF_SKY_SUBDIVISIONS; - break; - } - } - - sky_mins[0][i] = floor( sky_mins[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; - sky_mins[1][i] = floor( sky_mins[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; - sky_maxs[0][i] = ceil( sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; - sky_maxs[1][i] = ceil( sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; - - if ( ( sky_mins[0][i] >= sky_maxs[0][i] ) || - ( sky_mins[1][i] >= sky_maxs[1][i] ) ) - { - continue; - } - - sky_mins_subd[0] = myftol(sky_mins[0][i] * HALF_SKY_SUBDIVISIONS); - sky_mins_subd[1] = myftol(sky_mins[1][i] * HALF_SKY_SUBDIVISIONS); - sky_maxs_subd[0] = myftol(sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS); - sky_maxs_subd[1] = myftol(sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS); - - if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) - sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS; - else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS ) - sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS; - if ( sky_mins_subd[1] < MIN_T ) - sky_mins_subd[1] = MIN_T; - else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS ) - sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS; - - if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS ) - sky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS; - else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS ) - sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS; - if ( sky_maxs_subd[1] < MIN_T ) - sky_maxs_subd[1] = MIN_T; - else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS ) - sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS; - - // - // iterate through the subdivisions - // - for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ ) - { - for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ ) - { - MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, - ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, - i, - NULL, - s_skyPoints[t][s] ); - - s_skyTexCoords[t][s][0] = s_cloudTexCoords[i][t][s][0]; - s_skyTexCoords[t][s][1] = s_cloudTexCoords[i][t][s][1]; - } - } - - // only add indexes for first stage - FillCloudySkySide( sky_mins_subd, sky_maxs_subd, ( stage == 0 ) ); - } -} - -/* -** R_BuildCloudData -*/ -static void R_BuildCloudData( const shaderCommands_t *input ) -{ - int i; - const shader_t *shader; - - shader = input->shader; - - assert( shader->isSky ); - - sky_min = 1.0 / 256.0f; // FIXME: not correct? - sky_max = 255.0 / 256.0f; - - // set up for drawing - tess.numIndexes = 0; - tess.numVertexes = 0; - tess.firstIndex = 0; - - if ( shader->sky.cloudHeight ) - { - for ( i = 0; i < MAX_SHADER_STAGES; i++ ) - { - if ( !tess.xstages[i] ) { - break; - } - FillCloudBox( shader, i ); - } - } -} - -/* -** R_InitSkyTexCoords -** Called when a sky shader is parsed -*/ -#define SQR( a ) ((a)*(a)) -void R_InitSkyTexCoords( float heightCloud ) -{ - int i, s, t; - float radiusWorld = 4096; - float p; - float sRad, tRad; - vec3_t skyVec; - vec3_t v; - - // init zfar so MakeSkyVec works even though - // a world hasn't been bounded - backEnd.viewParms.zFar = 1024; - - for ( i = 0; i < 6; i++ ) - { - for ( t = 0; t <= SKY_SUBDIVISIONS; t++ ) - { - for ( s = 0; s <= SKY_SUBDIVISIONS; s++ ) - { - // compute vector from view origin to sky side integral point - MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, - ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, - i, - NULL, - skyVec ); - - // compute parametric value 'p' that intersects with cloud layer - p = ( 1.0f / ( 2 * DotProduct( skyVec, skyVec ) ) ) * - ( -2 * skyVec[2] * radiusWorld + - 2 * sqrt( SQR( skyVec[2] ) * SQR( radiusWorld ) + - 2 * SQR( skyVec[0] ) * radiusWorld * heightCloud + - SQR( skyVec[0] ) * SQR( heightCloud ) + - 2 * SQR( skyVec[1] ) * radiusWorld * heightCloud + - SQR( skyVec[1] ) * SQR( heightCloud ) + - 2 * SQR( skyVec[2] ) * radiusWorld * heightCloud + - SQR( skyVec[2] ) * SQR( heightCloud ) ) ); - - s_cloudTexP[i][t][s] = p; - - // compute intersection point based on p - VectorScale( skyVec, p, v ); - v[2] += radiusWorld; - - // compute vector from world origin to intersection point 'v' - VectorNormalize( v ); - - sRad = Q_acos( v[0] ); - tRad = Q_acos( v[1] ); - - s_cloudTexCoords[i][t][s][0] = sRad; - s_cloudTexCoords[i][t][s][1] = tRad; - } - } - } -} - -//====================================================================================== - -/* -** RB_DrawSun -*/ -void RB_DrawSun( float scale, shader_t *shader ) { - float size; - float dist; - vec3_t origin, vec1, vec2; - - if ( !backEnd.skyRenderedThisView ) { - return; - } - - //qglLoadMatrixf( backEnd.viewParms.world.modelMatrix ); - //qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]); - { - // FIXME: this could be a lot cleaner - mat4_t translation, modelview; - - Mat4Translation( backEnd.viewParms.or.origin, translation ); - Mat4Multiply( backEnd.viewParms.world.modelMatrix, translation, modelview ); - GL_SetModelviewMatrix( modelview ); - } - - dist = backEnd.viewParms.zFar / 1.75; // div sqrt(3) - size = dist * scale; - - VectorScale( tr.sunDirection, dist, origin ); - PerpendicularVector( vec1, tr.sunDirection ); - CrossProduct( tr.sunDirection, vec1, vec2 ); - - VectorScale( vec1, size, vec1 ); - VectorScale( vec2, size, vec2 ); - - // farthest depth range - qglDepthRange( 1.0, 1.0 ); - - RB_BeginSurface( shader, 0, 0 ); - - RB_AddQuadStamp(origin, vec1, vec2, colorWhite); - - RB_EndSurface(); - - // back to normal depth range - qglDepthRange( 0.0, 1.0 ); -} - - - - -/* -================ -RB_StageIteratorSky - -All of the visible sky triangles are in tess - -Other things could be stuck in here, like birds in the sky, etc -================ -*/ -void RB_StageIteratorSky( void ) { - if ( r_fastsky->integer ) { - return; - } - - // go through all the polygons and project them onto - // the sky box to see which blocks on each side need - // to be drawn - RB_ClipSkyPolygons( &tess ); - - // r_showsky will let all the sky blocks be drawn in - // front of everything to allow developers to see how - // much sky is getting sucked in - if ( r_showsky->integer ) { - qglDepthRange( 0.0, 0.0 ); - } else { - qglDepthRange( 1.0, 1.0 ); - } - - // draw the outer skybox - if ( tess.shader->sky.outerbox[0] && tess.shader->sky.outerbox[0] != tr.defaultImage ) { - mat4_t oldmodelview; - - GL_State( 0 ); - GL_Cull( CT_FRONT_SIDED ); - //qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]); - - { - // FIXME: this could be a lot cleaner - mat4_t trans, product; - - Mat4Copy( glState.modelview, oldmodelview ); - Mat4Translation( backEnd.viewParms.or.origin, trans ); - Mat4Multiply( glState.modelview, trans, product ); - GL_SetModelviewMatrix( product ); - - } - - DrawSkyBox( tess.shader ); - - GL_SetModelviewMatrix( oldmodelview ); - } - - // generate the vertexes for all the clouds, which will be drawn - // by the generic shader routine - R_BuildCloudData( &tess ); - - RB_StageIteratorGeneric(); - - // draw the inner skybox - - - // back to normal depth range - qglDepthRange( 0.0, 1.0 ); - - // note that sky was drawn so we will draw a sun later - backEnd.skyRenderedThisView = qtrue; -} - - - - - diff --git a/code/renderer2/tr_surface.c b/code/renderer2/tr_surface.c deleted file mode 100644 index 30c34b5dfe..0000000000 --- a/code/renderer2/tr_surface.c +++ /dev/null @@ -1,1316 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_surf.c -#include "tr_local.h" - -/* - - THIS ENTIRE FILE IS BACK END - -backEnd.currentEntity will be valid. - -Tess_Begin has already been called for the surface's shader. - -The modelview matrix will be set. - -It is safe to actually issue drawing commands here if you don't want to -use the shader system. -*/ - - -//============================================================================ - - -/* -============== -RB_CheckOverflow -============== -*/ -void RB_CheckOverflow( int verts, int indexes ) { - if (tess.numVertexes + verts < SHADER_MAX_VERTEXES - && tess.numIndexes + indexes < SHADER_MAX_INDEXES) { - return; - } - - RB_EndSurface(); - - if ( verts >= SHADER_MAX_VERTEXES ) { - ri.Error(ERR_DROP, "RB_CheckOverflow: verts > MAX (%d > %d)", verts, SHADER_MAX_VERTEXES ); - } - if ( indexes >= SHADER_MAX_INDEXES ) { - ri.Error(ERR_DROP, "RB_CheckOverflow: indices > MAX (%d > %d)", indexes, SHADER_MAX_INDEXES ); - } - - RB_BeginSurface(tess.shader, tess.fogNum, tess.cubemapIndex ); -} - -static void RB_CheckVao(vao_t *vao) -{ - if (vao != glState.currentVao) - { - RB_EndSurface(); - RB_BeginSurface(tess.shader, tess.fogNum, tess.cubemapIndex); - - R_BindVao(vao); - } - - if (vao != tess.vao) - tess.useInternalVao = qfalse; -} - - -/* -============== -RB_AddQuadStampExt -============== -*/ -void RB_AddQuadStampExt( const vec3_t origin, const vec3_t left, const vec3_t up, const float color[4], float s1, float t1, float s2, float t2 ) { - vec3_t normal; - int16_t iNormal[4]; - uint16_t iColor[4]; - int ndx; - - RB_CheckVao(tess.vao); - - RB_CHECKOVERFLOW( 4, 6 ); - - ndx = tess.numVertexes; - - // triangle indexes for a simple quad - tess.indexes[ tess.numIndexes ] = ndx; - tess.indexes[ tess.numIndexes + 1 ] = ndx + 1; - tess.indexes[ tess.numIndexes + 2 ] = ndx + 3; - - tess.indexes[ tess.numIndexes + 3 ] = ndx + 3; - tess.indexes[ tess.numIndexes + 4 ] = ndx + 1; - tess.indexes[ tess.numIndexes + 5 ] = ndx + 2; - - tess.xyz[ndx][0] = origin[0] + left[0] + up[0]; - tess.xyz[ndx][1] = origin[1] + left[1] + up[1]; - tess.xyz[ndx][2] = origin[2] + left[2] + up[2]; - - tess.xyz[ndx+1][0] = origin[0] - left[0] + up[0]; - tess.xyz[ndx+1][1] = origin[1] - left[1] + up[1]; - tess.xyz[ndx+1][2] = origin[2] - left[2] + up[2]; - - tess.xyz[ndx+2][0] = origin[0] - left[0] - up[0]; - tess.xyz[ndx+2][1] = origin[1] - left[1] - up[1]; - tess.xyz[ndx+2][2] = origin[2] - left[2] - up[2]; - - tess.xyz[ndx+3][0] = origin[0] + left[0] - up[0]; - tess.xyz[ndx+3][1] = origin[1] + left[1] - up[1]; - tess.xyz[ndx+3][2] = origin[2] + left[2] - up[2]; - - - // constant normal all the way around - VectorSubtract( vec3_origin, backEnd.viewParms.or.axis[0], normal ); - - R_VaoPackNormal(iNormal, normal); - - VectorCopy4(iNormal, tess.normal[ndx]); - VectorCopy4(iNormal, tess.normal[ndx + 1]); - VectorCopy4(iNormal, tess.normal[ndx + 2]); - VectorCopy4(iNormal, tess.normal[ndx + 3]); - - // standard square texture coordinates - VectorSet2(tess.texCoords[ndx], s1, t1); - VectorSet2(tess.lightCoords[ndx], s1, t1); - - VectorSet2(tess.texCoords[ndx+1], s2, t1); - VectorSet2(tess.lightCoords[ndx+1], s2, t1); - - VectorSet2(tess.texCoords[ndx+2], s2, t2); - VectorSet2(tess.lightCoords[ndx+2], s2, t2); - - VectorSet2(tess.texCoords[ndx+3], s1, t2); - VectorSet2(tess.lightCoords[ndx+3], s1, t2); - - // constant color all the way around - // should this be identity and let the shader specify from entity? - - R_VaoPackColor(iColor, color); - - VectorCopy4(iColor, tess.color[ndx]); - VectorCopy4(iColor, tess.color[ndx + 1]); - VectorCopy4(iColor, tess.color[ndx + 2]); - VectorCopy4(iColor, tess.color[ndx + 3]); - - tess.numVertexes += 4; - tess.numIndexes += 6; -} - -/* -============== -RB_AddQuadStamp -============== -*/ -void RB_AddQuadStamp( const vec3_t origin, const vec3_t left, const vec3_t up, const float color[4] ) { - RB_AddQuadStampExt( origin, left, up, color, 0, 0, 1, 1 ); -} - - -/* -============== -RB_InstantQuad - -based on Tess_InstantQuad from xreal -============== -*/ -void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4]) -{ -// GLimp_LogComment("--- RB_InstantQuad2 ---\n"); - - tess.numVertexes = 0; - tess.numIndexes = 0; - tess.firstIndex = 0; - - VectorCopy4(quadVerts[0], tess.xyz[tess.numVertexes]); - VectorCopy2(texCoords[0], tess.texCoords[tess.numVertexes]); - tess.numVertexes++; - - VectorCopy4(quadVerts[1], tess.xyz[tess.numVertexes]); - VectorCopy2(texCoords[1], tess.texCoords[tess.numVertexes]); - tess.numVertexes++; - - VectorCopy4(quadVerts[2], tess.xyz[tess.numVertexes]); - VectorCopy2(texCoords[2], tess.texCoords[tess.numVertexes]); - tess.numVertexes++; - - VectorCopy4(quadVerts[3], tess.xyz[tess.numVertexes]); - VectorCopy2(texCoords[3], tess.texCoords[tess.numVertexes]); - tess.numVertexes++; - - tess.indexes[tess.numIndexes++] = 0; - tess.indexes[tess.numIndexes++] = 1; - tess.indexes[tess.numIndexes++] = 2; - tess.indexes[tess.numIndexes++] = 0; - tess.indexes[tess.numIndexes++] = 2; - tess.indexes[tess.numIndexes++] = 3; - - RB_UpdateTessVao(ATTR_POSITION | ATTR_TEXCOORD); - - R_DrawElements(tess.numIndexes, tess.firstIndex); - - tess.numIndexes = 0; - tess.numVertexes = 0; - tess.firstIndex = 0; -} - - -void RB_InstantQuad(vec4_t quadVerts[4]) -{ - vec2_t texCoords[4]; - - VectorSet2(texCoords[0], 0.0f, 0.0f); - VectorSet2(texCoords[1], 1.0f, 0.0f); - VectorSet2(texCoords[2], 1.0f, 1.0f); - VectorSet2(texCoords[3], 0.0f, 1.0f); - - GLSL_BindProgram(&tr.textureColorShader); - - GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite); - - RB_InstantQuad2(quadVerts, texCoords); -} - - -/* -============== -RB_SurfaceSprite -============== -*/ -static void RB_SurfaceSprite( void ) { - vec3_t left, up; - float radius; - float colors[4]; - const trRefEntity_t *ent = backEnd.currentEntity; - - // calculate the xyz locations for the four corners - radius = ent->e.radius; - if ( ent->e.rotation == 0 ) { - VectorScale( backEnd.viewParms.or.axis[1], radius, left ); - VectorScale( backEnd.viewParms.or.axis[2], radius, up ); - } else { - float s, c; - float ang; - - ang = M_PI * ent->e.rotation / 180; - s = sin( ang ); - c = cos( ang ); - - VectorScale( backEnd.viewParms.or.axis[1], c * radius, left ); - VectorMA( left, -s * radius, backEnd.viewParms.or.axis[2], left ); - - VectorScale( backEnd.viewParms.or.axis[2], c * radius, up ); - VectorMA( up, s * radius, backEnd.viewParms.or.axis[1], up ); - } - if ( backEnd.viewParms.isMirror ) { - VectorSubtract( vec3_origin, left, left ); - } - - VectorScale4(ent->e.shader.rgba, 1.0f / 255.0f, colors); - - RB_AddQuadStamp( ent->e.origin, left, up, colors ); -} - - -/* -============= -RB_SurfacePolychain -============= -*/ -static void RB_SurfacePolychain( const srfPoly_t *p ) { - int i; - int numv; - - RB_CheckVao(tess.vao); - - RB_CHECKOVERFLOW( p->numVerts, 3*(p->numVerts - 2) ); - - // fan triangles into the tess array - numv = tess.numVertexes; - for ( i = 0; i < p->numVerts; i++ ) { - VectorCopy( p->verts[i].xyz, tess.xyz[numv] ); - tess.texCoords[numv][0] = p->verts[i].st[0]; - tess.texCoords[numv][1] = p->verts[i].st[1]; - tess.color[numv][0] = (int)p->verts[i].modulate.rgba[0] * 257; - tess.color[numv][1] = (int)p->verts[i].modulate.rgba[1] * 257; - tess.color[numv][2] = (int)p->verts[i].modulate.rgba[2] * 257; - tess.color[numv][3] = (int)p->verts[i].modulate.rgba[3] * 257; - - numv++; - } - - // generate fan indexes into the tess array - for ( i = 0; i < p->numVerts-2; i++ ) { - tess.indexes[tess.numIndexes + 0] = tess.numVertexes; - tess.indexes[tess.numIndexes + 1] = tess.numVertexes + i + 1; - tess.indexes[tess.numIndexes + 2] = tess.numVertexes + i + 2; - tess.numIndexes += 3; - } - - tess.numVertexes = numv; -} - -static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIndexes, glIndex_t *indexes, int dlightBits, int pshadowBits) -{ - int i; - glIndex_t *inIndex; - srfVert_t *dv; - float *xyz, *texCoords, *lightCoords; - int16_t *lightdir; - int16_t *normal; - int16_t *tangent; - glIndex_t *outIndex; - uint16_t *color; - - RB_CheckVao(tess.vao); - - RB_CHECKOVERFLOW( numVerts, numIndexes ); - - inIndex = indexes; - outIndex = &tess.indexes[ tess.numIndexes ]; - for ( i = 0 ; i < numIndexes ; i++ ) { - *outIndex++ = tess.numVertexes + *inIndex++; - } - tess.numIndexes += numIndexes; - - if ( tess.shader->vertexAttribs & ATTR_POSITION ) - { - dv = verts; - xyz = tess.xyz[ tess.numVertexes ]; - for ( i = 0 ; i < numVerts ; i++, dv++, xyz+=4 ) - VectorCopy(dv->xyz, xyz); - } - - if ( tess.shader->vertexAttribs & ATTR_NORMAL ) - { - dv = verts; - normal = tess.normal[ tess.numVertexes ]; - for ( i = 0 ; i < numVerts ; i++, dv++, normal+=4 ) - VectorCopy4(dv->normal, normal); - } - - if ( tess.shader->vertexAttribs & ATTR_TANGENT ) - { - dv = verts; - tangent = tess.tangent[ tess.numVertexes ]; - for ( i = 0 ; i < numVerts ; i++, dv++, tangent+=4 ) - VectorCopy4(dv->tangent, tangent); - } - - if ( tess.shader->vertexAttribs & ATTR_TEXCOORD ) - { - dv = verts; - texCoords = tess.texCoords[tess.numVertexes]; - for ( i = 0 ; i < numVerts ; i++, dv++, texCoords+=2 ) - VectorCopy2(dv->st, texCoords); - } - - if ( tess.shader->vertexAttribs & ATTR_LIGHTCOORD ) - { - dv = verts; - lightCoords = tess.lightCoords[ tess.numVertexes ]; - for ( i = 0 ; i < numVerts ; i++, dv++, lightCoords+=2 ) - VectorCopy2(dv->lightmap, lightCoords); - } - - if ( tess.shader->vertexAttribs & ATTR_COLOR ) - { - dv = verts; - color = tess.color[ tess.numVertexes ]; - for ( i = 0 ; i < numVerts ; i++, dv++, color+=4 ) - VectorCopy4(dv->color, color); - } - - if ( tess.shader->vertexAttribs & ATTR_LIGHTDIRECTION ) - { - dv = verts; - lightdir = tess.lightdir[ tess.numVertexes ]; - for ( i = 0 ; i < numVerts ; i++, dv++, lightdir+=4 ) - VectorCopy4(dv->lightdir, lightdir); - } - -#if 0 // nothing even uses vertex dlightbits - for ( i = 0 ; i < numVerts ; i++ ) { - tess.vertexDlightBits[ tess.numVertexes + i ] = dlightBits; - } -#endif - - tess.dlightBits |= dlightBits; - tess.pshadowBits |= pshadowBits; - - tess.numVertexes += numVerts; -} - -static qboolean RB_SurfaceVaoCached(int numVerts, srfVert_t *verts, int numIndexes, glIndex_t *indexes, int dlightBits, int pshadowBits) -{ - qboolean recycleVertexBuffer = qfalse; - qboolean recycleIndexBuffer = qfalse; - qboolean endSurface = qfalse; - - if (!(!ShaderRequiresCPUDeforms(tess.shader) && !tess.shader->isSky && !tess.shader->isPortal)) - return qfalse; - - if (!numIndexes || !numVerts) - return qfalse; - - VaoCache_BindVao(); - - tess.dlightBits |= dlightBits; - tess.pshadowBits |= pshadowBits; - - VaoCache_CheckAdd(&endSurface, &recycleVertexBuffer, &recycleIndexBuffer, numVerts, numIndexes); - - if (endSurface) - { - RB_EndSurface(); - RB_BeginSurface(tess.shader, tess.fogNum, tess.cubemapIndex); - } - - if (recycleVertexBuffer) - VaoCache_RecycleVertexBuffer(); - - if (recycleIndexBuffer) - VaoCache_RecycleIndexBuffer(); - - if (!tess.numVertexes) - VaoCache_InitQueue(); - - VaoCache_AddSurface(verts, numVerts, indexes, numIndexes); - - tess.numIndexes += numIndexes; - tess.numVertexes += numVerts; - tess.useInternalVao = qfalse; - tess.useCacheVao = qtrue; - - return qtrue; -} - -/* -============= -RB_SurfaceTriangles -============= -*/ -static void RB_SurfaceTriangles( const srfBspSurface_t *srf ) { - if (RB_SurfaceVaoCached(srf->numVerts, srf->verts, srf->numIndexes, - srf->indexes, srf->dlightBits, srf->pshadowBits)) - { - return; - } - - RB_SurfaceVertsAndIndexes(srf->numVerts, srf->verts, srf->numIndexes, - srf->indexes, srf->dlightBits, srf->pshadowBits); -} - - - -/* -============== -RB_SurfaceBeam -============== -*/ -static void RB_SurfaceBeam( void ) -{ -#define NUM_BEAM_SEGS 6 - const refEntity_t *e; - shaderProgram_t *sp = &tr.textureColorShader; - int i; - vec3_t perpvec; - vec3_t direction, normalized_direction; - vec3_t start_points[NUM_BEAM_SEGS], end_points[NUM_BEAM_SEGS]; - vec3_t oldorigin, origin; - - e = &backEnd.currentEntity->e; - - oldorigin[0] = e->oldorigin[0]; - oldorigin[1] = e->oldorigin[1]; - oldorigin[2] = e->oldorigin[2]; - - origin[0] = e->origin[0]; - origin[1] = e->origin[1]; - origin[2] = e->origin[2]; - - normalized_direction[0] = direction[0] = oldorigin[0] - origin[0]; - normalized_direction[1] = direction[1] = oldorigin[1] - origin[1]; - normalized_direction[2] = direction[2] = oldorigin[2] - origin[2]; - - if ( VectorNormalize( normalized_direction ) == 0 ) - return; - - PerpendicularVector( perpvec, normalized_direction ); - - VectorScale( perpvec, 4, perpvec ); - - for ( i = 0; i < NUM_BEAM_SEGS ; i++ ) - { - RotatePointAroundVector( start_points[i], normalized_direction, perpvec, (360.0/NUM_BEAM_SEGS)*i ); -// VectorAdd( start_points[i], origin, start_points[i] ); - VectorAdd( start_points[i], direction, end_points[i] ); - } - - GL_BindToTMU( tr.whiteImage, TB_COLORMAP ); - - GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); - - // FIXME: Quake3 doesn't use this, so I never tested it - tess.numVertexes = 0; - tess.numIndexes = 0; - tess.firstIndex = 0; - - for ( i = 0; i <= NUM_BEAM_SEGS; i++ ) { - VectorCopy(start_points[ i % NUM_BEAM_SEGS ], tess.xyz[tess.numVertexes++]); - VectorCopy(end_points [ i % NUM_BEAM_SEGS ], tess.xyz[tess.numVertexes++]); - } - - for ( i = 0; i < NUM_BEAM_SEGS; i++ ) { - tess.indexes[tess.numIndexes++] = i * 2; - tess.indexes[tess.numIndexes++] = (i + 1) * 2; - tess.indexes[tess.numIndexes++] = 1 + i * 2; - - tess.indexes[tess.numIndexes++] = 1 + i * 2; - tess.indexes[tess.numIndexes++] = (i + 1) * 2; - tess.indexes[tess.numIndexes++] = 1 + (i + 1) * 2; - } - - // FIXME: A lot of this can probably be removed for speed, and refactored into a more convenient function - RB_UpdateTessVao(ATTR_POSITION); - - GLSL_BindProgram(sp); - - GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - - GLSL_SetUniformVec4(sp, UNIFORM_COLOR, colorRed); - - GLSL_SetUniformInt(sp, UNIFORM_ALPHATEST, 0); - - R_DrawElements(tess.numIndexes, tess.firstIndex); - - tess.numIndexes = 0; - tess.numVertexes = 0; - tess.firstIndex = 0; -} - -//================================================================================ - -static void DoRailCore( const vec3_t start, const vec3_t end, const vec3_t up, float len, float spanWidth ) -{ - float spanWidth2; - int vbase; - float t = len / 256.0f; - - RB_CheckVao(tess.vao); - - RB_CHECKOVERFLOW( 4, 6 ); - - vbase = tess.numVertexes; - - spanWidth2 = -spanWidth; - - // FIXME: use quad stamp? - VectorMA( start, spanWidth, up, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0] = 0; - tess.texCoords[tess.numVertexes][1] = 0; - tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shader.rgba[0] * 0.25f * 257.0f; - tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shader.rgba[1] * 0.25f * 257.0f; - tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shader.rgba[2] * 0.25f * 257.0f; - tess.numVertexes++; - - VectorMA( start, spanWidth2, up, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0] = 0; - tess.texCoords[tess.numVertexes][1] = 1; - tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shader.rgba[0] * 257; - tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shader.rgba[1] * 257; - tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shader.rgba[2] * 257; - tess.numVertexes++; - - VectorMA( end, spanWidth, up, tess.xyz[tess.numVertexes] ); - - tess.texCoords[tess.numVertexes][0] = t; - tess.texCoords[tess.numVertexes][1] = 0; - tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shader.rgba[0] * 257; - tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shader.rgba[1] * 257; - tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shader.rgba[2] * 257; - tess.numVertexes++; - - VectorMA( end, spanWidth2, up, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0] = t; - tess.texCoords[tess.numVertexes][1] = 1; - tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shader.rgba[0] * 257; - tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shader.rgba[1] * 257; - tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shader.rgba[2] * 257; - tess.numVertexes++; - - tess.indexes[tess.numIndexes++] = vbase; - tess.indexes[tess.numIndexes++] = vbase + 1; - tess.indexes[tess.numIndexes++] = vbase + 2; - - tess.indexes[tess.numIndexes++] = vbase + 2; - tess.indexes[tess.numIndexes++] = vbase + 1; - tess.indexes[tess.numIndexes++] = vbase + 3; -} - -static void DoRailDiscs( int numSegs, const vec3_t start, const vec3_t dir, const vec3_t right, const vec3_t up ) -{ - int i; - vec3_t pos[4]; - vec3_t v; - int spanWidth = r_railWidth->integer; - float c, s; - float scale; - - if ( numSegs > 1 ) - numSegs--; - if ( !numSegs ) - return; - - scale = 0.25; - - for ( i = 0; i < 4; i++ ) - { - c = cos( DEG2RAD( 45 + i * 90 ) ); - s = sin( DEG2RAD( 45 + i * 90 ) ); - v[0] = ( right[0] * c + up[0] * s ) * scale * spanWidth; - v[1] = ( right[1] * c + up[1] * s ) * scale * spanWidth; - v[2] = ( right[2] * c + up[2] * s ) * scale * spanWidth; - VectorAdd( start, v, pos[i] ); - - if ( numSegs > 1 ) - { - // offset by 1 segment if we're doing a long distance shot - VectorAdd( pos[i], dir, pos[i] ); - } - } - - RB_CheckVao(tess.vao); - - for ( i = 0; i < numSegs; i++ ) - { - int j; - - RB_CHECKOVERFLOW( 4, 6 ); - - for ( j = 0; j < 4; j++ ) - { - VectorCopy( pos[j], tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0] = (j < 2); - tess.texCoords[tess.numVertexes][1] = (j && j != 3); - tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shader.rgba[0] * 257; - tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shader.rgba[1] * 257; - tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shader.rgba[2] * 257; - tess.numVertexes++; - - VectorAdd( pos[j], dir, pos[j] ); - } - - tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 0; - tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 1; - tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 3; - tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 3; - tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 1; - tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 2; - } -} - -/* -** RB_SurfaceRailRinges -*/ -static void RB_SurfaceRailRings( void ) { - const refEntity_t *e; - int numSegs; - int len; - vec3_t vec; - vec3_t right, up; - vec3_t start, end; - - e = &backEnd.currentEntity->e; - - VectorCopy( e->oldorigin, start ); - VectorCopy( e->origin, end ); - - // compute variables - VectorSubtract( end, start, vec ); - len = VectorNormalize( vec ); - MakeNormalVectors( vec, right, up ); - numSegs = ( len ) / r_railSegmentLength->value; - if ( numSegs <= 0 ) { - numSegs = 1; - } - - VectorScale( vec, r_railSegmentLength->value, vec ); - - DoRailDiscs( numSegs, start, vec, right, up ); -} - -/* -** RB_SurfaceRailCore -*/ -static void RB_SurfaceRailCore( void ) { - const refEntity_t *e; - int len; - vec3_t right; - vec3_t vec; - vec3_t start, end; - vec3_t v1, v2; - - e = &backEnd.currentEntity->e; - - VectorCopy( e->oldorigin, start ); - VectorCopy( e->origin, end ); - - VectorSubtract( end, start, vec ); - len = VectorNormalize( vec ); - - // compute side vector - VectorSubtract( start, backEnd.viewParms.or.origin, v1 ); - VectorNormalize( v1 ); - VectorSubtract( end, backEnd.viewParms.or.origin, v2 ); - VectorNormalize( v2 ); - CrossProduct( v1, v2, right ); - VectorNormalize( right ); - - DoRailCore( start, end, right, len, r_railCoreWidth->integer ); -} - -/* -** RB_SurfaceLightningBolt -*/ -static void RB_SurfaceLightningBolt( void ) { - const refEntity_t *e; - int len; - vec3_t right; - vec3_t vec; - vec3_t start, end; - vec3_t v1, v2; - int i; - - e = &backEnd.currentEntity->e; - - VectorCopy( e->oldorigin, end ); - VectorCopy( e->origin, start ); - - // compute variables - VectorSubtract( end, start, vec ); - len = VectorNormalize( vec ); - - // compute side vector - VectorSubtract( start, backEnd.viewParms.or.origin, v1 ); - VectorNormalize( v1 ); - VectorSubtract( end, backEnd.viewParms.or.origin, v2 ); - VectorNormalize( v2 ); - CrossProduct( v1, v2, right ); - VectorNormalize( right ); - - for ( i = 0 ; i < 4 ; i++ ) { - vec3_t temp; - - DoRailCore( start, end, right, len, 8 ); - RotatePointAroundVector( temp, vec, right, 45 ); - VectorCopy( temp, right ); - } -} - - -static void LerpMeshVertexes(const mdvSurface_t *surf, float backlerp) -{ - float *outXyz; - int16_t *outNormal, *outTangent; - mdvVertex_t *newVerts; - int vertNum; - - newVerts = surf->verts + backEnd.currentEntity->e.frame * surf->numVerts; - - outXyz = tess.xyz[tess.numVertexes]; - outNormal = tess.normal[tess.numVertexes]; - outTangent = tess.tangent[tess.numVertexes]; - - if (backlerp == 0) - { - // - // just copy the vertexes - // - - for (vertNum=0 ; vertNum < surf->numVerts ; vertNum++) - { - VectorCopy(newVerts->xyz, outXyz); - VectorCopy4(newVerts->normal, outNormal); - VectorCopy4(newVerts->tangent, outTangent); - - newVerts++; - outXyz += 4; - outNormal += 4; - outTangent += 4; - } - } - else - { - // - // interpolate and copy the vertex and normal - // - - mdvVertex_t *oldVerts; - - oldVerts = surf->verts + backEnd.currentEntity->e.oldframe * surf->numVerts; - - for (vertNum=0 ; vertNum < surf->numVerts ; vertNum++) - { - VectorLerp(newVerts->xyz, oldVerts->xyz, backlerp, outXyz); - - outNormal[0] = (int16_t)(newVerts->normal[0] * (1.0f - backlerp) + oldVerts->normal[0] * backlerp); - outNormal[1] = (int16_t)(newVerts->normal[1] * (1.0f - backlerp) + oldVerts->normal[1] * backlerp); - outNormal[2] = (int16_t)(newVerts->normal[2] * (1.0f - backlerp) + oldVerts->normal[2] * backlerp); - outNormal[3] = 0; - - outTangent[0] = (int16_t)(newVerts->tangent[0] * (1.0f - backlerp) + oldVerts->tangent[0] * backlerp); - outTangent[1] = (int16_t)(newVerts->tangent[1] * (1.0f - backlerp) + oldVerts->tangent[1] * backlerp); - outTangent[2] = (int16_t)(newVerts->tangent[2] * (1.0f - backlerp) + oldVerts->tangent[2] * backlerp); - outTangent[3] = newVerts->tangent[3]; - - newVerts++; - oldVerts++; - outXyz += 4; - outNormal += 4; - outTangent += 4; - } - } - -} - - -/* -============= -RB_SurfaceMesh -============= -*/ -static void RB_SurfaceMesh(const mdvSurface_t *surface) { - int j; - float backlerp; - mdvSt_t *texCoords; - int Bob, Doug; - int numVerts; - - if ( backEnd.currentEntity->e.oldframe == backEnd.currentEntity->e.frame ) { - backlerp = 0; - } else { - backlerp = backEnd.currentEntity->e.backlerp; - } - - RB_CheckVao(tess.vao); - - RB_CHECKOVERFLOW( surface->numVerts, surface->numIndexes ); - - LerpMeshVertexes (surface, backlerp); - - Bob = tess.numIndexes; - Doug = tess.numVertexes; - for (j = 0 ; j < surface->numIndexes ; j++) { - tess.indexes[Bob + j] = Doug + surface->indexes[j]; - } - tess.numIndexes += surface->numIndexes; - - texCoords = surface->st; - - numVerts = surface->numVerts; - for ( j = 0; j < numVerts; j++ ) { - tess.texCoords[Doug + j][0] = texCoords[j].st[0]; - tess.texCoords[Doug + j][1] = texCoords[j].st[1]; - // FIXME: fill in lightmapST for completeness? - } - - tess.numVertexes += surface->numVerts; - -} - - -/* -============== -RB_SurfaceFace -============== -*/ -static void RB_SurfaceFace( const srfBspSurface_t *srf ) { - if (RB_SurfaceVaoCached(srf->numVerts, srf->verts, srf->numIndexes, - srf->indexes, srf->dlightBits, srf->pshadowBits)) - { - return; - } - - RB_SurfaceVertsAndIndexes(srf->numVerts, srf->verts, srf->numIndexes, - srf->indexes, srf->dlightBits, srf->pshadowBits); -} - - -static float LodErrorForVolume( vec3_t local, float radius ) { - vec3_t world; - float d; - - // never let it go negative - if ( r_lodCurveError->value < 0 ) { - return 0; - } - - world[0] = local[0] * backEnd.or.axis[0][0] + local[1] * backEnd.or.axis[1][0] + - local[2] * backEnd.or.axis[2][0] + backEnd.or.origin[0]; - world[1] = local[0] * backEnd.or.axis[0][1] + local[1] * backEnd.or.axis[1][1] + - local[2] * backEnd.or.axis[2][1] + backEnd.or.origin[1]; - world[2] = local[0] * backEnd.or.axis[0][2] + local[1] * backEnd.or.axis[1][2] + - local[2] * backEnd.or.axis[2][2] + backEnd.or.origin[2]; - - VectorSubtract( world, backEnd.viewParms.or.origin, world ); - d = DotProduct( world, backEnd.viewParms.or.axis[0] ); - - if ( d < 0 ) { - d = -d; - } - d -= radius; - if ( d < 1 ) { - d = 1; - } - - return r_lodCurveError->value / d; -} - -/* -============= -RB_SurfaceGrid - -Just copy the grid of points and triangulate -============= -*/ -static void RB_SurfaceGrid( srfBspSurface_t *srf ) { - int i, j; - float *xyz; - float *texCoords, *lightCoords; - int16_t *normal; - int16_t *tangent; - uint16_t *color; - int16_t *lightdir; - const srfVert_t *dv; - int rows, irows, vrows; - int used; - int widthTable[MAX_GRID_SIZE]; - int heightTable[MAX_GRID_SIZE]; - float lodError; - int lodWidth, lodHeight; - int numVertexes; - int dlightBits; - int pshadowBits; - //int *vDlightBits; - - if (RB_SurfaceVaoCached(srf->numVerts, srf->verts, srf->numIndexes, - srf->indexes, srf->dlightBits, srf->pshadowBits)) - { - return; - } - - RB_CheckVao(tess.vao); - - dlightBits = srf->dlightBits; - tess.dlightBits |= dlightBits; - - pshadowBits = srf->pshadowBits; - tess.pshadowBits |= pshadowBits; - - // determine the allowable discrepance - lodError = LodErrorForVolume( srf->lodOrigin, srf->lodRadius ); - - // determine which rows and columns of the subdivision - // we are actually going to use - widthTable[0] = 0; - lodWidth = 1; - for ( i = 1 ; i < srf->width-1 ; i++ ) { - if ( srf->widthLodError[i] <= lodError ) { - widthTable[lodWidth] = i; - lodWidth++; - } - } - widthTable[lodWidth] = srf->width-1; - lodWidth++; - - heightTable[0] = 0; - lodHeight = 1; - for ( i = 1 ; i < srf->height-1 ; i++ ) { - if ( srf->heightLodError[i] <= lodError ) { - heightTable[lodHeight] = i; - lodHeight++; - } - } - heightTable[lodHeight] = srf->height-1; - lodHeight++; - - - // very large grids may have more points or indexes than can be fit - // in the tess structure, so we may have to issue it in multiple passes - - used = 0; - while ( used < lodHeight - 1 ) { - // see how many rows of both verts and indexes we can add without overflowing - do { - vrows = ( SHADER_MAX_VERTEXES - tess.numVertexes ) / lodWidth; - irows = ( SHADER_MAX_INDEXES - tess.numIndexes ) / ( lodWidth * 6 ); - - // if we don't have enough space for at least one strip, flush the buffer - if ( vrows < 2 || irows < 1 ) { - RB_EndSurface(); - RB_BeginSurface(tess.shader, tess.fogNum, tess.cubemapIndex ); - } else { - break; - } - } while ( 1 ); - - rows = irows; - if ( vrows < irows + 1 ) { - rows = vrows - 1; - } - if ( used + rows > lodHeight ) { - rows = lodHeight - used; - } - - numVertexes = tess.numVertexes; - - xyz = tess.xyz[numVertexes]; - normal = tess.normal[numVertexes]; - tangent = tess.tangent[numVertexes]; - texCoords = tess.texCoords[numVertexes]; - lightCoords = tess.lightCoords[numVertexes]; - color = tess.color[numVertexes]; - lightdir = tess.lightdir[numVertexes]; - //vDlightBits = &tess.vertexDlightBits[numVertexes]; - - for ( i = 0 ; i < rows ; i++ ) { - for ( j = 0 ; j < lodWidth ; j++ ) { - dv = srf->verts + heightTable[ used + i ] * srf->width - + widthTable[ j ]; - - if ( tess.shader->vertexAttribs & ATTR_POSITION ) - { - VectorCopy(dv->xyz, xyz); - xyz += 4; - } - - if ( tess.shader->vertexAttribs & ATTR_NORMAL ) - { - VectorCopy4(dv->normal, normal); - normal += 4; - } - - if ( tess.shader->vertexAttribs & ATTR_TANGENT ) - { - VectorCopy4(dv->tangent, tangent); - tangent += 4; - } - - if ( tess.shader->vertexAttribs & ATTR_TEXCOORD ) - { - VectorCopy2(dv->st, texCoords); - texCoords += 2; - } - - if ( tess.shader->vertexAttribs & ATTR_LIGHTCOORD ) - { - VectorCopy2(dv->lightmap, lightCoords); - lightCoords += 2; - } - - if ( tess.shader->vertexAttribs & ATTR_COLOR ) - { - VectorCopy4(dv->color, color); - color += 4; - } - - if ( tess.shader->vertexAttribs & ATTR_LIGHTDIRECTION ) - { - VectorCopy4(dv->lightdir, lightdir); - lightdir += 4; - } - - //*vDlightBits++ = dlightBits; - } - } - - - // add the indexes - { - int numIndexes; - int w, h; - - h = rows - 1; - w = lodWidth - 1; - numIndexes = tess.numIndexes; - for (i = 0 ; i < h ; i++) { - for (j = 0 ; j < w ; j++) { - int v1, v2, v3, v4; - - // vertex order to be reckognized as tristrips - v1 = numVertexes + i*lodWidth + j + 1; - v2 = v1 - 1; - v3 = v2 + lodWidth; - v4 = v3 + 1; - - tess.indexes[numIndexes] = v2; - tess.indexes[numIndexes+1] = v3; - tess.indexes[numIndexes+2] = v1; - - tess.indexes[numIndexes+3] = v1; - tess.indexes[numIndexes+4] = v3; - tess.indexes[numIndexes+5] = v4; - numIndexes += 6; - } - } - - tess.numIndexes = numIndexes; - } - - tess.numVertexes += rows * lodWidth; - - used += rows - 1; - } -} - - -/* -=========================================================================== - -NULL MODEL - -=========================================================================== -*/ - -/* -=================== -RB_SurfaceAxis - -Draws x/y/z lines from the origin for orientation debugging -=================== -*/ -static void RB_SurfaceAxis( void ) { - // FIXME: implement this -#if 0 - GL_BindToTMU( tr.whiteImage, TB_COLORMAP ); - GL_State( GLS_DEFAULT ); - qglLineWidth( 3 ); - qglBegin( GL_LINES ); - qglColor3f( 1,0,0 ); - qglVertex3f( 0,0,0 ); - qglVertex3f( 16,0,0 ); - qglColor3f( 0,1,0 ); - qglVertex3f( 0,0,0 ); - qglVertex3f( 0,16,0 ); - qglColor3f( 0,0,1 ); - qglVertex3f( 0,0,0 ); - qglVertex3f( 0,0,16 ); - qglEnd(); - qglLineWidth( 1 ); -#endif -} - -//=========================================================================== - -/* -==================== -RB_SurfaceEntity - -Entities that have a single procedurally generated surface -==================== -*/ -static void RB_SurfaceEntity( const surfaceType_t *surfType ) { - switch( backEnd.currentEntity->e.reType ) { - case RT_SPRITE: - RB_SurfaceSprite(); - break; - case RT_BEAM: - RB_SurfaceBeam(); - break; - case RT_RAIL_CORE: - RB_SurfaceRailCore(); - break; - case RT_RAIL_RINGS: - RB_SurfaceRailRings(); - break; - case RT_LIGHTNING: - RB_SurfaceLightningBolt(); - break; - default: - RB_SurfaceAxis(); - break; - } -} - -static void RB_SurfaceBad( const surfaceType_t *surfType ) { - ri.Printf( PRINT_ALL, "Bad surface tesselated.\n" ); -} - -static void RB_SurfaceFlare(srfFlare_t *surf) -{ - if (r_flares->integer) - RB_AddFlare(surf, tess.fogNum, surf->origin, surf->color, surf->normal); -} - -static void RB_SurfaceVaoMdvMesh(const srfVaoMdvMesh_t * surface) -{ - //mdvModel_t *mdvModel; - //mdvSurface_t *mdvSurface; - const refEntity_t *refEnt; - - //GLimp_LogComment("--- RB_SurfaceVaoMdvMesh ---\n"); - - if (ShaderRequiresCPUDeforms(tess.shader)) - { - RB_SurfaceMesh(surface->mdvSurface); - return; - } - - if(!surface->vao) - return; - - //RB_CheckVao(surface->vao); - RB_EndSurface(); - RB_BeginSurface(tess.shader, tess.fogNum, tess.cubemapIndex); - - R_BindVao(surface->vao); - - tess.useInternalVao = qfalse; - - tess.numIndexes = surface->numIndexes; - tess.numVertexes = surface->numVerts; - - //mdvModel = surface->mdvModel; - //mdvSurface = surface->mdvSurface; - - refEnt = &backEnd.currentEntity->e; - - glState.vertexAttribsInterpolation = (refEnt->oldframe == refEnt->frame) ? 0.0f : refEnt->backlerp; - - if (surface->mdvModel->numFrames > 1) - { - int frameOffset, attribIndex; - vaoAttrib_t *vAtb; - - glState.vertexAnimation = qtrue; - - if (glRefConfig.vertexArrayObject) - { - qglBindBuffer(GL_ARRAY_BUFFER, surface->vao->vertexesVBO); - } - - frameOffset = refEnt->frame * surface->vao->frameSize; - - attribIndex = ATTR_INDEX_POSITION; - vAtb = &surface->vao->attribs[attribIndex]; - qglVertexAttribPointer(attribIndex, vAtb->count, vAtb->type, vAtb->normalized, vAtb->stride, BUFFER_OFFSET(vAtb->offset + frameOffset)); - - attribIndex = ATTR_INDEX_NORMAL; - vAtb = &surface->vao->attribs[attribIndex]; - qglVertexAttribPointer(attribIndex, vAtb->count, vAtb->type, vAtb->normalized, vAtb->stride, BUFFER_OFFSET(vAtb->offset + frameOffset)); - - attribIndex = ATTR_INDEX_TANGENT; - vAtb = &surface->vao->attribs[attribIndex]; - qglVertexAttribPointer(attribIndex, vAtb->count, vAtb->type, vAtb->normalized, vAtb->stride, BUFFER_OFFSET(vAtb->offset + frameOffset)); - - frameOffset = refEnt->oldframe * surface->vao->frameSize; - - attribIndex = ATTR_INDEX_POSITION2; - vAtb = &surface->vao->attribs[attribIndex]; - qglVertexAttribPointer(attribIndex, vAtb->count, vAtb->type, vAtb->normalized, vAtb->stride, BUFFER_OFFSET(vAtb->offset + frameOffset)); - - attribIndex = ATTR_INDEX_NORMAL2; - vAtb = &surface->vao->attribs[attribIndex]; - qglVertexAttribPointer(attribIndex, vAtb->count, vAtb->type, vAtb->normalized, vAtb->stride, BUFFER_OFFSET(vAtb->offset + frameOffset)); - - attribIndex = ATTR_INDEX_TANGENT2; - vAtb = &surface->vao->attribs[attribIndex]; - qglVertexAttribPointer(attribIndex, vAtb->count, vAtb->type, vAtb->normalized, vAtb->stride, BUFFER_OFFSET(vAtb->offset + frameOffset)); - - - if (!glRefConfig.vertexArrayObject) - { - attribIndex = ATTR_INDEX_TEXCOORD; - vAtb = &surface->vao->attribs[attribIndex]; - qglVertexAttribPointer(attribIndex, vAtb->count, vAtb->type, vAtb->normalized, vAtb->stride, BUFFER_OFFSET(vAtb->offset)); - } - } - - RB_EndSurface(); - - // So we don't lerp surfaces that shouldn't be lerped - glState.vertexAnimation = qfalse; -} - -static void RB_SurfaceSkip( void *surf ) { -} - - -void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = { - (void(*)(void*))RB_SurfaceBad, // SF_BAD, - (void(*)(void*))RB_SurfaceSkip, // SF_SKIP, - (void(*)(void*))RB_SurfaceFace, // SF_FACE, - (void(*)(void*))RB_SurfaceGrid, // SF_GRID, - (void(*)(void*))RB_SurfaceTriangles, // SF_TRIANGLES, - (void(*)(void*))RB_SurfacePolychain, // SF_POLY, - (void(*)(void*))RB_SurfaceMesh, // SF_MDV, - (void(*)(void*))RB_MDRSurfaceAnim, // SF_MDR, - (void(*)(void*))RB_IQMSurfaceAnim, // SF_IQM, - (void(*)(void*))RB_SurfaceFlare, // SF_FLARE, - (void(*)(void*))RB_SurfaceEntity, // SF_ENTITY - (void(*)(void*))RB_SurfaceVaoMdvMesh, // SF_VAO_MDVMESH - (void(*)(void*))RB_IQMSurfaceAnimVao, // SF_VAO_IQM -}; diff --git a/code/renderer2/tr_vbo.c b/code/renderer2/tr_vbo.c deleted file mode 100644 index ccf4888a24..0000000000 --- a/code/renderer2/tr_vbo.c +++ /dev/null @@ -1,963 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2007-2009 Robert Beckebans - -This file is part of XreaL source code. - -XreaL source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -XreaL source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with XreaL source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// tr_vbo.c -#include "tr_local.h" - - -void R_VaoPackTangent(int16_t *out, vec4_t v) -{ - out[0] = v[0] * 32767.0f + (v[0] > 0.0f ? 0.5f : -0.5f); - out[1] = v[1] * 32767.0f + (v[1] > 0.0f ? 0.5f : -0.5f); - out[2] = v[2] * 32767.0f + (v[2] > 0.0f ? 0.5f : -0.5f); - out[3] = v[3] * 32767.0f + (v[3] > 0.0f ? 0.5f : -0.5f); -} - -void R_VaoPackNormal(int16_t *out, vec3_t v) -{ - out[0] = v[0] * 32767.0f + (v[0] > 0.0f ? 0.5f : -0.5f); - out[1] = v[1] * 32767.0f + (v[1] > 0.0f ? 0.5f : -0.5f); - out[2] = v[2] * 32767.0f + (v[2] > 0.0f ? 0.5f : -0.5f); - out[3] = 0; -} - -void R_VaoPackColor(uint16_t *out, const vec4_t c) -{ - out[0] = c[0] * 65535.0f + 0.5f; - out[1] = c[1] * 65535.0f + 0.5f; - out[2] = c[2] * 65535.0f + 0.5f; - out[3] = c[3] * 65535.0f + 0.5f; -} - -void R_VaoUnpackTangent(vec4_t v, int16_t *pack) -{ - v[0] = pack[0] / 32767.0f; - v[1] = pack[1] / 32767.0f; - v[2] = pack[2] / 32767.0f; - v[3] = pack[3] / 32767.0f; -} - -void R_VaoUnpackNormal(vec3_t v, int16_t *pack) -{ - v[0] = pack[0] / 32767.0f; - v[1] = pack[1] / 32767.0f; - v[2] = pack[2] / 32767.0f; -} - - -void Vao_SetVertexPointers(vao_t *vao) -{ - int attribIndex; - - // set vertex pointers - for (attribIndex = 0; attribIndex < ATTR_INDEX_COUNT; attribIndex++) - { - uint32_t attribBit = 1 << attribIndex; - vaoAttrib_t *vAtb = &vao->attribs[attribIndex]; - - if (vAtb->enabled) - { - qglVertexAttribPointer(attribIndex, vAtb->count, vAtb->type, vAtb->normalized, vAtb->stride, BUFFER_OFFSET(vAtb->offset)); - if (glRefConfig.vertexArrayObject || !(glState.vertexAttribsEnabled & attribBit)) - qglEnableVertexAttribArray(attribIndex); - - if (!glRefConfig.vertexArrayObject || vao == tess.vao) - glState.vertexAttribsEnabled |= attribBit; - } - else - { - // don't disable vertex attribs when using vertex array objects - // Vao_SetVertexPointers is only called during init when using VAOs, and vertex attribs start disabled anyway - if (!glRefConfig.vertexArrayObject && (glState.vertexAttribsEnabled & attribBit)) - qglDisableVertexAttribArray(attribIndex); - - if (!glRefConfig.vertexArrayObject || vao == tess.vao) - glState.vertexAttribsEnabled &= ~attribBit; - } - } -} - -/* -============ -R_CreateVao -============ -*/ -vao_t *R_CreateVao(const char *name, byte *vertexes, int vertexesSize, byte *indexes, int indexesSize, vaoUsage_t usage) -{ - vao_t *vao; - int glUsage; - - switch (usage) - { - case VAO_USAGE_STATIC: - glUsage = GL_STATIC_DRAW; - break; - - case VAO_USAGE_DYNAMIC: - glUsage = GL_DYNAMIC_DRAW; - break; - - default: - Com_Error(ERR_FATAL, "bad vaoUsage_t given: %i", usage); - return NULL; - } - - if(strlen(name) >= MAX_QPATH) - { - ri.Error(ERR_DROP, "R_CreateVao: \"%s\" is too long", name); - } - - if ( tr.numVaos == MAX_VAOS ) { - ri.Error( ERR_DROP, "R_CreateVao: MAX_VAOS hit"); - } - - R_IssuePendingRenderCommands(); - - vao = tr.vaos[tr.numVaos] = ri.Hunk_Alloc(sizeof(*vao), h_low); - tr.numVaos++; - - memset(vao, 0, sizeof(*vao)); - - Q_strncpyz(vao->name, name, sizeof(vao->name)); - - - if (glRefConfig.vertexArrayObject) - { - qglGenVertexArrays(1, &vao->vao); - qglBindVertexArray(vao->vao); - } - - - vao->vertexesSize = vertexesSize; - - qglGenBuffers(1, &vao->vertexesVBO); - - qglBindBuffer(GL_ARRAY_BUFFER, vao->vertexesVBO); - qglBufferData(GL_ARRAY_BUFFER, vertexesSize, vertexes, glUsage); - - - vao->indexesSize = indexesSize; - - qglGenBuffers(1, &vao->indexesIBO); - - qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vao->indexesIBO); - qglBufferData(GL_ELEMENT_ARRAY_BUFFER, indexesSize, indexes, glUsage); - - - glState.currentVao = vao; - - GL_CheckErrors(); - - return vao; -} - -/* -============ -R_CreateVao2 -============ -*/ -vao_t *R_CreateVao2(const char *name, int numVertexes, srfVert_t *verts, int numIndexes, glIndex_t *indexes) -{ - vao_t *vao; - int i; - - byte *data; - int dataSize; - int dataOfs; - - int glUsage = GL_STATIC_DRAW; - - if(!numVertexes || !numIndexes) - return NULL; - - if(strlen(name) >= MAX_QPATH) - { - ri.Error(ERR_DROP, "R_CreateVao2: \"%s\" is too long", name); - } - - if ( tr.numVaos == MAX_VAOS ) { - ri.Error( ERR_DROP, "R_CreateVao2: MAX_VAOS hit"); - } - - R_IssuePendingRenderCommands(); - - vao = tr.vaos[tr.numVaos] = ri.Hunk_Alloc(sizeof(*vao), h_low); - tr.numVaos++; - - memset(vao, 0, sizeof(*vao)); - - Q_strncpyz(vao->name, name, sizeof(vao->name)); - - // since these vertex attributes are never altered, interleave them - vao->attribs[ATTR_INDEX_POSITION ].enabled = 1; - vao->attribs[ATTR_INDEX_NORMAL ].enabled = 1; - vao->attribs[ATTR_INDEX_TANGENT ].enabled = 1; - vao->attribs[ATTR_INDEX_TEXCOORD ].enabled = 1; - vao->attribs[ATTR_INDEX_LIGHTCOORD ].enabled = 1; - vao->attribs[ATTR_INDEX_COLOR ].enabled = 1; - vao->attribs[ATTR_INDEX_LIGHTDIRECTION].enabled = 1; - - vao->attribs[ATTR_INDEX_POSITION ].count = 3; - vao->attribs[ATTR_INDEX_NORMAL ].count = 4; - vao->attribs[ATTR_INDEX_TANGENT ].count = 4; - vao->attribs[ATTR_INDEX_TEXCOORD ].count = 2; - vao->attribs[ATTR_INDEX_LIGHTCOORD ].count = 2; - vao->attribs[ATTR_INDEX_COLOR ].count = 4; - vao->attribs[ATTR_INDEX_LIGHTDIRECTION].count = 4; - - vao->attribs[ATTR_INDEX_POSITION ].type = GL_FLOAT; - vao->attribs[ATTR_INDEX_NORMAL ].type = GL_SHORT; - vao->attribs[ATTR_INDEX_TANGENT ].type = GL_SHORT; - vao->attribs[ATTR_INDEX_TEXCOORD ].type = GL_FLOAT; - vao->attribs[ATTR_INDEX_LIGHTCOORD ].type = GL_FLOAT; - vao->attribs[ATTR_INDEX_COLOR ].type = GL_UNSIGNED_SHORT; - vao->attribs[ATTR_INDEX_LIGHTDIRECTION].type = GL_SHORT; - - vao->attribs[ATTR_INDEX_POSITION ].normalized = GL_FALSE; - vao->attribs[ATTR_INDEX_NORMAL ].normalized = GL_TRUE; - vao->attribs[ATTR_INDEX_TANGENT ].normalized = GL_TRUE; - vao->attribs[ATTR_INDEX_TEXCOORD ].normalized = GL_FALSE; - vao->attribs[ATTR_INDEX_LIGHTCOORD ].normalized = GL_FALSE; - vao->attribs[ATTR_INDEX_COLOR ].normalized = GL_TRUE; - vao->attribs[ATTR_INDEX_LIGHTDIRECTION].normalized = GL_TRUE; - - vao->attribs[ATTR_INDEX_POSITION ].offset = 0; dataSize = sizeof(verts[0].xyz); - vao->attribs[ATTR_INDEX_NORMAL ].offset = dataSize; dataSize += sizeof(verts[0].normal); - vao->attribs[ATTR_INDEX_TANGENT ].offset = dataSize; dataSize += sizeof(verts[0].tangent); - vao->attribs[ATTR_INDEX_TEXCOORD ].offset = dataSize; dataSize += sizeof(verts[0].st); - vao->attribs[ATTR_INDEX_LIGHTCOORD ].offset = dataSize; dataSize += sizeof(verts[0].lightmap); - vao->attribs[ATTR_INDEX_COLOR ].offset = dataSize; dataSize += sizeof(verts[0].color); - vao->attribs[ATTR_INDEX_LIGHTDIRECTION].offset = dataSize; dataSize += sizeof(verts[0].lightdir); - - vao->attribs[ATTR_INDEX_POSITION ].stride = dataSize; - vao->attribs[ATTR_INDEX_NORMAL ].stride = dataSize; - vao->attribs[ATTR_INDEX_TANGENT ].stride = dataSize; - vao->attribs[ATTR_INDEX_TEXCOORD ].stride = dataSize; - vao->attribs[ATTR_INDEX_LIGHTCOORD ].stride = dataSize; - vao->attribs[ATTR_INDEX_COLOR ].stride = dataSize; - vao->attribs[ATTR_INDEX_LIGHTDIRECTION].stride = dataSize; - - - if (glRefConfig.vertexArrayObject) - { - qglGenVertexArrays(1, &vao->vao); - qglBindVertexArray(vao->vao); - } - - - // create VBO - dataSize *= numVertexes; - data = ri.Hunk_AllocateTempMemory(dataSize); - dataOfs = 0; - - for (i = 0; i < numVertexes; i++) - { - // xyz - memcpy(data + dataOfs, &verts[i].xyz, sizeof(verts[i].xyz)); - dataOfs += sizeof(verts[i].xyz); - - // normal - memcpy(data + dataOfs, &verts[i].normal, sizeof(verts[i].normal)); - dataOfs += sizeof(verts[i].normal); - - // tangent - memcpy(data + dataOfs, &verts[i].tangent, sizeof(verts[i].tangent)); - dataOfs += sizeof(verts[i].tangent); - - // texcoords - memcpy(data + dataOfs, &verts[i].st, sizeof(verts[i].st)); - dataOfs += sizeof(verts[i].st); - - // lightmap texcoords - memcpy(data + dataOfs, &verts[i].lightmap, sizeof(verts[i].lightmap)); - dataOfs += sizeof(verts[i].lightmap); - - // colors - memcpy(data + dataOfs, &verts[i].color, sizeof(verts[i].color)); - dataOfs += sizeof(verts[i].color); - - // light directions - memcpy(data + dataOfs, &verts[i].lightdir, sizeof(verts[i].lightdir)); - dataOfs += sizeof(verts[i].lightdir); - } - - vao->vertexesSize = dataSize; - - qglGenBuffers(1, &vao->vertexesVBO); - - qglBindBuffer(GL_ARRAY_BUFFER, vao->vertexesVBO); - qglBufferData(GL_ARRAY_BUFFER, vao->vertexesSize, data, glUsage); - - - // create IBO - vao->indexesSize = numIndexes * sizeof(glIndex_t); - - qglGenBuffers(1, &vao->indexesIBO); - - qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vao->indexesIBO); - qglBufferData(GL_ELEMENT_ARRAY_BUFFER, vao->indexesSize, indexes, glUsage); - - - Vao_SetVertexPointers(vao); - - - glState.currentVao = vao; - - GL_CheckErrors(); - - ri.Hunk_FreeTempMemory(data); - - return vao; -} - - -/* -============ -R_BindVao -============ -*/ -void R_BindVao(vao_t * vao) -{ - if(!vao) - { - //R_BindNullVao(); - ri.Error(ERR_DROP, "R_BindVao: NULL vao"); - return; - } - - if(glState.currentVao != vao) - { - glState.currentVao = vao; - - glState.vertexAttribsInterpolation = 0; - glState.vertexAnimation = qfalse; - backEnd.pc.c_vaoBinds++; - - if (glRefConfig.vertexArrayObject) - { - qglBindVertexArray(vao->vao); - - // Intel Graphics doesn't save GL_ELEMENT_ARRAY_BUFFER binding with VAO binding. - if (glRefConfig.intelGraphics || vao == tess.vao) - qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vao->indexesIBO); - - // tess VAO always has buffers bound - if (vao == tess.vao) - qglBindBuffer(GL_ARRAY_BUFFER, vao->vertexesVBO); - } - else - { - qglBindBuffer(GL_ARRAY_BUFFER, vao->vertexesVBO); - qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vao->indexesIBO); - - // tess VAO doesn't have vertex pointers set until data is uploaded - if (vao != tess.vao) - Vao_SetVertexPointers(vao); - } - } -} - -/* -============ -R_BindNullVao -============ -*/ -void R_BindNullVao(void) -{ -// GLimp_LogComment("--- R_BindNullVao ---\n"); - - if(glState.currentVao) - { - if (glRefConfig.vertexArrayObject) - { - qglBindVertexArray(0); - - // why you no save GL_ELEMENT_ARRAY_BUFFER binding, Intel? - if (1) qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - } - else - { - qglBindBuffer(GL_ARRAY_BUFFER, 0); - qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - } - glState.currentVao = NULL; - } - - GL_CheckErrors(); -} - - -/* -============ -R_InitVaos -============ -*/ -void R_InitVaos(void) -{ - int vertexesSize, indexesSize; - int offset; - - ri.Printf(PRINT_ALL, "------- R_InitVaos -------\n"); - - tr.numVaos = 0; - - vertexesSize = sizeof(tess.xyz[0]); - vertexesSize += sizeof(tess.normal[0]); - vertexesSize += sizeof(tess.tangent[0]); - vertexesSize += sizeof(tess.color[0]); - vertexesSize += sizeof(tess.texCoords[0]); - vertexesSize += sizeof(tess.lightCoords[0]); - vertexesSize += sizeof(tess.lightdir[0]); - vertexesSize *= SHADER_MAX_VERTEXES; - - indexesSize = sizeof(tess.indexes[0]) * SHADER_MAX_INDEXES; - - tess.vao = R_CreateVao("tessVertexArray_VAO", NULL, vertexesSize, NULL, indexesSize, VAO_USAGE_DYNAMIC); - - offset = 0; - - tess.vao->attribs[ATTR_INDEX_POSITION ].enabled = 1; - tess.vao->attribs[ATTR_INDEX_NORMAL ].enabled = 1; - tess.vao->attribs[ATTR_INDEX_TANGENT ].enabled = 1; - tess.vao->attribs[ATTR_INDEX_TEXCOORD ].enabled = 1; - tess.vao->attribs[ATTR_INDEX_LIGHTCOORD ].enabled = 1; - tess.vao->attribs[ATTR_INDEX_COLOR ].enabled = 1; - tess.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].enabled = 1; - - tess.vao->attribs[ATTR_INDEX_POSITION ].count = 3; - tess.vao->attribs[ATTR_INDEX_NORMAL ].count = 4; - tess.vao->attribs[ATTR_INDEX_TANGENT ].count = 4; - tess.vao->attribs[ATTR_INDEX_TEXCOORD ].count = 2; - tess.vao->attribs[ATTR_INDEX_LIGHTCOORD ].count = 2; - tess.vao->attribs[ATTR_INDEX_COLOR ].count = 4; - tess.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].count = 4; - - tess.vao->attribs[ATTR_INDEX_POSITION ].type = GL_FLOAT; - tess.vao->attribs[ATTR_INDEX_NORMAL ].type = GL_SHORT; - tess.vao->attribs[ATTR_INDEX_TANGENT ].type = GL_SHORT; - tess.vao->attribs[ATTR_INDEX_TEXCOORD ].type = GL_FLOAT; - tess.vao->attribs[ATTR_INDEX_LIGHTCOORD ].type = GL_FLOAT; - tess.vao->attribs[ATTR_INDEX_COLOR ].type = GL_UNSIGNED_SHORT; - tess.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].type = GL_SHORT; - - tess.vao->attribs[ATTR_INDEX_POSITION ].normalized = GL_FALSE; - tess.vao->attribs[ATTR_INDEX_NORMAL ].normalized = GL_TRUE; - tess.vao->attribs[ATTR_INDEX_TANGENT ].normalized = GL_TRUE; - tess.vao->attribs[ATTR_INDEX_TEXCOORD ].normalized = GL_FALSE; - tess.vao->attribs[ATTR_INDEX_LIGHTCOORD ].normalized = GL_FALSE; - tess.vao->attribs[ATTR_INDEX_COLOR ].normalized = GL_TRUE; - tess.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].normalized = GL_TRUE; - - tess.vao->attribs[ATTR_INDEX_POSITION ].offset = offset; offset += sizeof(tess.xyz[0]) * SHADER_MAX_VERTEXES; - tess.vao->attribs[ATTR_INDEX_NORMAL ].offset = offset; offset += sizeof(tess.normal[0]) * SHADER_MAX_VERTEXES; - tess.vao->attribs[ATTR_INDEX_TANGENT ].offset = offset; offset += sizeof(tess.tangent[0]) * SHADER_MAX_VERTEXES; - tess.vao->attribs[ATTR_INDEX_TEXCOORD ].offset = offset; offset += sizeof(tess.texCoords[0]) * SHADER_MAX_VERTEXES; - tess.vao->attribs[ATTR_INDEX_LIGHTCOORD ].offset = offset; offset += sizeof(tess.lightCoords[0]) * SHADER_MAX_VERTEXES; - tess.vao->attribs[ATTR_INDEX_COLOR ].offset = offset; offset += sizeof(tess.color[0]) * SHADER_MAX_VERTEXES; - tess.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].offset = offset; - - tess.vao->attribs[ATTR_INDEX_POSITION ].stride = sizeof(tess.xyz[0]); - tess.vao->attribs[ATTR_INDEX_NORMAL ].stride = sizeof(tess.normal[0]); - tess.vao->attribs[ATTR_INDEX_TANGENT ].stride = sizeof(tess.tangent[0]); - tess.vao->attribs[ATTR_INDEX_TEXCOORD ].stride = sizeof(tess.texCoords[0]); - tess.vao->attribs[ATTR_INDEX_LIGHTCOORD ].stride = sizeof(tess.lightCoords[0]); - tess.vao->attribs[ATTR_INDEX_COLOR ].stride = sizeof(tess.color[0]); - tess.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].stride = sizeof(tess.lightdir[0]); - - tess.attribPointers[ATTR_INDEX_POSITION] = tess.xyz; - tess.attribPointers[ATTR_INDEX_NORMAL] = tess.normal; - tess.attribPointers[ATTR_INDEX_TANGENT] = tess.tangent; - tess.attribPointers[ATTR_INDEX_TEXCOORD] = tess.texCoords; - tess.attribPointers[ATTR_INDEX_LIGHTCOORD] = tess.lightCoords; - tess.attribPointers[ATTR_INDEX_COLOR] = tess.color; - tess.attribPointers[ATTR_INDEX_LIGHTDIRECTION] = tess.lightdir; - - Vao_SetVertexPointers(tess.vao); - - R_BindNullVao(); - - VaoCache_Init(); - - GL_CheckErrors(); -} - -/* -============ -R_ShutdownVaos -============ -*/ -void R_ShutdownVaos(void) -{ - int i; - vao_t *vao; - - ri.Printf(PRINT_ALL, "------- R_ShutdownVaos -------\n"); - - R_BindNullVao(); - - for(i = 0; i < tr.numVaos; i++) - { - vao = tr.vaos[i]; - - if(vao->vao) - qglDeleteVertexArrays(1, &vao->vao); - - if(vao->vertexesVBO) - { - qglDeleteBuffers(1, &vao->vertexesVBO); - } - - if(vao->indexesIBO) - { - qglDeleteBuffers(1, &vao->indexesIBO); - } - } - - tr.numVaos = 0; -} - -/* -============ -R_VaoList_f -============ -*/ -void R_VaoList_f(void) -{ - int i; - vao_t *vao; - int vertexesSize = 0; - int indexesSize = 0; - - ri.Printf(PRINT_ALL, " size name\n"); - ri.Printf(PRINT_ALL, "----------------------------------------------------------\n"); - - for(i = 0; i < tr.numVaos; i++) - { - vao = tr.vaos[i]; - - ri.Printf(PRINT_ALL, "%d.%02d MB %s\n", vao->vertexesSize / (1024 * 1024), - (vao->vertexesSize % (1024 * 1024)) * 100 / (1024 * 1024), vao->name); - - vertexesSize += vao->vertexesSize; - } - - for(i = 0; i < tr.numVaos; i++) - { - vao = tr.vaos[i]; - - ri.Printf(PRINT_ALL, "%d.%02d MB %s\n", vao->indexesSize / (1024 * 1024), - (vao->indexesSize % (1024 * 1024)) * 100 / (1024 * 1024), vao->name); - - indexesSize += vao->indexesSize; - } - - ri.Printf(PRINT_ALL, " %i total VAOs\n", tr.numVaos); - ri.Printf(PRINT_ALL, " %d.%02d MB total vertices memory\n", vertexesSize / (1024 * 1024), - (vertexesSize % (1024 * 1024)) * 100 / (1024 * 1024)); - ri.Printf(PRINT_ALL, " %d.%02d MB total triangle indices memory\n", indexesSize / (1024 * 1024), - (indexesSize % (1024 * 1024)) * 100 / (1024 * 1024)); -} - - -/* -============== -RB_UpdateTessVao - -Adapted from Tess_UpdateVBOs from xreal - -Update the default VAO to replace the client side vertex arrays -============== -*/ -void RB_UpdateTessVao(unsigned int attribBits) -{ -// GLimp_LogComment("--- RB_UpdateTessVao ---\n"); - - backEnd.pc.c_dynamicVaoDraws++; - - // update the default VAO - if(tess.numVertexes > 0 && tess.numVertexes <= SHADER_MAX_VERTEXES && tess.numIndexes > 0 && tess.numIndexes <= SHADER_MAX_INDEXES) - { - int attribIndex; - int attribUpload; - - R_BindVao(tess.vao); - - // orphan old vertex buffer so we don't stall on it - qglBufferData(GL_ARRAY_BUFFER, tess.vao->vertexesSize, NULL, GL_DYNAMIC_DRAW); - - // if nothing to set, set everything - if(!(attribBits & ATTR_BITS)) - attribBits = ATTR_BITS; - - attribUpload = attribBits; - - for (attribIndex = 0; attribIndex < ATTR_INDEX_COUNT; attribIndex++) - { - uint32_t attribBit = 1 << attribIndex; - vaoAttrib_t *vAtb = &tess.vao->attribs[attribIndex]; - - if (attribUpload & attribBit) - { - // note: tess has a VBO where stride == size - qglBufferSubData(GL_ARRAY_BUFFER, vAtb->offset, tess.numVertexes * vAtb->stride, tess.attribPointers[attribIndex]); - } - - if (attribBits & attribBit) - { - if (!glRefConfig.vertexArrayObject) - qglVertexAttribPointer(attribIndex, vAtb->count, vAtb->type, vAtb->normalized, vAtb->stride, BUFFER_OFFSET(vAtb->offset)); - - if (!(glState.vertexAttribsEnabled & attribBit)) - { - qglEnableVertexAttribArray(attribIndex); - glState.vertexAttribsEnabled |= attribBit; - } - } - else - { - if ((glState.vertexAttribsEnabled & attribBit)) - { - qglDisableVertexAttribArray(attribIndex); - glState.vertexAttribsEnabled &= ~attribBit; - } - } - } - - // orphan old index buffer so we don't stall on it - qglBufferData(GL_ELEMENT_ARRAY_BUFFER, tess.vao->indexesSize, NULL, GL_DYNAMIC_DRAW); - - qglBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, tess.numIndexes * sizeof(tess.indexes[0]), tess.indexes); - } -} - -// FIXME: This sets a limit of 65536 verts/262144 indexes per static surface -// This is higher than the old vq3 limits but is worth noting -#define VAOCACHE_QUEUE_MAX_SURFACES (1 << 10) -#define VAOCACHE_QUEUE_MAX_VERTEXES (1 << 16) -#define VAOCACHE_QUEUE_MAX_INDEXES (VAOCACHE_QUEUE_MAX_VERTEXES * 4) - -typedef struct queuedSurface_s -{ - srfVert_t *vertexes; - int numVerts; - glIndex_t *indexes; - int numIndexes; -} -queuedSurface_t; - -static struct -{ - queuedSurface_t surfaces[VAOCACHE_QUEUE_MAX_SURFACES]; - int numSurfaces; - - srfVert_t vertexes[VAOCACHE_QUEUE_MAX_VERTEXES]; - int vertexCommitSize; - - glIndex_t indexes[VAOCACHE_QUEUE_MAX_INDEXES]; - int indexCommitSize; -} -vcq; - -#define VAOCACHE_MAX_SURFACES (1 << 16) -#define VAOCACHE_MAX_BATCHES (1 << 10) - -// srfVert_t is 60 bytes -// assuming each vert is referenced 4 times, need 16 bytes (4 glIndex_t) per vert -// -> need about 4/15ths the space for indexes as vertexes -#if GL_INDEX_TYPE == GL_UNSIGNED_SHORT -#define VAOCACHE_VERTEX_BUFFER_SIZE (sizeof(srfVert_t) * USHRT_MAX) -#define VAOCACHE_INDEX_BUFFER_SIZE (sizeof(glIndex_t) * USHRT_MAX * 4) -#else // GL_UNSIGNED_INT -#define VAOCACHE_VERTEX_BUFFER_SIZE (16 * 1024 * 1024) -#define VAOCACHE_INDEX_BUFFER_SIZE (5 * 1024 * 1024) -#endif - -typedef struct buffered_s -{ - void *data; - int size; - int bufferOffset; -} -buffered_t; - -static struct -{ - vao_t *vao; - buffered_t surfaceIndexSets[VAOCACHE_MAX_SURFACES]; - int numSurfaces; - - int batchLengths[VAOCACHE_MAX_BATCHES]; - int numBatches; - - int vertexOffset; - int indexOffset; -} -vc; - -void VaoCache_Commit(void) -{ - buffered_t *indexSet; - int *batchLength; - queuedSurface_t *surf, *end = vcq.surfaces + vcq.numSurfaces; - - R_BindVao(vc.vao); - - // Search for a matching batch - // FIXME: Use faster search - indexSet = vc.surfaceIndexSets; - batchLength = vc.batchLengths; - for (; batchLength < vc.batchLengths + vc.numBatches; batchLength++) - { - if (*batchLength == vcq.numSurfaces) - { - buffered_t *indexSet2 = indexSet; - for (surf = vcq.surfaces; surf < end; surf++, indexSet2++) - { - if (surf->indexes != indexSet2->data || (surf->numIndexes * sizeof(glIndex_t)) != indexSet2->size) - break; - } - - if (surf == end) - break; - } - - indexSet += *batchLength; - } - - // If found, use it - if (indexSet < vc.surfaceIndexSets + vc.numSurfaces) - { - tess.firstIndex = indexSet->bufferOffset / sizeof(glIndex_t); - //ri.Printf(PRINT_ALL, "firstIndex %d numIndexes %d as %d\n", tess.firstIndex, tess.numIndexes, (int)(batchLength - vc.batchLengths)); - //ri.Printf(PRINT_ALL, "vc.numSurfaces %d vc.numBatches %d\n", vc.numSurfaces, vc.numBatches); - } - // If not, rebuffer the batch - // FIXME: keep track of the vertexes so we don't have to reupload them every time - else - { - srfVert_t *dstVertex = vcq.vertexes; - glIndex_t *dstIndex = vcq.indexes; - - batchLength = vc.batchLengths + vc.numBatches; - *batchLength = vcq.numSurfaces; - vc.numBatches++; - - tess.firstIndex = vc.indexOffset / sizeof(glIndex_t); - vcq.vertexCommitSize = 0; - vcq.indexCommitSize = 0; - for (surf = vcq.surfaces; surf < end; surf++) - { - glIndex_t *srcIndex = surf->indexes; - int vertexesSize = surf->numVerts * sizeof(srfVert_t); - int indexesSize = surf->numIndexes * sizeof(glIndex_t); - int i, indexOffset = (vc.vertexOffset + vcq.vertexCommitSize) / sizeof(srfVert_t); - - Com_Memcpy(dstVertex, surf->vertexes, vertexesSize); - dstVertex += surf->numVerts; - - vcq.vertexCommitSize += vertexesSize; - - indexSet = vc.surfaceIndexSets + vc.numSurfaces; - indexSet->data = surf->indexes; - indexSet->size = indexesSize; - indexSet->bufferOffset = vc.indexOffset + vcq.indexCommitSize; - vc.numSurfaces++; - - for (i = 0; i < surf->numIndexes; i++) - *dstIndex++ = *srcIndex++ + indexOffset; - - vcq.indexCommitSize += indexesSize; - } - - //ri.Printf(PRINT_ALL, "committing %d to %d, %d to %d as %d\n", vcq.vertexCommitSize, vc.vertexOffset, vcq.indexCommitSize, vc.indexOffset, (int)(batchLength - vc.batchLengths)); - - if (vcq.vertexCommitSize) - { - qglBindBuffer(GL_ARRAY_BUFFER, vc.vao->vertexesVBO); - qglBufferSubData(GL_ARRAY_BUFFER, vc.vertexOffset, vcq.vertexCommitSize, vcq.vertexes); - vc.vertexOffset += vcq.vertexCommitSize; - } - - if (vcq.indexCommitSize) - { - qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vc.vao->indexesIBO); - qglBufferSubData(GL_ELEMENT_ARRAY_BUFFER, vc.indexOffset, vcq.indexCommitSize, vcq.indexes); - vc.indexOffset += vcq.indexCommitSize; - } - } -} - -void VaoCache_Init(void) -{ - vc.vao = R_CreateVao("VaoCache", NULL, VAOCACHE_VERTEX_BUFFER_SIZE, NULL, VAOCACHE_INDEX_BUFFER_SIZE, VAO_USAGE_DYNAMIC); - - vc.vao->attribs[ATTR_INDEX_POSITION].enabled = 1; - vc.vao->attribs[ATTR_INDEX_TEXCOORD].enabled = 1; - vc.vao->attribs[ATTR_INDEX_LIGHTCOORD].enabled = 1; - vc.vao->attribs[ATTR_INDEX_NORMAL].enabled = 1; - vc.vao->attribs[ATTR_INDEX_TANGENT].enabled = 1; - vc.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].enabled = 1; - vc.vao->attribs[ATTR_INDEX_COLOR].enabled = 1; - - vc.vao->attribs[ATTR_INDEX_POSITION].count = 3; - vc.vao->attribs[ATTR_INDEX_TEXCOORD].count = 2; - vc.vao->attribs[ATTR_INDEX_LIGHTCOORD].count = 2; - vc.vao->attribs[ATTR_INDEX_NORMAL].count = 4; - vc.vao->attribs[ATTR_INDEX_TANGENT].count = 4; - vc.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].count = 4; - vc.vao->attribs[ATTR_INDEX_COLOR].count = 4; - - vc.vao->attribs[ATTR_INDEX_POSITION].type = GL_FLOAT; - vc.vao->attribs[ATTR_INDEX_TEXCOORD].type = GL_FLOAT; - vc.vao->attribs[ATTR_INDEX_LIGHTCOORD].type = GL_FLOAT; - vc.vao->attribs[ATTR_INDEX_NORMAL].type = GL_SHORT; - vc.vao->attribs[ATTR_INDEX_TANGENT].type = GL_SHORT; - vc.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].type = GL_SHORT; - vc.vao->attribs[ATTR_INDEX_COLOR].type = GL_UNSIGNED_SHORT; - - vc.vao->attribs[ATTR_INDEX_POSITION].normalized = GL_FALSE; - vc.vao->attribs[ATTR_INDEX_TEXCOORD].normalized = GL_FALSE; - vc.vao->attribs[ATTR_INDEX_LIGHTCOORD].normalized = GL_FALSE; - vc.vao->attribs[ATTR_INDEX_NORMAL].normalized = GL_TRUE; - vc.vao->attribs[ATTR_INDEX_TANGENT].normalized = GL_TRUE; - vc.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].normalized = GL_TRUE; - vc.vao->attribs[ATTR_INDEX_COLOR].normalized = GL_TRUE; - - vc.vao->attribs[ATTR_INDEX_POSITION].offset = offsetof(srfVert_t, xyz); - vc.vao->attribs[ATTR_INDEX_TEXCOORD].offset = offsetof(srfVert_t, st); - vc.vao->attribs[ATTR_INDEX_LIGHTCOORD].offset = offsetof(srfVert_t, lightmap); - vc.vao->attribs[ATTR_INDEX_NORMAL].offset = offsetof(srfVert_t, normal); - vc.vao->attribs[ATTR_INDEX_TANGENT].offset = offsetof(srfVert_t, tangent); - vc.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].offset = offsetof(srfVert_t, lightdir); - vc.vao->attribs[ATTR_INDEX_COLOR].offset = offsetof(srfVert_t, color); - - vc.vao->attribs[ATTR_INDEX_POSITION].stride = sizeof(srfVert_t); - vc.vao->attribs[ATTR_INDEX_TEXCOORD].stride = sizeof(srfVert_t); - vc.vao->attribs[ATTR_INDEX_LIGHTCOORD].stride = sizeof(srfVert_t); - vc.vao->attribs[ATTR_INDEX_NORMAL].stride = sizeof(srfVert_t); - vc.vao->attribs[ATTR_INDEX_TANGENT].stride = sizeof(srfVert_t); - vc.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].stride = sizeof(srfVert_t); - vc.vao->attribs[ATTR_INDEX_COLOR].stride = sizeof(srfVert_t); - - Vao_SetVertexPointers(vc.vao); - - vc.numSurfaces = 0; - vc.numBatches = 0; - vc.vertexOffset = 0; - vc.indexOffset = 0; - vcq.vertexCommitSize = 0; - vcq.indexCommitSize = 0; - vcq.numSurfaces = 0; -} - -void VaoCache_BindVao(void) -{ - R_BindVao(vc.vao); -} - -void VaoCache_CheckAdd(qboolean *endSurface, qboolean *recycleVertexBuffer, qboolean *recycleIndexBuffer, int numVerts, int numIndexes) -{ - int vertexesSize = sizeof(srfVert_t) * numVerts; - int indexesSize = sizeof(glIndex_t) * numIndexes; - - if (vc.vao->vertexesSize < vc.vertexOffset + vcq.vertexCommitSize + vertexesSize) - { - //ri.Printf(PRINT_ALL, "out of space in vertex cache: %d < %d + %d + %d\n", vc.vao->vertexesSize, vc.vertexOffset, vcq.vertexCommitSize, vertexesSize); - *recycleVertexBuffer = qtrue; - *recycleIndexBuffer = qtrue; - *endSurface = qtrue; - } - - if (vc.vao->indexesSize < vc.indexOffset + vcq.indexCommitSize + indexesSize) - { - //ri.Printf(PRINT_ALL, "out of space in index cache\n"); - *recycleIndexBuffer = qtrue; - *endSurface = qtrue; - } - - if (vc.numSurfaces + vcq.numSurfaces >= VAOCACHE_MAX_SURFACES) - { - //ri.Printf(PRINT_ALL, "out of surfaces in index cache\n"); - *recycleIndexBuffer = qtrue; - *endSurface = qtrue; - } - - if (vc.numBatches >= VAOCACHE_MAX_BATCHES) - { - //ri.Printf(PRINT_ALL, "out of batches in index cache\n"); - *recycleIndexBuffer = qtrue; - *endSurface = qtrue; - } - - if (vcq.numSurfaces >= VAOCACHE_QUEUE_MAX_SURFACES) - { - //ri.Printf(PRINT_ALL, "out of queued surfaces\n"); - *endSurface = qtrue; - } - - if (VAOCACHE_QUEUE_MAX_VERTEXES * sizeof(srfVert_t) < vcq.vertexCommitSize + vertexesSize) - { - //ri.Printf(PRINT_ALL, "out of queued vertexes\n"); - *endSurface = qtrue; - } - - if (VAOCACHE_QUEUE_MAX_INDEXES * sizeof(glIndex_t) < vcq.indexCommitSize + indexesSize) - { - //ri.Printf(PRINT_ALL, "out of queued indexes\n"); - *endSurface = qtrue; - } -} - -void VaoCache_RecycleVertexBuffer(void) -{ - qglBindBuffer(GL_ARRAY_BUFFER, vc.vao->vertexesVBO); - qglBufferData(GL_ARRAY_BUFFER, vc.vao->vertexesSize, NULL, GL_DYNAMIC_DRAW); - vc.vertexOffset = 0; -} - -void VaoCache_RecycleIndexBuffer(void) -{ - qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vc.vao->indexesIBO); - qglBufferData(GL_ELEMENT_ARRAY_BUFFER, vc.vao->indexesSize, NULL, GL_DYNAMIC_DRAW); - vc.indexOffset = 0; - vc.numSurfaces = 0; - vc.numBatches = 0; -} - -void VaoCache_InitQueue(void) -{ - vcq.vertexCommitSize = 0; - vcq.indexCommitSize = 0; - vcq.numSurfaces = 0; -} - -void VaoCache_AddSurface(srfVert_t *verts, int numVerts, glIndex_t *indexes, int numIndexes) -{ - queuedSurface_t *queueEntry = vcq.surfaces + vcq.numSurfaces; - queueEntry->vertexes = verts; - queueEntry->numVerts = numVerts; - queueEntry->indexes = indexes; - queueEntry->numIndexes = numIndexes; - vcq.numSurfaces++; - - vcq.vertexCommitSize += sizeof(srfVert_t) * numVerts; - vcq.indexCommitSize += sizeof(glIndex_t) * numIndexes; -} diff --git a/code/renderer2/tr_world.c b/code/renderer2/tr_world.c deleted file mode 100644 index 18e8406b3e..0000000000 --- a/code/renderer2/tr_world.c +++ /dev/null @@ -1,809 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -#include "tr_local.h" - - - -/* -================ -R_CullSurface - -Tries to cull surfaces before they are lighted or -added to the sorting list. -================ -*/ -static qboolean R_CullSurface( msurface_t *surf ) { - if ( r_nocull->integer || surf->cullinfo.type == CULLINFO_NONE) { - return qfalse; - } - - if ( r_nocurves->integer && *surf->data == SF_GRID ) { - return qtrue; - } - - if (surf->cullinfo.type & CULLINFO_PLANE) - { - // Only true for SF_FACE, so treat like its own function - float d; - cullType_t ct; - - if ( !r_facePlaneCull->integer ) { - return qfalse; - } - - ct = surf->shader->cullType; - - if (ct == CT_TWO_SIDED) - { - return qfalse; - } - - // don't cull for depth shadow - /* - if ( tr.viewParms.flags & VPF_DEPTHSHADOW ) - { - return qfalse; - } - */ - - // shadowmaps draw back surfaces - if ( tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW) ) - { - if (ct == CT_FRONT_SIDED) - { - ct = CT_BACK_SIDED; - } - else - { - ct = CT_FRONT_SIDED; - } - } - - // do proper cull for orthographic projection - if (tr.viewParms.flags & VPF_ORTHOGRAPHIC) { - d = DotProduct(tr.viewParms.or.axis[0], surf->cullinfo.plane.normal); - if ( ct == CT_FRONT_SIDED ) { - if (d > 0) - return qtrue; - } else { - if (d < 0) - return qtrue; - } - return qfalse; - } - - d = DotProduct (tr.or.viewOrigin, surf->cullinfo.plane.normal); - - // don't cull exactly on the plane, because there are levels of rounding - // through the BSP, ICD, and hardware that may cause pixel gaps if an - // epsilon isn't allowed here - if ( ct == CT_FRONT_SIDED ) { - if ( d < surf->cullinfo.plane.dist - 8 ) { - return qtrue; - } - } else { - if ( d > surf->cullinfo.plane.dist + 8 ) { - return qtrue; - } - } - - return qfalse; - } - - if (surf->cullinfo.type & CULLINFO_SPHERE) - { - int sphereCull; - - if ( tr.currentEntityNum != REFENTITYNUM_WORLD ) { - sphereCull = R_CullLocalPointAndRadius( surf->cullinfo.localOrigin, surf->cullinfo.radius ); - } else { - sphereCull = R_CullPointAndRadius( surf->cullinfo.localOrigin, surf->cullinfo.radius ); - } - - if ( sphereCull == CULL_OUT ) - { - return qtrue; - } - } - - if (surf->cullinfo.type & CULLINFO_BOX) - { - int boxCull; - - if ( tr.currentEntityNum != REFENTITYNUM_WORLD ) { - boxCull = R_CullLocalBox( surf->cullinfo.bounds ); - } else { - boxCull = R_CullBox( surf->cullinfo.bounds ); - } - - if ( boxCull == CULL_OUT ) - { - return qtrue; - } - } - - return qfalse; -} - - -/* -==================== -R_DlightSurface - -The given surface is going to be drawn, and it touches a leaf -that is touched by one or more dlights, so try to throw out -more dlights if possible. -==================== -*/ -static int R_DlightSurface( msurface_t *surf, int dlightBits ) { - float d; - int i; - dlight_t *dl; - - if ( surf->cullinfo.type & CULLINFO_PLANE ) - { - for ( i = 0 ; i < tr.refdef.num_dlights ; i++ ) { - if ( ! ( dlightBits & ( 1 << i ) ) ) { - continue; - } - dl = &tr.refdef.dlights[i]; - d = DotProduct( dl->origin, surf->cullinfo.plane.normal ) - surf->cullinfo.plane.dist; - if ( d < -dl->radius || d > dl->radius ) { - // dlight doesn't reach the plane - dlightBits &= ~( 1 << i ); - } - } - } - - if ( surf->cullinfo.type & CULLINFO_BOX ) - { - for ( i = 0 ; i < tr.refdef.num_dlights ; i++ ) { - if ( ! ( dlightBits & ( 1 << i ) ) ) { - continue; - } - dl = &tr.refdef.dlights[i]; - if ( dl->origin[0] - dl->radius > surf->cullinfo.bounds[1][0] - || dl->origin[0] + dl->radius < surf->cullinfo.bounds[0][0] - || dl->origin[1] - dl->radius > surf->cullinfo.bounds[1][1] - || dl->origin[1] + dl->radius < surf->cullinfo.bounds[0][1] - || dl->origin[2] - dl->radius > surf->cullinfo.bounds[1][2] - || dl->origin[2] + dl->radius < surf->cullinfo.bounds[0][2] ) { - // dlight doesn't reach the bounds - dlightBits &= ~( 1 << i ); - } - } - } - - if ( surf->cullinfo.type & CULLINFO_SPHERE ) - { - for ( i = 0 ; i < tr.refdef.num_dlights ; i++ ) { - if ( ! ( dlightBits & ( 1 << i ) ) ) { - continue; - } - dl = &tr.refdef.dlights[i]; - if (!SpheresIntersect(dl->origin, dl->radius, surf->cullinfo.localOrigin, surf->cullinfo.radius)) - { - // dlight doesn't reach the bounds - dlightBits &= ~( 1 << i ); - } - } - } - - switch(*surf->data) - { - case SF_FACE: - case SF_GRID: - case SF_TRIANGLES: - ((srfBspSurface_t *)surf->data)->dlightBits = dlightBits; - break; - - default: - dlightBits = 0; - break; - } - - if ( dlightBits ) { - tr.pc.c_dlightSurfaces++; - } else { - tr.pc.c_dlightSurfacesCulled++; - } - - return dlightBits; -} - -/* -==================== -R_PshadowSurface - -Just like R_DlightSurface, cull any we can -==================== -*/ -static int R_PshadowSurface( msurface_t *surf, int pshadowBits ) { - float d; - int i; - pshadow_t *ps; - - if ( surf->cullinfo.type & CULLINFO_PLANE ) - { - for ( i = 0 ; i < tr.refdef.num_pshadows ; i++ ) { - if ( ! ( pshadowBits & ( 1 << i ) ) ) { - continue; - } - ps = &tr.refdef.pshadows[i]; - d = DotProduct( ps->lightOrigin, surf->cullinfo.plane.normal ) - surf->cullinfo.plane.dist; - if ( d < -ps->lightRadius || d > ps->lightRadius ) { - // pshadow doesn't reach the plane - pshadowBits &= ~( 1 << i ); - } - } - } - - if ( surf->cullinfo.type & CULLINFO_BOX ) - { - for ( i = 0 ; i < tr.refdef.num_pshadows ; i++ ) { - if ( ! ( pshadowBits & ( 1 << i ) ) ) { - continue; - } - ps = &tr.refdef.pshadows[i]; - if ( ps->lightOrigin[0] - ps->lightRadius > surf->cullinfo.bounds[1][0] - || ps->lightOrigin[0] + ps->lightRadius < surf->cullinfo.bounds[0][0] - || ps->lightOrigin[1] - ps->lightRadius > surf->cullinfo.bounds[1][1] - || ps->lightOrigin[1] + ps->lightRadius < surf->cullinfo.bounds[0][1] - || ps->lightOrigin[2] - ps->lightRadius > surf->cullinfo.bounds[1][2] - || ps->lightOrigin[2] + ps->lightRadius < surf->cullinfo.bounds[0][2] - || BoxOnPlaneSide(surf->cullinfo.bounds[0], surf->cullinfo.bounds[1], &ps->cullPlane) == 2 ) { - // pshadow doesn't reach the bounds - pshadowBits &= ~( 1 << i ); - } - } - } - - if ( surf->cullinfo.type & CULLINFO_SPHERE ) - { - for ( i = 0 ; i < tr.refdef.num_pshadows ; i++ ) { - if ( ! ( pshadowBits & ( 1 << i ) ) ) { - continue; - } - ps = &tr.refdef.pshadows[i]; - if (!SpheresIntersect(ps->viewOrigin, ps->viewRadius, surf->cullinfo.localOrigin, surf->cullinfo.radius) - || DotProduct( surf->cullinfo.localOrigin, ps->cullPlane.normal ) - ps->cullPlane.dist < -surf->cullinfo.radius) - { - // pshadow doesn't reach the bounds - pshadowBits &= ~( 1 << i ); - } - } - } - - switch(*surf->data) - { - case SF_FACE: - case SF_GRID: - case SF_TRIANGLES: - ((srfBspSurface_t *)surf->data)->pshadowBits = pshadowBits; - break; - - default: - pshadowBits = 0; - break; - } - - if ( pshadowBits ) { - //tr.pc.c_dlightSurfaces++; - } - - return pshadowBits; -} - - -/* -====================== -R_AddWorldSurface -====================== -*/ -static void R_AddWorldSurface( msurface_t *surf, int dlightBits, int pshadowBits ) { - // FIXME: bmodel fog? - - // try to cull before dlighting or adding - if ( R_CullSurface( surf ) ) { - return; - } - - // check for dlighting - /*if ( dlightBits ) */{ - dlightBits = R_DlightSurface( surf, dlightBits ); - dlightBits = ( dlightBits != 0 ); - } - - // check for pshadows - /*if ( pshadowBits ) */{ - pshadowBits = R_PshadowSurface( surf, pshadowBits); - pshadowBits = ( pshadowBits != 0 ); - } - - R_AddDrawSurf( surf->data, surf->shader, surf->fogIndex, dlightBits, pshadowBits, surf->cubemapIndex ); -} - -/* -============================================================= - - BRUSH MODELS - -============================================================= -*/ - -/* -================= -R_AddBrushModelSurfaces -================= -*/ -void R_AddBrushModelSurfaces ( trRefEntity_t *ent ) { - bmodel_t *bmodel; - int clip; - const model_t *pModel; - int i; - - pModel = R_GetModelByHandle( ent->e.hModel ); - - bmodel = pModel->bmodel; - - clip = R_CullLocalBox( bmodel->bounds ); - if ( clip == CULL_OUT ) { - return; - } - - R_SetupEntityLighting( &tr.refdef, ent ); - R_DlightBmodel( bmodel ); - - for ( i = 0 ; i < bmodel->numSurfaces ; i++ ) { - int surf = bmodel->firstSurface + i; - - if (tr.world->surfacesViewCount[surf] != tr.viewCount) - { - tr.world->surfacesViewCount[surf] = tr.viewCount; - R_AddWorldSurface( tr.world->surfaces + surf, tr.currentEntity->needDlights, 0 ); - } - } -} - - -/* -============================================================= - - WORLD MODEL - -============================================================= -*/ - - -/* -================ -R_RecursiveWorldNode -================ -*/ -static void R_RecursiveWorldNode( mnode_t *node, uint32_t planeBits, uint32_t dlightBits, uint32_t pshadowBits ) { - - do { - uint32_t newDlights[2]; - uint32_t newPShadows[2]; - - // if the node wasn't marked as potentially visible, exit - // pvs is skipped for depth shadows - if (!(tr.viewParms.flags & VPF_DEPTHSHADOW) && node->visCounts[tr.visIndex] != tr.visCounts[tr.visIndex]) { - return; - } - - // if the bounding volume is outside the frustum, nothing - // inside can be visible OPTIMIZE: don't do this all the way to leafs? - - if ( !r_nocull->integer ) { - int r; - - if ( planeBits & 1 ) { - r = BoxOnPlaneSide(node->mins, node->maxs, &tr.viewParms.frustum[0]); - if (r == 2) { - return; // culled - } - if ( r == 1 ) { - planeBits &= ~1; // all descendants will also be in front - } - } - - if ( planeBits & 2 ) { - r = BoxOnPlaneSide(node->mins, node->maxs, &tr.viewParms.frustum[1]); - if (r == 2) { - return; // culled - } - if ( r == 1 ) { - planeBits &= ~2; // all descendants will also be in front - } - } - - if ( planeBits & 4 ) { - r = BoxOnPlaneSide(node->mins, node->maxs, &tr.viewParms.frustum[2]); - if (r == 2) { - return; // culled - } - if ( r == 1 ) { - planeBits &= ~4; // all descendants will also be in front - } - } - - if ( planeBits & 8 ) { - r = BoxOnPlaneSide(node->mins, node->maxs, &tr.viewParms.frustum[3]); - if (r == 2) { - return; // culled - } - if ( r == 1 ) { - planeBits &= ~8; // all descendants will also be in front - } - } - - if ( planeBits & 16 ) { - r = BoxOnPlaneSide(node->mins, node->maxs, &tr.viewParms.frustum[4]); - if (r == 2) { - return; // culled - } - if ( r == 1 ) { - planeBits &= ~16; // all descendants will also be in front - } - } - } - - if ( node->contents != -1 ) { - break; - } - - // node is just a decision point, so go down both sides - // since we don't care about sort orders, just go positive to negative - - // determine which dlights are needed - newDlights[0] = 0; - newDlights[1] = 0; - if ( dlightBits ) { - int i; - - for ( i = 0 ; i < tr.refdef.num_dlights ; i++ ) { - const dlight_t *dl; - float dist; - - if ( dlightBits & ( 1 << i ) ) { - dl = &tr.refdef.dlights[i]; - dist = DotProduct( dl->origin, node->plane->normal ) - node->plane->dist; - - if ( dist > -dl->radius ) { - newDlights[0] |= ( 1 << i ); - } - if ( dist < dl->radius ) { - newDlights[1] |= ( 1 << i ); - } - } - } - } - - newPShadows[0] = 0; - newPShadows[1] = 0; - if ( pshadowBits ) { - int i; - - for ( i = 0 ; i < tr.refdef.num_pshadows ; i++ ) { - pshadow_t *shadow; - float dist; - - if ( pshadowBits & ( 1 << i ) ) { - shadow = &tr.refdef.pshadows[i]; - dist = DotProduct( shadow->lightOrigin, node->plane->normal ) - node->plane->dist; - - if ( dist > -shadow->lightRadius ) { - newPShadows[0] |= ( 1 << i ); - } - if ( dist < shadow->lightRadius ) { - newPShadows[1] |= ( 1 << i ); - } - } - } - } - - // recurse down the children, front side first - R_RecursiveWorldNode (node->children[0], planeBits, newDlights[0], newPShadows[0] ); - - // tail recurse - node = node->children[1]; - dlightBits = newDlights[1]; - pshadowBits = newPShadows[1]; - } while ( 1 ); - - { - // leaf node, so add mark surfaces - int c; - int surf, *view; - - tr.pc.c_leafs++; - - // add to z buffer bounds - if ( node->mins[0] < tr.viewParms.visBounds[0][0] ) { - tr.viewParms.visBounds[0][0] = node->mins[0]; - } - if ( node->mins[1] < tr.viewParms.visBounds[0][1] ) { - tr.viewParms.visBounds[0][1] = node->mins[1]; - } - if ( node->mins[2] < tr.viewParms.visBounds[0][2] ) { - tr.viewParms.visBounds[0][2] = node->mins[2]; - } - - if ( node->maxs[0] > tr.viewParms.visBounds[1][0] ) { - tr.viewParms.visBounds[1][0] = node->maxs[0]; - } - if ( node->maxs[1] > tr.viewParms.visBounds[1][1] ) { - tr.viewParms.visBounds[1][1] = node->maxs[1]; - } - if ( node->maxs[2] > tr.viewParms.visBounds[1][2] ) { - tr.viewParms.visBounds[1][2] = node->maxs[2]; - } - - // add surfaces - view = tr.world->marksurfaces + node->firstmarksurface; - - c = node->nummarksurfaces; - while (c--) { - // just mark it as visible, so we don't jump out of the cache derefencing the surface - surf = *view; - if (tr.world->surfacesViewCount[surf] != tr.viewCount) - { - tr.world->surfacesViewCount[surf] = tr.viewCount; - tr.world->surfacesDlightBits[surf] = dlightBits; - tr.world->surfacesPshadowBits[surf] = pshadowBits; - } - else - { - tr.world->surfacesDlightBits[surf] |= dlightBits; - tr.world->surfacesPshadowBits[surf] |= pshadowBits; - } - view++; - } - } - -} - - -/* -=============== -R_PointInLeaf -=============== -*/ -static mnode_t *R_PointInLeaf( const vec3_t p ) { - mnode_t *node; - float d; - const cplane_t *plane; - - if ( !tr.world ) { - ri.Error (ERR_DROP, "R_PointInLeaf: bad model"); - } - - node = tr.world->nodes; - while( 1 ) { - if (node->contents != -1) { - break; - } - plane = node->plane; - d = DotProduct (p,plane->normal) - plane->dist; - if (d > 0) { - node = node->children[0]; - } else { - node = node->children[1]; - } - } - - return node; -} - -/* -============== -R_ClusterPVS -============== -*/ -static const byte *R_ClusterPVS (int cluster) { - if (!tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters ) { - return NULL; - } - - return tr.world->vis + cluster * tr.world->clusterBytes; -} - -/* -================= -R_inPVS -================= -*/ -qboolean R_inPVS( const vec3_t p1, const vec3_t p2 ) { - const mnode_t *leaf; - const byte *vis; - - leaf = R_PointInLeaf( p1 ); - vis = ri.CM_ClusterPVS( leaf->cluster ); // why not R_ClusterPVS ?? - leaf = R_PointInLeaf( p2 ); - - if ( !(vis[leaf->cluster>>3] & (1<<(leaf->cluster&7))) ) { - return qfalse; - } - return qtrue; -} - -/* -=============== -R_MarkLeaves - -Mark the leaves and nodes that are in the PVS for the current -cluster -=============== -*/ -static void R_MarkLeaves (void) { - const byte *vis; - mnode_t *leaf, *parent; - int i; - int cluster; - - // lockpvs lets designers walk around to determine the - // extent of the current pvs - if ( r_lockpvs->integer ) { - return; - } - - // current viewcluster - leaf = R_PointInLeaf( tr.viewParms.pvsOrigin ); - cluster = leaf->cluster; - - // if the cluster is the same and the area visibility matrix - // hasn't changed, we don't need to mark everything again - - for(i = 0; i < MAX_VISCOUNTS; i++) - { - // if the areamask or r_showcluster was modified, invalidate all visclusters - // this caused doors to open into undrawn areas - if (tr.refdef.areamaskModified || r_showcluster->modified) - { - tr.visClusters[i] = -2; - } - else if(tr.visClusters[i] == cluster) - { - if(tr.visClusters[i] != tr.visClusters[tr.visIndex] && r_showcluster->integer) - { - ri.Printf(PRINT_ALL, "found cluster:%i area:%i index:%i\n", cluster, leaf->area, i); - } - tr.visIndex = i; - return; - } - } - - tr.visIndex = (tr.visIndex + 1) % MAX_VISCOUNTS; - tr.visCounts[tr.visIndex]++; - tr.visClusters[tr.visIndex] = cluster; - - if ( r_showcluster->modified || r_showcluster->integer ) { - r_showcluster->modified = qfalse; - if ( r_showcluster->integer ) { - ri.Printf( PRINT_ALL, "cluster:%i area:%i\n", cluster, leaf->area ); - } - } - - vis = R_ClusterPVS(tr.visClusters[tr.visIndex]); - - for (i=0,leaf=tr.world->nodes ; inumnodes ; i++, leaf++) { - cluster = leaf->cluster; - if ( cluster < 0 || cluster >= tr.world->numClusters ) { - continue; - } - - // check general pvs - if ( vis && !(vis[cluster>>3] & (1<<(cluster&7))) ) { - continue; - } - - // check for door connection - if ( (tr.refdef.areamask[leaf->area>>3] & (1<<(leaf->area&7)) ) ) { - continue; // not visible - } - - parent = leaf; - do { - if(parent->visCounts[tr.visIndex] == tr.visCounts[tr.visIndex]) - break; - parent->visCounts[tr.visIndex] = tr.visCounts[tr.visIndex]; - parent = parent->parent; - } while (parent); - } -} - - -/* -============= -R_AddWorldSurfaces -============= -*/ -void R_AddWorldSurfaces (void) { - uint32_t planeBits, dlightBits, pshadowBits; - - if ( !r_drawworld->integer ) { - return; - } - - if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { - return; - } - - tr.currentEntityNum = REFENTITYNUM_WORLD; - tr.shiftedEntityNum = tr.currentEntityNum << QSORT_REFENTITYNUM_SHIFT; - - // determine which leaves are in the PVS / areamask - if (!(tr.viewParms.flags & VPF_DEPTHSHADOW)) - R_MarkLeaves (); - - // clear out the visible min/max - ClearBounds( tr.viewParms.visBounds[0], tr.viewParms.visBounds[1] ); - - // perform frustum culling and flag all the potentially visible surfaces - if ( tr.refdef.num_dlights > MAX_DLIGHTS ) { - tr.refdef.num_dlights = MAX_DLIGHTS ; - } - - if ( tr.refdef.num_pshadows > MAX_DRAWN_PSHADOWS ) { - tr.refdef.num_pshadows = MAX_DRAWN_PSHADOWS; - } - - planeBits = (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 31 : 15; - - if ( tr.viewParms.flags & VPF_DEPTHSHADOW ) - { - dlightBits = 0; - pshadowBits = 0; - } - else if ( !(tr.viewParms.flags & VPF_SHADOWMAP) ) - { - dlightBits = ( 1ULL << tr.refdef.num_dlights ) - 1; - pshadowBits = ( 1ULL << tr.refdef.num_pshadows ) - 1; - } - else - { - dlightBits = ( 1ULL << tr.refdef.num_dlights ) - 1; - pshadowBits = 0; - } - - R_RecursiveWorldNode( tr.world->nodes, planeBits, dlightBits, pshadowBits); - - // now add all the potentially visible surfaces - // also mask invisible dlights for next frame - { - int i; - - tr.refdef.dlightMask = 0; - - for (i = 0; i < tr.world->numWorldSurfaces; i++) - { - if (tr.world->surfacesViewCount[i] != tr.viewCount) - continue; - - R_AddWorldSurface( tr.world->surfaces + i, tr.world->surfacesDlightBits[i], tr.world->surfacesPshadowBits[i] ); - tr.refdef.dlightMask |= tr.world->surfacesDlightBits[i]; - } - - tr.refdef.dlightMask = ~tr.refdef.dlightMask; - } -} diff --git a/docs/LinuxSupport/CHANGES-1.32.txt b/docs/LinuxSupport/CHANGES-1.32.txt deleted file mode 100644 index 0208b82440..0000000000 --- a/docs/LinuxSupport/CHANGES-1.32.txt +++ /dev/null @@ -1,150 +0,0 @@ -CHANGES 1.32 - -11/13/2002 - 1.32b - -Update to the Linux client, fixing a number of issues: - - -- Text mode install broken on glibc 2.3 (Debian Sid) -http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=165358 -Current Debian Sid's glibc package break backwards compatibility -with binaries compiled on older glibc and statically linked. -This will cause the text mode setup to segfault. - -For now you can either: - - find a solution to run the graphical gtk-based setup - - roll back to glibc 2.2 - - use an updated setup binary: - run the linux setup once, with the --keep option - (this will exand all the files to setup.tmp/) - get this updated setup file: - http://zerowing.idsoftware.com/linux/165358/setup - replace setup.tmp/setup.data/bin/Linux/x86/setup by the new one - cd to setup.tmp/ and run setup.sh - - -- Current NVidia drivers don't officially support glibc 2.3 systems -This affects Debian Sid in particular, causing crashes during vid_restart -The issue is related to the SMP build depending upon libpthreads -1.32b has both SMP and non-SMP binary. Use quake3-smp to launch -the SMP version if you want to use it. - - -- SMP and non-SMP builds: -Default quake3 shortcut will spawn a non-SMP build. Use quake3-smp -for an SMP-enabled run. From the feedback we got after the 1.32 release, -the SMP support as designed in the Quake III Arena technology isn't so -much relevant anymore. It was designed for much lower CPU frequencies -and lower AGP throughputs. Modern systems won't benefit from SMP. Since -it didn't make much sense to remove the SMP binary, we have both now. - - -- Fixing broken mouse on Suse: -Starting with XFree 4.2, the event timestamps returned by the X server -are no longer matching gettimeofday. And there is currently no API in X -to provide easy synchronisation. 1.32 introduced improved event timing -by correcting event time with X server event timestamp (sub-frame timing). -This worked fine with XFree 4.1, and no longer does. 1.32b adds a safe -check to work again with XFree 4.2, but basically the input timing is -back to 1.31 quality. - -Some new cvars related to the mouse control: -in_dgamouse - not new, but be sure to have it set to 1 on any recent system -in_subframe - completely disables sub-frame timing. If XFree 4.2 - in_subframe 1 won't hurt, but it won't do anything either. -in_nograb - for mod developers. Set to 1 and run windowed, Q3 won't be - grabbing your mouse pointer (useful for debug breaks) - - -8/26/2002 - -General: - -- new network protocol, 68 - -- network code: - improved fragmented messages handling - map change while client loads map no longer causes an 'Invalid .PK3' error - map_restart while client loads map no longer causes a reload - fixing donedl being ignored after autodl if map_restart'ed -- the demo command has a list of compatible protocols, it will loop through 66 67 68 - you can do '/demo four' and it will try four.dm_66 four.dm_67 four.dm_68 - or you can explicitely give a '/demo demoname.dm_??' - -- added mousewheel support in the console: - wheel to scroll, ctrl+wheel to scroll faster, shift+wheel to scroll history - -- UI in baseq3/ and missionpack/ for PunkBuster configuration - punkbuster server in server creation dialog (sv_punkbuster) - punkbuster client in server browser (cl_punkbuster) - added PB Yes/No to the browsers -- removed obsolete MPlayer UI stuff -- bumped server browser to handle up to 4096 servers - -- IP maintained in userinfo -- cl_guid in userinfo (as part of PB integration) -- printing ports as unsigned ints, no longer printing negative port numbers -- cleaned up the legacy IP banning code - use * for IP pattern matching now instead of 0 (fixes some confusion) - ex: 192.246.12.* - made it safe from overflowing and crashing - NOTE: using PunkBuster's banning system is advised instead though -- rcon: some fixes to the buffering to avoid overflowing and dropping parts of the message -- rcon: now supports quoting /rcon g_motd "foo bar" -- added SVF_CLIENTMASK (0x00000002), works only with <= 32 players - set bitmask of players to which send entity -- pushed cl_maxpackets upper limit to 125 -- added [skipnotify] from RTCW, use to display in the console only, but not on client screen - (also fixes pb_msgprefix and pb_sv_msgprefix) - -- new cvar sv_lanForceRate (defaults 1): - forces LAN clients to the maximum rate instead of accepting client setting - (1 is the default behaviour, backward compatible) - -- new cvar sv_strictAuth (defaults 1): - server side variable to control wether strict CDKEY auth should be performed with the auth server - this is required if you want reliable cl_guid for the server (for users tracking) - -- filesystem: - client re-orders it's pk3s according to the order given by server - (fixes some 'Invalid .PK3 files referenced' situations - -- fixed invisible entities/players bug (thanks goes to Rick Johnson / Raven for this one!) -- update x86 VM code (better and safer optimisations) (Richk Johnson / Raven too) -- clearing client gentity before GAME_INIT call -- failing vote if there's only one voting client (fixes exploit on 2-player server where one player votes then disconnects, forcing vote to pass) - -- added trap_FS_Seek - -- renderer fix: - if client game code registers a shader after drawsurfaces are generated but before frame is rendered - had a one-frame visual glitch (shader indexes messed up) -- renderer fix: - r_roundImagesDown 0 + map q3dm1 -> crash (buffer overflow fix) -- renderer fix: - fixed a crash in widescreen displays (q3dm11) -- renderer fix: - MAX_SHADERS up to 2^12 -- renderer fix: - moved screenshot from frontend to backend, fixes broken r_smp 1 screenshots - -- TA fixes: - MOD_KAMIKAZE MOD_JUICED logging properly to games.log - fixed bot taunt spamming -- fixed typo in scripts/models2.shader (shader error Ursula head) - -Win32 specific: - -- fixed the DirectInput mouse init procedure -- rcon: - fixed rcon not working on NT/2000/XP workstations that have a long uptime - -Linux specific: - -- no longer trying to load libMesaVoodooGL.so - obsolete code, was confusing when trying to setup correct OpenGL acceleration -- SMP support in the renderer. Detects CPU count, r_smp 1 default if available. (thanks to Gareth Hughes for contributing this) -- changed default GL driver from libGL.so to libGL.so.1 - see LSB 1.2 spec: http://www.linuxbase.org/spec/refspecs/LSB_1.2.0/gLSB/libgl.html -- Handle Ctrl and Space key together correctly (Ctrl was disabling Space) -- sub-frame timing of input events (key/mouse) (input timing quality now equivalent to win32) diff --git a/docs/LinuxSupport/INSTALL b/docs/LinuxSupport/INSTALL deleted file mode 100644 index d654d17cfe..0000000000 --- a/docs/LinuxSupport/INSTALL +++ /dev/null @@ -1,52 +0,0 @@ - Quake III Arena - Quake III: Team Arena - Installation instructions - ------ - -What you need: - -- retail CD-ROM of Quake III Arena for Windows or linux -- optionally, retail CD-ROM of Quake III: Team Arena -- a computer running linux (kernel >= 2.2 glibc >= 2.1) -- running the client requires X11 and 3D hardware acceleration with OpenGL - -Installation: - -If you have the retail CD-ROM of Quake III Arena for linux: -- install Quake III Arena from the CD-ROM -- run the Point Release installer -(to buy Quake III Arena for linux online, try http://www.tuxgames.com/) - -If you have the retail CD-ROM of Quake III Arena for Windows: -- run the Point Release installer first -- now you need to copy the main pak files from the CD-ROM - or from your win32 partition. Namely, you need to copy baseq3/pak0.pk3 - and for Team Arena, missionpack/pak0.pk3 - see below for more instructions on how to copy the files: - -WARNING: Those instructions are provided as a reference, -depending on your distribution the CD-ROM might not have the same -mount point. Please refer to your linux documentation for additional -information. - -- open a root shell and cd to the default installation path: - cd /usr/local/games/quake3 -- mount the Quake III Arena CD-ROM and install the game content - cp /mnt/cdrom/Quake3/baseq3/pak0.pk3 /usr/local/games/quake3/baseq3 -- optionally, mount the Quake III: Team Arena CD-ROM - cp /mnt/cdrom/Setup/missionpack/pak0.pk3 /usr/local/games/quake3/missionpack - -NOTES: -- If you are running Quake III Arena and Quake III: Team Arena on a - Windows partition, you can save some space by symlinking the game - assets to their windows installation: - ln -s /win/quake3/baseq3/pak0.pk3 /usr/local/games/quake3/baseq3/pak0.pk3 - ln -s /win/quake3/missionpack/pak0.pk3 /usr/local/games/quake3/missionpack/pak0.pk3 - (Windows partition is mounted as /win and Quake III Arena installation is C:\quake3) - -Getting Help: - -- consult the FAQ in Help/Q3A_FAQ.html -- head over to the Quake3World forums http://www.quake3world.com/forums -- consult the list of known issues and tips at - http://zerowing.idsoftware.com/linux diff --git a/docs/LinuxSupport/index.html b/docs/LinuxSupport/index.html deleted file mode 100644 index e87ef29ea6..0000000000 --- a/docs/LinuxSupport/index.html +++ /dev/null @@ -1,283 +0,0 @@ - - Linux Quake III Arena Known issues - - -Linux Quake III Arena Known issues
-Known issues and frequently asked questions - 1.32b
-
-TTimo
-Changes history
-2004.2.20 Last update
-2001.6.18 Initial version -

-Current topics - -
Installation instructions -
-
-

Linux Quake III Arena is using a graphical installer -(based on Loki software's Setup Graphic Installer -). However, since it's a Point Release, you need a retail CD-ROM of Quake -III Arena to perform a complete installation (and optionally your Quake III: -Team Arena CD-ROM). This process is documented in the INSTALLfile -(this file is also in the setups, it's default location is /usr/local/games/quake3/INSTALL -.. you can run the PR setup and read it to finish the installation afterwards).

-What do I do with a .x86.run file? -
-
-

Those are setup files, meant to be executed. They -come with graphical installation UI or console installation, depending on -what's available on your system. You may need to chmod +x file.x86.run -to make them executable.

-The setup crashes with Segmentation fault "$setup" "$@" 2>/dev/null -

This is happening on glibc 2.3 systems such as RedHat 9 and Suze. The text mode installer will crash. If you can do a graphical installation, make sure you have Gtk1 installed and avoid the text installer altogether. -If you are doing a remote installation (such as a dedicated server through ssh), you need to use a newer text mode installer. Run the installer with --keep to extract the files -(look for a setup* directory in the current directory for the extracted setup). -Then replace setup.data/bin/Linux/x86/setup by this newer version. Run setup.sh at top level and things should work fine.

-

-Update: Turns out this solution is working for RTCW and ET, but not for Q3 (because the last q3 setup uses an older version of the installer). Will update a specific solution for Q3 'soon'. -

-Installation on -BSD
-
-

The linux binaries will run fine on the BSD family (FreeBSD, -NetBSD and OpenBSD) with the linux binary compatibility software. However -if you are getting the error message ELF binary type "0" not known -while installing or trying to run the binaries, that means you need to run -brandelf on the files.

-

If it's a setup problem, proceed with the following steps: -

-
./linuxq3apoint-1.31.x86.run --keep
brandelf -t Linux setup.tmp/setup.data/bin/FreeBSD/x86/setup
cd setup.tmp
sh ./setup.sh
-

The --keep option will extract the files and leave them -somewhere below your current directory. Depending on the game (Q3 or RTCW) -and the setup version, your mileage may vary (setup.tmp or another directory).

-

The game binaries might need to be brandelf'ed too, with -a command such as

-
brandelf -t Linux /usr/local/games/quake3/quake3.x86
-CLIENT_UNKNOWN_TO_AUTH -
-
-

Graeme Devine recently updated his .plan with very -complete information about CLIENT_UNKNOWN_TO_AUTH errors.

-

-See some additional information from the gameadmins.com mailing list: -

-
If the server you are playing on and the auth server don't see you as the
-same IP (for instance you are trying to play on a public internet server
-that's on your LAN, and your internet access is using NAT), then it won't
-work.
-
-It used to work in 1.31, and it doesn't in 1.32. PunkBuster requires
-reliable auth of the players. What you can do:
-
-- run a server with sv_strictauth 0 and you'll be able to join your
-server. This will be the same behaviour as 1.31
-
-- connect to a server on the internet before you connect to your local
-server (this will trigger your IP into the cache of the auth server for
-15mn and let you in to your local server).
-
-- setup two NATs, one for your client one for your server and make sure
-your server and Id's auth see the same IP. (this one ain't for network
-setup newbies)
-
-Sys_Error: Couldn't load default.cfg / Sys_Error: -FS_FreeFile( NULL )
-

If you get one of these errors after installing Quake III Arena or Return -To Castle Wolfenstein, it means that the engine didn't find all the required -.pk3 files. Either you didn't copy them, or you copied them to the wrong -place. Check the INSTALL instructions for the game for more details, make -sure they are in baseq3/ for quake3 (missionpack/ for TA files) and main/ -for Return To Castle Wolfenstein.

-I get ./setup.sh {: ==: binary -operator expected when running the setup?
-
-

This is a known issue to 1.29h setups and prior. -It happens on systems with bash version < 2.*. There are several solutions:
-- Upgrade bash to something more recent and run the setup again - Run the -setup with the --keep option. It will fail but it will leave a setup-full -directory. You can then copy the files manually from that dir. - Once you -used the --keep option above, you can edit setup.sh and replace occurences -of == by =. Then run setup.sh and the installer will execute.

-The game doesn't -start, I have performance problems, etc.
-

The first thing to do is to check on the forums and various FAQs (this -one, but there are others. See the links). The Quake3World -forums have a great search function.

-

Before reporting the problem to me -make sure it's an issue with the game, and not an issue with your OS/OpenGL/sound -configuration. Common OS issues are listed in this FAQ. You should make sure -you have OpenGL configured correctly (by checking if gearsis running -for instance, and how well it runs). And see if non-Id linux games are running -fine too.

-

When you are going to report a bug, first make sure you are using the -latest version of the game. Include the game version in your report.

-

Include general information about your OS:
-

-
    -
  • Motherboard brand, CPU type, RAM
  • -
  • distribution name and version
  • -
  • kernel / OS info (from uname -a)
  • -
  • libc version (ls -l /lib/libc.so.*)
    - please specify if you can if the libc is your distribution's standard -version, or if you compiled yourself, and what binary target was used (x86, -or AMD, i686 etc.)
  • -
-

If it's a problem with the client, send the output of glxinfo.

-

If you have an nvidia board, send the output of cat /proc/nv/card0 -

-

Send output of the run:
-run the game with +set developer 1 option, and send the output. You -can do something like quake3 +set developer 1 &>q3run.log.

-

If it's a crash, you can send a backtrace of the game running through -gdb.

-

You can also send a log of the game running with strace:

-
cd /usr/local/games/quake3
strace -o ~/strace.log ./quake3.x86
-

NOTE: please avoid sending me the strace of /usr/local/games/quake3/quake3, -which is a shell script wrapper and probably no interest to your problem. -

-Aureal sound drivers
-
-

It seems that some versions of the Aureal sound drivers -don't work right with Q3. Last I heard, a kernel upgrade to 2.4.17 + Aureal -1.1.3, and/or using the old 1.1.1 drivers from Aureal's websitefixed -the problem.

-

If you need to know more about this, have a look at this Q3W forum thread.

-The sound doesn't work / sound crashes
-

The first thing to check is that it is actually a sound related. Run -the game with +set s_initsound 0 and see what happens. All problems -reported so far about sound turned out to be OS/drivers. Listed below:

-

On some Mandrake distributions:
-Check if you are running the enlightenment sound daemon (esd). With ps -aux | grep esdfor instance. It is a multiplexer for /dev/dsp, and might -block use of /dev/dsp by Quake III Arena. You can disable esd with esdctl -stop (as root).

-

Mandrake 8's default -sound drivers seem broken, installing the Alsa drivers or the - http://www.opensound.com drivers -fixes the problem.

-

Some beta Alsa drivers -have been reported to crash with Q3. Non-beta ones are fine.

-

VIA chipset and AC97 driver:
-This combination is known to have various issues. They have been fixed in -recent drivers (thanks to Arne Schmitz for the heads up):
-

-
http://sourceforge.net/projects/gkernel has got the up to date version of 
the AC97 kernel driver. The current version can be found here:

http://prdownloads.sourceforge.net/gkernel/via82cxxx-1.1.15.tar.gz

It has working mmap sound, so Q3 shouldn't be a problem any more.
-(thanks to Arne Schmitz for the heads up)

- -Where can I report bugs and discuss about linux Quake III -Arena?
-
-

Reports bugs to bugs@idsoftware.com. If you are pretty -sure this is a linux-only issue, you can shorten the loop by emailing ttimo@idsoftware.com directly.

-

You will find the discussion forums for linux Quake III Arena on -Quake3World forums. There is for sure a lot of other places to talk about -linux Quake III Arena, but this is the one we read regularly to track bugs -and common issues.

-The *.so files are not in the setups? -(cgamei386.so qagamei386.so uii386.so)
-
-

If you still have baseq3/*.so and missionpack/*.so -files, then those come from the earlier 1.27g beta installation and you should -REMOVE them. They were provided in 1.27g to go around a bug in the VM code, -which made win32 VMs incompatible with linux. This problem has been fixed -and the two files are no longer required.

-

If you are upgrading from 1.27g, it is likely that your -q3config.cfg files are set to use the native libraries (*.so files) -instead of the bytecode. Run quake3 with the following options to set things -right:
-quake3 +set vm_game 2 +set vm_cgame 2 +set vm_ui 2

-I get Sys_Error: -Sys_LoadDll(..) failed dlopen() completely!when running quake3?
-
-

Try running quake3 with the following options:
-quake3 +set vm_game 2 +set vm_cgame 2 +set vm_ui 2
-You should also read the
above answer.

-I have an AMD CPU and a kernel 2.4.*, -Quake III Arena is slowing down to a complete stop after a while?
-

It seems the 3DNow! copy routines have issues with the southbridge chip -in the KT133A, this results in performances degrading while playing for a -while. Re-compile your kernel without 3DNow! instructions to avoid the problem, -and wait for newer kernels with better support for 3DNow! / KT133A.

-How do I set up the gamma correction?
-

Starting with 1.29h, you can set the gamma correction with the brightness -slider in the graphical menu (under setup). On some older systems which don't -have the appropriate XFree86 extensions, you might have to set r_gamma -manually from the console, and issue a vid_restart command.

-Servers don't show up in the ingame -browser -

The reason for this has not been clearly identified yet, seems to be related -to upgrade from older versions. Deleting ~/.q3a/baseq3/q3config.cfg fixes -the problem (you will have to reconfigure your bindings)

-Detected an attempt to write across -stack boundary -

If Quake III Arena exits with the error "Detected an attempt to write -across stack boundary", this probably means that you are running libsafe -on this system. Quake III Arena is compiled with some options that confuse -libsafe, you should disable it before running. See this page for more details. -

-libMesaVoodooGL.so -

The GL driver for Voodoo cards (libMesaVoodoGL.so) used to be distributed -in older Q3 setups. This is no longer the case. If you have this .so -in your Quake III Arena directory (/usr/local/games/quake3), you should -remove it. Any recent/decent linux distribution should support your Voodoo -card out of the box, otherwise it is recommended that you setup XFree 4.* -and the correct DRI infrastructure for it.

-Running a LAN dedicated server with -multiple network interfaces -

A LAN dedicated server will use the net_ip cvar to identify the -NIC it is going to use (default is "localhost"). As it only opens one socket, -it is not possible to have a server broadcast it's packets on all the NICs. -This can be a problem if the server is serving games for a LAN and runs several -NICs to access the various sub networks.
-

-

The following Linux kernel patch (2.4.19) was provided by Rogier Mulhujzen -and John Tobin, it will force broadcasts to be emitted on all interfaces:
-udp_wide_broadcast.patch
-udp_wide_README.txt
-The equivalent patch for FreeBSD -is available too.
-

-Setup and execution on 64 bits CPUs
-

If you are running Linux on a 64 bit CPU (such as AMD's Opteron), and if your system is backwards compatible so that it can execute 32 bits x86 binaries, then the regular Quake III Arena binaries should work (your mileage may vary).

-

It's likely that the installer scripts will get confused though, and will refuse to install giving you an error: "This installation doesn't support glibc-2.1 on Linux / unknown". You will have to extract the game files manually by passing --keep on the command line when running the setup script. Once the files are unpacked, you will need to copy them manually to /usr/local/games. You probably want to have a working installation to refer to while doing this. This also applies to RTCW and ET

-Links
-

The Linux Gamer's -faq is a very good resource for general Linux Gaming topics.

-

Also at icculus.org, -the old -Q3 FAQ from Loki Software.

-

Quake3World's -linux FAQ

-
- diff --git a/docs/LinuxSupport/udp_wide_README.txt b/docs/LinuxSupport/udp_wide_README.txt deleted file mode 100644 index ecd0b982ea..0000000000 --- a/docs/LinuxSupport/udp_wide_README.txt +++ /dev/null @@ -1,20 +0,0 @@ -UDP Wide Broadcast Patch for Kernel 2.4.19 - -Main purpose is to allow Quake 3 servers, and all games powered by the -engine, to be visible in the server browser when the servers are being run on -aliased IP addresses and multiple NICs using the +set net_ip option. - -To apply the patch run "patch -p1 < udp_wide_broadcast.patch" from your -source directory and recompile. - -Add "echo "1" > /proc/sys/net/ipv4/udp_wide_broadcast" to one of your startup -scripts, i.e./etc/rc.d/rc.local, and run thousands of servers from your -computer. - - -Patch by: -Rogier Mulhujzen -John Tobin - -A patch with the same functionality for FreeBSD is available from -http://www.bsdchicks.com/patches diff --git a/docs/LinuxSupport/udp_wide_broadcast.patch b/docs/LinuxSupport/udp_wide_broadcast.patch deleted file mode 100644 index 2f1092e51c..0000000000 --- a/docs/LinuxSupport/udp_wide_broadcast.patch +++ /dev/null @@ -1,57 +0,0 @@ ---- linux/include/linux/sysctl.h.orig 2002-08-17 19:52:27.000000000 -0500 -+++ linux/include/linux/sysctl.h 2002-08-17 19:53:00.000000000 -0500 -@@ -291,7 +291,8 @@ - NET_IPV4_NONLOCAL_BIND=88, - NET_IPV4_ICMP_RATELIMIT=89, - NET_IPV4_ICMP_RATEMASK=90, -- NET_TCP_TW_REUSE=91 -+ NET_TCP_TW_REUSE=91, -+ NET_UDP_WIDE_BROADCAST=92 - }; - - enum { ---- linux-modified/net/ipv4/sysctl_net_ipv4.c.orig 2002-08-17 19:48:19.000000000 -0500 -+++ linux-modified/net/ipv4/sysctl_net_ipv4.c 2002-08-17 19:52:03.000000000 -0500 -@@ -45,6 +45,9 @@ - extern int inet_peer_gc_mintime; - extern int inet_peer_gc_maxtime; - -+/* From udp.c */ -+extern int sysctl_udp_wide_broadcast; -+ - #ifdef CONFIG_SYSCTL - static int tcp_retr1_max = 255; - static int ip_local_port_range_min[] = { 1, 1 }; -@@ -221,6 +224,8 @@ - &sysctl_icmp_ratemask, sizeof(int), 0644, NULL, &proc_dointvec}, - {NET_TCP_TW_REUSE, "tcp_tw_reuse", - &sysctl_tcp_tw_reuse, sizeof(int), 0644, NULL, &proc_dointvec}, -+ {NET_UDP_WIDE_BROADCAST, "udp_wide_broadcast", -+ &sysctl_udp_wide_broadcast, sizeof(int), 0644, NULL, &proc_dointvec}, - {0} - }; - ---- linux-modified/net/ipv4/udp.c.orig 2002-08-17 19:40:59.000000000 -0500 -+++ linux-modified/net/ipv4/udp.c 2002-08-17 23:37:47.000000000 -0500 -@@ -94,6 +94,8 @@ - #include - #include - -+int sysctl_udp_wide_broadcast = 0; -+ - /* - * Snmp MIB for the UDP layer - */ -@@ -272,9 +274,10 @@ - if ((s->num != hnum) || - (s->daddr && s->daddr!=rmt_addr) || - (s->dport != rmt_port && s->dport != 0) || -- (s->rcv_saddr && s->rcv_saddr != loc_addr) || -- (s->bound_dev_if && s->bound_dev_if != dif)) -+ !(sysctl_udp_wide_broadcast || !(s->rcv_saddr && s->rcv_saddr != loc_addr)) || -+ (s->bound_dev_if && s->bound_dev_if != dif)) { - continue; -+ } - break; - } - return s; diff --git a/docs/README.Linux b/docs/README.Linux deleted file mode 100644 index 05822e6050..0000000000 --- a/docs/README.Linux +++ /dev/null @@ -1,352 +0,0 @@ -+----------------------------------------+ -| Q3Test | -| The Official Quake 3: Arena TEST | -| Linux version | -| Revision 1.08 | -| Released Aug 3, 1999 | -| Copyright (C) 1999 id Software, inc. | -+----------------------------------------+ -| Documentation: Paul Jaquays | -| Dave Kirsch | -+----------------------------------------+ - -Outline: - -1. Introduction -2. Bug Reporting -3. Installing Q3Test -4. Running Q3Test. Operating Instructions -5. Known Issues - -================== -== Section 1. == -== INTRODUCTION == -================== - -This is the Linux version of the test. - -Before proceeding onward, please read the README.EULA file. This is -the End User License Agreement. It's the agreement between you and id -regarding this test. Read it. Understand that the acts of loading or -running the software, or placing it on your computer hard drive, RAM, -or other storage, you are agreeing to be bound by the terms of the End -User License Agreement. So it's best to know what you are agreeing to. - -The operating instructions for the test are included in the -separate "README.Q3Test" file. For the most part, the game functions -are the same across all platforms. Differences will be noted when necessary. - -+----------------+ -| THIS IS A TEST | -+----------------+ - -We want to set the record straight from the outset. This is neither a -demo nor an ALPHA version of the final game and should not be expected -to behave as such. Q3Test is a test of Quake3: Arena's network technology -and graphics compatibility. While many of the game features that you will -see in this test are in a highly polished state, do not confuse this with -being anything other than what it is intended to be: a test. By running -this test openly on the Internet and on a multitude of local networks, -we hope to expose problems that could not otherwise be discovered on the -limited number of in-house systems and computer. That's why we need your -assistance for this test. - -Furthermore, it is anticipated that there may be revisions and additions -made to the test that will make it incompatible with earlier versions. - -+---------------------+ -| SYSTEM REQUIREMENTS | -+---------------------+ - -There is no software-only version of the game. If your computer is not -hardware accelerated with a game compatible graphics card, you will NOT be -able to run Q3Test. Currently, 3DFX based cards are the only -tested compatible cards. If your computer does not meet the -minimum requirements, you are unlikely to be able to run a satisfactory -game experience. - -A glibc compatible Linux installation is required. An easy to determine -if you have glibc support is to type this: - - ls -l /lib/libc* - -If you get a report of libc6 (you may also have libc5), you have a -glibc based system. - -The Linux version requires a supported hardware 3D acceleration card. The -following are currently supported: - - o 3Dfx Voodoo Graphics based cards - o 3Dfx Voodoo2 based cards - -Other cards of similar make and model may work, but are not supported. - -Other X11 OpenGL libraries may work with a supported hardware -accelerator, but have not been extensively tested. Performance on -untested OpenGL configurations may not produce acceptable game -speed. - -For 3Dfx based products, Linux Q3Test is distributed with a version of Mesa -3-D specifically compiled for Voodoo support. You must have 3Dfx Linux Glide -drivers installed however. These drivers are available from: - - http://glide.xxedgexx.com/3DfxRPMS.html - -Make sure that you download and install the glibc versions of the drivers -(found at the bottom of the page). - -Mirrors for this site are can be found at: - - http://glide.mirrors.sonic.net - http://glide.samiam.org - -Please follow the installation instructions presented there for adding the -correct drivers for your 3D-acceleration card. Note that there are two ways -to install the 3DFX drivers-one with support for a /dev/3dfx device that -does not require root permissions in order to use the card. If you choose to -not use the /dev/3dfx method, you will have to run Q3Test as the root user. - -NOTE: Linux Q3Test will try to load "libGL.so" before using 3Dfx drivers. -This can cause problems if you have a software or third party OpenGL driver -installed. You can specifically target the included 3Dfx based Mesa driver -by using the following command line: - - ./linuxquake3 +set r_glDriver libMesaVoodooGL.so.3.1 - -For 3DFX users, you may disable the vertical sync refresh. This can improve -proformance at the cost of some visual tearing of the image. Entering the -following command into your shell before running Q3Test will turn off -the vertical sync: - - export FX_GLIDE_SWAPINTERVAL=0 - -Then run Linux Q3Test from the same command line normally. - -+-----------+ -| X11 Setup | -+-----------+ - -Linux Q3Test requires X11 to run. There is no console-based version as in -previous id products such as GLQuake and Quake2. XFree86 version 3.2 or -later is required. - -There are two ways that mouse input is handled under XFree86: - - o By default, Q3Test will attempt to use DGA mouse handling. DGA - support features direct reading of the mouse motion and provides - more accurate control while playing the game. By default this - support is enabled, but can be disabled by adding "+set - in_dgamouse 0" to the command line at startup. - o The non-DGA method of mouse input uses pointer grabbing and warps - the pointer to the middle of the window on each mouse update. On - systems with a slow frame rate and a lot of mouse user input, the - motion can get "clipped" to the window boundaries. This method of - input is more compatible however. - -Q3Test uses the XFree86 VidModeExtension facilities if available to provide -fullscreen play. This does not apply to 3Dfx passthrough based cards, since -the passthrough cable takes over the video display upon activation anyway. - -When configuring your X11 server, make sure that you include lower -resolution modes such as 640x480 and 800x600. Q3Test will auto-switch to -these modes using the VidModeExtension if you select fullscreen from the -graphics options menu. If the lower resolution modes are not listed in the -XFree86 configuration file, Q3Test will be unable to switch to the desired -resolution for fullscreen play. - -+-------------------------+ -| Sound Support and Setup | -+-------------------------+ - -Q3Test uses the /dev/dsp sound device for sound support under Linux. This is -the default device provided by the sound drivers included with the Linux -kernel. Please note that at the time of this writing, PCI based sound cards -such as the SoundBlaster Live and Diamond Monster MX series were not -supported. They may be supported in the future. Check -http://www.opensound.com/ for support in the future. - -If you do not run Q3Test as root (recommended), you may need to make sure -the permissions for the /dev/dsp device are read and write by the user -running Q3Test. The cheap and easy way to make this happen is to do "chmod -o+rw /dev/dsp" as root. For the more security conscious, a special sound -group could be created and Q3Test could be made setgid to the sound group to -access the device. - -Q3Test uses mmap() to map the sound buffers on /dev/dsp directly in order to -provide responsive sound needs. Sound cards must be able to support this -feature in order to work. SoundBlaster 16, AWE32 and AWE64 cards are known -to work. - -+----------------------+ -| WHAT'S IN THIS TEST? | -+----------------------+ - -We have included three maps with this test version of Quake3: Arena. They -are q3test1, q3test2, and q3tourney. - -q3test1 for 4-8 players on Internet or LAN play Best with 6 players -q3test2 for 3-8 players Primarily for LAN play Best with 3 players -q3tourney is the tournament map - -=================== -== Section 2. == -== BUG REPORTING == -=================== - -What we would like from our testers are emails with descriptions of -problems that are encountered, particularly those involving video or -network bugs. Do NOT send reports to individual id employees. All bug -reports should go to the following e-mail address: - -q3feedback@idsoftware.com - -In your subject line, please describe the system the game is being played -on (Mac, Linux, Win32) and the type of problem you are reporting: video, -network, sound or game. Example Subject Line: "Mac/video problem" or -"Linux/network connection problem." - -In the body of your letter (no attached files please), briefly list and -describe the problems. Detailed descriptions of problems are good, but -remember that brevity is best. Please do NOT send screen shots unless -they are the ONLY way to show a problem. - -While we realize that you may have comments and suggestions regarding -specific game play features, please refrain from submitting such along -with bug reports. Comments on game play can be made on the official -Quake 3: Arena message board at: - -http://www.quake3arena.com - -======================== -== Section 3. == -== INSTALLING Q3TEST == -======================== - -After you have installed the needed hardware drivers for your 3D -acceleration and sound hardware, you need to install the Q3Test package. - -Q3Test is available as a Red Hat RPM file or as a tar file. To install the -RPM file, enter the following when logged in as the root user: - -rpm -Uvh q3test-1.00-glibc-1.i386.rpm - -The rpm installs the game and data files in /usr/local/games/q3test. - -[ Note: If you have not installed (or do not wish to install) the Linux -glide drivers, you may get an error message about not having libglide2x.so -installed. This can be ignored and installation can be forced by adding -the --nodeps option to the rpm command line as follows: -rpm --nodeps -Uvh q3test-1.00-glibc-1.i386.rpm ] - -If you are going to install the tar version, make a directory for -installation, untar the file as follows: - -tar xzvf q3test-1.00-glibc-i386.tar.gz - -This will untar the files into a q3test subdirectory under the current -directory. - -==================== -== Section 4. == -== RUNNING Q3TEST == -==================== - -It is recommended that you do not run Q3Test using the root account or with -root privileges. There are two exceptions to this: - - o If you are using a 3Dfx based accelerator card and do not install - the /dev/3dfx configuration option. (You will have to run as root - in order to access the card). - o If you do not have access to the /dev/dsp device and do not wish - to change the mode of the device so that non-root accounts can - access it. - -You will have to be running under X11 or have the DISPLAY variable pointed -to a OpenGL glX capable X Server. - -By default, Q3Test tries to find the following OpenGL libraries in this -order: - - o libGL.so.1 - o libMesaVoodooGL.so.3.1 - -You can override the library name by entering, "+set r_glDriver " -on the command line. This may be needed if you are using a non-standard set -up and have a different name for the OpenGL shared library. - -If everything proceeds successfully, you should have a Q3Test window on your -desktop with a menu displayed (3DFX owners will get a full screen view). If -you want to use full screen, go to the System Configuration, Graphics -Options, Fullscreen, change the value to Yes, and hit enter to apply it. - -If you intend to connect to the Internet to play Q3Test, make certain -that your net connection is open and working first. - -====================== -== Section 5. == -== KNOWN ISSUES == -====================== - -Q. My mouse is erratic. My player is constantly looking up or down and -I can't seem to move him. - -A. This happens with two issues. Some versions of XFree86 have a bug in -DGA mouse handling that confuses Q3Test. You can try turning off DGA mouse -support by entering "+set in_dgamouse 0" on the command line when you -start Q3Test. This problem can also occur after a restart of the video -system (such as after a graphic setting change). This is because some -sort of event occurred to jam up the mouse. Restarting the video system -another time and not moving the mouse during the restart should clear it. - - -Q. When I do a video restart (for example, selecting Apply in the Graphics -Options menu), Q3Test exits with a Sig11. - -A. This is a driver related problem. -On 3DFX hardware that is using the /dev/3dfx device and you are NOT running -as root, it seems that the restart doesn't clear some sort of permission. -Running Q3Test as root will fix this problem. - - -Q. Performance is so slow I can't play! The frame rate looks like one -frame per second! - -A. Most of the current drivers for Linux do not support hardware -acceleration at any bit depth other than 15 or 16 bit color. Make sure -that you specify 16 bit color when you run your X11 Server, such as: - - startx -- -bpp 16 - - -Q. I have a Voodoo3. When I start the game, I send up at a low resolution -version of my desktop. - -A. The current Voodoo3 X11 Servers have problems with DGA Mouse support. -This is a known driver issue and will be fixed in newer revisions of the -Voodoo3 X11 Server. Run the game with the following to disable it: - ./linuxquake3 +set in_dgamouse 0 - - -Q. I'm running Gnome with Englightenment and sound doesn't work. - -A. If you are using the Enlightenment Sound Daemon (esd), it will not release -the sound hardware for Quake3 Test's usage. You can disable it before running -the test as follows: - esdctl off # turn it off - start q3test the normal way - esdctl on # turn it back on - - -Q. I try to run Q3Test, but sound doesn't work. The console says "Can't -open /dev/dsp. /dev/dsp: Can't allocate memory." - -A. This can happen if the vmware kernel modules are loaded. You can unload -them by typing when logged as root: - /etc/rc.d/init.d/vmware stop -Assuming you are using a RedHat system. - - -Q. I was playing Q3Test and suddenly it quit and reported a signal error. - -A. This is probably a bug. Please report it. - diff --git a/docs/README.Q3Test b/docs/README.Q3Test deleted file mode 100644 index 65ddef2711..0000000000 --- a/docs/README.Q3Test +++ /dev/null @@ -1,306 +0,0 @@ -+----------------------------------------+ -| Q3Test | -| The Official Quake 3: Arena TEST | -| Operating Instructions Readme | -| Revision 2.1 | -| Released Friday July 16th, 1999 | -| Copyright (C) 1999 id Software, inc. | -+----------------------------------------+ -| Documentation: Paul Jaquays | -+----------------------------------------+ - -This game is not yet rated by the ESRB. It contains animated -violence and blood. A rating for mature audiences 17+ is -anticipated. - -1. Introduction -2. Operating Instructions -3. Status Readouts -4. Player Actions -5. The Arena Environment -6. The Game Console -7. Problem Icons - -================== -== Section 1. == -== INTRODUCTION == -================== - - These instructions for game play should work with the versions of the game that are targeted at different platforms. - - Before proceeding onward, click on the EULA_Readme file icon. This is the End User License Agreement. It's the agreement between you and id regarding this test. Read it. Understand that the acts of loading or running the software, or placing it on your computer hard drive, RAM, or other storage, you are agreeing to be bound by the terms of the End User License Agreement. So it's best to know what you are agreeing to. - - If you agree to the conditions of the End User License Agreement, install the game on your computer's hard drive. - If you are using the Win32 version, open the readme file included for GLSetup. This application will load the most recent versions of the GL drivers needed to play Quake3: Arena. - - The platform-specific instructions for the test are included in a separate Readme file. Refer to the appropriate Readme for your hardware. - -+----------------+ -| THIS IS A TEST | -+----------------+ - We want to set the record straight from the outset. This is neither a demo nor an ALPHA version of the final game and should not be expected to behave as such. Q3Test is a test of Quake3: Arena's network technology and graphics compatibility. While many of the game features that you will see in this test are in a highly polished state, do not confuse this with being anything other than what it is intended to be: a test. By running this test openly on the Internet and on a multitude of local networks, we hope to expose problems that could not otherwise be discovered on the limited number of in-house systems and computers we have available. That's why we need your assistance for this test. - - Furthermore, it is anticipated that there may be ongoing revisions and additions made to the test that will make it incompatible with earlier versions. - -============================ -== Section 2. == -== OPERATING INSTRUCTIONS == -============================ - - When you start Q3Test, the game does not automatically load a map. Instead it displays the Main Menu screen. At this point (or at any time during the game) you may adjust and customize the video and audio settings on your computer, change details regarding your game character, and if desired, change the default controls to ones more to your liking. - -At any time during the game, press the Escape key to bring up the Main menu and superimpose it over the game screen. Use the up and down arrow keys to navigate the menu, and press the Enter key to select a function. Press Escape to return to the main level menu (and set any selected choices). Each Main menu function brings up a list of secondary menu items. If you have problems using the secondary menu selections, please refer to the message banner at the bottom of the screen for technical details. - -If a menu selection appears in gray, you cannot select or modify it. Choosing some options in the CONTROL CUSTOMIZATION and GRAPHICS OPTIONS menus will disallow other options. This is because they are either unnecessary (as is the case with MOUSE LOOK if you select the FREE LOOK option), or are not supported (as is the case with COLOR DEPTH if you chose the VOODOO OPENGL). - -+-----------+ -| MAIN MENU | -+-----------+ -The first three Main Menu options, SEARCH FOR LAN GAME, CONNECT TO NETWORK GAME and START NETWORK GAME are only available if the player is not currently connected to an ongoing game. - -SEARCH FOR LAN GAME: -If your computer is on a Local Area Network (LAN), this will show any currently active Q3Test servers on the network, along with the number of players currently in the game and the maximum number of players that can be in that game. - -Example: idserver q3test1 1/8 - -This indicates that the server on the LAN called "idserver" is currently playing the map "q3test1" and has one player in it out of the possible 8 that can be in the game at one time. - -Use the up/down arrow keys to select a server and hit ENTER to command your computer to connect to that game. - -CONNECT TO NETWORK GAME: - SERVER: If your computer is connected to the Internet, you can enter the IP address of a server and hit ENTER to attempt to make a connection to that server. For server id's Q3Test server listings, go to http://www.quake3arena.com or check with your favorite 3D gaming web sites for other servers. - RATE: Set the type of network connection you are using. Choices are: "<=28.8K", "33.6K", "56K", "ISDN", and "LAN/cable/xDSL". - -START NETWORK GAME: -To start a network game, whether on a LAN or over the Internet, select this option. The secondary menu screen has the following options: - -START: Launches the game using the parameters currently set on this menu. -MAP: This gives access to the list of maps located in the Quake3/Baseq3/Maps directory/folder. For the purposes of this test, there are only two maps. Use the left and right arrow keys to toggle between the two maps. -DEDICATED: This is either "no", "dedicated LAN," or "dedicated Internet." -A dedicated server (set to YES) runs the game, but does not display a graphic version of the game on the screen of the computer running the game. The default value for this is no. This means that you are running the server and participating as a player at the same time. -TIME LIMIT: entering a non-zero number here sets a time limit (in minutes) for the game duration. If the game has not ended because a frag limit has been set, then it will end when time runs out. -FRAG LIMIT: Entering a non-zero number here sets the number of "frags" or "kills" needed to win the game. If the game has not ended because a time limit has been set, then it will end when one player in the game reaches this number of frags. -MAX PLAYERS: This is the total number of players that may be in the game at any one time. -HOSTNAME: This is the name of the server. In the LAN example above, the hostname is "idserver." - -CUSTOMIZE PLAYER: -Allows the player to change information about his in-game persona. - -NAME: This is the player's name as it will appear on-screen during the game. It may be up to 33 characters long. - -SKIN: Visor is the only model in the test. Two skins (red and blue) are available for the model. Use the left and right arrow keys to select one. - -EFFECTS COLOR: You can choose an identifying color for your rail gun projectile trails. Use the left and right arrow keys to select a color. - -HANDICAP: Better players can choose to handicap themselves to balance a match against players of less skill by limiting the maximum amount of health and armor that they can have during the game. Use the left and right arrows to select a value from 25 to 100 points. Certain items and power ups will temporarily raise this value, but will then count down to the preset value. The default is 100. - -CUSTOMIZE CONTROLS: -Allows the player to change the assignment of game controls to other keyboard and mouse buttons. When you visit this menu for the first time, the default assignments for all controls are shown. To change an assignment, use the up/down arrow keys to select a game function. Press ENTER to activate the change process. Press the keyboard key or mouse input that you want to use for that function. Up to two keys/buttons may be assigned to each game function in this manner by repeating the process. If you inadvertently use a key assigned to another function, three question marks ("???") appear next to the function that previously used that key. - -ALWAYS RUN: setting this to YES causes your player to move faster, but make more noise as he moves. The RUN/WALK key allows the player to switch between fast/noisy and slow/silent movement modes. -FREELOOK: If YES, then you may look freely in all directions as if you were moving only your head by moving the mouse around. If this is Set to NO you must bind a key to mouse look. -INVERT MOUSE: Selecting YES inverts the up and down view movement directions. -MOUSE SPEED: This is set on the menu with a slide control. The faster your mouse speed, the greater the on-screen response to small movements of the mouse. Mouse speed can also be adjusted from the console. Bring the console down and type in "sensitivity". The game will respond by printing "sensitivity" is: "__" (the blank indicating the number value currently assigned to mouse speed) default is "5". Use the up arrow key to display sensitivity on the console again, enter a different number value and hit enter. Higher numbers are more sensitive. Lower numbers are less sensitive. - -SYSTEM CONFIGURATION: -EFFECTS VOLUME: Use the slide control to adjust game sound playback volume to your liking. -SOUND QUALITY: Select either Low (16 bit sound running at 11 megahertz) or High (32 bit sound running at 22 megahertz). -BRIGHTNESS: First, try running the game with the brightness set to 1.0 (the default level used by the designer when making the map). If the map is too dark to see in dimly lighted areas or too light in sunny areas, use this slide control to compensate for differences in the way some monitors and video cards draw the game world. Remember that the arenas are supposed to be dark and foreboding places. - -GRAPHICS OPTIONS: -This drops you down into another menu layer. The controls here are designed to help you optimize graphics and or/enhance the game's playability on your system. When you are satisfied with your selections, you must move the cursor to the bottom of the screen to the APPLY option to activate them. Pressing Escape to return to the SYSTEM CONFIGURATION MENU does not activate changes in the graphics settings. Changing anything on this menu will cause the game to restart the video. - -GRAPHICS MODE: This is a global setting for the display of the game's screen graphics. The settings are HIGH QUALITY, NORMAL, FAST, FASTEST, and CUSTOM. Selecting one of these choices affects most of the other settings on this page. If you make any adjustments to other settings on this page, the graphics mode changes to CUSTOM. -DRIVER: Consult the platform specific readme for the drivers that will work with your platform. -VIDEO MODE: This is the screen resolution size. Smaller resolutions can improve performance speed on slower machines. -COLOR DEPTH: Determines whether you are using 16-bit textures or 32-bit textures. Default means you run with the color depth currently set for your computer's desktop. -FULLSCREEN: A YES selection allows you to choose to run with the test filling the entire screen. A NO selection will run the game in a window. If run in a window, COLOR DEPTH is disabled because you are limited to whatever has been selected for the desktop. -LIGHTING: Allows you to chose either a LIGHTMAP or VERTEX lighting. Using the LIGHTMAP is recommended for best appearance. VERTEX lighting may improve game performance, but at a cost to appearance. -GEOMETRIC DETAIL: Lets you adjust the number subdivisions used to define curves in the arena on both world geometry and items, weapons and characters. HIGH is the normal setting. LOW greatly reduces curve complexity. -SCREEN SIZE: The slide control changes the amount of screen area devoted to display of the game. Reducing screen size can improve performance. -TEXTURE DETAIL: This sliding control allows you to adjust the level of detail displayed. Unless you have an extremely fast computer, the normal setting gives the best balance of detail vs. game speed. -TEXTURE QUALITY: This determines whether you wish to use 32-bit textures, 16-bit textures, or compressed textures. Many of the game's special effects will appear at their best only when defined by 32-bit textures. -OPENGL EXTENSIONS: Allows you to enable or disable OPENGL extensions. -DRIVER INFORMATION: Brings up a display of information regarding the drivers currently operating in your machine. It is not interactive. Hit ESC to return to the previous menu. - - -PREFERENCES: Hitting ENTER here will drop you into another menu that allows you to adjust other game features. -CROSSHAIR: choose one of four options, none, cross, dot, or angle. -MARKS ON WALLS: Enable or Disable weapons scars and blood smears. Disabling this feature may improve performance. -DYNAMIC LIGHTS: Enable or Disable lights that move through the world (such as light generated by weapon projectile trails). Disabling this feature may improve performance. -LIGHT FLARES: Enable or DISABLE glowing light halos around lights. Disabling this feature may improve performance. -IDENTIFY TARGET: Enable or Disable the ability to see the name of your foe when you put your crosshair on him (does not function if target is in fog). -SKY: Set the sky for either HIGH SPEED or HIGH QUALITY. - -RESET DEFAULTS: Restore all game settings and controls to their default value by reloading the default configuration. - -APPLY: You must select this and hit ENTER to lock in your choices. Doing so will restart the game video. - -SCREENSHOT: -Makes a targa file screen shot of what is currently in view on the screen. Look for it in the Screenshot folder within your Quake 3/Baseq3/screenshots folder. - -LEAVE ARENA: -This disconnects you from the arena you are currently playing, but does not quit you out of the game. From here you can connect to other servers or start your own. You can also leave an arena by typing "disconnect" on the command line of the console. - -QUIT GAME: -Returns you to the desktop. - - -====================== -== Section 6. == -== STATUS READOUTS == -====================== - - Your player status is shown as numbers and icons floating in your view at the bottom of the screen. There is an indicator for your ammo (far left) including the type of ammo currently in use, current health (left-center), your character portrait (center), armor (center-right), and Frag Count (far right). The digital timer in the upper right shows the amount of time you have been in this arena. When you have a one-use item in your inventory (such as the personal teleporter), its icon will appear on the right side of your display. When you are fragged, the character portrait and name of the foe who killed you appears in the upper right corner of the display. When you change weapons, icons representing the ammo of the weapons in your inventory will appear above your character portrait. If you have a weapon, but no ammunition for it, a negation symbol will be superimposed over the ammo icon. - -+----------------------------+ -| INTERPRETING THE LAGOMETER | -+----------------------------+ - The Lagometer is the graph in the lower right corner of the status display. It is a test function and not a part of regular game play. The upper graph (blue/yellow) slides one pixel for every rendered frame. Blue lines below the baseline mean that the frame is interpolating between two valid snapshots. Yellow lines above the baseline mean the frame is extrapolating beyond the latest valid time. The length of the line is proportional to the time. -The lower graph (green/yellow/red) slides one pixel for every received snapshot. By default, snapshots come 20 times a second, so if you are running >20 fps, the top graph will move faster, and vice versa. A red bar means the snapshot was dropped by the network. Green and yellow bars are properly received snapshots, with the height of the bar proportional to the ping. A yellow bar indicates that the previous snapshot was intentionally suppressed to stay under the rate limit. -The upper graph indicates the consistency of your connection. Ideally, you should always have blue bars of only a pixel or two in height. If you are commonly getting big triangles of yellow on the graph, your connection is inconsistent. - In a heavy firefight, it is normal for modem players to see yellow bars in the bottom graph, which should return to green when the action quiets down. If you are getting several red bars visible, you may want to look for a server that drops less packets. - There are a few tuning variables for people trying to optimize their connection: The most important one is "rate", which is what the connection speed option in the menu sets. We are fairly conservative with the values we set for the given modem speeds: 2500 for 28.8, 3000 for 33, and 3500 for 56k. You may actually be connecting faster than that, and modem compression may be buying you something, so you might get a better play experience by increasing the values slightly. If you connect at 50000 bps, try a rate of 5000, etc. Quake 3 errs on the conservative side, because too low of a rate will only make the movement of other things in the world choppy, while too high of a rate can cause huge amounts of lag. - Note that the optimal rate will be somewhat lower than a rate for QW or Q2, because Quake 3 now includes the UDP packet header length in the bandwidth estimate. You can ask for a different number of snapshots by changing the "snaps" variable, but there isn't a lot of benefit to that. Dedicated servers run at 40hz, so stick to divisors of that: 40, 20 (default), 10. A "snaps" of 40 will usually just cause you to hit your rate limit a lot faster. It may be useful for tuning rate, if nothing else. - You can adjust the local timing point with "cg_timenudge ", which effectively adds local lag to try to make sure you interpolate instead of extrapolate. If you really want to play on a server that is dropping a ton of packets, a timenudge of 100 or so might make the game smoother. - -===================== -== Section 7. == -== PLAYER ACTIONS == -===================== - - The descriptions below are based on the preset default configurations for the game controls. If you have played first person shooting games previously (such as Quake or Quake 2), you may want to reconfigure the controls to match your preferences. - -+----------+ -| ACTIONS | -+----------+ -WALKING: Use the four arrow keys or the mouse to walk around. To walk steadily forward, hold down the "forward" key (the up arrow or center button on a 3-button mouse). Turn left or right with the left or right arrow keys, or by sliding your mouse in the desired direction. - -RUNNING: To run, simply hold down the left Shift key to increase your -Speed (unless you have selected "Always Run", in which case it reverts you to a walk. If you prefer to always run during the game, open the Main menu, then the Customize Controls menu, and select Always Run. - -SHOOTING: Tap the Ctrl key or the left mouse button to fire. Hold the -fire key down to keep firing. - -LOOKING UP AND DOWN: The letters A and Z allow you to look up and down, -respectively. Start walking forward and your line of vision will -automatically readjust to the center position. You may also choose to -select Free Look under the Controls menu which will allow you to move the -mouse around as if it was your head movement. - -SWIMMING: While underwater, aim yourself in the direction you wish to go -and press the forward key to go in that direction. Unfortunately, as in -real life, you may lose your bearings while underwater. Use the jump key, -(default is the Space Bar), to kick straight up towards the surface. Once on -the surface, tread water by holding down the jump key. To get out of the -drink, swim toward the shore and you can either jump up onto the land or -walk straight out if it is shallow enough. There is always a way out of -water, but you may have to submerge even deeper in order to find it. - -CROUCHING: Press and hold down the C key to duck and move forward to "duck walk." When you release the C key, you will return to an upright position. It is also possible to avoid rockets in this manner. - -JUMPING: Tap the space bar to jump. You jump farther if you're moving -forward at the time. - -STRAFING: Hold down the ALT key and the left or right arrow key and you will side-step in that particular direction. This is perfect for avoiding incoming weapon attacks. - -PICKING UP OBJECTS: To pick up items, weapons, and power-ups, simply walk -over them. The weapon cross-hair will pulse larger briefly to indicate you have acquired a new weapon or supply. If you are unable to pick something up, it means you already have the maximum amount possible for that object. - -TALKING: To communicate with other players, press the T key -and type in your message. Press Enter when finished and your words will -appear at the top of the screen. You can also enter communications on the command line of the console. - -ATTACKING: Point your weapon at an opponent and press the fire button. Default fire keys are the left mouse and the control key). If a weapon runs out of ammo, it switches to the next available weapon with ammo the next time you fire it. If you have no ammo at all, you fight with the gauntlet. - -+--------+ -| DYING: | -+--------+ - When you die, the weapon you were using (except for the gauntlet and the machine gun), and any active power ups drop where you died. Armor, ammo and one-use items like the teleporter are lost. To respawn into the game, press the fire key. When you re-enter the game you are once again armed with only your starting equipment. - -=========================== -== Section 8. == -== THE ARENA ENVIRONMENT == -=========================== - -+-----------------------+ -| RAPID TRANSIT DEVICES | -+-----------------------+ -TELEPORTERS: These devices instantaneously move you to a pre-selected destination. - -PORTALS: These are devices that generate holes in space through which you can see your ultimate destination and move to it like walking through a doorway. - -JUMP PADS: Jump pads throw you upwards to land on higher portions of the arena. You have some "air" control over your final landing point. - -ACCELERATION PADS: Acceleration pads turn you into a human cannon ball, launching you to distant locations in the arena. As with the jump pads, you have some "air" control over your final landing point. - -+-----------------------+ -| ENVIRONMENTAL HAZARDS | -+-----------------------+ -LAVA: Walking on lava is not instantly fatal, but even with good armor protection, it can be a relatively quick (and noisy) doom. - -THE VOID: Falling off into the infinite blackness of the void is a near inescapable death. - -+--------------+ -| TEST ARSENAL | -+--------------+ -MACHINE GUN: This is your default weapon. It's an instant hit attack and reasonably accurate even at long range. It uses bullets. - -GAUNTLET: This is either your weapon of last resort when you're out of ammo or a cool tool to humiliate other players. When it hits, it does damage and knocks a foe back. It does not require ammunition, but you have to be in direct contact with a foe and activating (firing) it to cause injury and knockback. - -SHOTGUN: This uses shells for ammunition. The spread of the shotgun blast makes it deadly in close combat, but not the best choice for long-range attacks. - -ROCKET LAUNCHER: The rocket launcher delivers heavy fire power to your target, but travels slower compared to other attacks. Be careful when you use this weapon in close combat. - -PLASMA GUN: Powered by Energy cells, this rapid-fire weapon delivers deadly gouts of glowing energy quickly and accurately. - -RAIL GUN: The Rail Gun fires depleted uranium slugs at super high velocities. It hits instantly and can pass through the bodies of multiple opponents. But be warned, it recharges slowly and can be a liability in close combat. Take note of the distinctive trail of atmospheric disturbance -caused by the projectile. The color of the rail gun's trail can be changed under the CUSTOMIZE PLAYER menu on the EFFECTS COLOR line. - -LIGHTNING GUN: Zap them! - -+------------------+ -| COMBAT SUPPLIES: | -+------------------+ -Pick up these helpful items whenever possible. Some items take effect when -picked up, others you must activate during play. - -AMMO: With the exception of the gauntlet, each weapon has a corresponding ammo type. The color of the ammo boxes corresponds with the color of the graphic weapon icons displayed briefly in your heads up display. Each ammo type has a maximum you can carry. - -ARMOR: There are three armor types: Green armor shards, yellow combat armor and red body armor. Collecting them increases your armor protection. The red armor and the green armor shards can increase your total armor protection above the maximum for short duration. The points "decay" back to the normal maximum value. - -HEALTH: There are three types of standard health kits: small (green), medium (yellow) and large (red) encased in crystalline shells. The green health can increase your total health value above the maximum. Like armor, it "decays" back to your maximum possible health value. - -QUAD DAMAGE: The quad temporarily multiplies all your weapon's strengths. - -MEGA HEALTH: This blue health power up provides a temporary but significant boost to your health, taking it above your maximum level. Like armor, it "decays" back to your maximum possible health value. - -PERSONAL TELEPORTER: Grab this single-use power up and use it to escape from dangerous situations. Activating it immediately teleports you to one of the arena's spawn spots. - -======================= -== Section 9. == -== THE GAME CONSOLE == -======================= - - The game console (or just the console) is a pull down window shade that shows recent game information, including the text of conversations and recently executed game commands. The bottom line of the console is the command line. While playing Q3test, you can enter into console mode by pressing the tilde (~) key and exit by pressing it again. The console is where you enter all the commands to change the game state. - - For example, one console command is "map " which will load a map -and start it up. Starting up a map actually starts a local Server and a Client. For the purposes of this test, most of the console commands will be executed to optimize graphics. Pressing the up and down arrows in the console will change to the last command entered. You can backspace over the command and enter new values if you'd like. There is also a command-completion function. Type in the first few letters of a command. By pressing the TAB key, you can have the console automatically finish the name of the command for you. - - When you are in console mode (or when you have selected to "talk" by typing in words to appear on the screen), a blue "voice balloon" will appear over your head. Common game courtesy is to NOT shoot players who are in this mode. - -======================= -== Section 10. == -== PROBLEM ICONS == -======================= - -Q3Test has a Problem Icon that you may see on your screen from time to time. When you are disconnected from a Quake Server or the network packet flow is disturbed, you will see a Network Disconnect icon above the spot where your frag count is displayed. Other players will see it displayed over your character's head (similar to the way the talk balloon is displayed). If you are not immediately reconnected to the server, you will need to disconnect (leave arena) and attempt to reconnect with the server by either using the menu commands or by typing "connect" in the console command line. - NOTE: Courteous players will refrain from getting cheap points by fragging lagged out opponents. - -======================= -== Section 11. == -== MESSAGE OF THE DAY == -======================= - -When Quake 3 Arena starts a map up, it sends the GL_RENDERER string to the Message Of The Day server at id. This responds back with a message of the day to the client. If you wish to switch this option off, set CL_MOTD to 0 (+set CL_MOTD 0 from the command line). - diff --git a/docs/filter.txt b/docs/filter.txt deleted file mode 100644 index a8033fc896..0000000000 --- a/docs/filter.txt +++ /dev/null @@ -1,128 +0,0 @@ -================================================= - -This section describes format of userinfo filter files pointed by \sv_filter server cvar. - -================================================= - -Common format and expression syntax: - - [op] [ { key [op] { [ ... ] } } ] - -Where: - - - arbitrary userinfo key to compare, special built-in keys: - 'drop' - action key, can be followed by ban reason string, no further ops or nested keys is allowed - 'date' - represents current date in "YYYY-MM-DD HH:mm" format - 'fname' - filtered 'name' userinfo key (without color sequences) - -[op] - optional operator, can be '==', '!=', '>', '>=', '<', '<=', '*' (string pattern match) - default operator is '==' (equal) and '<' (less) for 'date' key - - - integer or string value to compare with the - default is integer comparison, if you want to force string comparison - use double-quoted values, i.e. "0" instead of 0 - -Examples: - - ip "127.0.0.1" { - name * "Unnamed*" { - drop "You have bad name" - } - } - - cl_guid "" { // disallow empty guids - drop - } - -One-line format (without brackets) is also acceptable: - - ip "127.0.0.1" name * "Unnamed*" drop "You have bad name" - cl_guid "" drop - -Multiple keys/comparisons inside single scope: - - ip "127.0.0.1" { - name * "*^0*" { - drop "Black color is not allowed on this server" - } - name "SomeBadGuy" { - drop "Bad Guy." - } - } - -Date key usage example: - - ip "192.168.11.12" { - date "2019-06-01" { // hours:minutes can be omitted for this particular case - drop "Banned till summer." - } - } - -If there is "date" keys which may expire - engine will perform regular checks and rewrite filter file contents to clear expired ban entries - -You can also use '$' prefix in to dereference any server-side cvar, for example: - - snaps < $sv_fps { - drop "raize your \snaps" - } - -Example of custom password cvar filtering: - - xxpassword != "12345678" { - drop "sorry, this is a private server" - } - - I.e. user must do "\setu xxpassword 12345678" to be able to connect - - -================================================= - -This section describes available server-side options and commands - -================================================= - - -------------------------------------------------- -\sv_filter - cvar that point on filter file, if it is "" then filtering will be disabled -------------------------------------------------- - - -------------------------------------------------- -\filter [key1] [key2] ... [keyN] [date +| ] [reason ] -------------------------------------------------- - - this command will kick and ban player with specified - specified key values will be extracted from his current userinfo and used to construct filter command, acceptable by filter engine - if no keys specified - "ip" key will be used by default - default duration unit used with '+' is minutes, additional h(ours), d(ays), w(eeks), m(onths) suffixes can also be specified - -Examples: - \filter 0 name cl_guid - - ban client 0 by his "name" and "cl_guid" userinfo fields - - \filter 0 reason "bad guy." - - ban client by his "ip" address field with a reason "bad guy." - - \filter 0 ip name date +1d - - ban client for 1 day by his ip and name - - -------------------------------------------------- -\filtercmd -------------------------------------------------- - - pass manually constructed filter string (described in previous section) to the engine - -Examples: - - \filtercmd ip "127.0.0.1" name "name" drop "reason" - - \filtercmd name * "*^0*" drop "black color is not allowed" - - scopes are acceptable as well: - - \filtercmd name * "*^0*" { ip != "127.0.0.1" { drop "black color is not allowed" } } - - diff --git a/docs/firewall/fw-openwrt.txt b/docs/firewall/fw-openwrt.txt deleted file mode 100644 index ec84c600b1..0000000000 --- a/docs/firewall/fw-openwrt.txt +++ /dev/null @@ -1,14 +0,0 @@ -Following custom firewall rule can be added in [Network] -> [Firewall] -> [Custom Rules]: - -iptables -A input_wan_rule -p udp --dport 27960 -m hashlimit --hashlimit-mode srcip --hashlimit-above 768/second --hashlimit-burst 128 --hashlimit-name q3server1 -j DROP - -Rate (--hashlimit-above) should be big enough to handle at least sv_maxclientsPerIP * cl_maxPackets * (cl_packetdup + 1) packets - -You may need to use other than input_wan_rule chains depending from your routing configuration - -LEDE/OpenWrt firmware MUST be built with following options: - -CONFIG_PACKAGE_iptables-mod-hashlimit=y - -CONFIG_PACKAGE_iptables-mod-u32=y (not required, but may be useful to inspect packet's contents) - diff --git a/docs/firewall/fw-q3host.sh b/docs/firewall/fw-q3host.sh deleted file mode 100644 index 1b68d0eac5..0000000000 --- a/docs/firewall/fw-q3host.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -# this can be called from another script as ./q3hostfw - -NAME=${1:-LIMITER} # you need to specify unique table name for each port - -PORT=${2:-27960} # and unique server port as well - -RATE=768/second -BURST=128 - -# flush INPUT table: -#iptables -F INPUT - -# insert our rule at the beginning of the INPUT chain: -iptables -I INPUT \ - -p udp --dport $PORT -m hashlimit \ - --hashlimit-mode srcip \ - --hashlimit-above $RATE \ - --hashlimit-burst $BURST \ - --hashlimit-name $NAME \ - -j DROP diff --git a/docs/q3url_add.cmd b/docs/q3url_add.cmd deleted file mode 100644 index ec6df6f348..0000000000 --- a/docs/q3url_add.cmd +++ /dev/null @@ -1,15 +0,0 @@ -@echo off -set CWD=%~dp0 -set CWD=%CWD:~0,-2% -set CWD=%CWD:\=\\% -set F=%TEMP%\q3a.reg -set RPATH=HKEY_CURRENT_USER\Software\Classes\q3a -rem set RPATH=HKEY_CLASSES_ROOT\q3a -echo REGEDIT4 > %F% -echo [%RPATH%] >> %F% -echo @="URL:Q3A (Quake III Arena)" >> %F% -echo "URL Protocol"="" >> %F% -echo [%RPATH%\shell\open\command] >> %F% -echo @="\"%CWD%\\quake3e.exe\" +set fs_basepath \"%CWD%\" +set fs_homepath \"%CWD%\" +connect \"%%1\"" >> %F% -regedit -s %F% -del %F% \ No newline at end of file diff --git a/docs/q3url_rem.cmd b/docs/q3url_rem.cmd deleted file mode 100644 index 26de23d779..0000000000 --- a/docs/q3url_rem.cmd +++ /dev/null @@ -1,7 +0,0 @@ -@echo off -set F=%TEMP%\q3a.reg -echo REGEDIT4 > %F% -rem echo [-HKEY_CLASSES_ROOT\q3a] >> %F% -echo [-HKEY_CURRENT_USER\Software\Classes\q3a] >> %F% -regedit -s %F% -del %F% \ No newline at end of file diff --git a/docs/quake3e-FAQ.txt b/docs/quake3e-FAQ.txt deleted file mode 100644 index af77be9b78..0000000000 --- a/docs/quake3e-FAQ.txt +++ /dev/null @@ -1,15 +0,0 @@ -Q: \r_mode doesn't work for fullscreen -A: dedicated cvar \r_modeFullscreen now is used for fullscreen, - set its value to "" if you want to use \r_mode again - -Q: what mouse mode is used for raw input? -A: \in_mouse 1 - -Q: cnq3' raw input feels different -A: try \in_lagged 1 - -Q: how to minimize/restore game window by ALT+X key, for example? -A: set \in_minimize "alt+x" ; in_restart - -Q: non-US/EN keyboard input is not working as before -A: \in_forceCharset 0 \ No newline at end of file diff --git a/docs/quake3e-changes.txt b/docs/quake3e-changes.txt deleted file mode 100644 index 6ac5cd5cc7..0000000000 --- a/docs/quake3e-changes.txt +++ /dev/null @@ -1,1293 +0,0 @@ -14-Oct-2025: -* Client: increase default \cl_maxpackets to 125 -* Client: search for modular renderers nearby main executable oly -* Server: reset \sv_maxclients modified flag after startup -* Server: improved gamestate acknowledge function -* Server: don't allow active clients to start downloads -* Win32: use GlobalMemoryStatusEx() on modern platforms for Sys_LowPhysicalMemory() -* Win32: try to minimize game window at break point, useful when debugging from full-screen crashes -* Win32: unregister exception handler to avoid recursive errors on exit() -* SDL: paste text on CMD-v for MacOS -* Sound: print messages about missing sounds in developer mode only -* FS: allow scanning external directories recursively via FS_MATCH_SUBDIRS flag, enabled for cfg and demo files completion -* FS: sort mod list, strip ending newlines in mod descriptions -* FS: fixed crash on directory traversal pattern match -* FS: reworked FS_LoadLibrary() to use predefined search paths only, not referencing current game dir anymore -* Makefile: disable unsafe FP optimizations for QVM modules (mostly for interpreter) to be IEEE754-compliant when handling NaNs -* QVM: reuse rounded up data segment space for extra pStack if possible -* Renderers: simplify tr.sinTable initialization -* Renderers: increase default geometric detail on characters and patches -* Renderers: implement \r_teleporterFlash cvar -* Renderers: correct 'tcMod transform' for indexed lightmaps with \r_mergeLightmaps enabled -* Renderers: fix grates on map 'tscabdm3' -* Renderers: reworked lighting stage detection to fix all known issues -* Renderers: added support for 'dlight' shader stage keyword to override stage used for dlight pass, available in .shaderx files -* OpenGL: perform alpha tests after vertex color multiplication in VBO shaders -* Vulkan: fix wrong semaphore state at buffer resize -* Vulkan: use dedicated descriptor layout for flare test pipeline to reduce generic pipeline layout size from 6 to 5 -* Vulkan: fix missing texture bound for \r_showNormals 1 -* Vulkan: handle glConfig.textureEnvAddAvailable as well, similar to OpenGL renderer -* Vulkan: enabled USE_BUFFER_CLEAR by default, optimized related code paths -* Vulkan: implemented (a sort of) \r_finish functionality -* Vulkan: check whenever vk_clear_color() can be used at all, avoid using it for \r_showImages -* Vulkan: separate swapchain image acquisition from fence wait -* Vulkan: do not mipmap images with 1-pixel width or height -* Vulkan: don't do double image upload on scratch image creation, misc.code cleanup -* Vulkan: handle VK_ERROR_OUT_OF_DATE_KHR more properly during swapchain acquisition -* Vulkan: added VK_PRESENT_MODE_FIFO_LATEST_READY_EXT definition -* Vulkan: do not print presentation info at swapchain restart -* Vulkan: use dedicated rendering finished semaphore for each swapchain image -* Vulkan: use larger staging/geometry buffers by default if possible - -14-Oct-2024: -* Common: improved 'wait' command handling, now it will wait exact amount of client/server frames -* Common: allow src and dest buffers to be overlapped in Q_strncpy() for QVM compatibility reasons -* Common: Use nanosleep(2) instead of usleep(3) - usleep(3) was declared obsolete in POSIX.1-2001 and removed in POSIX.1-2008 and nanosleep(2) was recommended to be used instead. -* Server: cache sv_maxclients value to avoid potential crashes caused by VMs changing it at runtime -* Server: save latched sv_pure state to dedicated variable -* Server: suppress false hitch warning during map load -* Server: reworked/optimized gamestate retransmission/acknowledgment -* Server: don't change serverid during map restart -* Server: don't spawn loading clients during map restart -* Server: fix server resource leaks during client reconnect -* Client: rewrote CL_WritePacket() to allow proper packet duplication - which was intended by multiple function calls before -* Client: Strip cl_aviPipeFormat -* Win32: report actual color bits and correct PFD count -* X11: request alpha bits for >=24 bit color profiles -* Docs: Create quake3e.md, update quake3e.htm -* Vulkan: increase MAX_IMAGE_CHUNKS from 48 to 56 -* Vulkan: added missing texture mode setup in GL_SetDefaultState() -* Vulkan: disabled r_ext_alpha_to_coverage for now due to rendering artifacts on beyond4-wfa map -* Vulkan: do not set transient flag for depth/stencil attachment when bloom (and thus - post-bloom pass) is enabled -* Vulkan: fix screenmap image layout transitions -* Vulkan: re-create swapchain on VK_SUBOPTIMAL_KHR as well -* Vulkan: improve flare visibility test code -* Vulkan: fixed various image layout transition synchronization issues -* Vulkan: applied fixes to some "Best Practices" validation layer errors -* Vulkan: add \r_bloom_threshold_mode and \r_bloom_modulate cvars, similar to OpenGL renderer -* OpenGL: allow all static tcGens/tcMods for VBO/environment mapping (assuming that we have all tcMod corrections applied before) -* Renderers: use glConfig.stencilBits instead of dereferencing \r_stencilbits cvar -* Renderers: apply lightmap texcoord correction only if lightmap is actually set -* Renderers: apply additional lightmap texcoord corrections when needed -* Renderers: do not merge single lightmap -* Filesystem: allow multiple basegames in fs_basegame cvar separated by '/' -* Filesystem: reset fs_basegame cvar to last separated item -* Makefile: fix grep warnings in macOS builds -* macOS: app will search for pk3 inside and next to the app bundle -* Use SDL_WINDOW_FULLSCREEN_DESKTOP on macOS - -14-Oct-2023: -* Added many CVAR descriptions -* Added "\vid_restart fast" - to perform fast \vid_restart in current gfx context -* x86: print CPU brand string if available -* Fixed spurious bound action on +vstr key releases -* Fix stuck binds in some cases -* misc: try to apply map-depending configuration from cvar \cl_mapConfig_\ cvars -* com_affinityMask: allow handy binding of P/E cores on Intel's x86, added support for hexadecimal notation and '+'/'-' operators -* Sound: added ogg-vorbis support -* Sound: Use more precise conversion for fp32le sound buffers -* Sound: re-enable sound-mixing asm in MSVC solutions -* Renderers: Fix jumppads shaders on q3wcp14 -* Renderers: fix incorrect ovebright bits displayed at startup -* Renderers: Fix clamp to edge detection -* Renderers: allow using *lightmap images in shaders -* Renderers: fix potential crash in FixRenderCommandList() -* Renderers: make sure that merged lighmaps fits well into reported max. texture dimensions -* Renderers: make sure that we always configure dst blend bits -* Renderers: fix bloom latch state when switching back to opengl from vulkan -* Renderers: use more reasonable default backend color -* Also fix \\screenshot levelshot taking not factoring scaled capture screen sizes. -* Vulkan: fix dlight regression on q3dm1 -* Vulkan: added some color-input optimized shaders, should improve FPS by up to 10% in bandwidth-limited cases (iGPUs) -* Vulkan: rebind indexes after legacy dlight pass before fog pass -* Vulkan: skip color/tex gen only if previous stage was not optimized and really calculated color/tex data -* Vulkan: fix depthFragment shaders in fog, allow fog-collapse for non-world shaders -* Vulkan: allow more color optimizations, with and without fog -* Vulkan: added entity-color optimization for single-stage shaders -* Added support for ppc64/ppc64le platforms -* Fix buffer overflow with fdir cmd and file argument command completion -* Added \cl_drawRecording cvar to disable or make "RECORDING" demo message shorter -* github-actions: run linux builds on Ubuntu-20.04 for binary compatibility reason -* Win32: fixed crash on win11-x64/msvc during longjmp() -* Win32: fix potential null-pointer dereference in ExceptionFilter() -* Msg: check for error before checking value to avoid false-positive results -* Network: Use uint32_t as scope_id for ipv6 connections -* Server: fix formatting for some connection states in \status output -* Server: fix host player being dropped in TA SP -* cURL: updated prebuilt libraries and headers to version 8.4.0 -* cURL: increase maximum buffer size -* cURL: fix deprecated warnings on modern versions -* vm_x86: convert "add reg, 128" to "sub reg, -128" to use 1-byte immediate value -* Fix & backport recent joystick code from ioq3 -* Fix Info_RemoveKey() deleting only first key -* Fix info string trailing key issue -* Made rsqrt optimization hint really work -* common: try to init logfile cvar as early as possible -* Stop using acstime for logfile date/time -* Cleanup Makefile - -14-Oct-2022: -* preserve \cl_reconnectAgrs between online mod changes -* fixed nested cgame command execution -* renderers: avoid potential division-by-zero for AGEN_PORTAL -* CMake: numerous improvements -* Vulkan: updated SDK headers, applied potential fix for molten-vk compatibility -* server: do not enforce non-zero level times at startup, for mod compatibility -* SDL2: fix escape key not sending a char event -* Vulkan: fixed insufficient attachment pool size for extreme case (antialiasing + supersampling + hdr + bloom) -* Vulkan: fixed error at \snd_restart (REF_KEEP_WINDOW context) -* video-pipe: use full (pc) color space and do not enforce particular rate for output audio stream -* OpenGL: setup TMU information in R_InitExtensions() to avoid potential errors with KEEP_WINDOW flag -* Implemented \in_forceCharset for SDL backend -* Renderers: fixed non-working \r_ignorehwgamma, \r_overbrightbits now can operate independently from \r_ignorehwgamma in some cases -* Vulkan: handle special DRM/KMS case (FIFO+maxImageCount==0), use 4 swapchain images for that -* Fixed missing video/audio frames during multi-segment avi rendering -* Fix client forgetting password when it is set in main menu -* Renderers: make sure that R_ColorShiftLightingBytes() is not picking more data that we actually need/have -* SDL2: fixed crash when some cvars (like in_keyboardDebug) may be dereferenced before initialization, unified that behavior with win32 backend -* Better support for non-standard protocols (71-compat etc.) -* Vulkan: use minimal VkApplicationInfo at instance creation -* Vulkan: disable anisotropy for nearest-sampling modes -* win32: show/hide mouse cursor only if it has been not suppressed by OS -* Added con_autoclear cvar -* Added \kicknum, \kickall, and 'kickbots commands, patch by Ensiform -* Always keep bots, even with \devmap -* Allow 8x multisampling in traditional (non-framebuffer) MSAA -* Improve the default texture quality settings: - - Use the highest texture quality - - Use 8x anisotropic filtering by default -* Renderers: make sure that amplitude for TMOD_STRETCH is not zero -* Fixed stack overflow in \varfunc -* Fixed potential out-of-bounds access caused by large s_paintedtime -* Added \con_scale - to scale console font size relative to default smallchar width/height -* Fixed erroneous gamma setup in windowed mode -* Handle negative color shift that caused black lightmaps -* Use differential time and interval comparisons whenever possible -* Various botlib and QVM fixes -* Vulkan: mark offscreen rendering unavailable for NVidia on linux too - -14-Oct-2021: -* Filesystem: close all handles when switching to other game directory -* Sound: fixed potential division-by-zero in S_GetSoundTime() in case of failed DirectSound initialization, reworked shutdown functions -* Unix: output only printable chars in console -* SDL: removed archive flag for \in_nograb -* QVM: added more optimizations, removed unsafe x86 optimizations with disabled VM_RTCHECK_DATA -* QVM: always force either range checks or data mask operations - -20-Jul-2021: -* vm_x86: implemented new bytecode compiler with dynamic register allocation and many optimizations similar to aarch64/armv7l, brings ~2x performance increase -* vm_aarch64, vm_armv7l: added more optimizations, yields another ~40% performance increase -* win32: allow copying selected text from dedicated console via keyboard shortcuts -* win32: fixed input regression caused by previous fix for high-dpi mice in win10 insider builds -* win32: fixed application crash caused by hardened longjmp() in recent win10 versions -* win32: fixed broken minimize function after \vid_restart - -27-May-2021: -* QVM: more correct handling of NaNs in bytecode compilers -* QVM: fixed non-working RocketArena3 server code -* Cvars: avoid misleading warnings when changing ROM variables -* Cvars: allow override "protocol" from command-line -* Sound: reduced lag during video capture -* SDL2: (somewhat) fixed non-working console key for non-US keyboard layouts -* Vulkan: fixed some broken debug features -* Vulkan: fixed resource leaks and incorrect layout transitions during image capture -* Vulkan: avoid redundant scissor updates -* Vulkan: use correct texture bundle for lighting, use static uniform location to avoid pushing garbage from stack variables -* Vulkan: fixed crash with \r_showtris 1 and \r_fastsky 1, fixed environment shader selection -* OpenGL: fixed crash with \snd_restart -* Do not light up shaders whose sort comes after insertion point (SS_FOG) -* Unified gamma correction between OpenGL and Vulkan renderers - -28-Mar-2021: -* Vulkan: implemented super-sample anti-aliasing, can be enabled via \r_ext_supersample 1, requires \r_fbo 1 -* Vulkan: added \r_presentBits to support HDR monitors, added \r_dither to control dithering in such cases -* Vulkan: added more multitexturing optimizations -* OpenGL: fixed incorrect image capture with supersampling and renderscale enabled -* OpenGL: fixed texture generation for environment-mapped shaders in VBO -* OpenGL: disable bloom if multitexturing was disabled via \r_ext_multitexture 0 -* Renderers: dereference $vid_width and $vid_height to actual rendering width/height inside extended shaders -* Win32: fixed crash on nvidia systems when using Vulkan renderer and Win+D hotkey -* Win32: fixed accidental focus losses when using high-dpi mice -* Win32: fixed non-working \in_minimize in windowed mode -* Win32: catch rare DescribePixelFormat() crash -* Fixed error raised by messagemode 3/4 called without running cgvm -* Fixed another crash in FixRenderCommandList() -* Fixed potential crash with fog table -* Allow \reconnect to work after client restart -* Added warnings in developer mode to know why and when a sound isn't played -* Added \r_dlightSaturation -* Unlocked \r_lodCurveError -* Check integrity of loaded maps and models -* SDL2+Wayland compatibility fixes -* Various fixes and improvements - -16-Jan-2021: -* Win32: try to catch exceptions instead of silent crashing -* Win32: made unhandled exceptions non-fatal -* Sound: backported some fixes from ioq3, improved skip protection and reduced latency -* Client: made console hide/display speed do not depend from \timescale -* Client: updated built-in jpeg library version from 8c to 9d -* Client: allow setting window title via command-line cl_title cvar -* Renderers: avoid using detail textures for lighting stage -* Renderers: fixed shader parsing regression introduced by optional 'firstPerson' key -* Renderers: reverted color correction for external lightmap atlases -* Vulkan: list all available GPUs at startup -* Vulkan: added option to automatically select discrete/integrated GPUs via \r_device values -1 and -2 -* Vulkan: changed \r_device default to -1 (auto-select first discrete GPU) -* Vulkan: fixed potential crash caused by incorrect index offset bond -* Miscellaneous fixes and improvements - -31-Oct-2020: -* Allow changing extension for \video-pipe output files -* More optimizations for vm_aarch64 -* Fixed "ResampleTexture: max width" error in renderers -* Fixed crash in linux client caused by unitialized cvars, added backtrace output for debug builds - -21-Sep-2020: -* Client: automatically rescale console chars height for resolutions greater than FullHD -* Vulkan: do not crash if validation layer is not available in debug mode, some other minor fixes -* Added support for Raspberry Pi 4, Vulkan renderer seems to work fine with its beta driver -* Added very fast bytecode compilers for 32/64-bit ARM processors, slight improvements for x86 - -08-Aug-2020: -* OpenGL: fixed anisotropy level always forced to 1 -* Vulkan: implemented bloom post-processing effect, can be enabled via \r_bloom 1 cvar, requires \r_fbo 1 -* Vulkan: speedup video/screenshot capture -* SDL: added missing \in_restart command -* Added description for \fs_homepath and \fs_excludeReference cvars -* Added support for compiling on MacOS and ARM-based platforms -* Various small corrections - -05-Jul-2020: -* Added support for external lightmap atlases stored in maps//lm_XXXX textures -* Vulkan: added debug markers for resources, can be useful for tools like RenderDoc -* Vulkan: fixed incorrect color format setup with r_hdr 1 and r_fbo 0 -* Vulkan: render screenmap only in first scene -* Fixed incorrect usage of \r_dlightScale, slightly improved lighting stage selection -* Added wrapper over gai_strerror() to force english error messages -* Fixed 2+ arguments command completion for \rcon commands - -27-May-2020: -* Fixed some broken binds - -25-May-2020: -* Removed dead KP_STAR bind (referenced only in unused macosx code) -* Re-enable depth writes for skybox to fix cases when it can overlap with portal models -* Backported alpha-to-coverage fix from cnq3 for alpha-test function #1 -* Vulkan: fixed discard optimization -* Vulkan: fixed broken TCgen optimization -* Vulkan: use FIFO_RELAXED if available for V-Sync -* Vulkan: added support for mailbox presentation mode via \r_swapInterval 2 cvar -* Server: missing pure checksums at CS_ACTIVE now will cause client drop or gamestate retransmission at CS_PRIMED -* Win32: try to reset read-only attribute when writing q3config.cfg - -15-Apr-2020: -* Server: run userinfo filter as early as possible -* Vulkan: reworked library loader -* Vulkan: fixed \imagelist displaying wrong image formats -* Vulkan: fixed broken cinematics with \r_textureBits 16 -* Vulkan: fixed broken single-texture+fog shader -* Vulkan: fixed multi-texture bind order -* Allow shaders extensions to be used within .shaderx files only - -04-Apr-2020: -* Vulkan: improved performance and compatibility -* Vulkan: imlemented reversed depth buffer to avoid z-figting on very large maps -* Vulkan: fixed framebuffer corruption on Intel iGPUs -* Vulkan: fixed HDR screenshots/video capture on Nvidia drivers -* OpenGL: fixed rendering of some environment mapping shaders in VBO -* Increased MAX_IMAGE_ANIMATIONS from 8 to 24, considering using it from shaderx files only to maintain compatibility -* Changed option set for \r_showTris to 0 (disabled), 1 (exclude console) and 2 (include everything) - -27-Feb-2020: -* Change Sys_SnapVector to `rint` the components for x64 linux/mingw (to sync with everything else) -* Fixed vertex buffer overflow on zeel-exzeel_slick map, optimized skybox rendering -* Vulkan: implemented geometry buffer resizing on the fly, no more fatal errors -* Vulkan: fixed screenMap rendering in some cases -* OpenGL: put more shader stages in VBO to increase performance -* OpenGL: removed \r_primitives and \r_ignoreFastPath cvars -* Removed CVAR_CHEAT flag for \r_noportals cvar -* Fixed image corruption caused by bug in FixRenderCommandList() -* Fixed dynamic lighting on moving platforms -* Added two-side lighting for some surfaces -* Removed massive spam about wrong image extension in developer mode - (information about extension substitution now printed by \imagelist command) -* Various bugfixes and optimizations - -23-Jan-2020: -* Added \cvar_trim command - to remove all user-created cvars -* Vulkan: implemented 2-pass rendering and \r_renderScale options similar to OpenGL renderer -* Vulkan: implemented screenMap keyword functionality, enabled .shaderx support -* Vulkan: improved performance and image quality in several aspects -* Fixed vertexlighting collapse -* Fixed sort order for shaders with stages mixing depthWrite and blendFunc -* Win32: set a bit higher process priority -* Updated IPDB - -29-Nov-2019: -* Win32: slightly boost Q3A process priority -* Vulkan: added \r_ext_alpha_to_coverage - to improve quality of alpha-tested textures with enabled \r_ext_multisample -* Vulkan: fixed a few alpha-test bugs in a light fragment shader -* Vulkan: fixed \imagelist command -* Vulkan: fixed startup with old AMD drivers -* Vulkan: enable \r_vbo by default and set developer mode dependency -* Fixed defrag mod compatibility issue -* Fixed crash with remapped shaders in vertexlight mode -* Fixed vertex lighting of shaders without vertex color data -* Made \r_allowExtensions developer-protected -* Changed \r_showtris: - 0 - disabled - 1 - enabled only for 3D surfaces - 2 - plus HUD - 3 - plus console - 1 and 2 might work incorrectly on case of multiple views -* More QVM optimizations -* Updated IPDB - -09-Sep-2019: -* Added experimental vulkan renderer: - - based on KennyAlive's reference implementation - - offsers significant (50..300%) performance increase (at least on AMD hardware) - - supports r_fbo, r_vbo, multisampling, fast flares, per-pixel dynamic lighting - - currently missing bloom+reflection, screenMap comparing to opengl renderer -* Added \r_noborder support for linux -* Changed noborder drag key from CTRL to ALT to unify behavior with linux WMs -* Added SDL2 support (window,audio,mouse,joysticks) for win32/linux, selectable at compile time -* Modular renderer design (selectable at compile time) -* Changed \com_yieldCPU from 2 to 1 by default -* Implemented correct ALT-TAB handling in windows -* Less visual spam in console -* Various bugfixes - -05-Jun-2019: -* Made \sv_pure latched to avoid side-effects after map startup -* Added \fs_excludeReference cvar - to exclude certain pk3s from download list on server side - for example: \fs_excludeReference "baseq3/pakx.pk3 modx/paky.pk3" -* Extended \logfile modes: - 0 - disabled - 1 - overwrite mode, buffered - 2 - overwrite mode, synced - 3 - append mode, buffered - 4 - append mode, synced -* Fixed non-working console scrolling in fullscreen with 2+ monitors on win32 -* Slightly changed "\rcon tell" appearance -* Misc. filesystem changes -* Updated ip4db - -18-Apr-2019: -* Added client country detection code - controlled by \sv_clientTLD 0|1 cvar, default is 0 - adds \\tld\\XX key to userinfo, can be used for filtering - requires external ip4db.dat database -* Added \locations client command -* Removed \com_maxfps limitations for defrag-1.91.25 -* Fixed "userinfo" client command DoS -* Fixed non-working exec[q] command file completion - -14-Mar-2019: -* Fixed client event handling regression -* Fixed shader duplication on some maps -* Improved client-side prediction - -17-Feb-2019: -* Do not allow listing/loading autoexec.cfg/q3config.cfg from pk3 files -* Fixed weird bug with non-working mousewheel under some conditions -* Fixed non-working virtual resolution (for capture) -* Misc. renderer fixes - -29-Jan-2019: -* Added 'novlcollapse' shader key - to bypass \r_vertexLight 1 setting -* Now using more explicit control over vertex lighting approximation to provide more predictable renderer output: - - always disable it for UI elements (this includes console shader) - - enable it only for CGame module -* Improved memory management during image loading, removed practical MAX_DRAWIMAGES/MAX_QPATH limits (conditions left only for forward compatibility) -* Implemented CTRL+Left and CTRL+Right hotkeys for in-game console to seek through words in command line -* Tab-complete cvar values and bind values -* Declare single-char bind keys for better tab-completion -* Increased MAX_EDIT_LINE to 512 -* Bypass K_MWHEELUP/K_MWHEELDOWN with opened console in linux -* Removed unused K_WORLD_* keys and unused K_AUX9..K_AUX16 key definitions, reduced set of K_JOY* keys -* Removed unused \r_inGameVideo cvar from renderer modules -* Removed unused \r_uiFullScreen cvar -* Improved FreeBSD compatibility - -22-Dec-2018: -* Fixed configstring race condition caused by previously loaded map -* Fixed redundant map downloads with \cl_mapAutoDownload 1 -* Fixed non-working +button15/-button15 - -27-Nov-2018: -* Added vendor-specific exported symbols to win32 executables in hope that it will select most powerful GPU for our process in multi-GPU configurations -* Really fixed fog shader for q3dm19 -* Fixed broken rendering with multiple views and opened console with FBO and MSAA enabled -* Fixed crash in renderer caused by corrupted fog data, found on `geminicastle` map -* Fixed memory leak in CL_CloseAVI() -* Reworked \status command output to draw variable-sized name and address fields -* Implemented userinfo filtering system (see docs/filter.txt): - - any userinfo key can be validated - - practically unlimited number of conditions and nested levels - - special "date" key for temporary bans -* Reverted SHADER_MAX_VERTEXES back to 1000, to enforce forward compatibility with other engines -* Renamed \sv_maxconcurrent to \sv_maxclientsPerIP and changed default from 4 to 3 -* Try to use least-used client slots for new connection to preserve client ids between connections -* QVM speed improvements - -22-Sep-2018: -* Fixed zero ping time causes empty server list -* Fixed wrong fog shader on q3dm19 -* Implemented \minimize console command -* Improved OSP mod compatibility - -18-Aug-2018: -* Accept negative \r_mapGreyScale values to apply old (lightmap-only) grey scale -* Implemented loading/saving of pk3 index data, speeds up initial filesystem startup in 10x-100x times -* Slightly reduced filesystem memory usage -* Improved zone memory manager -* Unified behavior of MWheelUp with PgUp and MWheelDown with PgDown for console scrolling -* Reworked ALSA initialization and improved compatibility with jack2 + zita-ajbridge -* Fixed error message during monitor detection via xrandr -* Fixed time wrapping causing very long reconnect delay - -05-Aug-2018: -Renamed \r_mapGrayScale to \r_mapGreyScale, also now it is more strong -Fixed engine crash caused by mods passing erroneous data to render -Fixed non-working rconPassword2 on linux - -29-Jul-2018: -* Fixed Defrag demo UI (works on linux now) -* Improved filesystem compatibility - -28-Jul-2018: -* Fixed regression in filesystem code -* Fixed 'floating' console color -* Fixed OSP demo UI - -23-Jul-2018: -* Fixed resolving optional FBO functions -* Fixed Escape key causing full client restart during cinematics -* Fixed excessive filesystem lookup with empty \fs_steampath -* Reduced memory fragmentation at filesystem startup -* Avoided bug in defrag mod (whose demo UI can't handle properly sorted directories) -* Improved file extension filtering so now defrag demo UI works (partially) on linux too - -17-Jul-2018: -* Fixed pak reference & checksum calculation for cached pk3 files - -15-Jul-2018: -* Implemented more correct online switching between mods -* Added \fs_restart command - to manually restart the filesystem -* Significally reduced filesystem restart time in case of thousands of pk3s installed - -05-Jul-2018: -* Fixed client/botlib memory corruption - -30-Jun-2018: -* Added \r_ext_supersample - SuperSample Anti-Aliasing, most resource-heavy antialiasing method, can be enabled in pair with \r_ext_multisample -* Fixed chat input position counting notify lines -* Fixed clipboard text length truncation on linux -* Corrected screenMap texture generation -* Linux console improvements -* Netcode improvements - -04-Jun-2018: -* Fixed resource leak in botlib code -* Fixed OSP game patch -* Fixed command history buffer size -* Fixed ctrl+n and ctrl+p hotkeys with \in_forceCharset > 0 -* Game configuration now saved much less frequently -* Reset console command history on game change -* Use own console command history for dedicated servers - -23-May-2018: -* Fixed server crash induced by permanent rcon functionality -* ioq3: Fix client kicked as unpure when missing the latest cgame/ui pk3s - -19-May-2018: -* Improved mod compatibility -* Now using \r_renderScale 0 to disable custom render resolution mode -* Allow only printable ASCII chars for cvar names -* Fixed \r_speeds 1 with enabled VBO -* Fixed black lines on dlighted surfaces with \r_showTris 1 and \r_dlightMode > 0 - -28-Apr-2018: -* ioq3: Fix uninitialized bot_goal_t fields -* ioq3: Fix possible bot goal state NULL pointer dereference -* Misc. renderer & netcode improvements -* Print up to 32 file sources in \which output -* Print developer messages with cyan color -* Increased win32' console width & height - -15-Apr-2018: -* ioq3: Fix q3history buffer not cleared between mods and OOB-access -* ioq3: Fix the behavior of CVAR_LATCH|CVAR_CHEAT cvars -* Netcode & QVM improvements - -09-Apr-2018: -* Fixed invalid files referenced on pure clients -* Fixed a few netcode exploits -* Fixed \sv_reconnectlimit is not always working -* Try to use persistent slot for each client after disconnect -* Print information about delay at reconnect -* Linux console imrovements - -02-Apr-2018: -* Fixed a few bugs in client connection code - -01-Apr-2018: -* Fixed remote server crash via rcon -* Send quoted rcon passwords when needed and parse them correctly on server-side -* Now rcon is always available on dedicated servers - so it is possible to start a map, retrieve status or recover from non-fatal error, for example -* Added rconPassword2 - hidden master rcon password that can be set only from command line, can be used to change/revoke compromised rconPassword -* Various bugfixes - -26-Mar-2018: -* Added \cl_autoNudge - automatic time nudge that uses your average ping as the time nudge value, suggested by @iradicus, values: - 0 - use fixed \cl_timeNudge - (0..1] - factor of median average ping to use as timenudge -* Added \sv_maxconcurrent - to limit number of simultaneous connections from the same IP address, default is 4 -* Added \fs_locked cvar to control pk3 file handle usage policy: - 0 - release after use (default from now), no pk3 file count limits - 1 - keep it locked (vq3 behavior), more consistent but pk3 file count is limited to ~1-4k -* Various bugfixes and optimizations - -14-Mar-2018: -* Win32: added \r_noborder 1 - to draw game window without border, hold CTRL to drag & drop it with opened console -* Win32: Fixed window handling -* Changed \r_neatsky to 0 by default -* Accept protocol headers (e.g. http://) in command lines and save them properly in cvars -* Try to prevent gamestate overflow on pure servers -* Various bugfixes and optimizations - -26-Feb-2018: -* Fixed regression added with recent optimizations -* Improved DoS protection - -24-Feb-2018: -* Slightly speedup collision detection for win64-msvc builds -* Added \r_defaultImage cvar - to replace the default (missing texture) images, can either point on external filename or specify solid color texture in (hex) formats: "#rgb" or "#rrggbb" -* Removed obsolete \com_maxfpsMinimized -* Synced \snaps with \sv_fps for localhost client -* Properly reflected \sv_fps changes for connected clients -* Reduced memory & CPU usage -* Fixed adjacent texels leaking in merged lightmaps -* ioq3: Make 'globalservers 0' fetch all masters -* Marked \sv_master[1..3] as CVAR_INIT to prevent overriding them by spoiled configuration files -* Fixed root of 14-years-old q3msgboom bug -* Misc. improvements and bugfixes - -09-Feb-2018: -* New server-side client connection code (no more "getchallenge" flooding, reduced CPU usage) -* Removed \sv_minPing and \sv_maxPing cvars -* Changed \r_dlightScale to 0.5 by default to match VQ3'dlights radius/intensity -* Fixed grid collision geometry to be more equal in 32-bit and 64-bit modes -* Fixed non-working \reconnect in some cases -* Misc. fixes and improvements - -30-Jan-2018: -* Added unified lightmaps, enabled by default, can be disabled by \r_mergeLightmaps 0 -* Changed default \com_hunkMegs from 96 to 128 for client and from 56 to 64 for server -* Reverted condump changes -* Drop error to local client on gamestate overflow -* ioq3: Fix exploit to bypass filename restrictions on Windows - -28-Jan-2018: -* Improved QVM memory isolation -* Improved QVM interpreter performance -* Improved cvar security -* Reduced GPU usage when minimized -* Fixed MSAA on Intel HD 530 -* Fixed non-working console scrolling in windowed mode with raw input and opened console -* Fixed crash caused by \timescale 0 -* Condumps now will be saved in upper level directory, not mod directory - -16-Jan-2018: -* Added experimental "screenMap" texture support for shader stages, can be used for real-time on-hand weapon reflections -* Fixed viewport/scissor with \r_fastSky 1 -* Fixed depth range for inserted dynamic lights -* Fixed wrong ping times at high uptime - -11-Jan-2018: -* Added range checks for \sv_timeout and \sv_zombietime cvars to avoid using values that may break server functionality -* Improved server-side flood protection (\sv_floodProtect 1), might be considered as really usable now -* Removed unused \sv_showloss cvar -* Misc. bugfixes - -08-Jan-2018: -* Faster map loading -* Do not take (blank) screenshots and print warning when minimized and FBO is not active -* Always save CPU when minimized -* Slightly optimized VBO rendering and fixed \r_showtris colors with VBO - -30-Dec-2017: -* Added \cl_dlDirectory - to specify location to save downloads initiated by \dlmap and \downloads commands: - 0 - save in current game directory - 1 - save in fs_basegame (baseq3) directory -* Fixed non-working VBO in fullbright mode - -23-Dec-2017: -* Better FPS control (client and server) -* More precise ping calculation -* Linux multimonitor improvements -* Implemented string comparisons for conditional shaders -* Fixed console messages may leak on screen with \con_notifytime 0 -* Removed \username and corresponding functionality -* Botlib security fix - -11-Dec-2017: -* Fixed missing dynamic lighting with collapsed multitexture shaders - -09-Dec-2017: -* Win32: do not minimize/restore video mode/gamma when switching out of game window in multimonitor configurations - -08-Dec-2017: -* Implemented \r_renderWidth and \r_renderHeight, see docs/quake3e.htm for details -* Now releasing mouse with opened console in multimonitor configurations -* Added multimonitor support for Linux, ALSA and window handling improvements -* Removed old non-FBO bloom and its variables, so only new bloom is available from now via \r_bloom: - 0 - (disabled) - 1 - (without hud) - 2 - (with hud) -* Renamed all \r_bloom2* cvars to \r_bloom* -* Now using \timescale 0 to pause demo playback -* Removed \cl_freezeDemo as it never worked as intended -* Various bugfixes - -27-Nov-2017: -* Backport master dns resolve timeout and dedicated \tell command support from ioq3 -* Fixed precision in collision detection module (to avoid incostistency between 32 and 64-bit builds) -* Fixed stuck at "awaiting snapshot..." state when connecting to pure servers and being kicked because of unpure -* Fixed spurious "Invalid .PK3 files referenced" errors on reconnect -* Fixed dlight quality with \r_vbo 1 - -15-Nov-2017: -* Implemented correct fog fading for new dynamic lights -* Actually use only 22 and 11 cases for \s_khz -* Fix SurfIsOffscreen() with enabled VBO - -10-Nov-2017: -* Fix non-working new dynamic lighting on some maps -* Fix VBO crash -* Another small VBO fix - -09-Nov-2017: -* Add \r_vbo 1 - GPU-accelerated static map geometry caching, map-dependent, typically adds 5-20% FPS on modern GPUs, but even 200%+ FPS increase was observed as well as zero difference cases -* Win32: restore gamma and hide fullscreen window in case of crash - -01-Nov-2017: -* Change [automatic] demo naming scheme from demoXXXX to demo-YYYYMMDD-HHmmSS[-NNN] -* Add \s_device cvar to specify output sound device for ALSA -* Clear key states on focus change/vid_restart in linux -* Slight bloom effect performance increase -* Fix \r_anaglyphMode rendering with \r_fbo -* Fix texture numbers generation - -16-Oct-2017: -* Fix non-working \r_ignorehwgamma 1 with \r_fbo 1 -* Use RGBA16 instead of RGBA12 textures for \r_hdr 1 - should fix errors on nvidia cards -* Fix some drivers reporting invalid preferred texture format -* Print detailed format of used FBO - -15-Oct-2017: -* Escape always closes console -* Fix sound muted when minimized with \s_muteWhenMinimized 0 -* Fix sounds leaks when muted -* Fix unfocused/minimized window state adding delays during video capture -* No more zone allocation errors, no need to tune \com_zoneMegs at all because of new multi-segment allocator -* Reduce \com_zoneMegs from 25 to 9 by default -* Fix bot routing cache growing to com_zoneMegs-1 (and potentially unlimited with new multi-segment allocator), use explicit 2MB limit which is enough even for route-heavy maps like q3dm12 with 60+ bots -* Increase MIN_DEDICATED_COMHUNKMEGS from 1 to 8 because common snapshot storage always uses 6.7MB i.e. there is no sense is smaller values -* Fix dynamic lights not working well with AMD drivers -* Add \r_hdr - use high dynamic range pixel format for framebuffers, improves visual quality -* Many bloom changes: - add \r_bloom2_passes [1..8] - number of downscaled textures used for final bloom composition - add \r_bloom2_filter_size [1..20]- number of texture lookups for blur - add \r_bloom2_intensity - scale factor applied to final bloom texture before adding to main frame - add \r_bloom2_blend_base - to select from which hi-level buffer start blending final bloom texture, default is 1 (i.e. do not blend first full-resolution intensity buffer) - add \r_bloom2_threshold_mode to specify color extraction condition: - 0 - (r|g|b) >= threshold - 1 - (r+g+b)/2 >= threshold - 2 - luminosity(r,g,b) >= threshold - add \r_bloom2_modulate to modify extracted bloom intensity: - 0 - do not modulate - 1 - modulate by itself - 2 - modulate by luminosity - always use hdr buffers for bloom - add \r_bloom2_reflection - bloom lens reflection effect, negative values will apply only lens effect and disable bloom - \r_bloom 3 now doesn't affect console - fix bloom intensity extractor - remove \r_bloom2_cap -* Remove old platform-dependent multisample setup code, leave only fbo version -* Allow changing \r_ext_multisample and \r_hdr on the fly (in \r_fbo 1 mode) -* Allow more than 32 surfaces in skin files -* Remove unused \r_ext_gamma_control -* Fix OpenGL 1.4 version detection -* Do light pass right before SS_UNDERWATER if possible -* Add \video-pipe command - redirect captured video stream to ffmpeg input pipe and save as mp4 - you need to install ffmpeg package (on linux) or put ffmpeg binary near quake3e executable (on windows) -* Add \cl_aviPipeFormat - encoder parameters used for \video-pipe, see ffmpeg documentation for details - -15-Sep-2017: -* Add "\screenshotBMP" command -* Add "\screenshotBMP clipboard" command - to copy screenshot in clipboard, works only in windows atm -* Add some hardcoded key binds: - PrintScreen - "\screenshotBMP clipboard" - Shift+PrintScreen - "\screenshotBMP" -* Add dedicated \r_nomip cvar instead of negative \r_picmip values to apply picmip only on worldspawn textures - as negative \r_picmip values is breaking cross-engine config compatibility -* Fix \r_greyscale validation -* Add descriptions for some renderer cvars -* Accept only HTTP(S)/FTP(S) protocols for download redirection - -10-Sep-2017: -* Add \s_muteWhenUnfocused and \s_muteWhenMinimized cvars -* Sound muting now works during video recording -* Fix memory allocation error caused by listing large directories - -08-Sep-2017: -* Package now shipped with baseq3a patch (baseq3/pak8a.pk3) -* Clear key states on disconnect -* Clean some server cvars on server shutdown -* Fix crash in TeamArena -* Fix main menu recorded in video after disconnect -* Fix slight sound corruption during video recording -* Fix MSVC compilation from paths that contains whitespace -* Rework cvar validation -* Range check \cl_packetdup cvar -* Detect and skip files with unsupported compression method inside pk3 archives - -26-Aug-2017: -* Call glFinish() only if requested by r_finish -* Fix sound stutter caused by filesystem operations -* Verbose bot kick message on map change -* Filter "connect" packet length to avoid overflows in dynamic huffman decoder -* Improve overflow handling in MSG_ReadBits/MSG_WriteBits -* Warn about userinfo and pure checksums truncation on client-side -* Do not send more than MAX_PACKETLEN (1400 bytes) in single statusResponse packet -* Read sv_pure directly from systeminfo, not local cvar -* Do not set following local cvars from remote userinfo: - sv_pure, sv_serverid, sv_paks, sv_pakNames, sv_referencedPaks, sv_referencedPakNames -* ioq3: Fix friction in AAS_ClientMovementPrediction ( ground and water friction were reversed ) -* Add trap_R_AddLinearLightToScene - linear light source, suitable for rail trails, lightsabers etc. - can be resolved via extension interface -* Do not issue late cull tests on modern gfx hardware or for linear lights - as CPU may bottleneck in these cases -* Fix FreeBSD compilation (partially) -* Fix some errors reported by clang' undefined behavior sanitizer -* Move \r_greyscale functionality to FBO/ARB shaders so now it requires \r_fbo 1, on other side: - - you can change \r_greyscale on the fly - - now it applies to everything including cinematics -* Parse systeminfo as big string on client side, rest of strings - as normal strings -* Add \systeminfo and \serverinfo commands on client side -* Read systeminfo and serverinfo from corresponding configstrings on server side -* Add "tcGen environment firstPerson" shader stage parameter - fixes non-working environment mapping for first-person (on-hand) models -* Increase shader loading speed -* Add complex token parser -* Add experimental conditional shader stages, see docs/quake3e.htm for details - -13-Jul-2017: -* Experimental: unconditionally complete \callvote command and its arguments for all mods -* Print screenshot filename after executing render commands so it won't appear on screenshot itself -* Add engine extension system, remove old r_floatfix hack -* Allow multiple mirror views to be rendered -* Fix non-working depth/stencil tests for extra refdefs in \r_bloom 2 mode -* Fix crash caused by window movements during map load -* Fix stuck AltGr key -* Fix shader rotation at high level times - -13-Jun-2017: -* Revert "Fix ^^ rendering in game console" due to mods compatibility problems - -12-Jun-2017: -* Add \cl_mapAutoDownload - automatic map download from cl_dlURL for non-pure servers and demo playback, disabled by default -* Add \r_bloom 2 - experimental high-quality bloom, use with \r_fbo 1, parameters: - \r_bloom2_threshold - bloom filter sensitivity - \r_bloom2_cap - max.resulting bloom intensity applied to original image -* Add pk3dir feature, backported from ioq3 with some differences, works only with sv_pure 0 -* Client echo/print packet security fix -* Win32: fix alt key hang -* Win32: fix AltGr+Enter hotkey on non-US layouts -* Win32: block monitor shutoff on battery -* Fix ^^ rendering in game console -* FBO-related fixes - -28-May-2017: -* Add \in_forceCharset 2 - to use physical EN/US layout, this is obviously incompatible with AZERTY keyboards but useful for UK/RU layouts -* Add \r_fbo - opengl framebuffer support, partially backported from cnq3, disabled by default - - gamma correction in windowed mode - - support for screenshots/video recording with larger resolutions - - allow window minimizing during video recording -* Increase max.count of file handles in win32, needed for defrag mod -* Detect and verbose a weird opengl error under linux -* Range check \r_gamma and \r_intensity cvars -* Fix '.' translation on numpad -* Fix last-standing frameloss bug (stuck waves at very big sv.leveltime) -* Fix early print to client console -* Remove non-archive flag for \rate -* Remove \r_measureOverdraw -* MinGW compilation support -* Win32: parse and set vid_xpos and vid_ypos from command line - - for dedicated binary it will set console position - - for client binary it will set main window position -* Win32: correctly restore main window position from vid_xpos and vid_ypos in multi monitor configurations -* Disable DPI scaling on windows 10 - -12-May-2017: -* Rename \in_forceLayout to \in_forceCharset and perform translation only for non-ASCII chars - -11-May-2017: -* Add negative \r_picmip values support - to apply picmip only on worldspawn textures - -09-May-2017: -* Experimental: add CVAR_NODEFAULT flag - to avoid writing cvar into config file if its value matching reset(default) string - this will reduce config file size and will help with upgrading archive cvars that most users never changing - also it will increase cross-plaftorm config compatibility for cases where some archive cvars may have different default values on different platforms -* Add \in_forceLayout - to use EN/US keyboard layout not depending from current language settings, enabled by default -* Add vsync workaround for linux opensource drivers - -07-May-2017: -* Bugfixes and network layer optimizations - -30-Apr-2017: -* Fix digits input on numpad in numlock mode -* Fix local console history not loaded when client is connected to pure server -* Stop demo recording on first download packet to avoid recording downloaded data -* Skip download blocks parsing during demo playback -* Replace some buggy shaders on mapel4b -* Fix non-working effect colors is OSP mod -* Try to handle some non-fatal errors during shaders loading -* A bit faster shader loading -* Add support for loading .shaderx files - to add or replace any existing shader -* Add "depthFragment" shader stage parameter - to store non-transparent (with alpha >=0.85) fragments into depth buffer, very useful for sprites (cg_simpleitems) -* Do not print each loaded shader name in developer mode -* Change some client defaults: - cl_maxpackets 30 -> 60 - snaps 20 -> 40 - -22-Apr-2017: -* Fix: crash caused by long filenames inside pk3 files -* Fix: demo filename truncation -* Fix: skip gamedata bounds check for dlls - -21-Apr-2017: -* Add: unlagged input for win32 mouse -* Add: \in_lagged to simulate old behavior for win32/raw mouse -* Chg: clamp \com_yieldCPU values to [0,1] -* Chg: increase max allowed \r_displayRefresh value to 250 - -16-Apr-2017: -* Fix: switch back to old mod if downloading new mod on \connect has been failed -* Chg: use q3config_server.cfg as config file for dedicated server binaries and do not write key bindings to that as well -* Chg: increase SHADER_MAX_VERTEXES from 1000 to 1536 -* Misc: reduce CPU usage on server side - -09-Apr-2017: -Add: \r_mapGrayScale -Chg: alphabetically sort cvars for \writeconfig, will affect \cvarlist too -Fix: renderer crash on negative \r_fullscreen values -Misc: add SSE math to QVM, speed optimizations - -02-Apr-2017: -Add: backport and use alternative huffman encoder from uberdemotools - means reduced CPU usage on server-side -Chg: avi segments naming scheme to "filename-NN.avi" instead of corrupting extension by '_' suffix -Chg: max avi file size to 4GB -Fix: black video frames with \r_faskSky 1 -Fix: crash on video recording -Fix: reversed timescale during video recording -Fix: check for ZIP archive signature before writing any received data -Fix: several bugs in video recording code - -24-Mar-2017: -Add: new snapshot system with reduced CPU/memory usage on dedicated servers -Fix: don't count \sv_timeout multiple times - so now it really works as expected - -20-Mar-2017: -Chg: fs_game default back to "baseq3" -Fix: clearing win32 dedicated console -Fix: do not build bot snapshots every client frame on listen servers -Fix: do not crash but just discard using corrupted JTRGSEG in QVM - -Fix: CVE-2017-6903, affects mostly linux builds: - - deny manipulations with ".exe", ".qvm" and ".so.[0-9]" extensions too - - Sys_LoadLibrary() now can load only known library extensions - - force dll extension during loading \r_glDriver under windows - - deny using referenced pak names that is too long - - increase some filesystem buffers to avoid possible filename truncations - -07-Mar-2017: -Fix: QVM memory leak -Fix: UrbanTerror-4.3.2 compatibility - -26-Feb-2017: -Fix: black screenshots at \r_fastSky 1 - + Rework screenshot code so we can take two screenshots (tga+jpg) per frame, each with different name - + Avoid situation with multiple screenshots (of the same type) being taken during one frame - which doesn't have any sense - + Now screenshot code doesn't use render command buffer so it will always success in case of overflow etc. -Chg: default screenshot naming scheme from shotNNNN to shot-YYYYMMDD-HHmmSS - -13-Feb-2017: -Fix: handle client gamestate overflow -Chg: set sv_levelTimeReset default to 0 -Fix: restart server every 12 hours when sv_levelTimeReset is 0 -Fix: potential hang in tty_FlushIn() -Fix: much more correct suspend/resume (SIGTSTP/SIGCONT) for unix console -Add: CTRL+L hotkey support for unix console - -04-Jan-2017: -Add: [out of source tree atm] multiview protocol and server-side demo recording - -22-Dec-2016: -Win32: non-blocking window movements/scrolling, faster dedicated console text output - -19-Dec-2016: -Fix: CPMA hacks - -18-Dec-2016: -Fix: do not handle "disconnect" command when downloading with cURL - -16-Dec-2016: -Add: allow recording demo duding demo playback -Fix: filehandle leak after reading zero-sized servercache.dat -Fix: do not add newlines to the end of cs/bcs* server commands -Fix: missing client name in debug output "Going to CS_ZOMBIE for [name]" -Chg: servercache.dat now per mod and not global for all -Misc: QVM improvements -ioq3: Don't have clients use private slots when sv_privatePassword is unset -ioq3: renderer2 fixes - -24-Nov-2016: -Add: overwhelming CPMA hack -Fix: OSP game module crash - it will continue corrupting its own memory but not crash -Fix: gcc and clang warnings -Fix: vmprofile - -12-Nov-2016: -Fix: \r_dlightMode 2 with \cg_shadows 2 -Fix: dynamic lights on decals on q3wcp18 and other maps -Fix: use dedicated dlight set for each view so old light counting code is not buggy anymore -Fix: use explicit litsurf count check since we can't correctly handle overflows because of ".next" pointers -Fix: round up \r_ext_multisample values in win32 to match linux behavior -Fix: use dedicated dll syscall wrappers for each game module -Chg: default number of dlights - 64 -Add: allow using '?' in extensions for trap_FS_GetFileList() - -02-Nov-2016: -Fix: list all available demos that matching valid protocols (66-71) -Fix: indicate actually opened demo file instead of command line argument -Fix: color blending on some old Intel GMA's -Fix: missing dlights on q3dm4 and maybe other maps too -Fix: dlights on q3wcp17 -Fix: portals now correctly works with \r_fastky 1 -Chg: raize MAX_POLYS and MAX_POLYVERTS defaults to 8k and 32k respectively -Chg: \r_noportals 1 - disable only portals, 2 - mirrors + portals -Chg: scissor viewport by portal model bounds -Chg: print extension for tab-completed demos -Cgh: rename \r_dlightSpecExp to \r_dlightSpecPower and set default to 8.0 -Add: \r_dlightIntensity -Add: \r_dlightSpecColor - color base for specular component - <= 0 - use current texture and modulate by abs(r_dlightSpecColor) - > 0 - use constant color with RGB components set to \r_dlightSpecColor - default is -0.25 - -21-Oct-2016: -Fix: anaglyph/stereo rendering with new dlights -Chg: Use 12 bits for refentites - fixes missing frames in stereo rendering and allows more game items to be drawed -Add: \r_dlightMode 2 - now illuminates md3 models i.e. almost everything on the map -Add: CPMA hacks -Add: sin,cos,rand to \varfunc - -10-Oct-2016: -Fix: skybox overbright with picmip and \r_intensity > 1 -Add: \varfunc [- or low limit] [high limit] -Remove: \inc and \dec - -09-Oct-2016: -Add: \r_dlightMode 1 - improved dlights backported from cnq3 - \r_dlightScale - for adjusting new light radius in old mods - \r_dlightSpexExp - control over specular component in new dlights -Add: multi sampling support via \r_ext_multisample -Add: \r_neatsky to force nopicmip for skyboxes -Add: \inc and \dec commands for increasing and decreasing cvar values - -27-Sep-2016: -Chg: undefine UNICODE for win64 build - -26-Sep-2016: -* Fix: non-working \reconnect -* Chg: r_modeFullscreen defaults to "-2" -* Add: extra r_mode entries -* Chg: undefine FORCE_DM68_EXT - -20-Sep-2016: -* Bring back dynamic OpenGL dll loading -* Upstream ioq3 fixes - -20-Aug-2016: -* Add \r_modeFullscreen - dedicated fullscreen mode, leave empty for old behavior, set to -2 to use desktop resolution etc. -* Add \com_affinityMask - bind application to specified CPU core(s) -* Fix win32 console update -* Fix WM_CLOSE message handling to avoid unneeded renderer errors at shutdown -* Fix \cl_shownet may print invalid entity number -* ioq3: Avoid generating client commands with zero frame_msec -* ioq3: preserve all \connect arguments for further \reconnect - -29-Jul-2016: -* Range check valuer of \com_yieldCPU -* Fix startup flags for \vm_rtChecks -* Linux: support gamma ramps larger than 256 entries - -26-Jul-2016: -* Never send snapshots often than client' "snaps" specifies -* Raize some client network rate limits -* Win32: set gamma only for used monitor -* Win32: track and change gamma when moving game window -* Win32: Implement \in_nograb - so now it is possible to move game window without opened console -* Fix non-working r_ignorehwgamma in linux -* Don't forget to release vidmodes on linux - -21-Jul-2016: -* Render CPMA/CNQ3 color codes (8,9,a-z) in console -* Fix "Restarting server due to numSnapshotEntities wrapping" -* bugfixes - -30-Jun-2016: -* backport UDP spoofing protection from ioq3 -* bugfixes - -24-Jun-2016: -* Fix win32 clipboard copy function -* Fix dlight #32 not being rendered - -21-Jun-2016: -* Backport fast legacy (udp) downloads from ioq3 -* Sync with redrerergl1 from ioq3 -* Netcode & renderer bugfixes - -07-Dec-2015: -* Fix r_picmip resetting to default value -* Add support for searching game data from Steam' Q3A installation -* Other backported ioq3 fixes - -10-May-2015: -* win32: Enable ASLR security feature -* win32: don't allow to minimize when recording video -* Hadle com_maxfpsMinimized in linux -* Reset mapname after server shutdown -* Reduced CPU usage in dedicated mode -* \com_yieldCPU now specifies maximum sub-frame sleep time in milliseconds, 1 by default - -28-Apr-2015: -* Clipboard paste support for linux client - -27-Apr-2015: -* Negative \r_overbrightBits to force gamma in windowed mode - -22-Apr-2015: -* Various fixes -* Remove 1000 fps lock in timedemo - -09-Mar-2014: -* Upstream ioq3 fixes - -26-May-2013: -* Backport MD4/MDR/IQM models support from ioq3 -* QVM: reworked interpreter and improved x86 bytecode compiler -* ioq3: fix QVM memset and memcpy return NULL - -01-May-2013: -* Fix non-working software GL in some cases under Win7/Vista -* Fix win32 dedicated console 'copy' button crash -* Don't allow to manipulate with multi-platform executables -* Add x86 QVM data read/write runtime checks - -24-Apr-2013: -* Fix linux file creation -* Complete arguments for \video and \record commands if possible -* ioq3: Fix referencing pk3 with only qagame QVM - -18-Apr-2013: -* Fix \condump command -* Allow listing all client demos when connected to pure server -* List only external files for condump/writeconfig -* Draw scroll start/end markers for input fields -* Fix input fields color tracking -* Fix x86 QVM - -07-Apr-2013: -* Console fixes/improvements: - Get rid of empty lines scrolling - Ctrl+HOME now works correctly in all cases - Pageup/down and mwheelup/down now scrolls by 1 line, not 2, hold +ctrl to accelerate -* Add \cl_conColor [RRR GGG BBB AAA] - controls console background color -* Mute sounds only in minimized client window state -* More correct linux client shutdown - -14-Mar-2013: -* Upstream ioquake3 fixes and improvements -* Use platform-dependent newlines for writing config files -* Try to use real process directory instead of just current one -* Remove hardcoded BASEGAME ("baseq3") content loading -* Remove fs_cdpath and related code - -31-Jan-2013: -* Fix bug with reporting too many referenced paks to pure server -* QVM improvements - -29-Jan-2013: -* ioq3: Makes cvar be flagged as VM created and unset ROM if ARCHIVE is set -* Code cleanup - -10-Jan-2013: -* Bugfixes -* \dlmap and \download command support, see documentation - -30-Nov-2012: -* Native 64-bit support for x86 (windows/linux) -* Another round of QVM performance/security improvements -* Link statically with OpenGL32.dll|so -* Remove 3DFX-gamma-related stuff -* Remove \r_clampToEdge - -14-Oct-2012: -* Try to open demo file first before shutting down any client stuff -* Improved qvm file validation -* ioq3: do not require clients to have a matching qagame.qvm - -24-Jul-2012: -* Add scrolling win32 dedicated console buffer by mouse wheel -* Fix compiler warnings - -23-Jul-2012: -* Preserve binds by dedicated server binaries -* Fix facets overflow -* Backport recent ioq3' socket/bot AI fixes - -14-Jun-2012: -* Filesystem layer fixes - -04-Jun-2012: -* Code cleanup -* Some x86 QVM improvements - -19-May-2012: -* Win32 multi-monitor fixes -* Another set of x86 QVM improvements - -02-May-2012: -* Fix custom GL driver loading -* Many x86 QVM improvements - -11-Apr-2012: -* Force focus for win32 decicated console input field -* Misc. fixes and improvements - -06-Apr-2012: -* Try to resolve remote server address first before shutting down any client stuff on "connect" command - -05-Apr-2012: -* Added win32 decicated server binary -* Reworked win32 decicated console -* Avoid adding last duplicated command in console history - -24-Mar-2012: -* Allow resizing win32 dedicated console -* Allow setting win32 dedicated console title via con_title cvar from application shortcut - -17-Mar-2012: -* Fix filtering duplicates in getserversResponse packets - -06-Mar-2012: -* Add SSE3 instruction set detection and corresponding fast float-to-int conversion inside QVM - -25-Feb-2012: -* Fix potential memory leak in host name resolution -* Set sv_master1 to master.maverickservers.com -* Add "master.ioquake3.org" as sv_master2 -* Rate limit getinfo queries -* Client no longer tries to run UI_SHUTDOWN on ui vms with an unsupported API version. - -03-Jan-2012: -* Add \r_bloom <0|1> - light bloom postprocessing effect - -26-Nov-2011: -* Revert fast SSE2 float-to-int conversion -* Code cleanup - -26-Oct-2011: -* Add SSE2 instruction set detection and fast SSE2 float-to-int conversion for QVM -* Use proper function for setting integer texture parameters -* Fix point contents detection in SV_AreaEntities() - -14-Oct-2011: -* Fix mouse clipping in windowed mode (win32) -* Change: unlock \bot_thinktime cvar - -08-Aug-2011: -* Clean-up mouse handling code -* Don't allow VMs to operate with executables -* Fix downloading 65M+ files via UDP -* Fix comments inside configs -* Fix bot AI - -02-Jul-2011: -* Fix few bugs in sound mixing code -* Reduce probability of sound drops - -27-Jun-2011: -* bring back Windows 2000 compatibility - -26-Jun-2011: -* more qvm optimizations - -09-Jun-2011: -* fs_game now is "edawn" by default so edawn.exe/ded now deprecated - (usual mod switch via menu or commandline is working as before) -* \video (motion capture) command now available -* fixed http 406 error when downloading content from some servers -* linux binaries now is glibc-2.3 compatible (suitable for deploying on old linux distributions) -* more x86-qvm improvements - -30-May-2011: -* more qvm optimizations - up to 30% speedup comparing to 1.32b/c :) -* removed buggy \r_smp - -12-May-2011: -* additional security checks against malicious qvms -* more correct code generation for vq3-compatible mods -* additional qvm jit-compiler optimizations (more than 10% codesize reduction for edawn + faster execution) - -04-May-2011: -* max.config size increased to 64k -* fixed few potential crash cases -* additional qvm optimizations and security improvements - -23-Apr-2011: -* Allow listing some type of files - fixes issue with in-game hud selection menu on pure servers -* Allow adding custom bots on pure servers -* improvements in x86 bytecode compiler - -07-Apr-2011: -* added K_AUX1..K_AUX8 keys support in linux -* added \r_mode -2 - sets current video mode -* remove com_blindlyLoadDLLs - no more nasty popups -* fixed spurious client disconnects in some cases -* fixed gamma in windowed mode (win32 ) - -18-Feb-2011: -* fixed OSP mod behavior - -16-Feb-2011: -* fixed potential crash/corruption in Q_vsnprintf function (affects even netcode) - -12-Feb-2011 -* fixed potentilal userinfo corruption - -21-Dec-2010: -* fixed some Vista/7 gfx issues - -19-Dec-2010: -* fixed rate limiter -* ttycon 0 also disables console input now (linux console) -* add missing interrupt (ctrl+c) handler for linux console (means correct client/server shutdown) - -16-Dec-2010: -* backported security fix from zlib-1.1.4 -* prevent game crash due to cvar overflow exploits \ No newline at end of file diff --git a/docs/quake3e.htm b/docs/quake3e.htm deleted file mode 100644 index 621f28c012..0000000000 --- a/docs/quake3e.htm +++ /dev/null @@ -1,264 +0,0 @@ -Quake3e -

-This client aims to be fully compatible with original baseq3 and other mods -while trying to be fast, reliable and bug-free. -
-It is based on ioquake3-r1160 (latest non-SDL revision) with upstream patches and many custom improvements.
-
-Common changes/additions: -

    -
  • a lot of security, performance and bug fixes
  • -
  • much improved autocompletion (map, demo, exec and other commands), in-game \callvote argument autocompletion
  • -
  • \com_affinityMask - bind Quake3e process to bitmask-specified CPU core(s)
  • -
  • raized filesystem limits, much faster startup with 1000+ pk3 files in use, level restart times were also reduced as well
  • -
  • \fs_locked 0|1 - keep opened pk3 files locked or not, removes pk3 file limit when unlocked
  • -
-Client-specific changes/additions: - - -Server-specific changes/additions: -
    -
  • \sv_levelTimeReset 0|1 - reset or do not reset leveltime after new map loads, when enabled - fixes gfx for clients affected by "frameloss" bug, however it may be necessary disable in case of troubles with GTV
  • -
  • \sv_maxclientsPerIP - limit number of simultaneous connections from the same IP address
  • -
  • much improved DDoS protection
  • -
  • \sv_minPing and \sv_maxPing were removed because of new much better client connecion code
  • -
  • userinfo filtering system, see docs/filter.txt
  • -
  • rcon now is always available on dedicated servers
  • -
  • rconPassword2 - hidden master rcon password that can be set only from command line, i.e.
    -   +set rconPassword2 "123456"
    -can be used to change/revoke compromised rconPassword
  • -
  • significally reduced memory usage for client slots
  • - -
- -
-
-

\in_minimize -
-
- cvar that specifies hotkey for fast minimize/restore main windows, set values in form
-   \in_minimize "ctrl+z"
-   \in_minimize "lshift+ralt+\"
-   or so then do \in_restart to apply changes. -
-
- -


-

Fast client downloads

-Usually downloads are slow in Q3 because all downloaded data is requested/received from game server directly. -So called `download redirection' allows very fast downloads because game server just tells you from where you should download all required mods/maps etc. - it can be internet or local http/ftp server
-So what you need: -

    -
  • set sv_dlURL cvar to download location, for example:
    -  sets sv_dlURL "ftp://myftp.com/games/q3"
    - Please note that your link should point on root game directory not particular mod or so -
    -
  • - -
  • Fill your download location with files.
    -   Please note that you should post ALL files that client may download, don't worry about pk3 overflows etc. on client side as client will download and use only required files -
  • -
-
-
-
-

Fast client-initiated downloads

-You can easy download pk3 files you need from any ftp/http/etc resource via following commands:
- -\download filename[.pk3]
-\dlmap mapname[.pk3]
-
-\dlmap is the same as \download but also will check for map existence -
-
-cl_dlURL cvar must point to download location, where (optional) %1 pattern will be replaced by \download|dlmap command argument (filename/mapmane) and HTTP header may be analysed to obtain destination filename

- -For example:

-  1) If cl_dlURL is http://127.0.0.1 and you type \download promaps.pk3 - -  resulting download url will be http://127.0.0.1/promaps.pk3
-  2) If cl_dlURL is http://127.0.0.1/%1 and you type \dlmap dm17 - -  resulting download url will be http://127.0.0.1/dm17
-  Also in this case HTTP-header will be analysed and resulting filename may be changed
- -
-To stop download just specify '-' as argument:
-
-  \dlmap - -

-cl_dlDirectory cvar specifies where to save downloaded files:

-  0 - save in current game directory
-  1 - save in fs_basegame (baseq3) directory
-
-


-

Built-in URL-filter

-There is ability to launch Quake3 1.32e client directly from your browser -by just clicking on URL that contains q3a:// -instead of usual http:// or ftp:// protocol headers

- -What you need to do: -

    -
  • copy q3url_add.cmd/q3url_rem.cmd in quake3e.exe directory
  • -
  • run q3url_add.cmd if you want to add protocol binding or q3url_add.cmd if you want to remove it
  • -
  • type in your browser q3a://127.0.0.1 and follow it - if you see quake3e launching and trying to connect then everything is fine -
  • -
-
-
-

Condifional shader stages

-Optional "if"-"elif"-"else" keywords can be used to control which shaders stages can be loaded depending from some cvar values.
-For example, old shader: -
-console
-{
- nopicmip
- nomipmaps
- {
-  map image1.tga
-  blendFunc blend
-  tcmod scale 1 1
-  }
-}
-
-New shader: -
-console
-{
- nopicmip
- nomipmaps
- if ( $r_vertexLight == 1 && $r_dynamicLight )
- {
-  map image1.tga
-  blendFunc blend
-  tcmod scale 1 1
- }
- else
- {
-  map image2.tga
-  blendFunc add
-  tcmod scale 1 1
- }
-}
-
-lvalue-only conditions are supported, count of conditions inside if()/elif() is not limited -
-
-
-

Redurect captured video to ffmpeg input pipe

-In order to use this functionality you need to install ffmpeg package (on linux) or put ffmpeg binary near quake3e executable (on windows).
-
-Use \cl_aviPipeFormat to control encoder parameters passed to ffmpeg, see ffmpeg documentation for details, default value is set according to YouTube recommendations:
-
--preset medium -crf 23 -c:v libx264 -flags +cgop -pix_fmt yuvj420p -bf 2 -c:a aac -strict -2 -b:a 160k -movflags faststart
-If you need higher bitrate - decrease -crf parameter, if you need better compression at cost of cpu time - set -preset to slow or slower.
-
-And since ffmpeg can utilize all available CPU cores for faster encoding - make sure you have \com_affinityMask set to 0. -
-
-
-
Arbitrary resolution rendering
-
-Use \r_renderWidth and \r_renderHeight cvars to set persistant rendering resolution, i.e. game frame will be rendered at this resolution and later upscaled/downscaled to window size set by either \r_mode or \r_modeFullscreen cvars.
-Cvar \r_renderScale controls upscale/downscale behavior: -
    -
  • 0 - disabled
  • -
  • 1 - nearest filtering, stretch to full size
  • -
  • 2 - nearest filtering, preserve aspect ratio (black bars on sides)
  • -
  • 3 - linear filtering, stretch to full size
  • -
  • 4 - linear filtering, preserve aspect ratio (black bars on sides)
  • -
-It may be useful if you want to render and record 4k+ video on HD display or if you're preferring playing at low resolution but your monitor or GPU driver can't set video|scaling mode properly.
-
-
-
High-Quality Bloom

-Requires \r_fbo 1, available operation modes via \r_bloom cvar: -
    -
  • 0 - disabled
  • -
  • 1 - enabled
  • -
  • 2 - enabled + applies to 2D/HUD elements too
  • -
-\r_bloom_threshold - color level to extract to bloom texture, default is 0.6
-
-\r_bloom_threshold_mode - color extraction mode:
-
    -
  • 0 - (r|g|b) >= threshold
  • -
  • 1 - (r+g+b)/3 >= threshold
  • -
  • 2 - luma(r,g,b) >= threshold
  • -
-\r_bloom_modulate - modulate extracted color:
-
    -
  • 0 - off (color=color, i.e. no changes)
  • -
  • 1 - by itself (color=color*color)
  • -
  • 2 - by intensity (color=color*luma(color))
  • -
-\r_bloom_intensity - final bloom blend factor, default is 0.5
-
-\r_bloom_passes - count of downsampled passes (framebuffers) to blend on final bloom image, default is 5
-
-\r_bloom_blend_base - 0-based, topmost downsampled framebuffer to use for final image, high values can be used for stronger haze effect, results in overall weaker intensity
-
-\r_bloom_filter_size - filter size of Gaussian Blur effect for each pass, bigger filter size means stronger and wider blur, lower value are faster, default is 6
-
-\r_bloom_reflection - bloom lens reflection effect, value is an intensity factor of the effect, negative value means blend only reflection and skip main bloom texture
-
- -
-End Of Document -
- diff --git a/docs/quake3e.md b/docs/quake3e.md deleted file mode 100644 index 311612cc5e..0000000000 --- a/docs/quake3e.md +++ /dev/null @@ -1,265 +0,0 @@ -# Quake3e - -

-This client aims to be fully compatible with original baseq3 and other mods -while trying to be fast, reliable and bug-free. -
-It is based on ioquake3-r1160 (latest non-SDL revision) with upstream patches an many custom improvements.
-
-Common changes/additions: -

    -
  • a lot of security, performance and bug fixes
  • -
  • much improved autocompletion (map, demo, exec and other commands), in-game \callvote argument autocompletion
  • -
  • \com_affinityMask - bind Quake3e process to bitmask-specified CPU core(s)
  • -
  • raized filesystem limits, much faster startup with 1000+ pk3 files in use, level restart times were also reduced as well
  • -
  • \fs_locked 0|1 - keep opened pk3 files locked or not, removes pk3 file limit when unlocked
  • -
-Client-specific changes/additions: - - -Server-specific changes/additions: -
    -
  • \sv_levelTimeReset 0|1 - reset or do not reset leveltime after new map loads, when enabled - fixes gfx for clients affected by "frameloss" bug, however it may be necessary disable in case of troubles with GTV
  • -
  • \sv_maxclientsPerIP - limit number of simultaneous connections from the same IP address
  • -
  • much improved DDoS protection
  • -
  • \sv_minPing and \sv_maxPing were removed because of new much better client connecion code
  • -
  • userinfo filtering system, see docs/filter.txt
  • -
  • rcon now is always available on dedicated servers
  • -
  • rconPassword2 - hidden master rcon password that can be set only from command line, i.e.
    -   +set rconPassword2 "123456"
    -can be used to change/revoke compromised rconPassword
  • -
  • significally reduced memory usage for client slots
  • - -
- -
-
-

\in_minimize -
-
- cvar that specifies hotkey for fast minimize/restore main windows, set values in form
-   \in_minimize "ctrl+z"
-   \in_minimize "lshift+ralt+\"
-   or so then do \in_restart to apply changes. -
-
- -


-

Fast client downloads

-Usually downloads in Q3 is slow because all dowloaded data is requested/revieced from game server directly. -So called `download redirection' allows very fast downloads because game server just tells you from where you should download all required mods/maps etc. - it can be internet or local http/ftp server
-So what you need: -

    -
  • set sv_dlURL cvar to download location, for example:
    -  sets sv_dlURL "ftp://myftp.com/games/q3"
    - Please note that your link should point on root game directory not particular mod or so -
    -
  • - -
  • Fill your download location with files.
    -   Please note that you should post ALL files that client may download, don't worry about pk3 overflows etc. on client side as client will download and use only required files -
  • -
-
-
-
-

Fast client-initiated downloads

-You can easy download pk3 files you need from any ftp/http/etc resource via following commands:
- -\download filename[.pk3]
-\dlmap mapname[.pk3]
-
-\dlmap is the same as \download but also will check for map existence -
-
-cl_dlURL cvar must points to download location, where (optional) %1 pattern will be replaced by \download|dlmap command argument (filename/mapmane) and HTTP header may be analysed to obtain destination filename

- -For example:

-  1) If cl_dlURL is http://127.0.0.1 and you type \download promaps.pk3 - -  resulting download url will be http://127.0.0.1/promaps.pk3
-  2) If cl_dlURL is http://127.0.0.1/%1 and you type \dlmap dm17 - -  resulting download url will be http://127.0.0.1/dm17
-  Also in this case HTTP-header will be analysed and resulting filename may be changed
- -
-To stop download just specify '-' as argument:
-
-  \dlmap - -

-cl_dlDirectory cvar specifies where to save downloaded files:

-  0 - save in current game directory
-  1 - save in fs_basegame (baseq3) directory
-
-


-

Built-in URL-filter

-There is ability to launch Quake3 1.32e client directly from your browser -by just clicking on URL that contains q3a:// -instead of usual http:// or ftp:// protocol headers

- -What you need to do: -

    -
  • copy q3url_add.cmd/q3url_rem.cmd in quake3e.exe directory
  • -
  • run q3url_add.cmd if you want to add protocol binding or q3url_add.cmd if you want to remove it
  • -
  • type in your browser q3a://127.0.0.1 and follow it - if you see quake3e launching and trying to connect then everything is fine -
  • -
-
-
-

Condifional shader stages

-Optional "if"-"elif"-"else" keywords can be used to control which shaders stages can be loaded depending from some cvar values.
-For example, old shader: -
-console
-{
- nopicmip
- nomipmaps
- {
-  map image1.tga
-  blendFunc blend
-  tcmod scale 1 1
-  }
-}
-
-New shader: -
-console
-{
- nopicmip
- nomipmaps
- if ( $r_vertexLight == 1 && $r_dynamicLight )
- {
-  map image1.tga
-  blendFunc blend
-  tcmod scale 1 1
- }
- else
- {
-  map image2.tga
-  blendFunc add
-  tcmod scale 1 1
- }
-}
-
-lvalue-only conditions are supported, count of conditions inside if()/elif() is not limited -
-
-
-

Redurect captured video to ffmpeg input pipe

-In order to use this functionality you need to install ffmpeg package (on linux) or put ffmpeg binary near quake3e executable (on windows).
-
-Use \cl_aviPipeFormat to control encoder parameters passed to ffmpeg, see ffmpeg documentation for details, default value is set according to YouTube recommendations:
-
--preset medium -crf 23 -c:v libx264 -flags +cgop -pix_fmt yuvj420p -bf 2 -c:a aac -strict -2 -b:a 160k -movflags faststart
-If you need higher bitrate - decrease -crf parameter, if you need better compression at cost of cpu time - set -preset to slow or slower.
-
-And since ffmpeg can utilize all available CPU cores for faster encoding - make sure you have \com_affinityMask set to 0. -
-
-
-
Arbitrary resolution rendering
-
-Use \r_renderWidth and \r_renderHeight cvars to set persistant rendering resolution, i.e. game frame will be rendered at this resolution and later upscaled/downscaled to window size set by either \r_mode or \r_modeFullscreen cvars.
-Cvar \r_renderScale controls upscale/downscale behavior: -
    -
  • 0 - disabled
  • -
  • 1 - nearest filtering, stretch to full size
  • -
  • 2 - nearest filtering, preserve aspect ratio (black bars on sides)
  • -
  • 3 - linear filtering, stretch to full size
  • -
  • 4 - linear filtering, preserve aspect ratio (black bars on sides)
  • -
-It may be useful if you want to render and record 4k+ video on HD display or if you're preferring playing at low resolution but your monitor or GPU driver can't set video|scaling mode properly.
-
-
-
High-Quality Bloom

-Requires \r_fbo 1, available operation modes via \r_bloom cvar: -
    -
  • 0 - disabled
  • -
  • 1 - enabled
  • -
  • 2 - enabled + applies to 2D/HUD elements too
  • -
-\r_bloom_threshold - color level to extract to bloom texture, default is 0.6
-
-\r_bloom_threshold_mode - color extraction mode:
-
    -
  • 0 - (r|g|b) >= threshold
  • -
  • 1 - (r+g+b)/3 >= threshold
  • -
  • 2 - luma(r,g,b) >= threshold
  • -
-\r_bloom_modulate - modulate extracted color:
-
    -
  • 0 - off (color=color, i.e. no changes)
  • -
  • 1 - by itself (color=color*color)
  • -
  • 2 - by intensity (color=color*luma(color))
  • -
-\r_bloom_intensity - final bloom blend factor, default is 0.5
-
-\r_bloom_passes - count of downsampled passes (framebuffers) to blend on final bloom image, default is 5
-
-\r_bloom_blend_base - 0-based, topmost downsampled framebuffer to use for final image, high values can be used for stronger haze effect, results in overall weaker intensity
-
-\r_bloom_filter_size - filter size of Gaussian Blur effect for each pass, bigger filter size means stronger and wider blur, lower value are faster, default is 6
-
-\r_bloom_reflection - bloom lens reflection effect, value is an intensity factor of the effect, negative value means blend only reflection and skip main bloom texture
-
- -
-End Of Document -
- diff --git a/scripts/compile_engine.sh b/scripts/compile_engine.sh new file mode 100755 index 0000000000..be6a6ffa90 --- /dev/null +++ b/scripts/compile_engine.sh @@ -0,0 +1,201 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Usage: ./compile_engine.sh [game_name] [Debug|Release] [clean] [quiet] [coverage] [vulkan] [opengl] +# Notes: +# - build type defaults to Release +# - vulkan and opengl are mutually exclusive +# - if neither is specified: defaults to OpenGL +# - first unrecognized arg becomes game_name + +VULKAN=0 +OPENGL=0 +SKIP_IDPAK=0 + +GAME_NAME="idtech3" +BUILD_TYPE="Release" +CLEAN=0 +COVERAGE=0 +QUIET=0 + +normalize_build_type() { + local arg + arg="$(echo "$1" | tr '[:upper:]' '[:lower:]')" + case "$arg" in + debug|dbg|d) echo "Debug" ;; + release|rel|r) echo "Release" ;; + *) echo "" ;; + esac +} + +# Find project root robustly (works whether script is in repo root or /scripts/) +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +if [ -f "$SCRIPT_DIR/CMakeLists.txt" ]; then + PROJECT_ROOT="$SCRIPT_DIR" +elif [ -f "$SCRIPT_DIR/../CMakeLists.txt" ]; then + PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" +else + echo "Error: Could not find CMakeLists.txt near script location." + exit 1 +fi + +RELEASE_DIR="$PROJECT_ROOT/release" + +# Argument parsing +for arg in "$@"; do + norm_bt="$(normalize_build_type "$arg")" + if [ -n "$norm_bt" ]; then BUILD_TYPE="$norm_bt"; continue; fi + + case "$arg" in + clean) CLEAN=1 ;; + coverage|cov) COVERAGE=1 ;; + quiet|-q|--quiet|q|silent|-s|--silent) QUIET=1 ;; + vulkan) VULKAN=1 ;; + skip-idpak-check|skip_idpak_check|skip-pak|skip-paks) SKIP_IDPAK=1 ;; + opengl) OPENGL=1 ;; + *) GAME_NAME="$arg" ;; + esac +done + +if [ "$VULKAN" -eq 1 ] && [ "$OPENGL" -eq 1 ]; then + echo "Error: vulkan and opengl are mutually exclusive" + exit 1 +fi + +# Default to OpenGL if neither specified +if [ "$VULKAN" -eq 0 ] && [ "$OPENGL" -eq 0 ]; then + OPENGL=1 +fi + +# Renderer-specific build directory (prevents cache collisions) +if [ "$VULKAN" -eq 1 ]; then + BUILD_DIR="$PROJECT_ROOT/build-vk-${BUILD_TYPE}" +else + BUILD_DIR="$PROJECT_ROOT/build-gl-${BUILD_TYPE}" +fi + +echo "Building id Tech 3 engine (${BUILD_TYPE})..." +echo "Project root: $PROJECT_ROOT" +echo "Build dir: $BUILD_DIR" +echo "Release dir: $RELEASE_DIR" + +if [ "$CLEAN" -eq 1 ]; then + echo "Cleaning build directory..." + rm -rf "$BUILD_DIR" + rm -rf "$PROJECT_ROOT/build-coverage" || true +fi + +mkdir -p "$BUILD_DIR" + +# CPU cores +if command -v nproc &>/dev/null; then + CORES="$(nproc)" +elif [[ "${OSTYPE:-}" =~ ^darwin ]]; then + CORES="$(sysctl -n hw.ncpu 2>/dev/null || echo 4)" +else + CORES=4 +fi + +# CMake flags +CMAKE_FLAGS=( + "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" + "-DUSE_STB_TRUETYPE=ON" + "-DENABLE_FORTIFY_SOURCE=OFF" + "-DENABLE_ASAN=OFF" + "-DBUILD_SERVER=ON" + "-DUSE_VULKAN=ON" + "-Wno-dev" +) + +if [ "$VULKAN" -eq 1 ]; then + CMAKE_FLAGS+=("-DRENDERER_DEFAULT=vulkan") +else + CMAKE_FLAGS+=("-DRENDERER_DEFAULT=opengl") +fi + +if [ "$SKIP_IDPAK" -eq 1 ]; then + CMAKE_FLAGS+=("-DSKIP_IDPAK_CHECK=ON") + echo "CMake: SKIP_IDPAK_CHECK=ON" +fi + +echo "Running CMake configuration..." +cmake -S "$PROJECT_ROOT" -B "$BUILD_DIR" "${CMAKE_FLAGS[@]}" + +echo "Building with ${CORES} parallel jobs..." +if [ "$QUIET" -eq 1 ]; then + cmake --build "$BUILD_DIR" -- -j"${CORES}" -s +else + cmake --build "$BUILD_DIR" -- -j"${CORES}" +fi + +echo "" +echo "Build completed. Binaries are in $BUILD_DIR" + +echo "" +echo "Copying engine binaries and renderer .so files to $RELEASE_DIR..." +mkdir -p "$RELEASE_DIR" + +# Game data (minimal): ensure base/default.cfg exists in release. +# The engine reads base/default.cfg very early (before +set fs_game is applied). +if [ -d "$PROJECT_ROOT/base" ]; then + mkdir -p "$RELEASE_DIR/base" + # Copy only small text assets; keep this conservative. + if [ -f "$PROJECT_ROOT/base/default.cfg" ]; then + cp -f "$PROJECT_ROOT/base/default.cfg" "$RELEASE_DIR/base/default.cfg" + fi +fi + +# Client +if [ -f "$BUILD_DIR/idtech3.x86_64" ]; then + cp -f "$BUILD_DIR/idtech3.x86_64" "$RELEASE_DIR/${GAME_NAME}.x86_64" + echo "Copied client -> $RELEASE_DIR/${GAME_NAME}.x86_64" +fi + + +if [ -f "$BUILD_DIR/idtech3" ]; then + cp -f "$BUILD_DIR/idtech3" "$RELEASE_DIR/${GAME_NAME}" + echo "Copied client -> $RELEASE_DIR/${GAME_NAME}" +fi + +# Server +if [ -f "$BUILD_DIR/idtech3_server.x86_64" ]; then + cp -f "$BUILD_DIR/idtech3_server.x86_64" "$RELEASE_DIR/${GAME_NAME}_server.x86_64" + echo "Copied server -> $RELEASE_DIR/${GAME_NAME}_server.x86_64" +fi + + +if [ -f "$BUILD_DIR/idtech3_server" ]; then + cp -f "$BUILD_DIR/idtech3_server" "$RELEASE_DIR/${GAME_NAME}_server" + echo "Copied server -> $RELEASE_DIR/${GAME_NAME}_server" +fi + + +# Renderers +shopt -s nullglob +for sofile in "$BUILD_DIR"/idtech3_*_*.so; do + base="$(basename "$sofile")" + cp -f "$sofile" "$RELEASE_DIR/$base" + echo "Copied renderer -> $RELEASE_DIR/$base" +done +shopt -u nullglob + +# ImGui shared +if [ -f "$BUILD_DIR/libimgui_shared.so" ]; then + cp -f "$BUILD_DIR/libimgui_shared.so" "$RELEASE_DIR/" + echo "Copied libimgui_shared.so to $RELEASE_DIR/" +fi + +# Coverage +if [ "$COVERAGE" -eq 1 ]; then + echo "" + echo "Running coverage configuration/build (Debug, ENABLE_COVERAGE=ON)..." + if ! command -v gcovr >/dev/null 2>&1; then + echo "gcovr not found in PATH; skipping coverage report generation." + else + cmake -S "$PROJECT_ROOT" -B "$PROJECT_ROOT/build-coverage" -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON + cmake --build "$PROJECT_ROOT/build-coverage" --target coverage + echo "Coverage artifacts (HTML/XML) should be in build-coverage/" + fi +fi + +echo "✓ Engine artifacts ready in $RELEASE_DIR" diff --git a/scripts/compile_game.sh b/scripts/compile_game.sh new file mode 100755 index 0000000000..ee5fa58309 --- /dev/null +++ b/scripts/compile_game.sh @@ -0,0 +1,295 @@ +#!/bin/bash + +# Compile Game Script for id Tech 3 mods, with robust CMake cache handling +set -euo pipefail + +# Usage: ./compile_game.sh [mod_name] [Debug|Release] [clean] + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" + +MOD_NAME="" +BUILD_TYPE="Release" +CLEAN=0 +PK3_ENABLED=1 + +normalize_build_type() { + local arg=$(echo "$1" | tr '[:upper:]' '[:lower:]') + case "$arg" in + debug|dbg|d) echo "Debug" ;; + release|rel|r) echo "Release" ;; + *) echo "" ;; + esac +} + +# Argument parsing: first non-flag is mod name +for arg in "$@"; do + # Handle help flag + if [ "$arg" = "--help" ] || [ "$arg" = "-h" ]; then + echo "Usage: $0 [mod_name] [Debug|Release] [clean]" + echo "" + echo "Options:" + echo " mod_name Name of the mod to compile (default: mymod)" + echo " Debug Build in Debug mode" + echo " Release Build in Release mode (default)" + echo " clean Clean build directory before building" + echo "" + echo "Examples:" + echo " $0 openarena # Build openarena mod in Release mode" + echo " $0 mymod Debug # Build mymod in Debug mode" + echo " $0 openarena Release clean # Clean build of openarena" + exit 0 + fi + norm_bt="$(normalize_build_type "$arg")" + if [ -n "$norm_bt" ]; then + BUILD_TYPE="$norm_bt" + continue + fi + if [ "$arg" = "clean" ]; then + CLEAN=1 + continue + fi + if [ -z "$MOD_NAME" ]; then + MOD_NAME="$arg" + fi +done +MOD_NAME=${MOD_NAME:-mymod} + +MOD_ROOT="$PROJECT_ROOT/mods/$MOD_NAME" +MOD_SOURCE_DIR="$MOD_ROOT/gamesrc" +MOD_BUILD_DIR="$MOD_SOURCE_DIR/build" +MOD_VM_DIR="$MOD_ROOT/vm" +RELEASE_MOD_DIR="$PROJECT_ROOT/release/$MOD_NAME" +RELEASE_VM_DIR="$RELEASE_MOD_DIR/vm" +RELEASE_PK3="$RELEASE_MOD_DIR/$MOD_NAME.pk3" +RUNTIME_VM_DIR="$HOME/.$MOD_NAME/vm" + +if [ ! -d "$MOD_SOURCE_DIR" ]; then + echo "Error: ${MOD_SOURCE_DIR} not found." + echo "" + echo "Available mods with gamesrc:" + for moddir in "$PROJECT_ROOT/mods"/*/; do + if [ -d "${moddir}gamesrc" ]; then + echo " - $(basename "$moddir")" + fi + done + echo "" + echo "Usage: $0 [mod_name] [Debug|Release] [clean]" + exit 1 +fi + +echo "Building game modules..." +echo "Project root: $PROJECT_ROOT" +echo "Mod name: $MOD_NAME" +echo "Build type: $BUILD_TYPE" +echo "Module sources: $MOD_SOURCE_DIR" +echo "Release destination: $RELEASE_MOD_DIR" + +cd "$MOD_SOURCE_DIR" + +# Check for CMake cache source mismatch or cross-directory confusion and fix it +CMAKE_CACHE="$MOD_BUILD_DIR/CMakeCache.txt" +CMAKE_CACHE_DIR_OK=1 +if [ -f "$CMAKE_CACHE" ]; then + # Extract CMAKE_HOME_DIRECTORY and look for old/bad values + CACHE_SRC_DIR=$(grep '^CMAKE_HOME_DIRECTORY:INTERNAL=' "$CMAKE_CACHE" | head -n1 | cut -d= -f2) + if [ -n "$CACHE_SRC_DIR" ] && [ "$CACHE_SRC_DIR" != "$MOD_SOURCE_DIR" ]; then + echo "" + echo "Warning:" + echo "CMake cache source mismatch detected." + echo " CMakeCache.txt: $CMAKE_CACHE" + echo " Current source: $MOD_SOURCE_DIR" + echo " Cached source: $CACHE_SRC_DIR" + echo "Removing bad CMake cache. (This happens when moving or renaming mod/source directories.)" + rm -rf "$MOD_BUILD_DIR" + fi +fi + +if [ $CLEAN -eq 1 ] && [ -d "$MOD_BUILD_DIR" ]; then + echo "Cleaning old build directory..." + rm -rf "$MOD_BUILD_DIR" +fi + +# Remove old VM files from the mod's own release directory (optional) +if [ $CLEAN -eq 1 ] && [ -d "$RELEASE_VM_DIR" ]; then + echo "Removing old VM files from $RELEASE_VM_DIR ..." + rm -f "$RELEASE_VM_DIR"/*.so "$RELEASE_VM_DIR"/*.dll 2>/dev/null || true +fi + +# Create build directory and configure CMake +mkdir -p "$MOD_BUILD_DIR" +cd "$MOD_BUILD_DIR" +if ! cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE ..; then + echo "Error: CMake configuration failed for $MOD_NAME" + exit 1 +fi + +# Build with parallel jobs +if command -v nproc &>/dev/null; then + CORES=$(nproc) +elif [[ "$OSTYPE" == "darwin"* ]]; then + CORES=$(sysctl -n hw.ncpu) +else + CORES=4 +fi +if ! cmake --build . -- -j${CORES}; then + echo "Error: Build failed for $MOD_NAME" + exit 1 +fi + +# VM files should be in mod/vm/ directory +echo "Checking for compiled VM files in $MOD_VM_DIR" +mkdir -p "$MOD_VM_DIR" + +# Map upstream artifact names to engine-expected names +map_vm_name() { + local base="$1" + case "$base" in + gamex86_64.so) echo "game.x86_64.so" ;; + cgamex86_64.so) echo "cgame.x86_64.so" ;; + uix86_64.so) echo "ui.x86_64.so" ;; + *) echo "$base" ;; + esac +} + +shopt -s nullglob +# Prefer vm/ outputs, but also pick up direct outputs in the mod root (CMake BS_OUTPUT_DIR=..) +ARTIFACTS=("$MOD_VM_DIR"/*.so "$MOD_VM_DIR"/*.dll "$MOD_ROOT"/*x86_64.so "$MOD_ROOT"/*x86_64.dll) +shopt -u nullglob + +if [ ${#ARTIFACTS[@]} -eq 0 ]; then + echo "Warning: No shared libraries found in $MOD_VM_DIR/" +else + mkdir -p "$RELEASE_VM_DIR" + mkdir -p "$RUNTIME_VM_DIR" + # Clear stale qvms and misnamed so files so the engine loads the fresh natives + rm -f "$RELEASE_VM_DIR"/*.qvm "$RUNTIME_VM_DIR"/*.qvm \ + "$RELEASE_VM_DIR"/gamex86_64.so "$RELEASE_VM_DIR"/cgamex86_64.so "$RELEASE_VM_DIR"/uix86_64.so \ + "$RUNTIME_VM_DIR"/gamex86_64.so "$RUNTIME_VM_DIR"/cgamex86_64.so "$RUNTIME_VM_DIR"/uix86_64.so 2>/dev/null || true + echo "Copying files to mod's release directory: $RELEASE_VM_DIR (and runtime: $RUNTIME_VM_DIR)" + + # Track which files we've already copied to avoid duplicates + declare -A copied_files + + for lib in "${ARTIFACTS[@]}"; do + if [ ! -f "$lib" ]; then + continue + fi + libname=$(basename "$lib") + mapped=$(map_vm_name "$libname") + + # Skip if we've already copied this mapped name + # Use [[ -v ]] to check if key exists (works with set -u) + if [[ -v copied_files[$mapped] ]]; then + continue + fi + + # Only copy if the target doesn't exist or source is newer + if [ ! -f "$RELEASE_VM_DIR/$mapped" ] || [ "$lib" -nt "$RELEASE_VM_DIR/$mapped" ]; then + cp -v "$lib" "$RELEASE_VM_DIR/$mapped" + cp -v "$lib" "$RUNTIME_VM_DIR/$mapped" + copied_files[$mapped]=1 + fi + done + echo "Libraries copied to $RELEASE_VM_DIR/" +fi + +package_pk3() { + INCLUDES=() + add_if_exists() { + local rel="$1" + if [ -e "$MOD_ROOT/$rel" ]; then + INCLUDES+=("$rel") + fi + } + + add_if_exists "default.cfg" + add_if_exists "autoexec.cfg" + add_if_exists "config" + add_if_exists "fonts" + add_if_exists "scripts" + add_if_exists "shaders" + add_if_exists "textures" + add_if_exists "models" + add_if_exists "players" + add_if_exists "ui" + add_if_exists "vm" + add_if_exists "maps" + add_if_exists "levelshots" + add_if_exists "gfx" + add_if_exists "sound" + + if [ ${#INCLUDES[@]} -eq 0 ]; then + echo "Nothing to package into pk3 for $MOD_NAME." + return + fi + + mkdir -p "$RELEASE_MOD_DIR" + cd "$MOD_ROOT" + + echo "Packaging ${MOD_NAME}.pk3 ..." + + # Verbose output: list contents and details before packaging + echo "Included in pk3:" + for inc in "${INCLUDES[@]}"; do + if [ -d "$MOD_ROOT/$inc" ]; then + # List files recursively for this directory + echo " [DIR] $inc" + find "$inc" -type f | while IFS= read -r file; do + # Print with indent and size + if [ -f "$file" ]; then + size=$(stat -c%s "$file" 2>/dev/null || stat -f%z "$file") + printf " - %s (%s bytes)\n" "$file" "$size" + fi + done + elif [ -f "$MOD_ROOT/$inc" ]; then + size=$(stat -c%s "$MOD_ROOT/$inc" 2>/dev/null || stat -f%z "$MOD_ROOT/$inc") + echo " [FILE] $inc ($size bytes)" + else + echo " [??] $inc (not found?)" + fi + done + + # zip may return non-zero exit codes for warnings, so check if file was created + zip -r "$RELEASE_PK3" "${INCLUDES[@]}" \ + -x "gamesrc/*" "gamesrc/**" \ + "build/*" "build/**" \ + "out/*" "out/**" \ + "vm/*.a" "vm/*.pdb" "vm/*.dll" \ + "**/.DS_Store" "**/.git*" "**/CMakeFiles/**" \ + >/dev/null 2>&1 || true # Ignore zip exit code, check file existence instead + + if [ -f "$RELEASE_PK3" ]; then + echo "✓ Wrote $RELEASE_PK3" + else + echo "Warning: PK3 package creation may have failed, but build succeeded" + fi +} + +if [ $PK3_ENABLED -eq 1 ]; then + package_pk3 +fi + +echo "" +if [ -d "$RELEASE_VM_DIR" ]; then + # Use find instead of ls to avoid exit code issues with globs + SO_COUNT=$(find "$RELEASE_VM_DIR" -maxdepth 1 \( -name "*.so" -o -name "*.dll" \) 2>/dev/null | wc -l) + if [ "$SO_COUNT" -gt 0 ]; then + echo "Libraries available in $RELEASE_VM_DIR/:" + ls -lh "$RELEASE_VM_DIR"/*.so "$RELEASE_VM_DIR"/*.dll 2>/dev/null || true + echo "✓ Game modules ready in $RELEASE_VM_DIR" + else + echo "Warning: No shared libraries found in $RELEASE_VM_DIR/" + fi +fi + +echo "" +echo "Game mod build completed!" +echo " Libraries: $RELEASE_VM_DIR/*.so" +if [ -f "$RELEASE_VM_DIR/game.x86_64.so" ]; then + echo " Game module: $RELEASE_VM_DIR/game.x86_64.so" +fi +if [ -f "$RELEASE_PK3" ]; then + echo " Package: $RELEASE_PK3" +fi +echo " Source: $MOD_SOURCE_DIR/" diff --git a/make-macosx-app.sh b/scripts/make-macosx-app.sh similarity index 100% rename from make-macosx-app.sh rename to scripts/make-macosx-app.sh diff --git a/make-macosx-ub2.sh b/scripts/make-macosx-ub2.sh similarity index 100% rename from make-macosx-ub2.sh rename to scripts/make-macosx-ub2.sh diff --git a/code/asm/common_x64.asm b/src/asm/common_x64.asm similarity index 100% rename from code/asm/common_x64.asm rename to src/asm/common_x64.asm diff --git a/code/asm/qasm.h b/src/asm/qasm.h similarity index 100% rename from code/asm/qasm.h rename to src/asm/qasm.h diff --git a/code/asm/snd_mix_mmx.s b/src/asm/snd_mix_mmx.s similarity index 100% rename from code/asm/snd_mix_mmx.s rename to src/asm/snd_mix_mmx.s diff --git a/code/asm/snd_mix_sse.s b/src/asm/snd_mix_sse.s similarity index 100% rename from code/asm/snd_mix_sse.s rename to src/asm/snd_mix_sse.s diff --git a/code/asm/snd_mix_x64.asm b/src/asm/snd_mix_x64.asm similarity index 100% rename from code/asm/snd_mix_x64.asm rename to src/asm/snd_mix_x64.asm diff --git a/code/asm/snd_mix_x86_64.s b/src/asm/snd_mix_x86_64.s similarity index 100% rename from code/asm/snd_mix_x86_64.s rename to src/asm/snd_mix_x86_64.s diff --git a/code/botlib/aasfile.h b/src/botlib/aasfile.h similarity index 100% rename from code/botlib/aasfile.h rename to src/botlib/aasfile.h diff --git a/code/botlib/be_aas.h b/src/botlib/be_aas.h similarity index 100% rename from code/botlib/be_aas.h rename to src/botlib/be_aas.h diff --git a/code/botlib/be_aas_bsp.h b/src/botlib/be_aas_bsp.h similarity index 100% rename from code/botlib/be_aas_bsp.h rename to src/botlib/be_aas_bsp.h diff --git a/code/botlib/be_aas_bspq3.c b/src/botlib/be_aas_bspq3.c similarity index 100% rename from code/botlib/be_aas_bspq3.c rename to src/botlib/be_aas_bspq3.c diff --git a/code/botlib/be_aas_cluster.c b/src/botlib/be_aas_cluster.c similarity index 100% rename from code/botlib/be_aas_cluster.c rename to src/botlib/be_aas_cluster.c diff --git a/code/botlib/be_aas_cluster.h b/src/botlib/be_aas_cluster.h similarity index 100% rename from code/botlib/be_aas_cluster.h rename to src/botlib/be_aas_cluster.h diff --git a/code/botlib/be_aas_debug.c b/src/botlib/be_aas_debug.c similarity index 100% rename from code/botlib/be_aas_debug.c rename to src/botlib/be_aas_debug.c diff --git a/code/botlib/be_aas_debug.h b/src/botlib/be_aas_debug.h similarity index 100% rename from code/botlib/be_aas_debug.h rename to src/botlib/be_aas_debug.h diff --git a/code/botlib/be_aas_def.h b/src/botlib/be_aas_def.h similarity index 100% rename from code/botlib/be_aas_def.h rename to src/botlib/be_aas_def.h diff --git a/code/botlib/be_aas_entity.c b/src/botlib/be_aas_entity.c similarity index 100% rename from code/botlib/be_aas_entity.c rename to src/botlib/be_aas_entity.c diff --git a/code/botlib/be_aas_entity.h b/src/botlib/be_aas_entity.h similarity index 100% rename from code/botlib/be_aas_entity.h rename to src/botlib/be_aas_entity.h diff --git a/code/botlib/be_aas_file.c b/src/botlib/be_aas_file.c similarity index 100% rename from code/botlib/be_aas_file.c rename to src/botlib/be_aas_file.c diff --git a/code/botlib/be_aas_file.h b/src/botlib/be_aas_file.h similarity index 100% rename from code/botlib/be_aas_file.h rename to src/botlib/be_aas_file.h diff --git a/code/botlib/be_aas_funcs.h b/src/botlib/be_aas_funcs.h similarity index 100% rename from code/botlib/be_aas_funcs.h rename to src/botlib/be_aas_funcs.h diff --git a/code/botlib/be_aas_main.c b/src/botlib/be_aas_main.c similarity index 100% rename from code/botlib/be_aas_main.c rename to src/botlib/be_aas_main.c diff --git a/code/botlib/be_aas_main.h b/src/botlib/be_aas_main.h similarity index 100% rename from code/botlib/be_aas_main.h rename to src/botlib/be_aas_main.h diff --git a/code/botlib/be_aas_move.c b/src/botlib/be_aas_move.c similarity index 100% rename from code/botlib/be_aas_move.c rename to src/botlib/be_aas_move.c diff --git a/code/botlib/be_aas_move.h b/src/botlib/be_aas_move.h similarity index 100% rename from code/botlib/be_aas_move.h rename to src/botlib/be_aas_move.h diff --git a/code/botlib/be_aas_optimize.c b/src/botlib/be_aas_optimize.c similarity index 100% rename from code/botlib/be_aas_optimize.c rename to src/botlib/be_aas_optimize.c diff --git a/code/botlib/be_aas_optimize.h b/src/botlib/be_aas_optimize.h similarity index 100% rename from code/botlib/be_aas_optimize.h rename to src/botlib/be_aas_optimize.h diff --git a/code/botlib/be_aas_reach.c b/src/botlib/be_aas_reach.c similarity index 100% rename from code/botlib/be_aas_reach.c rename to src/botlib/be_aas_reach.c diff --git a/code/botlib/be_aas_reach.h b/src/botlib/be_aas_reach.h similarity index 100% rename from code/botlib/be_aas_reach.h rename to src/botlib/be_aas_reach.h diff --git a/code/botlib/be_aas_route.c b/src/botlib/be_aas_route.c similarity index 100% rename from code/botlib/be_aas_route.c rename to src/botlib/be_aas_route.c diff --git a/code/botlib/be_aas_route.h b/src/botlib/be_aas_route.h similarity index 100% rename from code/botlib/be_aas_route.h rename to src/botlib/be_aas_route.h diff --git a/code/botlib/be_aas_routealt.c b/src/botlib/be_aas_routealt.c similarity index 100% rename from code/botlib/be_aas_routealt.c rename to src/botlib/be_aas_routealt.c diff --git a/code/botlib/be_aas_routealt.h b/src/botlib/be_aas_routealt.h similarity index 100% rename from code/botlib/be_aas_routealt.h rename to src/botlib/be_aas_routealt.h diff --git a/code/botlib/be_aas_sample.c b/src/botlib/be_aas_sample.c similarity index 100% rename from code/botlib/be_aas_sample.c rename to src/botlib/be_aas_sample.c diff --git a/code/botlib/be_aas_sample.h b/src/botlib/be_aas_sample.h similarity index 100% rename from code/botlib/be_aas_sample.h rename to src/botlib/be_aas_sample.h diff --git a/code/botlib/be_ai_char.c b/src/botlib/be_ai_char.c similarity index 100% rename from code/botlib/be_ai_char.c rename to src/botlib/be_ai_char.c diff --git a/code/botlib/be_ai_char.h b/src/botlib/be_ai_char.h similarity index 100% rename from code/botlib/be_ai_char.h rename to src/botlib/be_ai_char.h diff --git a/code/botlib/be_ai_chat.c b/src/botlib/be_ai_chat.c similarity index 100% rename from code/botlib/be_ai_chat.c rename to src/botlib/be_ai_chat.c diff --git a/code/botlib/be_ai_chat.h b/src/botlib/be_ai_chat.h similarity index 100% rename from code/botlib/be_ai_chat.h rename to src/botlib/be_ai_chat.h diff --git a/code/botlib/be_ai_gen.c b/src/botlib/be_ai_gen.c similarity index 100% rename from code/botlib/be_ai_gen.c rename to src/botlib/be_ai_gen.c diff --git a/code/botlib/be_ai_gen.h b/src/botlib/be_ai_gen.h similarity index 100% rename from code/botlib/be_ai_gen.h rename to src/botlib/be_ai_gen.h diff --git a/code/botlib/be_ai_goal.c b/src/botlib/be_ai_goal.c similarity index 100% rename from code/botlib/be_ai_goal.c rename to src/botlib/be_ai_goal.c diff --git a/code/botlib/be_ai_goal.h b/src/botlib/be_ai_goal.h similarity index 100% rename from code/botlib/be_ai_goal.h rename to src/botlib/be_ai_goal.h diff --git a/code/botlib/be_ai_move.c b/src/botlib/be_ai_move.c similarity index 100% rename from code/botlib/be_ai_move.c rename to src/botlib/be_ai_move.c diff --git a/code/botlib/be_ai_move.h b/src/botlib/be_ai_move.h similarity index 100% rename from code/botlib/be_ai_move.h rename to src/botlib/be_ai_move.h diff --git a/code/botlib/be_ai_weap.c b/src/botlib/be_ai_weap.c similarity index 100% rename from code/botlib/be_ai_weap.c rename to src/botlib/be_ai_weap.c diff --git a/code/botlib/be_ai_weap.h b/src/botlib/be_ai_weap.h similarity index 100% rename from code/botlib/be_ai_weap.h rename to src/botlib/be_ai_weap.h diff --git a/code/botlib/be_ai_weight.c b/src/botlib/be_ai_weight.c similarity index 100% rename from code/botlib/be_ai_weight.c rename to src/botlib/be_ai_weight.c diff --git a/code/botlib/be_ai_weight.h b/src/botlib/be_ai_weight.h similarity index 100% rename from code/botlib/be_ai_weight.h rename to src/botlib/be_ai_weight.h diff --git a/code/botlib/be_ea.c b/src/botlib/be_ea.c similarity index 100% rename from code/botlib/be_ea.c rename to src/botlib/be_ea.c diff --git a/code/botlib/be_ea.h b/src/botlib/be_ea.h similarity index 100% rename from code/botlib/be_ea.h rename to src/botlib/be_ea.h diff --git a/code/botlib/be_interface.c b/src/botlib/be_interface.c similarity index 100% rename from code/botlib/be_interface.c rename to src/botlib/be_interface.c diff --git a/code/botlib/be_interface.h b/src/botlib/be_interface.h similarity index 100% rename from code/botlib/be_interface.h rename to src/botlib/be_interface.h diff --git a/code/botlib/botlib.h b/src/botlib/botlib.h similarity index 100% rename from code/botlib/botlib.h rename to src/botlib/botlib.h diff --git a/code/botlib/l_crc.c b/src/botlib/l_crc.c similarity index 100% rename from code/botlib/l_crc.c rename to src/botlib/l_crc.c diff --git a/code/botlib/l_crc.h b/src/botlib/l_crc.h similarity index 100% rename from code/botlib/l_crc.h rename to src/botlib/l_crc.h diff --git a/code/botlib/l_libvar.c b/src/botlib/l_libvar.c similarity index 100% rename from code/botlib/l_libvar.c rename to src/botlib/l_libvar.c diff --git a/code/botlib/l_libvar.h b/src/botlib/l_libvar.h similarity index 100% rename from code/botlib/l_libvar.h rename to src/botlib/l_libvar.h diff --git a/code/botlib/l_log.c b/src/botlib/l_log.c similarity index 100% rename from code/botlib/l_log.c rename to src/botlib/l_log.c diff --git a/code/botlib/l_log.h b/src/botlib/l_log.h similarity index 100% rename from code/botlib/l_log.h rename to src/botlib/l_log.h diff --git a/code/botlib/l_memory.c b/src/botlib/l_memory.c similarity index 100% rename from code/botlib/l_memory.c rename to src/botlib/l_memory.c diff --git a/code/botlib/l_memory.h b/src/botlib/l_memory.h similarity index 100% rename from code/botlib/l_memory.h rename to src/botlib/l_memory.h diff --git a/code/botlib/l_precomp.c b/src/botlib/l_precomp.c similarity index 100% rename from code/botlib/l_precomp.c rename to src/botlib/l_precomp.c diff --git a/code/botlib/l_precomp.h b/src/botlib/l_precomp.h similarity index 100% rename from code/botlib/l_precomp.h rename to src/botlib/l_precomp.h diff --git a/code/botlib/l_script.c b/src/botlib/l_script.c similarity index 100% rename from code/botlib/l_script.c rename to src/botlib/l_script.c diff --git a/code/botlib/l_script.h b/src/botlib/l_script.h similarity index 100% rename from code/botlib/l_script.h rename to src/botlib/l_script.h diff --git a/code/botlib/l_struct.c b/src/botlib/l_struct.c similarity index 100% rename from code/botlib/l_struct.c rename to src/botlib/l_struct.c diff --git a/code/botlib/l_struct.h b/src/botlib/l_struct.h similarity index 100% rename from code/botlib/l_struct.h rename to src/botlib/l_struct.h diff --git a/code/botlib/l_utils.h b/src/botlib/l_utils.h similarity index 100% rename from code/botlib/l_utils.h rename to src/botlib/l_utils.h diff --git a/code/cgame/cg_public.h b/src/cgame/cg_public.h similarity index 100% rename from code/cgame/cg_public.h rename to src/cgame/cg_public.h diff --git a/code/client/cl_avi.c b/src/client/cl_avi.c similarity index 100% rename from code/client/cl_avi.c rename to src/client/cl_avi.c diff --git a/code/client/cl_cgame.c b/src/client/cl_cgame.c similarity index 100% rename from code/client/cl_cgame.c rename to src/client/cl_cgame.c diff --git a/code/client/cl_cin.c b/src/client/cl_cin.c similarity index 100% rename from code/client/cl_cin.c rename to src/client/cl_cin.c diff --git a/code/client/cl_console.c b/src/client/cl_console.c similarity index 100% rename from code/client/cl_console.c rename to src/client/cl_console.c diff --git a/code/client/cl_curl.c b/src/client/cl_curl.c similarity index 100% rename from code/client/cl_curl.c rename to src/client/cl_curl.c diff --git a/code/client/cl_curl.h b/src/client/cl_curl.h similarity index 100% rename from code/client/cl_curl.h rename to src/client/cl_curl.h diff --git a/code/client/cl_input.c b/src/client/cl_input.c similarity index 100% rename from code/client/cl_input.c rename to src/client/cl_input.c diff --git a/code/client/cl_jpeg.c b/src/client/cl_jpeg.c similarity index 100% rename from code/client/cl_jpeg.c rename to src/client/cl_jpeg.c diff --git a/code/client/cl_keys.c b/src/client/cl_keys.c similarity index 100% rename from code/client/cl_keys.c rename to src/client/cl_keys.c diff --git a/code/client/cl_main.c b/src/client/cl_main.c similarity index 99% rename from code/client/cl_main.c rename to src/client/cl_main.c index 9e23d28284..9176fe546d 100644 --- a/code/client/cl_main.c +++ b/src/client/cl_main.c @@ -3373,13 +3373,41 @@ static void CL_InitRef( void ) { #define REND_ARCH_STRING ARCH_STRING #endif - Com_sprintf( dllName, sizeof( dllName ), RENDERER_PREFIX "_%s_" REND_ARCH_STRING DLL_EXT, cl_renderer->string ); + { + /* sanitize renderer name: strip surrounding single/double quotes if present */ + const char *raw = cl_renderer->string; + char clean[64]; + size_t rawlen = strlen(raw); + if ( rawlen >= 2 && ((raw[0] == '\"' && raw[rawlen-1] == '\"') || (raw[0] == '\'' && raw[rawlen-1] == '\'')) ) { + size_t n = rawlen - 2; + if ( n >= sizeof(clean) ) n = sizeof(clean) - 1; + memcpy(clean, raw + 1, n); + clean[n] = '\0'; + } else { + Q_strncpyz(clean, raw, sizeof(clean)); + } + Com_sprintf( dllName, sizeof( dllName ), RENDERER_PREFIX "_%s_" REND_ARCH_STRING DLL_EXT, clean ); + } ospath = FS_BuildOSPath( Sys_DefaultBasePath(), dllName, NULL ); rendererLib = Sys_LoadLibrary( ospath ); if ( !rendererLib ) { Cvar_ForceReset( "cl_renderer" ); - Com_sprintf( dllName, sizeof( dllName ), RENDERER_PREFIX "_%s_" REND_ARCH_STRING DLL_EXT, cl_renderer->string ); + /* sanitize renderer name for the retry as well */ + { + const char *raw = cl_renderer->string; + char clean[64]; + size_t rawlen = strlen(raw); + if ( rawlen >= 2 && ((raw[0] == '\"' && raw[rawlen-1] == '\"') || (raw[0] == '\'' && raw[rawlen-1] == '\'')) ) { + size_t n = rawlen - 2; + if ( n >= sizeof(clean) ) n = sizeof(clean) - 1; + memcpy(clean, raw + 1, n); + clean[n] = '\0'; + } else { + Q_strncpyz(clean, raw, sizeof(clean)); + } + Com_sprintf( dllName, sizeof( dllName ), RENDERER_PREFIX "_%s_" REND_ARCH_STRING DLL_EXT, clean ); + } ospath = FS_BuildOSPath( Sys_DefaultBasePath(), dllName, NULL ); rendererLib = Sys_LoadLibrary( ospath ); if ( !rendererLib ) diff --git a/code/client/cl_net_chan.c b/src/client/cl_net_chan.c similarity index 100% rename from code/client/cl_net_chan.c rename to src/client/cl_net_chan.c diff --git a/code/client/cl_parse.c b/src/client/cl_parse.c similarity index 100% rename from code/client/cl_parse.c rename to src/client/cl_parse.c diff --git a/code/client/cl_scrn.c b/src/client/cl_scrn.c similarity index 100% rename from code/client/cl_scrn.c rename to src/client/cl_scrn.c diff --git a/code/client/cl_ui.c b/src/client/cl_ui.c similarity index 100% rename from code/client/cl_ui.c rename to src/client/cl_ui.c diff --git a/code/client/client.h b/src/client/client.h similarity index 100% rename from code/client/client.h rename to src/client/client.h diff --git a/code/client/keycodes.h b/src/client/keycodes.h similarity index 100% rename from code/client/keycodes.h rename to src/client/keycodes.h diff --git a/code/client/keys.h b/src/client/keys.h similarity index 100% rename from code/client/keys.h rename to src/client/keys.h diff --git a/src/client/mp3/cdct.c b/src/client/mp3/cdct.c new file mode 100644 index 0000000000..403ef9097f --- /dev/null +++ b/src/client/mp3/cdct.c @@ -0,0 +1,329 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: cdct.c,v 1.11 1999/10/19 07:13:08 elrod Exp $ +____________________________________________________________________________*/ + +/**** cdct.c *************************************************** + +mod 5/16/95 first stage in 8 pt dct does not drop last sb mono + + +MPEG audio decoder, dct +portable C + +******************************************************************/ + +#include "config.h" +#include +#include +#include +#include + +float coef32[31]; /* 32 pt dct coefs */ // !!!!!!!!!!!!!!!!!! (only generated once (always to same value) + +float *dct_coef_addr(void); +void fdct32(float x[], float c[]); +void fdct32_dual(float x[], float c[]); +void fdct32_dual_mono(float x[], float c[]); +void fdct16(float x[], float c[]); +void fdct16_dual(float x[], float c[]); +void fdct16_dual_mono(float x[], float c[]); +void fdct8(float x[], float c[]); +void fdct8_dual(float x[], float c[]); +void fdct8_dual_mono(float x[], float c[]); + +/*------------------------------------------------------------*/ +float *dct_coef_addr() +{ + return coef32; +} +/*------------------------------------------------------------*/ +static void forward_bf(int m, int n, float x[], float f[], float coef[]) +{ + int i, j, n2; + int p, q, p0, k; + + p0 = 0; + n2 = n >> 1; + for (i = 0; i < m; i++, p0 += n) + { + k = 0; + p = p0; + q = p + n - 1; + for (j = 0; j < n2; j++, p++, q--, k++) + { + f[p] = x[p] + x[q]; + f[n2 + p] = coef[k] * (x[p] - x[q]); + } + } +} +/*------------------------------------------------------------*/ +static void back_bf(int m, int n, float x[], float f[]) +{ + int i, j, n2, n21; + int p, q, p0; + + p0 = 0; + n2 = n >> 1; + n21 = n2 - 1; + for (i = 0; i < m; i++, p0 += n) + { + p = p0; + q = p0; + for (j = 0; j < n2; j++, p += 2, q++) + f[p] = x[q]; + p = p0 + 1; + for (j = 0; j < n21; j++, p += 2, q++) + f[p] = x[q] + x[q + 1]; + f[p] = x[q]; + } +} +/*------------------------------------------------------------*/ + + +void fdct32(float x[], float c[]) +{ + float a[32]; /* ping pong buffers */ + float b[32]; + int p, q; + + float *src = x; + +/* special first stage */ + for (p = 0, q = 31; p < 16; p++, q--) + { + a[p] = src[p] + src[q]; + a[16 + p] = coef32[p] * (src[p] - src[q]); + } + forward_bf(2, 16, a, b, coef32 + 16); + forward_bf(4, 8, b, a, coef32 + 16 + 8); + forward_bf(8, 4, a, b, coef32 + 16 + 8 + 4); + forward_bf(16, 2, b, a, coef32 + 16 + 8 + 4 + 2); + back_bf(8, 4, a, b); + back_bf(4, 8, b, a); + back_bf(2, 16, a, b); + back_bf(1, 32, b, c); +} +/*------------------------------------------------------------*/ +void fdct32_dual(float x[], float c[]) +{ + float a[32]; /* ping pong buffers */ + float b[32]; + int p, pp, qq; + +/* special first stage for dual chan (interleaved x) */ + pp = 0; + qq = 2 * 31; + for (p = 0; p < 16; p++, pp += 2, qq -= 2) + { + a[p] = x[pp] + x[qq]; + a[16 + p] = coef32[p] * (x[pp] - x[qq]); + } + forward_bf(2, 16, a, b, coef32 + 16); + forward_bf(4, 8, b, a, coef32 + 16 + 8); + forward_bf(8, 4, a, b, coef32 + 16 + 8 + 4); + forward_bf(16, 2, b, a, coef32 + 16 + 8 + 4 + 2); + back_bf(8, 4, a, b); + back_bf(4, 8, b, a); + back_bf(2, 16, a, b); + back_bf(1, 32, b, c); +} +/*---------------convert dual to mono------------------------------*/ +void fdct32_dual_mono(float x[], float c[]) +{ + float a[32]; /* ping pong buffers */ + float b[32]; + float t1, t2; + int p, pp, qq; + +/* special first stage */ + pp = 0; + qq = 2 * 31; + for (p = 0; p < 16; p++, pp += 2, qq -= 2) + { + t1 = 0.5F * (x[pp] + x[pp + 1]); + t2 = 0.5F * (x[qq] + x[qq + 1]); + a[p] = t1 + t2; + a[16 + p] = coef32[p] * (t1 - t2); + } + forward_bf(2, 16, a, b, coef32 + 16); + forward_bf(4, 8, b, a, coef32 + 16 + 8); + forward_bf(8, 4, a, b, coef32 + 16 + 8 + 4); + forward_bf(16, 2, b, a, coef32 + 16 + 8 + 4 + 2); + back_bf(8, 4, a, b); + back_bf(4, 8, b, a); + back_bf(2, 16, a, b); + back_bf(1, 32, b, c); +} +/*------------------------------------------------------------*/ +/*---------------- 16 pt fdct -------------------------------*/ +void fdct16(float x[], float c[]) +{ + float a[16]; /* ping pong buffers */ + float b[16]; + int p, q; + +/* special first stage (drop highest sb) */ + a[0] = x[0]; + a[8] = coef32[16] * x[0]; + for (p = 1, q = 14; p < 8; p++, q--) + { + a[p] = x[p] + x[q]; + a[8 + p] = coef32[16 + p] * (x[p] - x[q]); + } + forward_bf(2, 8, a, b, coef32 + 16 + 8); + forward_bf(4, 4, b, a, coef32 + 16 + 8 + 4); + forward_bf(8, 2, a, b, coef32 + 16 + 8 + 4 + 2); + back_bf(4, 4, b, a); + back_bf(2, 8, a, b); + back_bf(1, 16, b, c); +} +/*------------------------------------------------------------*/ +/*---------------- 16 pt fdct dual chan---------------------*/ +void fdct16_dual(float x[], float c[]) +{ + float a[16]; /* ping pong buffers */ + float b[16]; + int p, pp, qq; + +/* special first stage for interleaved input */ + a[0] = x[0]; + a[8] = coef32[16] * x[0]; + pp = 2; + qq = 2 * 14; + for (p = 1; p < 8; p++, pp += 2, qq -= 2) + { + a[p] = x[pp] + x[qq]; + a[8 + p] = coef32[16 + p] * (x[pp] - x[qq]); + } + forward_bf(2, 8, a, b, coef32 + 16 + 8); + forward_bf(4, 4, b, a, coef32 + 16 + 8 + 4); + forward_bf(8, 2, a, b, coef32 + 16 + 8 + 4 + 2); + back_bf(4, 4, b, a); + back_bf(2, 8, a, b); + back_bf(1, 16, b, c); +} +/*------------------------------------------------------------*/ +/*---------------- 16 pt fdct dual to mono-------------------*/ +void fdct16_dual_mono(float x[], float c[]) +{ + float a[16]; /* ping pong buffers */ + float b[16]; + float t1, t2; + int p, pp, qq; + +/* special first stage */ + a[0] = 0.5F * (x[0] + x[1]); + a[8] = coef32[16] * a[0]; + pp = 2; + qq = 2 * 14; + for (p = 1; p < 8; p++, pp += 2, qq -= 2) + { + t1 = 0.5F * (x[pp] + x[pp + 1]); + t2 = 0.5F * (x[qq] + x[qq + 1]); + a[p] = t1 + t2; + a[8 + p] = coef32[16 + p] * (t1 - t2); + } + forward_bf(2, 8, a, b, coef32 + 16 + 8); + forward_bf(4, 4, b, a, coef32 + 16 + 8 + 4); + forward_bf(8, 2, a, b, coef32 + 16 + 8 + 4 + 2); + back_bf(4, 4, b, a); + back_bf(2, 8, a, b); + back_bf(1, 16, b, c); +} +/*------------------------------------------------------------*/ +/*---------------- 8 pt fdct -------------------------------*/ +void fdct8(float x[], float c[]) +{ + float a[8]; /* ping pong buffers */ + float b[8]; + int p, q; + +/* special first stage */ + + b[0] = x[0] + x[7]; + b[4] = coef32[16 + 8] * (x[0] - x[7]); + for (p = 1, q = 6; p < 4; p++, q--) + { + b[p] = x[p] + x[q]; + b[4 + p] = coef32[16 + 8 + p] * (x[p] - x[q]); + } + + forward_bf(2, 4, b, a, coef32 + 16 + 8 + 4); + forward_bf(4, 2, a, b, coef32 + 16 + 8 + 4 + 2); + back_bf(2, 4, b, a); + back_bf(1, 8, a, c); +} +/*------------------------------------------------------------*/ +/*---------------- 8 pt fdct dual chan---------------------*/ +void fdct8_dual(float x[], float c[]) +{ + float a[8]; /* ping pong buffers */ + float b[8]; + int p, pp, qq; + +/* special first stage for interleaved input */ + b[0] = x[0] + x[14]; + b[4] = coef32[16 + 8] * (x[0] - x[14]); + pp = 2; + qq = 2 * 6; + for (p = 1; p < 4; p++, pp += 2, qq -= 2) + { + b[p] = x[pp] + x[qq]; + b[4 + p] = coef32[16 + 8 + p] * (x[pp] - x[qq]); + } + forward_bf(2, 4, b, a, coef32 + 16 + 8 + 4); + forward_bf(4, 2, a, b, coef32 + 16 + 8 + 4 + 2); + back_bf(2, 4, b, a); + back_bf(1, 8, a, c); +} +/*------------------------------------------------------------*/ +/*---------------- 8 pt fdct dual to mono---------------------*/ +void fdct8_dual_mono(float x[], float c[]) +{ + float a[8]; /* ping pong buffers */ + float b[8]; + float t1, t2; + int p, pp, qq; + +/* special first stage */ + t1 = 0.5F * (x[0] + x[1]); + t2 = 0.5F * (x[14] + x[15]); + b[0] = t1 + t2; + b[4] = coef32[16 + 8] * (t1 - t2); + pp = 2; + qq = 2 * 6; + for (p = 1; p < 4; p++, pp += 2, qq -= 2) + { + t1 = 0.5F * (x[pp] + x[pp + 1]); + t2 = 0.5F * (x[qq] + x[qq + 1]); + b[p] = t1 + t2; + b[4 + p] = coef32[16 + 8 + p] * (t1 - t2); + } + forward_bf(2, 4, b, a, coef32 + 16 + 8 + 4); + forward_bf(4, 2, a, b, coef32 + 16 + 8 + 4 + 2); + back_bf(2, 4, b, a); + back_bf(1, 8, a, c); +} +/*------------------------------------------------------------*/ diff --git a/src/client/mp3/config.h b/src/client/mp3/config.h new file mode 100644 index 0000000000..36a2651766 --- /dev/null +++ b/src/client/mp3/config.h @@ -0,0 +1,134 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: config.win32,v 1.16 1999/12/09 08:44:07 elrod Exp $ +____________________________________________________________________________*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#if !defined(RC_INVOKED) + +#include + +#define HAVE_IO_H 1 +#define HAVE_ERRNO_H 1 + +#if HAVE_UNISTD_H +#define RD_BNRY_FLAGS O_RDONLY +#elif HAVE_IO_H +#define RD_BNRY_FLAGS O_RDONLY | O_BINARY +#endif + +/* Endian Issues */ +#ifdef LINUX +#include +#endif + +#ifdef WIN32 +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 +#define __PDP_ENDIAN 3412 +#define __BYTE_ORDER __LITTLE_ENDIAN +#define usleep(x) ::Sleep(x/1000) +typedef int socklen_t; +#endif + +#ifndef _MAX_PATH +#define _MAX_PATH 260 +#endif + +/* define our datatypes */ +// real number +typedef double real; + +#if UCHAR_MAX == 0xff + +typedef unsigned char uint8; +typedef signed char int8; + +#else +#error This machine has no 8-bit type +#endif + +#if UINT_MAX == 0xffff + +typedef unsigned int uint16; +typedef int int16; + +#elif USHRT_MAX == 0xffff + +typedef unsigned short uint16; +typedef short int16; + +#else +#error This machine has no 16-bit type +#endif + + +#if UINT_MAX == 0xfffffffful + +typedef unsigned int uint32; +typedef int int32; + +#elif ULONG_MAX == 0xfffffffful + +typedef unsigned long uint32; +typedef long int32; + +#elif USHRT_MAX == 0xfffffffful + +typedef unsigned short uint32; +typedef short int32; + +#else +#error This machine has no 32-bit type +#endif + + +// What character marks the end of a directory entry? For DOS and +// Windows, it is "\"; in UNIX it is "/". +#if defined(WIN32) || defined(OS2) || defined(__DOS__) +#define DIR_MARKER '\\' +#define DIR_MARKER_STR "\\" +#else +#define DIR_MARKER '/' +#define DIR_MARKER_STR "/" +#endif /* WIN32 */ + +// What character(s) marks the end of a line in a text file? +// For DOS and Windows, it is "\r\n"; in UNIX it is "\r". +#if defined(WIN32) || defined(OS2) || defined(__DOS__) +#define LINE_END_MARKER_STR "\r\n" +#else +#define LINE_END_MARKER_STR "\n" +#endif /* WIN32 */ + +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif /* NULL */ + +#endif /* RC_INVOKED */ + +#endif /* CONFIG_H */ diff --git a/src/client/mp3/csbt.c b/src/client/mp3/csbt.c new file mode 100644 index 0000000000..f5b59613a3 --- /dev/null +++ b/src/client/mp3/csbt.c @@ -0,0 +1,372 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: csbt.c,v 1.2 1999/10/19 07:13:08 elrod Exp $ +____________________________________________________________________________*/ + +/**** csbt.c *************************************************** + +MPEG audio decoder, dct and window +portable C + +1/7/96 mod for Layer III + +******************************************************************/ + +#include +#include +#include +#include + +void fdct32(float *, float *); +void fdct32_dual(float *, float *); +void fdct32_dual_mono(float *, float *); +void fdct16(float *, float *); +void fdct16_dual(float *, float *); +void fdct16_dual_mono(float *, float *); +void fdct8(float *, float *); +void fdct8_dual(float *, float *); +void fdct8_dual_mono(float *, float *); + +void window(float *vbuf, int vb_ptr, short *pcm); +void window_dual(float *vbuf, int vb_ptr, short *pcm); +void window16(float *vbuf, int vb_ptr, short *pcm); +void window16_dual(float *vbuf, int vb_ptr, short *pcm); +void window8(float *vbuf, int vb_ptr, short *pcm); +void window8_dual(float *vbuf, int vb_ptr, short *pcm); + +void sbt_init(void); +void sbt_mono(float *sample, short *pcm, int n); +void sbt_dual(float *sample, short *pcm, int n); +void sbt_dual_mono(float *sample, short *pcm, int n); +void sbt_dual_left(float *sample, short *pcm, int n); +void sbt_dual_right(float *sample, short *pcm, int n); +void sbt16_mono(float *sample, short *pcm, int n); +void sbt16_dual(float *sample, short *pcm, int n); +void sbt16_dual_mono(float *sample, short *pcm, int n); +void sbt16_dual_left(float *sample, short *pcm, int n); +void sbt16_dual_right(float *sample, short *pcm, int n); +void sbt8_mono(float *sample, short *pcm, int n); +void sbt8_dual(float *sample, short *pcm, int n); +void sbt8_dual_mono(float *sample, short *pcm, int n); +void sbt8_dual_left(float *sample, short *pcm, int n); +void sbt8_dual_right(float *sample, short *pcm, int n); + +/*-------------------------------------------------------------------------*/ +/* circular window buffers */ +#include "mp3struct.h" +////static signed int vb_ptr; // !!!!!!!!!!!!! +////static signed int vb2_ptr; // !!!!!!!!!!!!! +////static float pMP3Stream->vbuf[512]; // !!!!!!!!!!!!! +////static float vbuf2[512]; // !!!!!!!!!!!!! + +float *dct_coef_addr(); + +/*======================================================================*/ +static void gencoef() /* gen coef for N=32 (31 coefs) */ +{ + static int iOnceOnly = 0; + int p, n, i, k; + double t, pi; + float *coef32; + + if (!iOnceOnly++) + { + coef32 = dct_coef_addr(); + + pi = 4.0 * atan(1.0); + n = 16; + k = 0; + for (i = 0; i < 5; i++, n = n / 2) + { + + for (p = 0; p < n; p++, k++) + { + t = (pi / (4 * n)) * (2 * p + 1); + coef32[k] = (float) (0.50 / cos(t)); + } + } + } +} +/*------------------------------------------------------------*/ +void sbt_init() +{ + int i; + static int first_pass = 1; + + if (first_pass) + { + gencoef(); + first_pass = 0; + } + +/* clear window pMP3Stream->vbuf */ + for (i = 0; i < 512; i++) + { + pMP3Stream->vbuf[i] = 0.0F; + pMP3Stream->vbuf2[i] = 0.0F; + } + pMP3Stream->vb2_ptr = pMP3Stream->vb_ptr = 0; + +} +/*============================================================*/ +/*============================================================*/ +/*============================================================*/ +void sbt_mono(float *sample, short *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct32(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + window(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511; + pcm += 32; + } + +} +/*------------------------------------------------------------*/ +void sbt_dual(float *sample, short *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct32_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + fdct32_dual(sample + 1, pMP3Stream->vbuf2 + pMP3Stream->vb_ptr); + window_dual(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + window_dual(pMP3Stream->vbuf2, pMP3Stream->vb_ptr, pcm + 1); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511; + pcm += 64; + } + + +} +/*------------------------------------------------------------*/ +/* convert dual to mono */ +void sbt_dual_mono(float *sample, short *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct32_dual_mono(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + window(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511; + pcm += 32; + } + +} +/*------------------------------------------------------------*/ +/* convert dual to left */ +void sbt_dual_left(float *sample, short *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct32_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + window(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511; + pcm += 32; + } +} +/*------------------------------------------------------------*/ +/* convert dual to right */ +void sbt_dual_right(float *sample, short *pcm, int n) +{ + int i; + + sample++; /* point to right chan */ + for (i = 0; i < n; i++) + { + fdct32_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + window(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511; + pcm += 32; + } +} +/*------------------------------------------------------------*/ +/*---------------- 16 pt sbt's -------------------------------*/ +/*------------------------------------------------------------*/ +void sbt16_mono(float *sample, short *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct16(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + window16(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255; + pcm += 16; + } + + +} +/*------------------------------------------------------------*/ +void sbt16_dual(float *sample, short *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct16_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + fdct16_dual(sample + 1, pMP3Stream->vbuf2 + pMP3Stream->vb_ptr); + window16_dual(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + window16_dual(pMP3Stream->vbuf2, pMP3Stream->vb_ptr, pcm + 1); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255; + pcm += 32; + } +} +/*------------------------------------------------------------*/ +void sbt16_dual_mono(float *sample, short *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct16_dual_mono(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + window16(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255; + pcm += 16; + } +} +/*------------------------------------------------------------*/ +void sbt16_dual_left(float *sample, short *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct16_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + window16(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255; + pcm += 16; + } +} +/*------------------------------------------------------------*/ +void sbt16_dual_right(float *sample, short *pcm, int n) +{ + int i; + + sample++; + for (i = 0; i < n; i++) + { + fdct16_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + window16(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255; + pcm += 16; + } +} +/*------------------------------------------------------------*/ +/*---------------- 8 pt sbt's -------------------------------*/ +/*------------------------------------------------------------*/ +void sbt8_mono(float *sample, short *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct8(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + window8(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127; + pcm += 8; + } + +} +/*------------------------------------------------------------*/ +void sbt8_dual(float *sample, short *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct8_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + fdct8_dual(sample + 1, pMP3Stream->vbuf2 + pMP3Stream->vb_ptr); + window8_dual(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + window8_dual(pMP3Stream->vbuf2, pMP3Stream->vb_ptr, pcm + 1); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127; + pcm += 16; + } +} +/*------------------------------------------------------------*/ +void sbt8_dual_mono(float *sample, short *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct8_dual_mono(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + window8(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127; + pcm += 8; + } +} +/*------------------------------------------------------------*/ +void sbt8_dual_left(float *sample, short *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct8_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + window8(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127; + pcm += 8; + } +} +/*------------------------------------------------------------*/ +void sbt8_dual_right(float *sample, short *pcm, int n) +{ + int i; + + sample++; + for (i = 0; i < n; i++) + { + fdct8_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + window8(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127; + pcm += 8; + } +} +/*------------------------------------------------------------*/ +/*------------------------------------------------------------*/ +#define COMPILE_ME +#include "csbtb.c" /* 8 bit output */ +#include "csbtl3.c" /* Layer III */ +/*------------------------------------------------------------*/ diff --git a/src/client/mp3/csbtb.c b/src/client/mp3/csbtb.c new file mode 100644 index 0000000000..29dbb70b41 --- /dev/null +++ b/src/client/mp3/csbtb.c @@ -0,0 +1,299 @@ +#ifdef COMPILE_ME +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: csbtb.c,v 1.2 1999/10/19 07:13:08 elrod Exp $ +____________________________________________________________________________*/ + +/**** csbtb.c *************************************************** +include to csbt.c + +MPEG audio decoder, dct and window - byte (8 pcm bit output) +portable C + +******************************************************************/ +/*============================================================*/ +/*============================================================*/ +void windowB(float *vbuf, int vb_ptr, unsigned char *pcm); +void windowB_dual(float *vbuf, int vb_ptr, unsigned char *pcm); +void windowB16(float *vbuf, int vb_ptr, unsigned char *pcm); +void windowB16_dual(float *vbuf, int vb_ptr, unsigned char *pcm); +void windowB8(float *vbuf, int vb_ptr, unsigned char *pcm); +void windowB8_dual(float *vbuf, int vb_ptr, unsigned char *pcm); + +void sbtB_mono(float *sample, unsigned char *pcm, int n); +void sbtB_dual(float *sample, unsigned char *pcm, int n); +void sbtB_dual_mono(float *sample, unsigned char *pcm, int n); +void sbtB_dual_left(float *sample, unsigned char *pcm, int n); +void sbtB_dual_right(float *sample, unsigned char *pcm, int n); +void sbtB16_mono(float *sample, unsigned char *pcm, int n); +void sbtB16_dual(float *sample, unsigned char *pcm, int n); +void sbtB16_dual_mono(float *sample, unsigned char *pcm, int n); +void sbtB16_dual_left(float *sample, unsigned char *pcm, int n); +void sbtB16_dual_right(float *sample, unsigned char *pcm, int n); +void sbtB8_mono(float *sample, unsigned char *pcm, int n); +void sbtB8_dual(float *sample, unsigned char *pcm, int n); +void sbtB8_dual_mono(float *sample, unsigned char *pcm, int n); +void sbtB8_dual_left(float *sample, unsigned char *pcm, int n); +void sbtB8_dual_right(float *sample, unsigned char *pcm, int n); + +/*============================================================*/ +void sbtB_mono(float *sample, unsigned char *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct32(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + windowB(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511; + pcm += 32; + } + +} +/*------------------------------------------------------------*/ +void sbtB_dual(float *sample, unsigned char *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct32_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + fdct32_dual(sample + 1, pMP3Stream->vbuf2 + pMP3Stream->vb_ptr); + windowB_dual(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + windowB_dual(pMP3Stream->vbuf2, pMP3Stream->vb_ptr, pcm + 1); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511; + pcm += 64; + } + + +} +/*------------------------------------------------------------*/ +/* convert dual to mono */ +void sbtB_dual_mono(float *sample, unsigned char *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct32_dual_mono(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + windowB(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511; + pcm += 32; + } + +} +/*------------------------------------------------------------*/ +/* convert dual to left */ +void sbtB_dual_left(float *sample, unsigned char *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct32_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + windowB(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511; + pcm += 32; + } +} +/*------------------------------------------------------------*/ +/* convert dual to right */ +void sbtB_dual_right(float *sample, unsigned char *pcm, int n) +{ + int i; + + sample++; /* point to right chan */ + for (i = 0; i < n; i++) + { + fdct32_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + windowB(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511; + pcm += 32; + } +} +/*------------------------------------------------------------*/ +/*---------------- 16 pt sbt's -------------------------------*/ +/*------------------------------------------------------------*/ +void sbtB16_mono(float *sample, unsigned char *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct16(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + windowB16(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255; + pcm += 16; + } + + +} +/*------------------------------------------------------------*/ +void sbtB16_dual(float *sample, unsigned char *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct16_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + fdct16_dual(sample + 1, pMP3Stream->vbuf2 + pMP3Stream->vb_ptr); + windowB16_dual(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + windowB16_dual(pMP3Stream->vbuf2, pMP3Stream->vb_ptr, pcm + 1); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255; + pcm += 32; + } +} +/*------------------------------------------------------------*/ +void sbtB16_dual_mono(float *sample, unsigned char *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct16_dual_mono(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + windowB16(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255; + pcm += 16; + } +} +/*------------------------------------------------------------*/ +void sbtB16_dual_left(float *sample, unsigned char *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct16_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + windowB16(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255; + pcm += 16; + } +} +/*------------------------------------------------------------*/ +void sbtB16_dual_right(float *sample, unsigned char *pcm, int n) +{ + int i; + + sample++; + for (i = 0; i < n; i++) + { + fdct16_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + windowB16(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255; + pcm += 16; + } +} +/*------------------------------------------------------------*/ +/*---------------- 8 pt sbt's -------------------------------*/ +/*------------------------------------------------------------*/ +void sbtB8_mono(float *sample, unsigned char *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct8(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + windowB8(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127; + pcm += 8; + } + +} +/*------------------------------------------------------------*/ +void sbtB8_dual(float *sample, unsigned char *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct8_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + fdct8_dual(sample + 1, pMP3Stream->vbuf2 + pMP3Stream->vb_ptr); + windowB8_dual(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + windowB8_dual(pMP3Stream->vbuf2, pMP3Stream->vb_ptr, pcm + 1); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127; + pcm += 16; + } +} +/*------------------------------------------------------------*/ +void sbtB8_dual_mono(float *sample, unsigned char *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct8_dual_mono(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + windowB8(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127; + pcm += 8; + } +} +/*------------------------------------------------------------*/ +void sbtB8_dual_left(float *sample, unsigned char *pcm, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + fdct8_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + windowB8(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127; + pcm += 8; + } +} +/*------------------------------------------------------------*/ +void sbtB8_dual_right(float *sample, unsigned char *pcm, int n) +{ + int i; + + sample++; + for (i = 0; i < n; i++) + { + fdct8_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + windowB8(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 64; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127; + pcm += 8; + } +} +/*------------------------------------------------------------*/ +#endif // #ifdef COMPILE_ME + +#ifndef COMPILE_ME +// Dummy function to suppress empty translation unit warning +static void csbtb_dummy(void) {} +#endif diff --git a/src/client/mp3/csbtl3.c b/src/client/mp3/csbtl3.c new file mode 100644 index 0000000000..10474b38e9 --- /dev/null +++ b/src/client/mp3/csbtl3.c @@ -0,0 +1,326 @@ +#ifdef COMPILE_ME +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: csbtL3.c,v 1.2 1999/10/19 07:13:08 elrod Exp $ +____________________________________________________________________________*/ + +/**** csbtL3.c *************************************************** + +layer III + + include to csbt.c + +******************************************************************/ +/*============================================================*/ +/*============ Layer III =====================================*/ +/*============================================================*/ +void sbt_mono_L3(float *sample, short *pcm, int ch); +void sbt_dual_L3(float *sample, short *pcm, int ch); +void sbt16_mono_L3(float *sample, short *pcm, int ch); +void sbt16_dual_L3(float *sample, short *pcm, int ch); +void sbt8_mono_L3(float *sample, short *pcm, int ch); +void sbt8_dual_L3(float *sample, short *pcm, int ch); +void sbtB_mono_L3(float *sample, unsigned char *pcm, int ch); +void sbtB_dual_L3(float *sample, unsigned char *pcm, int ch); +void sbtB16_mono_L3(float *sample, unsigned char *pcm, int ch); +void sbtB16_dual_L3(float *sample, unsigned char *pcm, int ch); +void sbtB8_mono_L3(float *sample, unsigned char *pcm, int ch); +void sbtB8_dual_L3(float *sample, unsigned char *pcm, int ch); + +void sbt_mono_L3(float *sample, short *pcm, int ch) +{ + int i; + + (void)ch; /* unused */ + for (i = 0; i < 18; i++) + { + fdct32(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + window(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 32; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511; + pcm += 32; + } +} +/*------------------------------------------------------------*/ +void sbt_dual_L3(float *sample, short *pcm, int ch) +{ + int i; + + if (ch == 0) + { + for (i = 0; i < 18; i++) + { + fdct32(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + window_dual(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 32; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511; + pcm += 64; + } + } + else + { + for (i = 0; i < 18; i++) + { + fdct32(sample, pMP3Stream->vbuf2 + pMP3Stream->vb2_ptr); + window_dual(pMP3Stream->vbuf2, pMP3Stream->vb2_ptr, pcm + 1); + sample += 32; + pMP3Stream->vb2_ptr = (pMP3Stream->vb2_ptr - 32) & 511; + pcm += 64; + } + } +} +/*------------------------------------------------------------*/ +/*------------------------------------------------------------*/ +/*---------------- 16 pt sbt's -------------------------------*/ +/*------------------------------------------------------------*/ +void sbt16_mono_L3(float *sample, short *pcm, int ch) +{ + int i; + + (void)ch; /* unused */ + for (i = 0; i < 18; i++) + { + fdct16(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + window16(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 32; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255; + pcm += 16; + } +} +/*------------------------------------------------------------*/ +void sbt16_dual_L3(float *sample, short *pcm, int ch) +{ + int i; + + if (ch == 0) + { + for (i = 0; i < 18; i++) + { + fdct16(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + window16_dual(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 32; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255; + pcm += 32; + } + } + else + { + for (i = 0; i < 18; i++) + { + fdct16(sample, pMP3Stream->vbuf2 + pMP3Stream->vb2_ptr); + window16_dual(pMP3Stream->vbuf2, pMP3Stream->vb2_ptr, pcm + 1); + sample += 32; + pMP3Stream->vb2_ptr = (pMP3Stream->vb2_ptr - 16) & 255; + pcm += 32; + } + } +} +/*------------------------------------------------------------*/ +/*---------------- 8 pt sbt's -------------------------------*/ +/*------------------------------------------------------------*/ +void sbt8_mono_L3(float *sample, short *pcm, int ch) +{ + int i; + + (void)ch; /* unused */ + for (i = 0; i < 18; i++) + { + fdct8(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + window8(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 32; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127; + pcm += 8; + } +} +/*------------------------------------------------------------*/ +void sbt8_dual_L3(float *sample, short *pcm, int ch) +{ + int i; + + if (ch == 0) + { + for (i = 0; i < 18; i++) + { + fdct8(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + window8_dual(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 32; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127; + pcm += 16; + } + } + else + { + for (i = 0; i < 18; i++) + { + fdct8(sample, pMP3Stream->vbuf2 + pMP3Stream->vb2_ptr); + window8_dual(pMP3Stream->vbuf2, pMP3Stream->vb2_ptr, pcm + 1); + sample += 32; + pMP3Stream->vb2_ptr = (pMP3Stream->vb2_ptr - 8) & 127; + pcm += 16; + } + } +} +/*------------------------------------------------------------*/ +/*------- 8 bit output ---------------------------------------*/ +/*------------------------------------------------------------*/ +void sbtB_mono_L3(float *sample, unsigned char *pcm, int ch) +{ + int i; + + (void)ch; /* unused */ + for (i = 0; i < 18; i++) + { + fdct32(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + windowB(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 32; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511; + pcm += 32; + } +} +/*------------------------------------------------------------*/ +void sbtB_dual_L3(float *sample, unsigned char *pcm, int ch) +{ + int i; + + if (ch == 0) + { + for (i = 0; i < 18; i++) + { + fdct32(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + windowB_dual(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 32; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511; + pcm += 64; + } + } + else + { + for (i = 0; i < 18; i++) + { + fdct32(sample, pMP3Stream->vbuf2 + pMP3Stream->vb2_ptr); + windowB_dual(pMP3Stream->vbuf2, pMP3Stream->vb2_ptr, pcm + 1); + sample += 32; + pMP3Stream->vb2_ptr = (pMP3Stream->vb2_ptr - 32) & 511; + pcm += 64; + } + } +} +/*------------------------------------------------------------*/ +/*------------------------------------------------------------*/ +/*---------------- 16 pt sbtB's -------------------------------*/ +/*------------------------------------------------------------*/ +void sbtB16_mono_L3(float *sample, unsigned char *pcm, int ch) +{ + int i; + + (void)ch; /* unused */ + for (i = 0; i < 18; i++) + { + fdct16(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + windowB16(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 32; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255; + pcm += 16; + } +} +/*------------------------------------------------------------*/ +void sbtB16_dual_L3(float *sample, unsigned char *pcm, int ch) +{ + int i; + + if (ch == 0) + { + for (i = 0; i < 18; i++) + { + fdct16(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + windowB16_dual(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 32; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255; + pcm += 32; + } + } + else + { + for (i = 0; i < 18; i++) + { + fdct16(sample, pMP3Stream->vbuf2 + pMP3Stream->vb2_ptr); + windowB16_dual(pMP3Stream->vbuf2, pMP3Stream->vb2_ptr, pcm + 1); + sample += 32; + pMP3Stream->vb2_ptr = (pMP3Stream->vb2_ptr - 16) & 255; + pcm += 32; + } + } +} +/*------------------------------------------------------------*/ +/*---------------- 8 pt sbtB's -------------------------------*/ +/*------------------------------------------------------------*/ +void sbtB8_mono_L3(float *sample, unsigned char *pcm, int ch) +{ + int i; + + (void)ch; /* unused */ + for (i = 0; i < 18; i++) + { + fdct8(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + windowB8(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 32; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127; + pcm += 8; + } +} +/*------------------------------------------------------------*/ +void sbtB8_dual_L3(float *sample, unsigned char *pcm, int ch) +{ + int i; + + if (ch == 0) + { + for (i = 0; i < 18; i++) + { + fdct8(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr); + windowB8_dual(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm); + sample += 32; + pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127; + pcm += 16; + } + } + else + { + for (i = 0; i < 18; i++) + { + fdct8(sample, pMP3Stream->vbuf2 + pMP3Stream->vb2_ptr); + windowB8_dual(pMP3Stream->vbuf2, pMP3Stream->vb2_ptr, pcm + 1); + sample += 32; + pMP3Stream->vb2_ptr = (pMP3Stream->vb2_ptr - 8) & 127; + pcm += 16; + } + } +} +/*------------------------------------------------------------*/ +#endif // #ifdef COMPILE_ME + +#ifndef COMPILE_ME +// Dummy function to suppress empty translation unit warning +static void csbtl3_dummy(void) {} +#endif diff --git a/src/client/mp3/cup.c b/src/client/mp3/cup.c new file mode 100644 index 0000000000..01f765d8d3 --- /dev/null +++ b/src/client/mp3/cup.c @@ -0,0 +1,542 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: cup.c,v 1.3 1999/10/19 07:13:08 elrod Exp $ +____________________________________________________________________________*/ + +/**** cup.c *************************************************** + +MPEG audio decoder Layer I/II mpeg1 and mpeg2 +should be portable ANSI C, should be endian independent + + +mod 2/21/95 2/21/95 add bit skip, sb limiting + +mods 11/15/95 for Layer I + +******************************************************************/ +/****************************************************************** + + MPEG audio software decoder portable ANSI c. + Decodes all Layer I/II to 16 bit linear pcm. + Optional stereo to mono conversion. Optional + output sample rate conversion to half or quarter of + native mpeg rate. dec8.c adds oupuut conversion features. + +------------------------------------- +int audio_decode_init(MPEG_HEAD *h, int framebytes_arg, + int reduction_code, int transform_code, int convert_code, + int freq_limit) + +initilize decoder: + return 0 = fail, not 0 = success + +MPEG_HEAD *h input, mpeg header info (returned by call to head_info) +pMP3Stream->framebytes input, mpeg frame size (returned by call to head_info) +reduction_code input, sample rate reduction code + 0 = full rate + 1 = half rate + 2 = quarter rate + +transform_code input, ignored +convert_code input, channel conversion + convert_code: 0 = two chan output + 1 = convert two chan to mono + 2 = convert two chan to left chan + 3 = convert two chan to right chan +freq_limit input, limits bandwidth of pcm output to specified + frequency. Special use. Set to 24000 for normal use. + + +--------------------------------- +void audio_decode_info( DEC_INFO *info) + +information return: + Call after audio_decode_init. See mhead.h for + information returned in DEC_INFO structure. + + +--------------------------------- +IN_OUT audio_decode(unsigned char *bs, void *pcmbuf) + +decode one mpeg audio frame: +bs input, mpeg bitstream, must start with + sync word. Caution: may read up to 3 bytes + beyond end of frame. +pcmbuf output, pcm samples. + +IN_OUT structure returns: + Number bytes conceptually removed from mpeg bitstream. + Returns 0 if sync loss. + Number bytes of pcm output. + +*******************************************************************/ + + +#include +#include +#include +#include +#include "mhead.h" /* mpeg header structure */ + +#include "mp3struct.h" + + +/*------------------------------------------------------- +NOTE: Decoder may read up to three bytes beyond end of +frame. Calling application must ensure that this does +not cause a memory access violation (protection fault) +---------------------------------------------------------*/ + +/*====================================================================*/ +/*----------------*/ +//@@@@ This next one (decinfo) is ok: +DEC_INFO decinfo; /* global for Layer III */ // only written into by decode init funcs, then copied to stack struct higher up + +/*----------------*/ +static float look_c_value[18]; /* built by init */ // effectively constant + +/*----------------*/ +////@@@@static int pMP3Stream->outbytes; // !!!!!!!!!!!!!!? +////@@@@static int pMP3Stream->framebytes; // !!!!!!!!!!!!!!!! +////@@@@static int pMP3Stream->outvalues; // !!!!!!!!!!!!? +////@@@@static int pad; +static const int look_joint[16] = +{ /* lookup stereo sb's by mode+ext */ + 64, 64, 64, 64, /* stereo */ + 2 * 4, 2 * 8, 2 * 12, 2 * 16, /* joint */ + 64, 64, 64, 64, /* dual */ + 32, 32, 32, 32, /* mono */ +}; + +/*----------------*/ +////@@@@static int max_sb; // !!!!!!!!! L1, 2 3 +////@@@@static int stereo_sb; + +/*----------------*/ +////@@@@static int pMP3Stream->nsb_limit = 6; +////@@@@static int bit_skip; +static const int bat_bit_master[] = +{ + 0, 5, 7, 9, 10, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48}; + +/*----------------*/ +////@@@@static int nbat[4] = {3, 8, 12, 7}; // !!!!!!!!!!!!! not constant!!!! +////@@@@static int bat[4][16]; // built as constant, but built according to header type (sigh) +static int ballo[64]; /* set by unpack_ba */ // scratchpad +static unsigned int samp_dispatch[66]; /* set by unpack_ba */ // scratchpad? +static float c_value[64]; /* set by unpack_ba */ // scratchpad + +/*----------------*/ +static unsigned int sf_dispatch[66]; /* set by unpack_ba */ // scratchpad? +static float sf_table[64]; // effectively constant +////@@@@ static float cs_factor[3][64]; + +/*----------------*/ +////@@@@FINDME - groan.... (I shoved a *2 in just in case it needed it for stereo. This whole thing is crap now +float sample[2304*2]; /* global for use by Later 3 */ // !!!!!!!!!!!!!!!!!!!!!! // scratchpad? +static signed char group3_table[32][3]; // effectively constant +static signed char group5_table[128][3]; // effectively constant +static signed short group9_table[1024][3]; // effectively constant + +/*----------------*/ + +////@@@@typedef void (*SBT_FUNCTION) (float *sample, short *pcm, int n); +void sbt_mono(float *sample, short *pcm, int n); +void sbt_dual(float *sample, short *pcm, int n); +////@@@@static SBT_FUNCTION sbt = sbt_mono; + + +typedef IN_OUT(*AUDIO_DECODE_ROUTINE) (unsigned char *bs, signed short *pcm); +IN_OUT L2audio_decode(unsigned char *bs, signed short *pcm); +static AUDIO_DECODE_ROUTINE audio_decode_routine = L2audio_decode; + +/*======================================================================*/ +/*======================================================================*/ +/* get bits from bitstream in endian independent way */ +////@@@@ FINDME - this stuff doesn't appear to be used by any of our samples (phew) +static unsigned char *bs_ptr; +static unsigned long bitbuf; +static int bits; +static long bitval; + +/*------------- initialize bit getter -------------*/ +static void load_init(unsigned char *buf) +{ + bs_ptr = buf; + bits = 0; + bitbuf = 0; +} +/*------------- get n bits from bitstream -------------*/ +static long load(int n) +{ + unsigned long x; + + if (bits < n) + { /* refill bit buf if necessary */ + while (bits <= 24) + { + bitbuf = (bitbuf << 8) | *bs_ptr++; + bits += 8; + } + } + bits -= n; + x = bitbuf >> bits; + bitbuf -= x << bits; + return x; +} +/*------------- skip over n bits in bitstream -------------*/ +static void skip(int n) +{ + int k; + + if (bits < n) + { + n -= bits; + k = n >> 3; +/*--- bytes = n/8 --*/ + bs_ptr += k; + n -= k << 3; + bitbuf = *bs_ptr++; + bits = 8; + } + bits -= n; + bitbuf -= (bitbuf >> bits) << bits; +} +/*--------------------------------------------------------------*/ +#define mac_load_check(n) if( bits < (n) ) { \ + while( bits <= 24 ) { \ + bitbuf = (bitbuf << 8) | *bs_ptr++; \ + bits += 8; \ + } \ + } +/*--------------------------------------------------------------*/ +#define mac_load(n) ( bits -= n, \ + bitval = bitbuf >> bits, \ + bitbuf -= bitval << bits, \ + bitval ) +/*======================================================================*/ +static void unpack_ba() +{ + int i, j, k; + static int nbit[4] = + {4, 4, 3, 2}; + int nstereo; + + pMP3Stream->bit_skip = 0; + nstereo = pMP3Stream->stereo_sb; + k = 0; + for (i = 0; i < 4; i++) + { + for (j = 0; j < pMP3Stream->nbat[i]; j++, k++) + { + mac_load_check(4); + ballo[k] = samp_dispatch[k] = pMP3Stream->bat[i][mac_load(nbit[i])]; + if (k >= pMP3Stream->nsb_limit) + pMP3Stream->bit_skip += bat_bit_master[samp_dispatch[k]]; + c_value[k] = look_c_value[samp_dispatch[k]]; + if (--nstereo < 0) + { + ballo[k + 1] = ballo[k]; + samp_dispatch[k] += 18; /* flag as joint */ + samp_dispatch[k + 1] = samp_dispatch[k]; /* flag for sf */ + c_value[k + 1] = c_value[k]; + k++; + j++; + } + } + } + samp_dispatch[pMP3Stream->nsb_limit] = 37; /* terminate the dispatcher with skip */ + samp_dispatch[k] = 36; /* terminate the dispatcher */ + +} +/*-------------------------------------------------------------------------*/ +static void unpack_sfs() /* unpack scale factor selectors */ +{ + int i; + + for (i = 0; i < pMP3Stream->max_sb; i++) + { + mac_load_check(2); + if (ballo[i]) + sf_dispatch[i] = mac_load(2); + else + sf_dispatch[i] = 4; /* no allo */ + } + sf_dispatch[i] = 5; /* terminate dispatcher */ +} +/*-------------------------------------------------------------------------*/ +static void unpack_sf() /* unpack scale factor */ +{ /* combine dequant and scale factors */ + int i; + + i = -1; + dispatch:switch (sf_dispatch[++i]) + { + case 0: /* 3 factors 012 */ + mac_load_check(18); + pMP3Stream->cs_factor[0][i] = c_value[i] * sf_table[mac_load(6)]; + pMP3Stream->cs_factor[1][i] = c_value[i] * sf_table[mac_load(6)]; + pMP3Stream->cs_factor[2][i] = c_value[i] * sf_table[mac_load(6)]; + goto dispatch; + case 1: /* 2 factors 002 */ + mac_load_check(12); + pMP3Stream->cs_factor[1][i] = pMP3Stream->cs_factor[0][i] = c_value[i] * sf_table[mac_load(6)]; + pMP3Stream->cs_factor[2][i] = c_value[i] * sf_table[mac_load(6)]; + goto dispatch; + case 2: /* 1 factor 000 */ + mac_load_check(6); + pMP3Stream->cs_factor[2][i] = pMP3Stream->cs_factor[1][i] = pMP3Stream->cs_factor[0][i] = + c_value[i] * sf_table[mac_load(6)]; + goto dispatch; + case 3: /* 2 factors 022 */ + mac_load_check(12); + pMP3Stream->cs_factor[0][i] = c_value[i] * sf_table[mac_load(6)]; + pMP3Stream->cs_factor[2][i] = pMP3Stream->cs_factor[1][i] = c_value[i] * sf_table[mac_load(6)]; + goto dispatch; + case 4: /* no allo */ +/*-- pMP3Stream->cs_factor[2][i] = pMP3Stream->cs_factor[1][i] = pMP3Stream->cs_factor[0][i] = 0.0; --*/ + goto dispatch; + case 5: /* all done */ + ; + } /* end switch */ +} +/*-------------------------------------------------------------------------*/ +#define UNPACK_N(n) s[k] = pMP3Stream->cs_factor[i][k]*(load(n)-((1 << (n-1)) -1)); \ + s[k+64] = pMP3Stream->cs_factor[i][k]*(load(n)-((1 << (n-1)) -1)); \ + s[k+128] = pMP3Stream->cs_factor[i][k]*(load(n)-((1 << (n-1)) -1)); \ + goto dispatch; +#define UNPACK_N2(n) mac_load_check(3*n); \ + s[k] = pMP3Stream->cs_factor[i][k]*(mac_load(n)-((1 << (n-1)) -1)); \ + s[k+64] = pMP3Stream->cs_factor[i][k]*(mac_load(n)-((1 << (n-1)) -1)); \ + s[k+128] = pMP3Stream->cs_factor[i][k]*(mac_load(n)-((1 << (n-1)) -1)); \ + goto dispatch; +#define UNPACK_N3(n) mac_load_check(2*n); \ + s[k] = pMP3Stream->cs_factor[i][k]*(mac_load(n)-((1 << (n-1)) -1)); \ + s[k+64] = pMP3Stream->cs_factor[i][k]*(mac_load(n)-((1 << (n-1)) -1)); \ + mac_load_check(n); \ + s[k+128] = pMP3Stream->cs_factor[i][k]*(mac_load(n)-((1 << (n-1)) -1)); \ + goto dispatch; +#define UNPACKJ_N(n) tmp = (load(n)-((1 << (n-1)) -1)); \ + s[k] = pMP3Stream->cs_factor[i][k]*tmp; \ + s[k+1] = pMP3Stream->cs_factor[i][k+1]*tmp; \ + tmp = (load(n)-((1 << (n-1)) -1)); \ + s[k+64] = pMP3Stream->cs_factor[i][k]*tmp; \ + s[k+64+1] = pMP3Stream->cs_factor[i][k+1]*tmp; \ + tmp = (load(n)-((1 << (n-1)) -1)); \ + s[k+128] = pMP3Stream->cs_factor[i][k]*tmp; \ + s[k+128+1] = pMP3Stream->cs_factor[i][k+1]*tmp; \ + k++; /* skip right chan dispatch */ \ + goto dispatch; +/*-------------------------------------------------------------------------*/ +static void unpack_samp() /* unpack samples */ +{ + int i, j, k; + float *s; + int n; + long tmp; + + s = sample; + for (i = 0; i < 3; i++) + { /* 3 groups of scale factors */ + for (j = 0; j < 4; j++) + { + k = -1; + dispatch:switch (samp_dispatch[++k]) + { + case 0: + s[k + 128] = s[k + 64] = s[k] = 0.0F; + goto dispatch; + case 1: /* 3 levels grouped 5 bits */ + mac_load_check(5); + n = mac_load(5); + s[k] = pMP3Stream->cs_factor[i][k] * group3_table[n][0]; + s[k + 64] = pMP3Stream->cs_factor[i][k] * group3_table[n][1]; + s[k + 128] = pMP3Stream->cs_factor[i][k] * group3_table[n][2]; + goto dispatch; + case 2: /* 5 levels grouped 7 bits */ + mac_load_check(7); + n = mac_load(7); + s[k] = pMP3Stream->cs_factor[i][k] * group5_table[n][0]; + s[k + 64] = pMP3Stream->cs_factor[i][k] * group5_table[n][1]; + s[k + 128] = pMP3Stream->cs_factor[i][k] * group5_table[n][2]; + goto dispatch; + case 3: + UNPACK_N2(3) /* 7 levels */ + case 4: /* 9 levels grouped 10 bits */ + mac_load_check(10); + n = mac_load(10); + s[k] = pMP3Stream->cs_factor[i][k] * group9_table[n][0]; + s[k + 64] = pMP3Stream->cs_factor[i][k] * group9_table[n][1]; + s[k + 128] = pMP3Stream->cs_factor[i][k] * group9_table[n][2]; + goto dispatch; + case 5: + UNPACK_N2(4) /* 15 levels */ + case 6: + UNPACK_N2(5) /* 31 levels */ + case 7: + UNPACK_N2(6) /* 63 levels */ + case 8: + UNPACK_N2(7) /* 127 levels */ + case 9: + UNPACK_N2(8) /* 255 levels */ + case 10: + UNPACK_N3(9) /* 511 levels */ + case 11: + UNPACK_N3(10) /* 1023 levels */ + case 12: + UNPACK_N3(11) /* 2047 levels */ + case 13: + UNPACK_N3(12) /* 4095 levels */ + case 14: + UNPACK_N(13) /* 8191 levels */ + case 15: + UNPACK_N(14) /* 16383 levels */ + case 16: + UNPACK_N(15) /* 32767 levels */ + case 17: + UNPACK_N(16) /* 65535 levels */ +/* -- joint ---- */ + case 18 + 0: + s[k + 128 + 1] = s[k + 128] = s[k + 64 + 1] = s[k + 64] = s[k + 1] = s[k] = 0.0F; + k++; /* skip right chan dispatch */ + goto dispatch; + case 18 + 1: /* 3 levels grouped 5 bits */ + n = load(5); + s[k] = pMP3Stream->cs_factor[i][k] * group3_table[n][0]; + s[k + 1] = pMP3Stream->cs_factor[i][k + 1] * group3_table[n][0]; + s[k + 64] = pMP3Stream->cs_factor[i][k] * group3_table[n][1]; + s[k + 64 + 1] = pMP3Stream->cs_factor[i][k + 1] * group3_table[n][1]; + s[k + 128] = pMP3Stream->cs_factor[i][k] * group3_table[n][2]; + s[k + 128 + 1] = pMP3Stream->cs_factor[i][k + 1] * group3_table[n][2]; + k++; /* skip right chan dispatch */ + goto dispatch; + case 18 + 2: /* 5 levels grouped 7 bits */ + n = load(7); + s[k] = pMP3Stream->cs_factor[i][k] * group5_table[n][0]; + s[k + 1] = pMP3Stream->cs_factor[i][k + 1] * group5_table[n][0]; + s[k + 64] = pMP3Stream->cs_factor[i][k] * group5_table[n][1]; + s[k + 64 + 1] = pMP3Stream->cs_factor[i][k + 1] * group5_table[n][1]; + s[k + 128] = pMP3Stream->cs_factor[i][k] * group5_table[n][2]; + s[k + 128 + 1] = pMP3Stream->cs_factor[i][k + 1] * group5_table[n][2]; + k++; /* skip right chan dispatch */ + goto dispatch; + case 18 + 3: + UNPACKJ_N(3) /* 7 levels */ + case 18 + 4: /* 9 levels grouped 10 bits */ + n = load(10); + s[k] = pMP3Stream->cs_factor[i][k] * group9_table[n][0]; + s[k + 1] = pMP3Stream->cs_factor[i][k + 1] * group9_table[n][0]; + s[k + 64] = pMP3Stream->cs_factor[i][k] * group9_table[n][1]; + s[k + 64 + 1] = pMP3Stream->cs_factor[i][k + 1] * group9_table[n][1]; + s[k + 128] = pMP3Stream->cs_factor[i][k] * group9_table[n][2]; + s[k + 128 + 1] = pMP3Stream->cs_factor[i][k + 1] * group9_table[n][2]; + k++; /* skip right chan dispatch */ + goto dispatch; + case 18 + 5: + UNPACKJ_N(4) /* 15 levels */ + case 18 + 6: + UNPACKJ_N(5) /* 31 levels */ + case 18 + 7: + UNPACKJ_N(6) /* 63 levels */ + case 18 + 8: + UNPACKJ_N(7) /* 127 levels */ + case 18 + 9: + UNPACKJ_N(8) /* 255 levels */ + case 18 + 10: + UNPACKJ_N(9) /* 511 levels */ + case 18 + 11: + UNPACKJ_N(10) /* 1023 levels */ + case 18 + 12: + UNPACKJ_N(11) /* 2047 levels */ + case 18 + 13: + UNPACKJ_N(12) /* 4095 levels */ + case 18 + 14: + UNPACKJ_N(13) /* 8191 levels */ + case 18 + 15: + UNPACKJ_N(14) /* 16383 levels */ + case 18 + 16: + UNPACKJ_N(15) /* 32767 levels */ + case 18 + 17: + UNPACKJ_N(16) /* 65535 levels */ +/* -- end of dispatch -- */ + case 37: + skip(pMP3Stream->bit_skip); + /* fall through */ + case 36: + s += 3 * 64; + } /* end switch */ + } /* end j loop */ + } /* end i loop */ + + +} +/*-------------------------------------------------------------------------*/ +unsigned char *gpNextByteAfterData = NULL; +IN_OUT audio_decode(unsigned char *bs, signed short *pcm, unsigned char *pNextByteAfterData) +{ + gpNextByteAfterData = pNextByteAfterData; // sigh.... + return audio_decode_routine(bs, pcm); +} +/*-------------------------------------------------------------------------*/ +IN_OUT L2audio_decode(unsigned char *bs, signed short *pcm) +{ + int sync, prot; + IN_OUT in_out; + + load_init(bs); /* initialize bit getter */ +/* test sync */ + in_out.in_bytes = 0; /* assume fail */ + in_out.out_bytes = 0; + sync = load(12); + if (sync != 0xFFF) + return in_out; /* sync fail */ + + load(3); /* skip id and option (checked by init) */ + prot = load(1); /* load prot bit */ + load(6); /* skip to pad */ + pMP3Stream->pad = load(1); + load(1); /* skip to mode */ + pMP3Stream->stereo_sb = look_joint[load(4)]; + if (prot) + load(4); /* skip to data */ + else + load(20); /* skip crc */ + + unpack_ba(); /* unpack bit allocation */ + unpack_sfs(); /* unpack scale factor selectors */ + unpack_sf(); /* unpack scale factor */ + unpack_samp(); /* unpack samples */ + + pMP3Stream->sbt(sample, pcm, 36); +/*-----------*/ + in_out.in_bytes = pMP3Stream->framebytes + pMP3Stream->pad; + in_out.out_bytes = pMP3Stream->outbytes; + + return in_out; +} +/*-------------------------------------------------------------------------*/ +#define COMPILE_ME +#include "cupini.c" /* initialization */ +#include "cupl1.c" /* Layer I */ +/*-------------------------------------------------------------------------*/ diff --git a/src/client/mp3/cupini.c b/src/client/mp3/cupini.c new file mode 100644 index 0000000000..a6dab78718 --- /dev/null +++ b/src/client/mp3/cupini.c @@ -0,0 +1,396 @@ +#ifdef COMPILE_ME +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: cupini.c,v 1.3 1999/10/19 07:13:08 elrod Exp $ +____________________________________________________________________________*/ + +/*========================================================= + initialization for cup.c - include to cup.c + mpeg audio decoder portable "c" + +mod 8/6/96 add 8 bit output + +mod 5/10/95 add quick (low precision) window + +mod 5/16/95 sb limit for reduced samprate output + changed from 94% to 100% of Nyquist sb + +mod 11/15/95 for Layer I + + +=========================================================*/ +/*-- compiler bug, floating constant overflow w/ansi --*/ + +static const long steps[18] = +{ + 0, 3, 5, 7, 9, 15, 31, 63, 127, + 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535}; + + +/* ABCD_INDEX = lookqt[mode][sr_index][br_index] */ +/* -1 = invalid */ +static const signed char lookqt[4][3][16] = +{ + {{1, -1, -1, -1, 2, -1, 2, 0, 0, 0, 1, 1, 1, 1, 1, -1}, /* 44ks stereo */ + {0, -1, -1, -1, 2, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, -1}, /* 48ks */ + {1, -1, -1, -1, 3, -1, 3, 0, 0, 0, 1, 1, 1, 1, 1, -1}}, /* 32ks */ + {{1, -1, -1, -1, 2, -1, 2, 0, 0, 0, 1, 1, 1, 1, 1, -1}, /* 44ks joint stereo */ + {0, -1, -1, -1, 2, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, -1}, /* 48ks */ + {1, -1, -1, -1, 3, -1, 3, 0, 0, 0, 1, 1, 1, 1, 1, -1}}, /* 32ks */ + {{1, -1, -1, -1, 2, -1, 2, 0, 0, 0, 1, 1, 1, 1, 1, -1}, /* 44ks dual chan */ + {0, -1, -1, -1, 2, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, -1}, /* 48ks */ + {1, -1, -1, -1, 3, -1, 3, 0, 0, 0, 1, 1, 1, 1, 1, -1}}, /* 32ks */ +// mono extended beyond legal br index +// 1,2,2,0,0,0,1,1,1,1,1,1,1,1,1,-1, /* 44ks single chan */ +// 0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,-1, /* 48ks */ +// 1,3,3,0,0,0,1,1,1,1,1,1,1,1,1,-1, /* 32ks */ +// legal mono + {{1, 2, 2, 0, 0, 0, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1}, /* 44ks single chan */ + {0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1}, /* 48ks */ + {1, 3, 3, 0, 0, 0, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1}}, /* 32ks */ +}; + +static const long sr_table[8] = +{22050L, 24000L, 16000L, 1L, + 44100L, 48000L, 32000L, 1L}; + +/* bit allocation table look up */ +/* table per mpeg spec tables 3b2a/b/c/d /e is mpeg2 */ +/* look_bat[abcd_index][4][16] */ +static const unsigned char look_bat[5][4][16] = +{ +/* LOOK_BATA */ + {{0, 1, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}, + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17}, + {0, 1, 2, 3, 4, 5, 6, 17, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 1, 2, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, +/* LOOK_BATB */ + {{0, 1, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}, + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17}, + {0, 1, 2, 3, 4, 5, 6, 17, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 1, 2, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, +/* LOOK_BATC */ + {{0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 1, 2, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, +/* LOOK_BATD */ + {{0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 1, 2, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, +/* LOOK_BATE */ + {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 1, 2, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 1, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, +}; + +/* look_nbat[abcd_index]][4] */ +static const unsigned char look_nbat[5][4] = +{ + {3, 8, 12, 4}, + {3, 8, 12, 7}, + {2, 0, 6, 0}, + {2, 0, 10, 0}, + {4, 0, 7, 19}, +}; + + +void sbt_mono(float *sample, short *pcm, int n); +void sbt_dual(float *sample, short *pcm, int n); +void sbt_dual_mono(float *sample, short *pcm, int n); +void sbt_dual_left(float *sample, short *pcm, int n); +void sbt_dual_right(float *sample, short *pcm, int n); +void sbt16_mono(float *sample, short *pcm, int n); +void sbt16_dual(float *sample, short *pcm, int n); +void sbt16_dual_mono(float *sample, short *pcm, int n); +void sbt16_dual_left(float *sample, short *pcm, int n); +void sbt16_dual_right(float *sample, short *pcm, int n); +void sbt8_mono(float *sample, short *pcm, int n); +void sbt8_dual(float *sample, short *pcm, int n); +void sbt8_dual_mono(float *sample, short *pcm, int n); +void sbt8_dual_left(float *sample, short *pcm, int n); +void sbt8_dual_right(float *sample, short *pcm, int n); + +/*--- 8 bit output ---*/ +void sbtB_mono(float *sample, unsigned char *pcm, int n); +void sbtB_dual(float *sample, unsigned char *pcm, int n); +void sbtB_dual_mono(float *sample, unsigned char *pcm, int n); +void sbtB_dual_left(float *sample, unsigned char *pcm, int n); +void sbtB_dual_right(float *sample, unsigned char *pcm, int n); +void sbtB16_mono(float *sample, unsigned char *pcm, int n); +void sbtB16_dual(float *sample, unsigned char *pcm, int n); +void sbtB16_dual_mono(float *sample, unsigned char *pcm, int n); +void sbtB16_dual_left(float *sample, unsigned char *pcm, int n); +void sbtB16_dual_right(float *sample, unsigned char *pcm, int n); +void sbtB8_mono(float *sample, unsigned char *pcm, int n); +void sbtB8_dual(float *sample, unsigned char *pcm, int n); +void sbtB8_dual_mono(float *sample, unsigned char *pcm, int n); +void sbtB8_dual_left(float *sample, unsigned char *pcm, int n); +void sbtB8_dual_right(float *sample, unsigned char *pcm, int n); + + +static const SBT_FUNCTION sbt_table[2][3][5] = +{ + {{sbt_mono, sbt_dual, sbt_dual_mono, sbt_dual_left, sbt_dual_right}, + {sbt16_mono, sbt16_dual, sbt16_dual_mono, sbt16_dual_left, sbt16_dual_right}, + {sbt8_mono, sbt8_dual, sbt8_dual_mono, sbt8_dual_left, sbt8_dual_right}}, + {{(SBT_FUNCTION) sbtB_mono, + (SBT_FUNCTION) sbtB_dual, + (SBT_FUNCTION) sbtB_dual_mono, + (SBT_FUNCTION) sbtB_dual_left, + (SBT_FUNCTION) sbtB_dual_right}, + {(SBT_FUNCTION) sbtB16_mono, + (SBT_FUNCTION) sbtB16_dual, + (SBT_FUNCTION) sbtB16_dual_mono, + (SBT_FUNCTION) sbtB16_dual_left, + (SBT_FUNCTION) sbtB16_dual_right}, + {(SBT_FUNCTION) sbtB8_mono, + (SBT_FUNCTION) sbtB8_dual, + (SBT_FUNCTION) sbtB8_dual_mono, + (SBT_FUNCTION) sbtB8_dual_left, + (SBT_FUNCTION) sbtB8_dual_right}}, +}; + +static const int out_chans[5] = +{1, 2, 1, 1, 1}; + + +int audio_decode_initL1(MPEG_HEAD * h, int framebytes_arg, + int reduction_code, int transform_code, int convert_code, + int freq_limit); +void sbt_init(); +void decode_table_init(void); + + +IN_OUT L1audio_decode(unsigned char *bs, signed short *pcm); +IN_OUT L2audio_decode(unsigned char *bs, signed short *pcm); +IN_OUT L3audio_decode(unsigned char *bs, unsigned char *pcm); +static const AUDIO_DECODE_ROUTINE decode_routine_table[4] = +{ + L2audio_decode, + (AUDIO_DECODE_ROUTINE)L3audio_decode, + L2audio_decode, + L1audio_decode,}; + +/*---------------------------------------------------------*/ +static void table_init() +{ + int i, j; + int code; + static int iOnceOnly=0; + + if (!iOnceOnly++) + { + /*-- c_values (dequant) --*/ + for (i = 1; i < 18; i++) + look_c_value[i] = 2.0F / steps[i]; + + /*-- scale factor table, scale by 32768 for 16 pcm output --*/ + for (i = 0; i < 64; i++) + sf_table[i] = (float) (32768.0 * 2.0 * pow(2.0, -i / 3.0)); + + /*-- grouped 3 level lookup table 5 bit token --*/ + for (i = 0; i < 32; i++) + { + code = i; + for (j = 0; j < 3; j++) + { + group3_table[i][j] = (char) ((code % 3) - 1); + code /= 3; + } + } + + /*-- grouped 5 level lookup table 7 bit token --*/ + for (i = 0; i < 128; i++) + { + code = i; + for (j = 0; j < 3; j++) + { + group5_table[i][j] = (char) ((code % 5) - 2); + code /= 5; + } + } + + /*-- grouped 9 level lookup table 10 bit token --*/ + for (i = 0; i < 1024; i++) + { + code = i; + for (j = 0; j < 3; j++) + { + group9_table[i][j] = (short) ((code % 9) - 4); + code /= 9; + } + } + } +} +/*---------------------------------------------------------*/ +int L1audio_decode_init(MPEG_HEAD * h, int framebytes_arg, + int reduction_code, int transform_code, int convert_code, + int freq_limit); +int L3audio_decode_init(MPEG_HEAD * h, int framebytes_arg, + int reduction_code, int transform_code, int convert_code, + int freq_limit); + +/*---------------------------------------------------------*/ +/* mpeg_head defined in mhead.h frame bytes is without pad */ +int audio_decode_init(MPEG_HEAD * h, int framebytes_arg, + int reduction_code, int transform_code, int convert_code, + int freq_limit) +{ + int i, j, k; + static int first_pass = 1; + int abcd_index; + long samprate; + int limit; + int bit_code; + + if (first_pass) + { + table_init(); + first_pass = 0; + } + +/* select decoder routine Layer I,II,III */ + audio_decode_routine = decode_routine_table[h->option & 3]; + + + if (h->option == 3) /* layer I */ + return L1audio_decode_init(h, framebytes_arg, + reduction_code, transform_code, convert_code, freq_limit); + + if (h->option == 1) /* layer III */ + return L3audio_decode_init(h, framebytes_arg, + reduction_code, transform_code, convert_code, freq_limit); + + + + bit_code = 0; + if (convert_code & 8) + bit_code = 1; + convert_code = convert_code & 3; /* higher bits used by dec8 freq cvt */ + if (reduction_code < 0) + reduction_code = 0; + if (reduction_code > 2) + reduction_code = 2; + if (freq_limit < 1000) + freq_limit = 1000; + + + pMP3Stream->framebytes = framebytes_arg; +/* check if code handles */ + if (h->option != 2) + return 0; /* layer II only */ + if (h->sr_index == 3) + return 0; /* reserved */ + +/* compute abcd index for bit allo table selection */ + if (h->id) /* mpeg 1 */ + abcd_index = lookqt[h->mode][h->sr_index][h->br_index]; + else + abcd_index = 4; /* mpeg 2 */ + + if (abcd_index < 0) + return 0; // fail invalid Layer II bit rate index + + for (i = 0; i < 4; i++) + for (j = 0; j < 16; j++) + pMP3Stream->bat[i][j] = look_bat[abcd_index][i][j]; + for (i = 0; i < 4; i++) + pMP3Stream->nbat[i] = look_nbat[abcd_index][i]; + pMP3Stream->max_sb = pMP3Stream->nbat[0] + pMP3Stream->nbat[1] + pMP3Stream->nbat[2] + pMP3Stream->nbat[3]; +/*----- compute pMP3Stream->nsb_limit --------*/ + samprate = sr_table[4 * h->id + h->sr_index]; + pMP3Stream->nsb_limit = (freq_limit * 64L + samprate / 2) / samprate; +/*- caller limit -*/ +/*---- limit = 0.94*(32>>reduction_code); ----*/ + limit = (32 >> reduction_code); + if (limit > 8) + limit--; + if (pMP3Stream->nsb_limit > limit) + pMP3Stream->nsb_limit = limit; + if (pMP3Stream->nsb_limit > pMP3Stream->max_sb) + pMP3Stream->nsb_limit = pMP3Stream->max_sb; + + pMP3Stream->outvalues = 1152 >> reduction_code; + if (h->mode != 3) + { /* adjust for 2 channel modes */ + for (i = 0; i < 4; i++) + pMP3Stream->nbat[i] *= 2; + pMP3Stream->max_sb *= 2; + pMP3Stream->nsb_limit *= 2; + } + +/* set sbt function */ + k = 1 + convert_code; + if (h->mode == 3) + { + k = 0; + } + pMP3Stream->sbt = sbt_table[bit_code][reduction_code][k]; + pMP3Stream->outvalues *= out_chans[k]; + if (bit_code) + pMP3Stream->outbytes = pMP3Stream->outvalues; + else + pMP3Stream->outbytes = sizeof(short) * pMP3Stream->outvalues; + + decinfo.channels = out_chans[k]; + decinfo.outvalues = pMP3Stream->outvalues; + decinfo.samprate = samprate >> reduction_code; + if (bit_code) + decinfo.bits = 8; + else + decinfo.bits = sizeof(short) * 8; + + decinfo.framebytes = pMP3Stream->framebytes; + decinfo.type = 0; + + + +/* clear sample buffer, unused sub bands must be 0 */ + for (i = 0; i < 2304*2; i++) // the *2 here was inserted by me just in case, since the array is now *2, because of stereo files unpacking at 4608 bytes per frame (which may or may not be relevant, but in any case I don't think we use the L1 versions of MP3 now anyway + sample[i] = 0.0F; + + +/* init sub-band transform */ + sbt_init(); + + return 1; +} +/*---------------------------------------------------------*/ +void audio_decode_info(DEC_INFO * info) +{ + *info = decinfo; /* info return, call after init */ +} +/*---------------------------------------------------------*/ +void decode_table_init() +{ +/* dummy for asm version compatability */ +} +/*---------------------------------------------------------*/ +#endif // #ifdef COMPILE_ME + +/* Dummy statement to avoid empty translation unit warning */ +static void *dummy_cupini __attribute__((unused)) = (void *)0; diff --git a/src/client/mp3/cupl1.c b/src/client/mp3/cupl1.c new file mode 100644 index 0000000000..3ac000a9b0 --- /dev/null +++ b/src/client/mp3/cupl1.c @@ -0,0 +1,329 @@ +#ifdef COMPILE_ME +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: cupL1.c,v 1.3 1999/10/19 07:13:08 elrod Exp $ +____________________________________________________________________________*/ + +/**** cupL1.c *************************************************** + +MPEG audio decoder Layer I mpeg1 and mpeg2 + +include to clup.c + + +******************************************************************/ +/*======================================================================*/ +static const int bat_bit_masterL1[] = +{ + 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 +}; +////@@@@static float *pMP3Stream->cs_factorL1 = &pMP3Stream->cs_factor[0]; // !!!!!!!!!!!!!!!! +static float look_c_valueL1[16]; // effectively constant +////@@@@static int nbatL1 = 32; + +/*======================================================================*/ +static void unpack_baL1() +{ + int j; + int nstereo; + + pMP3Stream->bit_skip = 0; + nstereo = pMP3Stream->stereo_sb; + + for (j = 0; j < pMP3Stream->nbatL1; j++) + { + mac_load_check(4); + ballo[j] = samp_dispatch[j] = mac_load(4); + if (j >= pMP3Stream->nsb_limit) + pMP3Stream->bit_skip += bat_bit_masterL1[samp_dispatch[j]]; + c_value[j] = look_c_valueL1[samp_dispatch[j]]; + if (--nstereo < 0) + { + ballo[j + 1] = ballo[j]; + samp_dispatch[j] += 15; /* flag as joint */ + samp_dispatch[j + 1] = samp_dispatch[j]; /* flag for sf */ + c_value[j + 1] = c_value[j]; + j++; + } + } +/*-- terminate with bit skip and end --*/ + samp_dispatch[pMP3Stream->nsb_limit] = 31; + samp_dispatch[j] = 30; +} +/*-------------------------------------------------------------------------*/ +static void unpack_sfL1(void) /* unpack scale factor */ +{ /* combine dequant and scale factors */ + int i; + + for (i = 0; i < pMP3Stream->nbatL1; i++) + { + if (ballo[i]) + { + mac_load_check(6); + pMP3Stream->cs_factorL1[i] = c_value[i] * sf_table[mac_load(6)]; + } + } +/*-- done --*/ +} +/*-------------------------------------------------------------------------*/ +#define UNPACKL1_N(n) s[k] = pMP3Stream->cs_factorL1[k]*(load(n)-((1 << (n-1)) -1)); \ + goto dispatch; +#define UNPACKL1J_N(n) tmp = (load(n)-((1 << (n-1)) -1)); \ + s[k] = pMP3Stream->cs_factorL1[k]*tmp; \ + s[k+1] = pMP3Stream->cs_factorL1[k+1]*tmp; \ + k++; \ + goto dispatch; +/*-------------------------------------------------------------------------*/ +static void unpack_sampL1() /* unpack samples */ +{ + int j, k; + float *s; + long tmp; + + s = sample; + for (j = 0; j < 12; j++) + { + k = -1; + dispatch:switch (samp_dispatch[++k]) + { + case 0: + s[k] = 0.0F; + goto dispatch; + case 1: + UNPACKL1_N(2) /* 3 levels */ + case 2: + UNPACKL1_N(3) /* 7 levels */ + case 3: + UNPACKL1_N(4) /* 15 levels */ + case 4: + UNPACKL1_N(5) /* 31 levels */ + case 5: + UNPACKL1_N(6) /* 63 levels */ + case 6: + UNPACKL1_N(7) /* 127 levels */ + case 7: + UNPACKL1_N(8) /* 255 levels */ + case 8: + UNPACKL1_N(9) /* 511 levels */ + case 9: + UNPACKL1_N(10) /* 1023 levels */ + case 10: + UNPACKL1_N(11) /* 2047 levels */ + case 11: + UNPACKL1_N(12) /* 4095 levels */ + case 12: + UNPACKL1_N(13) /* 8191 levels */ + case 13: + UNPACKL1_N(14) /* 16383 levels */ + case 14: + UNPACKL1_N(15) /* 32767 levels */ +/* -- joint ---- */ + case 15 + 0: + s[k + 1] = s[k] = 0.0F; + k++; /* skip right chan dispatch */ + goto dispatch; +/* -- joint ---- */ + case 15 + 1: + UNPACKL1J_N(2) /* 3 levels */ + case 15 + 2: + UNPACKL1J_N(3) /* 7 levels */ + case 15 + 3: + UNPACKL1J_N(4) /* 15 levels */ + case 15 + 4: + UNPACKL1J_N(5) /* 31 levels */ + case 15 + 5: + UNPACKL1J_N(6) /* 63 levels */ + case 15 + 6: + UNPACKL1J_N(7) /* 127 levels */ + case 15 + 7: + UNPACKL1J_N(8) /* 255 levels */ + case 15 + 8: + UNPACKL1J_N(9) /* 511 levels */ + case 15 + 9: + UNPACKL1J_N(10) /* 1023 levels */ + case 15 + 10: + UNPACKL1J_N(11) /* 2047 levels */ + case 15 + 11: + UNPACKL1J_N(12) /* 4095 levels */ + case 15 + 12: + UNPACKL1J_N(13) /* 8191 levels */ + case 15 + 13: + UNPACKL1J_N(14) /* 16383 levels */ + case 15 + 14: + UNPACKL1J_N(15) /* 32767 levels */ + +/* -- end of dispatch -- */ + case 31: + skip(pMP3Stream->bit_skip); + /* fall through */ + case 30: + s += 64; + } /* end switch */ + } /* end j loop */ + +/*-- done --*/ +} +/*-------------------------------------------------------------------*/ +IN_OUT L1audio_decode(unsigned char *bs, signed short *pcm) +{ + int sync, prot; + IN_OUT in_out; + + load_init(bs); /* initialize bit getter */ +/* test sync */ + in_out.in_bytes = 0; /* assume fail */ + in_out.out_bytes = 0; + sync = load(12); + if (sync != 0xFFF) + return in_out; /* sync fail */ + + + load(3); /* skip id and option (checked by init) */ + prot = load(1); /* load prot bit */ + load(6); /* skip to pad */ + pMP3Stream->pad = (load(1)) << 2; + load(1); /* skip to mode */ + pMP3Stream->stereo_sb = look_joint[load(4)]; + if (prot) + load(4); /* skip to data */ + else + load(20); /* skip crc */ + + unpack_baL1(); /* unpack bit allocation */ + unpack_sfL1(); /* unpack scale factor */ + unpack_sampL1(); /* unpack samples */ + + pMP3Stream->sbt(sample, pcm, 12); +/*-----------*/ + in_out.in_bytes = pMP3Stream->framebytes + pMP3Stream->pad; + in_out.out_bytes = pMP3Stream->outbytes; + + return in_out; +} +/*-------------------------------------------------------------------------*/ +int L1audio_decode_init(MPEG_HEAD * h, int framebytes_arg, + int reduction_code, int transform_code, int convert_code, + int freq_limit) +{ + int i, k; + static int first_pass = 1; + long samprate; + + (void)transform_code; /* unused */ + int limit; + long step; + int bit_code; + +/*--- sf init done by layer II init ---*/ + if (first_pass) + { + for (step = 4, i = 1; i < 16; i++, step <<= 1) + look_c_valueL1[i] = (float) (2.0 / (step - 1)); + first_pass = 0; + } + pMP3Stream->cs_factorL1 = pMP3Stream->cs_factor[0]; + + bit_code = 0; + if (convert_code & 8) + bit_code = 1; + convert_code = convert_code & 3; /* higher bits used by dec8 freq cvt */ + if (reduction_code < 0) + reduction_code = 0; + if (reduction_code > 2) + reduction_code = 2; + if (freq_limit < 1000) + freq_limit = 1000; + + + pMP3Stream->framebytes = framebytes_arg; +/* check if code handles */ + if (h->option != 3) + return 0; /* layer I only */ + + pMP3Stream->nbatL1 = 32; + pMP3Stream->max_sb = pMP3Stream->nbatL1; +/*----- compute pMP3Stream->nsb_limit --------*/ + samprate = sr_table[4 * h->id + h->sr_index]; + pMP3Stream->nsb_limit = (freq_limit * 64L + samprate / 2) / samprate; +/*- caller limit -*/ +/*---- limit = 0.94*(32>>reduction_code); ----*/ + limit = (32 >> reduction_code); + if (limit > 8) + limit--; + if (pMP3Stream->nsb_limit > limit) + pMP3Stream->nsb_limit = limit; + if (pMP3Stream->nsb_limit > pMP3Stream->max_sb) + pMP3Stream->nsb_limit = pMP3Stream->max_sb; + + pMP3Stream->outvalues = 384 >> reduction_code; + if (h->mode != 3) + { /* adjust for 2 channel modes */ + pMP3Stream->nbatL1 *= 2; + pMP3Stream->max_sb *= 2; + pMP3Stream->nsb_limit *= 2; + } + +/* set sbt function */ + k = 1 + convert_code; + if (h->mode == 3) + { + k = 0; + } + pMP3Stream->sbt = sbt_table[bit_code][reduction_code][k]; + pMP3Stream->outvalues *= out_chans[k]; + + if (bit_code) + pMP3Stream->outbytes = pMP3Stream->outvalues; + else + pMP3Stream->outbytes = sizeof(short) * pMP3Stream->outvalues; + + decinfo.channels = out_chans[k]; + decinfo.outvalues = pMP3Stream->outvalues; + decinfo.samprate = samprate >> reduction_code; + if (bit_code) + decinfo.bits = 8; + else + decinfo.bits = sizeof(short) * 8; + + decinfo.framebytes = pMP3Stream->framebytes; + decinfo.type = 0; + + +/* clear sample buffer, unused sub bands must be 0 */ + for (i = 0; i < 768; i++) + sample[i] = 0.0F; + + +/* init sub-band transform */ + sbt_init(); + + return 1; +} +/*---------------------------------------------------------*/ +#endif // #ifdef COMPILE_ME + +#ifndef COMPILE_ME +// Dummy function to suppress empty translation unit warning +static void cupl1_dummy(void) {} +#endif diff --git a/src/client/mp3/cupl3.c b/src/client/mp3/cupl3.c new file mode 100644 index 0000000000..87da238121 --- /dev/null +++ b/src/client/mp3/cupl3.c @@ -0,0 +1,1301 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: cupl3.c,v 1.8 1999/10/19 07:13:08 elrod Exp $ +____________________________________________________________________________*/ + +/**** cupL3.c *************************************************** +unpack Layer III + + +mod 8/18/97 bugfix crc problem + +mod 10/9/97 add pMP3Stream->band_limit12 for short blocks + +mod 10/22/97 zero buf_ptrs in init + +mod 5/15/98 mpeg 2.5 + +mod 8/19/98 decode 22 sf bands + +******************************************************************/ + +/*--------------------------------------- +TO DO: Test mixed blocks (mixed long/short) + No mixed blocks in mpeg-1 test stream being used for development + +-----------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include "mhead.h" /* mpeg header structure */ +#include "l3.h" +#include "jdw.h" + +#include "mp3struct.h" + +#if !defined(min) +# define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +/*====================================================================*/ +static const int mp_sr20_table[2][4] = +{{441, 480, 320, -999}, {882, 960, 640, -999}}; +static const int mp_br_tableL3[2][16] = +{{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0}, /* mpeg 2 */ + {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0}}; + +/*====================================================================*/ + +/*-- global band tables */ +/*-- short portion is 3*x !! --*/ +////@@@@int nBand[2][22]; /* [long/short][cb] */ +////@@@@int sfBandIndex[2][22]; /* [long/short][cb] */ + +/*====================================================================*/ + +/*----------------*/ +extern DEC_INFO decinfo; ////@@@@ this is ok, only written to during init, then chucked. + +/*----------------*/ +////@@@@static int pMP3Stream->mpeg25_flag; // L3 only + +//int iframe; + +/*-------*/ +////@@@@static int pMP3Stream->band_limit = (576); // L3 only +////@@@@static int pMP3Stream->band_limit21 = (576); // limit for sf band 21 // L3 only +////@@@@static int pMP3Stream->band_limit12 = (576); // limit for sf band 12 short //L3 only + +////@@@@int band_limit_nsb = 32; /* global for hybrid */ +////@@@@static int pMP3Stream->nsb_limit = 32; +////@@@@static int pMP3Stream->gain_adjust = 0; /* adjust gain e.g. cvt to mono */ // L3 only +////@@@@static int id; // L3 only +////@@@@static int pMP3Stream->ncbl_mixed; /* number of long cb's in mixed block 8 or 6 */ // L3 only +////@@@@static int pMP3Stream->sr_index; // L3 only (99%) + +//@@@@ +////@@@@static int pMP3Stream->outvalues; // +////@@@@static int pMP3Stream->outbytes; // +////@@@@static int pMP3Stream->half_outbytes; // L3 only +////@@@@static int pMP3Stream->framebytes; // + +//static int padframebytes; +////@@@@static int pMP3Stream->crcbytes; // L3 only +////@@@@static int pMP3Stream->pad; // +//static int stereo_flag; // only written to +////@@@@static int pMP3Stream->nchan; // L3 only +////@@@@static int pMP3Stream->ms_mode; // L3 only (99%) +////@@@@static int pMP3Stream->is_mode; // L3 only +////@@@@static unsigned int pMP3Stream->zero_level_pcm = 0; // L3 only + +/* cb_info[igr][ch], compute by dequant, used by joint */ +static CB_INFO cb_info[2][2]; // L3 only ############ I think this is ok, only a scratchpad? +static IS_SF_INFO is_sf_info; /* MPEG-2 intensity stereo */ // L3 only ############## scratchpad? + +/*---------------------------------*/ +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +/* main data bit buffer */ +/*@@@@ +#define NBUF (8*1024) +#define BUF_TRIGGER (NBUF-1500) +static unsigned char buf[NBUF]; +static int buf_ptr0 = 0; // !!!!!!!!!!! +static int buf_ptr1 = 0; // !!!!!!!!!!! +static int main_pos_bit; +*/ +/*---------------------------------*/ +static SIDE_INFO side_info; // ####### scratchpad? + +static SCALEFACT sf[2][2]; /* [gr][ch] */ // ########## scratchpad? + +static int nsamp[2][2]; /* must start = 0, for nsamp[igr_prev] */ // ########## scratchpad? + +/*- sample union of int/float sample[ch][gr][576] */ +/* static SAMPLE sample[2][2][576]; */ +// @@@@FINDME +////@@@@extern SAMPLE sample[2][2][576]; ////////////????? suspicious, mainly used in decode loop, but zeroed init code +static float yout[576]; /* hybrid out, sbt in */ //////////// scratchpad + +////@@@@typedef void (*SBT_FUNCTION) (float *sample, short *pcm, int ch); +void sbt_dual_L3(float *sample, short *pcm, int n); +////@@@@static SBT_FUNCTION sbt_L3 = sbt_dual_L3; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +////@@@@typedef void (*XFORM_FUNCTION) (void *pcm, int igr); +static void Xform_dual(void *pcm, int igr); +////@@@@static XFORM_FUNCTION Xform = Xform_dual; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +IN_OUT L3audio_decode_MPEG1(unsigned char *bs, unsigned char *pcm); +IN_OUT L3audio_decode_MPEG2(unsigned char *bs, unsigned char *pcm); +////@@@@typedef IN_OUT(*DECODE_FUNCTION) (unsigned char *bs, unsigned char *pcm); +////@@@@static DECODE_FUNCTION decode_function = L3audio_decode_MPEG1; <------------------ needs streaming, ditto above!!! + + +/*====================================================================*/ +int hybrid(void *xin, void *xprev, float *y, + int btype, int nlong, int ntot, int nprev); +int hybrid_sum(void *xin, void *xin_left, float *y, + int btype, int nlong, int ntot); +void sum_f_bands(void *a, void *b, int n); +void FreqInvert(float *y, int n); +void antialias(void *x, int n); +void ms_process(void *x, int n); /* sum-difference stereo */ +void is_process_MPEG1(void *x, /* intensity stereo */ + SCALEFACT * sf, + CB_INFO cb_info[2], /* [ch] */ + int nsamp, int ms_mode); +void is_process_MPEG2(void *x, /* intensity stereo */ + SCALEFACT * sf, + CB_INFO cb_info[2], /* [ch] */ + IS_SF_INFO * is_sf_info, + int nsamp, int ms_mode); + +void unpack_huff(void *xy, int n, int ntable); +int unpack_huff_quad(void *vwxy, int n, int nbits, int ntable); +void dequant(SAMPLE sample[], int *nsamp, + SCALEFACT * sf, + GR * gr, + CB_INFO * cb_info, int ncbl_mixed); +void unpack_sf_sub_MPEG1(SCALEFACT * scalefac, GR * gr, + int scfsi, /* bit flag */ + int igr); +void unpack_sf_sub_MPEG2(SCALEFACT sf[], /* return intensity scale */ + GR * grdat, + int is_and_ch, IS_SF_INFO * is_sf_info); + +/*====================================================================*/ +/* get bits from bitstream in endian independent way */ + +BITDAT bitdat; /* global for inline use by Huff */ // !!!!!!!!!!!!!!!!!!! + +/*------------- initialize bit getter -------------*/ +static void bitget_init(unsigned char *buf) +{ + bitdat.bs_ptr0 = bitdat.bs_ptr = buf; + bitdat.bits = 0; + bitdat.bitbuf = 0; +} +/*------------- initialize bit getter -------------*/ +static void bitget_init_end(unsigned char *buf_end) +{ + bitdat.bs_ptr_end = buf_end; +} +/*------------- get n bits from bitstream -------------*/ +int bitget_bits_used(void); +void bitget_check(int n); +unsigned int bitget(int n); +unsigned int bitget_1bit(void); +IN_OUT L3audio_decode(unsigned char *bs, unsigned char *pcm); +int L3audio_decode_init(MPEG_HEAD * h, int framebytes_arg, + int reduction_code, int transform_code, int convert_code, + int freq_limit); + +int bitget_bits_used() +{ + int n; /* compute bits used from last init call */ + + n = ((bitdat.bs_ptr - bitdat.bs_ptr0) << 3) - bitdat.bits; + return n; +} +/*------------- check for n bits in bitbuf -------------*/ +void bitget_check(int n) +{ + if (bitdat.bits < n) + { + while (bitdat.bits <= 24) + { + bitdat.bitbuf = (bitdat.bitbuf << 8) | *bitdat.bs_ptr++; + bitdat.bits += 8; + } + } +} +/*------------- get n bits from bitstream -------------*/ +unsigned int bitget(int n) +{ + unsigned int x; + + if (bitdat.bits < n) + { /* refill bit buf if necessary */ + while (bitdat.bits <= 24) + { + bitdat.bitbuf = (bitdat.bitbuf << 8) | *bitdat.bs_ptr++; + bitdat.bits += 8; + } + } + bitdat.bits -= n; + x = bitdat.bitbuf >> bitdat.bits; + bitdat.bitbuf -= x << bitdat.bits; + return x; +} +/*------------- get 1 bit from bitstream -------------*/ +unsigned int bitget_1bit() +{ + unsigned int x; + + if (bitdat.bits <= 0) + { /* refill bit buf if necessary */ + while (bitdat.bits <= 24) + { + bitdat.bitbuf = (bitdat.bitbuf << 8) | *bitdat.bs_ptr++; + bitdat.bits += 8; + } + } + bitdat.bits--; + x = bitdat.bitbuf >> bitdat.bits; + bitdat.bitbuf -= x << bitdat.bits; + return x; +} +/*====================================================================*/ +static void Xform_mono(void *pcm, int igr) +{ + int igr_prev, n1, n2; + +/*--- hybrid + sbt ---*/ + n1 = n2 = nsamp[igr][0]; /* total number bands */ + if (side_info.gr[igr][0].block_type == 2) + { /* long bands */ + n1 = 0; + if (side_info.gr[igr][0].mixed_block_flag) + n1 = pMP3Stream->sfBandIndex[0][pMP3Stream->ncbl_mixed - 1]; + } + if (n1 > pMP3Stream->band_limit) + n1 = pMP3Stream->band_limit; + if (n2 > pMP3Stream->band_limit) + n2 = pMP3Stream->band_limit; + igr_prev = igr ^ 1; + + nsamp[igr][0] = hybrid(pMP3Stream->sample[0][igr], pMP3Stream->sample[0][igr_prev], + yout, side_info.gr[igr][0].block_type, n1, n2, nsamp[igr_prev][0]); + FreqInvert(yout, nsamp[igr][0]); + pMP3Stream->sbt_L3(yout, pcm, 0); + +} +/*--------------------------------------------------------------------*/ +static void Xform_dual_right(void *pcm, int igr) +{ + int igr_prev, n1, n2; + +/*--- hybrid + sbt ---*/ + n1 = n2 = nsamp[igr][1]; /* total number bands */ + if (side_info.gr[igr][1].block_type == 2) + { /* long bands */ + n1 = 0; + if (side_info.gr[igr][1].mixed_block_flag) + n1 = pMP3Stream->sfBandIndex[0][pMP3Stream->ncbl_mixed - 1]; + } + if (n1 > pMP3Stream->band_limit) + n1 = pMP3Stream->band_limit; + if (n2 > pMP3Stream->band_limit) + n2 = pMP3Stream->band_limit; + igr_prev = igr ^ 1; + nsamp[igr][1] = hybrid(pMP3Stream->sample[1][igr], pMP3Stream->sample[1][igr_prev], + yout, side_info.gr[igr][1].block_type, n1, n2, nsamp[igr_prev][1]); + FreqInvert(yout, nsamp[igr][1]); + pMP3Stream->sbt_L3(yout, pcm, 0); + +} +/*--------------------------------------------------------------------*/ +static void Xform_dual(void *pcm, int igr) +{ + int ch; + int igr_prev, n1, n2; + +/*--- hybrid + sbt ---*/ + igr_prev = igr ^ 1; + for (ch = 0; ch < pMP3Stream->nchan; ch++) + { + n1 = n2 = nsamp[igr][ch]; /* total number bands */ + if (side_info.gr[igr][ch].block_type == 2) + { /* long bands */ + n1 = 0; + if (side_info.gr[igr][ch].mixed_block_flag) + n1 = pMP3Stream->sfBandIndex[0][pMP3Stream->ncbl_mixed - 1]; + } + if (n1 > pMP3Stream->band_limit) + n1 = pMP3Stream->band_limit; + if (n2 > pMP3Stream->band_limit) + n2 = pMP3Stream->band_limit; + nsamp[igr][ch] = hybrid(pMP3Stream->sample[ch][igr], pMP3Stream->sample[ch][igr_prev], + yout, side_info.gr[igr][ch].block_type, n1, n2, nsamp[igr_prev][ch]); + FreqInvert(yout, nsamp[igr][ch]); + pMP3Stream->sbt_L3(yout, pcm, ch); + } + +} +/*--------------------------------------------------------------------*/ +static void Xform_dual_mono(void *pcm, int igr) +{ + int igr_prev, n1, n2, n3; + +/*--- hybrid + sbt ---*/ + igr_prev = igr ^ 1; + if ((side_info.gr[igr][0].block_type == side_info.gr[igr][1].block_type) + && (side_info.gr[igr][0].mixed_block_flag == 0) + && (side_info.gr[igr][1].mixed_block_flag == 0)) + { + + n2 = nsamp[igr][0]; /* total number bands max of L R */ + if (n2 < nsamp[igr][1]) + n2 = nsamp[igr][1]; + if (n2 > pMP3Stream->band_limit) + n2 = pMP3Stream->band_limit; + n1 = n2; /* n1 = number long bands */ + if (side_info.gr[igr][0].block_type == 2) + n1 = 0; + sum_f_bands(pMP3Stream->sample[0][igr], pMP3Stream->sample[1][igr], n2); + n3 = nsamp[igr][0] = hybrid(pMP3Stream->sample[0][igr], pMP3Stream->sample[0][igr_prev], + yout, side_info.gr[igr][0].block_type, n1, n2, nsamp[igr_prev][0]); + } + else + { /* transform and then sum (not tested - never happens in test) */ +/*-- left chan --*/ + n1 = n2 = nsamp[igr][0]; /* total number bands */ + if (side_info.gr[igr][0].block_type == 2) + { + n1 = 0; /* long bands */ + if (side_info.gr[igr][0].mixed_block_flag) + n1 = pMP3Stream->sfBandIndex[0][pMP3Stream->ncbl_mixed - 1]; + } + n3 = nsamp[igr][0] = hybrid(pMP3Stream->sample[0][igr], pMP3Stream->sample[0][igr_prev], + yout, side_info.gr[igr][0].block_type, n1, n2, nsamp[igr_prev][0]); +/*-- right chan --*/ + n1 = n2 = nsamp[igr][1]; /* total number bands */ + if (side_info.gr[igr][1].block_type == 2) + { + n1 = 0; /* long bands */ + if (side_info.gr[igr][1].mixed_block_flag) + n1 = pMP3Stream->sfBandIndex[0][pMP3Stream->ncbl_mixed - 1]; + } + nsamp[igr][1] = hybrid_sum(pMP3Stream->sample[1][igr], pMP3Stream->sample[0][igr], + yout, side_info.gr[igr][1].block_type, n1, n2); + if (n3 < nsamp[igr][1]) + n1 = nsamp[igr][1]; + } + +/*--------*/ + FreqInvert(yout, n3); + pMP3Stream->sbt_L3(yout, pcm, 0); + +} +/*--------------------------------------------------------------------*/ +/*====================================================================*/ +static int unpack_side_MPEG1() +{ + int prot; + int br_index; + int igr, ch; + int side_bytes; + +/* decode partial header plus initial side info */ +/* at entry bit getter points at id, sync skipped by caller */ + + pMP3Stream->id = bitget(1); /* id */ + bitget(2); /* skip layer */ + prot = bitget(1); /* bitget prot bit */ + br_index = bitget(4); + pMP3Stream->sr_index = bitget(2); + pMP3Stream->pad = bitget(1); + bitget(1); /* skip to mode */ + side_info.mode = bitget(2); /* mode */ + side_info.mode_ext = bitget(2); /* mode ext */ + + if (side_info.mode != 1) + side_info.mode_ext = 0; + +/* adjust global gain in ms mode to avoid having to mult by 1/sqrt(2) */ + pMP3Stream->ms_mode = side_info.mode_ext >> 1; + pMP3Stream->is_mode = side_info.mode_ext & 1; + + + pMP3Stream->crcbytes = 0; + if (prot) + bitget(4); /* skip to data */ + else + { + bitget(20); /* skip crc */ + pMP3Stream->crcbytes = 2; + } + + if (br_index > 0) /* pMP3Stream->framebytes fixed for free format */ + { + pMP3Stream->framebytes = + 2880 * mp_br_tableL3[pMP3Stream->id][br_index] / mp_sr20_table[pMP3Stream->id][pMP3Stream->sr_index]; + } + + side_info.main_data_begin = bitget(9); + if (side_info.mode == 3) + { + side_info.private_bits = bitget(5); + pMP3Stream->nchan = 1; +// stereo_flag = 0; + side_bytes = (4 + 17); +/*-- with header --*/ + } + else + { + side_info.private_bits = bitget(3); + pMP3Stream->nchan = 2; +// stereo_flag = 1; + side_bytes = (4 + 32); +/*-- with header --*/ + } + for (ch = 0; ch < pMP3Stream->nchan; ch++) + side_info.scfsi[ch] = bitget(4); +/* this always 0 (both igr) for short blocks */ + + for (igr = 0; igr < 2; igr++) + { + for (ch = 0; ch < pMP3Stream->nchan; ch++) + { + side_info.gr[igr][ch].part2_3_length = bitget(12); + side_info.gr[igr][ch].big_values = bitget(9); + side_info.gr[igr][ch].global_gain = bitget(8) + pMP3Stream->gain_adjust; + if (pMP3Stream->ms_mode) + side_info.gr[igr][ch].global_gain -= 2; + side_info.gr[igr][ch].scalefac_compress = bitget(4); + side_info.gr[igr][ch].window_switching_flag = bitget(1); + if (side_info.gr[igr][ch].window_switching_flag) + { + side_info.gr[igr][ch].block_type = bitget(2); + side_info.gr[igr][ch].mixed_block_flag = bitget(1); + side_info.gr[igr][ch].table_select[0] = bitget(5); + side_info.gr[igr][ch].table_select[1] = bitget(5); + side_info.gr[igr][ch].subblock_gain[0] = bitget(3); + side_info.gr[igr][ch].subblock_gain[1] = bitget(3); + side_info.gr[igr][ch].subblock_gain[2] = bitget(3); + /* region count set in terms of long block cb's/bands */ + /* r1 set so r0+r1+1 = 21 (lookup produces 576 bands ) */ + /* if(window_switching_flag) always 36 samples in region0 */ + side_info.gr[igr][ch].region0_count = (8 - 1); /* 36 samples */ + side_info.gr[igr][ch].region1_count = 20 - (8 - 1); + } + else + { + side_info.gr[igr][ch].mixed_block_flag = 0; + side_info.gr[igr][ch].block_type = 0; + side_info.gr[igr][ch].table_select[0] = bitget(5); + side_info.gr[igr][ch].table_select[1] = bitget(5); + side_info.gr[igr][ch].table_select[2] = bitget(5); + side_info.gr[igr][ch].region0_count = bitget(4); + side_info.gr[igr][ch].region1_count = bitget(3); + } + side_info.gr[igr][ch].preflag = bitget(1); + side_info.gr[igr][ch].scalefac_scale = bitget(1); + side_info.gr[igr][ch].count1table_select = bitget(1); + } + } + + + +/* return bytes in header + side info */ + return side_bytes; +} +/*====================================================================*/ +static int unpack_side_MPEG2(int igr) +{ + int prot; + int br_index; + int ch; + int side_bytes; + +/* decode partial header plus initial side info */ +/* at entry bit getter points at id, sync skipped by caller */ + + pMP3Stream->id = bitget(1); /* id */ + bitget(2); /* skip layer */ + prot = bitget(1); /* bitget prot bit */ + br_index = bitget(4); + pMP3Stream->sr_index = bitget(2); + pMP3Stream->pad = bitget(1); + bitget(1); /* skip to mode */ + side_info.mode = bitget(2); /* mode */ + side_info.mode_ext = bitget(2); /* mode ext */ + + if (side_info.mode != 1) + side_info.mode_ext = 0; + +/* adjust global gain in ms mode to avoid having to mult by 1/sqrt(2) */ + pMP3Stream->ms_mode = side_info.mode_ext >> 1; + pMP3Stream->is_mode = side_info.mode_ext & 1; + + pMP3Stream->crcbytes = 0; + if (prot) + bitget(4); /* skip to data */ + else + { + bitget(20); /* skip crc */ + pMP3Stream->crcbytes = 2; + } + + if (br_index > 0) + { /* pMP3Stream->framebytes fixed for free format */ + if (pMP3Stream->mpeg25_flag == 0) + { + pMP3Stream->framebytes = + 1440 * mp_br_tableL3[pMP3Stream->id][br_index] / mp_sr20_table[pMP3Stream->id][pMP3Stream->sr_index]; + } + else + { + pMP3Stream->framebytes = + 2880 * mp_br_tableL3[pMP3Stream->id][br_index] / mp_sr20_table[pMP3Stream->id][pMP3Stream->sr_index]; + //if( pMP3Stream->sr_index == 2 ) return 0; // fail mpeg25 8khz + } + } + side_info.main_data_begin = bitget(8); + if (side_info.mode == 3) + { + side_info.private_bits = bitget(1); + pMP3Stream->nchan = 1; +// stereo_flag = 0; + side_bytes = (4 + 9); +/*-- with header --*/ + } + else + { + side_info.private_bits = bitget(2); + pMP3Stream->nchan = 2; +// stereo_flag = 1; + side_bytes = (4 + 17); +/*-- with header --*/ + } + side_info.scfsi[1] = side_info.scfsi[0] = 0; + + + for (ch = 0; ch < pMP3Stream->nchan; ch++) + { + side_info.gr[igr][ch].part2_3_length = bitget(12); + side_info.gr[igr][ch].big_values = bitget(9); + side_info.gr[igr][ch].global_gain = bitget(8) + pMP3Stream->gain_adjust; + if (pMP3Stream->ms_mode) + side_info.gr[igr][ch].global_gain -= 2; + side_info.gr[igr][ch].scalefac_compress = bitget(9); + side_info.gr[igr][ch].window_switching_flag = bitget(1); + if (side_info.gr[igr][ch].window_switching_flag) + { + side_info.gr[igr][ch].block_type = bitget(2); + side_info.gr[igr][ch].mixed_block_flag = bitget(1); + side_info.gr[igr][ch].table_select[0] = bitget(5); + side_info.gr[igr][ch].table_select[1] = bitget(5); + side_info.gr[igr][ch].subblock_gain[0] = bitget(3); + side_info.gr[igr][ch].subblock_gain[1] = bitget(3); + side_info.gr[igr][ch].subblock_gain[2] = bitget(3); + /* region count set in terms of long block cb's/bands */ + /* r1 set so r0+r1+1 = 21 (lookup produces 576 bands ) */ + /* bt=1 or 3 54 samples */ + /* bt=2 mixed=0 36 samples */ + /* bt=2 mixed=1 54 (8 long sf) samples? or maybe 36 */ + /* region0 discussion says 54 but this would mix long */ + /* and short in region0 if scale factors switch */ + /* at band 36 (6 long scale factors) */ + if (side_info.gr[igr][ch].block_type == 2) + { + side_info.gr[igr][ch].region0_count = (6 - 1); /* 36 samples */ + side_info.gr[igr][ch].region1_count = 20 - (6 - 1); + } + else + { /* long block type 1 or 3 */ + side_info.gr[igr][ch].region0_count = (8 - 1); /* 54 samples */ + side_info.gr[igr][ch].region1_count = 20 - (8 - 1); + } + } + else + { + side_info.gr[igr][ch].mixed_block_flag = 0; + side_info.gr[igr][ch].block_type = 0; + side_info.gr[igr][ch].table_select[0] = bitget(5); + side_info.gr[igr][ch].table_select[1] = bitget(5); + side_info.gr[igr][ch].table_select[2] = bitget(5); + side_info.gr[igr][ch].region0_count = bitget(4); + side_info.gr[igr][ch].region1_count = bitget(3); + } + side_info.gr[igr][ch].preflag = 0; + side_info.gr[igr][ch].scalefac_scale = bitget(1); + side_info.gr[igr][ch].count1table_select = bitget(1); + } + +/* return bytes in header + side info */ + return side_bytes; +} +/*-----------------------------------------------------------------*/ +static void unpack_main(unsigned char *pcm, int igr) +{ + int ch; + int bit0; + int n1, n2, n3, n4, nn2, nn3; + int nn4; + int qbits; + int m0; + + + for (ch = 0; ch < pMP3Stream->nchan; ch++) + { + bitget_init(pMP3Stream->buf + (pMP3Stream->main_pos_bit >> 3)); + bit0 = (pMP3Stream->main_pos_bit & 7); + if (bit0) + bitget(bit0); + pMP3Stream->main_pos_bit += side_info.gr[igr][ch].part2_3_length; + bitget_init_end(pMP3Stream->buf + ((pMP3Stream->main_pos_bit + 39) >> 3)); +/*-- scale factors --*/ + if (pMP3Stream->id) + unpack_sf_sub_MPEG1(&sf[igr][ch], + &side_info.gr[igr][ch], side_info.scfsi[ch], igr); + else + unpack_sf_sub_MPEG2(&sf[igr][ch], + &side_info.gr[igr][ch], pMP3Stream->is_mode & ch, &is_sf_info); +/*--- huff data ---*/ + n1 = pMP3Stream->sfBandIndex[0][side_info.gr[igr][ch].region0_count]; + n2 = pMP3Stream->sfBandIndex[0][side_info.gr[igr][ch].region0_count + + side_info.gr[igr][ch].region1_count + 1]; + n3 = side_info.gr[igr][ch].big_values; + n3 = n3 + n3; + + + if (n3 > pMP3Stream->band_limit) + n3 = pMP3Stream->band_limit; + if (n2 > n3) + n2 = n3; + if (n1 > n3) + n1 = n3; + nn3 = n3 - n2; + nn2 = n2 - n1; + unpack_huff(pMP3Stream->sample[ch][igr], n1, side_info.gr[igr][ch].table_select[0]); + unpack_huff(pMP3Stream->sample[ch][igr] + n1, nn2, side_info.gr[igr][ch].table_select[1]); + unpack_huff(pMP3Stream->sample[ch][igr] + n2, nn3, side_info.gr[igr][ch].table_select[2]); + qbits = side_info.gr[igr][ch].part2_3_length - (bitget_bits_used() - bit0); + nn4 = unpack_huff_quad(pMP3Stream->sample[ch][igr] + n3, pMP3Stream->band_limit - n3, qbits, + side_info.gr[igr][ch].count1table_select); + n4 = n3 + nn4; + nsamp[igr][ch] = n4; + //limit n4 or allow deqaunt to sf band 22 + if (side_info.gr[igr][ch].block_type == 2) + n4 = min(n4, pMP3Stream->band_limit12); + else + n4 = min(n4, pMP3Stream->band_limit21); + if (n4 < 576) + memset(pMP3Stream->sample[ch][igr] + n4, 0, sizeof(SAMPLE) * (576 - n4)); + if (bitdat.bs_ptr > bitdat.bs_ptr_end) + { // bad data overrun + + memset(pMP3Stream->sample[ch][igr], 0, sizeof(SAMPLE) * (576)); + } + } + + + +/*--- dequant ---*/ + for (ch = 0; ch < pMP3Stream->nchan; ch++) + { + dequant(pMP3Stream->sample[ch][igr], + &nsamp[igr][ch], /* nsamp updated for shorts */ + &sf[igr][ch], &side_info.gr[igr][ch], + &cb_info[igr][ch], pMP3Stream->ncbl_mixed); + } + +/*--- ms stereo processing ---*/ + if (pMP3Stream->ms_mode) + { + if (pMP3Stream->is_mode == 0) + { + m0 = nsamp[igr][0]; /* process to longer of left/right */ + if (m0 < nsamp[igr][1]) + m0 = nsamp[igr][1]; + } + else + { /* process to last cb in right */ + m0 = pMP3Stream->sfBandIndex[cb_info[igr][1].cbtype][cb_info[igr][1].cbmax]; + } + ms_process(pMP3Stream->sample[0][igr], m0); + } + +/*--- is stereo processing ---*/ + if (pMP3Stream->is_mode) + { + if (pMP3Stream->id) + is_process_MPEG1(pMP3Stream->sample[0][igr], &sf[igr][1], + cb_info[igr], nsamp[igr][0], pMP3Stream->ms_mode); + else + is_process_MPEG2(pMP3Stream->sample[0][igr], &sf[igr][1], + cb_info[igr], &is_sf_info, + nsamp[igr][0], pMP3Stream->ms_mode); + } + +/*-- adjust ms and is modes to max of left/right */ + if (side_info.mode_ext) + { + if (nsamp[igr][0] < nsamp[igr][1]) + nsamp[igr][0] = nsamp[igr][1]; + else + nsamp[igr][1] = nsamp[igr][0]; + } + +/*--- antialias ---*/ + for (ch = 0; ch < pMP3Stream->nchan; ch++) + { + if (cb_info[igr][ch].ncbl == 0) + continue; /* have no long blocks */ + if (side_info.gr[igr][ch].mixed_block_flag) + n1 = 1; /* 1 -> 36 samples */ + else + n1 = (nsamp[igr][ch] + 7) / 18; + if (n1 > 31) + n1 = 31; + antialias(pMP3Stream->sample[ch][igr], n1); + n1 = 18 * n1 + 8; /* update number of samples */ + if (n1 > nsamp[igr][ch]) + nsamp[igr][ch] = n1; + } + + + +/*--- hybrid + sbt ---*/ + pMP3Stream->Xform(pcm, igr); + + +/*-- done --*/ +} +/*--------------------------------------------------------------------*/ +/*-----------------------------------------------------------------*/ +IN_OUT L3audio_decode(unsigned char *bs, unsigned char *pcm) +{ + return pMP3Stream->decode_function(bs, pcm); +} + +/*--------------------------------------------------------------------*/ +extern unsigned char *gpNextByteAfterData; +IN_OUT L3audio_decode_MPEG1(unsigned char *bs, unsigned char *pcm) +{ + int sync; + IN_OUT in_out; + int side_bytes; + int nbytes; + + int padframebytes; ////@@@@ + +// iframe++; + + bitget_init(bs); /* initialize bit getter */ +/* test sync */ + in_out.in_bytes = 0; /* assume fail */ + in_out.out_bytes = 0; + sync = bitget(12); + + if (sync != 0xFFF) + return in_out; /* sync fail */ +/*-----------*/ + +/*-- unpack side info --*/ + side_bytes = unpack_side_MPEG1(); + padframebytes = pMP3Stream->framebytes + pMP3Stream->pad; + + if (bs + padframebytes > gpNextByteAfterData) + return in_out; // error check if we're about to read off the end of the legal memory (caused by certain MP3 writers' goofy comment formats) -ste. + in_out.in_bytes = padframebytes; + +/*-- load main data and update buf pointer --*/ +/*------------------------------------------- + if start point < 0, must just cycle decoder + if jumping into middle of stream, +w---------------------------------------------*/ + pMP3Stream->buf_ptr0 = pMP3Stream->buf_ptr1 - side_info.main_data_begin; /* decode start point */ + if (pMP3Stream->buf_ptr1 > BUF_TRIGGER) + { /* shift buffer */ + memmove(pMP3Stream->buf, pMP3Stream->buf + pMP3Stream->buf_ptr0, side_info.main_data_begin); + pMP3Stream->buf_ptr0 = 0; + pMP3Stream->buf_ptr1 = side_info.main_data_begin; + } + nbytes = padframebytes - side_bytes - pMP3Stream->crcbytes; + + // RAK: This is no bueno. :-( + if (nbytes < 0 || nbytes > NBUF) + { + in_out.in_bytes = 0; + return in_out; + } + + if (bFastEstimateOnly) + { + in_out.out_bytes = pMP3Stream->outbytes; + return in_out; + } + + memmove(pMP3Stream->buf + pMP3Stream->buf_ptr1, bs + side_bytes + pMP3Stream->crcbytes, nbytes); + pMP3Stream->buf_ptr1 += nbytes; +/*-----------------------*/ + + if (pMP3Stream->buf_ptr0 >= 0) + { +// dump_frame(buf+buf_ptr0, 64); + pMP3Stream->main_pos_bit = pMP3Stream->buf_ptr0 << 3; + unpack_main(pcm, 0); + unpack_main(pcm + pMP3Stream->half_outbytes, 1); + in_out.out_bytes = pMP3Stream->outbytes; + } + else + { + memset(pcm, pMP3Stream->zero_level_pcm, pMP3Stream->outbytes); /* fill out skipped frames */ + in_out.out_bytes = pMP3Stream->outbytes; +/* iframe--; in_out.out_bytes = 0; // test test */ + } + + return in_out; +} +/*--------------------------------------------------------------------*/ +/*--------------------------------------------------------------------*/ +IN_OUT L3audio_decode_MPEG2(unsigned char *bs, unsigned char *pcm) +{ + int sync; + IN_OUT in_out; + int side_bytes; + int nbytes; + static int igr = 0; + + int padframebytes; ////@@@@ + +// iframe++; + + + bitget_init(bs); /* initialize bit getter */ +/* test sync */ + in_out.in_bytes = 0; /* assume fail */ + in_out.out_bytes = 0; + sync = bitget(12); + +// if( sync != 0xFFF ) return in_out; /* sync fail */ + + pMP3Stream->mpeg25_flag = 0; + if (sync != 0xFFF) + { + pMP3Stream->mpeg25_flag = 1; /* mpeg 2.5 sync */ + if (sync != 0xFFE) + return in_out; /* sync fail */ + } +/*-----------*/ + + +/*-- unpack side info --*/ + side_bytes = unpack_side_MPEG2(igr); + padframebytes = pMP3Stream->framebytes + pMP3Stream->pad; + in_out.in_bytes = padframebytes; + + pMP3Stream->buf_ptr0 = pMP3Stream->buf_ptr1 - side_info.main_data_begin; /* decode start point */ + if (pMP3Stream->buf_ptr1 > BUF_TRIGGER) + { /* shift buffer */ + memmove(pMP3Stream->buf, pMP3Stream->buf + pMP3Stream->buf_ptr0, side_info.main_data_begin); + pMP3Stream->buf_ptr0 = 0; + pMP3Stream->buf_ptr1 = side_info.main_data_begin; + } + nbytes = padframebytes - side_bytes - pMP3Stream->crcbytes; + // RAK: This is no bueno. :-( + if (nbytes < 0 || nbytes > NBUF) + { + in_out.in_bytes = 0; + return in_out; + } + + if (bFastEstimateOnly) + { + in_out.out_bytes = pMP3Stream->outbytes; + return in_out; + } + + memmove(pMP3Stream->buf + pMP3Stream->buf_ptr1, bs + side_bytes + pMP3Stream->crcbytes, nbytes); + pMP3Stream->buf_ptr1 += nbytes; +/*-----------------------*/ + + if (pMP3Stream->buf_ptr0 >= 0) + { + pMP3Stream->main_pos_bit = pMP3Stream->buf_ptr0 << 3; + unpack_main(pcm, igr); + in_out.out_bytes = pMP3Stream->outbytes; + } + else + { + memset(pcm, pMP3Stream->zero_level_pcm, pMP3Stream->outbytes); /* fill out skipped frames */ + in_out.out_bytes = pMP3Stream->outbytes; +// iframe--; in_out.out_bytes = 0; return in_out;// test test */ + } + + + + igr = igr ^ 1; + return in_out; +} +/*--------------------------------------------------------------------*/ +/*--------------------------------------------------------------------*/ +/*--------------------------------------------------------------------*/ +static const int sr_table[8] = +{22050, 24000, 16000, 1, + 44100, 48000, 32000, 1}; + +static const struct +{ + int l[23]; + int s[14]; +} +sfBandIndexTable[3][3] = +{ +/* mpeg-2 */ + { + { + { + 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576 + } + , + { + 0, 4, 8, 12, 18, 24, 32, 42, 56, 74, 100, 132, 174, 192 + } + } + , + { + { + 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 114, 136, 162, 194, 232, 278, 332, 394, 464, 540, 576 + } + , + { + 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 136, 180, 192 + } + } + , + { + { + 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576 + } + , + { + 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192 + } + } + , + } + , +/* mpeg-1 */ + { + { + { + 0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 52, 62, 74, 90, 110, 134, 162, 196, 238, 288, 342, 418, 576 + } + , + { + 0, 4, 8, 12, 16, 22, 30, 40, 52, 66, 84, 106, 136, 192 + } + } + , + { + { + 0, 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 60, 72, 88, 106, 128, 156, 190, 230, 276, 330, 384, 576 + } + , + { + 0, 4, 8, 12, 16, 22, 28, 38, 50, 64, 80, 100, 126, 192 + } + } + , + { + { + 0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 54, 66, 82, 102, 126, 156, 194, 240, 296, 364, 448, 550, 576 + } + , + { + 0, 4, 8, 12, 16, 22, 30, 42, 58, 78, 104, 138, 180, 192 + } + } + } + , + +/* mpeg-2.5, 11 & 12 KHz seem ok, 8 ok */ + { + { + { + 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576 + } + , + { + 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192 + } + } + , + { + { + 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576 + } + , + { + 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192 + } + } + , +// this 8khz table, and only 8khz, from mpeg123) + { + { + 0, 12, 24, 36, 48, 60, 72, 88, 108, 132, 160, 192, 232, 280, 336, 400, 476, 566, 568, 570, 572, 574, 576 + } + , + { + 0, 8, 16, 24, 36, 52, 72, 96, 124, 160, 162, 164, 166, 192 + } + } + , + } + , +}; + + +void sbt_mono_L3(float *sample, signed short *pcm, int ch); +void sbt_dual_L3(float *sample, signed short *pcm, int ch); +void sbt16_mono_L3(float *sample, signed short *pcm, int ch); +void sbt16_dual_L3(float *sample, signed short *pcm, int ch); +void sbt8_mono_L3(float *sample, signed short *pcm, int ch); +void sbt8_dual_L3(float *sample, signed short *pcm, int ch); + +void sbtB_mono_L3(float *sample, unsigned char *pcm, int ch); +void sbtB_dual_L3(float *sample, unsigned char *pcm, int ch); +void sbtB16_mono_L3(float *sample, unsigned char *pcm, int ch); +void sbtB16_dual_L3(float *sample, unsigned char *pcm, int ch); +void sbtB8_mono_L3(float *sample, unsigned char *pcm, int ch); +void sbtB8_dual_L3(float *sample, unsigned char *pcm, int ch); + + + +static const SBT_FUNCTION sbt_table[2][3][2] = +{ +{{ (SBT_FUNCTION) sbt_mono_L3, + (SBT_FUNCTION) sbt_dual_L3 } , + { (SBT_FUNCTION) sbt16_mono_L3, + (SBT_FUNCTION) sbt16_dual_L3 } , + { (SBT_FUNCTION) sbt8_mono_L3, + (SBT_FUNCTION) sbt8_dual_L3 }} , +/*-- 8 bit output -*/ +{{ (SBT_FUNCTION) sbtB_mono_L3, + (SBT_FUNCTION) sbtB_dual_L3 }, + { (SBT_FUNCTION) sbtB16_mono_L3, + (SBT_FUNCTION) sbtB16_dual_L3 }, + { (SBT_FUNCTION) sbtB8_mono_L3, + (SBT_FUNCTION) sbtB8_dual_L3 }} +}; + + +void Xform_mono(void *pcm, int igr); +void Xform_dual(void *pcm, int igr); +void Xform_dual_mono(void *pcm, int igr); +void Xform_dual_right(void *pcm, int igr); + +static XFORM_FUNCTION xform_table[5] = +{ + Xform_mono, + Xform_dual, + Xform_dual_mono, + Xform_mono, /* left */ + Xform_dual_right, +}; +int L3table_init(); +void msis_init(); +void sbt_init(); +typedef int iARRAY22[22]; +iARRAY22 *quant_init_band_addr(); +iARRAY22 *msis_init_band_addr(); + +/*---------------------------------------------------------*/ +/* mpeg_head defined in mhead.h frame bytes is without pMP3Stream->pad */ +////@@@@INIT +int L3audio_decode_init(MPEG_HEAD * h, int framebytes_arg, + int reduction_code, int transform_code, int convert_code, + int freq_limit) +{ + int i, j, k; + // static int first_pass = 1; + + (void)transform_code; /* unused */ + int samprate; + int limit; + int bit_code; + int out_chans; + + pMP3Stream->buf_ptr0 = 0; + pMP3Stream->buf_ptr1 = 0; + +/* check if code handles */ + if (h->option != 1) + return 0; /* layer III only */ + + if (h->id) + pMP3Stream->ncbl_mixed = 8; /* mpeg-1 */ + else + pMP3Stream->ncbl_mixed = 6; /* mpeg-2 */ + + pMP3Stream->framebytes = framebytes_arg; + + bit_code = 0; + if (convert_code & 8) + bit_code = 1; + convert_code = convert_code & 3; /* higher bits used by dec8 freq cvt */ + if (reduction_code < 0) + reduction_code = 0; + if (reduction_code > 2) + reduction_code = 2; + if (freq_limit < 1000) + freq_limit = 1000; + + + samprate = sr_table[4 * h->id + h->sr_index]; + if ((h->sync & 1) == 0) + samprate = samprate / 2; // mpeg 2.5 +/*----- compute pMP3Stream->nsb_limit --------*/ + pMP3Stream->nsb_limit = (freq_limit * 64L + samprate / 2) / samprate; +/*- caller limit -*/ + limit = (32 >> reduction_code); + if (limit > 8) + limit--; + if (pMP3Stream->nsb_limit > limit) + pMP3Stream->nsb_limit = limit; + limit = 18 * pMP3Stream->nsb_limit; + + k = h->id; + if ((h->sync & 1) == 0) + k = 2; // mpeg 2.5 + + if (k == 1) + { + pMP3Stream->band_limit12 = 3 * sfBandIndexTable[k][h->sr_index].s[13]; + pMP3Stream->band_limit = pMP3Stream->band_limit21 = sfBandIndexTable[k][h->sr_index].l[22]; + } + else + { + pMP3Stream->band_limit12 = 3 * sfBandIndexTable[k][h->sr_index].s[12]; + pMP3Stream->band_limit = pMP3Stream->band_limit21 = sfBandIndexTable[k][h->sr_index].l[21]; + } + pMP3Stream->band_limit += 8; /* allow for antialias */ + if (pMP3Stream->band_limit > limit) + pMP3Stream->band_limit = limit; + + if (pMP3Stream->band_limit21 > pMP3Stream->band_limit) + pMP3Stream->band_limit21 = pMP3Stream->band_limit; + if (pMP3Stream->band_limit12 > pMP3Stream->band_limit) + pMP3Stream->band_limit12 = pMP3Stream->band_limit; + + + pMP3Stream->band_limit_nsb = (pMP3Stream->band_limit + 17) / 18; /* limit nsb's rounded up */ +/*----------------------------------------------*/ + pMP3Stream->gain_adjust = 0; /* adjust gain e.g. cvt to mono sum channel */ + if ((h->mode != 3) && (convert_code == 1)) + pMP3Stream->gain_adjust = -4; + + pMP3Stream->outvalues = 1152 >> reduction_code; + if (h->id == 0) + pMP3Stream->outvalues /= 2; + + out_chans = 2; + if (h->mode == 3) + out_chans = 1; + if (convert_code) + out_chans = 1; + + pMP3Stream->sbt_L3 = sbt_table[bit_code][reduction_code][out_chans - 1]; + k = 1 + convert_code; + if (h->mode == 3) + k = 0; + pMP3Stream->Xform = xform_table[k]; + + + pMP3Stream->outvalues *= out_chans; + + if (bit_code) + pMP3Stream->outbytes = pMP3Stream->outvalues; + else + pMP3Stream->outbytes = sizeof(short) * pMP3Stream->outvalues; + + if (bit_code) + pMP3Stream->zero_level_pcm = 128; /* 8 bit output */ + else + pMP3Stream->zero_level_pcm = 0; + + + decinfo.channels = out_chans; + decinfo.outvalues = pMP3Stream->outvalues; + decinfo.samprate = samprate >> reduction_code; + if (bit_code) + decinfo.bits = 8; + else + decinfo.bits = sizeof(short) * 8; + + decinfo.framebytes = pMP3Stream->framebytes; + decinfo.type = 0; + + pMP3Stream->half_outbytes = pMP3Stream->outbytes / 2; +/*------------------------------------------*/ + +/*- init band tables --*/ + + + k = h->id; + if ((h->sync & 1) == 0) + k = 2; // mpeg 2.5 + + for (i = 0; i < 22; i++) + pMP3Stream->sfBandIndex[0][i] = sfBandIndexTable[k][h->sr_index].l[i + 1]; + for (i = 0; i < 13; i++) + pMP3Stream->sfBandIndex[1][i] = 3 * sfBandIndexTable[k][h->sr_index].s[i + 1]; + for (i = 0; i < 22; i++) + pMP3Stream->nBand[0][i] = sfBandIndexTable[k][h->sr_index].l[i + 1] - sfBandIndexTable[k][h->sr_index].l[i]; + for (i = 0; i < 13; i++) + pMP3Stream->nBand[1][i] = sfBandIndexTable[k][h->sr_index].s[i + 1] - sfBandIndexTable[k][h->sr_index].s[i]; + + +/* init tables */ + L3table_init(); +/* init ms and is stereo modes */ + msis_init(); + +/*----- init sbt ---*/ + sbt_init(); + + + +/*--- clear buffers --*/ + for (i = 0; i < 576; i++) + yout[i] = 0.0f; + for (j = 0; j < 2; j++) + { + for (k = 0; k < 2; k++) + { + for (i = 0; i < 576; i++) + { + pMP3Stream->sample[j][k][i].x = 0.0f; + pMP3Stream->sample[j][k][i].s = 0; + } + } + } + + if (h->id == 1) + pMP3Stream->decode_function = L3audio_decode_MPEG1; + else + pMP3Stream->decode_function = L3audio_decode_MPEG2; + + return 1; +} +/*---------------------------------------------------------*/ +/*==========================================================*/ diff --git a/src/client/mp3/cwin.c b/src/client/mp3/cwin.c new file mode 100644 index 0000000000..4e4afbecf7 --- /dev/null +++ b/src/client/mp3/cwin.c @@ -0,0 +1,481 @@ +#ifdef COMPILE_ME +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: cwin.c,v 1.7 1999/10/19 07:13:08 elrod Exp $ +____________________________________________________________________________*/ + +/**** cwin.c *************************************************** + +include to cwinm.c + +MPEG audio decoder, float window routines +portable C + +******************************************************************/ + +#include "config.h" + +void window(float *vbuf, int vb_ptr, short *pcm); +void window_dual(float *vbuf, int vb_ptr, short *pcm); +void window16(float *vbuf, int vb_ptr, short *pcm); +void window16_dual(float *vbuf, int vb_ptr, short *pcm); +void window8(float *vbuf, int vb_ptr, short *pcm); +void window8_dual(float *vbuf, int vb_ptr, short *pcm); + +/*-------------------------------------------------------------------------*/ +void window(float *vbuf, int vb_ptr, short *pcm) +{ + int i, j; + int si, bx; + const float *coef; + float sum; + long tmp; + + si = vb_ptr + 16; + bx = (si + 32) & 511; + coef = wincoef; + +/*-- first 16 --*/ + for (i = 0; i < 16; i++) + { + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[si]; + si = (si + 64) & 511; + sum -= (*coef++) * vbuf[bx]; + bx = (bx + 64) & 511; + } + si++; + bx--; + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm++ = (short)tmp; + } +/*-- special case --*/ + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[bx]; + bx = (bx + 64) & 511; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm++ = (short)tmp; +/*-- last 15 --*/ + coef = wincoef + 255; /* back pass through coefs */ + for (i = 0; i < 15; i++) + { + si--; + bx++; + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef--) * vbuf[si]; + si = (si + 64) & 511; + sum += (*coef--) * vbuf[bx]; + bx = (bx + 64) & 511; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm++ = (short)tmp; + } +} + + + +/*------------------------------------------------------------*/ +void window_dual(float *vbuf, int vb_ptr, short *pcm) +{ + int i, j; /* dual window interleaves output */ + int si, bx; + const float *coef; + float sum; + long tmp; + + si = vb_ptr + 16; + bx = (si + 32) & 511; + coef = wincoef; + +/*-- first 16 --*/ + for (i = 0; i < 16; i++) + { + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[si]; + si = (si + 64) & 511; + sum -= (*coef++) * vbuf[bx]; + bx = (bx + 64) & 511; + } + si++; + bx--; + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm = (short)tmp; + pcm += 2; + } +/*-- special case --*/ + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[bx]; + bx = (bx + 64) & 511; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm = (short)tmp; + pcm += 2; +/*-- last 15 --*/ + coef = wincoef + 255; /* back pass through coefs */ + for (i = 0; i < 15; i++) + { + si--; + bx++; + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef--) * vbuf[si]; + si = (si + 64) & 511; + sum += (*coef--) * vbuf[bx]; + bx = (bx + 64) & 511; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm = (short)tmp; + pcm += 2; + } +} +/*------------------------------------------------------------*/ +/*------------------- 16 pt window ------------------------------*/ +void window16(float *vbuf, int vb_ptr, short *pcm) +{ + int i, j; + unsigned char si, bx; + const float *coef; + float sum; + long tmp; + + si = vb_ptr + 8; + bx = si + 16; + coef = wincoef; + +/*-- first 8 --*/ + for (i = 0; i < 8; i++) + { + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[si]; + si += 32; + sum -= (*coef++) * vbuf[bx]; + bx += 32; + } + si++; + bx--; + coef += 16; + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm++ = (short)tmp; + } +/*-- special case --*/ + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[bx]; + bx += 32; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm++ = (short)tmp; +/*-- last 7 --*/ + coef = wincoef + 255; /* back pass through coefs */ + for (i = 0; i < 7; i++) + { + coef -= 16; + si--; + bx++; + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef--) * vbuf[si]; + si += 32; + sum += (*coef--) * vbuf[bx]; + bx += 32; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm++ = (short)tmp; + } +} +/*--------------- 16 pt dual window (interleaved output) -----------------*/ +void window16_dual(float *vbuf, int vb_ptr, short *pcm) +{ + int i, j; + unsigned char si, bx; + const float *coef; + float sum; + long tmp; + + si = vb_ptr + 8; + bx = si + 16; + coef = wincoef; + +/*-- first 8 --*/ + for (i = 0; i < 8; i++) + { + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[si]; + si += 32; + sum -= (*coef++) * vbuf[bx]; + bx += 32; + } + si++; + bx--; + coef += 16; + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm = (short)tmp; + pcm += 2; + } +/*-- special case --*/ + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[bx]; + bx += 32; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm = (short)tmp; + pcm += 2; +/*-- last 7 --*/ + coef = wincoef + 255; /* back pass through coefs */ + for (i = 0; i < 7; i++) + { + coef -= 16; + si--; + bx++; + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef--) * vbuf[si]; + si += 32; + sum += (*coef--) * vbuf[bx]; + bx += 32; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm = (short)tmp; + pcm += 2; + } +} +/*------------------- 8 pt window ------------------------------*/ +void window8(float *vbuf, int vb_ptr, short *pcm) +{ + int i, j; + int si, bx; + const float *coef; + float sum; + long tmp; + + si = vb_ptr + 4; + bx = (si + 8) & 127; + coef = wincoef; + +/*-- first 4 --*/ + for (i = 0; i < 4; i++) + { + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[si]; + si = (si + 16) & 127; + sum -= (*coef++) * vbuf[bx]; + bx = (bx + 16) & 127; + } + si++; + bx--; + coef += 48; + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm++ = (short)tmp; + } +/*-- special case --*/ + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[bx]; + bx = (bx + 16) & 127; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm++ = (short)tmp; +/*-- last 3 --*/ + coef = wincoef + 255; /* back pass through coefs */ + for (i = 0; i < 3; i++) + { + coef -= 48; + si--; + bx++; + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef--) * vbuf[si]; + si = (si + 16) & 127; + sum += (*coef--) * vbuf[bx]; + bx = (bx + 16) & 127; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm++ = (short)tmp; + } +} +/*--------------- 8 pt dual window (interleaved output) -----------------*/ +void window8_dual(float *vbuf, int vb_ptr, short *pcm) +{ + int i, j; + int si, bx; + const float *coef; + float sum; + long tmp; + + si = vb_ptr + 4; + bx = (si + 8) & 127; + coef = wincoef; + +/*-- first 4 --*/ + for (i = 0; i < 4; i++) + { + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[si]; + si = (si + 16) & 127; + sum -= (*coef++) * vbuf[bx]; + bx = (bx + 16) & 127; + } + si++; + bx--; + coef += 48; + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm = (short)tmp; + pcm += 2; + } +/*-- special case --*/ + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[bx]; + bx = (bx + 16) & 127; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm = (short)tmp; + pcm += 2; +/*-- last 3 --*/ + coef = wincoef + 255; /* back pass through coefs */ + for (i = 0; i < 3; i++) + { + coef -= 48; + si--; + bx++; + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef--) * vbuf[si]; + si = (si + 16) & 127; + sum += (*coef--) * vbuf[bx]; + bx = (bx + 16) & 127; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm = (short)tmp; + pcm += 2; + } +} +/*------------------------------------------------------------*/ +#endif // #ifdef COMPILE_ME + +#ifndef COMPILE_ME +// Dummy function to suppress empty translation unit warning +static void cwin_dummy(void) {} +#endif diff --git a/src/client/mp3/cwinb.c b/src/client/mp3/cwinb.c new file mode 100644 index 0000000000..aa3857303e --- /dev/null +++ b/src/client/mp3/cwinb.c @@ -0,0 +1,475 @@ +#ifdef COMPILE_ME +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: cwinb.c,v 1.4 1999/10/19 07:13:08 elrod Exp $ +____________________________________________________________________________*/ + +/**** cwin.c *************************************************** + +include to cwinm.c + +MPEG audio decoder, float window routines - 8 bit output +portable C + +******************************************************************/ +/*-------------------------------------------------------------------------*/ +void windowB(float *vbuf, int vb_ptr, unsigned char *pcm); +void windowB_dual(float *vbuf, int vb_ptr, unsigned char *pcm); +void windowB16(float *vbuf, int vb_ptr, unsigned char *pcm); +void windowB16_dual(float *vbuf, int vb_ptr, unsigned char *pcm); +void windowB8(float *vbuf, int vb_ptr, unsigned char *pcm); +void windowB8_dual(float *vbuf, int vb_ptr, unsigned char *pcm); + +void windowB(float *vbuf, int vb_ptr, unsigned char *pcm) +{ + int i, j; + int si, bx; + const float *coef; + float sum; + long tmp; + + si = vb_ptr + 16; + bx = (si + 32) & 511; + coef = wincoef; + +/*-- first 16 --*/ + for (i = 0; i < 16; i++) + { + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[si]; + si = (si + 64) & 511; + sum -= (*coef++) * vbuf[bx]; + bx = (bx + 64) & 511; + } + si++; + bx--; + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; + } +/*-- special case --*/ + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[bx]; + bx = (bx + 64) & 511; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; +/*-- last 15 --*/ + coef = wincoef + 255; /* back pass through coefs */ + for (i = 0; i < 15; i++) + { + si--; + bx++; + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef--) * vbuf[si]; + si = (si + 64) & 511; + sum += (*coef--) * vbuf[bx]; + bx = (bx + 64) & 511; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; + } +} +/*------------------------------------------------------------*/ +void windowB_dual(float *vbuf, int vb_ptr, unsigned char *pcm) +{ + int i, j; /* dual window interleaves output */ + int si, bx; + const float *coef; + float sum; + long tmp; + + si = vb_ptr + 16; + bx = (si + 32) & 511; + coef = wincoef; + +/*-- first 16 --*/ + for (i = 0; i < 16; i++) + { + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[si]; + si = (si + 64) & 511; + sum -= (*coef++) * vbuf[bx]; + bx = (bx + 64) & 511; + } + si++; + bx--; + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; + pcm += 2; + } +/*-- special case --*/ + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[bx]; + bx = (bx + 64) & 511; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; + pcm += 2; +/*-- last 15 --*/ + coef = wincoef + 255; /* back pass through coefs */ + for (i = 0; i < 15; i++) + { + si--; + bx++; + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef--) * vbuf[si]; + si = (si + 64) & 511; + sum += (*coef--) * vbuf[bx]; + bx = (bx + 64) & 511; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; + pcm += 2; + } +} +/*------------------------------------------------------------*/ +/*------------------- 16 pt window ------------------------------*/ +void windowB16(float *vbuf, int vb_ptr, unsigned char *pcm) +{ + int i, j; + unsigned char si, bx; + const float *coef; + float sum; + long tmp; + + si = vb_ptr + 8; + bx = si + 16; + coef = wincoef; + +/*-- first 8 --*/ + for (i = 0; i < 8; i++) + { + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[si]; + si += 32; + sum -= (*coef++) * vbuf[bx]; + bx += 32; + } + si++; + bx--; + coef += 16; + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; + } +/*-- special case --*/ + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[bx]; + bx += 32; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; +/*-- last 7 --*/ + coef = wincoef + 255; /* back pass through coefs */ + for (i = 0; i < 7; i++) + { + coef -= 16; + si--; + bx++; + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef--) * vbuf[si]; + si += 32; + sum += (*coef--) * vbuf[bx]; + bx += 32; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; + } +} +/*--------------- 16 pt dual window (interleaved output) -----------------*/ +void windowB16_dual(float *vbuf, int vb_ptr, unsigned char *pcm) +{ + int i, j; + unsigned char si, bx; + const float *coef; + float sum; + long tmp; + + si = vb_ptr + 8; + bx = si + 16; + coef = wincoef; + +/*-- first 8 --*/ + for (i = 0; i < 8; i++) + { + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[si]; + si += 32; + sum -= (*coef++) * vbuf[bx]; + bx += 32; + } + si++; + bx--; + coef += 16; + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; + pcm += 2; + } +/*-- special case --*/ + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[bx]; + bx += 32; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; + pcm += 2; +/*-- last 7 --*/ + coef = wincoef + 255; /* back pass through coefs */ + for (i = 0; i < 7; i++) + { + coef -= 16; + si--; + bx++; + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef--) * vbuf[si]; + si += 32; + sum += (*coef--) * vbuf[bx]; + bx += 32; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; + pcm += 2; + } +} +/*------------------- 8 pt window ------------------------------*/ +void windowB8(float *vbuf, int vb_ptr, unsigned char *pcm) +{ + int i, j; + int si, bx; + const float *coef; + float sum; + long tmp; + + si = vb_ptr + 4; + bx = (si + 8) & 127; + coef = wincoef; + +/*-- first 4 --*/ + for (i = 0; i < 4; i++) + { + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[si]; + si = (si + 16) & 127; + sum -= (*coef++) * vbuf[bx]; + bx = (bx + 16) & 127; + } + si++; + bx--; + coef += 48; + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; + } +/*-- special case --*/ + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[bx]; + bx = (bx + 16) & 127; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; +/*-- last 3 --*/ + coef = wincoef + 255; /* back pass through coefs */ + for (i = 0; i < 3; i++) + { + coef -= 48; + si--; + bx++; + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef--) * vbuf[si]; + si = (si + 16) & 127; + sum += (*coef--) * vbuf[bx]; + bx = (bx + 16) & 127; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; + } +} +/*--------------- 8 pt dual window (interleaved output) -----------------*/ +void windowB8_dual(float *vbuf, int vb_ptr, unsigned char *pcm) +{ + int i, j; + int si, bx; + const float *coef; + float sum; + long tmp; + + si = vb_ptr + 4; + bx = (si + 8) & 127; + coef = wincoef; + +/*-- first 4 --*/ + for (i = 0; i < 4; i++) + { + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[si]; + si = (si + 16) & 127; + sum -= (*coef++) * vbuf[bx]; + bx = (bx + 16) & 127; + } + si++; + bx--; + coef += 48; + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; + pcm += 2; + } +/*-- special case --*/ + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef++) * vbuf[bx]; + bx = (bx + 16) & 127; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; + pcm += 2; +/*-- last 3 --*/ + coef = wincoef + 255; /* back pass through coefs */ + for (i = 0; i < 3; i++) + { + coef -= 48; + si--; + bx++; + sum = 0.0F; + for (j = 0; j < 8; j++) + { + sum += (*coef--) * vbuf[si]; + si = (si + 16) & 127; + sum += (*coef--) * vbuf[bx]; + bx = (bx + 16) & 127; + } + tmp = (long) sum; + if (tmp > 32767) + tmp = 32767; + else if (tmp < -32768) + tmp = -32768; + *pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; + pcm += 2; + } +} +/*------------------------------------------------------------*/ +#endif // #ifdef COMPILE_ME + +#ifndef COMPILE_ME +// Dummy function to suppress empty translation unit warning +static void cwinb_dummy(void) {} +#endif diff --git a/src/client/mp3/cwinm.c b/src/client/mp3/cwinm.c new file mode 100644 index 0000000000..d1a292e11f --- /dev/null +++ b/src/client/mp3/cwinm.c @@ -0,0 +1,49 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: cwinm.c,v 1.3 1999/10/19 07:13:08 elrod Exp $ +____________________________________________________________________________*/ + +/**** cwinm.c *************************************************** + +MPEG audio decoder, window master routine +portable C + + +******************************************************************/ + +#include +#include +#include +#include + +const float wincoef[264] = +{ /* window coefs */ +#include "tableawd.h" +}; + +/*--------------------------------------------------------*/ +#define COMPILE_ME +#include "cwin.c" +#include "cwinb.c" +/*--------------------------------------------------------*/ diff --git a/src/client/mp3/htable.h b/src/client/mp3/htable.h new file mode 100644 index 0000000000..44fe30e864 --- /dev/null +++ b/src/client/mp3/htable.h @@ -0,0 +1,999 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License}, {or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not}, {write to the Free Software + Foundation}, {Inc.}, {675 Mass Ave}, {Cambridge}, {MA 02139}, {USA. + + $Id: htable.h,v 1.2 1999/10/19 07:13:08 elrod Exp $ +____________________________________________________________________________*/ + +/* TABLE 1 4 entries maxbits 3 linbits 0 */ +static const HUFF_ELEMENT huff_table_1[] = +{ + {0xFF000003}, {0x03010102}, {0x03010001}, {0x02000101}, {0x02000101}, /* 4 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, +}; + +/* max table bits 3 */ + +/* TABLE 2 9 entries maxbits 6 linbits 0 */ +static const HUFF_ELEMENT huff_table_2[] = +{ + {0xFF000006}, {0x06020202}, {0x06020001}, {0x05020102}, {0x05020102}, /* 4 */ + {0x05010202}, {0x05010202}, {0x05000201}, {0x05000201}, {0x03010102}, /* 9 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 14 */ + {0x03010102}, {0x03010102}, {0x03010001}, {0x03010001}, {0x03010001}, /* 19 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 24 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 29 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x01000000}, {0x01000000}, /* 34 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 39 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 44 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 49 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 54 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 59 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 64 */ +}; + +/* max table bits 6 */ + +/* TABLE 3 9 entries maxbits 6 linbits 0 */ +static const HUFF_ELEMENT huff_table_3[] = +{ + {0xFF000006}, {0x06020202}, {0x06020001}, {0x05020102}, {0x05020102}, /* 4 */ + {0x05010202}, {0x05010202}, {0x05000201}, {0x05000201}, {0x03000101}, /* 9 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 14 */ + {0x03000101}, {0x03000101}, {0x02010102}, {0x02010102}, {0x02010102}, /* 19 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 24 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 29 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010001}, {0x02010001}, /* 34 */ + {0x02010001}, {0x02010001}, {0x02010001}, {0x02010001}, {0x02010001}, /* 39 */ + {0x02010001}, {0x02010001}, {0x02010001}, {0x02010001}, {0x02010001}, /* 44 */ + {0x02010001}, {0x02010001}, {0x02010001}, {0x02010001}, {0x02000000}, /* 49 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 54 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 59 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 64 */ +}; + +/* max table bits 6 */ +/* NO XING TABLE 4 */ + +/* TABLE 5 16 entries maxbits 8 linbits 0 */ +static const HUFF_ELEMENT huff_table_5[] = +{ + {0xFF000008}, {0x08030302}, {0x08030202}, {0x07020302}, {0x07020302}, /* 4 */ + {0x06010302}, {0x06010302}, {0x06010302}, {0x06010302}, {0x07030102}, /* 9 */ + {0x07030102}, {0x07030001}, {0x07030001}, {0x07000301}, {0x07000301}, /* 14 */ + {0x07020202}, {0x07020202}, {0x06020102}, {0x06020102}, {0x06020102}, /* 19 */ + {0x06020102}, {0x06010202}, {0x06010202}, {0x06010202}, {0x06010202}, /* 24 */ + {0x06020001}, {0x06020001}, {0x06020001}, {0x06020001}, {0x06000201}, /* 29 */ + {0x06000201}, {0x06000201}, {0x06000201}, {0x03010102}, {0x03010102}, /* 34 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 39 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 44 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 49 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 54 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 59 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 64 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 69 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 74 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 79 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 84 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 89 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 94 */ + {0x03010001}, {0x03010001}, {0x03000101}, {0x03000101}, {0x03000101}, /* 99 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 104 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 109 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 114 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 119 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 124 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x01000000}, /* 129 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 134 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 139 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 144 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 149 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 154 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 159 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 164 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 169 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 174 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 179 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 184 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 189 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 194 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 199 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 204 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 209 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 214 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 219 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 224 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 229 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 234 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 239 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 244 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 249 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 254 */ + {0x01000000}, {0x01000000}, +}; + +/* max table bits 8 */ + +/* TABLE 6 16 entries maxbits 7 linbits 0 */ +static const HUFF_ELEMENT huff_table_6[] = +{ + {0xFF000007}, {0x07030302}, {0x07030001}, {0x06030202}, {0x06030202}, /* 4 */ + {0x06020302}, {0x06020302}, {0x06000301}, {0x06000301}, {0x05030102}, /* 9 */ + {0x05030102}, {0x05030102}, {0x05030102}, {0x05010302}, {0x05010302}, /* 14 */ + {0x05010302}, {0x05010302}, {0x05020202}, {0x05020202}, {0x05020202}, /* 19 */ + {0x05020202}, {0x05020001}, {0x05020001}, {0x05020001}, {0x05020001}, /* 24 */ + {0x04020102}, {0x04020102}, {0x04020102}, {0x04020102}, {0x04020102}, /* 29 */ + {0x04020102}, {0x04020102}, {0x04020102}, {0x04010202}, {0x04010202}, /* 34 */ + {0x04010202}, {0x04010202}, {0x04010202}, {0x04010202}, {0x04010202}, /* 39 */ + {0x04010202}, {0x04000201}, {0x04000201}, {0x04000201}, {0x04000201}, /* 44 */ + {0x04000201}, {0x04000201}, {0x04000201}, {0x04000201}, {0x03010001}, /* 49 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 54 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 59 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 64 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 69 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 74 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 79 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 84 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 89 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 94 */ + {0x02010102}, {0x02010102}, {0x03000101}, {0x03000101}, {0x03000101}, /* 99 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 104 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 109 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000000}, {0x03000000}, /* 114 */ + {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, /* 119 */ + {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, /* 124 */ + {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, +}; + +/* max table bits 7 */ + +/* TABLE 7 36 entries maxbits 10 linbits 0 */ +static const HUFF_ELEMENT huff_table_7[] = +{ + {0xFF000006}, {0x00000041}, {0x00000052}, {0x0000005B}, {0x00000060}, /* 4 */ + {0x00000063}, {0x00000068}, {0x0000006B}, {0x06020102}, {0x05010202}, /* 9 */ + {0x05010202}, {0x06020001}, {0x06000201}, {0x04010102}, {0x04010102}, /* 14 */ + {0x04010102}, {0x04010102}, {0x03010001}, {0x03010001}, {0x03010001}, /* 19 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 24 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 29 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x01000000}, {0x01000000}, /* 34 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 39 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 44 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 49 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 54 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 59 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 64 */ + {0xFF000004}, {0x04050502}, {0x04050402}, {0x04040502}, {0x04030502}, /* 69 */ + {0x03050302}, {0x03050302}, {0x03040402}, {0x03040402}, {0x03050202}, /* 74 */ + {0x03050202}, {0x03020502}, {0x03020502}, {0x02050102}, {0x02050102}, /* 79 */ + {0x02050102}, {0x02050102}, {0xFF000003}, {0x02010502}, {0x02010502}, /* 84 */ + {0x03050001}, {0x03040302}, {0x02000501}, {0x02000501}, {0x03030402}, /* 89 */ + {0x03030302}, {0xFF000002}, {0x02040202}, {0x02020402}, {0x01040102}, /* 94 */ + {0x01040102}, {0xFF000001}, {0x01010402}, {0x01000401}, {0xFF000002}, /* 99 */ + {0x02040001}, {0x02030202}, {0x02020302}, {0x02030001}, {0xFF000001}, /* 104 */ + {0x01030102}, {0x01010302}, {0xFF000001}, {0x01000301}, {0x01020202}, /* 109 */ +}; + +/* max table bits 6 */ + +/* TABLE 8 36 entries maxbits 11 linbits 0 */ +static const HUFF_ELEMENT huff_table_8[] = +{ + {0xFF000008}, {0x00000101}, {0x0000010A}, {0x0000010F}, {0x08050102}, /* 4 */ + {0x08010502}, {0x00000112}, {0x00000115}, {0x08040202}, {0x08020402}, /* 9 */ + {0x08040102}, {0x07010402}, {0x07010402}, {0x08040001}, {0x08000401}, /* 14 */ + {0x08030202}, {0x08020302}, {0x08030102}, {0x08010302}, {0x08030001}, /* 19 */ + {0x08000301}, {0x06020202}, {0x06020202}, {0x06020202}, {0x06020202}, /* 24 */ + {0x06020001}, {0x06020001}, {0x06020001}, {0x06020001}, {0x06000201}, /* 29 */ + {0x06000201}, {0x06000201}, {0x06000201}, {0x04020102}, {0x04020102}, /* 34 */ + {0x04020102}, {0x04020102}, {0x04020102}, {0x04020102}, {0x04020102}, /* 39 */ + {0x04020102}, {0x04020102}, {0x04020102}, {0x04020102}, {0x04020102}, /* 44 */ + {0x04020102}, {0x04020102}, {0x04020102}, {0x04020102}, {0x04010202}, /* 49 */ + {0x04010202}, {0x04010202}, {0x04010202}, {0x04010202}, {0x04010202}, /* 54 */ + {0x04010202}, {0x04010202}, {0x04010202}, {0x04010202}, {0x04010202}, /* 59 */ + {0x04010202}, {0x04010202}, {0x04010202}, {0x04010202}, {0x04010202}, /* 64 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 69 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 74 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 79 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 84 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 89 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 94 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 99 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 104 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 109 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 114 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 119 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, /* 124 */ + {0x02010102}, {0x02010102}, {0x02010102}, {0x02010102}, {0x03010001}, /* 129 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 134 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 139 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 144 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 149 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 154 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 159 */ + {0x03010001}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 164 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 169 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 174 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 179 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 184 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 189 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x02000000}, {0x02000000}, /* 194 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 199 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 204 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 209 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 214 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 219 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 224 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 229 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 234 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 239 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 244 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 249 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 254 */ + {0x02000000}, {0x02000000}, {0xFF000003}, {0x03050502}, {0x03040502}, /* 259 */ + {0x02050402}, {0x02050402}, {0x01030502}, {0x01030502}, {0x01030502}, /* 264 */ + {0x01030502}, {0xFF000002}, {0x02050302}, {0x02040402}, {0x01050202}, /* 269 */ + {0x01050202}, {0xFF000001}, {0x01020502}, {0x01050001}, {0xFF000001}, /* 274 */ + {0x01040302}, {0x01030402}, {0xFF000001}, {0x01000501}, {0x01030302}, /* 279 */ +}; + +/* max table bits 8 */ + +/* TABLE 9 36 entries maxbits 9 linbits 0 */ +static const HUFF_ELEMENT huff_table_9[] = +{ + {0xFF000006}, {0x00000041}, {0x0000004A}, {0x0000004F}, {0x00000052}, /* 4 */ + {0x00000057}, {0x0000005A}, {0x06040102}, {0x06010402}, {0x06030202}, /* 9 */ + {0x06020302}, {0x05030102}, {0x05030102}, {0x05010302}, {0x05010302}, /* 14 */ + {0x06030001}, {0x06000301}, {0x05020202}, {0x05020202}, {0x05020001}, /* 19 */ + {0x05020001}, {0x04020102}, {0x04020102}, {0x04020102}, {0x04020102}, /* 24 */ + {0x04010202}, {0x04010202}, {0x04010202}, {0x04010202}, {0x04000201}, /* 29 */ + {0x04000201}, {0x04000201}, {0x04000201}, {0x03010102}, {0x03010102}, /* 34 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 39 */ + {0x03010102}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 44 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03000101}, /* 49 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 54 */ + {0x03000101}, {0x03000101}, {0x03000000}, {0x03000000}, {0x03000000}, /* 59 */ + {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, /* 64 */ + {0xFF000003}, {0x03050502}, {0x03050402}, {0x02050302}, {0x02050302}, /* 69 */ + {0x02030502}, {0x02030502}, {0x03040502}, {0x03050001}, {0xFF000002}, /* 74 */ + {0x02040402}, {0x02050202}, {0x02020502}, {0x02050102}, {0xFF000001}, /* 79 */ + {0x01010502}, {0x01040302}, {0xFF000002}, {0x01030402}, {0x01030402}, /* 84 */ + {0x02000501}, {0x02040001}, {0xFF000001}, {0x01040202}, {0x01020402}, /* 89 */ + {0xFF000001}, {0x01030302}, {0x01000401}, +}; + +/* max table bits 6 */ + +/* TABLE 10 64 entries maxbits 11 linbits 0 */ +static const HUFF_ELEMENT huff_table_10[] = +{ + {0xFF000008}, {0x00000101}, {0x0000010A}, {0x0000010F}, {0x00000118}, /* 4 */ + {0x0000011B}, {0x00000120}, {0x00000125}, {0x08070102}, {0x08010702}, /* 9 */ + {0x0000012A}, {0x0000012D}, {0x00000132}, {0x08060102}, {0x08010602}, /* 14 */ + {0x08000601}, {0x00000137}, {0x0000013A}, {0x0000013D}, {0x08040102}, /* 19 */ + {0x08010402}, {0x08000401}, {0x08030202}, {0x08020302}, {0x08030001}, /* 24 */ + {0x07030102}, {0x07030102}, {0x07010302}, {0x07010302}, {0x07000301}, /* 29 */ + {0x07000301}, {0x07020202}, {0x07020202}, {0x06020102}, {0x06020102}, /* 34 */ + {0x06020102}, {0x06020102}, {0x06010202}, {0x06010202}, {0x06010202}, /* 39 */ + {0x06010202}, {0x06020001}, {0x06020001}, {0x06020001}, {0x06020001}, /* 44 */ + {0x06000201}, {0x06000201}, {0x06000201}, {0x06000201}, {0x04010102}, /* 49 */ + {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, /* 54 */ + {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, /* 59 */ + {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, /* 64 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 69 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 74 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 79 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 84 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 89 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 94 */ + {0x03010001}, {0x03010001}, {0x03000101}, {0x03000101}, {0x03000101}, /* 99 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 104 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 109 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 114 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 119 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 124 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x01000000}, /* 129 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 134 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 139 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 144 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 149 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 154 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 159 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 164 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 169 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 174 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 179 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 184 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 189 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 194 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 199 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 204 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 209 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 214 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 219 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 224 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 229 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 234 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 239 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 244 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 249 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 254 */ + {0x01000000}, {0x01000000}, {0xFF000003}, {0x03070702}, {0x03070602}, /* 259 */ + {0x03060702}, {0x03070502}, {0x03050702}, {0x03060602}, {0x02070402}, /* 264 */ + {0x02070402}, {0xFF000002}, {0x02040702}, {0x02060502}, {0x02050602}, /* 269 */ + {0x02070302}, {0xFF000003}, {0x02030702}, {0x02030702}, {0x02060402}, /* 274 */ + {0x02060402}, {0x03050502}, {0x03040502}, {0x02030602}, {0x02030602}, /* 279 */ + {0xFF000001}, {0x01070202}, {0x01020702}, {0xFF000002}, {0x02040602}, /* 284 */ + {0x02070001}, {0x01000701}, {0x01000701}, {0xFF000002}, {0x01020602}, /* 289 */ + {0x01020602}, {0x02050402}, {0x02050302}, {0xFF000002}, {0x01060001}, /* 294 */ + {0x01060001}, {0x02030502}, {0x02040402}, {0xFF000001}, {0x01060302}, /* 299 */ + {0x01060202}, {0xFF000002}, {0x02050202}, {0x02020502}, {0x01050102}, /* 304 */ + {0x01050102}, {0xFF000002}, {0x01010502}, {0x01010502}, {0x02040302}, /* 309 */ + {0x02030402}, {0xFF000001}, {0x01050001}, {0x01000501}, {0xFF000001}, /* 314 */ + {0x01040202}, {0x01020402}, {0xFF000001}, {0x01030302}, {0x01040001}, /* 319 */ +}; + +/* max table bits 8 */ + +/* TABLE 11 64 entries maxbits 11 linbits 0 */ +static const HUFF_ELEMENT huff_table_11[] = +{ + {0xFF000008}, {0x00000101}, {0x00000106}, {0x0000010F}, {0x00000114}, /* 4 */ + {0x00000117}, {0x08070202}, {0x08020702}, {0x0000011C}, {0x07010702}, /* 9 */ + {0x07010702}, {0x08070102}, {0x08000701}, {0x08060302}, {0x08030602}, /* 14 */ + {0x08000601}, {0x0000011F}, {0x00000122}, {0x08050102}, {0x07020602}, /* 19 */ + {0x07020602}, {0x08060202}, {0x08060001}, {0x07060102}, {0x07060102}, /* 24 */ + {0x07010602}, {0x07010602}, {0x08010502}, {0x08040302}, {0x08000501}, /* 29 */ + {0x00000125}, {0x08040202}, {0x08020402}, {0x08040102}, {0x08010402}, /* 34 */ + {0x08040001}, {0x08000401}, {0x07030202}, {0x07030202}, {0x07020302}, /* 39 */ + {0x07020302}, {0x06030102}, {0x06030102}, {0x06030102}, {0x06030102}, /* 44 */ + {0x06010302}, {0x06010302}, {0x06010302}, {0x06010302}, {0x07030001}, /* 49 */ + {0x07030001}, {0x07000301}, {0x07000301}, {0x06020202}, {0x06020202}, /* 54 */ + {0x06020202}, {0x06020202}, {0x05010202}, {0x05010202}, {0x05010202}, /* 59 */ + {0x05010202}, {0x05010202}, {0x05010202}, {0x05010202}, {0x05010202}, /* 64 */ + {0x04020102}, {0x04020102}, {0x04020102}, {0x04020102}, {0x04020102}, /* 69 */ + {0x04020102}, {0x04020102}, {0x04020102}, {0x04020102}, {0x04020102}, /* 74 */ + {0x04020102}, {0x04020102}, {0x04020102}, {0x04020102}, {0x04020102}, /* 79 */ + {0x04020102}, {0x05020001}, {0x05020001}, {0x05020001}, {0x05020001}, /* 84 */ + {0x05020001}, {0x05020001}, {0x05020001}, {0x05020001}, {0x05000201}, /* 89 */ + {0x05000201}, {0x05000201}, {0x05000201}, {0x05000201}, {0x05000201}, /* 94 */ + {0x05000201}, {0x05000201}, {0x03010102}, {0x03010102}, {0x03010102}, /* 99 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 104 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 109 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 114 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 119 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 124 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010001}, /* 129 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 134 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 139 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 144 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 149 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 154 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 159 */ + {0x03010001}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 164 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 169 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 174 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 179 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 184 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 189 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x02000000}, {0x02000000}, /* 194 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 199 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 204 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 209 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 214 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 219 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 224 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 229 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 234 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 239 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 244 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 249 */ + {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, {0x02000000}, /* 254 */ + {0x02000000}, {0x02000000}, {0xFF000002}, {0x02070702}, {0x02070602}, /* 259 */ + {0x02060702}, {0x02050702}, {0xFF000003}, {0x02060602}, {0x02060602}, /* 264 */ + {0x02070402}, {0x02070402}, {0x02040702}, {0x02040702}, {0x03070502}, /* 269 */ + {0x03050502}, {0xFF000002}, {0x02060502}, {0x02050602}, {0x01070302}, /* 274 */ + {0x01070302}, {0xFF000001}, {0x01030702}, {0x01060402}, {0xFF000002}, /* 279 */ + {0x02050402}, {0x02040502}, {0x02050302}, {0x02030502}, {0xFF000001}, /* 284 */ + {0x01040602}, {0x01070001}, {0xFF000001}, {0x01040402}, {0x01050202}, /* 289 */ + {0xFF000001}, {0x01020502}, {0x01050001}, {0xFF000001}, {0x01030402}, /* 294 */ + {0x01030302}, +}; + +/* max table bits 8 */ + +/* TABLE 12 64 entries maxbits 10 linbits 0 */ +static const HUFF_ELEMENT huff_table_12[] = +{ + {0xFF000007}, {0x00000081}, {0x0000008A}, {0x0000008F}, {0x00000092}, /* 4 */ + {0x00000097}, {0x0000009A}, {0x0000009D}, {0x000000A2}, {0x000000A5}, /* 9 */ + {0x000000A8}, {0x07060202}, {0x07020602}, {0x07010602}, {0x000000AD}, /* 14 */ + {0x000000B0}, {0x000000B3}, {0x07050102}, {0x07010502}, {0x07040302}, /* 19 */ + {0x07030402}, {0x000000B6}, {0x07040202}, {0x07020402}, {0x07040102}, /* 24 */ + {0x06030302}, {0x06030302}, {0x06010402}, {0x06010402}, {0x06030202}, /* 29 */ + {0x06030202}, {0x06020302}, {0x06020302}, {0x07000401}, {0x07030001}, /* 34 */ + {0x06000301}, {0x06000301}, {0x05030102}, {0x05030102}, {0x05030102}, /* 39 */ + {0x05030102}, {0x05010302}, {0x05010302}, {0x05010302}, {0x05010302}, /* 44 */ + {0x05020202}, {0x05020202}, {0x05020202}, {0x05020202}, {0x04020102}, /* 49 */ + {0x04020102}, {0x04020102}, {0x04020102}, {0x04020102}, {0x04020102}, /* 54 */ + {0x04020102}, {0x04020102}, {0x04010202}, {0x04010202}, {0x04010202}, /* 59 */ + {0x04010202}, {0x04010202}, {0x04010202}, {0x04010202}, {0x04010202}, /* 64 */ + {0x05020001}, {0x05020001}, {0x05020001}, {0x05020001}, {0x05000201}, /* 69 */ + {0x05000201}, {0x05000201}, {0x05000201}, {0x04000000}, {0x04000000}, /* 74 */ + {0x04000000}, {0x04000000}, {0x04000000}, {0x04000000}, {0x04000000}, /* 79 */ + {0x04000000}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 84 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 89 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 94 */ + {0x03010102}, {0x03010102}, {0x03010001}, {0x03010001}, {0x03010001}, /* 99 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 104 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, {0x03010001}, /* 109 */ + {0x03010001}, {0x03010001}, {0x03010001}, {0x03000101}, {0x03000101}, /* 114 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 119 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 124 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0xFF000003}, /* 129 */ + {0x03070702}, {0x03070602}, {0x02060702}, {0x02060702}, {0x02070502}, /* 134 */ + {0x02070502}, {0x02050702}, {0x02050702}, {0xFF000002}, {0x02060602}, /* 139 */ + {0x02070402}, {0x02040702}, {0x02050602}, {0xFF000001}, {0x01060502}, /* 144 */ + {0x01070302}, {0xFF000002}, {0x02030702}, {0x02050502}, {0x01070202}, /* 149 */ + {0x01070202}, {0xFF000001}, {0x01020702}, {0x01060402}, {0xFF000001}, /* 154 */ + {0x01040602}, {0x01070102}, {0xFF000002}, {0x01010702}, {0x01010702}, /* 159 */ + {0x02070001}, {0x02000701}, {0xFF000001}, {0x01060302}, {0x01030602}, /* 164 */ + {0xFF000001}, {0x01050402}, {0x01040502}, {0xFF000002}, {0x01040402}, /* 169 */ + {0x01040402}, {0x02060001}, {0x02050001}, {0xFF000001}, {0x01060102}, /* 174 */ + {0x01000601}, {0xFF000001}, {0x01050302}, {0x01030502}, {0xFF000001}, /* 179 */ + {0x01050202}, {0x01020502}, {0xFF000001}, {0x01000501}, {0x01040001}, /* 184 */ +}; + +/* max table bits 7 */ + +/* TABLE 13 256 entries maxbits 19 linbits 0 */ +static const HUFF_ELEMENT huff_table_13[] = +{ + {0xFF000006}, {0x00000041}, {0x00000082}, {0x000000C3}, {0x000000E4}, /* 4 */ + {0x00000105}, {0x00000116}, {0x0000011F}, {0x00000130}, {0x00000139}, /* 9 */ + {0x0000013E}, {0x00000143}, {0x00000146}, {0x06020102}, {0x06010202}, /* 14 */ + {0x06020001}, {0x06000201}, {0x04010102}, {0x04010102}, {0x04010102}, /* 19 */ + {0x04010102}, {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, /* 24 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 29 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x01000000}, {0x01000000}, /* 34 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 39 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 44 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 49 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 54 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 59 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 64 */ + {0xFF000006}, {0x00000108}, {0x00000111}, {0x0000011A}, {0x00000123}, /* 69 */ + {0x0000012C}, {0x00000131}, {0x00000136}, {0x0000013F}, {0x00000144}, /* 74 */ + {0x00000147}, {0x0000014C}, {0x00000151}, {0x00000156}, {0x0000015B}, /* 79 */ + {0x060F0102}, {0x06010F02}, {0x06000F01}, {0x00000160}, {0x00000163}, /* 84 */ + {0x00000166}, {0x06020E02}, {0x00000169}, {0x060E0102}, {0x06010E02}, /* 89 */ + {0x0000016C}, {0x0000016F}, {0x00000172}, {0x00000175}, {0x00000178}, /* 94 */ + {0x0000017B}, {0x06060C02}, {0x060D0302}, {0x0000017E}, {0x060D0202}, /* 99 */ + {0x06020D02}, {0x060D0102}, {0x06070B02}, {0x00000181}, {0x00000184}, /* 104 */ + {0x06030C02}, {0x00000187}, {0x060B0402}, {0x05010D02}, {0x05010D02}, /* 109 */ + {0x060D0001}, {0x06000D01}, {0x060A0802}, {0x06080A02}, {0x060C0402}, /* 114 */ + {0x06040C02}, {0x060B0602}, {0x06060B02}, {0x050C0302}, {0x050C0302}, /* 119 */ + {0x050C0202}, {0x050C0202}, {0x05020C02}, {0x05020C02}, {0x050B0502}, /* 124 */ + {0x050B0502}, {0x06050B02}, {0x06090802}, {0x050C0102}, {0x050C0102}, /* 129 */ + {0xFF000006}, {0x05010C02}, {0x05010C02}, {0x06080902}, {0x060C0001}, /* 134 */ + {0x05000C01}, {0x05000C01}, {0x06040B02}, {0x060A0602}, {0x06060A02}, /* 139 */ + {0x06090702}, {0x050B0302}, {0x050B0302}, {0x05030B02}, {0x05030B02}, /* 144 */ + {0x06080802}, {0x060A0502}, {0x050B0202}, {0x050B0202}, {0x06050A02}, /* 149 */ + {0x06090602}, {0x05040A02}, {0x05040A02}, {0x06080702}, {0x06070802}, /* 154 */ + {0x05040902}, {0x05040902}, {0x06070702}, {0x06060702}, {0x04020B02}, /* 159 */ + {0x04020B02}, {0x04020B02}, {0x04020B02}, {0x040B0102}, {0x040B0102}, /* 164 */ + {0x040B0102}, {0x040B0102}, {0x04010B02}, {0x04010B02}, {0x04010B02}, /* 169 */ + {0x04010B02}, {0x050B0001}, {0x050B0001}, {0x05000B01}, {0x05000B01}, /* 174 */ + {0x05060902}, {0x05060902}, {0x050A0402}, {0x050A0402}, {0x050A0302}, /* 179 */ + {0x050A0302}, {0x05030A02}, {0x05030A02}, {0x05090502}, {0x05090502}, /* 184 */ + {0x05050902}, {0x05050902}, {0x040A0202}, {0x040A0202}, {0x040A0202}, /* 189 */ + {0x040A0202}, {0x04020A02}, {0x04020A02}, {0x04020A02}, {0x04020A02}, /* 194 */ + {0xFF000005}, {0x040A0102}, {0x040A0102}, {0x04010A02}, {0x04010A02}, /* 199 */ + {0x050A0001}, {0x05080602}, {0x04000A01}, {0x04000A01}, {0x05060802}, /* 204 */ + {0x05090402}, {0x04030902}, {0x04030902}, {0x05090302}, {0x05080502}, /* 209 */ + {0x05050802}, {0x05070602}, {0x04090202}, {0x04090202}, {0x04020902}, /* 214 */ + {0x04020902}, {0x05070502}, {0x05050702}, {0x04080302}, {0x04080302}, /* 219 */ + {0x04030802}, {0x04030802}, {0x05060602}, {0x05070402}, {0x05040702}, /* 224 */ + {0x05060502}, {0x05050602}, {0x05030702}, {0xFF000005}, {0x03090102}, /* 229 */ + {0x03090102}, {0x03090102}, {0x03090102}, {0x03010902}, {0x03010902}, /* 234 */ + {0x03010902}, {0x03010902}, {0x04090001}, {0x04090001}, {0x04000901}, /* 239 */ + {0x04000901}, {0x04080402}, {0x04080402}, {0x04040802}, {0x04040802}, /* 244 */ + {0x04020702}, {0x04020702}, {0x05060402}, {0x05040602}, {0x03080202}, /* 249 */ + {0x03080202}, {0x03080202}, {0x03080202}, {0x03020802}, {0x03020802}, /* 254 */ + {0x03020802}, {0x03020802}, {0x03080102}, {0x03080102}, {0x03080102}, /* 259 */ + {0x03080102}, {0xFF000004}, {0x04070302}, {0x04070202}, {0x03070102}, /* 264 */ + {0x03070102}, {0x03010702}, {0x03010702}, {0x04050502}, {0x04070001}, /* 269 */ + {0x04000701}, {0x04060302}, {0x04030602}, {0x04050402}, {0x04040502}, /* 274 */ + {0x04060202}, {0x04020602}, {0x04050302}, {0xFF000003}, {0x02010802}, /* 279 */ + {0x02010802}, {0x03080001}, {0x03000801}, {0x03060102}, {0x03010602}, /* 284 */ + {0x03060001}, {0x03000601}, {0xFF000004}, {0x04030502}, {0x04040402}, /* 289 */ + {0x03050202}, {0x03050202}, {0x03020502}, {0x03020502}, {0x03050001}, /* 294 */ + {0x03050001}, {0x02050102}, {0x02050102}, {0x02050102}, {0x02050102}, /* 299 */ + {0x02010502}, {0x02010502}, {0x02010502}, {0x02010502}, {0xFF000003}, /* 304 */ + {0x03040302}, {0x03030402}, {0x03000501}, {0x03040202}, {0x03020402}, /* 309 */ + {0x03030302}, {0x02040102}, {0x02040102}, {0xFF000002}, {0x01010402}, /* 314 */ + {0x01010402}, {0x02040001}, {0x02000401}, {0xFF000002}, {0x02030202}, /* 319 */ + {0x02020302}, {0x01030102}, {0x01030102}, {0xFF000001}, {0x01010302}, /* 324 */ + {0x01030001}, {0xFF000001}, {0x01000301}, {0x01020202}, {0xFF000003}, /* 329 */ + {0x00000082}, {0x0000008B}, {0x0000008E}, {0x00000091}, {0x00000094}, /* 334 */ + {0x00000097}, {0x030C0E02}, {0x030D0D02}, {0xFF000003}, {0x00000093}, /* 339 */ + {0x030E0B02}, {0x030B0E02}, {0x030F0902}, {0x03090F02}, {0x030A0E02}, /* 344 */ + {0x030D0B02}, {0x030B0D02}, {0xFF000003}, {0x030F0802}, {0x03080F02}, /* 349 */ + {0x030C0C02}, {0x0000008D}, {0x030E0802}, {0x00000090}, {0x02070F02}, /* 354 */ + {0x02070F02}, {0xFF000003}, {0x020A0D02}, {0x020A0D02}, {0x030D0A02}, /* 359 */ + {0x030C0B02}, {0x030B0C02}, {0x03060F02}, {0x020F0602}, {0x020F0602}, /* 364 */ + {0xFF000002}, {0x02080E02}, {0x020F0502}, {0x020D0902}, {0x02090D02}, /* 369 */ + {0xFF000002}, {0x02050F02}, {0x02070E02}, {0x020C0A02}, {0x020B0B02}, /* 374 */ + {0xFF000003}, {0x020F0402}, {0x020F0402}, {0x02040F02}, {0x02040F02}, /* 379 */ + {0x030A0C02}, {0x03060E02}, {0x02030F02}, {0x02030F02}, {0xFF000002}, /* 384 */ + {0x010F0302}, {0x010F0302}, {0x020D0802}, {0x02080D02}, {0xFF000001}, /* 389 */ + {0x010F0202}, {0x01020F02}, {0xFF000002}, {0x020E0602}, {0x020C0902}, /* 394 */ + {0x010F0001}, {0x010F0001}, {0xFF000002}, {0x02090C02}, {0x020E0502}, /* 399 */ + {0x010B0A02}, {0x010B0A02}, {0xFF000002}, {0x020D0702}, {0x02070D02}, /* 404 */ + {0x010E0402}, {0x010E0402}, {0xFF000002}, {0x02080C02}, {0x02060D02}, /* 409 */ + {0x010E0302}, {0x010E0302}, {0xFF000002}, {0x01090B02}, {0x01090B02}, /* 414 */ + {0x020B0902}, {0x020A0A02}, {0xFF000001}, {0x010A0B02}, {0x01050E02}, /* 419 */ + {0xFF000001}, {0x01040E02}, {0x010C0802}, {0xFF000001}, {0x010D0602}, /* 424 */ + {0x01030E02}, {0xFF000001}, {0x010E0202}, {0x010E0001}, {0xFF000001}, /* 429 */ + {0x01000E01}, {0x010D0502}, {0xFF000001}, {0x01050D02}, {0x010C0702}, /* 434 */ + {0xFF000001}, {0x01070C02}, {0x010D0402}, {0xFF000001}, {0x010B0802}, /* 439 */ + {0x01080B02}, {0xFF000001}, {0x01040D02}, {0x010A0902}, {0xFF000001}, /* 444 */ + {0x01090A02}, {0x010C0602}, {0xFF000001}, {0x01030D02}, {0x010B0702}, /* 449 */ + {0xFF000001}, {0x010C0502}, {0x01050C02}, {0xFF000001}, {0x01090902}, /* 454 */ + {0x010A0702}, {0xFF000001}, {0x01070A02}, {0x01070902}, {0xFF000003}, /* 459 */ + {0x00000023}, {0x030D0F02}, {0x020D0E02}, {0x020D0E02}, {0x010F0F02}, /* 464 */ + {0x010F0F02}, {0x010F0F02}, {0x010F0F02}, {0xFF000001}, {0x010F0E02}, /* 469 */ + {0x010F0D02}, {0xFF000001}, {0x010E0E02}, {0x010F0C02}, {0xFF000001}, /* 474 */ + {0x010E0D02}, {0x010F0B02}, {0xFF000001}, {0x010B0F02}, {0x010E0C02}, /* 479 */ + {0xFF000002}, {0x010C0D02}, {0x010C0D02}, {0x020F0A02}, {0x02090E02}, /* 484 */ + {0xFF000001}, {0x010A0F02}, {0x010D0C02}, {0xFF000001}, {0x010E0A02}, /* 489 */ + {0x010E0902}, {0xFF000001}, {0x010F0702}, {0x010E0702}, {0xFF000001}, /* 494 */ + {0x010E0F02}, {0x010C0F02}, +}; + +/* max table bits 6 */ +/* NO XING TABLE 14 */ + +/* TABLE 15 256 entries maxbits 13 linbits 0 */ +static const HUFF_ELEMENT huff_table_15[] = +{ + {0xFF000008}, {0x00000101}, {0x00000122}, {0x00000143}, {0x00000154}, /* 4 */ + {0x00000165}, {0x00000176}, {0x0000017F}, {0x00000188}, {0x00000199}, /* 9 */ + {0x000001A2}, {0x000001AB}, {0x000001B4}, {0x000001BD}, {0x000001C2}, /* 14 */ + {0x000001CB}, {0x000001D4}, {0x000001D9}, {0x000001DE}, {0x000001E3}, /* 19 */ + {0x000001E8}, {0x000001ED}, {0x000001F2}, {0x000001F7}, {0x000001FC}, /* 24 */ + {0x00000201}, {0x00000204}, {0x00000207}, {0x0000020A}, {0x0000020F}, /* 29 */ + {0x00000212}, {0x00000215}, {0x0000021A}, {0x0000021D}, {0x00000220}, /* 34 */ + {0x08010902}, {0x00000223}, {0x00000226}, {0x00000229}, {0x0000022C}, /* 39 */ + {0x0000022F}, {0x08080202}, {0x08020802}, {0x08080102}, {0x08010802}, /* 44 */ + {0x00000232}, {0x00000235}, {0x00000238}, {0x0000023B}, {0x08070202}, /* 49 */ + {0x08020702}, {0x08040602}, {0x08070102}, {0x08050502}, {0x08010702}, /* 54 */ + {0x0000023E}, {0x08060302}, {0x08030602}, {0x08050402}, {0x08040502}, /* 59 */ + {0x08060202}, {0x08020602}, {0x08060102}, {0x00000241}, {0x08050302}, /* 64 */ + {0x07010602}, {0x07010602}, {0x08030502}, {0x08040402}, {0x07050202}, /* 69 */ + {0x07050202}, {0x07020502}, {0x07020502}, {0x07050102}, {0x07050102}, /* 74 */ + {0x07010502}, {0x07010502}, {0x08050001}, {0x08000501}, {0x07040302}, /* 79 */ + {0x07040302}, {0x07030402}, {0x07030402}, {0x07040202}, {0x07040202}, /* 84 */ + {0x07020402}, {0x07020402}, {0x07030302}, {0x07030302}, {0x06010402}, /* 89 */ + {0x06010402}, {0x06010402}, {0x06010402}, {0x07040102}, {0x07040102}, /* 94 */ + {0x07040001}, {0x07040001}, {0x06030202}, {0x06030202}, {0x06030202}, /* 99 */ + {0x06030202}, {0x06020302}, {0x06020302}, {0x06020302}, {0x06020302}, /* 104 */ + {0x07000401}, {0x07000401}, {0x07030001}, {0x07030001}, {0x06030102}, /* 109 */ + {0x06030102}, {0x06030102}, {0x06030102}, {0x06010302}, {0x06010302}, /* 114 */ + {0x06010302}, {0x06010302}, {0x06000301}, {0x06000301}, {0x06000301}, /* 119 */ + {0x06000301}, {0x05020202}, {0x05020202}, {0x05020202}, {0x05020202}, /* 124 */ + {0x05020202}, {0x05020202}, {0x05020202}, {0x05020202}, {0x05020102}, /* 129 */ + {0x05020102}, {0x05020102}, {0x05020102}, {0x05020102}, {0x05020102}, /* 134 */ + {0x05020102}, {0x05020102}, {0x05010202}, {0x05010202}, {0x05010202}, /* 139 */ + {0x05010202}, {0x05010202}, {0x05010202}, {0x05010202}, {0x05010202}, /* 144 */ + {0x05020001}, {0x05020001}, {0x05020001}, {0x05020001}, {0x05020001}, /* 149 */ + {0x05020001}, {0x05020001}, {0x05020001}, {0x05000201}, {0x05000201}, /* 154 */ + {0x05000201}, {0x05000201}, {0x05000201}, {0x05000201}, {0x05000201}, /* 159 */ + {0x05000201}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 164 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 169 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 174 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 179 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 184 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, {0x03010102}, /* 189 */ + {0x03010102}, {0x03010102}, {0x03010102}, {0x04010001}, {0x04010001}, /* 194 */ + {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, /* 199 */ + {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, /* 204 */ + {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, {0x04000101}, /* 209 */ + {0x04000101}, {0x04000101}, {0x04000101}, {0x04000101}, {0x04000101}, /* 214 */ + {0x04000101}, {0x04000101}, {0x04000101}, {0x04000101}, {0x04000101}, /* 219 */ + {0x04000101}, {0x04000101}, {0x04000101}, {0x04000101}, {0x04000101}, /* 224 */ + {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, /* 229 */ + {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, /* 234 */ + {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, /* 239 */ + {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, /* 244 */ + {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, /* 249 */ + {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, {0x03000000}, /* 254 */ + {0x03000000}, {0x03000000}, {0xFF000005}, {0x050F0F02}, {0x050F0E02}, /* 259 */ + {0x050E0F02}, {0x050F0D02}, {0x040E0E02}, {0x040E0E02}, {0x050D0F02}, /* 264 */ + {0x050F0C02}, {0x050C0F02}, {0x050E0D02}, {0x050D0E02}, {0x050F0B02}, /* 269 */ + {0x040B0F02}, {0x040B0F02}, {0x050E0C02}, {0x050C0E02}, {0x040D0D02}, /* 274 */ + {0x040D0D02}, {0x040F0A02}, {0x040F0A02}, {0x040A0F02}, {0x040A0F02}, /* 279 */ + {0x040E0B02}, {0x040E0B02}, {0x040B0E02}, {0x040B0E02}, {0x040D0C02}, /* 284 */ + {0x040D0C02}, {0x040C0D02}, {0x040C0D02}, {0x040F0902}, {0x040F0902}, /* 289 */ + {0xFF000005}, {0x04090F02}, {0x04090F02}, {0x040A0E02}, {0x040A0E02}, /* 294 */ + {0x040D0B02}, {0x040D0B02}, {0x040B0D02}, {0x040B0D02}, {0x040F0802}, /* 299 */ + {0x040F0802}, {0x04080F02}, {0x04080F02}, {0x040C0C02}, {0x040C0C02}, /* 304 */ + {0x040E0902}, {0x040E0902}, {0x04090E02}, {0x04090E02}, {0x040F0702}, /* 309 */ + {0x040F0702}, {0x04070F02}, {0x04070F02}, {0x040D0A02}, {0x040D0A02}, /* 314 */ + {0x040A0D02}, {0x040A0D02}, {0x040C0B02}, {0x040C0B02}, {0x040F0602}, /* 319 */ + {0x040F0602}, {0x050E0A02}, {0x050F0001}, {0xFF000004}, {0x030B0C02}, /* 324 */ + {0x030B0C02}, {0x03060F02}, {0x03060F02}, {0x040E0802}, {0x04080E02}, /* 329 */ + {0x040F0502}, {0x040D0902}, {0x03050F02}, {0x03050F02}, {0x030E0702}, /* 334 */ + {0x030E0702}, {0x03070E02}, {0x03070E02}, {0x030C0A02}, {0x030C0A02}, /* 339 */ + {0xFF000004}, {0x030A0C02}, {0x030A0C02}, {0x030B0B02}, {0x030B0B02}, /* 344 */ + {0x04090D02}, {0x040D0802}, {0x030F0402}, {0x030F0402}, {0x03040F02}, /* 349 */ + {0x03040F02}, {0x030F0302}, {0x030F0302}, {0x03030F02}, {0x03030F02}, /* 354 */ + {0x03080D02}, {0x03080D02}, {0xFF000004}, {0x03060E02}, {0x03060E02}, /* 359 */ + {0x030F0202}, {0x030F0202}, {0x03020F02}, {0x03020F02}, {0x040E0602}, /* 364 */ + {0x04000F01}, {0x030F0102}, {0x030F0102}, {0x03010F02}, {0x03010F02}, /* 369 */ + {0x030C0902}, {0x030C0902}, {0x03090C02}, {0x03090C02}, {0xFF000003}, /* 374 */ + {0x030E0502}, {0x030B0A02}, {0x030A0B02}, {0x03050E02}, {0x030D0702}, /* 379 */ + {0x03070D02}, {0x030E0402}, {0x03040E02}, {0xFF000003}, {0x030C0802}, /* 384 */ + {0x03080C02}, {0x030E0302}, {0x030D0602}, {0x03060D02}, {0x03030E02}, /* 389 */ + {0x030B0902}, {0x03090B02}, {0xFF000004}, {0x030E0202}, {0x030E0202}, /* 394 */ + {0x030A0A02}, {0x030A0A02}, {0x03020E02}, {0x03020E02}, {0x030E0102}, /* 399 */ + {0x030E0102}, {0x03010E02}, {0x03010E02}, {0x040E0001}, {0x04000E01}, /* 404 */ + {0x030D0502}, {0x030D0502}, {0x03050D02}, {0x03050D02}, {0xFF000003}, /* 409 */ + {0x030C0702}, {0x03070C02}, {0x030D0402}, {0x030B0802}, {0x02040D02}, /* 414 */ + {0x02040D02}, {0x03080B02}, {0x030A0902}, {0xFF000003}, {0x03090A02}, /* 419 */ + {0x030C0602}, {0x03060C02}, {0x030D0302}, {0x02030D02}, {0x02030D02}, /* 424 */ + {0x02020D02}, {0x02020D02}, {0xFF000003}, {0x030D0202}, {0x030D0001}, /* 429 */ + {0x020D0102}, {0x020D0102}, {0x020B0702}, {0x020B0702}, {0x02070B02}, /* 434 */ + {0x02070B02}, {0xFF000003}, {0x02010D02}, {0x02010D02}, {0x030C0502}, /* 439 */ + {0x03000D01}, {0x02050C02}, {0x02050C02}, {0x020A0802}, {0x020A0802}, /* 444 */ + {0xFF000002}, {0x02080A02}, {0x020C0402}, {0x02040C02}, {0x020B0602}, /* 449 */ + {0xFF000003}, {0x02060B02}, {0x02060B02}, {0x03090902}, {0x030C0001}, /* 454 */ + {0x020C0302}, {0x020C0302}, {0x02030C02}, {0x02030C02}, {0xFF000003}, /* 459 */ + {0x020A0702}, {0x020A0702}, {0x02070A02}, {0x02070A02}, {0x02060A02}, /* 464 */ + {0x02060A02}, {0x03000C01}, {0x030B0001}, {0xFF000002}, {0x01020C02}, /* 469 */ + {0x01020C02}, {0x020C0202}, {0x020B0502}, {0xFF000002}, {0x02050B02}, /* 474 */ + {0x020C0102}, {0x02090802}, {0x02080902}, {0xFF000002}, {0x02010C02}, /* 479 */ + {0x020B0402}, {0x02040B02}, {0x020A0602}, {0xFF000002}, {0x020B0302}, /* 484 */ + {0x02090702}, {0x01030B02}, {0x01030B02}, {0xFF000002}, {0x02070902}, /* 489 */ + {0x02080802}, {0x020B0202}, {0x020A0502}, {0xFF000002}, {0x01020B02}, /* 494 */ + {0x01020B02}, {0x02050A02}, {0x020B0102}, {0xFF000002}, {0x01010B02}, /* 499 */ + {0x01010B02}, {0x02000B01}, {0x02090602}, {0xFF000002}, {0x02060902}, /* 504 */ + {0x020A0402}, {0x02040A02}, {0x02080702}, {0xFF000002}, {0x02070802}, /* 509 */ + {0x020A0302}, {0x01030A02}, {0x01030A02}, {0xFF000001}, {0x01090502}, /* 514 */ + {0x01050902}, {0xFF000001}, {0x010A0202}, {0x01020A02}, {0xFF000001}, /* 519 */ + {0x010A0102}, {0x01010A02}, {0xFF000002}, {0x020A0001}, {0x02000A01}, /* 524 */ + {0x01080602}, {0x01080602}, {0xFF000001}, {0x01060802}, {0x01090402}, /* 529 */ + {0xFF000001}, {0x01040902}, {0x01090302}, {0xFF000002}, {0x01030902}, /* 534 */ + {0x01030902}, {0x02070702}, {0x02090001}, {0xFF000001}, {0x01080502}, /* 539 */ + {0x01050802}, {0xFF000001}, {0x01090202}, {0x01070602}, {0xFF000001}, /* 544 */ + {0x01060702}, {0x01020902}, {0xFF000001}, {0x01090102}, {0x01000901}, /* 549 */ + {0xFF000001}, {0x01080402}, {0x01040802}, {0xFF000001}, {0x01070502}, /* 554 */ + {0x01050702}, {0xFF000001}, {0x01080302}, {0x01030802}, {0xFF000001}, /* 559 */ + {0x01060602}, {0x01070402}, {0xFF000001}, {0x01040702}, {0x01080001}, /* 564 */ + {0xFF000001}, {0x01000801}, {0x01060502}, {0xFF000001}, {0x01050602}, /* 569 */ + {0x01070302}, {0xFF000001}, {0x01030702}, {0x01060402}, {0xFF000001}, /* 574 */ + {0x01070001}, {0x01000701}, {0xFF000001}, {0x01060001}, {0x01000601}, /* 579 */ +}; + +/* max table bits 8 */ + +/* TABLE 16 256 entries maxbits 17 linbits 0 */ +static const HUFF_ELEMENT huff_table_16[] = +{ + {0xFF000008}, {0x00000101}, {0x0000010A}, {0x00000113}, {0x080F0F02}, /* 4 */ + {0x00000118}, {0x0000011D}, {0x00000120}, {0x08020F02}, {0x00000131}, /* 9 */ + {0x080F0102}, {0x08010F02}, {0x00000134}, {0x00000145}, {0x00000156}, /* 14 */ + {0x00000167}, {0x00000178}, {0x00000189}, {0x0000019A}, {0x000001A3}, /* 19 */ + {0x000001AC}, {0x000001B5}, {0x000001BE}, {0x000001C7}, {0x000001D0}, /* 24 */ + {0x000001D9}, {0x000001DE}, {0x000001E3}, {0x000001E6}, {0x000001EB}, /* 29 */ + {0x000001F0}, {0x08010502}, {0x000001F3}, {0x000001F6}, {0x000001F9}, /* 34 */ + {0x000001FC}, {0x08040102}, {0x08010402}, {0x000001FF}, {0x08030202}, /* 39 */ + {0x08020302}, {0x07030102}, {0x07030102}, {0x07010302}, {0x07010302}, /* 44 */ + {0x08030001}, {0x08000301}, {0x07020202}, {0x07020202}, {0x06020102}, /* 49 */ + {0x06020102}, {0x06020102}, {0x06020102}, {0x06010202}, {0x06010202}, /* 54 */ + {0x06010202}, {0x06010202}, {0x06020001}, {0x06020001}, {0x06020001}, /* 59 */ + {0x06020001}, {0x06000201}, {0x06000201}, {0x06000201}, {0x06000201}, /* 64 */ + {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, /* 69 */ + {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, /* 74 */ + {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, /* 79 */ + {0x04010102}, {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, /* 84 */ + {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, /* 89 */ + {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, /* 94 */ + {0x04010001}, {0x04010001}, {0x03000101}, {0x03000101}, {0x03000101}, /* 99 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 104 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 109 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 114 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 119 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, /* 124 */ + {0x03000101}, {0x03000101}, {0x03000101}, {0x03000101}, {0x01000000}, /* 129 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 134 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 139 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 144 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 149 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 154 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 159 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 164 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 169 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 174 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 179 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 184 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 189 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 194 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 199 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 204 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 209 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 214 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 219 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 224 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 229 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 234 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 239 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 244 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 249 */ + {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, {0x01000000}, /* 254 */ + {0x01000000}, {0x01000000}, {0xFF000003}, {0x030F0E02}, {0x030E0F02}, /* 259 */ + {0x030F0D02}, {0x030D0F02}, {0x030F0C02}, {0x030C0F02}, {0x030F0B02}, /* 264 */ + {0x030B0F02}, {0xFF000003}, {0x020F0A02}, {0x020F0A02}, {0x030A0F02}, /* 269 */ + {0x030F0902}, {0x03090F02}, {0x03080F02}, {0x020F0802}, {0x020F0802}, /* 274 */ + {0xFF000002}, {0x020F0702}, {0x02070F02}, {0x020F0602}, {0x02060F02}, /* 279 */ + {0xFF000002}, {0x020F0502}, {0x02050F02}, {0x010F0402}, {0x010F0402}, /* 284 */ + {0xFF000001}, {0x01040F02}, {0x01030F02}, {0xFF000004}, {0x01000F01}, /* 289 */ + {0x01000F01}, {0x01000F01}, {0x01000F01}, {0x01000F01}, {0x01000F01}, /* 294 */ + {0x01000F01}, {0x01000F01}, {0x020F0302}, {0x020F0302}, {0x020F0302}, /* 299 */ + {0x020F0302}, {0x000000E2}, {0x000000F3}, {0x000000FC}, {0x00000105}, /* 304 */ + {0xFF000001}, {0x010F0202}, {0x010F0001}, {0xFF000004}, {0x000000FA}, /* 309 */ + {0x000000FF}, {0x00000104}, {0x00000109}, {0x0000010C}, {0x00000111}, /* 314 */ + {0x00000116}, {0x00000119}, {0x0000011E}, {0x00000123}, {0x00000128}, /* 319 */ + {0x04030E02}, {0x0000012D}, {0x00000130}, {0x00000133}, {0x00000136}, /* 324 */ + {0xFF000004}, {0x00000128}, {0x0000012B}, {0x0000012E}, {0x040D0001}, /* 329 */ + {0x00000131}, {0x00000134}, {0x00000137}, {0x040C0302}, {0x0000013A}, /* 334 */ + {0x040C0102}, {0x04000C01}, {0x0000013D}, {0x03020E02}, {0x03020E02}, /* 339 */ + {0x040E0202}, {0x040E0102}, {0xFF000004}, {0x04030D02}, {0x040D0202}, /* 344 */ + {0x04020D02}, {0x04010D02}, {0x040B0302}, {0x0000012F}, {0x030D0102}, /* 349 */ + {0x030D0102}, {0x04040C02}, {0x040B0602}, {0x04030C02}, {0x04070A02}, /* 354 */ + {0x030C0202}, {0x030C0202}, {0x04020C02}, {0x04050B02}, {0xFF000004}, /* 359 */ + {0x04010C02}, {0x040C0001}, {0x040B0402}, {0x04040B02}, {0x040A0602}, /* 364 */ + {0x04060A02}, {0x03030B02}, {0x03030B02}, {0x040A0502}, {0x04050A02}, /* 369 */ + {0x030B0202}, {0x030B0202}, {0x03020B02}, {0x03020B02}, {0x030B0102}, /* 374 */ + {0x030B0102}, {0xFF000004}, {0x03010B02}, {0x03010B02}, {0x040B0001}, /* 379 */ + {0x04000B01}, {0x04090602}, {0x04060902}, {0x040A0402}, {0x04040A02}, /* 384 */ + {0x04080702}, {0x04070802}, {0x03030A02}, {0x03030A02}, {0x040A0302}, /* 389 */ + {0x04090502}, {0x030A0202}, {0x030A0202}, {0xFF000004}, {0x04050902}, /* 394 */ + {0x04080602}, {0x03010A02}, {0x03010A02}, {0x04060802}, {0x04070702}, /* 399 */ + {0x03040902}, {0x03040902}, {0x04090402}, {0x04070502}, {0x03070602}, /* 404 */ + {0x03070602}, {0x02020A02}, {0x02020A02}, {0x02020A02}, {0x02020A02}, /* 409 */ + {0xFF000003}, {0x020A0102}, {0x020A0102}, {0x030A0001}, {0x03000A01}, /* 414 */ + {0x03090302}, {0x03030902}, {0x03080502}, {0x03050802}, {0xFF000003}, /* 419 */ + {0x02090202}, {0x02090202}, {0x02020902}, {0x02020902}, {0x03060702}, /* 424 */ + {0x03090001}, {0x02090102}, {0x02090102}, {0xFF000003}, {0x02010902}, /* 429 */ + {0x02010902}, {0x03000901}, {0x03080402}, {0x03040802}, {0x03050702}, /* 434 */ + {0x03080302}, {0x03030802}, {0xFF000003}, {0x03060602}, {0x03080202}, /* 439 */ + {0x02020802}, {0x02020802}, {0x03070402}, {0x03040702}, {0x02080102}, /* 444 */ + {0x02080102}, {0xFF000003}, {0x02010802}, {0x02010802}, {0x02000801}, /* 449 */ + {0x02000801}, {0x03080001}, {0x03060502}, {0x02070302}, {0x02070302}, /* 454 */ + {0xFF000003}, {0x02030702}, {0x02030702}, {0x03050602}, {0x03060402}, /* 459 */ + {0x02070202}, {0x02070202}, {0x02020702}, {0x02020702}, {0xFF000003}, /* 464 */ + {0x03040602}, {0x03050502}, {0x02070001}, {0x02070001}, {0x01070102}, /* 469 */ + {0x01070102}, {0x01070102}, {0x01070102}, {0xFF000002}, {0x01010702}, /* 474 */ + {0x01010702}, {0x02000701}, {0x02060302}, {0xFF000002}, {0x02030602}, /* 479 */ + {0x02050402}, {0x02040502}, {0x02060202}, {0xFF000001}, {0x01020602}, /* 484 */ + {0x01060102}, {0xFF000002}, {0x01010602}, {0x01010602}, {0x02060001}, /* 489 */ + {0x02000601}, {0xFF000002}, {0x01030502}, {0x01030502}, {0x02050302}, /* 494 */ + {0x02040402}, {0xFF000001}, {0x01050202}, {0x01020502}, {0xFF000001}, /* 499 */ + {0x01050102}, {0x01050001}, {0xFF000001}, {0x01040302}, {0x01030402}, /* 504 */ + {0xFF000001}, {0x01000501}, {0x01040202}, {0xFF000001}, {0x01020402}, /* 509 */ + {0x01030302}, {0xFF000001}, {0x01040001}, {0x01000401}, {0xFF000004}, /* 514 */ + {0x040E0C02}, {0x00000086}, {0x030E0D02}, {0x030E0D02}, {0x03090E02}, /* 519 */ + {0x03090E02}, {0x040A0E02}, {0x04090D02}, {0x020E0E02}, {0x020E0E02}, /* 524 */ + {0x020E0E02}, {0x020E0E02}, {0x030D0E02}, {0x030D0E02}, {0x030B0E02}, /* 529 */ + {0x030B0E02}, {0xFF000003}, {0x020E0B02}, {0x020E0B02}, {0x020D0C02}, /* 534 */ + {0x020D0C02}, {0x030C0D02}, {0x030B0D02}, {0x020E0A02}, {0x020E0A02}, /* 539 */ + {0xFF000003}, {0x020C0C02}, {0x020C0C02}, {0x030D0A02}, {0x030A0D02}, /* 544 */ + {0x030E0702}, {0x030C0A02}, {0x020A0C02}, {0x020A0C02}, {0xFF000003}, /* 549 */ + {0x03090C02}, {0x030D0702}, {0x020E0502}, {0x020E0502}, {0x010D0B02}, /* 554 */ + {0x010D0B02}, {0x010D0B02}, {0x010D0B02}, {0xFF000002}, {0x010E0902}, /* 559 */ + {0x010E0902}, {0x020C0B02}, {0x020B0C02}, {0xFF000002}, {0x020E0802}, /* 564 */ + {0x02080E02}, {0x020D0902}, {0x02070E02}, {0xFF000002}, {0x020B0B02}, /* 569 */ + {0x020D0802}, {0x02080D02}, {0x020E0602}, {0xFF000001}, {0x01060E02}, /* 574 */ + {0x010C0902}, {0xFF000002}, {0x020B0A02}, {0x020A0B02}, {0x02050E02}, /* 579 */ + {0x02070D02}, {0xFF000002}, {0x010E0402}, {0x010E0402}, {0x02040E02}, /* 584 */ + {0x020C0802}, {0xFF000001}, {0x01080C02}, {0x010E0302}, {0xFF000002}, /* 589 */ + {0x010D0602}, {0x010D0602}, {0x02060D02}, {0x020B0902}, {0xFF000002}, /* 594 */ + {0x02090B02}, {0x020A0A02}, {0x01010E02}, {0x01010E02}, {0xFF000002}, /* 599 */ + {0x01040D02}, {0x01040D02}, {0x02080B02}, {0x02090A02}, {0xFF000002}, /* 604 */ + {0x010B0702}, {0x010B0702}, {0x02070B02}, {0x02000D01}, {0xFF000001}, /* 609 */ + {0x010E0001}, {0x01000E01}, {0xFF000001}, {0x010D0502}, {0x01050D02}, /* 614 */ + {0xFF000001}, {0x010C0702}, {0x01070C02}, {0xFF000001}, {0x010D0402}, /* 619 */ + {0x010B0802}, {0xFF000001}, {0x010A0902}, {0x010C0602}, {0xFF000001}, /* 624 */ + {0x01060C02}, {0x010D0302}, {0xFF000001}, {0x010C0502}, {0x01050C02}, /* 629 */ + {0xFF000001}, {0x010A0802}, {0x01080A02}, {0xFF000001}, {0x01090902}, /* 634 */ + {0x010C0402}, {0xFF000001}, {0x01060B02}, {0x010A0702}, {0xFF000001}, /* 639 */ + {0x010B0502}, {0x01090802}, {0xFF000001}, {0x01080902}, {0x01090702}, /* 644 */ + {0xFF000001}, {0x01070902}, {0x01080802}, {0xFF000001}, {0x010C0E02}, /* 649 */ + {0x010D0D02}, +}; + +/* max table bits 8 */ +/* NO XING TABLE 17 */ +/* NO XING TABLE 18 */ +/* NO XING TABLE 19 */ +/* NO XING TABLE 20 */ +/* NO XING TABLE 21 */ +/* NO XING TABLE 22 */ +/* NO XING TABLE 23 */ + +/* TABLE 24 256 entries maxbits 12 linbits 0 */ +static const HUFF_ELEMENT huff_table_24[] = +{ + {0xFF000009}, {0x080F0E02}, {0x080F0E02}, {0x080E0F02}, {0x080E0F02}, /* 4 */ + {0x080F0D02}, {0x080F0D02}, {0x080D0F02}, {0x080D0F02}, {0x080F0C02}, /* 9 */ + {0x080F0C02}, {0x080C0F02}, {0x080C0F02}, {0x080F0B02}, {0x080F0B02}, /* 14 */ + {0x080B0F02}, {0x080B0F02}, {0x070A0F02}, {0x070A0F02}, {0x070A0F02}, /* 19 */ + {0x070A0F02}, {0x080F0A02}, {0x080F0A02}, {0x080F0902}, {0x080F0902}, /* 24 */ + {0x07090F02}, {0x07090F02}, {0x07090F02}, {0x07090F02}, {0x07080F02}, /* 29 */ + {0x07080F02}, {0x07080F02}, {0x07080F02}, {0x080F0802}, {0x080F0802}, /* 34 */ + {0x080F0702}, {0x080F0702}, {0x07070F02}, {0x07070F02}, {0x07070F02}, /* 39 */ + {0x07070F02}, {0x070F0602}, {0x070F0602}, {0x070F0602}, {0x070F0602}, /* 44 */ + {0x07060F02}, {0x07060F02}, {0x07060F02}, {0x07060F02}, {0x070F0502}, /* 49 */ + {0x070F0502}, {0x070F0502}, {0x070F0502}, {0x07050F02}, {0x07050F02}, /* 54 */ + {0x07050F02}, {0x07050F02}, {0x070F0402}, {0x070F0402}, {0x070F0402}, /* 59 */ + {0x070F0402}, {0x07040F02}, {0x07040F02}, {0x07040F02}, {0x07040F02}, /* 64 */ + {0x070F0302}, {0x070F0302}, {0x070F0302}, {0x070F0302}, {0x07030F02}, /* 69 */ + {0x07030F02}, {0x07030F02}, {0x07030F02}, {0x070F0202}, {0x070F0202}, /* 74 */ + {0x070F0202}, {0x070F0202}, {0x07020F02}, {0x07020F02}, {0x07020F02}, /* 79 */ + {0x07020F02}, {0x07010F02}, {0x07010F02}, {0x07010F02}, {0x07010F02}, /* 84 */ + {0x080F0102}, {0x080F0102}, {0x08000F01}, {0x08000F01}, {0x090F0001}, /* 89 */ + {0x00000201}, {0x00000206}, {0x0000020B}, {0x00000210}, {0x00000215}, /* 94 */ + {0x0000021A}, {0x0000021F}, {0x040F0F02}, {0x040F0F02}, {0x040F0F02}, /* 99 */ + {0x040F0F02}, {0x040F0F02}, {0x040F0F02}, {0x040F0F02}, {0x040F0F02}, /* 104 */ + {0x040F0F02}, {0x040F0F02}, {0x040F0F02}, {0x040F0F02}, {0x040F0F02}, /* 109 */ + {0x040F0F02}, {0x040F0F02}, {0x040F0F02}, {0x040F0F02}, {0x040F0F02}, /* 114 */ + {0x040F0F02}, {0x040F0F02}, {0x040F0F02}, {0x040F0F02}, {0x040F0F02}, /* 119 */ + {0x040F0F02}, {0x040F0F02}, {0x040F0F02}, {0x040F0F02}, {0x040F0F02}, /* 124 */ + {0x040F0F02}, {0x040F0F02}, {0x040F0F02}, {0x040F0F02}, {0x00000224}, /* 129 */ + {0x00000229}, {0x00000232}, {0x00000237}, {0x0000023A}, {0x0000023F}, /* 134 */ + {0x00000242}, {0x00000245}, {0x0000024A}, {0x0000024D}, {0x00000250}, /* 139 */ + {0x00000253}, {0x00000256}, {0x00000259}, {0x0000025C}, {0x0000025F}, /* 144 */ + {0x00000262}, {0x00000265}, {0x00000268}, {0x0000026B}, {0x0000026E}, /* 149 */ + {0x00000271}, {0x00000274}, {0x00000277}, {0x0000027A}, {0x0000027D}, /* 154 */ + {0x00000280}, {0x00000283}, {0x00000288}, {0x0000028B}, {0x0000028E}, /* 159 */ + {0x00000291}, {0x00000294}, {0x00000297}, {0x0000029A}, {0x0000029F}, /* 164 */ + {0x09040B02}, {0x000002A4}, {0x000002A7}, {0x000002AA}, {0x09030B02}, /* 169 */ + {0x09080802}, {0x000002AF}, {0x09020B02}, {0x000002B2}, {0x000002B5}, /* 174 */ + {0x09060902}, {0x09040A02}, {0x000002B8}, {0x09070802}, {0x090A0302}, /* 179 */ + {0x09030A02}, {0x09090502}, {0x09050902}, {0x090A0202}, {0x09020A02}, /* 184 */ + {0x09010A02}, {0x09080602}, {0x09060802}, {0x09070702}, {0x09090402}, /* 189 */ + {0x09040902}, {0x09090302}, {0x09030902}, {0x09080502}, {0x09050802}, /* 194 */ + {0x09090202}, {0x09070602}, {0x09060702}, {0x09020902}, {0x09090102}, /* 199 */ + {0x09010902}, {0x09080402}, {0x09040802}, {0x09070502}, {0x09050702}, /* 204 */ + {0x09080302}, {0x09030802}, {0x09060602}, {0x09080202}, {0x09020802}, /* 209 */ + {0x09080102}, {0x09070402}, {0x09040702}, {0x09010802}, {0x000002BB}, /* 214 */ + {0x09060502}, {0x09050602}, {0x09070102}, {0x000002BE}, {0x08030702}, /* 219 */ + {0x08030702}, {0x09070302}, {0x09070202}, {0x08020702}, {0x08020702}, /* 224 */ + {0x08060402}, {0x08060402}, {0x08040602}, {0x08040602}, {0x08050502}, /* 229 */ + {0x08050502}, {0x08010702}, {0x08010702}, {0x08060302}, {0x08060302}, /* 234 */ + {0x08030602}, {0x08030602}, {0x08050402}, {0x08050402}, {0x08040502}, /* 239 */ + {0x08040502}, {0x08060202}, {0x08060202}, {0x08020602}, {0x08020602}, /* 244 */ + {0x08060102}, {0x08060102}, {0x08010602}, {0x08010602}, {0x09060001}, /* 249 */ + {0x09000601}, {0x08050302}, {0x08050302}, {0x08030502}, {0x08030502}, /* 254 */ + {0x08040402}, {0x08040402}, {0x08050202}, {0x08050202}, {0x08020502}, /* 259 */ + {0x08020502}, {0x08050102}, {0x08050102}, {0x09050001}, {0x09000501}, /* 264 */ + {0x07010502}, {0x07010502}, {0x07010502}, {0x07010502}, {0x08040302}, /* 269 */ + {0x08040302}, {0x08030402}, {0x08030402}, {0x07040202}, {0x07040202}, /* 274 */ + {0x07040202}, {0x07040202}, {0x07020402}, {0x07020402}, {0x07020402}, /* 279 */ + {0x07020402}, {0x07030302}, {0x07030302}, {0x07030302}, {0x07030302}, /* 284 */ + {0x07040102}, {0x07040102}, {0x07040102}, {0x07040102}, {0x07010402}, /* 289 */ + {0x07010402}, {0x07010402}, {0x07010402}, {0x08040001}, {0x08040001}, /* 294 */ + {0x08000401}, {0x08000401}, {0x07030202}, {0x07030202}, {0x07030202}, /* 299 */ + {0x07030202}, {0x07020302}, {0x07020302}, {0x07020302}, {0x07020302}, /* 304 */ + {0x06030102}, {0x06030102}, {0x06030102}, {0x06030102}, {0x06030102}, /* 309 */ + {0x06030102}, {0x06030102}, {0x06030102}, {0x06010302}, {0x06010302}, /* 314 */ + {0x06010302}, {0x06010302}, {0x06010302}, {0x06010302}, {0x06010302}, /* 319 */ + {0x06010302}, {0x07030001}, {0x07030001}, {0x07030001}, {0x07030001}, /* 324 */ + {0x07000301}, {0x07000301}, {0x07000301}, {0x07000301}, {0x06020202}, /* 329 */ + {0x06020202}, {0x06020202}, {0x06020202}, {0x06020202}, {0x06020202}, /* 334 */ + {0x06020202}, {0x06020202}, {0x05020102}, {0x05020102}, {0x05020102}, /* 339 */ + {0x05020102}, {0x05020102}, {0x05020102}, {0x05020102}, {0x05020102}, /* 344 */ + {0x05020102}, {0x05020102}, {0x05020102}, {0x05020102}, {0x05020102}, /* 349 */ + {0x05020102}, {0x05020102}, {0x05020102}, {0x05010202}, {0x05010202}, /* 354 */ + {0x05010202}, {0x05010202}, {0x05010202}, {0x05010202}, {0x05010202}, /* 359 */ + {0x05010202}, {0x05010202}, {0x05010202}, {0x05010202}, {0x05010202}, /* 364 */ + {0x05010202}, {0x05010202}, {0x05010202}, {0x05010202}, {0x06020001}, /* 369 */ + {0x06020001}, {0x06020001}, {0x06020001}, {0x06020001}, {0x06020001}, /* 374 */ + {0x06020001}, {0x06020001}, {0x06000201}, {0x06000201}, {0x06000201}, /* 379 */ + {0x06000201}, {0x06000201}, {0x06000201}, {0x06000201}, {0x06000201}, /* 384 */ + {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, /* 389 */ + {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, /* 394 */ + {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, /* 399 */ + {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, /* 404 */ + {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, /* 409 */ + {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, {0x04010102}, /* 414 */ + {0x04010102}, {0x04010102}, {0x04010001}, {0x04010001}, {0x04010001}, /* 419 */ + {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, /* 424 */ + {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, /* 429 */ + {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, /* 434 */ + {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, /* 439 */ + {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, /* 444 */ + {0x04010001}, {0x04010001}, {0x04010001}, {0x04010001}, {0x04000101}, /* 449 */ + {0x04000101}, {0x04000101}, {0x04000101}, {0x04000101}, {0x04000101}, /* 454 */ + {0x04000101}, {0x04000101}, {0x04000101}, {0x04000101}, {0x04000101}, /* 459 */ + {0x04000101}, {0x04000101}, {0x04000101}, {0x04000101}, {0x04000101}, /* 464 */ + {0x04000101}, {0x04000101}, {0x04000101}, {0x04000101}, {0x04000101}, /* 469 */ + {0x04000101}, {0x04000101}, {0x04000101}, {0x04000101}, {0x04000101}, /* 474 */ + {0x04000101}, {0x04000101}, {0x04000101}, {0x04000101}, {0x04000101}, /* 479 */ + {0x04000101}, {0x04000000}, {0x04000000}, {0x04000000}, {0x04000000}, /* 484 */ + {0x04000000}, {0x04000000}, {0x04000000}, {0x04000000}, {0x04000000}, /* 489 */ + {0x04000000}, {0x04000000}, {0x04000000}, {0x04000000}, {0x04000000}, /* 494 */ + {0x04000000}, {0x04000000}, {0x04000000}, {0x04000000}, {0x04000000}, /* 499 */ + {0x04000000}, {0x04000000}, {0x04000000}, {0x04000000}, {0x04000000}, /* 504 */ + {0x04000000}, {0x04000000}, {0x04000000}, {0x04000000}, {0x04000000}, /* 509 */ + {0x04000000}, {0x04000000}, {0x04000000}, {0xFF000002}, {0x020E0E02}, /* 514 */ + {0x020E0D02}, {0x020D0E02}, {0x020E0C02}, {0xFF000002}, {0x020C0E02}, /* 519 */ + {0x020D0D02}, {0x020E0B02}, {0x020B0E02}, {0xFF000002}, {0x020D0C02}, /* 524 */ + {0x020C0D02}, {0x020E0A02}, {0x020A0E02}, {0xFF000002}, {0x020D0B02}, /* 529 */ + {0x020B0D02}, {0x020C0C02}, {0x020E0902}, {0xFF000002}, {0x02090E02}, /* 534 */ + {0x020D0A02}, {0x020A0D02}, {0x020C0B02}, {0xFF000002}, {0x020B0C02}, /* 539 */ + {0x020E0802}, {0x02080E02}, {0x020D0902}, {0xFF000002}, {0x02090D02}, /* 544 */ + {0x020E0702}, {0x02070E02}, {0x020C0A02}, {0xFF000002}, {0x020A0C02}, /* 549 */ + {0x020B0B02}, {0x020D0802}, {0x02080D02}, {0xFF000003}, {0x030E0001}, /* 554 */ + {0x03000E01}, {0x020D0001}, {0x020D0001}, {0x01060E02}, {0x01060E02}, /* 559 */ + {0x01060E02}, {0x01060E02}, {0xFF000002}, {0x020E0602}, {0x020C0902}, /* 564 */ + {0x01090C02}, {0x01090C02}, {0xFF000001}, {0x010E0502}, {0x010A0B02}, /* 569 */ + {0xFF000002}, {0x01050E02}, {0x01050E02}, {0x020B0A02}, {0x020D0702}, /* 574 */ + {0xFF000001}, {0x01070D02}, {0x01040E02}, {0xFF000001}, {0x010C0802}, /* 579 */ + {0x01080C02}, {0xFF000002}, {0x020E0402}, {0x020E0202}, {0x010E0302}, /* 584 */ + {0x010E0302}, {0xFF000001}, {0x010D0602}, {0x01060D02}, {0xFF000001}, /* 589 */ + {0x01030E02}, {0x010B0902}, {0xFF000001}, {0x01090B02}, {0x010A0A02}, /* 594 */ + {0xFF000001}, {0x01020E02}, {0x010E0102}, {0xFF000001}, {0x01010E02}, /* 599 */ + {0x010D0502}, {0xFF000001}, {0x01050D02}, {0x010C0702}, {0xFF000001}, /* 604 */ + {0x01070C02}, {0x010D0402}, {0xFF000001}, {0x010B0802}, {0x01080B02}, /* 609 */ + {0xFF000001}, {0x01040D02}, {0x010A0902}, {0xFF000001}, {0x01090A02}, /* 614 */ + {0x010C0602}, {0xFF000001}, {0x01060C02}, {0x010D0302}, {0xFF000001}, /* 619 */ + {0x01030D02}, {0x010D0202}, {0xFF000001}, {0x01020D02}, {0x010D0102}, /* 624 */ + {0xFF000001}, {0x010B0702}, {0x01070B02}, {0xFF000001}, {0x01010D02}, /* 629 */ + {0x010C0502}, {0xFF000001}, {0x01050C02}, {0x010A0802}, {0xFF000001}, /* 634 */ + {0x01080A02}, {0x01090902}, {0xFF000001}, {0x010C0402}, {0x01040C02}, /* 639 */ + {0xFF000001}, {0x010B0602}, {0x01060B02}, {0xFF000002}, {0x02000D01}, /* 644 */ + {0x020C0001}, {0x010C0302}, {0x010C0302}, {0xFF000001}, {0x01030C02}, /* 649 */ + {0x010A0702}, {0xFF000001}, {0x01070A02}, {0x010C0202}, {0xFF000001}, /* 654 */ + {0x01020C02}, {0x010B0502}, {0xFF000001}, {0x01050B02}, {0x010C0102}, /* 659 */ + {0xFF000001}, {0x01090802}, {0x01080902}, {0xFF000001}, {0x01010C02}, /* 664 */ + {0x010B0402}, {0xFF000002}, {0x02000C01}, {0x020B0001}, {0x010B0302}, /* 669 */ + {0x010B0302}, {0xFF000002}, {0x02000B01}, {0x020A0001}, {0x010A0102}, /* 674 */ + {0x010A0102}, {0xFF000001}, {0x010A0602}, {0x01060A02}, {0xFF000001}, /* 679 */ + {0x01090702}, {0x01070902}, {0xFF000002}, {0x02000A01}, {0x02090001}, /* 684 */ + {0x01000901}, {0x01000901}, {0xFF000001}, {0x010B0202}, {0x010A0502}, /* 689 */ + {0xFF000001}, {0x01050A02}, {0x010B0102}, {0xFF000001}, {0x01010B02}, /* 694 */ + {0x01090602}, {0xFF000001}, {0x010A0402}, {0x01080702}, {0xFF000001}, /* 699 */ + {0x01080001}, {0x01000801}, {0xFF000001}, {0x01070001}, {0x01000701}, /* 704 */ +}; + +/* max table bits 9 */ +/* NO XING TABLE 25 */ +/* NO XING TABLE 26 */ +/* NO XING TABLE 27 */ +/* NO XING TABLE 28 */ +/* NO XING TABLE 29 */ +/* NO XING TABLE 30 */ +/* NO XING TABLE 31 */ +/* done */ diff --git a/src/client/mp3/hwin.c b/src/client/mp3/hwin.c new file mode 100644 index 0000000000..8eb9f40187 --- /dev/null +++ b/src/client/mp3/hwin.c @@ -0,0 +1,265 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: hwin.c,v 1.5 1999/10/19 07:13:08 elrod Exp $ +____________________________________________________________________________*/ + +/**** hwin.c *************************************************** + +Layer III + +hybrid window/filter + +******************************************************************/ +#include +#include +#include +#include + +#include "mp3struct.h" +////@@@@extern int band_limit_nsb; + +typedef float ARRAY36[36]; + +/*-- windows by block type --*/ +static float win[4][36]; // effectively a constant + + +/*====================================================================*/ +void imdct18(float f[]); /* 18 point */ +void imdct6_3(float f[]); /* 6 point */ +ARRAY36 *hwin_init_addr(void); + +/*====================================================================*/ +ARRAY36 *hwin_init_addr() +{ + return win; +} + + +/*====================================================================*/ +int hybrid(float xin[], float xprev[], float y[18][32], + int btype, int nlong, int ntot, int nprev) +{ + int i, j; + float *x, *x0; + float xa, xb; + int n; + int nout; + + + + if (btype == 2) + btype = 0; + x = xin; + x0 = xprev; + +/*-- do long blocks (if any) --*/ + n = (nlong + 17) / 18; /* number of dct's to do */ + for (i = 0; i < n; i++) + { + imdct18(x); + for (j = 0; j < 9; j++) + { + y[j][i] = x0[j] + win[btype][j] * x[9 + j]; + y[9 + j][i] = x0[9 + j] + win[btype][9 + j] * x[17 - j]; + } + /* window x for next time x0 */ + for (j = 0; j < 4; j++) + { + xa = x[j]; + xb = x[8 - j]; + x[j] = win[btype][18 + j] * xb; + x[8 - j] = win[btype][(18 + 8) - j] * xa; + x[9 + j] = win[btype][(18 + 9) + j] * xa; + x[17 - j] = win[btype][(18 + 17) - j] * xb; + } + xa = x[j]; + x[j] = win[btype][18 + j] * xa; + x[9 + j] = win[btype][(18 + 9) + j] * xa; + + x += 18; + x0 += 18; + } + +/*-- do short blocks (if any) --*/ + n = (ntot + 17) / 18; /* number of 6 pt dct's triples to do */ + for (; i < n; i++) + { + imdct6_3(x); + for (j = 0; j < 3; j++) + { + y[j][i] = x0[j]; + y[3 + j][i] = x0[3 + j]; + + y[6 + j][i] = x0[6 + j] + win[2][j] * x[3 + j]; + y[9 + j][i] = x0[9 + j] + win[2][3 + j] * x[5 - j]; + + y[12 + j][i] = x0[12 + j] + win[2][6 + j] * x[2 - j] + win[2][j] * x[(6 + 3) + j]; + y[15 + j][i] = x0[15 + j] + win[2][9 + j] * x[j] + win[2][3 + j] * x[(6 + 5) - j]; + } + /* window x for next time x0 */ + for (j = 0; j < 3; j++) + { + x[j] = win[2][6 + j] * x[(6 + 2) - j] + win[2][j] * x[(12 + 3) + j]; + x[3 + j] = win[2][9 + j] * x[6 + j] + win[2][3 + j] * x[(12 + 5) - j]; + } + for (j = 0; j < 3; j++) + { + x[6 + j] = win[2][6 + j] * x[(12 + 2) - j]; + x[9 + j] = win[2][9 + j] * x[12 + j]; + } + for (j = 0; j < 3; j++) + { + x[12 + j] = 0.0f; + x[15 + j] = 0.0f; + } + x += 18; + x0 += 18; + } + +/*--- overlap prev if prev longer that current --*/ + n = (nprev + 17) / 18; + for (; i < n; i++) + { + for (j = 0; j < 18; j++) + y[j][i] = x0[j]; + x0 += 18; + } + nout = 18 * i; + +/*--- clear remaining only to band limit --*/ + for (; i < pMP3Stream->band_limit_nsb; i++) + { + for (j = 0; j < 18; j++) + y[j][i] = 0.0f; + } + + return nout; +} + + +/*--------------------------------------------------------------------*/ +/*--------------------------------------------------------------------*/ +/*-- convert to mono, add curr result to y, + window and add next time to current left */ +int hybrid_sum(float xin[], float xin_left[], float y[18][32], + int btype, int nlong, int ntot) +{ + int i, j; + float *x, *x0; + float xa, xb; + int n; + int nout; + + + + if (btype == 2) + btype = 0; + x = xin; + x0 = xin_left; + +/*-- do long blocks (if any) --*/ + n = (nlong + 17) / 18; /* number of dct's to do */ + for (i = 0; i < n; i++) + { + imdct18(x); + for (j = 0; j < 9; j++) + { + y[j][i] += win[btype][j] * x[9 + j]; + y[9 + j][i] += win[btype][9 + j] * x[17 - j]; + } + /* window x for next time x0 */ + for (j = 0; j < 4; j++) + { + xa = x[j]; + xb = x[8 - j]; + x0[j] += win[btype][18 + j] * xb; + x0[8 - j] += win[btype][(18 + 8) - j] * xa; + x0[9 + j] += win[btype][(18 + 9) + j] * xa; + x0[17 - j] += win[btype][(18 + 17) - j] * xb; + } + xa = x[j]; + x0[j] += win[btype][18 + j] * xa; + x0[9 + j] += win[btype][(18 + 9) + j] * xa; + + x += 18; + x0 += 18; + } + +/*-- do short blocks (if any) --*/ + n = (ntot + 17) / 18; /* number of 6 pt dct's triples to do */ + for (; i < n; i++) + { + imdct6_3(x); + for (j = 0; j < 3; j++) + { + y[6 + j][i] += win[2][j] * x[3 + j]; + y[9 + j][i] += win[2][3 + j] * x[5 - j]; + + y[12 + j][i] += win[2][6 + j] * x[2 - j] + win[2][j] * x[(6 + 3) + j]; + y[15 + j][i] += win[2][9 + j] * x[j] + win[2][3 + j] * x[(6 + 5) - j]; + } + /* window x for next time */ + for (j = 0; j < 3; j++) + { + x0[j] += win[2][6 + j] * x[(6 + 2) - j] + win[2][j] * x[(12 + 3) + j]; + x0[3 + j] += win[2][9 + j] * x[6 + j] + win[2][3 + j] * x[(12 + 5) - j]; + } + for (j = 0; j < 3; j++) + { + x0[6 + j] += win[2][6 + j] * x[(12 + 2) - j]; + x0[9 + j] += win[2][9 + j] * x[12 + j]; + } + x += 18; + x0 += 18; + } + + nout = 18 * i; + + return nout; +} +/*--------------------------------------------------------------------*/ +void sum_f_bands(float a[], float b[], int n) +{ + int i; + + for (i = 0; i < n; i++) + a[i] += b[i]; +} +/*--------------------------------------------------------------------*/ +/*--------------------------------------------------------------------*/ +void FreqInvert(float y[18][32], int n) +{ + int i, j; + + n = (n + 17) / 18; + for (j = 0; j < 18; j += 2) + { + for (i = 0; i < n; i += 2) + { + y[1 + j][1 + i] = -y[1 + j][1 + i]; + } + } +} +/*--------------------------------------------------------------------*/ diff --git a/src/client/mp3/jdw.h b/src/client/mp3/jdw.h new file mode 100644 index 0000000000..61dedca465 --- /dev/null +++ b/src/client/mp3/jdw.h @@ -0,0 +1,22 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + Copyright (C) 1998 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: jdw.h,v 1.2 1999/10/19 07:13:08 elrod Exp $ +____________________________________________________________________________*/ diff --git a/src/client/mp3/l3.h b/src/client/mp3/l3.h new file mode 100644 index 0000000000..c534ccd657 --- /dev/null +++ b/src/client/mp3/l3.h @@ -0,0 +1,166 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1996-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 Emusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: L3.h,v 1.7 1999/12/10 07:16:42 elrod Exp $ +____________________________________________________________________________*/ + +/**** L3.h *************************************************** + + Layer III structures + + *** Layer III is 32 bit only *** + *** Layer III code assumes 32 bit int *** + +******************************************************************/ +#ifndef L3_H +#define L3_H + +#include "config.h" + +#include "../../qcommon/q_platform.h" + +#define GLOBAL_GAIN_SCALE (4*15) +/* #define GLOBAL_GAIN_SCALE 0 */ + +/*-----------------------------------------------------------*/ +/*---- huffman lookup tables ---*/ +/* endian dependent !!! */ +#ifdef Q3_LITTLE_ENDIAN +typedef union +{ + int ptr; + struct + { + unsigned char signbits; + unsigned char x; + unsigned char y; + unsigned char purgebits; // 0 = esc + + } + b; +} +HUFF_ELEMENT; + +#else /* big endian machines */ +typedef union +{ + int ptr; /* int must be 32 bits or more */ + struct + { + unsigned char purgebits; // 0 = esc + + unsigned char y; + unsigned char x; + unsigned char signbits; + } + b; +} +HUFF_ELEMENT; + +#endif +/*--------------------------------------------------------------*/ +typedef struct +{ + unsigned int bitbuf; + int bits; + unsigned char *bs_ptr; + unsigned char *bs_ptr0; + unsigned char *bs_ptr_end; // optional for overrun test + +} +BITDAT; + +/*-- side info ---*/ +typedef struct +{ + int part2_3_length; + int big_values; + int global_gain; + int scalefac_compress; + int window_switching_flag; + int block_type; + int mixed_block_flag; + int table_select[3]; + int subblock_gain[3]; + int region0_count; + int region1_count; + int preflag; + int scalefac_scale; + int count1table_select; +} +GR; +typedef struct +{ + int mode; + int mode_ext; +/*---------------*/ + int main_data_begin; /* beginning, not end, my spec wrong */ + int private_bits; +/*---------------*/ + int scfsi[2]; /* 4 bit flags [ch] */ + GR gr[2][2]; /* [gran][ch] */ +} +SIDE_INFO; + +/*-----------------------------------------------------------*/ +/*-- scale factors ---*/ +// check dimensions - need 21 long, 3*12 short +// plus extra for implicit sf=0 above highest cb +typedef struct +{ + int l[23]; /* [cb] */ + int s[3][13]; /* [window][cb] */ +} +SCALEFACT; + +/*-----------------------------------------------------------*/ +typedef struct +{ + int cbtype; /* long=0 short=1 */ + int cbmax; /* max crit band */ +// int lb_type; /* long block type 0 1 3 */ + int cbs0; /* short band start index 0 3 12 (12=no shorts */ + int ncbl; /* number long cb's 0 8 21 */ + int cbmax_s[3]; /* cbmax by individual short blocks */ +} +CB_INFO; + +/*-----------------------------------------------------------*/ +/* scale factor infor for MPEG2 intensity stereo */ +typedef struct +{ + int nr[3]; + int slen[3]; + int intensity_scale; +} +IS_SF_INFO; + + +#ifndef SAMPLE +#include "small_header.h" +#endif + +/*-----------------------------------------------------------*/ + +#endif // #ifndef L3_H + diff --git a/src/client/mp3/l3dq.c b/src/client/mp3/l3dq.c new file mode 100644 index 0000000000..a5a56d3bc6 --- /dev/null +++ b/src/client/mp3/l3dq.c @@ -0,0 +1,254 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: l3dq.c,v 1.6 1999/10/19 07:13:09 elrod Exp $ +____________________________________________________________________________*/ + +/**** quant.c *************************************************** + Layer III dequant + + does reordering of short blocks + + mod 8/19/98 decode 22 sf bands + +******************************************************************/ + +#include +#include +#include +#include +#include +#include "l3.h" + +#include "mp3struct.h" + +/*---------- +static struct { +int l[23]; +int s[14];} sfBandTable[3] = +{{{0,4,8,12,16,20,24,30,36,44,52,62,74,90,110,134,162,196,238,288,342,418,576}, + {0,4,8,12,16,22,30,40,52,66,84,106,136,192}}, +{{0,4,8,12,16,20,24,30,36,42,50,60,72,88,106,128,156,190,230,276,330,384,576}, + {0,4,8,12,16,22,28,38,50,64,80,100,126,192}}, +{{0,4,8,12,16,20,24,30,36,44,54,66,82,102,126,156,194,240,296,364,448,550,576}, + {0,4,8,12,16,22,30,42,58,78,104,138,180,192}}}; +----------*/ + +/*--------------------------------*/ +static const int pretab[2][22] = +{ + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0}, +}; + + +////@@@@extern int nBand[2][22]; /* long = nBand[0][i], short = nBand[1][i] */ + +/* 8 bit plus 2 lookup x = pow(2.0, 0.25*(global_gain-210)) */ +/* two extra slots to do 1/sqrt(2) scaling for ms */ +/* 4 extra slots to do 1/2 scaling for cvt to mono */ +static float look_global[256 + 2 + 4]; // effectively constant + +/*-------- scaling lookup +x = pow(2.0, -0.5*(1+scalefact_scale)*scalefac + preemp) +look_scale[scalefact_scale][preemp][scalefac] +-----------------------*/ +static float look_scale[2][4][32]; // effectively constant +typedef float LS[4][32]; + + +/*--- iSample**(4/3) lookup, -32<=i<=31 ---*/ +#define ISMAX 32 +static float look_pow[2 * ISMAX]; // effectively constant + +/*-- pow(2.0, -0.25*8.0*subblock_gain) --*/ +static float look_subblock[8]; // effectively constant + +/*-- reorder buffer ---*/ +static float re_buf[192][3]; // used by dequant() below, but only during func (as workspace) +typedef float ARRAY3[3]; + + +/*=============================================================*/ +float *quant_init_global_addr() +{ + return look_global; +} +/*-------------------------------------------------------------*/ +LS *quant_init_scale_addr() +{ + return look_scale; +} +/*-------------------------------------------------------------*/ +float *quant_init_pow_addr() +{ + return look_pow; +} +/*-------------------------------------------------------------*/ +float *quant_init_subblock_addr() +{ + return look_subblock; +} +/*=============================================================*/ + +void dequant(SAMPLE Sample[], int *nsamp, + SCALEFACT * sf, + GR * gr, + CB_INFO * cb_info, int ncbl_mixed) +{ + int i, j; + int cb, n, w; + float x0, xs; + float xsb[3]; + double tmp; + int ncbl; + int cbs0; + ARRAY3 *buf; /* short block reorder */ + int nbands; + int i0; + int non_zero; + int cbmax[3]; + + nbands = *nsamp; + + + ncbl = 22; /* long block cb end */ + cbs0 = 12; /* short block cb start */ +/* ncbl_mixed = 8 or 6 mpeg1 or 2 */ + if (gr->block_type == 2) + { + ncbl = 0; + cbs0 = 0; + if (gr->mixed_block_flag) + { + ncbl = ncbl_mixed; + cbs0 = 3; + } + } +/* fill in cb_info -- */ + /* This doesn't seem used anywhere... + cb_info->lb_type = gr->block_type; + if (gr->block_type == 2) + cb_info->lb_type; + */ + cb_info->cbs0 = cbs0; + cb_info->ncbl = ncbl; + + cbmax[2] = cbmax[1] = cbmax[0] = 0; +/* global gain pre-adjusted by 2 if ms_mode, 0 otherwise */ + x0 = look_global[(2 + 4) + gr->global_gain]; + i = 0; +/*----- long blocks ---*/ + for (cb = 0; cb < ncbl; cb++) + { + non_zero = 0; + xs = x0 * look_scale[gr->scalefac_scale][pretab[gr->preflag][cb]][sf->l[cb]]; + n = pMP3Stream->nBand[0][cb]; + for (j = 0; j < n; j++, i++) + { + if (Sample[i].s == 0) + Sample[i].x = 0.0F; + else + { + non_zero = 1; + if ((Sample[i].s >= (-ISMAX)) && (Sample[i].s < ISMAX)) + Sample[i].x = xs * look_pow[ISMAX + Sample[i].s]; + else + { + float tmpConst = (float)(1.0/3.0); + tmp = (double) Sample[i].s; + Sample[i].x = (float) (xs * tmp * pow(fabs(tmp), tmpConst)); + } + } + } + if (non_zero) + cbmax[0] = cb; + if (i >= nbands) + break; + } + + cb_info->cbmax = cbmax[0]; + cb_info->cbtype = 0; // type = long + + if (cbs0 >= 12) + return; +/*--------------------------- +block type = 2 short blocks +----------------------------*/ + cbmax[2] = cbmax[1] = cbmax[0] = cbs0; + i0 = i; /* save for reorder */ + buf = re_buf; + for (w = 0; w < 3; w++) + xsb[w] = x0 * look_subblock[gr->subblock_gain[w]]; + for (cb = cbs0; cb < 13; cb++) + { + n = pMP3Stream->nBand[1][cb]; + for (w = 0; w < 3; w++) + { + non_zero = 0; + xs = xsb[w] * look_scale[gr->scalefac_scale][0][sf->s[w][cb]]; + for (j = 0; j < n; j++, i++) + { + if (Sample[i].s == 0) + buf[j][w] = 0.0F; + else + { + non_zero = 1; + if ((Sample[i].s >= (-ISMAX)) && (Sample[i].s < ISMAX)) + buf[j][w] = xs * look_pow[ISMAX + Sample[i].s]; + else + { + float tmpConst = (float)(1.0/3.0); + tmp = (double) Sample[i].s; + buf[j][w] = (float) (xs * tmp * pow(fabs(tmp), tmpConst)); + } + } + } + if (non_zero) + cbmax[w] = cb; + } + if (i >= nbands) + break; + buf += n; + } + + + memmove(&Sample[i0].x, &re_buf[0][0], sizeof(float) * (i - i0)); + + *nsamp = i; /* update nsamp */ + cb_info->cbmax_s[0] = cbmax[0]; + cb_info->cbmax_s[1] = cbmax[1]; + cb_info->cbmax_s[2] = cbmax[2]; + if (cbmax[1] > cbmax[0]) + cbmax[0] = cbmax[1]; + if (cbmax[2] > cbmax[0]) + cbmax[0] = cbmax[2]; + + cb_info->cbmax = cbmax[0]; + cb_info->cbtype = 1; /* type = short */ + + + return; +} + +/*-------------------------------------------------------------*/ diff --git a/src/client/mp3/l3init.c b/src/client/mp3/l3init.c new file mode 100644 index 0000000000..174bb39deb --- /dev/null +++ b/src/client/mp3/l3init.c @@ -0,0 +1,416 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: l3init.c,v 1.2 1999/10/19 07:13:09 elrod Exp $ +____________________________________________________________________________*/ + +/**** tinit.c *************************************************** + Layer III init tables + + +******************************************************************/ + +#include +#include +#include +#include +#include "l3.h" + +/*---------- quant ---------------------------------*/ +/* 8 bit lookup x = pow(2.0, 0.25*(global_gain-210)) */ +float *quant_init_global_addr(); + + +/* x = pow(2.0, -0.5*(1+scalefact_scale)*scalefac + preemp) */ +typedef float LS[4][32]; +LS *quant_init_scale_addr(); + + +float *quant_init_pow_addr(); +float *quant_init_subblock_addr(); + +typedef int iARRAY22[22]; +iARRAY22 *quant_init_band_addr(); + +/*---------- antialias ---------------------------------*/ +typedef float PAIR[2]; +PAIR *alias_init_addr(); + +static const float Ci[8] = +{ + -0.6f, -0.535f, -0.33f, -0.185f, -0.095f, -0.041f, -0.0142f, -0.0037f}; + + +void hwin_init(); /* hybrid windows -- */ +void imdct_init(); +typedef struct +{ + float *w; + float *w2; + void *coef; +} +IMDCT_INIT_BLOCK; + +void msis_init(); +void msis_init_MPEG2(); + +/*=============================================================*/ +int L3table_init() +{ + int i; + float *x; + LS *ls; + int scalefact_scale, preemp, scalefac; + double tmp; + PAIR *csa; + + static int iOnceOnly = 0; + + if (!iOnceOnly++) + { +/*================ quant ===============================*/ + + /* 8 bit plus 2 lookup x = pow(2.0, 0.25*(global_gain-210)) */ + /* extra 2 for ms scaling by 1/sqrt(2) */ + /* extra 4 for cvt to mono scaling by 1/2 */ + x = quant_init_global_addr(); + for (i = 0; i < 256 + 2 + 4; i++) + x[i] = (float) pow(2.0, 0.25 * ((i - (2 + 4)) - 210 + GLOBAL_GAIN_SCALE)); + + + + /* x = pow(2.0, -0.5*(1+scalefact_scale)*scalefac + preemp) */ + ls = quant_init_scale_addr(); + for (scalefact_scale = 0; scalefact_scale < 2; scalefact_scale++) + { + for (preemp = 0; preemp < 4; preemp++) + { + for (scalefac = 0; scalefac < 32; scalefac++) + { + ls[scalefact_scale][preemp][scalefac] = + (float) pow(2.0, -0.5 * (1 + scalefact_scale) * (scalefac + preemp)); + } + } + } + + /*--- iSample**(4/3) lookup, -32<=i<=31 ---*/ + x = quant_init_pow_addr(); + for (i = 0; i < 64; i++) + { + tmp = i - 32; + x[i] = (float) (tmp * pow(fabs(tmp), (1.0 / 3.0))); + } + + + /*-- pow(2.0, -0.25*8.0*subblock_gain) 3 bits --*/ + x = quant_init_subblock_addr(); + for (i = 0; i < 8; i++) + { + x[i] = (float) pow(2.0, 0.25 * -8.0 * i); + } + + /*-------------------------*/ + // quant_init_sf_band(sr_index); replaced by code in sup.c + + +/*================ antialias ===============================*/ + // onceonly!!!!!!!!!!!!!!!!!!!!! + csa = alias_init_addr(); + for (i = 0; i < 8; i++) + { + csa[i][0] = (float) (1.0 / sqrt(1.0 + Ci[i] * Ci[i])); + csa[i][1] = (float) (Ci[i] / sqrt(1.0 + Ci[i] * Ci[i])); + } + } + + // these 4 are iOnceOnly-protected inside... + +/*================ msis ===============================*/ + msis_init(); + msis_init_MPEG2(); + +/*================ imdct ===============================*/ + imdct_init(); + +/*--- hybrid windows ------------*/ + hwin_init(); + + return 0; +} +/*====================================================================*/ +typedef float ARRAY36[36]; +ARRAY36 *hwin_init_addr(); + +/*--------------------------------------------------------------------*/ +void hwin_init() +{ + int i, j; + double pi; + ARRAY36 *win; + + static int iOnceOnly = 0; + + if (!iOnceOnly++) + { + win = hwin_init_addr(); + + pi = 4.0 * atan(1.0); + + /* type 0 */ + for (i = 0; i < 36; i++) + win[0][i] = (float) sin(pi / 36 * (i + 0.5)); + + /* type 1 */ + for (i = 0; i < 18; i++) + win[1][i] = (float) sin(pi / 36 * (i + 0.5)); + for (i = 18; i < 24; i++) + win[1][i] = 1.0F; + for (i = 24; i < 30; i++) + win[1][i] = (float) sin(pi / 12 * (i + 0.5 - 18)); + for (i = 30; i < 36; i++) + win[1][i] = 0.0F; + + /* type 3 */ + for (i = 0; i < 6; i++) + win[3][i] = 0.0F; + for (i = 6; i < 12; i++) + win[3][i] = (float) sin(pi / 12 * (i + 0.5 - 6)); + for (i = 12; i < 18; i++) + win[3][i] = 1.0F; + for (i = 18; i < 36; i++) + win[3][i] = (float) sin(pi / 36 * (i + 0.5)); + + /* type 2 */ + for (i = 0; i < 12; i++) + win[2][i] = (float) sin(pi / 12 * (i + 0.5)); + for (i = 12; i < 36; i++) + win[2][i] = 0.0F; + + /*--- invert signs by region to match mdct 18pt --> 36pt mapping */ + for (j = 0; j < 4; j++) + { + if (j == 2) + continue; + for (i = 9; i < 36; i++) + win[j][i] = -win[j][i]; + } + + /*-- invert signs for short blocks --*/ + for (i = 3; i < 12; i++) + win[2][i] = -win[2][i]; + } +} +/*=============================================================*/ +typedef float ARRAY4[4]; +const IMDCT_INIT_BLOCK *imdct_init_addr_18(); +const IMDCT_INIT_BLOCK *imdct_init_addr_6(); + +/*-------------------------------------------------------------*/ +void imdct_init() +{ + int k, p, n; + double t, pi; + const IMDCT_INIT_BLOCK *addr; + float *w, *w2; + float *v, *v2, *coef87; + ARRAY4 *coef; + + static int iOnceOnly = 0; + + if (!iOnceOnly++) + { + /*--- 18 point --*/ + addr = imdct_init_addr_18(); + w = addr->w; + w2 = addr->w2; + coef = addr->coef; + /*----*/ + n = 18; + pi = 4.0 * atan(1.0); + t = pi / (4 * n); + for (p = 0; p < n; p++) + w[p] = (float) (2.0 * cos(t * (2 * p + 1))); + for (p = 0; p < 9; p++) + w2[p] = (float) (2.0 *cos(2 * t * (2 * p + 1))); + + t = pi / (2 * n); + for (k = 0; k < 9; k++) + { + for (p = 0; p < 4; p++) + coef[k][p] = (float) cos(t * (2 * k) * (2 * p + 1)); + } + + /*--- 6 point */ + addr = imdct_init_addr_6(); + v = addr->w; + v2 = addr->w2; + coef87 = addr->coef; + /*----*/ + n = 6; + pi = 4.0 * atan(1.0); + t = pi / (4 * n); + for (p = 0; p < n; p++) + v[p] = (float) (2.0 *cos(t * (2 * p + 1))); + + for (p = 0; p < 3; p++) + v2[p] = (float) (2.0 *cos(2 * t * (2 * p + 1))); + + t = pi / (2 * n); + k = 1; + p = 0; + *coef87 = (float) cos(t * (2 * k) * (2 * p + 1)); + /* adjust scaling to save a few mults */ + for (p = 0; p < 6; p++) + v[p] = v[p] / 2.0f; + *coef87 = (float) (2.0 *(*coef87)); + + } +} +/*===============================================================*/ +typedef float ARRAY8_2[8][2]; +ARRAY8_2 *msis_init_addr(); + +/*-------------------------------------------------------------*/ +void msis_init() +{ + int i; + double s, c; + double pi; + double t; + ARRAY8_2 *lr; + + static int iOnceOnly = 0; + + if (!iOnceOnly++) + { + lr = msis_init_addr(); + + + pi = 4.0 * atan(1.0); + t = pi / 12.0; + for (i = 0; i < 7; i++) + { + s = sin(i * t); + c = cos(i * t); + /* ms_mode = 0 */ + lr[0][i][0] = (float) (s / (s + c)); + lr[0][i][1] = (float) (c / (s + c)); + /* ms_mode = 1 */ + lr[1][i][0] = (float) (sqrt(2.0) * (s / (s + c))); + lr[1][i][1] = (float) (sqrt(2.0) * (c / (s + c))); + } + /* sf = 7 */ + /* ms_mode = 0 */ + lr[0][i][0] = 1.0f; + lr[0][i][1] = 0.0f; + /* ms_mode = 1, in is bands is routine does ms processing */ + lr[1][i][0] = 1.0f; + lr[1][i][1] = 1.0f; + + + /*------- + for(i=0;i<21;i++) nBand[0][i] = + sfBandTable[sr_index].l[i+1] - sfBandTable[sr_index].l[i]; + for(i=0;i<12;i++) nBand[1][i] = + sfBandTable[sr_index].s[i+1] - sfBandTable[sr_index].s[i]; + -------------*/ + } +} +/*-------------------------------------------------------------*/ +/*===============================================================*/ +typedef float ARRAY2_64_2[2][64][2]; +ARRAY2_64_2 *msis_init_addr_MPEG2(); + +/*-------------------------------------------------------------*/ +void msis_init_MPEG2() +{ + int k, n; + double t; + ARRAY2_64_2 *lr2; + int intensity_scale, ms_mode, sf, sflen; + float ms_factor[2]; + + static int iOnceOnly = 0; + + if (!iOnceOnly++) + { + ms_factor[0] = 1.0; + ms_factor[1] = (float) sqrt(2.0); + + lr2 = msis_init_addr_MPEG2(); + + /* intensity stereo MPEG2 */ + /* lr2[intensity_scale][ms_mode][sflen_offset+sf][left/right] */ + + for (intensity_scale = 0; intensity_scale < 2; intensity_scale++) + { + t = pow(2.0, -0.25 * (1 + intensity_scale)); + for (ms_mode = 0; ms_mode < 2; ms_mode++) + { + + n = 1; + k = 0; + for (sflen = 0; sflen < 6; sflen++) + { + for (sf = 0; sf < (n - 1); sf++, k++) + { + if (sf == 0) + { + lr2[intensity_scale][ms_mode][k][0] = ms_factor[ms_mode] * 1.0f; + lr2[intensity_scale][ms_mode][k][1] = ms_factor[ms_mode] * 1.0f; + } + else if ((sf & 1)) + { + lr2[intensity_scale][ms_mode][k][0] = + (float) (ms_factor[ms_mode] * pow(t, (sf + 1) / 2)); + lr2[intensity_scale][ms_mode][k][1] = ms_factor[ms_mode] * 1.0f; + } + else + { + lr2[intensity_scale][ms_mode][k][0] = ms_factor[ms_mode] * 1.0f; + lr2[intensity_scale][ms_mode][k][1] = + (float) (ms_factor[ms_mode] * pow(t, sf / 2)); + } + } + + /* illegal is_pos used to do ms processing */ + if (ms_mode == 0) + { /* ms_mode = 0 */ + lr2[intensity_scale][ms_mode][k][0] = 1.0f; + lr2[intensity_scale][ms_mode][k][1] = 0.0f; + } + else + { + /* ms_mode = 1, in is bands is routine does ms processing */ + lr2[intensity_scale][ms_mode][k][0] = 1.0f; + lr2[intensity_scale][ms_mode][k][1] = 1.0f; + } + k++; + n = n + n; + } + } + } + } + +} +/*-------------------------------------------------------------*/ diff --git a/src/client/mp3/mdct.c b/src/client/mp3/mdct.c new file mode 100644 index 0000000000..59b5d19bc9 --- /dev/null +++ b/src/client/mp3/mdct.c @@ -0,0 +1,229 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: mdct.c,v 1.4 1999/10/19 07:13:09 elrod Exp $ +____________________________________________________________________________*/ + +/**** mdct.c *************************************************** + +Layer III + + cos transform for n=18, n=6 + +computes c[k] = Sum( cos((pi/4*n)*(2*k+1)*(2*p+1))*f[p] ) + k = 0, ...n-1, p = 0...n-1 + + +inplace ok. + +******************************************************************/ + +#include +#include +#include +#include + + +/*------ 18 point xform -------*/ +float mdct18w[18]; // effectively constant +float mdct18w2[9]; // " " +float coef[9][4]; // " " + +float mdct6_3v[6]; // " " +float mdct6_3v2[3]; // " " +float coef87; // " " + +typedef struct +{ + float *w; + float *w2; + void *coef; +} +IMDCT_INIT_BLOCK; + +static const IMDCT_INIT_BLOCK imdct_info_18 = +{mdct18w, mdct18w2, coef}; +static const IMDCT_INIT_BLOCK imdct_info_6 = +{mdct6_3v, mdct6_3v2, &coef87}; + + + +/*====================================================================*/ +const IMDCT_INIT_BLOCK *imdct_init_addr_18() +{ + return &imdct_info_18; +} +const IMDCT_INIT_BLOCK *imdct_init_addr_6() +{ + return &imdct_info_6; +} +/*--------------------------------------------------------------------*/ +void imdct18(float f[18]) /* 18 point */ +{ + int p; + float a[9], b[9]; + float ap, bp, a8p, b8p; + float g1, g2; + + + for (p = 0; p < 4; p++) + { + g1 = mdct18w[p] * f[p]; + g2 = mdct18w[17 - p] * f[17 - p]; + ap = g1 + g2; // a[p] + + bp = mdct18w2[p] * (g1 - g2); // b[p] + + g1 = mdct18w[8 - p] * f[8 - p]; + g2 = mdct18w[9 + p] * f[9 + p]; + a8p = g1 + g2; // a[8-p] + + b8p = mdct18w2[8 - p] * (g1 - g2); // b[8-p] + + a[p] = ap + a8p; + a[5 + p] = ap - a8p; + b[p] = bp + b8p; + b[5 + p] = bp - b8p; + } + g1 = mdct18w[p] * f[p]; + g2 = mdct18w[17 - p] * f[17 - p]; + a[p] = g1 + g2; + b[p] = mdct18w2[p] * (g1 - g2); + + + f[0] = 0.5f * (a[0] + a[1] + a[2] + a[3] + a[4]); + f[1] = 0.5f * (b[0] + b[1] + b[2] + b[3] + b[4]); + + f[2] = coef[1][0] * a[5] + coef[1][1] * a[6] + coef[1][2] * a[7] + + coef[1][3] * a[8]; + f[3] = coef[1][0] * b[5] + coef[1][1] * b[6] + coef[1][2] * b[7] + + coef[1][3] * b[8] - f[1]; + f[1] = f[1] - f[0]; + f[2] = f[2] - f[1]; + + f[4] = coef[2][0] * a[0] + coef[2][1] * a[1] + coef[2][2] * a[2] + + coef[2][3] * a[3] - a[4]; + f[5] = coef[2][0] * b[0] + coef[2][1] * b[1] + coef[2][2] * b[2] + + coef[2][3] * b[3] - b[4] - f[3]; + f[3] = f[3] - f[2]; + f[4] = f[4] - f[3]; + + f[6] = coef[3][0] * (a[5] - a[7] - a[8]); + f[7] = coef[3][0] * (b[5] - b[7] - b[8]) - f[5]; + f[5] = f[5] - f[4]; + f[6] = f[6] - f[5]; + + f[8] = coef[4][0] * a[0] + coef[4][1] * a[1] + coef[4][2] * a[2] + + coef[4][3] * a[3] + a[4]; + f[9] = coef[4][0] * b[0] + coef[4][1] * b[1] + coef[4][2] * b[2] + + coef[4][3] * b[3] + b[4] - f[7]; + f[7] = f[7] - f[6]; + f[8] = f[8] - f[7]; + + f[10] = coef[5][0] * a[5] + coef[5][1] * a[6] + coef[5][2] * a[7] + + coef[5][3] * a[8]; + f[11] = coef[5][0] * b[5] + coef[5][1] * b[6] + coef[5][2] * b[7] + + coef[5][3] * b[8] - f[9]; + f[9] = f[9] - f[8]; + f[10] = f[10] - f[9]; + + f[12] = 0.5f * (a[0] + a[2] + a[3]) - a[1] - a[4]; + f[13] = 0.5f * (b[0] + b[2] + b[3]) - b[1] - b[4] - f[11]; + f[11] = f[11] - f[10]; + f[12] = f[12] - f[11]; + + f[14] = coef[7][0] * a[5] + coef[7][1] * a[6] + coef[7][2] * a[7] + + coef[7][3] * a[8]; + f[15] = coef[7][0] * b[5] + coef[7][1] * b[6] + coef[7][2] * b[7] + + coef[7][3] * b[8] - f[13]; + f[13] = f[13] - f[12]; + f[14] = f[14] - f[13]; + + f[16] = coef[8][0] * a[0] + coef[8][1] * a[1] + coef[8][2] * a[2] + + coef[8][3] * a[3] + a[4]; + f[17] = coef[8][0] * b[0] + coef[8][1] * b[1] + coef[8][2] * b[2] + + coef[8][3] * b[3] + b[4] - f[15]; + f[15] = f[15] - f[14]; + f[16] = f[16] - f[15]; + f[17] = f[17] - f[16]; + + + return; +} +/*--------------------------------------------------------------------*/ +/* does 3, 6 pt dct. changes order from f[i][window] c[window][i] */ +void imdct6_3(float f[]) /* 6 point */ +{ + int w; + float buf[18]; + float *a, *c; // b[i] = a[3+i] + + float g1, g2; + float a02, b02; + + c = f; + a = buf; + for (w = 0; w < 3; w++) + { + g1 = mdct6_3v[0] * f[3 * 0]; + g2 = mdct6_3v[5] * f[3 * 5]; + a[0] = g1 + g2; + a[3 + 0] = mdct6_3v2[0] * (g1 - g2); + + g1 = mdct6_3v[1] * f[3 * 1]; + g2 = mdct6_3v[4] * f[3 * 4]; + a[1] = g1 + g2; + a[3 + 1] = mdct6_3v2[1] * (g1 - g2); + + g1 = mdct6_3v[2] * f[3 * 2]; + g2 = mdct6_3v[3] * f[3 * 3]; + a[2] = g1 + g2; + a[3 + 2] = mdct6_3v2[2] * (g1 - g2); + + a += 6; + f++; + } + + a = buf; + for (w = 0; w < 3; w++) + { + a02 = (a[0] + a[2]); + b02 = (a[3 + 0] + a[3 + 2]); + c[0] = a02 + a[1]; + c[1] = b02 + a[3 + 1]; + c[2] = coef87 * (a[0] - a[2]); + c[3] = coef87 * (a[3 + 0] - a[3 + 2]) - c[1]; + c[1] = c[1] - c[0]; + c[2] = c[2] - c[1]; + c[4] = a02 - a[1] - a[1]; + c[5] = b02 - a[3 + 1] - a[3 + 1] - c[3]; + c[3] = c[3] - c[2]; + c[4] = c[4] - c[3]; + c[5] = c[5] - c[4]; + a += 6; + c += 6; + } + + return; +} +/*--------------------------------------------------------------------*/ diff --git a/src/client/mp3/mhead.c b/src/client/mp3/mhead.c new file mode 100644 index 0000000000..61340a93e8 --- /dev/null +++ b/src/client/mp3/mhead.c @@ -0,0 +1,328 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: mhead.c,v 1.7 1999/10/19 07:13:09 elrod Exp $ +____________________________________________________________________________*/ + +/*------------ mhead.c ---------------------------------------------- + mpeg audio + extract info from mpeg header + portable version (adapted from c:\eco\mhead.c + + add Layer III + + mods 6/18/97 re mux restart, 32 bit ints + + mod 5/7/98 parse mpeg 2.5 + +---------------------------------------------------------------------*/ +#include +#include +#include +#include +#include "mhead.h" /* mpeg header structure */ + +static const int mp_br_table[2][16] = +{{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0}, + {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 0}}; +static const int mp_sr20_table[2][4] = +{{441, 480, 320, -999}, {882, 960, 640, -999}}; + +static const int mp_br_tableL1[2][16] = +{{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0},/* mpeg2 */ + {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 0}}; + +static const int mp_br_tableL3[2][16] = +{{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0}, /* mpeg 2 */ + {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0}}; + + + +static int find_sync(unsigned char *buf, int n); +static int sync_scan(unsigned char *buf, int n, int i0); +static int sync_test(unsigned char *buf, int n, int isync, int padbytes); + + +/*--------------------------------------------------------------*/ +int head_info(unsigned char *buf, unsigned int n, MPEG_HEAD * h) +{ + int framebytes; + int mpeg25_flag; + + if (n > 10000) + n = 10000; /* limit scan for free format */ + + + + h->sync = 0; + //if ((buf[0] == 0xFF) && ((buf[1] & 0xF0) == 0xF0)) + if ((buf[0] == 0xFF) && ((buf[0+1] & 0xF0) == 0xF0)) + { + mpeg25_flag = 0; // mpeg 1 & 2 + + } + else if ((buf[0] == 0xFF) && ((buf[0+1] & 0xF0) == 0xE0)) + { + mpeg25_flag = 1; // mpeg 2.5 + + } + else + return 0; // sync fail + + h->sync = 1; + if (mpeg25_flag) + h->sync = 2; //low bit clear signals mpeg25 (as in 0xFFE) + + h->id = (buf[0+1] & 0x08) >> 3; + h->option = (buf[0+1] & 0x06) >> 1; + h->prot = (buf[0+1] & 0x01); + + h->br_index = (buf[0+2] & 0xf0) >> 4; + h->sr_index = (buf[0+2] & 0x0c) >> 2; + h->pad = (buf[0+2] & 0x02) >> 1; + h->private_bit = (buf[0+2] & 0x01); + h->mode = (buf[0+3] & 0xc0) >> 6; + h->mode_ext = (buf[0+3] & 0x30) >> 4; + h->cr = (buf[0+3] & 0x08) >> 3; + h->original = (buf[0+3] & 0x04) >> 2; + h->emphasis = (buf[0+3] & 0x03); + + +// if( mpeg25_flag ) { + // if( h->sr_index == 2 ) return 0; // fail 8khz + //} + + +/* compute framebytes for Layer I, II, III */ + if (h->option < 1) + return 0; + if (h->option > 3) + return 0; + + framebytes = 0; + + if (h->br_index > 0) + { + if (h->option == 3) + { /* layer I */ + framebytes = + 240 * mp_br_tableL1[h->id][h->br_index] + / mp_sr20_table[h->id][h->sr_index]; + framebytes = 4 * framebytes; + } + else if (h->option == 2) + { /* layer II */ + framebytes = + 2880 * mp_br_table[h->id][h->br_index] + / mp_sr20_table[h->id][h->sr_index]; + } + else if (h->option == 1) + { /* layer III */ + if (h->id) + { // mpeg1 + + framebytes = + 2880 * mp_br_tableL3[h->id][h->br_index] + / mp_sr20_table[h->id][h->sr_index]; + } + else + { // mpeg2 + + if (mpeg25_flag) + { // mpeg2.2 + + framebytes = + 2880 * mp_br_tableL3[h->id][h->br_index] + / mp_sr20_table[h->id][h->sr_index]; + } + else + { + framebytes = + 1440 * mp_br_tableL3[h->id][h->br_index] + / mp_sr20_table[h->id][h->sr_index]; + } + } + } + } + else + framebytes = find_sync(buf, n); /* free format */ + + return framebytes; +} + +int head_info3(unsigned char *buf, unsigned int n, MPEG_HEAD *h, int *br, unsigned int *searchForward) { + unsigned int pBuf = 0; + + // jdw insertion... + while ((pBuf < n) && !((buf[pBuf] == 0xFF) && + ((buf[pBuf+1] & 0xF0) == 0xF0 || (buf[pBuf+1] & 0xF0) == 0xE0))) + { + pBuf++; + } + + if (pBuf == n) return 0; + + *searchForward = pBuf; + return head_info2(&(buf[pBuf]),n,h,br); +} + +/*--------------------------------------------------------------*/ +int head_info2(unsigned char *buf, unsigned int n, MPEG_HEAD * h, int *br) +{ + int framebytes; + + /*--- return br (in bits/sec) in addition to frame bytes ---*/ + + *br = 0; + /*-- assume fail --*/ + framebytes = head_info(buf, n, h); + + if (framebytes == 0) + return 0; + + switch (h->option) + { + case 1: /* layer III */ + { + if (h->br_index > 0) + *br = 1000 * mp_br_tableL3[h->id][h->br_index]; + else + { + if (h->id) // mpeg1 + + *br = 1000 * framebytes * mp_sr20_table[h->id][h->sr_index] / (144 * 20); + else + { // mpeg2 + + if ((h->sync & 1) == 0) // flags mpeg25 + + *br = 500 * framebytes * mp_sr20_table[h->id][h->sr_index] / (72 * 20); + else + *br = 1000 * framebytes * mp_sr20_table[h->id][h->sr_index] / (72 * 20); + } + } + } + break; + + case 2: /* layer II */ + { + if (h->br_index > 0) + *br = 1000 * mp_br_table[h->id][h->br_index]; + else + *br = 1000 * framebytes * mp_sr20_table[h->id][h->sr_index] / (144 * 20); + } + break; + + case 3: /* layer I */ + { + if (h->br_index > 0) + *br = 1000 * mp_br_tableL1[h->id][h->br_index]; + else + *br = 1000 * framebytes * mp_sr20_table[h->id][h->sr_index] / (48 * 20); + } + break; + + default: + + return 0; // fuck knows what this is, but it ain't one of ours... + } + + + return framebytes; +} +/*--------------------------------------------------------------*/ +static int compare(unsigned char *buf, unsigned char *buf2) +{ + if (buf[0] != buf2[0]) + return 0; + if (buf[1] != buf2[1]) + return 0; + return 1; +} +/*----------------------------------------------------------*/ +/*-- does not scan for initial sync, initial sync assumed --*/ +static int find_sync(unsigned char *buf, int n) +{ + int i0, isync, nmatch, pad; + int padbytes, option; + +/* mod 4/12/95 i0 change from 72, allows as low as 8kbits for mpeg1 */ + i0 = 24; + padbytes = 1; + option = (buf[1] & 0x06) >> 1; + if (option == 3) + { + padbytes = 4; + i0 = 24; /* for shorter layer I frames */ + } + + pad = (buf[2] & 0x02) >> 1; + + n -= 3; /* need 3 bytes of header */ + + while (i0 < 2000) + { + isync = sync_scan(buf, n, i0); + i0 = isync + 1; + isync -= pad; + if (isync <= 0) + return 0; + nmatch = sync_test(buf, n, isync, padbytes); + if (nmatch > 0) + return isync; + } + + return 0; +} +/*------------------------------------------------------*/ +/*---- scan for next sync, assume start is valid -------*/ +/*---- return number bytes to next sync ----------------*/ +static int sync_scan(unsigned char *buf, int n, int i0) +{ + int i; + + for (i = i0; i < n; i++) + if (compare(buf, buf + i)) + return i; + + return 0; +} +/*------------------------------------------------------*/ +/*- test consecutative syncs, input isync without pad --*/ +static int sync_test(unsigned char *buf, int n, int isync, int padbytes) +{ + int i, nmatch, pad; + + nmatch = 0; + for (i = 0;;) + { + pad = padbytes * ((buf[i + 2] & 0x02) >> 1); + i += (pad + isync); + if (i > n) + break; + if (!compare(buf, buf + i)) + return -nmatch; + nmatch++; + } + return nmatch; +} diff --git a/src/client/mp3/mhead.h b/src/client/mp3/mhead.h new file mode 100644 index 0000000000..6ee9871d15 --- /dev/null +++ b/src/client/mp3/mhead.h @@ -0,0 +1,99 @@ +#ifndef MHEAD_H +#define MHEAD_H + + +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: mhead.h,v 1.3 1999/10/19 07:13:08 elrod Exp $ +____________________________________________________________________________*/ + +/* portable copy of eco\mhead.h */ +/* mpeg audio header */ +typedef struct +{ + int sync; /* 1 if valid sync */ + int id; + int option; + int prot; + int br_index; + int sr_index; + int pad; + int private_bit; + int mode; + int mode_ext; + int cr; + int original; + int emphasis; +} +MPEG_HEAD; + +/* portable mpeg audio decoder, decoder functions */ + +#ifndef IN_OUT +#include "small_header.h" +#endif + +typedef struct +{ + int channels; + int outvalues; + long samprate; + int bits; + int framebytes; + int type; +} +DEC_INFO; + + +#ifdef __cplusplus +extern "C" +{ +#endif + + int head_info(unsigned char *buf, unsigned int n, MPEG_HEAD * h); + int head_info2(unsigned char *buf, + unsigned int n, MPEG_HEAD * h, int *br); + int head_info3(unsigned char *buf, unsigned int n, MPEG_HEAD *h, int*br, unsigned int *searchForward); +/* head_info returns framebytes > 0 for success */ +/* audio_decode_init returns 1 for success, 0 for fail */ +/* audio_decode returns in_bytes = 0 on sync loss */ + + int audio_decode_init(MPEG_HEAD * h, int framebytes_arg, + int reduction_code, int transform_code, int convert_code, + int freq_limit); + void audio_decode_info(DEC_INFO * info); + IN_OUT audio_decode(unsigned char *bs, short *pcm, unsigned char *pNextByteAfterData); + + int audio_decode8_init(MPEG_HEAD * h, int framebytes_arg, + int reduction_code, int transform_code, int convert_code, + int freq_limit); + void audio_decode8_info(DEC_INFO * info); + IN_OUT audio_decode8(unsigned char *bs, short *pcmbuf); + + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef MHEAD_H diff --git a/src/client/mp3/mp3struct.h b/src/client/mp3/mp3struct.h new file mode 100644 index 0000000000..d958134804 --- /dev/null +++ b/src/client/mp3/mp3struct.h @@ -0,0 +1,145 @@ +// Filename: mp3struct.h +// +// this file is my struct to gather all loose MP3 global vars into one struct so we can do multiple-stream decompression +// + +#ifndef MP3STRUCT_H +#define MP3STRUCT_H + +#include "small_header.h" // for SAMPLE and IN_OUT +#include "q_shared.h" + +typedef void (*SBT_FUNCTION) (float *sample, short *pcm, int n); +typedef void (*XFORM_FUNCTION) (void *pcm, int igr); +typedef IN_OUT(*DECODE_FUNCTION) (unsigned char *bs, unsigned char *pcm); + +typedef struct +{ + union + { + struct + { + SBT_FUNCTION sbt; + + float cs_factor[3][64]; // 768 bytes + + int nbat[4]; + int bat[4][16]; + int max_sb; + int stereo_sb; + int bit_skip; + + float* cs_factorL1; + int nbatL1; + + };//L1_2; + + struct + { + SBT_FUNCTION sbt_L3; + XFORM_FUNCTION Xform; + DECODE_FUNCTION decode_function; + + SAMPLE sample[2][2][576]; // if this isn't kept per stream then the decode breaks up + + // the 4k version of these 2 seems to work for everything, but I'm reverting to original 8k for safety jic. + // + #define NBUF (8*1024) + #define BUF_TRIGGER (NBUF-1500) +// #define NBUF (4096) // 2048 works for all except 133+ kbps VBR files, 4096 copes with these +// #define BUF_TRIGGER ((NBUF/4)*3) + + unsigned char buf[NBUF]; + int buf_ptr0; + int buf_ptr1; + int main_pos_bit; + + + int band_limit_nsb; + int nBand[2][22]; /* [long/short][cb] */ + int sfBandIndex[2][22]; /* [long/short][cb] */ + int half_outbytes; + int crcbytes; + int nchan; + int ms_mode; + int is_mode; + unsigned int zero_level_pcm; + int mpeg25_flag; + int band_limit; + int band_limit21; + int band_limit12; + int gain_adjust; + int ncbl_mixed; + };//L3; + }; + // from csbt.c... + // + // if this isn't kept per stream then the decode breaks up + signed int vb_ptr; // + signed int vb2_ptr; // + float vbuf[512]; // + float vbuf2[512]; // this can be lost if we stick to mono samples + + // L3 only... + // + int sr_index; // L3 only (99%) + int id; + + // any type... + // + int outvalues; + int outbytes; + int framebytes; + int pad; + int nsb_limit; + + // stuff added now that the game uses streaming MP3s... + // + byte *pbSourceData; // a useful dup ptr only, this whole struct will be owned by an sfx_t struct that has the actual data ptr field + int iSourceBytesRemaining; + int iSourceReadIndex; + int iSourceFrameBytes; +#ifdef _DEBUG + int iSourceFrameCounter; // not really important +#endif + int iBytesDecodedTotal; + int iBytesDecodedThisPacket;// not sure how useful this will be, it's only per-frame, so will always be full frame size (eg 2304 or below for mono) except possibly for the last frame? + + int iRewind_FinalReductionCode; + int iRewind_FinalConvertCode; + int iRewind_SourceBytesRemaining; + int iRewind_SourceReadIndex; + byte bDecodeBuffer[2304*2]; // *2 to allow for stereo now + int iCopyOffset; // used for painting to DMA-feeder, since 2304 won't match the size it wants + + // some new stuff added for dynamic music, to allow "how many seconds left to play" queries... + // + // ( m_lengthInSeconds = ((iUnpackedDataLength / iRate) / iChannels) / iWidth; ) + // + // Note that these fields are only valid/initialised if MP3Stream_InitPlayingTimeFields() was called. + // If not, this->iTimeQuery_UnpackedLength will be zero. + // + int iTimeQuery_UnpackedLength; + int iTimeQuery_SampleRate; + int iTimeQuery_Channels; + int iTimeQuery_Width; + +} MP3STREAM, *LP_MP3STREAM; + + +// Function declarations +char *C_MP3_IsValid(void *pvData, int iDataLen, int bStereoDesired); +char* C_MP3_GetHeaderData(void *pvData, int iDataLen, int *piRate, int *piWidth, int *piChannels, int bStereoDesired); +char *C_MP3_GetUnpackedSize(void *pvData, int iSourceBytesRemaining, int *piUnpackedSize, int bStereoDesired); +char *C_MP3_UnpackRawPCM(void *pvData, int iSourceBytesRemaining, int *piUnpackedSize, void *pbUnpackBuffer, int bStereoDesired); +char *C_MP3Stream_DecodeInit(LP_MP3STREAM pSFX_MP3Stream, void *pvSourceData, int iSourceBytesRemaining, int iGameAudioSampleRate, int iGameAudioSampleBits, int bStereoDesired); +unsigned int C_MP3Stream_Decode(LP_MP3STREAM pSFX_MP3Stream); +char *C_MP3Stream_Rewind(LP_MP3STREAM pSFX_MP3Stream); + +extern LP_MP3STREAM pMP3Stream; +extern int bFastEstimateOnly; + +#endif // #ifndef MP3STRUCT_H + +////////////////// eof ///////////////////// + diff --git a/src/client/mp3/msis.c b/src/client/mp3/msis.c new file mode 100644 index 0000000000..01df7feec0 --- /dev/null +++ b/src/client/mp3/msis.c @@ -0,0 +1,296 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: msis.c,v 1.4 1999/10/19 07:13:09 elrod Exp $ +____________________________________________________________________________*/ + +/**** msis.c *************************************************** + Layer III + antialias, ms and is stereo precessing + +**** is_process assumes never switch + from short to long in is region ***** + +is_process does ms or stereo in "forbidded sf regions" + //ms_mode = 0 + lr[0][i][0] = 1.0f; + lr[0][i][1] = 0.0f; + // ms_mode = 1, in is bands is routine does ms processing + lr[1][i][0] = 1.0f; + lr[1][i][1] = 1.0f; + +******************************************************************/ + +#include +#include +#include +#include +#include "l3.h" + +#include "mp3struct.h" + +typedef float ARRAY2[2]; +typedef float ARRAY8_2[8][2]; + +float csa[8][2]; /* antialias */ // effectively constant + +/* pMP3Stream->nBand[0] = long, pMP3Stream->nBand[1] = short */ +////@@@@extern int pMP3Stream->nBand[2][22]; +////@@@@extern int pMP3Stream->sfBandIndex[2][22]; /* [long/short][cb] */ + +/* intensity stereo */ +/* if ms mode quant pre-scales all values by 1.0/sqrt(2.0) ms_mode in table + compensates */ +static float lr[2][8][2]; /* [ms_mode 0/1][sf][left/right] */ // effectively constant + + +/* intensity stereo MPEG2 */ +/* lr2[intensity_scale][ms_mode][sflen_offset+sf][left/right] */ +typedef float ARRAY2_64_2[2][64][2]; +typedef float ARRAY64_2[64][2]; +static float lr2[2][2][64][2]; // effectively constant + + +/*===============================================================*/ +ARRAY2 *alias_init_addr() +{ + return csa; +} +/*-----------------------------------------------------------*/ +ARRAY8_2 *msis_init_addr() +{ +/*------- +pi = 4.0*atan(1.0); +t = pi/12.0; +for(i=0;i<7;i++) { + s = sin(i*t); + c = cos(i*t); + // ms_mode = 0 + lr[0][i][0] = (float)(s/(s+c)); + lr[0][i][1] = (float)(c/(s+c)); + // ms_mode = 1 + lr[1][i][0] = (float)(sqrt(2.0)*(s/(s+c))); + lr[1][i][1] = (float)(sqrt(2.0)*(c/(s+c))); +} +//sf = 7 +//ms_mode = 0 +lr[0][i][0] = 1.0f; +lr[0][i][1] = 0.0f; +// ms_mode = 1, in is bands is routine does ms processing +lr[1][i][0] = 1.0f; +lr[1][i][1] = 1.0f; +------------*/ + + return lr; +} +/*-------------------------------------------------------------*/ +ARRAY2_64_2 *msis_init_addr_MPEG2() +{ + return lr2; +} +/*===============================================================*/ +void antialias(float x[], int n) +{ + int i, k; + float a, b; + + for (k = 0; k < n; k++) + { + for (i = 0; i < 8; i++) + { + a = x[17 - i]; + b = x[18 + i]; + x[17 - i] = a * csa[i][0] - b * csa[i][1]; + x[18 + i] = b * csa[i][0] + a * csa[i][1]; + } + x += 18; + } +} +/*===============================================================*/ +void ms_process(float x[][1152], int n) /* sum-difference stereo */ +{ + int i; + float xl, xr; + +/*-- note: sqrt(2) done scaling by dequant ---*/ + for (i = 0; i < n; i++) + { + xl = x[0][i] + x[1][i]; + xr = x[0][i] - x[1][i]; + x[0][i] = xl; + x[1][i] = xr; + } + return; +} +/*===============================================================*/ +void is_process_MPEG1(float x[][1152], /* intensity stereo */ + SCALEFACT * sf, + CB_INFO cb_info[2], /* [ch] */ + int nsamp, int ms_mode) +{ + int i, j, n, cb, w; + float fl, fr; + int m; + int isf; + float fls[3], frs[3]; + int cb0; + + + cb0 = cb_info[1].cbmax; /* start at end of right */ + i = pMP3Stream->sfBandIndex[cb_info[1].cbtype][cb0]; + cb0++; + m = nsamp - i; /* process to len of left */ + + if (cb_info[1].cbtype) + goto short_blocks; +/*------------------------*/ +/* long_blocks: */ + for (cb = cb0; cb < 21; cb++) + { + isf = sf->l[cb]; + n = pMP3Stream->nBand[0][cb]; + fl = lr[ms_mode][isf][0]; + fr = lr[ms_mode][isf][1]; + for (j = 0; j < n; j++, i++) + { + if (--m < 0) + goto exit; + x[1][i] = fr * x[0][i]; + x[0][i] = fl * x[0][i]; + } + } + return; +/*------------------------*/ + short_blocks: + for (cb = cb0; cb < 12; cb++) + { + for (w = 0; w < 3; w++) + { + isf = sf->s[w][cb]; + fls[w] = lr[ms_mode][isf][0]; + frs[w] = lr[ms_mode][isf][1]; + } + n = pMP3Stream->nBand[1][cb]; + for (j = 0; j < n; j++) + { + m -= 3; + if (m < 0) + goto exit; + x[1][i] = frs[0] * x[0][i]; + x[0][i] = fls[0] * x[0][i]; + x[1][1 + i] = frs[1] * x[0][1 + i]; + x[0][1 + i] = fls[1] * x[0][1 + i]; + x[1][2 + i] = frs[2] * x[0][2 + i]; + x[0][2 + i] = fls[2] * x[0][2 + i]; + i += 3; + } + } + + exit: + return; +} +/*===============================================================*/ +void is_process_MPEG2(float x[][1152], /* intensity stereo */ + SCALEFACT * sf, + CB_INFO cb_info[2], /* [ch] */ + IS_SF_INFO * is_sf_info, + int nsamp, int ms_mode) +{ + int i, j, k, n, cb, w; + float fl, fr; + int m; + int isf; + int il[21]; + int tmp; + int r; + ARRAY2 *lr_ptr; + int cb0, cb1; + + lr_ptr = lr2[is_sf_info->intensity_scale][ms_mode]; + + if (cb_info[1].cbtype) + goto short_blocks; + +/*------------------------*/ +/* long_blocks: */ + cb0 = cb_info[1].cbmax; /* start at end of right */ + i = pMP3Stream->sfBandIndex[0][cb0]; + m = nsamp - i; /* process to len of left */ +/* gen sf info */ + for (k = r = 0; r < 3; r++) + { + tmp = (1 << is_sf_info->slen[r]) - 1; + for (j = 0; j < is_sf_info->nr[r]; j++, k++) + il[k] = tmp; + } + for (cb = cb0 + 1; cb < 21; cb++) + { + isf = il[cb] + sf->l[cb]; + fl = lr_ptr[isf][0]; + fr = lr_ptr[isf][1]; + n = pMP3Stream->nBand[0][cb]; + for (j = 0; j < n; j++, i++) + { + if (--m < 0) + goto exit; + x[1][i] = fr * x[0][i]; + x[0][i] = fl * x[0][i]; + } + } + return; +/*------------------------*/ + short_blocks: + + for (k = r = 0; r < 3; r++) + { + tmp = (1 << is_sf_info->slen[r]) - 1; + for (j = 0; j < is_sf_info->nr[r]; j++, k++) + il[k] = tmp; + } + + for (w = 0; w < 3; w++) + { + cb0 = cb_info[1].cbmax_s[w]; /* start at end of right */ + i = pMP3Stream->sfBandIndex[1][cb0] + w; + cb1 = cb_info[0].cbmax_s[w]; /* process to end of left */ + + for (cb = cb0 + 1; cb <= cb1; cb++) + { + isf = il[cb] + sf->s[w][cb]; + fl = lr_ptr[isf][0]; + fr = lr_ptr[isf][1]; + n = pMP3Stream->nBand[1][cb]; + for (j = 0; j < n; j++) + { + x[1][i] = fr * x[0][i]; + x[0][i] = fl * x[0][i]; + i += 3; + } + } + + } + + exit: + return; +} +/*===============================================================*/ diff --git a/src/client/mp3/port.h b/src/client/mp3/port.h new file mode 100644 index 0000000000..da9babd055 --- /dev/null +++ b/src/client/mp3/port.h @@ -0,0 +1,84 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: port.h,v 1.2 1999/10/19 07:13:08 elrod Exp $ +____________________________________________________________________________*/ + +#ifndef O_BINARY +#define O_BINARY 0 +#endif + + +/*--- no kb function unless DOS ---*/ + +#ifndef KB_OK +#ifdef __MSDOS__ +#define KB_OK +#endif +#ifdef _CONSOLE +#define KB_OK +#endif +#endif + +/*-- no pcm conversion to wave required + if short = 16 bits and little endian ---*/ + +/* mods 1/9/97 LITTLE_SHORT16 detect */ + +#ifndef LITTLE_SHORT16 + #ifdef __MSDOS__ + #undef LITTLE_SHORT16 + #define LITTLE_SHORT16 + #endif + #ifdef WIN32 + #undef LITTLE_SHORT16 + #define LITTLE_SHORT16 + #endif + #ifdef _M_IX86 + #undef LITTLE_SHORT16 + #define LITTLE_SHORT16 + #endif + #ifdef __i386__ + #undef LITTLE_SHORT16 + #define LITTLE_SHORT16 + #endif +#endif + + +// JDW // +//#ifdef LITTLE_SHORT16 +//#define cvt_to_wave_init(a) +//#define cvt_to_wave(a, b) b +//#else +//void cvt_to_wave_init(int bits); +//unsigned int cvt_to_wave(void *a, unsigned int b); +// +//#endif +#ifdef LITTLE_SHORT16 +#define cvt_to_wave_init(a) +#define cvt_to_wave(a, b) b +#else +void cvt_to_wave_init(int); +unsigned int cvt_to_wave(unsigned char *,unsigned int); +#endif + diff --git a/src/client/mp3/small_header.h b/src/client/mp3/small_header.h new file mode 100644 index 0000000000..044942cdea --- /dev/null +++ b/src/client/mp3/small_header.h @@ -0,0 +1,34 @@ +// Filename:- small_header.h +// +// This file is just used so I can isolate a few small structs from various horrible MP3 header files without +// externalising code protos etc. This can now be included by both main game sound code (through sfx_t) and MP3 C code. +// + +#ifndef SMALL_HEADER_H +#define SMALL_HEADER_H + + +typedef union +{ + int s; + float x; +} +SAMPLE; + +typedef struct +{ + int in_bytes; + int out_bytes; +} +IN_OUT; + +#ifdef WIN32 // Damn linux gcc isn't detecting byte as defined +#ifndef byte +typedef unsigned char byte; +#endif +#endif + +#endif // #ifndef SMALL_HEADER_H + +/////////////// eof //////////// + diff --git a/src/client/mp3/tableawd.h b/src/client/mp3/tableawd.h new file mode 100644 index 0000000000..9b7fc7ca2f --- /dev/null +++ b/src/client/mp3/tableawd.h @@ -0,0 +1,93 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: tableawd.h,v 1.2 1999/10/19 07:13:08 elrod Exp $ +____________________________________________________________________________*/ + +/* decoder analysis window gen by dinit.c (asm version table gen) */ +0.000000000f, 0.000442505f, -0.003250122f, 0.007003784f, +-0.031082151f, 0.078628540f, -0.100311279f, 0.572036743f, +-1.144989014f, -0.572036743f, -0.100311279f, -0.078628540f, +-0.031082151f, -0.007003784f, -0.003250122f, -0.000442505f, +0.000015259f, 0.000473022f, -0.003326416f, 0.007919312f, +-0.030517576f, 0.084182739f, -0.090927124f, 0.600219727f, +-1.144287109f, -0.543823242f, -0.108856201f, -0.073059082f, +-0.031478882f, -0.006118774f, -0.003173828f, -0.000396729f, +0.000015259f, 0.000534058f, -0.003387451f, 0.008865356f, +-0.029785154f, 0.089706421f, -0.080688477f, 0.628295898f, +-1.142211914f, -0.515609741f, -0.116577141f, -0.067520142f, +-0.031738281f, -0.005294800f, -0.003082275f, -0.000366211f, +0.000015259f, 0.000579834f, -0.003433228f, 0.009841919f, +-0.028884888f, 0.095169067f, -0.069595337f, 0.656219482f, +-1.138763428f, -0.487472534f, -0.123474121f, -0.061996460f, +-0.031845093f, -0.004486084f, -0.002990723f, -0.000320435f, +0.000015259f, 0.000625610f, -0.003463745f, 0.010848999f, +-0.027801514f, 0.100540161f, -0.057617184f, 0.683914185f, +-1.133926392f, -0.459472656f, -0.129577637f, -0.056533810f, +-0.031814575f, -0.003723145f, -0.002899170f, -0.000289917f, +0.000015259f, 0.000686646f, -0.003479004f, 0.011886597f, +-0.026535034f, 0.105819702f, -0.044784546f, 0.711318970f, +-1.127746582f, -0.431655884f, -0.134887695f, -0.051132202f, +-0.031661987f, -0.003005981f, -0.002792358f, -0.000259399f, +0.000015259f, 0.000747681f, -0.003479004f, 0.012939452f, +-0.025085449f, 0.110946655f, -0.031082151f, 0.738372803f, +-1.120223999f, -0.404083252f, -0.139450073f, -0.045837402f, +-0.031387329f, -0.002334595f, -0.002685547f, -0.000244141f, +0.000030518f, 0.000808716f, -0.003463745f, 0.014022826f, +-0.023422241f, 0.115921021f, -0.016510010f, 0.765029907f, +-1.111373901f, -0.376800537f, -0.143264771f, -0.040634155f, +-0.031005858f, -0.001693726f, -0.002578735f, -0.000213623f, +0.000030518f, 0.000885010f, -0.003417969f, 0.015121460f, +-0.021575928f, 0.120697014f, -0.001068115f, 0.791213989f, +-1.101211548f, -0.349868774f, -0.146362305f, -0.035552979f, +-0.030532837f, -0.001098633f, -0.002456665f, -0.000198364f, +0.000030518f, 0.000961304f, -0.003372192f, 0.016235352f, +-0.019531250f, 0.125259399f, 0.015228271f, 0.816864014f, +-1.089782715f, -0.323318481f, -0.148773193f, -0.030609131f, +-0.029937742f, -0.000549316f, -0.002349854f, -0.000167847f, +0.000030518f, 0.001037598f, -0.003280640f, 0.017349243f, +-0.017257690f, 0.129562378f, 0.032379150f, 0.841949463f, +-1.077117920f, -0.297210693f, -0.150497437f, -0.025817871f, +-0.029281614f, -0.000030518f, -0.002243042f, -0.000152588f, +0.000045776f, 0.001113892f, -0.003173828f, 0.018463135f, +-0.014801024f, 0.133590698f, 0.050354004f, 0.866363525f, +-1.063217163f, -0.271591187f, -0.151596069f, -0.021179199f, +-0.028533936f, 0.000442505f, -0.002120972f, -0.000137329f, +0.000045776f, 0.001205444f, -0.003051758f, 0.019577026f, +-0.012115479f, 0.137298584f, 0.069168091f, 0.890090942f, +-1.048156738f, -0.246505737f, -0.152069092f, -0.016708374f, +-0.027725220f, 0.000869751f, -0.002014160f, -0.000122070f, +0.000061035f, 0.001296997f, -0.002883911f, 0.020690918f, +-0.009231566f, 0.140670776f, 0.088775635f, 0.913055420f, +-1.031936646f, -0.221984863f, -0.151962280f, -0.012420653f, +-0.026840210f, 0.001266479f, -0.001907349f, -0.000106812f, +0.000061035f, 0.001388550f, -0.002700806f, 0.021789551f, +-0.006134033f, 0.143676758f, 0.109161377f, 0.935195923f, +-1.014617920f, -0.198059082f, -0.151306152f, -0.008316040f, +-0.025909424f, 0.001617432f, -0.001785278f, -0.000106812f, +0.000076294f, 0.001480103f, -0.002487183f, 0.022857666f, +-0.002822876f, 0.146255493f, 0.130310059f, 0.956481934f, +-0.996246338f, -0.174789429f, -0.150115967f, -0.004394531f, +-0.024932859f, 0.001937866f, -0.001693726f, -0.000091553f, +-0.001586914f, -0.023910521f, -0.148422241f, -0.976852417f, +0.152206421f, 0.000686646f, -0.002227783f, 0.000076294f, diff --git a/src/client/mp3/towave.c b/src/client/mp3/towave.c new file mode 100644 index 0000000000..ed83c13399 --- /dev/null +++ b/src/client/mp3/towave.c @@ -0,0 +1,756 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: towave.c,v 1.3 1999/10/19 07:13:09 elrod Exp $ +____________________________________________________________________________*/ + +/* ------------------------------------------------------------------------ + + NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE + + This file exists for reference only. It is not actually used + in the FreeAmp project. There is no need to mess with this + file. There is no need to flatten the beavers, either. + + NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE + +/*---- towave.c --------------------------------------------*/ +/* + 32 bit version only + +decode mpeg Layer I/II/III file using portable ANSI C decoder, +output to pcm wave file. + +mod 8/19/98 decode 22 sf bands + +mod 5/14/98 allow mpeg25 (dec8 not supported for mpeg25 samp rate) + +mod 3/4/98 bs_trigger bs_bufbytes made signed, unsigned may + not terminate properly. Also extra test in bs_fill. + +mod 8/6/96 add 8 bit output to standard decoder + +ver 1.4 mods 7/18/96 32 bit and add asm option + +mods 6/29/95 allow MS wave file for u-law. bugfix u-law table dec8.c + +mods 2/95 add sample rate reduction, freq_limit and conversions. + add _decode8 for 8Ks output, 16bit 8bit, u-law output. + add additional control parameters to init. + add _info function + +mod 5/12/95 add quick window cwinq.c + +mod 5/19/95 change from stream io to handle io + +mod 11/16/95 add Layer I + +mod 1/5/95 integer overflow mod iup.c + +ver 1.3 +mod 2/5/96 portability mods + drop Tom and Gloria pcm file types + +ver 2.0 +mod 1/7/97 Layer 3 (float mpeg-1 only) + 2/6/97 Layer 3 MPEG-2 + +ver 3.01 Layer III bugfix crc problem 8/18/97 +ver 3.02 Layer III fix wannabe.mp3 problem 10/9/97 +ver 3.03 allow mpeg 2.5 5/14/98 + +Decoder functions for _decode8 are defined in dec8.c. Useage +is same as regular decoder. + +Towave illustrates use of decoder. Towave converts +mpeg audio files to 16 bit (short) pcm. Default pcm file +format is wave. Other formats can be accommodated by +adding alternative write_pcm_header and write_pcm_tailer +functions. The functions kbhit and getch used in towave.c +may not port to other systems. + +The decoder handles all mpeg1 and mpeg2 Layer I/II bitstreams. + +For compatability with the asm decoder and future C versions, +source code users are discouraged from making modifications +to the decoder proper. MS Windows applications can use wrapper +functions in a separate module if decoder functions need to +be exported. + +NOTE additional control parameters. + +mod 8/6/96 standard decoder adds 8 bit output + +decode8 (8Ks output) convert_code: + convert_code = 4*bit_code + chan_code + bit_code: 1 = 16 bit linear pcm + 2 = 8 bit (unsigned) linear pcm + 3 = u-law (8 bits unsigned) + chan_code: 0 = convert two chan to mono + 1 = convert two chan to mono + 2 = convert two chan to left chan + 3 = convert two chan to right chan + +decode (standard decoder) convert_code: + 0 = two chan output + 1 = convert two chan to mono + 2 = convert two chan to left chan + 3 = convert two chan to right chan + or with 8 = 8 bit output + (other bits ignored) + +decode (standard decoder) reduction_code: + 0 = full sample rate output + 1 = half rate + 2 = quarter rate + +-----------------------------------------------------------*/ +#include +#include +#include +#include +#include +#ifdef WIN32 +#include +#endif +#include /* file open flags */ +#include /* someone wants for port */ +#include /* forward slash for portability */ +#include "mhead.h" /* mpeg header structure, decode protos */ + +#include "port.h" + +// JDW +#ifdef __linux__ +#include +#include +#include +#include +#endif +// JDW + +#include "mp3struct.h" +#include + + +#if !defined(MACOS_X) && !defined(byte) && !defined (__linux__) +typedef unsigned char byte; +#endif + + + +typedef struct id3v1_1 { + char id[3]; + char title[30]; // + char artist[30]; // "Raven Software" + char album[30]; // "#UNCOMP %d" // needed + char year[4]; // "2000" + char comment[28]; // "#MAXVOL %g" // needed + char zero; + char track; + char genre; +} id3v1_1; // 128 bytes in size + +id3v1_1 *gpTAG; +#define BYTESREMAINING_ACCOUNT_FOR_REAR_TAG(_pvData, _iBytesRemaining) \ + \ + /* account for trailing ID3 tag in _iBytesRemaining */ \ + gpTAG = (id3v1_1*) (((byte *)_pvData + _iBytesRemaining)-sizeof(id3v1_1)); /* sizeof = 128 */ \ + if (!strncmp(gpTAG->id, "TAG", (size_t)3)) \ + { \ + _iBytesRemaining -= sizeof(id3v1_1); \ + } + + + + + +/******** pcm buffer ********/ + +#define PCM_BUFBYTES 60000U // more than enough to cover the largest that one packet will ever expand to +char PCM_Buffer[PCM_BUFBYTES]; // better off being declared, so we don't do mallocs in this module (MAC reasons) + + typedef struct + { + int (*decode_init) (MPEG_HEAD * h, int framebytes_arg, + int reduction_code, int transform_code, + int convert_code, int freq_limit); + void (*decode_info) (DEC_INFO * info); + IN_OUT(*decode) (unsigned char *bs, short *pcm, unsigned char *pNextByteAfterData); + } + AUDIO; + +#if 0 + // stuff this... + static AUDIO audio_table[2][2] = + { + { + {audio_decode_init, audio_decode_info, audio_decode}, + {audio_decode8_init, audio_decode8_info, audio_decode8}, + }, + { + {i_audio_decode_init, i_audio_decode_info, i_audio_decode}, + {audio_decode8_init, audio_decode8_info, audio_decode8}, + } + }; + static AUDIO audio_table[2][2] = + { + { + {audio_decode_init, audio_decode_info, audio_decode}, + {audio_decode_init, audio_decode_info, audio_decode}, + }, + { + {audio_decode_init, audio_decode_info, audio_decode}, + {audio_decode_init, audio_decode_info, audio_decode}, + } + }; +#endif + + static const AUDIO audio = {audio_decode_init, audio_decode_info, audio_decode}; //audio_table[0][0]; + + +// Do NOT change these, ever!!!!!!!!!!!!!!!!!! +// +const int reduction_code = 0; // unpack at full sample rate output +const int convert_code_mono = 1; +const int convert_code_stereo = 0; +const int freq_limit = 24000; // no idea what this is about, but it's always this value so... + +// the entire decode mechanism uses this now... +// +MP3STREAM _MP3Stream; +LP_MP3STREAM pMP3Stream = &_MP3Stream; +int bFastEstimateOnly = 0; // MUST DEFAULT TO THIS VALUE!!!!!!!!! + + +// char *return is NZ for any errors (no trailing CR!) +// +char *C_MP3_IsValid(void *pvData, int iDataLen, int bStereoDesired) +{ +// char sTemp[1024]; ///////////////////////////////////////////////// + unsigned int iRealDataStart; + MPEG_HEAD head; + DEC_INFO decinfo; + + int iBitRate; + int iFrameBytes; + +//#ifdef _DEBUG +// int iIgnoreThisForNowIJustNeedItToBreakpointOnToReadAValue = sizeof(MP3STREAM); +//#endif + + memset(pMP3Stream,0,sizeof(*pMP3Stream)); + + iFrameBytes = head_info3( pvData, iDataLen/2, &head, &iBitRate, &iRealDataStart); + if (iFrameBytes == 0) + { + return "MP3ERR: Bad or unsupported file!"; + } + + // check for files with bad frame unpack sizes (that would crash the game), or stereo files. + // + // although the decoder can convert stereo to mono (apparently), we want to know about stereo files + // because they're a waste of source space... (all FX are mono, and moved via panning) + // + if (head.mode != 3 && !bStereoDesired) //3 seems to mean mono + { + if (iDataLen > 98000) { // we'll allow it for small files even if stereo + return "MP3ERR: Sound file is stereo!"; + } + } + if (audio.decode_init(&head, iFrameBytes, reduction_code, iRealDataStart, bStereoDesired?convert_code_stereo:convert_code_mono, freq_limit)) + { + if (bStereoDesired) + { + if (pMP3Stream->outbytes > 4608) + { + return "MP3ERR: Source file has output packet size > 2304 (*2 for stereo) bytes!"; + } + } + else + { + if (pMP3Stream->outbytes > 2304) + { + return "MP3ERR: Source file has output packet size > 2304 bytes!"; + } + } + + audio.decode_info(&decinfo); + + if (decinfo.bits != 16) + { + return "MP3ERR: Source file is not 16bit!"; // will this ever happen? oh well... + } + + if (decinfo.samprate != 44100) + { + return "MP3ERR: Source file is not sampled @ 44100!"; + } + + if (bStereoDesired && decinfo.channels != 2) + { + return "MP3ERR: Source file is not stereo!"; // sod it, I'm going to count this as an error now + } + } + else + { + return "MP3ERR: Decoder failed to initialise"; + } + + // file seems to be valid... + // + return NULL; +} + + + +// char *return is NZ for any errors (no trailing CR!) +// +char* C_MP3_GetHeaderData(void *pvData, int iDataLen, int *piRate, int *piWidth, int *piChannels, int bStereoDesired) +{ + unsigned int iRealDataStart; + MPEG_HEAD head; + DEC_INFO decinfo; + + int iBitRate; + int iFrameBytes; + + memset(pMP3Stream,0,sizeof(*pMP3Stream)); + + iFrameBytes = head_info3( pvData, iDataLen/2, &head, &iBitRate, &iRealDataStart); + if (iFrameBytes == 0) + { + return "MP3ERR: Bad or unsupported file!"; + } + + if (audio.decode_init(&head, iFrameBytes, reduction_code, iRealDataStart, bStereoDesired?convert_code_stereo:convert_code_mono, freq_limit)) + { + audio.decode_info(&decinfo); + + *piRate = decinfo.samprate; // rate (eg 22050, 44100 etc) + *piWidth = decinfo.bits/8; // 1 for 8bit, 2 for 16 bit + *piChannels = decinfo.channels; // 1 for mono, 2 for stereo + } + else + { + return "MP3ERR: Decoder failed to initialise"; + } + + // everything ok... + // + return NULL; +} + + + + +// this duplicates work done in C_MP3_IsValid(), but it avoids global structs, and means that you can call this anytime +// if you just want info for some reason +// +// ( size is now workd out just by decompressing each packet header, not the whole stream. MUCH faster :-) +// +// char *return is NZ for any errors (no trailing CR!) +// +char *C_MP3_GetUnpackedSize(void *pvData, int iSourceBytesRemaining, int *piUnpackedSize, int bStereoDesired ) +{ + int iReadLimit; + unsigned int iRealDataStart; + MPEG_HEAD head; + int iBitRate; + + char *pPCM_Buffer = PCM_Buffer; + char *psReturn = NULL; +// int iSourceReadIndex = 0; + int iDestWriteIndex = 0; + + int iFrameBytes; + int iFrameCounter; + + DEC_INFO decinfo; + IN_OUT x; + + memset(pMP3Stream,0,sizeof(*pMP3Stream)); + +#define iSourceReadIndex iRealDataStart + +// iFrameBytes = head_info2( pvData, 0, &head, &iBitRate); + iFrameBytes = head_info3( pvData, iSourceBytesRemaining/2, &head, &iBitRate, &iRealDataStart); + + BYTESREMAINING_ACCOUNT_FOR_REAR_TAG(pvData, iSourceBytesRemaining) + iSourceBytesRemaining -= iRealDataStart; + + iReadLimit = iSourceReadIndex + iSourceBytesRemaining; + + if (iFrameBytes) + { + //pPCM_Buffer = malloc(PCM_BUFBYTES); + + //if (pPCM_Buffer) + { + // init decoder... + + if (audio.decode_init(&head, iFrameBytes, reduction_code, iRealDataStart, bStereoDesired?convert_code_stereo:convert_code_mono, freq_limit)) + { + audio.decode_info(&decinfo); + + // decode... + // + for (iFrameCounter = 0;;iFrameCounter++) + { + if ( iSourceBytesRemaining == 0 || iSourceBytesRemaining < iFrameBytes) + break; // end of file + + bFastEstimateOnly = 1; /////////////////////////////// + + x = audio.decode((unsigned char *)pvData + iSourceReadIndex, (short *) ((char *)pPCM_Buffer + //+ iDestWriteIndex // keep decoding over the same spot since we're only counting bytes in this function + ), + (unsigned char *)pvData + iReadLimit + ); + + bFastEstimateOnly = 0; /////////////////////////////// + + iSourceReadIndex += x.in_bytes; + iSourceBytesRemaining -= x.in_bytes; + iDestWriteIndex += x.out_bytes; + + if (x.in_bytes <= 0) + { + //psReturn = "MP3ERR: Bad sync in file"; + break; + } + } + + *piUnpackedSize = iDestWriteIndex; // yeeehaaa! + } + else + { + psReturn = "MP3ERR: Decoder failed to initialise"; + } + } +// else +// { +// psReturn = "MP3ERR: Unable to alloc temp decomp buffer"; +// } + } + else + { + psReturn = "MP3ERR: Bad or Unsupported MP3 file!"; + } + + +// if (pPCM_Buffer) +// { +// free(pPCM_Buffer); +// pPCM_Buffer = NULL; // I know, I know... +// } + + return psReturn; + +#undef iSourceReadIndex +} + + + + +char *C_MP3_UnpackRawPCM( void *pvData, int iSourceBytesRemaining, int *piUnpackedSize, void *pbUnpackBuffer, int bStereoDesired) +{ + int iReadLimit; + unsigned int iRealDataStart; + MPEG_HEAD head; + int iBitRate; + + char *psReturn = NULL; +// int iSourceReadIndex = 0; + int iDestWriteIndex = 0; + + int iFrameBytes; + int iFrameCounter; + + DEC_INFO decinfo; + IN_OUT x; + + memset(pMP3Stream,0,sizeof(*pMP3Stream)); + +#define iSourceReadIndex iRealDataStart + +// iFrameBytes = head_info2( pvData, 0, &head, &iBitRate); + iFrameBytes = head_info3( pvData, iSourceBytesRemaining/2, &head, &iBitRate, &iRealDataStart); + + BYTESREMAINING_ACCOUNT_FOR_REAR_TAG(pvData, iSourceBytesRemaining) + iSourceBytesRemaining -= iRealDataStart; + + iReadLimit = iSourceReadIndex + iSourceBytesRemaining; + + if (iFrameBytes) + { +// if (1)////////////////////////pPCM_Buffer) + { + // init decoder... + + if (audio.decode_init(&head, iFrameBytes, reduction_code, iRealDataStart, bStereoDesired?convert_code_stereo:convert_code_mono, freq_limit)) + { + audio.decode_info(&decinfo); + +// printf("\n output samprate = %6ld",decinfo.samprate); +// printf("\n output channels = %6d", decinfo.channels); +// printf("\n output bits = %6d", decinfo.bits); +// printf("\n output type = %6d", decinfo.type); + +//=============== + + // decode... + // + for (iFrameCounter = 0;;iFrameCounter++) + { + if ( iSourceBytesRemaining == 0 || iSourceBytesRemaining < iFrameBytes) + break; // end of file + + x = audio.decode((unsigned char *)pvData + iSourceReadIndex, (short *) ((char *)pbUnpackBuffer + iDestWriteIndex), + (unsigned char *)pvData + iReadLimit + ); + + iSourceReadIndex += x.in_bytes; + iSourceBytesRemaining -= x.in_bytes; + iDestWriteIndex += x.out_bytes; + + if (x.in_bytes <= 0) + { + //psReturn = "MP3ERR: Bad sync in file"; + break; + } + } + + *piUnpackedSize = iDestWriteIndex; // yeeehaaa! + } + else + { + psReturn = "MP3ERR: Decoder failed to initialise"; + } + } + } + else + { + psReturn = "MP3ERR: Bad or Unsupported MP3 file!"; + } + + return psReturn; + +#undef iSourceReadIndex +} + + +// called once, after we've decided to keep something as MP3. This just sets up the decoder for subsequent stream-calls. +// +// (the struct pSFX_MP3Stream is cleared internally, so pass as args anything you want stored in it) +// +// char * return is NULL for ok, else error string +// +// NEW CODE NOTE: Now that this function is being called for raw data that's going to be runtime-stored in a link-list +// chunk format for SOF2 instead of just one alloc then you must re-init pMP3Stream->pbSourceData after you've called +// this, or it'll be pointing at the deallocated original raw data, not the first chunk of the link list +// +char *C_MP3Stream_DecodeInit( LP_MP3STREAM pSFX_MP3Stream, void *pvSourceData, int iSourceBytesRemaining, + int iGameAudioSampleRate, int iGameAudioSampleBits, int bStereoDesired ) +{ + char *psReturn = NULL; + MPEG_HEAD head; // only relevant within this function during init + DEC_INFO decinfo; // " " + int iBitRate; // not used after being filled in by head_info3() + + pMP3Stream = pSFX_MP3Stream; + + memset(pMP3Stream,0,sizeof(*pMP3Stream)); + + pMP3Stream->pbSourceData = (byte *) pvSourceData; // this MUST be re-initialised to link-mem outside here for SOF2, since raw data is now link-listed + pMP3Stream->iSourceBytesRemaining = iSourceBytesRemaining; + pMP3Stream->iSourceFrameBytes = head_info3( (byte *) pvSourceData, iSourceBytesRemaining/2, &head, &iBitRate, (unsigned int*)&pMP3Stream->iSourceReadIndex ); + + // hack, do NOT do this for stereo, since music files are now streamed and therefore the data isn't actually fully + // loaded at this point, only about 4k or so for the header is actually in memory!!!... + // + if (!bStereoDesired) + { + BYTESREMAINING_ACCOUNT_FOR_REAR_TAG(pvSourceData, pMP3Stream->iSourceBytesRemaining); + pMP3Stream->iSourceBytesRemaining -= pMP3Stream->iSourceReadIndex; + } + + // backup a couple of fields so we can play this again later... + // + pMP3Stream->iRewind_SourceReadIndex = pMP3Stream->iSourceReadIndex; + pMP3Stream->iRewind_SourceBytesRemaining= pMP3Stream->iSourceBytesRemaining; + + assert(pMP3Stream->iSourceFrameBytes); + if (pMP3Stream->iSourceFrameBytes) + { + if (audio.decode_init(&head, pMP3Stream->iSourceFrameBytes, reduction_code, pMP3Stream->iSourceReadIndex, bStereoDesired?convert_code_stereo:convert_code_mono, freq_limit)) + { + pMP3Stream->iRewind_FinalReductionCode = reduction_code; // default = 0 (no reduction), 1=half, 2 = quarter + + pMP3Stream->iRewind_FinalConvertCode = bStereoDesired?convert_code_stereo:convert_code_mono; + // default = 1 (mono), OR with 8 for 8-bit output + + // only now can we ask what kind of properties this file has, and then adjust to fit what the game wants... + // + audio.decode_info(&decinfo); + +// printf("\n output samprate = %6ld",decinfo.samprate); +// printf("\n output channels = %6d", decinfo.channels); +// printf("\n output bits = %6d", decinfo.bits); +// printf("\n output type = %6d", decinfo.type); + + // decoder offers half or quarter rate adjustement only... + // + if (iGameAudioSampleRate == decinfo.samprate>>1) + pMP3Stream->iRewind_FinalReductionCode = 1; + else + if (iGameAudioSampleRate == decinfo.samprate>>2) + pMP3Stream->iRewind_FinalReductionCode = 2; + + if (iGameAudioSampleBits == decinfo.bits>>1) // if game wants 8 bit sounds, then setup for that + pMP3Stream->iRewind_FinalConvertCode |= 8; + + if (audio.decode_init(&head, pMP3Stream->iSourceFrameBytes, pMP3Stream->iRewind_FinalReductionCode, pMP3Stream->iSourceReadIndex, pMP3Stream->iRewind_FinalConvertCode, freq_limit)) + { + audio.decode_info(&decinfo); +#ifdef _DEBUG + assert( iGameAudioSampleRate == decinfo.samprate ); + assert( iGameAudioSampleBits == decinfo.bits ); +#endif + + // sod it, no harm in one last check... (should never happen) + // + if ( iGameAudioSampleRate != decinfo.samprate || iGameAudioSampleBits != decinfo.bits ) + { + psReturn = "MP3ERR: Decoder unable to convert to current game audio settings"; + } + } + else + { + psReturn = "MP3ERR: Decoder failed to initialise for pass 2 sample adjust"; + } + } + else + { + psReturn = "MP3ERR: Decoder failed to initialise"; + } + } + else + { + psReturn = "MP3ERR: Errr.... something's broken with this MP3 file"; // should never happen by this point + } + + // restore global stream ptr before returning to normal functions (so the rest of the MP3 code still works)... + // + pMP3Stream = &_MP3Stream; + + return psReturn; +} + +// return value is decoded bytes for this packet, which is effectively a BOOL, NZ for not finished decoding yet... +// +unsigned int C_MP3Stream_Decode( LP_MP3STREAM pSFX_MP3Stream ) +{ + unsigned int uiDecoded = 0; // default to "finished" + IN_OUT x; + + pMP3Stream = pSFX_MP3Stream; + + if ( pSFX_MP3Stream->iSourceBytesRemaining == 0)// || pSFX_MP3Stream->iSourceBytesRemaining < pSFX_MP3Stream->iSourceFrameBytes) + { + uiDecoded = 0; // finished + pMP3Stream = &_MP3Stream; + return uiDecoded; + } + + x = audio.decode(pSFX_MP3Stream->pbSourceData + pSFX_MP3Stream->iSourceReadIndex, (short *) (pSFX_MP3Stream->bDecodeBuffer), + pSFX_MP3Stream->pbSourceData + pSFX_MP3Stream->iRewind_SourceReadIndex + pSFX_MP3Stream->iRewind_SourceBytesRemaining + ); + +#ifdef _DEBUG + pSFX_MP3Stream->iSourceFrameCounter++; +#endif + + pSFX_MP3Stream->iSourceReadIndex += x.in_bytes; + pSFX_MP3Stream->iSourceBytesRemaining -= x.in_bytes; + pSFX_MP3Stream->iBytesDecodedTotal += x.out_bytes; + pSFX_MP3Stream->iBytesDecodedThisPacket = x.out_bytes; + + uiDecoded = x.out_bytes; + + if (x.in_bytes <= 0) + { + //psReturn = "MP3ERR: Bad sync in file"; + uiDecoded= 0; // finished + pMP3Stream = &_MP3Stream; + return uiDecoded; + } + + // restore global stream ptr before returning to normal functions (so the rest of the MP3 code still works)... + // + pMP3Stream = &_MP3Stream; + + return uiDecoded; +} + + +// ret is char* errstring, else NULL for ok +// +char *C_MP3Stream_Rewind( LP_MP3STREAM pSFX_MP3Stream ) +{ + char* psReturn = NULL; + MPEG_HEAD head; // only relevant within this function during init + int iBitRate; // ditto + int iNULL; + + pMP3Stream = pSFX_MP3Stream; + + pMP3Stream->iSourceReadIndex = pMP3Stream->iRewind_SourceReadIndex; + pMP3Stream->iSourceBytesRemaining = pMP3Stream->iRewind_SourceBytesRemaining; // already adjusted for tags etc + + // I'm not sure that this is needed, but where else does decode_init get passed useful data ptrs?... + // + if (pMP3Stream->iSourceFrameBytes == head_info3( pMP3Stream->pbSourceData, pMP3Stream->iSourceBytesRemaining/2, &head, &iBitRate, (unsigned int*)&iNULL ) ) + { + if (audio.decode_init(&head, pMP3Stream->iSourceFrameBytes, pMP3Stream->iRewind_FinalReductionCode, pMP3Stream->iSourceReadIndex, pMP3Stream->iRewind_FinalConvertCode, freq_limit)) + { + // we should always get here... + // + } + else + { + psReturn = "MP3ERR: Failed to re-init decoder for rewind!"; + } + } + else + { + psReturn = "MP3ERR: Frame bytes mismatch during rewind header-read!"; + } + + // restore global stream ptr before returning to normal functions (so the rest of the MP3 code still works)... + // + pMP3Stream = &_MP3Stream; + + return psReturn; +} + diff --git a/src/client/mp3/uph.c b/src/client/mp3/uph.c new file mode 100644 index 0000000000..aec373f8cb --- /dev/null +++ b/src/client/mp3/uph.c @@ -0,0 +1,500 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: uph.c,v 1.3 1999/10/19 07:13:09 elrod Exp $ +____________________________________________________________________________*/ + +/**** uph.c *************************************************** + +Layer 3 audio + huffman decode + + +******************************************************************/ +#include +#include +#include +#include + +#include "l3.h" + +/*===============================================================*/ + +/* max bits required for any lookup - change if htable changes */ +/* quad required 10 bit w/signs must have (MAXBITS+2) >= 10 */ +#define MAXBITS 9 + +static const HUFF_ELEMENT huff_table_0[4] = +{{0}, {0}, {0}, {64}}; /* dummy must not use */ + +#include "htable.h" + +/*-- 6 bit lookup (purgebits, value) --*/ +static const unsigned char quad_table_a[][2] = +{ + {6, 11}, {6, 15}, {6, 13}, {6, 14}, {6, 7}, {6, 5}, {5, 9}, + {5, 9}, {5, 6}, {5, 6}, {5, 3}, {5, 3}, {5, 10}, {5, 10}, + {5, 12}, {5, 12}, {4, 2}, {4, 2}, {4, 2}, {4, 2}, {4, 1}, + {4, 1}, {4, 1}, {4, 1}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, + {4, 8}, {4, 8}, {4, 8}, {4, 8}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, + {1, 0}, +}; + + +typedef struct +{ + const HUFF_ELEMENT *table; + int linbits; + int ncase; +} +HUFF_SETUP; + +#define no_bits 0 +#define one_shot 1 +#define no_linbits 2 +#define have_linbits 3 +#define quad_a 4 +#define quad_b 5 + + +static const HUFF_SETUP table_look[] = +{ + {huff_table_0, 0, no_bits}, + {huff_table_1, 0, one_shot}, + {huff_table_2, 0, one_shot}, + {huff_table_3, 0, one_shot}, + {huff_table_0, 0, no_bits}, + {huff_table_5, 0, one_shot}, + {huff_table_6, 0, one_shot}, + {huff_table_7, 0, no_linbits}, + {huff_table_8, 0, no_linbits}, + {huff_table_9, 0, no_linbits}, + {huff_table_10, 0, no_linbits}, + {huff_table_11, 0, no_linbits}, + {huff_table_12, 0, no_linbits}, + {huff_table_13, 0, no_linbits}, + {huff_table_0, 0, no_bits}, + {huff_table_15, 0, no_linbits}, + {huff_table_16, 1, have_linbits}, + {huff_table_16, 2, have_linbits}, + {huff_table_16, 3, have_linbits}, + {huff_table_16, 4, have_linbits}, + {huff_table_16, 6, have_linbits}, + {huff_table_16, 8, have_linbits}, + {huff_table_16, 10, have_linbits}, + {huff_table_16, 13, have_linbits}, + {huff_table_24, 4, have_linbits}, + {huff_table_24, 5, have_linbits}, + {huff_table_24, 6, have_linbits}, + {huff_table_24, 7, have_linbits}, + {huff_table_24, 8, have_linbits}, + {huff_table_24, 9, have_linbits}, + {huff_table_24, 11, have_linbits}, + {huff_table_24, 13, have_linbits}, + {huff_table_0, 0, quad_a}, + {huff_table_0, 0, quad_b}, +}; + +/*========================================================*/ +extern BITDAT bitdat; + +/*------------- get n bits from bitstream -------------*/ +/* unused +static unsigned int bitget(int n) +{ + unsigned int x; + + if (bitdat.bits < n) + { */ /* refill bit buf if necessary */ +/* while (bitdat.bits <= 24) + { + bitdat.bitbuf = (bitdat.bitbuf << 8) | *bitdat.bs_ptr++; + bitdat.bits += 8; + } + } + bitdat.bits -= n; + x = bitdat.bitbuf >> bitdat.bits; + bitdat.bitbuf -= x << bitdat.bits; + return x; +} +*/ +/*----- get n bits - checks for n+2 avail bits (linbits+sign) -----*/ +static unsigned int bitget_lb(int n) +{ + unsigned int x; + + if (bitdat.bits < (n + 2)) + { /* refill bit buf if necessary */ + while (bitdat.bits <= 24) + { + bitdat.bitbuf = (bitdat.bitbuf << 8) | *bitdat.bs_ptr++; + bitdat.bits += 8; + } + } + bitdat.bits -= n; + x = bitdat.bitbuf >> bitdat.bits; + bitdat.bitbuf -= x << bitdat.bits; + return x; +} + + + + +/*------------- get n bits but DO NOT remove from bitstream --*/ +static unsigned int bitget2(int n) +{ + unsigned int x; + + if (bitdat.bits < (MAXBITS + 2)) + { /* refill bit buf if necessary */ + while (bitdat.bits <= 24) + { + bitdat.bitbuf = (bitdat.bitbuf << 8) | *bitdat.bs_ptr++; + bitdat.bits += 8; + } + } + x = bitdat.bitbuf >> (bitdat.bits - n); + return x; +} +/*------------- remove n bits from bitstream ---------*/ +/* unused +static void bitget_purge(int n) +{ + bitdat.bits -= n; + bitdat.bitbuf -= (bitdat.bitbuf >> bitdat.bits) << bitdat.bits; +} +*/ +/*------------- get 1 bit from bitstream NO CHECK -------------*/ +/* unused +static unsigned int bitget_1bit() +{ + unsigned int x; + + bitdat.bits--; + x = bitdat.bitbuf >> bitdat.bits; + bitdat.bitbuf -= x << bitdat.bits; + return x; +} +*/ +/*========================================================*/ +/*========================================================*/ +#define mac_bitget_check(n) if( bitdat.bits < (n) ) { \ + while( bitdat.bits <= 24 ) { \ + bitdat.bitbuf = (bitdat.bitbuf << 8) | *bitdat.bs_ptr++; \ + bitdat.bits += 8; \ + } \ +} +/*---------------------------------------------------------*/ +#define mac_bitget2(n) (bitdat.bitbuf >> (bitdat.bits-n)); +/*---------------------------------------------------------*/ +#define mac_bitget(n) ( bitdat.bits -= n, \ + code = bitdat.bitbuf >> bitdat.bits, \ + bitdat.bitbuf -= code << bitdat.bits, \ + code ) +/*---------------------------------------------------------*/ +#define mac_bitget_purge(n) bitdat.bits -= n, \ + bitdat.bitbuf -= (bitdat.bitbuf >> bitdat.bits) << bitdat.bits; +/*---------------------------------------------------------*/ +#define mac_bitget_1bit() ( bitdat.bits--, \ + code = bitdat.bitbuf >> bitdat.bits, \ + bitdat.bitbuf -= code << bitdat.bits, \ + code ) +/*========================================================*/ +/*========================================================*/ +void unpack_huff(int xy[][2], int n, int ntable) +{ + int i; + const HUFF_ELEMENT *t; + const HUFF_ELEMENT *t0; + int linbits; + int bits; + int code; + int x, y; + + if (n <= 0) + return; + n = n >> 1; /* huff in pairs */ +/*-------------*/ + t0 = table_look[ntable].table; + linbits = table_look[ntable].linbits; + switch (table_look[ntable].ncase) + { + default: +/*------------------------------------------*/ + case no_bits: +/*- table 0, no data, x=y=0--*/ + for (i = 0; i < n; i++) + { + xy[i][0] = 0; + xy[i][1] = 0; + } + return; +/*------------------------------------------*/ + case one_shot: +/*- single lookup, no escapes -*/ + for (i = 0; i < n; i++) + { + mac_bitget_check((MAXBITS + 2)); + bits = t0[0].b.signbits; + code = mac_bitget2(bits); + mac_bitget_purge(t0[1 + code].b.purgebits); + x = t0[1 + code].b.x; + y = t0[1 + code].b.y; + if (x) + if (mac_bitget_1bit()) + x = -x; + if (y) + if (mac_bitget_1bit()) + y = -y; + xy[i][0] = x; + xy[i][1] = y; + if (bitdat.bs_ptr > bitdat.bs_ptr_end) + break; // bad data protect + + } + return; +/*------------------------------------------*/ + case no_linbits: + for (i = 0; i < n; i++) + { + t = t0; + for (;;) + { + mac_bitget_check((MAXBITS + 2)); + bits = t[0].b.signbits; + code = mac_bitget2(bits); + if (t[1 + code].b.purgebits) + break; + t += t[1 + code].ptr; /* ptr include 1+code */ + mac_bitget_purge(bits); + } + mac_bitget_purge(t[1 + code].b.purgebits); + x = t[1 + code].b.x; + y = t[1 + code].b.y; + if (x) + if (mac_bitget_1bit()) + x = -x; + if (y) + if (mac_bitget_1bit()) + y = -y; + xy[i][0] = x; + xy[i][1] = y; + if (bitdat.bs_ptr > bitdat.bs_ptr_end) + break; // bad data protect + + } + return; +/*------------------------------------------*/ + case have_linbits: + for (i = 0; i < n; i++) + { + t = t0; + for (;;) + { + bits = t[0].b.signbits; + code = bitget2(bits); + if (t[1 + code].b.purgebits) + break; + t += t[1 + code].ptr; /* ptr includes 1+code */ + mac_bitget_purge(bits); + } + mac_bitget_purge(t[1 + code].b.purgebits); + x = t[1 + code].b.x; + y = t[1 + code].b.y; + if (x == 15) + x += bitget_lb(linbits); + if (x) + if (mac_bitget_1bit()) + x = -x; + if (y == 15) + y += bitget_lb(linbits); + if (y) + if (mac_bitget_1bit()) + y = -y; + xy[i][0] = x; + xy[i][1] = y; + if (bitdat.bs_ptr > bitdat.bs_ptr_end) + break; // bad data protect + + } + return; + } +/*--- end switch ---*/ + +} +/*==========================================================*/ +int unpack_huff_quad(int vwxy[][4], int n, int nbits, int ntable) +{ + int i; + int code; + int x, y, v, w; + int tmp; + int i_non_zero, tmp_nz; + + tmp_nz = 15; + i_non_zero = -1; + + n = n >> 2; /* huff in quads */ + + if (ntable) + goto case_quad_b; + +/* case_quad_a: */ + for (i = 0; i < n; i++) + { + if (nbits <= 0) + break; + mac_bitget_check(10); + code = mac_bitget2(6); + nbits -= quad_table_a[code][0]; + mac_bitget_purge(quad_table_a[code][0]); + tmp = quad_table_a[code][1]; + if (tmp) + { + i_non_zero = i; + tmp_nz = tmp; + } + v = (tmp >> 3) & 1; + w = (tmp >> 2) & 1; + x = (tmp >> 1) & 1; + y = tmp & 1; + if (v) + { + if (mac_bitget_1bit()) + v = -v; + nbits--; + } + if (w) + { + if (mac_bitget_1bit()) + w = -w; + nbits--; + } + if (x) + { + if (mac_bitget_1bit()) + x = -x; + nbits--; + } + if (y) + { + if (mac_bitget_1bit()) + y = -y; + nbits--; + } + vwxy[i][0] = v; + vwxy[i][1] = w; + vwxy[i][2] = x; + vwxy[i][3] = y; + if (bitdat.bs_ptr > bitdat.bs_ptr_end) + break; // bad data protect + + } + if (i && nbits < 0) + { + i--; + vwxy[i][0] = 0; + vwxy[i][1] = 0; + vwxy[i][2] = 0; + vwxy[i][3] = 0; + } + + i_non_zero = (i_non_zero + 1) << 2; + + if ((tmp_nz & 3) == 0) + i_non_zero -= 2; + + return i_non_zero; + +/*--------------------*/ + case_quad_b: + for (i = 0; i < n; i++) + { + if (nbits < 4) + break; + nbits -= 4; + mac_bitget_check(8); + tmp = mac_bitget(4) ^ 15; /* one's complement of bitstream */ + if (tmp) + { + i_non_zero = i; + tmp_nz = tmp; + } + v = (tmp >> 3) & 1; + w = (tmp >> 2) & 1; + x = (tmp >> 1) & 1; + y = tmp & 1; + if (v) + { + if (mac_bitget_1bit()) + v = -v; + nbits--; + } + if (w) + { + if (mac_bitget_1bit()) + w = -w; + nbits--; + } + if (x) + { + if (mac_bitget_1bit()) + x = -x; + nbits--; + } + if (y) + { + if (mac_bitget_1bit()) + y = -y; + nbits--; + } + vwxy[i][0] = v; + vwxy[i][1] = w; + vwxy[i][2] = x; + vwxy[i][3] = y; + if (bitdat.bs_ptr > bitdat.bs_ptr_end) + break; // bad data protect + + } + if (nbits < 0) + { + i--; + vwxy[i][0] = 0; + vwxy[i][1] = 0; + vwxy[i][2] = 0; + vwxy[i][3] = 0; + } + + i_non_zero = (i_non_zero + 1) << 2; + + if ((tmp_nz & 3) == 0) + i_non_zero -= 2; + + return i_non_zero; /* return non-zero sample (to nearest pair) */ + +} +/*-----------------------------------------------------*/ diff --git a/src/client/mp3/upsf.c b/src/client/mp3/upsf.c new file mode 100644 index 0000000000..da3d311ae4 --- /dev/null +++ b/src/client/mp3/upsf.c @@ -0,0 +1,402 @@ +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: upsf.c,v 1.3 1999/10/19 07:13:09 elrod Exp $ +____________________________________________________________________________*/ + +/**** upsf.c *************************************************** + +Layer III + unpack scale factors + + + +******************************************************************/ + +#include +#include +#include +#include +#include "l3.h" + +unsigned int bitget(int n); + +/*------------------------------------------------------------*/ +static const int slen_table[16][2] = +{ + {0, 0}, {0, 1}, + {0, 2}, {0, 3}, + {3, 0}, {1, 1}, + {1, 2}, {1, 3}, + {2, 1}, {2, 2}, + {2, 3}, {3, 1}, + {3, 2}, {3, 3}, + {4, 2}, {4, 3}, +}; + +/* nr_table[size+3*is_right][block type 0,1,3 2, 2+mixed][4] */ +/* for bt=2 nr is count for group of 3 */ +static const int nr_table[6][3][4] = +{ + {{6, 5, 5, 5}, + {3, 3, 3, 3}, + {6, 3, 3, 3}}, + + {{6, 5, 7, 3}, + {3, 3, 4, 2}, + {6, 3, 4, 2}}, + + {{11, 10, 0, 0}, + {6, 6, 0, 0}, + {6, 3, 6, 0}}, /* adjusted *//* 15, 18, 0, 0, */ +/*-intensity stereo right chan--*/ + {{7, 7, 7, 0}, + {4, 4, 4, 0}, + {6, 5, 4, 0}}, + + {{6, 6, 6, 3}, + {4, 3, 3, 2}, + {6, 4, 3, 2}}, + + {{8, 8, 5, 0}, + {5, 4, 3, 0}, + {6, 6, 3, 0}}, +}; + +/*=============================================================*/ +void unpack_sf_sub_MPEG1(SCALEFACT sf[], + GR * grdat, + int scfsi, /* bit flag */ + int gr) +{ + int sfb; + int slen0, slen1; + int block_type, mixed_block_flag, scalefac_compress; + + + block_type = grdat->block_type; + mixed_block_flag = grdat->mixed_block_flag; + scalefac_compress = grdat->scalefac_compress; + + slen0 = slen_table[scalefac_compress][0]; + slen1 = slen_table[scalefac_compress][1]; + + + if (block_type == 2) + { + if (mixed_block_flag) + { /* mixed */ + for (sfb = 0; sfb < 8; sfb++) + sf[0].l[sfb] = bitget(slen0); + for (sfb = 3; sfb < 6; sfb++) + { + sf[0].s[0][sfb] = bitget(slen0); + sf[0].s[1][sfb] = bitget(slen0); + sf[0].s[2][sfb] = bitget(slen0); + } + for (sfb = 6; sfb < 12; sfb++) + { + sf[0].s[0][sfb] = bitget(slen1); + sf[0].s[1][sfb] = bitget(slen1); + sf[0].s[2][sfb] = bitget(slen1); + } + return; + } + for (sfb = 0; sfb < 6; sfb++) + { + sf[0].s[0][sfb] = bitget(slen0); + sf[0].s[1][sfb] = bitget(slen0); + sf[0].s[2][sfb] = bitget(slen0); + } + for (; sfb < 12; sfb++) + { + sf[0].s[0][sfb] = bitget(slen1); + sf[0].s[1][sfb] = bitget(slen1); + sf[0].s[2][sfb] = bitget(slen1); + } + return; + } + +/* long blocks types 0 1 3, first granule */ + if (gr == 0) + { + for (sfb = 0; sfb < 11; sfb++) + sf[0].l[sfb] = bitget(slen0); + for (; sfb < 21; sfb++) + sf[0].l[sfb] = bitget(slen1); + return; + } + +/* long blocks 0, 1, 3, second granule */ + sfb = 0; + if (scfsi & 8) + for (; sfb < 6; sfb++) + sf[0].l[sfb] = sf[-2].l[sfb]; + else + for (; sfb < 6; sfb++) + sf[0].l[sfb] = bitget(slen0); + if (scfsi & 4) + for (; sfb < 11; sfb++) + sf[0].l[sfb] = sf[-2].l[sfb]; + else + for (; sfb < 11; sfb++) + sf[0].l[sfb] = bitget(slen0); + if (scfsi & 2) + for (; sfb < 16; sfb++) + sf[0].l[sfb] = sf[-2].l[sfb]; + else + for (; sfb < 16; sfb++) + sf[0].l[sfb] = bitget(slen1); + if (scfsi & 1) + for (; sfb < 21; sfb++) + sf[0].l[sfb] = sf[-2].l[sfb]; + else + for (; sfb < 21; sfb++) + sf[0].l[sfb] = bitget(slen1); + + + + return; +} +/*=============================================================*/ +void unpack_sf_sub_MPEG2(SCALEFACT sf[], + GR * grdat, + int is_and_ch, IS_SF_INFO * sf_info) +{ + int sfb; + int slen1, slen2, slen3, slen4; + int nr1, nr2, nr3, nr4; + int i, k; + int preflag, intensity_scale; + int block_type, mixed_block_flag, scalefac_compress; + + + block_type = grdat->block_type; + mixed_block_flag = grdat->mixed_block_flag; + scalefac_compress = grdat->scalefac_compress; + + preflag = 0; + intensity_scale = 0; /* to avoid compiler warning */ + if (is_and_ch == 0) + { + if (scalefac_compress < 400) + { + slen2 = scalefac_compress >> 4; + slen1 = slen2 / 5; + slen2 = slen2 % 5; + slen4 = scalefac_compress & 15; + slen3 = slen4 >> 2; + slen4 = slen4 & 3; + k = 0; + } + else if (scalefac_compress < 500) + { + scalefac_compress -= 400; + slen2 = scalefac_compress >> 2; + slen1 = slen2 / 5; + slen2 = slen2 % 5; + slen3 = scalefac_compress & 3; + slen4 = 0; + k = 1; + } + else + { + scalefac_compress -= 500; + slen1 = scalefac_compress / 3; + slen2 = scalefac_compress % 3; + slen3 = slen4 = 0; + if (mixed_block_flag) + { + slen3 = slen2; /* adjust for long/short mix logic */ + slen2 = slen1; + } + preflag = 1; + k = 2; + } + } + else + { /* intensity stereo ch = 1 (right) */ + intensity_scale = scalefac_compress & 1; + scalefac_compress >>= 1; + if (scalefac_compress < 180) + { + slen1 = scalefac_compress / 36; + slen2 = scalefac_compress % 36; + slen3 = slen2 % 6; + slen2 = slen2 / 6; + slen4 = 0; + k = 3 + 0; + } + else if (scalefac_compress < 244) + { + scalefac_compress -= 180; + slen3 = scalefac_compress & 3; + scalefac_compress >>= 2; + slen2 = scalefac_compress & 3; + slen1 = scalefac_compress >> 2; + slen4 = 0; + k = 3 + 1; + } + else + { + scalefac_compress -= 244; + slen1 = scalefac_compress / 3; + slen2 = scalefac_compress % 3; + slen3 = slen4 = 0; + k = 3 + 2; + } + } + + i = 0; + if (block_type == 2) + i = (mixed_block_flag & 1) + 1; + nr1 = nr_table[k][i][0]; + nr2 = nr_table[k][i][1]; + nr3 = nr_table[k][i][2]; + nr4 = nr_table[k][i][3]; + + +/* return is scale factor info (for right chan is mode) */ + if (is_and_ch) + { + sf_info->nr[0] = nr1; + sf_info->nr[1] = nr2; + sf_info->nr[2] = nr3; + sf_info->slen[0] = slen1; + sf_info->slen[1] = slen2; + sf_info->slen[2] = slen3; + sf_info->intensity_scale = intensity_scale; + } + grdat->preflag = preflag; /* return preflag */ + +/*--------------------------------------*/ + if (block_type == 2) + { + if (mixed_block_flag) + { /* mixed */ + if (slen1 != 0) /* long block portion */ + for (sfb = 0; sfb < 6; sfb++) + sf[0].l[sfb] = bitget(slen1); + else + for (sfb = 0; sfb < 6; sfb++) + sf[0].l[sfb] = 0; + sfb = 3; /* start sfb for short */ + } + else + { /* all short, initial short blocks */ + sfb = 0; + if (slen1 != 0) + for (i = 0; i < nr1; i++, sfb++) + { + sf[0].s[0][sfb] = bitget(slen1); + sf[0].s[1][sfb] = bitget(slen1); + sf[0].s[2][sfb] = bitget(slen1); + } + else + for (i = 0; i < nr1; i++, sfb++) + { + sf[0].s[0][sfb] = 0; + sf[0].s[1][sfb] = 0; + sf[0].s[2][sfb] = 0; + } + } +/* remaining short blocks */ + if (slen2 != 0) + for (i = 0; i < nr2; i++, sfb++) + { + sf[0].s[0][sfb] = bitget(slen2); + sf[0].s[1][sfb] = bitget(slen2); + sf[0].s[2][sfb] = bitget(slen2); + } + else + for (i = 0; i < nr2; i++, sfb++) + { + sf[0].s[0][sfb] = 0; + sf[0].s[1][sfb] = 0; + sf[0].s[2][sfb] = 0; + } + if (slen3 != 0) + for (i = 0; i < nr3; i++, sfb++) + { + sf[0].s[0][sfb] = bitget(slen3); + sf[0].s[1][sfb] = bitget(slen3); + sf[0].s[2][sfb] = bitget(slen3); + } + else + for (i = 0; i < nr3; i++, sfb++) + { + sf[0].s[0][sfb] = 0; + sf[0].s[1][sfb] = 0; + sf[0].s[2][sfb] = 0; + } + if (slen4 != 0) + for (i = 0; i < nr4; i++, sfb++) + { + sf[0].s[0][sfb] = bitget(slen4); + sf[0].s[1][sfb] = bitget(slen4); + sf[0].s[2][sfb] = bitget(slen4); + } + else + for (i = 0; i < nr4; i++, sfb++) + { + sf[0].s[0][sfb] = 0; + sf[0].s[1][sfb] = 0; + sf[0].s[2][sfb] = 0; + } + return; + } + + +/* long blocks types 0 1 3 */ + sfb = 0; + if (slen1 != 0) + for (i = 0; i < nr1; i++, sfb++) + sf[0].l[sfb] = bitget(slen1); + else + for (i = 0; i < nr1; i++, sfb++) + sf[0].l[sfb] = 0; + + if (slen2 != 0) + for (i = 0; i < nr2; i++, sfb++) + sf[0].l[sfb] = bitget(slen2); + else + for (i = 0; i < nr2; i++, sfb++) + sf[0].l[sfb] = 0; + + if (slen3 != 0) + for (i = 0; i < nr3; i++, sfb++) + sf[0].l[sfb] = bitget(slen3); + else + for (i = 0; i < nr3; i++, sfb++) + sf[0].l[sfb] = 0; + + if (slen4 != 0) + for (i = 0; i < nr4; i++, sfb++) + sf[0].l[sfb] = bitget(slen4); + else + for (i = 0; i < nr4; i++, sfb++) + sf[0].l[sfb] = 0; + + +} +/*-------------------------------------------------*/ diff --git a/src/client/mp3/wavep.c b/src/client/mp3/wavep.c new file mode 100644 index 0000000000..b82073ee8f --- /dev/null +++ b/src/client/mp3/wavep.c @@ -0,0 +1,95 @@ +#if 0 +/*____________________________________________________________________________ + + FreeAmp - The Free MP3 Player + + MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology + Corp. http://www.xingtech.com + + Portions Copyright (C) 1998-1999 EMusic.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: wavep.c,v 1.3 1999/10/19 07:13:09 elrod Exp $ +____________________________________________________________________________*/ + +/*---- wavep.c -------------------------------------------- + +WAVE FILE HEADER ROUTINES +with conditional pcm conversion to MS wave format +portable version + +-----------------------------------------------------------*/ +#include +#include +#include +#include +#ifdef WIN32 +#include +#else +#include +#endif +#include "port.h" + +typedef struct +{ + unsigned char riff[4]; + unsigned char size[4]; + unsigned char wave[4]; + unsigned char fmt[4]; + unsigned char fmtsize[4]; + unsigned char tag[2]; + unsigned char nChannels[2]; + unsigned char nSamplesPerSec[4]; + unsigned char nAvgBytesPerSec[4]; + unsigned char nBlockAlign[2]; + unsigned char nBitsPerSample[2]; + unsigned char data[4]; + unsigned char pcm_bytes[4]; +} +BYTE_WAVE; + +static const BYTE_WAVE wave = +{ + "RIFF", + {(sizeof(BYTE_WAVE) - 8), 0, 0, 0}, + "WAVE", + "fmt ", + {16, 0, 0, 0}, + {1, 0}, + {1, 0}, + {34, 86, 0, 0}, /* 86 * 256 + 34 = 22050 */ + {172, 68, 0, 0}, /* 172 * 256 + 68 = 44100 */ + {2, 0}, + {16, 0}, + "data", + {0, 0, 0, 0} +}; + +/*---------------------------------------------------------------- + pcm conversion to wave format + + This conversion code required for big endian machine, or, + if sizeof(short) != 16 bits. + Conversion routines may be used on any machine, but if + not required, the do nothing macros in port.h can be used instead + to reduce overhead. + +-----------------------------------------------------------------*/ +#ifndef LITTLE_SHORT16 +#include "wcvt.c" +#endif +/*-----------------------------------------------*/ +#endif diff --git a/code/client/snd_adpcm.c b/src/client/snd_adpcm.c similarity index 100% rename from code/client/snd_adpcm.c rename to src/client/snd_adpcm.c diff --git a/code/client/snd_codec.c b/src/client/snd_codec.c similarity index 92% rename from code/client/snd_codec.c rename to src/client/snd_codec.c index f97f509cfe..4b85d1f69a 100644 --- a/code/client/snd_codec.c +++ b/src/client/snd_codec.c @@ -130,6 +130,19 @@ void S_CodecInit( void ) #ifdef USE_OGG_VORBIS S_CodecRegister( &ogg_codec ); #endif +#ifdef USE_MP3 + { + cvar_t *s_enableMp3 = Cvar_Get( "s_enableMp3", "1", CVAR_ARCHIVE ); + Cvar_CheckRange( s_enableMp3, "0", "1", CV_INTEGER ); + Cvar_SetDescription( s_enableMp3, "Enable MP3 codec support for loading and streaming audio." ); + if ( s_enableMp3->integer ) { + Com_Printf( "MP3 codec enabled.\n" ); + S_CodecRegister( &mp3_codec ); + } else { + Com_Printf( "MP3 codec disabled.\n" ); + } + } +#endif // Register wav codec last so that it is always tried first when a file extension was not found S_CodecRegister( &wav_codec ); diff --git a/code/client/snd_codec.h b/src/client/snd_codec.h similarity index 86% rename from code/client/snd_codec.h rename to src/client/snd_codec.h index e8d7fa137a..ccafe2e230 100644 --- a/code/client/snd_codec.h +++ b/src/client/snd_codec.h @@ -1,90 +1,90 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. -Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com) - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ - -#ifndef _SND_CODEC_H_ -#define _SND_CODEC_H_ - -#include "../qcommon/q_shared.h" -#include "../qcommon/qcommon.h" - -typedef struct snd_info_s -{ - int rate; - int width; - int channels; - int samples; - int size; - int dataofs; -} snd_info_t; - -typedef struct snd_codec_s snd_codec_t; - -typedef struct snd_stream_s -{ - snd_codec_t *codec; - fileHandle_t file; - snd_info_t info; - int length; - int pos; - void *ptr; -} snd_stream_t; - -// Codec functions -typedef void *(*CODEC_LOAD)(const char *filename, snd_info_t *info); -typedef snd_stream_t *(*CODEC_OPEN)(const char *filename); -typedef int (*CODEC_READ)(snd_stream_t *stream, int bytes, void *buffer); -typedef void (*CODEC_CLOSE)(snd_stream_t *stream); - -// Codec data structure -struct snd_codec_s -{ - const char *ext; - CODEC_LOAD load; - CODEC_OPEN open; - CODEC_READ read; - CODEC_CLOSE close; - snd_codec_t *next; -}; - -// Codec management -void S_CodecInit( void ); -void S_CodecShutdown( void ); -void *S_CodecLoad(const char *filename, snd_info_t *info); -snd_stream_t *S_CodecOpenStream(const char *filename); -void S_CodecCloseStream(snd_stream_t *stream); -int S_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer); - -// Util functions (used by codecs) -snd_stream_t *S_CodecUtilOpen(const char *filename, snd_codec_t *codec); -void S_CodecUtilClose(snd_stream_t **stream); - -// WAV Codec -extern snd_codec_t wav_codec; -void *S_WAV_CodecLoad(const char *filename, snd_info_t *info); -snd_stream_t *S_WAV_CodecOpenStream(const char *filename); -void S_WAV_CodecCloseStream(snd_stream_t *stream); -int S_WAV_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer); - +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. +Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com) + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef _SND_CODEC_H_ +#define _SND_CODEC_H_ + +#include "../qcommon/q_shared.h" +#include "../qcommon/qcommon.h" + +typedef struct snd_info_s +{ + int rate; + int width; + int channels; + int samples; + int size; + int dataofs; +} snd_info_t; + +typedef struct snd_codec_s snd_codec_t; + +typedef struct snd_stream_s +{ + snd_codec_t *codec; + fileHandle_t file; + snd_info_t info; + int length; + int pos; + void *ptr; +} snd_stream_t; + +// Codec functions +typedef void *(*CODEC_LOAD)(const char *filename, snd_info_t *info); +typedef snd_stream_t *(*CODEC_OPEN)(const char *filename); +typedef int (*CODEC_READ)(snd_stream_t *stream, int bytes, void *buffer); +typedef void (*CODEC_CLOSE)(snd_stream_t *stream); + +// Codec data structure +struct snd_codec_s +{ + const char *ext; + CODEC_LOAD load; + CODEC_OPEN open; + CODEC_READ read; + CODEC_CLOSE close; + snd_codec_t *next; +}; + +// Codec management +void S_CodecInit( void ); +void S_CodecShutdown( void ); +void *S_CodecLoad(const char *filename, snd_info_t *info); +snd_stream_t *S_CodecOpenStream(const char *filename); +void S_CodecCloseStream(snd_stream_t *stream); +int S_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer); + +// Util functions (used by codecs) +snd_stream_t *S_CodecUtilOpen(const char *filename, snd_codec_t *codec); +void S_CodecUtilClose(snd_stream_t **stream); + +// WAV Codec +extern snd_codec_t wav_codec; +void *S_WAV_CodecLoad(const char *filename, snd_info_t *info); +snd_stream_t *S_WAV_CodecOpenStream(const char *filename); +void S_WAV_CodecCloseStream(snd_stream_t *stream); +int S_WAV_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer); + // Ogg Vorbis codec #ifdef USE_OGG_VORBIS extern snd_codec_t ogg_codec; @@ -92,6 +92,13 @@ void *S_OGG_CodecLoad(const char *filename, snd_info_t *info); snd_stream_t *S_OGG_CodecOpenStream(const char *filename); void S_OGG_CodecCloseStream(snd_stream_t *stream); int S_OGG_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer); -#endif // USE_OGG_VORBIS - -#endif // !_SND_CODEC_H_ +#endif // USE_OGG_VORBIS + +// MP3 codec (powered by the integrated mp3/ decoder in client/mp3/) +extern snd_codec_t mp3_codec; +void *S_MP3_CodecLoad(const char *filename, snd_info_t *info); +snd_stream_t *S_MP3_CodecOpenStream(const char *filename); +void S_MP3_CodecCloseStream(snd_stream_t *stream); +int S_MP3_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer); + +#endif // !_SND_CODEC_H_ diff --git a/src/client/snd_codec_mp3.c b/src/client/snd_codec_mp3.c new file mode 100644 index 0000000000..003325f950 --- /dev/null +++ b/src/client/snd_codec_mp3.c @@ -0,0 +1,252 @@ +/* +=========================================================================== + MP3 codec wrapper for idTech3 sound system +=========================================================================== +*/ + +#include "client.h" +#include "snd_codec.h" +#include "mp3/mp3struct.h" +#include "snd_local.h" + +typedef struct { + byte *data; + int length; + MP3STREAM mp3; +} mp3_stream_ctx_t; + +// forward declarations +void *S_MP3_CodecLoad(const char *filename, snd_info_t *info); +snd_stream_t *S_MP3_CodecOpenStream(const char *filename); +int S_MP3_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer); +void S_MP3_CodecCloseStream(snd_stream_t *stream); + +snd_codec_t mp3_codec = +{ + "mp3", + S_MP3_CodecLoad, + S_MP3_CodecOpenStream, + S_MP3_CodecReadStream, + S_MP3_CodecCloseStream, + NULL +}; + +/* +================= +S_MP3_CodecLoad + +Load entire MP3 file, decode to raw PCM and return buffer (caller frees) +================= +*/ +void *S_MP3_CodecLoad(const char *filename, snd_info_t *info) +{ + fileHandle_t f; + int length; + byte *filebuf = NULL; + char *err; + int unpackSize = 0; + byte *outbuf = NULL; + int stereoDesired = (dma.channels == 2) ? 1 : 0; + int maxSoundBytes; + + if (!filename || !info) return NULL; + + length = FS_FOpenFileRead(filename, &f, qtrue); + if ( f == FS_INVALID_HANDLE ) { + return NULL; + } + + // read file into temp buffer + filebuf = Z_Malloc(length); + if (!filebuf) { + FS_FCloseFile(f); + return NULL; + } + FS_Read(filebuf, length, f); + FS_FCloseFile(f); + + // get header info + { + int rate=0, width=0, channels=0; + err = C_MP3_GetHeaderData(filebuf, length, &rate, &width, &channels, stereoDesired); + if (err) { + Z_Free(filebuf); + return NULL; + } + info->rate = rate; + info->width = width; + info->channels = channels; + } + + // estimate unpacked size + err = C_MP3_GetUnpackedSize(filebuf, length, &unpackSize, stereoDesired); + if (err || unpackSize <= 0) { + // fallback: free and fail + Z_Free(filebuf); + return NULL; + } + maxSoundBytes = Cvar_VariableIntegerValue("com_soundMegs") * 1024 * 1024; + if (maxSoundBytes <= 0) { + maxSoundBytes = 8 * 1024 * 1024; + } + if (unpackSize > maxSoundBytes) { + Com_Printf(S_COLOR_YELLOW "WARNING: MP3 %s is too large for SFX (%d bytes). Use music instead.\n", + filename, unpackSize); + Z_Free(filebuf); + return NULL; + } + + outbuf = Hunk_AllocateTempMemory(unpackSize); + if (!outbuf) { + Z_Free(filebuf); + return NULL; + } + + err = C_MP3_UnpackRawPCM(filebuf, length, &unpackSize, outbuf, stereoDesired); + if (err) { + Z_Free(filebuf); + Hunk_FreeTempMemory(outbuf); + return NULL; + } + + info->size = unpackSize; + info->samples = unpackSize / (info->width * info->channels); + info->dataofs = 0; + + // free file buffer + Z_Free(filebuf); + + return outbuf; +} + +/* +================= +S_MP3_CodecOpenStream + +Open MP3 file and prepare decoder for streaming +================= +*/ +snd_stream_t *S_MP3_CodecOpenStream(const char *filename) +{ + snd_stream_t *stream; + fileHandle_t f; + int length; + byte *filebuf = NULL; + mp3_stream_ctx_t *ctx = NULL; + char *err; + int stereoDesired = (dma.channels == 2) ? 1 : 0; + + if (!filename) return NULL; + + stream = S_CodecUtilOpen(filename, &mp3_codec); + if (!stream) return NULL; + + // read entire compressed file into temp memory for the MP3 decoder + length = stream->length; + filebuf = Z_Malloc(length); + if (!filebuf) { + S_CodecUtilClose(&stream); + return NULL; + } + // seek to start and read + FS_Seek(stream->file, 0, FS_SEEK_SET); + FS_Read(filebuf, length, stream->file); + + // allocate context + ctx = Z_Malloc(sizeof(*ctx)); + if (!ctx) { + Z_Free(filebuf); + S_CodecUtilClose(&stream); + return NULL; + } + ctx->data = filebuf; + ctx->length = length; + + // init decoder to game audio format (dma.speed / dma.samplebits) + err = C_MP3Stream_DecodeInit(&ctx->mp3, ctx->data, ctx->length, dma.speed, dma.samplebits, stereoDesired); + if (err) { + Z_Free(ctx); + Z_Free(filebuf); + S_CodecUtilClose(&stream); + return NULL; + } + + // fill stream info to indicate decoded output format + stream->info.rate = dma.speed; + stream->info.width = dma.samplebits / 8; + stream->info.channels = dma.channels; + stream->info.samples = 0; + stream->info.size = 0; + stream->info.dataofs = 0; + + stream->ptr = ctx; + // we will use stream->pos for compressed stream offset if needed + stream->pos = 0; + + return stream; +} + +/* +================= +S_MP3_CodecReadStream + +Decode mp3 into provided buffer up to 'bytes' and return number of bytes written +================= +*/ +int S_MP3_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer) +{ + mp3_stream_ctx_t *ctx; + int bytesRead = 0; + char *bufPtr; + int bytesAvailable; + unsigned int out; + + if (!stream || !buffer || bytes <= 0) return 0; + ctx = (mp3_stream_ctx_t *) stream->ptr; + if (!ctx) return 0; + + bufPtr = buffer; + + while (bytesRead < bytes) { + bytesAvailable = ctx->mp3.iBytesDecodedThisPacket - ctx->mp3.iCopyOffset; + if (bytesAvailable <= 0) { + out = C_MP3Stream_Decode(&ctx->mp3); + if (out == 0) { + break; + } + ctx->mp3.iCopyOffset = 0; + bytesAvailable = ctx->mp3.iBytesDecodedThisPacket; + } + // copy decoded data + { + int copy = bytesAvailable; + if (copy + bytesRead > bytes) copy = bytes - bytesRead; + memcpy(bufPtr + bytesRead, ctx->mp3.bDecodeBuffer + ctx->mp3.iCopyOffset, copy); + ctx->mp3.iCopyOffset += copy; + bytesRead += copy; + } + } + + return bytesRead; +} + +/* +================= +S_MP3_CodecCloseStream +================= +*/ +void S_MP3_CodecCloseStream(snd_stream_t *stream) +{ + mp3_stream_ctx_t *ctx; + if (!stream) return; + ctx = (mp3_stream_ctx_t *) stream->ptr; + if (ctx) { + if (ctx->data) { + Z_Free(ctx->data); + } + Z_Free(ctx); + stream->ptr = NULL; + } + S_CodecUtilClose(&stream); +} + diff --git a/code/client/snd_codec_ogg.c b/src/client/snd_codec_ogg.c similarity index 100% rename from code/client/snd_codec_ogg.c rename to src/client/snd_codec_ogg.c diff --git a/code/client/snd_codec_wav.c b/src/client/snd_codec_wav.c similarity index 100% rename from code/client/snd_codec_wav.c rename to src/client/snd_codec_wav.c diff --git a/code/client/snd_dma.c b/src/client/snd_dma.c similarity index 100% rename from code/client/snd_dma.c rename to src/client/snd_dma.c diff --git a/code/client/snd_local.h b/src/client/snd_local.h similarity index 100% rename from code/client/snd_local.h rename to src/client/snd_local.h diff --git a/code/client/snd_main.c b/src/client/snd_main.c similarity index 100% rename from code/client/snd_main.c rename to src/client/snd_main.c diff --git a/code/client/snd_mem.c b/src/client/snd_mem.c similarity index 98% rename from code/client/snd_mem.c rename to src/client/snd_mem.c index bafd693d04..bbd88326b8 100644 --- a/code/client/snd_mem.c +++ b/src/client/snd_mem.c @@ -268,7 +268,7 @@ of a forced fallback of a player specific sound qboolean S_LoadSound( sfx_t *sfx ) { byte *data; - short *samples; + short *samples = NULL; snd_info_t info; // int size; @@ -285,8 +285,6 @@ qboolean S_LoadSound( sfx_t *sfx ) Com_DPrintf(S_COLOR_YELLOW "WARNING: %s is not a 22kHz audio file\n", sfx->soundName); } - samples = Hunk_AllocateTempMemory(info.samples * sizeof(short) * 2); - sfx->lastTimeUsed = s_soundtime + 1; // Com_Milliseconds()+1 // each of these compression schemes works just fine @@ -296,6 +294,7 @@ qboolean S_LoadSound( sfx_t *sfx ) // sound in as needed if( info.channels == 1 && sfx->soundCompressed == qtrue) { + samples = Hunk_AllocateTempMemory(info.samples * sizeof(short) * 2); sfx->soundCompressionMethod = 1; sfx->soundData = NULL; sfx->soundLength = ResampleSfxRaw( samples, info.channels, info.rate, info.width, info.samples, data + info.dataofs ); @@ -320,7 +319,9 @@ qboolean S_LoadSound( sfx_t *sfx ) sfx->soundChannels = info.channels; - Hunk_FreeTempMemory(samples); + if ( samples ) { + Hunk_FreeTempMemory(samples); + } Hunk_FreeTempMemory(data); return qtrue; diff --git a/code/client/snd_mix.c b/src/client/snd_mix.c similarity index 99% rename from code/client/snd_mix.c rename to src/client/snd_mix.c index ac9af1579a..5d39380451 100644 --- a/code/client/snd_mix.c +++ b/src/client/snd_mix.c @@ -265,7 +265,7 @@ __asm { #endif // id386 -#if idx64 && (!defined (_MSC_VER) || defined(USE_WIN32_ASM)) +#if idx64 && (!defined (_MSC_VER) || defined(USE_WIN32_ASM)) && defined(USE_ASM) void S_WriteLinearBlastStereo16_SSE_x64( int*, short*, int ); #endif @@ -299,7 +299,7 @@ void S_TransferStereo16( unsigned long *pbuf, int endtime ) S_WriteLinearBlastStereo16_MMX(); else #endif -#if idx64 && (!defined (_MSC_VER) || defined (USE_WIN32_ASM)) +#if idx64 && (!defined (_MSC_VER) || defined (USE_WIN32_ASM)) && defined(USE_ASM) S_WriteLinearBlastStereo16_SSE_x64( snd_p, snd_out, snd_linear_count ); #else S_WriteLinearBlastStereo16(); diff --git a/src/client/snd_mix_fallback.c b/src/client/snd_mix_fallback.c new file mode 100644 index 0000000000..06e222c6e9 --- /dev/null +++ b/src/client/snd_mix_fallback.c @@ -0,0 +1,35 @@ +/* Fallback implementation for S_WriteLinearBlastStereo16_SSE_x64 + * Provides a weak C implementation that forwards to the portable C writer. + * If an optimized assembly version is present, the strong symbol will override this. + */ +#include "client.h" +#include "snd_local.h" + +/* Globals used by the portable writer (defined in snd_mix.c) */ +extern int *snd_p; +extern int snd_linear_count; +extern short *snd_out; + +/* Prototype of the portable writer */ +void S_WriteLinearBlastStereo16(void); + +/* Provide weak symbol so assembler implementation (if present) takes precedence. */ +void S_WriteLinearBlastStereo16_SSE_x64(int *p, short *out, int count) __attribute__((weak)); + +void S_WriteLinearBlastStereo16_SSE_x64(int *p, short *out, int count) +{ + int *old_p = snd_p; + short *old_out = snd_out; + int old_count = snd_linear_count; + + snd_p = p; + snd_out = out; + snd_linear_count = count; + + S_WriteLinearBlastStereo16(); + + /* restore globals */ + snd_p = old_p; + snd_out = old_out; + snd_linear_count = old_count; +} diff --git a/code/client/snd_public.h b/src/client/snd_public.h similarity index 100% rename from code/client/snd_public.h rename to src/client/snd_public.h diff --git a/code/client/snd_wavelet.c b/src/client/snd_wavelet.c similarity index 100% rename from code/client/snd_wavelet.c rename to src/client/snd_wavelet.c diff --git a/code/game/bg_public.h b/src/game/bg_public.h similarity index 100% rename from code/game/bg_public.h rename to src/game/bg_public.h diff --git a/code/game/g_public.h b/src/game/g_public.h similarity index 100% rename from code/game/g_public.h rename to src/game/g_public.h diff --git a/code/libcurl/conf751.sh b/src/libcurl/conf751.sh similarity index 100% rename from code/libcurl/conf751.sh rename to src/libcurl/conf751.sh diff --git a/code/libcurl/conf840.sh b/src/libcurl/conf840.sh similarity index 100% rename from code/libcurl/conf840.sh rename to src/libcurl/conf840.sh diff --git a/code/libcurl/windows/include/curl/curl.h b/src/libcurl/windows/include/curl/curl.h similarity index 100% rename from code/libcurl/windows/include/curl/curl.h rename to src/libcurl/windows/include/curl/curl.h diff --git a/code/libcurl/windows/include/curl/curlver.h b/src/libcurl/windows/include/curl/curlver.h similarity index 100% rename from code/libcurl/windows/include/curl/curlver.h rename to src/libcurl/windows/include/curl/curlver.h diff --git a/code/libcurl/windows/include/curl/easy.h b/src/libcurl/windows/include/curl/easy.h similarity index 100% rename from code/libcurl/windows/include/curl/easy.h rename to src/libcurl/windows/include/curl/easy.h diff --git a/code/libcurl/windows/include/curl/header.h b/src/libcurl/windows/include/curl/header.h similarity index 100% rename from code/libcurl/windows/include/curl/header.h rename to src/libcurl/windows/include/curl/header.h diff --git a/code/libcurl/windows/include/curl/mprintf.h b/src/libcurl/windows/include/curl/mprintf.h similarity index 100% rename from code/libcurl/windows/include/curl/mprintf.h rename to src/libcurl/windows/include/curl/mprintf.h diff --git a/code/libcurl/windows/include/curl/multi.h b/src/libcurl/windows/include/curl/multi.h similarity index 100% rename from code/libcurl/windows/include/curl/multi.h rename to src/libcurl/windows/include/curl/multi.h diff --git a/code/libcurl/windows/include/curl/options.h b/src/libcurl/windows/include/curl/options.h similarity index 100% rename from code/libcurl/windows/include/curl/options.h rename to src/libcurl/windows/include/curl/options.h diff --git a/code/libcurl/windows/include/curl/stdcheaders.h b/src/libcurl/windows/include/curl/stdcheaders.h similarity index 100% rename from code/libcurl/windows/include/curl/stdcheaders.h rename to src/libcurl/windows/include/curl/stdcheaders.h diff --git a/code/libcurl/windows/include/curl/system.h b/src/libcurl/windows/include/curl/system.h similarity index 100% rename from code/libcurl/windows/include/curl/system.h rename to src/libcurl/windows/include/curl/system.h diff --git a/code/libcurl/windows/include/curl/typecheck-gcc.h b/src/libcurl/windows/include/curl/typecheck-gcc.h similarity index 100% rename from code/libcurl/windows/include/curl/typecheck-gcc.h rename to src/libcurl/windows/include/curl/typecheck-gcc.h diff --git a/code/libcurl/windows/include/curl/urlapi.h b/src/libcurl/windows/include/curl/urlapi.h similarity index 100% rename from code/libcurl/windows/include/curl/urlapi.h rename to src/libcurl/windows/include/curl/urlapi.h diff --git a/code/libcurl/windows/include/curl/websockets.h b/src/libcurl/windows/include/curl/websockets.h similarity index 100% rename from code/libcurl/windows/include/curl/websockets.h rename to src/libcurl/windows/include/curl/websockets.h diff --git a/code/libcurl/windows/mingw/lib32/libcurl.a b/src/libcurl/windows/mingw/lib32/libcurl.a similarity index 100% rename from code/libcurl/windows/mingw/lib32/libcurl.a rename to src/libcurl/windows/mingw/lib32/libcurl.a diff --git a/code/libcurl/windows/mingw/lib64/libcurl.a b/src/libcurl/windows/mingw/lib64/libcurl.a similarity index 100% rename from code/libcurl/windows/mingw/lib64/libcurl.a rename to src/libcurl/windows/mingw/lib64/libcurl.a diff --git a/code/libcurl/windows/vs2005/lib32/libcurl_a.lib b/src/libcurl/windows/vs2005/lib32/libcurl_a.lib similarity index 100% rename from code/libcurl/windows/vs2005/lib32/libcurl_a.lib rename to src/libcurl/windows/vs2005/lib32/libcurl_a.lib diff --git a/code/libcurl/windows/vs2005/lib32/libcurl_a_debug.lib b/src/libcurl/windows/vs2005/lib32/libcurl_a_debug.lib similarity index 100% rename from code/libcurl/windows/vs2005/lib32/libcurl_a_debug.lib rename to src/libcurl/windows/vs2005/lib32/libcurl_a_debug.lib diff --git a/code/libcurl/windows/vs2005/lib64/libcurl_a.lib b/src/libcurl/windows/vs2005/lib64/libcurl_a.lib similarity index 100% rename from code/libcurl/windows/vs2005/lib64/libcurl_a.lib rename to src/libcurl/windows/vs2005/lib64/libcurl_a.lib diff --git a/code/libcurl/windows/vs2005/lib64/libcurl_a_debug.lib b/src/libcurl/windows/vs2005/lib64/libcurl_a_debug.lib similarity index 100% rename from code/libcurl/windows/vs2005/lib64/libcurl_a_debug.lib rename to src/libcurl/windows/vs2005/lib64/libcurl_a_debug.lib diff --git a/code/libcurl/windows/vs2017/lib32/libcurl_a.lib b/src/libcurl/windows/vs2017/lib32/libcurl_a.lib similarity index 100% rename from code/libcurl/windows/vs2017/lib32/libcurl_a.lib rename to src/libcurl/windows/vs2017/lib32/libcurl_a.lib diff --git a/code/libcurl/windows/vs2017/lib32/libcurl_a_debug.lib b/src/libcurl/windows/vs2017/lib32/libcurl_a_debug.lib similarity index 100% rename from code/libcurl/windows/vs2017/lib32/libcurl_a_debug.lib rename to src/libcurl/windows/vs2017/lib32/libcurl_a_debug.lib diff --git a/code/libcurl/windows/vs2017/lib64/libcurl_a.lib b/src/libcurl/windows/vs2017/lib64/libcurl_a.lib similarity index 100% rename from code/libcurl/windows/vs2017/lib64/libcurl_a.lib rename to src/libcurl/windows/vs2017/lib64/libcurl_a.lib diff --git a/code/libcurl/windows/vs2017/lib64/libcurl_a_debug.lib b/src/libcurl/windows/vs2017/lib64/libcurl_a_debug.lib similarity index 100% rename from code/libcurl/windows/vs2017/lib64/libcurl_a_debug.lib rename to src/libcurl/windows/vs2017/lib64/libcurl_a_debug.lib diff --git a/code/libjpeg/README b/src/libjpeg/README similarity index 100% rename from code/libjpeg/README rename to src/libjpeg/README diff --git a/code/libjpeg/jaricom.c b/src/libjpeg/jaricom.c similarity index 100% rename from code/libjpeg/jaricom.c rename to src/libjpeg/jaricom.c diff --git a/code/libjpeg/jcapimin.c b/src/libjpeg/jcapimin.c similarity index 100% rename from code/libjpeg/jcapimin.c rename to src/libjpeg/jcapimin.c diff --git a/code/libjpeg/jcapistd.c b/src/libjpeg/jcapistd.c similarity index 100% rename from code/libjpeg/jcapistd.c rename to src/libjpeg/jcapistd.c diff --git a/code/libjpeg/jcarith.c b/src/libjpeg/jcarith.c similarity index 100% rename from code/libjpeg/jcarith.c rename to src/libjpeg/jcarith.c diff --git a/code/libjpeg/jccoefct.c b/src/libjpeg/jccoefct.c similarity index 100% rename from code/libjpeg/jccoefct.c rename to src/libjpeg/jccoefct.c diff --git a/code/libjpeg/jccolor.c b/src/libjpeg/jccolor.c similarity index 100% rename from code/libjpeg/jccolor.c rename to src/libjpeg/jccolor.c diff --git a/code/libjpeg/jcdctmgr.c b/src/libjpeg/jcdctmgr.c similarity index 100% rename from code/libjpeg/jcdctmgr.c rename to src/libjpeg/jcdctmgr.c diff --git a/code/libjpeg/jchuff.c b/src/libjpeg/jchuff.c similarity index 100% rename from code/libjpeg/jchuff.c rename to src/libjpeg/jchuff.c diff --git a/code/libjpeg/jcinit.c b/src/libjpeg/jcinit.c similarity index 100% rename from code/libjpeg/jcinit.c rename to src/libjpeg/jcinit.c diff --git a/code/libjpeg/jcmainct.c b/src/libjpeg/jcmainct.c similarity index 100% rename from code/libjpeg/jcmainct.c rename to src/libjpeg/jcmainct.c diff --git a/code/libjpeg/jcmarker.c b/src/libjpeg/jcmarker.c similarity index 100% rename from code/libjpeg/jcmarker.c rename to src/libjpeg/jcmarker.c diff --git a/code/libjpeg/jcmaster.c b/src/libjpeg/jcmaster.c similarity index 100% rename from code/libjpeg/jcmaster.c rename to src/libjpeg/jcmaster.c diff --git a/code/libjpeg/jcomapi.c b/src/libjpeg/jcomapi.c similarity index 100% rename from code/libjpeg/jcomapi.c rename to src/libjpeg/jcomapi.c diff --git a/code/libjpeg/jconfig.h b/src/libjpeg/jconfig.h similarity index 100% rename from code/libjpeg/jconfig.h rename to src/libjpeg/jconfig.h diff --git a/code/libjpeg/jcparam.c b/src/libjpeg/jcparam.c similarity index 100% rename from code/libjpeg/jcparam.c rename to src/libjpeg/jcparam.c diff --git a/code/libjpeg/jcprepct.c b/src/libjpeg/jcprepct.c similarity index 100% rename from code/libjpeg/jcprepct.c rename to src/libjpeg/jcprepct.c diff --git a/code/libjpeg/jcsample.c b/src/libjpeg/jcsample.c similarity index 100% rename from code/libjpeg/jcsample.c rename to src/libjpeg/jcsample.c diff --git a/code/libjpeg/jctrans.c b/src/libjpeg/jctrans.c similarity index 100% rename from code/libjpeg/jctrans.c rename to src/libjpeg/jctrans.c diff --git a/code/libjpeg/jdapimin.c b/src/libjpeg/jdapimin.c similarity index 100% rename from code/libjpeg/jdapimin.c rename to src/libjpeg/jdapimin.c diff --git a/code/libjpeg/jdapistd.c b/src/libjpeg/jdapistd.c similarity index 100% rename from code/libjpeg/jdapistd.c rename to src/libjpeg/jdapistd.c diff --git a/code/libjpeg/jdarith.c b/src/libjpeg/jdarith.c similarity index 100% rename from code/libjpeg/jdarith.c rename to src/libjpeg/jdarith.c diff --git a/code/libjpeg/jdatadst.c b/src/libjpeg/jdatadst.c similarity index 100% rename from code/libjpeg/jdatadst.c rename to src/libjpeg/jdatadst.c diff --git a/code/libjpeg/jdatasrc.c b/src/libjpeg/jdatasrc.c similarity index 100% rename from code/libjpeg/jdatasrc.c rename to src/libjpeg/jdatasrc.c diff --git a/code/libjpeg/jdcoefct.c b/src/libjpeg/jdcoefct.c similarity index 100% rename from code/libjpeg/jdcoefct.c rename to src/libjpeg/jdcoefct.c diff --git a/code/libjpeg/jdcolor.c b/src/libjpeg/jdcolor.c similarity index 100% rename from code/libjpeg/jdcolor.c rename to src/libjpeg/jdcolor.c diff --git a/code/libjpeg/jdct.h b/src/libjpeg/jdct.h similarity index 100% rename from code/libjpeg/jdct.h rename to src/libjpeg/jdct.h diff --git a/code/libjpeg/jddctmgr.c b/src/libjpeg/jddctmgr.c similarity index 100% rename from code/libjpeg/jddctmgr.c rename to src/libjpeg/jddctmgr.c diff --git a/code/libjpeg/jdhuff.c b/src/libjpeg/jdhuff.c similarity index 100% rename from code/libjpeg/jdhuff.c rename to src/libjpeg/jdhuff.c diff --git a/code/libjpeg/jdinput.c b/src/libjpeg/jdinput.c similarity index 100% rename from code/libjpeg/jdinput.c rename to src/libjpeg/jdinput.c diff --git a/code/libjpeg/jdmainct.c b/src/libjpeg/jdmainct.c similarity index 100% rename from code/libjpeg/jdmainct.c rename to src/libjpeg/jdmainct.c diff --git a/code/libjpeg/jdmarker.c b/src/libjpeg/jdmarker.c similarity index 100% rename from code/libjpeg/jdmarker.c rename to src/libjpeg/jdmarker.c diff --git a/code/libjpeg/jdmaster.c b/src/libjpeg/jdmaster.c similarity index 100% rename from code/libjpeg/jdmaster.c rename to src/libjpeg/jdmaster.c diff --git a/code/libjpeg/jdmerge.c b/src/libjpeg/jdmerge.c similarity index 100% rename from code/libjpeg/jdmerge.c rename to src/libjpeg/jdmerge.c diff --git a/code/libjpeg/jdpostct.c b/src/libjpeg/jdpostct.c similarity index 100% rename from code/libjpeg/jdpostct.c rename to src/libjpeg/jdpostct.c diff --git a/code/libjpeg/jdsample.c b/src/libjpeg/jdsample.c similarity index 100% rename from code/libjpeg/jdsample.c rename to src/libjpeg/jdsample.c diff --git a/code/libjpeg/jdtrans.c b/src/libjpeg/jdtrans.c similarity index 100% rename from code/libjpeg/jdtrans.c rename to src/libjpeg/jdtrans.c diff --git a/code/libjpeg/jerror.c b/src/libjpeg/jerror.c similarity index 100% rename from code/libjpeg/jerror.c rename to src/libjpeg/jerror.c diff --git a/code/libjpeg/jerror.h b/src/libjpeg/jerror.h similarity index 100% rename from code/libjpeg/jerror.h rename to src/libjpeg/jerror.h diff --git a/code/libjpeg/jfdctflt.c b/src/libjpeg/jfdctflt.c similarity index 100% rename from code/libjpeg/jfdctflt.c rename to src/libjpeg/jfdctflt.c diff --git a/code/libjpeg/jfdctfst.c b/src/libjpeg/jfdctfst.c similarity index 100% rename from code/libjpeg/jfdctfst.c rename to src/libjpeg/jfdctfst.c diff --git a/code/libjpeg/jfdctint.c b/src/libjpeg/jfdctint.c similarity index 100% rename from code/libjpeg/jfdctint.c rename to src/libjpeg/jfdctint.c diff --git a/code/libjpeg/jidctflt.c b/src/libjpeg/jidctflt.c similarity index 100% rename from code/libjpeg/jidctflt.c rename to src/libjpeg/jidctflt.c diff --git a/code/libjpeg/jidctfst.c b/src/libjpeg/jidctfst.c similarity index 100% rename from code/libjpeg/jidctfst.c rename to src/libjpeg/jidctfst.c diff --git a/code/libjpeg/jidctint.c b/src/libjpeg/jidctint.c similarity index 100% rename from code/libjpeg/jidctint.c rename to src/libjpeg/jidctint.c diff --git a/code/libjpeg/jinclude.h b/src/libjpeg/jinclude.h similarity index 100% rename from code/libjpeg/jinclude.h rename to src/libjpeg/jinclude.h diff --git a/code/libjpeg/jmemmgr.c b/src/libjpeg/jmemmgr.c similarity index 100% rename from code/libjpeg/jmemmgr.c rename to src/libjpeg/jmemmgr.c diff --git a/code/libjpeg/jmemnobs.c b/src/libjpeg/jmemnobs.c similarity index 100% rename from code/libjpeg/jmemnobs.c rename to src/libjpeg/jmemnobs.c diff --git a/code/libjpeg/jmemsys.h b/src/libjpeg/jmemsys.h similarity index 100% rename from code/libjpeg/jmemsys.h rename to src/libjpeg/jmemsys.h diff --git a/code/libjpeg/jmorecfg.h b/src/libjpeg/jmorecfg.h similarity index 100% rename from code/libjpeg/jmorecfg.h rename to src/libjpeg/jmorecfg.h diff --git a/code/libjpeg/jpegint.h b/src/libjpeg/jpegint.h similarity index 100% rename from code/libjpeg/jpegint.h rename to src/libjpeg/jpegint.h diff --git a/code/libjpeg/jpeglib.h b/src/libjpeg/jpeglib.h similarity index 100% rename from code/libjpeg/jpeglib.h rename to src/libjpeg/jpeglib.h diff --git a/code/libjpeg/jquant1.c b/src/libjpeg/jquant1.c similarity index 100% rename from code/libjpeg/jquant1.c rename to src/libjpeg/jquant1.c diff --git a/code/libjpeg/jquant2.c b/src/libjpeg/jquant2.c similarity index 100% rename from code/libjpeg/jquant2.c rename to src/libjpeg/jquant2.c diff --git a/code/libjpeg/jutils.c b/src/libjpeg/jutils.c similarity index 100% rename from code/libjpeg/jutils.c rename to src/libjpeg/jutils.c diff --git a/code/libjpeg/jversion.h b/src/libjpeg/jversion.h similarity index 100% rename from code/libjpeg/jversion.h rename to src/libjpeg/jversion.h diff --git a/code/libjpeg/libjpeg-changes.diff b/src/libjpeg/libjpeg-changes.diff similarity index 100% rename from code/libjpeg/libjpeg-changes.diff rename to src/libjpeg/libjpeg-changes.diff diff --git a/code/libogg/COPYING b/src/libogg/COPYING similarity index 100% rename from code/libogg/COPYING rename to src/libogg/COPYING diff --git a/code/libogg/include/ogg/config_types.h b/src/libogg/include/ogg/config_types.h similarity index 100% rename from code/libogg/include/ogg/config_types.h rename to src/libogg/include/ogg/config_types.h diff --git a/code/libogg/include/ogg/ogg.h b/src/libogg/include/ogg/ogg.h similarity index 100% rename from code/libogg/include/ogg/ogg.h rename to src/libogg/include/ogg/ogg.h diff --git a/code/libogg/include/ogg/os_types.h b/src/libogg/include/ogg/os_types.h similarity index 100% rename from code/libogg/include/ogg/os_types.h rename to src/libogg/include/ogg/os_types.h diff --git a/code/libogg/src/bitwise.c b/src/libogg/src/bitwise.c similarity index 100% rename from code/libogg/src/bitwise.c rename to src/libogg/src/bitwise.c diff --git a/code/libogg/src/crctable.h b/src/libogg/src/crctable.h similarity index 100% rename from code/libogg/src/crctable.h rename to src/libogg/src/crctable.h diff --git a/code/libogg/src/framing.c b/src/libogg/src/framing.c similarity index 100% rename from code/libogg/src/framing.c rename to src/libogg/src/framing.c diff --git a/code/libsdl/include/SDL2/SDL.h b/src/libsdl/include/SDL2/SDL.h similarity index 100% rename from code/libsdl/include/SDL2/SDL.h rename to src/libsdl/include/SDL2/SDL.h diff --git a/code/libsdl/include/SDL2/SDL_assert.h b/src/libsdl/include/SDL2/SDL_assert.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_assert.h rename to src/libsdl/include/SDL2/SDL_assert.h diff --git a/code/libsdl/include/SDL2/SDL_atomic.h b/src/libsdl/include/SDL2/SDL_atomic.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_atomic.h rename to src/libsdl/include/SDL2/SDL_atomic.h diff --git a/code/libsdl/include/SDL2/SDL_audio.h b/src/libsdl/include/SDL2/SDL_audio.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_audio.h rename to src/libsdl/include/SDL2/SDL_audio.h diff --git a/code/libsdl/include/SDL2/SDL_bits.h b/src/libsdl/include/SDL2/SDL_bits.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_bits.h rename to src/libsdl/include/SDL2/SDL_bits.h diff --git a/code/libsdl/include/SDL2/SDL_blendmode.h b/src/libsdl/include/SDL2/SDL_blendmode.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_blendmode.h rename to src/libsdl/include/SDL2/SDL_blendmode.h diff --git a/code/libsdl/include/SDL2/SDL_clipboard.h b/src/libsdl/include/SDL2/SDL_clipboard.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_clipboard.h rename to src/libsdl/include/SDL2/SDL_clipboard.h diff --git a/code/libsdl/include/SDL2/SDL_config.h b/src/libsdl/include/SDL2/SDL_config.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_config.h rename to src/libsdl/include/SDL2/SDL_config.h diff --git a/code/libsdl/include/SDL2/SDL_cpuinfo.h b/src/libsdl/include/SDL2/SDL_cpuinfo.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_cpuinfo.h rename to src/libsdl/include/SDL2/SDL_cpuinfo.h diff --git a/code/libsdl/include/SDL2/SDL_egl.h b/src/libsdl/include/SDL2/SDL_egl.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_egl.h rename to src/libsdl/include/SDL2/SDL_egl.h diff --git a/code/libsdl/include/SDL2/SDL_endian.h b/src/libsdl/include/SDL2/SDL_endian.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_endian.h rename to src/libsdl/include/SDL2/SDL_endian.h diff --git a/code/libsdl/include/SDL2/SDL_error.h b/src/libsdl/include/SDL2/SDL_error.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_error.h rename to src/libsdl/include/SDL2/SDL_error.h diff --git a/code/libsdl/include/SDL2/SDL_events.h b/src/libsdl/include/SDL2/SDL_events.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_events.h rename to src/libsdl/include/SDL2/SDL_events.h diff --git a/code/libsdl/include/SDL2/SDL_filesystem.h b/src/libsdl/include/SDL2/SDL_filesystem.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_filesystem.h rename to src/libsdl/include/SDL2/SDL_filesystem.h diff --git a/code/libsdl/include/SDL2/SDL_gamecontroller.h b/src/libsdl/include/SDL2/SDL_gamecontroller.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_gamecontroller.h rename to src/libsdl/include/SDL2/SDL_gamecontroller.h diff --git a/code/libsdl/include/SDL2/SDL_gesture.h b/src/libsdl/include/SDL2/SDL_gesture.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_gesture.h rename to src/libsdl/include/SDL2/SDL_gesture.h diff --git a/code/libsdl/include/SDL2/SDL_haptic.h b/src/libsdl/include/SDL2/SDL_haptic.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_haptic.h rename to src/libsdl/include/SDL2/SDL_haptic.h diff --git a/code/libsdl/include/SDL2/SDL_hints.h b/src/libsdl/include/SDL2/SDL_hints.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_hints.h rename to src/libsdl/include/SDL2/SDL_hints.h diff --git a/code/libsdl/include/SDL2/SDL_joystick.h b/src/libsdl/include/SDL2/SDL_joystick.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_joystick.h rename to src/libsdl/include/SDL2/SDL_joystick.h diff --git a/code/libsdl/include/SDL2/SDL_keyboard.h b/src/libsdl/include/SDL2/SDL_keyboard.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_keyboard.h rename to src/libsdl/include/SDL2/SDL_keyboard.h diff --git a/code/libsdl/include/SDL2/SDL_keycode.h b/src/libsdl/include/SDL2/SDL_keycode.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_keycode.h rename to src/libsdl/include/SDL2/SDL_keycode.h diff --git a/code/libsdl/include/SDL2/SDL_loadso.h b/src/libsdl/include/SDL2/SDL_loadso.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_loadso.h rename to src/libsdl/include/SDL2/SDL_loadso.h diff --git a/code/libsdl/include/SDL2/SDL_log.h b/src/libsdl/include/SDL2/SDL_log.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_log.h rename to src/libsdl/include/SDL2/SDL_log.h diff --git a/code/libsdl/include/SDL2/SDL_main.h b/src/libsdl/include/SDL2/SDL_main.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_main.h rename to src/libsdl/include/SDL2/SDL_main.h diff --git a/code/libsdl/include/SDL2/SDL_messagebox.h b/src/libsdl/include/SDL2/SDL_messagebox.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_messagebox.h rename to src/libsdl/include/SDL2/SDL_messagebox.h diff --git a/code/libsdl/include/SDL2/SDL_mouse.h b/src/libsdl/include/SDL2/SDL_mouse.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_mouse.h rename to src/libsdl/include/SDL2/SDL_mouse.h diff --git a/code/libsdl/include/SDL2/SDL_mutex.h b/src/libsdl/include/SDL2/SDL_mutex.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_mutex.h rename to src/libsdl/include/SDL2/SDL_mutex.h diff --git a/code/libsdl/include/SDL2/SDL_name.h b/src/libsdl/include/SDL2/SDL_name.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_name.h rename to src/libsdl/include/SDL2/SDL_name.h diff --git a/code/libsdl/include/SDL2/SDL_opengl.h b/src/libsdl/include/SDL2/SDL_opengl.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_opengl.h rename to src/libsdl/include/SDL2/SDL_opengl.h diff --git a/code/libsdl/include/SDL2/SDL_opengl_glext.h b/src/libsdl/include/SDL2/SDL_opengl_glext.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_opengl_glext.h rename to src/libsdl/include/SDL2/SDL_opengl_glext.h diff --git a/code/libsdl/include/SDL2/SDL_opengles.h b/src/libsdl/include/SDL2/SDL_opengles.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_opengles.h rename to src/libsdl/include/SDL2/SDL_opengles.h diff --git a/code/libsdl/include/SDL2/SDL_opengles2.h b/src/libsdl/include/SDL2/SDL_opengles2.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_opengles2.h rename to src/libsdl/include/SDL2/SDL_opengles2.h diff --git a/code/libsdl/include/SDL2/SDL_opengles2_gl2.h b/src/libsdl/include/SDL2/SDL_opengles2_gl2.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_opengles2_gl2.h rename to src/libsdl/include/SDL2/SDL_opengles2_gl2.h diff --git a/code/libsdl/include/SDL2/SDL_opengles2_gl2ext.h b/src/libsdl/include/SDL2/SDL_opengles2_gl2ext.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_opengles2_gl2ext.h rename to src/libsdl/include/SDL2/SDL_opengles2_gl2ext.h diff --git a/code/libsdl/include/SDL2/SDL_opengles2_gl2platform.h b/src/libsdl/include/SDL2/SDL_opengles2_gl2platform.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_opengles2_gl2platform.h rename to src/libsdl/include/SDL2/SDL_opengles2_gl2platform.h diff --git a/code/libsdl/include/SDL2/SDL_opengles2_khrplatform.h b/src/libsdl/include/SDL2/SDL_opengles2_khrplatform.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_opengles2_khrplatform.h rename to src/libsdl/include/SDL2/SDL_opengles2_khrplatform.h diff --git a/code/libsdl/include/SDL2/SDL_pixels.h b/src/libsdl/include/SDL2/SDL_pixels.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_pixels.h rename to src/libsdl/include/SDL2/SDL_pixels.h diff --git a/code/libsdl/include/SDL2/SDL_platform.h b/src/libsdl/include/SDL2/SDL_platform.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_platform.h rename to src/libsdl/include/SDL2/SDL_platform.h diff --git a/code/libsdl/include/SDL2/SDL_power.h b/src/libsdl/include/SDL2/SDL_power.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_power.h rename to src/libsdl/include/SDL2/SDL_power.h diff --git a/code/libsdl/include/SDL2/SDL_quit.h b/src/libsdl/include/SDL2/SDL_quit.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_quit.h rename to src/libsdl/include/SDL2/SDL_quit.h diff --git a/code/libsdl/include/SDL2/SDL_rect.h b/src/libsdl/include/SDL2/SDL_rect.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_rect.h rename to src/libsdl/include/SDL2/SDL_rect.h diff --git a/code/libsdl/include/SDL2/SDL_render.h b/src/libsdl/include/SDL2/SDL_render.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_render.h rename to src/libsdl/include/SDL2/SDL_render.h diff --git a/code/libsdl/include/SDL2/SDL_revision.h b/src/libsdl/include/SDL2/SDL_revision.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_revision.h rename to src/libsdl/include/SDL2/SDL_revision.h diff --git a/code/libsdl/include/SDL2/SDL_rwops.h b/src/libsdl/include/SDL2/SDL_rwops.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_rwops.h rename to src/libsdl/include/SDL2/SDL_rwops.h diff --git a/code/libsdl/include/SDL2/SDL_scancode.h b/src/libsdl/include/SDL2/SDL_scancode.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_scancode.h rename to src/libsdl/include/SDL2/SDL_scancode.h diff --git a/code/libsdl/include/SDL2/SDL_sensor.h b/src/libsdl/include/SDL2/SDL_sensor.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_sensor.h rename to src/libsdl/include/SDL2/SDL_sensor.h diff --git a/code/libsdl/include/SDL2/SDL_shape.h b/src/libsdl/include/SDL2/SDL_shape.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_shape.h rename to src/libsdl/include/SDL2/SDL_shape.h diff --git a/code/libsdl/include/SDL2/SDL_stdinc.h b/src/libsdl/include/SDL2/SDL_stdinc.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_stdinc.h rename to src/libsdl/include/SDL2/SDL_stdinc.h diff --git a/code/libsdl/include/SDL2/SDL_surface.h b/src/libsdl/include/SDL2/SDL_surface.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_surface.h rename to src/libsdl/include/SDL2/SDL_surface.h diff --git a/code/libsdl/include/SDL2/SDL_system.h b/src/libsdl/include/SDL2/SDL_system.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_system.h rename to src/libsdl/include/SDL2/SDL_system.h diff --git a/code/libsdl/include/SDL2/SDL_syswm.h b/src/libsdl/include/SDL2/SDL_syswm.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_syswm.h rename to src/libsdl/include/SDL2/SDL_syswm.h diff --git a/code/libsdl/include/SDL2/SDL_test.h b/src/libsdl/include/SDL2/SDL_test.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_test.h rename to src/libsdl/include/SDL2/SDL_test.h diff --git a/code/libsdl/include/SDL2/SDL_test_assert.h b/src/libsdl/include/SDL2/SDL_test_assert.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_test_assert.h rename to src/libsdl/include/SDL2/SDL_test_assert.h diff --git a/code/libsdl/include/SDL2/SDL_test_common.h b/src/libsdl/include/SDL2/SDL_test_common.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_test_common.h rename to src/libsdl/include/SDL2/SDL_test_common.h diff --git a/code/libsdl/include/SDL2/SDL_test_compare.h b/src/libsdl/include/SDL2/SDL_test_compare.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_test_compare.h rename to src/libsdl/include/SDL2/SDL_test_compare.h diff --git a/code/libsdl/include/SDL2/SDL_test_crc32.h b/src/libsdl/include/SDL2/SDL_test_crc32.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_test_crc32.h rename to src/libsdl/include/SDL2/SDL_test_crc32.h diff --git a/code/libsdl/include/SDL2/SDL_test_font.h b/src/libsdl/include/SDL2/SDL_test_font.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_test_font.h rename to src/libsdl/include/SDL2/SDL_test_font.h diff --git a/code/libsdl/include/SDL2/SDL_test_fuzzer.h b/src/libsdl/include/SDL2/SDL_test_fuzzer.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_test_fuzzer.h rename to src/libsdl/include/SDL2/SDL_test_fuzzer.h diff --git a/code/libsdl/include/SDL2/SDL_test_harness.h b/src/libsdl/include/SDL2/SDL_test_harness.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_test_harness.h rename to src/libsdl/include/SDL2/SDL_test_harness.h diff --git a/code/libsdl/include/SDL2/SDL_test_images.h b/src/libsdl/include/SDL2/SDL_test_images.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_test_images.h rename to src/libsdl/include/SDL2/SDL_test_images.h diff --git a/code/libsdl/include/SDL2/SDL_test_log.h b/src/libsdl/include/SDL2/SDL_test_log.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_test_log.h rename to src/libsdl/include/SDL2/SDL_test_log.h diff --git a/code/libsdl/include/SDL2/SDL_test_md5.h b/src/libsdl/include/SDL2/SDL_test_md5.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_test_md5.h rename to src/libsdl/include/SDL2/SDL_test_md5.h diff --git a/code/libsdl/include/SDL2/SDL_test_memory.h b/src/libsdl/include/SDL2/SDL_test_memory.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_test_memory.h rename to src/libsdl/include/SDL2/SDL_test_memory.h diff --git a/code/libsdl/include/SDL2/SDL_test_random.h b/src/libsdl/include/SDL2/SDL_test_random.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_test_random.h rename to src/libsdl/include/SDL2/SDL_test_random.h diff --git a/code/libsdl/include/SDL2/SDL_thread.h b/src/libsdl/include/SDL2/SDL_thread.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_thread.h rename to src/libsdl/include/SDL2/SDL_thread.h diff --git a/code/libsdl/include/SDL2/SDL_timer.h b/src/libsdl/include/SDL2/SDL_timer.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_timer.h rename to src/libsdl/include/SDL2/SDL_timer.h diff --git a/code/libsdl/include/SDL2/SDL_touch.h b/src/libsdl/include/SDL2/SDL_touch.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_touch.h rename to src/libsdl/include/SDL2/SDL_touch.h diff --git a/code/libsdl/include/SDL2/SDL_types.h b/src/libsdl/include/SDL2/SDL_types.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_types.h rename to src/libsdl/include/SDL2/SDL_types.h diff --git a/code/libsdl/include/SDL2/SDL_version.h b/src/libsdl/include/SDL2/SDL_version.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_version.h rename to src/libsdl/include/SDL2/SDL_version.h diff --git a/code/libsdl/include/SDL2/SDL_video.h b/src/libsdl/include/SDL2/SDL_video.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_video.h rename to src/libsdl/include/SDL2/SDL_video.h diff --git a/code/libsdl/include/SDL2/SDL_vulkan.h b/src/libsdl/include/SDL2/SDL_vulkan.h similarity index 100% rename from code/libsdl/include/SDL2/SDL_vulkan.h rename to src/libsdl/include/SDL2/SDL_vulkan.h diff --git a/code/libsdl/include/SDL2/begin_code.h b/src/libsdl/include/SDL2/begin_code.h similarity index 100% rename from code/libsdl/include/SDL2/begin_code.h rename to src/libsdl/include/SDL2/begin_code.h diff --git a/code/libsdl/include/SDL2/close_code.h b/src/libsdl/include/SDL2/close_code.h similarity index 100% rename from code/libsdl/include/SDL2/close_code.h rename to src/libsdl/include/SDL2/close_code.h diff --git a/code/libsdl/macosx/libSDL2-2.0.0.dylib b/src/libsdl/macosx/libSDL2-2.0.0.dylib similarity index 100% rename from code/libsdl/macosx/libSDL2-2.0.0.dylib rename to src/libsdl/macosx/libSDL2-2.0.0.dylib diff --git a/code/libsdl/macosx/libSDL2main.a b/src/libsdl/macosx/libSDL2main.a similarity index 100% rename from code/libsdl/macosx/libSDL2main.a rename to src/libsdl/macosx/libSDL2main.a diff --git a/code/libsdl/windows/mingw/lib32/SDL2.dll b/src/libsdl/windows/mingw/lib32/SDL2.dll similarity index 100% rename from code/libsdl/windows/mingw/lib32/SDL2.dll rename to src/libsdl/windows/mingw/lib32/SDL2.dll diff --git a/code/libsdl/windows/mingw/lib32/libSDL2.dll.a b/src/libsdl/windows/mingw/lib32/libSDL2.dll.a similarity index 100% rename from code/libsdl/windows/mingw/lib32/libSDL2.dll.a rename to src/libsdl/windows/mingw/lib32/libSDL2.dll.a diff --git a/code/libsdl/windows/mingw/lib32/libSDL2.la b/src/libsdl/windows/mingw/lib32/libSDL2.la similarity index 100% rename from code/libsdl/windows/mingw/lib32/libSDL2.la rename to src/libsdl/windows/mingw/lib32/libSDL2.la diff --git a/code/libsdl/windows/mingw/lib64/SDL264.dll b/src/libsdl/windows/mingw/lib64/SDL264.dll similarity index 100% rename from code/libsdl/windows/mingw/lib64/SDL264.dll rename to src/libsdl/windows/mingw/lib64/SDL264.dll diff --git a/code/libsdl/windows/mingw/lib64/libSDL264.dll.a b/src/libsdl/windows/mingw/lib64/libSDL264.dll.a similarity index 100% rename from code/libsdl/windows/mingw/lib64/libSDL264.dll.a rename to src/libsdl/windows/mingw/lib64/libSDL264.dll.a diff --git a/code/libsdl/windows/mingw/lib64/libSDL264.la b/src/libsdl/windows/mingw/lib64/libSDL264.la similarity index 100% rename from code/libsdl/windows/mingw/lib64/libSDL264.la rename to src/libsdl/windows/mingw/lib64/libSDL264.la diff --git a/code/libvorbis/COPYING b/src/libvorbis/COPYING similarity index 100% rename from code/libvorbis/COPYING rename to src/libvorbis/COPYING diff --git a/code/libvorbis/include/vorbis/codec.h b/src/libvorbis/include/vorbis/codec.h similarity index 100% rename from code/libvorbis/include/vorbis/codec.h rename to src/libvorbis/include/vorbis/codec.h diff --git a/code/libvorbis/include/vorbis/vorbisenc.h b/src/libvorbis/include/vorbis/vorbisenc.h similarity index 100% rename from code/libvorbis/include/vorbis/vorbisenc.h rename to src/libvorbis/include/vorbis/vorbisenc.h diff --git a/code/libvorbis/include/vorbis/vorbisfile.h b/src/libvorbis/include/vorbis/vorbisfile.h similarity index 100% rename from code/libvorbis/include/vorbis/vorbisfile.h rename to src/libvorbis/include/vorbis/vorbisfile.h diff --git a/code/libvorbis/lib/analysis.c b/src/libvorbis/lib/analysis.c similarity index 100% rename from code/libvorbis/lib/analysis.c rename to src/libvorbis/lib/analysis.c diff --git a/code/libvorbis/lib/backends.h b/src/libvorbis/lib/backends.h similarity index 100% rename from code/libvorbis/lib/backends.h rename to src/libvorbis/lib/backends.h diff --git a/code/libvorbis/lib/bitrate.c b/src/libvorbis/lib/bitrate.c similarity index 100% rename from code/libvorbis/lib/bitrate.c rename to src/libvorbis/lib/bitrate.c diff --git a/code/libvorbis/lib/bitrate.h b/src/libvorbis/lib/bitrate.h similarity index 100% rename from code/libvorbis/lib/bitrate.h rename to src/libvorbis/lib/bitrate.h diff --git a/code/libvorbis/lib/block.c b/src/libvorbis/lib/block.c similarity index 100% rename from code/libvorbis/lib/block.c rename to src/libvorbis/lib/block.c diff --git a/code/libvorbis/lib/books/coupled/res_books_51.h b/src/libvorbis/lib/books/coupled/res_books_51.h similarity index 100% rename from code/libvorbis/lib/books/coupled/res_books_51.h rename to src/libvorbis/lib/books/coupled/res_books_51.h diff --git a/code/libvorbis/lib/books/coupled/res_books_stereo.h b/src/libvorbis/lib/books/coupled/res_books_stereo.h similarity index 100% rename from code/libvorbis/lib/books/coupled/res_books_stereo.h rename to src/libvorbis/lib/books/coupled/res_books_stereo.h diff --git a/code/libvorbis/lib/books/floor/floor_books.h b/src/libvorbis/lib/books/floor/floor_books.h similarity index 100% rename from code/libvorbis/lib/books/floor/floor_books.h rename to src/libvorbis/lib/books/floor/floor_books.h diff --git a/code/libvorbis/lib/books/uncoupled/res_books_uncoupled.h b/src/libvorbis/lib/books/uncoupled/res_books_uncoupled.h similarity index 100% rename from code/libvorbis/lib/books/uncoupled/res_books_uncoupled.h rename to src/libvorbis/lib/books/uncoupled/res_books_uncoupled.h diff --git a/code/libvorbis/lib/codebook.c b/src/libvorbis/lib/codebook.c similarity index 100% rename from code/libvorbis/lib/codebook.c rename to src/libvorbis/lib/codebook.c diff --git a/code/libvorbis/lib/codebook.h b/src/libvorbis/lib/codebook.h similarity index 100% rename from code/libvorbis/lib/codebook.h rename to src/libvorbis/lib/codebook.h diff --git a/code/libvorbis/lib/codec_internal.h b/src/libvorbis/lib/codec_internal.h similarity index 100% rename from code/libvorbis/lib/codec_internal.h rename to src/libvorbis/lib/codec_internal.h diff --git a/code/libvorbis/lib/envelope.c b/src/libvorbis/lib/envelope.c similarity index 100% rename from code/libvorbis/lib/envelope.c rename to src/libvorbis/lib/envelope.c diff --git a/code/libvorbis/lib/envelope.h b/src/libvorbis/lib/envelope.h similarity index 100% rename from code/libvorbis/lib/envelope.h rename to src/libvorbis/lib/envelope.h diff --git a/code/libvorbis/lib/floor0.c b/src/libvorbis/lib/floor0.c similarity index 100% rename from code/libvorbis/lib/floor0.c rename to src/libvorbis/lib/floor0.c diff --git a/code/libvorbis/lib/floor1.c b/src/libvorbis/lib/floor1.c similarity index 100% rename from code/libvorbis/lib/floor1.c rename to src/libvorbis/lib/floor1.c diff --git a/code/libvorbis/lib/highlevel.h b/src/libvorbis/lib/highlevel.h similarity index 100% rename from code/libvorbis/lib/highlevel.h rename to src/libvorbis/lib/highlevel.h diff --git a/code/libvorbis/lib/info.c b/src/libvorbis/lib/info.c similarity index 100% rename from code/libvorbis/lib/info.c rename to src/libvorbis/lib/info.c diff --git a/code/libvorbis/lib/lookup.c b/src/libvorbis/lib/lookup.c similarity index 100% rename from code/libvorbis/lib/lookup.c rename to src/libvorbis/lib/lookup.c diff --git a/code/libvorbis/lib/lookup.h b/src/libvorbis/lib/lookup.h similarity index 100% rename from code/libvorbis/lib/lookup.h rename to src/libvorbis/lib/lookup.h diff --git a/code/libvorbis/lib/lookup_data.h b/src/libvorbis/lib/lookup_data.h similarity index 100% rename from code/libvorbis/lib/lookup_data.h rename to src/libvorbis/lib/lookup_data.h diff --git a/code/libvorbis/lib/lpc.c b/src/libvorbis/lib/lpc.c similarity index 100% rename from code/libvorbis/lib/lpc.c rename to src/libvorbis/lib/lpc.c diff --git a/code/libvorbis/lib/lpc.h b/src/libvorbis/lib/lpc.h similarity index 100% rename from code/libvorbis/lib/lpc.h rename to src/libvorbis/lib/lpc.h diff --git a/code/libvorbis/lib/lsp.c b/src/libvorbis/lib/lsp.c similarity index 100% rename from code/libvorbis/lib/lsp.c rename to src/libvorbis/lib/lsp.c diff --git a/code/libvorbis/lib/lsp.h b/src/libvorbis/lib/lsp.h similarity index 100% rename from code/libvorbis/lib/lsp.h rename to src/libvorbis/lib/lsp.h diff --git a/code/libvorbis/lib/mapping0.c b/src/libvorbis/lib/mapping0.c similarity index 100% rename from code/libvorbis/lib/mapping0.c rename to src/libvorbis/lib/mapping0.c diff --git a/code/libvorbis/lib/masking.h b/src/libvorbis/lib/masking.h similarity index 100% rename from code/libvorbis/lib/masking.h rename to src/libvorbis/lib/masking.h diff --git a/code/libvorbis/lib/mdct.c b/src/libvorbis/lib/mdct.c similarity index 100% rename from code/libvorbis/lib/mdct.c rename to src/libvorbis/lib/mdct.c diff --git a/code/libvorbis/lib/mdct.h b/src/libvorbis/lib/mdct.h similarity index 100% rename from code/libvorbis/lib/mdct.h rename to src/libvorbis/lib/mdct.h diff --git a/code/libvorbis/lib/misc.h b/src/libvorbis/lib/misc.h similarity index 100% rename from code/libvorbis/lib/misc.h rename to src/libvorbis/lib/misc.h diff --git a/code/libvorbis/lib/modes/floor_all.h b/src/libvorbis/lib/modes/floor_all.h similarity index 100% rename from code/libvorbis/lib/modes/floor_all.h rename to src/libvorbis/lib/modes/floor_all.h diff --git a/code/libvorbis/lib/modes/psych_11.h b/src/libvorbis/lib/modes/psych_11.h similarity index 100% rename from code/libvorbis/lib/modes/psych_11.h rename to src/libvorbis/lib/modes/psych_11.h diff --git a/code/libvorbis/lib/modes/psych_16.h b/src/libvorbis/lib/modes/psych_16.h similarity index 100% rename from code/libvorbis/lib/modes/psych_16.h rename to src/libvorbis/lib/modes/psych_16.h diff --git a/code/libvorbis/lib/modes/psych_44.h b/src/libvorbis/lib/modes/psych_44.h similarity index 100% rename from code/libvorbis/lib/modes/psych_44.h rename to src/libvorbis/lib/modes/psych_44.h diff --git a/code/libvorbis/lib/modes/psych_8.h b/src/libvorbis/lib/modes/psych_8.h similarity index 100% rename from code/libvorbis/lib/modes/psych_8.h rename to src/libvorbis/lib/modes/psych_8.h diff --git a/code/libvorbis/lib/modes/residue_16.h b/src/libvorbis/lib/modes/residue_16.h similarity index 100% rename from code/libvorbis/lib/modes/residue_16.h rename to src/libvorbis/lib/modes/residue_16.h diff --git a/code/libvorbis/lib/modes/residue_44.h b/src/libvorbis/lib/modes/residue_44.h similarity index 100% rename from code/libvorbis/lib/modes/residue_44.h rename to src/libvorbis/lib/modes/residue_44.h diff --git a/code/libvorbis/lib/modes/residue_44p51.h b/src/libvorbis/lib/modes/residue_44p51.h similarity index 100% rename from code/libvorbis/lib/modes/residue_44p51.h rename to src/libvorbis/lib/modes/residue_44p51.h diff --git a/code/libvorbis/lib/modes/residue_44u.h b/src/libvorbis/lib/modes/residue_44u.h similarity index 100% rename from code/libvorbis/lib/modes/residue_44u.h rename to src/libvorbis/lib/modes/residue_44u.h diff --git a/code/libvorbis/lib/modes/residue_8.h b/src/libvorbis/lib/modes/residue_8.h similarity index 100% rename from code/libvorbis/lib/modes/residue_8.h rename to src/libvorbis/lib/modes/residue_8.h diff --git a/code/libvorbis/lib/modes/setup_11.h b/src/libvorbis/lib/modes/setup_11.h similarity index 100% rename from code/libvorbis/lib/modes/setup_11.h rename to src/libvorbis/lib/modes/setup_11.h diff --git a/code/libvorbis/lib/modes/setup_16.h b/src/libvorbis/lib/modes/setup_16.h similarity index 100% rename from code/libvorbis/lib/modes/setup_16.h rename to src/libvorbis/lib/modes/setup_16.h diff --git a/code/libvorbis/lib/modes/setup_22.h b/src/libvorbis/lib/modes/setup_22.h similarity index 100% rename from code/libvorbis/lib/modes/setup_22.h rename to src/libvorbis/lib/modes/setup_22.h diff --git a/code/libvorbis/lib/modes/setup_32.h b/src/libvorbis/lib/modes/setup_32.h similarity index 100% rename from code/libvorbis/lib/modes/setup_32.h rename to src/libvorbis/lib/modes/setup_32.h diff --git a/code/libvorbis/lib/modes/setup_44.h b/src/libvorbis/lib/modes/setup_44.h similarity index 100% rename from code/libvorbis/lib/modes/setup_44.h rename to src/libvorbis/lib/modes/setup_44.h diff --git a/code/libvorbis/lib/modes/setup_44p51.h b/src/libvorbis/lib/modes/setup_44p51.h similarity index 100% rename from code/libvorbis/lib/modes/setup_44p51.h rename to src/libvorbis/lib/modes/setup_44p51.h diff --git a/code/libvorbis/lib/modes/setup_44u.h b/src/libvorbis/lib/modes/setup_44u.h similarity index 100% rename from code/libvorbis/lib/modes/setup_44u.h rename to src/libvorbis/lib/modes/setup_44u.h diff --git a/code/libvorbis/lib/modes/setup_8.h b/src/libvorbis/lib/modes/setup_8.h similarity index 100% rename from code/libvorbis/lib/modes/setup_8.h rename to src/libvorbis/lib/modes/setup_8.h diff --git a/code/libvorbis/lib/modes/setup_X.h b/src/libvorbis/lib/modes/setup_X.h similarity index 100% rename from code/libvorbis/lib/modes/setup_X.h rename to src/libvorbis/lib/modes/setup_X.h diff --git a/code/libvorbis/lib/os.h b/src/libvorbis/lib/os.h similarity index 100% rename from code/libvorbis/lib/os.h rename to src/libvorbis/lib/os.h diff --git a/code/libvorbis/lib/psy.c b/src/libvorbis/lib/psy.c similarity index 100% rename from code/libvorbis/lib/psy.c rename to src/libvorbis/lib/psy.c diff --git a/code/libvorbis/lib/psy.h b/src/libvorbis/lib/psy.h similarity index 100% rename from code/libvorbis/lib/psy.h rename to src/libvorbis/lib/psy.h diff --git a/code/libvorbis/lib/registry.c b/src/libvorbis/lib/registry.c similarity index 100% rename from code/libvorbis/lib/registry.c rename to src/libvorbis/lib/registry.c diff --git a/code/libvorbis/lib/registry.h b/src/libvorbis/lib/registry.h similarity index 100% rename from code/libvorbis/lib/registry.h rename to src/libvorbis/lib/registry.h diff --git a/code/libvorbis/lib/res0.c b/src/libvorbis/lib/res0.c similarity index 100% rename from code/libvorbis/lib/res0.c rename to src/libvorbis/lib/res0.c diff --git a/code/libvorbis/lib/scales.h b/src/libvorbis/lib/scales.h similarity index 100% rename from code/libvorbis/lib/scales.h rename to src/libvorbis/lib/scales.h diff --git a/code/libvorbis/lib/sharedbook.c b/src/libvorbis/lib/sharedbook.c similarity index 100% rename from code/libvorbis/lib/sharedbook.c rename to src/libvorbis/lib/sharedbook.c diff --git a/code/libvorbis/lib/smallft.c b/src/libvorbis/lib/smallft.c similarity index 100% rename from code/libvorbis/lib/smallft.c rename to src/libvorbis/lib/smallft.c diff --git a/code/libvorbis/lib/smallft.h b/src/libvorbis/lib/smallft.h similarity index 100% rename from code/libvorbis/lib/smallft.h rename to src/libvorbis/lib/smallft.h diff --git a/code/libvorbis/lib/synthesis.c b/src/libvorbis/lib/synthesis.c similarity index 100% rename from code/libvorbis/lib/synthesis.c rename to src/libvorbis/lib/synthesis.c diff --git a/code/libvorbis/lib/vorbisfile.c b/src/libvorbis/lib/vorbisfile.c similarity index 100% rename from code/libvorbis/lib/vorbisfile.c rename to src/libvorbis/lib/vorbisfile.c diff --git a/code/libvorbis/lib/window.c b/src/libvorbis/lib/window.c similarity index 100% rename from code/libvorbis/lib/window.c rename to src/libvorbis/lib/window.c diff --git a/code/libvorbis/lib/window.h b/src/libvorbis/lib/window.h similarity index 100% rename from code/libvorbis/lib/window.h rename to src/libvorbis/lib/window.h diff --git a/code/qcommon/cm_load.c b/src/qcommon/cm_load.c similarity index 100% rename from code/qcommon/cm_load.c rename to src/qcommon/cm_load.c diff --git a/code/qcommon/cm_local.h b/src/qcommon/cm_local.h similarity index 100% rename from code/qcommon/cm_local.h rename to src/qcommon/cm_local.h diff --git a/code/qcommon/cm_patch.c b/src/qcommon/cm_patch.c similarity index 100% rename from code/qcommon/cm_patch.c rename to src/qcommon/cm_patch.c diff --git a/code/qcommon/cm_patch.h b/src/qcommon/cm_patch.h similarity index 100% rename from code/qcommon/cm_patch.h rename to src/qcommon/cm_patch.h diff --git a/code/qcommon/cm_polylib.c b/src/qcommon/cm_polylib.c similarity index 100% rename from code/qcommon/cm_polylib.c rename to src/qcommon/cm_polylib.c diff --git a/code/qcommon/cm_polylib.h b/src/qcommon/cm_polylib.h similarity index 100% rename from code/qcommon/cm_polylib.h rename to src/qcommon/cm_polylib.h diff --git a/code/qcommon/cm_public.h b/src/qcommon/cm_public.h similarity index 100% rename from code/qcommon/cm_public.h rename to src/qcommon/cm_public.h diff --git a/code/qcommon/cm_test.c b/src/qcommon/cm_test.c similarity index 100% rename from code/qcommon/cm_test.c rename to src/qcommon/cm_test.c diff --git a/code/qcommon/cm_trace.c b/src/qcommon/cm_trace.c similarity index 100% rename from code/qcommon/cm_trace.c rename to src/qcommon/cm_trace.c diff --git a/code/qcommon/cmd.c b/src/qcommon/cmd.c similarity index 81% rename from code/qcommon/cmd.c rename to src/qcommon/cmd.c index 943ee41cae..c3f977f386 100644 --- a/code/qcommon/cmd.c +++ b/src/qcommon/cmd.c @@ -19,11 +19,13 @@ along with Quake III Arena source code; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -// cmd.c -- Quake script command processing module - #include "q_shared.h" #include "qcommon.h" +#ifdef USE_LUA +#include "lua_debug.h" +#endif + #define MAX_CMD_BUFFER 65536 typedef struct { @@ -408,13 +410,22 @@ static void Cmd_Exec_f( void ) { Cbuf_InsertText( f.c ); + // Note: File buffer is intentionally not freed here + // Config files remain loaded in memory for the duration of the session + // FS_LoadStack will be checked later during hunk initialization + // + // The inserted text has been copied into the command buffer by + // Cbuf_InsertText, so it's safe to free the file memory now. Leaving + // these buffers allocated can cause fs_loadStack to be non-zero at + // hunk initialization and trigger fatal errors. Freeing here keeps + // memory accounting balanced while preserving behavior. + FS_FreeFile( f.v ); + #ifdef DELAY_WRITECONFIG if ( !Q_stricmp( filename, Q3CONFIG_CFG ) ) { Com_WriteConfiguration(); // to avoid loading outdated values } #endif - - FS_FreeFile( f.v ); } @@ -440,7 +451,7 @@ static void Cmd_Vstr_f( void ) { /* =============== -Cmd_Echo_f +Cmd_f Just prints the rest of the line to the console =============== @@ -502,7 +513,7 @@ Cmd_Argv ============ */ const char *Cmd_Argv( int arg ) { - if ( (unsigned)arg >= cmd_argc ) { + if ( arg < 0 || arg >= cmd_argc ) { return ""; } return cmd_argv[arg]; @@ -532,15 +543,60 @@ Returns a single string containing argv(arg) to argv(argc()-1) char *Cmd_ArgsFrom( int arg ) { static char cmd_args[BIG_INFO_STRING], *s; int i; + size_t remaining; + + // Input validation + if (arg < 0) { + arg = 0; + } + if (arg >= cmd_argc) { + cmd_args[0] = '\0'; + return cmd_args; + } s = cmd_args; *s = '\0'; - if (arg < 0) - arg = 0; + remaining = sizeof(cmd_args); + for ( i = arg ; i < cmd_argc ; i++ ) { + // Validate argument pointer + if (!cmd_argv[i]) { + Com_Printf( S_COLOR_RED "Cmd_ArgsFrom: NULL argument at index %d\n", i ); + break; + } + + size_t arg_len = strlen(cmd_argv[i]); + + // Validate argument length + if (arg_len >= MAX_STRING_CHARS) { + Com_Printf( S_COLOR_RED "Cmd_ArgsFrom: Argument %d too long (%d >= %d), truncating\n", + i, (int)arg_len, MAX_STRING_CHARS ); + arg_len = MAX_STRING_CHARS - 1; + } + + // Check if we can fit this argument (+ space/null terminator) + size_t needed_space = arg_len + 1; // +1 for space or null + if (i != cmd_argc-1) { + needed_space += 1; // extra space for separator + } + + if (needed_space >= remaining) { + Com_Printf( S_COLOR_RED "Cmd_ArgsFrom: Buffer full, truncating at argument %d\n", i ); + break; + } + + // Add the argument s = Q_stradd( s, cmd_argv[i] ); + remaining -= arg_len; + + // Add space between arguments if ( i != cmd_argc-1 ) { + if (remaining < 2) { // need space for " " and null + Com_Printf( S_COLOR_RED "Cmd_ArgsFrom: Buffer full after argument %d\n", i ); + break; + } s = Q_stradd( s, " " ); + remaining -= 1; } } @@ -610,12 +666,44 @@ will point into this temporary buffer. */ // NOTE TTimo define that to track tokenization issues //#define TKN_DBG +/* +================= +Cmd_SanitizeInput +Sanitize command input to prevent malicious characters and buffer issues +================= +*/ +static void Cmd_SanitizeInput(char *input, int maxLength) { + if (!input || maxLength <= 0) { + return; + } + + char *dst = input; + const char *src = input; + int count = 0; + + // Sanitize input: remove control characters, limit length + while (*src && count < maxLength - 1) { + // Allow printable ASCII characters, spaces, and common symbols + if ((*src >= 32 && *src <= 126) || *src == '\t' || *src == '\n') { + *dst++ = *src; + count++; + } + src++; + } + + // Null terminate + *dst = '\0'; +} + static void Cmd_TokenizeString2( const char *text_in, qboolean ignoreQuotes ) { const char *text; char *textOut; + char sanitizedInput[MAX_CMD_BUFFER]; #ifdef TKN_DBG - // FIXME TTimo blunt hook to try to find the tokenization of userinfo + // FIXME: Debug hook for tokenization - this is a temporary debugging aid. + // Consider implementing proper tokenization debugging with structured output + // (token boundaries, types, etc.) rather than just printing the input string. Com_DPrintf("Cmd_TokenizeString: %s\n", text_in); #endif @@ -627,16 +715,28 @@ static void Cmd_TokenizeString2( const char *text_in, qboolean ignoreQuotes ) { return; } - Q_strncpyz( cmd_cmd, text_in, sizeof( cmd_cmd ) ); + // Sanitize input to prevent malicious characters + Q_strncpyz(sanitizedInput, text_in, sizeof(sanitizedInput)); + Cmd_SanitizeInput(sanitizedInput, sizeof(sanitizedInput)); + + Q_strncpyz( cmd_cmd, sanitizedInput, sizeof( cmd_cmd ) ); text = cmd_cmd; // read from safe-length buffer textOut = cmd_tokenized; while ( 1 ) { - if ( cmd_argc >= ARRAY_LEN( cmd_argv ) ) { + if ( cmd_argc >= MAX_STRING_TOKENS ) { + Com_Printf( S_COLOR_RED "Cmd_TokenizeString: Too many tokens (%d >= %d), truncating\n", cmd_argc, MAX_STRING_TOKENS ); return; // this is usually something malicious } + // Check if we have enough space left in the tokenized buffer (reserve space for current token + null terminator) + if ( textOut - cmd_tokenized >= (int)sizeof( cmd_tokenized ) - MAX_STRING_CHARS - 1 ) { + Com_Printf( S_COLOR_RED "Cmd_TokenizeString: Tokenized buffer nearly full (%d/%d bytes), truncating command\n", + (int)(textOut - cmd_tokenized), (int)sizeof(cmd_tokenized) ); + return; // prevent buffer overflow + } + while ( 1 ) { // skip whitespace while ( *text && *text <= ' ' ) { @@ -674,14 +774,26 @@ static void Cmd_TokenizeString2( const char *text_in, qboolean ignoreQuotes ) { cmd_argv[cmd_argc] = textOut; cmd_argc++; text++; + + // Parse quoted string with bounds checking while ( *text && *text != '"' ) { + // Check bounds before adding character + if ( textOut - cmd_tokenized >= (int)sizeof( cmd_tokenized ) - 2 ) { + Com_Printf( S_COLOR_RED "Cmd_TokenizeString: Quoted string too long, truncating\n" ); + break; + } *textOut++ = *text++; } + *textOut++ = '\0'; - if ( !*text ) { - return; // all tokens parsed + + // Skip closing quote if present, warn if missing + if ( *text == '"' ) { + text++; + } else if ( *text ) { + Com_DPrintf( "Cmd_TokenizeString: Missing closing quote in command\n" ); } - text++; + continue; } @@ -707,6 +819,12 @@ static void Cmd_TokenizeString2( const char *text_in, qboolean ignoreQuotes ) { break; } + // Bounds check before adding character + if ( textOut - cmd_tokenized >= (int)sizeof( cmd_tokenized ) - 2 ) { + Com_Printf( S_COLOR_RED "Cmd_TokenizeString: Token too long, truncating\n" ); + break; + } + *textOut++ = *text++; } @@ -1011,6 +1129,7 @@ Cmd_CompleteCfgName ================== */ static void Cmd_CompleteCfgName( const char *args, int argNum ) { + (void)args; // Suppress unused parameter warning if ( argNum == 2 ) { Field_CompleteFilename( "", "cfg", qfalse, FS_MATCH_ANY | FS_MATCH_STICK | FS_MATCH_SUBDIRS ); } @@ -1023,6 +1142,7 @@ Cmd_CompleteWriteCfgName ================== */ void Cmd_CompleteWriteCfgName( const char *args, int argNum ) { + (void)args; // Suppress unused parameter warning if( argNum == 2 ) { Field_CompleteFilename( "", "cfg", qfalse, FS_MATCH_EXTERN | FS_MATCH_STICK ); } @@ -1044,4 +1164,14 @@ void Cmd_Init( void ) { Cmd_SetCommandCompletionFunc( "vstr", Cvar_CompleteCvarName ); Cmd_AddCommand ("echo",Cmd_Echo_f); Cmd_AddCommand ("wait", Cmd_Wait_f); -} + +#ifdef USE_LUA + // Script debugging commands + extern void Cmd_ScriptReload_f(void); + extern void Cmd_ScriptList_f(void); + extern void Cmd_ScriptDump_f(void); + Cmd_AddCommand("script_reload", Cmd_ScriptReload_f); + Cmd_AddCommand("script_list", Cmd_ScriptList_f); + Cmd_AddCommand("script_dump", Cmd_ScriptDump_f); +#endif +} \ No newline at end of file diff --git a/code/qcommon/common.c b/src/qcommon/common.c similarity index 99% rename from code/qcommon/common.c rename to src/qcommon/common.c index cceae6575c..73643f1a4f 100644 --- a/code/qcommon/common.c +++ b/src/qcommon/common.c @@ -207,10 +207,10 @@ void FORMAT_PRINTF(1, 2) QDECL Com_Printf( const char *fmt, ... ) { // logfile if ( com_logfile && com_logfile->integer ) { - // TTimo: only open the qconsole.log if the filesystem is in an initialized state - // also, avoid recursing in the qconsole.log opening (i.e. if fs_debug is on) + // TTimo: only open the console.log if the filesystem is in an initialized state + // also, avoid recursing in the console.log opening (i.e. if fs_debug is on) if ( logfile == FS_INVALID_HANDLE && FS_Initialized() && !opening_qconsole ) { - const char *logName = "qconsole.log"; + const char *logName = "console.log"; int mode; opening_qconsole = qtrue; diff --git a/code/qcommon/cvar.c b/src/qcommon/cvar.c similarity index 100% rename from code/qcommon/cvar.c rename to src/qcommon/cvar.c diff --git a/code/qcommon/files.c b/src/qcommon/files.c similarity index 99% rename from code/qcommon/files.c rename to src/qcommon/files.c index bdf4770725..2dd7c55f7f 100644 --- a/code/qcommon/files.c +++ b/src/qcommon/files.c @@ -4836,10 +4836,12 @@ static void FS_Startup( void ) { fs_gamedirvar->modified = qfalse; // We just loaded, it's not modified - // check original q3a files + // check original q3a files (can be disabled via SKIP_IDPAK_CHECK) +#ifndef SKIP_IDPAK_CHECK if ( FS_IsBaseGame( BASEGAME ) || FS_IsBaseGame( BASEDEMO ) ) { FS_CheckIdPaks(); } +#endif #ifdef FS_MISSING if (missingFiles == NULL) { @@ -4924,8 +4926,7 @@ static void FS_CheckIdPaks( void ) Com_Printf("\n\n" "**************************************************\n" "ERROR: pak0.pk3 is present but its checksum (%u)\n" - "is not correct. Please re-copy pak0.pk3 from your\n" - "legitimate Q3 CDROM.\n" + "is not correct.\n" "**************************************************\n\n\n", path->pack->checksum ); } @@ -4934,8 +4935,7 @@ static void FS_CheckIdPaks( void ) Com_Printf("\n\n" "**************************************************\n" "ERROR: pak%d.pk3 is present but its checksum (%u)\n" - "is not correct. Please re-install Quake 3 Arena \n" - "Point Release v1.32 pk3 files\n" + "is not correct.\n" "**************************************************\n\n\n", pakBasename[3]-'0', path->pack->checksum ); } @@ -4953,15 +4953,13 @@ static void FS_CheckIdPaks( void ) if((foundPak&1) != 1 ) { Com_Printf("\n\n" - "pak0.pk3 is missing. Please copy it\n" - "from your legitimate Q3 CDROM.\n"); + "pak0.pk3 is missing.\n"); } if((foundPak&0x1fe) != 0x1fe ) { Com_Printf("\n\n" - "Point Release files are missing. Please\n" - "re-install the 1.32 point release.\n"); + "Point Release files are missing.\n"); } Com_Printf("\n\n" diff --git a/code/qcommon/history.c b/src/qcommon/history.c similarity index 100% rename from code/qcommon/history.c rename to src/qcommon/history.c diff --git a/code/qcommon/huffman.c b/src/qcommon/huffman.c similarity index 100% rename from code/qcommon/huffman.c rename to src/qcommon/huffman.c diff --git a/code/qcommon/huffman_static.c b/src/qcommon/huffman_static.c similarity index 100% rename from code/qcommon/huffman_static.c rename to src/qcommon/huffman_static.c diff --git a/code/qcommon/json.h b/src/qcommon/json.h similarity index 100% rename from code/qcommon/json.h rename to src/qcommon/json.h diff --git a/code/qcommon/keys.c b/src/qcommon/keys.c similarity index 100% rename from code/qcommon/keys.c rename to src/qcommon/keys.c diff --git a/code/qcommon/md4.c b/src/qcommon/md4.c similarity index 100% rename from code/qcommon/md4.c rename to src/qcommon/md4.c diff --git a/code/qcommon/md5.c b/src/qcommon/md5.c similarity index 100% rename from code/qcommon/md5.c rename to src/qcommon/md5.c diff --git a/code/qcommon/msg.c b/src/qcommon/msg.c similarity index 100% rename from code/qcommon/msg.c rename to src/qcommon/msg.c diff --git a/code/qcommon/net_chan.c b/src/qcommon/net_chan.c similarity index 100% rename from code/qcommon/net_chan.c rename to src/qcommon/net_chan.c diff --git a/code/qcommon/net_ip.c b/src/qcommon/net_ip.c similarity index 100% rename from code/qcommon/net_ip.c rename to src/qcommon/net_ip.c diff --git a/code/qcommon/puff.c b/src/qcommon/puff.c similarity index 100% rename from code/qcommon/puff.c rename to src/qcommon/puff.c diff --git a/code/qcommon/puff.h b/src/qcommon/puff.h similarity index 100% rename from code/qcommon/puff.h rename to src/qcommon/puff.h diff --git a/code/qcommon/q_math.c b/src/qcommon/q_math.c similarity index 100% rename from code/qcommon/q_math.c rename to src/qcommon/q_math.c diff --git a/code/qcommon/q_platform.h b/src/qcommon/q_platform.h similarity index 100% rename from code/qcommon/q_platform.h rename to src/qcommon/q_platform.h diff --git a/code/qcommon/q_shared.c b/src/qcommon/q_shared.c similarity index 100% rename from code/qcommon/q_shared.c rename to src/qcommon/q_shared.c diff --git a/code/qcommon/q_shared.h b/src/qcommon/q_shared.h similarity index 99% rename from code/qcommon/q_shared.h rename to src/qcommon/q_shared.h index b4433b718a..0357af9f44 100644 --- a/code/qcommon/q_shared.h +++ b/src/qcommon/q_shared.h @@ -26,12 +26,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // q_shared.h -- included first by ALL program modules. // A user mod should never modify this file -#define Q3_VERSION "Q3 1.32e" +#define Q3_VERSION "id Tech 3" #ifndef SVN_VERSION #define SVN_VERSION Q3_VERSION #endif -#define CLIENT_WINDOW_TITLE "Quake 3: Arena" -#define CONSOLE_WINDOW_TITLE "Quake 3 Console" +#define CLIENT_WINDOW_TITLE "id Tech 3" +#define CONSOLE_WINDOW_TITLE "id Tech 3 Console" // 1.32 released 7-10-2002 //#define DEFAULT_GAME "edawn" diff --git a/code/qcommon/qcommon.h b/src/qcommon/qcommon.h similarity index 100% rename from code/qcommon/qcommon.h rename to src/qcommon/qcommon.h diff --git a/code/qcommon/qfiles.h b/src/qcommon/qfiles.h similarity index 100% rename from code/qcommon/qfiles.h rename to src/qcommon/qfiles.h diff --git a/code/qcommon/surfaceflags.h b/src/qcommon/surfaceflags.h similarity index 100% rename from code/qcommon/surfaceflags.h rename to src/qcommon/surfaceflags.h diff --git a/code/qcommon/unzip.c b/src/qcommon/unzip.c similarity index 100% rename from code/qcommon/unzip.c rename to src/qcommon/unzip.c diff --git a/code/qcommon/unzip.h b/src/qcommon/unzip.h similarity index 100% rename from code/qcommon/unzip.h rename to src/qcommon/unzip.h diff --git a/code/qcommon/vm.c b/src/qcommon/vm.c similarity index 100% rename from code/qcommon/vm.c rename to src/qcommon/vm.c diff --git a/code/qcommon/vm_aarch64.c b/src/qcommon/vm_aarch64.c similarity index 99% rename from code/qcommon/vm_aarch64.c rename to src/qcommon/vm_aarch64.c index b427c7d53d..9afe0f5d99 100644 --- a/code/qcommon/vm_aarch64.c +++ b/src/qcommon/vm_aarch64.c @@ -39,6 +39,24 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "vm_local.h" +// Provide portable icache-clear wrapper for non-Windows platforms +#ifndef _WIN32 +# if defined(__clang__) || defined(__GNUC__) +static inline void vm_clear_icache(void *start, void *end) +{ + /* Clang/GCC builtin for clearing the instruction cache */ + __builtin___clear_cache((char*)start, (char*)end); +} +# else +/* Fallback: declare platform-specific symbol if available */ +extern void __clear_cache(void* start, void* end); +static inline void vm_clear_icache(void *start, void *end) +{ + __clear_cache(start, end); +} +# endif +#endif + #define NUM_PASSES 1 // additional integrity checks @@ -3483,7 +3501,7 @@ qboolean VM_Compile( vm_t *vm, vmHeader_t *header ) } // clear icache, http://blogs.arm.com/software-enablement/141-caches-and-self-modifying-code/ - __clear_cache( vm->codeBase.ptr, vm->codeBase.ptr + vm->codeLength ); + vm_clear_icache( vm->codeBase.ptr, (char*)vm->codeBase.ptr + vm->codeLength ); #endif vm->destroy = VM_Destroy_Compiled; diff --git a/code/qcommon/vm_armv7l.c b/src/qcommon/vm_armv7l.c similarity index 100% rename from code/qcommon/vm_armv7l.c rename to src/qcommon/vm_armv7l.c diff --git a/code/qcommon/vm_interpreted.c b/src/qcommon/vm_interpreted.c similarity index 100% rename from code/qcommon/vm_interpreted.c rename to src/qcommon/vm_interpreted.c diff --git a/code/qcommon/vm_local.h b/src/qcommon/vm_local.h similarity index 100% rename from code/qcommon/vm_local.h rename to src/qcommon/vm_local.h diff --git a/code/qcommon/vm_x86.c b/src/qcommon/vm_x86.c similarity index 100% rename from code/qcommon/vm_x86.c rename to src/qcommon/vm_x86.c diff --git a/code/renderer/iqm.h b/src/renderer/iqm.h similarity index 100% rename from code/renderer/iqm.h rename to src/renderer/iqm.h diff --git a/code/renderer/qgl.h b/src/renderer/qgl.h similarity index 100% rename from code/renderer/qgl.h rename to src/renderer/qgl.h diff --git a/code/renderer/tr_animation.c b/src/renderer/tr_animation.c similarity index 100% rename from code/renderer/tr_animation.c rename to src/renderer/tr_animation.c diff --git a/code/renderer/tr_arb.c b/src/renderer/tr_arb.c similarity index 100% rename from code/renderer/tr_arb.c rename to src/renderer/tr_arb.c diff --git a/code/renderer/tr_backend.c b/src/renderer/tr_backend.c similarity index 100% rename from code/renderer/tr_backend.c rename to src/renderer/tr_backend.c diff --git a/code/renderer/tr_bsp.c b/src/renderer/tr_bsp.c similarity index 100% rename from code/renderer/tr_bsp.c rename to src/renderer/tr_bsp.c diff --git a/code/renderer/tr_cmds.c b/src/renderer/tr_cmds.c similarity index 100% rename from code/renderer/tr_cmds.c rename to src/renderer/tr_cmds.c diff --git a/code/renderer/tr_common.h b/src/renderer/tr_common.h similarity index 100% rename from code/renderer/tr_common.h rename to src/renderer/tr_common.h diff --git a/code/renderer/tr_curve.c b/src/renderer/tr_curve.c similarity index 100% rename from code/renderer/tr_curve.c rename to src/renderer/tr_curve.c diff --git a/code/renderer/tr_flares.c b/src/renderer/tr_flares.c similarity index 100% rename from code/renderer/tr_flares.c rename to src/renderer/tr_flares.c diff --git a/code/renderer/tr_image.c b/src/renderer/tr_image.c similarity index 100% rename from code/renderer/tr_image.c rename to src/renderer/tr_image.c diff --git a/code/renderer/tr_init.c b/src/renderer/tr_init.c similarity index 100% rename from code/renderer/tr_init.c rename to src/renderer/tr_init.c diff --git a/code/renderer/tr_light.c b/src/renderer/tr_light.c similarity index 100% rename from code/renderer/tr_light.c rename to src/renderer/tr_light.c diff --git a/code/renderer/tr_local.h b/src/renderer/tr_local.h similarity index 100% rename from code/renderer/tr_local.h rename to src/renderer/tr_local.h diff --git a/code/renderer/tr_main.c b/src/renderer/tr_main.c similarity index 100% rename from code/renderer/tr_main.c rename to src/renderer/tr_main.c diff --git a/code/renderer/tr_marks.c b/src/renderer/tr_marks.c similarity index 100% rename from code/renderer/tr_marks.c rename to src/renderer/tr_marks.c diff --git a/code/renderer/tr_mesh.c b/src/renderer/tr_mesh.c similarity index 100% rename from code/renderer/tr_mesh.c rename to src/renderer/tr_mesh.c diff --git a/code/renderer/tr_model.c b/src/renderer/tr_model.c similarity index 100% rename from code/renderer/tr_model.c rename to src/renderer/tr_model.c diff --git a/code/renderer/tr_model_iqm.c b/src/renderer/tr_model_iqm.c similarity index 100% rename from code/renderer/tr_model_iqm.c rename to src/renderer/tr_model_iqm.c diff --git a/code/renderer/tr_scene.c b/src/renderer/tr_scene.c similarity index 100% rename from code/renderer/tr_scene.c rename to src/renderer/tr_scene.c diff --git a/code/renderer/tr_shade.c b/src/renderer/tr_shade.c similarity index 100% rename from code/renderer/tr_shade.c rename to src/renderer/tr_shade.c diff --git a/code/renderer/tr_shade_calc.c b/src/renderer/tr_shade_calc.c similarity index 100% rename from code/renderer/tr_shade_calc.c rename to src/renderer/tr_shade_calc.c diff --git a/code/renderer/tr_shader.c b/src/renderer/tr_shader.c similarity index 100% rename from code/renderer/tr_shader.c rename to src/renderer/tr_shader.c diff --git a/code/renderer/tr_shadows.c b/src/renderer/tr_shadows.c similarity index 100% rename from code/renderer/tr_shadows.c rename to src/renderer/tr_shadows.c diff --git a/code/renderer/tr_sky.c b/src/renderer/tr_sky.c similarity index 100% rename from code/renderer/tr_sky.c rename to src/renderer/tr_sky.c diff --git a/code/renderer/tr_surface.c b/src/renderer/tr_surface.c similarity index 100% rename from code/renderer/tr_surface.c rename to src/renderer/tr_surface.c diff --git a/code/renderer/tr_vbo.c b/src/renderer/tr_vbo.c similarity index 100% rename from code/renderer/tr_vbo.c rename to src/renderer/tr_vbo.c diff --git a/code/renderer/tr_world.c b/src/renderer/tr_world.c similarity index 100% rename from code/renderer/tr_world.c rename to src/renderer/tr_world.c diff --git a/code/renderercommon/tr_font.c b/src/renderercommon/tr_font.c similarity index 100% rename from code/renderercommon/tr_font.c rename to src/renderercommon/tr_font.c diff --git a/code/renderercommon/tr_image_bmp.c b/src/renderercommon/tr_image_bmp.c similarity index 100% rename from code/renderercommon/tr_image_bmp.c rename to src/renderercommon/tr_image_bmp.c diff --git a/code/renderercommon/tr_image_jpg.c b/src/renderercommon/tr_image_jpg.c similarity index 100% rename from code/renderercommon/tr_image_jpg.c rename to src/renderercommon/tr_image_jpg.c diff --git a/code/renderercommon/tr_image_pcx.c b/src/renderercommon/tr_image_pcx.c similarity index 100% rename from code/renderercommon/tr_image_pcx.c rename to src/renderercommon/tr_image_pcx.c diff --git a/code/renderercommon/tr_image_png.c b/src/renderercommon/tr_image_png.c similarity index 100% rename from code/renderercommon/tr_image_png.c rename to src/renderercommon/tr_image_png.c diff --git a/code/renderercommon/tr_image_tga.c b/src/renderercommon/tr_image_tga.c similarity index 100% rename from code/renderercommon/tr_image_tga.c rename to src/renderercommon/tr_image_tga.c diff --git a/code/renderercommon/tr_noise.c b/src/renderercommon/tr_noise.c similarity index 100% rename from code/renderercommon/tr_noise.c rename to src/renderercommon/tr_noise.c diff --git a/code/renderercommon/tr_public.h b/src/renderercommon/tr_public.h similarity index 100% rename from code/renderercommon/tr_public.h rename to src/renderercommon/tr_public.h diff --git a/code/renderercommon/tr_types.h b/src/renderercommon/tr_types.h similarity index 100% rename from code/renderercommon/tr_types.h rename to src/renderercommon/tr_types.h diff --git a/code/renderercommon/vulkan/vk_platform.h b/src/renderercommon/vulkan/vk_platform.h similarity index 100% rename from code/renderercommon/vulkan/vk_platform.h rename to src/renderercommon/vulkan/vk_platform.h diff --git a/code/renderercommon/vulkan/vulkan.h b/src/renderercommon/vulkan/vulkan.h similarity index 100% rename from code/renderercommon/vulkan/vulkan.h rename to src/renderercommon/vulkan/vulkan.h diff --git a/code/renderercommon/vulkan/vulkan_core.h b/src/renderercommon/vulkan/vulkan_core.h similarity index 100% rename from code/renderercommon/vulkan/vulkan_core.h rename to src/renderercommon/vulkan/vulkan_core.h diff --git a/code/renderercommon/vulkan/vulkan_win32.h b/src/renderercommon/vulkan/vulkan_win32.h similarity index 100% rename from code/renderercommon/vulkan/vulkan_win32.h rename to src/renderercommon/vulkan/vulkan_win32.h diff --git a/code/renderercommon/vulkan/vulkan_xlib.h b/src/renderercommon/vulkan/vulkan_xlib.h similarity index 100% rename from code/renderercommon/vulkan/vulkan_xlib.h rename to src/renderercommon/vulkan/vulkan_xlib.h diff --git a/code/renderercommon/vulkan/vulkan_xlib_xrandr.h b/src/renderercommon/vulkan/vulkan_xlib_xrandr.h similarity index 100% rename from code/renderercommon/vulkan/vulkan_xlib_xrandr.h rename to src/renderercommon/vulkan/vulkan_xlib_xrandr.h diff --git a/code/renderervk/iqm.h b/src/renderervk/iqm.h similarity index 100% rename from code/renderervk/iqm.h rename to src/renderervk/iqm.h diff --git a/code/renderervk/json.h b/src/renderervk/json.h similarity index 100% rename from code/renderervk/json.h rename to src/renderervk/json.h diff --git a/code/renderervk/json.hpp b/src/renderervk/json.hpp similarity index 100% rename from code/renderervk/json.hpp rename to src/renderervk/json.hpp diff --git a/code/renderervk/shaders/compile.bat b/src/renderervk/shaders/compile.bat similarity index 100% rename from code/renderervk/shaders/compile.bat rename to src/renderervk/shaders/compile.bat diff --git a/code/renderervk/shaders/compile_threaded.bat b/src/renderervk/shaders/compile_threaded.bat similarity index 100% rename from code/renderervk/shaders/compile_threaded.bat rename to src/renderervk/shaders/compile_threaded.bat diff --git a/code/renderervk/shaders/glsl/blend.frag b/src/renderervk/shaders/glsl/blend.frag similarity index 100% rename from code/renderervk/shaders/glsl/blend.frag rename to src/renderervk/shaders/glsl/blend.frag diff --git a/code/renderervk/shaders/glsl/bloom.frag b/src/renderervk/shaders/glsl/bloom.frag similarity index 100% rename from code/renderervk/shaders/glsl/bloom.frag rename to src/renderervk/shaders/glsl/bloom.frag diff --git a/code/renderervk/shaders/glsl/blur.frag b/src/renderervk/shaders/glsl/blur.frag similarity index 100% rename from code/renderervk/shaders/glsl/blur.frag rename to src/renderervk/shaders/glsl/blur.frag diff --git a/code/renderervk/shaders/glsl/brdflut.frag b/src/renderervk/shaders/glsl/brdflut.frag similarity index 100% rename from code/renderervk/shaders/glsl/brdflut.frag rename to src/renderervk/shaders/glsl/brdflut.frag diff --git a/code/renderervk/shaders/glsl/color.frag b/src/renderervk/shaders/glsl/color.frag similarity index 100% rename from code/renderervk/shaders/glsl/color.frag rename to src/renderervk/shaders/glsl/color.frag diff --git a/code/renderervk/shaders/glsl/color.vert b/src/renderervk/shaders/glsl/color.vert similarity index 100% rename from code/renderervk/shaders/glsl/color.vert rename to src/renderervk/shaders/glsl/color.vert diff --git a/code/renderervk/shaders/glsl/dot.frag b/src/renderervk/shaders/glsl/dot.frag similarity index 100% rename from code/renderervk/shaders/glsl/dot.frag rename to src/renderervk/shaders/glsl/dot.frag diff --git a/code/renderervk/shaders/glsl/dot.vert b/src/renderervk/shaders/glsl/dot.vert similarity index 100% rename from code/renderervk/shaders/glsl/dot.vert rename to src/renderervk/shaders/glsl/dot.vert diff --git a/code/renderervk/shaders/glsl/filtercube.geom b/src/renderervk/shaders/glsl/filtercube.geom similarity index 100% rename from code/renderervk/shaders/glsl/filtercube.geom rename to src/renderervk/shaders/glsl/filtercube.geom diff --git a/code/renderervk/shaders/glsl/filtercube.vert b/src/renderervk/shaders/glsl/filtercube.vert similarity index 100% rename from code/renderervk/shaders/glsl/filtercube.vert rename to src/renderervk/shaders/glsl/filtercube.vert diff --git a/code/renderervk/shaders/glsl/fog.frag b/src/renderervk/shaders/glsl/fog.frag similarity index 100% rename from code/renderervk/shaders/glsl/fog.frag rename to src/renderervk/shaders/glsl/fog.frag diff --git a/code/renderervk/shaders/glsl/fog.vert b/src/renderervk/shaders/glsl/fog.vert similarity index 100% rename from code/renderervk/shaders/glsl/fog.vert rename to src/renderervk/shaders/glsl/fog.vert diff --git a/code/renderervk/shaders/glsl/gamma.frag b/src/renderervk/shaders/glsl/gamma.frag similarity index 100% rename from code/renderervk/shaders/glsl/gamma.frag rename to src/renderervk/shaders/glsl/gamma.frag diff --git a/code/renderervk/shaders/glsl/gamma.vert b/src/renderervk/shaders/glsl/gamma.vert similarity index 100% rename from code/renderervk/shaders/glsl/gamma.vert rename to src/renderervk/shaders/glsl/gamma.vert diff --git a/code/renderervk/shaders/glsl/gen_frag.tmpl b/src/renderervk/shaders/glsl/gen_frag.tmpl similarity index 100% rename from code/renderervk/shaders/glsl/gen_frag.tmpl rename to src/renderervk/shaders/glsl/gen_frag.tmpl diff --git a/code/renderervk/shaders/glsl/gen_vert.tmpl b/src/renderervk/shaders/glsl/gen_vert.tmpl similarity index 100% rename from code/renderervk/shaders/glsl/gen_vert.tmpl rename to src/renderervk/shaders/glsl/gen_vert.tmpl diff --git a/code/renderervk/shaders/glsl/irradiancecube.frag b/src/renderervk/shaders/glsl/irradiancecube.frag similarity index 100% rename from code/renderervk/shaders/glsl/irradiancecube.frag rename to src/renderervk/shaders/glsl/irradiancecube.frag diff --git a/code/renderervk/shaders/glsl/light_frag.tmpl b/src/renderervk/shaders/glsl/light_frag.tmpl similarity index 100% rename from code/renderervk/shaders/glsl/light_frag.tmpl rename to src/renderervk/shaders/glsl/light_frag.tmpl diff --git a/code/renderervk/shaders/glsl/light_vert.tmpl b/src/renderervk/shaders/glsl/light_vert.tmpl similarity index 100% rename from code/renderervk/shaders/glsl/light_vert.tmpl rename to src/renderervk/shaders/glsl/light_vert.tmpl diff --git a/code/renderervk/shaders/glsl/prefilterenvmap.frag b/src/renderervk/shaders/glsl/prefilterenvmap.frag similarity index 100% rename from code/renderervk/shaders/glsl/prefilterenvmap.frag rename to src/renderervk/shaders/glsl/prefilterenvmap.frag diff --git a/code/renderervk/shaders/spirv/shader_binding.c b/src/renderervk/shaders/spirv/shader_binding.c similarity index 100% rename from code/renderervk/shaders/spirv/shader_binding.c rename to src/renderervk/shaders/spirv/shader_binding.c diff --git a/code/renderervk/shaders/spirv/shader_data.c b/src/renderervk/shaders/spirv/shader_data.c similarity index 100% rename from code/renderervk/shaders/spirv/shader_data.c rename to src/renderervk/shaders/spirv/shader_data.c diff --git a/code/renderervk/shaders/tools/bin2hex.c b/src/renderervk/shaders/tools/bin2hex.c similarity index 100% rename from code/renderervk/shaders/tools/bin2hex.c rename to src/renderervk/shaders/tools/bin2hex.c diff --git a/code/renderervk/shaders/tools/bin2hex.exe b/src/renderervk/shaders/tools/bin2hex.exe similarity index 100% rename from code/renderervk/shaders/tools/bin2hex.exe rename to src/renderervk/shaders/tools/bin2hex.exe diff --git a/code/renderervk/shaders/tools/bin2hex.obj b/src/renderervk/shaders/tools/bin2hex.obj similarity index 100% rename from code/renderervk/shaders/tools/bin2hex.obj rename to src/renderervk/shaders/tools/bin2hex.obj diff --git a/code/renderervk/shaders/tools/bindshader.c b/src/renderervk/shaders/tools/bindshader.c similarity index 100% rename from code/renderervk/shaders/tools/bindshader.c rename to src/renderervk/shaders/tools/bindshader.c diff --git a/code/renderervk/shaders/tools/bindshader.exe b/src/renderervk/shaders/tools/bindshader.exe similarity index 100% rename from code/renderervk/shaders/tools/bindshader.exe rename to src/renderervk/shaders/tools/bindshader.exe diff --git a/code/renderervk/shaders/tools/bindshader.obj b/src/renderervk/shaders/tools/bindshader.obj similarity index 100% rename from code/renderervk/shaders/tools/bindshader.obj rename to src/renderervk/shaders/tools/bindshader.obj diff --git a/code/renderervk/shaders/tools/compile_threaded.cpp b/src/renderervk/shaders/tools/compile_threaded.cpp similarity index 100% rename from code/renderervk/shaders/tools/compile_threaded.cpp rename to src/renderervk/shaders/tools/compile_threaded.cpp diff --git a/code/renderervk/shaders/tools/compile_threaded.exe b/src/renderervk/shaders/tools/compile_threaded.exe similarity index 100% rename from code/renderervk/shaders/tools/compile_threaded.exe rename to src/renderervk/shaders/tools/compile_threaded.exe diff --git a/code/renderervk/shaders/tools/compile_threaded.obj b/src/renderervk/shaders/tools/compile_threaded.obj similarity index 100% rename from code/renderervk/shaders/tools/compile_threaded.obj rename to src/renderervk/shaders/tools/compile_threaded.obj diff --git a/code/renderervk/tr_animation.c b/src/renderervk/tr_animation.c similarity index 100% rename from code/renderervk/tr_animation.c rename to src/renderervk/tr_animation.c diff --git a/code/renderervk/tr_backend.c b/src/renderervk/tr_backend.c similarity index 100% rename from code/renderervk/tr_backend.c rename to src/renderervk/tr_backend.c diff --git a/code/renderervk/tr_bsp.c b/src/renderervk/tr_bsp.c similarity index 100% rename from code/renderervk/tr_bsp.c rename to src/renderervk/tr_bsp.c diff --git a/code/renderervk/tr_cmds.c b/src/renderervk/tr_cmds.c similarity index 100% rename from code/renderervk/tr_cmds.c rename to src/renderervk/tr_cmds.c diff --git a/code/renderervk/tr_common.h b/src/renderervk/tr_common.h similarity index 100% rename from code/renderervk/tr_common.h rename to src/renderervk/tr_common.h diff --git a/code/renderervk/tr_curve.c b/src/renderervk/tr_curve.c similarity index 100% rename from code/renderervk/tr_curve.c rename to src/renderervk/tr_curve.c diff --git a/code/renderervk/tr_image.c b/src/renderervk/tr_image.c similarity index 99% rename from code/renderervk/tr_image.c rename to src/renderervk/tr_image.c index 371d5cd10d..3f85b9a877 100644 --- a/code/renderervk/tr_image.c +++ b/src/renderervk/tr_image.c @@ -1518,7 +1518,7 @@ qboolean vk_create_phyisical_texture( shaderStage_t *stage, const char *name, im else stage->physicalMap = R_CreateImage( packedName, NULL, packedPic, packedWidth, packedHeight, flags, 0, stage->physicalMapType ); - Z_Free( packedPic ); + ri.Free( packedPic ); stage->vk_pbr_flags |= PBR_HAS_PHYSICALMAP; return qtrue; diff --git a/code/renderervk/tr_init.c b/src/renderervk/tr_init.c similarity index 100% rename from code/renderervk/tr_init.c rename to src/renderervk/tr_init.c diff --git a/code/renderervk/tr_light.c b/src/renderervk/tr_light.c similarity index 100% rename from code/renderervk/tr_light.c rename to src/renderervk/tr_light.c diff --git a/code/renderervk/tr_local.h b/src/renderervk/tr_local.h similarity index 100% rename from code/renderervk/tr_local.h rename to src/renderervk/tr_local.h diff --git a/code/renderervk/tr_main.c b/src/renderervk/tr_main.c similarity index 100% rename from code/renderervk/tr_main.c rename to src/renderervk/tr_main.c diff --git a/code/renderervk/tr_marks.c b/src/renderervk/tr_marks.c similarity index 100% rename from code/renderervk/tr_marks.c rename to src/renderervk/tr_marks.c diff --git a/code/renderervk/tr_mesh.c b/src/renderervk/tr_mesh.c similarity index 100% rename from code/renderervk/tr_mesh.c rename to src/renderervk/tr_mesh.c diff --git a/code/renderervk/tr_model.c b/src/renderervk/tr_model.c similarity index 100% rename from code/renderervk/tr_model.c rename to src/renderervk/tr_model.c diff --git a/code/renderervk/tr_model_iqm.c b/src/renderervk/tr_model_iqm.c similarity index 100% rename from code/renderervk/tr_model_iqm.c rename to src/renderervk/tr_model_iqm.c diff --git a/code/renderervk/tr_scene.c b/src/renderervk/tr_scene.c similarity index 100% rename from code/renderervk/tr_scene.c rename to src/renderervk/tr_scene.c diff --git a/code/renderervk/tr_shade.c b/src/renderervk/tr_shade.c similarity index 100% rename from code/renderervk/tr_shade.c rename to src/renderervk/tr_shade.c diff --git a/code/renderervk/tr_shade_calc.c b/src/renderervk/tr_shade_calc.c similarity index 100% rename from code/renderervk/tr_shade_calc.c rename to src/renderervk/tr_shade_calc.c diff --git a/code/renderervk/tr_shader.c b/src/renderervk/tr_shader.c similarity index 100% rename from code/renderervk/tr_shader.c rename to src/renderervk/tr_shader.c diff --git a/code/renderervk/tr_shadows.c b/src/renderervk/tr_shadows.c similarity index 100% rename from code/renderervk/tr_shadows.c rename to src/renderervk/tr_shadows.c diff --git a/code/renderervk/tr_sky.c b/src/renderervk/tr_sky.c similarity index 100% rename from code/renderervk/tr_sky.c rename to src/renderervk/tr_sky.c diff --git a/code/renderervk/tr_surface.c b/src/renderervk/tr_surface.c similarity index 100% rename from code/renderervk/tr_surface.c rename to src/renderervk/tr_surface.c diff --git a/code/renderervk/tr_world.c b/src/renderervk/tr_world.c similarity index 100% rename from code/renderervk/tr_world.c rename to src/renderervk/tr_world.c diff --git a/code/renderervk/vk.c b/src/renderervk/vk.c similarity index 100% rename from code/renderervk/vk.c rename to src/renderervk/vk.c diff --git a/code/renderervk/vk.h b/src/renderervk/vk.h similarity index 100% rename from code/renderervk/vk.h rename to src/renderervk/vk.h diff --git a/code/renderervk/vk_flares.c b/src/renderervk/vk_flares.c similarity index 100% rename from code/renderervk/vk_flares.c rename to src/renderervk/vk_flares.c diff --git a/code/renderervk/vk_vbo.c b/src/renderervk/vk_vbo.c similarity index 100% rename from code/renderervk/vk_vbo.c rename to src/renderervk/vk_vbo.c diff --git a/code/sdl/sdl_gamma.c b/src/sdl/sdl_gamma.c similarity index 100% rename from code/sdl/sdl_gamma.c rename to src/sdl/sdl_gamma.c diff --git a/code/sdl/sdl_glimp.c b/src/sdl/sdl_glimp.c similarity index 100% rename from code/sdl/sdl_glimp.c rename to src/sdl/sdl_glimp.c diff --git a/code/sdl/sdl_glw.h b/src/sdl/sdl_glw.h similarity index 100% rename from code/sdl/sdl_glw.h rename to src/sdl/sdl_glw.h diff --git a/code/sdl/sdl_icon.h b/src/sdl/sdl_icon.h similarity index 100% rename from code/sdl/sdl_icon.h rename to src/sdl/sdl_icon.h diff --git a/code/sdl/sdl_input.c b/src/sdl/sdl_input.c similarity index 100% rename from code/sdl/sdl_input.c rename to src/sdl/sdl_input.c diff --git a/code/sdl/sdl_snd.c b/src/sdl/sdl_snd.c similarity index 100% rename from code/sdl/sdl_snd.c rename to src/sdl/sdl_snd.c diff --git a/code/server/server.h b/src/server/server.h similarity index 100% rename from code/server/server.h rename to src/server/server.h diff --git a/code/server/sv_bot.c b/src/server/sv_bot.c similarity index 100% rename from code/server/sv_bot.c rename to src/server/sv_bot.c diff --git a/code/server/sv_ccmds.c b/src/server/sv_ccmds.c similarity index 100% rename from code/server/sv_ccmds.c rename to src/server/sv_ccmds.c diff --git a/code/server/sv_client.c b/src/server/sv_client.c similarity index 100% rename from code/server/sv_client.c rename to src/server/sv_client.c diff --git a/code/server/sv_filter.c b/src/server/sv_filter.c similarity index 100% rename from code/server/sv_filter.c rename to src/server/sv_filter.c diff --git a/code/server/sv_game.c b/src/server/sv_game.c similarity index 100% rename from code/server/sv_game.c rename to src/server/sv_game.c diff --git a/code/server/sv_init.c b/src/server/sv_init.c similarity index 100% rename from code/server/sv_init.c rename to src/server/sv_init.c diff --git a/code/server/sv_main.c b/src/server/sv_main.c similarity index 100% rename from code/server/sv_main.c rename to src/server/sv_main.c diff --git a/code/server/sv_net_chan.c b/src/server/sv_net_chan.c similarity index 100% rename from code/server/sv_net_chan.c rename to src/server/sv_net_chan.c diff --git a/code/server/sv_rankings.c b/src/server/sv_rankings.c similarity index 100% rename from code/server/sv_rankings.c rename to src/server/sv_rankings.c diff --git a/code/server/sv_snapshot.c b/src/server/sv_snapshot.c similarity index 100% rename from code/server/sv_snapshot.c rename to src/server/sv_snapshot.c diff --git a/code/server/sv_world.c b/src/server/sv_world.c similarity index 100% rename from code/server/sv_world.c rename to src/server/sv_world.c diff --git a/code/server/tlds.h b/src/server/tlds.h similarity index 100% rename from code/server/tlds.h rename to src/server/tlds.h diff --git a/code/ui/ui_public.h b/src/ui/ui_public.h similarity index 100% rename from code/ui/ui_public.h rename to src/ui/ui_public.h diff --git a/code/unix/linux_glimp.c b/src/unix/linux_glimp.c similarity index 100% rename from code/unix/linux_glimp.c rename to src/unix/linux_glimp.c diff --git a/code/unix/linux_joystick.c b/src/unix/linux_joystick.c similarity index 100% rename from code/unix/linux_joystick.c rename to src/unix/linux_joystick.c diff --git a/code/unix/linux_local.h b/src/unix/linux_local.h similarity index 100% rename from code/unix/linux_local.h rename to src/unix/linux_local.h diff --git a/code/unix/linux_qgl.c b/src/unix/linux_qgl.c similarity index 100% rename from code/unix/linux_qgl.c rename to src/unix/linux_qgl.c diff --git a/code/unix/linux_qvk.c b/src/unix/linux_qvk.c similarity index 100% rename from code/unix/linux_qvk.c rename to src/unix/linux_qvk.c diff --git a/code/unix/linux_signals.c b/src/unix/linux_signals.c similarity index 100% rename from code/unix/linux_signals.c rename to src/unix/linux_signals.c diff --git a/code/unix/linux_snd.c b/src/unix/linux_snd.c similarity index 100% rename from code/unix/linux_snd.c rename to src/unix/linux_snd.c diff --git a/code/unix/quake3.png b/src/unix/quake3.png similarity index 100% rename from code/unix/quake3.png rename to src/unix/quake3.png diff --git a/code/unix/quake3.svg b/src/unix/quake3.svg similarity index 100% rename from code/unix/quake3.svg rename to src/unix/quake3.svg diff --git a/code/unix/quake3_flat.icns b/src/unix/quake3_flat.icns similarity index 100% rename from code/unix/quake3_flat.icns rename to src/unix/quake3_flat.icns diff --git a/code/unix/unix_glw.h b/src/unix/unix_glw.h similarity index 100% rename from code/unix/unix_glw.h rename to src/unix/unix_glw.h diff --git a/code/unix/unix_main.c b/src/unix/unix_main.c similarity index 100% rename from code/unix/unix_main.c rename to src/unix/unix_main.c diff --git a/code/unix/unix_shared.c b/src/unix/unix_shared.c similarity index 100% rename from code/unix/unix_shared.c rename to src/unix/unix_shared.c diff --git a/code/unix/x11_dga.c b/src/unix/x11_dga.c similarity index 100% rename from code/unix/x11_dga.c rename to src/unix/x11_dga.c diff --git a/code/unix/x11_randr.c b/src/unix/x11_randr.c similarity index 100% rename from code/unix/x11_randr.c rename to src/unix/x11_randr.c diff --git a/code/unix/x11_vidmode.c b/src/unix/x11_vidmode.c similarity index 100% rename from code/unix/x11_vidmode.c rename to src/unix/x11_vidmode.c diff --git a/code/win32/background.bmp b/src/win32/background.bmp similarity index 100% rename from code/win32/background.bmp rename to src/win32/background.bmp diff --git a/code/win32/clear.bmp b/src/win32/clear.bmp similarity index 100% rename from code/win32/clear.bmp rename to src/win32/clear.bmp diff --git a/code/win32/glw_win.h b/src/win32/glw_win.h similarity index 100% rename from code/win32/glw_win.h rename to src/win32/glw_win.h diff --git a/code/win32/msvc2005/botlib.vcproj b/src/win32/msvc2005/botlib.vcproj similarity index 100% rename from code/win32/msvc2005/botlib.vcproj rename to src/win32/msvc2005/botlib.vcproj diff --git a/code/win32/msvc2005/clean.cmd b/src/win32/msvc2005/clean.cmd similarity index 100% rename from code/win32/msvc2005/clean.cmd rename to src/win32/msvc2005/clean.cmd diff --git a/code/win32/msvc2005/glsl_stringify.vbs b/src/win32/msvc2005/glsl_stringify.vbs similarity index 100% rename from code/win32/msvc2005/glsl_stringify.vbs rename to src/win32/msvc2005/glsl_stringify.vbs diff --git a/code/win32/msvc2005/libjpeg.vcproj b/src/win32/msvc2005/libjpeg.vcproj similarity index 100% rename from code/win32/msvc2005/libjpeg.vcproj rename to src/win32/msvc2005/libjpeg.vcproj diff --git a/code/win32/msvc2005/libogg.vcproj b/src/win32/msvc2005/libogg.vcproj similarity index 100% rename from code/win32/msvc2005/libogg.vcproj rename to src/win32/msvc2005/libogg.vcproj diff --git a/code/win32/msvc2005/libvorbis.vcproj b/src/win32/msvc2005/libvorbis.vcproj similarity index 100% rename from code/win32/msvc2005/libvorbis.vcproj rename to src/win32/msvc2005/libvorbis.vcproj diff --git a/code/win32/msvc2005/quake3e-ded.vcproj b/src/win32/msvc2005/quake3e-ded.vcproj similarity index 100% rename from code/win32/msvc2005/quake3e-ded.vcproj rename to src/win32/msvc2005/quake3e-ded.vcproj diff --git a/code/win32/msvc2005/quake3e.sln b/src/win32/msvc2005/quake3e.sln similarity index 100% rename from code/win32/msvc2005/quake3e.sln rename to src/win32/msvc2005/quake3e.sln diff --git a/code/win32/msvc2005/quake3e.vcproj b/src/win32/msvc2005/quake3e.vcproj similarity index 100% rename from code/win32/msvc2005/quake3e.vcproj rename to src/win32/msvc2005/quake3e.vcproj diff --git a/code/win32/msvc2005/ref_trin.def b/src/win32/msvc2005/ref_trin.def similarity index 100% rename from code/win32/msvc2005/ref_trin.def rename to src/win32/msvc2005/ref_trin.def diff --git a/code/win32/msvc2005/renderer.vcproj b/src/win32/msvc2005/renderer.vcproj similarity index 100% rename from code/win32/msvc2005/renderer.vcproj rename to src/win32/msvc2005/renderer.vcproj diff --git a/code/win32/msvc2005/renderer2.vcproj b/src/win32/msvc2005/renderer2.vcproj similarity index 100% rename from code/win32/msvc2005/renderer2.vcproj rename to src/win32/msvc2005/renderer2.vcproj diff --git a/code/win32/msvc2005/renderervk.vcproj b/src/win32/msvc2005/renderervk.vcproj similarity index 100% rename from code/win32/msvc2005/renderervk.vcproj rename to src/win32/msvc2005/renderervk.vcproj diff --git a/code/win32/msvc2017/botlib.vcxproj b/src/win32/msvc2017/botlib.vcxproj similarity index 100% rename from code/win32/msvc2017/botlib.vcxproj rename to src/win32/msvc2017/botlib.vcxproj diff --git a/code/win32/msvc2017/botlib.vcxproj.filters b/src/win32/msvc2017/botlib.vcxproj.filters similarity index 100% rename from code/win32/msvc2017/botlib.vcxproj.filters rename to src/win32/msvc2017/botlib.vcxproj.filters diff --git a/code/win32/msvc2017/clean.cmd b/src/win32/msvc2017/clean.cmd similarity index 100% rename from code/win32/msvc2017/clean.cmd rename to src/win32/msvc2017/clean.cmd diff --git a/code/win32/msvc2017/glsl_stringify.vbs b/src/win32/msvc2017/glsl_stringify.vbs similarity index 100% rename from code/win32/msvc2017/glsl_stringify.vbs rename to src/win32/msvc2017/glsl_stringify.vbs diff --git a/code/win32/msvc2017/libjpeg.vcxproj b/src/win32/msvc2017/libjpeg.vcxproj similarity index 100% rename from code/win32/msvc2017/libjpeg.vcxproj rename to src/win32/msvc2017/libjpeg.vcxproj diff --git a/code/win32/msvc2017/libjpeg.vcxproj.filters b/src/win32/msvc2017/libjpeg.vcxproj.filters similarity index 100% rename from code/win32/msvc2017/libjpeg.vcxproj.filters rename to src/win32/msvc2017/libjpeg.vcxproj.filters diff --git a/code/win32/msvc2017/libogg.vcxproj b/src/win32/msvc2017/libogg.vcxproj similarity index 100% rename from code/win32/msvc2017/libogg.vcxproj rename to src/win32/msvc2017/libogg.vcxproj diff --git a/code/win32/msvc2017/libogg.vcxproj.filters b/src/win32/msvc2017/libogg.vcxproj.filters similarity index 100% rename from code/win32/msvc2017/libogg.vcxproj.filters rename to src/win32/msvc2017/libogg.vcxproj.filters diff --git a/code/win32/msvc2017/libvorbis.vcxproj b/src/win32/msvc2017/libvorbis.vcxproj similarity index 100% rename from code/win32/msvc2017/libvorbis.vcxproj rename to src/win32/msvc2017/libvorbis.vcxproj diff --git a/code/win32/msvc2017/libvorbis.vcxproj.filters b/src/win32/msvc2017/libvorbis.vcxproj.filters similarity index 100% rename from code/win32/msvc2017/libvorbis.vcxproj.filters rename to src/win32/msvc2017/libvorbis.vcxproj.filters diff --git a/code/win32/msvc2017/quake3ded.vcxproj.filters b/src/win32/msvc2017/quake3ded.vcxproj.filters similarity index 100% rename from code/win32/msvc2017/quake3ded.vcxproj.filters rename to src/win32/msvc2017/quake3ded.vcxproj.filters diff --git a/code/win32/msvc2017/quake3e-ded.vcxproj b/src/win32/msvc2017/quake3e-ded.vcxproj similarity index 100% rename from code/win32/msvc2017/quake3e-ded.vcxproj rename to src/win32/msvc2017/quake3e-ded.vcxproj diff --git a/code/win32/msvc2017/quake3e-ded.vcxproj.filters b/src/win32/msvc2017/quake3e-ded.vcxproj.filters similarity index 100% rename from code/win32/msvc2017/quake3e-ded.vcxproj.filters rename to src/win32/msvc2017/quake3e-ded.vcxproj.filters diff --git a/code/win32/msvc2017/quake3e.sln b/src/win32/msvc2017/quake3e.sln similarity index 100% rename from code/win32/msvc2017/quake3e.sln rename to src/win32/msvc2017/quake3e.sln diff --git a/code/win32/msvc2017/quake3e.vcxproj b/src/win32/msvc2017/quake3e.vcxproj similarity index 100% rename from code/win32/msvc2017/quake3e.vcxproj rename to src/win32/msvc2017/quake3e.vcxproj diff --git a/code/win32/msvc2017/quake3e.vcxproj.filters b/src/win32/msvc2017/quake3e.vcxproj.filters similarity index 100% rename from code/win32/msvc2017/quake3e.vcxproj.filters rename to src/win32/msvc2017/quake3e.vcxproj.filters diff --git a/code/win32/msvc2017/ref_trin.def b/src/win32/msvc2017/ref_trin.def similarity index 100% rename from code/win32/msvc2017/ref_trin.def rename to src/win32/msvc2017/ref_trin.def diff --git a/code/win32/msvc2017/renderer.vcxproj b/src/win32/msvc2017/renderer.vcxproj similarity index 100% rename from code/win32/msvc2017/renderer.vcxproj rename to src/win32/msvc2017/renderer.vcxproj diff --git a/code/win32/msvc2017/renderer.vcxproj.filters b/src/win32/msvc2017/renderer.vcxproj.filters similarity index 100% rename from code/win32/msvc2017/renderer.vcxproj.filters rename to src/win32/msvc2017/renderer.vcxproj.filters diff --git a/code/win32/msvc2017/renderer2.vcxproj b/src/win32/msvc2017/renderer2.vcxproj similarity index 100% rename from code/win32/msvc2017/renderer2.vcxproj rename to src/win32/msvc2017/renderer2.vcxproj diff --git a/code/win32/msvc2017/renderer2.vcxproj.filters b/src/win32/msvc2017/renderer2.vcxproj.filters similarity index 100% rename from code/win32/msvc2017/renderer2.vcxproj.filters rename to src/win32/msvc2017/renderer2.vcxproj.filters diff --git a/code/win32/msvc2017/renderervk.vcxproj b/src/win32/msvc2017/renderervk.vcxproj similarity index 100% rename from code/win32/msvc2017/renderervk.vcxproj rename to src/win32/msvc2017/renderervk.vcxproj diff --git a/code/win32/msvc2017/renderervk.vcxproj.filters b/src/win32/msvc2017/renderervk.vcxproj.filters similarity index 100% rename from code/win32/msvc2017/renderervk.vcxproj.filters rename to src/win32/msvc2017/renderervk.vcxproj.filters diff --git a/code/win32/q3.manifest b/src/win32/q3.manifest similarity index 100% rename from code/win32/q3.manifest rename to src/win32/q3.manifest diff --git a/code/win32/qe3.ico b/src/win32/qe3.ico similarity index 100% rename from code/win32/qe3.ico rename to src/win32/qe3.ico diff --git a/code/win32/resource.h b/src/win32/resource.h similarity index 100% rename from code/win32/resource.h rename to src/win32/resource.h diff --git a/code/win32/win_gamma.c b/src/win32/win_gamma.c similarity index 100% rename from code/win32/win_gamma.c rename to src/win32/win_gamma.c diff --git a/code/win32/win_glimp.c b/src/win32/win_glimp.c similarity index 100% rename from code/win32/win_glimp.c rename to src/win32/win_glimp.c diff --git a/code/win32/win_input.c b/src/win32/win_input.c similarity index 100% rename from code/win32/win_input.c rename to src/win32/win_input.c diff --git a/code/win32/win_local.h b/src/win32/win_local.h similarity index 100% rename from code/win32/win_local.h rename to src/win32/win_local.h diff --git a/code/win32/win_main.c b/src/win32/win_main.c similarity index 100% rename from code/win32/win_main.c rename to src/win32/win_main.c diff --git a/code/win32/win_minimize.c b/src/win32/win_minimize.c similarity index 100% rename from code/win32/win_minimize.c rename to src/win32/win_minimize.c diff --git a/code/win32/win_qgl.c b/src/win32/win_qgl.c similarity index 100% rename from code/win32/win_qgl.c rename to src/win32/win_qgl.c diff --git a/code/win32/win_qvk.c b/src/win32/win_qvk.c similarity index 100% rename from code/win32/win_qvk.c rename to src/win32/win_qvk.c diff --git a/code/win32/win_resource.rc b/src/win32/win_resource.rc similarity index 90% rename from code/win32/win_resource.rc rename to src/win32/win_resource.rc index 1850ce9e11..33ab23f8da 100644 --- a/code/win32/win_resource.rc +++ b/src/win32/win_resource.rc @@ -53,11 +53,7 @@ END // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. -#ifndef __MINGW32__ IDI_ICON1 ICON DISCARDABLE "qe3.ico" -#else -IDI_ICON1 ICON DISCARDABLE "code/win32/qe3.ico" -#endif ///////////////////////////////////////////////////////////////////////////// @@ -77,8 +73,4 @@ END // // Applicatioin manifest // -#ifndef __MINGW32__ 1 RT_MANIFEST "q3.manifest" -#else -1 RT_MANIFEST "code/win32/q3.manifest" -#endif diff --git a/code/win32/win_shared.c b/src/win32/win_shared.c similarity index 100% rename from code/win32/win_shared.c rename to src/win32/win_shared.c diff --git a/code/win32/win_snd.c b/src/win32/win_snd.c similarity index 100% rename from code/win32/win_snd.c rename to src/win32/win_snd.c diff --git a/code/win32/win_syscon.c b/src/win32/win_syscon.c similarity index 100% rename from code/win32/win_syscon.c rename to src/win32/win_syscon.c diff --git a/code/win32/win_wndproc.c b/src/win32/win_wndproc.c similarity index 100% rename from code/win32/win_wndproc.c rename to src/win32/win_wndproc.c