Merge pull request #335 from DigitalPulseSoftware/graphics-next

Graphics next
This commit is contained in:
Jérôme Leclercq 2021-06-05 12:57:36 +02:00 committed by GitHub
commit df8b4b59e3
1464 changed files with 43511 additions and 278669 deletions

83
.github/workflows/linux-build.yml vendored Normal file
View File

@ -0,0 +1,83 @@
name: Linux-Build
on:
pull_request:
push:
paths-ignore:
- '.github/workflows/windows-build.yml'
- '.gitignore'
- 'LICENSE'
- 'CHANGELOG.md'
- 'README.md'
- 'README_en.md'
- 'README_fr.md'
jobs:
build:
strategy:
matrix:
os: [ubuntu-20.04]
arch: [x64]
mode: [debug, releasedbg]
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, 'ci skip')"
steps:
- uses: actions/checkout@v2
# Install Qt (required for shader nodes editor)
- name: Install Qt
uses: jurplel/install-qt-action@v2
# Install Nazara dependencies
- name: Update apt repositories
run: sudo apt-get update
# Install Nazara dependencies
- name: Install system dependencies
run: sudo apt-get install libsndfile1-dev libfreetype6-dev libsdl2-dev mesa-common-dev libxcb-ewmh-dev libxcb-randr0-dev libxcb-icccm4-dev libxcb-keysyms1-dev libgl1-mesa-dev -y
# Force xmake to a specific folder (for cache)
- name: Set xmake env
run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" >> $GITHUB_ENV
# Install xmake
- name: Setup xmake
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: branch@dev
# Update xmake repository (in order to have the file that will be cached)
- name: Update xmake repository
run: xmake repo --update
# Fetch xmake dephash
- name: Retrieve dependencies hash
id: dep_hash
run: echo "::set-output name=hash::$(xmake l utils.ci.packageskey)"
# Cache xmake dependencies
- name: Retrieve cached xmake dependencies
uses: actions/cache@v2
with:
path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages
key: ${{ runner.os }}-${{ matrix.arch }}-${{ matrix.mode }}-${{ steps.dep_hash.outputs.hash }}
# Setup compilation mode and install project dependencies
- name: Configure xmake and install dependencies
run: xmake config --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --yes --verbose
# Build the engine
- name: Build Nazara
run: xmake
# Install the result files
- name: Install Nazara
run: xmake install -vo package
# Upload artifacts
- uses: actions/upload-artifact@v2
with:
name: ${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.mode }}
path: package

75
.github/workflows/windows-build.yml vendored Normal file
View File

@ -0,0 +1,75 @@
name: Windows-Build
on:
pull_request:
push:
paths-ignore:
- '.github/workflows/linux-build.yml'
- '.gitignore'
- 'LICENSE'
- 'CHANGELOG.md'
- 'README.md'
- 'README_en.md'
- 'README_fr.md'
jobs:
build:
strategy:
matrix:
os: [windows-latest]
arch: [x64]
mode: [debug, releasedbg]
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, 'ci skip')"
steps:
- uses: actions/checkout@v2
# Install Qt (required for shader nodes editor)
- name: Install Qt
uses: jurplel/install-qt-action@v2
# Force xmake to a specific folder (for cache)
- name: Set xmake env
run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# Install xmake
- name: Setup xmake
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: branch@dev
# Update xmake repository (in order to have the file that will be cached)
- name: Update xmake repository
run: xmake.exe repo --update
# Fetch xmake dephash
- name: Retrieve dependencies hash
id: dep_hash
run: echo "::set-output name=hash::$(xmake.exe l utils.ci.packageskey)"
# Cache xmake dependencies
- name: Retrieve cached xmake dependencies
uses: actions/cache@v2
with:
path: ${{ env.XMAKE_GLOBALDIR }}\.xmake\packages
key: ${{ runner.os }}-${{ matrix.arch }}-${{ matrix.mode }}-${{ steps.dep_hash.outputs.hash }}
# Setup compilation mode and install project dependencies
- name: Configure xmake and install dependencies
run: xmake.exe config --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --yes --verbose
# Build the engine
- name: Build Nazara
run: xmake.exe
# Install the result files
- name: Install Nazara
run: xmake.exe install -vo package
# Upload artifacts
- uses: actions/upload-artifact@v2
with:
name: ${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.mode }}
path: package

15
.gitignore vendored
View File

@ -1,12 +1,19 @@
# Nazara build # xmake-related files
build/config.lua .xmake/*
.vs/*
.vscode/*
CMakeLists.txt
Makefile
vs/*
vsxmake*/*
# Nazara binaries # Nazara binaries
bin/* bin/*
!bin/resources
!bin/resources/*
# Build files # Build files
build/gmake*/ build/*
build/vs*/
# Nazara libraries # Nazara libraries
lib/* lib/*

View File

@ -1,26 +0,0 @@
language:
cpp
sudo:
required
notifications:
email: true
services:
- docker
before_install:
- docker build -t nazara .
script:
- docker run --name Nazara -v `pwd`:/NazaraEngine nazara
sh -c "
cd build &&
./premake5-linux64 --cc=clang gmake &&
cd gmake &&
make -j4 &&
cd ../../tests &&
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib/gmake/x64/:../extlibs/lib/gmake/x64/ &&
./NazaraUnitTestsServer
"

View File

@ -1,6 +0,0 @@
FROM debian:buster
RUN apt-get update && apt-get install -y build-essential clang libopenal-dev libsndfile1-dev libfreetype6-dev libassimp-dev libsdl2-dev libxcb-keysyms1-dev libxcb-ewmh-dev libx11-dev libfreetype6-dev mesa-common-dev libgl1-mesa-dev
RUN mkdir /NazaraEngine
WORKDIR /NazaraEngine

View File

@ -1,9 +0,0 @@
// This file was automatically generated
#pragma once
#ifndef NDK_COMPONENTS_GLOBAL_HPP
#define NDK_COMPONENTS_GLOBAL_HPP
#endif // NDK_COMPONENTS_GLOBAL_HPP

View File

@ -1,9 +0,0 @@
// This file was automatically generated
#pragma once
#ifndef NDK_SYSTEMS_GLOBAL_HPP
#define NDK_SYSTEMS_GLOBAL_HPP
#endif // NDK_SYSTEMS_GLOBAL_HPP

View File

@ -1,9 +0,0 @@
// This file was automatically generated
#pragma once
#ifndef NDK_WIDGETS_GLOBAL_HPP
#define NDK_WIDGETS_GLOBAL_HPP
#endif // NDK_WIDGETS_GLOBAL_HPP

View File

@ -1,59 +0,0 @@
version: '{branch}-rev{build}'
shallow_clone: true
skip_commits:
files:
- .travis.yml
- Dockerfile
- Doxyfile
- LICENSE
- License-Cabin.txt
- Logo.png
- LogoMini.png
- readme.md
- readme_fr.md
- 'writing style.md'
- doc/*
- NazaraModuleTemplate/*
message: /\[Posix\]/
os:
- Visual Studio 2019
environment:
matrix:
- TOOLSET: vs2019
install:
- cd build && "./premake5.exe" %TOOLSET% && cd ..
configuration:
- DebugDynamic
- ReleaseDynamic
platform:
- Win32
- x64
build:
project: build/$(TOOLSET)/NazaraEngine.sln
after_build:
- cd build && "./premake5.exe" package && cd ../package
- 7z a NazaraEngine.7z * && cd ..
artifacts:
- path: package/NazaraEngine.7z
name: 'NazaraEngine-$(CONFIGURATION)-$(PLATFORM)-$(APPVEYOR_REPO_COMMIT)'
on_success:
- cd tests && "./NazaraUnitTestsServer.exe"
notifications:
- provider: Slack
incoming_webhook:
secure: 5FSnJzsZCMXNDqPYGhN4ZSX7qa1KMmbV0UGT9i0LcElk3X91z3fs1TZRpZZ3++Tkw8qAk1G/qDChom5GQ7Vj7X29cScQHvGHXffl3qaC5EdSiGpjloMZKfeiGTnf798IX0n/ABSlDHG7GrB8IiulRGx3iVOpPQmrPWCiz9ZPtY8h84xpd65FGd8gETKG/sYk
on_build_success: true
on_build_failure: true
on_build_status_changed: false

View File

@ -0,0 +1,69 @@
[layout(std140)]
struct ViewerData
{
projectionMatrix: mat4<f32>,
invProjectionMatrix: mat4<f32>,
viewMatrix: mat4<f32>,
invViewMatrix: mat4<f32>,
viewProjMatrix: mat4<f32>,
invViewProjMatrix: mat4<f32>,
renderTargetSize: vec2<f32>,
invRenderTargetSize: vec2<f32>,
eyePosition: vec3<f32>
}
external
{
[binding(0)] colorTexture: sampler2D<f32>,
[binding(1)] viewerData: uniform<ViewerData>
}
struct FragIn
{
[builtin(fragcoord)] fragcoord: vec4<f32>
}
struct FragOut
{
[location(0)] color: vec4<f32>
}
struct VertIn
{
[location(0)] pos: vec3<f32>
}
struct VertOut
{
[builtin(position)] position: vec4<f32>
}
[entry(frag)]
fn main(input: FragIn) -> FragOut
{
let BrightLuminance = 0.8;
let BrightMiddleGrey = 0.5;
let BrightThreshold = 0.7;
let fragcoord = input.fragcoord.xy * viewerData.invRenderTargetSize * 10.0;
let color = colorTexture.Sample(fragcoord).rgb;
color = color * (BrightMiddleGrey/BrightLuminance);
color = color * (vec3<f32>(1.0, 1.0, 1.0) + (color / (BrightThreshold*BrightThreshold)));
color = color - vec3<f32>(0.5, 0.5, 0.5);
color = color / (vec3<f32>(1.0, 1.0, 1.0) + color);
let output: FragOut;
output.color = vec4<f32>(color, 1.0);
return output;
}
[entry(vert)]
fn main(input: VertIn) -> VertOut
{
let output: VertOut;
output.position = vec4<f32>(input.pos, 1.0);
return output;
}

View File

@ -0,0 +1,60 @@
[layout(std140)]
struct ViewerData
{
projectionMatrix: mat4<f32>,
invProjectionMatrix: mat4<f32>,
viewMatrix: mat4<f32>,
invViewMatrix: mat4<f32>,
viewProjMatrix: mat4<f32>,
invViewProjMatrix: mat4<f32>,
renderTargetSize: vec2<f32>,
invRenderTargetSize: vec2<f32>,
eyePosition: vec3<f32>
}
external
{
[binding(0)] colorTexture: sampler2D<f32>,
[binding(1)] bloomTexture: sampler2D<f32>,
[binding(2)] viewerData: uniform<ViewerData>
}
struct FragIn
{
[builtin(fragcoord)] fragcoord: vec4<f32>
}
struct FragOut
{
[location(0)] color: vec4<f32>
}
struct VertIn
{
[location(0)] pos: vec3<f32>
}
struct VertOut
{
[builtin(position)] position: vec4<f32>
}
[entry(frag)]
fn main(input: FragIn) -> FragOut
{
let fragcoord = input.fragcoord.xy * viewerData.invRenderTargetSize;
let output: FragOut;
output.color = colorTexture.Sample(fragcoord) + bloomTexture.Sample(fragcoord);
return output;
}
[entry(vert)]
fn main(input: VertIn) -> VertOut
{
let output: VertOut;
output.position = vec4<f32>(input.pos, 1.0);
return output;
}

View File

@ -0,0 +1,72 @@
option HAS_DIFFUSE_TEXTURE: bool;
option HAS_ALPHA_TEXTURE: bool;
option ALPHA_TEST: bool;
[layout(std140)]
struct BasicSettings
{
AlphaThreshold: f32,
DiffuseColor: vec4<f32>
}
[layout(std140)]
struct InstanceData
{
worldMatrix: mat4<f32>,
invWorldMatrix: mat4<f32>
}
[layout(std140)]
struct ViewerData
{
projectionMatrix: mat4<f32>,
invProjectionMatrix: mat4<f32>,
viewMatrix: mat4<f32>,
invViewMatrix: mat4<f32>,
viewProjMatrix: mat4<f32>,
invViewProjMatrix: mat4<f32>,
renderTargetSize: vec2<f32>,
invRenderTargetSize: vec2<f32>,
eyePosition: vec3<f32>
}
external
{
[binding(5)] viewerData: uniform<ViewerData>,
[binding(4)] instanceData: uniform<InstanceData>,
[binding(3)] settings: uniform<BasicSettings>,
[binding(0)] MaterialAlphaMap: sampler2D<f32>,
[binding(1)] MaterialDiffuseMap: sampler2D<f32>,
[binding(2)] TextureOverlay: sampler2D<f32>
}
struct InputData
{
[location(0)] vertNormal: vec3<f32>,
[location(1)] vertUV: vec2<f32>,
[location(2)] vertPos: vec3<f32>
}
struct OutputData
{
[location(0)] diffuseMap: vec4<f32>,
[location(1)] normalMap: vec4<f32>,
[location(2)] positionMap: vec4<f32>
}
[entry(frag)]
fn main(input: InputData) -> OutputData
{
let textureColor = select_opt(HAS_DIFFUSE_TEXTURE, MaterialDiffuseMap.Sample(input.vertUV) * settings.DiffuseColor, settings.DiffuseColor);
let alpha = select_opt(HAS_ALPHA_TEXTURE, MaterialAlphaMap.Sample(input.vertUV).x * textureColor.w, 1.0);
/*if ((select_opt(ALPHA_TEST, var0.w < settings.AlphaThreshold, false)) == (true))
{
discard;
}*/
let output: OutputData;
output.diffuseMap = textureColor;
output.normalMap = vec4<f32>((vec3<f32>(1.0, 1.0, 1.0) + input.vertNormal) * 0.5, 1.0);
output.positionMap = vec4<f32>(input.vertPos, 1.0);
return output;
}

View File

@ -0,0 +1,62 @@
[layout(std140)]
struct BasicSettings
{
AlphaThreshold: f32,
DiffuseColor: vec4<f32>
}
[layout(std140)]
struct InstanceData
{
worldMatrix: mat4<f32>,
invWorldMatrix: mat4<f32>
}
[layout(std140)]
struct ViewerData
{
projectionMatrix: mat4<f32>,
invProjectionMatrix: mat4<f32>,
viewMatrix: mat4<f32>,
invViewMatrix: mat4<f32>,
viewProjMatrix: mat4<f32>,
invViewProjMatrix: mat4<f32>,
renderTargetSize: vec2<f32>,
invRenderTargetSize: vec2<f32>,
eyePosition: vec3<f32>
}
external
{
[binding(5)] viewerData: uniform<ViewerData>,
[binding(4)] instanceData: uniform<InstanceData>,
[binding(3)] settings: uniform<BasicSettings>
}
struct InputData
{
[location(0)] inPos: vec3<f32>,
[location(1)] inNormals: vec3<f32>,
[location(2)] inTexCoord: vec2<f32>
}
struct OutputData
{
[location(0)] vertNormal: vec3<f32>,
[location(1)] vertUV: vec2<f32>,
[location(2)] vertPos: vec3<f32>,
[builtin(position)] position: vec4<f32>
}
[entry(vert)]
fn main(input: InputData) -> OutputData
{
let worldPos = instanceData.worldMatrix * vec4<f32>(input.inPos, 1.0);
let output: OutputData;
output.vertUV = input.inTexCoord;
output.vertNormal = input.inNormals;
output.vertPos = worldPos.xyz;
output.position = viewerData.projectionMatrix * viewerData.viewMatrix * instanceData.worldMatrix * vec4<f32>(input.inPos, 1.0);
return output;
}

View File

@ -0,0 +1 @@
https://file-examples.com/index.php/sample-audio-files/sample-mp3-download/

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,78 @@
[layout(std140)]
struct ViewerData
{
projectionMatrix: mat4<f32>,
invProjectionMatrix: mat4<f32>,
viewMatrix: mat4<f32>,
invViewMatrix: mat4<f32>,
viewProjMatrix: mat4<f32>,
invViewProjMatrix: mat4<f32>,
renderTargetSize: vec2<f32>,
invRenderTargetSize: vec2<f32>,
eyePosition: vec3<f32>
}
external
{
[binding(0)] colorTexture: sampler2D<f32>,
[binding(1)] viewerData: uniform<ViewerData>
}
struct FragIn
{
[builtin(fragcoord)] fragcoord: vec4<f32>
}
struct FragOut
{
[location(0)] color: vec4<f32>
}
struct VertIn
{
[location(0)] pos: vec3<f32>
}
struct VertOut
{
[builtin(position)] position: vec4<f32>
}
[entry(frag)]
fn main(input: FragIn) -> FragOut
{
let invTargetSize = viewerData.invRenderTargetSize * 10.0;
let fragcoord = input.fragcoord.xy * invTargetSize;
let color = colorTexture.Sample(fragcoord).rgb * 0.2270270270;
let filter = vec2<f32>(1.0, 0.0);
color = color + colorTexture.Sample(fragcoord + filter * 1.3846153846 * invTargetSize).rgb * 0.3162162162;
color = color + colorTexture.Sample(fragcoord - filter * 1.3846153846 * invTargetSize).rgb * 0.3162162162;
color = color + colorTexture.Sample(fragcoord + filter * 3.2307692308 * invTargetSize).rgb * 0.0702702703;
color = color + colorTexture.Sample(fragcoord - filter * 3.2307692308 * invTargetSize).rgb * 0.0702702703;
filter = vec2<f32>(0.0, 1.0);
color = color + colorTexture.Sample(fragcoord + filter * 1.3846153846 * invTargetSize).rgb * 0.3162162162;
color = color + colorTexture.Sample(fragcoord - filter * 1.3846153846 * invTargetSize).rgb * 0.3162162162;
color = color + colorTexture.Sample(fragcoord + filter * 3.2307692308 * invTargetSize).rgb * 0.0702702703;
color = color + colorTexture.Sample(fragcoord - filter * 3.2307692308 * invTargetSize).rgb * 0.0702702703;
let output: FragOut;
output.color = vec4<f32>(color, 1.0);
return output;
}
[entry(vert)]
fn main(input: VertIn) -> VertOut
{
let output: VertOut;
output.position = vec4<f32>(input.pos, 1.0);
return output;
}

108
bin/resources/lighting.nzsl Normal file
View File

