Merge remote-tracking branch 'origin/GameLogicBranch' into Physics
This commit is contained in:
commit
64565b50de
|
@ -29,6 +29,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GamePhysics", "GamePhysics\
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tester", "Tester\Tester.vcxproj", "{1B3BEA4C-CF75-438A-9693-60FB8444BBF3}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tester", "Tester\Tester.vcxproj", "{1B3BEA4C-CF75-438A-9693-60FB8444BBF3}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasGame", "DanBiasGame\DanBiasGame.vcxproj", "{2A1BC987-AF42-4500-802D-89CD32FC1309}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Mixed Platforms = Debug|Mixed Platforms
|
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||||
|
@ -175,6 +177,7 @@ Global
|
||||||
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Win32.ActiveCfg = Debug|Win32
|
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Win32.Build.0 = Debug|Win32
|
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|x64.ActiveCfg = Debug|x64
|
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|x64.Build.0 = Debug|x64
|
||||||
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||||
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Mixed Platforms.Build.0 = Release|Win32
|
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Mixed Platforms.Build.0 = Release|Win32
|
||||||
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Win32.ActiveCfg = Release|Win32
|
{104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
@ -190,6 +193,18 @@ Global
|
||||||
{1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|Win32.ActiveCfg = Release|Win32
|
{1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|Win32.Build.0 = Release|Win32
|
{1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|Win32.Build.0 = Release|Win32
|
||||||
{1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|x64.ActiveCfg = Release|Win32
|
{1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|x64.ActiveCfg = Release|Win32
|
||||||
|
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||||
|
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||||
|
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||||
|
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Mixed Platforms.Build.0 = Release|Win32
|
||||||
|
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|x64.Build.0 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
@ -0,0 +1,193 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{2A1BC987-AF42-4500-802D-89CD32FC1309}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>DanBiasGame</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</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 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" />
|
||||||
|
</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 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" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
|
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
|
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
|
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
|
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;GameLogic_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<DelayLoadDLLs>OysterGraphics_$(PlatformShortName)D.dll;GameLogic_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;GameLogic_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<DelayLoadDLLs>OysterGraphics_$(PlatformShortName)D.dll;GameLogic_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalDependencies>OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;GameLogic_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<DelayLoadDLLs>OysterGraphics_$(PlatformShortName)D.dll;GameLogic_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalDependencies>OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;GameLogic_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<DelayLoadDLLs>OysterGraphics_$(PlatformShortName)D.dll;GameLogic_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\GameLogic\GameLogic.vcxproj">
|
||||||
|
<Project>{b1195bb9-b3a5-47f0-906c-8dea384d1520}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\Input\Input.vcxproj">
|
||||||
|
<Project>{7e3990d2-3d94-465c-b58d-64a74b3ecf9b}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\OysterMath\OysterMath.vcxproj">
|
||||||
|
<Project>{f10cbc03-9809-4cba-95d8-327c287b18ee}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\OysterPhysics3D\OysterPhysics3D.vcxproj">
|
||||||
|
<Project>{4285bd3f-3c6c-4670-b7af-a29afef5f6a8}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="DanBiasMaincpp.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,302 @@
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// File: TemplateMain.cpp
|
||||||
|
//
|
||||||
|
// BTH-D3D-Template
|
||||||
|
//
|
||||||
|
// Copyright (c) Stefan Petersson 2011. All rights reserved.
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
#define NOMINMAX
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
#include "DllInterfaces/GFXAPI.h"
|
||||||
|
#include "IGame.h"
|
||||||
|
|
||||||
|
#include "L_inputClass.h"
|
||||||
|
|
||||||
|
// debug window include
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <io.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Global Variables
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
HINSTANCE g_hInst = NULL;
|
||||||
|
HWND g_hWnd = NULL;
|
||||||
|
|
||||||
|
GameLogic::IGame* game;
|
||||||
|
InputClass* inputObj;
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Forward declarations
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow );
|
||||||
|
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
|
HRESULT Render(float deltaTime);
|
||||||
|
HRESULT Update(float deltaTime);
|
||||||
|
HRESULT InitGame();
|
||||||
|
HRESULT CleanUp();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Entry point to the program. Initializes everything and goes into a message processing
|
||||||
|
// loop. Idle time is used to render the scene.
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void SetStdOutToNewConsole()
|
||||||
|
{
|
||||||
|
// allocate a console for this app
|
||||||
|
AllocConsole();
|
||||||
|
|
||||||
|
// redirect unbuffered STDOUT to the console
|
||||||
|
HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
int fileDescriptor = _open_osfhandle((intptr_t)consoleHandle, _O_TEXT);
|
||||||
|
FILE *fp = _fdopen( fileDescriptor, "w" );
|
||||||
|
*stdout = *fp;
|
||||||
|
setvbuf( stdout, NULL, _IONBF, 0 );
|
||||||
|
|
||||||
|
// give the console window a nicer title
|
||||||
|
|
||||||
|
SetConsoleTitle(L"Debug Output");
|
||||||
|
|
||||||
|
// give the console window a bigger buffer size
|
||||||
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
if ( GetConsoleScreenBufferInfo(consoleHandle, &csbi) )
|
||||||
|
{
|
||||||
|
COORD bufferSize;
|
||||||
|
bufferSize.X = csbi.dwSize.X;
|
||||||
|
bufferSize.Y = 50;
|
||||||
|
SetConsoleScreenBufferSize(consoleHandle, bufferSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow )
|
||||||
|
{
|
||||||
|
BOOL success = SetDllDirectory(L"..\\..\\DLL");
|
||||||
|
if (success == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( FAILED( InitWindow( hInstance, nCmdShow ) ) )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if( FAILED( InitGame() ) )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
__int64 cntsPerSec = 0;
|
||||||
|
QueryPerformanceFrequency((LARGE_INTEGER*)&cntsPerSec);
|
||||||
|
float secsPerCnt = 1.0f / (float)cntsPerSec;
|
||||||
|
|
||||||
|
__int64 prevTimeStamp = 0;
|
||||||
|
QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);
|
||||||
|
|
||||||
|
//debug window
|
||||||
|
//SetStdOutToNewConsole();
|
||||||
|
|
||||||
|
// Main message loop
|
||||||
|
MSG msg = {0};
|
||||||
|
while(WM_QUIT != msg.message)
|
||||||
|
{
|
||||||
|
if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE) )
|
||||||
|
{
|
||||||
|
TranslateMessage( &msg );
|
||||||
|
DispatchMessage( &msg );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
__int64 currTimeStamp = 0;
|
||||||
|
QueryPerformanceCounter((LARGE_INTEGER*)&currTimeStamp);
|
||||||
|
float dt = (currTimeStamp - prevTimeStamp) * secsPerCnt;
|
||||||
|
|
||||||
|
//render
|
||||||
|
Update(dt);
|
||||||
|
Render(dt);
|
||||||
|
|
||||||
|
prevTimeStamp = currTimeStamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CleanUp();
|
||||||
|
return (int) msg.wParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Register class and create window
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow )
|
||||||
|
{
|
||||||
|
// Register class
|
||||||
|
WNDCLASSEX wcex;
|
||||||
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||||
|
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
|
wcex.lpfnWndProc = WndProc;
|
||||||
|
wcex.cbClsExtra = 0;
|
||||||
|
wcex.cbWndExtra = 0;
|
||||||
|
wcex.hInstance = hInstance;
|
||||||
|
wcex.hIcon = 0;
|
||||||
|
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
|
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
||||||
|
wcex.lpszMenuName = NULL;
|
||||||
|
wcex.lpszClassName = L"BTH_D3D_Template";
|
||||||
|
wcex.hIconSm = 0;
|
||||||
|
if( !RegisterClassEx(&wcex) )
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
// Adjust and create window
|
||||||
|
g_hInst = hInstance;
|
||||||
|
RECT rc = { 0, 0, 1024, 768 };
|
||||||
|
AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE );
|
||||||
|
|
||||||
|
if(!(g_hWnd = CreateWindow(
|
||||||
|
L"BTH_D3D_Template",
|
||||||
|
L"BTH - Direct3D 11.0 Template",
|
||||||
|
WS_OVERLAPPEDWINDOW,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
rc.right - rc.left,
|
||||||
|
rc.bottom - rc.top,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
hInstance,
|
||||||
|
NULL)))
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowWindow( g_hWnd, nCmdShow );
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HRESULT InitGame()
|
||||||
|
{
|
||||||
|
inputObj = new InputClass;
|
||||||
|
if(!inputObj->Initialize(g_hInst, g_hWnd, 1024, 768))
|
||||||
|
{
|
||||||
|
MessageBox(0, L"Could not initialize the input object.", L"Error", MB_OK);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(Oyster::Graphics::API::Init(g_hWnd, false, false, Oyster::Math::Float2( 1024, 768)) != Oyster::Graphics::API::Sucsess)
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
|
||||||
|
game = new GameLogic::IGame();
|
||||||
|
game->Init();
|
||||||
|
game->StartGame();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
HRESULT Update(float deltaTime)
|
||||||
|
{
|
||||||
|
inputObj->Update();
|
||||||
|
GameLogic::keyInput key = GameLogic::keyInput_none;
|
||||||
|
|
||||||
|
if(inputObj->IsKeyPressed(DIK_W))
|
||||||
|
{
|
||||||
|
key = GameLogic::keyInput_W;
|
||||||
|
}
|
||||||
|
else if(inputObj->IsKeyPressed(DIK_A))
|
||||||
|
{
|
||||||
|
key = GameLogic::keyInput_A;
|
||||||
|
}
|
||||||
|
else if(inputObj->IsKeyPressed(DIK_S))
|
||||||
|
{
|
||||||
|
key = GameLogic::keyInput_S;
|
||||||
|
}
|
||||||
|
else if(inputObj->IsKeyPressed(DIK_D))
|
||||||
|
{
|
||||||
|
key = GameLogic::keyInput_D;
|
||||||
|
}
|
||||||
|
|
||||||
|
game->Update(key);
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT Render(float deltaTime)
|
||||||
|
{
|
||||||
|
int isPressed = 0;
|
||||||
|
if(inputObj->IsKeyPressed(DIK_A))
|
||||||
|
{
|
||||||
|
isPressed = 1;
|
||||||
|
//std::cout<<"test";
|
||||||
|
}
|
||||||
|
|
||||||
|
// test view and projection matrix
|
||||||
|
Oyster::Math::Float3 dir = Oyster::Math::Float3(0,0,-1);
|
||||||
|
Oyster::Math::Float3 up =Oyster::Math::Float3(0,1,0);
|
||||||
|
Oyster::Math::Float3 pos = Oyster::Math::Float3(0, 0, 100);
|
||||||
|
|
||||||
|
Oyster::Math::Float4x4 view =Oyster::Math3D::OrientationMatrix_LookAtDirection(dir, up, pos);
|
||||||
|
view = view.GetInverse();
|
||||||
|
|
||||||
|
Oyster::Math::Float4x4 proj = Oyster::Math3D::ProjectionMatrix_Perspective(3.14f/2, 1024/768, 1, 1000);
|
||||||
|
|
||||||
|
Oyster::Graphics::API::NewFrame(view, proj);
|
||||||
|
|
||||||
|
game->Render();
|
||||||
|
wchar_t title[255];
|
||||||
|
swprintf(title, sizeof(title), L"| Pressing A: %d | \n", (int)(isPressed));
|
||||||
|
SetWindowText(g_hWnd, title);
|
||||||
|
|
||||||
|
Oyster::Graphics::API::EndFrame();
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT CleanUp()
|
||||||
|
{
|
||||||
|
|
||||||
|
if(game)
|
||||||
|
{
|
||||||
|
delete game;
|
||||||
|
game = NULL;
|
||||||
|
}
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Called every time the application receives a message
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
|
||||||
|
{
|
||||||
|
PAINTSTRUCT ps;
|
||||||
|
HDC hdc;
|
||||||
|
|
||||||
|
switch (message)
|
||||||
|
{
|
||||||
|
case WM_PAINT:
|
||||||
|
hdc = BeginPaint(hWnd, &ps);
|
||||||
|
EndPaint(hWnd, &ps);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_DESTROY:
|
||||||
|
PostQuitMessage(0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_KEYDOWN:
|
||||||
|
|
||||||
|
switch(wParam)
|
||||||
|
{
|
||||||
|
case VK_ESCAPE:
|
||||||
|
PostQuitMessage(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
#include "CollisionManager.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace CollisionManager
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ColisionEvent(Oyster::Physics::ICustomBody &obj1, Oyster::Physics::ICustomBody &obj2)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
//Object *realObj1 = refManager.GetMap(obj1);
|
||||||
|
//Object *realObj2 = refManager.GetMap(obj2);
|
||||||
|
//
|
||||||
|
//switch(realObj1->GetType())
|
||||||
|
//{
|
||||||
|
//case Object::OBJECT_TYPE_PLAYER:
|
||||||
|
|
||||||
|
// if (realObj2->GetType() == Object::OBJECT_TYPE_BOX )
|
||||||
|
// {
|
||||||
|
//CollisionManager::PlayerVBox(*((Player*)realObj1),*((DynamicObject*)realObj2));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// break;
|
||||||
|
//case Object::OBJECT_TYPE_BOX:
|
||||||
|
|
||||||
|
// if (realObj2->GetType() == Object::OBJECT_TYPE_PLAYER)
|
||||||
|
// {
|
||||||
|
// CollisionManager::PlayerVBox(*((Player*)realObj2),*((DynamicObject*)realObj1));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// break;
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlayerCollision(Oyster::Physics::ICustomBody &rigidBodyPlayer,Oyster::Physics::ICustomBody &obj)
|
||||||
|
{
|
||||||
|
Player *player = ((Player*)GameLogic::RefManager::getInstance()->GetMap(rigidBodyPlayer));
|
||||||
|
Object *realObj = GameLogic::RefManager::getInstance()->GetMap(obj);
|
||||||
|
|
||||||
|
switch (realObj->GetType())
|
||||||
|
{
|
||||||
|
case Object::OBJECT_TYPE_BOX:
|
||||||
|
PlayerVBox(*player,(*(DynamicObject*) realObj));
|
||||||
|
break;
|
||||||
|
case Object::OBJECT_TYPE_PLAYER:
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//spela ljud? ta skada? etc etc
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlayerVBox(Player &player, DynamicObject &box)
|
||||||
|
{
|
||||||
|
//spela ljud? ta skada? etc etc
|
||||||
|
}
|
||||||
|
|
||||||
|
void BoxCollision(Oyster::Physics::ICustomBody &rigidBodyBox, Oyster::Physics::ICustomBody &obj)
|
||||||
|
{
|
||||||
|
DynamicObject *box = ((DynamicObject*)GameLogic::RefManager::getInstance()->GetMap(rigidBodyBox));
|
||||||
|
Object *realObj = GameLogic::RefManager::getInstance()->GetMap(obj);
|
||||||
|
|
||||||
|
switch (realObj->GetType())
|
||||||
|
{
|
||||||
|
case Object::OBJECT_TYPE_BOX:
|
||||||
|
|
||||||
|
break;
|
||||||
|
case Object::OBJECT_TYPE_PLAYER:
|
||||||
|
PlayerVBox(*(Player*)realObj,*box);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef COLLISIONMANAGER_H
|
||||||
|
#define COLLISIONMANAGER_H
|
||||||
|
|
||||||
|
#include "Object.h"
|
||||||
|
#include "PhysicsAPI.h"
|
||||||
|
#include "RefManager.h"
|
||||||
|
#include "DynamicObject.h"
|
||||||
|
#include "Player.h"
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace CollisionManager
|
||||||
|
{
|
||||||
|
void PlayerCollision(Oyster::Physics::ICustomBody &rigidBodyPlayer,Oyster::Physics::ICustomBody &obj);
|
||||||
|
void BoxCollision(Oyster::Physics::ICustomBody &rigidBodyBox, Oyster::Physics::ICustomBody &obj);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void PlayerVBox(Player &player, DynamicObject &box);
|
||||||
|
void BoxVBox(DynamicObject &box1, DynamicObject &box2);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,21 @@
|
||||||
|
#include "DynamicObject.h"
|
||||||
|
|
||||||
|
using namespace GameLogic;
|
||||||
|
using namespace Oyster::Physics;
|
||||||
|
using namespace Utility::DynamicMemory;
|
||||||
|
|
||||||
|
DynamicObject::DynamicObject(void)
|
||||||
|
{
|
||||||
|
rigidBody = API::Instance().CreateSimpleRigidBody();
|
||||||
|
API::Instance().AddObject(rigidBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DynamicObject::~DynamicObject(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicObject::Update()
|
||||||
|
{
|
||||||
|
//updatera objectet
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
//Created by Erik and Linda of the GameLogic team
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef DYNAMICOBJECT_H
|
||||||
|
#define DYNAMICOBJECT_H
|
||||||
|
|
||||||
|
#include "Object.h"
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
class DynamicObject : public Object
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
DynamicObject(void);
|
||||||
|
~DynamicObject(void);
|
||||||
|
|
||||||
|
void Update();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,35 @@
|
||||||
|
#include "Game.h"
|
||||||
|
using namespace GameLogic;
|
||||||
|
|
||||||
|
Game::Game(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Game::~Game(void)
|
||||||
|
{
|
||||||
|
//SAFE_DELETE(player);
|
||||||
|
if(player)
|
||||||
|
{
|
||||||
|
delete player;
|
||||||
|
player = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Game::Init()
|
||||||
|
{
|
||||||
|
player = new Player();
|
||||||
|
}
|
||||||
|
void Game::StartGame()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void Game::Update(keyInput keyPressed)
|
||||||
|
{
|
||||||
|
player->Update(keyPressed);
|
||||||
|
}
|
||||||
|
void Game::Render()
|
||||||
|
{
|
||||||
|
player->Render();
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
#ifndef GAME_H
|
||||||
|
#define GAME_H
|
||||||
|
|
||||||
|
#include "Level.h"
|
||||||
|
#include "Player.h"
|
||||||
|
#include "IGame.h"
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
class Game
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Game();
|
||||||
|
~Game();
|
||||||
|
|
||||||
|
void Init();
|
||||||
|
void StartGame();
|
||||||
|
void Update(keyInput keyPressed);
|
||||||
|
void Render();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Level* level;
|
||||||
|
Player* player;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -24,30 +24,30 @@
|
||||||
</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|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
@ -66,34 +66,41 @@
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
|
<LibraryPath>$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath)</LibraryPath>
|
||||||
|
<TargetExt>.dll</TargetExt>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
|
<LibraryPath>$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
|
<LibraryPath>$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
|
<LibraryPath>$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;$(SolutionDir)GamePhysics;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;$(SolutionDir)GamePhysics;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>GAME_DLL_EXPORT;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;GamePhysics_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
@ -101,10 +108,12 @@
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;$(SolutionDir)GamePhysics;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;$(SolutionDir)GamePhysics;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>GAME_DLL_EXPORT;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;GamePhysics_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
@ -114,12 +123,14 @@
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;$(SolutionDir)GamePhysics;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;$(SolutionDir)GamePhysics;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>GAME_DLL_EXPORT;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalDependencies>OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;GamePhysics_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
@ -129,21 +140,34 @@
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;$(SolutionDir)GamePhysics;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;$(SolutionDir)GamePhysics;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>GAME_DLL_EXPORT;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalDependencies>OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;GamePhysics_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\GamePhysics\GamePhysics.vcxproj">
|
<ProjectReference Include="..\GamePhysics\GamePhysics.vcxproj">
|
||||||
<Project>{104fa3e9-94d9-4e1d-a941-28a03bc8a095}</Project>
|
<Project>{104fa3e9-94d9-4e1d-a941-28a03bc8a095}</Project>
|
||||||
|
<Private>false</Private>
|
||||||
|
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||||
|
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||||
|
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
||||||
|
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\Input\Input.vcxproj">
|
||||||
|
<Project>{7e3990d2-3d94-465c-b58d-64a74b3ecf9b}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\Misc\Misc.vcxproj">
|
<ProjectReference Include="..\Misc\Misc.vcxproj">
|
||||||
<Project>{2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}</Project>
|
<Project>{2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\OysterGraphics\OysterGraphics.vcxproj">
|
||||||
|
<Project>{0ec83e64-230e-48ef-b08c-6ac9651b4f82}</Project>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\OysterMath\OysterMath.vcxproj">
|
<ProjectReference Include="..\OysterMath\OysterMath.vcxproj">
|
||||||
<Project>{f10cbc03-9809-4cba-95d8-327c287b18ee}</Project>
|
<Project>{f10cbc03-9809-4cba-95d8-327c287b18ee}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
@ -151,6 +175,29 @@
|
||||||
<Project>{4285bd3f-3c6c-4670-b7af-a29afef5f6a8}</Project>
|
<Project>{4285bd3f-3c6c-4670-b7af-a29afef5f6a8}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="DynamicObject.h" />
|
||||||
|
<ClInclude Include="Game.h" />
|
||||||
|
<ClInclude Include="IGame.h" />
|
||||||
|
<ClInclude Include="Level.h" />
|
||||||
|
<ClInclude Include="Object.h" />
|
||||||
|
<ClInclude Include="Player.h" />
|
||||||
|
<ClInclude Include="RefManager.h" />
|
||||||
|
<ClInclude Include="StaticObject.h" />
|
||||||
|
<ClInclude Include="Weapon.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="DynamicObject.cpp" />
|
||||||
|
<ClCompile Include="Game.cpp" />
|
||||||
|
<ClCompile Include="IGame.cpp" />
|
||||||
|
<ClCompile Include="Level.cpp" />
|
||||||
|
<ClCompile Include="Object.cpp" />
|
||||||
|
<ClCompile Include="Player.cpp" />
|
||||||
|
<ClCompile Include="RefManager.cpp" />
|
||||||
|
<ClCompile Include="StaticObject.cpp" />
|
||||||
|
<ClCompile Include="TestGLMain.cpp" />
|
||||||
|
<ClCompile Include="Weapon.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
|
|
@ -14,4 +14,65 @@
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Game.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Level.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Object.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Player.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="IGame.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="StaticObject.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Weapon.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DynamicObject.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="RefManager.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Game.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Level.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Object.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Player.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="IGame.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="StaticObject.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Weapon.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DynamicObject.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="RefManager.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="TestGLMain.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -0,0 +1,15 @@
|
||||||
|
#include "GameMode.h"
|
||||||
|
|
||||||
|
using namespace GameLogic;
|
||||||
|
|
||||||
|
|
||||||
|
GameMode::GameMode(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GameMode::~GameMode(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
//Created by Erik and Linda of the GameLogic team
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GAMEMODE_H
|
||||||
|
#define GAMEMODE_H
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
class GameMode
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GameMode(void);
|
||||||
|
~GameMode(void);
|
||||||
|
private:
|
||||||
|
//variabels that control what game rules the level runs on
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,45 @@
|
||||||
|
#include "IGame.h"
|
||||||
|
#include "Game.h"
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
BOOL WINAPI DllMain(
|
||||||
|
_In_ HINSTANCE hinstDLL,
|
||||||
|
_In_ DWORD fdwReason,
|
||||||
|
_In_ LPVOID lpvReserved
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
using namespace GameLogic;
|
||||||
|
IGame::IGame()
|
||||||
|
{
|
||||||
|
gameModule = new Game();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IGame::~IGame()
|
||||||
|
{
|
||||||
|
delete gameModule;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IGame::Init()
|
||||||
|
{
|
||||||
|
gameModule->Init();
|
||||||
|
}
|
||||||
|
void IGame::StartGame()
|
||||||
|
{
|
||||||
|
gameModule->StartGame();
|
||||||
|
}
|
||||||
|
void IGame::Update(keyInput keyPressed)
|
||||||
|
{
|
||||||
|
gameModule->Update(keyPressed);
|
||||||
|
}
|
||||||
|
void IGame::Render()
|
||||||
|
{
|
||||||
|
gameModule->Render();
|
||||||
|
}
|
||||||
|
Game* IGame::getGameModule()
|
||||||
|
{
|
||||||
|
return gameModule;
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
//Created by Erik and Linda of the GameLogic team
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef IGAME_H
|
||||||
|
#define IGAME_H
|
||||||
|
|
||||||
|
#if defined GAME_DLL_EXPORT
|
||||||
|
#define GAME_DLL_USAGE __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define GAME_DLL_USAGE __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
class Game;
|
||||||
|
|
||||||
|
enum keyInput
|
||||||
|
{
|
||||||
|
keyInput_W,
|
||||||
|
keyInput_A,
|
||||||
|
keyInput_S,
|
||||||
|
keyInput_D,
|
||||||
|
keyInput_none
|
||||||
|
};
|
||||||
|
|
||||||
|
class GAME_DLL_USAGE IGame
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
Game* gameModule;
|
||||||
|
public:
|
||||||
|
IGame();
|
||||||
|
~IGame();
|
||||||
|
|
||||||
|
|
||||||
|
void Init();
|
||||||
|
void StartGame();
|
||||||
|
/************************************************************************/
|
||||||
|
/* Get key input to update the player */
|
||||||
|
/************************************************************************/
|
||||||
|
void Update(keyInput keyPressed);
|
||||||
|
void Render();
|
||||||
|
Game* getGameModule();
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include "Level.h"
|
||||||
|
|
||||||
|
using namespace GameLogic;
|
||||||
|
|
||||||
|
Level::Level(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Level::~Level(void)
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
//Created by Erik and Linda of the GameLogic team
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef LEVEL_H
|
||||||
|
#define LEVEL_H
|
||||||
|
|
||||||
|
#include "StaticObject.h"
|
||||||
|
#include "DynamicObject.h"
|
||||||
|
#include "GameMode.h"
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
class Level
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
Level(void);
|
||||||
|
~Level(void);
|
||||||
|
|
||||||
|
private:
|
||||||
|
StaticObject** staticObjects;
|
||||||
|
int nrOfStaticObjects;
|
||||||
|
|
||||||
|
DynamicObject** dynamicObjects;
|
||||||
|
int nrOfDynamicObjects;
|
||||||
|
|
||||||
|
GameMode* gameMode;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,52 @@
|
||||||
|
#include "Object.h"
|
||||||
|
#include "OysterMath.h"
|
||||||
|
#include "DllInterfaces\GFXAPI.h"
|
||||||
|
#include "CollisionManager.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace GameLogic;
|
||||||
|
|
||||||
|
using namespace Oyster::Math;
|
||||||
|
using namespace Oyster::Graphics::Model;
|
||||||
|
|
||||||
|
using namespace Utility::DynamicMemory;
|
||||||
|
using namespace Oyster::Physics;
|
||||||
|
|
||||||
|
Object::Object(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
model = new Model();
|
||||||
|
model = Oyster::Graphics::API::CreateModel(L"bth.obj");
|
||||||
|
|
||||||
|
ICustomBody* temp = rigidBody = API::Instance().CreateSimpleRigidBody().Release();
|
||||||
|
|
||||||
|
rigidBody->SetCenter(Float3(50,0,0));
|
||||||
|
rigidBody->SetMass_KeepMomentum(30);
|
||||||
|
rigidBody->SetSize(Float3(2,2,2));
|
||||||
|
rigidBody->SetSubscription(true);
|
||||||
|
rigidBody->SetMomentOfInertiaTensor_KeepMomentum(Float4x4(MomentOfInertia::CreateCuboidMatrix(30, 2, 2, 2)));
|
||||||
|
|
||||||
|
|
||||||
|
GameLogic::RefManager::getInstance()->AddMapping(*rigidBody, *this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Object::~Object(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
Oyster::Graphics::API::DeleteModel(model);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::Render()
|
||||||
|
{
|
||||||
|
this->rigidBody->GetOrientation(model->WorldMatrix);
|
||||||
|
Oyster::Graphics::API::RenderScene(model, 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Object::OBJECT_TYPE Object::GetType()
|
||||||
|
{
|
||||||
|
return this->type;
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
//Created by Erik and Linda of the GameLogic team
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef OBJECT_H
|
||||||
|
#define OBJECT_H
|
||||||
|
|
||||||
|
#include "PhysicsAPI.h"
|
||||||
|
#include "DllInterfaces/GFXAPI.h"
|
||||||
|
|
||||||
|
#include "Model/Model.h"
|
||||||
|
#include "Utilities.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
class Object
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Object(void);
|
||||||
|
virtual ~Object(void);
|
||||||
|
|
||||||
|
enum OBJECT_TYPE
|
||||||
|
{
|
||||||
|
OBJECT_TYPE_PLAYER,
|
||||||
|
OBJECT_TYPE_BOX,
|
||||||
|
};
|
||||||
|
|
||||||
|
void Render();
|
||||||
|
|
||||||
|
OBJECT_TYPE GetType();
|
||||||
|
|
||||||
|
private:
|
||||||
|
OBJECT_TYPE type;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//either a model pointer or an ID to an arraypos filled with models that are to be rendered
|
||||||
|
//rigidBody
|
||||||
|
|
||||||
|
Oyster::Physics::ICustomBody *rigidBody;
|
||||||
|
Oyster::Graphics::Model::Model *model;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,56 @@
|
||||||
|
#include "Player.h"
|
||||||
|
#include "OysterMath.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace GameLogic;
|
||||||
|
using namespace Oyster::Physics;
|
||||||
|
using namespace Utility::DynamicMemory;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Player::Player(void)
|
||||||
|
:Object()
|
||||||
|
{
|
||||||
|
life = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Player::~Player(void)
|
||||||
|
{
|
||||||
|
delete this->rigidBody;
|
||||||
|
}
|
||||||
|
void Player::Update(keyInput keyPressed)
|
||||||
|
{
|
||||||
|
if(keyPressed != keyInput_none)
|
||||||
|
{
|
||||||
|
Move();
|
||||||
|
|
||||||
|
if(keyPressed == keyInput_A)
|
||||||
|
{
|
||||||
|
Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
|
||||||
|
pos.x -= 0.1;
|
||||||
|
rigidBody->SetCenter(pos);
|
||||||
|
}
|
||||||
|
if(keyPressed == keyInput_D)
|
||||||
|
{
|
||||||
|
Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
|
||||||
|
pos.x += 0.1;
|
||||||
|
rigidBody->SetCenter(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::Move()
|
||||||
|
{
|
||||||
|
//API::Instance().Update();
|
||||||
|
/*Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
|
||||||
|
pos.x += 0.1;
|
||||||
|
rigidBody->SetCenter(pos);*/
|
||||||
|
//API::Instance().SetCenter(rigidBody, pos);
|
||||||
|
}
|
||||||
|
void Player::Shoot()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
//Created by Erik and Linda of the GameLogic team
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef PLAYER_H
|
||||||
|
#define PLAYER_H
|
||||||
|
|
||||||
|
#include "Object.h"
|
||||||
|
#include "Weapon.h"
|
||||||
|
#include "IGame.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
class Player : public Object
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
Player(void);
|
||||||
|
~Player(void);
|
||||||
|
|
||||||
|
void Update(keyInput keyPressed);
|
||||||
|
|
||||||
|
void Move();
|
||||||
|
void Shoot();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
int life;
|
||||||
|
Weapon *weapon;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,47 @@
|
||||||
|
#include "RefManager.h"
|
||||||
|
|
||||||
|
using namespace GameLogic;
|
||||||
|
|
||||||
|
typedef std::pair<Oyster::Physics::ICustomBody*, Object*> mapData;
|
||||||
|
|
||||||
|
RefManager* RefManager::instance = 0;
|
||||||
|
|
||||||
|
RefManager::RefManager(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RefManager::~RefManager(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void RefManager::Release()
|
||||||
|
{
|
||||||
|
if (instance)
|
||||||
|
{
|
||||||
|
delete instance;
|
||||||
|
instance = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
RefManager* RefManager::getInstance( )
|
||||||
|
{
|
||||||
|
if (!instance)
|
||||||
|
{
|
||||||
|
instance = new RefManager();
|
||||||
|
};
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object* RefManager::GetMap(Oyster::Physics::ICustomBody &body)
|
||||||
|
{
|
||||||
|
return mapper[&body];
|
||||||
|
}
|
||||||
|
|
||||||
|
void RefManager::AddMapping(Oyster::Physics::ICustomBody &body, Object &obj)
|
||||||
|
{
|
||||||
|
mapper.insert(mapData(&body,&obj));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
//Created by Erik and Linda of the GameLogic team
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef REFMANAGER_H
|
||||||
|
#define REFMANAGER_H
|
||||||
|
|
||||||
|
#include<map>
|
||||||
|
#include "Object.h"
|
||||||
|
#include "PhysicsAPI.h"
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
class RefManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RefManager(void);
|
||||||
|
~RefManager(void);
|
||||||
|
|
||||||
|
static RefManager* getInstance( );
|
||||||
|
void Release();
|
||||||
|
|
||||||
|
|
||||||
|
Object* GetMap(Oyster::Physics::ICustomBody &body); //returns the object of an rigidBody, mainly used for CollisionHandler
|
||||||
|
void AddMapping(Oyster::Physics::ICustomBody &body, Object &obj); //adds a mapping with body as key and the object as a value
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
static RefManager* instance;
|
||||||
|
std::map<Oyster::Physics::ICustomBody*,Object*> mapper; //mapper points a rigidBody to an actual game object
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include "StaticObject.h"
|
||||||
|
|
||||||
|
using namespace GameLogic;
|
||||||
|
|
||||||
|
StaticObject::StaticObject(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
StaticObject::~StaticObject(void)
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
//Created by Erik and Linda of the GameLogic team
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef STATICOBJECT_H
|
||||||
|
#define STATICOBJECT_H
|
||||||
|
|
||||||
|
#include "Object.h"
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
class StaticObject : public Object
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
StaticObject(void);
|
||||||
|
~StaticObject(void);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,337 @@
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// File: TemplateMain.cpp
|
||||||
|
//
|
||||||
|
// BTH-D3D-Template
|
||||||
|
//
|
||||||
|
// Copyright (c) Stefan Petersson 2011. All rights reserved.
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
#define NOMINMAX
|
||||||
|
#include <Windows.h>
|
||||||
|
#include "Core/Core.h"
|
||||||
|
#include "DllInterfaces/GFXAPI.h"
|
||||||
|
#include "IGame.h"
|
||||||
|
|
||||||
|
#include "L_inputClass.h"
|
||||||
|
|
||||||
|
// debug window include
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <io.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Global Variables
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
HINSTANCE g_hInst = NULL;
|
||||||
|
HWND g_hWnd = NULL;
|
||||||
|
|
||||||
|
GameLogic::IGame* game;
|
||||||
|
InputClass* inputObj;
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Forward declarations
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow );
|
||||||
|
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
|
HRESULT Render(float deltaTime);
|
||||||
|
HRESULT Update(float deltaTime);
|
||||||
|
HRESULT InitDirect3D();
|
||||||
|
HRESULT InitGame();
|
||||||
|
HRESULT CleanUp();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Entry point to the program. Initializes everything and goes into a message processing
|
||||||
|
// loop. Idle time is used to render the scene.
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void SetStdOutToNewConsole()
|
||||||
|
{
|
||||||
|
// allocate a console for this app
|
||||||
|
AllocConsole();
|
||||||
|
|
||||||
|
// redirect unbuffered STDOUT to the console
|
||||||
|
HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
int fileDescriptor = _open_osfhandle((intptr_t)consoleHandle, _O_TEXT);
|
||||||
|
FILE *fp = _fdopen( fileDescriptor, "w" );
|
||||||
|
*stdout = *fp;
|
||||||
|
setvbuf( stdout, NULL, _IONBF, 0 );
|
||||||
|
|
||||||
|
// give the console window a nicer title
|
||||||
|
|
||||||
|
SetConsoleTitle(L"Debug Output");
|
||||||
|
|
||||||
|
// give the console window a bigger buffer size
|
||||||
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
if ( GetConsoleScreenBufferInfo(consoleHandle, &csbi) )
|
||||||
|
{
|
||||||
|
COORD bufferSize;
|
||||||
|
bufferSize.X = csbi.dwSize.X;
|
||||||
|
bufferSize.Y = 50;
|
||||||
|
SetConsoleScreenBufferSize(consoleHandle, bufferSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow )
|
||||||
|
{
|
||||||
|
if( FAILED( InitWindow( hInstance, nCmdShow ) ) )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if( FAILED( InitDirect3D() ) )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if( FAILED( InitGame() ) )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
__int64 cntsPerSec = 0;
|
||||||
|
QueryPerformanceFrequency((LARGE_INTEGER*)&cntsPerSec);
|
||||||
|
float secsPerCnt = 1.0f / (float)cntsPerSec;
|
||||||
|
|
||||||
|
__int64 prevTimeStamp = 0;
|
||||||
|
QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);
|
||||||
|
|
||||||
|
//debugwindow
|
||||||
|
//SetStdOutToNewConsole();
|
||||||
|
// Main message loop
|
||||||
|
MSG msg = {0};
|
||||||
|
while(WM_QUIT != msg.message)
|
||||||
|
{
|
||||||
|
if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE) )
|
||||||
|
{
|
||||||
|
TranslateMessage( &msg );
|
||||||
|
DispatchMessage( &msg );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
__int64 currTimeStamp = 0;
|
||||||
|
QueryPerformanceCounter((LARGE_INTEGER*)&currTimeStamp);
|
||||||
|
float dt = (currTimeStamp - prevTimeStamp) * secsPerCnt;
|
||||||
|
|
||||||
|
//render
|
||||||
|
Update(dt);
|
||||||
|
Render(dt);
|
||||||
|
|
||||||
|
prevTimeStamp = currTimeStamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CleanUp();
|
||||||
|
return (int) msg.wParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Register class and create window
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow )
|
||||||
|
{
|
||||||
|
// Register class
|
||||||
|
WNDCLASSEX wcex;
|
||||||
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||||
|
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
|
wcex.lpfnWndProc = WndProc;
|
||||||
|
wcex.cbClsExtra = 0;
|
||||||
|
wcex.cbWndExtra = 0;
|
||||||
|
wcex.hInstance = hInstance;
|
||||||
|
wcex.hIcon = 0;
|
||||||
|
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
|
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
||||||
|
wcex.lpszMenuName = NULL;
|
||||||
|
wcex.lpszClassName = L"BTH_D3D_Template";
|
||||||
|
wcex.hIconSm = 0;
|
||||||
|
if( !RegisterClassEx(&wcex) )
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
// Adjust and create window
|
||||||
|
g_hInst = hInstance;
|
||||||
|
RECT rc = { 0, 0, 1024, 768 };
|
||||||
|
AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE );
|
||||||
|
|
||||||
|
if(!(g_hWnd = CreateWindow(
|
||||||
|
L"BTH_D3D_Template",
|
||||||
|
L"BTH - Direct3D 11.0 Template",
|
||||||
|
WS_OVERLAPPEDWINDOW,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
rc.right - rc.left,
|
||||||
|
rc.bottom - rc.top,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
hInstance,
|
||||||
|
NULL)))
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowWindow( g_hWnd, nCmdShow );
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Create Direct3D device and swap chain
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
HRESULT InitDirect3D()
|
||||||
|
{
|
||||||
|
/*HRESULT hr = S_OK;;
|
||||||
|
|
||||||
|
Oyster::Graphics::Core::resolution = Oyster::Math::Float2( 1024, 768 );
|
||||||
|
|
||||||
|
if(Oyster::Graphics::Core::Init::FullInit(g_hWnd,false,false)==Oyster::Graphics::Core::Init::Fail)
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::wstring ShaderPath = L"..\\OysterGraphics\\Shader\\HLSL\\";
|
||||||
|
std::wstring EffectPath = L"SimpleDebug\\";
|
||||||
|
|
||||||
|
Oyster::Graphics::Core::ShaderManager::Init(ShaderPath + EffectPath + L"DebugPixel.hlsl",Oyster::Graphics::Core::ShaderManager::ShaderType::Pixel,L"Debug",false);
|
||||||
|
Oyster::Graphics::Core::ShaderManager::Init(ShaderPath + EffectPath + L"DebugVertex.hlsl",Oyster::Graphics::Core::ShaderManager::ShaderType::Vertex,L"PassThroughFloat4",false);
|
||||||
|
|
||||||
|
Oyster::Graphics::Core::ShaderManager::Set::Vertex(Oyster::Graphics::Core::ShaderManager::Get::Vertex(L"PassThroughFloat4"));
|
||||||
|
Oyster::Graphics::Core::ShaderManager::Set::Pixel(Oyster::Graphics::Core::ShaderManager::Get::Pixel(L"Debug"));
|
||||||
|
|
||||||
|
D3D11_INPUT_ELEMENT_DESC inputDesc[] =
|
||||||
|
{
|
||||||
|
{ "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
ID3D11InputLayout* layout;
|
||||||
|
|
||||||
|
Oyster::Graphics::Core::ShaderManager::CreateInputLayout( inputDesc, 1, Oyster::Graphics::Core::ShaderManager::Get::Vertex(L"PassThroughFloat4"), layout);
|
||||||
|
|
||||||
|
Oyster::Graphics::Core::deviceContext->IASetInputLayout(layout);
|
||||||
|
Oyster::Graphics::Core::deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||||
|
|
||||||
|
Oyster::Graphics::Render::Preparations::Basic::BindBackBufferRTV();
|
||||||
|
|
||||||
|
Oyster::Graphics::Render::Preparations::Basic::SetViewPort();*/
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT InitGame()
|
||||||
|
{
|
||||||
|
|
||||||
|
if(Oyster::Graphics::API::Init(g_hWnd, false, false, Oyster::Math::Float2( 1024, 768)) != Oyster::Graphics::API::Sucsess)
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
inputObj = new InputClass;
|
||||||
|
if(!inputObj->Initialize(g_hInst, g_hWnd, 1024, 768))
|
||||||
|
{
|
||||||
|
MessageBox(0, L"Could not initialize the input object.", L"Error", MB_OK);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
game = new GameLogic::IGame();
|
||||||
|
game->Init();
|
||||||
|
game->StartGame();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
HRESULT Update(float deltaTime)
|
||||||
|
{
|
||||||
|
inputObj->Update();
|
||||||
|
GameLogic::keyInput key = GameLogic::keyInput_none;
|
||||||
|
|
||||||
|
if(inputObj->IsKeyPressed(DIK_W))
|
||||||
|
{
|
||||||
|
key = GameLogic::keyInput_W;
|
||||||
|
}
|
||||||
|
else if(inputObj->IsKeyPressed(DIK_A))
|
||||||
|
{
|
||||||
|
key = GameLogic::keyInput_A;
|
||||||
|
}
|
||||||
|
else if(inputObj->IsKeyPressed(DIK_S))
|
||||||
|
{
|
||||||
|
key = GameLogic::keyInput_S;
|
||||||
|
}
|
||||||
|
else if(inputObj->IsKeyPressed(DIK_D))
|
||||||
|
{
|
||||||
|
key = GameLogic::keyInput_D;
|
||||||
|
}
|
||||||
|
|
||||||
|
game->Update(key);
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT Render(float deltaTime)
|
||||||
|
{
|
||||||
|
int isPressed = 0;
|
||||||
|
if(inputObj->IsKeyPressed(DIK_A))
|
||||||
|
{
|
||||||
|
isPressed = 1;
|
||||||
|
//std::cout<<"test";
|
||||||
|
}
|
||||||
|
|
||||||
|
// test view and projection matrix
|
||||||
|
Oyster::Math::Float3 dir = Oyster::Math::Float3(0,0,-1);
|
||||||
|
Oyster::Math::Float3 up =Oyster::Math::Float3(0,1,0);
|
||||||
|
Oyster::Math::Float3 pos = Oyster::Math::Float3(0, 0, 100);
|
||||||
|
|
||||||
|
Oyster::Math::Float4x4 view =Oyster::Math3D::OrientationMatrix_LookAtDirection(dir, up, pos);
|
||||||
|
view = view.GetInverse();
|
||||||
|
|
||||||
|
Oyster::Math::Float4x4 proj = Oyster::Math3D::ProjectionMatrix_Perspective(PI/2, 1024/768, 1, 1000);
|
||||||
|
|
||||||
|
Oyster::Graphics::API::NewFrame(view, proj);
|
||||||
|
|
||||||
|
game->Render();
|
||||||
|
wchar_t title[255];
|
||||||
|
swprintf(title, sizeof(title), L"| Pressing A: %d | \n", (int)(isPressed));
|
||||||
|
SetWindowText(g_hWnd, title);
|
||||||
|
|
||||||
|
Oyster::Graphics::API::EndFrame();
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT CleanUp()
|
||||||
|
{
|
||||||
|
|
||||||
|
SAFE_DELETE(game);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Called every time the application receives a message
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
|
||||||
|
{
|
||||||
|
PAINTSTRUCT ps;
|
||||||
|
HDC hdc;
|
||||||
|
|
||||||
|
switch (message)
|
||||||
|
{
|
||||||
|
case WM_PAINT:
|
||||||
|
hdc = BeginPaint(hWnd, &ps);
|
||||||
|
EndPaint(hWnd, &ps);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_DESTROY:
|
||||||
|
PostQuitMessage(0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_KEYDOWN:
|
||||||
|
|
||||||
|
switch(wParam)
|
||||||
|
{
|
||||||
|
case VK_ESCAPE:
|
||||||
|
PostQuitMessage(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include "Weapon.h"
|
||||||
|
|
||||||
|
using namespace GameLogic;
|
||||||
|
|
||||||
|
Weapon::Weapon(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Weapon::~Weapon(void)
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
//Created by Erik and Linda of the GameLogic team
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef WEAPON_H
|
||||||
|
#define WEAPON_H
|
||||||
|
|
||||||
|
#include "Object.h"
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
class Weapon : public Object
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
Weapon(void);
|
||||||
|
~Weapon(void);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -18,13 +18,19 @@
|
||||||
<Platform>x64</Platform>
|
<Platform>x64</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="L_inputClass.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="L_inputClass.h" />
|
||||||
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{7E3990D2-3D94-465C-B58D-64A74B3ECF9B}</ProjectGuid>
|
<ProjectGuid>{7E3990D2-3D94-465C-B58D-64A74B3ECF9B}</ProjectGuid>
|
||||||
<RootNamespace>Input</RootNamespace>
|
<RootNamespace>Input</RootNamespace>
|
||||||
</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|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
|
|
@ -14,4 +14,14 @@
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="L_inputClass.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="L_inputClass.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -0,0 +1,203 @@
|
||||||
|
#include "L_inputclass.h"
|
||||||
|
|
||||||
|
InputClass::InputClass()
|
||||||
|
{
|
||||||
|
m_directInput = NULL;
|
||||||
|
m_keyboard = NULL;
|
||||||
|
m_mouse = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
InputClass::~InputClass()
|
||||||
|
{
|
||||||
|
// Release the mouse.
|
||||||
|
if(m_mouse)
|
||||||
|
{
|
||||||
|
(m_mouse)->Unacquire();
|
||||||
|
(m_mouse)->Release();
|
||||||
|
(m_mouse) = NULL;
|
||||||
|
}
|
||||||
|
//SAFE_UNACQUIRE(m_mouse);
|
||||||
|
|
||||||
|
// Release the keyboard.
|
||||||
|
if(m_keyboard)
|
||||||
|
{
|
||||||
|
(m_keyboard)->Unacquire();
|
||||||
|
(m_keyboard)->Release();
|
||||||
|
(m_keyboard) = NULL;
|
||||||
|
}
|
||||||
|
//SAFE_UNACQUIRE(m_keyboard);
|
||||||
|
|
||||||
|
// Release the main interface to direct input.
|
||||||
|
if( m_directInput )
|
||||||
|
{
|
||||||
|
(m_directInput)->Release();
|
||||||
|
(m_directInput) = NULL;
|
||||||
|
}
|
||||||
|
//SAFE_RELEASE(m_directInput);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InputClass::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, int screenHeight)
|
||||||
|
{
|
||||||
|
HRESULT result;
|
||||||
|
|
||||||
|
// Initialize the main direct input interface.
|
||||||
|
result = DirectInput8Create(hinstance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&m_directInput, NULL);
|
||||||
|
if(FAILED(result))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize the direct input interface for the keyboard.
|
||||||
|
result = m_directInput->CreateDevice(GUID_SysKeyboard, &m_keyboard, NULL);
|
||||||
|
if(FAILED(result))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the cooperative level of the keyboard to not share with other programs.
|
||||||
|
result = m_keyboard->SetCooperativeLevel(hwnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);
|
||||||
|
if(FAILED(result))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Set the data format. In this case since it is a keyboard we can use the predefined data format.
|
||||||
|
result = m_keyboard->SetDataFormat(&c_dfDIKeyboard);
|
||||||
|
if(FAILED(result))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now acquire the keyboard.
|
||||||
|
result = m_keyboard->Acquire();
|
||||||
|
if(FAILED(result))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize the direct input interface for the mouse.
|
||||||
|
result = m_directInput->CreateDevice(GUID_SysMouse, &m_mouse, NULL);
|
||||||
|
if(FAILED(result))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the data format for the mouse using the pre-defined mouse data format.
|
||||||
|
result = m_mouse->SetDataFormat(&c_dfDIMouse);
|
||||||
|
if(FAILED(result))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the cooperative level of the mouse to share with other programs.
|
||||||
|
result = m_mouse->SetCooperativeLevel(hwnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);
|
||||||
|
if(FAILED(result))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Acquire the mouse.
|
||||||
|
result = m_mouse->Acquire();
|
||||||
|
if(FAILED(result))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InputClass::Update()
|
||||||
|
{
|
||||||
|
bool result;
|
||||||
|
|
||||||
|
//Read the current state of the keyboard.
|
||||||
|
result = ReadKeyboard();
|
||||||
|
if(!result)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read the current state of the mouse.
|
||||||
|
result = ReadMouse();
|
||||||
|
if(!result)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InputClass::ReadKeyboard()
|
||||||
|
{
|
||||||
|
HRESULT result;
|
||||||
|
|
||||||
|
// Read the keyboard device.
|
||||||
|
result = m_keyboard->GetDeviceState(sizeof(m_keyboardState), (LPVOID)&m_keyboardState);
|
||||||
|
if(FAILED(result))
|
||||||
|
{
|
||||||
|
// If the keyboard lost focus or was not acquired then try to get control back.
|
||||||
|
if((result == DIERR_INPUTLOST) || (result == DIERR_NOTACQUIRED))
|
||||||
|
{
|
||||||
|
m_keyboard->Acquire();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InputClass::ReadMouse()
|
||||||
|
{
|
||||||
|
HRESULT result;
|
||||||
|
|
||||||
|
// Read the mouse device.
|
||||||
|
result = m_mouse->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&m_mouseState);
|
||||||
|
if(FAILED(result))
|
||||||
|
{
|
||||||
|
// If the mouse lost focus or was not acquired then try to get control back.
|
||||||
|
if((result == DIERR_INPUTLOST) || (result == DIERR_NOTACQUIRED))
|
||||||
|
{
|
||||||
|
m_mouse->Acquire();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputClass::MouseMove(float &Pitch, float &RotateY )
|
||||||
|
{
|
||||||
|
//if left mouse button is pressed
|
||||||
|
if (m_mouseState.rgbButtons[0])
|
||||||
|
{
|
||||||
|
float dx = (static_cast<float>( m_mouseState.lX)/150);
|
||||||
|
float dy = (static_cast<float>( m_mouseState.lY)/150);
|
||||||
|
|
||||||
|
//
|
||||||
|
Pitch=dy;
|
||||||
|
RotateY=dx;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool InputClass::IsMousePressed()
|
||||||
|
{
|
||||||
|
if (m_mouseState.rgbButtons[0])
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool InputClass::IsKeyPressed(int key)
|
||||||
|
{
|
||||||
|
if( m_keyboardState[key] & 0x80 )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
#ifndef _INPUTCLASS_H_
|
||||||
|
#define _INPUTCLASS_H_
|
||||||
|
|
||||||
|
|
||||||
|
#define DIRECTINPUT_VERSION 0x0800
|
||||||
|
|
||||||
|
#pragma comment(lib, "dinput8.lib")
|
||||||
|
#pragma comment(lib, "dxguid.lib")
|
||||||
|
|
||||||
|
#include <dinput.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class InputClass
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
IDirectInput8* m_directInput;
|
||||||
|
IDirectInputDevice8* m_keyboard;
|
||||||
|
IDirectInputDevice8* m_mouse;
|
||||||
|
|
||||||
|
unsigned char m_keyboardState[256];
|
||||||
|
DIMOUSESTATE m_mouseState;
|
||||||
|
|
||||||
|
bool ReadKeyboard();
|
||||||
|
bool ReadMouse();
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
InputClass();
|
||||||
|
~InputClass();
|
||||||
|
|
||||||
|
// Initialize DirectInput8Create and acquire the mouse and keyboard
|
||||||
|
bool Initialize(HINSTANCE, HWND, int, int);
|
||||||
|
|
||||||
|
//read the mouse and keyboard and send back
|
||||||
|
// delta mouse pos and if any button is pressed
|
||||||
|
bool Update();
|
||||||
|
|
||||||
|
bool IsKeyPressed(int key);
|
||||||
|
bool IsMousePressed();
|
||||||
|
void MouseMove(float &Pitch, float &RoateY);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -69,21 +69,29 @@
|
||||||
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
|
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
|
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
|
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
|
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
|
@ -138,10 +146,16 @@
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Resource\Loaders\ByteLoader.cpp" />
|
||||||
|
<ClCompile Include="Resource\Loaders\CustomLoader.cpp" />
|
||||||
|
<ClCompile Include="Resource\OResourceHandler.cpp" />
|
||||||
|
<ClCompile Include="Resource\OResource.cpp" />
|
||||||
<ClCompile Include="Utilities.cpp" />
|
<ClCompile Include="Utilities.cpp" />
|
||||||
<ClCompile Include="WinTimer.cpp" />
|
<ClCompile Include="WinTimer.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Resource\OysterResource.h" />
|
||||||
|
<ClInclude Include="Resource\OResource.h" />
|
||||||
<ClInclude Include="Utilities-InlineImpl.h" />
|
<ClInclude Include="Utilities-InlineImpl.h" />
|
||||||
<ClInclude Include="Utilities.h" />
|
<ClInclude Include="Utilities.h" />
|
||||||
<ClInclude Include="WinTimer.h" />
|
<ClInclude Include="WinTimer.h" />
|
||||||
|
|
|
@ -21,6 +21,18 @@
|
||||||
<ClCompile Include="WinTimer.cpp">
|
<ClCompile Include="WinTimer.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Resource\OResource.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Resource\OResourceHandler.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Resource\Loaders\ByteLoader.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Resource\Loaders\CustomLoader.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Utilities.h">
|
<ClInclude Include="Utilities.h">
|
||||||
|
@ -32,5 +44,11 @@
|
||||||
<ClInclude Include="Utilities-InlineImpl.h">
|
<ClInclude Include="Utilities-InlineImpl.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Resource\OysterResource.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Resource\OResource.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -0,0 +1,173 @@
|
||||||
|
|
||||||
|
#include "..\OResource.h"
|
||||||
|
#include "..\..\Utilities.h"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
using namespace Oyster::Resource;
|
||||||
|
bool readANSI = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool ReadFromFile(const wchar_t fileName[], const wchar_t openFlag[], std::wstring& outData, size_t elemSize)
|
||||||
|
{
|
||||||
|
size_t bytesTotal = 0;
|
||||||
|
size_t bytesRead = 0;
|
||||||
|
FILE *stream;
|
||||||
|
|
||||||
|
if( _wfopen_s( &stream, fileName, openFlag ) == 0 )
|
||||||
|
{
|
||||||
|
//Get size of the file
|
||||||
|
fseek(stream, 0L, SEEK_END);
|
||||||
|
bytesTotal = ftell(stream);
|
||||||
|
fseek(stream, 0L, SEEK_SET);
|
||||||
|
|
||||||
|
//Sanity check
|
||||||
|
if(bytesTotal == 0) return false;
|
||||||
|
|
||||||
|
//Create the new byte buffer
|
||||||
|
wchar_t *buff = new wchar_t[bytesTotal + 1];
|
||||||
|
|
||||||
|
//Read the bytes to the end
|
||||||
|
bytesRead = fread_s( buff, bytesTotal, elemSize, bytesTotal ,stream );
|
||||||
|
fclose( stream );
|
||||||
|
|
||||||
|
//Did we read enough bytes
|
||||||
|
if(!readANSI && bytesRead != bytesTotal) return false;
|
||||||
|
|
||||||
|
//Add delimiter
|
||||||
|
buff[bytesRead] = L'\0';
|
||||||
|
|
||||||
|
outData.resize(bytesTotal);
|
||||||
|
outData = buff;
|
||||||
|
|
||||||
|
delete [] buff;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::wstring msg = L"Failed to open file: \n";
|
||||||
|
msg.append(fileName);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool ReadFromFile(const wchar_t fileName[], const char openFlag[], std::string& outData, size_t elemSize)
|
||||||
|
{
|
||||||
|
std::string sFilename;
|
||||||
|
std::wstring wsFile = fileName;
|
||||||
|
::Utility::String::WStringToString(wsFile, sFilename);
|
||||||
|
size_t bytesTotal = 0;
|
||||||
|
size_t bytesRead = 0;
|
||||||
|
FILE *stream;
|
||||||
|
|
||||||
|
if( fopen_s( &stream, sFilename.c_str(), openFlag ) == 0 )
|
||||||
|
{
|
||||||
|
//Get size of the file
|
||||||
|
fseek(stream, 0L, SEEK_END);
|
||||||
|
bytesTotal = ftell(stream);
|
||||||
|
fseek(stream, 0L, SEEK_SET);
|
||||||
|
fflush(stream);
|
||||||
|
|
||||||
|
//Sanity check
|
||||||
|
if(bytesTotal == 0) return false;
|
||||||
|
|
||||||
|
//Create the new byte buffer
|
||||||
|
char *buff = new char[bytesTotal + 1];
|
||||||
|
|
||||||
|
//Read the bytes to the end
|
||||||
|
bytesRead = fread_s( buff, bytesTotal, elemSize, bytesTotal ,stream );
|
||||||
|
fclose( stream );
|
||||||
|
|
||||||
|
//Did we read enough bytes (Get the bytes if we read with ANSI since the hidden characters is ignored)
|
||||||
|
if(!readANSI && bytesRead != bytesTotal) return false;
|
||||||
|
|
||||||
|
buff[bytesRead + 1];
|
||||||
|
|
||||||
|
outData.clear();
|
||||||
|
outData.resize(bytesRead);
|
||||||
|
memcpy(&outData[0], &buff[0], bytesRead);
|
||||||
|
|
||||||
|
delete [] buff;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string msg = "Failed to open file: \n";
|
||||||
|
msg.append(sFilename.c_str());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
OResource* OResource::ByteLoader(const wchar_t filename[], ResourceType type, OResource* old)
|
||||||
|
{
|
||||||
|
OResource *resource = old;
|
||||||
|
std::wstring wOut;
|
||||||
|
std::string sOut;
|
||||||
|
bool success = false;
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case Oyster::Resource::ResourceType_Byte_Raw:
|
||||||
|
success = ReadFromFile(filename, "rb", sOut, sizeof(char));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Oyster::Resource::ResourceType_Byte_ANSI:
|
||||||
|
readANSI = true;
|
||||||
|
success = ReadFromFile(filename, "r", sOut, sizeof(char));
|
||||||
|
readANSI = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Oyster::Resource::ResourceType_Byte_UTF8:
|
||||||
|
success = ReadFromFile(filename, "r, ccs=UTF-8", sOut, sizeof(char));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Oyster::Resource::ResourceType_Byte_UNICODE:
|
||||||
|
success = ReadFromFile(filename, "r, ccs=UNICODE", sOut, sizeof(char));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Oyster::Resource::ResourceType_Byte_UTF16LE:
|
||||||
|
success = ReadFromFile(filename, "r, ccs=UTF-16LE", sOut, sizeof(char));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!success) return 0;
|
||||||
|
if(wOut.size())
|
||||||
|
{
|
||||||
|
//const wchar_t *data = new wchar_t[wOut.size()];
|
||||||
|
//resource = new OResource((void*)data, type, (sizeof(wchar_t) * wOut.size()), sizeof(wchar_t), filename);
|
||||||
|
}
|
||||||
|
else if(sOut.size())
|
||||||
|
{
|
||||||
|
char *data = new char[sOut.size()+1];
|
||||||
|
data[sOut.size()] = '\0';
|
||||||
|
memcpy(&data[0], &sOut[0], sOut.size());
|
||||||
|
|
||||||
|
if(!old)
|
||||||
|
{
|
||||||
|
resource = new OResource((OHRESOURCE)data, type, (sizeof(char) * sOut.size()), sizeof(char), filename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
old->resourceData = (OHRESOURCE)data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OResource::ByteUnloader()
|
||||||
|
{
|
||||||
|
delete [] ((char*)this->resourceData);
|
||||||
|
this->resourceData = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
OResource* OResource::ByteReloader()
|
||||||
|
{
|
||||||
|
ByteUnloader();
|
||||||
|
return ByteLoader(this->resourceFilename.c_str(), this->resourceType, this);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
|
||||||
|
#include "..\OResource.h"
|
||||||
|
#include "..\..\Utilities.h"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
using namespace Oyster::Resource;
|
||||||
|
|
||||||
|
|
||||||
|
OResource* OResource::CustomLoader(const wchar_t filename[], CustomLoadFunction fnc)
|
||||||
|
{
|
||||||
|
const CustomData &data = fnc();
|
||||||
|
|
||||||
|
if(!data.loadedData) return 0;
|
||||||
|
if(!data.resourceUnloadFnc) return 0;
|
||||||
|
|
||||||
|
OResource *resource = new OResource((OHRESOURCE)data.loadedData, ResourceType_UNKNOWN, 0, 0, filename);
|
||||||
|
|
||||||
|
resource->customData = new CustomResourceData();
|
||||||
|
resource->customData->unloadingFunction = data.resourceUnloadFnc;
|
||||||
|
resource->resourceData = (OHRESOURCE)data.loadedData;
|
||||||
|
resource->customData->loadingFunction = fnc;
|
||||||
|
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
void OResource::CustomUnloader()
|
||||||
|
{
|
||||||
|
this->customData->unloadingFunction((void*)this->resourceData);
|
||||||
|
}
|
||||||
|
OResource* OResource::CustomReloader()
|
||||||
|
{
|
||||||
|
CustomUnloader();
|
||||||
|
|
||||||
|
const CustomData &data = this->customData->loadingFunction();
|
||||||
|
this->resourceData = (OHRESOURCE)data.loadedData;
|
||||||
|
|
||||||
|
if(data.resourceUnloadFnc)
|
||||||
|
this->customData->unloadingFunction = data.resourceUnloadFnc;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
#include "OResource.h"
|
||||||
|
|
||||||
|
using namespace Oyster::Resource;
|
||||||
|
|
||||||
|
OResource::OResource(OHRESOURCE handle, ResourceType type, size_t resourceSize, size_t elementSize, ::std::wstring filename)
|
||||||
|
: resourceData (handle)
|
||||||
|
, resourceFilename (filename)
|
||||||
|
, resourceSize (resourceSize)
|
||||||
|
, resourceElementSize (elementSize)
|
||||||
|
, resourceType (type)
|
||||||
|
, customData (0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
OResource::~OResource()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
OResource* OResource::Load (const wchar_t filename[], ResourceType type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case Oyster::Resource::ResourceType_Byte_Raw:
|
||||||
|
case Oyster::Resource::ResourceType_Byte_ANSI:
|
||||||
|
case Oyster::Resource::ResourceType_Byte_UTF8:
|
||||||
|
case Oyster::Resource::ResourceType_Byte_UNICODE:
|
||||||
|
case Oyster::Resource::ResourceType_Byte_UTF16LE:
|
||||||
|
return OResource::ByteLoader(filename, type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
OResource* OResource::Load (const wchar_t filename[], CustomLoadFunction loadFnc)
|
||||||
|
{
|
||||||
|
return OResource::CustomLoader(filename, loadFnc);
|
||||||
|
}
|
||||||
|
OResource* OResource::Reload (OResource* resource)
|
||||||
|
{
|
||||||
|
if(!resource) return 0;
|
||||||
|
|
||||||
|
switch (resource->resourceType)
|
||||||
|
{
|
||||||
|
case Oyster::Resource::ResourceType_Byte_Raw:
|
||||||
|
case Oyster::Resource::ResourceType_Byte_ANSI:
|
||||||
|
case Oyster::Resource::ResourceType_Byte_UTF8:
|
||||||
|
case Oyster::Resource::ResourceType_Byte_UNICODE:
|
||||||
|
case Oyster::Resource::ResourceType_Byte_UTF16LE:
|
||||||
|
resource->ByteReloader();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Oyster::Resource::ResourceType_UNKNOWN:
|
||||||
|
resource->CustomReloader();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
bool OResource::Release (OResource* resource)
|
||||||
|
{
|
||||||
|
if(resource->resourceRef.Decref() == 0)
|
||||||
|
{
|
||||||
|
switch (resource->resourceType)
|
||||||
|
{
|
||||||
|
case Oyster::Resource::ResourceType_Byte_Raw:
|
||||||
|
case Oyster::Resource::ResourceType_Byte_ANSI:
|
||||||
|
case Oyster::Resource::ResourceType_Byte_UTF8:
|
||||||
|
case Oyster::Resource::ResourceType_Byte_UNICODE:
|
||||||
|
case Oyster::Resource::ResourceType_Byte_UTF16LE:
|
||||||
|
resource->ByteUnloader();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Oyster::Resource::ResourceType_UNKNOWN:
|
||||||
|
resource->CustomUnloader();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
// Created by [Dennis Andersen] [2013]
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef MISC_O_RESOURCE_H
|
||||||
|
#define MISC_O_RESOURCE_H
|
||||||
|
|
||||||
|
#include "..\Utilities.h"
|
||||||
|
#include "OysterResource.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Resource
|
||||||
|
{
|
||||||
|
class OResource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct CustomResourceData
|
||||||
|
{
|
||||||
|
CustomLoadFunction loadingFunction;
|
||||||
|
CustomUnloadFunction unloadingFunction;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
OResource(OHRESOURCE handle, ResourceType type, size_t size, size_t elementSize, ::std::wstring resourceFilename);
|
||||||
|
virtual~ OResource();
|
||||||
|
|
||||||
|
inline ResourceType GetResourceType() const
|
||||||
|
{ return this->resourceType; }
|
||||||
|
inline const wchar_t* GetResourceFilename() const
|
||||||
|
{ return this->resourceFilename.c_str(); }
|
||||||
|
inline OHRESOURCE GetResourceHandle() const
|
||||||
|
{ return this->resourceData; }
|
||||||
|
inline unsigned long long GetResourceSize() const
|
||||||
|
{ return this->resourceSize; }
|
||||||
|
inline unsigned long long GetResourceElementSize() const
|
||||||
|
{ return this->resourceElementSize; }
|
||||||
|
inline unsigned int GetResourceID() const
|
||||||
|
{ return this->resourceID; }
|
||||||
|
inline void SetResourceID(unsigned int id)
|
||||||
|
{ this->resourceID = id; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
static OResource* Load (const wchar_t filename[], ResourceType type);
|
||||||
|
static OResource* Load (const wchar_t filename[], CustomLoadFunction loadFnc);
|
||||||
|
static OResource* Reload (OResource* resource);
|
||||||
|
static bool Release (OResource* resource);
|
||||||
|
|
||||||
|
Utility::DynamicMemory::RefCount resourceRef;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static OResource* ByteLoader (const wchar_t filename[], ResourceType type, OResource* old = 0);
|
||||||
|
void ByteUnloader ();
|
||||||
|
OResource* ByteReloader ();
|
||||||
|
|
||||||
|
static OResource* CustomLoader (const wchar_t filename[], CustomLoadFunction loadFnc);
|
||||||
|
void CustomUnloader ();
|
||||||
|
OResource* CustomReloader ();
|
||||||
|
|
||||||
|
OHRESOURCE resourceData;
|
||||||
|
ResourceType resourceType;
|
||||||
|
size_t resourceSize;
|
||||||
|
size_t resourceElementSize;
|
||||||
|
::std::wstring resourceFilename;
|
||||||
|
unsigned int resourceID;
|
||||||
|
|
||||||
|
CustomResourceData *customData;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,179 @@
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
// Created by [Dennis Andersen] [2013]
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#include "OysterResource.h"
|
||||||
|
#include "OResource.h"
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
using namespace Oyster::Resource;
|
||||||
|
|
||||||
|
class ResourcePrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
std::map<std::wstring, OResource*> resources;
|
||||||
|
|
||||||
|
OResource* FindResource(const OHRESOURCE& h) const;
|
||||||
|
OResource* FindResource(const wchar_t c[]) const;
|
||||||
|
void SaveResource(OResource* r, bool addNew = true);
|
||||||
|
|
||||||
|
} resourcePrivate;
|
||||||
|
|
||||||
|
|
||||||
|
OHRESOURCE OysterResource::LoadResource(const wchar_t* filename, ResourceType type)
|
||||||
|
{
|
||||||
|
if(!filename) return 0;
|
||||||
|
|
||||||
|
OResource *resourceData = resourcePrivate.FindResource(filename);
|
||||||
|
if(resourceData)
|
||||||
|
{
|
||||||
|
//Add new reference
|
||||||
|
resourcePrivate.SaveResource(resourceData, false);
|
||||||
|
return resourceData->GetResourceHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
resourceData = OResource::Load(filename, type);
|
||||||
|
|
||||||
|
if(!resourceData) return 0;
|
||||||
|
|
||||||
|
resourcePrivate.SaveResource(resourceData);
|
||||||
|
|
||||||
|
return resourceData->GetResourceHandle();
|
||||||
|
}
|
||||||
|
OHRESOURCE OysterResource::LoadResource(const wchar_t filename[], CustomLoadFunction loadFnc, unsigned int CustomId)
|
||||||
|
{
|
||||||
|
if(!filename) return 0;
|
||||||
|
if(!loadFnc) return 0;
|
||||||
|
|
||||||
|
OResource *resourceData = resourcePrivate.FindResource(filename);
|
||||||
|
if(resourceData)
|
||||||
|
{
|
||||||
|
//Add new reference
|
||||||
|
resourcePrivate.SaveResource(resourceData, false);
|
||||||
|
return resourceData->GetResourceHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
resourceData = OResource::Load(filename, loadFnc);
|
||||||
|
|
||||||
|
if(!resourceData) return 0;
|
||||||
|
|
||||||
|
if(resourceData) resourceData->SetResourceID(CustomId);
|
||||||
|
resourcePrivate.SaveResource(resourceData);
|
||||||
|
|
||||||
|
return (OHRESOURCE)resourceData->GetResourceHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
OHRESOURCE ReloadResource(const wchar_t filename[])
|
||||||
|
{
|
||||||
|
OResource *resourceData = resourcePrivate.FindResource(filename);
|
||||||
|
if(!resourceData) return 0; //The resource has not been loaded
|
||||||
|
|
||||||
|
return OResource::Reload(resourceData)->GetResourceHandle();
|
||||||
|
}
|
||||||
|
OHRESOURCE ReloadResource(OHRESOURCE resource)
|
||||||
|
{
|
||||||
|
OResource *resourceData = resourcePrivate.FindResource(resource);
|
||||||
|
if(!resourceData) return 0; //The resource has not been loaded
|
||||||
|
|
||||||
|
return OResource::Reload(resourceData)->GetResourceHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OysterResource::Clean()
|
||||||
|
{
|
||||||
|
auto i = resourcePrivate.resources.begin();
|
||||||
|
auto last = resourcePrivate.resources.end();
|
||||||
|
|
||||||
|
for (i; i != last; i++)
|
||||||
|
{
|
||||||
|
if(OResource::Release(i->second))
|
||||||
|
{
|
||||||
|
const wchar_t* temp = i->second->GetResourceFilename();
|
||||||
|
delete resourcePrivate.resources[temp];
|
||||||
|
resourcePrivate.resources.erase(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void OysterResource::ReleaseResource(const OHRESOURCE& resourceData)
|
||||||
|
{
|
||||||
|
OResource* t = resourcePrivate.FindResource(resourceData);
|
||||||
|
if(t)
|
||||||
|
{
|
||||||
|
if(OResource::Release(t))
|
||||||
|
{
|
||||||
|
const wchar_t* temp = t->GetResourceFilename();
|
||||||
|
delete resourcePrivate.resources[temp];
|
||||||
|
resourcePrivate.resources.erase(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OysterResource::SetResourceId (const OHRESOURCE& resourceData, unsigned int id)
|
||||||
|
{
|
||||||
|
OResource* t = resourcePrivate.FindResource(resourceData);
|
||||||
|
|
||||||
|
if(t) t->SetResourceID(id);
|
||||||
|
}
|
||||||
|
ResourceType OysterResource::GetResourceType (const OHRESOURCE& resourceData)
|
||||||
|
{
|
||||||
|
OResource* t = resourcePrivate.FindResource(resourceData);
|
||||||
|
|
||||||
|
if(t) return t->GetResourceType();
|
||||||
|
|
||||||
|
return ResourceType_UNKNOWN;
|
||||||
|
}
|
||||||
|
const wchar_t* OysterResource::GetResourceFilename (const OHRESOURCE& resourceData)
|
||||||
|
{
|
||||||
|
OResource* t = resourcePrivate.FindResource(resourceData);
|
||||||
|
|
||||||
|
if(t) return t->GetResourceFilename();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
unsigned int OysterResource::GetResourceId (const OHRESOURCE& resourceData)
|
||||||
|
{
|
||||||
|
OResource* t = resourcePrivate.FindResource(resourceData);
|
||||||
|
|
||||||
|
if(t) return t->GetResourceID();
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
OResource* ResourcePrivate::FindResource(const OHRESOURCE& h) const
|
||||||
|
{
|
||||||
|
for (auto i = this->resources.begin(); i != this->resources.end() ; i++)
|
||||||
|
{
|
||||||
|
if(i->second->GetResourceHandle() == h)
|
||||||
|
{
|
||||||
|
return i->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
OResource* ResourcePrivate::FindResource(const wchar_t c[]) const
|
||||||
|
{
|
||||||
|
std::wstring temp = c;
|
||||||
|
auto t = this->resources.find(c);
|
||||||
|
if(t == this->resources.end()) return 0;
|
||||||
|
|
||||||
|
return t->second;
|
||||||
|
}
|
||||||
|
void ResourcePrivate::SaveResource( OResource* r, bool addNew )
|
||||||
|
{
|
||||||
|
if(!r) return;
|
||||||
|
|
||||||
|
if(addNew)
|
||||||
|
{
|
||||||
|
this->resources[r->GetResourceFilename()] = r;
|
||||||
|
}
|
||||||
|
|
||||||
|
r->resourceRef.Incref();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,122 @@
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
// Created by [Dennis Andersen] [2013]
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef MISC_OYSTER_RESOURCE_H
|
||||||
|
#define MISC_OYSTER_RESOURCE_H
|
||||||
|
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Resource
|
||||||
|
{
|
||||||
|
struct CustomData;
|
||||||
|
/** A Resource handle representing various resources */
|
||||||
|
typedef unsigned long OHRESOURCE;
|
||||||
|
typedef void(*CustomUnloadFunction)(void*);
|
||||||
|
typedef const CustomData&(*CustomLoadFunction)();
|
||||||
|
|
||||||
|
/** An enum class representing all avalible resources that is supported. */
|
||||||
|
enum ResourceType
|
||||||
|
{
|
||||||
|
//Byte
|
||||||
|
ResourceType_Byte_Raw, /**< Handle can be interpeted as char[] or char* */
|
||||||
|
ResourceType_Byte_ANSI, /**< Handle can be interpeted as char[] or char* */
|
||||||
|
ResourceType_Byte_UTF8, /**< Handle can be interpeted as char[] or char* */
|
||||||
|
ResourceType_Byte_UNICODE, /**< Handle can be interpeted as char[] or char* */
|
||||||
|
ResourceType_Byte_UTF16LE, /**< Handle can be interpeted as char[] or char* */
|
||||||
|
|
||||||
|
ResourceType_COUNT, /**< Handle can be interpeted as ? */
|
||||||
|
|
||||||
|
ResourceType_UNKNOWN = -1, /**< Handle can be interpeted as void* */
|
||||||
|
};
|
||||||
|
|
||||||
|
/** A struct to return when doing a custom resource Load
|
||||||
|
* By loading this way you are handing over the ownership to the resource loaded.
|
||||||
|
*/
|
||||||
|
struct CustomData
|
||||||
|
{
|
||||||
|
void* loadedData; ///<! The loaded resource interpeted as a void*.
|
||||||
|
CustomUnloadFunction resourceUnloadFnc; ///<! The function that will be used to free the resource when needed.
|
||||||
|
};
|
||||||
|
|
||||||
|
/** A resource handler interface to interact with when loading resources.
|
||||||
|
* The resource handler uses the filename to make resources unuiqe.
|
||||||
|
*/
|
||||||
|
class OysterResource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Load a resource given a type.
|
||||||
|
* @param filename The path to the resource.
|
||||||
|
* @param type The resource type to load.
|
||||||
|
* @param force If set to true, the resource will be reloaded if it already exists. If it does not, nothing happens.
|
||||||
|
* @return If function suceeds, a handle to the resource will be returned. If failed 0 is returned.
|
||||||
|
*/
|
||||||
|
static OHRESOURCE LoadResource(const wchar_t filename[], ResourceType type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a resource with a custom loading function
|
||||||
|
* @param filename The path to the resource.
|
||||||
|
* @param force If set to true, the resource will be reloaded even if exists.
|
||||||
|
* @param loadFnc If set, this gives you the right to do custom resource loading if your recource type is not supported.
|
||||||
|
* @return If function suceeds, a handle to the resource will be returned. If failed 0 is returned.
|
||||||
|
*/
|
||||||
|
static OHRESOURCE LoadResource(const wchar_t filename[], CustomLoadFunction loadFnc = 0, unsigned int CustomId = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reload a resource
|
||||||
|
* @param filename The path to the resource.
|
||||||
|
* @return If function suceeds, a handle to the resource will be returned. If failed 0 is returned.
|
||||||
|
*/
|
||||||
|
static OHRESOURCE ReloadResource(const wchar_t filename[]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reload a resource
|
||||||
|
* @param filename The path to the resource.
|
||||||
|
* @return If function suceeds, a handle to the resource will be returned. If failed 0 is returned.
|
||||||
|
*/
|
||||||
|
static OHRESOURCE ReloadResource(OHRESOURCE resource);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases all resources loaded by the resource handler.
|
||||||
|
* @return Nothing
|
||||||
|
*/
|
||||||
|
static void Clean();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Release a reference to the resource handle
|
||||||
|
* @param resource The handle to release.
|
||||||
|
* @return Nothing
|
||||||
|
*/
|
||||||
|
static void ReleaseResource(const OHRESOURCE& resource);
|
||||||
|
|
||||||
|
/** Set a user defined ID
|
||||||
|
* @param resource A handle to accociate the id with.
|
||||||
|
* @param id A user defined identifier that the resource handler does not touch.
|
||||||
|
*/
|
||||||
|
static void SetResourceId(const OHRESOURCE& resource, unsigned int id);
|
||||||
|
|
||||||
|
/** Get a resource type given a OHRESOURCE handle
|
||||||
|
* @param resource The handle to check
|
||||||
|
* @return Returns the resource type of the handle
|
||||||
|
*/
|
||||||
|
static ResourceType GetResourceType(const OHRESOURCE& resource);
|
||||||
|
|
||||||
|
/** Get a resource filename given a OHRESOURCE handle
|
||||||
|
* @param resource The handle to check
|
||||||
|
* @return Returns the accociated filename
|
||||||
|
*/
|
||||||
|
static const wchar_t* GetResourceFilename(const OHRESOURCE& resource);
|
||||||
|
|
||||||
|
/** Get a user defined ID accociated with a handle
|
||||||
|
* @param resource The handle to check
|
||||||
|
* @return Returns the accociated ID
|
||||||
|
*/
|
||||||
|
static unsigned int GetResourceId(const OHRESOURCE& resource);
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -37,6 +37,14 @@ namespace Utility
|
||||||
this->ownedInstance = assignedInstance;
|
this->ownedInstance = assignedInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Type>
|
||||||
|
UniquePointer<Type>::UniquePointer( const UniquePointer<Type> &donor )
|
||||||
|
{
|
||||||
|
this->ownedInstance = donor.ownedInstance;
|
||||||
|
donor.ownedInstance = NULL;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
UniquePointer<Type>::~UniquePointer()
|
UniquePointer<Type>::~UniquePointer()
|
||||||
{
|
{
|
||||||
|
@ -122,6 +130,14 @@ namespace Utility
|
||||||
this->ownedArray = assignedArray;
|
this->ownedArray = assignedArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Type>
|
||||||
|
UniqueArray<Type>::UniqueArray( const UniqueArray<Type> &donor )
|
||||||
|
{
|
||||||
|
this->ownedArray = donor.ownedArray;
|
||||||
|
donor.ownedArray = NULL;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
UniqueArray<Type>::~UniqueArray()
|
UniqueArray<Type>::~UniqueArray()
|
||||||
{
|
{
|
||||||
|
|
|
@ -281,6 +281,53 @@ namespace Utility
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
::std::wstring & wToLowerCase( ::std::wstring &output, const ::std::wstring &str )
|
||||||
|
{
|
||||||
|
int length = (int)str.length();
|
||||||
|
output.resize( length );
|
||||||
|
for( int i = 0; i < length; ++i )
|
||||||
|
output[i] = ::std::tolower( str[i], ::std::locale() );
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
::std::wstring & wToLowerCase( ::std::wstring &str )
|
||||||
|
{
|
||||||
|
int length = (int)str.length();
|
||||||
|
for( int i = 0; i < length; ++i )
|
||||||
|
str[i] = ::std::tolower( str[i], ::std::locale() );
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
//To wstring
|
||||||
|
|
||||||
|
::std::wstring & StringToWString( const ::std::string &str, ::std::wstring &wstr )
|
||||||
|
{
|
||||||
|
const char *orig = str.c_str();
|
||||||
|
|
||||||
|
// Convert to a wchar_t*
|
||||||
|
size_t origsize = strlen(orig) + 1;
|
||||||
|
const size_t newsize = 255;
|
||||||
|
size_t convertedChars = 0;
|
||||||
|
wchar_t wcstring[newsize];
|
||||||
|
mbstowcs_s(&convertedChars, wcstring, origsize, orig, _TRUNCATE);
|
||||||
|
wstr = wcstring;
|
||||||
|
//wcscat_s(wcstring, L" (wchar_t *)");
|
||||||
|
return wstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
::std::string & WStringToString( const ::std::wstring &wstr, ::std::string &str )
|
||||||
|
{
|
||||||
|
const wchar_t* orig = wstr.c_str();
|
||||||
|
// Convert to a char*
|
||||||
|
size_t origsize = wcslen(orig) + 1;
|
||||||
|
const size_t newsize = 255;
|
||||||
|
size_t convertedChars = 0;
|
||||||
|
char nstring[newsize];
|
||||||
|
wcstombs_s(&convertedChars, nstring, origsize, orig, _TRUNCATE);
|
||||||
|
str = nstring;
|
||||||
|
//strcat_s(nstring, " (char *)");
|
||||||
|
return str;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// STREAM ////////////////////////////////////////////////////////////
|
// STREAM ////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -27,18 +27,22 @@ namespace Utility
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Assigns assignedInstance ownership to this UniquePonter, old owned instance will be deleted.
|
//! Assigns assignedInstance ownership to this UniquePonter, old owned instance will be deleted.
|
||||||
//! If NULL is assigned is equavalent with clearing all responsibilities from this UniquePointer.
|
//! If NULL is assigned is equivalent with clearing all responsibilities from this UniquePointer.
|
||||||
UniquePointer( Type *assignedInstance = NULL );
|
UniquePointer( Type *assignedInstance = NULL );
|
||||||
|
|
||||||
|
//! Transfers assignedInstance ownership from donor to this UniquePonter, old owned instance will be deleted.
|
||||||
|
//! If donor had nothing, is equivalent with clearing all responsibilities from this UniquePointer.
|
||||||
|
UniquePointer( const UniquePointer<Type> &donor );
|
||||||
|
|
||||||
//! Will auto delete assigned dynamic instance.
|
//! Will auto delete assigned dynamic instance.
|
||||||
~UniquePointer();
|
~UniquePointer();
|
||||||
|
|
||||||
//! Assigns assignedInstance ownership to this UniquePonter, old owned instance will be deleted.
|
//! Assigns assignedInstance ownership to this UniquePonter, old owned instance will be deleted.
|
||||||
//! If NULL is assigned is equavalent with clearing all responsibilities from this UniquePointer.
|
//! If NULL is assigned is equivalent with clearing all responsibilities from this UniquePointer.
|
||||||
UniquePointer<Type> & operator = ( Type *assignedInstance );
|
UniquePointer<Type> & operator = ( Type *assignedInstance );
|
||||||
|
|
||||||
//! Transfers assignedInstance ownership from donor to this UniquePonter, old owned instance will be deleted.
|
//! Transfers assignedInstance ownership from donor to this UniquePonter, old owned instance will be deleted.
|
||||||
//! If donor had nothing, is equavalent with clearing all responsibilities from this UniquePointer.
|
//! If donor had nothing, is equivalent with clearing all responsibilities from this UniquePointer.
|
||||||
UniquePointer<Type> & operator = ( const UniquePointer<Type> &donor );
|
UniquePointer<Type> & operator = ( const UniquePointer<Type> &donor );
|
||||||
|
|
||||||
//! Access the assigned dynamic instance. Will crash if nothing there
|
//! Access the assigned dynamic instance. Will crash if nothing there
|
||||||
|
@ -77,18 +81,22 @@ namespace Utility
|
||||||
{ //! Wrapper to safely transfer dynamic ownership/responsibility
|
{ //! Wrapper to safely transfer dynamic ownership/responsibility
|
||||||
public:
|
public:
|
||||||
//! Assigns assignedInstance ownership to this UniquePonter, old owned array will be deleted.
|
//! Assigns assignedInstance ownership to this UniquePonter, old owned array will be deleted.
|
||||||
//! If NULL is assigned is equavalent with clearing all responsibilities from this UniqueArray.
|
//! If NULL is assigned is equivalent with clearing all responsibilities from this UniqueArray.
|
||||||
UniqueArray( Type assignedArray[] = NULL );
|
UniqueArray( Type assignedArray[] = NULL );
|
||||||
|
|
||||||
|
//! Transfers assignedInstance ownership from donor to this UniquePonter, old owned array will be deleted.
|
||||||
|
//! If donor had nothing, is equivalent with clearing all responsibilities from this UniqueArray.
|
||||||
|
UniqueArray( const UniqueArray<Type> &donor );
|
||||||
|
|
||||||
//! Will auto delete assigned dynamic array.
|
//! Will auto delete assigned dynamic array.
|
||||||
~UniqueArray();
|
~UniqueArray();
|
||||||
|
|
||||||
//! Assigns assignedInstance ownership to this UniquePonter, old owned array will be deleted.
|
//! Assigns assignedInstance ownership to this UniquePonter, old owned array will be deleted.
|
||||||
//! If NULL is assigned is equavalent with clearing all responsibilities from this UniqueArray.
|
//! If NULL is assigned is equivalent with clearing all responsibilities from this UniqueArray.
|
||||||
UniqueArray<Type> & operator = ( Type assignedArray[] );
|
UniqueArray<Type> & operator = ( Type assignedArray[] );
|
||||||
|
|
||||||
//! Transfers assignedInstance ownership from donor to this UniquePonter, old owned array will be deleted.
|
//! Transfers assignedInstance ownership from donor to this UniquePonter, old owned array will be deleted.
|
||||||
//! If donor had nothing, is equavalent with clearing all responsibilities from this UniqueArray.
|
//! If donor had nothing, is equivalent with clearing all responsibilities from this UniqueArray.
|
||||||
UniqueArray<Type> & operator = ( const UniqueArray<Type> &donor );
|
UniqueArray<Type> & operator = ( const UniqueArray<Type> &donor );
|
||||||
|
|
||||||
//! Accesses the instance at index i of this UniqeArray's owned dynamic array.
|
//! Accesses the instance at index i of this UniqeArray's owned dynamic array.
|
||||||
|
@ -117,6 +125,21 @@ namespace Utility
|
||||||
private:
|
private:
|
||||||
mutable Type *ownedArray;
|
mutable Type *ownedArray;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct RefCount
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
int count;
|
||||||
|
|
||||||
|
public:
|
||||||
|
RefCount() :count(0) { }
|
||||||
|
RefCount(const RefCount& o) { count = o.count; }
|
||||||
|
const RefCount& operator=(const RefCount& o) { count = o.count; return *this;}
|
||||||
|
void Incref() { this->count++; }
|
||||||
|
void Incref(int c) { this->count += c; }
|
||||||
|
int Decref() { return --this->count;}
|
||||||
|
void Reset() { this->count = 0; }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace String
|
namespace String
|
||||||
|
@ -140,6 +163,13 @@ namespace Utility
|
||||||
::std::vector<::std::wstring> & Split( ::std::vector<::std::wstring> &output, const ::std::wstring &str, char delim, ::std::wstring::size_type offset = 0 );
|
::std::vector<::std::wstring> & Split( ::std::vector<::std::wstring> &output, const ::std::wstring &str, char delim, ::std::wstring::size_type offset = 0 );
|
||||||
::std::vector<::std::wstring> & Split( ::std::vector<::std::wstring> &output, const ::std::wstring &str, const ::std::wstring &delim, ::std::wstring::size_type offset = 0 );
|
::std::vector<::std::wstring> & Split( ::std::vector<::std::wstring> &output, const ::std::wstring &str, const ::std::wstring &delim, ::std::wstring::size_type offset = 0 );
|
||||||
::std::vector<::std::wstring> & Split( ::std::vector<::std::wstring> &output, const ::std::wstring &str, const ::std::vector<::std::wstring> &delim, ::std::wstring::size_type offset = 0 );
|
::std::vector<::std::wstring> & Split( ::std::vector<::std::wstring> &output, const ::std::wstring &str, const ::std::vector<::std::wstring> &delim, ::std::wstring::size_type offset = 0 );
|
||||||
|
::std::wstring & wToLowerCase( ::std::wstring &output, const ::std::wstring &str );
|
||||||
|
::std::wstring & wToLowerCase( ::std::wstring &str );
|
||||||
|
|
||||||
|
//To wstring
|
||||||
|
|
||||||
|
::std::wstring & StringToWstring( const ::std::string &str, ::std::wstring &wstr );
|
||||||
|
::std::string & WStringToString( const ::std::wstring &wstr, ::std::string &str );
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Stream
|
namespace Stream
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
#include "Buffer.h"
|
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
|
|
||||||
using namespace Oyster;
|
using namespace Oyster::Graphics;
|
||||||
|
|
||||||
Oyster::Buffer::Buffer()
|
Core::Buffer::Buffer()
|
||||||
{
|
{
|
||||||
mBuffer = NULL;
|
mBuffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer::~Buffer()
|
Core::Buffer::~Buffer()
|
||||||
{
|
{
|
||||||
SAFE_RELEASE(mBuffer);
|
SAFE_RELEASE(mBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT Buffer::Apply(UINT32 misc) const
|
HRESULT Core::Buffer::Apply(UINT32 misc) const
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
|
@ -23,32 +22,32 @@ HRESULT Buffer::Apply(UINT32 misc) const
|
||||||
{
|
{
|
||||||
UINT32 vertexSize = mElementSize;
|
UINT32 vertexSize = mElementSize;
|
||||||
UINT32 offset = 0;
|
UINT32 offset = 0;
|
||||||
Oyster::Core::DeviceContext->IASetVertexBuffers(misc, 1, &mBuffer, &vertexSize, &offset );
|
Core::deviceContext->IASetVertexBuffers(misc, 1, &mBuffer, &vertexSize, &offset );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INDEX_BUFFER:
|
case INDEX_BUFFER:
|
||||||
{
|
{
|
||||||
Oyster::Core::DeviceContext->IASetIndexBuffer(mBuffer, DXGI_FORMAT_R32_UINT, 0);
|
Core::deviceContext->IASetIndexBuffer(mBuffer, DXGI_FORMAT_R32_UINT, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CONSTANT_BUFFER_VS:
|
case CONSTANT_BUFFER_VS:
|
||||||
{
|
{
|
||||||
Oyster::Core::DeviceContext->VSSetConstantBuffers(misc, 1, &mBuffer);
|
Core::deviceContext->VSSetConstantBuffers(misc, 1, &mBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CONSTANT_BUFFER_GS:
|
case CONSTANT_BUFFER_GS:
|
||||||
{
|
{
|
||||||
Oyster::Core::DeviceContext->GSSetConstantBuffers(misc, 1, &mBuffer);
|
Core::deviceContext->GSSetConstantBuffers(misc, 1, &mBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CONSTANT_BUFFER_PS:
|
case CONSTANT_BUFFER_PS:
|
||||||
{
|
{
|
||||||
Oyster::Core::DeviceContext->PSSetConstantBuffers(misc, 1, &mBuffer);
|
Core::deviceContext->PSSetConstantBuffers(misc, 1, &mBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CONSTANT_BUFFER_CS:
|
case CONSTANT_BUFFER_CS:
|
||||||
{
|
{
|
||||||
Oyster::Core::DeviceContext->CSSetConstantBuffers(misc,1,&mBuffer);
|
Core::deviceContext->CSSetConstantBuffers(misc,1,&mBuffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -59,7 +58,7 @@ HRESULT Buffer::Apply(UINT32 misc) const
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT Buffer::Init(const BUFFER_INIT_DESC& initDesc)
|
HRESULT Core::Buffer::Init(const BUFFER_INIT_DESC& initDesc)
|
||||||
{
|
{
|
||||||
D3D11_BUFFER_DESC bufferDesc;
|
D3D11_BUFFER_DESC bufferDesc;
|
||||||
|
|
||||||
|
@ -145,22 +144,22 @@ HRESULT Buffer::Init(const BUFFER_INIT_DESC& initDesc)
|
||||||
data.pSysMem = initDesc.InitData;
|
data.pSysMem = initDesc.InitData;
|
||||||
data.SysMemPitch=0;
|
data.SysMemPitch=0;
|
||||||
data.SysMemSlicePitch = 0;
|
data.SysMemSlicePitch = 0;
|
||||||
hr = Oyster::Core::Device->CreateBuffer(&bufferDesc, &data, &mBuffer);
|
hr = Core::device->CreateBuffer(&bufferDesc, &data, &mBuffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hr = Oyster::Core::Device->CreateBuffer(&bufferDesc, NULL, &mBuffer);
|
hr = Core::device->CreateBuffer(&bufferDesc, NULL, &mBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(FAILED(hr))
|
if(FAILED(hr))
|
||||||
{
|
{
|
||||||
MessageBox(NULL, "Unable to create buffer.", "Slenda Error", MB_ICONERROR | MB_OK);
|
//MessageBox(NULL, L"Unable to create buffer.", L"Slenda Error", MB_ICONERROR | MB_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Buffer::Map()
|
void* Core::Buffer::Map()
|
||||||
{
|
{
|
||||||
void* ret = NULL;
|
void* ret = NULL;
|
||||||
if(mUsage == BUFFER_CPU_WRITE || mUsage == BUFFER_CPU_READ || mUsage == BUFFER_CPU_WRITE_DISCARD)
|
if(mUsage == BUFFER_CPU_WRITE || mUsage == BUFFER_CPU_READ || mUsage == BUFFER_CPU_WRITE_DISCARD)
|
||||||
|
@ -173,7 +172,7 @@ void* Buffer::Map()
|
||||||
else if(mUsage == BUFFER_CPU_WRITE_DISCARD) mapType = D3D11_MAP_WRITE_DISCARD;
|
else if(mUsage == BUFFER_CPU_WRITE_DISCARD) mapType = D3D11_MAP_WRITE_DISCARD;
|
||||||
|
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
if(FAILED(hr = Oyster::Core::DeviceContext->Map(
|
if(FAILED(hr = Core::deviceContext->Map(
|
||||||
mBuffer,
|
mBuffer,
|
||||||
0,
|
0,
|
||||||
(D3D11_MAP)mapType,
|
(D3D11_MAP)mapType,
|
||||||
|
@ -192,17 +191,17 @@ void* Buffer::Map()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::Unmap()
|
void Core::Buffer::Unmap()
|
||||||
{
|
{
|
||||||
Oyster::Core::DeviceContext->Unmap( mBuffer, 0 );
|
Core::deviceContext->Unmap( mBuffer, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
Oyster::Buffer::operator ID3D11Buffer *()
|
Core::Buffer::operator ID3D11Buffer *()
|
||||||
{
|
{
|
||||||
return this->mBuffer;
|
return this->mBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer::operator const ID3D11Buffer *() const
|
Core::Buffer::operator const ID3D11Buffer *() const
|
||||||
{
|
{
|
||||||
return this->mBuffer;
|
return this->mBuffer;
|
||||||
}
|
}
|
|
@ -1,77 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#ifndef CoreBuffer
|
|
||||||
#define CoreBuffer
|
|
||||||
|
|
||||||
#include "CoreIncludes.h"
|
|
||||||
|
|
||||||
namespace Oyster
|
|
||||||
{
|
|
||||||
class Buffer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum BUFFER_TYPE
|
|
||||||
{
|
|
||||||
VERTEX_BUFFER,
|
|
||||||
INDEX_BUFFER,
|
|
||||||
CONSTANT_BUFFER_VS,
|
|
||||||
CONSTANT_BUFFER_GS,
|
|
||||||
CONSTANT_BUFFER_PS,
|
|
||||||
CONSTANT_BUFFER_CS,
|
|
||||||
STRUCTURED_BUFFER,
|
|
||||||
BUFFER_TYPE_COUNT
|
|
||||||
};
|
|
||||||
|
|
||||||
enum BUFFER_USAGE
|
|
||||||
{
|
|
||||||
BUFFER_DEFAULT,
|
|
||||||
BUFFER_STREAM_OUT_TARGET,
|
|
||||||
BUFFER_CPU_WRITE,
|
|
||||||
BUFFER_CPU_WRITE_DISCARD,
|
|
||||||
BUFFER_CPU_READ,
|
|
||||||
BUFFER_USAGE_COUNT,
|
|
||||||
BUFFER_USAGE_IMMUTABLE
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BUFFER_INIT_DESC
|
|
||||||
{
|
|
||||||
BUFFER_TYPE Type;
|
|
||||||
UINT32 NumElements;
|
|
||||||
UINT32 ElementSize;
|
|
||||||
BUFFER_USAGE Usage;
|
|
||||||
void* InitData;
|
|
||||||
|
|
||||||
BUFFER_INIT_DESC()
|
|
||||||
{
|
|
||||||
InitData = NULL;
|
|
||||||
Usage = BUFFER_DEFAULT;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
protected:
|
|
||||||
ID3D11Buffer* mBuffer;
|
|
||||||
BUFFER_TYPE mType;
|
|
||||||
BUFFER_USAGE mUsage;
|
|
||||||
|
|
||||||
UINT32 mElementSize;
|
|
||||||
UINT32 mElementCount;
|
|
||||||
public:
|
|
||||||
Buffer();
|
|
||||||
virtual ~Buffer();
|
|
||||||
|
|
||||||
HRESULT Init(const BUFFER_INIT_DESC& initDesc);
|
|
||||||
|
|
||||||
void* Map();
|
|
||||||
void Unmap();
|
|
||||||
|
|
||||||
operator ID3D11Buffer*();
|
|
||||||
operator const ID3D11Buffer*() const;
|
|
||||||
|
|
||||||
HRESULT Apply(UINT32 misc = 0) const;
|
|
||||||
|
|
||||||
ID3D11Buffer* GetBufferPointer();
|
|
||||||
UINT32 GetVertexSize();
|
|
||||||
UINT32 GetElementCount();
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,169 +1,25 @@
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
|
|
||||||
using namespace Oyster;
|
using namespace Oyster::Graphics;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
//GPU
|
//GPU
|
||||||
ID3D11Device *Core::Device = NULL;
|
ID3D11Device *Core::device = NULL;
|
||||||
|
|
||||||
//API
|
//API
|
||||||
ID3D11DeviceContext *Core::DeviceContext = NULL;
|
ID3D11DeviceContext *Core::deviceContext = NULL;
|
||||||
|
|
||||||
//SwapChain
|
//SwapChain
|
||||||
IDXGISwapChain* Core::SwapChain = NULL;
|
IDXGISwapChain* Core::swapChain = NULL;
|
||||||
|
|
||||||
std::stringstream Log;
|
std::stringstream Core::log;
|
||||||
|
|
||||||
inline std::stringstream* AccesLog(){return &Log;}
|
ID3D11RenderTargetView* Core::backBufferRTV = NULL;
|
||||||
|
|
||||||
bool Core::Init(bool SingleThreaded, bool Reference,bool ForceDX11)
|
ID3D11UnorderedAccessView* Core::backBufferUAV = NULL;
|
||||||
{
|
|
||||||
UINT createDeviceFlags = 0;
|
|
||||||
|
|
||||||
if( SingleThreaded )
|
ID3D11DepthStencilView* Core::depthStencil = NULL;
|
||||||
createDeviceFlags = ::D3D11_CREATE_DEVICE_SINGLETHREADED;
|
|
||||||
|
|
||||||
::D3D_DRIVER_TYPE driverType = ::D3D_DRIVER_TYPE_HARDWARE;
|
D3D11_VIEWPORT* Core::viewPort = NULL;
|
||||||
|
|
||||||
if(Reference)
|
|
||||||
driverType = D3D_DRIVER_TYPE_REFERENCE;
|
|
||||||
|
|
||||||
#if defined(DEBUG) || defined(_DEBUG)
|
|
||||||
Log << "DirectX running in debug mode.\n";
|
|
||||||
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
Oyster::Math::Float2 Core::resolution = Oyster::Math::Float2::null;
|
||||||
D3D_FEATURE_LEVEL featureLevelsToTry[] =
|
|
||||||
{
|
|
||||||
D3D_FEATURE_LEVEL_11_0,
|
|
||||||
D3D_FEATURE_LEVEL_10_1,
|
|
||||||
D3D_FEATURE_LEVEL_10_0
|
|
||||||
};
|
|
||||||
D3D_FEATURE_LEVEL initiatedFeatureLevel;
|
|
||||||
|
|
||||||
if( FAILED( ::D3D11CreateDevice( NULL, // default adapter
|
|
||||||
driverType,
|
|
||||||
NULL, // no software device
|
|
||||||
createDeviceFlags,
|
|
||||||
featureLevelsToTry, 3, // default feature level array. DX11 support assumed
|
|
||||||
D3D11_SDK_VERSION,
|
|
||||||
&Device, // device
|
|
||||||
&initiatedFeatureLevel,
|
|
||||||
&DeviceContext ) ) ) // context
|
|
||||||
{ // if failed
|
|
||||||
if( DeviceContext ) { DeviceContext->Release(); DeviceContext = NULL; } // safe cleanup
|
|
||||||
if( Device ) { Device->Release(); Device = NULL; } // safe cleanup
|
|
||||||
}
|
|
||||||
|
|
||||||
if( driverType == ::D3D_DRIVER_TYPE_HARDWARE )
|
|
||||||
Log << "D3D_DRIVER_TYPE_HARDWARE support discovered.\n";
|
|
||||||
else
|
|
||||||
Log << "D3D_DRIVER_TYPE_REFERENCE support discovered.\n";
|
|
||||||
|
|
||||||
if( initiatedFeatureLevel == ::D3D_FEATURE_LEVEL_11_0 )
|
|
||||||
{
|
|
||||||
Log << "DirectX Featurelevel 11.0 supported.\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(ForceDX11)
|
|
||||||
return false;
|
|
||||||
if( initiatedFeatureLevel == ::D3D_FEATURE_LEVEL_10_1 )
|
|
||||||
{
|
|
||||||
Log << "DirectX Featurelevel 10.1 supported.\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( initiatedFeatureLevel == ::D3D_FEATURE_LEVEL_10_0 )
|
|
||||||
{
|
|
||||||
Log << "DirectX Featurelevel 10.0 supported.\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(Device)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Core::CreateSwapChain(HWND Window, int NrofBuffers,bool MSAA_Quality,bool Fullscreen)
|
|
||||||
{
|
|
||||||
//generate static Swapchain Desc
|
|
||||||
DXGI_SWAP_CHAIN_DESC desc;
|
|
||||||
desc.OutputWindow=Window;
|
|
||||||
desc.BufferCount=NrofBuffers;
|
|
||||||
desc.Windowed=!Fullscreen;
|
|
||||||
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_UNORDERED_ACCESS;
|
|
||||||
desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
|
||||||
desc.Flags=0;
|
|
||||||
desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
|
||||||
desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
|
|
||||||
desc.BufferDesc.Scaling = DXGI_MODE_SCALING_CENTERED;
|
|
||||||
desc.BufferDesc.RefreshRate.Denominator=1;
|
|
||||||
desc.BufferDesc.RefreshRate.Numerator=60;
|
|
||||||
|
|
||||||
RECT rc;
|
|
||||||
GetClientRect( Window, &rc );
|
|
||||||
int screenWidth = rc.right - rc.left;
|
|
||||||
int screenHeight = rc.bottom - rc.top;
|
|
||||||
|
|
||||||
desc.BufferDesc.Height = screenHeight;
|
|
||||||
desc.BufferDesc.Width = screenWidth;
|
|
||||||
|
|
||||||
//Check and Set multiSampling
|
|
||||||
if(MSAA_Quality)
|
|
||||||
{
|
|
||||||
if(FAILED(Device->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM,4,&desc.SampleDesc.Quality)))
|
|
||||||
{
|
|
||||||
Log<< "Failed to check multisample quality levels (MSAAQuality).\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
desc.SampleDesc.Count=4;
|
|
||||||
--desc.SampleDesc.Quality;
|
|
||||||
Log << "Supported multisample quality levels (MSAAQuality): " << desc.SampleDesc.Quality+1 << "x\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
desc.SampleDesc.Count=1;
|
|
||||||
desc.SampleDesc.Quality=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Get Device Factory
|
|
||||||
::IDXGIDevice *dxgiDevice = NULL;
|
|
||||||
if( FAILED( Device->QueryInterface( __uuidof( IDXGIDevice ), (void**)&dxgiDevice ) ) )
|
|
||||||
{
|
|
||||||
Log << "Failed to Query for the GPU's dxgiDevice.\nFailed to create swapChain for the GPU.\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
::IDXGIAdapter *dxgiAdapter = NULL;
|
|
||||||
if( FAILED( dxgiDevice->GetParent( __uuidof( IDXGIAdapter ), (void**)&dxgiAdapter ) ) )
|
|
||||||
{
|
|
||||||
dxgiDevice->Release();
|
|
||||||
Log << "Failed to get GPU's parent dxgiAdapter.\nFailed to create swapChain for the GPU.\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
dxgiDevice->Release();
|
|
||||||
|
|
||||||
::IDXGIFactory *dxgiFactory = NULL;
|
|
||||||
if( FAILED( dxgiAdapter->GetParent( __uuidof( IDXGIFactory ), (void**)&dxgiFactory ) ) )
|
|
||||||
{
|
|
||||||
dxgiAdapter->Release();
|
|
||||||
Log << "Failed to get GPU's parent dxgiFactory.\nFailed to create swapChain for the GPU.\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
dxgiAdapter->Release();
|
|
||||||
|
|
||||||
//Create SwapChain
|
|
||||||
if( FAILED( dxgiFactory->CreateSwapChain( Device, &desc, &SwapChain ) ) )
|
|
||||||
{
|
|
||||||
dxgiFactory->Release();
|
|
||||||
Log << "Failed to create swapChain for the GPU.\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
dxgiFactory->Release();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
|
@ -4,111 +4,214 @@
|
||||||
#define Core_h
|
#define Core_h
|
||||||
|
|
||||||
|
|
||||||
#include "CoreIncludes.h"
|
#include "Dx11Includes.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "Buffer.h"
|
#include "OysterMath.h"
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
class Core
|
namespace Graphics
|
||||||
{
|
{
|
||||||
public:
|
class Core
|
||||||
|
|
||||||
static ID3D11Device* Device;
|
|
||||||
|
|
||||||
static ID3D11DeviceContext* DeviceContext;
|
|
||||||
|
|
||||||
static IDXGISwapChain* SwapChain;
|
|
||||||
|
|
||||||
static std::stringstream* AccesLog();
|
|
||||||
|
|
||||||
static bool Init(bool SingleThreaded,bool Reference,bool ForceDX11);
|
|
||||||
|
|
||||||
static bool CreateSwapChain(HWND Window, int NrofBuffers,bool MSAA_Quality,bool Fullscreen);
|
|
||||||
|
|
||||||
class ShaderManager
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct ShaderEffect
|
|
||||||
|
static ID3D11Device* device;
|
||||||
|
|
||||||
|
static ID3D11DeviceContext* deviceContext;
|
||||||
|
|
||||||
|
static IDXGISwapChain* swapChain;
|
||||||
|
|
||||||
|
static std::stringstream log;
|
||||||
|
|
||||||
|
//BackBufferRTV
|
||||||
|
static ID3D11RenderTargetView* backBufferRTV;
|
||||||
|
//BackBufferUAV
|
||||||
|
static ID3D11UnorderedAccessView* backBufferUAV;
|
||||||
|
//DepthStencil
|
||||||
|
static ID3D11DepthStencilView* depthStencil;
|
||||||
|
//ViewPort
|
||||||
|
static D3D11_VIEWPORT* viewPort;
|
||||||
|
|
||||||
|
static Oyster::Math::Float2 resolution;
|
||||||
|
|
||||||
|
class Buffer
|
||||||
{
|
{
|
||||||
struct
|
public:
|
||||||
{
|
enum BUFFER_TYPE
|
||||||
int Pixel,Vertex,Geometry,Compute,Hull,Domain;
|
{
|
||||||
}Shaders;
|
VERTEX_BUFFER,
|
||||||
|
INDEX_BUFFER,
|
||||||
|
CONSTANT_BUFFER_VS,
|
||||||
|
CONSTANT_BUFFER_GS,
|
||||||
|
CONSTANT_BUFFER_PS,
|
||||||
|
CONSTANT_BUFFER_CS,
|
||||||
|
STRUCTURED_BUFFER,
|
||||||
|
BUFFER_TYPE_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
struct IAStage_
|
enum BUFFER_USAGE
|
||||||
{
|
{
|
||||||
ID3D11InputLayout* Layout;
|
BUFFER_DEFAULT,
|
||||||
D3D11_PRIMITIVE_TOPOLOGY Topology;
|
BUFFER_STREAM_OUT_TARGET,
|
||||||
}IAStage;
|
BUFFER_CPU_WRITE,
|
||||||
|
BUFFER_CPU_WRITE_DISCARD,
|
||||||
|
BUFFER_CPU_READ,
|
||||||
|
BUFFER_USAGE_COUNT,
|
||||||
|
BUFFER_USAGE_IMMUTABLE
|
||||||
|
};
|
||||||
|
|
||||||
struct RenderStates_
|
struct BUFFER_INIT_DESC
|
||||||
{
|
{
|
||||||
ID3D11DepthStencilState *DepthStencil;
|
BUFFER_TYPE Type;
|
||||||
ID3D11RasterizerState *Rasterizer;
|
UINT32 NumElements;
|
||||||
ID3D11SamplerState **SampleState;
|
UINT32 ElementSize;
|
||||||
int SampleCount;
|
BUFFER_USAGE Usage;
|
||||||
ID3D11BlendState *BlendState;
|
void* InitData;
|
||||||
}RenderStates;
|
|
||||||
|
|
||||||
struct
|
BUFFER_INIT_DESC()
|
||||||
{
|
{
|
||||||
std::vector<Oyster::Buffer*> Vertex;
|
InitData = NULL;
|
||||||
std::vector<Oyster::Buffer*> Geometry;
|
Usage = BUFFER_DEFAULT;
|
||||||
std::vector<Oyster::Buffer*> Pixel;
|
|
||||||
}CBuffers;
|
|
||||||
|
|
||||||
ShaderEffect()
|
|
||||||
{
|
|
||||||
RenderStates.BlendState=NULL;
|
|
||||||
RenderStates.DepthStencil=NULL;
|
|
||||||
RenderStates.Rasterizer=NULL;
|
|
||||||
RenderStates.SampleState=NULL;
|
|
||||||
RenderStates.SampleCount=0;
|
|
||||||
Shaders.Compute=-1;
|
|
||||||
Shaders.Domain=-1;
|
|
||||||
Shaders.Geometry=-1;
|
|
||||||
Shaders.Hull=-1;
|
|
||||||
Shaders.Pixel=-1;
|
|
||||||
Shaders.Vertex=-1;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
enum ShaderType
|
protected:
|
||||||
|
ID3D11Buffer* mBuffer;
|
||||||
|
BUFFER_TYPE mType;
|
||||||
|
BUFFER_USAGE mUsage;
|
||||||
|
|
||||||
|
UINT32 mElementSize;
|
||||||
|
UINT32 mElementCount;
|
||||||
|
public:
|
||||||
|
Buffer();
|
||||||
|
virtual ~Buffer();
|
||||||
|
|
||||||
|
HRESULT Init(const BUFFER_INIT_DESC& initDesc);
|
||||||
|
|
||||||
|
void* Map();
|
||||||
|
void Unmap();
|
||||||
|
|
||||||
|
operator ID3D11Buffer*();
|
||||||
|
operator const ID3D11Buffer*() const;
|
||||||
|
|
||||||
|
HRESULT Apply(UINT32 misc = 0) const;
|
||||||
|
|
||||||
|
ID3D11Buffer* GetBufferPointer();
|
||||||
|
UINT32 GetVertexSize();
|
||||||
|
UINT32 GetElementCount();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class ShaderManager
|
||||||
{
|
{
|
||||||
Vertex,
|
public:
|
||||||
Hull,
|
struct ShaderEffect
|
||||||
Domain,
|
{
|
||||||
Geometry,
|
struct
|
||||||
Pixel,
|
{
|
||||||
Compute
|
int Pixel,Vertex,Geometry,Compute,Hull,Domain;
|
||||||
|
}Shaders;
|
||||||
|
|
||||||
|
struct IAStage_
|
||||||
|
{
|
||||||
|
ID3D11InputLayout* Layout;
|
||||||
|
D3D11_PRIMITIVE_TOPOLOGY Topology;
|
||||||
|
}IAStage;
|
||||||
|
|
||||||
|
struct RenderStates_
|
||||||
|
{
|
||||||
|
ID3D11DepthStencilState *DepthStencil;
|
||||||
|
ID3D11RasterizerState *Rasterizer;
|
||||||
|
ID3D11SamplerState **SampleState;
|
||||||
|
int SampleCount;
|
||||||
|
ID3D11BlendState *BlendState;
|
||||||
|
}RenderStates;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
std::vector<Buffer*> Vertex;
|
||||||
|
std::vector<Buffer*> Geometry;
|
||||||
|
std::vector<Buffer*> Pixel;
|
||||||
|
}CBuffers;
|
||||||
|
|
||||||
|
ShaderEffect()
|
||||||
|
{
|
||||||
|
RenderStates.BlendState=NULL;
|
||||||
|
RenderStates.DepthStencil=NULL;
|
||||||
|
RenderStates.Rasterizer=NULL;
|
||||||
|
RenderStates.SampleState=NULL;
|
||||||
|
RenderStates.SampleCount=0;
|
||||||
|
Shaders.Compute=-1;
|
||||||
|
Shaders.Domain=-1;
|
||||||
|
Shaders.Geometry=-1;
|
||||||
|
Shaders.Hull=-1;
|
||||||
|
Shaders.Pixel=-1;
|
||||||
|
Shaders.Vertex=-1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
enum ShaderType
|
||||||
|
{
|
||||||
|
Vertex,
|
||||||
|
Hull,
|
||||||
|
Domain,
|
||||||
|
Geometry,
|
||||||
|
Pixel,
|
||||||
|
Compute
|
||||||
|
};
|
||||||
|
|
||||||
|
static void SetShaderEffect(ShaderEffect);
|
||||||
|
|
||||||
|
static void CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout);
|
||||||
|
|
||||||
|
static bool Init(std::wstring filename, ShaderType type, std::wstring name, bool Precompiled = true);
|
||||||
|
|
||||||
|
struct Get
|
||||||
|
{
|
||||||
|
static int Pixel(std::wstring Name);
|
||||||
|
static int Vertex(std::wstring Name);
|
||||||
|
static int Geometry(std::wstring Name);
|
||||||
|
static int Compute(std::wstring Name);
|
||||||
|
static int Hull(std::wstring Name);
|
||||||
|
static int Domain(std::wstring Name);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Set
|
||||||
|
{
|
||||||
|
static void Pixel(int Index);
|
||||||
|
static void Vertex(int Index);
|
||||||
|
static void Geometry(int Index);
|
||||||
|
static void Compute(int Index);
|
||||||
|
static void Hull(int Index);
|
||||||
|
static void Domain(int Index);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
static void SetShaderEffect(ShaderEffect);
|
//Set resulotion Before Calling Full Init
|
||||||
|
class Init
|
||||||
static void CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout);
|
|
||||||
|
|
||||||
static bool Init(std::wstring filename, ShaderType type, std::wstring name, bool Precompiled = true);
|
|
||||||
|
|
||||||
struct Get
|
|
||||||
{
|
{
|
||||||
static int Pixel(std::wstring Name);
|
public:
|
||||||
static int Vertex(std::wstring Name);
|
enum State
|
||||||
static int Geometry(std::wstring Name);
|
{
|
||||||
static int Compute(std::wstring Name);
|
Sucsess,
|
||||||
static int Hull(std::wstring Name);
|
Fail
|
||||||
static int Domain(std::wstring Name);
|
};
|
||||||
};
|
|
||||||
|
|
||||||
struct Set
|
static State CreateDeviceAndDeviceContext(bool SingleThreaded = true, bool Reference = false, bool ForceDX11 = true);
|
||||||
{
|
|
||||||
static void Pixel(int Index);
|
static State CreateSwapChain(HWND Window, int NrofBuffers,bool MSAA_Quality,bool Fullscreen, Oyster::Math::Float2 Size);
|
||||||
static void Vertex(int Index);
|
|
||||||
static void Geometry(int Index);
|
static State CreateDepthStencil(bool MSAA_Quality, Oyster::Math::Float2 Size);
|
||||||
static void Compute(int Index);
|
|
||||||
static void Hull(int Index);
|
static State CreateBackBufferViews();
|
||||||
static void Domain(int Index);
|
|
||||||
|
static State CreateViewPort(Oyster::Math::Float2 Origin, Oyster::Math::Float2 Size);
|
||||||
|
|
||||||
|
static State FullInit(HWND Window, bool MSAA_Quality, bool Fullscreen);
|
||||||
|
|
||||||
|
static State ReInitialize(HWND Window, bool MSAA_Quality, bool Fullscreen);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,14 @@
|
||||||
// http://lolengine.net/blog/2011/3/4/fuck-you-microsoft-near-far-macros
|
// http://lolengine.net/blog/2011/3/4/fuck-you-microsoft-near-far-macros
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <D3D11.h>
|
#include <D3D11.h>
|
||||||
#include <d3dCompiler.h>
|
|
||||||
|
|
||||||
#pragma comment(lib, "d3d11.lib")
|
#pragma comment(lib, "d3d11.lib")
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#include <d3dcompiler.h>
|
||||||
#pragma comment(lib, "d3dcompiler.lib")
|
#pragma comment(lib, "d3dcompiler.lib")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
|
@ -0,0 +1,337 @@
|
||||||
|
#include "Core.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
Core::Init::State Core::Init::CreateDeviceAndDeviceContext(bool SingleThreaded,bool Reference,bool ForceDX11)
|
||||||
|
{
|
||||||
|
UINT createDeviceFlags = 0;
|
||||||
|
|
||||||
|
if(Core::deviceContext)
|
||||||
|
{
|
||||||
|
Core::deviceContext->Release();
|
||||||
|
delete Core::deviceContext;
|
||||||
|
}
|
||||||
|
if(Core::device)
|
||||||
|
{
|
||||||
|
Core::device->Release();
|
||||||
|
delete Core::device;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( SingleThreaded )
|
||||||
|
createDeviceFlags = ::D3D11_CREATE_DEVICE_SINGLETHREADED;
|
||||||
|
|
||||||
|
::D3D_DRIVER_TYPE driverType = ::D3D_DRIVER_TYPE_HARDWARE;
|
||||||
|
|
||||||
|
if(Reference)
|
||||||
|
driverType = D3D_DRIVER_TYPE_REFERENCE;
|
||||||
|
|
||||||
|
#if defined(DEBUG) || defined(_DEBUG)
|
||||||
|
log << "DirectX running in debug mode.\n";
|
||||||
|
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
D3D_FEATURE_LEVEL featureLevelsToTry[] =
|
||||||
|
{
|
||||||
|
D3D_FEATURE_LEVEL_11_0,
|
||||||
|
D3D_FEATURE_LEVEL_10_1,
|
||||||
|
D3D_FEATURE_LEVEL_10_0
|
||||||
|
};
|
||||||
|
D3D_FEATURE_LEVEL initiatedFeatureLevel;
|
||||||
|
|
||||||
|
if( FAILED( ::D3D11CreateDevice( NULL, // default adapter
|
||||||
|
driverType,
|
||||||
|
NULL, // no software device
|
||||||
|
createDeviceFlags,
|
||||||
|
featureLevelsToTry, 3, // default feature level array. DX11 support assumed
|
||||||
|
D3D11_SDK_VERSION,
|
||||||
|
&Core::device, // device
|
||||||
|
&initiatedFeatureLevel,
|
||||||
|
&Core::deviceContext ) ) ) // context
|
||||||
|
{ // if failed
|
||||||
|
if( Core::deviceContext ) { Core::deviceContext->Release(); Core::deviceContext = NULL; } // safe cleanup
|
||||||
|
if( Core::device ) { Core::device->Release(); Core::device = NULL; } // safe cleanup
|
||||||
|
}
|
||||||
|
|
||||||
|
if( driverType == ::D3D_DRIVER_TYPE_HARDWARE )
|
||||||
|
log << "D3D_DRIVER_TYPE_HARDWARE support discovered.\n";
|
||||||
|
else
|
||||||
|
log << "D3D_DRIVER_TYPE_REFERENCE support discovered.\n";
|
||||||
|
|
||||||
|
if( initiatedFeatureLevel == ::D3D_FEATURE_LEVEL_11_0 )
|
||||||
|
{
|
||||||
|
log << "DirectX Featurelevel 11.0 supported.\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(ForceDX11)
|
||||||
|
return Init::Fail;
|
||||||
|
if( initiatedFeatureLevel == ::D3D_FEATURE_LEVEL_10_1 )
|
||||||
|
{
|
||||||
|
log << "DirectX Featurelevel 10.1 supported.\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( initiatedFeatureLevel == ::D3D_FEATURE_LEVEL_10_0 )
|
||||||
|
{
|
||||||
|
log << "DirectX Featurelevel 10.0 supported.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(Core::device)
|
||||||
|
return Init::Sucsess;
|
||||||
|
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::CreateSwapChain(HWND Window, int NrofBuffers,bool MSAA_Quality,bool Fullscreen, Oyster::Math::Float2 Size)
|
||||||
|
{
|
||||||
|
//generate static Swapchain Desc
|
||||||
|
DXGI_SWAP_CHAIN_DESC desc;
|
||||||
|
desc.OutputWindow=Window;
|
||||||
|
desc.BufferCount=NrofBuffers;
|
||||||
|
desc.Windowed=!Fullscreen;
|
||||||
|
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_UNORDERED_ACCESS;
|
||||||
|
desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||||
|
desc.Flags=0;
|
||||||
|
desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
|
||||||
|
desc.BufferDesc.Scaling = DXGI_MODE_SCALING_CENTERED;
|
||||||
|
desc.BufferDesc.RefreshRate.Denominator=1;
|
||||||
|
desc.BufferDesc.RefreshRate.Numerator=60;
|
||||||
|
|
||||||
|
desc.BufferDesc.Height = (UINT)Size.y;
|
||||||
|
desc.BufferDesc.Width = (UINT)Size.x;
|
||||||
|
|
||||||
|
if(Core::swapChain)
|
||||||
|
{
|
||||||
|
Core::swapChain->Release();
|
||||||
|
delete Core::swapChain;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Check and Set multiSampling
|
||||||
|
if(MSAA_Quality)
|
||||||
|
{
|
||||||
|
if(FAILED(Core::device->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM,4,&desc.SampleDesc.Quality)))
|
||||||
|
{
|
||||||
|
log<< "Failed to check multisample quality levels (MSAAQuality).\n";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
desc.SampleDesc.Count=4;
|
||||||
|
--desc.SampleDesc.Quality;
|
||||||
|
log << "Supported multisample quality levels (MSAAQuality): " << desc.SampleDesc.Quality+1 << "x\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
desc.SampleDesc.Count=1;
|
||||||
|
desc.SampleDesc.Quality=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get Device Factory
|
||||||
|
::IDXGIDevice *dxgiDevice = NULL;
|
||||||
|
if( FAILED( Core::device->QueryInterface( __uuidof( IDXGIDevice ), (void**)&dxgiDevice ) ) )
|
||||||
|
{
|
||||||
|
log << "Failed to Query for the GPU's dxgiDevice.\nFailed to create swapChain for the GPU.\n";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
::IDXGIAdapter *dxgiAdapter = NULL;
|
||||||
|
if( FAILED( dxgiDevice->GetParent( __uuidof( IDXGIAdapter ), (void**)&dxgiAdapter ) ) )
|
||||||
|
{
|
||||||
|
dxgiDevice->Release();
|
||||||
|
log << "Failed to get GPU's parent dxgiAdapter.\nFailed to create swapChain for the GPU.\n";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
dxgiDevice->Release();
|
||||||
|
|
||||||
|
::IDXGIFactory *dxgiFactory = NULL;
|
||||||
|
if( FAILED( dxgiAdapter->GetParent( __uuidof( IDXGIFactory ), (void**)&dxgiFactory ) ) )
|
||||||
|
{
|
||||||
|
dxgiAdapter->Release();
|
||||||
|
log << "Failed to get GPU's parent dxgiFactory.\nFailed to create swapChain for the GPU.\n";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
dxgiAdapter->Release();
|
||||||
|
|
||||||
|
//Create SwapChain
|
||||||
|
if( FAILED( dxgiFactory->CreateSwapChain( Core::device, &desc, &Core::swapChain ) ) )
|
||||||
|
{
|
||||||
|
dxgiFactory->Release();
|
||||||
|
log << "Failed to create swapChain for the GPU.\n";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
dxgiFactory->Release();
|
||||||
|
|
||||||
|
return Init::Sucsess;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::CreateDepthStencil(bool MSAA_Quality, Oyster::Math::Float2 Size)
|
||||||
|
{
|
||||||
|
D3D11_TEXTURE2D_DESC desc;
|
||||||
|
desc.MipLevels=1;
|
||||||
|
desc.ArraySize=1;
|
||||||
|
desc.Format = DXGI_FORMAT_D32_FLOAT;
|
||||||
|
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||||
|
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||||
|
desc.CPUAccessFlags=0;
|
||||||
|
desc.MiscFlags=0;
|
||||||
|
desc.Height = (UINT)Size.y;
|
||||||
|
desc.Width = (UINT)Size.x;
|
||||||
|
|
||||||
|
if(Core::depthStencil)
|
||||||
|
{
|
||||||
|
Core::depthStencil->Release();
|
||||||
|
delete Core::depthStencil;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check and Set multiSampling
|
||||||
|
if(MSAA_Quality)
|
||||||
|
{
|
||||||
|
if(FAILED(Core::device->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM,4,&desc.SampleDesc.Quality)))
|
||||||
|
{
|
||||||
|
log<< "Failed to check multisample quality levels (MSAAQuality).\n";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
desc.SampleDesc.Count=4;
|
||||||
|
--desc.SampleDesc.Quality;
|
||||||
|
log << "Supported multisample quality levels (MSAAQuality): " << desc.SampleDesc.Quality+1 << "x\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
desc.SampleDesc.Count=1;
|
||||||
|
desc.SampleDesc.Quality=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ID3D11Texture2D* depthstencil;
|
||||||
|
|
||||||
|
if(FAILED(Core::device->CreateTexture2D(&desc,0,&depthstencil)))
|
||||||
|
return Init::Fail;
|
||||||
|
if(FAILED(Core::device->CreateDepthStencilView(depthstencil,0,&Core::depthStencil)))
|
||||||
|
{
|
||||||
|
depthstencil->Release();
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
depthstencil->Release();
|
||||||
|
|
||||||
|
return Init::Sucsess;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::CreateBackBufferViews()
|
||||||
|
{
|
||||||
|
D3D11_UNORDERED_ACCESS_VIEW_DESC descView;
|
||||||
|
ZeroMemory( &descView, sizeof(descView) );
|
||||||
|
descView.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2D;
|
||||||
|
descView.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
descView.Texture2D.MipSlice=0;
|
||||||
|
|
||||||
|
ID3D11Texture2D* backBuffer;
|
||||||
|
if(FAILED(Core::swapChain->GetBuffer(0,__uuidof(ID3D11Texture2D),reinterpret_cast<void**>(&backBuffer))))
|
||||||
|
{
|
||||||
|
log << "Failed to get BackBuffer from Swapchain";
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
if(Core::backBufferRTV)
|
||||||
|
{
|
||||||
|
Core::backBufferRTV->Release();
|
||||||
|
delete Core::backBufferRTV;
|
||||||
|
}
|
||||||
|
if(FAILED(Core::device->CreateRenderTargetView(backBuffer,0,&Core::backBufferRTV)))
|
||||||
|
{
|
||||||
|
log << "Failed to create RTV for BackBuffer";
|
||||||
|
backBuffer->Release();
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
if(Core::backBufferUAV)
|
||||||
|
{
|
||||||
|
Core::backBufferUAV->Release();
|
||||||
|
delete Core::backBufferUAV;
|
||||||
|
}
|
||||||
|
if(FAILED(Core::device->CreateUnorderedAccessView(backBuffer,0,&Core::backBufferUAV)))
|
||||||
|
{
|
||||||
|
log << "Failed to create UAV for BackBuffer";
|
||||||
|
backBuffer->Release();
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
backBuffer->Release();
|
||||||
|
|
||||||
|
return Init::Sucsess;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::CreateViewPort(Oyster::Math::Float2 Origin, Oyster::Math::Float2 Size)
|
||||||
|
{
|
||||||
|
if(Core::viewPort)
|
||||||
|
delete Core::viewPort;
|
||||||
|
Core::viewPort = new D3D11_VIEWPORT;
|
||||||
|
|
||||||
|
Core::viewPort->TopLeftX = Origin.x;
|
||||||
|
Core::viewPort->TopLeftY = Origin.y;
|
||||||
|
Core::viewPort->Width = Size.x;
|
||||||
|
Core::viewPort->Height = Size.y;
|
||||||
|
Core::viewPort->MinDepth = 0.0f;
|
||||||
|
Core::viewPort->MaxDepth = 1.0f;
|
||||||
|
|
||||||
|
return Init::Sucsess;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::FullInit(HWND Window, bool MSAA_Quality, bool Fullscreen)
|
||||||
|
{
|
||||||
|
if(Init::CreateDeviceAndDeviceContext() == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateSwapChain(Window, 1, MSAA_Quality, Fullscreen, Core::resolution) == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateDepthStencil(MSAA_Quality, Core::resolution) == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateBackBufferViews() == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateViewPort(Oyster::Math::Float2::null, Core::resolution) == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Init::Sucsess;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::ReInitialize(HWND Window, bool MSAA_Quality, bool Fullscreen)
|
||||||
|
{
|
||||||
|
if(Init::CreateSwapChain(Window, 1, MSAA_Quality, Fullscreen, Core::resolution) == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateDepthStencil(MSAA_Quality, Core::resolution) == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateBackBufferViews() == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Init::CreateViewPort(Oyster::Math::Float2::null, Core::resolution) == Init::Fail)
|
||||||
|
{
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Init::Sucsess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,351 +1,351 @@
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
const char* ShaderFunction = "main";
|
const char* ShaderFunction = "main";
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
bool LoadPrecompiled(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name);
|
namespace Graphics
|
||||||
bool LoadCompile(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name);
|
|
||||||
namespace
|
|
||||||
{
|
{
|
||||||
struct ShaderData
|
bool LoadPrecompiled(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name);
|
||||||
|
bool LoadCompile(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name);
|
||||||
|
namespace
|
||||||
{
|
{
|
||||||
size_t size;
|
struct ShaderData
|
||||||
char* data;
|
{
|
||||||
};
|
size_t size;
|
||||||
std::vector<ID3D11PixelShader*> PS;
|
char* data;
|
||||||
std::map<std::wstring,int> PSMap;
|
};
|
||||||
|
std::vector<ID3D11PixelShader*> PS;
|
||||||
|
std::map<std::wstring,int> PSMap;
|
||||||
|
|
||||||
std::vector<ID3D11GeometryShader*> GS;
|
std::vector<ID3D11GeometryShader*> GS;
|
||||||
std::map<std::wstring,int> GSMap;
|
std::map<std::wstring,int> GSMap;
|
||||||
|
|
||||||
std::vector<ID3D11ComputeShader*> CS;
|
std::vector<ID3D11ComputeShader*> CS;
|
||||||
std::map<std::wstring,int> CSMap;
|
std::map<std::wstring,int> CSMap;
|
||||||
|
|
||||||
std::vector<ID3D11VertexShader*> VS;
|
std::vector<ID3D11VertexShader*> VS;
|
||||||
std::vector<ShaderData> VData;
|
std::vector<ShaderData> VData;
|
||||||
std::map<std::wstring,int> VSMap;
|
std::map<std::wstring,int> VSMap;
|
||||||
}
|
|
||||||
|
|
||||||
#pragma region Init
|
|
||||||
bool Core::ShaderManager::Init(std::wstring filename, ShaderType type, std::wstring name, bool Precompiled)
|
|
||||||
{
|
|
||||||
if(Precompiled)
|
|
||||||
{
|
|
||||||
return LoadPrecompiled(filename, type, name);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
#pragma region Init
|
||||||
|
bool Core::ShaderManager::Init(std::wstring filename, ShaderType type, std::wstring name, bool Precompiled)
|
||||||
{
|
{
|
||||||
return LoadCompile(filename, type, name);
|
if(Precompiled)
|
||||||
|
{
|
||||||
|
return LoadPrecompiled(filename, type, name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return LoadCompile(filename, type, name);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LoadPrecompiled(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name)
|
bool LoadPrecompiled(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::ifstream stream;
|
std::ifstream stream;
|
||||||
ShaderData sd;
|
ShaderData sd;
|
||||||
|
|
||||||
|
|
||||||
//Create Vertex shader and Layout
|
//Create Vertex shader and Layout
|
||||||
stream.open(filename, std::ifstream::in | std::ifstream::binary);
|
stream.open(filename, std::ifstream::in | std::ifstream::binary);
|
||||||
if(stream.good())
|
if(stream.good())
|
||||||
{
|
{
|
||||||
stream.seekg(0, std::ios::end);
|
stream.seekg(0, std::ios::end);
|
||||||
sd.size = size_t(stream.tellg());
|
sd.size = size_t(stream.tellg());
|
||||||
sd.data = new char[sd.size];
|
sd.data = new char[sd.size];
|
||||||
stream.seekg(0, std::ios::beg);
|
stream.seekg(0, std::ios::beg);
|
||||||
stream.read(&sd.data[0], sd.size);
|
stream.read(&sd.data[0], sd.size);
|
||||||
stream.close();
|
stream.close();
|
||||||
|
|
||||||
|
|
||||||
ID3D11VertexShader* vertex;
|
ID3D11VertexShader* vertex;
|
||||||
ID3D11GeometryShader* geometry;
|
ID3D11GeometryShader* geometry;
|
||||||
ID3D11PixelShader* pixel;
|
ID3D11PixelShader* pixel;
|
||||||
ID3D11ComputeShader* compute;
|
ID3D11ComputeShader* compute;
|
||||||
|
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case Core::ShaderManager::ShaderType::Vertex:
|
||||||
|
|
||||||
|
if(VSMap.count(name))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(FAILED(Core::device->CreateVertexShader(sd.data, sd.size, 0, &vertex)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
VSMap[name] = VS.size();
|
||||||
|
VS.push_back(vertex);
|
||||||
|
VData.push_back(sd);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Core::ShaderManager::ShaderType::Hull:
|
||||||
|
case Core::ShaderManager::ShaderType::Domain:
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case Core::ShaderManager::ShaderType::Geometry:
|
||||||
|
|
||||||
|
if(GSMap.count(name))
|
||||||
|
return false;
|
||||||
|
if(FAILED(Core::device->CreateGeometryShader(sd.data, sd.size, 0, &geometry)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
GSMap[name] = GS.size();
|
||||||
|
GS.push_back(geometry);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Core::ShaderManager::ShaderType::Pixel:
|
||||||
|
|
||||||
|
if(PSMap.count(name))
|
||||||
|
return false;
|
||||||
|
if(FAILED(Core::device->CreatePixelShader(sd.data, sd.size, 0, &pixel)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
PSMap[name] = PS.size();
|
||||||
|
PS.push_back(pixel);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Core::ShaderManager::ShaderType::Compute:
|
||||||
|
|
||||||
|
if(CSMap.count(name))
|
||||||
|
return false;
|
||||||
|
if(FAILED(Core::device->CreateComputeShader(sd.data, sd.size, 0, &compute)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
CSMap[name] = CS.size();
|
||||||
|
CS.push_back(compute);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LoadCompile(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name)
|
||||||
|
{
|
||||||
|
/// \todo error reporting
|
||||||
|
ID3D10Blob *Shader,*Error;
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case Core::ShaderManager::ShaderType::Vertex:
|
case Core::ShaderManager::ShaderType::Pixel:
|
||||||
|
|
||||||
if(VSMap.count(name))
|
ID3D11PixelShader* pixel;
|
||||||
return false;
|
|
||||||
|
|
||||||
if(FAILED(Core::Device->CreateVertexShader(sd.data, sd.size, 0, &vertex)))
|
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"ps_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error)))
|
||||||
{
|
{
|
||||||
|
std::string fel = (char*)Error->GetBufferPointer();
|
||||||
|
Error->Release();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
VSMap[name] = VS.size();
|
if(FAILED(Core::device->CreatePixelShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&pixel)))
|
||||||
VS.push_back(vertex);
|
|
||||||
VData.push_back(sd);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Core::ShaderManager::ShaderType::Hull:
|
|
||||||
case Core::ShaderManager::ShaderType::Domain:
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
case Core::ShaderManager::ShaderType::Geometry:
|
|
||||||
|
|
||||||
if(GSMap.count(name))
|
|
||||||
return false;
|
|
||||||
if(FAILED(Core::Device->CreateGeometryShader(sd.data, sd.size, 0, &geometry)))
|
|
||||||
{
|
{
|
||||||
|
Shader->Release();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
GSMap[name] = GS.size();
|
|
||||||
GS.push_back(geometry);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Core::ShaderManager::ShaderType::Pixel:
|
|
||||||
|
|
||||||
if(PSMap.count(name))
|
|
||||||
return false;
|
|
||||||
if(FAILED(Core::Device->CreatePixelShader(sd.data, sd.size, 0, &pixel)))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
PSMap[name] = PS.size();
|
|
||||||
PS.push_back(pixel);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Core::ShaderManager::ShaderType::Compute:
|
|
||||||
|
|
||||||
if(CSMap.count(name))
|
|
||||||
return false;
|
|
||||||
if(FAILED(Core::Device->CreateComputeShader(sd.data, sd.size, 0, &compute)))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
CSMap[name] = CS.size();
|
|
||||||
CS.push_back(compute);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LoadCompile(std::wstring filename, Core::ShaderManager::ShaderType type, std::wstring name)
|
|
||||||
{
|
|
||||||
/// \todo error reporting
|
|
||||||
ID3D10Blob *Shader,*Error;
|
|
||||||
switch(type)
|
|
||||||
{
|
|
||||||
case Core::ShaderManager::ShaderType::Pixel:
|
|
||||||
|
|
||||||
ID3D11PixelShader* pixel;
|
|
||||||
|
|
||||||
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"ps_5_0",0,0,&Shader,&Error)))
|
|
||||||
{
|
|
||||||
std::string fel = (char*)Error->GetBufferPointer();
|
|
||||||
Error->Release();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(FAILED(Oyster::Core::Device->CreatePixelShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&pixel)))
|
|
||||||
{
|
|
||||||
Error->Release();
|
|
||||||
Shader->Release();
|
Shader->Release();
|
||||||
return false;
|
if(!PSMap.count(name))
|
||||||
}
|
{
|
||||||
Shader->Release();
|
PSMap[name] = PS.size();
|
||||||
if(!PSMap.count(name))
|
PS.push_back(pixel);
|
||||||
{
|
}
|
||||||
PSMap[name] = PS.size();
|
else
|
||||||
PS.push_back(pixel);
|
{
|
||||||
}
|
PS[PSMap[name]] = pixel;
|
||||||
else
|
}
|
||||||
{
|
break;
|
||||||
PS[PSMap[name]] = pixel;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Core::ShaderManager::ShaderType::Geometry:
|
case Core::ShaderManager::ShaderType::Geometry:
|
||||||
|
|
||||||
ID3D11GeometryShader* geometry;
|
ID3D11GeometryShader* geometry;
|
||||||
|
|
||||||
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"gs_5_0",0,0,&Shader,&Error)))
|
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"gs_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error)))
|
||||||
{
|
{
|
||||||
std::string fel = (char*)Error->GetBufferPointer();
|
std::string fel = (char*)Error->GetBufferPointer();
|
||||||
Error->Release();
|
Error->Release();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(FAILED(Oyster::Core::Device->CreateGeometryShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&geometry)))
|
if(FAILED(Core::device->CreateGeometryShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&geometry)))
|
||||||
{
|
{
|
||||||
Error->Release();
|
Shader->Release();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Shader->Release();
|
Shader->Release();
|
||||||
return false;
|
if(!GSMap.count(name))
|
||||||
}
|
{
|
||||||
Shader->Release();
|
GSMap[name] = GS.size();
|
||||||
if(!GSMap.count(name))
|
GS.push_back(geometry);
|
||||||
{
|
}
|
||||||
GSMap[name] = GS.size();
|
else
|
||||||
GS.push_back(geometry);
|
{
|
||||||
}
|
GS[GSMap[name]] = geometry;
|
||||||
else
|
}
|
||||||
{
|
break;
|
||||||
GS[GSMap[name]] = geometry;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Core::ShaderManager::ShaderType::Vertex:
|
case Core::ShaderManager::ShaderType::Vertex:
|
||||||
|
|
||||||
ID3D11VertexShader* vertex;
|
ID3D11VertexShader* vertex;
|
||||||
|
|
||||||
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"vs_5_0",0,0,&Shader,&Error)))
|
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"vs_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error)))
|
||||||
{
|
{
|
||||||
std::string fel = (char*)Error->GetBufferPointer();
|
std::string fel = (char*)Error->GetBufferPointer();
|
||||||
Error->Release();
|
Error->Release();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(FAILED(Oyster::Core::Device->CreateVertexShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&vertex)))
|
if(FAILED(Core::device->CreateVertexShader(Shader->GetBufferPointer(),Shader->GetBufferSize(),NULL,&vertex)))
|
||||||
{
|
{
|
||||||
Error->Release();
|
Shader->Release();
|
||||||
Shader->Release();
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
if(!VSMap.count(name))
|
||||||
if(!VSMap.count(name))
|
{
|
||||||
{
|
VSMap[name] = VS.size();
|
||||||
VSMap[name] = VS.size();
|
VS.push_back(vertex);
|
||||||
VS.push_back(vertex);
|
ShaderData sd;
|
||||||
ShaderData sd;
|
sd.size = Shader->GetBufferSize();
|
||||||
sd.size = Shader->GetBufferSize();
|
sd.data = new char[sd.size];
|
||||||
sd.data = new char[sd.size];
|
memcpy(sd.data,Shader->GetBufferPointer(),sd.size);
|
||||||
memcpy(sd.data,Shader->GetBufferPointer(),sd.size);
|
VData.push_back(sd);
|
||||||
VData.push_back(sd);
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
VS[VSMap[name]] = vertex;
|
||||||
VS[VSMap[name]] = vertex;
|
delete[] VData[VSMap[name]].data;
|
||||||
delete[] VData[VSMap[name]].data;
|
VData[VSMap[name]].size = Shader->GetBufferSize();
|
||||||
VData[VSMap[name]].size = Shader->GetBufferSize();
|
VData[VSMap[name]].data = new char[VData[VSMap[name]].size];
|
||||||
VData[VSMap[name]].data = new char[VData[VSMap[name]].size];
|
memcpy(VData[VSMap[name]].data,Shader->GetBufferPointer(),VData[VSMap[name]].size);
|
||||||
memcpy(VData[VSMap[name]].data,Shader->GetBufferPointer(),VData[VSMap[name]].size);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Shader->Release();
|
Shader->Release();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
#pragma endregion
|
||||||
}
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
void Core::ShaderManager::CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout)
|
void Core::ShaderManager::CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout)
|
||||||
{
|
{
|
||||||
if(VertexIndex==-1)
|
if(VertexIndex==-1)
|
||||||
|
{
|
||||||
|
Layout=0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Core::device->CreateInputLayout(desc,ElementCount,VData[VertexIndex].data,VData[VertexIndex].size,&Layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma region Get
|
||||||
|
int Core::ShaderManager::Get::Pixel(std::wstring Name)
|
||||||
|
{
|
||||||
|
if(PSMap.count(Name))
|
||||||
|
return PSMap[Name];
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Core::ShaderManager::Get::Vertex(std::wstring Name)
|
||||||
|
{
|
||||||
|
if(VSMap.count(Name))
|
||||||
|
return VSMap[Name];
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int Core::ShaderManager::Get::Geometry(std::wstring Name)
|
||||||
|
{
|
||||||
|
if(GSMap.count(Name))
|
||||||
|
return GSMap[Name];
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Core::ShaderManager::Get::Compute(std::wstring Name)
|
||||||
|
{
|
||||||
|
if(CSMap.count(Name))
|
||||||
|
return CSMap[Name];
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int Core::ShaderManager::Get::Hull(std::wstring Name)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int Core::ShaderManager::Get::Domain(std::wstring Name)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Set
|
||||||
|
/// \todo smart set
|
||||||
|
void Core::ShaderManager::Set::Pixel(int Index)
|
||||||
|
{
|
||||||
|
if(Index==-1)
|
||||||
|
Core::deviceContext->PSSetShader( NULL,NULL,0);
|
||||||
|
else
|
||||||
|
Core::deviceContext->PSSetShader( PS[Index],NULL,0);
|
||||||
|
}
|
||||||
|
void Core::ShaderManager::Set::Vertex(int Index)
|
||||||
|
{
|
||||||
|
if(Index==-1)
|
||||||
|
Core::deviceContext->VSSetShader( NULL,NULL,0);
|
||||||
|
else
|
||||||
|
Core::deviceContext->VSSetShader( VS[Index],NULL,0);
|
||||||
|
}
|
||||||
|
void Core::ShaderManager::Set::Geometry(int Index)
|
||||||
|
{
|
||||||
|
if(Index==-1)
|
||||||
|
Core::deviceContext->GSSetShader( NULL,NULL,0);
|
||||||
|
else
|
||||||
|
Core::deviceContext->GSSetShader( GS[Index],NULL,0);
|
||||||
|
}
|
||||||
|
void Core::ShaderManager::Set::Compute(int Index)
|
||||||
|
{
|
||||||
|
if(Index==-1)
|
||||||
|
Core::deviceContext->CSSetShader( NULL,NULL,0);
|
||||||
|
else
|
||||||
|
Core::deviceContext->CSSetShader( CS[Index],NULL,0);
|
||||||
|
}
|
||||||
|
/// \todo set Hull
|
||||||
|
void Core::ShaderManager::Set::Hull(int Index)
|
||||||
{
|
{
|
||||||
Layout=0;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Device->CreateInputLayout(desc,ElementCount,VData[VertexIndex].data,VData[VertexIndex].size,&Layout);
|
/// \todo set Domain
|
||||||
}
|
void Core::ShaderManager::Set::Domain(int Index)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region Get
|
/// \todo smart Set ie. not resetting the shader
|
||||||
int Core::ShaderManager::Get::Pixel(std::wstring Name)
|
/// \todo research states
|
||||||
{
|
/// \todo smart buffer set
|
||||||
if(PSMap.count(Name))
|
void Core::ShaderManager::SetShaderEffect(ShaderEffect se)
|
||||||
return PSMap[Name];
|
{
|
||||||
return -1;
|
Set::Pixel(se.Shaders.Pixel);
|
||||||
|
Set::Vertex(se.Shaders.Vertex);
|
||||||
|
Set::Geometry(se.Shaders.Geometry);
|
||||||
|
Set::Compute(se.Shaders.Compute);
|
||||||
|
Core::deviceContext->IASetInputLayout(se.IAStage.Layout);
|
||||||
|
Core::deviceContext->IASetPrimitiveTopology(se.IAStage.Topology);
|
||||||
|
for(unsigned int i=0;i<se.CBuffers.Vertex.size();++i)
|
||||||
|
se.CBuffers.Vertex[i]->Apply(i);
|
||||||
|
for(unsigned int i=0;i<se.CBuffers.Geometry.size();++i)
|
||||||
|
se.CBuffers.Geometry[i]->Apply(i);
|
||||||
|
for(unsigned int i=0;i<se.CBuffers.Pixel.size();++i)
|
||||||
|
se.CBuffers.Pixel[i]->Apply(i);
|
||||||
|
Core::deviceContext->RSSetState(se.RenderStates.Rasterizer);
|
||||||
|
Core::deviceContext->PSSetSamplers(0,se.RenderStates.SampleCount,se.RenderStates.SampleState);
|
||||||
|
float test[4] = {0};
|
||||||
|
Core::deviceContext->OMSetBlendState(se.RenderStates.BlendState,test,-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Core::ShaderManager::Get::Vertex(std::wstring Name)
|
|
||||||
{
|
|
||||||
if(VSMap.count(Name))
|
|
||||||
return VSMap[Name];
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
int Core::ShaderManager::Get::Geometry(std::wstring Name)
|
|
||||||
{
|
|
||||||
if(GSMap.count(Name))
|
|
||||||
return GSMap[Name];
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Core::ShaderManager::Get::Compute(std::wstring Name)
|
|
||||||
{
|
|
||||||
if(CSMap.count(Name))
|
|
||||||
return CSMap[Name];
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
int Core::ShaderManager::Get::Hull(std::wstring Name)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
int Core::ShaderManager::Get::Domain(std::wstring Name)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
#pragma region Set
|
|
||||||
/// \todo smart set
|
|
||||||
void Core::ShaderManager::Set::Pixel(int Index)
|
|
||||||
{
|
|
||||||
if(Index==-1)
|
|
||||||
DeviceContext->PSSetShader( NULL,NULL,0);
|
|
||||||
else
|
|
||||||
DeviceContext->PSSetShader( PS[Index],NULL,0);
|
|
||||||
}
|
|
||||||
void Core::ShaderManager::Set::Vertex(int Index)
|
|
||||||
{
|
|
||||||
if(Index==-1)
|
|
||||||
DeviceContext->VSSetShader( NULL,NULL,0);
|
|
||||||
else
|
|
||||||
DeviceContext->VSSetShader( VS[Index],NULL,0);
|
|
||||||
}
|
|
||||||
void Core::ShaderManager::Set::Geometry(int Index)
|
|
||||||
{
|
|
||||||
if(Index==-1)
|
|
||||||
DeviceContext->GSSetShader( NULL,NULL,0);
|
|
||||||
else
|
|
||||||
DeviceContext->GSSetShader( GS[Index],NULL,0);
|
|
||||||
}
|
|
||||||
void Core::ShaderManager::Set::Compute(int Index)
|
|
||||||
{
|
|
||||||
if(Index==-1)
|
|
||||||
DeviceContext->CSSetShader( NULL,NULL,0);
|
|
||||||
else
|
|
||||||
DeviceContext->CSSetShader( CS[Index],NULL,0);
|
|
||||||
}
|
|
||||||
/// \todo set Hull
|
|
||||||
void Core::ShaderManager::Set::Hull(int Index)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/// \todo set Domain
|
|
||||||
void Core::ShaderManager::Set::Domain(int Index)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
/// \todo smart Set ie. not resetting the shader
|
|
||||||
/// \todo research states
|
|
||||||
/// \todo smart buffer set
|
|
||||||
void Core::ShaderManager::SetShaderEffect(ShaderEffect se)
|
|
||||||
{
|
|
||||||
Set::Pixel(se.Shaders.Pixel);
|
|
||||||
Set::Vertex(se.Shaders.Vertex);
|
|
||||||
Set::Geometry(se.Shaders.Geometry);
|
|
||||||
Set::Compute(se.Shaders.Compute);
|
|
||||||
Oyster::Core::DeviceContext->IASetInputLayout(se.IAStage.Layout);
|
|
||||||
Oyster::Core::DeviceContext->IASetPrimitiveTopology(se.IAStage.Topology);
|
|
||||||
for(unsigned int i=0;i<se.CBuffers.Vertex.size();++i)
|
|
||||||
se.CBuffers.Vertex[i]->Apply(i);
|
|
||||||
for(unsigned int i=0;i<se.CBuffers.Geometry.size();++i)
|
|
||||||
se.CBuffers.Geometry[i]->Apply(i);
|
|
||||||
for(unsigned int i=0;i<se.CBuffers.Pixel.size();++i)
|
|
||||||
se.CBuffers.Pixel[i]->Apply(i);
|
|
||||||
Oyster::Core::DeviceContext->RSSetState(se.RenderStates.Rasterizer);
|
|
||||||
Oyster::Core::DeviceContext->PSSetSamplers(0,se.RenderStates.SampleCount,se.RenderStates.SampleState);
|
|
||||||
float test[4] = {0};
|
|
||||||
Oyster::Core::DeviceContext->OMSetBlendState(se.RenderStates.BlendState,test,-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
#include "..\OysterGraphics\Core\Dx11Includes.h"
|
||||||
|
#include "OysterMath.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Definitions
|
||||||
|
{
|
||||||
|
struct ObjVertex
|
||||||
|
{
|
||||||
|
Oyster::Math::Float3 pos;
|
||||||
|
Oyster::Math::Float2 uv;
|
||||||
|
Oyster::Math::Float3 normal;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VP
|
||||||
|
{
|
||||||
|
Oyster::Math::Matrix V;
|
||||||
|
Oyster::Math::Matrix P;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FinalVertex
|
||||||
|
{
|
||||||
|
Oyster::Math::Float3 pos;
|
||||||
|
Oyster::Math::Float2 uv;
|
||||||
|
Oyster::Math::Float3 normal;
|
||||||
|
Oyster::Math::Float3 tangent;
|
||||||
|
Oyster::Math::Float3 biTangent;
|
||||||
|
Oyster::Math::Float4 boneIndex;
|
||||||
|
Oyster::Math::Float4 boneWeights;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
#include "GFXAPI.h"
|
||||||
|
#include "../Core/Core.h"
|
||||||
|
#include "../Render/Resources/Resources.h"
|
||||||
|
#include "../Render/Rendering/Render.h"
|
||||||
|
#include "../FileLoader/ObjReader.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
API::State API::Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Math::Float2 resulotion)
|
||||||
|
{
|
||||||
|
Core::resolution = resulotion;
|
||||||
|
|
||||||
|
if(Core::Init::FullInit(Window, MSAA_Quality, Fullscreen) == Core::Init::Fail)
|
||||||
|
{
|
||||||
|
return API::Fail;
|
||||||
|
}
|
||||||
|
if(Render::Resources::Init() == Core::Init::Fail)
|
||||||
|
{
|
||||||
|
return API::Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
Render::Preparations::Basic::SetViewPort();
|
||||||
|
return API::Sucsess;
|
||||||
|
}
|
||||||
|
|
||||||
|
void API::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection)
|
||||||
|
{
|
||||||
|
Render::Rendering::Basic::NewFrame(View, Projection);
|
||||||
|
}
|
||||||
|
|
||||||
|
void API::RenderScene(Model::Model* models, int count)
|
||||||
|
{
|
||||||
|
Render::Rendering::Basic::RenderScene(models,count);
|
||||||
|
}
|
||||||
|
|
||||||
|
void API::EndFrame()
|
||||||
|
{
|
||||||
|
Render::Rendering::Basic::EndFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
API::State API::SetOptions(API::Option option)
|
||||||
|
{
|
||||||
|
return API::Sucsess;
|
||||||
|
}
|
||||||
|
|
||||||
|
Model::Model* API::CreateModel(std::wstring filename)
|
||||||
|
{
|
||||||
|
Model::Model* m = new Model::Model();
|
||||||
|
m->WorldMatrix = Oyster::Math::Float4x4::identity;
|
||||||
|
m->Visible = true;
|
||||||
|
|
||||||
|
OBJReader or;
|
||||||
|
or.readOBJFile(filename);
|
||||||
|
m->info = or.toModel();
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
void API::DeleteModel(Model::Model* model)
|
||||||
|
{
|
||||||
|
delete model;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
#include "..\Model\Model.h"
|
||||||
|
#include "OysterMath.h"
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
#if defined GFX_DLL_EXPORT
|
||||||
|
#define GFX_DLL_USAGE __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define GFX_DLL_USAGE __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
class GFX_DLL_USAGE API
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum State
|
||||||
|
{
|
||||||
|
Sucsess,
|
||||||
|
Fail
|
||||||
|
};
|
||||||
|
struct Option
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
static State Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Oyster::Math::Float2 StartResulotion);
|
||||||
|
//! @brief from Oyster::Math Float4x4, expects corect methods
|
||||||
|
static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection);
|
||||||
|
static void RenderScene(Oyster::Graphics::Model::Model* models, int count);
|
||||||
|
static void EndFrame();
|
||||||
|
|
||||||
|
static Oyster::Graphics::Model::Model* CreateModel(std::wstring filename);
|
||||||
|
static void DeleteModel(Oyster::Graphics::Model::Model* model);
|
||||||
|
|
||||||
|
static State SetOptions(Option);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,157 +9,160 @@
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
class Engine
|
namespace Graphics
|
||||||
{
|
{
|
||||||
private:
|
class Engine
|
||||||
Engine();
|
{
|
||||||
~Engine();
|
private:
|
||||||
|
Engine();
|
||||||
|
~Engine();
|
||||||
|
|
||||||
public:
|
|
||||||
class Init
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
struct Setup
|
/*class Init
|
||||||
{
|
|
||||||
int NrOfBuffers;
|
|
||||||
bool MSAA_Quality;
|
|
||||||
bool Fullscreen;
|
|
||||||
bool SingleThreaded;
|
|
||||||
bool Reference;
|
|
||||||
bool ForceDX11;
|
|
||||||
bool GenerateDepthStencil;
|
|
||||||
bool BindDefault;
|
|
||||||
HWND window;
|
|
||||||
//all but Window params have Default Values
|
|
||||||
Setup()
|
|
||||||
{
|
|
||||||
NrOfBuffers=1;
|
|
||||||
MSAA_Quality = false;
|
|
||||||
Fullscreen = true;
|
|
||||||
SingleThreaded = true;
|
|
||||||
Reference = false;
|
|
||||||
ForceDX11 = false;
|
|
||||||
GenerateDepthStencil = true;
|
|
||||||
BindDefault = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool IsInstanced();
|
|
||||||
|
|
||||||
//Creates Device and DeviceContext, if not Initialized
|
|
||||||
static bool Instance(bool SingleThreaded=true,bool Reference=false,bool ForceDX11=false);
|
|
||||||
static bool HasSwapChain();
|
|
||||||
|
|
||||||
//Creates Swapchain, if not Aready Created
|
|
||||||
static bool CreateSwapChain(HWND Window, int NrofBuffers=1,bool MSAA_Quality=false,bool Fullscreen=true);
|
|
||||||
|
|
||||||
//CreateWindow, if Not Already Created
|
|
||||||
static bool InitializeWindow(const LPCSTR appName, const LPCSTR className,const HINSTANCE &hInstance, const int &nCmdShow, WNDPROC wProc, bool HandleLoop = false );
|
|
||||||
|
|
||||||
//Performs a full initialization of a rendering pipeline, including a Window
|
|
||||||
static bool FullInit(const Setup& setup);
|
|
||||||
struct Buffers
|
|
||||||
{
|
|
||||||
static Buffer* CreateBuffer(const Buffer::BUFFER_INIT_DESC BufferDesc);
|
|
||||||
};
|
|
||||||
private:
|
|
||||||
Init();
|
|
||||||
~Init();
|
|
||||||
};
|
|
||||||
|
|
||||||
class States
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//SSAO Quality
|
|
||||||
static void SetNrOfSSAOSamples(int);
|
|
||||||
static int GetNrOfSSAOSamples();
|
|
||||||
|
|
||||||
//SSAO Frequency
|
|
||||||
static void SetSSAOSampleSpread(int);
|
|
||||||
static int GetSSAOSampleSpread();
|
|
||||||
|
|
||||||
//PointLights
|
|
||||||
static void SetMaxPointlights(int);
|
|
||||||
static int GetMaxPointlights();
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
States();
|
|
||||||
~States();
|
|
||||||
};
|
|
||||||
|
|
||||||
class Render
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Render a number of models, setting the Per model data to the included cBuffer
|
|
||||||
/// specify NULL if no such data exists
|
|
||||||
static void Geometry(const Oyster::Render::Model* models,int count,Oyster::Buffer* cBufferEveryObject, int slot);
|
|
||||||
static void Text(std::string text, Oyster::Math::Float2 size, Oyster::Math::Float3 Pos);
|
|
||||||
//static void TextBox(const Oyster::Render::
|
|
||||||
|
|
||||||
//ensure that a compatible 2D shadereffect is applied
|
|
||||||
static void ScreenQuad(ID3D11ShaderResourceView* srv, float ZPos=1);
|
|
||||||
|
|
||||||
//ensure that a compatible 2D shadereffect is applied and that pos.z is between 0 and 1
|
|
||||||
static void Sprite(ID3D11ShaderResourceView* srv, Oyster::Math::Float2 size, Oyster::Math::Float3 Pos);
|
|
||||||
|
|
||||||
static void PresentScene();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Render();
|
|
||||||
~Render();
|
|
||||||
};
|
|
||||||
|
|
||||||
class PrepareForRendering
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//Binds several rendertargets and a depthstencil
|
|
||||||
static void BindRenderTargets(ID3D11RenderTargetView** RenderTargets,int NrOfTargets,ID3D11DepthStencilView* depth);
|
|
||||||
|
|
||||||
//Binds several Rendertargest and a default depthstencil
|
|
||||||
static void BindRenderTargets(ID3D11RenderTargetView** RenderTargets,int NrOfTargets);
|
|
||||||
|
|
||||||
//Binds the backbuffer and a depthstencil
|
|
||||||
static void BindBackBuffer(ID3D11DepthStencilView* depth);
|
|
||||||
|
|
||||||
//Binds the backbuffer and a default depthstencil
|
|
||||||
static void BindBackBuffer();
|
|
||||||
|
|
||||||
//Binds the backbuffer to the compute shader
|
|
||||||
static void BindBackBufferAsUAV();
|
|
||||||
|
|
||||||
//binds several UAV to the computeshader
|
|
||||||
static void BindUAV(ID3D11UnorderedAccessView** uav, int NrOfUavs);
|
|
||||||
|
|
||||||
//Clears the backbuffer and default depthstencil
|
|
||||||
static void ClearBackBuffer(Math::Float4 color);
|
|
||||||
|
|
||||||
static void Begin2DRender();
|
|
||||||
|
|
||||||
static void Begin2DTextRender();
|
|
||||||
};
|
|
||||||
|
|
||||||
class Pipeline
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
class Deffered_Lightning
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//Basic Setup
|
struct Setup
|
||||||
static void NewFrame(const Float4& Color, const Matrix& View, const Matrix& Projection);
|
{
|
||||||
|
int NrOfBuffers;
|
||||||
|
bool MSAA_Quality;
|
||||||
|
bool Fullscreen;
|
||||||
|
bool SingleThreaded;
|
||||||
|
bool Reference;
|
||||||
|
bool ForceDX11;
|
||||||
|
bool GenerateDepthStencil;
|
||||||
|
bool BindDefault;
|
||||||
|
HWND window;
|
||||||
|
//all but Window params have Default Values
|
||||||
|
Setup()
|
||||||
|
{
|
||||||
|
NrOfBuffers=1;
|
||||||
|
MSAA_Quality = false;
|
||||||
|
Fullscreen = true;
|
||||||
|
SingleThreaded = true;
|
||||||
|
Reference = false;
|
||||||
|
ForceDX11 = false;
|
||||||
|
GenerateDepthStencil = true;
|
||||||
|
BindDefault = true;
|
||||||
|
}
|
||||||
|
|
||||||
//Geometry Pass
|
};
|
||||||
static void BeginRenderGeometry();
|
|
||||||
static void RenderGeometry(const Oyster::Render::Model* models,int count);
|
|
||||||
static void EndRenderGeometry();
|
|
||||||
|
|
||||||
//Lightning Pass
|
static bool IsInstanced();
|
||||||
static void InputPointLights(Oyster::Resources::BufferDefinitions::PointLightDescription *p, int NrOfPointlights );
|
|
||||||
static void RenderLightning();
|
//Creates Device and DeviceContext, if not Initialized
|
||||||
|
static bool Instance(bool SingleThreaded=true,bool Reference=false,bool ForceDX11=false);
|
||||||
|
static bool HasSwapChain();
|
||||||
|
|
||||||
|
//Creates Swapchain, if not Aready Created
|
||||||
|
static bool CreateSwapChain(HWND Window, int NrofBuffers=1,bool MSAA_Quality=false,bool Fullscreen=true);
|
||||||
|
|
||||||
|
//CreateWindow, if Not Already Created
|
||||||
|
static bool InitializeWindow(const LPCSTR appName, const LPCSTR className,const HINSTANCE &hInstance, const int &nCmdShow, WNDPROC wProc, bool HandleLoop = false );
|
||||||
|
|
||||||
|
//Performs a full initialization of a rendering pipeline, including a Window
|
||||||
|
static bool FullInit(const Setup& setup);
|
||||||
|
struct Buffers
|
||||||
|
{
|
||||||
|
static Buffer* CreateBuffer(const Buffer::BUFFER_INIT_DESC BufferDesc);
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
Init();
|
||||||
|
~Init();
|
||||||
|
};*/
|
||||||
|
|
||||||
|
class States
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//SSAO Quality
|
||||||
|
static void SetNrOfSSAOSamples(int);
|
||||||
|
static int GetNrOfSSAOSamples();
|
||||||
|
|
||||||
|
//SSAO Frequency
|
||||||
|
static void SetSSAOSampleSpread(int);
|
||||||
|
static int GetSSAOSampleSpread();
|
||||||
|
|
||||||
|
//PointLights
|
||||||
|
static void SetMaxPointlights(int);
|
||||||
|
static int GetMaxPointlights();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
States();
|
||||||
|
~States();
|
||||||
|
};
|
||||||
|
|
||||||
|
class Render
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/// Render a number of models, setting the Per model data to the included cBuffer
|
||||||
|
/// specify NULL if no such data exists
|
||||||
|
//static void Geometry(const Oyster::Graphics::Render::Model* models,int count,Buffer* cBufferEveryObject, int slot);
|
||||||
|
static void Text(std::string text, Oyster::Math::Float2 size, Oyster::Math::Float3 Pos);
|
||||||
|
//static void TextBox(const Oyster::Render::
|
||||||
|
|
||||||
|
//ensure that a compatible 2D shadereffect is applied
|
||||||
|
static void ScreenQuad(ID3D11ShaderResourceView* srv, float ZPos=1);
|
||||||
|
|
||||||
|
//ensure that a compatible 2D shadereffect is applied and that pos.z is between 0 and 1
|
||||||
|
static void Sprite(ID3D11ShaderResourceView* srv, Oyster::Math::Float2 size, Oyster::Math::Float3 Pos);
|
||||||
|
|
||||||
|
static void PresentScene();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Render();
|
||||||
|
~Render();
|
||||||
|
};
|
||||||
|
|
||||||
|
class PrepareForRendering
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//Binds several rendertargets and a depthstencil
|
||||||
|
static void BindRenderTargets(ID3D11RenderTargetView** RenderTargets,int NrOfTargets,ID3D11DepthStencilView* depth);
|
||||||
|
|
||||||
|
//Binds several Rendertargest and a default depthstencil
|
||||||
|
static void BindRenderTargets(ID3D11RenderTargetView** RenderTargets,int NrOfTargets);
|
||||||
|
|
||||||
|
//Binds the backbuffer and a depthstencil
|
||||||
|
static void BindBackBuffer(ID3D11DepthStencilView* depth);
|
||||||
|
|
||||||
|
//Binds the backbuffer and a default depthstencil
|
||||||
|
static void BindBackBuffer();
|
||||||
|
|
||||||
|
//Binds the backbuffer to the compute shader
|
||||||
|
static void BindBackBufferAsUAV();
|
||||||
|
|
||||||
|
//binds several UAV to the computeshader
|
||||||
|
static void BindUAV(ID3D11UnorderedAccessView** uav, int NrOfUavs);
|
||||||
|
|
||||||
|
//Clears the backbuffer and default depthstencil
|
||||||
|
static void ClearBackBuffer(Math::Float4 color);
|
||||||
|
|
||||||
|
static void Begin2DRender();
|
||||||
|
|
||||||
|
static void Begin2DTextRender();
|
||||||
|
};
|
||||||
|
|
||||||
|
class Pipeline
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
class Deffered_Lightning
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//Basic Setup
|
||||||
|
//static void NewFrame(const Float4& Color, const Matrix& View, const Matrix& Projection);
|
||||||
|
|
||||||
|
//Geometry Pass
|
||||||
|
static void BeginRenderGeometry();
|
||||||
|
//static void RenderGeometry(const Oyster::Graphics::Render::Model* models,int count);
|
||||||
|
static void EndRenderGeometry();
|
||||||
|
|
||||||
|
//Lightning Pass
|
||||||
|
//static void InputPointLights(Oyster::Resources::BufferDefinitions::PointLightDescription *p, int NrOfPointlights );
|
||||||
|
static void RenderLightning();
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,9 +1,9 @@
|
||||||
//Oyster
|
//Oyster
|
||||||
|
|
||||||
// Render
|
// Render
|
||||||
#include "Render\Model.h"
|
//#include "Render\Model.h"
|
||||||
#include "Render\Camera.h"
|
//#include "Render\Camera.h"
|
||||||
#include "Render\TextBox.h"
|
//#include "Render\TextBox.h"
|
||||||
|
|
||||||
// Core
|
// Core
|
||||||
#include "Core\Core.h"
|
#include "Core\Core.h"
|
||||||
|
@ -16,8 +16,8 @@
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
|
|
||||||
// Resources
|
// Resources
|
||||||
#include "Resourses\ShaderEffects.h"
|
//#include "Resourses\ShaderEffects.h"
|
||||||
#include "Resourses\Buffers.h"
|
//#include "Resourses\Buffers.h"
|
||||||
#include "Resourses\PipelineResources.h"
|
//#include "Resourses\PipelineResources.h"
|
||||||
#include "Resourses\GraphicsDefinitions.h"
|
//#include "Resourses\GraphicsDefinitions.h"
|
||||||
#include "Resourses\Manager.h"
|
//#include "Resourses\Manager.h"
|
|
@ -1,268 +1,152 @@
|
||||||
#include "ObjReader.h"
|
#include "OBJReader.h"
|
||||||
#include "Utilities.h"
|
#include "..\Definitions\GraphicalDefinition.h"
|
||||||
#include "..\Core\Core.h"
|
#include <sstream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <map>
|
#include "TextureLoader.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Oyster::FileLoaders;
|
OBJReader::OBJReader()
|
||||||
using namespace Oyster;
|
|
||||||
using namespace Oyster::Math;
|
|
||||||
|
|
||||||
ObjReader *ObjReader::LoadFile(std::string fileName, Oyster::Math::Float4x4 transform)
|
|
||||||
{
|
{
|
||||||
static std::map<std::string, ObjReader *> cache;
|
_mPos = 0;
|
||||||
|
_mNormal = 0;
|
||||||
ObjReader *reader = NULL;
|
_mTexel = 0;
|
||||||
|
|
||||||
if (cache.count(fileName))
|
|
||||||
{
|
|
||||||
reader = cache[fileName];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reader = new ObjReader();
|
|
||||||
reader->ParseFile(fileName, transform);
|
|
||||||
|
|
||||||
cache[fileName] = reader;
|
|
||||||
}
|
|
||||||
|
|
||||||
return reader;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjReader::ObjReader(void)
|
OBJReader::~OBJReader()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OBJReader::readOBJFile( std::wstring fileName )
|
||||||
ObjReader::~ObjReader(void)
|
|
||||||
{
|
{
|
||||||
}
|
std::fstream inStream;
|
||||||
|
std::string typeOfData = " ";
|
||||||
|
float vertexData;
|
||||||
|
std::string face1, face2, face3;
|
||||||
|
|
||||||
void ObjReader::ParseFile(std::string fileName, Float4x4 transform)
|
inStream.open( fileName, std::fstream::in );
|
||||||
{
|
|
||||||
ifstream input;
|
if( inStream.is_open() )
|
||||||
input.open(fileName.c_str());
|
|
||||||
|
|
||||||
if(!input.is_open())
|
|
||||||
{
|
{
|
||||||
return;
|
while( !inStream.eof() )
|
||||||
}
|
|
||||||
|
|
||||||
string path;
|
|
||||||
Utility::String::extractDirPath(path,fileName,'\\');
|
|
||||||
|
|
||||||
std::vector<Vertex> VertexList;
|
|
||||||
std::vector<Float3> vList;
|
|
||||||
std::vector<Float3> nList;
|
|
||||||
std::vector<Float2> uvList;
|
|
||||||
Vertex vertex1, vertex2, vertex3;
|
|
||||||
Float3 face[3];
|
|
||||||
Float3 position, normal;
|
|
||||||
Float2 uv;
|
|
||||||
string s;
|
|
||||||
|
|
||||||
while(!input.eof())
|
|
||||||
{
|
|
||||||
getline(input,s);
|
|
||||||
int offset = (int)s.find(' ');
|
|
||||||
|
|
||||||
if(offset!=-1)
|
|
||||||
{
|
{
|
||||||
string c = s.substr(0,offset);
|
inStream >> typeOfData;
|
||||||
|
|
||||||
if(c=="v")
|
if( typeOfData == "v" )
|
||||||
{
|
{
|
||||||
position = readVertex(offset,s);
|
Oyster::Math::Float3 position;
|
||||||
vList.push_back(position);
|
|
||||||
|
inStream >> vertexData;
|
||||||
|
position.x = vertexData;
|
||||||
|
|
||||||
|
inStream >> vertexData;
|
||||||
|
position.y = vertexData;
|
||||||
|
|
||||||
|
inStream >> vertexData;
|
||||||
|
position.z = vertexData;
|
||||||
|
|
||||||
|
_mVertexCoord.push_back( position );
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(c=="vt")
|
else if( typeOfData == "vt" )
|
||||||
{
|
{
|
||||||
uv = readUV(offset,s);
|
Oyster::Math::Float2 texel;
|
||||||
uvList.push_back(uv);
|
inStream >> vertexData;
|
||||||
|
texel.x = vertexData;
|
||||||
|
|
||||||
|
inStream >> vertexData;
|
||||||
|
texel.y = 1 - vertexData;
|
||||||
|
|
||||||
|
_mVertexTexture.push_back( texel );
|
||||||
}
|
}
|
||||||
else if(c=="vn")
|
else if( typeOfData == "vn" )
|
||||||
{
|
{
|
||||||
normal = readNormal(offset,s);
|
Oyster::Math::Float3 normal;
|
||||||
nList.push_back(normal);
|
inStream >> vertexData;
|
||||||
|
normal.x = vertexData;
|
||||||
|
|
||||||
|
inStream >> vertexData;
|
||||||
|
normal.y = vertexData;
|
||||||
|
|
||||||
|
inStream >> vertexData;
|
||||||
|
normal.z = vertexData;
|
||||||
|
|
||||||
|
_mVertexNormal.push_back( normal );
|
||||||
}
|
}
|
||||||
else if(c=="f")
|
else if( typeOfData == "f" )
|
||||||
{
|
{
|
||||||
readFace(offset, s, face);
|
inStream >> face1;
|
||||||
|
stringSplit( face1 );
|
||||||
|
|
||||||
|
addToOBJarray();
|
||||||
|
|
||||||
vertex1.Position = vList[(int)face[0].x];
|
inStream >> face2;
|
||||||
vertex1.UV = uvList[(int)face[0].y];
|
stringSplit( face2 );
|
||||||
vertex1.Normal = nList[(int)face[0].z];
|
|
||||||
|
|
||||||
vertex2.Position = vList[(int)face[1].x];
|
addToOBJarray();
|
||||||
vertex2.UV = uvList[(int)face[1].y];
|
|
||||||
vertex2.Normal = nList[(int)face[1].z];
|
|
||||||
|
|
||||||
vertex3.Position = vList[(int)face[2].x];
|
inStream >> face3;
|
||||||
vertex3.UV = uvList[(int)face[2].y];
|
stringSplit( face3 );
|
||||||
vertex3.Normal = nList[(int)face[2].z];
|
|
||||||
|
|
||||||
VertexList.push_back(vertex1);
|
addToOBJarray();
|
||||||
VertexList.push_back(vertex3);
|
|
||||||
VertexList.push_back(vertex2);
|
|
||||||
}
|
|
||||||
else if(c=="mtllib")
|
|
||||||
{
|
|
||||||
this->materials = GetMaterials(path+s.substr(offset+1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
input.close();
|
inStream.close();
|
||||||
|
}
|
||||||
|
|
||||||
this->numVertices = VertexList.size();
|
Oyster::Graphics::Model::ModelInfo* OBJReader::toModel()
|
||||||
this->vertices = new Vertex[this->numVertices];
|
{
|
||||||
|
Oyster::Graphics::Core::Buffer* b = new Oyster::Graphics::Core::Buffer();
|
||||||
for(size_t i=0;i<this->numVertices;++i)
|
Oyster::Graphics::Core::Buffer::BUFFER_INIT_DESC desc;
|
||||||
|
Oyster::Graphics::Model::ModelInfo* modelInfo = new Oyster::Graphics::Model::ModelInfo();
|
||||||
|
|
||||||
|
desc.ElementSize = 32;
|
||||||
|
desc.InitData = &this->_myOBJ[0];
|
||||||
|
desc.NumElements = this->_myOBJ.size();
|
||||||
|
desc.Type = Oyster::Graphics::Core::Buffer::BUFFER_TYPE::VERTEX_BUFFER;
|
||||||
|
desc.Usage = Oyster::Graphics::Core::Buffer::BUFFER_DEFAULT;
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
|
hr = b->Init(desc);
|
||||||
|
if(FAILED(hr))
|
||||||
{
|
{
|
||||||
vertices[i].Position=Math::transformVector(Math::Float4(VertexList[i].Position,1),transform);
|
//Something isn't okay here
|
||||||
vertices[i].Normal=Math::transformVector(Math::Float4(VertexList[i].Normal,0),transform);
|
|
||||||
vertices[i].UV = VertexList[i].UV;
|
|
||||||
}
|
}
|
||||||
|
modelInfo->Indexed = false;
|
||||||
|
modelInfo->VertexCount = (int)desc.NumElements;
|
||||||
|
modelInfo->Vertices = b;
|
||||||
|
|
||||||
|
//Oyster::Resource::OysterResource::LoadResource(L"Normal.png",(Oyster::Resource::CustomLoadFunction)Oyster::Graphics::Loading::LoadTexture);
|
||||||
|
|
||||||
|
|
||||||
|
return modelInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjReader::GetVertexData(Vertex **vertex,int &numVertex, std::map<std::string, ID3D11ShaderResourceView *> &Textures)
|
//Private functions
|
||||||
|
void OBJReader::stringSplit( std::string strToSplit )
|
||||||
{
|
{
|
||||||
numVertex=(int)this->numVertices;
|
char delim = '/';
|
||||||
(*vertex)=this->vertices;
|
std::string vPos, vNormal, vTexel;
|
||||||
Textures = this->materials;
|
std::stringstream aStream(strToSplit);
|
||||||
|
getline( aStream, vPos, delim );
|
||||||
|
getline( aStream, vTexel, delim );
|
||||||
|
getline( aStream, vNormal );
|
||||||
|
|
||||||
|
_mPos = atoi( vPos.c_str() );
|
||||||
|
_mNormal = atoi( vNormal.c_str() );
|
||||||
|
_mTexel = atoi( vTexel.c_str() );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Float3 ObjReader::extract(std::string d)
|
void OBJReader::addToOBJarray()
|
||||||
{
|
{
|
||||||
Float3 data;
|
OBJFormat temp;
|
||||||
int offset=(int)d.find('/');
|
|
||||||
data.x=(float)atoi(d.substr(1,offset).c_str())-1;
|
|
||||||
|
|
||||||
int newOffset = (int)d.find('/',offset+1);
|
temp._d3VertexCoord = _mVertexCoord.at( _mPos - 1 );
|
||||||
string d2=d.substr(offset+1,newOffset-offset-1);
|
temp._d3VertexNormal = _mVertexNormal.at( _mNormal - 1 );
|
||||||
data.y=(float)atoi(d2.c_str())-1;
|
temp._d3VertexTexture = _mVertexTexture.at( _mTexel - 1 );
|
||||||
offset=newOffset;
|
|
||||||
|
|
||||||
newOffset = (int)d.find('/',offset+1);
|
_myOBJ.push_back( temp );
|
||||||
string d3=d.substr(offset+1,newOffset-offset-1);
|
}
|
||||||
data.z=(float)atoi(d3.c_str())-1;
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
Float3 ObjReader::readVertex(int offset,string s)
|
|
||||||
{
|
|
||||||
int newOffset = (int)s.find(' ',offset+1);
|
|
||||||
Float3 vertex;
|
|
||||||
string d = s.substr(offset,newOffset-offset);
|
|
||||||
vertex.x = (float)atof(d.c_str());
|
|
||||||
offset=newOffset;
|
|
||||||
|
|
||||||
newOffset = (int)s.find(' ',offset+1);
|
|
||||||
vertex.y = (float)atof(s.substr(offset,newOffset-offset).c_str());
|
|
||||||
offset=newOffset;
|
|
||||||
|
|
||||||
newOffset = (int)s.find(' ',offset+1);
|
|
||||||
vertex.z = (float)-atof(s.substr(offset,newOffset-offset).c_str());
|
|
||||||
|
|
||||||
return vertex;
|
|
||||||
}
|
|
||||||
|
|
||||||
Float2 ObjReader::readUV(int offset,string s)
|
|
||||||
{
|
|
||||||
int newOffset = (int)s.find(' ',offset+1);
|
|
||||||
Float2 uv;
|
|
||||||
string d = s.substr(offset,newOffset-offset);
|
|
||||||
uv.x =(float)atof(d.c_str());
|
|
||||||
offset=newOffset;
|
|
||||||
|
|
||||||
newOffset = (int)s.find(' ',offset+1);
|
|
||||||
d = s.substr(offset,newOffset-offset);
|
|
||||||
uv.y =1- (float)atof(d.c_str());
|
|
||||||
offset=newOffset;
|
|
||||||
|
|
||||||
return uv;
|
|
||||||
}
|
|
||||||
|
|
||||||
Float3 ObjReader::readNormal(int offset,string s)
|
|
||||||
{
|
|
||||||
int newOffset = (int)s.find(' ',offset+1);
|
|
||||||
Float3 vertex;
|
|
||||||
string d = s.substr(offset,newOffset-offset);
|
|
||||||
vertex.x = (float)atof(d.c_str());
|
|
||||||
offset=newOffset;
|
|
||||||
|
|
||||||
newOffset = (int)s.find(' ',offset+1);
|
|
||||||
vertex.y = (float)atof(s.substr(offset,newOffset-offset).c_str());
|
|
||||||
offset=newOffset;
|
|
||||||
|
|
||||||
newOffset = (int)s.find(' ',offset+1);
|
|
||||||
vertex.z = (float)-atof(s.substr(offset,newOffset-offset).c_str());
|
|
||||||
|
|
||||||
return vertex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObjReader::readFace(int offset,string s, Oyster::Math::Float3 face[3])
|
|
||||||
{
|
|
||||||
int newOffset = (int)s.find(' ',offset+1);
|
|
||||||
string point1 = s.substr(offset,newOffset-offset);
|
|
||||||
|
|
||||||
offset = newOffset;
|
|
||||||
newOffset = (int)s.find(' ',offset+1);
|
|
||||||
string point2 = s.substr(offset,newOffset-offset);
|
|
||||||
|
|
||||||
offset = newOffset;
|
|
||||||
newOffset = (int)s.find(' ',offset+1);
|
|
||||||
string point3 = s.substr(offset,newOffset-offset);
|
|
||||||
|
|
||||||
face[0] = extract(point1);
|
|
||||||
face[1] = extract(point2);
|
|
||||||
face[2] = extract(point3);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::map<std::string, ID3D11ShaderResourceView *> ObjReader::GetMaterials(std::string fileName)
|
|
||||||
{
|
|
||||||
ifstream input;
|
|
||||||
input.open(fileName.c_str());
|
|
||||||
|
|
||||||
std::map<std::string, ID3D11ShaderResourceView *> materials;
|
|
||||||
ID3D11ShaderResourceView *srv;
|
|
||||||
string texture;
|
|
||||||
string s;
|
|
||||||
string path;
|
|
||||||
Utility::String::extractDirPath(path,fileName,'\\');
|
|
||||||
if(!input.is_open())
|
|
||||||
return materials;
|
|
||||||
|
|
||||||
while(!input.eof())
|
|
||||||
{
|
|
||||||
getline(input,s);
|
|
||||||
int offset = (int)s.find(' ');
|
|
||||||
if(offset!=-1)
|
|
||||||
{
|
|
||||||
string c = s.substr(0,offset);
|
|
||||||
if(c=="map_Kd")
|
|
||||||
{
|
|
||||||
texture = path+s.substr(offset+1);
|
|
||||||
D3DX11CreateShaderResourceViewFromFile(Oyster::Core::Device,texture.c_str(), NULL, NULL, &srv, NULL);
|
|
||||||
materials["Diffuse"] = srv;
|
|
||||||
}
|
|
||||||
if(c=="map_G")
|
|
||||||
{
|
|
||||||
texture = path+s.substr(offset+1);
|
|
||||||
D3DX11CreateShaderResourceViewFromFile(Oyster::Core::Device,texture.c_str(), NULL, NULL, &srv, NULL);
|
|
||||||
materials["Glow"] = srv;
|
|
||||||
}
|
|
||||||
if(c=="map_Ks")
|
|
||||||
{
|
|
||||||
texture = path+s.substr(offset+1);
|
|
||||||
D3DX11CreateShaderResourceViewFromFile(Oyster::Core::Device,texture.c_str(), NULL, NULL, &srv, NULL);
|
|
||||||
materials["Specular"] = srv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
input.close();
|
|
||||||
|
|
||||||
return materials;
|
|
||||||
}
|
|
|
@ -1,42 +1,55 @@
|
||||||
#pragma once
|
#ifndef OBJREADER_H
|
||||||
#include "..\Core\CoreIncludes.h"
|
#define OBJREADER_H
|
||||||
#include "..\Math\OysterMath.h"
|
#include "..\..\Misc\Utilities.h"
|
||||||
|
#include "..\..\OysterMath\OysterMath.h"
|
||||||
|
#include "..\Model\ModelInfo.h"
|
||||||
|
|
||||||
namespace Oyster
|
//#include <fstream>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class OBJReader
|
||||||
{
|
{
|
||||||
namespace FileLoaders
|
public:
|
||||||
{
|
struct OBJFormat
|
||||||
class ObjReader
|
|
||||||
{
|
{
|
||||||
public:
|
Oyster::Math::Float3 _d3VertexCoord;
|
||||||
struct Vertex
|
Oyster::Math::Float2 _d3VertexTexture;
|
||||||
{
|
Oyster::Math::Float3 _d3VertexNormal;
|
||||||
Oyster::Math::Float3 Position;
|
|
||||||
Oyster::Math::Float3 Normal;
|
|
||||||
Oyster::Math::Float2 UV;
|
|
||||||
};
|
|
||||||
|
|
||||||
static ObjReader *LoadFile(std::string fileName, Oyster::Math::Float4x4 transform = Oyster::Math::Float4x4::identity);
|
|
||||||
|
|
||||||
ObjReader(void);
|
|
||||||
~ObjReader(void);
|
|
||||||
|
|
||||||
void GetVertexData(Vertex **vertex,int &numVertex, std::map<std::string, ID3D11ShaderResourceView *> &textures);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Vertex *vertices;
|
|
||||||
size_t numVertices;
|
|
||||||
std::map<std::string, ID3D11ShaderResourceView *> materials;
|
|
||||||
|
|
||||||
void ParseFile(std::string fileName, Oyster::Math::Float4x4 transform = Oyster::Math::Float4x4::identity);
|
|
||||||
|
|
||||||
Oyster::Math::Float3 extract(std::string d);
|
|
||||||
Oyster::Math::Float3 readVertex(int offset,std::string s);
|
|
||||||
Oyster::Math::Float2 readUV(int offset,std::string s);
|
|
||||||
Oyster::Math::Float3 readNormal(int offset,std::string s);
|
|
||||||
void readFace(int offset,std::string s, Oyster::Math::Float3 face[3]);
|
|
||||||
|
|
||||||
std::map<std::string, ID3D11ShaderResourceView *> GetMaterials(std::string fileName);
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
struct OBJMaterialData
|
||||||
|
{
|
||||||
|
std::string _name;
|
||||||
|
std::string _mapKd;
|
||||||
|
float _kd[3];
|
||||||
|
float _ka[3];
|
||||||
|
float _tf[3];
|
||||||
|
float _ni;
|
||||||
|
|
||||||
|
OBJMaterialData()
|
||||||
|
{
|
||||||
|
_name = " ";
|
||||||
|
_mapKd = " ";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
std::vector<OBJFormat> _myOBJ;
|
||||||
|
private:
|
||||||
|
|
||||||
|
std::vector<Oyster::Math::Float3> _mVertexCoord, _mVertexNormal;
|
||||||
|
std::vector<Oyster::Math::Float2> _mVertexTexture;
|
||||||
|
|
||||||
|
int _mNrOfCoords, _mNrOfNormals, _mNrOfTexels, _mNrOfFaces;
|
||||||
|
int _mPos, _mNormal, _mTexel;
|
||||||
|
void stringSplit( std::string strToSplit );
|
||||||
|
void addToOBJarray();
|
||||||
|
|
||||||
|
public:
|
||||||
|
OBJReader();
|
||||||
|
~OBJReader();
|
||||||
|
|
||||||
|
void readOBJFile( std::wstring fileName);
|
||||||
|
Oyster::Graphics::Model::ModelInfo* toModel();
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include "TextureLoader.h"
|
||||||
|
#include "..\Core\Dx11Includes.h"
|
||||||
|
|
||||||
|
Oyster::Resource::CustomData* Oyster::Graphics::Loading::LoadTexture()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
#pragma once
|
||||||
|
#include "..\..\Misc\Resource\OysterResource.h"
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Loading
|
||||||
|
{
|
||||||
|
void UnloadTexture();
|
||||||
|
Oyster::Resource::CustomData* LoadTexture();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
#pragma once
|
||||||
|
#ifndef Mesh_h
|
||||||
|
#define Mesh_h
|
||||||
|
#include "OysterMath.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Model
|
||||||
|
{
|
||||||
|
struct Model
|
||||||
|
{
|
||||||
|
//! do not Edit, linked to render data
|
||||||
|
void* info;
|
||||||
|
Oyster::Math::Float4x4 WorldMatrix;
|
||||||
|
bool Visible;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,25 @@
|
||||||
|
#pragma once
|
||||||
|
#ifndef MODELINFO_h
|
||||||
|
#define MODELINFO_h
|
||||||
|
|
||||||
|
|
||||||
|
#include "..\Core\Core.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Model
|
||||||
|
{
|
||||||
|
struct ModelInfo
|
||||||
|
{
|
||||||
|
std::vector<ID3D11ShaderResourceView*> Material;
|
||||||
|
Core::Buffer *Vertices,*Indecies;
|
||||||
|
bool Indexed;
|
||||||
|
int VertexCount;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,70 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "..\Engine.h"
|
||||||
|
const int MAX_LETTER_COUNT=60;
|
||||||
|
const int TEXT_NR_LETTERS=95;
|
||||||
|
const float TEXT_SIZE=2.5;
|
||||||
|
struct Text2D
|
||||||
|
{
|
||||||
|
Oyster::Math::Float Pos;
|
||||||
|
int offset;
|
||||||
|
float coff;
|
||||||
|
};
|
||||||
|
/*struct TextInstanceData
|
||||||
|
{
|
||||||
|
Oyster::Buffer InstanceBuffer;
|
||||||
|
bool Visible;
|
||||||
|
int NumLetters;
|
||||||
|
Oyster::Math::Float4x4 World;
|
||||||
|
};*/
|
||||||
|
/*struct TextData
|
||||||
|
{
|
||||||
|
Oyster::Math::Float3 pos;
|
||||||
|
Oyster::Math::Float2 uv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PerCharData
|
||||||
|
{
|
||||||
|
float data;
|
||||||
|
Oyster::Math::Float3 charOffset;
|
||||||
|
};
|
||||||
|
struct TextInstanceData
|
||||||
|
{
|
||||||
|
Oyster::Buffer InstanceBuffer;
|
||||||
|
bool Visible;
|
||||||
|
int NumLetters;
|
||||||
|
Oyster::Math::Float4x4 World;
|
||||||
|
};*/
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
class Textbox
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
static float getCharID(char _in);
|
||||||
|
static HRESULT CreateVertexBuffer();
|
||||||
|
static HRESULT CreateTextfield(int _id);
|
||||||
|
public:
|
||||||
|
//static Oyster::Buffer TextBuffer;
|
||||||
|
//static int NumVertices;
|
||||||
|
//static std::vector<TextInstanceData> TextInstances;
|
||||||
|
static Buffer TextBuffer;
|
||||||
|
static int NumLetters;
|
||||||
|
static ID3D11ShaderResourceView* Texture;
|
||||||
|
|
||||||
|
static bool Init();
|
||||||
|
static bool UpdateTextField(std::string _str);
|
||||||
|
static bool SetTexture(const char* _file);
|
||||||
|
//Updates a textbox with the certain id
|
||||||
|
static void Update(std::string _str, float _scale);
|
||||||
|
//Removes all old instances and recreates it with the input data
|
||||||
|
static HRESULT Reset(int _count, std::string* _str, Float3* _pos);
|
||||||
|
static void Apply(int _id);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,7 +24,7 @@
|
||||||
</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|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
@ -66,22 +66,22 @@
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -90,11 +90,15 @@
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>GFX_DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
|
<ProjectReference>
|
||||||
|
<LinkLibraryDependencies>true</LinkLibraryDependencies>
|
||||||
|
</ProjectReference>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
|
@ -102,6 +106,7 @@
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>..\OysterPhysic3D\Collision;..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\OysterPhysic3D\Collision;..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>GFX_DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
@ -115,6 +120,7 @@
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>GFX_DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
@ -130,6 +136,7 @@
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>GFX_DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
@ -140,31 +147,27 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Core\Buffer.cpp" />
|
<ClCompile Include="Core\Buffer.cpp" />
|
||||||
<ClCompile Include="Core\Core.cpp" />
|
<ClCompile Include="Core\Core.cpp" />
|
||||||
|
<ClCompile Include="Core\Init.cpp" />
|
||||||
<ClCompile Include="Core\ShaderManager.cpp" />
|
<ClCompile Include="Core\ShaderManager.cpp" />
|
||||||
<ClCompile Include="Engine.cpp" />
|
<ClCompile Include="DllInterfaces\GFXAPI.cpp" />
|
||||||
<ClCompile Include="Render\Model.cpp" />
|
<ClCompile Include="FileLoader\ObjReader.cpp" />
|
||||||
<ClCompile Include="Render\TextBox.cpp" />
|
<ClCompile Include="FileLoader\TextureLoader.cpp" />
|
||||||
<ClCompile Include="Resourses\Buffers.cpp" />
|
<ClCompile Include="Render\Preparations\BasicPreparations.cpp" />
|
||||||
<ClCompile Include="Resourses\Manager.cpp" />
|
<ClCompile Include="Render\Rendering\BasicRender.cpp" />
|
||||||
<ClCompile Include="Resourses\PipelineResources.cpp" />
|
<ClCompile Include="Render\Resources\Resources.cpp" />
|
||||||
<ClCompile Include="Resourses\ShaderEffects.cpp" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Core\Buffer.h" />
|
|
||||||
<ClInclude Include="Core\Core.h" />
|
<ClInclude Include="Core\Core.h" />
|
||||||
<ClInclude Include="Core\CoreIncludes.h" />
|
<ClInclude Include="Core\Dx11Includes.h" />
|
||||||
<ClInclude Include="Engine.h" />
|
<ClInclude Include="DllInterfaces\GFXAPI.h" />
|
||||||
<ClInclude Include="EngineIncludes.h" />
|
|
||||||
<ClInclude Include="FileLoader\ObjReader.h" />
|
<ClInclude Include="FileLoader\ObjReader.h" />
|
||||||
<ClInclude Include="Render\Lights.h" />
|
<ClInclude Include="FileLoader\TextureLoader.h" />
|
||||||
<ClInclude Include="Render\Model.h" />
|
<ClInclude Include="Model\Model.h" />
|
||||||
<ClInclude Include="Render\ModelInfo.h" />
|
<ClInclude Include="Model\ModelInfo.h" />
|
||||||
<ClInclude Include="Render\TextBox.h" />
|
<ClInclude Include="Render\Preparations\Preparations.h" />
|
||||||
<ClInclude Include="Resourses\Buffers.h" />
|
<ClInclude Include="Render\Rendering\Render.h" />
|
||||||
<ClInclude Include="Resourses\GraphicsDefinitions.h" />
|
<ClInclude Include="Definitions\GraphicalDefinition.h" />
|
||||||
<ClInclude Include="Resourses\Manager.h" />
|
<ClInclude Include="Render\Resources\Resources.h" />
|
||||||
<ClInclude Include="Resourses\PipelineResources.h" />
|
|
||||||
<ClInclude Include="Resourses\ShaderEffects.h" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Misc\Misc.vcxproj">
|
<ProjectReference Include="..\Misc\Misc.vcxproj">
|
||||||
|
@ -175,6 +178,31 @@
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<FxCompile Include="Shader\HLSL\Deffered Shaders\GatherGBuffer\PixelGatherData.hlsl">
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
|
||||||
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
|
||||||
|
</FxCompile>
|
||||||
|
<FxCompile Include="Shader\HLSL\Deffered Shaders\GatherGBuffer\VertexGatherData.hlsl">
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
|
||||||
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
|
||||||
|
</FxCompile>
|
||||||
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugCameraVertex.hlsl">
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
|
||||||
|
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
</AssemblerOutput>
|
||||||
|
<AssemblerOutputFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
</AssemblerOutputFile>
|
||||||
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
|
||||||
|
</FxCompile>
|
||||||
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl">
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl">
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
|
||||||
|
@ -192,8 +220,15 @@
|
||||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
|
||||||
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">main</EntryPointName>
|
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">main</EntryPointName>
|
||||||
|
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
</AssemblerOutput>
|
||||||
</FxCompile>
|
</FxCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="OysterGraphics.vcxproj.filters.orig" />
|
||||||
|
<None Include="OysterGraphics.vcxproj.orig" />
|
||||||
|
<None Include="Shader\HLSL\Deffered Shaders\GatherGBuffer\GBufferHeader.hlsli" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
|
|
@ -1,100 +1,40 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="Source Files">
|
<FxCompile Include="Shader\HLSL\Deffered Shaders\GatherGBuffer\PixelGatherData.hlsl" />
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
<FxCompile Include="Shader\HLSL\Deffered Shaders\GatherGBuffer\VertexGatherData.hlsl" />
|
||||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugCameraVertex.hlsl" />
|
||||||
</Filter>
|
|
||||||
<Filter Include="Header Files">
|
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
|
||||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Resource Files">
|
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="Core\Buffer.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Core\Core.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Render\Model.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Render\TextBox.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Resourses\Buffers.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Resourses\Manager.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Resourses\PipelineResources.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Resourses\ShaderEffects.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Engine.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Core\ShaderManager.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="Core\Buffer.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Core\Core.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Core\CoreIncludes.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Render\Lights.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Render\Model.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Render\ModelInfo.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Render\TextBox.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Resourses\Buffers.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Resourses\GraphicsDefinitions.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Resourses\Manager.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Resourses\PipelineResources.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Resourses\ShaderEffects.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Engine.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="EngineIncludes.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="FileLoader\ObjReader.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugVertex.hlsl" />
|
|
||||||
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl" />
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl" />
|
||||||
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugVertex.hlsl" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Core\Buffer.cpp" />
|
||||||
|
<ClCompile Include="Core\Core.cpp" />
|
||||||
|
<ClCompile Include="Core\Init.cpp" />
|
||||||
|
<ClCompile Include="Core\ShaderManager.cpp" />
|
||||||
|
<ClCompile Include="DllInterfaces\GFXAPI.cpp" />
|
||||||
|
<ClCompile Include="FileLoader\ObjReader.cpp" />
|
||||||
|
<ClCompile Include="FileLoader\TextureLoader.cpp" />
|
||||||
|
<ClCompile Include="Render\Preparations\BasicPreparations.cpp" />
|
||||||
|
<ClCompile Include="Render\Rendering\BasicRender.cpp" />
|
||||||
|
<ClCompile Include="Render\Resources\Resources.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Core\Core.h" />
|
||||||
|
<ClInclude Include="Core\Dx11Includes.h" />
|
||||||
|
<ClInclude Include="DllInterfaces\GFXAPI.h" />
|
||||||
|
<ClInclude Include="FileLoader\ObjReader.h" />
|
||||||
|
<ClInclude Include="FileLoader\TextureLoader.h" />
|
||||||
|
<ClInclude Include="Model\Model.h" />
|
||||||
|
<ClInclude Include="Model\ModelInfo.h" />
|
||||||
|
<ClInclude Include="Render\Preparations\Preparations.h" />
|
||||||
|
<ClInclude Include="Render\Rendering\Render.h" />
|
||||||
|
<ClInclude Include="Definitions\GraphicalDefinition.h" />
|
||||||
|
<ClInclude Include="Render\Resources\Resources.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Shader\HLSL\Deffered Shaders\GatherGBuffer\GBufferHeader.hlsli" />
|
||||||
|
<None Include="OysterGraphics.vcxproj.filters.orig" />
|
||||||
|
<None Include="OysterGraphics.vcxproj.orig" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -0,0 +1,88 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Core\Buffer.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Core\Core.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Core\ShaderManager.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Core\Init.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<ClCompile Include="Render\Rendering\BasicRender.cpp">
|
||||||
|
=======
|
||||||
|
<ClCompile Include="Resources\Resources.cpp">
|
||||||
|
>>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Render\Preparations\BasicPreparations.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<ClCompile Include="Render\Resources\Resources.cpp">
|
||||||
|
=======
|
||||||
|
<ClCompile Include="Render\Rendering\BasicRender.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="FileLoader\ObjReader.cpp">
|
||||||
|
>>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Core\Buffer.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Core\Core.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Core\CoreIncludes.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Render\Preparations\Preparations.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Render\Rendering\Render.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Model\ModelInfo.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Model\Model.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Render\Resources\Resources.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Definitions\GraphicalDefinition.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="FileLoader\ObjReader.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugVertex.hlsl" />
|
||||||
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl" />
|
||||||
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugCameraVertex.hlsl" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,214 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{0EC83E64-230E-48EF-B08C-6AC9651B4F82}</ProjectGuid>
|
||||||
|
<RootNamespace>OysterGraphics</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</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 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" />
|
||||||
|
</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 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" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
<ProjectReference>
|
||||||
|
<LinkLibraryDependencies>true</LinkLibraryDependencies>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>..\OysterPhysic3D\Collision;..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Core\Buffer.cpp" />
|
||||||
|
<ClCompile Include="Core\Core.cpp" />
|
||||||
|
<ClCompile Include="Core\Init.cpp" />
|
||||||
|
<ClCompile Include="Core\ShaderManager.cpp" />
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<ClCompile Include="Render\Preparations\BasicPreparations.cpp" />
|
||||||
|
<ClCompile Include="Render\Rendering\BasicRender.cpp" />
|
||||||
|
<ClCompile Include="Render\Resources\Resources.cpp" />
|
||||||
|
=======
|
||||||
|
<ClCompile Include="FileLoader\ObjReader.cpp" />
|
||||||
|
<ClCompile Include="Render\Preparations\BasicPreparations.cpp" />
|
||||||
|
<ClCompile Include="Render\Rendering\BasicRender.cpp" />
|
||||||
|
<ClCompile Include="Resources\Resources.cpp" />
|
||||||
|
>>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Core\Buffer.h" />
|
||||||
|
<ClInclude Include="Core\Core.h" />
|
||||||
|
<ClInclude Include="Core\CoreIncludes.h" />
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
<ClInclude Include="EngineIncludes.h" />
|
||||||
|
<ClInclude Include="FileLoader\ObjReader.h" />
|
||||||
|
>>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2
|
||||||
|
<ClInclude Include="Model\Model.h" />
|
||||||
|
<ClInclude Include="Model\ModelInfo.h" />
|
||||||
|
<ClInclude Include="Render\Preparations\Preparations.h" />
|
||||||
|
<ClInclude Include="Render\Rendering\Render.h" />
|
||||||
|
<ClInclude Include="Definitions\GraphicalDefinition.h" />
|
||||||
|
<ClInclude Include="Render\Resources\Resources.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Misc\Misc.vcxproj">
|
||||||
|
<Project>{2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\OysterMath\OysterMath.vcxproj">
|
||||||
|
<Project>{f10cbc03-9809-4cba-95d8-327c287b18ee}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugCameraVertex.hlsl">
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
|
||||||
|
</FxCompile>
|
||||||
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl">
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
|
||||||
|
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||||
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
|
||||||
|
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">main</EntryPointName>
|
||||||
|
</FxCompile>
|
||||||
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugVertex.hlsl">
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
|
||||||
|
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||||
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
|
||||||
|
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">main</EntryPointName>
|
||||||
|
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
</AssemblerOutput>
|
||||||
|
</FxCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
|
@ -1,32 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#ifndef Mesh_h
|
|
||||||
#define Mesh_h
|
|
||||||
|
|
||||||
//#include "../Engine.h"
|
|
||||||
|
|
||||||
|
|
||||||
//#include "..\Core\CoreIncludes.h"
|
|
||||||
//#include "..\Core\Buffer.h"
|
|
||||||
#include "OysterMath.h"
|
|
||||||
//#include "ICollideable.h"
|
|
||||||
#include "ModelInfo.h"
|
|
||||||
|
|
||||||
using namespace Oyster::Math;
|
|
||||||
|
|
||||||
namespace Oyster
|
|
||||||
{
|
|
||||||
namespace Render
|
|
||||||
{
|
|
||||||
|
|
||||||
struct Model
|
|
||||||
{
|
|
||||||
ModelInfo* info;
|
|
||||||
Float4x4 *World;
|
|
||||||
bool Visible;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,29 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#ifndef MODELINFO_h
|
|
||||||
#define MODELINFO_h
|
|
||||||
|
|
||||||
//#include "../Engine.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include "..\Core\CoreIncludes.h"
|
|
||||||
#include "..\Core\Buffer.h"
|
|
||||||
//#include "OysterMath.h"
|
|
||||||
//#include "ICollideable.h"
|
|
||||||
|
|
||||||
using namespace Oyster::Math;
|
|
||||||
|
|
||||||
namespace Oyster
|
|
||||||
{
|
|
||||||
namespace Render
|
|
||||||
{
|
|
||||||
struct ModelInfo
|
|
||||||
{
|
|
||||||
std::vector<ID3D11ShaderResourceView*> Material;
|
|
||||||
Oyster::Buffer Vertices,Indecies;
|
|
||||||
bool Indexed;
|
|
||||||
int VertexCount;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
#include "Preparations.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
namespace Preparations
|
||||||
|
{
|
||||||
|
void Basic::BindBackBufferRTV()
|
||||||
|
{
|
||||||
|
BindBackBufferRTV(Core::depthStencil);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::BindBackBufferRTV(ID3D11DepthStencilView* depthStencil)
|
||||||
|
{
|
||||||
|
Core::deviceContext->OMSetRenderTargets(1,&Core::backBufferRTV,depthStencil);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::BindBackBufferUAV()
|
||||||
|
{
|
||||||
|
Core::deviceContext->CSSetUnorderedAccessViews(0,1,&Core::backBufferUAV,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::BindRTV(ID3D11RenderTargetView* RTVs[], int size, bool UseDepthStencil)
|
||||||
|
{
|
||||||
|
if(UseDepthStencil)
|
||||||
|
{
|
||||||
|
BindRTV(RTVs, size, Core::depthStencil);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BindRTV(RTVs, size, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::BindRTV(ID3D11RenderTargetView* RTVs[], int size,ID3D11DepthStencilView* depthStencil)
|
||||||
|
{
|
||||||
|
Core::deviceContext->OMSetRenderTargets(size,RTVs,depthStencil);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::BindUAV(ID3D11UnorderedAccessView* UAVs[], int size)
|
||||||
|
{
|
||||||
|
Core::deviceContext->CSSetUnorderedAccessViews(0,size,UAVs,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::ClearBackBuffer(Oyster::Math::Float4 Color)
|
||||||
|
{
|
||||||
|
ClearRTV(&Core::backBufferRTV, 1,Color);
|
||||||
|
ClearDepthStencil(Core::depthStencil);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::ClearRTV(ID3D11RenderTargetView* RTVs[], int size,Oyster::Math::Float4 Color)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < size; ++i)
|
||||||
|
{
|
||||||
|
Core::deviceContext->ClearRenderTargetView(RTVs[i],Color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::ClearDepthStencil(ID3D11DepthStencilView* depthStencil)
|
||||||
|
{
|
||||||
|
Core::deviceContext->ClearDepthStencilView(depthStencil,1,1,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::SetViewPort()
|
||||||
|
{
|
||||||
|
Core::deviceContext->RSSetViewports(1,Core::viewPort);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef Preparations_h
|
||||||
|
#define Preparations_h
|
||||||
|
|
||||||
|
#include "..\..\Core\Core.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
namespace Preparations
|
||||||
|
{
|
||||||
|
class Basic
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// @brief Binds the backbuffer as a RenderTargetView with the default DepthStencil
|
||||||
|
//! Binds the backbuffer as a RenderTargetView with the default DepthStencil
|
||||||
|
|
||||||
|
static void BindBackBufferRTV();
|
||||||
|
/** @brief Binds the backbuffer as a RenderTargetView with the specified DepthStencil*/
|
||||||
|
static void BindBackBufferRTV(ID3D11DepthStencilView* depthStencil);
|
||||||
|
|
||||||
|
|
||||||
|
/** @brief Binds the backbuffer as a UnorderedAccessView*/
|
||||||
|
static void BindBackBufferUAV();
|
||||||
|
|
||||||
|
/** @brief Binds the specified RenderTargetViews with the default DepthStencil*/
|
||||||
|
static void BindRTV(ID3D11RenderTargetView* RTVs[], int size, bool UseDepthStencil = true);
|
||||||
|
/** @brief Binds the specified RenderTargetViews with the specified DepthStencil*/
|
||||||
|
static void BindRTV(ID3D11RenderTargetView* RTVs[], int size,ID3D11DepthStencilView* depthStencil);
|
||||||
|
|
||||||
|
/** @brief Binds the specified UnorderedAccessViews*/
|
||||||
|
static void BindUAV(ID3D11UnorderedAccessView* UAVs[], int size);
|
||||||
|
|
||||||
|
/** @brief Clear the BackBuffer and the default DepthStencil*/
|
||||||
|
static void ClearBackBuffer(Oyster::Math::Float4 Color);
|
||||||
|
|
||||||
|
/** @brief Clear the specified RenderTargetViews*/
|
||||||
|
static void ClearRTV(ID3D11RenderTargetView* RTVs[], int size,Oyster::Math::Float4 Color);
|
||||||
|
/** @brief Clear the specified DepthStencil*/
|
||||||
|
static void ClearDepthStencil(ID3D11DepthStencilView* depthStencil);
|
||||||
|
|
||||||
|
/** @brief Binds the default ViewPort*/
|
||||||
|
static void SetViewPort();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,67 @@
|
||||||
|
#include "Render.h"
|
||||||
|
#include "../Resources/Resources.h"
|
||||||
|
#include "../../Definitions/GraphicalDefinition.h"
|
||||||
|
#include "../../Model/ModelInfo.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
namespace Rendering
|
||||||
|
{
|
||||||
|
|
||||||
|
void Basic::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection)
|
||||||
|
{
|
||||||
|
Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(0,0,0,1));
|
||||||
|
Core::ShaderManager::SetShaderEffect(Graphics::Render::Resources::obj);
|
||||||
|
Preparations::Basic::BindBackBufferRTV(nullptr);
|
||||||
|
|
||||||
|
Definitions::VP vp;
|
||||||
|
vp.V = View;
|
||||||
|
vp.P = Projection;
|
||||||
|
|
||||||
|
void* data = Resources::VPData.Map();
|
||||||
|
memcpy(data, &vp, sizeof(Definitions::VP));
|
||||||
|
Resources::VPData.Unmap();
|
||||||
|
|
||||||
|
Resources::VPData.Apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic::RenderScene(Model::Model* models, int count)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
if(models[i].Visible)
|
||||||
|
{
|
||||||
|
void* data = Resources::ModelData.Map();
|
||||||
|
memcpy(data,&(models[i].WorldMatrix),sizeof(Math::Float4x4));
|
||||||
|
Resources::ModelData.Unmap();
|
||||||
|
|
||||||
|
//Set Materials :: NONE
|
||||||
|
|
||||||
|
Model
|
||||||
|
::ModelInfo* info = (Model::ModelInfo*)models[i].info;
|
||||||
|
|
||||||
|
info->Vertices->Apply();
|
||||||
|
if(info->Indexed)
|
||||||
|
{
|
||||||
|
info->Indecies->Apply();
|
||||||
|
Oyster::Graphics::Core::deviceContext->DrawIndexed(info->VertexCount,0,0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Oyster::Graphics::Core::deviceContext->Draw(info->VertexCount,0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void Basic::EndFrame()
|
||||||
|
{
|
||||||
|
Core::swapChain->Present(0,0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "..\..\Core\Core.h"
|
||||||
|
#include "..\Preparations\Preparations.h"
|
||||||
|
#include "..\..\Model\Model.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
namespace Rendering
|
||||||
|
{
|
||||||
|
class Basic
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection);
|
||||||
|
static void RenderScene(Model::Model* models, int count);
|
||||||
|
static void EndFrame();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
#include "Resources.h"
|
||||||
|
#include "..\OysterGraphics\Definitions\GraphicalDefinition.h"
|
||||||
|
|
||||||
|
// /Bin/Executable/Tester ->
|
||||||
|
// /Code/OysterGraphics/Shader/HLSL
|
||||||
|
const std::wstring PathFromExeToHlsl = L"..\\..\\..\\Code\\OysterGraphics\\Shader\\HLSL\\";
|
||||||
|
const std::wstring VertexTransformDebug = L"TransformDebugVertex";
|
||||||
|
const std::wstring VertexDebug = L"DebugVertex";
|
||||||
|
const std::wstring PixelRed = L"DebugPixel";
|
||||||
|
|
||||||
|
typedef Oyster::Graphics::Core::ShaderManager::ShaderType ShaderType;
|
||||||
|
typedef Oyster::Graphics::Core::ShaderManager::Get GetShader;
|
||||||
|
typedef Oyster::Graphics::Core::ShaderManager Shader;
|
||||||
|
typedef Oyster::Graphics::Core::Buffer Buffer;
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
Shader::ShaderEffect Resources::obj;
|
||||||
|
Buffer Resources::ModelData = Buffer();
|
||||||
|
Buffer Resources::VPData = Buffer();
|
||||||
|
|
||||||
|
Core::Init::State Resources::Init()
|
||||||
|
{
|
||||||
|
|
||||||
|
#pragma region LoadShaders
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
|
||||||
|
/** Load Vertex Shader for d3dcompile*/
|
||||||
|
Core::ShaderManager::Init(PathFromExeToHlsl + L"SimpleDebug\\" +L"DebugCameraVertex.hlsl",ShaderType::Vertex, VertexTransformDebug, false);
|
||||||
|
Core::ShaderManager::Init(PathFromExeToHlsl + L"SimpleDebug\\" +L"DebugVertex.hlsl",ShaderType::Vertex, VertexDebug, false);
|
||||||
|
|
||||||
|
/** Load Pixel Shader for d3dcompile */
|
||||||
|
Core::ShaderManager::Init(PathFromExeToHlsl + L"SimpleDebug\\" + L"DebugPixel.hlsl", ShaderType::Pixel, PixelRed, false);
|
||||||
|
|
||||||
|
#else
|
||||||
|
/** Load Vertex Shader with Precompiled */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region CreateBuffers
|
||||||
|
Buffer::BUFFER_INIT_DESC desc;
|
||||||
|
desc.ElementSize = sizeof(Oyster::Math::Matrix);
|
||||||
|
desc.NumElements = 1;
|
||||||
|
desc.InitData = NULL;
|
||||||
|
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_VS;
|
||||||
|
desc.Usage = Buffer::BUFFER_USAGE::BUFFER_CPU_WRITE_DISCARD;
|
||||||
|
|
||||||
|
ModelData.Init(desc);
|
||||||
|
|
||||||
|
desc.NumElements = 2;
|
||||||
|
VPData.Init(desc);
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Setup Render States
|
||||||
|
/** @todo Create DX States */
|
||||||
|
|
||||||
|
D3D11_RASTERIZER_DESC rdesc;
|
||||||
|
rdesc.CullMode = D3D11_CULL_NONE;
|
||||||
|
rdesc.FillMode = D3D11_FILL_SOLID;
|
||||||
|
rdesc.FrontCounterClockwise = false;
|
||||||
|
rdesc.DepthBias = 0;
|
||||||
|
rdesc.DepthBiasClamp = 0;
|
||||||
|
rdesc.DepthClipEnable = true;
|
||||||
|
rdesc.SlopeScaledDepthBias = 0;
|
||||||
|
rdesc.ScissorEnable = false;
|
||||||
|
rdesc.MultisampleEnable = false;
|
||||||
|
rdesc.AntialiasedLineEnable = false;
|
||||||
|
|
||||||
|
ID3D11RasterizerState* rs = NULL;
|
||||||
|
Oyster::Graphics::Core::device->CreateRasterizerState(&rdesc,&rs);
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Setup Views
|
||||||
|
/** @todo Create Views */
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Create Shader Effects
|
||||||
|
/** @todo Create ShaderEffects */
|
||||||
|
obj.Shaders.Pixel = GetShader::Pixel(PixelRed);
|
||||||
|
obj.Shaders.Vertex = GetShader::Vertex(VertexTransformDebug);
|
||||||
|
|
||||||
|
D3D11_INPUT_ELEMENT_DESC indesc[] =
|
||||||
|
{
|
||||||
|
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
|
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
|
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
Shader::CreateInputLayout(indesc,3,GetShader::Vertex(VertexTransformDebug),obj.IAStage.Layout);
|
||||||
|
obj.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
||||||
|
obj.CBuffers.Vertex.push_back(&VPData);
|
||||||
|
obj.RenderStates.Rasterizer = rs;
|
||||||
|
|
||||||
|
ModelData.Apply(1);
|
||||||
|
#pragma endregion
|
||||||
|
return Core::Init::Sucsess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef Reources_h
|
||||||
|
#define Reources_h
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include "../OysterGraphics/Core/Core.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
class Resources
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Core::ShaderManager::ShaderEffect obj;
|
||||||
|
static Core::Buffer ModelData;
|
||||||
|
static Core::Buffer VPData;
|
||||||
|
|
||||||
|
static Core::Init::State Init();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,67 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "..\Engine.h"
|
|
||||||
const int MAX_LETTER_COUNT=60;
|
|
||||||
const int TEXT_NR_LETTERS=95;
|
|
||||||
const float TEXT_SIZE=2.5;
|
|
||||||
struct Text2D
|
|
||||||
{
|
|
||||||
Oyster::Math::Float Pos;
|
|
||||||
int offset;
|
|
||||||
float coff;
|
|
||||||
};
|
|
||||||
/*struct TextInstanceData
|
|
||||||
{
|
|
||||||
Oyster::Buffer InstanceBuffer;
|
|
||||||
bool Visible;
|
|
||||||
int NumLetters;
|
|
||||||
Oyster::Math::Float4x4 World;
|
|
||||||
};*/
|
|
||||||
/*struct TextData
|
|
||||||
{
|
|
||||||
Oyster::Math::Float3 pos;
|
|
||||||
Oyster::Math::Float2 uv;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct PerCharData
|
|
||||||
{
|
|
||||||
float data;
|
|
||||||
Oyster::Math::Float3 charOffset;
|
|
||||||
};
|
|
||||||
struct TextInstanceData
|
|
||||||
{
|
|
||||||
Oyster::Buffer InstanceBuffer;
|
|
||||||
bool Visible;
|
|
||||||
int NumLetters;
|
|
||||||
Oyster::Math::Float4x4 World;
|
|
||||||
};*/
|
|
||||||
|
|
||||||
namespace Oyster
|
|
||||||
{
|
|
||||||
namespace Render
|
|
||||||
{
|
|
||||||
class Textbox
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
static float getCharID(char _in);
|
|
||||||
static HRESULT CreateVertexBuffer();
|
|
||||||
static HRESULT CreateTextfield(int _id);
|
|
||||||
public:
|
|
||||||
//static Oyster::Buffer TextBuffer;
|
|
||||||
//static int NumVertices;
|
|
||||||
//static std::vector<TextInstanceData> TextInstances;
|
|
||||||
static Oyster::Buffer TextBuffer;
|
|
||||||
static int NumLetters;
|
|
||||||
static ID3D11ShaderResourceView* Texture;
|
|
||||||
|
|
||||||
static bool Init();
|
|
||||||
static bool UpdateTextField(std::string _str);
|
|
||||||
static bool SetTexture(const char* _file);
|
|
||||||
//Updates a textbox with the certain id
|
|
||||||
static void Update(std::string _str, float _scale);
|
|
||||||
//Removes all old instances and recreates it with the input data
|
|
||||||
static HRESULT Reset(int _count, std::string* _str, Float3* _pos);
|
|
||||||
static void Apply(int _id);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
struct VertexIn
|
||||||
|
{
|
||||||
|
float3 pos : POSITION;
|
||||||
|
float2 UV : TEXCOORD;
|
||||||
|
float3 normal : NORMAL;
|
||||||
|
float3 tangent : TANGENT;
|
||||||
|
float3 biTangent : BITANGENT;
|
||||||
|
float4 boneIndex : BONEINDEX;
|
||||||
|
float4 boneWeight : BONEWEIGHT;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VertexOut
|
||||||
|
{
|
||||||
|
float4 pos : SV_POSITION;
|
||||||
|
float4 ViewPos : POSITION;
|
||||||
|
float2 UV : TEXCOORD;
|
||||||
|
float3 normal : NORMAL;
|
||||||
|
float3 tangent : TANGENT;
|
||||||
|
float3 biTangent : BITANGENT;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PixelOut
|
||||||
|
{
|
||||||
|
float4 DiffuseGlow : SV_TARGET0;
|
||||||
|
float4 NormalSpec : SV_TARGET1;
|
||||||
|
};
|
||||||
|
|
||||||
|
Texture2D Diffuse : register(t0);
|
||||||
|
Texture2D Specular : register(t1);
|
||||||
|
|
||||||
|
cbuffer PerFrame : register(b0)
|
||||||
|
{
|
||||||
|
matrix View;
|
||||||
|
float4x4 Projection;
|
||||||
|
matrix VP;
|
||||||
|
}
|
||||||
|
|
||||||
|
cbuffer PerModel : register(b1)
|
||||||
|
{
|
||||||
|
matrix World;
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
#include "GBufferHeader.hlsli"
|
||||||
|
|
||||||
|
PixelOut main(VertexOut input)
|
||||||
|
{
|
||||||
|
PixelOut output;
|
||||||
|
output.DiffuseGlow = float4(1.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
output.NormalSpec = float4(input.normal, 1.0f);
|
||||||
|
return output;
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include "GBufferHeader.hlsli"
|
||||||
|
|
||||||
|
VertexOut main( VertexIn input )
|
||||||
|
{
|
||||||
|
VertexOut output;
|
||||||
|
matrix WV = mul(View, World);
|
||||||
|
output.ViewPos = mul(WV, float4(input.pos,1));
|
||||||
|
output.pos = mul(Projection, output.ViewPos);
|
||||||
|
output.UV = input.UV;
|
||||||
|
output.normal = float4(input.normal, 0);
|
||||||
|
return output;
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
cbuffer PerFrame : register(b0)
|
||||||
|
{
|
||||||
|
matrix View;
|
||||||
|
float4x4 Projection;
|
||||||
|
}
|
||||||
|
|
||||||
|
cbuffer PerModel : register(b1)
|
||||||
|
{
|
||||||
|
matrix World;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct VertexIn
|
||||||
|
{
|
||||||
|
float3 pos : POSITION;
|
||||||
|
float2 UV : TEXCOORD;
|
||||||
|
float3 normal : NORMAL;
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 main( VertexIn input ) : SV_POSITION
|
||||||
|
{
|
||||||
|
float4 postTransform = mul( World, float4(input.pos,1) );
|
||||||
|
//float4 postTransform = float4(input.pos,1);
|
||||||
|
//return postTransform;
|
||||||
|
//return mul(View, float4(input.pos,1));
|
||||||
|
matrix VP = mul(Projection, View);
|
||||||
|
//matrix WVP = mul(World, VP);
|
||||||
|
return mul(VP, postTransform );
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
float4 main() : SV_TARGET
|
float4 main() : SV_TARGET0
|
||||||
{
|
{
|
||||||
return float4(1.0f, 0.0f, 0.0f, 1.0f);
|
return float4(1.0f, 0.0f, 0.0f, 1.0f);
|
||||||
}
|
}
|
|
@ -4,75 +4,78 @@
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
class Shader
|
namespace Graphics
|
||||||
{
|
{
|
||||||
public:
|
class Shader
|
||||||
struct ShaderEffect
|
|
||||||
{
|
{
|
||||||
struct
|
public:
|
||||||
|
struct ShaderEffect
|
||||||
{
|
{
|
||||||
int Pixel,Vertex,Geometry,Compute,Hull,Domain;
|
struct
|
||||||
}Shaders;
|
{
|
||||||
struct IAStage_
|
int Pixel,Vertex,Geometry,Compute,Hull,Domain;
|
||||||
{
|
}Shaders;
|
||||||
ID3D11InputLayout* Layout;
|
struct IAStage_
|
||||||
D3D11_PRIMITIVE_TOPOLOGY Topology;
|
{
|
||||||
}IAStage;
|
ID3D11InputLayout* Layout;
|
||||||
struct RenderStates_
|
D3D11_PRIMITIVE_TOPOLOGY Topology;
|
||||||
{
|
}IAStage;
|
||||||
ID3D11DepthStencilState *DepthStencil;
|
struct RenderStates_
|
||||||
ID3D11RasterizerState *Rasterizer;
|
{
|
||||||
ID3D11SamplerState **SampleState;
|
ID3D11DepthStencilState *DepthStencil;
|
||||||
int SampleCount;
|
ID3D11RasterizerState *Rasterizer;
|
||||||
ID3D11BlendState *BlendState;
|
ID3D11SamplerState **SampleState;
|
||||||
}RenderStates;
|
int SampleCount;
|
||||||
struct
|
ID3D11BlendState *BlendState;
|
||||||
{
|
}RenderStates;
|
||||||
std::vector<Buffer*> Vertex;
|
struct
|
||||||
std::vector<Buffer*> Geometry;
|
{
|
||||||
std::vector<Buffer*> Pixel;
|
std::vector<Buffer*> Vertex;
|
||||||
}CBuffers;
|
std::vector<Buffer*> Geometry;
|
||||||
ShaderEffect()
|
std::vector<Buffer*> Pixel;
|
||||||
{
|
}CBuffers;
|
||||||
RenderStates.BlendState=NULL;
|
ShaderEffect()
|
||||||
RenderStates.DepthStencil=NULL;
|
{
|
||||||
RenderStates.Rasterizer=NULL;
|
RenderStates.BlendState=NULL;
|
||||||
RenderStates.SampleState=NULL;
|
RenderStates.DepthStencil=NULL;
|
||||||
RenderStates.SampleCount=0;
|
RenderStates.Rasterizer=NULL;
|
||||||
Shaders.Compute=-1;
|
RenderStates.SampleState=NULL;
|
||||||
Shaders.Domain=-1;
|
RenderStates.SampleCount=0;
|
||||||
Shaders.Geometry=-1;
|
Shaders.Compute=-1;
|
||||||
Shaders.Hull=-1;
|
Shaders.Domain=-1;
|
||||||
Shaders.Pixel=-1;
|
Shaders.Geometry=-1;
|
||||||
Shaders.Vertex=-1;
|
Shaders.Hull=-1;
|
||||||
}
|
Shaders.Pixel=-1;
|
||||||
};
|
Shaders.Vertex=-1;
|
||||||
static bool InitShaders(const std::string &name = "..\\Shaders\\ShaderConfig.txt");
|
}
|
||||||
|
};
|
||||||
|
static bool InitShaders(const std::string &name = "..\\Shaders\\ShaderConfig.txt");
|
||||||
|
|
||||||
static void SetShaderEffect(ShaderEffect);
|
static void SetShaderEffect(ShaderEffect);
|
||||||
|
|
||||||
static void CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout);
|
static void CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout);
|
||||||
|
|
||||||
struct Set
|
struct Set
|
||||||
{
|
{
|
||||||
static void SetPixel(int Index);
|
static void SetPixel(int Index);
|
||||||
static void SetVertex(int Index);
|
static void SetVertex(int Index);
|
||||||
static void SetGeometry(int Index);
|
static void SetGeometry(int Index);
|
||||||
static void SetCompute(int Index);
|
static void SetCompute(int Index);
|
||||||
static void SetHull(int Index);
|
static void SetHull(int Index);
|
||||||
static void SetDomain(int Index);
|
static void SetDomain(int Index);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Get
|
||||||
|
{
|
||||||
|
static int GetPixel(std::string Name);
|
||||||
|
static int GetVertex(std::string Name);
|
||||||
|
static int GetGeometry(std::string Name);
|
||||||
|
static int GetCompute(std::string Name);
|
||||||
|
static int GetHull(std::string Name);
|
||||||
|
static int GetDomain(std::string Name);
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::stringstream* AccesLog();
|
||||||
};
|
};
|
||||||
|
}
|
||||||
struct Get
|
|
||||||
{
|
|
||||||
static int GetPixel(std::string Name);
|
|
||||||
static int GetVertex(std::string Name);
|
|
||||||
static int GetGeometry(std::string Name);
|
|
||||||
static int GetCompute(std::string Name);
|
|
||||||
static int GetHull(std::string Name);
|
|
||||||
static int GetDomain(std::string Name);
|
|
||||||
};
|
|
||||||
|
|
||||||
static std::stringstream* AccesLog();
|
|
||||||
};
|
|
||||||
}
|
}
|
Binary file not shown.
|
@ -1,2 +0,0 @@
|
||||||
#v4.0:v110:false
|
|
||||||
Debug|Win32|C:\DanBias\Danbias\|
|
|
|
@ -1,13 +0,0 @@
|
||||||
Build started 11/15/2013 11:04:26 AM.
|
|
||||||
1>Project "C:\DanBias\Danbias\Tester\Tester.vcxproj" on node 3 (Build target(s)).
|
|
||||||
1>Link:
|
|
||||||
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"C:\DanBias\Danbias\Debug\Tester.exe" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:\DanBias\Danbias\Debug\Tester.pdb" /SUBSYSTEM:WINDOWS /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\DanBias\Danbias\Debug\Tester.lib" /MACHINE:X86 Debug\MainTest.obj
|
|
||||||
C:\DanBias\External\Lib\Misc\Misc_x86D.lib
|
|
||||||
C:\DanBias\External\Lib\OysterMath\OysterMath_x86D.lib
|
|
||||||
C:\DanBias\External\Lib\OysterGraphics\OysterGraphics_x86D.lib
|
|
||||||
Tester.vcxproj -> C:\DanBias\Danbias\Debug\Tester.exe
|
|
||||||
1>Done Building Project "C:\DanBias\Danbias\Tester\Tester.vcxproj" (Build target(s)).
|
|
||||||
|
|
||||||
Build succeeded.
|
|
||||||
|
|
||||||
Time Elapsed 00:00:00.98
|
|
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue