Switched to x64 and added basic 3D sound

This commit is contained in:
Grayson Riffe (Laptop) 2021-10-06 07:46:42 -05:00
parent f422d1d138
commit d2604e9edc
30 changed files with 210 additions and 291 deletions

View File

@ -1,14 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64"> <ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
<Platform>x64</Platform> <Platform>x64</Platform>
@ -26,19 +18,6 @@
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
@ -57,12 +36,6 @@
</ImportGroup> </ImportGroup>
<ImportGroup Label="Shared"> <ImportGroup Label="Shared">
</ImportGroup> </ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
@ -70,16 +43,6 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(ProjectDir)bin\$(Platform)$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)int\$(Platform)$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(ProjectDir)bin\$(Platform)$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)int\$(Platform)$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<OutDir>$(ProjectDir)bin\$(Platform)$(Configuration)\</OutDir> <OutDir>$(ProjectDir)bin\$(Platform)$(Configuration)\</OutDir>
@ -90,51 +53,6 @@
<OutDir>$(ProjectDir)bin\$(Platform)$(Configuration)\</OutDir> <OutDir>$(ProjectDir)bin\$(Platform)$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)int\$(Platform)$(Configuration)\</IntDir> <IntDir>$(ProjectDir)int\$(Platform)$(Configuration)\</IntDir>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(ProjectDir)src\include\;$(SolutionDir)NothinFancy\src\include\</AdditionalIncludeDirectories>
<ObjectFileName>$(IntDir)obj\</ObjectFileName>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
<IgnoreSpecificDefaultLibraries>libcmt.lib</IgnoreSpecificDefaultLibraries>
<AdditionalOptions>/ignore:4099 %(AdditionalOptions)</AdditionalOptions>
</Link>
<PostBuildEvent>
<Command>cd "$(SolutionDir)NFPackCreator\AssetBuild" &amp;&amp; "$(SolutionDir)NFPackCreator\bin\Win32$(Configuration)\NFPackCreator.exe" &amp;&amp; del "$(OutDir)assets\" /Q /S &amp;&amp; move "$(SolutionDir)NFPackCreator\AssetBuild\*.nfpack" "$(OutDir)assets\"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(ProjectDir)src\include\;$(SolutionDir)NothinFancy\src\include\</AdditionalIncludeDirectories>
<ObjectFileName>$(IntDir)obj\</ObjectFileName>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
<IgnoreSpecificDefaultLibraries>libcmt.lib</IgnoreSpecificDefaultLibraries>
<AdditionalOptions>/ignore:4099 %(AdditionalOptions)</AdditionalOptions>
<Profile>true</Profile>
</Link>
<PostBuildEvent>
<Command>cd "$(SolutionDir)NFPackCreator\AssetBuild" &amp;&amp; "$(SolutionDir)NFPackCreator\bin\Win32$(Configuration)\NFPackCreator.exe" &amp;&amp; del "$(OutDir)assets\" /Q /S &amp;&amp; move "$(SolutionDir)NFPackCreator\AssetBuild\*.nfpack" "$(OutDir)assets\"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
@ -152,7 +70,12 @@
<AdditionalOptions>/ignore:4099 %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions>/ignore:4099 %(AdditionalOptions)</AdditionalOptions>
</Link> </Link>
<PostBuildEvent> <PostBuildEvent>
<Command>cd "$(SolutionDir)NFPackCreator\AssetBuild" &amp;&amp; "$(SolutionDir)NFPackCreator\bin\Win32$(Configuration)\NFPackCreator.exe" &amp;&amp; del "$(OutDir)assets\" /Q /S &amp;&amp; move "$(SolutionDir)NFPackCreator\AssetBuild\*.nfpack" "$(OutDir)assets\"</Command> <Command>cd "$(SolutionDir)NFPackCreator\AssetBuild"
"$(SolutionDir)NFPackCreator\bin\x64$(Configuration)\NFPackCreator.exe"
if exist "$(OutDir)assets" (rmdir "$(OutDir)assets" /S /Q &amp;&amp; goto end) else goto end
:end
mkdir "$(OutDir)assets"
move "*.nfpack" "$(OutDir)assets\"</Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -177,7 +100,12 @@
<Profile>true</Profile> <Profile>true</Profile>
</Link> </Link>
<PostBuildEvent> <PostBuildEvent>
<Command>cd "$(SolutionDir)NFPackCreator\AssetBuild" &amp;&amp; "$(SolutionDir)NFPackCreator\bin\Win32$(Configuration)\NFPackCreator.exe" &amp;&amp; del "$(OutDir)assets\" /Q /S &amp;&amp; move "$(SolutionDir)NFPackCreator\AssetBuild\*.nfpack" "$(OutDir)assets\"</Command> <Command>cd "$(SolutionDir)NFPackCreator\AssetBuild"
"$(SolutionDir)NFPackCreator\bin\x64$(Configuration)\NFPackCreator.exe"
if exist "$(OutDir)assets" (rmdir "$(OutDir)assets" /S /Q &amp;&amp; goto end) else goto end
:end
mkdir "$(OutDir)assets"
move "*.nfpack" "$(OutDir)assets\"</Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
@ -207,5 +135,6 @@
<_delete Include="$(OutDir)**\*" /> <_delete Include="$(OutDir)**\*" />
</ItemGroup> </ItemGroup>
<Delete Files="@(_delete)" /> <Delete Files="@(_delete)" />
<RemoveDir Directories="$(OUTDIR)" />
</Target> </Target>
</Project> </Project>

View File

@ -3,14 +3,6 @@
<PropertyGroup> <PropertyGroup>
<ShowAllFiles>true</ShowAllFiles> <ShowAllFiles>true</ShowAllFiles>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>

View File