@ -0,0 +1,108 @@
[layout(std140)]
struct PointLight
{
color: vec3<f32>,
position: vec3<f32>,
radius: f32,
invRadius: f32,
}
[layout(std140)]
struct SpotLight
{
transformMatrix: mat4<f32>,
color: vec3<f32>,
position: vec3<f32>,
direction: vec3<f32>,
radius: f32,
invRadius: f32,
innerAngle: f32,
outerAngle: f32
}
[layout(std140)]
struct ViewerData
{
projectionMatrix: mat4<f32>,
invProjectionMatrix: mat4<f32>,
viewMatrix: mat4<f32>,
invViewMatrix: mat4<f32>,
viewProjMatrix: mat4<f32>,
invViewProjMatrix: mat4<f32>,
renderTargetSize: vec2<f32>,
invRenderTargetSize: vec2<f32>,
eyePosition: vec3<f32>
}
external
{
[binding(0)] colorTexture: sampler2D<f32>,
[binding(1)] normalTexture: sampler2D<f32>,
[binding(2)] positionTexture: sampler2D<f32>,
[binding(3)] lightParameters: uniform<SpotLight>,
[binding(4)] viewerData: uniform<ViewerData>
}
struct FragIn
{
[builtin(fragcoord)] fragcoord: vec4<f32>
}
struct FragOut
{
[location(0)] color: vec4<f32>
}
struct VertIn
{
[location(0)] pos: vec3<f32>
}
struct VertOut
{
[builtin(position)] position: vec4<f32>
}
[entry(frag)]
fn main(input: FragIn) -> FragOut
{
let fragcoord = input.fragcoord.xy * viewerData.invRenderTargetSize;
let normal = normalTexture.Sample(fragcoord).xyz * 2.0 - vec3<f32>(1.0, 1.0, 1.0);
let position = positionTexture.Sample(fragcoord).xyz;
let attenuation = compute_attenuation(position, normal);
let output: FragOut;
output.color = vec4<f32>(lightParameters.color, 1.0) * attenuation * colorTexture.Sample(fragcoord);
return output;
}
[entry(vert)]
fn main(input: VertIn) -> VertOut
{
let output: VertOut;
output.position = viewerData.projectionMatrix * viewerData.viewMatrix * lightParameters.transformMatrix * vec4<f32>(input.pos, 1.0);
return output;
}
fn compute_attenuation(worldPos: vec3<f32>, normal: vec3<f32>) -> f32
{
let distance = length(lightParameters.position - worldPos);
let posToLight = (lightParameters.position - worldPos) / distance;
let lambert = dot(normal, posToLight);
let curAngle = dot(lightParameters.direction, -posToLight);
let innerMinusOuterAngle = lightParameters.innerAngle - lightParameters.outerAngle;
let attenuation = max(1.0 - distance * lightParameters.invRadius, 0.0);
attenuation = attenuation * lambert * max((curAngle - lightParameters.outerAngle) / innerMinusOuterAngle, 0.0);
return attenuation;
}

68
bin/resources/skybox.nzsl Normal file
View File

@ -0,0 +1,68 @@
[layout(std140)]
struct ViewerData
{
projectionMatrix: mat4<f32>,
invProjectionMatrix: mat4<f32>,
viewMatrix: mat4<f32>,
invViewMatrix: mat4<f32>,
viewProjMatrix: mat4<f32>,
invViewProjMatrix: mat4<f32>,
renderTargetSize: vec2<f32>,
invRenderTargetSize: vec2<f32>,
eyePosition: vec3<f32>
}
external
{
[binding(1)] skybox: samplerCube<f32>
}
struct VertOut
{
[location(0)] uvw: vec3<f32>,
[builtin(position)] position: vec4<f32>
}
struct FragOut
{
[location(0)] color: vec4<f32>,
[builtin(fragdepth)] depth: f32
}
[entry(frag)]
[depth_write(greater)]
fn main(input: VertOut) -> FragOut
{
let output: FragOut;
output.color = skybox.Sample(input.uvw);
output.depth = 1.0;
return output;
}
external
{
[binding(0)] viewerData: uniform<ViewerData>
}
struct VertIn
{
[location(0)] position: vec3<f32>
}
[entry(vert)]
fn main(input: VertIn) -> VertOut
{
// Set translation part to zero
let rotationMat = viewerData.viewMatrix;
// rotationMat[3].xyz = vec3<f32>(0.0, 0.0, 0.0); // Requires SPIRV generator to handle swizzle for store expressions
rotationMat[3][0] = 0.0;
rotationMat[3][1] = 0.0;
rotationMat[3][2] = 0.0;
let output: VertOut;
output.position = viewerData.projectionMatrix * rotationMat * vec4<f32>(input.position, 1.0);
output.uvw = vec3<f32>(input.position.xy * -1.0, input.position.z);
return output;
}

View File

@ -1 +0,0 @@
.\premake5.exe codeblocks

View File

@ -1 +0,0 @@
.\premake5.exe codelite

View File

@ -1 +0,0 @@
.\premake5.exe --premakeproject vs2015

View File

@ -1 +0,0 @@
.\premake5.exe --premakeproject vs2017

View File

@ -1 +0,0 @@
.\premake5.exe --premakeproject vs2019

View File

@ -1,2 +0,0 @@
.\premake5.exe encoderesources
pause

View File

@ -1,2 +0,0 @@
.\premake5.exe generateheaders
pause

View File

@ -1,2 +0,0 @@
.\premake5.exe parseunicode
pause

View File

@ -1,2 +0,0 @@
.\premake5.exe package
pause

View File

@ -1,2 +0,0 @@
.\premake5.exe --pack-libdir=msvc package
pause

View File

@ -1,2 +0,0 @@
.\premake5.exe --pack-libdir=mingw package
pause

View File

@ -1,41 +0,0 @@
-- This file contains special configurations values, such as directories to extern libraries (Qt)
-- Editing this file is not required to use/compile the engine, as default values should be enough
-- Additionnal compilation options
--AdditionalCompilationOptions = "-fsanitize=address" -- Enable ASan
-- Builds Nazara extern libraries (such as lua/STB)
BuildDependencies = true
-- Builds Nazara examples
BuildExamples = true
-- Setup configurations array (valid values: Debug, Release, ReleaseWithDebug)
Configurations = "Debug,Release,ReleaseWithDebug" -- "Debug,Release,ReleaseWithDebug"
-- Setup additionnals install directories, separated by a semi-colon ; (library binaries will be copied there)
--InstallDir = "/usr/local/lib64"
-- Adds a project which will recall premake with its original arguments when built (only works on Windows for now)
PremakeProject = false
-- Excludes client-only modules/tools/examples
ServerMode = false
-- Builds modules as one united library (useless on POSIX systems)
UniteModules = false
-- Qt5 directories (required for ShaderNodes editor)
--Qt5IncludeDir = [[C:\Projets\Libs\Qt\5.15.0\msvc2019\include]]
--Qt5BinDir_x86 = [[C:\Projets\Libs\Qt\5.15.0\msvc2019\bin]]
--Qt5BinDir_x64 = [[C:\Projets\Libs\Qt\5.15.0\msvc2019_64\bin]]
--Qt5LibDir_x86 = [[C:\Projets\Libs\Qt\5.15.0\msvc2019\lib]]
--Qt5LibDir_x64 = [[C:\Projets\Libs\Qt\5.15.0\msvc2019_64\lib]]
-- QtNodes directories (required for ShaderNodes editor)
--QtNodesIncludeDir = [[C:\Projets\Libs\nodeeditor\include]]
--QtNodesBinDir_x86 = [[C:\Projets\Libs\nodeeditor\build32\bin\Release]]
--QtNodesBinDir_x64 = [[C:\Projets\Libs\nodeeditor\build64\bin\Release]]
--QtNodesLibDir_x86 = [[C:\Projets\Libs\nodeeditor\build32\lib\Release]]
--QtNodesLibDir_x64 = [[C:\Projets\Libs\nodeeditor\build64\lib\Release]]

View File

@ -1,4 +0,0 @@
dofile("codeblocks/_codeblocks.lua")
dofile("codeblocks/codeblocks.lua")
ACTION.Manual = true

View File

@ -1,44 +0,0 @@
--
-- _codeblocks.lua
-- Define the Code::Blocks action(s).
-- Copyright (c) 2002-2011 Jason Perkins and the Premake project
--
local p = premake
p.modules.codeblocks = {}
p.modules.codeblocks._VERSION = p._VERSION
local codeblocks = p.modules.codeblocks
newaction {
trigger = "codeblocks",
shortname = "Code::Blocks",
description = "Generate Code::Blocks project files",
valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" },
valid_languages = { "C", "C++" },
valid_tools = {
cc = { "clang", "gcc", "ow" },
},
onWorkspace = function(wks)
p.modules.codeblocks.generateWorkspace(wks)
end,
onProject = function(prj)
p.modules.codeblocks.generateProject(prj)
end,
onCleanWorkspace = function(wks)
p.clean.file(wks, wks.name .. ".workspace")
p.clean.file(wks, wks.name .. ".workspace.layout")
end,
onCleanProject = function(prj)
p.clean.file(prj, prj.name .. ".workspace")
p.clean.file(prj, prj.name .. ".depend")
p.clean.file(prj, prj.name .. ".layout")
end
}

View File

@ -1,67 +0,0 @@
--
-- codeblocks_workspace.lua
-- Generate a Code::Blocks workspace.
-- Copyright (c) 2009 Jason Perkins and the Premake project
--
local p = premake
p.modules.codeblocks = {}
p.modules.codeblocks._VERSION = p._VERSION
local codeblocks = p.modules.codeblocks
local project = p.project
function codeblocks.cfgname(cfg)
local cfgname = cfg.buildcfg
if codeblocks.workspace.multiplePlatforms then
cfgname = string.format("%s|%s", cfg.platform, cfg.buildcfg)
end
return cfgname
end
function codeblocks.esc(value)
local result = value:gsub('"', '&quot;')
result = result:gsub('<', '&lt;')
result = result:gsub('>', '&gt;')
return result
end
function codeblocks.generateWorkspace(wks)
p.eol("\r\n")
p.indent("\t")
p.escaper(codeblocks.esc)
p.generate(wks, ".workspace", codeblocks.workspace.generate)
end
function codeblocks.generateProject(prj)
p.eol("\r\n")
p.indent("\t")
p.escaper(codeblocks.esc)
if project.iscpp(prj) then
p.generate(prj, ".cbp", codeblocks.project.generate)
end
end
function codeblocks.cleanWorkspace(wks)
p.clean.file(wks, wks.name .. ".workspace")
p.clean.file(wks, wks.name .. ".workspace.layout")
end
function codeblocks.cleanProject(prj)
p.clean.file(prj, prj.name .. ".workspace")
p.clean.file(prj, prj.name .. ".depend")
p.clean.file(prj, prj.name .. ".layout")
end
function codeblocks.cleanTarget(prj)
-- TODO..
end
include("codeblocks_workspace.lua")
include("codeblocks_project.lua")

View File

@ -1,243 +0,0 @@
--
-- codeblocks_cbp.lua
-- Generate a Code::Blocks C/C++ project.
-- Copyright (c) 2009, 2011 Jason Perkins and the Premake project
--
local p = premake
local project = p.project
local config = p.config
local tree = p.tree
local codeblocks = p.modules.codeblocks
codeblocks.project = {}
local m = codeblocks.project
m.elements = {}
m.ctools = {
gcc = "gcc",
msc = "Visual C++",
}
function m.getcompilername(cfg)
local tool = _OPTIONS.cc or cfg.toolset or p.GCC
local toolset = p.tools[tool]
if not toolset then
error("Invalid toolset '" + (_OPTIONS.cc or cfg.toolset) + "'")
end
return m.ctools[tool]
end
function m.getcompiler(cfg)
local toolset = p.tools[_OPTIONS.cc or cfg.toolset or p.GCC]
if not toolset then
error("Invalid toolset '" + (_OPTIONS.cc or cfg.toolset) + "'")
end
return toolset
end
function m.header(prj)
_p('<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>')
_p('<CodeBlocks_project_file>')
_p(1,'<FileVersion major="1" minor="6" />')
-- write project block header
_p(1,'<Project>')
_p(2,'<Option title="%s" />', prj.name)
_p(2,'<Option pch_mode="2" />')
end
function m.footer(prj)
-- write project block footer
_p(1,'</Project>')
_p('</CodeBlocks_project_file>')
end
m.elements.project = function(prj)
return {
m.header,
m.configurations,
m.files,
m.extensions,
m.footer
}
end
--
-- Project: Generate the CodeBlocks project file.
--
function m.generate(prj)
p.utf8()
p.callArray(m.elements.project, prj)
end
function m.configurations(prj)
-- write configuration blocks
_p(2,'<Build>')
local platforms = {}
for cfg in project.eachconfig(prj) do
local found = false
for k,v in pairs(platforms) do
if (v.platform == cfg.platform) then
table.insert(v.configs, cfg)
found = true
break
end
end
if (not found) then
table.insert(platforms, {platform = cfg.platform, configs = {cfg}})
end
end
for k,platform in pairs(platforms) do
for k,cfg in pairs(platform.configs) do
local compiler = m.getcompiler(cfg)
_p(3,'<Target title="%s">', cfg.longname)
_p(4,'<Option output="%s" prefix_auto="0" extension_auto="0" />', p.esc(cfg.buildtarget.relpath))
if cfg.debugdir then
_p(4,'<Option working_dir="%s" />', p.esc(path.getrelative(prj.location, cfg.debugdir)))
end
_p(4,'<Option object_output="%s" />', p.esc(path.getrelative(prj.location, cfg.objdir)))
-- identify the type of binary
local types = { WindowedApp = 0, ConsoleApp = 1, StaticLib = 2, SharedLib = 3 }
_p(4,'<Option type="%d" />', types[cfg.kind])
_p(4,'<Option compiler="%s" />', m.getcompilername(cfg))
if (cfg.kind == "SharedLib") then
_p(4,'<Option createDefFile="0" />')
_p(4,'<Option createStaticLib="%s" />', iif(cfg.flags.NoImportLib, 0, 1))
end
-- begin compiler block --
_p(4,'<Compiler>')
for _,flag in ipairs(table.join(compiler.getcflags(cfg), compiler.getcxxflags(cfg), compiler.getdefines(cfg.defines), cfg.buildoptions)) do
_p(5,'<Add option="%s" />', p.esc(flag))
end
if not cfg.flags.NoPCH and cfg.pchheader then
_p(5,'<Add option="-Winvalid-pch" />')
_p(5,'<Add option="-include &quot;%s&quot;" />', p.esc(cfg.pchheader))
end
for _,v in ipairs(cfg.includedirs) do
_p(5,'<Add directory="%s" />', p.esc(path.getrelative(prj.location, v)))
end
_p(4,'</Compiler>')
-- end compiler block --
-- begin linker block --
_p(4,'<Linker>')
for _,flag in ipairs(table.join(compiler.getldflags(cfg), cfg.linkoptions)) do
_p(5,'<Add option="%s" />', p.esc(flag))
end
for _,v in ipairs(config.getlinks(cfg, "all", "directory")) do
_p(5,'<Add directory="%s" />', p.esc(v))
end
for _,v in ipairs(config.getlinks(cfg, "all", "basename")) do
_p(5,'<Add library="%s" />', p.esc(v))
end
_p(4,'</Linker>')
-- end linker block --
-- begin resource compiler block --
if config.findfile(cfg, ".rc") then
_p(4,'<ResourceCompiler>')
for _,v in ipairs(cfg.includedirs) do
_p(5,'<Add directory="%s" />', p.esc(v))
end
for _,v in ipairs(cfg.resincludedirs) do
_p(5,'<Add directory="%s" />', p.esc(v))
end
_p(4,'</ResourceCompiler>')
end
-- end resource compiler block --
-- begin build steps --
if #cfg.prebuildcommands > 0 or #cfg.postbuildcommands > 0 then
_p(4,'<ExtraCommands>')
for _,v in ipairs(cfg.prebuildcommands) do
_p(5,'<Add before="%s" />', p.esc(v))
end
for _,v in ipairs(cfg.postbuildcommands) do
_p(5,'<Add after="%s" />', p.esc(v))
end
_p(4,'</ExtraCommands>')
end
-- end build steps --
_p(3,'</Target>')
end
end
_p(2,'</Build>')
end
--
-- Write out a list of the source code files in the project.
--
function m.files(prj)
local pchheader
if (prj.pchheader) then
pchheader = path.getrelative(prj.location, prj.pchheader)
end
local tr = project.getsourcetree(prj)
tree.traverse(tr, {
-- source files are handled at the leaves
onleaf = function(node, depth)
if node.relpath == node.vpath then
_p(2,'<Unit filename="%s">', node.relpath)
else
_p(2,'<Unit filename="%s">', node.name)
_p(3,'<Option virtualFolder="%s" />', path.getdirectory(node.vpath))
end
if path.isresourcefile(node.name) then
_p(3,'<Option compilerVar="WINDRES" />')
elseif path.iscfile(node.name) and prj.language == "C++" then
_p(3,'<Option compilerVar="CC" />')
end
if not prj.flags.NoPCH and node.name == pchheader then
_p(3,'<Option compilerVar="%s" />', iif(prj.language == "C", "CC", "CPP"))
_p(3,'<Option compile="1" />')
_p(3,'<Option weight="0" />')
_p(3,'<Add option="-x c++-header" />')
end
_p(2,'</Unit>')
end,
}, false, 1)
end
function m.extensions(prj)
for cfg in project.eachconfig(prj) do
if cfg.debugenvs and #cfg.debugenvs > 0 then
--Assumption: if gcc is being used then so is gdb although this section will be ignored by
--other debuggers. If using gcc and not gdb it will silently not pass the
--environment arguments to the debugger
if m.getcompilername(cfg) == "gcc" then
_p(3,'<debugger>')
_p(4,'<remote_debugging target="%s">', p.esc(cfg.longname))
local args = ''
local sz = #cfg.debugenvs
for idx, v in ipairs(cfg.debugenvs) do
args = args .. 'set env ' .. v
if sz ~= idx then args = args .. '&#x0A;' end
end
_p(5,'<options additional_cmds_before="%s" />',args)
_p(4,'</remote_debugging>')
_p(3,'</debugger>')
else
error('Sorry at this moment there is no support for debug environment variables with this debugger and codeblocks')
end
end
end
end

View File

@ -1,44 +0,0 @@
--
-- Name: codelite/codelite_workspace.lua
-- Purpose: Generate a CodeLite workspace.
-- Author: Ryan Pusztai
-- Modified by: Andrea Zanellato
-- Manu Evans
-- Created: 2013/05/06
-- Copyright: (c) 2008-2015 Jason Perkins and the Premake project
--
local p = premake
local project = p.project
local workspace = p.workspace
local tree = p.tree
local codeblocks = p.modules.codeblocks
codeblocks.workspace = {}
local m = codeblocks.workspace
--
-- Generate a CodeBlocks workspace
--
function m.generate(wks)
p.utf8()
_p('<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>')
_p('<CodeBlocks_workspace_file>')
_p(1,'<Workspace title="%s">', wks.name)
for prj in workspace.eachproject(wks) do
local fname = path.join(path.getrelative(wks.location, prj.location), prj.name)
local active = iif(prj.project == wks.projects[1], ' active="1"', '')
_p(2,'<Project filename="%s.cbp"%s>', fname, active)
for _,dep in ipairs(project.getdependencies(prj)) do
_p(3,'<Depends filename="%s.cbp" />', path.join(path.getrelative(wks.location, dep.location), dep.name))
end
_p(2,'</Project>')
end
_p(1,'</Workspace>')
_p('</CodeBlocks_workspace_file>')
end

View File

@ -1,49 +0,0 @@
ACTION.Name = "EncodeResources"
ACTION.Description = "Generate a includable header version of resources"
ACTION.Function = function ()
print("Encoding resources ...")
local startClock = os.clock()
local modules = os.matchdirs("../src/Nazara/*")
table.insert(modules, "../SDK/src/NDK")
for k, modulePath in pairs(modules) do
local moduleName
if (modulePath:sub(4, 6) == "src") then
moduleName = modulePath:sub(15, -1)
else
moduleName = "SDK"
end
local files = os.matchfiles(modulePath .. "/Resources/**")
for k, filePath in pairs(files) do
if (filePath:sub(-2) ~= ".h") then
local file = filePath:sub(modulePath:len() + 12, -1)
local resource, err = io.open(filePath, "rb")
if (not resource) then
error("Failed to read resource file " .. file .. ": " .. err)
end
local resourceContent = resource:read("*a")
resource:close()
local contentLength = resourceContent:len()
local headerContentTable = {}
for i = 1, contentLength do
table.insert(headerContentTable, string.format("%d,", resourceContent:byte(i)))
end
local headerContent = table.concat(headerContentTable)
local header, err = io.open(filePath .. ".h", "w+")
if (not header) then
error("Failed to create header file for " .. file .. ": " .. err)
end
header:write(headerContent)
header:close()
print(string.format("%s: %s (raw: %.3g kB, header: %.3g kB)", moduleName, file, contentLength/1024, string.format("%.3g", headerContent:len()/1024)))
end
end
end
print("Finished (took " .. os.clock() - startClock .. "s)")
end

View File

@ -1,237 +0,0 @@
function PrintTable ( t, indent, done )
done = done or {}
indent = indent or 0
local txt = {}
for key, value in pairs (t) do
table.insert(txt, string.rep (" ", indent))
if (type(value) == "table" and not done[value]) then
done [value] = true
table.insert(txt, tostring(key) .. ":" .. "\n")
table.insert(txt, PrintTable (value, indent + 2, done))
else
table.insert(txt, tostring (key) .. "\t=\t" )
table.insert(txt, tostring(value) .. "\n" )
end
end
return table.concat(txt)
end
Feature = {}
-- Tables de vérité
local andTable =
{
{0,0},
{0,1},
}
local orTable =
{
{0,1},
{1,1},
}
local xorTable =
{
{0,1},
{1,0},
}
local bitFunc = function (a, b, truthTable)
local power = 1
local c = 0
while (a > 0 or b > 0) do
c = c + (truthTable[(a % 2)+1][(b % 2)+1] * power)
a = math.floor(a/2)
b = math.floor(b/2)
power = power * 2
end
return c
end
function Feature.AND(a, b)
return bitFunc(a, b, andTable)
end
function Feature.OR(a, b)
return bitFunc(a, b, orTable)
end
function Feature.XOR(a, b)
return bitFunc(a, b, xorTable)
end
Feature.NotApplicable = 0
Feature.Windows = 2 ^ 0
Feature.Linux = 2 ^ 1
Feature.MacOSX = 2 ^ 2
Feature.RaspberryPi = 2 ^ 3
Feature.POSIX = Feature.Linux + Feature.MacOSX + Feature.RaspberryPi
function Feature.CompleteData(tab, requiredPortability)
if (not requiredPortability) then
assert(tab.RequiredPortability)
requiredPortability = tab.RequiredPortability
elseif (tab.RequiredPortability) then
requiredPortability = Feature.OR(requiredPortability, tab.RequiredPortability)
end
tab.RequiredPortability = requiredPortability
if (not tab.Portability) then
tab.Portability = Feature.NotApplicable
end
if (tab.Features) then
local acc = 0
for k,v in pairs(tab.Features) do
if (type(v) == "string") then
v = {Title = v}
tab.Features[k] = v
end
Feature.CompleteData(v, requiredPortability)
v.Progress = v.Progress or 100
acc = acc + v.Progress
end
tab.Progress = acc/#tab.Features
end
end
function Feature.Generate()
local files = os.matchfiles("scripts/features/*.lua")
local modules = {}
for k, filePath in pairs(files) do
local moduleName = filePath:match(".*/(.*).lua")
local data = dofile(filePath)
Feature.CompleteData(data)
modules[moduleName] = data
end
local content = {}
local contentType =
{
["(%s*)%%MODULELIST%%"] = Feature.GenerateModuleList,
["(%s*)%%MODULEDESCRIPTION%%"] = Feature.GenerateModuleDescriptions,
["(%s*)%%DATE%%"] = function (dontcare, space, content)
table.insert(content, string.format("%s%s", space, os.date("%d/%m/%Y")))
end,
}
local index = io.open("scripts/features/index_template.html")
for line in index:lines() do
local matched = false
for k,v in pairs(contentType) do
local space = line:match(k)
if (space) then
matched = true
v(modules, space, content)
break
end
end
if (not matched) then
table.insert(content, line)
end
end
io.open("scripts/features/index.html", "w+"):write(table.concat(content, "\n"))
end
function Feature.Interpolate(from, to, p)
return from + (to - from)*p
end
function Feature.ComputeColor(progress)
local stable = {0, 200, 0}
local partial = {255, 127, 0}
local unusable = {255, 0, 0}
local a, b, p
if (progress < 20) then
a = unusable
b = partial
p = progress/20.0
else
a = partial
b = stable
p = math.min(20 * 1.020321705^(progress - 20), 100.0)/100.0 -- Je me complique certainement la vie pour ce qui est d'avoir une interpolation exponentielle, mais ça remonte tout ça ...
end
local color = {nil, nil, nil}
for i = 1, 3 do
color[i] = Feature.Interpolate(a[i], b[i], p)
end
return color
end
function Feature.GenerateModuleList(modules, space, content)
for k,v in pairs(modules) do
local c = Feature.ComputeColor(v.Progress)
table.insert(content, string.format([[%s<tr>]], space))
table.insert(content, string.format([[%s <td><a href="#%s">%s</a></td>]], space, k, v.Title))
table.insert(content, string.format([[%s <td style="color: rgb(%d, %d, %d);">%d%%</td>]], space, c[1], c[2], c[3], v.Progress))
table.insert(content, string.format([[%s</tr>]], space))
end
end
function Feature.GenerateModuleDescriptions(modules, space, content)
for k,v in pairs(modules) do
table.insert(content, string.format([[%s<div class="module">]], space))
table.insert(content, string.format([[%s <hr />]], space, k, v.Title))
table.insert(content, string.format([[%s <span id="%s" class="modulename">%s (%s) : %d%%</span>]], space, k, v.Title, v.LibName, math.floor(v.Progress)))
table.insert(content, string.format([[%s <h4>Fonctionnalités:</h4>]], space))
Feature.GenerateFeatureList(v.Features, space .. "\t\t", content)
table.insert(content, string.format([[%s</div>]], space))
end
end
function Feature.GenerateFeatureList(featureTable, space, content)
table.insert(content, string.format("%s<ul>", space))
for k,v in pairs(featureTable) do
local progress = v.Progress
local c = Feature.ComputeColor(progress)
local desc = (progress == 100) and "" or string.format(" (%d%%)", math.floor(progress))
table.insert(content, string.format("%s <li>", space))
table.insert(content, string.format([[%s <span style="color: rgb(%d, %d, %d);">%s%s</span>]], space, c[1], c[2], c[3], v.Title, desc))
if (v.Description) then
table.insert(content, string.format([[%s <br><span class="description">%s</span>]], space, v.Description))
end
if (v.Features) then
Feature.GenerateFeatureList(v.Features, space .. "\t\t\t", content)
end
if (v.Note) then
table.insert(content, string.format([[%s <br><span class="note">Note: <span class="notedesc">%s</span></span>]], space, v.Note))
end
if (v.Portability ~= Feature.NotApplicable and Feature.AND(v.Portability, v.RequiredPortability) ~= v.RequiredPortability) then
table.insert(content, string.format([[%s <br><span class="portability">Il manque une implémentation sur au moins un des OS supportés</span>]], space))
end
table.insert(content, string.format("%s </li>", space))
end
table.insert(content, string.format("%s</ul>", space))
end
ACTION.Name = "GenerateFeatures"
ACTION.Description = "Generate a web page describing each module's feature"
ACTION.Function = Feature.Generate

View File

@ -1,116 +0,0 @@
ACTION.Name = "GenerateHeaders"
ACTION.Description = "Generate a global header for each module"
ACTION.ModuleExcludes = {}
ACTION.ModuleExcludes["ConfigCheck.hpp"] = true
ACTION.ModuleExcludes["Debug.hpp"] = true
ACTION.ModuleExcludes["DebugOff.hpp"] = true
ACTION.ModuleExcludes["ThreadSafety.hpp"] = true
ACTION.ModuleExcludes["ThreadSafetyOff.hpp"] = true
local action = ACTION
ACTION.Function = function ()
local paths = {}
local modules = os.matchdirs("../include/Nazara/*")
for k, modulePath in pairs(modules) do
local moduleName = modulePath:match(".*/(.*)")
local config, err = io.open(modulePath .. "/Config.hpp", "r")
local head = ""
if (not config) then
error("Failed to read config file: " .. err)
end
for line in config:lines() do
if (line == "#pragma once") then -- Stop before including the #pragma once as it's already written automatically
break
end
head = head .. line .. "\n"
end
config:close()
table.insert(paths, {
Excludes = action.ModuleExcludes,
Header = head,
HeaderGuard = "NAZARA_GLOBAL_" .. moduleName:upper() .. "_HPP",
Name = "Nazara" .. moduleName,
SearchDir = modulePath,
Target = modulePath .. ".hpp",
TopDir = "Nazara"
})
end
table.insert(paths, {
Excludes = {
["DeviceFunctions.hpp"] = true,
["GlobalFunctions.hpp"] = true,
["InstanceFunctions.hpp"] = true,
},
HeaderGuard = "NAZARA_GLOBAL_VULKANRENDERER_WRAPPER_HPP",
Name = "Vulkan wrapper",
SearchDir = "../include/Nazara/VulkanRenderer/Wrapper",
TopDir = "Nazara",
Target = "../include/Nazara/VulkanRenderer/Wrapper.hpp"
})
table.insert(paths, {
Excludes = {},
HeaderGuard = "NDK_COMPONENTS_GLOBAL_HPP",
Name = "NDK Components",
SearchDir = "../SDK/include/NDK/Components",
TopDir = "NDK",
Target = "../SDK/include/NDK/Components.hpp"
})
table.insert(paths, {
Excludes = {},
HeaderGuard = "NDK_SYSTEMS_GLOBAL_HPP",
Name = "NDK Systems",
SearchDir = "../SDK/include/NDK/Systems",
TopDir = "NDK",
Target = "../SDK/include/NDK/Systems.hpp"
})
table.insert(paths, {
Excludes = {},
HeaderGuard = "NDK_WIDGETS_GLOBAL_HPP",
Name = "NDK Widgets",
SearchDir = "../SDK/include/NDK/Widgets",
TopDir = "NDK",
Target = "../SDK/include/NDK/Widgets.hpp"
})
for k,v in ipairs(paths) do
print(v.Name)
local header, err = io.open(v.Target, "w+")
if (not header) then
error("Failed to create header file (" .. v.Target .. "): " .. err)
end
header:write("// This file was automatically generated\n\n")
if (v.Header) then
header:write(v.Header)
end
header:write("#pragma once\n\n")
header:write("#ifndef " .. v.HeaderGuard .. "\n")
header:write("#define " .. v.HeaderGuard .. "\n\n")
local files = os.matchfiles(v.SearchDir .. "/*.hpp")
local count = 0
for k, filePath in pairs(files) do
local include, fileName = filePath:match(".*(" .. v.TopDir .. "/.*/(.*))")
if (not v.Excludes[fileName]) then
header:write("#include <" .. include .. ">\n")
count = count + 1
end
end
header:write("\n#endif // " .. v.HeaderGuard .. "\n")
header:close()
print(string.format("-#include count: %d", count))
end
end

View File

@ -1,200 +0,0 @@
newoption({
trigger = "pack-libdir",
description = "Specifies the subdirectory in lib/ to be used when packaging the project"
})
ACTION.Name = "Package"
ACTION.Description = "Pack Nazara binaries/include/lib together"
ACTION.Function = function ()
local libDir = _OPTIONS["pack-libdir"]
if (not libDir or #libDir == 0) then
local libDirs = os.matchdirs("../lib/*")
if (#libDirs > 1) then
error("More than one subdirectory was found in the lib directory, please use the --pack-libdir command to clarify which directory should be used")
elseif (#libDirs == 0) then
error("No subdirectory was found in the lib directory, have you built the engine yet?")
else
libDir = path.getname(libDirs[1])
print("No directory was set by the --pack-libdir command, \"" .. libDir .. "\" will be used")
end
end
local realLibDir = "../lib/" .. libDir .. "/"
if (not os.isdir(realLibDir)) then
error(string.format("\"%s\" doesn't seem to be an existing directory", realLibDir))
end
local archEnabled = {
["x64"] = false,
["x86"] = false
}
local enabledArchs = {}
for k,v in pairs(os.matchdirs(realLibDir .. "*")) do
local arch = path.getname(v)
if (archEnabled[arch] ~= nil) then
archEnabled[arch] = true
table.insert(enabledArchs, arch)
else
print("Unknown directory " .. v .. " found, ignored")
end
end
enabledArchs = table.concat(enabledArchs, ", ")
print(enabledArchs .. " arch found")
local packageDir = "../package/"
local copyTargets = {
{ -- Engine headers
Masks = {"**.hpp", "**.inl"},
Source = "../include/",
Target = "include/"
},
{ -- SDK headers
Masks = {"**.hpp", "**.inl"},
Source = "../SDK/include/",
Target = "include/"
},
{ -- Examples files
Masks = {"**.hpp", "**.inl", "**.cpp"},
Source = "../examples/",
Target = "examples/"
},
{ -- Demo resources
Masks = {"**.*"},
Source = "../examples/bin/resources/",
Target = "examples/bin/resources/"
},
-- Unit test sources
{
Masks = {"**.hpp", "**.inl", "**.cpp"},
Source = "../tests/",
Target = "tests/src/"
},
-- Unit test resources
{
Masks = {"**.*"},
Source = "../tests/resources/",
Target = "tests/resources/"
}
}
local binFileMasks
local libFileMasks
local exeFileExt
local exeFilterFunc
if (os.ishost("windows")) then
binFileMasks = {"**.dll", "**.pdb"}
libFileMasks = {"**.lib", "**.a"}
exeFileExt = ".exe"
exeFilterFunc = function (filePath) return true end
else
if (os.ishost("macosx")) then
binFileMasks = {"**.dynlib"}
else
binFileMasks = {"**.so"}
end
libFileMasks = {"**.a"}
exeFileExt = ""
exeFilterFunc = function (filePath) return path.getextension(filePath):contains('/') end
end
for arch, enabled in pairs(archEnabled) do
if (enabled) then
local archLibSrc = realLibDir .. arch .. "/"
local arch3rdPartyBinSrc = "../thirdparty/lib/common/" .. arch .. "/"
local archBinDst = "bin/" .. arch .. "/"
local archLibDst = "lib/" .. arch .. "/"
-- Engine/SDK binaries
table.insert(copyTargets, {
Masks = binFileMasks,
Source = archLibSrc,
Target = archBinDst
})
-- Engine/SDK libraries
table.insert(copyTargets, {
Masks = libFileMasks,
Source = archLibSrc,
Target = archLibDst
})
-- 3rd party binary dep
table.insert(copyTargets, {
Masks = binFileMasks,
Source = arch3rdPartyBinSrc,
Target = archBinDst
})
end
end
-- Demo executable
table.insert(copyTargets, {
Masks = {"Demo*" .. exeFileExt},
Filter = exeFilterFunc,
Source = "../examples/bin/",
Target = "examples/bin/"
})
-- Unit test
table.insert(copyTargets, {
Masks = {"*" .. exeFileExt},
Filter = exeFilterFunc,
Source = "../tests/",
Target = "tests/"
})
-- Processing
os.mkdir(packageDir)
local size = 0
for k,v in pairs(copyTargets) do
local target = packageDir .. v.Target
local includePrefix = v.Source
local targetFiles = {}
for k, mask in pairs(v.Masks) do
print(includePrefix .. mask .. " => " .. target)
local files = os.matchfiles(includePrefix .. mask)
if (v.Filter) then
for k,path in pairs(files) do
if (not v.Filter(path)) then
files[k] = nil
end
end
end
targetFiles = table.join(targetFiles, files)
end
for k,v in pairs(targetFiles) do
local relPath = v:sub(#includePrefix + 1)
local targetPath = target .. relPath
local targetDir = path.getdirectory(targetPath)
if (not os.isdir(targetDir)) then
local ok, err = os.mkdir(targetDir)
if (not ok) then
print("Failed to create directory \"" .. targetDir .. "\": " .. err)
end
end
local ok, err = os.copyfile(v, targetPath)
if (not ok) then
print("Failed to copy \"" .. v .. "\" to \"" .. targetPath .. "\": " .. err)
end
local stat = os.stat(targetPath)
if (stat) then
size = size + stat.size
end
end
end
local config = libDir .. " - " .. enabledArchs
print(string.format("Package successfully created at \"%s\" (%u MB, %s)", packageDir, size // (1024 * 1024), config))
end

File diff suppressed because it is too large Load Diff

View File

@ -1,89 +0,0 @@
return {
Title = "Module audio",
LibName = "NazaraAudio",
Description = "Module permettant de charger et jouer des sons, ainsi que d'accéder au microphone",
RequiredPortability = Feature.Windows + Feature.POSIX,
Features =
{
{
Title = "Gestion des émetteurs de sons (SoundEmitter)",
Description = "Classe de base dont héritent les sources sonores (Music, Sound)",
Features =
{
"Positionnement 3D (spatialisation) si désiré",
"Configuration de l'atténuation",
"Prise en charge de l'effet Doppler (vitesse du son)",
"Altération du ton (pitch)"
}
},
{
Title = "Gestion des tampons sonores (SoundBuffer)",
Description = "Tampon (buffer) stockant les échantillons (samples) décompressés, chargés à partir de fichiers sonores.",
Features =
{
{
Title = "Mixage mono",
Description = "Permet de mixer les différents canaux en un seul (mono), permettant la spatialisation.",
Note = "Le mixage mono n'est actuellement possible qu'au chargement du tampon depuis un fichier",
Progress = 90
}
}
},
{
Title = "Gestion des flux sonores (SoundStream)",
Description = "Interface permettant de définir un flux sonore de source indéfinie (fichier, réseau, etc.)"
},
{
Title = "Sons (Sound)",
Description = "Classe permettant de jouer un tampon sonore",
Features =
{
"Bouclage",
"Mise en pause",
"Récupération/positionnement de l'indice de lecture (offset)"
}
},
{
Title = "Sons streamés (Music)",
Description = "Classe permettant de jouer un son depuis un flux quelconque (SoundStream)",
Features =
{
"Streaming depuis un fichier sonore (+ mixage mono si demandé)",
"Bouclage",
"Mise en pause",
{Title = "Mixage mono", Note = "Le mixage mono devrait être possible au niveau du son lui-même plutôt qu'au niveau du loader", Progress = 0},
{Title = "Récupération/positionnement de l'indice de lecture (offset)", Progress = 0}
}
},
{
Title = "Configuration globale (Audio)",
Description = "Classe permettant de régler les différents paramètres généraux de l'environnement sonore",
Features =
{
"Positionnement/Orientation du listener",
"Réglage du volume général",
"Réglage de la vitesse du son/facteur Doppler"
}
},
{
Title = "Microphone",
Description = "Classe permettant l'accès aux microphones connectés à l'ordinateur",
Progress = 0
},
{
Title = "Environnement (EFX)",
Description = "Prise en charge de l'environnement",
Progress = 0
},
{
Title = "Formats supportés (chargement/streaming)",
Description = "Liste des formats de fichiers supportés par le loader inclus par le module (libsndfile)",
Note = "Le populaire format MP3 n'est pas supporté pour des raisons de royalties (mais la flexibilité du moteur vous permet de rajouter votre propre loader MP3)",
Features =
{
"aiff", "au", "avr", "caf", "flac", "htk", "ircam", "mat4", "mat5", "mpc2k", "nist","ogg", "pvf", "raw", "rf64", "sd2", "sds", "svx", "voc", "w64", "wav", "wve"
}
}
}
}

View File

@ -1,203 +0,0 @@
return {
Title = "Noyau",
LibName = "NazaraCore",
Description = "Noyau du moteur, possède les fonctionnalités utilisées partout ailleurs dans le moteur.",
RequiredPortability = Feature.Windows + Feature.POSIX,
Features =
{
{
Title = "Classes utilitaires de base",
Description = "Classes assurant certaines fonctionnalités de base destinées à aider le programmeur.",
Features =
{
{
Title = "Chaînes de caractère unicode (String)",
Description = "Classe supplantant std::string, rajoutant le support de l'UTF-8 et quelques opérations utiles (rechercher/remplacer, correspondance par motif, ..)."
},
{
Title = "Exécution de code lors de la destruction (CallOnExit)",
Description = "Permet l'appel d'une fonction/lambda à la destruction de cet objet, en accordance avec le RAII/RRID."
},
{
Title = "Gestion de l'initialisation/libération statique de classes, en accordance avec le RAII/RRID",
Description = "Permet d'initialiser et de libérer automatiquement des classes possédant des fonctions membres statiques Initialize/Uninitialize, selon un ordre de dépendance, comme par exemple les classes des modules du moteur lui-même."
},
{
Title = "Gestion des couleurs (Color)",
Description = "Classe permettant de stocker et effectuer des opérations sur des couleurs (conversion, mélange, etc.)."
},
{
Title = "Gestion de primitives, au sens géométrique (Primitive, PrimitiveList)",
Description = "Structures définissant certaines primitives géométriques (boite, cône, plan, sphère), utiles pour la génération de meshs (de rendu ou physiques)."
},
{
Title = "OffsetOf",
Description = "Fonction permettant de récupérer à la compilation l'adresse locale (décalage d'octets) d'un membre de n'importe quelle structure/classe."
},
{
Title = "Pointeurs à écart (stride) indépendant (SparsePtr)",
Description = "Classe se comportant comme un pointeur, à l'exception de l'écart entre deux éléments (opérations d'accès, d'addition et de soustraction) qui est indépendant du type pointé."
},
{
Title = "Stockage et gestion de champs de bits dynamiques (Bitset)",
Description = "Classe permettant le stockage et la manipulation optimisée d'un nombre élevé et dynamique de bits (=booléens, opérations de comptage, recherche de bits activés, opérations entre champs de bits, etc.)",
Note = "Il manque une spécialisation de la fonction de hachage",
Progress = 95
}
}
},
{
Title = "Gestion de fichiers et dossiers (File/Directory)",
Description = "Classes supportant les chemins unicodes et les tailles 64 bits, ainsi que quelques opérations sur les chemins (normalisation, transformation d'un chemin relatif en chemin absolu).",
Portability = Feature.Windows + Feature.POSIX
},
{
Title = "Gestion de l'endianness",
Description = "Boutisme, récupération à la compilation ou à l'exécution, possibilité de lire des fichiers en corrigeant le boutisme des objets lors de la lecture."
},
{
Title = "Gestion de bibliothèques dynamiques (DynLib)",
Description = "Classe permettant de charger à l'exécution des bibliothèques dynamiques (selon la plateforme: .dll/.so/.dynlib) et d'en extraire des fonctions.",
Portability = Feature.Windows + Feature.POSIX
},
{
Title = "Fonctions de hachage",
Description = "Possibilité de hacher (calculer une somme de contrôle) de n'importe quelles données, chaîne de caractère ou fichier.",
Features =
{
{Title = "CRC16", Progress = 0},
"CRC32",
"Fletcher16",
{Title = "Fletcher32", Progress = 0},
"MD5",
"SHA-1",
"SHA-224",
"SHA-256",
"SHA-384",
"SHA-512",
"Whirlpool"
}
},
{
Title = "Gestion de la mémoire",
Description = "Set de fonctionnalités permettant d'aider le programmeur à gérer la mémoire de son programme.",
Features =
{
{
Title = "MemoryManager",
Description = "Classe permettant de suivre les allocations de mémoire et éventuels leaks, peut suivre automatiquement chaque allocation du programme."
},
{
Title = "MemoryPool",
Description = "Classe permettant d'allouer/libérer des blocs de mémoire de taille prédéfinie à coût constant."
}
}
},
{
Title = "Gestion de l'exécution concurrentielle",
Description = "Set de fonctionnalités liées à l'exécution et la synchronisation entre processus légers (threads) sans dépendance sur la bibliothèque standard.",
Features =
{
{
Title = "Thread",
Description = "Classe permettant d'appeler une fonction (avec passage d'arguments) dans un thread, supporte une interface similaire à std::thread.",
Note = "Il n'est pas encore possible de récupérer le Thread::Id courant",
Progress = 95,
Portability = Feature.Windows + Feature.POSIX
},
{
Title = "Mutex",
Description = "Primitive de synchronisation binaire (exclusion mutuelle).",
Portability = Feature.Windows + Feature.POSIX
},
{
Title = "Semaphore",
Description = "Primitive de synchronisation à N concurrents simultanés.",
Portability = Feature.Windows + Feature.POSIX
},
{
Title = "ConditionVariable",
Description = "Primitive de synchronisation à signaux.",
Portability = Feature.Windows + Feature.POSIX
},
{
Title = "LockGuard",
Description = "Classe utilitaire permettant de verrouiller/déverrouiller une mutex en accordance avec le RAII/RRID."
},
{
Title = "TaskScheduler",
Description = "Classe permettant de répartir X tâches sur Y workers de façon efficace.",
Portability = Feature.Windows + Feature.POSIX
}
}
},
{
Title = "Gestion du temps",
Description = "Classes/fonctions permettant de gérer le temps dans un programme.",
Features =
{
{
Title = "Récupération du temps en millisecondes ou en microsecondes",
Description = "Permet de récupérer le nombre de millisecondes ou de microsecondes (si supporté par le système) écoulées depuis un référentiel constant (référentiel indéterminé).",
Portability = Feature.Windows + Feature.POSIX
},
{
Title = "Clock",
Description = "Classe chronomètre permettant de mesurer le temps écoulé depuis un évènement précis, supporte la mise en pause."
}
}
},
{
Title = "Gestion de compteurs de référence",
Description = "Set de classes permettant de gérer des pointeurs intelligents partagés intrusifs.",
},
{
Title = "Gestion de liste de paramètres",
Description = "Classe gérant une liste de paramètres nommées à type variable.",
},
{
Title = "Gestion de ressources (chargement/gestion)",
Description = "Set de classes s'occupant du chargement et de la gestion de certaines classes spéciales, appartenant au groupe des ressources (ex: chargée depuis un fichier).",
Features =
{
{
Title = "ResourceLibrary",
Description = "Classe template chargée du stockage de ressources de façon nommée."
},
{
Title = "ResourceLoader",
Description = "Classe template chargée de stocker et gérer des loaders (fonctions s'occupant de transformer un flux de données en ressource)."
},
{
Title = "ResourceManager",
Description = "Classe template chargée de charger et mettre en cache des ressources depuis un chemin de fichier."
}
}
},
{
Title = "Gestion des plugins",
Description = "Capacité d'extension du moteur à l'aide de bibliothèques dynamiques conçues dans cette optique.",
Note = "Nécessite une révision, permettant aux plugins de se signaler (nom, version)",
Progress = 80
},
{
Title = "Gestion de l'empaquetage bidimensionnel",
Description = "Algorithmes permettant de placer des rectangles 2D arbitraires dans un espace prédéfini de façon à minimiser la perte d'espace.",
Note = "Algorithme Guillotine terminé, algorithme Skyline manquant",
Progress = 60
},
{
Title = "Gestion de l'Unicode",
Description = "Récupération d'informations sur les caractères Unicode (si les données Unicode sont incorporées au programme).",
Note = "Il manque l'intégration des UnicodeData dans le moteur",
Progress = 20
},
{
Title = "Récupération d'informations sur le hardware",
Description = "Classe permettant, si la plateforme le supporte, de récupérer des informations utiles sur le matériel: nom et fabricant du processeur, nombre de coeurs, support d'un set d'extension (exemple: SSE), quantité de mémoire vive, exécution de l'instruction CPUID.",
Progress = 100,
Portability = Feature.Windows + Feature.POSIX
}
}
}

View File

@ -1,71 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Avancement de Nazara</title>
</head>
<body>
<div id="englob">
<img style="display: block;margin-left: auto;margin-right: auto;" src="https://github.com/DigitalPulseSoftware/NazaraEngine/raw/master/Logo.png" alt="Nazara Engine" />
<hr>
Retrouvez le moteur sur GitHub !<br>
<a href="https://github.com/DigitalPulseSoftware/NazaraEngine">Dépôt GitHub</a><br><br>
Venez vous renseigner sur les topics dédiés à Nazara présents sur plusieurs sites web :<br>
<a href="https://openclassrooms.com/forum/sujet/moteur-de-jeu-nazara-engine-69732">OpenClassrooms</a>, <a href="http://pdp.microjoe.org/forums/sujet/354/projet-nazara-engine-moteur-de-jeu">Progdupeupl</a> ou <a href="https://zestedesavoir.com/forums/sujet/1039/nazara-engine/">ZesteDeSavoir</a>
<br><br>
... ou pourquoi ne pas venir faire un tour sur <a href="http://forum.digitalpulsesoftware.net">le forum dédié au moteur</a> ?
<hr>
<h1>Fonctionnalités de Nazara</h1>
<div>Dernière mise à jour : <span class="lastupdate">
%DATE%
</span></div>
<h2>Important:</h2>
<p>Afin de faciliter la mise à jour, la page que vous voyez ici a été générée automatiquement par un <i>script Lua</i>, ce qui m'oblige néanmoins à encoder les fonctionnalités de chaque module dans un premier temps.
C'est un travail assez long (pour vous donner une idée, les données du noyau représentent un fichier de 200 lignes), et il n'est pas encore complet, c'est pourquoi des modules manquent sur cette page.<br>
Gardez donc à l'esprit que le moteur possède plus de fonctionnalités que ce qui est décrit actuellement sur cette page.</p>
<p>Oh et bien sûr je ne suis pas concepteur de site web, c'est pourquoi cette page est moche (j'ai <u>essayé</u> de minimiser les dégâts).<br>
Si vous sentez en vous l'irrésistible envie d'améliorer cette page, sachez que votre aide serait grandement appréciée (vous pouvez me contacter via le lien de votre choix plus haut).</p>
<p>Le pourcentage indiqué est calculé automatiquement en fonction des <u>fonctionnalités</u>, cela signifie qu'une fonctionnalité présente sera comptée à 100% à partir du moment où son implémentation de base est considérée fonctionnelle, <u>cela n'est donc pas une assurance qu'aucun bug n'existe concernant cette fonctionnalité</u> (cependant cela signifie que la fonctionnalité est utilisable).<br>
Et bien entendu, un module ou une fonctionnalité ayant atteint les 100% peut toujours évoluer par la suite.</p>
<hr>
<table>
<caption>Sommaire</caption>
<thead>
<tr>
<th>Module</th>
<th>Avancement</th>
</tr>
</thead>
<tbody>
%MODULELIST%
</tbody>
</table>
%MODULEDESCRIPTION%
<hr>
<table>
<caption>Sommaire</caption>
<thead>
<tr>
<th>Module</th>
<th>Pourcentage</th>
</tr>
</thead>
<tbody>
%MODULELIST%
</tbody>
</table>
</div>
</body>
</html>

View File

@ -1,121 +0,0 @@
/* Je ne suis pas développeur HTML/CSS, je dois y toucher une fois l'an, désolé pour les quelques atrocités que vous pourrez trouver ici */
body
{
font-family: sans-serif;
text-align: center;
margin: 0;
background-color: #f1f1f1;
}
#englob {
display: block;
margin-left: auto;
margin-right: auto;
background-color: white;
width: 50%;
min-width: 765px;
padding: 0 20px;
}
hr {
height: 0;
border: 0;
border-top: 1px solid #eee;
}
a
{
color: #007ACC;
}
a:hover
{
color: lightblue;
}
h1
{
display: inline;
}
h2
{
display: inline;
text-decoration: underline;
}
h4
{
text-decoration: underline;
}
p {
text-align: justify;
}
ol
{
list-style-type: none;
}
table
{
border-collapse: collapse;
text-align: center;
display: inline-block;
border: white groove;
border-radius: 10px;
box-shadow: 0px 0px 10px lightblue;
}
th
{
text-shadow: 2px 2px 4px black;
}
tr
{
border: 1px solid white;
}
tbody tr:hover
{
text-shadow: 0px 0px 4px white;
}
.description
{
margin-left: 20px;
}
.lastupdate
{
font-size: x-large;
font-weight: bold;
color: #f1c40f;
}
.modulename
{
font-size: x-large;
font-weight: bold;
text-shadow: 2px 2px 10px #007ACC;
}
.note
{
margin-left: 20px;
color: #007ACC;
}
.notedesc
{
color: rgb(200, 200, 255);
}
.portability
{
margin-left: 20px;
color: red;
}

View File

@ -1,37 +0,0 @@
MODULE.Name = "Audio"
MODULE.ClientOnly = true
MODULE.Defines = {
"NAZARA_AUDIO_OPENAL"
}
MODULE.Libraries = {
"NazaraCore"
}
MODULE.OsLibraries.Windows = {
"sndfile-1"
}
MODULE.OsLibraries.Posix = {
"sndfile"
}
MODULE.OsDynLib.Windows = {
"soft_oal"
}
MODULE.OsFiles.Windows = {
"../src/Nazara/Audio/Win32/**.hpp",
"../src/Nazara/Audio/Win32/**.cpp"
}
MODULE.OsFiles.Posix = {
"../src/Nazara/Audio/Posix/**.hpp",
"../src/Nazara/Audio/Posix/**.cpp"
}
MODULE.DynLib = {
"soft_oal"
}

View File

@ -1,24 +0,0 @@
MODULE.Name = "Core"
MODULE.Excludable = false -- Excluding the core makes no sense as everything relies on it
MODULE.Files = { -- Other files will be automatically added
"../include/Nazara/Prerequisites.hpp",
"../include/Nazara/Math/**.hpp",
"../include/Nazara/Math/**.inl",
}
MODULE.OsFiles.Windows = {
"../src/Nazara/Core/Win32/**.hpp",
"../src/Nazara/Core/Win32/**.cpp"
}
MODULE.OsFiles.Posix = {
"../src/Nazara/Core/Posix/**.hpp",
"../src/Nazara/Core/Posix/**.cpp"
}
MODULE.OsLibraries.Posix = {
"dl",
"m", -- Math library (for sincos())
"pthread"
}

View File

@ -1,9 +0,0 @@
MODULE.Name = "Graphics"
MODULE.ClientOnly = true
MODULE.Libraries = {
"NazaraCore",
"NazaraRenderer",
"NazaraUtility"
}

View File

@ -1,29 +0,0 @@
MODULE.Name = "Network"
MODULE.Libraries = {
"NazaraCore"
}
MODULE.OsFiles.Windows = {
"../src/Nazara/Network/Win32/**.hpp",
"../src/Nazara/Network/Win32/**.cpp"
}
MODULE.OsFiles.Posix = {
"../src/Nazara/Network/Posix/**.hpp",
"../src/Nazara/Network/Posix/**.cpp"
}
MODULE.OsFiles.Linux = {
"../src/Nazara/Network/Linux/**.hpp",
"../src/Nazara/Network/Linux/**.cpp"
}
MODULE.OsFilesExcluded.Linux = {
"../src/Nazara/Network/Posix/SocketPollerImpl.hpp",
"../src/Nazara/Network/Posix/SocketPollerImpl.cpp"
}
MODULE.OsLibraries.Windows = {
"ws2_32"
}

View File

@ -1,12 +0,0 @@
MODULE.Name = "Physics2D"
MODULE.Defines = {"CP_USE_CGTYPES=0", "TARGET_OS_IPHONE=0", "TARGET_OS_MAC=0"}
MODULE.Libraries = {
"NazaraCore",
"chipmunk"
}
MODULE.DynLib = {
"chipmunk"
}

View File

@ -1,30 +0,0 @@
MODULE.Name = "Physics3D"
MODULE.Defines = {
"_NEWTON_STATIC_LIB"
}
MODULE.OsDefines.Windows = {
"_WINDOWS"
}
MODULE.Libraries = {
"NazaraCore",
"newton" -- Newton Game Dynamics
}
MODULE.Custom = function()
vectorextensions("SSE3")
filter({"architecture:x86_64", "system:linux"})
defines("_POSIX_VER_64")
filter({"architecture:x86", "system:linux"})
defines("_POSIX_VER")
filter({"architecture:x86_64", "system:macosx"})
defines("_POSIX_VER_64")
filter({"architecture:x86", "system:macosx"})
defines("_POSIX_VER")
end

View File

@ -1,35 +0,0 @@
MODULE.Name = "Platform"
MODULE.ClientOnly = true
MODULE.Defines = {
"NAZARA_PLATFORM_SDL2"
}
MODULE.Libraries = {
"NazaraCore",
"NazaraUtility",
"SDL2"
}
MODULE.Files = {
"../src/Nazara/Platform/SDL2/**.hpp",
"../src/Nazara/Platform/SDL2/**.cpp"
}
MODULE.OsDefines.Windows = {
"SDL_VIDEO_DRIVER_WINDOWS=1"
}
MODULE.DynLib = {
"SDL2"
}
MODULE.Custom = function()
filter("system:linux")
defines("SDL_VIDEO_DRIVER_X11=1")
defines("SDL_VIDEO_DRIVER_WAYLAND=1")
filter("system:macosx")
defines("SDL_VIDEO_DRIVER_COCOA=1")
end

View File

@ -1,20 +0,0 @@
MODULE.Name = "Renderer"
MODULE.ClientOnly = true
MODULE.Libraries = {
"NazaraCore",
"NazaraShader",
"NazaraUtility",
"NazaraPlatform"
}
MODULE.OsFiles.Windows = {
"../src/Nazara/Renderer/Win32/**.hpp",
"../src/Nazara/Renderer/Win32/**.cpp"
}
MODULE.OsFiles.Posix = {
"../src/Nazara/Renderer/GLX/**.hpp",
"../src/Nazara/Renderer/GLX/**.cpp"
}

View File

@ -1,6 +0,0 @@
MODULE.Name = "Shader"
MODULE.Libraries = {
"NazaraCore",
"NazaraUtility"
}

View File

@ -1,15 +0,0 @@
MODULE.Name = "Utility"
MODULE.Libraries = {
"NazaraCore",
"stb_image"
}
MODULE.OsLibraries.Windows = {
"freetype-s"
}
MODULE.OsLibraries.Posix = {
"freetype"
}

View File

@ -1,22 +0,0 @@
TOOL.Name = "Assimp"
TOOL.Directory = "../plugins/Assimp"
TOOL.Kind = "Plugin"
TOOL.Includes = {
"../thirdparty/include",
"../include",
"../plugins/Assimp"
}
TOOL.Files = {
"../plugins/Assimp/**.hpp",
"../plugins/Assimp/**.inl",
"../plugins/Assimp/**.cpp"
}
TOOL.Libraries = {
"NazaraCore",
"NazaraUtility",
"assimp"
}

View File

@ -1,34 +0,0 @@
TOOL.Name = "SDK"
TOOL.Directory = "../SDK"
TOOL.Kind = "Library"
TOOL.TargetDirectory = "../lib"
TOOL.Defines = {
"NDK_BUILD"
}
TOOL.Includes = {
"../include",
"../src"
}
TOOL.Files = {
"../include/NazaraSDK/**.hpp",
"../include/NazaraSDK/**.inl",
"../src/NazaraSDK/**.hpp",
"../src/NazaraSDK/**.inl",
"../src/NazaraSDK/**.cpp"
}
TOOL.Libraries = function()
local libraries = {}
for k,v in pairs(NazaraBuild.Modules) do
table.insert(libraries, "Nazara" .. v.Name)
end
-- Keep libraries in the same order to prevent useless premake regeneration
table.sort(libraries)
return libraries
end

View File

@ -1,51 +0,0 @@
TOOL.Name = "SDKServer"
TOOL.Directory = "../SDK"
TOOL.Kind = "Library"
TOOL.TargetDirectory = "../lib"
TOOL.Defines = {
"NDK_BUILD",
"NDK_SERVER"
}
TOOL.Includes = {
"../include",
"../src"
}
TOOL.Files = {
"../include/NazaraSDK/**.hpp",
"../include/NazaraSDK/**.inl",
"../src/NazaraSDK/**.hpp",
"../src/NazaraSDK/**.inl",
"../src/NazaraSDK/**.cpp"
}
-- Excludes client-only files
TOOL.FilesExcluded = {
"../*/NazaraSDK/BaseWidget.*",
"../*/NazaraSDK/Canvas.*",
"../*/NazaraSDK/Console.*",
"../*/NazaraSDK/**/CameraComponent.*",
"../*/NazaraSDK/**/DebugComponent.*",
"../*/NazaraSDK/**/DebugSystem.*",
"../*/NazaraSDK/**/GraphicsComponent.*",
"../*/NazaraSDK/**/LightComponent.*",
"../*/NazaraSDK/**/ListenerComponent.*",
"../*/NazaraSDK/**/ListenerSystem.*",
"../*/NazaraSDK/**/Particle*Component.*",
"../*/NazaraSDK/**/ParticleSystem.*",
"../*/NazaraSDK/**/RenderSystem.*",
"../*/NazaraSDK/**/*Layout*.*",
"../*/NazaraSDK/**/*Widget*.*"
}
TOOL.Libraries = {
"NazaraCore",
"NazaraNetwork",
"NazaraPhysics2D",
"NazaraPhysics3D",
"NazaraShader",
"NazaraUtility"
}

View File

@ -1,54 +0,0 @@
TOOL.Name = "OpenGLRenderer"
TOOL.ClientOnly = true
TOOL.Kind = "Library"
TOOL.TargetDirectory = "../lib"
TOOL.Defines = {
"NAZARA_BUILD",
"NAZARA_OPENGLRENDERER_BUILD"
}
TOOL.Includes = {
"../include",
"../src/",
"../extlibs/include"
}
TOOL.Files = {
"../include/Nazara/OpenGLRenderer/**.hpp",
"../include/Nazara/OpenGLRenderer/**.inl",
"../src/Nazara/OpenGLRenderer/**.hpp",
"../src/Nazara/OpenGLRenderer/**.inl",
"../src/Nazara/OpenGLRenderer/**.cpp"
}
TOOL.Libraries = {
"NazaraCore",
"NazaraPlatform",
"NazaraRenderer",
"NazaraShader",
"NazaraUtility"
}
TOOL.OsFiles.Windows = {
"../include/Nazara/OpenGLRenderer/Wrapper/Win32/**.hpp",
"../include/Nazara/OpenGLRenderer/Wrapper/Win32/**.inl",
"../include/Nazara/OpenGLRenderer/Wrapper/WGL/**.hpp",
"../include/Nazara/OpenGLRenderer/Wrapper/WGL/**.inl",
"../src/Nazara/OpenGLRenderer/Wrapper/Win32/**.hpp",
"../src/Nazara/OpenGLRenderer/Wrapper/Win32/**.inl",
"../src/Nazara/OpenGLRenderer/Wrapper/Win32/**.cpp",
"../src/Nazara/OpenGLRenderer/Wrapper/WGL/**.hpp",
"../src/Nazara/OpenGLRenderer/Wrapper/WGL/**.inl",
"../src/Nazara/OpenGLRenderer/Wrapper/WGL/**.cpp"
}
TOOL.OsFiles.Linux = {
"../include/Nazara/OpenGLRenderer/Wrapper/Linux/**.hpp",
"../include/Nazara/OpenGLRenderer/Wrapper/Linux/**.inl",
"../src/Nazara/OpenGLRenderer/Wrapper/Linux/**.hpp",
"../src/Nazara/OpenGLRenderer/Wrapper/Linux/**.inl",
"../src/Nazara/OpenGLRenderer/Wrapper/Linux/**.cpp"
}

View File

@ -1,92 +0,0 @@
TOOL.Name = "ShaderNodes"
TOOL.ClientOnly = true
TOOL.EnableConsole = true
TOOL.Kind = "Application"
TOOL.TargetDirectory = "../bin"
TOOL.Defines = {
"NODE_EDITOR_SHARED"
}
TOOL.Includes = {
"../include",
"../extlibs/include",
"../src"
}
TOOL.Files = {
"../src/ShaderNode/**.hpp",
"../src/ShaderNode/**.inl",
"../src/ShaderNode/**.cpp"
}
TOOL.Libraries = {
"NazaraCore%s(-s)%d(-d)",
"NazaraShader%s(-s)%d(-d)",
"NazaraUtility%s(-s)%d(-d)",
"Qt5Core%d(d)",
"Qt5Gui%d(d)",
"Qt5Widgets%d(d)",
"nodes%d(d)"
}
local function AppendValues(tab, value)
if (type(value) == "table") then
for _, v in pairs(value) do
AppendValues(tab, v)
end
else
table.insert(tab, value)
end
end
function TOOL:ValidateLib(libName)
local config = NazaraBuild:GetConfig()
local includes = config[libName .. "IncludeDir"]
local binDir32 = config[libName .. "BinDir_x86"]
local binDir64 = config[libName .. "BinDir_x64"]
local libDir32 = config[libName .. "LibDir_x86"]
local libDir64 = config[libName .. "LibDir_x64"]
if (not includes) then
return false, "missing " .. libName .. " includes directories in config.lua"
end
if (not libDir32 and not libDir64) then
return false, "missing " .. libName .. " library search directories in config.lua"
end
AppendValues(self.Includes, includes)
if (binDir32) then
AppendValues(self.BinaryPaths.x86, binDir32)
end
if (binDir64) then
AppendValues(self.BinaryPaths.x64, binDir64)
end
if (libDir32) then
AppendValues(self.LibraryPaths.x86, libDir32)
end
if (libDir64) then
AppendValues(self.LibraryPaths.x64, libDir64)
end
return true
end
function TOOL:Validate()
local success, err = self:ValidateLib("Qt5")
if (not success) then
return false, err
end
local success, err = self:ValidateLib("QtNodes")
if (not success) then
return false, err
end
return true
end

View File

@ -1,27 +0,0 @@
TOOL.Name = "UnitTests"
TOOL.Category = "Test"
TOOL.Directory = "../tests"
TOOL.EnableConsole = true
TOOL.Kind = "Application"
TOOL.TargetDirectory = TOOL.Directory
TOOL.Defines = {
}
TOOL.Includes = {
"../include"
}
TOOL.Files = {
"../tests/main.cpp",
"../tests/Engine/**.hpp",
"../tests/Engine/**.cpp",
"../tests/SDK/**.hpp",
"../tests/SDK/**.cpp"
}
TOOL.Libraries = {
"NazaraNetwork",
"NazaraSDK"
}

View File

@ -1,38 +0,0 @@
TOOL.Name = "UnitTestsServer"
TOOL.Category = "Test"
TOOL.Directory = "../tests"
TOOL.EnableConsole = true
TOOL.Kind = "Application"
TOOL.TargetDirectory = TOOL.Directory
TOOL.Defines = {
"NDK_SERVER"
}
TOOL.Includes = {
"../include"
}
TOOL.Files = {
"../tests/main.cpp",
"../tests/Engine/**.hpp",
"../tests/Engine/**.cpp",
"../tests/SDK/**.hpp",
"../tests/SDK/**.cpp"
}
-- Excludes client-only files
TOOL.FilesExcluded = {
"../tests/Engine/Audio/**",
"../tests/Engine/Graphics/**",
"../tests/Engine/Platform/**",
"../tests/SDK/NDK/Application.cpp",
"../tests/SDK/NDK/Systems/ListenerSystem.cpp",
"../tests/SDK/NDK/Systems/RenderSystem.cpp"
}
TOOL.Libraries = {
"NazaraNetwork",
"NazaraSDKServer"
}

View File

@ -1,53 +0,0 @@
TOOL.Name = "VulkanRenderer"
TOOL.ClientOnly = true
TOOL.Kind = "Library"
TOOL.TargetDirectory = "../lib"
TOOL.Defines = {
"NAZARA_BUILD",
"NAZARA_VULKANRENDERER_BUILD",
"VK_NO_PROTOTYPES"
}
TOOL.Includes = {
"../include",
"../src/",
"../extlibs/include"
}
TOOL.Files = {
"../include/Nazara/VulkanRenderer/**.hpp",
"../include/Nazara/VulkanRenderer/**.inl",
"../src/Nazara/VulkanRenderer/**.hpp",
"../src/Nazara/VulkanRenderer/**.inl",
"../src/Nazara/VulkanRenderer/**.cpp"
}
TOOL.Libraries = {
"NazaraCore",
"NazaraPlatform",
"NazaraRenderer",
"NazaraShader",
"NazaraUtility"
}
TOOL.OsDefines.Linux = {
-- "VK_USE_PLATFORM_MIR_KHR",
-- "VK_USE_PLATFORM_XCB_KHR"
"VK_USE_PLATFORM_XLIB_KHR",
"VK_USE_PLATFORM_WAYLAND_KHR"
}
TOOL.OsDefines.BSD = TOOL.OsDefines.Linux
TOOL.OsDefines.Solaris = TOOL.OsDefines.Linux
TOOL.OsDefines.Windows = {
"VK_USE_PLATFORM_WIN32_KHR"
}
TOOL.OsFiles.Windows = {
"../src/Nazara/VulkanRenderer/Win32/**.hpp",
"../src/Nazara/VulkanRenderer/Win32/**.cpp"
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,5 @@
target("DeferredShading")
set_group("Examples")
set_kind("binary")
add_deps("NazaraGraphics")
add_files("main.cpp")

View File

@ -1,14 +0,0 @@
EXAMPLE.Name = "DopplerEffect"
EXAMPLE.EnableConsole = true
EXAMPLE.Files = {
"main.cpp"
}
EXAMPLE.Libraries = {
"NazaraAudio",
"NazaraCore",
"NazaraPlatform",
"NazaraUtility"
}

View File

@ -20,17 +20,14 @@
int main() int main()
{ {
// NzKeyboard nécessite l'initialisation du module Utilitaire std::filesystem::path resourceDir = "resources";
if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory(".." / resourceDir))
resourceDir = ".." / resourceDir;
Nz::Modules<Nz::Audio, Nz::Platform> audio; Nz::Modules<Nz::Audio, Nz::Platform> audio;
/*if (!audio)
{
std::cout << "Failed to initialize audio module" << std::endl;
std::getchar();
return 1;
}*/
Nz::Sound sound; Nz::Sound sound;
if (!sound.LoadFromFile("resources/siren.wav")) if (!sound.LoadFromFile(resourceDir / "siren.wav"))
{ {
std::cout << "Failed to load sound" << std::endl; std::cout << "Failed to load sound" << std::endl;
std::getchar(); std::getchar();
@ -57,7 +54,7 @@ int main()
// La boucle du programme (Pour déplacer le son) // La boucle du programme (Pour déplacer le son)
Nz::Clock clock; Nz::Clock clock;
while (sound.GetStatus() == Nz::SoundStatus_Playing) while (sound.GetStatus() == Nz::SoundStatus::Playing)
{ {
// Comme le son se joue dans un thread séparé, on peut mettre en pause le principal régulièrement // Comme le son se joue dans un thread séparé, on peut mettre en pause le principal régulièrement
int sleepTime = int(1000/60 - clock.GetMilliseconds()); // 60 FPS int sleepTime = int(1000/60 - clock.GetMilliseconds()); // 60 FPS

View File

@ -0,0 +1,5 @@
target("DopplerEffect")
set_group("Examples")
set_kind("binary")
add_deps("NazaraAudio", "NazaraPlatform")
add_files("main.cpp")

View File

@ -0,0 +1,308 @@
#include <Nazara/Core.hpp>
#include <Nazara/Platform.hpp>
#include <Nazara/Graphics.hpp>
#include <Nazara/Renderer.hpp>
#include <Nazara/Shader.hpp>
#include <Nazara/Shader/SpirvConstantCache.hpp>
#include <Nazara/Shader/SpirvPrinter.hpp>
#include <Nazara/Utility.hpp>
#include <array>
#include <iostream>
int main()
{
std::filesystem::path resourceDir = "resources";
if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory(".." / resourceDir))
resourceDir = ".." / resourceDir;
Nz::Renderer::Config rendererConfig;
std::cout << "Run using Vulkan? (y/n)" << std::endl;
if (std::getchar() == 'y')
rendererConfig.preferredAPI = Nz::RenderAPI::Vulkan;
else
rendererConfig.preferredAPI = Nz::RenderAPI::OpenGL;
Nz::Modules<Nz::Graphics> nazara(rendererConfig);
Nz::RenderWindow window;
Nz::MeshParams meshParams;
meshParams.storage = Nz::DataStorage::Software;
meshParams.matrix = Nz::Matrix4f::Rotate(Nz::EulerAnglesf(0.f, 90.f, 180.f)) * Nz::Matrix4f::Scale(Nz::Vector3f(0.002f));
meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout::XYZ_Normal_UV);
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();
std::string windowTitle = "Graphics Test";
if (!window.Create(device, Nz::VideoMode(800, 600, 32), windowTitle))
{
std::cout << "Failed to create Window" << std::endl;
return __LINE__;
}
std::shared_ptr<Nz::Mesh> spaceshipMesh = Nz::Mesh::LoadFromFile(resourceDir / "Spaceship/spaceship.obj", meshParams);
if (!spaceshipMesh)
{
NazaraError("Failed to load model");
return __LINE__;
}
std::shared_ptr<Nz::GraphicalMesh> gfxMesh = std::make_shared<Nz::GraphicalMesh>(*spaceshipMesh);
// Texture
std::shared_ptr<Nz::Image> diffuseImage = Nz::Image::LoadFromFile(resourceDir / "Spaceship/Texture/diffuse.png");
if (!diffuseImage || !diffuseImage->Convert(Nz::PixelFormat::RGBA8_SRGB))
{
NazaraError("Failed to load image");
return __LINE__;
}
Nz::TextureParams texParams;
texParams.renderDevice = device;
texParams.loadFormat = Nz::PixelFormat::RGBA8_SRGB;
std::shared_ptr<Nz::Material> material = std::make_shared<Nz::Material>(Nz::BasicMaterial::GetSettings());
material->EnableDepthBuffer(true);
material->EnableFaceCulling(true);
Nz::BasicMaterial basicMat(*material);
basicMat.EnableAlphaTest(true);
basicMat.SetAlphaMap(Nz::Texture::LoadFromFile(resourceDir / "alphatile.png", texParams));
basicMat.SetDiffuseMap(Nz::Texture::LoadFromFile(resourceDir / "Spaceship/Texture/diffuse.png", texParams));
Nz::Model model(std::move(gfxMesh));
for (std::size_t i = 0; i < model.GetSubMeshCount(); ++i)
model.SetMaterial(i, material);
Nz::PredefinedInstanceData instanceUboOffsets = Nz::PredefinedInstanceData::GetOffsets();
Nz::PredefinedViewerData viewerUboOffsets = Nz::PredefinedViewerData::GetOffsets();
const Nz::BasicMaterial::UniformOffsets& materialSettingOffsets = Nz::BasicMaterial::GetOffsets();
std::vector<std::uint8_t> viewerDataBuffer(viewerUboOffsets.totalSize);
Nz::Vector2ui windowSize = window.GetSize();
Nz::AccessByOffset<Nz::Matrix4f&>(viewerDataBuffer.data(), viewerUboOffsets.viewMatrixOffset) = Nz::Matrix4f::Translate(Nz::Vector3f::Backward() * 1);
Nz::AccessByOffset<Nz::Matrix4f&>(viewerDataBuffer.data(), viewerUboOffsets.projMatrixOffset) = Nz::Matrix4f::Perspective(Nz::DegreeAnglef(70.f), float(windowSize.x) / windowSize.y, 0.1f, 1000.f);
std::vector<std::uint8_t> instanceDataBuffer(instanceUboOffsets.totalSize);
Nz::ModelInstance modelInstance(material->GetSettings());
{
material->UpdateShaderBinding(modelInstance.GetShaderBinding());
Nz::AccessByOffset<Nz::Matrix4f&>(instanceDataBuffer.data(), instanceUboOffsets.worldMatrixOffset) = Nz::Matrix4f::Translate(Nz::Vector3f::Forward() * 2 + Nz::Vector3f::Right());
std::shared_ptr<Nz::AbstractBuffer>& instanceDataUBO = modelInstance.GetInstanceBuffer();
instanceDataUBO->Fill(instanceDataBuffer.data(), 0, instanceDataBuffer.size());
}
Nz::ModelInstance modelInstance2(material->GetSettings());
{
material->UpdateShaderBinding(modelInstance2.GetShaderBinding());
Nz::AccessByOffset<Nz::Matrix4f&>(instanceDataBuffer.data(), instanceUboOffsets.worldMatrixOffset) = Nz::Matrix4f::Translate(Nz::Vector3f::Forward() * 2 + Nz::Vector3f::Right() * 3.f);
std::shared_ptr<Nz::AbstractBuffer>& instanceDataUBO = modelInstance2.GetInstanceBuffer();
instanceDataUBO->Fill(instanceDataBuffer.data(), 0, instanceDataBuffer.size());
}
std::shared_ptr<Nz::AbstractBuffer> viewerDataUBO = Nz::Graphics::Instance()->GetViewerDataUBO();
Nz::RenderWindowImpl* windowImpl = window.GetImpl();
std::shared_ptr<Nz::CommandPool> commandPool = windowImpl->CreateCommandPool(Nz::QueueType::Graphics);
Nz::CommandBufferPtr drawCommandBuffer;
auto RebuildCommandBuffer = [&]
{
Nz::Vector2ui windowSize = window.GetSize();
drawCommandBuffer = commandPool->BuildCommandBuffer([&](Nz::CommandBufferBuilder& builder)
{
Nz::Recti renderRect(0, 0, window.GetSize().x, window.GetSize().y);
Nz::CommandBufferBuilder::ClearValues clearValues[2];
clearValues[0].color = Nz::Color::Black;
clearValues[1].depth = 1.f;
clearValues[1].stencil = 0;
builder.BeginDebugRegion("Main window rendering", Nz::Color::Green);
{
builder.BeginRenderPass(windowImpl->GetFramebuffer(), windowImpl->GetRenderPass(), renderRect, { clearValues[0], clearValues[1] });
{
builder.SetScissor(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) });
builder.SetViewport(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) });
for (Nz::ModelInstance& modelInstance : { std::ref(modelInstance), std::ref(modelInstance2) })
{
builder.BindShaderBinding(modelInstance.GetShaderBinding());
for (std::size_t i = 0; i < model.GetSubMeshCount(); ++i)
{
builder.BindIndexBuffer(model.GetIndexBuffer(i).get());
builder.BindVertexBuffer(0, model.GetVertexBuffer(i).get());
builder.BindPipeline(*model.GetRenderPipeline(i));
builder.DrawIndexed(model.GetIndexCount(i));
}
}
}
builder.EndRenderPass();
}
builder.EndDebugRegion();
});
};
RebuildCommandBuffer();
Nz::Vector3f viewerPos = Nz::Vector3f::Zero();
Nz::EulerAnglesf camAngles(0.f, 0.f, 0.f);
Nz::Quaternionf camQuat(camAngles);
window.EnableEventPolling(true);
Nz::Clock updateClock;
Nz::Clock secondClock;
unsigned int fps = 0;
bool viewerUboUpdate = true;
Nz::Mouse::SetRelativeMouseMode(true);
while (window.IsOpen())
{
Nz::WindowEvent event;
while (window.PollEvent(&event))
{
switch (event.type)
{
case Nz::WindowEventType::Quit:
window.Close();
break;
case Nz::WindowEventType::MouseMoved: // La souris a bougé
{
// Gestion de la caméra free-fly (Rotation)
float sensitivity = 0.3f; // Sensibilité de la souris
// On modifie l'angle de la caméra grâce au déplacement relatif sur X de la souris
camAngles.yaw = camAngles.yaw - event.mouseMove.deltaX * sensitivity;
camAngles.yaw.Normalize();
// Idem, mais pour éviter les problèmes de calcul de la matrice de vue, on restreint les angles
camAngles.pitch = Nz::Clamp(camAngles.pitch + event.mouseMove.deltaY*sensitivity, -89.f, 89.f);
camQuat = camAngles;
viewerUboUpdate = true;
break;
}
case Nz::WindowEventType::Resized:
{
Nz::Vector2ui windowSize = window.GetSize();
Nz::AccessByOffset<Nz::Matrix4f&>(viewerDataBuffer.data(), viewerUboOffsets.projMatrixOffset) = Nz::Matrix4f::Perspective(Nz::DegreeAnglef(70.f), float(windowSize.x) / windowSize.y, 0.1f, 1000.f);
viewerUboUpdate = true;
break;
}
default:
break;
}
}
if (updateClock.GetMilliseconds() > 1000 / 60)
{
float cameraSpeed = 2.f * updateClock.GetSeconds();
updateClock.Restart();
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Up) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Z))
viewerPos += camQuat * Nz::Vector3f::Forward() * cameraSpeed;
// Si la flèche du bas ou la touche S est pressée, on recule
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Down) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::S))
viewerPos += camQuat * Nz::Vector3f::Backward() * cameraSpeed;
// Etc...
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Left) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Q))
viewerPos += camQuat * Nz::Vector3f::Left() * cameraSpeed;
// Etc...
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Right) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::D))
viewerPos += camQuat * Nz::Vector3f::Right() * cameraSpeed;
// Majuscule pour monter, notez l'utilisation d'une direction globale (Non-affectée par la rotation)
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::RShift))
viewerPos += Nz::Vector3f::Up() * cameraSpeed;
// Contrôle (Gauche ou droite) pour descendre dans l'espace global, etc...
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::LControl) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::RControl))
viewerPos += Nz::Vector3f::Down() * cameraSpeed;
viewerUboUpdate = true;
}
Nz::RenderFrame frame = windowImpl->Acquire();
if (!frame)
continue;
if (frame.IsFramebufferInvalidated())
RebuildCommandBuffer();
Nz::AccessByOffset<Nz::Matrix4f&>(viewerDataBuffer.data(), viewerUboOffsets.viewMatrixOffset) = Nz::Matrix4f::ViewMatrix(viewerPos, camAngles);
if (viewerUboUpdate)
{
Nz::UploadPool& uploadPool = frame.GetUploadPool();
auto& allocation = uploadPool.Allocate(viewerDataBuffer.size());
std::memcpy(allocation.mappedPtr, viewerDataBuffer.data(), viewerDataBuffer.size());
frame.Execute([&](Nz::CommandBufferBuilder& builder)
{
builder.BeginDebugRegion("UBO Update", Nz::Color::Yellow);
{
builder.PreTransferBarrier();
builder.CopyBuffer(allocation, viewerDataUBO.get());
material->UpdateBuffers(uploadPool, builder);
builder.PostTransferBarrier();
}
builder.EndDebugRegion();
}, Nz::QueueType::Transfer);
viewerUboUpdate = false;
}
frame.SubmitCommandBuffer(drawCommandBuffer.get(), Nz::QueueType::Graphics);
frame.Present();
window.Display();
// On incrémente le compteur de FPS improvisé
fps++;
if (secondClock.GetMilliseconds() >= 1000) // Toutes les secondes
{
// Et on insère ces données dans le titre de la fenêtre
window.SetTitle(windowTitle + " - " + Nz::NumberToString(fps) + " FPS");
/*
Note: En C++11 il est possible d'insérer de l'Unicode de façon standard, quel que soit l'encodage du fichier,
via quelque chose de similaire à u8"Cha\u00CEne de caract\u00E8res".
Cependant, si le code source est encodé en UTF-8 (Comme c'est le cas dans ce fichier),
cela fonctionnera aussi comme ceci : "Chaîne de caractères".
*/
// Et on réinitialise le compteur de FPS
fps = 0;
// Et on relance l'horloge pour refaire ça dans une seconde
secondClock.Restart();
}
}
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,5 @@
target("GraphicsTest")
set_group("Examples")
set_kind("binary")
add_deps("NazaraGraphics")
add_files("main.cpp")

View File

@ -63,7 +63,7 @@ int main()
std::cout << oss.str() << std::endl; std::cout << oss.str() << std::endl;
Nz::File reportFile("HardwareInfo.txt"); Nz::File reportFile("HardwareInfo.txt");
if (reportFile.Open(Nz::OpenMode_Text | Nz::OpenMode_Truncate | Nz::OpenMode_WriteOnly)) if (reportFile.Open(Nz::OpenMode::Text | Nz::OpenMode::Truncate | Nz::OpenMode::WriteOnly))
{ {
reportFile.Write(oss.str()); // Conversion implicite en std::string reportFile.Write(oss.str()); // Conversion implicite en std::string
reportFile.Close(); reportFile.Close();

View File

@ -0,0 +1,42 @@
/*
** PlayMusic - Example on playing a sound using streaming (doesn't load all the file in memory, only the played part) with Nz::Music
*/
#include <Nazara/Audio.hpp>
#include <Nazara/Core/Clock.hpp>
#include <Nazara/Core/Modules.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Platform/Keyboard.hpp>
#include <Nazara/Platform/Platform.hpp>
#include <chrono>
#include <iostream>
#include <thread>
int main()
{
std::filesystem::path resourceDir = "resources";
if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory(".." / resourceDir))
resourceDir = ".." / resourceDir;
Nz::Modules<Nz::Audio> audio;
Nz::SoundStreamParams streamParams;
streamParams.forceMono = false;
Nz::Music music;
if (!music.OpenFromFile(resourceDir / "file_example_MP3_700KB.mp3", streamParams))
{
std::cout << "Failed to load sound" << std::endl;
std::getchar();
return EXIT_FAILURE;
}
music.Play();
std::cout << "Playing sound..." << std::endl;
while (music.IsPlaying())
std::this_thread::sleep_for(std::chrono::milliseconds(100));
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,5 @@
target("PlayMusic")
set_group("Examples")
set_kind("binary")
add_deps("NazaraAudio")
add_files("main.cpp")

View File

@ -1,15 +0,0 @@
EXAMPLE.Name = "RenderTest"
EXAMPLE.EnableConsole = true
EXAMPLE.Files = {
"main.cpp"
}
EXAMPLE.Libraries = {
"NazaraCore",
"NazaraPlatform",
"NazaraRenderer",
"NazaraShader",
"NazaraUtility"
}

View File

@ -8,8 +8,73 @@
#include <array> #include <array>
#include <iostream> #include <iostream>
const char shaderSource[] = R"(
option red: bool;
[layout(std140)]
struct Data
{
projectionMatrix: mat4<f32>,
worldMatrix: mat4<f32>,
viewMatrix: mat4<f32>
}
external
{
[binding(0)] viewerData: uniform<Data>,
[binding(1)] tex: sampler2D<f32>
}
struct VertIn
{
[location(0)] position: vec3<f32>,
[location(1)] normal: vec3<f32>,
[location(2)] uv: vec2<f32>
}
struct VertOut
{
[builtin(position)] position: vec4<f32>,
[location(0)] normal: vec3<f32>,
[location(1)] uv: vec2<f32>
}
struct FragOut
{
[location(0)] color: vec4<f32>
}
[entry(frag)]
fn main(fragIn: VertOut) -> FragOut
{
let lightDir = vec3<f32>(0.0, -0.707, 0.707);
let lightFactor = dot(fragIn.normal, lightDir);
let fragOut: FragOut;
fragOut.color = lightFactor * tex.Sample(fragIn.uv) * select_opt(red, vec4<f32>(1.0, 0.0, 0.0, 1.0), vec4<f32>(1.0, 1.0, 1.0, 1.0));
return fragOut;
}
[entry(vert)]
fn main(vertIn: VertIn) -> VertOut
{
let vertOut: VertOut;
vertOut.position = viewerData.projectionMatrix * viewerData.viewMatrix * viewerData.worldMatrix * vec4<f32>(vertIn.position, 1.0);
vertOut.normal = vertIn.normal;
vertOut.uv = vertIn.uv;
return vertOut;
}
)";
int main() int main()
{ {
std::filesystem::path resourceDir = "resources";
if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory(".." / resourceDir))
resourceDir = ".." / resourceDir;
Nz::Renderer::Config rendererConfig; Nz::Renderer::Config rendererConfig;
std::cout << "Run using Vulkan? (y/n)" << std::endl; std::cout << "Run using Vulkan? (y/n)" << std::endl;
if (std::getchar() == 'y') if (std::getchar() == 'y')
@ -23,71 +88,52 @@ int main()
Nz::MeshParams meshParams; Nz::MeshParams meshParams;
meshParams.matrix = Nz::Matrix4f::Rotate(Nz::EulerAnglesf(0.f, 90.f, 180.f)) * Nz::Matrix4f::Scale(Nz::Vector3f(0.002f)); meshParams.matrix = Nz::Matrix4f::Rotate(Nz::EulerAnglesf(0.f, 90.f, 180.f)) * Nz::Matrix4f::Scale(Nz::Vector3f(0.002f));
meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout_XYZ_Normal_UV); meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout::XYZ_Normal_UV);
std::shared_ptr<Nz::RenderDevice> device = Nz::Renderer::Instance()->InstanciateRenderDevice(0);
std::string windowTitle = "Render Test"; std::string windowTitle = "Render Test";
if (!window.Create(Nz::VideoMode(800, 600, 32), windowTitle)) if (!window.Create(device, Nz::VideoMode(800, 600, 32), windowTitle))
{ {
std::cout << "Failed to create Window" << std::endl; std::cout << "Failed to create Window" << std::endl;
return __LINE__; return __LINE__;
} }
std::shared_ptr<Nz::RenderDevice> device = window.GetRenderDevice(); Nz::ShaderWriter::States states;
states.enabledOptions = 0;
states.optimize = true;
auto fragmentShader = device->InstantiateShaderStage(Nz::ShaderStageType::Fragment, Nz::ShaderLanguage::NazaraBinary, "frag.shader"); auto fragVertShader = device->InstantiateShaderModule(Nz::ShaderStageType::Fragment | Nz::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, shaderSource, sizeof(shaderSource), states);
if (!fragmentShader) if (!fragVertShader)
{ {
std::cout << "Failed to instantiate fragment shader" << std::endl; std::cout << "Failed to instantiate shader" << std::endl;
return __LINE__; return __LINE__;
} }
auto vertexShader = device->InstantiateShaderStage(Nz::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraBinary, "vert.shader"); std::shared_ptr<Nz::Mesh> drfreak = Nz::Mesh::LoadFromFile(resourceDir / "Spaceship/spaceship.obj", meshParams);
if (!vertexShader)
{
std::cout << "Failed to instantiate fragment shader" << std::endl;
return __LINE__;
}
Nz::MeshRef drfreak = Nz::Mesh::LoadFromFile("resources/Spaceship/spaceship.obj", meshParams);
if (!drfreak) if (!drfreak)
{ {
NazaraError("Failed to load model"); NazaraError("Failed to load model");
return __LINE__; return __LINE__;
} }
Nz::StaticMesh* drfreakMesh = static_cast<Nz::StaticMesh*>(drfreak->GetSubMesh(0)); std::shared_ptr<Nz::StaticMesh> spaceshipMesh = std::static_pointer_cast<Nz::StaticMesh>(drfreak->GetSubMesh(0));
const Nz::VertexBuffer* drfreakVB = drfreakMesh->GetVertexBuffer(); const std::shared_ptr<Nz::VertexBuffer>& meshVB = spaceshipMesh->GetVertexBuffer();
const Nz::IndexBuffer* drfreakIB = drfreakMesh->GetIndexBuffer(); const std::shared_ptr<const Nz::IndexBuffer>& meshIB = spaceshipMesh->GetIndexBuffer();
// Index buffer // Index buffer
std::cout << "Index count: " << drfreakIB->GetIndexCount() << std::endl; std::cout << "Index count: " << meshIB->GetIndexCount() << std::endl;
// Vertex buffer // Vertex buffer
std::cout << "Vertex count: " << drfreakVB->GetVertexCount() << std::endl; std::cout << "Vertex count: " << meshVB->GetVertexCount() << std::endl;
// Texture // Texture
Nz::ImageRef drfreakImage = Nz::Image::LoadFromFile("resources/Spaceship/Texture/diffuse.png"); Nz::TextureParams texParams;
if (!drfreakImage || !drfreakImage->Convert(Nz::PixelFormat_RGBA8)) texParams.renderDevice = device;
{ texParams.loadFormat = Nz::PixelFormat::RGBA8_SRGB;
NazaraError("Failed to load image");
return __LINE__;
}
Nz::TextureInfo texParams;
texParams.pixelFormat = drfreakImage->GetFormat();
texParams.type = drfreakImage->GetType();
texParams.width = drfreakImage->GetWidth();
texParams.height = drfreakImage->GetHeight();
texParams.depth = drfreakImage->GetDepth();
std::shared_ptr<Nz::Texture> texture = device->InstantiateTexture(texParams);
if (!texture->Update(drfreakImage->GetConstPixels()))
{
NazaraError("Failed to update texture");
return __LINE__;
}
std::shared_ptr<Nz::Texture> texture = Nz::Texture::LoadFromFile(resourceDir / "Spaceship/Texture/diffuse.png", texParams);
std::shared_ptr<Nz::TextureSampler> textureSampler = device->InstantiateTextureSampler({}); std::shared_ptr<Nz::TextureSampler> textureSampler = device->InstantiateTextureSampler({});
struct struct
@ -99,7 +145,7 @@ int main()
ubo; ubo;
Nz::Vector2ui windowSize = window.GetSize(); Nz::Vector2ui windowSize = window.GetSize();
ubo.projectionMatrix = Nz::Matrix4f::Perspective(70.f, float(windowSize.x) / windowSize.y, 0.1f, 1000.f); ubo.projectionMatrix = Nz::Matrix4f::Perspective(Nz::DegreeAnglef(70.f), float(windowSize.x) / windowSize.y, 0.1f, 1000.f);
ubo.viewMatrix = Nz::Matrix4f::Translate(Nz::Vector3f::Backward() * 1); ubo.viewMatrix = Nz::Matrix4f::Translate(Nz::Vector3f::Backward() * 1);
ubo.modelMatrix = Nz::Matrix4f::Translate(Nz::Vector3f::Forward() * 2 + Nz::Vector3f::Right()); ubo.modelMatrix = Nz::Matrix4f::Translate(Nz::Vector3f::Forward() * 2 + Nz::Vector3f::Right());
@ -120,8 +166,8 @@ int main()
Nz::ShaderBindingPtr shaderBinding = renderPipelineLayout->AllocateShaderBinding(); Nz::ShaderBindingPtr shaderBinding = renderPipelineLayout->AllocateShaderBinding();
std::shared_ptr<Nz::AbstractBuffer> uniformBuffer = device->InstantiateBuffer(Nz::BufferType_Uniform); std::shared_ptr<Nz::AbstractBuffer> uniformBuffer = device->InstantiateBuffer(Nz::BufferType::Uniform);
if (!uniformBuffer->Initialize(uniformSize, Nz::BufferUsage_DeviceLocal | Nz::BufferUsage_Dynamic)) if (!uniformBuffer->Initialize(uniformSize, Nz::BufferUsage::DeviceLocal | Nz::BufferUsage::Dynamic))
{ {
NazaraError("Failed to create uniform buffer"); NazaraError("Failed to create uniform buffer");
return __LINE__; return __LINE__;
@ -144,14 +190,14 @@ int main()
Nz::RenderPipelineInfo pipelineInfo; Nz::RenderPipelineInfo pipelineInfo;
pipelineInfo.pipelineLayout = renderPipelineLayout; pipelineInfo.pipelineLayout = renderPipelineLayout;
pipelineInfo.faceCulling = true;
pipelineInfo.depthBuffer = true; pipelineInfo.depthBuffer = true;
pipelineInfo.shaderStages.emplace_back(fragmentShader); pipelineInfo.shaderModules.emplace_back(fragVertShader);
pipelineInfo.shaderStages.emplace_back(vertexShader);
auto& vertexBuffer = pipelineInfo.vertexBuffers.emplace_back(); auto& vertexBuffer = pipelineInfo.vertexBuffers.emplace_back();
vertexBuffer.binding = 0; vertexBuffer.binding = 0;
vertexBuffer.declaration = drfreakVB->GetVertexDeclaration(); vertexBuffer.declaration = meshVB->GetVertexDeclaration();
std::shared_ptr<Nz::RenderPipeline> pipeline = device->InstantiateRenderPipeline(pipelineInfo); std::shared_ptr<Nz::RenderPipeline> pipeline = device->InstantiateRenderPipeline(pipelineInfo);
@ -160,8 +206,8 @@ int main()
Nz::RenderWindowImpl* windowImpl = window.GetImpl(); Nz::RenderWindowImpl* windowImpl = window.GetImpl();
std::shared_ptr<Nz::CommandPool> commandPool = windowImpl->CreateCommandPool(Nz::QueueType::Graphics); std::shared_ptr<Nz::CommandPool> commandPool = windowImpl->CreateCommandPool(Nz::QueueType::Graphics);
Nz::RenderBuffer* renderBufferIB = static_cast<Nz::RenderBuffer*>(drfreakIB->GetBuffer()->GetImpl()); Nz::RenderBuffer* renderBufferIB = static_cast<Nz::RenderBuffer*>(meshIB->GetBuffer()->GetImpl());
Nz::RenderBuffer* renderBufferVB = static_cast<Nz::RenderBuffer*>(drfreakVB->GetBuffer()->GetImpl()); Nz::RenderBuffer* renderBufferVB = static_cast<Nz::RenderBuffer*>(meshVB->GetBuffer()->GetImpl());
if (!renderBufferIB->Synchronize(renderDevice)) if (!renderBufferIB->Synchronize(renderDevice))
{ {
@ -204,7 +250,7 @@ int main()
builder.SetScissor(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) }); builder.SetScissor(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) });
builder.SetViewport(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) }); builder.SetViewport(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) });
builder.DrawIndexed(drfreakIB->GetIndexCount()); builder.DrawIndexed(meshIB->GetIndexCount());
} }
builder.EndRenderPass(); builder.EndRenderPass();
} }
@ -235,17 +281,18 @@ int main()
{ {
switch (event.type) switch (event.type)
{ {
case Nz::WindowEventType_Quit: case Nz::WindowEventType::Quit:
window.Close(); window.Close();
break; break;
case Nz::WindowEventType_MouseMoved: // La souris a bougé case Nz::WindowEventType::MouseMoved: // La souris a bougé
{ {
// Gestion de la caméra free-fly (Rotation) // Gestion de la caméra free-fly (Rotation)
float sensitivity = 0.3f; // Sensibilité de la souris float sensitivity = 0.3f; // Sensibilité de la souris
// On modifie l'angle de la caméra grâce au déplacement relatif sur X de la souris // On modifie l'angle de la caméra grâce au déplacement relatif sur X de la souris
camAngles.yaw = Nz::NormalizeAngle(camAngles.yaw - event.mouseMove.deltaX*sensitivity); camAngles.yaw = camAngles.yaw - event.mouseMove.deltaX * sensitivity;
camAngles.yaw.Normalize();
// Idem, mais pour éviter les problèmes de calcul de la matrice de vue, on restreint les angles // Idem, mais pour éviter les problèmes de calcul de la matrice de vue, on restreint les angles
camAngles.pitch = Nz::Clamp(camAngles.pitch + event.mouseMove.deltaY*sensitivity, -89.f, 89.f); camAngles.pitch = Nz::Clamp(camAngles.pitch + event.mouseMove.deltaY*sensitivity, -89.f, 89.f);
@ -256,10 +303,10 @@ int main()
break; break;
} }
case Nz::WindowEventType_Resized: case Nz::WindowEventType::Resized:
{ {
Nz::Vector2ui windowSize = window.GetSize(); Nz::Vector2ui windowSize = window.GetSize();
ubo.projectionMatrix = Nz::Matrix4f::Perspective(70.f, float(windowSize.x) / windowSize.y, 0.1f, 1000.f); ubo.projectionMatrix = Nz::Matrix4f::Perspective(Nz::DegreeAnglef(70.f), float(windowSize.x) / windowSize.y, 0.1f, 1000.f);
uboUpdate = true; uboUpdate = true;
break; break;
} }

View File

@ -0,0 +1,5 @@
target("RenderTest")
set_group("Examples")
set_kind("binary")
add_deps("NazaraRenderer")
add_files("main.cpp")

View File

@ -0,0 +1,174 @@
#include <Nazara/Core.hpp>
#include <Nazara/OpenGLRenderer.hpp>
#include <Nazara/OpenGLRenderer/Wrapper.hpp>
#include <Nazara/Renderer.hpp>
#include <Nazara/Utility/FieldOffsets.hpp>
#include <iostream>
#include <numeric>
const char fragmentSource[] = R"(
#version 310 es
#if GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
layout(binding = 3, std140) uniform LightParameters
{
mat4 projectionMatrix;
mat4 invProjectionMatrix;
mat4 viewMatrix;
mat4 invViewMatrix;
mat4 viewProjMatrix;
mat4 invViewProjMatrix;
vec2 renderTargetSize;
vec2 invRenderTargetSize;
vec3 eyePosition;
};
void main()
{
}
)";
const char vertexSource[] = R"(
#version 310 es
void main()
{
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
}
)";
template <typename T, typename Compare>
std::vector<std::size_t> SortIndexes(const std::vector<T>& vec, Compare&& compare)
{
std::vector<std::size_t> p(vec.size());
std::iota(p.begin(), p.end(), 0);
std::sort(p.begin(), p.end(), [&](std::size_t i, std::size_t j) { return compare(vec[i], vec[j]); });
return p;
}
int main()
{
Nz::Renderer::Config rendererConfig;
rendererConfig.preferredAPI = Nz::RenderAPI::OpenGL;
Nz::Modules<Nz::Renderer> nazara(rendererConfig);
if (Nz::Renderer::Instance()->QueryAPI() != Nz::RenderAPI::OpenGL)
{
std::cout << "This program only works with OpenGL" << std::endl;
return EXIT_FAILURE;
}
std::shared_ptr<Nz::OpenGLDevice> device = std::static_pointer_cast<Nz::OpenGLDevice>(Nz::Renderer::Instance()->InstanciateRenderDevice(0));
std::string err;
// Fragment shader
Nz::GL::Shader fragmentShader;
if (!fragmentShader.Create(*device, GL_FRAGMENT_SHADER))
{
std::cerr << "Failed to create fragment shader" << std::endl;
return EXIT_FAILURE;
}
fragmentShader.SetSource(fragmentSource, sizeof(fragmentSource));
fragmentShader.Compile();
if (!fragmentShader.GetCompilationStatus(&err))
{
std::cerr << "Failed to compile fragment shader: " << err << std::endl;
return EXIT_FAILURE;
}
// Vertex shader
Nz::GL::Shader vertexShader;
if (!vertexShader.Create(*device, GL_VERTEX_SHADER))
{
std::cerr << "Failed to create vertex shader" << std::endl;
return EXIT_FAILURE;
}
vertexShader.SetSource(vertexSource, sizeof(vertexSource));
vertexShader.Compile();
if (!vertexShader.GetCompilationStatus(&err))
{
std::cerr << "Failed to compile vertex shader: " << err << std::endl;
return EXIT_FAILURE;
}
// Program
Nz::GL::Program program;
if (!program.Create(*device))
{
std::cerr << "Failed to create program" << std::endl;
return EXIT_FAILURE;
}
program.AttachShader(fragmentShader.GetObjectId());
program.AttachShader(vertexShader.GetObjectId());
program.Link();
if (!program.GetLinkStatus(&err))
{
std::cerr << "Failed to link program: " << err << std::endl;
return EXIT_FAILURE;
}
// Get infos
GLuint blockIndex = program.GetUniformBlockIndex("LightParameters");
if (blockIndex == GL_INVALID_INDEX)
{
std::cerr << "Failed to find uniform block in program" << std::endl;
return EXIT_FAILURE;
}
std::vector<GLint> uniformIndices = program.GetActiveUniformBlockUniformIndices(blockIndex);
std::vector<GLint> offsets = program.GetActiveUniforms(uniformIndices.size(), reinterpret_cast<GLuint*>(uniformIndices.data()), GL_UNIFORM_OFFSET);
auto p = SortIndexes(offsets, std::less<std::size_t>());
std::vector<std::size_t> computedOffsets;
Nz::FieldOffsets fieldOffsets(Nz::StructLayout::Std140);
computedOffsets.push_back(fieldOffsets.AddMatrix(Nz::StructFieldType::Float1, 4, 4, true));
computedOffsets.push_back(fieldOffsets.AddMatrix(Nz::StructFieldType::Float1, 4, 4, true));
computedOffsets.push_back(fieldOffsets.AddMatrix(Nz::StructFieldType::Float1, 4, 4, true));
computedOffsets.push_back(fieldOffsets.AddMatrix(Nz::StructFieldType::Float1, 4, 4, true));
computedOffsets.push_back(fieldOffsets.AddMatrix(Nz::StructFieldType::Float1, 4, 4, true));
computedOffsets.push_back(fieldOffsets.AddMatrix(Nz::StructFieldType::Float1, 4, 4, true));
computedOffsets.push_back(fieldOffsets.AddField(Nz::StructFieldType::Float2));
computedOffsets.push_back(fieldOffsets.AddField(Nz::StructFieldType::Float2));
computedOffsets.push_back(fieldOffsets.AddField(Nz::StructFieldType::Float3));
GLint dataSize;
program.GetActiveUniformBlock(blockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &dataSize);
if (fieldOffsets.GetAlignedSize() != dataSize)
std::cout << "size mismatch (computed " << fieldOffsets.GetAlignedSize() << ", reference has " << dataSize << ")" << std::endl;;
if (computedOffsets.size() != uniformIndices.size())
{
std::cout << "member count mismatch" << std::endl;
return EXIT_FAILURE;
}
for (std::size_t i = 0; i < uniformIndices.size(); ++i)
{
GLint realOffset = offsets[p[i]];
std::cout << program.GetActiveUniformName(uniformIndices[p[i]]) << ": " << realOffset;
if (realOffset != computedOffsets[i])
std::cout << " ERR";
std::cout << std::endl;
}
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,5 @@
target("Std140Debug")
set_group("Examples")
set_kind("binary")
add_deps("NazaraOpenGLRenderer")
add_files("main.cpp")

View File

@ -1,488 +0,0 @@
#if EARLY_FRAGMENT_TESTS && !ALPHA_TEST
layout(early_fragment_tests) in;
#endif
// HACK UNTIL PROPER FIX
#if GLSL_VERSION < 400
#undef SHADOW_MAPPING
#define SHADOW_MAPPING 0
#endif
// HACK
#define LIGHT_DIRECTIONAL 0
#define LIGHT_POINT 1
#define LIGHT_SPOT 2
/********************Entrant********************/
in vec4 vColor;
in vec4 vLightSpacePos[3];
in mat3 vLightToWorld;
in vec3 vNormal;
in vec2 vTexCoord;
in vec3 vViewDir;
in vec3 vWorldPos;
/********************Sortant********************/
out vec4 RenderTarget0;
out vec4 RenderTarget1;
out vec4 RenderTarget2;
/********************Uniformes********************/
struct Light
{
int type;
vec4 color;
vec2 factors;
vec4 parameters1;
vec4 parameters2;
vec2 parameters3;
bool shadowMapping;
};
// Lumières
uniform Light Lights[3];
uniform samplerCube PointLightShadowMap[3];
uniform sampler2D DirectionalSpotLightShadowMap[3];
// Matériau
uniform sampler2D MaterialAlphaMap;
uniform float MaterialAlphaThreshold;
uniform vec4 MaterialAmbient;
uniform vec4 MaterialDiffuse;
uniform sampler2D MaterialDiffuseMap;
uniform sampler2D MaterialEmissiveMap;
uniform sampler2D MaterialHeightMap;
uniform sampler2D MaterialNormalMap;
uniform float MaterialShininess;
uniform vec4 MaterialSpecular;
uniform sampler2D MaterialSpecularMap;
// Autres
uniform float ParallaxBias = -0.03;
uniform float ParallaxScale = 0.02;
uniform vec2 InvTargetSize;
uniform vec3 EyePosition;
uniform samplerCube ReflectionMap;
uniform vec4 SceneAmbient;
uniform mat4 WorldMatrix;
uniform sampler2D TextureOverlay;
/********************Fonctions********************/
#define kPI 3.1415926536
vec4 EncodeNormal(in vec3 normal)
{
//return vec4(normal*0.5 + 0.5, 0.0);
return vec4(vec2(atan(normal.y, normal.x)/kPI, normal.z), 0.0, 0.0);
}
float VectorToDepthValue(vec3 vec, float zNear, float zFar)
{
vec3 absVec = abs(vec);
float localZ = max(absVec.x, max(absVec.y, absVec.z));
float normZ = ((zFar + zNear) * localZ - (2.0*zFar*zNear)) / ((zFar - zNear)*localZ);
return (normZ + 1.0) * 0.5;
}
#if SHADOW_MAPPING
float CalculateDirectionalShadowFactor(int lightIndex)
{
vec4 lightSpacePos = vLightSpacePos[lightIndex];
return (texture(DirectionalSpotLightShadowMap[lightIndex], lightSpacePos.xy).x >= (lightSpacePos.z - 0.0005)) ? 1.0 : 0.0;
}
float CalculatePointShadowFactor(int lightIndex, vec3 lightToWorld, float zNear, float zFar)
{
return (texture(PointLightShadowMap[lightIndex], vec3(lightToWorld.x, -lightToWorld.y, -lightToWorld.z)).x >= VectorToDepthValue(lightToWorld, zNear, zFar)) ? 1.0 : 0.0;
}
float CalculateSpotShadowFactor(int lightIndex, float lambert)
{
vec4 lightSpacePos = vLightSpacePos[lightIndex];
#if 0
float visibility = 1.0;
float bias = 0.005 * tan(acos(NoL));
bias = clamp(bias, MinAllowedBias, MaxAllowedBias);
float x,y;
for (y = -1.0; y <= 1.0; y+= 1.0)
for (x = -1.0; x <= 1.0; x+= 1.0)
visibility += (textureProj(DirectionalSpotLightShadowMap[lightIndex], lightSpacePos.xyw + vec3(x/1024.0 * lightSpacePos.w, y/1024.0 * lightSpacePos.w, 0.0)).x >= (lightSpacePos.z - 0.0005)/lightSpacePos.w) ? 1.0 : 0.0;
visibility /= 9.0;
return visibility;
#else
float bias = 0.005 * tan(acos(lambert));
return (textureProj(DirectionalSpotLightShadowMap[lightIndex], lightSpacePos.xyw).x >= (lightSpacePos.z - bias)/lightSpacePos.w) ? 1.0 : 0.0;
#endif
}
#endif
void main()
{
vec4 diffuseColor = MaterialDiffuse * vColor;
#if AUTO_TEXCOORDS
vec2 texCoord = gl_FragCoord.xy * InvTargetSize;
#else
vec2 texCoord = vTexCoord;
#endif
#if PARALLAX_MAPPING
float height = texture(MaterialHeightMap, texCoord).r;
float v = height*ParallaxScale + ParallaxBias;
vec3 viewDir = normalize(vViewDir);
texCoord += v * viewDir.xy;
#endif
#if DIFFUSE_MAPPING
diffuseColor *= texture(MaterialDiffuseMap, texCoord);
#endif
#if FLAG_TEXTUREOVERLAY
diffuseColor *= texture(TextureOverlay, texCoord);
#endif
#if FLAG_DEFERRED
#if ALPHA_TEST
// Inutile de faire de l'alpha-mapping sans alpha-test en Deferred (l'alpha n'est pas sauvegardé dans le G-Buffer)
#if ALPHA_MAPPING
diffuseColor.a *= texture(MaterialAlphaMap, texCoord).r;
#endif
if (diffuseColor.a < MaterialAlphaThreshold)
discard;
#endif // ALPHA_TEST
#if NORMAL_MAPPING
vec3 normal = normalize(vLightToWorld * (2.0 * vec3(texture(MaterialNormalMap, texCoord)) - 1.0));
#else
vec3 normal = normalize(vNormal);
#endif // NORMAL_MAPPING
vec3 specularColor = MaterialSpecular.rgb;
#if SPECULAR_MAPPING
specularColor *= texture(MaterialSpecularMap, texCoord).rgb;
#endif
/*
Texture0: Diffuse Color + Specular
Texture1: Normal + Specular
Texture2: Encoded depth + Shininess
*/
RenderTarget0 = vec4(diffuseColor.rgb, dot(specularColor, vec3(0.3, 0.59, 0.11)));
RenderTarget1 = vec4(EncodeNormal(normal));
RenderTarget2 = vec4(0.0, 0.0, 0.0, (MaterialShininess == 0.0) ? 0.0 : max(log2(MaterialShininess), 0.1)/10.5); // http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf
#else // FLAG_DEFERRED
#if ALPHA_MAPPING
diffuseColor.a *= texture(MaterialAlphaMap, texCoord).r;
#endif
#if ALPHA_TEST
if (diffuseColor.a < MaterialAlphaThreshold)
discard;
#endif
vec3 lightAmbient = vec3(0.0);
vec3 lightDiffuse = vec3(0.0);
vec3 lightSpecular = vec3(0.0);
#if NORMAL_MAPPING
vec3 normal = normalize(vLightToWorld * (2.0 * vec3(texture(MaterialNormalMap, texCoord)) - 1.0));
#else
vec3 normal = normalize(vNormal);
#endif
if (MaterialShininess > 0.0)
{
vec3 eyeVec = normalize(EyePosition - vWorldPos);
for (int i = 0; i < 3; ++i)
{
vec4 lightColor = Lights[i].color;
float lightAmbientFactor = Lights[i].factors.x;
float lightDiffuseFactor = Lights[i].factors.y;
switch (Lights[i].type)
{
case LIGHT_DIRECTIONAL:
{
vec3 lightDir = -Lights[i].parameters1.xyz;
// Ambient
lightAmbient += lightColor.rgb * lightAmbientFactor * (MaterialAmbient.rgb + SceneAmbient.rgb);
float att = 1.0;
float lambert = max(dot(normal, lightDir), 0.0);
#if SHADOW_MAPPING
if (Lights[i].shadowMapping)
{
float shadowFactor = CalculateDirectionalShadowFactor(i);
if (shadowFactor == 0.0)
break;
att *= shadowFactor;
}
#endif
// Diffuse
lightDiffuse += att * lambert * lightColor.rgb * lightDiffuseFactor;
// Specular
vec3 reflection = reflect(-lightDir, normal);
float specularFactor = max(dot(reflection, eyeVec), 0.0);
specularFactor = pow(specularFactor, MaterialShininess);
lightSpecular += att * specularFactor * lightColor.rgb;
break;
}
case LIGHT_POINT:
{
vec3 lightPos = Lights[i].parameters1.xyz;
float lightAttenuation = Lights[i].parameters1.w;
float lightInvRadius = Lights[i].parameters2.w;
vec3 worldToLight = lightPos - vWorldPos;
float lightDirLength = length(worldToLight);
vec3 lightDir = worldToLight / lightDirLength; // Normalisation
float att = max(lightAttenuation - lightInvRadius * lightDirLength, 0.0);
// Ambient
lightAmbient += att * lightColor.rgb * lightAmbientFactor * (MaterialAmbient.rgb + SceneAmbient.rgb);
#if SHADOW_MAPPING
if (Lights[i].shadowMapping)
{
float shadowFactor = CalculatePointShadowFactor(i, vWorldPos - lightPos, 0.1, 50.0);
if (shadowFactor == 0.0)
break;
att *= shadowFactor;
}
#endif
// Diffuse
float lambert = max(dot(normal, lightDir), 0.0);
lightDiffuse += att * lambert * lightColor.rgb * lightDiffuseFactor;
// Specular
vec3 reflection = reflect(-lightDir, normal);
float specularFactor = max(dot(reflection, eyeVec), 0.0);
specularFactor = pow(specularFactor, MaterialShininess);
lightSpecular += att * specularFactor * lightColor.rgb;
break;
}
case LIGHT_SPOT:
{
vec3 lightPos = Lights[i].parameters1.xyz;
vec3 lightDir = Lights[i].parameters2.xyz;
float lightAttenuation = Lights[i].parameters1.w;
float lightInvRadius = Lights[i].parameters2.w;
float lightInnerAngle = Lights[i].parameters3.x;
float lightOuterAngle = Lights[i].parameters3.y;
vec3 worldToLight = lightPos - vWorldPos;
float lightDistance = length(worldToLight);
worldToLight /= lightDistance; // Normalisation
float att = max(lightAttenuation - lightInvRadius * lightDistance, 0.0);
// Ambient
lightAmbient += att * lightColor.rgb * lightAmbientFactor * (MaterialAmbient.rgb + SceneAmbient.rgb);
float lambert = max(dot(normal, worldToLight), 0.0);
#if SHADOW_MAPPING
if (Lights[i].shadowMapping)
{
float shadowFactor = CalculateSpotShadowFactor(i, lambert);
if (shadowFactor == 0.0)
break;
att *= shadowFactor;
}
#endif
// Modification de l'atténuation pour gérer le spot
float curAngle = dot(lightDir, -worldToLight);
float innerMinusOuterAngle = lightInnerAngle - lightOuterAngle;
att *= max((curAngle - lightOuterAngle) / innerMinusOuterAngle, 0.0);
// Diffuse
lightDiffuse += att * lambert * lightColor.rgb * lightDiffuseFactor;
// Specular
vec3 reflection = reflect(-worldToLight, normal);
float specularFactor = max(dot(reflection, eyeVec), 0.0);
specularFactor = pow(specularFactor, MaterialShininess);
lightSpecular += att * specularFactor * lightColor.rgb;
break;
}
default:
break;
}
}
}
else
{
for (int i = 0; i < 3; ++i)
{
vec4 lightColor = Lights[i].color;
float lightAmbientFactor = Lights[i].factors.x;
float lightDiffuseFactor = Lights[i].factors.y;
switch (Lights[i].type)
{
case LIGHT_DIRECTIONAL:
{
vec3 lightDir = -Lights[i].parameters1.xyz;
// Ambient
lightAmbient += lightColor.rgb * lightAmbientFactor * (MaterialAmbient.rgb + SceneAmbient.rgb);
float att = 1.0;
#if SHADOW_MAPPING
if (Lights[i].shadowMapping)
{
float shadowFactor = CalculateDirectionalShadowFactor(i);
if (shadowFactor == 0.0)
break;
att *= shadowFactor;
}
#endif
// Diffuse
float lambert = max(dot(normal, lightDir), 0.0);
lightDiffuse += att * lambert * lightColor.rgb * lightDiffuseFactor;
break;
}
case LIGHT_POINT:
{
vec3 lightPos = Lights[i].parameters1.xyz;
float lightAttenuation = Lights[i].parameters1.w;
float lightInvRadius = Lights[i].parameters2.w;
vec3 worldToLight = lightPos - vWorldPos;
float lightDirLength = length(worldToLight);
vec3 lightDir = worldToLight / lightDirLength; // Normalisation
float att = max(lightAttenuation - lightInvRadius * lightDirLength, 0.0);
// Ambient
lightAmbient += att * lightColor.rgb * lightAmbientFactor * (MaterialAmbient.rgb + SceneAmbient.rgb);
#if SHADOW_MAPPING
if (Lights[i].shadowMapping)
{
float shadowFactor = CalculatePointShadowFactor(i, vWorldPos - lightPos, 0.1, 50.0);
if (shadowFactor == 0.0)
break;
att *= shadowFactor;
}
#endif
// Diffuse
float lambert = max(dot(normal, lightDir), 0.0);
lightDiffuse += att * lambert * lightColor.rgb * lightDiffuseFactor;
break;
}
case LIGHT_SPOT:
{
vec3 lightPos = Lights[i].parameters1.xyz;
vec3 lightDir = Lights[i].parameters2.xyz;
float lightAttenuation = Lights[i].parameters1.w;
float lightInvRadius = Lights[i].parameters2.w;
float lightInnerAngle = Lights[i].parameters3.x;
float lightOuterAngle = Lights[i].parameters3.y;
vec3 worldToLight = lightPos - vWorldPos;
float lightDistance = length(worldToLight);
worldToLight /= lightDistance; // Normalisation
float att = max(lightAttenuation - lightInvRadius * lightDistance, 0.0);
// Ambient
lightAmbient += att * lightColor.rgb * lightAmbientFactor * (MaterialAmbient.rgb + SceneAmbient.rgb);
float lambert = max(dot(normal, worldToLight), 0.0);
#if SHADOW_MAPPING
if (Lights[i].shadowMapping)
{
float shadowFactor = CalculateSpotShadowFactor(i, lambert);
if (shadowFactor == 0.0)
break;
att *= shadowFactor;
}
#endif
// Modification de l'atténuation pour gérer le spot
float curAngle = dot(lightDir, -worldToLight);
float innerMinusOuterAngle = lightInnerAngle - lightOuterAngle;
att *= max((curAngle - lightOuterAngle) / innerMinusOuterAngle, 0.0);
// Diffuse
lightDiffuse += att * lambert * lightColor.rgb * lightDiffuseFactor;
}
default:
break;
}
}
}
lightSpecular *= MaterialSpecular.rgb;
#if SPECULAR_MAPPING
lightSpecular *= texture(MaterialSpecularMap, texCoord).rgb; // Utiliser l'alpha de MaterialSpecular n'aurait aucun sens
#endif
vec3 lightColor = (lightAmbient + lightDiffuse + lightSpecular);
#if REFLECTION_MAPPING
vec3 eyeVec = normalize(vWorldPos - EyePosition);
vec3 reflected = normalize(reflect(eyeVec, normal));
//reflected = vec3(inverse(WorldMatrix) * vec4(reflected, 0.0));
lightColor *= texture(ReflectionMap, reflected).rgb;
#endif
vec4 fragmentColor = vec4(lightColor, 1.0) * diffuseColor;
#if EMISSIVE_MAPPING
float lightIntensity = dot(lightColor, vec3(0.3, 0.59, 0.11));
vec3 emissionColor = MaterialDiffuse.rgb * texture(MaterialEmissiveMap, texCoord).rgb;
RenderTarget0 = vec4(mix(fragmentColor.rgb, emissionColor, clamp(1.0 - 3.0*lightIntensity, 0.0, 1.0)), fragmentColor.a);
#else
RenderTarget0 = fragmentColor;
#endif // EMISSIVE_MAPPING
#endif // FLAG_DEFERRED
}

View File

@ -1,148 +0,0 @@
/********************Entrant********************/
#if FLAG_BILLBOARD
in vec3 InstanceData0; // center
in vec4 InstanceData1; // size | sin cos
in vec4 InstanceData2; // color
#else
in mat4 InstanceData0;
#endif
in vec4 VertexColor;
in vec3 VertexPosition;
in vec3 VertexNormal;
in vec3 VertexTangent;
in vec2 VertexTexCoord;
in vec4 VertexUserdata0;
/********************Sortant********************/
out vec4 vColor;
out vec4 vLightSpacePos[3];
out mat3 vLightToWorld;
out vec3 vNormal;
out vec2 vTexCoord;
out vec3 vViewDir;
out vec3 vWorldPos;
/********************Uniformes********************/
uniform vec3 EyePosition;
uniform mat4 InvViewMatrix;
uniform mat4 LightViewProjMatrix[3];
uniform float VertexDepth;
uniform mat4 ViewMatrix;
uniform mat4 ViewProjMatrix;
uniform mat4 WorldMatrix;
uniform mat4 WorldViewProjMatrix;
/********************Fonctions********************/
void main()
{
#if FLAG_VERTEXCOLOR
vec4 color = VertexColor;
#else
vec4 color = vec4(1.0);
#endif
vec2 texCoords;
#if FLAG_BILLBOARD
#if FLAG_INSTANCING
vec3 billboardCenter = InstanceData0;
vec2 billboardSize = InstanceData1.xy;
vec2 billboardSinCos = InstanceData1.zw;
vec4 billboardColor = InstanceData2;
vec2 rotatedPosition;
rotatedPosition.x = VertexPosition.x*billboardSinCos.y - VertexPosition.y*billboardSinCos.x;
rotatedPosition.y = VertexPosition.y*billboardSinCos.y + VertexPosition.x*billboardSinCos.x;
rotatedPosition *= billboardSize;
vec3 cameraRight = vec3(ViewMatrix[0][0], ViewMatrix[1][0], ViewMatrix[2][0]);
vec3 cameraUp = vec3(ViewMatrix[0][1], ViewMatrix[1][1], ViewMatrix[2][1]);
vec3 vertexPos = billboardCenter + cameraRight*rotatedPosition.x + cameraUp*rotatedPosition.y;
gl_Position = ViewProjMatrix * vec4(vertexPos, 1.0);
color = billboardColor;
texCoords = VertexPosition.xy + 0.5;
#else
vec2 billboardCorner = VertexTexCoord - 0.5;
vec2 billboardSize = VertexUserdata0.xy;
vec2 billboardSinCos = VertexUserdata0.zw;
vec2 rotatedPosition;
rotatedPosition.x = billboardCorner.x*billboardSinCos.y - billboardCorner.y*billboardSinCos.x;
rotatedPosition.y = billboardCorner.y*billboardSinCos.y + billboardCorner.x*billboardSinCos.x;
rotatedPosition *= billboardSize;
vec3 cameraRight = vec3(ViewMatrix[0][0], ViewMatrix[1][0], ViewMatrix[2][0]);
vec3 cameraUp = vec3(ViewMatrix[0][1], ViewMatrix[1][1], ViewMatrix[2][1]);
vec3 vertexPos = VertexPosition + cameraRight*rotatedPosition.x + cameraUp*rotatedPosition.y;
gl_Position = ViewProjMatrix * vec4(vertexPos, 1.0);
texCoords = VertexTexCoord;
#endif
texCoords.y = 1.0 - texCoords.y;
#else
#if FLAG_INSTANCING
#if TRANSFORM
gl_Position = ViewProjMatrix * InstanceData0 * vec4(VertexPosition, 1.0);
#else
#if UNIFORM_VERTEX_DEPTH
gl_Position = InstanceData0 * vec4(VertexPosition.xy, VertexDepth, 1.0);
#else
gl_Position = InstanceData0 * vec4(VertexPosition, 1.0);
#endif
#endif
#else
#if TRANSFORM
gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0);
#else
#if UNIFORM_VERTEX_DEPTH
gl_Position = vec4(VertexPosition.xy, VertexDepth, 1.0);
#else
gl_Position = vec4(VertexPosition, 1.0);
#endif
#endif
#endif
texCoords = VertexTexCoord;
#endif
vColor = color;
#if FLAG_INSTANCING
mat3 rotationMatrix = mat3(InstanceData0);
#else
mat3 rotationMatrix = mat3(WorldMatrix);
#endif
#if COMPUTE_TBNMATRIX
vec3 binormal = cross(VertexNormal, VertexTangent);
vLightToWorld[0] = normalize(rotationMatrix * VertexTangent);
vLightToWorld[1] = normalize(rotationMatrix * binormal);
vLightToWorld[2] = normalize(rotationMatrix * VertexNormal);
#else
vNormal = normalize(rotationMatrix * VertexNormal);
#endif
#if SHADOW_MAPPING
for (int i = 0; i < 3; ++i)
vLightSpacePos[i] = LightViewProjMatrix[i] * WorldMatrix * vec4(VertexPosition, 1.0);
#endif
#if TEXTURE_MAPPING
vTexCoord = VertexTexCoord;
#endif
#if PARALLAX_MAPPING
vViewDir = EyePosition - VertexPosition;
vViewDir *= vLightToWorld;
#endif
#if !FLAG_DEFERRED
#if FLAG_INSTANCING
vWorldPos = vec3(InstanceData0 * vec4(VertexPosition, 1.0));
#else
vWorldPos = vec3(WorldMatrix * vec4(VertexPosition, 1.0));
#endif
#endif
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -8,9 +8,11 @@
#define NAZARA_ALGORITHM_AUDIO_HPP #define NAZARA_ALGORITHM_AUDIO_HPP
#include <Nazara/Prerequisites.hpp> #include <Nazara/Prerequisites.hpp>
#include <Nazara/Audio/Enums.hpp>
namespace Nz namespace Nz
{ {
inline UInt32 GetChannelCount(AudioFormat format);
template<typename T> void MixToMono(T* input, T* output, UInt32 channelCount, UInt64 frameCount); template<typename T> void MixToMono(T* input, T* output, UInt32 channelCount, UInt64 frameCount);
} }

View File

@ -2,11 +2,52 @@
// This file is part of the "Nazara Engine - Audio module" // This file is part of the "Nazara Engine - Audio module"
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Audio/Algorithm.hpp>
#include <Nazara/Core/Error.hpp> #include <Nazara/Core/Error.hpp>
#include <Nazara/Audio/Debug.hpp> #include <Nazara/Audio/Debug.hpp>
namespace Nz namespace Nz
{ {
/*!
* \ingroup audio
* \brief Get the number of channels occupied by an audio format
* \returns The number of channels occupied by an audio format (mono returns 1, stero returns 2, etc.)
*
* \param format A valid audio format
*
* \remark The format must be valid (using AudioFormat::Unknown will trigger an error)
*/
UInt32 GetChannelCount(AudioFormat format)
{
NazaraAssert(format != AudioFormat::Unknown, "invalid audio format");
switch (format)
{
case AudioFormat::Unknown: //< Just to make the compiler stop complaining
break;
case AudioFormat::I16_Mono:
return 1;
case AudioFormat::I16_Stereo:
return 2;
case AudioFormat::I16_Quad:
return 4;
case AudioFormat::I16_5_1:
return 6;
case AudioFormat::I16_6_1:
return 7;
case AudioFormat::I16_7_1:
return 8;
}
return 0;
}
/*! /*!
* \ingroup audio * \ingroup audio
* \brief Mixes channels in mono * \brief Mixes channels in mono

View File

@ -10,6 +10,8 @@
#include <Nazara/Prerequisites.hpp> #include <Nazara/Prerequisites.hpp>
#include <Nazara/Audio/Config.hpp> #include <Nazara/Audio/Config.hpp>
#include <Nazara/Audio/Enums.hpp> #include <Nazara/Audio/Enums.hpp>
#include <Nazara/Audio/SoundBuffer.hpp>
#include <Nazara/Audio/SoundStream.hpp>
#include <Nazara/Core/Core.hpp> #include <Nazara/Core/Core.hpp>
#include <Nazara/Math/Quaternion.hpp> #include <Nazara/Math/Quaternion.hpp>
#include <Nazara/Math/Vector3.hpp> #include <Nazara/Math/Vector3.hpp>
@ -26,18 +28,24 @@ namespace Nz
struct Config {}; struct Config {};
Audio(Config /*config*/); Audio(Config /*config*/);
Audio(const Audio&) = delete;
Audio(Audio&&) = delete;
~Audio(); ~Audio();
AudioFormat GetAudioFormat(unsigned int channelCount); float GetDopplerFactor() const;
float GetDopplerFactor(); float GetGlobalVolume() const;
float GetGlobalVolume(); Vector3f GetListenerDirection() const;
Vector3f GetListenerDirection(); Vector3f GetListenerPosition() const;
Vector3f GetListenerPosition(); Quaternionf GetListenerRotation() const;
Quaternionf GetListenerRotation(); Vector3f GetListenerVelocity() const;
Vector3f GetListenerVelocity(); SoundBufferLoader& GetSoundBufferLoader();
float GetSpeedOfSound(); const SoundBufferLoader& GetSoundBufferLoader() const;
SoundStreamLoader& GetSoundStreamLoader();
const SoundStreamLoader& GetSoundStreamLoader() const;
float GetSpeedOfSound() const;
bool IsFormatSupported(AudioFormat format) const;
bool IsFormatSupported(AudioFormat format);
void SetDopplerFactor(float dopplerFactor); void SetDopplerFactor(float dopplerFactor);
void SetGlobalVolume(float volume); void SetGlobalVolume(float volume);
void SetListenerDirection(const Vector3f& direction); void SetListenerDirection(const Vector3f& direction);
@ -49,7 +57,13 @@ namespace Nz
void SetListenerVelocity(float velX, float velY, float velZ); void SetListenerVelocity(float velX, float velY, float velZ);
void SetSpeedOfSound(float speed); void SetSpeedOfSound(float speed);
Audio& operator=(const Audio&) = delete;
Audio& operator=(Audio&&) = delete;
private: private:
SoundBufferLoader m_soundBufferLoader;
SoundStreamLoader m_soundStreamLoader;
static Audio* s_instance; static Audio* s_instance;
}; };
} }

View File

@ -9,27 +9,32 @@
namespace Nz namespace Nz
{ {
enum AudioFormat enum class AudioFormat
{ {
AudioFormat_Unknown = -1, Unknown = -1,
// The integer value is the number of channels used by the format I16_Mono,
AudioFormat_Mono = 1, I16_Stereo,
AudioFormat_Stereo = 2, I16_Quad,
AudioFormat_Quad = 4, I16_5_1,
AudioFormat_5_1 = 6, I16_6_1,
AudioFormat_6_1 = 7, I16_7_1,
AudioFormat_7_1 = 8,
AudioFormat_Max = AudioFormat_7_1 Max = I16_7_1
}; };
enum SoundStatus constexpr std::size_t AudioFormatCount = static_cast<std::size_t>(AudioFormat::Max) + 1;
enum class SoundStatus
{ {
SoundStatus_Playing, Playing,
SoundStatus_Paused, Paused,
SoundStatus_Stopped Stopped,
Max = Stopped
}; };
constexpr std::size_t SoundStatusCount = static_cast<std::size_t>(SoundStatus::Max) + 1;
} }
#endif // NAZARA_ENUMS_AUDIO_HPP #endif // NAZARA_ENUMS_AUDIO_HPP

Some files were not shown because too many files have changed in this diff Show More