@ -20,6 +20,7 @@ void MainState::onEnter() {
cm.create(nf::BaseAssets::cubemap); cm.create(nf::BaseAssets::cubemap);
sound.create(ap["sound.wav"]); sound.create(ap["sound.wav"]);
sound.setEntity(test);
for (int x = 0; x < 10; x++) { for (int x = 0; x < 10; x++) {
for (int y = 0; y < 10; y++) { for (int y = 0; y < 10; y++) {
@ -66,7 +67,7 @@ void MainState::update(double deltaTime) {
if (button.isClicked()) if (button.isClicked())
app->changeState("Main State"); app->changeState("Main State");
if (button2.isClicked()) if (app->isKeyPressed(NFI_SPACE))
sound.play(); sound.play();
if (app->isKeyPressed(NFI_ESCAPE)) if (app->isKeyPressed(NFI_ESCAPE))

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
<Platform>Win32</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32"> <ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<Platform>Win32</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
@ -18,13 +18,13 @@
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset> <PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset> <PlatformToolset>v142</PlatformToolset>
@ -36,24 +36,24 @@
</ImportGroup> </ImportGroup>
<ImportGroup Label="Shared"> <ImportGroup Label="Shared">
</ImportGroup> </ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<OutDir>$(ProjectDir)bin\$(Platform)$(Configuration)\</OutDir> <OutDir>$(ProjectDir)bin\$(Platform)$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)int\$(Platform)$(Configuration)\</IntDir> <IntDir>$(ProjectDir)int\$(Platform)$(Configuration)\</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(ProjectDir)bin\$(Platform)$(Configuration)\</OutDir> <OutDir>$(ProjectDir)bin\$(Platform)$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)int\$(Platform)$(Configuration)\</IntDir> <IntDir>$(ProjectDir)int\$(Platform)$(Configuration)\</IntDir>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
@ -66,7 +66,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>

View File

@ -3,11 +3,11 @@
<PropertyGroup> <PropertyGroup>
<ShowAllFiles>true</ShowAllFiles> <ShowAllFiles>true</ShowAllFiles>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments>-h</LocalDebuggerCommandArguments> <LocalDebuggerCommandArguments>-h</LocalDebuggerCommandArguments>

View File

@ -66,7 +66,7 @@ void writeFile(const std::string& filename, const std::string& in, bool encrypte
void getNeededImages(std::string mtl, std::set<std::string>& set) { void getNeededImages(std::string mtl, std::set<std::string>& set) {
while (mtl.size()) { while (mtl.size()) {
unsigned int pos = mtl.find("map_"); size_t pos = mtl.find("map_");
if (pos == std::string::npos) if (pos == std::string::npos)
break; break;
if (pos == mtl.find("map_Kd") || pos == mtl.find("map_Ks")) if (pos == mtl.find("map_Kd") || pos == mtl.find("map_Ks"))
@ -76,7 +76,7 @@ void getNeededImages(std::string mtl, std::set<std::string>& set) {
std::stringstream ss(mtl); std::stringstream ss(mtl);
std::string temp; std::string temp;
ss >> temp; ss >> temp;
unsigned int pos2 = temp.find_last_of("/\\"); size_t pos2 = temp.find_last_of("/\\");
if (pos2 != std::string::npos) if (pos2 != std::string::npos)
temp = temp.substr(pos2 + 1); temp = temp.substr(pos2 + 1);
set.insert(temp); set.insert(temp);

View File

@ -1,14 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64"> <ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
<Platform>x64</Platform> <Platform>x64</Platform>
@ -26,19 +18,6 @@
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
@ -57,12 +36,6 @@
</ImportGroup> </ImportGroup>
<ImportGroup Label="Shared"> <ImportGroup Label="Shared">
</ImportGroup> </ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
@ -70,16 +43,6 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(ProjectDir)bin\$(Platform)$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)int\$(Platform)$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(ProjectDir)bin\$(Platform)$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)int\$(Platform)$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<OutDir>$(ProjectDir)bin\$(Platform)$(Configuration)\</OutDir> <OutDir>$(ProjectDir)bin\$(Platform)$(Configuration)\</OutDir>
@ -90,58 +53,6 @@
<OutDir>$(ProjectDir)bin\$(Platform)$(Configuration)\</OutDir> <OutDir>$(ProjectDir)bin\$(Platform)$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)int\$(Platform)$(Configuration)\</IntDir> <IntDir>$(ProjectDir)int\$(Platform)$(Configuration)\</IntDir>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NFENGINE; GLEW_STATIC;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(ProjectDir)src\include\;$(ProjectDir)dep\include\</AdditionalIncludeDirectories>
<ObjectFileName>$(IntDir)obj\</ObjectFileName>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Lib>
<AdditionalDependencies>glew32s.lib;opengl32.lib;freetype.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Lib>
<Lib>
<AdditionalLibraryDirectories>$(ProjectDir)dep\lib\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Lib>
<ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
<PostBuildEvent />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NFENGINE; GLEW_STATIC;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(ProjectDir)src\include\;$(ProjectDir)dep\include\</AdditionalIncludeDirectories>
<ObjectFileName>$(IntDir)obj\</ObjectFileName>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Lib>
<AdditionalDependencies>glew32s.lib;opengl32.lib;freetype.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Lib>
<Lib>
<AdditionalLibraryDirectories>$(ProjectDir)dep\lib\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Lib>
<ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
<PostBuildEvent />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
@ -156,10 +67,11 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
</Link> </Link>
<Lib> <Lib>
<AdditionalDependencies>glew32s.lib;opengl32.lib;freetype.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>glew32s.lib;opengl32.lib;freetype.lib;xaudio2.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Lib> </Lib>
<Lib> <Lib>
<AdditionalLibraryDirectories>$(ProjectDir)dep\lib\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(ProjectDir)dep\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalOptions>/ignore:4006 %(AdditionalOptions)</AdditionalOptions>
</Lib> </Lib>
<ProjectReference> <ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies> <LinkLibraryDependencies>true</LinkLibraryDependencies>
@ -184,10 +96,11 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
</Link> </Link>
<Lib> <Lib>
<AdditionalDependencies>glew32s.lib;opengl32.lib;freetype.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>glew32s.lib;opengl32.lib;freetype.lib;xaudio2.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Lib> </Lib>
<Lib> <Lib>
<AdditionalLibraryDirectories>$(ProjectDir)dep\lib\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(ProjectDir)dep\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalOptions>/ignore:4006 %(AdditionalOptions)</AdditionalOptions>
</Lib> </Lib>
<ProjectReference> <ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies> <LinkLibraryDependencies>true</LinkLibraryDependencies>

Binary file not shown.

Binary file not shown.

View File

@ -312,8 +312,8 @@ namespace nf {
} }
} }
} }
m_currentState->onExit();
delete m_audio; delete m_audio;
m_currentState->onExit();
m_currentState->cleanup(); m_currentState->cleanup();
delete m_renderer; delete m_renderer;
} }

View File

@ -57,15 +57,15 @@ namespace nf {
unsigned int cubemapCount = 0; unsigned int cubemapCount = 0;
unsigned int buttonCount = 0; unsigned int buttonCount = 0;
while (packContents.size()) { while (packContents.size()) {
unsigned int startingPos = packContents.find_first_of("#NFASSET ") + 9; size_t startingPos = packContents.find_first_of("#NFASSET ") + 9;
packContents = packContents.substr(9); packContents = packContents.substr(9);
unsigned int endAssetNamePos = packContents.find_first_of('\n'); size_t endAssetNamePos = packContents.find_first_of('\n');
std::string assetName = packContents.substr(0, endAssetNamePos); std::string assetName = packContents.substr(0, endAssetNamePos);
packContents = packContents.substr(endAssetNamePos + 1); packContents = packContents.substr(endAssetNamePos + 1);
unsigned int extensionPos = assetName.find_first_of('.'); size_t extensionPos = assetName.find_first_of('.');
std::string extension = assetName.substr(extensionPos + 1); std::string extension = assetName.substr(extensionPos + 1);
std::string assetContents; std::string assetContents;
unsigned int nextAssetPos = packContents.find("#NFASSET "); size_t nextAssetPos = packContents.find("#NFASSET ");
if (nextAssetPos != std::string::npos) { if (nextAssetPos != std::string::npos) {
assetContents = packContents.substr(0, nextAssetPos - 1); assetContents = packContents.substr(0, nextAssetPos - 1);
packContents = packContents.substr(nextAssetPos); packContents = packContents.substr(nextAssetPos);
@ -74,7 +74,7 @@ namespace nf {
assetContents = packContents; assetContents = packContents;
packContents = ""; packContents = "";
} }
size_t assetSize = assetContents.size(); unsigned int assetSize = (unsigned int)assetContents.size();
if (extension == "obj") if (extension == "obj")
continue; continue;
@ -204,15 +204,15 @@ namespace nf {
Error("Could not find full button set in pack \"" + (std::string)packName + (std::string)"\"!"); Error("Could not find full button set in pack \"" + (std::string)packName + (std::string)"\"!");
while (packContentsOBJ.size()) { while (packContentsOBJ.size()) {
unsigned int startingPos = packContentsOBJ.find_first_of("#NFASSET ") + 9; size_t startingPos = packContentsOBJ.find_first_of("#NFASSET ") + 9;
packContentsOBJ = packContentsOBJ.substr(9); packContentsOBJ = packContentsOBJ.substr(9);
unsigned int endAssetNamePos = packContentsOBJ.find_first_of('\n'); size_t endAssetNamePos = packContentsOBJ.find_first_of('\n');
std::string assetName = packContentsOBJ.substr(0, endAssetNamePos); std::string assetName = packContentsOBJ.substr(0, endAssetNamePos);
packContentsOBJ = packContentsOBJ.substr(endAssetNamePos + 1); packContentsOBJ = packContentsOBJ.substr(endAssetNamePos + 1);
unsigned int extensionPos = assetName.find_first_of('.'); size_t extensionPos = assetName.find_first_of('.');
std::string extension = assetName.substr(extensionPos + 1); std::string extension = assetName.substr(extensionPos + 1);
std::string assetContents; std::string assetContents;
unsigned int nextAssetPos = packContentsOBJ.find("#NFASSET "); size_t nextAssetPos = packContentsOBJ.find("#NFASSET ");
if (nextAssetPos != std::string::npos) { if (nextAssetPos != std::string::npos) {
assetContents = packContentsOBJ.substr(0, nextAssetPos - 1); assetContents = packContentsOBJ.substr(0, nextAssetPos - 1);
packContentsOBJ = packContentsOBJ.substr(nextAssetPos); packContentsOBJ = packContentsOBJ.substr(nextAssetPos);

View File

@ -15,6 +15,9 @@ namespace nf {
debug.BreakMask = XAUDIO2_LOG_ERRORS; debug.BreakMask = XAUDIO2_LOG_ERRORS;
m_engine->SetDebugConfiguration(&debug, 0); m_engine->SetDebugConfiguration(&debug, 0);
m_engine->CreateMasteringVoice(&m_masterVoice); m_engine->CreateMasteringVoice(&m_masterVoice);
DWORD channelMask;
m_masterVoice->GetChannelMask(&channelMask);
X3DAudioInitialize(channelMask, X3DAUDIO_SPEED_OF_SOUND, m_x3d);
} }
void AudioEngine::updateSources() { void AudioEngine::updateSources() {
@ -33,11 +36,19 @@ namespace nf {
IXAudio2SourceVoice* AudioEngine::getNewSourceVoice(WAVEFORMATEXTENSIBLE* fmt) { IXAudio2SourceVoice* AudioEngine::getNewSourceVoice(WAVEFORMATEXTENSIBLE* fmt) {
IXAudio2SourceVoice* s; IXAudio2SourceVoice* s;
HRESULT hr = m_engine->CreateSourceVoice(&s, &fmt->Format); HRESULT hr = m_engine->CreateSourceVoice(&s, &fmt->Format, XAUDIO2_VOICE_USEFILTER);
m_voices.push_back(s); m_voices.push_back(s);
return s; return s;
} }
IXAudio2MasteringVoice* AudioEngine::getMasterVoice() {
return m_masterVoice;
}
X3DAUDIO_HANDLE* AudioEngine::getX3DAudioInstance() {
return &m_x3d;
}
void AudioEngine::cleanup() { void AudioEngine::cleanup() {
for (unsigned int i = 0; i < m_voices.size(); i++) { for (unsigned int i = 0; i < m_voices.size(); i++) {
m_voices[i]->Stop(); m_voices[i]->Stop();

View File

@ -69,6 +69,10 @@ namespace nf {
m_scale = scale; m_scale = scale;
} }
const Vec3& Entity::getPosition() {
return m_position;
}
void Entity::render(Shader* shader, bool onlyDepth) { void Entity::render(Shader* shader, bool onlyDepth) {
shader->bind(); shader->bind();
glm::mat4 model = getModelMatrix(); glm::mat4 model = getModelMatrix();

View File

@ -2,6 +2,7 @@
#include "Application.h" #include "Application.h"
#include "Assets.h" #include "Assets.h"
#include "Entity.h"
#include "Utility.h" #include "Utility.h"
namespace nf { namespace nf {
@ -9,9 +10,12 @@ namespace nf {
m_constructed(false), m_constructed(false),
m_dataSize(0), m_dataSize(0),
m_volume(1.0f), m_volume(1.0f),
m_usePos(false),
m_format({ 0 }), m_format({ 0 }),
m_buffer(nullptr), m_buffer(nullptr),
m_currentVoice(nullptr) m_currentVoice(nullptr),
m_targetEntity(nullptr),
m_soundPos(0.0)
{ {
} }
@ -27,17 +31,21 @@ namespace nf {
if (data.find("RIFF") == std::string::npos) if (data.find("RIFF") == std::string::npos)
Error("Sound asset not of correct format!"); Error("Sound asset not of correct format!");
unsigned int fileSize = *(unsigned int*)&data[4]; unsigned int fileSize = *(unsigned int*)&data[4];
unsigned int fmtPos; size_t fmtPos;
if ((fmtPos = data.find("fmt")) == std::string::npos) if ((fmtPos = data.find("fmt")) == std::string::npos)
Error("Sound asset not of correct format!"); Error("Sound asset not of correct format!");
std::memcpy(&m_format, &data[fmtPos + 8], 16); std::memcpy(&m_format, &data[fmtPos + 8], 16);
unsigned int dataPos; size_t dataPos;
if ((dataPos = data.find("data")) == std::string::npos) if ((dataPos = data.find("data")) == std::string::npos)
Error("Sound asset not of correct m_format!"); Error("Sound asset not of correct m_format!");
m_dataSize = *(unsigned int*)&data[dataPos + 4]; m_dataSize = *(unsigned int*)&data[dataPos + 4];
m_buffer = new unsigned char[m_dataSize]; m_buffer = new unsigned char[m_dataSize];
std::memcpy(m_buffer, &data[dataPos + 8], m_dataSize); std::memcpy(m_buffer, &data[dataPos + 8], m_dataSize);
m_emitter = { 0 };
m_emitter.ChannelCount = 2;
m_emitter.CurveDistanceScaler = 1.0;
Application::getApp()->getCurrentState()->m_nfObjects.push_back(this); Application::getApp()->getCurrentState()->m_nfObjects.push_back(this);
} }
@ -45,6 +53,16 @@ namespace nf {
m_volume = (float)volume; m_volume = (float)volume;
} }
void Sound::setEntity(Entity& entity) {
m_targetEntity = &entity;
m_usePos = false;
}
void Sound::setPosition(const Vec3& position) {
m_soundPos = position;
m_usePos = true;
}
void Sound::play(bool loop) { void Sound::play(bool loop) {
m_currentVoice = Application::getApp()->getAudioEngine()->getNewSourceVoice(&m_format); m_currentVoice = Application::getApp()->getAudioEngine()->getNewSourceVoice(&m_format);
m_currentVoice->SetVolume(m_volume); m_currentVoice->SetVolume(m_volume);
@ -54,6 +72,41 @@ namespace nf {
xBuffer.AudioBytes = m_dataSize; xBuffer.AudioBytes = m_dataSize;
if (loop) if (loop)
xBuffer.LoopCount = XAUDIO2_LOOP_INFINITE; xBuffer.LoopCount = XAUDIO2_LOOP_INFINITE;
if (m_usePos || m_targetEntity) {
if (m_usePos)
m_emitter.Position = X3DAUDIO_VECTOR((float)m_soundPos.x, (float)m_soundPos.y, (float)-m_soundPos.z);
else if (m_targetEntity) {
Vec3 temp = m_targetEntity->getPosition();
m_emitter.Position = X3DAUDIO_VECTOR((float)temp.x, (float)temp.y, (float)-temp.z);
}
m_emitter.OrientFront = X3DAUDIO_VECTOR(0.0, 0.0, 1.0);
m_emitter.OrientTop = X3DAUDIO_VECTOR(0.0, 1.0, 0.0);
float az[2] = { 0 };
m_emitter.pChannelAzimuths = az;
Vec3 temp = Application::getApp()->getCurrentState()->getCamera()->getPosition();
m_listener.Position = X3DAUDIO_VECTOR((float)temp.x, (float)temp.y, (float)-temp.z);
temp = Application::getApp()->getCurrentState()->getCamera()->getRotation();
m_listener.OrientFront = X3DAUDIO_VECTOR((float)temp.x, 0.0f, (float)-temp.z);
m_listener.OrientTop = X3DAUDIO_VECTOR(0.0, 1.0, 0.0);
X3DAUDIO_DSP_SETTINGS settings = { 0 };
settings.SrcChannelCount = 2;
settings.DstChannelCount = 2;
float matrix[4] = { 0 };
settings.pMatrixCoefficients = matrix;
IXAudio2MasteringVoice* master = Application::getApp()->getAudioEngine()->getMasterVoice();
X3DAUDIO_HANDLE* instance = Application::getApp()->getAudioEngine()->getX3DAudioInstance();
X3DAudioCalculate(*instance, &m_listener, &m_emitter, X3DAUDIO_CALCULATE_MATRIX | X3DAUDIO_CALCULATE_DOPPLER | X3DAUDIO_CALCULATE_LPF_DIRECT | X3DAUDIO_CALCULATE_REVERB, &settings);
float temp2 = settings.pMatrixCoefficients[1];
settings.pMatrixCoefficients[1] = settings.pMatrixCoefficients[2];
settings.pMatrixCoefficients[2] = temp2;
m_currentVoice->SetOutputMatrix(master, 2, 2, settings.pMatrixCoefficients);
m_currentVoice->SetFrequencyRatio(settings.DopplerFactor);
XAUDIO2_FILTER_PARAMETERS lpf = { LowPassFilter, 2.0f * std::sinf(X3DAUDIO_PI / 6.0f * settings.LPFDirectCoefficient), 1.0f };
m_currentVoice->SetFilterParameters(&lpf);
}
m_currentVoice->SubmitSourceBuffer(&xBuffer); m_currentVoice->SubmitSourceBuffer(&xBuffer);
m_currentVoice->Start(); m_currentVoice->Start();
} }

View File

@ -36,7 +36,7 @@ namespace nf {
if (FT_Init_FreeType(&ft)) if (FT_Init_FreeType(&ft))
Error("Could not initialize FreeType!"); Error("Could not initialize FreeType!");
FT_Face face; FT_Face face;
if (FT_New_Memory_Face(ft, (const unsigned char*)newFont.data, newFont.size, 0, &face)) if (FT_New_Memory_Face(ft, (const unsigned char*)newFont.data, (unsigned int)newFont.size, 0, &face))
Error("Could not load font!"); Error("Could not load font!");
FT_Set_Pixel_Sizes(face, 0, 160); FT_Set_Pixel_Sizes(face, 0, 160);
for (unsigned char c = 0; c < 128; c++) { for (unsigned char c = 0; c < 128; c++) {

View File

@ -19,7 +19,7 @@ namespace nf {
m_width = Application::getApp()->getConfig().width; m_width = Application::getApp()->getConfig().width;
m_height = Application::getApp()->getConfig().height; m_height = Application::getApp()->getConfig().height;
glGenTextures(m_textures.size(), &m_textures[0]); glGenTextures((unsigned int)m_textures.size(), &m_textures[0]);
for (unsigned int i = 0; i < m_textures.size(); i++) { for (unsigned int i = 0; i < m_textures.size(); i++) {
glBindTexture(GL_TEXTURE_2D, m_textures[i]); glBindTexture(GL_TEXTURE_2D, m_textures[i]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, m_width, m_height, 0, GL_RGB, GL_FLOAT, nullptr); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, m_width, m_height, 0, GL_RGB, GL_FLOAT, nullptr);
@ -28,7 +28,7 @@ namespace nf {
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, m_textures[i], 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, m_textures[i], 0);
} }
unsigned int draw[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 }; unsigned int draw[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
glDrawBuffers(m_textures.size(), draw); glDrawBuffers((unsigned int)m_textures.size(), draw);
glGenRenderbuffers(1, &m_depth); glGenRenderbuffers(1, &m_depth);
glBindRenderbuffer(GL_RENDERBUFFER, m_depth); glBindRenderbuffer(GL_RENDERBUFFER, m_depth);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_width, m_height); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_width, m_height);
@ -38,8 +38,6 @@ namespace nf {
} }
void GBuffer::render(std::vector<Entity*>& entites, Shader* shader) { void GBuffer::render(std::vector<Entity*>& entites, Shader* shader) {
int prevFBO;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFBO);
glBindFramebuffer(GL_FRAMEBUFFER, m_FBO); glBindFramebuffer(GL_FRAMEBUFFER, m_FBO);
resize(); resize();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -51,9 +49,9 @@ namespace nf {
for (auto& curr : m_modelsToDraw) { for (auto& curr : m_modelsToDraw) {
std::vector<glm::mat4>& mats = curr.second; std::vector<glm::mat4>& mats = curr.second;
std::string pos; std::string pos;
unsigned int modelsRemaining = mats.size(); size_t modelsRemaining = mats.size();
while (modelsRemaining != 0) { while (modelsRemaining != 0) {
unsigned int modelCount; size_t modelCount;
if (modelsRemaining > 60) if (modelsRemaining > 60)
modelCount = 60; modelCount = 60;
else else
@ -63,7 +61,7 @@ namespace nf {
pos = std::to_string(i) + "]"; pos = std::to_string(i) + "]";
shader->setUniform(m_modelString + pos, mats[i]); shader->setUniform(m_modelString + pos, mats[i]);
} }
curr.first->render(shader, false, modelCount); curr.first->render(shader, false, (unsigned int)modelCount);
mats.erase(mats.begin(), mats.begin() + modelCount); mats.erase(mats.begin(), mats.begin() + modelCount);
} }
} }
@ -72,7 +70,7 @@ namespace nf {
//TODO: Blit depth buffer for transparent objects later //TODO: Blit depth buffer for transparent objects later
glBindFramebuffer(GL_FRAMEBUFFER, prevFBO); glBindFramebuffer(GL_FRAMEBUFFER, 0);
} }
void GBuffer::bindTextures(Shader* shader) { void GBuffer::bindTextures(Shader* shader) {

View File

@ -4,7 +4,7 @@
namespace nf { namespace nf {
IndexBuffer::IndexBuffer(const void* data, size_t count) { IndexBuffer::IndexBuffer(const void* data, size_t count) {
m_count = count; m_count = (unsigned int)count;
glGenBuffers(1, &m_id); glGenBuffers(1, &m_id);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_id); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_id);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, count * sizeof(unsigned int), data, GL_STATIC_DRAW); glBufferData(GL_ELEMENT_ARRAY_BUFFER, count * sizeof(unsigned int), data, GL_STATIC_DRAW);

View File

@ -18,7 +18,7 @@ namespace nf {
if (model->neededTextures.size() > 32) if (model->neededTextures.size() > 32)
Error("Model exceedes 32 texture limit!"); Error("Model exceedes 32 texture limit!");
std::string obj = model->data; std::string obj = model->data;
unsigned int startMtlPos = obj.find("newmtl"); size_t startMtlPos = obj.find("newmtl");
if (startMtlPos == std::string::npos) if (startMtlPos == std::string::npos)
Error("No materials found in model!"); Error("No materials found in model!");
std::string mtl = obj.substr(startMtlPos); std::string mtl = obj.substr(startMtlPos);
@ -81,7 +81,7 @@ namespace nf {
sscanf_s(mtl.c_str(), "\nNs %f\n", &s); sscanf_s(mtl.c_str(), "\nNs %f\n", &s);
mats[currMat]->shininess = s; mats[currMat]->shininess = s;
} }
unsigned int pos = mtl.find(line) + strlen(line); size_t pos = mtl.find(line) + strlen(line);
mtl = mtl.substr(pos); mtl = mtl.substr(pos);
} }
@ -142,7 +142,7 @@ namespace nf {
mats[usingMat]->vnIndices.push_back(vnIndex[2]); mats[usingMat]->vnIndices.push_back(vnIndex[2]);
} }
unsigned int pos = file.find(line) + strlen(line) + remove; size_t pos = file.find(line) + strlen(line) + remove;
file = file.substr(pos); file = file.substr(pos);
} }
@ -250,9 +250,9 @@ namespace nf {
mats[curr]->outTan.push_back(mats[curr]->unindexedTan[(i * 3)]); mats[curr]->outTan.push_back(mats[curr]->unindexedTan[(i * 3)]);
mats[curr]->outTan.push_back(mats[curr]->unindexedTan[(i * 3 + 1)]); mats[curr]->outTan.push_back(mats[curr]->unindexedTan[(i * 3 + 1)]);
mats[curr]->outTan.push_back(mats[curr]->unindexedTan[(i * 3 + 2)]); mats[curr]->outTan.push_back(mats[curr]->unindexedTan[(i * 3 + 2)]);
unsigned int index = (mats[curr]->outVB.size() / 3) - 1; size_t index = (mats[curr]->outVB.size() / 3) - 1;
mats[curr]->outIB.push_back(index); mats[curr]->outIB.push_back((unsigned int)index);
vertexMap[currVertex] = index; vertexMap[currVertex] = (unsigned int)index;
mats[curr]->ibCount++; mats[curr]->ibCount++;
} }
} }
@ -277,14 +277,14 @@ namespace nf {
norm = new Texture(normA, true); norm = new Texture(normA, true);
} }
m_materials.push_back(std::make_tuple(diff, spec, norm, (float)curr2.diffuseColor.x, (float)curr2.diffuseColor.y, (float)curr2.diffuseColor.z, curr2.shininess)); m_materials.push_back(std::make_tuple(diff, spec, norm, (float)curr2.diffuseColor.x, (float)curr2.diffuseColor.y, (float)curr2.diffuseColor.z, curr2.shininess));
unsigned int offset = vboPositions.size() / 3; size_t offset = vboPositions.size() / 3;
vboPositions.insert(vboPositions.end(), curr2.outVB.begin(), curr2.outVB.end()); vboPositions.insert(vboPositions.end(), curr2.outVB.begin(), curr2.outVB.end());
vboTexCoords.insert(vboTexCoords.end(), curr2.outTC.begin(), curr2.outTC.end()); vboTexCoords.insert(vboTexCoords.end(), curr2.outTC.begin(), curr2.outTC.end());
vboNormals.insert(vboNormals.end(), curr2.outVN.begin(), curr2.outVN.end()); vboNormals.insert(vboNormals.end(), curr2.outVN.begin(), curr2.outVN.end());
vboTangents.insert(vboTangents.end(), curr2.outTan.begin(), curr2.outTan.end()); vboTangents.insert(vboTangents.end(), curr2.outTan.begin(), curr2.outTan.end());
vboMaterialIndices.insert(vboMaterialIndices.end(), curr2.outVB.size() / 3, matCount); vboMaterialIndices.insert(vboMaterialIndices.end(), curr2.outVB.size() / 3, matCount);
if (offset) if (offset)
std::for_each(curr2.outIB.begin(), curr2.outIB.end(), [offset](unsigned int& out) { out += offset; }); std::for_each(curr2.outIB.begin(), curr2.outIB.end(), [offset](unsigned int& out) { out += (unsigned int)offset; });
vboIndices.insert(vboIndices.end(), curr2.outIB.begin(), curr2.outIB.end()); vboIndices.insert(vboIndices.end(), curr2.outIB.begin(), curr2.outIB.end());
delete m.second; delete m.second;
matCount++; matCount++;
@ -315,6 +315,9 @@ namespace nf {
m_ib->bind(); m_ib->bind();
if (!onlyDepth) if (!onlyDepth)
bindMaterials(shader); bindMaterials(shader);
#ifdef _DEBUG
shader->validate();
#endif
glDrawElementsInstanced(GL_TRIANGLES, m_ib->getCount(), GL_UNSIGNED_INT, nullptr, count); glDrawElementsInstanced(GL_TRIANGLES, m_ib->getCount(), GL_UNSIGNED_INT, nullptr, count);
} }

View File

@ -24,6 +24,7 @@ namespace nf {
m_shadowMapFBO(0), m_shadowMapFBO(0),
m_directionalDepthTexSize(0), m_directionalDepthTexSize(0),
m_pointDepthTexSize(0), m_pointDepthTexSize(0),
m_directionalShadowMap(0),
m_cubemap(nullptr), m_cubemap(nullptr),
m_fadeIn(false), m_fadeIn(false),
m_fadeOut(false), m_fadeOut(false),
@ -86,7 +87,7 @@ namespace nf {
if (!m_app->isCustomWindowIcon()) { if (!m_app->isCustomWindowIcon()) {
ATexture& windowTex = *(ATexture*)m_baseAP["defaultwindowicon.png"]; ATexture& windowTex = *(ATexture*)m_baseAP["defaultwindowicon.png"];
int width, height, nChannels; int width, height, nChannels;
unsigned char* tex = stbi_load_from_memory((const unsigned char*)windowTex.data, windowTex.size, &width, &height, &nChannels, 0); unsigned char* tex = stbi_load_from_memory((const unsigned char*)windowTex.data, (unsigned int)windowTex.size, &width, &height, &nChannels, 0);
std::vector<unsigned char> pixels(width * height * 4); std::vector<unsigned char> pixels(width * height * 4);
for (unsigned int i = 0; i < pixels.size() / 4; i++) { for (unsigned int i = 0; i < pixels.size() / 4; i++) {
pixels[i * 4 + 0] = tex[i * 4 + 2]; pixels[i * 4 + 0] = tex[i * 4 + 2];
@ -163,7 +164,7 @@ namespace nf {
m_gBuffer->render(m_lGame, m_gBufferShader); m_gBuffer->render(m_lGame, m_gBufferShader);
//Light entities using the gBuffer //Light entities using the gBuffer
unsigned int lightsRemaining = m_lights.size(); size_t lightsRemaining = m_lights.size();
if (!lightsRemaining) { if (!lightsRemaining) {
m_quadVAO->bind(); m_quadVAO->bind();
m_quadIB->bind(); m_quadIB->bind();
@ -173,7 +174,7 @@ namespace nf {
} }
unsigned int drawCount = 0; unsigned int drawCount = 0;
while (lightsRemaining > 0) { while (lightsRemaining > 0) {
unsigned int currLightsDrawn; size_t currLightsDrawn;
if (lightsRemaining > m_texSlots) if (lightsRemaining > m_texSlots)
currLightsDrawn = m_texSlots; currLightsDrawn = m_texSlots;
else else
@ -285,18 +286,21 @@ namespace nf {
SwapBuffers(m_hdc); SwapBuffers(m_hdc);
} }
void Renderer::renderShadowMaps(unsigned int count) { void Renderer::renderShadowMaps(size_t count) {
float nearP = 0.1f, farP = 400.0f; float nearP = 0.1f, farP = 400.0f;
glm::mat4 directionalLightProj = glm::ortho(-50.0f, 50.0f, -50.0f, 50.0f, nearP, farP); glm::mat4 directionalLightProj = glm::ortho(-50.0f, 50.0f, -50.0f, 50.0f, nearP, farP);
glm::mat4 pointLightProj = glm::perspective(glm::radians(90.0f), 1.0f, nearP, farP); glm::mat4 pointLightProj = glm::perspective(glm::radians(90.0f), 1.0f, nearP, farP);
glm::mat4 lightView; glm::mat4 lightView;
glm::mat4 lightSpaceMat; glm::mat4 lightSpaceMat;
bool directionalRendered = false;
unsigned int directionalSlot = 0; //TODO: Test this
glBindFramebuffer(GL_FRAMEBUFFER, m_shadowMapFBO); glBindFramebuffer(GL_FRAMEBUFFER, m_shadowMapFBO);
for (unsigned int i = 0; i < count; i++) { for (unsigned int i = 0; i < count; i++) {
Light::Type type = m_lights[i]->getType(); Light::Type type = m_lights[i]->getType();
unsigned int tex = type == Light::Type::DIRECTIONAL ? m_directionalShadowMaps[i] : m_pointShadowMaps[i]; unsigned int tex = type == Light::Type::DIRECTIONAL ? m_directionalShadowMap : m_pointShadowMaps[i];
switch (type) { switch (type) {
case Light::Type::DIRECTIONAL: { case Light::Type::DIRECTIONAL: {
std::string stringPos;
glViewport(0, 0, m_directionalDepthTexSize, m_directionalDepthTexSize); glViewport(0, 0, m_directionalDepthTexSize, m_directionalDepthTexSize);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, tex, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, tex, 0);
glDrawBuffer(GL_NONE); glDrawBuffer(GL_NONE);
@ -307,7 +311,7 @@ namespace nf {
lightView = glm::lookAt(lightPos, glm::vec3(0.0), glm::vec3(0.0, 1.0, 0.0)); lightView = glm::lookAt(lightPos, glm::vec3(0.0), glm::vec3(0.0, 1.0, 0.0));
lightSpaceMat = directionalLightProj * lightView; lightSpaceMat = directionalLightProj * lightView;
m_directionalShadowShader->setUniform("lightSpace", lightSpaceMat); m_directionalShadowShader->setUniform("lightSpace", lightSpaceMat);
std::string stringPos = "lightSpaceMat["; stringPos = "lightSpaceMat[";
stringPos += std::to_string(i); stringPos += std::to_string(i);
stringPos += "]"; stringPos += "]";
m_lightingShader->setUniform(stringPos, lightSpaceMat); m_lightingShader->setUniform(stringPos, lightSpaceMat);
@ -320,6 +324,7 @@ namespace nf {
glActiveTexture(GL_TEXTURE4 + i); glActiveTexture(GL_TEXTURE4 + i);
glBindTexture(GL_TEXTURE_2D, tex); glBindTexture(GL_TEXTURE_2D, tex);
m_lightingShader->setUniform(stringPos, 4 + (int)i); m_lightingShader->setUniform(stringPos, 4 + (int)i);
directionalRendered = true;
break; break;
} }
case Light::Type::POINT: { case Light::Type::POINT: {
@ -406,18 +411,8 @@ namespace nf {
m_texSlots = 12; m_texSlots = 12;
glGenFramebuffers(1, &m_shadowMapFBO); glGenFramebuffers(1, &m_shadowMapFBO);
for (unsigned int i = 0; i < m_texSlots; i++) { for (unsigned int i = 0; i < m_texSlots; i++) {
unsigned int directionalDepthMap, pointDepthMap; unsigned int pointDepthMap;
glGenTextures(1, &directionalDepthMap);
glGenTextures(1, &pointDepthMap); glGenTextures(1, &pointDepthMap);
glBindTexture(GL_TEXTURE_2D, directionalDepthMap);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_DEPTH_COMPONENT24, m_directionalDepthTexSize, m_directionalDepthTexSize);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
float borderColor[] = { 1.0f, 1.0f, 1.0f, 1.0f };
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);
glBindTexture(GL_TEXTURE_2D, 0);
glBindTexture(GL_TEXTURE_CUBE_MAP, pointDepthMap); glBindTexture(GL_TEXTURE_CUBE_MAP, pointDepthMap);
glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_DEPTH_COMPONENT24, m_pointDepthTexSize, m_pointDepthTexSize); glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_DEPTH_COMPONENT24, m_pointDepthTexSize, m_pointDepthTexSize);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@ -426,10 +421,18 @@ namespace nf {
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_CUBE_MAP, 0); glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
m_directionalShadowMaps.push_back(directionalDepthMap);
m_pointShadowMaps.push_back(pointDepthMap); m_pointShadowMaps.push_back(pointDepthMap);
} }
glBindFramebuffer(GL_FRAMEBUFFER, 0); glGenTextures(1, &m_directionalShadowMap);
glBindTexture(GL_TEXTURE_2D, m_directionalShadowMap);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_DEPTH_COMPONENT24, m_directionalDepthTexSize, m_directionalDepthTexSize);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
float borderColor[] = { 1.0f, 1.0f, 1.0f, 1.0f };
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);
glBindTexture(GL_TEXTURE_2D, 0);
} }
Renderer::~Renderer() { Renderer::~Renderer() {

View File

@ -53,15 +53,6 @@ namespace nf {
glGetProgramInfoLog(m_id, length, &length, message); glGetProgramInfoLog(m_id, length, &length, message);
Error("OpenGL Error: " + (std::string)message); Error("OpenGL Error: " + (std::string)message);
} }
glValidateProgram(m_id);
glGetProgramiv(m_id, GL_VALIDATE_STATUS, &result);
if (result != GL_TRUE) {
int length;
glGetProgramiv(m_id, GL_INFO_LOG_LENGTH, &length);
char* message = new char[length];
glGetProgramInfoLog(m_id, length, &length, message);
Error("OpenGL Error: " + (std::string)message);
}
glDetachShader(m_id, vs); glDetachShader(m_id, vs);
glDetachShader(m_id, fs); glDetachShader(m_id, fs);
glDeleteShader(vs); glDeleteShader(vs);
@ -72,6 +63,19 @@ namespace nf {
} }
} }
void Shader::validate() {
glValidateProgram(m_id);
int result;
glGetProgramiv(m_id, GL_VALIDATE_STATUS, &result);
if (result != GL_TRUE) {
int length;
glGetProgramiv(m_id, GL_INFO_LOG_LENGTH, &length);
char* message = new char[length];
glGetProgramInfoLog(m_id, length, &length, message);
Error("OpenGL Error: " + (std::string)message);
}
}
void Shader::bind() { void Shader::bind() {
glUseProgram(m_id); glUseProgram(m_id);
} }

View File

@ -16,7 +16,7 @@ namespace nf {
{ {
int nChannels; int nChannels;
stbi_set_flip_vertically_on_load(true); stbi_set_flip_vertically_on_load(true);
unsigned char* texture = stbi_load_from_memory((unsigned char*)tex->data, tex->size, &m_x, &m_y, &nChannels, 0); unsigned char* texture = stbi_load_from_memory((unsigned char*)tex->data, (unsigned int)tex->size, &m_x, &m_y, &nChannels, 0);
if (!texture) if (!texture)
Error("Texture failed to load from memory!"); Error("Texture failed to load from memory!");
glGenTextures(1, &m_id); glGenTextures(1, &m_id);

View File

@ -37,7 +37,7 @@ namespace nf {
} }
void VertexArray::finishBufferLayout() { void VertexArray::finishBufferLayout() {
unsigned int offset = 0; size_t offset = 0;
for (; m_attribute < m_lastBufferLayout.size(); m_attribute++) { for (; m_attribute < m_lastBufferLayout.size(); m_attribute++) {
const VertexBufferElement& curr = m_lastBufferLayout[m_attribute]; const VertexBufferElement& curr = m_lastBufferLayout[m_attribute];
glEnableVertexAttribArray(m_attribute); glEnableVertexAttribArray(m_attribute);

View File

@ -53,14 +53,14 @@ namespace nf {
#endif #endif
const wchar_t* toWide(const char* in) { const wchar_t* toWide(const char* in) {
int length = std::strlen(in) + 1; unsigned int length = (unsigned int)std::strlen(in) + 1;
wchar_t* out = new wchar_t[length]; wchar_t* out = new wchar_t[length];
MultiByteToWideChar(CP_ACP, NULL, in, -1, out, length); MultiByteToWideChar(CP_ACP, NULL, in, -1, out, length);
return out; return out;
} }
const wchar_t* toWide(const std::string& in) { const wchar_t* toWide(const std::string& in) {
const char* cstr = in.c_str(); const char* cstr = in.c_str();
int length = std::strlen(cstr) + 1; unsigned int length = (unsigned int)std::strlen(cstr) + 1;
wchar_t* out = new wchar_t[length]; wchar_t* out = new wchar_t[length];
MultiByteToWideChar(CP_ACP, NULL, cstr, -1, out, length); MultiByteToWideChar(CP_ACP, NULL, cstr, -1, out, length);
return out; return out;
@ -68,7 +68,7 @@ namespace nf {
void writeFile(const std::string& filename, const std::string& in, bool encrypted) { void writeFile(const std::string& filename, const std::string& in, bool encrypted) {
if (filename.find('/') != std::string::npos || filename.find('\\') != std::string::npos) { if (filename.find('/') != std::string::npos || filename.find('\\') != std::string::npos) {
int pos = filename.find_last_of("/\\"); size_t pos = filename.find_last_of("/\\");
std::string temp = filename.substr(0, pos); std::string temp = filename.substr(0, pos);
std::wstring folders(temp.begin(), temp.end()); std::wstring folders(temp.begin(), temp.end());
WCHAR exe[MAX_PATH]; WCHAR exe[MAX_PATH];

View File

@ -31,17 +31,17 @@ namespace nf {
struct ACubemap : Asset { struct ACubemap : Asset {
char* frontData = nullptr; char* frontData = nullptr;
size_t frontSize = 0; unsigned int frontSize = 0;
char* backData = nullptr; char* backData = nullptr;
size_t backSize = 0; unsigned int backSize = 0;
char* topData = nullptr; char* topData = nullptr;
size_t topSize = 0; unsigned int topSize = 0;
char* bottomData = nullptr; char* bottomData = nullptr;
size_t bottomSize = 0; unsigned int bottomSize = 0;
char* leftData = nullptr; char* leftData = nullptr;
size_t leftSize = 0; unsigned int leftSize = 0;
char* rightData = nullptr; char* rightData = nullptr;
size_t rightSize = 0; unsigned int rightSize = 0;
unsigned int numImages = 0; unsigned int numImages = 0;

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <vector> #include <vector>
#include <xaudio2.h> #include <xaudio2.h>
#include <x3daudio.h>
namespace nf { namespace nf {
class Application; class Application;
@ -11,12 +12,15 @@ namespace nf {
void updateSources(); void updateSources();
IXAudio2SourceVoice* getNewSourceVoice(WAVEFORMATEXTENSIBLE* fmt); IXAudio2SourceVoice* getNewSourceVoice(WAVEFORMATEXTENSIBLE* fmt);
IXAudio2MasteringVoice* getMasterVoice();
X3DAUDIO_HANDLE* getX3DAudioInstance();
void cleanup(); void cleanup();
~AudioEngine(); ~AudioEngine();
private: private:
Application* m_app; Application* m_app;
IXAudio2* m_engine; IXAudio2* m_engine;
X3DAUDIO_HANDLE m_x3d;
IXAudio2MasteringVoice* m_masterVoice; IXAudio2MasteringVoice* m_masterVoice;
std::vector<IXAudio2SourceVoice*> m_voices; std::vector<IXAudio2SourceVoice*> m_voices;
}; };

View File

@ -25,6 +25,7 @@ namespace nf {
void setScale(double x, double y, double z); void setScale(double x, double y, double z);
void setScale(const Vec3& scale); void setScale(const Vec3& scale);
const Vec3& getPosition();
void render(Shader* shader, bool onlyDepth); void render(Shader* shader, bool onlyDepth);
Model* getModel() const; Model* getModel() const;
#ifdef NFENGINE #ifdef NFENGINE

View File

@ -33,7 +33,7 @@ namespace nf {
~Renderer(); ~Renderer();
private: private:
void renderShadowMaps(unsigned int count); void renderShadowMaps(size_t count);
void loadBaseAssets(); void loadBaseAssets();
void createShadowMaps(); void createShadowMaps();
@ -50,7 +50,7 @@ namespace nf {
unsigned int m_shadowMapFBO; unsigned int m_shadowMapFBO;
int m_directionalDepthTexSize; int m_directionalDepthTexSize;
int m_pointDepthTexSize; int m_pointDepthTexSize;
std::vector<unsigned int> m_directionalShadowMaps; unsigned int m_directionalShadowMap;
std::vector<unsigned int> m_pointShadowMaps; std::vector<unsigned int> m_pointShadowMaps;
unsigned int m_texSlots; unsigned int m_texSlots;

View File

@ -8,6 +8,7 @@ namespace nf {
public: public:
Shader(const char* vertexSource, const char* fragmentSource, const char* geometrySource = nullptr); Shader(const char* vertexSource, const char* fragmentSource, const char* geometrySource = nullptr);
void validate();
void bind(); void bind();
void setUniform(const std::string& name, glm::mat4& data); void setUniform(const std::string& name, glm::mat4& data);
void setUniform(const std::string& name, glm::vec3& data); void setUniform(const std::string& name, glm::vec3& data);

View File

@ -1,10 +1,13 @@
#pragma once #pragma once
#include <xaudio2.h> #include <xaudio2.h>
#include <x3daudio.h>
#include "NFObject.h" #include "NFObject.h"
#include "Utility.h"
namespace nf { namespace nf {
struct Asset; struct Asset;
class Entity;
class Sound : public NFObject { class Sound : public NFObject {
public: public:
@ -12,6 +15,8 @@ namespace nf {
void create(Asset* soundAsset); void create(Asset* soundAsset);
void setVolume(double volume); void setVolume(double volume);
void setEntity(Entity& entity);
void setPosition(const Vec3& position);
void play(bool loop = false); void play(bool loop = false);
void stop(); void stop();
@ -21,8 +26,13 @@ namespace nf {
bool m_constructed; bool m_constructed;
unsigned int m_dataSize; unsigned int m_dataSize;
float m_volume; float m_volume;
bool m_usePos;
WAVEFORMATEXTENSIBLE m_format; WAVEFORMATEXTENSIBLE m_format;
unsigned char* m_buffer; unsigned char* m_buffer;
IXAudio2SourceVoice* m_currentVoice; IXAudio2SourceVoice* m_currentVoice;
Entity* m_targetEntity;
Vec3 m_soundPos;
X3DAUDIO_EMITTER m_emitter;
X3DAUDIO_LISTENER m_listener;
}; };
} }

View File

@ -15,29 +15,21 @@ EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64 Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1B9C5361-E301-41BF-97E7-56D65F11E2BB}.Debug|x64.ActiveCfg = Debug|x64 {1B9C5361-E301-41BF-97E7-56D65F11E2BB}.Debug|x64.ActiveCfg = Debug|x64
{1B9C5361-E301-41BF-97E7-56D65F11E2BB}.Debug|x86.ActiveCfg = Debug|Win32 {1B9C5361-E301-41BF-97E7-56D65F11E2BB}.Debug|x64.Build.0 = Debug|x64
{1B9C5361-E301-41BF-97E7-56D65F11E2BB}.Debug|x86.Build.0 = Debug|Win32
{1B9C5361-E301-41BF-97E7-56D65F11E2BB}.Release|x64.ActiveCfg = Release|x64 {1B9C5361-E301-41BF-97E7-56D65F11E2BB}.Release|x64.ActiveCfg = Release|x64
{1B9C5361-E301-41BF-97E7-56D65F11E2BB}.Release|x86.ActiveCfg = Release|Win32 {1B9C5361-E301-41BF-97E7-56D65F11E2BB}.Release|x64.Build.0 = Release|x64
{1B9C5361-E301-41BF-97E7-56D65F11E2BB}.Release|x86.Build.0 = Release|Win32
{B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Debug|x64.ActiveCfg = Debug|x64 {B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Debug|x64.ActiveCfg = Debug|x64
{B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Debug|x86.ActiveCfg = Debug|Win32 {B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Debug|x64.Build.0 = Debug|x64
{B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Debug|x86.Build.0 = Debug|Win32
{B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Release|x64.ActiveCfg = Release|x64 {B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Release|x64.ActiveCfg = Release|x64
{B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Release|x86.ActiveCfg = Release|Win32 {B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Release|x64.Build.0 = Release|x64
{B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Release|x86.Build.0 = Release|Win32 {771B4AEE-E2C6-4745-AC40-1EF57149612E}.Debug|x64.ActiveCfg = Debug|x64
{771B4AEE-E2C6-4745-AC40-1EF57149612E}.Debug|x64.ActiveCfg = Debug|Win32 {771B4AEE-E2C6-4745-AC40-1EF57149612E}.Debug|x64.Build.0 = Debug|x64
{771B4AEE-E2C6-4745-AC40-1EF57149612E}.Debug|x86.ActiveCfg = Debug|Win32 {771B4AEE-E2C6-4745-AC40-1EF57149612E}.Release|x64.ActiveCfg = Release|x64
{771B4AEE-E2C6-4745-AC40-1EF57149612E}.Debug|x86.Build.0 = Debug|Win32 {771B4AEE-E2C6-4745-AC40-1EF57149612E}.Release|x64.Build.0 = Release|x64
{771B4AEE-E2C6-4745-AC40-1EF57149612E}.Release|x64.ActiveCfg = Release|Win32
{771B4AEE-E2C6-4745-AC40-1EF57149612E}.Release|x86.ActiveCfg = Release|Win32
{771B4AEE-E2C6-4745-AC40-1EF57149612E}.Release|x86.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE