Compare commits

...

13 Commits

123 changed files with 6085 additions and 5239 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" charset="windows-1252" />
<file url="file://$PROJECT_DIR$/enginecustom/src/src/system/application_class.cpp" charset="windows-1252" />
<file url="file://$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" charset="windows-1252" />
<file url="PROJECT" charset="windows-1252" />
</component>

View File

@ -5,9 +5,12 @@
</component>
<component name="ChangeListManager">
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/shadow_map.h" afterDir="false" />
<change afterPath="$PROJECT_DIR$/enginecustom/src/src/system/shadow_map.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/imgui.ini" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/imgui.ini" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/application_class.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/application_class.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/application_class.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/application_class.cpp" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -22,11 +25,15 @@
</component>
<component name="HighlightingSettingsPerFile">
<setting file="file://C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um/d3d11.h" root0="SKIP_HIGHLIGHTING" />
<setting file="file://C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um/dinput.h" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/enginecustom/include/Inc/VertexTypes.h" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/enginecustom/include/Vulkan/Include/vulkan/vulkan_core.h" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/enginecustom/src/src/shader/CelShadingShader.cpp" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/../../IDE_VS/VC/Tools/MSVC/14.38.33130/include/type_traits" root0="SKIP_HIGHLIGHTING" />
</component>
<component name="KubernetesApiPersistence">{}</component>
<component name="KubernetesApiProvider">{
&quot;isMigrated&quot;: true
}</component>
<component name="MetaFilesCheckinStateConfiguration" checkMetaFiles="true" />
<component name="ProblemsViewState">
<option name="selectedTabId" value="CurrentFile" />
@ -35,6 +42,9 @@
&quot;associatedIndex&quot;: 6
}</component>
<component name="ProjectId" id="2sGIWDeT5ixyzDQ0he4A3RFpG9W" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
@ -54,7 +64,7 @@
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.build.unityPlugin&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.keymap&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}</component>
@ -179,7 +189,18 @@
<workItem from="1746538260893" duration="5781000" />
<workItem from="1746546014271" duration="1814000" />
<workItem from="1746619988287" duration="12282000" />
<workItem from="1746711806997" duration="6619000" />
<workItem from="1746711806997" duration="6736000" />
<workItem from="1746719840054" duration="991000" />
<workItem from="1746795732153" duration="33000" />
<workItem from="1746795828588" duration="592000" />
<workItem from="1747049871967" duration="9350000" />
<workItem from="1747136509645" duration="3939000" />
<workItem from="1747258663152" duration="835000" />
<workItem from="1747826758888" duration="3587000" />
<workItem from="1747830379222" duration="7954000" />
<workItem from="1748254142068" duration="10499000" />
<workItem from="1748267553700" duration="654000" />
<workItem from="1748429087202" duration="7421000" />
</task>
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
<option name="closed" value="true" />

View File

@ -2,13 +2,13 @@
Khaotic Engine Reborn reprend comme base le moteur Khaotic Engine pour lui ajouter plus de fonctionalité.
Ce moteur est basé sur **DirectX11** utilise **ImGui** avec une couche d'abstraction pour permetre son usage avec d'autres API.
Ce moteur est basé sur **DirectX11** et utilise **ImGui** pour son interface graphique.
---
Khaotic Engine is a rendering engine made in **C++** by a small team with the aim of learning how to use rendering APIs (OpenGL, DirectX 11/12 and Vulkan).
This **DirectX11** based engine uses **ImGui** with an abstraction layer to enable its use with other APIs.
This **DirectX11** based engine uses **ImGui** for the user interface.
## Installation
@ -64,7 +64,7 @@ This **DirectX11** based engine uses **ImGui** with an abstraction layer to enab
## Demo :
[![Demo Video](https://img.youtube.com/vi/qCOCTyB_97c/0.jpg)](https://youtu.be/DYgT1Nu7B4c)
[![Demo Video](https://img.youtube.com/vi/CbK1a0Ar94Q/0.jpg)](https://youtu.be/CbK1a0Ar94Q)
## Engine Build by :
@ -77,7 +77,7 @@ This **DirectX11** based engine uses **ImGui** with an abstraction layer to enab
- [@Harpie94](https://github.com/Harpie94)
- [@axelpicou](https://github.com/axelpicou)
- [@GolfOcean334](https://github.com/GolfOcean334)
- [@sutabasuto](https://github.com/sutabasuto)
- [@sutabasuto](https://github.com/sutabasuto)
**Moteur Reborn** :

View File

@ -0,0 +1 @@
1 isosphere 0 10 0 0 -0 0 1 1 1 Content/Assets/Kobject/isosphere.obj ALPHA_MAPPING 1 Unknown 1 0 2 assets/Texture/Bricks2K.png F:\Github_Repo\khaotic-engine-Reborn\enginecustom\assets\Texture\moss01.png 1 assets/Texture/BricksNRM2K.png 1 assets/Texture/BricksGLOSS2K.png 1 F:\Github_Repo\khaotic-engine-Reborn\enginecustom\assets\Texture\alpha01.png

View File

@ -4,28 +4,28 @@ Size=400,400
Collapsed=0
[Window][Khaotic Engine]
Pos=1697,27
Size=343,1094
Pos=1745,19
Size=303,667
Collapsed=0
DockId=0x00000005,0
DockId=0x0000000F,0
[Window][Objects]
Pos=8,27
Size=289,547
Pos=0,19
Size=281,441
Collapsed=0
DockId=0x00000011,0
[Window][Terrain]
Pos=283,19
Size=280,883
Collapsed=0
DockId=0x00000007,0
[Window][Terrain]
Pos=8,576
Size=289,545
Collapsed=0
DockId=0x00000008,0
[Window][Light]
Pos=8,27
Size=290,866
Pos=0,462
Size=281,440
Collapsed=0
DockId=0x0000000B,1
DockId=0x00000012,0
[Window][Shader Manager]
Pos=8,27
@ -34,10 +34,10 @@ Collapsed=0
DockId=0x00000001,2
[Window][Engine Settings]
Pos=8,27
Size=289,547
Pos=1745,688
Size=303,441
Collapsed=0
DockId=0x00000007,1
DockId=0x00000010,0
[Window][DockSpace Demo]
Size=1584,861
@ -47,7 +47,7 @@ Collapsed=0
Pos=8,27
Size=1559,974
Collapsed=0
DockId=0x00000007,0
DockId=0x00000011,0
[Window][DockSpace]
Pos=0,0
@ -66,24 +66,36 @@ Collapsed=0
DockId=0x0000000C,0
[Window][Log Window]
Pos=8,37
Size=16,19
Pos=873,904
Size=870,225
Collapsed=0
DockId=0x00000006,0
[Docking][Data]
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x393905AB
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=2032,1094 Split=Y
DockNode ID=0x00000004 Parent=0xCCBD8CF7 SizeRef=1568,598 Split=X
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=289,974 Split=Y Selected=0x031DC75C
DockNode ID=0x00000007 Parent=0x00000009 SizeRef=289,547 Selected=0x0B098C4B
DockNode ID=0x00000008 Parent=0x00000009 SizeRef=289,545 Selected=0x393905AB
DockNode ID=0x0000000D Parent=0x00000004 SizeRef=1613,974 Split=X
DockNode ID=0x00000002 Parent=0x0000000D SizeRef=1268,826 Split=Y
DockNode ID=0x0000000B Parent=0x00000002 SizeRef=1568,637 CentralNode=1
DockNode ID=0x0000000C Parent=0x00000002 SizeRef=1568,335 Selected=0x139FDA3F
DockNode ID=0x00000005 Parent=0x0000000D SizeRef=343,826 Selected=0x9F035453
DockNode ID=0x00000006 Parent=0xCCBD8CF7 SizeRef=1568,226 Selected=0xAB74BEE9
[Window][Render Stats]
Pos=0,904
Size=871,225
Collapsed=0
DockId=0x00000004,0
[Docking][Data]
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x393905AB
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=2048,1110 Split=X
DockNode ID=0x00000002 Parent=0xCCBD8CF7 SizeRef=1743,826 Split=Y
DockNode ID=0x0000000A Parent=0x00000002 SizeRef=1568,599 Split=X
DockNode ID=0x00000009 Parent=0x0000000A SizeRef=281,974 Split=Y Selected=0x031DC75C
DockNode ID=0x00000011 Parent=0x00000009 SizeRef=281,441 Selected=0x031DC75C
DockNode ID=0x00000012 Parent=0x00000009 SizeRef=281,440 Selected=0x321620B2
DockNode ID=0x0000000D Parent=0x0000000A SizeRef=1460,974 Split=Y
DockNode ID=0x0000000B Parent=0x0000000D SizeRef=1568,637 Split=X Selected=0x321620B2
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=280,883 Selected=0x393905AB
DockNode ID=0x00000008 Parent=0x0000000B SizeRef=1178,883 CentralNode=1
DockNode ID=0x0000000C Parent=0x0000000D SizeRef=1568,335 Selected=0x139FDA3F
DockNode ID=0x0000000E Parent=0x00000002 SizeRef=1568,225 Split=X Selected=0xD99DEA49
DockNode ID=0x00000004 Parent=0x0000000E SizeRef=871,225 Selected=0xD99DEA49
DockNode ID=0x00000006 Parent=0x0000000E SizeRef=870,225 Selected=0xAB74BEE9
DockNode ID=0x00000005 Parent=0xCCBD8CF7 SizeRef=303,826 Split=Y Selected=0x9F035453
DockNode ID=0x0000000F Parent=0x00000005 SizeRef=303,667 Selected=0x9F035453
DockNode ID=0x00000010 Parent=0x00000005 SizeRef=303,441 Selected=0x0B098C4B

View File

@ -30,49 +30,52 @@
<ClCompile Include="include\Src\pch.cpp" />
<ClCompile Include="include\Src\SimpleMath.cpp" />
<ClCompile Include="include\Src\WICTextureLoader.cpp" />
<ClCompile Include="src\src\shader\alphamapshaderclass.cpp" />
<ClCompile Include="src\src\shader\CelShadingShader.cpp" />
<ClCompile Include="src\src\shader\Colorshaderclass.cpp" />
<ClCompile Include="src\src\shader\fontshaderclass.cpp" />
<ClCompile Include="src\src\shader\lightmapshaderclass.cpp" />
<ClCompile Include="src\src\shader\lightshaderclass.cpp" />
<ClCompile Include="src\src\shader\Multitextureshaderclass.cpp" />
<ClCompile Include="src\src\shader\normalmapshaderclass.cpp" />
<ClCompile Include="src\src\shader\reflectionshaderclass.cpp" />
<ClCompile Include="src\src\shader\refractionshaderclass.cpp" />
<ClCompile Include="src\src\shader\shadermanagerclass.cpp" />
<ClCompile Include="src\src\shader\SkyboxShaderClass.cpp" />
<ClCompile Include="src\src\shader\specmapshaderclass.cpp" />
<ClCompile Include="src\src\shader\sunlightshaderclass.cpp" />
<ClCompile Include="src\src\shader\textureshaderclass.cpp" />
<ClCompile Include="src\src\shader\translateshaderclass.cpp" />
<ClCompile Include="src\src\shader\transparentshaderclass.cpp" />
<ClCompile Include="src\src\shader\watershaderclass.cpp" />
<ClCompile Include="src\src\system\applicationclass.cpp" />
<ClCompile Include="src\src\system\bitmapclass.cpp" />
<ClCompile Include="src\src\system\Cameraclass.cpp" />
<ClCompile Include="src\src\system\d3dclass.cpp" />
<ClCompile Include="src\src\system\displayplaneclass.cpp" />
<ClCompile Include="src\src\system\fontclass.cpp" />
<ClCompile Include="src\src\system\fpsclass.cpp" />
<ClCompile Include="src\src\shader\alpha_map_shader_class.cpp" />
<ClCompile Include="src\src\shader\celshade_class.cpp" />
<ClCompile Include="src\src\shader\color_shader_class.cpp" />
<ClCompile Include="src\src\shader\depth_shader_class.cpp" />
<ClCompile Include="src\src\shader\font_shader_class.cpp" />
<ClCompile Include="src\src\shader\light_map_shader_class.cpp" />
<ClCompile Include="src\src\shader\light_shader_class.cpp" />
<ClCompile Include="src\src\shader\master_shader.cpp" />
<ClCompile Include="src\src\shader\multi_texture_shader_class.cpp" />
<ClCompile Include="src\src\shader\normal_map_shader_class.cpp" />
<ClCompile Include="src\src\shader\reflection_shader_class.cpp" />
<ClCompile Include="src\src\shader\refraction_shader_class.cpp" />
<ClCompile Include="src\src\shader\shader_manager_class.cpp" />
<ClCompile Include="src\src\shader\skybox_shader_class.cpp" />
<ClCompile Include="src\src\shader\spec_map_shader_class.cpp" />
<ClCompile Include="src\src\shader\sunlight_shader_class.cpp" />
<ClCompile Include="src\src\shader\texture_shader_class.cpp" />
<ClCompile Include="src\src\shader\translate_shader_class.cpp" />
<ClCompile Include="src\src\shader\transparent_shader_class.cpp" />
<ClCompile Include="src\src\shader\water_shader_class.cpp" />
<ClCompile Include="src\src\system\application_class.cpp" />
<ClCompile Include="src\src\system\bitmap_class.cpp" />
<ClCompile Include="src\src\system\camera_class.cpp" />
<ClCompile Include="src\src\system\d_3d_class.cpp" />
<ClCompile Include="src\src\system\display_plane_class.cpp" />
<ClCompile Include="src\src\system\font_class.cpp" />
<ClCompile Include="src\src\system\fps_class.cpp" />
<ClCompile Include="src\src\system\frustum.cpp" />
<ClCompile Include="src\src\system\frustumclass.cpp" />
<ClCompile Include="src\src\system\imguiManager.cpp" />
<ClCompile Include="src\src\system\inputclass.cpp" />
<ClCompile Include="src\src\system\lightclass.cpp" />
<ClCompile Include="src\src\system\input_class.cpp" />
<ClCompile Include="src\src\system\light_class.cpp" />
<ClCompile Include="src\src\system\Main.cpp" />
<ClCompile Include="src\src\system\modelclass.cpp" />
<ClCompile Include="src\src\system\model_class.cpp" />
<ClCompile Include="src\src\system\Modellistclass.cpp" />
<ClCompile Include="src\src\system\object.cpp" />
<ClCompile Include="src\src\system\physics.cpp" />
<ClCompile Include="src\src\system\Positionclass.cpp" />
<ClCompile Include="src\src\system\rendertextureclass.cpp" />
<ClCompile Include="src\src\system\position_class.cpp" />
<ClCompile Include="src\src\system\render_texture_class.cpp" />
<ClCompile Include="src\src\system\shadow_map.cpp" />
<ClCompile Include="src\src\system\Skybox.cpp" />
<ClCompile Include="src\src\system\Spriteclass.cpp" />
<ClCompile Include="src\src\system\Systemclass.cpp" />
<ClCompile Include="src\src\system\textclass.cpp" />
<ClCompile Include="src\src\system\textureclass.cpp" />
<ClCompile Include="src\src\system\Timerclass.cpp" />
<ClCompile Include="src\src\system\sprite_class.cpp" />
<ClCompile Include="src\src\system\system_class.cpp" />
<ClCompile Include="src\src\system\text_class.cpp" />
<ClCompile Include="src\src\system\texture_class.cpp" />
<ClCompile Include="src\src\system\timer_class.cpp" />
<ClCompile Include="src\src\system\vulkan.cpp" />
</ItemGroup>
<ItemGroup>
@ -89,51 +92,54 @@
<ClInclude Include="include\Src\LoaderHelpers.h" />
<ClInclude Include="include\Src\pch.h" />
<ClInclude Include="include\Src\PlatformHelpers.h" />
<ClInclude Include="src\inc\shader\alphamapshaderclass.h" />
<ClInclude Include="src\inc\shader\CelShadingShader.h" />
<ClInclude Include="src\inc\shader\Colorshaderclass.h" />
<ClInclude Include="src\inc\shader\fontshaderclass.h" />
<ClInclude Include="src\inc\shader\lightmapshaderclass.h" />
<ClInclude Include="src\inc\shader\lightshaderclass.h" />
<ClInclude Include="src\inc\shader\lightshaderwaterclass.h" />
<ClInclude Include="src\inc\shader\Multitextureshaderclass.h" />
<ClInclude Include="src\inc\shader\normalmapshaderclass.h" />
<ClInclude Include="src\inc\shader\reflectionshaderclass.h" />
<ClInclude Include="src\inc\shader\refractionshaderclass.h" />
<ClInclude Include="src\inc\shader\shadermanagerclass.h" />
<ClInclude Include="src\inc\shader\SkyboxShaderClass.h" />
<ClInclude Include="src\inc\shader\specmapshaderclass.h" />
<ClInclude Include="src\inc\shader\sunlightshaderclass.h" />
<ClInclude Include="src\inc\shader\textureshaderclass.h" />
<ClInclude Include="src\inc\shader\translateshaderclass.h" />
<ClInclude Include="src\inc\shader\transparentshaderclass.h" />
<ClInclude Include="src\inc\shader\watershaderclass.h" />
<ClInclude Include="src\inc\system\applicationclass.h" />
<ClInclude Include="src\inc\system\bitmapclass.h" />
<ClInclude Include="src\inc\system\Cameraclass.h" />
<ClInclude Include="src\inc\system\d3dclass.h" />
<ClInclude Include="src\inc\system\displayplaneclass.h" />
<ClInclude Include="src\inc\system\fontclass.h" />
<ClInclude Include="src\inc\system\fpsclass.h" />
<ClInclude Include="src\inc\shader\alpha_map_shader_class.h" />
<ClInclude Include="src\inc\shader\celshade_class.h" />
<ClInclude Include="src\inc\shader\color_shader_class.h" />
<ClInclude Include="src\inc\shader\depth_shader_class.h" />
<ClInclude Include="src\inc\shader\font_shader_class.h" />
<ClInclude Include="src\inc\shader\light_map_shader_class.h" />
<ClInclude Include="src\inc\shader\light_shader_class.h" />
<ClInclude Include="src\inc\shader\master_shader.h" />
<ClInclude Include="src\inc\shader\multi_texture_shader_class.h" />
<ClInclude Include="src\inc\shader\normal_map_shader_class.h" />
<ClInclude Include="src\inc\shader\reflection_shader_class.h" />
<ClInclude Include="src\inc\shader\refraction_shader_class.h" />
<ClInclude Include="src\inc\shader\shader_manager_class.h" />
<ClInclude Include="src\inc\shader\skybox_shader_class.h" />
<ClInclude Include="src\inc\shader\spec_map_shader_class.h" />
<ClInclude Include="src\inc\shader\sunlight_shader_class.h" />
<ClInclude Include="src\inc\shader\texture_shader_class.h" />
<ClInclude Include="src\inc\shader\translate_shader_class.h" />
<ClInclude Include="src\inc\shader\transparent_shader_class.h" />
<ClInclude Include="src\inc\shader\water_shader_class.h" />
<ClInclude Include="src\inc\system\application_class.h" />
<ClInclude Include="src\inc\system\bitmap_class.h" />
<ClInclude Include="src\inc\system\camera_class.h" />
<ClInclude Include="src\inc\system\d_3d_class.h" />
<ClInclude Include="src\inc\system\display_plane_class.h" />
<ClInclude Include="src\inc\system\font_class.h" />
<ClInclude Include="src\inc\system\fps_class.h" />
<ClInclude Include="src\inc\system\fps_limiter.h" />
<ClInclude Include="src\inc\system\frustum.h" />
<ClInclude Include="src\inc\system\frustumclass.h" />
<ClInclude Include="src\inc\system\imguiManager.h" />
<ClInclude Include="src\inc\system\inputclass.h" />
<ClInclude Include="src\inc\system\lightclass.h" />
<ClInclude Include="src\inc\system\input_class.h" />
<ClInclude Include="src\inc\system\light_class.h" />
<ClInclude Include="src\inc\system\Logger.h" />
<ClInclude Include="src\inc\system\modelclass.h" />
<ClInclude Include="src\inc\system\model_class.h" />
<ClInclude Include="src\inc\system\Modellistclass.h" />
<ClInclude Include="src\inc\system\object.h" />
<ClInclude Include="src\inc\system\physics.h" />
<ClInclude Include="src\inc\system\Positionclass.h" />
<ClInclude Include="src\inc\system\rendertextureclass.h" />
<ClInclude Include="src\inc\system\position_class.h" />
<ClInclude Include="src\inc\system\render_texture_class.h" />
<ClInclude Include="src\inc\system\sceneManager.h" />
<ClInclude Include="src\inc\system\shadow_map.h" />
<ClInclude Include="src\inc\system\Skybox.h" />
<ClInclude Include="src\inc\system\Spriteclass.h" />
<ClInclude Include="src\inc\system\systemclass.h" />
<ClInclude Include="src\inc\system\textclass.h" />
<ClInclude Include="src\inc\system\textureclass.h" />
<ClInclude Include="src\inc\system\Timerclass.h" />
<ClInclude Include="src\inc\system\sprite_class.h" />
<ClInclude Include="src\inc\system\system_class.h" />
<ClInclude Include="src\inc\system\text_class.h" />
<ClInclude Include="src\inc\system\texture_class.h" />
<ClInclude Include="src\inc\system\timer_class.h" />
<ClInclude Include="src\inc\system\vulkan.h" />
</ItemGroup>
<ItemGroup>
@ -167,6 +173,16 @@
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\src\hlsl</DestinationFolders>
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)\src\hlsl</DestinationFolders>
</CopyFileToFolders>
<CopyFileToFolders Include="src\hlsl\depth.ps">
<DestinationFolders>F:\Github_Repo\khaotic-engine-Reborn\x64\Debug\\src\hlsl</DestinationFolders>
<DestinationFileName>%(Filename)%(Extension)</DestinationFileName>
<FileType>Document</FileType>
</CopyFileToFolders>
<CopyFileToFolders Include="src\hlsl\depth.vs">
<DestinationFolders>F:\Github_Repo\khaotic-engine-Reborn\x64\Debug\\src\hlsl</DestinationFolders>
<DestinationFileName>%(Filename)%(Extension)</DestinationFileName>
<FileType>Document</FileType>
</CopyFileToFolders>
<CopyFileToFolders Include="src\hlsl\font.ps">
<FileType>Document</FileType>
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\src\hlsl</DestinationFolders>

View File

@ -4,28 +4,28 @@ Size=400,400
Collapsed=0
[Window][Khaotic Engine]
Pos=1745,19
Size=303,1110
Pos=1281,19
Size=303,842
Collapsed=0
DockId=0x00000005,0
DockId=0x0000000F,0
[Window][Objects]
Pos=0,19
Size=281,307
Collapsed=0
DockId=0x00000007,0
DockId=0x00000011,0
[Window][Terrain]
Pos=0,19
Size=281,883
Size=280,842
Collapsed=0
DockId=0x00000008,0
DockId=0x00000007,0
[Window][Light]
Pos=0,328
Size=281,306
Pos=0,19
Size=281,842
Collapsed=0
DockId=0x00000008,1
DockId=0x00000012,0
[Window][Shader Manager]
Pos=8,27
@ -34,10 +34,10 @@ Collapsed=0
DockId=0x00000001,2
[Window][Engine Settings]
Pos=0,19
Size=281,307
Pos=1281,527
Size=303,334
Collapsed=0
DockId=0x00000007,1
DockId=0x00000010,0
[Window][DockSpace Demo]
Size=1584,861
@ -47,11 +47,11 @@ Collapsed=0
Pos=8,27
Size=1559,974
Collapsed=0
DockId=0x00000007,0
DockId=0x00000011,0
[Window][DockSpace]
Pos=0,0
Size=2048,1129
Size=1584,861
Collapsed=0
[Window][Add Object]
@ -66,32 +66,36 @@ Collapsed=0
DockId=0x0000000C,0
[Window][Log Window]
Pos=652,636
Size=649,225
Pos=0,636
Size=1279,225
Collapsed=0
DockId=0x00000006,0
[Window][Render Stats]
Pos=0,904
Size=1743,225
Pos=0,636
Size=1279,225
Collapsed=0
DockId=0x00000004,0
[Docking][Data]
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x393905AB
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=2048,1110 Split=X
DockNode ID=0x00000002 Parent=0xCCBD8CF7 SizeRef=1743,826 Split=Y
DockNode ID=0x0000000A Parent=0x00000002 SizeRef=1568,599 Split=X
DockNode ID=0x00000009 Parent=0x0000000A SizeRef=281,974 Split=Y Selected=0x031DC75C
DockNode ID=0x00000007 Parent=0x00000009 SizeRef=289,547 Selected=0x0B098C4B
DockNode ID=0x00000008 Parent=0x00000009 SizeRef=289,545 Selected=0x393905AB
DockNode ID=0x0000000D Parent=0x0000000A SizeRef=1460,974 Split=Y
DockNode ID=0x0000000B Parent=0x0000000D SizeRef=1568,637 CentralNode=1 Selected=0x321620B2
DockNode ID=0x0000000C Parent=0x0000000D SizeRef=1568,335 Selected=0x139FDA3F
DockNode ID=0x0000000E Parent=0x00000002 SizeRef=1568,225 Split=X Selected=0xD99DEA49
DockNode ID=0x00000004 Parent=0x0000000E SizeRef=882,225 Selected=0xD99DEA49
DockNode ID=0x00000006 Parent=0x0000000E SizeRef=881,225 Selected=0xAB74BEE9
DockNode ID=0x00000005 Parent=0xCCBD8CF7 SizeRef=303,826 Selected=0x9F035453
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x393905AB
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1584,842 Split=X
DockNode ID=0x00000002 Parent=0xCCBD8CF7 SizeRef=1743,826 Split=Y
DockNode ID=0x0000000A Parent=0x00000002 SizeRef=1568,599 Split=X
DockNode ID=0x00000009 Parent=0x0000000A SizeRef=281,974 Split=Y Selected=0x031DC75C
DockNode ID=0x00000011 Parent=0x00000009 SizeRef=281,441 Selected=0x031DC75C
DockNode ID=0x00000012 Parent=0x00000009 SizeRef=281,440 Selected=0x321620B2
DockNode ID=0x0000000D Parent=0x0000000A SizeRef=1460,974 Split=Y
DockNode ID=0x0000000B Parent=0x0000000D SizeRef=1568,637 Split=X Selected=0x321620B2
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=280,883 Selected=0x393905AB
DockNode ID=0x00000008 Parent=0x0000000B SizeRef=1178,883 CentralNode=1
DockNode ID=0x0000000C Parent=0x0000000D SizeRef=1568,335 Selected=0x139FDA3F
DockNode ID=0x0000000E Parent=0x00000002 SizeRef=1568,225 Split=X Selected=0xD99DEA49
DockNode ID=0x00000004 Parent=0x0000000E SizeRef=871,225 Selected=0xD99DEA49
DockNode ID=0x00000006 Parent=0x0000000E SizeRef=870,225 Selected=0xAB74BEE9
DockNode ID=0x00000005 Parent=0xCCBD8CF7 SizeRef=303,826 Split=Y Selected=0x9F035453
DockNode ID=0x0000000F Parent=0x00000005 SizeRef=303,667 Selected=0x9F035453
DockNode ID=0x00000010 Parent=0x00000005 SizeRef=303,441 Selected=0x0B098C4B

View File

@ -340,10 +340,10 @@ namespace ImGui
IMGUI_API ImGuiIO& GetIO(); // access the ImGuiIO structure (mouse/keyboard/gamepad inputs, time, various configuration options/flags)
IMGUI_API ImGuiPlatformIO& GetPlatformIO(); // access the ImGuiPlatformIO structure (mostly hooks/functions to connect to platform/renderer and OS Clipboard, IME etc.)
IMGUI_API ImGuiStyle& GetStyle(); // access the Style structure (colors, sizes). Always use PushStyleColor(), PushStyleVar() to modify style mid-frame!
IMGUI_API void NewFrame(); // start a new Dear ImGui frame, you can submit any command from this point until Render()/EndFrame().
IMGUI_API void EndFrame(); // ends the Dear ImGui frame. automatically called by Render(). If you don't need to render data (skipping rendering) you may call EndFrame() without Render()... but you'll have wasted CPU already! If you don't need to render, better to not create any windows and not call NewFrame() at all!
IMGUI_API void NewFrame(); // start a new Dear ImGui frame, you can submit any command from this point until render()/EndFrame().
IMGUI_API void EndFrame(); // ends the Dear ImGui frame. automatically called by render(). If you don't need to render data (skipping rendering) you may call EndFrame() without render()... but you'll have wasted CPU already! If you don't need to render, better to not create any windows and not call NewFrame() at all!
IMGUI_API void Render(); // ends the Dear ImGui frame, finalize the draw data. You can then get call GetDrawData().
IMGUI_API ImDrawData* GetDrawData(); // valid after Render() and until the next call to NewFrame(). this is what you have to render.
IMGUI_API ImDrawData* GetDrawData(); // valid after render() and until the next call to NewFrame(). this is what you have to render.
// Demo, Debug, Information
IMGUI_API void ShowDemoWindow(bool* p_open = NULL); // create Demo window. demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application!
@ -409,8 +409,8 @@ namespace ImGui
IMGUI_API float GetWindowDpiScale(); // get DPI scale currently associated to the current window's viewport.
IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (IT IS UNLIKELY YOU EVER NEED TO USE THIS. Consider always using GetCursorScreenPos() and GetContentRegionAvail() instead)
IMGUI_API ImVec2 GetWindowSize(); // get current window size (IT IS UNLIKELY YOU EVER NEED TO USE THIS. Consider always using GetCursorScreenPos() and GetContentRegionAvail() instead)
IMGUI_API float GetWindowWidth(); // get current window width (IT IS UNLIKELY YOU EVER NEED TO USE THIS). Shortcut for GetWindowSize().x.
IMGUI_API float GetWindowHeight(); // get current window height (IT IS UNLIKELY YOU EVER NEED TO USE THIS). Shortcut for GetWindowSize().y.
IMGUI_API float GetWindowWidth(); // get current window width (IT IS UNLIKELY YOU EVER NEED TO USE THIS). Shortcut for get_window_size().x.
IMGUI_API float GetWindowHeight(); // get current window height (IT IS UNLIKELY YOU EVER NEED TO USE THIS). Shortcut for get_window_size().y.
IMGUI_API ImGuiViewport*GetWindowViewport(); // get viewport currently associated to the current window.
// Window manipulation
@ -1048,7 +1048,7 @@ namespace ImGui
IMGUI_API bool IsMouseDragging(ImGuiMouseButton button, float lock_threshold = -1.0f); // is mouse dragging? (uses io.MouseDraggingThreshold if lock_threshold < 0.0f)
IMGUI_API ImVec2 GetMouseDragDelta(ImGuiMouseButton button = 0, float lock_threshold = -1.0f); // return the delta from the initial clicking position while the mouse button is pressed or was just released. This is locked and return 0.0f until the mouse moves past a distance threshold at least once (uses io.MouseDraggingThreshold if lock_threshold < 0.0f)
IMGUI_API void ResetMouseDragDelta(ImGuiMouseButton button = 0); //
IMGUI_API ImGuiMouseCursor GetMouseCursor(); // get desired mouse cursor shape. Important: reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you
IMGUI_API ImGuiMouseCursor GetMouseCursor(); // get desired mouse cursor shape. Important: reset in ImGui::NewFrame(), this is updated during the frame. valid before render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you
IMGUI_API void SetMouseCursor(ImGuiMouseCursor cursor_type); // set desired mouse cursor shape
IMGUI_API void SetNextFrameWantCaptureMouse(bool want_capture_mouse); // Override io.WantCaptureMouse flag next frame (said flag is left for your application to handle, typical when true it instucts your app to ignore inputs). This is equivalent to setting "io.WantCaptureMouse = want_capture_mouse;" after the next NewFrame() call.
@ -1091,7 +1091,7 @@ namespace ImGui
// Note: You may use GetWindowViewport() to get the current viewport of the current window.
IMGUI_API void UpdatePlatformWindows(); // call in main loop. will call CreateWindow/ResizeWindow/etc. platform functions for each secondary viewport, and DestroyWindow for each inactive viewport.
IMGUI_API void RenderPlatformWindowsDefault(void* platform_render_arg = NULL, void* renderer_render_arg = NULL); // call in main loop. will call RenderWindow/SwapBuffers platform functions for each secondary viewport which doesn't have the ImGuiViewportFlags_Minimized flag set. May be reimplemented by user for custom rendering needs.
IMGUI_API void DestroyPlatformWindows(); // call DestroyWindow platform functions for all viewports. call from backend Shutdown() if you need to close platform windows before imgui shutdown. otherwise will be called by DestroyContext().
IMGUI_API void DestroyPlatformWindows(); // call DestroyWindow platform functions for all viewports. call from backend shutdown() if you need to close platform windows before imgui shutdown. otherwise will be called by DestroyContext().
IMGUI_API ImGuiViewport* FindViewportByID(ImGuiID id); // this is a helper for backends.
IMGUI_API ImGuiViewport* FindViewportByPlatformHandle(void* platform_handle); // this is a helper for backends. the type platform_handle is decided by the backend (e.g. HWND, MyWindow*, GLFWwindow* etc.)
@ -1247,7 +1247,7 @@ enum ImGuiTreeNodeFlags_
ImGuiTreeNodeFlags_SpanAvailWidth = 1 << 11, // Extend hit box to the right-most edge, even if not framed. This is not the default in order to allow adding other items on the same line without using AllowOverlap mode.
ImGuiTreeNodeFlags_SpanFullWidth = 1 << 12, // Extend hit box to the left-most and right-most edges (cover the indent area).
ImGuiTreeNodeFlags_SpanLabelWidth = 1 << 13, // Narrow hit box + narrow hovering highlight, will only cover the label text.
ImGuiTreeNodeFlags_SpanAllColumns = 1 << 14, // Frame will span all columns of its container table (label will still fit in current column)
ImGuiTreeNodeFlags_SpanAllColumns = 1 << 14, // frame will span all columns of its container table (label will still fit in current column)
ImGuiTreeNodeFlags_LabelSpanAllColumns = 1 << 15, // Label will span all columns of its container table
//ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 16, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible
ImGuiTreeNodeFlags_NavLeftJumpsBackHere = 1 << 17, // (WIP) Nav: left direction may move to this TreeNode() from any of its child (items submitted between TreeNode and TreePop)
@ -1289,7 +1289,7 @@ enum ImGuiSelectableFlags_
{
ImGuiSelectableFlags_None = 0,
ImGuiSelectableFlags_NoAutoClosePopups = 1 << 0, // Clicking this doesn't close parent popup window (overrides ImGuiItemFlags_AutoClosePopups)
ImGuiSelectableFlags_SpanAllColumns = 1 << 1, // Frame will span all columns of its container table (text will still fit in current column)
ImGuiSelectableFlags_SpanAllColumns = 1 << 1, // frame will span all columns of its container table (text will still fit in current column)
ImGuiSelectableFlags_AllowDoubleClick = 1 << 2, // Generate press events on double clicks too
ImGuiSelectableFlags_Disabled = 1 << 3, // Cannot be selected, display grayed out text
ImGuiSelectableFlags_AllowOverlap = 1 << 4, // (WIP) Hit testing to allow subsequent widgets to overlap this one
@ -2251,7 +2251,7 @@ struct ImGuiStyle
float DockingSeparatorSize; // Thickness of resizing border between docked windows
float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). We apply per-monitor DPI scaling over this scale. May be removed later.
bool AntiAliasedLines; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList).
bool AntiAliasedLinesUseTex; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering). Latched at the beginning of the frame (copied to ImDrawList).
bool AntiAliasedLinesUseTex; // Enable anti-aliased lines/borders using textures_ where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering). Latched at the beginning of the frame (copied to ImDrawList).
bool AntiAliasedFill; // Enable anti-aliased edges around filled shapes (rounded rectangles, circles, etc.). Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList).
float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
float CircleTessellationMaxError; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry.
@ -2446,7 +2446,7 @@ struct ImGuiIO
#endif
//------------------------------------------------------------------
// Output - Updated by NewFrame() or EndFrame()/Render()
// Output - Updated by NewFrame() or EndFrame()/render()
// (when reading from the io.WantCaptureMouse, io.WantCaptureKeyboard flags to dispatch your inputs, it is
// generally easier and more correct to use their state BEFORE calling NewFrame(). See FAQ for details!)
//------------------------------------------------------------------
@ -2459,8 +2459,8 @@ struct ImGuiIO
bool NavActive; // Keyboard/Gamepad navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
bool NavVisible; // Keyboard/Gamepad navigation highlight is visible and allowed (will handle ImGuiKey_NavXXX events).
float Framerate; // Estimate of application framerate (rolling average over 60 frames, based on io.DeltaTime), in frame per second. Solely for convenience. Slow applications may not want to use a moving average or may want to reset underlying buffers occasionally.
int MetricsRenderVertices; // Vertices output during last call to Render()
int MetricsRenderIndices; // Indices output during last call to Render() = number of triangles * 3
int MetricsRenderVertices; // Vertices output during last call to render()
int MetricsRenderIndices; // Indices output during last call to render() = number of triangles * 3
int MetricsRenderWindows; // Number of visible windows
int MetricsActiveWindows; // Number of active windows
ImVec2 MouseDelta; // Mouse delta. Note that this is zero if either current or previous position are invalid (-FLT_MAX,-FLT_MAX), so a disappearing/reappearing mouse won't have a huge delta.
@ -3038,7 +3038,7 @@ struct ImGuiSelectionExternalStorage
// Hold a series of drawing commands. The user provides a renderer for ImDrawData which essentially contains an array of ImDrawList.
//-----------------------------------------------------------------------------
// The maximum line width to bake anti-aliased textures for. Build atlas with ImFontAtlasFlags_NoBakedLines to disable baking.
// The maximum line width to bake anti-aliased textures_ for. Build atlas with ImFontAtlasFlags_NoBakedLines to disable baking.
#ifndef IM_DRAWLIST_TEX_LINES_WIDTH_MAX
#define IM_DRAWLIST_TEX_LINES_WIDTH_MAX (32)
#endif
@ -3057,7 +3057,7 @@ typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* c
// Special Draw callback value to request renderer backend to reset the graphics/render state.
// The renderer backend needs to handle this special value, otherwise it will crash trying to call a function at this address.
// This is useful, for example, if you submitted callbacks which you know have altered the render state and you want it to be restored.
// Render state is not reset by default because they are many perfectly useful way of altering render state (e.g. changing shader/blending settings before an Image call).
// render state is not reset by default because they are many perfectly useful way of altering render state (e.g. changing shader/blending settings before an Image call).
#define ImDrawCallback_ResetRenderState (ImDrawCallback)(-8)
// Typically, 1 command = 1 GPU draw call (unless command is a callback)
@ -3156,8 +3156,8 @@ enum ImDrawFlags_
enum ImDrawListFlags_
{
ImDrawListFlags_None = 0,
ImDrawListFlags_AntiAliasedLines = 1 << 0, // Enable anti-aliased lines/borders (*2 the number of triangles for 1.0f wide line or lines thin enough to be drawn using textures, otherwise *3 the number of triangles)
ImDrawListFlags_AntiAliasedLinesUseTex = 1 << 1, // Enable anti-aliased lines/borders using textures when possible. Require backend to render with bilinear filtering (NOT point/nearest filtering).
ImDrawListFlags_AntiAliasedLines = 1 << 0, // Enable anti-aliased lines/borders (*2 the number of triangles for 1.0f wide line or lines thin enough to be drawn using textures_, otherwise *3 the number of triangles)
ImDrawListFlags_AntiAliasedLinesUseTex = 1 << 1, // Enable anti-aliased lines/borders using textures_ when possible. Require backend to render with bilinear filtering (NOT point/nearest filtering).
ImDrawListFlags_AntiAliasedFill = 1 << 2, // Enable anti-aliased edge around filled shapes (rounded rectangles, circles).
ImDrawListFlags_AllowVtxOffset = 1 << 3, // Can emit 'VtxOffset > 0' to allow large meshes. Set when 'ImGuiBackendFlags_RendererHasVtxOffset' is enabled.
};
@ -3198,7 +3198,7 @@ struct ImDrawList
IMGUI_API ImDrawList(ImDrawListSharedData* shared_data);
IMGUI_API ~ImDrawList();
IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect = false); // Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect = false); // render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
IMGUI_API void PushClipRectFullScreen();
IMGUI_API void PopClipRect();
IMGUI_API void PushTextureID(ImTextureID texture_id);
@ -3211,7 +3211,7 @@ struct ImDrawList
// - For rectangular primitives, "p_min" and "p_max" represent the upper-left and lower-right corners.
// - For circle primitives, use "num_segments == 0" to automatically calculate tessellation (preferred).
// In older versions (until Dear ImGui 1.77) the AddCircle functions defaulted to num_segments == 12.
// In future versions we will use textures to provide cheaper and higher-quality circles.
// In future versions we will use textures_ to provide cheaper and higher-quality circles.
// Use AddNgon() and AddNgonFilled() functions if you need to guarantee a specific number of sides.
IMGUI_API void AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float thickness = 1.0f);
IMGUI_API void AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding = 0.0f, ImDrawFlags flags = 0, float thickness = 1.0f); // a: upper-left, b: lower-right (== upper-left + size)
@ -3326,7 +3326,7 @@ struct ImDrawList
// as this is one of the oldest structure exposed by the library! Basically, ImDrawList == CmdList)
struct ImDrawData
{
bool Valid; // Only valid after Render() is called and before the next NewFrame() is called.
bool Valid; // Only valid after render() is called and before the next NewFrame() is called.
int CmdListsCount; // Number of ImDrawList* to render
int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size
int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size
@ -3426,7 +3426,7 @@ enum ImFontAtlasFlags_
ImFontAtlasFlags_None = 0,
ImFontAtlasFlags_NoPowerOfTwoHeight = 1 << 0, // Don't round the height to next power of two
ImFontAtlasFlags_NoMouseCursors = 1 << 1, // Don't build software mouse cursors into the atlas (save a little texture memory)
ImFontAtlasFlags_NoBakedLines = 1 << 2, // Don't build thick line textures into the atlas (save a little texture memory, allow support for point/nearest filtering). The AntiAliasedLinesUseTex features uses them, otherwise they will be rendered using polygons (more expensive for CPU/GPU).
ImFontAtlasFlags_NoBakedLines = 1 << 2, // Don't build thick line textures_ into the atlas (save a little texture memory, allow support for point/nearest filtering). The AntiAliasedLinesUseTex features uses them, otherwise they will be rendered using polygons (more expensive for CPU/GPU).
};
// Load and rasterize multiple TTF/OTF fonts into a same texture. The font atlas will build a single texture holding:
@ -3647,7 +3647,7 @@ struct ImGuiViewport
ImVec2 WorkSize; // Work Area: Size of the viewport minus task bars, menu bars, status bars (<= Size)
float DpiScale; // 1.0f = 96 DPI = No extra scale.
ImGuiID ParentViewportId; // (Advanced) 0: no parent. Instruct the platform backend to setup a parent/child relationship between platform windows.
ImDrawData* DrawData; // The ImDrawData corresponding to this viewport. Valid after Render() and until the next call to NewFrame().
ImDrawData* DrawData; // The ImDrawData corresponding to this viewport. Valid after render() and until the next call to NewFrame().
// Platform/Backend Dependent Data
// Our design separate the Renderer and Platform backends to facilitate combining default backends with each others.
@ -3693,7 +3693,7 @@ struct ImGuiViewport
// Steps to use multi-viewports in your application, when using a default backend from the examples/ folder:
// - Application: Enable feature with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// - Backend: The backend initialization will setup all necessary ImGuiPlatformIO's functions and update monitors info every frame.
// - Application: In your main loop, call ImGui::UpdatePlatformWindows(), ImGui::RenderPlatformWindowsDefault() after EndFrame() or Render().
// - Application: In your main loop, call ImGui::UpdatePlatformWindows(), ImGui::RenderPlatformWindowsDefault() after EndFrame() or render().
// - Application: Fix absolute coordinates used in ImGui::SetWindowPos() or ImGui::SetNextWindowPos() calls.
//
// Steps to use multi-viewports in your application, when using a custom backend:
@ -3705,7 +3705,7 @@ struct ImGuiViewport
// Set 'io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports' and 'io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports'.
// Update ImGuiPlatformIO's Monitors list every frame.
// Update MousePos every frame, in absolute coordinates.
// - Application: In your main loop, call ImGui::UpdatePlatformWindows(), ImGui::RenderPlatformWindowsDefault() after EndFrame() or Render().
// - Application: In your main loop, call ImGui::UpdatePlatformWindows(), ImGui::RenderPlatformWindowsDefault() after EndFrame() or render().
// You may skip calling RenderPlatformWindowsDefault() if its API is not convenient for your needs. Read comments below.
// - Application: Fix absolute coordinates used in ImGui::SetWindowPos() or ImGui::SetNextWindowPos() calls.
//
@ -3811,7 +3811,7 @@ struct ImGuiPlatformIO
// Output - List of viewports to render into platform windows
//------------------------------------------------------------------
// Viewports list (the list is updated by calling ImGui::EndFrame or ImGui::Render)
// Viewports list (the list is updated by calling ImGui::EndFrame or ImGui::render)
// (in the future we will attempt to organize this feature to remove the need for a "main viewport")
ImVector<ImGuiViewport*> Viewports; // Main viewports, followed by all secondary viewports.
};

Binary file not shown.

View File

@ -0,0 +1,24 @@
/////////////
// GLOBALS //
/////////////
Texture2D shaderTexture : register(t0);
SamplerState SampleType : register(s0);
//////////////
// TYPEDEFS //
//////////////
struct PixelInputType
{
float4 position : SV_POSITION;
float2 tex : TEXCOORD0;
};
////////////////////////////////////////////////////////////////////////////////
// Pixel Shader
////////////////////////////////////////////////////////////////////////////////
float4 DepthPixelShader(PixelInputType input) : SV_TARGET
{
float depth = input.position.z / input.position.w;
depth = 1.0f - depth;
return float4(depth, depth, depth, 1.0f);
}

View File

@ -0,0 +1,47 @@
/////////////
// GLOBALS //
/////////////
cbuffer MatrixBuffer
{
matrix worldMatrix;
matrix viewMatrix;
matrix projectionMatrix;
};
//////////////
// TYPEDEFS //
//////////////
struct VertexInputType
{
float4 position : POSITION;
float2 tex : TEXCOORD0;
};
struct PixelInputType
{
float4 position : SV_POSITION;
float2 tex : TEXCOORD0;
};
////////////////////////////////////////////////////////////////////////////////
// Vertex Shader
////////////////////////////////////////////////////////////////////////////////
PixelInputType DepthVertexShader(VertexInputType input)
{
PixelInputType output;
// Change the position vector to be 4 units for proper matrix calculations.
input.position.w = 1.0f;
// Calculate the position of the vertex against the world, view, and projection matrices.
output.position = mul(input.position, worldMatrix);
output.position = mul(output.position, viewMatrix);
output.position = mul(output.position, projectionMatrix);
// Store the texture coordinates for the pixel shader.
output.tex = input.tex;
return output;
}

View File

@ -1,64 +0,0 @@
#pragma once
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
class CelshadeClass
{
private :
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct CameraBufferType
{
XMFLOAT3 cameraPosition;
float padding;
};
struct SunLightBufferType
{
XMFLOAT4 diffuseColor;
XMFLOAT4 ambientColor;
XMFLOAT3 sunDirection;
float intensity;
};
public :
CelshadeClass();
CelshadeClass(const CelshadeClass&);
~CelshadeClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext* deviceContex, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection,float intensity);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 ambientColor, XMFLOAT4 diffuseColor, XMFLOAT3 lightDirection, float sunIntensity);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_matrixBuffer;
ID3D11Buffer* m_cameraBuffer;
ID3D11Buffer* m_sunlightBuffer;
ID3D11Buffer* m_sunlightColorBuffer;
ID3D11Buffer* m_sunlightPositionBuffer;
};

View File

@ -1,59 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: multitextureshaderclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _MULTITEXTURESHADERCLASS_H_
#define _MULTITEXTURESHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: MultiTextureShaderClass
////////////////////////////////////////////////////////////////////////////////
class MultiTextureShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
public:
MultiTextureShaderClass();
MultiTextureShaderClass(const MultiTextureShaderClass&);
~MultiTextureShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
};
#endif

View File

@ -0,0 +1,55 @@
#ifndef _ALPHAMAPSHADERCLASS_H_
#define _ALPHAMAPSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: alpha_map_shader_class
////////////////////////////////////////////////////////////////////////////////
class alpha_map_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
public:
alpha_map_shader_class();
alpha_map_shader_class(const alpha_map_shader_class&);
~alpha_map_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
private:
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
};
#endif

View File

@ -1,55 +0,0 @@
#ifndef _ALPHAMAPSHADERCLASS_H_
#define _ALPHAMAPSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: AlphaMapShaderClass
////////////////////////////////////////////////////////////////////////////////
class AlphaMapShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
public:
AlphaMapShaderClass();
AlphaMapShaderClass(const AlphaMapShaderClass&);
~AlphaMapShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
};
#endif

View File

@ -0,0 +1,85 @@
#pragma once
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
class celshade_class
{
private :
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct camera_buffer_type
{
XMFLOAT3 cameraPosition;
float padding;
};
struct sun_light_buffer_type
{
XMFLOAT4 diffuse_color;
XMFLOAT4 ambient_color;
XMFLOAT3 sun_direction;
float intensity;
};
public :
celshade_class();
celshade_class(const celshade_class&);
~celshade_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(
ID3D11DeviceContext* device_context,
int index_count,
XMMATRIX world_matrix,
XMMATRIX view_matrix, XMMATRIX
projection_matrix,
ID3D11ShaderResourceView* texture,
XMFLOAT4 diffuse_color,
XMFLOAT4 ambient_color,
XMFLOAT3 sun_direction,
float intensity
);
private:
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool set_shader_parameters(
ID3D11DeviceContext* device_context,
XMMATRIX world_matrix,
XMMATRIX view_matrix,
XMMATRIX projection_matrix,
ID3D11ShaderResourceView* texture,
XMFLOAT4 ambient_color,
XMFLOAT4 diffuse_color,
XMFLOAT3 light_direction,
float sun_intensity
);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* matrix_buffer_;
ID3D11Buffer* camera_buffer_;
ID3D11Buffer* sunlight_buffer_;
ID3D11Buffer* sunlight_color_buffer_;
ID3D11Buffer* sunlight_position_buffer_;
};

View File

@ -18,12 +18,12 @@ using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: ColorShaderClass
// Class name: color_shader_class
////////////////////////////////////////////////////////////////////////////////
class ColorShaderClass
class color_shader_class
{
private:
struct MatrixBufferType
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
@ -31,27 +31,27 @@ private:
};
public:
ColorShaderClass();
ColorShaderClass(const ColorShaderClass&);
~ColorShaderClass();
color_shader_class();
color_shader_class(const color_shader_class&);
~color_shader_class();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX);
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX);
void RenderShader(ID3D11DeviceContext*, int);
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
};
#endif

View File

@ -0,0 +1,56 @@
#ifndef _DEPTH_SHADER_CLASS_H_
#define _DEPTH_SHADER_CLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: depth_shader_class
////////////////////////////////////////////////////////////////////////////////
class depth_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
public:
depth_shader_class();
depth_shader_class(const depth_shader_class&);
~depth_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*);
private:
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
};
#endif

View File

@ -0,0 +1,62 @@
#ifndef _FONTSHADERCLASS_H_
#define _FONTSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: font_shader_class
////////////////////////////////////////////////////////////////////////////////
class font_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct pixel_buffer_type
{
XMFLOAT4 pixelColor;
};
public:
font_shader_class();
font_shader_class(const font_shader_class&);
~font_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4);
private:
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* pixel_buffer_;
};
#endif

View File

@ -1,62 +0,0 @@
#ifndef _FONTSHADERCLASS_H_
#define _FONTSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: FontShaderClass
////////////////////////////////////////////////////////////////////////////////
class FontShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct PixelBufferType
{
XMFLOAT4 pixelColor;
};
public:
FontShaderClass();
FontShaderClass(const FontShaderClass&);
~FontShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_pixelBuffer;
};
#endif

View File

@ -0,0 +1,57 @@
////////////////////////////////////////////////////////////////////////////////
#ifndef _LIGHTMAPSHADERCLASS_H_
#define _LIGHTMAPSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: light_map_shader_class
////////////////////////////////////////////////////////////////////////////////
class light_map_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
public:
light_map_shader_class();
light_map_shader_class(const light_map_shader_class&);
~light_map_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
private:
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
};
#endif

View File

@ -0,0 +1,92 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: lightshaderclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _LIGHTSHADERCLASS_H_
#define _LIGHTSHADERCLASS_H_
#pragma once
/////////////
// GLOBALS //
/////////////
constexpr int num_lights = 4;
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: light_shader_class
////////////////////////////////////////////////////////////////////////////////
class light_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct camera_buffer_type
{
XMFLOAT3 cameraPosition;
float padding;
};
struct light_buffer_type
{
XMFLOAT4 ambientColor;
XMFLOAT4 diffuseColor;
XMFLOAT3 lightDirection;
float padding; // Added extra padding so structure is a multiple of 16 for CreateBuffer function requirements.
float specularPower;
XMFLOAT4 specularColor;
};
struct light_color_buffer_type
{
XMFLOAT4 diffuseColor[num_lights];
};
struct light_position_buffer_type
{
XMFLOAT4 lightPosition[num_lights];
};
public:
light_shader_class();
light_shader_class(const light_shader_class&);
~light_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[]);
private:
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[]);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* matrix_buffer_;
ID3D11Buffer* camera_buffer_;
ID3D11Buffer* light_buffer_;
ID3D11Buffer* light_color_buffer_;
ID3D11Buffer* light_position_buffer_;
};
#endif

View File

@ -1,57 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
#ifndef _LIGHTMAPSHADERCLASS_H_
#define _LIGHTMAPSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: LightMapShaderClass
////////////////////////////////////////////////////////////////////////////////
class LightMapShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
public:
LightMapShaderClass();
LightMapShaderClass(const LightMapShaderClass&);
~LightMapShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
};
#endif

View File

@ -1,92 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: lightshaderclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _LIGHTSHADERCLASS_H_
#define _LIGHTSHADERCLASS_H_
#pragma once
/////////////
// GLOBALS //
/////////////
const int NUM_LIGHTS = 4;
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: LightShaderClass
////////////////////////////////////////////////////////////////////////////////
class LightShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct CameraBufferType
{
XMFLOAT3 cameraPosition;
float padding;
};
struct LightBufferType
{
XMFLOAT4 ambientColor;
XMFLOAT4 diffuseColor;
XMFLOAT3 lightDirection;
float padding; // Added extra padding so structure is a multiple of 16 for CreateBuffer function requirements.
float specularPower;
XMFLOAT4 specularColor;
};
struct LightColorBufferType
{
XMFLOAT4 diffuseColor[NUM_LIGHTS];
};
struct LightPositionBufferType
{
XMFLOAT4 lightPosition[NUM_LIGHTS];
};
public:
LightShaderClass();
LightShaderClass(const LightShaderClass&);
~LightShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[]);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[]);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_matrixBuffer;
ID3D11Buffer* m_cameraBuffer;
ID3D11Buffer* m_lightBuffer;
ID3D11Buffer* m_lightColorBuffer;
ID3D11Buffer* m_lightPositionBuffer;
};
#endif

View File

@ -1 +0,0 @@
#pragma once

View File

@ -0,0 +1,25 @@
#pragma once
#include <d3d11.h>
#include <DirectXMath.h>
#include <string>
class master_shader
{
public :
master_shader();
master_shader(const master_shader& other) = delete;
virtual ~master_shader();
virtual bool initialize(ID3D11Device* device, HWND hwnd) = 0;
protected:
wchar_t vs_filename_[128], ps_filename_[128];
wchar_t const* vs_name_ = L"";
wchar_t const* ps_name_ = L"";
};

View File

@ -0,0 +1,59 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: multitextureshaderclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _MULTITEXTURESHADERCLASS_H_
#define _MULTITEXTURESHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: multi_texture_shader_class
////////////////////////////////////////////////////////////////////////////////
class multi_texture_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
public:
multi_texture_shader_class();
multi_texture_shader_class(const multi_texture_shader_class&);
~multi_texture_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
private:
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
};
#endif

View File

@ -0,0 +1,64 @@
#ifndef _NORMALMAPSHADERCLASS_H_
#define _NORMALMAPSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: normal_map_shader_class
////////////////////////////////////////////////////////////////////////////////
class normal_map_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct light_buffer_type
{
XMFLOAT4 diffuse_color;
XMFLOAT3 light_direction;
float padding;
};
public:
normal_map_shader_class();
normal_map_shader_class(const normal_map_shader_class&);
~normal_map_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4);
private:
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* light_buffer_;
};
#endif

View File

@ -1,64 +0,0 @@
#ifndef _NORMALMAPSHADERCLASS_H_
#define _NORMALMAPSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: NormalMapShaderClass
////////////////////////////////////////////////////////////////////////////////
class NormalMapShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct LightBufferType
{
XMFLOAT4 diffuseColor;
XMFLOAT3 lightDirection;
float padding;
};
public:
NormalMapShaderClass();
NormalMapShaderClass(const NormalMapShaderClass&);
~NormalMapShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_lightBuffer;
};
#endif

View File

@ -0,0 +1,65 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: reflectionshaderclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _REFLECTIONSHADERCLASS_H_
#define _REFLECTIONSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: reflection_shader_class
////////////////////////////////////////////////////////////////////////////////
class reflection_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct reflection_buffer_type
{
XMMATRIX reflection_matrix;
};
public:
reflection_shader_class();
reflection_shader_class(const reflection_shader_class&);
~reflection_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMMATRIX);
private:
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMMATRIX);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* reflection_buffer_;
};
#endif

View File

@ -1,65 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: reflectionshaderclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _REFLECTIONSHADERCLASS_H_
#define _REFLECTIONSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: ReflectionShaderClass
////////////////////////////////////////////////////////////////////////////////
class ReflectionShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct ReflectionBufferType
{
XMMATRIX reflectionMatrix;
};
public:
ReflectionShaderClass();
ReflectionShaderClass(const ReflectionShaderClass&);
~ReflectionShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMMATRIX);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMMATRIX);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_reflectionBuffer;
};
#endif

View File

@ -0,0 +1,72 @@
#ifndef _REFRACTIONSHADERCLASS_H_
#define _REFRACTIONSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: refraction_shader_class
////////////////////////////////////////////////////////////////////////////////
class refraction_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct light_buffer_type
{
XMFLOAT4 ambient_color;
XMFLOAT4 diffuse_color;
XMFLOAT4 light_position;
XMFLOAT3 light_direction;
float padding;
};
struct clip_plane_buffer_type
{
XMFLOAT4 clip_plane;
};
public:
refraction_shader_class();
refraction_shader_class(const refraction_shader_class&);
~refraction_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*,
XMFLOAT3, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[], XMFLOAT4);
private:
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*,
XMFLOAT3, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[], XMFLOAT4);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* matrix_buffer_;
ID3D11Buffer* light_buffer_;
ID3D11Buffer* clip_plane_buffer_;
};
#endif

View File

@ -1,72 +0,0 @@
#ifndef _REFRACTIONSHADERCLASS_H_
#define _REFRACTIONSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: RefractionShaderClass
////////////////////////////////////////////////////////////////////////////////
class RefractionShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct LightBufferType
{
XMFLOAT4 ambientColor;
XMFLOAT4 diffuseColor;
XMFLOAT4 lightPosition;
XMFLOAT3 lightDirection;
float padding;
};
struct ClipPlaneBufferType
{
XMFLOAT4 clipPlane;
};
public:
RefractionShaderClass();
RefractionShaderClass(const RefractionShaderClass&);
~RefractionShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*,
XMFLOAT3, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[], XMFLOAT4);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*,
XMFLOAT3, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[], XMFLOAT4);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_matrixBuffer;
ID3D11Buffer* m_lightBuffer;
ID3D11Buffer* m_clipPlaneBuffer;
};
#endif

View File

@ -0,0 +1,78 @@
#ifndef _SHADERMANAGERCLASS_H_
#define _SHADERMANAGERCLASS_H_
// Inclure les en-têtes nécessaires
#include <d3d11.h>
#include <DirectXMath.h>
#include <vector>
#include "texture_shader_class.h"
#include "normal_map_shader_class.h"
#include "multi_texture_shader_class.h"
#include "translate_shader_class.h"
#include "alpha_map_shader_class.h"
#include "spec_map_shader_class.h"
#include "transparent_shader_class.h"
#include "light_shader_class.h"
#include "light_map_shader_class.h"
#include "refraction_shader_class.h"
#include "water_shader_class.h"
#include "celshade_class.h"
#include "depth_shader_class.h"
#include "skybox_shader_class.h"
#include "sunlight_shader_class.h"
#include "depth_shader_class.h"
using namespace DirectX;
class shader_manager_class
{
public:
shader_manager_class();
shader_manager_class(const shader_manager_class&);
~shader_manager_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render_texture_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*);
bool render_normal_map_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4);
bool render_multitexture_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
bool render_translate_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
bool render_alpha_map_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
bool render_spec_map_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4, XMFLOAT3, XMFLOAT4, float);
bool render_transparent_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
bool renderlight_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[]);
bool renderlight_map_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
bool render_refraction_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[], XMFLOAT4);
bool render_water_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, float, float);
bool render_cel_shading_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
bool render_sunlight_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
bool render_skybox_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
bool render_depth_shader(
ID3D11DeviceContext* context,
int indexCount,
XMMATRIX worldMatrix,
XMMATRIX viewMatrix,
XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture
);
private:
texture_shader_class* texture_shader_;
normal_map_shader_class* normal_map_shader_;
multi_texture_shader_class* multitexture_shader_;
translate_shader_class* translate_shader_;
alpha_map_shader_class* alpha_map_shader_;
spec_map_shader_class* spec_map_shader_;
transparent_shader_class* transparent_shader_;
light_shader_class* light_shader_;
light_map_shader_class* light_map_shader_;
refraction_shader_class* refraction_shader_;
water_shader_class* water_shader_;
celshade_class* cel_shading_shader_;
sunlight_shader_class* sunlight_shader_;
skybox_shader_class* skybox_shader_;
depth_shader_class* depth_shader_;
};
#endif

View File

@ -1,67 +0,0 @@
#ifndef _SHADERMANAGERCLASS_H_
#define _SHADERMANAGERCLASS_H_
// Inclure les en-têtes nécessaires
#include <d3d11.h>
#include <DirectXMath.h>
#include <vector>
#include "textureshaderclass.h"
#include "normalmapshaderclass.h"
#include "multitextureshaderclass.h"
#include "translateshaderclass.h"
#include "alphamapshaderclass.h"
#include "specmapshaderclass.h"
#include "transparentshaderclass.h"
#include "lightshaderclass.h"
#include "lightmapshaderclass.h"
#include "refractionshaderclass.h"
#include "watershaderclass.h"
#include "celshadingshader.h"
#include "SkyboxShaderClass.h"
#include "sunlightshaderclass.h"
using namespace DirectX;
class ShaderManagerClass
{
public:
ShaderManagerClass();
ShaderManagerClass(const ShaderManagerClass&);
~ShaderManagerClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool RenderTextureShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*);
bool RenderNormalMapShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4);
bool RenderMultitextureShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
bool RenderTranslateShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
bool RenderAlphaMapShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
bool RenderSpecMapShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4, XMFLOAT3, XMFLOAT4, float);
bool RenderTransparentShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
bool RenderlightShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[]);
bool RenderlightMapShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
bool RenderRefractionShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[], XMFLOAT4);
bool RenderWaterShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, float, float);
bool RenderCelShadingShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
bool RenderSunlightShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
bool RenderSkyboxShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
private:
TextureShaderClass* m_TextureShader;
NormalMapShaderClass* m_NormalMapShader;
MultiTextureShaderClass* m_MultitextureShader;
TranslateShaderClass* m_TranslateShader;
AlphaMapShaderClass* m_AlphaMapShader;
SpecMapShaderClass* m_SpecMapShader;
TransparentShaderClass* m_TransparentShader;
LightShaderClass* m_LightShader;
LightMapShaderClass* m_LightMapShader;
RefractionShaderClass* m_RefractionShader;
WaterShaderClass* m_WaterShader;
CelshadeClass* m_CelShadingShader;
SunlightShaderClass* m_SunlightShader;
SkyboxShaderClass* m_SkyboxShader;
};
#endif

View File

@ -8,7 +8,7 @@
using namespace DirectX;
using namespace std;
class SkyboxShaderClass
class skybox_shader_class
{
private :
@ -39,9 +39,9 @@ class SkyboxShaderClass
};
public :
SkyboxShaderClass();
SkyboxShaderClass(const SkyboxShaderClass&);
~SkyboxShaderClass();
skybox_shader_class();
skybox_shader_class(const skybox_shader_class&);
~skybox_shader_class();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();

View File

@ -0,0 +1,72 @@
#ifndef _SPECMAPSHADERCLASS_H_
#define _SPECMAPSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: spec_map_shader_class
////////////////////////////////////////////////////////////////////////////////
class spec_map_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct light_buffer_type
{
XMFLOAT4 diffuse_color;
XMFLOAT4 specular_color;
float specular_power;
XMFLOAT3 light_direction;
};
struct camera_buffer_type
{
XMFLOAT3 camera_position;
float padding;
};
public:
spec_map_shader_class();
spec_map_shader_class(const spec_map_shader_class&);
~spec_map_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*,
XMFLOAT3, XMFLOAT4, XMFLOAT3, XMFLOAT4, float);
private:
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*,
XMFLOAT3, XMFLOAT4, XMFLOAT3, XMFLOAT4, float);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* light_buffer_;
ID3D11Buffer* camera_buffer_;
};
#endif

View File

@ -1,72 +0,0 @@
#ifndef _SPECMAPSHADERCLASS_H_
#define _SPECMAPSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: SpecMapShaderClass
////////////////////////////////////////////////////////////////////////////////
class SpecMapShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct LightBufferType
{
XMFLOAT4 diffuseColor;
XMFLOAT4 specularColor;
float specularPower;
XMFLOAT3 lightDirection;
};
struct CameraBufferType
{
XMFLOAT3 cameraPosition;
float padding;
};
public:
SpecMapShaderClass();
SpecMapShaderClass(const SpecMapShaderClass&);
~SpecMapShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*,
XMFLOAT3, XMFLOAT4, XMFLOAT3, XMFLOAT4, float);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*,
XMFLOAT3, XMFLOAT4, XMFLOAT3, XMFLOAT4, float);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_lightBuffer;
ID3D11Buffer* m_cameraBuffer;
};
#endif

View File

@ -0,0 +1,68 @@
#pragma once
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
class sunlight_shader_class
{
private :
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct camera_buffer_type
{
XMFLOAT3 camera_position;
float padding;
};
struct sun_light_buffer_type
{
XMFLOAT4 diffuse_color;
XMFLOAT4 ambient_color;
XMFLOAT3 sun_direction;
float intensity;
};
struct sun_light_color_buffer_type
{
XMFLOAT4 sun_color;
};
public :
sunlight_shader_class();
sunlight_shader_class(const sunlight_shader_class&);
~sunlight_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3,float);
private:
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* matrix_buffer_;
ID3D11Buffer* camera_buffer_;
ID3D11Buffer* sunlight_buffer_;
ID3D11Buffer* sunlight_color_buffer_;
ID3D11Buffer* sunlight_position_buffer_;
};

View File

@ -1,68 +0,0 @@
#pragma once
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
class SunlightShaderClass
{
private :
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct CameraBufferType
{
XMFLOAT3 cameraPosition;
float padding;
};
struct SunLightBufferType
{
XMFLOAT4 diffuseColor;
XMFLOAT4 ambientColor;
XMFLOAT3 sunDirection;
float intensity;
};
struct SunLightColorBufferType
{
XMFLOAT4 sunColor;
};
public :
SunlightShaderClass();
SunlightShaderClass(const SunlightShaderClass&);
~SunlightShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3,float);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_matrixBuffer;
ID3D11Buffer* m_cameraBuffer;
ID3D11Buffer* m_sunlightBuffer;
ID3D11Buffer* m_sunlightColorBuffer;
ID3D11Buffer* m_sunlightPositionBuffer;
};

View File

@ -0,0 +1,56 @@
#ifndef _TEXTURESHADERCLASS_H_
#define _TEXTURESHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: texture_shader_class
////////////////////////////////////////////////////////////////////////////////
class texture_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
public:
texture_shader_class();
texture_shader_class(const texture_shader_class&);
~texture_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*);
private:
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
};
#endif

View File

@ -1,56 +0,0 @@
#ifndef _TEXTURESHADERCLASS_H_
#define _TEXTURESHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: TextureShaderClass
////////////////////////////////////////////////////////////////////////////////
class TextureShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
public:
TextureShaderClass();
TextureShaderClass(const TextureShaderClass&);
~TextureShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
};
#endif

View File

@ -0,0 +1,63 @@
#ifndef _TRANSLATESHADERCLASS_H_
#define _TRANSLATESHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: translate_shader_class
////////////////////////////////////////////////////////////////////////////////
class translate_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct translate_buffer_type
{
float translation;
XMFLOAT3 padding;
};
public:
translate_shader_class();
translate_shader_class(const translate_shader_class&);
~translate_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
private:
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* translate_buffer_;
};
#endif

View File

@ -1,63 +0,0 @@
#ifndef _TRANSLATESHADERCLASS_H_
#define _TRANSLATESHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: TranslateShaderClass
////////////////////////////////////////////////////////////////////////////////
class TranslateShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct TranslateBufferType
{
float translation;
XMFLOAT3 padding;
};
public:
TranslateShaderClass();
TranslateShaderClass(const TranslateShaderClass&);
~TranslateShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_translateBuffer;
};
#endif

View File

@ -0,0 +1,63 @@
#ifndef _TRANSPARENTSHADERCLASS_H_
#define _TRANSPARENTSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: transparent_shader_class
////////////////////////////////////////////////////////////////////////////////
class transparent_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct transparent_buffer_type
{
float blend_amount;
XMFLOAT3 padding;
};
public:
transparent_shader_class();
transparent_shader_class(const transparent_shader_class&);
~transparent_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
private:
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* transparent_buffer_;
};
#endif

View File

@ -1,63 +0,0 @@
#ifndef _TRANSPARENTSHADERCLASS_H_
#define _TRANSPARENTSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: TransparentShaderClass
////////////////////////////////////////////////////////////////////////////////
class TransparentShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct TransparentBufferType
{
float blendAmount;
XMFLOAT3 padding;
};
public:
TransparentShaderClass();
TransparentShaderClass(const TransparentShaderClass&);
~TransparentShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_transparentBuffer;
};
#endif

View File

@ -0,0 +1,70 @@
#ifndef _WATERSHADERCLASS_H_
#define _WATERSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: water_shader_class
////////////////////////////////////////////////////////////////////////////////
class water_shader_class
{
private:
struct matrix_buffer_type
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct reflection_buffer_type
{
XMMATRIX reflection;
};
struct water_buffer_type
{
float water_translation;
float reflect_refract_scale;
XMFLOAT2 padding;
};
public:
water_shader_class();
water_shader_class(const water_shader_class&);
~water_shader_class();
bool initialize(ID3D11Device*, HWND);
void shutdown();
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*,
ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, float, float);
private:
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void shutdown_shader();
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*,
ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, float, float);
void render_shader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* vertex_shader_;
ID3D11PixelShader* pixel_shader_;
ID3D11InputLayout* layout_;
ID3D11Buffer* matrix_buffer_;
ID3D11SamplerState* sample_state_;
ID3D11Buffer* reflection_buffer_;
ID3D11Buffer* water_buffer_;
};
#endif

View File

@ -1,70 +0,0 @@
#ifndef _WATERSHADERCLASS_H_
#define _WATERSHADERCLASS_H_
//////////////
// INCLUDES //
//////////////
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: WaterShaderClass
////////////////////////////////////////////////////////////////////////////////
class WaterShaderClass
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct ReflectionBufferType
{
XMMATRIX reflection;
};
struct WaterBufferType
{
float waterTranslation;
float reflectRefractScale;
XMFLOAT2 padding;
};
public:
WaterShaderClass();
WaterShaderClass(const WaterShaderClass&);
~WaterShaderClass();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*,
ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, float, float);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*,
ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, float, float);
void RenderShader(ID3D11DeviceContext*, int);
private:
ID3D11VertexShader* m_vertexShader;
ID3D11PixelShader* m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_reflectionBuffer;
ID3D11Buffer* m_waterBuffer;
};
#endif

View File

@ -1,46 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: cameraclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _CAMERACLASS_H_
#define _CAMERACLASS_H_
//////////////
// INCLUDES //
//////////////
#include <directxmath.h>
using namespace DirectX;
////////////////////////////////////////////////////////////////////////////////
// Class name: CameraClass
////////////////////////////////////////////////////////////////////////////////
class CameraClass
{
public:
CameraClass();
CameraClass(const CameraClass&);
~CameraClass();
void SetPosition(float, float, float);
void SetRotation(float, float, float);
XMFLOAT3 GetPosition();
XMFLOAT3 GetRotation();
void Render();
XMMATRIX GetViewMatrix(XMMATRIX& viewMatrix) const;
void RenderReflection(float);
void GetReflectionViewMatrix(XMMATRIX&) const;
private:
float m_positionX, m_positionY, m_positionZ;
float m_rotationX, m_rotationY, m_rotationZ;
XMMATRIX m_viewMatrix;
XMMATRIX m_reflectionViewMatrix;
};
#endif

View File

@ -67,12 +67,12 @@ public:
case LogLevel::Info: return LogLevelInfo{ "Info", 0, ImVec4(0.0f, 1.0f, 0.0f, 1.0f) };
case LogLevel::Warning: return LogLevelInfo{ "Warning", 1, ImVec4(1.0f, 1.0f, 0.0f, 1.0f) };
case LogLevel::Error: return LogLevelInfo{ "Error", 2, ImVec4(1.0f, 0.0f, 0.0f, 1.0f) };
case LogLevel::Shutdown: return LogLevelInfo{ "Shutdown", 3, ImVec4(0.5f, 0.0f, 0.0f, 1.0f) };
case LogLevel::Initialize: return LogLevelInfo{ "Initialize", 4, ImVec4(0.0f, 1.0f, 1.0f, 1.0f) };
case LogLevel::Shutdown: return LogLevelInfo{ "shutdown", 3, ImVec4(0.5f, 0.0f, 0.0f, 1.0f) };
case LogLevel::Initialize: return LogLevelInfo{ "initialize", 4, ImVec4(0.0f, 1.0f, 1.0f, 1.0f) };
case LogLevel::Update: return LogLevelInfo{ "Update", 5, ImVec4(1.0f, 0.0f, 1.0f, 1.0f) };
case LogLevel::Render: return LogLevelInfo{ "Render", 6, ImVec4(1.0f, 1.0f, 1.0f, 1.0f) };
case LogLevel::Render: return LogLevelInfo{ "render", 6, ImVec4(1.0f, 1.0f, 1.0f, 1.0f) };
case LogLevel::Input: return LogLevelInfo{ "Input", 7, ImVec4(0.5f, 0.5f, 0.5f, 1.0f) };
case LogLevel::Physics: return LogLevelInfo{ "Physics", 8, ImVec4(0.5f, 0.5f, 0.5f, 1.0f) };
case LogLevel::Physics: return LogLevelInfo{ "physics", 8, ImVec4(0.5f, 0.5f, 0.5f, 1.0f) };
case LogLevel::Audio: return LogLevelInfo{ "Audio", 9, ImVec4(0.5f, 0.5f, 0.5f, 1.0f) };
case LogLevel::Network: return LogLevelInfo{ "Network", 10, ImVec4(0.5f, 0.5f, 0.5f, 1.0f) };
case LogLevel::Scripting: return LogLevelInfo{ "Scripting", 11, ImVec4(0.5f, 0.5f, 0.5f, 1.0f) };

View File

@ -1,7 +1,7 @@
#pragma once
#include <vector>
#include "d3dclass.h"
#include "d_3d_class.h"
#include "object.h"
class Skybox
@ -11,9 +11,9 @@ public:
Skybox();
~Skybox();
void Initialize(D3DClass* d3dClassRef); // Get all the required references
void Initialize(d_3d_class* d3dClassRef); // Get all the required references
Object* ConstructSkybox();
object* ConstructSkybox();
// Variables
@ -23,8 +23,8 @@ public:
private:
D3DClass* m_d3dClassRef; // Reference to the D3DClass instance
Object* m_Skybox;
d_3d_class* m_d3dClassRef; // Reference to the d_3d_class instance
object* m_Skybox;
};

View File

@ -0,0 +1,331 @@
#ifndef _APPLICATIONCLASS_H_
#define _APPLICATIONCLASS_H_
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "d_3d_class.h"
#include "camera_class.h"
#include "object.h"
#include "light_class.h"
#include <vector>
#include <filesystem>
#include "bitmap_class.h"
#include "sprite_class.h"
#include "timer_class.h"
#include "font_shader_class.h"
#include "font_class.h"
#include "text_class.h"
#include "fps_class.h"
#include "input_class.h"
#include "shader_manager_class.h"
#include "modellistclass.h"
#include "position_class.h"
#include "frustumclass.h"
#include "render_texture_class.h"
#include "display_plane_class.h"
#include "translate_shader_class.h"
#include "reflection_shader_class.h"
#include "physics.h"
#include "frustum.h"
#include "skybox.h"
#include <fstream>
#include <WICTextureLoader.h>
#include <comdef.h> // Pour _com_error
#include <chrono>
#include <thread>
#include <map>
#include <algorithm>
#include <DirectXMath.h>
#include <mutex>
#include "shadow_map.h"
/////////////
// GLOBALS //
/////////////
constexpr bool full_screen = false;
constexpr float screen_depth = 1000.0f;
constexpr float screen_near = 0.3f;
struct input
{
bool key_left = false;
bool key_right = false;
bool key_up = false;
bool key_down = false;
};
////////////////////////////////////////////////////////////////////////////////
// Class name: application_class
////////////////////////////////////////////////////////////////////////////////
class application_class
{
public:
application_class();
~application_class();
d_3d_class* get_direct_3d();
render_texture_class* get_scene_texture() const { return scene_texture_; };
render_texture_class* get_render_texture() const { return render_texture_; };
render_texture_class* get_refraction_texture() const { return refraction_texture_; };
render_texture_class* get_reflection_texture() const { return reflection_texture_; };
int get_total_vertex_count() const;
int get_total_triangle_count() const;
int get_visible_triangle_count() const;
void create_big_cube(int side_count);
void process_terrain_generation();
bool initialize(int, int, HWND, bool is_vulkan);
void shutdown();
bool frame(input_class*);
void physics_thread_function();
int get_physics_tick_rate() const { return physics_tick_rate_; };
void set_physics_tick_rate(int physics_tick_rate) { physics_tick_rate_ = physics_tick_rate; };
int get_screen_width() const;
void set_screen_width(int screen_width);
int get_screen_height() const;
void set_screen_height(int screen_height);
float get_speed() const { return speed_; };
void set_speed(const float speed) { this->speed_ = speed; };
void add_cube();
void delete_kobject(int index);
size_t get_cube_count() const { return cubes_.size(); };
size_t get_terrain_cube_count() const { return terrain_chunk_.size(); };
std::vector<object*> get_cubes() const { return cubes_; };
std::vector<object*> get_terrain_cubes() const { return terrain_chunk_; };
std::vector<object*> get_kobjects() const { return object_; };
void add_kobject(std::wstring& filepath);
void set_path(WCHAR* path) { path_ = path; };
void set_w_folder(const std::filesystem::path& w_folder) { w_folder_ = w_folder; };
void generate_terrain();
void delete_terrain();
XMVECTOR get_light_position(int index);
XMVECTOR get_light_color(int index);
void set_light_position(int index, XMVECTOR position);
void set_light_color(int index, XMVECTOR color);
std::vector<light_class*> get_lights() const { return lights_; };
light_class* get_sun_light() const { return sun_light_; };
bool get_should_quit() const { return should_quit_; };
void set_should_quit(const bool should_quit) { should_quit_ = should_quit; };
void set_cel_shading(const bool enable) { enable_cel_shading_ = enable; };
void set_vsync(bool vsync);
bool get_vsync() const { return vsync_enabled_; };
HWND get_hwnd() const;
void set_hwnd(HWND hwnd);
bool is_windowed() const;
void set_windowed(bool windowed);
void set_window_size(const ImVec2 size) { window_size_ = size; };
ImVec2 get_window_size() const { return window_size_; };
float get_aspect_ratio() const { return static_cast<float>(screen_width_) / static_cast<float>(screen_height_); };
physics* get_physics() const { return physics_; };
// ------------------------------------- //
// --------------- Stats --------------- //
// ------------------------------------- //
int get_current_fps() const;
int get_min_fps() const;
int get_max_fps() const;
float get_frame_time() const;
int get_draw_calls() const;
void reset_fps_stats();
void increment_draw_call_count();
void reset_draw_call_count();
// ----------------------------------- //
// ------------- Culling ------------- //
// ----------------------------------- //
frustum get_frustum() const { return frustum_culling_; };
void set_frustum(const frustum& frustum) { frustum_culling_ = frustum; };
void construct_frustum();
int get_render_count() const { return render_count_; };
void set_render_count(const int render_count) { render_count_ = render_count; };
float get_frustum_tolerance() const { return frustum_culling_tolerance_; };
void set_frustum_tolerance(const float frustum_tolerance) { frustum_culling_tolerance_ = frustum_tolerance; };
bool get_can_fixed_update() const { return can_fixed_update_; };
void set_can_fixed_update(bool can_fixed_update) { can_fixed_update_ = can_fixed_update; };
ID3D11ShaderResourceView* get_back_buffer_srv() const {return back_buffer_srv_;};
// Save and load scene
void save_scene();
bool load_scene();
void set_scene_path(const std::string& path) { scene_path_ = path; };
std::wstring get_scene_path();
std::string convert_w_string_to_string(const std::wstring& w_str);
private:
bool render(float, float, float, float, float);
bool render_physics(bool key_left, bool key_right, bool key_up, bool key_down, float delta_time);
bool update_mouse_strings(int, int, bool);
bool update_fps();
bool update_render_count_string(int);
bool render_scene_to_texture(float);
bool render_refraction_to_texture();
bool render_reflection_to_texture();
bool render_pass(const std::vector<std::reference_wrapper<std::vector<object*>>>& RenderQueues, XMFLOAT4* diffuse, XMFLOAT4* position, XMFLOAT4* ambient, XMMATRIX view, XMMATRIX projection);
void update_skybox_position();
public :
std::vector<ID3D11ShaderResourceView*> textures;
private :
// Thread de culling
std::thread culling_thread_;
std::atomic<bool> culling_active_;
std::mutex objects_mutex_;
void culling_thread_function();
std::mutex terrain_mutex_;
std::vector<std::tuple<float, float, float, std::string, int>> terrain_generation_data_;
bool terrain_generation_ready_;
int next_terrain_object_id_;
// ------------------------------------- //
// ------------- DIRECT3D -------------- //
// ------------------------------------- //
d_3d_class* direct_3d_;
IDXGISwapChain* swap_chain_;
model_class* model_,* ground_model_, * wall_model_, * bath_model_, * water_model_;
ModelListClass* model_list_;
bool vsync_enabled_ = true;
HWND hwnd_;
bool windowed_;
std::string scene_path_;
// ------------------------------------- //
// ------------- RENDERING ------------- //
// ------------------------------------- //
XMMATRIX base_view_matrix_;
render_texture_class* render_texture_, * refraction_texture_, * reflection_texture_;
render_texture_class* scene_texture_;
display_plane_class* display_plane_;
int screen_width_, screen_height_;
camera_class* camera_;
camera_class* sun_camera_;
camera_class* active_camera_;
position_class* position_;
int drawcalls_;
shadow_map* shadow_map_;
ID3D11ShaderResourceView* shadow_map_srv_;
// ------------------------------------ //
// ------------- OBJECTS -------------- //
// ------------------------------------ //
object* selected_object_;
std::vector<object*> cubes_;
std::vector<object*> terrain_chunk_;
float speed_ = 0.1f; // speed for the demo spinning object
std::vector<object*> object_;
std::vector<object*> imported_object_;
int object_id_ = 0;
std::vector<std::reference_wrapper<std::vector<object*>>> render_queues_;
std::vector<object*> skybox_;
// ----------------------------------- //
// ------------- LIGHTS -------------- //
// ----------------------------------- //
light_class* m_light_;
std::vector<light_class*> lights_;
int num_lights_;
light_class* sun_light_;
XMFLOAT3 true_light_position_;
model_class* light_model_;
// ----------------------------------- //
// ------------- SHADERS ------------- //
// ----------------------------------- //
shader_manager_class* shader_manager_;
font_shader_class* font_shader_;
bitmap_class* bitmap_;
sprite_class* sprite_;
bool enable_cel_shading_;
// ----------------------------------- //
// ------------ VARIABLES ------------ //
// ----------------------------------- //
float water_height_, water_translation_;
wchar_t* path_;
std::filesystem::path w_folder_;
// ------------------------------------------------- //
// ------------- FPS AND INFO ON SCREEN ------------ //
// ------------------------------------------------- //
timer_class* timer_;
text_class* mouse_strings_;
text_class* render_count_string_;
font_class* font_;
fps_class* fps_;
text_class* fps_string_;
int previous_fps_;
// ------------------------------------------------- //
// ------------------- OTHER ----------------------- //
// ------------------------------------------------- //
bool should_quit_;
physics* physics_;
float gravity_;
XMVECTOR previous_position_;
ImVec2 window_size_;
int physics_tick_rate_ = 50;
bool can_fixed_update_ = false;
std::thread physics_thread_;
ID3D11Texture2D* back_buffer_texture_;
ID3D11ShaderResourceView* back_buffer_srv_;
// ------------------------------------------------- //
// ------------------- Culling --------------------- //
// ------------------------------------------------- //
frustum frustum_culling_;
int render_count_;
float frustum_culling_tolerance_ = 5.f;
// ------------------------------------------------- //
// -------------------- Input ---------------------- //
// ------------------------------------------------- //
input inputs_;
bool tab_was_pressed_;
};
#endif

View File

@ -1,327 +0,0 @@
#ifndef _APPLICATIONCLASS_H_
#define _APPLICATIONCLASS_H_
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "d3dclass.h"
#include "cameraclass.h"
#include "object.h"
#include "lightclass.h"
#include <vector>
#include <filesystem>
#include "bitmapclass.h"
#include "spriteclass.h"
#include "timerclass.h"
#include "fontshaderclass.h"
#include "fontclass.h"
#include "textclass.h"
#include "fpsclass.h"
#include "inputclass.h"
#include "shadermanagerclass.h"
#include "modellistclass.h"
#include "positionclass.h"
#include "frustumclass.h"
#include "rendertextureclass.h"
#include "displayplaneclass.h"
#include "translateshaderclass.h"
#include "reflectionshaderclass.h"
#include "physics.h"
#include "frustum.h"
#include "skybox.h"
#include <fstream>
#include <WICTextureLoader.h>
#include <comdef.h> // Pour _com_error
#include <chrono>
#include <thread>
#include <map>
#include <algorithm>
#include <DirectXMath.h>
#include <mutex>
/////////////
// GLOBALS //
/////////////
const bool FULL_SCREEN = false;
const float SCREEN_DEPTH = 1000.0f;
const float SCREEN_NEAR = 0.3f;
struct Input
{
bool m_KeyLeft = false;
bool m_KeyRight = false;
bool m_KeyUp = false;
bool m_KeyDown = false;
};
////////////////////////////////////////////////////////////////////////////////
// Class name: ApplicationClass
////////////////////////////////////////////////////////////////////////////////
class ApplicationClass
{
public:
ApplicationClass();
~ApplicationClass();
D3DClass* GetDirect3D();
RenderTextureClass* GetSceneTexture() const { return m_SceneTexture; };
RenderTextureClass* GetRenderTexture() const { return m_RenderTexture; };
RenderTextureClass* GetRefractionTexture() const { return m_RefractionTexture; };
RenderTextureClass* GetReflectionTexture() const { return m_ReflectionTexture; };
int GetTotalVertexCount() const;
int GetTotalTriangleCount() const;
int GetVisibleTriangleCount() const;
void CreateBigCube(int sideCount);
void ProcessTerrainGeneration();
bool Initialize(int, int, HWND, bool IsVulkan);
void Shutdown();
bool Frame(InputClass*);
void PhysicsThreadFunction();
int GetPhysicsTickRate() const { return m_PhysicsTickRate; };
void SetPhysicsTickRate(int physicsTickRate) { m_PhysicsTickRate = physicsTickRate; };
int GetScreenWidth() const;
void SetScreenWidth(int screenWidth);
int GetScreenHeight() const;
void SetScreenHeight(int screenHeight);
float GetSpeed() const { return m_speed; };
void SetSpeed(float speed) { this->m_speed = speed; };
void AddCube();
void DeleteKobject(int index);
size_t GetCubeCount() const { return m_cubes.size(); };
size_t GetTerrainCubeCount() const { return m_terrainChunk.size(); };
std::vector<Object*> GetCubes() const { return m_cubes; };
std::vector<Object*> GetTerrainCubes() const { return m_terrainChunk; };
std::vector<Object*> GetKobjects() const { return m_object; };
void AddKobject(std::wstring& filepath);
void SetPath(WCHAR* path) { m_path = path; };
void SetWFolder(std::filesystem::path WFolder) { m_WFolder = WFolder; };
void GenerateTerrain();
void DeleteTerrain();
XMVECTOR GetLightPosition(int index);
XMVECTOR GetLightColor(int index);
void SetLightPosition(int index, XMVECTOR color);
void SetLightColor(int index, XMVECTOR color);
void DeleteLight(int index);
void AddLight();
std::vector<LightClass*> GetLights() const { return m_Lights; };
LightClass* GetSunLight() const { return m_SunLight; };
bool GetShouldQuit() const { return m_ShouldQuit; };
void SetShouldQuit(bool shouldQuit) { m_ShouldQuit = shouldQuit; };
void SetCelShading(bool enable) { m_enableCelShading = enable; };
void SetVsync(bool vsync);
bool GetVsync() const { return VSYNC_ENABLED; };
HWND GetHwnd() const;
void SetHwnd(HWND hwnd);
bool IsWindowed() const;
void SetWindowed(bool windowed);
void SetWindowSize(ImVec2 size) { windowSize = size; };
ImVec2 GetWindowSize() const { return windowSize; };
float GetAspectRatio() const { return (float)m_screenWidth / (float)m_screenHeight; };
Physics* GetPhysics() const { return m_Physics; };
// ------------------------------------- //
// --------------- Stats --------------- //
// ------------------------------------- //
int GetCurrentFps() const;
int GetMinFps() const;
int GetMaxFps() const;
float GetFrameTime() const;
int GetDrawCalls() const;
void ResetFpsStats();
void IncrementDrawCallCount();
void ResetDrawCallCount();
// ----------------------------------- //
// ------------- Culling ------------- //
// ----------------------------------- //
Frustum GetFrustum() const { return m_FrustumCulling; };
void SetFrustum(Frustum frustum) { m_FrustumCulling = frustum; };
void ConstructFrustum();
int GetRenderCount() const { return m_renderCount; };
void SetRenderCount(int renderCount) { m_renderCount = renderCount; };
float GetFrustumTolerance() const { return m_FrustumCullingTolerance; };
void SetFrustumTolerance(float frustumTolerance) { m_FrustumCullingTolerance = frustumTolerance; };
bool GetCanFixedUpdate() const { return CanFixedUpdate; };
void SetCanFixedUpdate(bool canFixedUpdate) { CanFixedUpdate = canFixedUpdate; };
ID3D11ShaderResourceView* GetBackBufferSRV() const {return m_BackBufferSRV;};
// Save and load scene
void SaveScene();
bool LoadScene();
void SetScenePath(std::string path) { m_scenePath = path; };
std::wstring GetScenePath();
std::string ConvertWStringToString(const std::wstring& wstr);
private:
bool Render(float, float, float, float, float);
bool RenderPhysics(bool keyLeft, bool keyRight, bool keyUp, bool keyDown, float deltaTime);
bool UpdateMouseStrings(int, int, bool);
bool UpdateFps();
bool UpdateRenderCountString(int);
bool RenderSceneToTexture(float);
bool RenderRefractionToTexture();
bool RenderReflectionToTexture();
bool RenderPass(const std::vector<std::reference_wrapper<std::vector<Object*>>>& RenderQueues, XMFLOAT4* diffuse, XMFLOAT4* position, XMFLOAT4* ambient, XMMATRIX view, XMMATRIX projection);
void UpdateSkyboxPosition();
public :
std::vector<ID3D11ShaderResourceView*> textures;
private :
// Thread de culling
std::thread m_CullingThread;
std::atomic<bool> m_CullingActive;
std::mutex m_ObjectsMutex;
void CullingThreadFunction();
std::mutex m_TerrainMutex;
std::vector<std::tuple<float, float, float, std::string, int>> m_TerrainGenerationData;
bool m_TerrainGenerationReady;
int m_NextTerrainObjectId;
// ------------------------------------- //
// ------------- DIRECT3D -------------- //
// ------------------------------------- //
D3DClass* m_Direct3D;
IDXGISwapChain* m_swapChain;
ModelClass* m_Model,* m_GroundModel, * m_WallModel, * m_BathModel, * m_WaterModel;
ModelListClass* m_ModelList;
bool VSYNC_ENABLED = true;
HWND m_hwnd;
bool m_windowed;
std::string m_scenePath;
// ------------------------------------- //
// ------------- RENDERING ------------- //
// ------------------------------------- //
XMMATRIX m_baseViewMatrix;
RenderTextureClass* m_RenderTexture, * m_RefractionTexture, * m_ReflectionTexture;
RenderTextureClass* m_SceneTexture;
DisplayPlaneClass* m_DisplayPlane;
int m_screenWidth, m_screenHeight;
CameraClass* m_Camera;
PositionClass* m_Position;
int m_drawcalls;
// ------------------------------------ //
// ------------- OBJECTS -------------- //
// ------------------------------------ //
Object* m_SelectedObject;
std::vector<Object*> m_cubes;
std::vector<Object*> m_terrainChunk;
float m_speed = 0.1f; // speed for the demo spinning object
std::vector<Object*> m_object;
std::vector<Object*> m_ImportedObject;
int m_ObjectId = 0;
std::vector<std::reference_wrapper<std::vector<Object*>>> m_RenderQueues;
std::vector<Object*> m_Skybox;
// ----------------------------------- //
// ------------- LIGHTS -------------- //
// ----------------------------------- //
LightClass* m_Light;
std::vector<LightClass*> m_Lights;
int m_numLights;
LightClass* m_SunLight;
XMFLOAT3 TrueLightPosition;
ModelClass* m_LightModel;
// ----------------------------------- //
// ------------- SHADERS ------------- //
// ----------------------------------- //
ShaderManagerClass* m_ShaderManager;
FontShaderClass* m_FontShader;
BitmapClass* m_Bitmap;
SpriteClass* m_Sprite;
bool m_enableCelShading;
// ----------------------------------- //
// ------------ VARIABLES ------------ //
// ----------------------------------- //
float m_waterHeight, m_waterTranslation;
wchar_t* m_path;
std::filesystem::path m_WFolder;
// ------------------------------------------------- //
// ------------- FPS AND INFO ON SCREEN ------------ //
// ------------------------------------------------- //
TimerClass* m_Timer;
TextClass* m_MouseStrings;
TextClass* m_RenderCountString;
FontClass* m_Font;
FpsClass* m_Fps;
TextClass* m_FpsString;
int m_previousFps;
// ------------------------------------------------- //
// ------------------- OTHER ----------------------- //
// ------------------------------------------------- //
bool m_ShouldQuit;
Physics* m_Physics;
float m_gravity;
XMVECTOR m_previousPosition;
ImVec2 windowSize;
int m_PhysicsTickRate = 50;
bool CanFixedUpdate = false;
std::thread m_PhysicsThread;
ID3D11Texture2D* m_BackBufferTexture;
ID3D11ShaderResourceView* m_BackBufferSRV;
// ------------------------------------------------- //
// ------------------- Culling --------------------- //
// ------------------------------------------------- //
Frustum m_FrustumCulling;
int m_renderCount;
float m_FrustumCullingTolerance = 5.f;
// ------------------------------------------------- //
// -------------------- Input ---------------------- //
// ------------------------------------------------- //
Input m_Inputs;
};
#endif

View File

@ -0,0 +1,59 @@
#ifndef _BITMAPCLASS_H_
#define _BITMAPCLASS_H_
//////////////
// INCLUDES //
//////////////
#include <directxmath.h>
using namespace DirectX;
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "texture_class.h"
////////////////////////////////////////////////////////////////////////////////
// Class name: bitmap_class
////////////////////////////////////////////////////////////////////////////////
class bitmap_class
{
private:
struct vertex_type
{
XMFLOAT3 position;
XMFLOAT2 texture;
};
public:
bitmap_class();
bitmap_class(const bitmap_class&);
~bitmap_class();
bool initialize(ID3D11Device*, ID3D11DeviceContext*, int, int, char*, int, int);
void shutdown();
bool render(ID3D11DeviceContext*);
int get_index_count();
ID3D11ShaderResourceView* get_texture();
void set_render_location(int, int);
private:
bool initialize_buffers(ID3D11Device*);
void shutdown_buffers();
bool update_buffers(ID3D11DeviceContext*);
void render_buffers(ID3D11DeviceContext*);
bool load_texture(ID3D11Device*, ID3D11DeviceContext*, char*);
void release_texture();
private:
ID3D11Buffer* vertex_buffer_, * index_buffer_;
int vertex_count_, index_count_, screen_width_, screen_height_, bitmap_width_, bitmap_height_, render_x_, render_y_, prev_pos_x_, prev_pos_y_;
texture_class* texture_;
};
#endif

View File

@ -1,59 +0,0 @@
#ifndef _BITMAPCLASS_H_
#define _BITMAPCLASS_H_
//////////////
// INCLUDES //
//////////////
#include <directxmath.h>
using namespace DirectX;
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "textureclass.h"
////////////////////////////////////////////////////////////////////////////////
// Class name: BitmapClass
////////////////////////////////////////////////////////////////////////////////
class BitmapClass
{
private:
struct VertexType
{
XMFLOAT3 position;
XMFLOAT2 texture;
};
public:
BitmapClass();
BitmapClass(const BitmapClass&);
~BitmapClass();
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, int, int, char*, int, int);
void Shutdown();
bool Render(ID3D11DeviceContext*);
int GetIndexCount();
ID3D11ShaderResourceView* GetTexture();
void SetRenderLocation(int, int);
private:
bool InitializeBuffers(ID3D11Device*);
void ShutdownBuffers();
bool UpdateBuffers(ID3D11DeviceContext*);
void RenderBuffers(ID3D11DeviceContext*);
bool LoadTexture(ID3D11Device*, ID3D11DeviceContext*, char*);
void ReleaseTexture();
private:
ID3D11Buffer* m_vertexBuffer, * m_indexBuffer;
int m_vertexCount, m_indexCount, m_screenWidth, m_screenHeight, m_bitmapWidth, m_bitmapHeight, m_renderX, m_renderY, m_prevPosX, m_prevPosY;
TextureClass* m_Texture;
};
#endif

View File

@ -0,0 +1,46 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: cameraclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _CAMERACLASS_H_
#define _CAMERACLASS_H_
//////////////
// INCLUDES //
//////////////
#include <directxmath.h>
using namespace DirectX;
////////////////////////////////////////////////////////////////////////////////
// Class name: camera_class
////////////////////////////////////////////////////////////////////////////////
class camera_class
{
public:
camera_class();
camera_class(const camera_class&);
~camera_class();
void set_position(float, float, float);
void set_rotation(float, float, float);
XMFLOAT3 get_position();
XMFLOAT3 get_rotation();
void render();
XMMATRIX get_view_matrix(XMMATRIX& view_matrix) const;
void render_reflection(float);
void get_reflection_view_matrix(XMMATRIX&) const;
private:
float position_x_, position_y_, position_z_;
float rotation_x_, rotation_y_, rotation_z_;
XMMATRIX view_matrix_;
XMMATRIX reflection_view_matrix_;
};
#endif

View File

@ -1,90 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: d3dclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _D3DCLASS_H_
#define _D3DCLASS_H_
/////////////
// LINKING //
/////////////
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "d3dcompiler.lib")
//////////////
// INCLUDES //
//////////////
#include "imguiManager.h"
#include "d3d11.h"
#include "fontshaderclass.h"
#include "fontclass.h"
#include "textclass.h"
using namespace DirectX;
////////////////////////////////////////////////////////////////////////////////
// Class name: D3DClass
////////////////////////////////////////////////////////////////////////////////
class D3DClass
{
public:
D3DClass();
D3DClass(const D3DClass&);
~D3DClass();
bool Initialize(int, int, bool, HWND, bool, float, float);
void Shutdown();
void BeginScene(float, float, float, float);
void EndScene();
ID3D11Device* GetDevice();
ID3D11DeviceContext* GetDeviceContext();
//XMMATRIX GetProjectionMatrix(XMMATRIX& projectionMatrix);
IDXGISwapChain* m_swapChain;
IDXGISwapChain* GetSwapChain();
void ResizeSwapChain(int, int);
void SetVsync(bool vsync);
XMMATRIX GetProjectionMatrix() const { return m_projectionMatrix; };
XMMATRIX GetWorldMatrix() const { return m_worldMatrix;};
XMMATRIX GetOrthoMatrix() const { return m_orthoMatrix; };
void GetVideoCardInfo(char*, int&);
void SetBackBufferRenderTarget();
void ResetViewport();
void ReleaseResources();
void ResetResources(int newWidth, int newHeight);
void TurnZBufferOn();
void TurnZBufferOff();
void EnableAlphaBlending();
void DisableAlphaBlending();
private:
bool m_vsync_enabled;
int m_videoCardMemory;
char m_videoCardDescription[128];
ID3D11Device* m_device;
ID3D11DeviceContext* m_deviceContext;
ID3D11RenderTargetView* m_renderTargetView;
ID3D11Texture2D* m_depthStencilBuffer;
ID3D11DepthStencilState* m_depthStencilState;
ID3D11DepthStencilView* m_depthStencilView;
ID3D11RasterizerState* m_rasterState;
XMMATRIX m_projectionMatrix;
XMMATRIX m_worldMatrix;
XMMATRIX m_orthoMatrix;
D3D11_VIEWPORT m_viewport;
ID3D11DepthStencilState* m_depthDisabledStencilState;
ID3D11BlendState* m_alphaEnableBlendingState;
ID3D11BlendState* m_alphaDisableBlendingState;
};
#endif

View File

@ -0,0 +1,90 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: d3dclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _D3DCLASS_H_
#define _D3DCLASS_H_
/////////////
// LINKING //
/////////////
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "d3dcompiler.lib")
//////////////
// INCLUDES //
//////////////
#include "imguiManager.h"
#include "d3d11.h"
#include "font_shader_class.h"
#include "font_class.h"
#include "text_class.h"
using namespace DirectX;
////////////////////////////////////////////////////////////////////////////////
// Class name: d_3d_class
////////////////////////////////////////////////////////////////////////////////
class d_3d_class
{
public:
d_3d_class();
d_3d_class(const d_3d_class&);
~d_3d_class();
bool initialize(int, int, bool, HWND, bool, float, float);
void shutdown();
void begin_scene(float, float, float, float);
void end_scene();
ID3D11Device* get_device();
ID3D11DeviceContext* get_device_context();
//XMMATRIX get_projection_matrix(XMMATRIX& projectionMatrix);
IDXGISwapChain* swap_chain;
IDXGISwapChain* get_swap_chain();
void resize_swap_chain(int, int);
void set_vsync(bool vsync);
XMMATRIX get_projection_matrix() const { return projection_matrix_; };
XMMATRIX get_world_matrix() const { return world_matrix_;};
XMMATRIX get_ortho_matrix() const { return ortho_matrix_; };
void get_video_card_info(char*, int&);
void set_back_buffer_render_target();
void reset_viewport();
void release_resources();
void reset_resources(int newWidth, int newHeight);
void turn_z_buffer_on();
void turn_z_buffer_off();
void enable_alpha_blending();
void disable_alpha_blending();
private:
bool vsync_enabled_;
int video_card_memory_;
char video_card_description_[128];
ID3D11Device* device_;
ID3D11DeviceContext* device_context_;
ID3D11RenderTargetView* render_target_view_;
ID3D11Texture2D* depth_stencil_buffer_;
ID3D11DepthStencilState* depth_stencil_state_;
ID3D11DepthStencilView* depth_stencil_view_;
ID3D11RasterizerState* raster_state_;
XMMATRIX projection_matrix_;
XMMATRIX world_matrix_;
XMMATRIX ortho_matrix_;
D3D11_VIEWPORT viewport_;
ID3D11DepthStencilState* depth_disabled_stencil_state_;
ID3D11BlendState* alpha_enable_blending_state_;
ID3D11BlendState* alpha_disable_blending_state_;
};
#endif

View File

@ -5,13 +5,13 @@
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "d3dclass.h"
#include "d_3d_class.h"
////////////////////////////////////////////////////////////////////////////////
// Class name: DisplayPlaneClass
// Class name: display_plane_class
////////////////////////////////////////////////////////////////////////////////
class DisplayPlaneClass
class display_plane_class
{
private:
struct VertexType
@ -21,9 +21,9 @@ private:
};
public:
DisplayPlaneClass();
DisplayPlaneClass(const DisplayPlaneClass&);
~DisplayPlaneClass();
display_plane_class();
display_plane_class(const display_plane_class&);
~display_plane_class();
bool Initialize(ID3D11Device*, float, float);
void Shutdown();

View File

@ -13,13 +13,13 @@ using namespace DirectX;
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "textureclass.h"
#include "texture_class.h"
////////////////////////////////////////////////////////////////////////////////
// Class name: FontClass
// Class name: font_class
////////////////////////////////////////////////////////////////////////////////
class FontClass
class font_class
{
private:
struct FontType
@ -35,9 +35,9 @@ private:
};
public:
FontClass();
FontClass(const FontClass&);
~FontClass();
font_class();
font_class(const font_class&);
~font_class();
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, int);
void Shutdown();
@ -56,7 +56,7 @@ private:
private:
FontType* m_Font;
TextureClass* m_Texture;
texture_class* m_Texture;
float m_fontHeight;
int m_spaceSize;
};

View File

@ -15,14 +15,14 @@
#include <mmsystem.h>
////////////////////////////////////////////////////////////////////////////////
// Class name: FpsClass
// Class name: fps_class
////////////////////////////////////////////////////////////////////////////////
class FpsClass
class fps_class
{
public:
FpsClass();
FpsClass(const FpsClass&);
~FpsClass();
fps_class();
fps_class(const fps_class&);
~fps_class();
void Initialize();
void Frame();

View File

@ -0,0 +1,22 @@
#pragma once
#include <chrono>
class fps_limiter {
public:
explicit fps_limiter(const float target_fps = 60.0f)
: min_delta_(1.0f / target_fps), last_time_(std::chrono::high_resolution_clock::now()) {}
// Retourne true si la fonction peut etre executee
bool should_run() {
const auto now = std::chrono::high_resolution_clock::now();
if (const float elapsed = std::chrono::duration<float>(now - last_time_).count(); elapsed >= min_delta_) {
last_time_ = now;
return true;
}
return false;
}
private:
float min_delta_;
std::chrono::high_resolution_clock::time_point last_time_;
};

View File

@ -1,7 +1,7 @@
#include <DirectXMath.h>
using namespace DirectX;
class Frustum
class frustum
{
public:
void ConstructFrustum(float screenDepth, XMMATRIX projectionMatrix, XMMATRIX viewMatrix);

View File

@ -4,15 +4,24 @@
#include "Logger.h"
#include "sceneManager.h"
#include "fps_limiter.h"
#include <imgui.h>
#include <imgui_impl_dx11.h>
#include <imgui_impl_win32.h>
#include <windows.h>
#include <deque>
#include "rendertextureclass.h"
#include <functional>
class ApplicationClass;
#include "render_texture_class.h"
class application_class;
struct widget_entry
{
bool* show;
std::function<void()> func;
};
class imguiManager
{
@ -22,29 +31,32 @@ public:
bool Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceContext* deviceContext);
void Shutdown();
void Render(ApplicationClass* app);
void Render();
void NewFrame();
void SetupDockspace(ApplicationClass* app);
void SetupDockspace();
// Widgets
void WidgetSpeedSlider(float* speed);
void WidgetButton();
void WidgetFPS();
void WidgetAddObject(ApplicationClass* app);
void WidgetAddObject();
void WidgetObjectWindow(ApplicationClass* app);
void WidgetTerrainWindow(ApplicationClass* app);
void WidgetLightWindow(ApplicationClass* app);
void WidgetEngineSettingsWindow(ApplicationClass* app);
void WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSize);
void WidgetLogWindow(ApplicationClass* app);
void WidgetRenderStats(ApplicationClass* app);
void WidgetObjectWindow();
void WidgetTerrainWindow();
void WidgetLightWindow();
void WidgetEngineSettingsWindow();
void WidgetRenderWindow(ImVec2 availableSize);
void WidgetLogWindow();
void WidgetRenderStats();
bool ImGuiWidgetRenderer(ApplicationClass* app);
bool ImGuiWidgetRenderer();
void SetWindowSize(ImVec2 size) { windowSize = size; }
ImVec2 GetWindowSize() const { return windowSize; }
// Getters
void SetApp(application_class* app) { app_ = app; }
// Shader toggles
bool m_EnableCelShading;
@ -59,6 +71,9 @@ private:
// ----------------- Variables ----------------- //
// --------------------------------------------- //
std::vector<widget_entry> widgets_;
application_class* app_;
bool showObjectWindow;
bool showTerrainWindow;
@ -68,6 +83,8 @@ private:
bool showLogWindow;
bool showStatsWindow;
int m_SideCount = 0;
static const int FRAME_HISTORY_COUNT = 3600; // 1min secondes à 60 FPS
float m_frameTimeHistory[FRAME_HISTORY_COUNT] = {};
int m_frameTimeHistoryIndex = 0;
@ -81,9 +98,12 @@ private:
ID3D11DeviceContext* m_deviceContext;
ImVec2 windowSize;
RenderTextureClass* m_renderTexture;
render_texture_class* m_renderTexture;
const std::deque<Logger::LogEntry>& logBuffer = Logger::Get().GetLogBuffer();
int current_fps_, min_fps_, max_fps_, draw_calls_, total_vertex_count_, total_triangle_count_, visible_triangle_count_;
float current_frame_time_, min_frame_time_, max_frame_time_ ;
};
#endif

View File

@ -19,14 +19,14 @@
#include <dinput.h>
////////////////////////////////////////////////////////////////////////////////
// Class name: InputClass
// Class name: input_class
////////////////////////////////////////////////////////////////////////////////
class InputClass
class input_class
{
public:
InputClass();
InputClass(const InputClass&);
~InputClass();
input_class();
input_class(const input_class&);
~input_class();
bool Initialize(HINSTANCE, HWND, int, int);
void Shutdown();
@ -50,10 +50,8 @@ public:
bool IsSPressed() const;
bool IsQPressed() const;
bool IsEPressed()const;
bool IsTildePressed() const;
bool IsTildeReleased() const;
bool IsKeyDown(unsigned int) const;
bool is_key_pressed(const unsigned int);
private:
bool m_keys[256];

View File

@ -14,14 +14,14 @@ using namespace DirectX;
////////////////////////////////////////////////////////////////////////////////
// Class name: LightClass
// Class name: light_class
////////////////////////////////////////////////////////////////////////////////
class LightClass
class light_class
{
public:
LightClass();
LightClass(const LightClass&);
~LightClass();
light_class();
light_class(const light_class&);
~light_class();
void SetAmbientColor(float, float, float, float);
void SetDiffuseColor(float, float, float, float);

View File

@ -20,7 +20,7 @@ using namespace std;
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "textureclass.h"
#include "texture_class.h"
enum class TextureType
{
@ -46,7 +46,7 @@ struct TextureContainer
std::vector<std::wstring> alphaPaths;
// Get the vector of textures based on the type
// Get the vector of textures_ based on the type
std::vector<ID3D11ShaderResourceView*>& Get(TextureType type) const {
switch (type) {
case TextureType::Diffuse: return const_cast<std::vector<ID3D11ShaderResourceView*>&>(diffuse);
@ -57,7 +57,7 @@ struct TextureContainer
}
}
// Get the vector of textures paths based on the type
// Get the vector of textures_ paths based on the type
std::vector<std::wstring> GetPaths(TextureType type) const {
switch (type)
{
@ -87,7 +87,7 @@ struct TextureContainer
return L"";
}
// Release all textures and textures paths
// Release all textures_ and textures_ paths
void ReleaseAll() {
ReleaseVector(diffuse);
@ -145,9 +145,9 @@ private:
}
};
////////////////////////////////////////////////////////////////////////////////
// Class name: ModelClass
// Class name: model_class
////////////////////////////////////////////////////////////////////////////////
class ModelClass
class model_class
{
protected:
@ -200,14 +200,15 @@ protected:
};
public:
ModelClass();
ModelClass(const ModelClass&);
~ModelClass();
model_class();
model_class(const model_class&) = delete;
model_class& operator=(const model_class&) = delete;
~model_class();
//bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*, std::vector<ID3D11ShaderResourceView*>);
//bool initialize(ID3D11Device*, ID3D11DeviceContext*, char*, std::vector<ID3D11ShaderResourceView*>);
// Nouvelle surcharge avec TextureContainer
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*, const TextureContainer&);
// Nouvelle méthode - initialisation sans textures
// Nouvelle méthode - initialisation sans textures_
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*);
void Shutdown();
void Render(ID3D11DeviceContext*);
@ -217,7 +218,7 @@ public:
// TEXTURE //
//ID3D11ShaderResourceView* GetTexture(int index) const;
//ID3D11ShaderResourceView* get_texture(int index) const;
ID3D11ShaderResourceView* GetTexture(TextureType type, int index) const;
//bool ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, int index);
@ -231,7 +232,7 @@ public:
TextureContainer GetTextureContainer() const { return m_Textures; }
bool PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, TextureContainer& textureContainer);
protected:
int m_vertexCount, m_indexCount;
ID3D11Buffer* m_vertexBuffer, * m_indexBuffer;
@ -240,7 +241,6 @@ private:
bool InitializeBuffers(ID3D11Device*);
void ShutdownBuffers();
void RenderBuffers(ID3D11DeviceContext*);
bool LoadTextures(ID3D11Device*, ID3D11DeviceContext*, vector<string> filename);
void ReleaseTextures();
bool LoadModel(char*);

View File

@ -1,9 +1,9 @@
#pragma once
#include "modelclass.h"
#include "model_class.h"
#include <WICTextureLoader.h>
#include <SimpleMath.h>
#include "d3dclass.h"
#include "d_3d_class.h"
enum class ObjectType
{
@ -26,11 +26,14 @@ enum class ShaderType
ALPHA_MAPPING
};
class Object : public ModelClass
class object : public model_class
{
public:
Object();
~Object();
object();
~object();
object(const object&) = delete;
object& operator=(const object&) = delete;
void SetScaleMatrix(XMMATRIX scaleMatrix);
void SetRotateMatrix(XMMATRIX rotateMatrix);
@ -50,7 +53,6 @@ public:
XMVECTOR GetPosition();
XMVECTOR GetRotation();
void Render(ID3D11DeviceContext* deviceContext);
XMVECTOR GetScale();
void SetVelocity(XMVECTOR);
@ -101,7 +103,7 @@ public:
void LaunchObject();
bool LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, TextureContainer& texturesContainer,
D3DClass* m_Direct3D);
d_3d_class* m_Direct3D);
bool SetupInstancing(ID3D11Device* device, const std::vector<XMMATRIX>& instanceTransforms);
void EnableInstancing(bool enabled);
void SetInstanceCount(int count);
@ -148,10 +150,5 @@ private:
float m_alpha = 0.0f;
float m_initialStretch = 0.0f;
float m_springConstant = 10.0f;
bool m_instancingEnabled;
int m_instanceCount;
ID3D11Buffer* m_instanceBuffer;
std::vector<XMMATRIX> m_instanceTransforms;
};

View File

@ -4,21 +4,21 @@
#include "object.h"
#include "math.h"
class Physics : public Object
class physics : public object
{
public:
Physics();
explicit Physics(const Physics&); // Use explicit to avoid implicit conversion
~Physics();
physics();
explicit physics(const physics&); // Use explicit to avoid implicit conversion
~physics();
XMVECTOR GetGravity() const; // Get the gravity value
void SetGravity(XMVECTOR gravity); // Define the gravity value
void ApplyGravity(Object*, float); // Apply gravity to an object
void AddForce(Object*, XMVECTOR);
bool IsColliding(Object*, Object*);
bool CubesOverlap(Object*, Object*);
bool SpheresOverlap(Object*, Object*);
bool SphereCubeOverlap(Object*, Object*);
void ApplyGravity(object*, float); // Apply gravity to an object
void AddForce(object*, XMVECTOR);
bool IsColliding(object*, object*);
bool CubesOverlap(object*, object*);
bool SpheresOverlap(object*, object*);
bool SphereCubeOverlap(object*, object*);
private:
XMVECTOR m_gravity;

View File

@ -9,14 +9,14 @@
////////////////////////////////////////////////////////////////////////////////
// Class name: PositionClass
// Class name: position_class
////////////////////////////////////////////////////////////////////////////////
class PositionClass
class position_class
{
public:
PositionClass();
PositionClass(const PositionClass&);
~PositionClass();
position_class();
position_class(const position_class&);
~position_class();
void SetFrameTime(float);
void GetRotation(float&, float&) const;

View File

@ -15,14 +15,14 @@ using namespace DirectX;
////////////////////////////////////////////////////////////////////////////////
// Class name: RenderTextureClass
// Class name: render_texture_class
////////////////////////////////////////////////////////////////////////////////
class RenderTextureClass
class render_texture_class
{
public:
RenderTextureClass();
RenderTextureClass(const RenderTextureClass&);
~RenderTextureClass();
render_texture_class();
render_texture_class(const render_texture_class&);
~render_texture_class();
bool Initialize(ID3D11Device*, int, int, float, float, int);
void Shutdown();

View File

@ -0,0 +1,23 @@
#pragma once
#include <d3d11.h>
#include <directxmath.h>
class shadow_map {
public:
shadow_map();
~shadow_map();
bool initialize(ID3D11Device* device, int width, int height);
void shutdown();
void set_render_target(ID3D11DeviceContext* context);
void clear_render_target(ID3D11DeviceContext* context, float depth = 1.0f);
ID3D11ShaderResourceView* get_shader_resource_view();
private:
ID3D11Texture2D* depth_texture_;
ID3D11DepthStencilView* depth_stencil_view_;
ID3D11ShaderResourceView* shader_resource_view_;
int width_, height_;
};

View File

@ -13,13 +13,13 @@ using namespace DirectX;
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "textureclass.h"
#include "texture_class.h"
////////////////////////////////////////////////////////////////////////////////
// Class name: SpriteClass
// Class name: sprite_class
////////////////////////////////////////////////////////////////////////////////
class SpriteClass
class sprite_class
{
private:
struct VertexType
@ -29,9 +29,9 @@ private:
};
public:
SpriteClass();
SpriteClass(const SpriteClass&);
~SpriteClass();
sprite_class();
sprite_class(const sprite_class&);
~sprite_class();
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, int, int, char*, int, int);
void Shutdown();
@ -55,7 +55,7 @@ private:
private:
ID3D11Buffer* m_vertexBuffer, * m_indexBuffer;
int m_vertexCount, m_indexCount, m_screenWidth, m_screenHeight, m_bitmapWidth, m_bitmapHeight, m_renderX, m_renderY, m_prevPosX, m_prevPosY;
TextureClass* m_Textures;
texture_class* m_Textures;
float m_frameTime, m_cycleTime;
int m_currentTexture, m_textureCount;
};

View File

@ -0,0 +1,72 @@
#ifndef _SYSTEMCLASS_H_
#define _SYSTEMCLASS_H_
#define WIN32_LEAN_AND_MEAN
static bool DEBUG_MODE = true;
#include "Logger.h"
#include "input_class.h"
#include "application_class.h"
#include "imguiManager.h"
#include <mutex>
#include <filesystem>
#include <commdlg.h>
#include "../resources.h"
#include <chrono>
class system_class
{
public:
system_class();
system_class(const system_class&);
~system_class();
bool initialize();
void shutdown();
void run();
LRESULT CALLBACK message_handler(HWND, UINT, WPARAM, LPARAM);
void send_path(wchar_t* path, std::filesystem::path w_folder);
protected:
bool frame();
void initialize_windows(int&, int&);
void shutdown_windows();
private:
LPCWSTR application_name_;
HINSTANCE hinstance_;
HWND hwnd_;
input_class* input_;
application_class* application_;
imguiManager* imgui_manager_;
int initial_window_width_;
int initial_window_height_;
bool is_direct_3d_initialized_;
bool is_resizing_ = false;
bool is_debug_key_pressed_ = false;
std::mutex render_mutex_;
};
/////////////////////////
// FUNCTION PROTOTYPES //
/////////////////////////
static LRESULT CALLBACK wnd_proc(HWND, UINT, WPARAM, LPARAM);
/////////////
// GLOBALS //
/////////////
static system_class* application_handle = 0;
#endif

View File

@ -1,73 +0,0 @@
#ifndef _SYSTEMCLASS_H_
#define _SYSTEMCLASS_H_
#define WIN32_LEAN_AND_MEAN
static bool DEBUG_MODE = true;
#include "Logger.h"
#include "inputclass.h"
#include "applicationclass.h"
#include "imguiManager.h"
#include <mutex>
#include <filesystem>
#include <commdlg.h>
#include "../resources.h"
#include <chrono>
class SystemClass
{
public:
SystemClass();
SystemClass(const SystemClass&);
~SystemClass();
bool Initialize();
void Shutdown();
void Run();
LRESULT CALLBACK MessageHandler(HWND, UINT, WPARAM, LPARAM);
void SendPath(wchar_t* path, std::filesystem::path WFolder);
void GetScenePath();
protected:
bool Frame();
void InitializeWindows(int&, int&);
void ShutdownWindows();
private:
LPCWSTR m_applicationName;
HINSTANCE m_hinstance;
HWND m_hwnd;
InputClass* m_Input;
ApplicationClass* m_Application;
imguiManager* m_imguiManager;
int m_initialWindowWidth;
int m_initialWindowHeight;
bool m_isDirect3DInitialized;
bool m_isResizing = false;
bool m_IsDebugKeyPressed = false;
std::mutex renderMutex;
};
/////////////////////////
// FUNCTION PROTOTYPES //
/////////////////////////
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
/////////////
// GLOBALS //
/////////////
static SystemClass* ApplicationHandle = 0;
#endif

View File

@ -5,11 +5,11 @@
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "fontclass.h"
#include "font_class.h"
////////////////////////////////////////////////////////////////////////////////
// Class name: TextClass
// Class name: text_class
////////////////////////////////////////////////////////////////////////////////
class TextClass
class text_class
{
private:
struct VertexType
@ -19,21 +19,21 @@ private:
};
public:
TextClass();
TextClass(const TextClass&);
~TextClass();
text_class();
text_class(const text_class&);
~text_class();
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, int, int, int, FontClass*, char*, int, int, float, float, float);
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, int, int, int, font_class*, char*, int, int, float, float, float);
void Shutdown();
void Render(ID3D11DeviceContext*);
int GetIndexCount();
bool UpdateText(ID3D11DeviceContext*, FontClass*, char*, int, int, float, float, float);
bool UpdateText(ID3D11DeviceContext*, font_class*, char*, int, int, float, float, float);
XMFLOAT4 GetPixelColor();
private:
bool InitializeBuffers(ID3D11Device*, ID3D11DeviceContext*, FontClass*, char*, int, int, float, float, float);
bool InitializeBuffers(ID3D11Device*, ID3D11DeviceContext*, font_class*, char*, int, int, float, float, float);
void ShutdownBuffers();
void RenderBuffers(ID3D11DeviceContext*);

View File

@ -11,9 +11,9 @@
////////////////////////////////////////////////////////////////////////////////
// Class name: TextureClass
// Class name: texture_class
////////////////////////////////////////////////////////////////////////////////
class TextureClass
class texture_class
{
private:
struct TargaHeader
@ -26,9 +26,9 @@ private:
};
public:
TextureClass();
TextureClass(const TextureClass&);
~TextureClass();
texture_class();
texture_class(const texture_class&);
~texture_class();
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, std::string);
void Shutdown();

View File

@ -10,14 +10,14 @@
////////////////////////////////////////////////////////////////////////////////
// Class name: TimerClass
// Class name: timer_class
////////////////////////////////////////////////////////////////////////////////
class TimerClass
class timer_class
{
public:
TimerClass();
TimerClass(const TimerClass&);
~TimerClass();
timer_class();
timer_class(const timer_class&);
~timer_class();
bool Initialize();
void Frame();

View File

@ -1,29 +1,29 @@
#include "alphamapshaderclass.h"
#include "alpha_map_shader_class.h"
AlphaMapShaderClass::AlphaMapShaderClass()
alpha_map_shader_class::alpha_map_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
}
AlphaMapShaderClass::AlphaMapShaderClass(const AlphaMapShaderClass& other)
alpha_map_shader_class::alpha_map_shader_class(const alpha_map_shader_class& other)
{
}
AlphaMapShaderClass::~AlphaMapShaderClass()
alpha_map_shader_class::~alpha_map_shader_class()
{
}
bool AlphaMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool alpha_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing AlphaMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Initializing alpha_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
wchar_t vsFilename[128];
@ -46,8 +46,8 @@ bool AlphaMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -58,23 +58,23 @@ bool AlphaMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
}
void AlphaMapShaderClass::Shutdown()
void alpha_map_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool AlphaMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool alpha_map_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, ID3D11ShaderResourceView* texture3)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3);
if (!result)
{
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -82,13 +82,13 @@ bool AlphaMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCo
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool alpha_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -102,7 +102,7 @@ bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
D3D11_SAMPLER_DESC samplerDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@ -115,7 +115,7 @@ bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@ -134,7 +134,7 @@ bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@ -146,7 +146,7 @@ bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -154,7 +154,7 @@ bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -191,7 +191,7 @@ bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -207,14 +207,14 @@ bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -237,7 +237,7 @@ bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Error creating sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -250,53 +250,53 @@ bool AlphaMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
}
void AlphaMapShaderClass::ShutdownShader()
void alpha_map_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
Logger::Get().Log("Releasing sampler state", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
Logger::Get().Log("Sampler state released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
Logger::Get().Log("Releasing constant buffer", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
Logger::Get().Log("Constant buffer released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
// Release the layout.
if (m_layout)
if (layout_)
{
Logger::Get().Log("Releasing layout", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
Logger::Get().Log("Layout released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
Logger::Get().Log("Releasing pixel shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
Logger::Get().Log("Pixel shader released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
Logger::Get().Log("Releasing vertex shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
Logger::Get().Log("Vertex shader released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
@ -306,7 +306,7 @@ void AlphaMapShaderClass::ShutdownShader()
}
void AlphaMapShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void alpha_map_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@ -342,12 +342,12 @@ void AlphaMapShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWN
}
bool AlphaMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool alpha_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, ID3D11ShaderResourceView* texture3)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
@ -357,7 +357,7 @@ bool AlphaMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -365,7 +365,7 @@ bool AlphaMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@ -373,13 +373,13 @@ bool AlphaMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resources in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture1);
@ -390,20 +390,20 @@ bool AlphaMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
}
void AlphaMapShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void alpha_map_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@ -1,34 +1,34 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: lightshaderclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "CelShadingShader.h"
#include "celshade_class.h"
CelshadeClass::CelshadeClass()
celshade_class::celshade_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_sampleState = 0;
m_matrixBuffer = 0;
m_cameraBuffer = 0;
m_sunlightBuffer = 0;
m_sunlightColorBuffer = 0;
m_sunlightPositionBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
sample_state_ = 0;
matrix_buffer_ = 0;
camera_buffer_ = 0;
sunlight_buffer_ = 0;
sunlight_color_buffer_ = 0;
sunlight_position_buffer_ = 0;
}
CelshadeClass::CelshadeClass(const CelshadeClass& other)
celshade_class::celshade_class(const celshade_class& other)
{
}
CelshadeClass::~CelshadeClass()
celshade_class::~celshade_class()
{
}
bool CelshadeClass::Initialize(ID3D11Device* device, HWND hwnd)
bool celshade_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -52,8 +52,8 @@ bool CelshadeClass::Initialize(ID3D11Device* device, HWND hwnd)
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Failed to initialize shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -66,22 +66,22 @@ bool CelshadeClass::Initialize(ID3D11Device* device, HWND hwnd)
}
void CelshadeClass::Shutdown()
void celshade_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool CelshadeClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
bool celshade_class::render(ID3D11DeviceContext* deviceContext, int index_count, XMMATRIX world_matrix, XMMATRIX view_matrix, XMMATRIX projection_matrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuse_color, XMFLOAT4 ambient_color, XMFLOAT3 sun_direction, float sunIntensity)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
result = set_shader_parameters(deviceContext, world_matrix, view_matrix, projection_matrix, texture, diffuse_color, ambient_color, sun_direction, sunIntensity);
if (!result)
{
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -89,13 +89,13 @@ bool CelshadeClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, X
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, index_count);
return true;
}
bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool celshade_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -109,7 +109,7 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
D3D11_BUFFER_DESC matrixBufferDesc;
D3D11_BUFFER_DESC sunlightBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@ -120,7 +120,7 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
{
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
else
{
@ -135,7 +135,7 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
{
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
else
{
@ -145,7 +145,7 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -153,7 +153,7 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -189,7 +189,7 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
numElements = sizeof(polygonLayout) / sizeof(polygonLayout[0]);
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &m_layout);
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -219,7 +219,7 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -228,14 +228,14 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -244,14 +244,14 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
// Setup the description of the dynamic sunlight constant buffer that is in the pixel shader.
sunlightBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
sunlightBufferDesc.ByteWidth = sizeof(SunLightBufferType);
sunlightBufferDesc.ByteWidth = sizeof(sun_light_buffer_type);
sunlightBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
sunlightBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
sunlightBufferDesc.MiscFlags = 0;
sunlightBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the pixel shader constant buffer from within this class.
result = device->CreateBuffer(&sunlightBufferDesc, NULL, &m_sunlightBuffer);
result = device->CreateBuffer(&sunlightBufferDesc, NULL, &sunlight_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create sunlight buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -266,70 +266,70 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
void CelshadeClass::ShutdownShader()
void celshade_class::shutdown_shader()
{
Logger::Get().Log("Shutting down SunLightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the light constant buffers.
if (m_sunlightColorBuffer)
if (sunlight_color_buffer_)
{
m_sunlightColorBuffer->Release();
m_sunlightColorBuffer = 0;
sunlight_color_buffer_->Release();
sunlight_color_buffer_ = 0;
}
if (m_sunlightPositionBuffer)
if (sunlight_position_buffer_)
{
m_sunlightPositionBuffer->Release();
m_sunlightPositionBuffer = 0;
sunlight_position_buffer_->Release();
sunlight_position_buffer_ = 0;
}
// Release the light constant buffer.
if (m_sunlightBuffer)
if (sunlight_buffer_)
{
m_sunlightBuffer->Release();
m_sunlightBuffer = 0;
sunlight_buffer_->Release();
sunlight_buffer_ = 0;
}
// Release the camera constant buffer.
if (m_cameraBuffer)
if (camera_buffer_)
{
m_cameraBuffer->Release();
m_cameraBuffer = 0;
camera_buffer_->Release();
camera_buffer_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("SunLightShaderClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@ -338,7 +338,7 @@ void CelshadeClass::ShutdownShader()
}
void CelshadeClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void celshade_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned __int64 bufferSize, i;
@ -374,98 +374,98 @@ void CelshadeClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd
}
bool CelshadeClass::SetShaderParameters(
ID3D11DeviceContext* deviceContext,
XMMATRIX worldMatrix,
XMMATRIX viewMatrix,
XMMATRIX projectionMatrix,
bool celshade_class::set_shader_parameters(
ID3D11DeviceContext* device_context,
XMMATRIX world_matrix,
XMMATRIX view_matrix,
XMMATRIX projection_matrix,
ID3D11ShaderResourceView* texture,
XMFLOAT4 ambientColor,
XMFLOAT4 diffuseColor,
XMFLOAT3 lightDirection,
float sunIntensity
XMFLOAT4 ambient_color,
XMFLOAT4 diffuse_color,
XMFLOAT3 light_direction,
float sun_intensity
)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
CameraBufferType* dataPtr2;
SunLightBufferType* dataPtr3;
matrix_buffer_type* dataPtr;
camera_buffer_type* dataPtr2;
sun_light_buffer_type* dataPtr3;
unsigned int bufferNumber;
// Transpose the matrices to prepare them for the shader.
worldMatrix = XMMatrixTranspose(worldMatrix);
viewMatrix = XMMatrixTranspose(viewMatrix);
projectionMatrix = XMMatrixTranspose(projectionMatrix);
world_matrix = XMMatrixTranspose(world_matrix);
view_matrix = XMMatrixTranspose(view_matrix);
projection_matrix = XMMatrixTranspose(projection_matrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = device_context->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
dataPtr->view = viewMatrix;
dataPtr->projection = projectionMatrix;
dataPtr->world = world_matrix;
dataPtr->view = view_matrix;
dataPtr->projection = projection_matrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
device_context->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
device_context->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Lock the sunlight constant buffer so it can be written to.
result = deviceContext->Map(m_sunlightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = device_context->Map(sunlight_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr3 = (SunLightBufferType*)mappedResource.pData;
dataPtr3 = (sun_light_buffer_type*)mappedResource.pData;
// Copy the lighting variables into the constant buffer.
dataPtr3->ambientColor = ambientColor;
dataPtr3->diffuseColor = diffuseColor;
dataPtr3->sunDirection = lightDirection;
dataPtr3->intensity = sunIntensity;
dataPtr3->ambient_color = ambient_color;
dataPtr3->diffuse_color = diffuse_color;
dataPtr3->sun_direction = light_direction;
dataPtr3->intensity = sun_intensity;
// Unlock the constant buffer.
deviceContext->Unmap(m_sunlightBuffer, 0);
device_context->Unmap(sunlight_buffer_, 0);
// Set the position of the sunlight constant buffer in the pixel shader.
bufferNumber = 0;
// Finally set the sunlight constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_sunlightBuffer);
device_context->PSSetConstantBuffers(bufferNumber, 1, &sunlight_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
device_context->PSSetShaderResources(0, 1, &texture);
return true;
}
void CelshadeClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void celshade_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@ -1,29 +1,29 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: colorshaderclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "colorshaderclass.h"
#include "color_shader_class.h"
ColorShaderClass::ColorShaderClass()
color_shader_class::color_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
}
ColorShaderClass::ColorShaderClass(const ColorShaderClass& other)
color_shader_class::color_shader_class(const color_shader_class& other)
{
}
ColorShaderClass::~ColorShaderClass()
color_shader_class::~color_shader_class()
{
}
bool ColorShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool color_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing ColorShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Initializing color_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
wchar_t vsFilename[128];
@ -47,35 +47,35 @@ bool ColorShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("ColorShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("color_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void ColorShaderClass::Shutdown()
void color_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool ColorShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool color_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix);
if (!result)
{
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -83,12 +83,12 @@ bool ColorShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool color_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -101,7 +101,7 @@ bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
D3D11_BUFFER_DESC matrixBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@ -114,7 +114,7 @@ bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@ -133,7 +133,7 @@ bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@ -145,7 +145,7 @@ bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -153,7 +153,7 @@ bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -183,7 +183,7 @@ bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -199,14 +199,14 @@ bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -218,43 +218,43 @@ bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
return true;
}
void ColorShaderClass::ShutdownShader()
void color_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
Logger::Get().Log("Releasing matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
Logger::Get().Log("Matrix buffer released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
// Release the layout.
if (m_layout)
if (layout_)
{
Logger::Get().Log("Releasing layout", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
Logger::Get().Log("Layout released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
Logger::Get().Log("Releasing pixel shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
Logger::Get().Log("Pixel shader released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
Logger::Get().Log("Releasing vertex shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
Logger::Get().Log("Vertex shader released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
@ -263,7 +263,7 @@ void ColorShaderClass::ShutdownShader()
return;
}
void ColorShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void color_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@ -298,14 +298,14 @@ void ColorShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND h
return;
}
bool ColorShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool color_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix)
{
Logger::Get().Log("Setting shader parameters", __FILE__, __LINE__);
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
// Transpose the matrices to prepare them for the shader.
@ -314,7 +314,7 @@ bool ColorShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -322,7 +322,7 @@ bool ColorShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@ -330,27 +330,27 @@ bool ColorShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finanly set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
return true;
}
void ColorShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void color_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@ -0,0 +1,378 @@
#include "depth_shader_class.h"
depth_shader_class::depth_shader_class()
{
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
}
depth_shader_class::depth_shader_class(const depth_shader_class& other)
{
}
depth_shader_class::~depth_shader_class()
{
}
bool depth_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing texture shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
wchar_t vsFilename[128];
wchar_t psFilename[128];
int error;
// Set the filename of the vertex shader.
error = wcscpy_s(vsFilename, 128, L"src/hlsl/depth.vs");
if (error != 0)
{
Logger::Get().Log("Error copying stirng", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Set the filename of the pixel shader.
error = wcscpy_s(psFilename, 128, L"src/hlsl/depth.ps");
if (error != 0)
{
Logger::Get().Log("Error copying stirng", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("Texture shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void depth_shader_class::shutdown()
{
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool depth_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture);
if (!result)
{
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Now render the prepared buffers with the shader.
render_shader(deviceContext, indexCount);
return true;
}
bool depth_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
HRESULT result;
ID3D10Blob* errorMessage;
ID3D10Blob* vertexShaderBuffer;
ID3D10Blob* pixelShaderBuffer;
D3D11_INPUT_ELEMENT_DESC polygonLayout[2];
unsigned int numElements;
D3D11_BUFFER_DESC matrixBufferDesc;
D3D11_SAMPLER_DESC samplerDesc;
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
// Compile the vertex shader code.
result = D3DCompileFromFile(vsFilename, NULL, NULL, "DepthVertexShader", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0,
&vertexShaderBuffer, &errorMessage);
if (FAILED(result))
{
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
{
Logger::Get().Log("Error compiling shader", __FILE__, __LINE__, Logger::LogLevel::Error);
}
return false;
}
// Compile the pixel shader code.
result = D3DCompileFromFile(psFilename, NULL, NULL, "DepthPixelShader", "ps_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0,
&pixelShaderBuffer, &errorMessage);
if (FAILED(result))
{
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
{
Logger::Get().Log("Error compiling shader", __FILE__, __LINE__, Logger::LogLevel::Error);
}
return false;
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create the vertex input layout description.
// This setup needs to match the VertexType stucture in the ModelClass and in the shader.
polygonLayout[0].SemanticName = "POSITION";
polygonLayout[0].SemanticIndex = 0;
polygonLayout[0].Format = DXGI_FORMAT_R32G32B32_FLOAT;
polygonLayout[0].InputSlot = 0;
polygonLayout[0].AlignedByteOffset = 0;
polygonLayout[0].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
polygonLayout[0].InstanceDataStepRate = 0;
polygonLayout[1].SemanticName = "TEXCOORD";
polygonLayout[1].SemanticIndex = 0;
polygonLayout[1].Format = DXGI_FORMAT_R32G32_FLOAT;
polygonLayout[1].InputSlot = 0;
polygonLayout[1].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
polygonLayout[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
polygonLayout[1].InstanceDataStepRate = 0;
// Get a count of the elements in the layout.
numElements = sizeof(polygonLayout) / sizeof(polygonLayout[0]);
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
vertexShaderBuffer->Release();
vertexShaderBuffer = 0;
pixelShaderBuffer->Release();
pixelShaderBuffer = 0;
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create a texture sampler state description.
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.MipLODBias = 0.0f;
samplerDesc.MaxAnisotropy = 1;
samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
samplerDesc.BorderColor[0] = 0;
samplerDesc.BorderColor[1] = 0;
samplerDesc.BorderColor[2] = 0;
samplerDesc.BorderColor[3] = 0;
samplerDesc.MinLOD = 0;
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Error creating sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("Shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void depth_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the sampler state.
if (sample_state_)
{
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (matrix_buffer_)
{
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (layout_)
{
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (pixel_shader_)
{
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (vertex_shader_)
{
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("Shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
return;
}
void depth_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
ofstream fout;
// Get a pointer to the error message text buffer.
compileErrors = (char*)(errorMessage->GetBufferPointer());
// Get the length of the message.
bufferSize = errorMessage->GetBufferSize();
// Open a file to write the error message to.
fout.open("shader-error.txt");
// Write out the error message.
for (i = 0; i < bufferSize; i++)
{
fout << compileErrors[i];
}
// Close the file.
fout.close();
// Release the error message.
errorMessage->Release();
errorMessage = 0;
// Pop a message up on the screen to notify the user to check the text file for compile errors.
MessageBox(hwnd, L"Error compiling shader. Check shader-error.txt for message.", shaderFilename, MB_OK);
return;
}
bool depth_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
// Transpose the matrices to prepare them for the shader.
worldMatrix = XMMatrixTranspose(worldMatrix);
viewMatrix = XMMatrixTranspose(viewMatrix);
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
dataPtr->view = viewMatrix;
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finanly set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
return true;
}
void depth_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;
}

View File

@ -1,30 +1,30 @@
#include "fontshaderclass.h"
#include "font_shader_class.h"
FontShaderClass::FontShaderClass()
font_shader_class::font_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
m_pixelBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
pixel_buffer_ = 0;
}
FontShaderClass::FontShaderClass(const FontShaderClass& other)
font_shader_class::font_shader_class(const font_shader_class& other)
{
}
FontShaderClass::~FontShaderClass()
font_shader_class::~font_shader_class()
{
}
bool FontShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool font_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing FontShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Initializing font_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
wchar_t vsFilename[128];
@ -47,35 +47,35 @@ bool FontShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("FontShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("font_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void FontShaderClass::Shutdown()
void font_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool FontShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool font_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 pixelColor)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, pixelColor);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, pixelColor);
if (!result)
{
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -83,12 +83,12 @@ bool FontShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount,
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool font_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -103,7 +103,7 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
D3D11_BUFFER_DESC pixelBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@ -116,7 +116,7 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@ -135,7 +135,7 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@ -147,7 +147,7 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -155,7 +155,7 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -185,7 +185,7 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -201,14 +201,14 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -231,7 +231,7 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Error creating sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -240,14 +240,14 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
// Setup the description of the dynamic pixel constant buffer that is in the pixel shader.
pixelBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
pixelBufferDesc.ByteWidth = sizeof(PixelBufferType);
pixelBufferDesc.ByteWidth = sizeof(pixel_buffer_type);
pixelBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
pixelBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
pixelBufferDesc.MiscFlags = 0;
pixelBufferDesc.StructureByteStride = 0;
// Create the pixel constant buffer pointer so we can access the pixel shader constant buffer from within this class.
result = device->CreateBuffer(&pixelBufferDesc, NULL, &m_pixelBuffer);
result = device->CreateBuffer(&pixelBufferDesc, NULL, &pixel_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -259,50 +259,50 @@ bool FontShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* v
return true;
}
void FontShaderClass::ShutdownShader()
void font_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the pixel constant buffer.
if (m_pixelBuffer)
if (pixel_buffer_)
{
m_pixelBuffer->Release();
m_pixelBuffer = 0;
pixel_buffer_->Release();
pixel_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("Shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@ -310,7 +310,7 @@ void FontShaderClass::ShutdownShader()
return;
}
void FontShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void font_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@ -345,15 +345,15 @@ void FontShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hw
return;
}
bool FontShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool font_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 pixelColor)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
PixelBufferType* dataPtr2;
pixel_buffer_type* dataPtr2;
// Transpose the matrices to prepare them for the shader.
@ -362,7 +362,7 @@ bool FontShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XM
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -370,7 +370,7 @@ bool FontShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XM
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@ -378,19 +378,19 @@ bool FontShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XM
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
// Lock the pixel constant buffer so it can be written to.
result = deviceContext->Map(m_pixelBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(pixel_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -398,36 +398,36 @@ bool FontShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XM
}
// Get a pointer to the data in the pixel constant buffer.
dataPtr2 = (PixelBufferType*)mappedResource.pData;
dataPtr2 = (pixel_buffer_type*)mappedResource.pData;
// Copy the pixel color into the pixel constant buffer.
dataPtr2->pixelColor = pixelColor;
// Unlock the pixel constant buffer.
deviceContext->Unmap(m_pixelBuffer, 0);
deviceContext->Unmap(pixel_buffer_, 0);
// Set the position of the pixel constant buffer in the pixel shader.
bufferNumber = 0;
// Now set the pixel constant buffer in the pixel shader with the updated value.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_pixelBuffer);
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &pixel_buffer_);
return true;
}
void FontShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void font_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@ -1,29 +1,29 @@
#include "lightmapshaderclass.h"
#include "light_map_shader_class.h"
LightMapShaderClass::LightMapShaderClass()
light_map_shader_class::light_map_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
}
LightMapShaderClass::LightMapShaderClass(const LightMapShaderClass& other)
light_map_shader_class::light_map_shader_class(const light_map_shader_class& other)
{
}
LightMapShaderClass::~LightMapShaderClass()
light_map_shader_class::~light_map_shader_class()
{
}
bool LightMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool light_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing LightMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Initializing light_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
wchar_t vsFilename[128];
@ -46,37 +46,37 @@ bool LightMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("LightMapShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("light_map_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void LightMapShaderClass::Shutdown()
void light_map_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool LightMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool light_map_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
if (!result)
{
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -84,13 +84,13 @@ bool LightMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCo
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool light_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
HRESULT result;
@ -103,7 +103,7 @@ bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
D3D11_SAMPLER_DESC samplerDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@ -116,7 +116,7 @@ bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@ -135,7 +135,7 @@ bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@ -147,7 +147,7 @@ bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -155,7 +155,7 @@ bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -192,7 +192,7 @@ bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -208,14 +208,14 @@ bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -238,7 +238,7 @@ bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Error creating sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -251,52 +251,52 @@ bool LightMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
}
void LightMapShaderClass::ShutdownShader()
void light_map_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down LightMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
Logger::Get().Log("Shutting down light_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("LightMapShaderClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
Logger::Get().Log("light_map_shader_class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
return;
}
void LightMapShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void light_map_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@ -332,12 +332,12 @@ void LightMapShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWN
}
bool LightMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool light_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
@ -347,7 +347,7 @@ bool LightMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -355,7 +355,7 @@ bool LightMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@ -363,13 +363,13 @@ bool LightMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resources in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture1);
@ -379,19 +379,19 @@ bool LightMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
}
void LightMapShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void light_map_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@ -1,36 +1,36 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: lightshaderclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "lightshaderclass.h"
#include "light_shader_class.h"
LightShaderClass::LightShaderClass()
light_shader_class::light_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_sampleState = 0;
m_matrixBuffer = 0;
m_cameraBuffer = 0;
m_lightBuffer = 0;
m_lightColorBuffer = 0;
m_lightPositionBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
sample_state_ = 0;
matrix_buffer_ = 0;
camera_buffer_ = 0;
light_buffer_ = 0;
light_color_buffer_ = 0;
light_position_buffer_ = 0;
}
LightShaderClass::LightShaderClass(const LightShaderClass& other)
light_shader_class::light_shader_class(const light_shader_class& other)
{
}
LightShaderClass::~LightShaderClass()
light_shader_class::~light_shader_class()
{
}
bool LightShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool light_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Initializing light_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
wchar_t vsFilename[128];
wchar_t psFilename[128];
@ -52,36 +52,36 @@ bool LightShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Failed to initialize shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("LightShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("light_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void LightShaderClass::Shutdown()
void light_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool LightShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool light_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[], XMFLOAT4 ambientClor[])
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, lightPosition, ambientClor);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, lightPosition, ambientClor);
if(!result)
{
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -89,13 +89,13 @@ bool LightShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -112,7 +112,7 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
D3D11_BUFFER_DESC lightPositionBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@ -124,7 +124,7 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@ -142,7 +142,7 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@ -154,7 +154,7 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -162,7 +162,7 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -200,7 +200,7 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(),
&m_layout);
&layout_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -230,7 +230,7 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -239,14 +239,14 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -257,14 +257,14 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Setup the description of the camera dynamic constant buffer that is in the vertex shader.
cameraBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
cameraBufferDesc.ByteWidth = sizeof(CameraBufferType);
cameraBufferDesc.ByteWidth = sizeof(camera_buffer_type);
cameraBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
cameraBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
cameraBufferDesc.MiscFlags = 0;
cameraBufferDesc.StructureByteStride = 0;
// Create the camera constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&cameraBufferDesc, NULL, &m_cameraBuffer);
result = device->CreateBuffer(&cameraBufferDesc, NULL, &camera_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create camera buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -273,14 +273,14 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Setup the description of the dynamic constant buffer that is in the pixel shader.
lightColorBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
lightColorBufferDesc.ByteWidth = sizeof(LightColorBufferType);
lightColorBufferDesc.ByteWidth = sizeof(light_color_buffer_type);
lightColorBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
lightColorBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
lightColorBufferDesc.MiscFlags = 0;
lightColorBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the pixel shader constant buffer from within this class.
result = device->CreateBuffer(&lightColorBufferDesc, NULL, &m_lightColorBuffer);
result = device->CreateBuffer(&lightColorBufferDesc, NULL, &light_color_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create light color buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -289,14 +289,14 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Setup the description of the dynamic constant buffer that is in the vertex shader.
lightPositionBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
lightPositionBufferDesc.ByteWidth = sizeof(LightPositionBufferType);
lightPositionBufferDesc.ByteWidth = sizeof(light_position_buffer_type);
lightPositionBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
lightPositionBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
lightPositionBufferDesc.MiscFlags = 0;
lightPositionBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&lightPositionBufferDesc, NULL, &m_lightPositionBuffer);
result = device->CreateBuffer(&lightPositionBufferDesc, NULL, &light_position_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create light position buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -309,79 +309,79 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
}
void LightShaderClass::ShutdownShader()
void light_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
Logger::Get().Log("Shutting down light_shader_class", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the light constant buffers.
if (m_lightColorBuffer)
if (light_color_buffer_)
{
m_lightColorBuffer->Release();
m_lightColorBuffer = 0;
light_color_buffer_->Release();
light_color_buffer_ = 0;
}
if (m_lightPositionBuffer)
if (light_position_buffer_)
{
m_lightPositionBuffer->Release();
m_lightPositionBuffer = 0;
light_position_buffer_->Release();
light_position_buffer_ = 0;
}
// Release the light constant buffer.
if (m_lightBuffer)
if (light_buffer_)
{
m_lightBuffer->Release();
m_lightBuffer = 0;
light_buffer_->Release();
light_buffer_ = 0;
}
// Release the camera constant buffer.
if (m_cameraBuffer)
if (camera_buffer_)
{
m_cameraBuffer->Release();
m_cameraBuffer = 0;
camera_buffer_->Release();
camera_buffer_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("LightShaderClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
Logger::Get().Log("light_shader_class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
return;
}
void LightShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void light_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned __int64 bufferSize, i;
@ -417,15 +417,15 @@ void LightShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND h
}
bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool light_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[], XMFLOAT4 ambientColor[])
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
unsigned int bufferNumber;
MatrixBufferType* dataPtr;
LightPositionBufferType* dataPtr2;
LightColorBufferType* dataPtr3;
matrix_buffer_type* dataPtr;
light_position_buffer_type* dataPtr2;
light_color_buffer_type* dataPtr3;
// Transpose the matrices to prepare them for the shader.
worldMatrix = XMMatrixTranspose(worldMatrix);
@ -433,7 +433,7 @@ bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -441,7 +441,7 @@ bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@ -449,16 +449,16 @@ bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Now set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Lock the camera constant buffer so it can be written to.
result = deviceContext->Map(m_cameraBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(camera_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map camera buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -466,7 +466,7 @@ bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
}
// Lock the light position constant buffer so it can be written to.
result = deviceContext->Map(m_lightPositionBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(light_position_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map light position buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -474,28 +474,28 @@ bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
}
// Get a pointer to the data in the constant buffer.
dataPtr2 = (LightPositionBufferType*)mappedResource.pData;
dataPtr2 = (light_position_buffer_type*)mappedResource.pData;
// Copy the light position variables into the constant buffer.
for (int i = 0; i < NUM_LIGHTS; i++)
for (int i = 0; i < num_lights; i++)
{
dataPtr2->lightPosition[i] = lightPosition[i];
}
// Unlock the constant buffer.
deviceContext->Unmap(m_lightPositionBuffer, 0);
deviceContext->Unmap(light_position_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 1;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_lightPositionBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &light_position_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
// Lock the light color constant buffer so it can be written to.
result = deviceContext->Map(m_lightColorBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(light_color_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map light color buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -503,41 +503,41 @@ bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
}
// Get a pointer to the data in the constant buffer.
dataPtr3 = (LightColorBufferType*)mappedResource.pData;
dataPtr3 = (light_color_buffer_type*)mappedResource.pData;
// Copy the light color variables into the constant buffer.
for (int i = 0; i < NUM_LIGHTS; i++)
for (int i = 0; i < num_lights; i++)
{
dataPtr3->diffuseColor[i] = diffuseColor[i];
}
// Unlock the constant buffer.
deviceContext->Unmap(m_lightColorBuffer, 0);
deviceContext->Unmap(light_color_buffer_, 0);
// Set the position of the constant buffer in the pixel shader.
bufferNumber = 0;
// Finally set the constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_lightColorBuffer);
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &light_color_buffer_);
return true;
}
void LightShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void light_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@ -0,0 +1,24 @@
#include "master_shader.h"
#include "Logger.h"
master_shader::master_shader()
{
// Initialize shader filenames
wcscpy_s(vs_filename_, 128, vs_name_);
wcscpy_s(ps_filename_, 128, ps_name_);
}
master_shader::~master_shader()
{
// Destructor implementation
}
bool master_shader::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing master_shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool success = false;
return true;
}

View File

@ -1,32 +1,32 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: multitextureshaderclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "multitextureshaderclass.h"
#include "multi_texture_shader_class.h"
MultiTextureShaderClass::MultiTextureShaderClass()
multi_texture_shader_class::multi_texture_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
}
MultiTextureShaderClass::MultiTextureShaderClass(const MultiTextureShaderClass& other)
multi_texture_shader_class::multi_texture_shader_class(const multi_texture_shader_class& other)
{
}
MultiTextureShaderClass::~MultiTextureShaderClass()
multi_texture_shader_class::~multi_texture_shader_class()
{
}
bool MultiTextureShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool multi_texture_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing MultiTextureShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Initializing multi_texture_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
wchar_t vsFilename[128];
@ -49,35 +49,35 @@ bool MultiTextureShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Failed to initialize the vertex and pixel shaders", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("MultiTextureShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("multi_texture_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void MultiTextureShaderClass::Shutdown()
void multi_texture_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool MultiTextureShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool multi_texture_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
if (!result)
{
Logger::Get().Log("Failed to set the shader parameters that it will use for rendering", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -85,12 +85,12 @@ bool MultiTextureShaderClass::Render(ID3D11DeviceContext* deviceContext, int ind
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool multi_texture_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing the shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -104,7 +104,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
D3D11_SAMPLER_DESC samplerDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@ -117,7 +117,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@ -136,7 +136,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@ -148,7 +148,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the vertex shader from the buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -156,7 +156,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the pixel shader from the buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -193,7 +193,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the vertex input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -209,14 +209,14 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the constant buffer pointer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -239,7 +239,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the texture sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -251,43 +251,43 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
return true;
}
void MultiTextureShaderClass::ShutdownShader()
void multi_texture_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down the shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("Shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@ -295,7 +295,7 @@ void MultiTextureShaderClass::ShutdownShader()
return;
}
void MultiTextureShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void multi_texture_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@ -330,12 +330,12 @@ void MultiTextureShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage,
return;
}
bool MultiTextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool multi_texture_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
@ -345,7 +345,7 @@ bool MultiTextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceCon
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to lock the constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -353,7 +353,7 @@ bool MultiTextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceCon
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@ -361,13 +361,13 @@ bool MultiTextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceCon
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resources in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture1);
@ -376,19 +376,19 @@ bool MultiTextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceCon
return true;
}
void MultiTextureShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void multi_texture_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@ -1,28 +1,28 @@
#include "normalmapshaderclass.h"
#include "normal_map_shader_class.h"
NormalMapShaderClass::NormalMapShaderClass()
normal_map_shader_class::normal_map_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
m_lightBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
light_buffer_ = 0;
}
NormalMapShaderClass::NormalMapShaderClass(const NormalMapShaderClass& other)
normal_map_shader_class::normal_map_shader_class(const normal_map_shader_class& other)
{
}
NormalMapShaderClass::~NormalMapShaderClass()
normal_map_shader_class::~normal_map_shader_class()
{
}
bool NormalMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool normal_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing normal map shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -47,8 +47,8 @@ bool NormalMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Failed to initialize the vertex and pixel shaders", __FILE__, __LINE__);
@ -61,22 +61,22 @@ bool NormalMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
}
void NormalMapShaderClass::Shutdown()
void normal_map_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool NormalMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool normal_map_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, lightDirection, diffuseColor);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, lightDirection, diffuseColor);
if (!result)
{
Logger::Get().Log("Failed to set the shader parameters that will be used for rendering", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -84,13 +84,13 @@ bool NormalMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexC
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool normal_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing normal map shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -105,7 +105,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
D3D11_BUFFER_DESC lightBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@ -118,7 +118,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@ -137,7 +137,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@ -149,7 +149,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the vertex shader from the buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -157,7 +157,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the pixel shader from the buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -210,7 +210,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the vertex input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -226,14 +226,14 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the constant buffer pointer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -256,7 +256,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the texture sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -265,14 +265,14 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
// Setup the description of the light dynamic constant buffer that is in the pixel shader.
lightBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
lightBufferDesc.ByteWidth = sizeof(LightBufferType);
lightBufferDesc.ByteWidth = sizeof(light_buffer_type);
lightBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
lightBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
lightBufferDesc.MiscFlags = 0;
lightBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&lightBufferDesc, NULL, &m_lightBuffer);
result = device->CreateBuffer(&lightBufferDesc, NULL, &light_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create the light constant buffer pointer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -285,50 +285,50 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
}
void NormalMapShaderClass::ShutdownShader()
void normal_map_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down normal map shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the light constant buffer.
if (m_lightBuffer)
if (light_buffer_)
{
m_lightBuffer->Release();
m_lightBuffer = 0;
light_buffer_->Release();
light_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("Successfully shut down normal map shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@ -337,7 +337,7 @@ void NormalMapShaderClass::ShutdownShader()
}
void NormalMapShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void normal_map_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@ -373,14 +373,14 @@ void NormalMapShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HW
}
bool NormalMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool normal_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
LightBufferType* dataPtr2;
light_buffer_type* dataPtr2;
// Transpose the matrices to prepare them for the shader.
@ -389,7 +389,7 @@ bool NormalMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContex
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to lock the constant buffer so it can be written to", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -397,7 +397,7 @@ bool NormalMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContex
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@ -405,20 +405,20 @@ bool NormalMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContex
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resources in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture1);
deviceContext->PSSetShaderResources(1, 1, &texture2);
// Lock the light constant buffer so it can be written to.
result = deviceContext->Map(m_lightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(light_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to lock the light constant buffer so it can be written to", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -426,21 +426,21 @@ bool NormalMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContex
}
// Get a pointer to the data in the constant buffer.
dataPtr2 = (LightBufferType*)mappedResource.pData;
dataPtr2 = (light_buffer_type*)mappedResource.pData;
// Copy the lighting variables into the constant buffer.
dataPtr2->diffuseColor = diffuseColor;
dataPtr2->lightDirection = lightDirection;
dataPtr2->diffuse_color = diffuseColor;
dataPtr2->light_direction = lightDirection;
dataPtr2->padding = 0.0f;
// Unlock the constant buffer.
deviceContext->Unmap(m_lightBuffer, 0);
deviceContext->Unmap(light_buffer_, 0);
// Set the position of the light constant buffer in the pixel shader.
bufferNumber = 0;
// Finally set the light constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_lightBuffer);
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &light_buffer_);
// Set shader texture resources in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture1);
@ -450,19 +450,19 @@ bool NormalMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContex
}
void NormalMapShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void normal_map_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@ -1,25 +1,25 @@
#include "reflectionshaderclass.h"
#include "reflection_shader_class.h"
ReflectionShaderClass::ReflectionShaderClass()
reflection_shader_class::reflection_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
m_reflectionBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
reflection_buffer_ = 0;
}
ReflectionShaderClass::ReflectionShaderClass(const ReflectionShaderClass& other)
reflection_shader_class::reflection_shader_class(const reflection_shader_class& other)
{
}
ReflectionShaderClass::~ReflectionShaderClass()
reflection_shader_class::~reflection_shader_class()
{
}
bool ReflectionShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool reflection_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing reflection shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -44,8 +44,8 @@ bool ReflectionShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -57,22 +57,22 @@ bool ReflectionShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return true;
}
void ReflectionShaderClass::Shutdown()
void reflection_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool ReflectionShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool reflection_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, ID3D11ShaderResourceView* reflectionTexture, XMMATRIX reflectionMatrix)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, reflectionTexture, reflectionMatrix);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, reflectionTexture, reflectionMatrix);
if (!result)
{
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -80,12 +80,12 @@ bool ReflectionShaderClass::Render(ID3D11DeviceContext* deviceContext, int index
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool reflection_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing reflection shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -100,7 +100,7 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
D3D11_BUFFER_DESC reflectionBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@ -113,7 +113,7 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@ -131,7 +131,7 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@ -143,7 +143,7 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -151,7 +151,7 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -180,7 +180,7 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -196,14 +196,14 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -225,7 +225,7 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Error creating sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -233,14 +233,14 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
}
// Setup the description of the reflection dynamic constant buffer that is in the vertex shader.
reflectionBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
reflectionBufferDesc.ByteWidth = sizeof(ReflectionBufferType);
reflectionBufferDesc.ByteWidth = sizeof(reflection_buffer_type);
reflectionBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
reflectionBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
reflectionBufferDesc.MiscFlags = 0;
reflectionBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&reflectionBufferDesc, NULL, &m_reflectionBuffer);
result = device->CreateBuffer(&reflectionBufferDesc, NULL, &reflection_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -252,50 +252,50 @@ bool ReflectionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
return true;
}
void ReflectionShaderClass::ShutdownShader()
void reflection_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down reflection shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the reflection constant buffer.
if (m_reflectionBuffer)
if (reflection_buffer_)
{
m_reflectionBuffer->Release();
m_reflectionBuffer = 0;
reflection_buffer_->Release();
reflection_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("Reflection shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@ -304,7 +304,7 @@ void ReflectionShaderClass::ShutdownShader()
}
void ReflectionShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void reflection_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@ -339,14 +339,14 @@ void ReflectionShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, H
return;
}
bool ReflectionShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool reflection_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, ID3D11ShaderResourceView* reflectionTexture, XMMATRIX reflectionMatrix)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
ReflectionBufferType* dataPtr2;
reflection_buffer_type* dataPtr2;
// Transpose the matrices to prepare them for the shader.
@ -358,7 +358,7 @@ bool ReflectionShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceConte
reflectionMatrix = XMMatrixTranspose(reflectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -366,7 +366,7 @@ bool ReflectionShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceConte
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@ -374,16 +374,16 @@ bool ReflectionShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceConte
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Lock the reflection constant buffer so it can be written to.
result = deviceContext->Map(m_reflectionBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(reflection_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -391,19 +391,19 @@ bool ReflectionShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceConte
}
// Get a pointer to the data in the matrix constant buffer.
dataPtr2 = (ReflectionBufferType*)mappedResource.pData;
dataPtr2 = (reflection_buffer_type*)mappedResource.pData;
// Copy the matrix into the reflection constant buffer.
dataPtr2->reflectionMatrix = reflectionMatrix;
dataPtr2->reflection_matrix = reflectionMatrix;
// Unlock the reflection constant buffer.
deviceContext->Unmap(m_reflectionBuffer, 0);
deviceContext->Unmap(reflection_buffer_, 0);
// Set the position of the reflection constant buffer in the vertex shader.
bufferNumber = 1;
// Now set the reflection constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_reflectionBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &reflection_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
@ -415,19 +415,19 @@ bool ReflectionShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceConte
}
void ReflectionShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void reflection_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render the geometry.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the geometry.
// render the geometry.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@ -1,29 +1,29 @@
#include "refractionshaderclass.h"
#include "refraction_shader_class.h"
RefractionShaderClass::RefractionShaderClass()
refraction_shader_class::refraction_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
m_lightBuffer = 0;
m_clipPlaneBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
light_buffer_ = 0;
clip_plane_buffer_ = 0;
}
RefractionShaderClass::RefractionShaderClass(const RefractionShaderClass& other)
refraction_shader_class::refraction_shader_class(const refraction_shader_class& other)
{
}
RefractionShaderClass::~RefractionShaderClass()
refraction_shader_class::~refraction_shader_class()
{
}
bool RefractionShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool refraction_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
bool result;
wchar_t vsFilename[128];
@ -44,8 +44,8 @@ bool RefractionShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
return false;
@ -55,35 +55,35 @@ bool RefractionShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
}
void RefractionShaderClass::Shutdown()
void refraction_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool RefractionShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool refraction_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 ambientColor[], XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[], XMFLOAT4 clipPlane)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, lightDirection, ambientColor, diffuseColor, lightPosition, clipPlane);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, lightDirection, ambientColor, diffuseColor, lightPosition, clipPlane);
if (!result)
{
return false;
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool refraction_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
HRESULT result;
ID3D10Blob* errorMessage;
@ -97,7 +97,7 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
D3D11_BUFFER_DESC clipPlaneBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@ -110,7 +110,7 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@ -129,7 +129,7 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@ -141,14 +141,14 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
return false;
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
return false;
@ -184,7 +184,7 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
return false;
@ -199,14 +199,14 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
return false;
@ -228,7 +228,7 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
return false;
@ -237,14 +237,14 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// Setup the description of the light dynamic constant buffer that is in the pixel shader.
// Note that ByteWidth always needs to be a multiple of 16 if using D3D11_BIND_CONSTANT_BUFFER or CreateBuffer will fail.
lightBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
lightBufferDesc.ByteWidth = sizeof(LightBufferType);
lightBufferDesc.ByteWidth = sizeof(light_buffer_type);
lightBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
lightBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
lightBufferDesc.MiscFlags = 0;
lightBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&lightBufferDesc, NULL, &m_lightBuffer);
result = device->CreateBuffer(&lightBufferDesc, NULL, &light_buffer_);
if (FAILED(result))
{
return false;
@ -252,14 +252,14 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
// Setup the description of the clip plane dynamic constant buffer that is in the vertex shader.
clipPlaneBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
clipPlaneBufferDesc.ByteWidth = sizeof(ClipPlaneBufferType);
clipPlaneBufferDesc.ByteWidth = sizeof(clip_plane_buffer_type);
clipPlaneBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
clipPlaneBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
clipPlaneBufferDesc.MiscFlags = 0;
clipPlaneBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&clipPlaneBufferDesc, NULL, &m_clipPlaneBuffer);
result = device->CreateBuffer(&clipPlaneBufferDesc, NULL, &clip_plane_buffer_);
if (FAILED(result))
{
return false;
@ -269,62 +269,62 @@ bool RefractionShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WC
}
void RefractionShaderClass::ShutdownShader()
void refraction_shader_class::shutdown_shader()
{
// Release the clip plane constant buffer.
if (m_clipPlaneBuffer)
if (clip_plane_buffer_)
{
m_clipPlaneBuffer->Release();
m_clipPlaneBuffer = 0;
clip_plane_buffer_->Release();
clip_plane_buffer_ = 0;
}
// Release the light constant buffer.
if (m_lightBuffer)
if (light_buffer_)
{
m_lightBuffer->Release();
m_lightBuffer = 0;
light_buffer_->Release();
light_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
return;
}
void RefractionShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void refraction_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@ -360,15 +360,15 @@ void RefractionShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, H
}
bool RefractionShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool refraction_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 ambientColor[], XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[], XMFLOAT4 clipPlane)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
ClipPlaneBufferType* dataPtr2;
LightBufferType* dataPtr3;
clip_plane_buffer_type* dataPtr2;
light_buffer_type* dataPtr3;
// Transpose the matrices to prepare them for the shader.
@ -377,14 +377,14 @@ bool RefractionShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceConte
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@ -392,81 +392,81 @@ bool RefractionShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceConte
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Lock the clip plane constant buffer so it can be written to.
result = deviceContext->Map(m_clipPlaneBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(clip_plane_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if(FAILED(result))
{
return false;
}
// Get a pointer to the data in the clip plane constant buffer.
dataPtr2 = (ClipPlaneBufferType*)mappedResource.pData;
dataPtr2 = (clip_plane_buffer_type*)mappedResource.pData;
// Copy the clip plane into the clip plane constant buffer.
dataPtr2->clipPlane = clipPlane;
dataPtr2->clip_plane = clipPlane;
// Unlock the buffer.
deviceContext->Unmap(m_clipPlaneBuffer, 0);
deviceContext->Unmap(clip_plane_buffer_, 0);
// Set the position of the clip plane constant buffer in the vertex shader.
bufferNumber = 1;
// Now set the clip plane constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_clipPlaneBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &clip_plane_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
// Lock the light constant buffer so it can be written to.
result = deviceContext->Map(m_lightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(light_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if(FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr3 = (LightBufferType*)mappedResource.pData;
dataPtr3 = (light_buffer_type*)mappedResource.pData;
// Copy the lighting variables into the constant buffer.
dataPtr3->ambientColor = ambientColor[0];
dataPtr3->diffuseColor = diffuseColor[0];
dataPtr3->lightPosition = lightPosition[0];
dataPtr3->lightDirection = lightDirection;
dataPtr3->ambient_color = ambientColor[0];
dataPtr3->diffuse_color = diffuseColor[0];
dataPtr3->light_position = lightPosition[0];
dataPtr3->light_direction = lightDirection;
// Unlock the constant buffer.
deviceContext->Unmap(m_lightBuffer, 0);
deviceContext->Unmap(light_buffer_, 0);
// Set the position of the light constant buffer in the pixel shader.
bufferNumber = 0;
// Finally set the light constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_lightBuffer);
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &light_buffer_);
return true;
}
void RefractionShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void refraction_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render the geometry.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the geometry.
// render the geometry.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@ -0,0 +1,518 @@
#include "shader_manager_class.h"
shader_manager_class::shader_manager_class()
{
texture_shader_ = 0;
normal_map_shader_ = 0;
multitexture_shader_ = 0;
translate_shader_ = 0;
alpha_map_shader_ = 0;
spec_map_shader_ = 0;
transparent_shader_ = 0;
light_shader_ = 0;
light_map_shader_ = 0;
refraction_shader_ = 0;
water_shader_ = 0;
cel_shading_shader_ = 0;
sunlight_shader_ = 0;
skybox_shader_ = 0;
refraction_shader_ = 0;
depth_shader_ = 0;
}
shader_manager_class::shader_manager_class(const shader_manager_class& other)
{
}
shader_manager_class::~shader_manager_class()
{
}
bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing shader_manager_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
// Create and initialize the texture shader object.
texture_shader_ = new texture_shader_class;
result = texture_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing texture_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the normal map shader object.
normal_map_shader_ = new normal_map_shader_class;
result = normal_map_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing normal_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the multitexture shader object.
multitexture_shader_ = new multi_texture_shader_class;
result = multitexture_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing multi_texture_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the translate shader object.
translate_shader_ = new translate_shader_class;
result = translate_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing translate_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the alpha map shader object.
alpha_map_shader_ = new alpha_map_shader_class;
result = alpha_map_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing alpha_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the specular map shader object.
spec_map_shader_ = new spec_map_shader_class;
result = spec_map_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing spec_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the transparent shader object.
transparent_shader_ = new transparent_shader_class;
result = transparent_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing transparent_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the light shader object.
light_shader_ = new light_shader_class;
result = light_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing light_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the light map shader object.
light_map_shader_ = new light_map_shader_class;
result = light_map_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing light_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the refraction shader object.
refraction_shader_ = new refraction_shader_class;
result = refraction_shader_->initialize(device, hwnd);
if (!result)
{
return false;
}
// Create and initialize the water shader object.
water_shader_ = new water_shader_class;
result = water_shader_->initialize(device, hwnd);
if (!result)
{
return false;
}
cel_shading_shader_ = new celshade_class;
result = cel_shading_shader_->initialize(device, hwnd);
if (!result)
{
return false;
}
sunlight_shader_ = new sunlight_shader_class;
result = sunlight_shader_->initialize(device, hwnd);
if (!result)
{
return false;
}
skybox_shader_ = new skybox_shader_class;
result = skybox_shader_->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing skybox_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
depth_shader_ = new depth_shader_class;
result = depth_shader_->initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing depth_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("shader_manager_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void shader_manager_class::shutdown()
{
Logger::Get().Log("Shutting down shader_manager_class", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the normal map shader object.
if (normal_map_shader_)
{
normal_map_shader_->shutdown();
delete normal_map_shader_;
normal_map_shader_ = 0;
}
// Release the texture shader object.
if (texture_shader_)
{
texture_shader_->shutdown();
delete texture_shader_;
texture_shader_ = 0;
}
// Release the multitexture shader object.
if (multitexture_shader_)
{
multitexture_shader_->shutdown();
delete multitexture_shader_;
multitexture_shader_ = 0;
}
// Release the translate shader object.
if (translate_shader_)
{
translate_shader_->shutdown();
delete translate_shader_;
translate_shader_ = 0;
}
// Release the alpha map shader object.
if (alpha_map_shader_)
{
alpha_map_shader_->shutdown();
delete alpha_map_shader_;
alpha_map_shader_ = 0;
}
// Release the specular map shader object.
if (spec_map_shader_)
{
spec_map_shader_->shutdown();
delete spec_map_shader_;
spec_map_shader_ = 0;
}
// Release the transparent shader object.
if (transparent_shader_)
{
transparent_shader_->shutdown();
delete transparent_shader_;
transparent_shader_ = 0;
}
// Release the light shader object.
if (light_shader_)
{
light_shader_->shutdown();
delete light_shader_;
light_shader_ = 0;
}
// Release the light map shader object.
if (light_map_shader_)
{
light_map_shader_->shutdown();
delete light_map_shader_;
light_map_shader_ = 0;
}
// Release the refraction shader object.
if (refraction_shader_)
{
refraction_shader_->shutdown();
delete refraction_shader_;
refraction_shader_ = 0;
}
// Release the water shader object.
if (water_shader_)
{
water_shader_->shutdown();
delete water_shader_;
water_shader_ = 0;
}
// Release the cel shading shader object.
if (cel_shading_shader_)
{
cel_shading_shader_->shutdown();
delete cel_shading_shader_;
cel_shading_shader_ = 0;
}
if (sunlight_shader_)
{
sunlight_shader_->shutdown();
delete sunlight_shader_;
sunlight_shader_ = 0;
}
if (skybox_shader_)
{
skybox_shader_->Shutdown();
delete skybox_shader_;
skybox_shader_ = 0;
}
if (depth_shader_)
{
depth_shader_->shutdown();
delete depth_shader_;
depth_shader_ = 0;
}
Logger::Get().Log("shader_manager_class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
bool shader_manager_class::render_texture_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture)
{
bool result;
result = texture_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture);
if (!result)
{
Logger::Get().Log("Error rendering texture_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool shader_manager_class::render_normal_map_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* colorTexture, ID3D11ShaderResourceView* normalTexture, XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor)
{
bool result;
result = normal_map_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, colorTexture, normalTexture, lightDirection, diffuseColor);
if (!result)
{
Logger::Get().Log("Error rendering normal_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool shader_manager_class::render_multitexture_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2)
{
bool result;
result = multitexture_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
if (!result)
{
Logger::Get().Log("Error rendering multi_texture_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool shader_manager_class::render_translate_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, float valeur)
{
bool result;
result = translate_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, valeur);
if (!result)
{
Logger::Get().Log("Error rendering translate_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool shader_manager_class::render_alpha_map_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, ID3D11ShaderResourceView* texture3)
{
bool result;
result = alpha_map_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3);
if (!result)
{
Logger::Get().Log("Error rendering alpha_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool shader_manager_class::render_spec_map_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, ID3D11ShaderResourceView* texture3,
XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor, XMFLOAT3 cameraPosition, XMFLOAT4 specularColor, float specularPower)
{
bool result;
result = spec_map_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3, lightDirection,
diffuseColor, cameraPosition, specularColor, specularPower);
if (!result)
{
Logger::Get().Log("Error rendering spec_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool shader_manager_class::render_transparent_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, float blendAmount)
{
bool result;
result = transparent_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, blendAmount);
if (!result)
{
Logger::Get().Log("Error rendering transparent_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool shader_manager_class::renderlight_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[], XMFLOAT4 ambientColor[])
{
bool result;
result = light_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, lightPosition, ambientColor);
if (!result)
{
return false;
}
return true;
}
bool shader_manager_class::renderlight_map_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2)
{
bool result;
result = light_map_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
if (!result)
{
return false;
}
return true;
}
bool shader_manager_class::render_refraction_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 ambientColor[], XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[], XMFLOAT4 clipPlane)
{
bool result;
result = refraction_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, lightDirection, ambientColor, diffuseColor, lightPosition, clipPlane);
if (!result)
{
return false;
}
return true;
}
bool shader_manager_class::render_water_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
XMMATRIX reflectionMatrix, ID3D11ShaderResourceView* reflectionTexture, ID3D11ShaderResourceView* refractionTexture,
ID3D11ShaderResourceView* normalTexture, float waterTranslation, float reflectRefractScale)
{
bool result;
result = water_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, reflectionMatrix, reflectionTexture,
refractionTexture, normalTexture, waterTranslation, reflectRefractScale);
if (!result)
{
return false;
}
return true;
}
bool shader_manager_class::render_cel_shading_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
{
bool result;
result = cel_shading_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
if (!result)
{
return false;
}
return true;
}
bool shader_manager_class::render_sunlight_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
{
bool result;
result = sunlight_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
if (!result)
{
return false;
}
return true;
}
bool shader_manager_class::render_skybox_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
{
bool result;
result = skybox_shader_->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
if (!result)
{
return false;
}
return true;
}
bool shader_manager_class::render_depth_shader(
ID3D11DeviceContext* context,
int indexCount,
XMMATRIX worldMatrix,
XMMATRIX viewMatrix,
XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture
)
{
bool result;
result = depth_shader_->render(context, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture);
if (!result)
{
return false;
}
return true;
}

View File

@ -1,479 +0,0 @@
#include "shadermanagerclass.h"
ShaderManagerClass::ShaderManagerClass()
{
m_TextureShader = 0;
m_NormalMapShader = 0;
m_MultitextureShader = 0;
m_TranslateShader = 0;
m_AlphaMapShader = 0;
m_SpecMapShader = 0;
m_TransparentShader = 0;
m_LightShader = 0;
m_LightMapShader = 0;
m_RefractionShader = 0;
m_WaterShader = 0;
m_CelShadingShader = 0;
}
ShaderManagerClass::ShaderManagerClass(const ShaderManagerClass& other)
{
}
ShaderManagerClass::~ShaderManagerClass()
{
}
bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing ShaderManagerClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
// Create and initialize the texture shader object.
m_TextureShader = new TextureShaderClass;
result = m_TextureShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing TextureShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the normal map shader object.
m_NormalMapShader = new NormalMapShaderClass;
result = m_NormalMapShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing NormalMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the multitexture shader object.
m_MultitextureShader = new MultiTextureShaderClass;
result = m_MultitextureShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing MultiTextureShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the translate shader object.
m_TranslateShader = new TranslateShaderClass;
result = m_TranslateShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing TranslateShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the alpha map shader object.
m_AlphaMapShader = new AlphaMapShaderClass;
result = m_AlphaMapShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing AlphaMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the specular map shader object.
m_SpecMapShader = new SpecMapShaderClass;
result = m_SpecMapShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing SpecMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the transparent shader object.
m_TransparentShader = new TransparentShaderClass;
result = m_TransparentShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing TransparentShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the light shader object.
m_LightShader = new LightShaderClass;
result = m_LightShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the light map shader object.
m_LightMapShader = new LightMapShaderClass;
result = m_LightMapShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing LightMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create and initialize the refraction shader object.
m_RefractionShader = new RefractionShaderClass;
result = m_RefractionShader->Initialize(device, hwnd);
if (!result)
{
return false;
}
// Create and initialize the water shader object.
m_WaterShader = new WaterShaderClass;
result = m_WaterShader->Initialize(device, hwnd);
if (!result)
{
return false;
}
m_CelShadingShader = new CelshadeClass;
result = m_CelShadingShader->Initialize(device, hwnd);
if (!result)
{
return false;
}
m_SunlightShader = new SunlightShaderClass;
result = m_SunlightShader->Initialize(device, hwnd);
if (!result)
{
return false;
}
m_SkyboxShader = new SkyboxShaderClass;
result = m_SkyboxShader->Initialize(device, hwnd);
if (!result)
{
Logger::Get().Log("Error initializing SkyboxShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("ShaderManagerClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void ShaderManagerClass::Shutdown()
{
Logger::Get().Log("Shutting down ShaderManagerClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the normal map shader object.
if (m_NormalMapShader)
{
m_NormalMapShader->Shutdown();
delete m_NormalMapShader;
m_NormalMapShader = 0;
}
// Release the texture shader object.
if (m_TextureShader)
{
m_TextureShader->Shutdown();
delete m_TextureShader;
m_TextureShader = 0;
}
// Release the multitexture shader object.
if (m_MultitextureShader)
{
m_MultitextureShader->Shutdown();
delete m_MultitextureShader;
m_MultitextureShader = 0;
}
// Release the translate shader object.
if (m_TranslateShader)
{
m_TranslateShader->Shutdown();
delete m_TranslateShader;
m_TranslateShader = 0;
}
// Release the alpha map shader object.
if (m_AlphaMapShader)
{
m_AlphaMapShader->Shutdown();
delete m_AlphaMapShader;
m_AlphaMapShader = 0;
}
// Release the specular map shader object.
if (m_SpecMapShader)
{
m_SpecMapShader->Shutdown();
delete m_SpecMapShader;
m_SpecMapShader = 0;
}
// Release the transparent shader object.
if (m_TransparentShader)
{
m_TransparentShader->Shutdown();
delete m_TransparentShader;
m_TransparentShader = 0;
}
// Release the light shader object.
if (m_LightShader)
{
m_LightShader->Shutdown();
delete m_LightShader;
m_LightShader = 0;
}
// Release the light map shader object.
if (m_LightMapShader)
{
m_LightMapShader->Shutdown();
delete m_LightMapShader;
m_LightMapShader = 0;
}
// Release the refraction shader object.
if (m_RefractionShader)
{
m_RefractionShader->Shutdown();
delete m_RefractionShader;
m_RefractionShader = 0;
}
// Release the water shader object.
if (m_WaterShader)
{
m_WaterShader->Shutdown();
delete m_WaterShader;
m_WaterShader = 0;
}
// Release the cel shading shader object.
if (m_CelShadingShader)
{
m_CelShadingShader->Shutdown();
delete m_CelShadingShader;
m_CelShadingShader = 0;
}
if (m_SunlightShader)
{
m_SunlightShader->Shutdown();
delete m_SunlightShader;
m_SunlightShader = 0;
}
if (m_SkyboxShader)
{
m_SkyboxShader->Shutdown();
delete m_SkyboxShader;
m_SkyboxShader = 0;
}
Logger::Get().Log("ShaderManagerClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
bool ShaderManagerClass::RenderTextureShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture)
{
bool result;
result = m_TextureShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture);
if (!result)
{
Logger::Get().Log("Error rendering TextureShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool ShaderManagerClass::RenderNormalMapShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* colorTexture, ID3D11ShaderResourceView* normalTexture, XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor)
{
bool result;
result = m_NormalMapShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, colorTexture, normalTexture, lightDirection, diffuseColor);
if (!result)
{
Logger::Get().Log("Error rendering NormalMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool ShaderManagerClass::RenderMultitextureShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2)
{
bool result;
result = m_MultitextureShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
if (!result)
{
Logger::Get().Log("Error rendering MultiTextureShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool ShaderManagerClass::RenderTranslateShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, float valeur)
{
bool result;
result = m_TranslateShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, valeur);
if (!result)
{
Logger::Get().Log("Error rendering TranslateShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool ShaderManagerClass::RenderAlphaMapShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, ID3D11ShaderResourceView* texture3)
{
bool result;
result = m_AlphaMapShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3);
if (!result)
{
Logger::Get().Log("Error rendering AlphaMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool ShaderManagerClass::RenderSpecMapShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, ID3D11ShaderResourceView* texture3,
XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor, XMFLOAT3 cameraPosition, XMFLOAT4 specularColor, float specularPower)
{
bool result;
result = m_SpecMapShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3, lightDirection,
diffuseColor, cameraPosition, specularColor, specularPower);
if (!result)
{
Logger::Get().Log("Error rendering SpecMapShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool ShaderManagerClass::RenderTransparentShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, float blendAmount)
{
bool result;
result = m_TransparentShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, blendAmount);
if (!result)
{
Logger::Get().Log("Error rendering TransparentShaderClass", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
return true;
}
bool ShaderManagerClass::RenderlightShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[], XMFLOAT4 ambientColor[])
{
bool result;
result = m_LightShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, lightPosition, ambientColor);
if (!result)
{
return false;
}
return true;
}
bool ShaderManagerClass::RenderlightMapShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2)
{
bool result;
result = m_LightMapShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
if (!result)
{
return false;
}
return true;
}
bool ShaderManagerClass::RenderRefractionShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 ambientColor[], XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[], XMFLOAT4 clipPlane)
{
bool result;
result = m_RefractionShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, lightDirection, ambientColor, diffuseColor, lightPosition, clipPlane);
if (!result)
{
return false;
}
return true;
}
bool ShaderManagerClass::RenderWaterShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
XMMATRIX reflectionMatrix, ID3D11ShaderResourceView* reflectionTexture, ID3D11ShaderResourceView* refractionTexture,
ID3D11ShaderResourceView* normalTexture, float waterTranslation, float reflectRefractScale)
{
bool result;
result = m_WaterShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, reflectionMatrix, reflectionTexture,
refractionTexture, normalTexture, waterTranslation, reflectRefractScale);
if (!result)
{
return false;
}
return true;
}
bool ShaderManagerClass::RenderCelShadingShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
{
bool result;
result = m_CelShadingShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
if (!result)
{
return false;
}
return true;
}
bool ShaderManagerClass::RenderSunlightShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
{
bool result;
result = m_SunlightShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
if (!result)
{
return false;
}
return true;
}
bool ShaderManagerClass::RenderSkyboxShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
{
bool result;
result = m_SkyboxShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
if (!result)
{
return false;
}
return true;
}

View File

@ -1,10 +1,10 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: lightshaderclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "SkyboxShaderClass.h"
#include "skybox_shader_class.h"
SkyboxShaderClass::SkyboxShaderClass()
skybox_shader_class::skybox_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
@ -18,17 +18,17 @@ SkyboxShaderClass::SkyboxShaderClass()
}
SkyboxShaderClass::SkyboxShaderClass(const SkyboxShaderClass& other)
skybox_shader_class::skybox_shader_class(const skybox_shader_class& other)
{
}
SkyboxShaderClass::~SkyboxShaderClass()
skybox_shader_class::~skybox_shader_class()
{
}
bool SkyboxShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool skybox_shader_class::Initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -60,13 +60,13 @@ bool SkyboxShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
Logger::Get().Log("SkyboxShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("skybox_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void SkyboxShaderClass::Shutdown()
void skybox_shader_class::Shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
@ -74,7 +74,7 @@ void SkyboxShaderClass::Shutdown()
return;
}
bool SkyboxShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool skybox_shader_class::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
{
bool result;
@ -95,7 +95,7 @@ bool SkyboxShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCoun
}
bool SkyboxShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool skybox_shader_class::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -266,7 +266,7 @@ bool SkyboxShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
void SkyboxShaderClass::ShutdownShader()
void skybox_shader_class::ShutdownShader()
{
Logger::Get().Log("Shutting down SunLightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@ -338,7 +338,7 @@ void SkyboxShaderClass::ShutdownShader()
}
void SkyboxShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void skybox_shader_class::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned __int64 bufferSize, i;
@ -374,7 +374,7 @@ void SkyboxShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND
}
bool SkyboxShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 ambientColor, XMFLOAT4 diffuseColor, XMFLOAT3 lightDirection, float sunIntensity)
bool skybox_shader_class::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 ambientColor, XMFLOAT4 diffuseColor, XMFLOAT3 lightDirection, float sunIntensity)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
@ -443,7 +443,7 @@ bool SkyboxShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext,
return true;
}
void SkyboxShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void skybox_shader_class::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);

View File

@ -1,29 +1,29 @@
#include "specmapshaderclass.h"
#include "spec_map_shader_class.h"
SpecMapShaderClass::SpecMapShaderClass()
spec_map_shader_class::spec_map_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
m_lightBuffer = 0;
m_cameraBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
light_buffer_ = 0;
camera_buffer_ = 0;
}
SpecMapShaderClass::SpecMapShaderClass(const SpecMapShaderClass& other)
spec_map_shader_class::spec_map_shader_class(const spec_map_shader_class& other)
{
}
SpecMapShaderClass::~SpecMapShaderClass()
spec_map_shader_class::~spec_map_shader_class()
{
}
bool SpecMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool spec_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
bool result;
wchar_t vsFilename[128];
@ -44,8 +44,8 @@ bool SpecMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
return false;
@ -55,15 +55,15 @@ bool SpecMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
}
void SpecMapShaderClass::Shutdown()
void spec_map_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool SpecMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool spec_map_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, ID3D11ShaderResourceView* texture3,
XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor, XMFLOAT3 cameraPosition, XMFLOAT4 specularColor, float specularPower)
{
@ -71,7 +71,7 @@ bool SpecMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCou
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3, lightDirection, diffuseColor,
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3, lightDirection, diffuseColor,
cameraPosition, specularColor, specularPower);
if (!result)
{
@ -79,13 +79,13 @@ bool SpecMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCou
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool spec_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
HRESULT result;
ID3D10Blob* errorMessage;
@ -99,7 +99,7 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
D3D11_BUFFER_DESC cameraBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@ -112,7 +112,7 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@ -131,7 +131,7 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@ -143,14 +143,14 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
return false;
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
return false;
@ -202,7 +202,7 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
return false;
@ -217,14 +217,14 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
return false;
@ -246,7 +246,7 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
return false;
@ -254,14 +254,14 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// Setup the description of the light dynamic constant buffer that is in the pixel shader.
lightBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
lightBufferDesc.ByteWidth = sizeof(LightBufferType);
lightBufferDesc.ByteWidth = sizeof(light_buffer_type);
lightBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
lightBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
lightBufferDesc.MiscFlags = 0;
lightBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&lightBufferDesc, NULL, &m_lightBuffer);
result = device->CreateBuffer(&lightBufferDesc, NULL, &light_buffer_);
if (FAILED(result))
{
return false;
@ -269,14 +269,14 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// Setup the description of the camera dynamic constant buffer that is in the vertex shader.
cameraBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
cameraBufferDesc.ByteWidth = sizeof(CameraBufferType);
cameraBufferDesc.ByteWidth = sizeof(camera_buffer_type);
cameraBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
cameraBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
cameraBufferDesc.MiscFlags = 0;
cameraBufferDesc.StructureByteStride = 0;
// Create the camera constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&cameraBufferDesc, NULL, &m_cameraBuffer);
result = device->CreateBuffer(&cameraBufferDesc, NULL, &camera_buffer_);
if (FAILED(result))
{
return false;
@ -286,62 +286,62 @@ bool SpecMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
}
void SpecMapShaderClass::ShutdownShader()
void spec_map_shader_class::shutdown_shader()
{
// Release the camera constant buffer.
if (m_cameraBuffer)
if (camera_buffer_)
{
m_cameraBuffer->Release();
m_cameraBuffer = 0;
camera_buffer_->Release();
camera_buffer_ = 0;
}
// Release the light constant buffer.
if (m_lightBuffer)
if (light_buffer_)
{
m_lightBuffer->Release();
m_lightBuffer = 0;
light_buffer_->Release();
light_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
return;
}
void SpecMapShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void spec_map_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@ -376,16 +376,16 @@ void SpecMapShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND
return;
}
bool SpecMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool spec_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2, ID3D11ShaderResourceView* texture3,
XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor, XMFLOAT3 cameraPosition, XMFLOAT4 specularColor, float specularPower)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
LightBufferType* dataPtr2;
CameraBufferType* dataPtr3;
light_buffer_type* dataPtr2;
camera_buffer_type* dataPtr3;
// Transpose the matrices to prepare them for the shader.
@ -394,14 +394,14 @@ bool SpecMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext,
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@ -409,13 +409,13 @@ bool SpecMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext,
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resources in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture1);
@ -423,69 +423,69 @@ bool SpecMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext,
deviceContext->PSSetShaderResources(2, 1, &texture3);
// Lock the light constant buffer so it can be written to.
result = deviceContext->Map(m_lightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(light_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr2 = (LightBufferType*)mappedResource.pData;
dataPtr2 = (light_buffer_type*)mappedResource.pData;
// Copy the lighting variables into the constant buffer.
dataPtr2->diffuseColor = diffuseColor;
dataPtr2->lightDirection = lightDirection;
dataPtr2->specularColor = specularColor;
dataPtr2->specularPower = specularPower;
dataPtr2->diffuse_color = diffuseColor;
dataPtr2->light_direction = lightDirection;
dataPtr2->specular_color = specularColor;
dataPtr2->specular_power = specularPower;
// Unlock the constant buffer.
deviceContext->Unmap(m_lightBuffer, 0);
deviceContext->Unmap(light_buffer_, 0);
// Set the position of the light constant buffer in the pixel shader.
bufferNumber = 0;
// Finally set the light constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_lightBuffer);
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &light_buffer_);
// Lock the camera constant buffer so it can be written to.
result = deviceContext->Map(m_cameraBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(camera_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr3 = (CameraBufferType*)mappedResource.pData;
dataPtr3 = (camera_buffer_type*)mappedResource.pData;
// Copy the camera position into the constant buffer.
dataPtr3->cameraPosition = cameraPosition;
dataPtr3->camera_position = cameraPosition;
// Unlock the camera constant buffer.
deviceContext->Unmap(m_cameraBuffer, 0);
deviceContext->Unmap(camera_buffer_, 0);
// Set the position of the camera constant buffer in the vertex shader as the second buffer.
bufferNumber = 1;
// Now set the camera constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_cameraBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &camera_buffer_);
return true;
}
void SpecMapShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void spec_map_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this model.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the model.
// render the model.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@ -1,34 +1,34 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: lightshaderclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "sunlightshaderclass.h"
#include "sunlight_shader_class.h"
SunlightShaderClass::SunlightShaderClass()
sunlight_shader_class::sunlight_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_sampleState = 0;
m_matrixBuffer = 0;
m_cameraBuffer = 0;
m_sunlightBuffer = 0;
m_sunlightColorBuffer = 0;
m_sunlightPositionBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
sample_state_ = 0;
matrix_buffer_ = 0;
camera_buffer_ = 0;
sunlight_buffer_ = 0;
sunlight_color_buffer_ = 0;
sunlight_position_buffer_ = 0;
}
SunlightShaderClass::SunlightShaderClass(const SunlightShaderClass& other)
sunlight_shader_class::sunlight_shader_class(const sunlight_shader_class& other)
{
}
SunlightShaderClass::~SunlightShaderClass()
sunlight_shader_class::~sunlight_shader_class()
{
}
bool SunlightShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool sunlight_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -52,8 +52,8 @@ bool SunlightShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Failed to initialize shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -66,22 +66,22 @@ bool SunlightShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
}
void SunlightShaderClass::Shutdown()
void sunlight_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool SunlightShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool sunlight_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
if (!result)
{
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -89,13 +89,13 @@ bool SunlightShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCo
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -109,7 +109,7 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
D3D11_BUFFER_DESC matrixBufferDesc;
D3D11_BUFFER_DESC sunlightBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@ -120,7 +120,7 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
{
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
else
{
@ -135,7 +135,7 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
{
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
else
{
@ -145,7 +145,7 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -153,7 +153,7 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -189,7 +189,7 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
numElements = sizeof(polygonLayout) / sizeof(polygonLayout[0]);
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &m_layout);
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -219,7 +219,7 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -228,14 +228,14 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -244,14 +244,14 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
// Setup the description of the dynamic sunlight constant buffer that is in the pixel shader.
sunlightBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
sunlightBufferDesc.ByteWidth = sizeof(SunLightBufferType);
sunlightBufferDesc.ByteWidth = sizeof(sun_light_buffer_type);
sunlightBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
sunlightBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
sunlightBufferDesc.MiscFlags = 0;
sunlightBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the pixel shader constant buffer from within this class.
result = device->CreateBuffer(&sunlightBufferDesc, NULL, &m_sunlightBuffer);
result = device->CreateBuffer(&sunlightBufferDesc, NULL, &sunlight_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create sunlight buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -266,70 +266,70 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
void SunlightShaderClass::ShutdownShader()
void sunlight_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down SunLightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the light constant buffers.
if (m_sunlightColorBuffer)
if (sunlight_color_buffer_)
{
m_sunlightColorBuffer->Release();
m_sunlightColorBuffer = 0;
sunlight_color_buffer_->Release();
sunlight_color_buffer_ = 0;
}
if (m_sunlightPositionBuffer)
if (sunlight_position_buffer_)
{
m_sunlightPositionBuffer->Release();
m_sunlightPositionBuffer = 0;
sunlight_position_buffer_->Release();
sunlight_position_buffer_ = 0;
}
// Release the light constant buffer.
if (m_sunlightBuffer)
if (sunlight_buffer_)
{
m_sunlightBuffer->Release();
m_sunlightBuffer = 0;
sunlight_buffer_->Release();
sunlight_buffer_ = 0;
}
// Release the camera constant buffer.
if (m_cameraBuffer)
if (camera_buffer_)
{
m_cameraBuffer->Release();
m_cameraBuffer = 0;
camera_buffer_->Release();
camera_buffer_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("SunLightShaderClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@ -338,7 +338,7 @@ void SunlightShaderClass::ShutdownShader()
}
void SunlightShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void sunlight_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned __int64 bufferSize, i;
@ -374,13 +374,13 @@ void SunlightShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWN
}
bool SunlightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 ambientColor, XMFLOAT4 diffuseColor, XMFLOAT3 lightDirection, float sunIntensity)
bool sunlight_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 ambientColor, XMFLOAT4 diffuseColor, XMFLOAT3 lightDirection, float sunIntensity)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
CameraBufferType* dataPtr2;
SunLightBufferType* dataPtr3;
matrix_buffer_type* dataPtr;
camera_buffer_type* dataPtr2;
sun_light_buffer_type* dataPtr3;
unsigned int bufferNumber;
// Transpose the matrices to prepare them for the shader.
@ -389,14 +389,14 @@ bool SunlightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@ -404,38 +404,38 @@ bool SunlightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Lock the sunlight constant buffer so it can be written to.
result = deviceContext->Map(m_sunlightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(sunlight_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr3 = (SunLightBufferType*)mappedResource.pData;
dataPtr3 = (sun_light_buffer_type*)mappedResource.pData;
// Copy the lighting variables into the constant buffer.
dataPtr3->ambientColor = ambientColor;
dataPtr3->diffuseColor = diffuseColor;
dataPtr3->sunDirection = lightDirection;
dataPtr3->ambient_color = ambientColor;
dataPtr3->diffuse_color = diffuseColor;
dataPtr3->sun_direction = lightDirection;
dataPtr3->intensity = sunIntensity;
// Unlock the constant buffer.
deviceContext->Unmap(m_sunlightBuffer, 0);
deviceContext->Unmap(sunlight_buffer_, 0);
// Set the position of the sunlight constant buffer in the pixel shader.
bufferNumber = 0;
// Finally set the sunlight constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_sunlightBuffer);
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &sunlight_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
@ -443,19 +443,19 @@ bool SunlightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
return true;
}
void SunlightShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void sunlight_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@ -1,27 +1,27 @@
#include "textureshaderclass.h"
#include "texture_shader_class.h"
TextureShaderClass::TextureShaderClass()
texture_shader_class::texture_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
}
TextureShaderClass::TextureShaderClass(const TextureShaderClass& other)
texture_shader_class::texture_shader_class(const texture_shader_class& other)
{
}
TextureShaderClass::~TextureShaderClass()
texture_shader_class::~texture_shader_class()
{
}
bool TextureShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool texture_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing texture shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -45,8 +45,8 @@ bool TextureShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -58,22 +58,22 @@ bool TextureShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return true;
}
void TextureShaderClass::Shutdown()
void texture_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool TextureShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool texture_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture);
if (!result)
{
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -81,12 +81,12 @@ bool TextureShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCou
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool texture_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -100,7 +100,7 @@ bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
D3D11_SAMPLER_DESC samplerDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@ -112,7 +112,7 @@ bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@ -131,7 +131,7 @@ bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@ -143,7 +143,7 @@ bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -151,7 +151,7 @@ bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -180,7 +180,7 @@ bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -196,14 +196,14 @@ bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -225,7 +225,7 @@ bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Error creating sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -237,43 +237,43 @@ bool TextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR
return true;
}
void TextureShaderClass::ShutdownShader()
void texture_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("Shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@ -281,7 +281,7 @@ void TextureShaderClass::ShutdownShader()
return;
}
void TextureShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void texture_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@ -316,12 +316,12 @@ void TextureShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND
return;
}
bool TextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool texture_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
@ -331,7 +331,7 @@ bool TextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext,
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -339,7 +339,7 @@ bool TextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext,
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@ -347,31 +347,31 @@ bool TextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext,
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finanly set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
return true;
}
void TextureShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void texture_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the triangle.
// render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@ -1,30 +1,30 @@
#include "translateshaderclass.h"
#include "translate_shader_class.h"
TranslateShaderClass::TranslateShaderClass()
translate_shader_class::translate_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
m_translateBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
translate_buffer_ = 0;
}
TranslateShaderClass::TranslateShaderClass(const TranslateShaderClass& other)
translate_shader_class::translate_shader_class(const translate_shader_class& other)
{
}
TranslateShaderClass::~TranslateShaderClass()
translate_shader_class::~translate_shader_class()
{
}
bool TranslateShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool translate_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initilaizing TranslateShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Initilaizing translate_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
wchar_t vsFilename[128];
@ -47,36 +47,36 @@ bool TranslateShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Failed to initialize shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("TranslateShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("translate_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void TranslateShaderClass::Shutdown()
void translate_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool TranslateShaderClass::Render(ID3D11DeviceContext * deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool translate_shader_class::render(ID3D11DeviceContext * deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView * texture, float translation)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, translation);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, translation);
if (!result)
{
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -84,13 +84,13 @@ bool TranslateShaderClass::Render(ID3D11DeviceContext * deviceContext, int index
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WCHAR * vsFilename, WCHAR * psFilename)
bool translate_shader_class::initialize_shader(ID3D11Device * device, HWND hwnd, WCHAR * vsFilename, WCHAR * psFilename)
{
Logger::Get().Log("Initializing translate shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -105,7 +105,7 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
D3D11_BUFFER_DESC translateBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@ -118,7 +118,7 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@ -137,7 +137,7 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@ -149,7 +149,7 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -157,7 +157,7 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -186,7 +186,7 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -202,14 +202,14 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -232,7 +232,7 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -241,14 +241,14 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
// Setup the description of the texture translation dynamic constant buffer that is in the pixel shader.
translateBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
translateBufferDesc.ByteWidth = sizeof(TranslateBufferType);
translateBufferDesc.ByteWidth = sizeof(translate_buffer_type);
translateBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
translateBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
translateBufferDesc.MiscFlags = 0;
translateBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the pixel shader constant buffer from within this class.
result = device->CreateBuffer(&translateBufferDesc, NULL, &m_translateBuffer);
result = device->CreateBuffer(&translateBufferDesc, NULL, &translate_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create translate buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -261,50 +261,50 @@ bool TranslateShaderClass::InitializeShader(ID3D11Device * device, HWND hwnd, WC
}
void TranslateShaderClass::ShutdownShader()
void translate_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down translate shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the texture translation constant buffer.
if (m_translateBuffer)
if (translate_buffer_)
{
m_translateBuffer->Release();
m_translateBuffer = 0;
translate_buffer_->Release();
translate_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("Translate shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@ -313,7 +313,7 @@ void TranslateShaderClass::ShutdownShader()
}
void TranslateShaderClass::OutputShaderErrorMessage(ID3D10Blob * errorMessage, HWND hwnd, WCHAR * shaderFilename)
void translate_shader_class::output_shader_error_message(ID3D10Blob * errorMessage, HWND hwnd, WCHAR * shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@ -349,14 +349,14 @@ void TranslateShaderClass::OutputShaderErrorMessage(ID3D10Blob * errorMessage, H
}
bool TranslateShaderClass::SetShaderParameters(ID3D11DeviceContext * deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool translate_shader_class::set_shader_parameters(ID3D11DeviceContext * deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView * texture, float translation)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
TranslateBufferType* dataPtr2;
translate_buffer_type* dataPtr2;
// Transpose the matrices to prepare them for the shader.
@ -365,7 +365,7 @@ bool TranslateShaderClass::SetShaderParameters(ID3D11DeviceContext * deviceConte
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -373,7 +373,7 @@ bool TranslateShaderClass::SetShaderParameters(ID3D11DeviceContext * deviceConte
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@ -381,19 +381,19 @@ bool TranslateShaderClass::SetShaderParameters(ID3D11DeviceContext * deviceConte
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
// Lock the texture translation constant buffer so it can be written to.
result = deviceContext->Map(m_translateBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(translate_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map translate buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -401,37 +401,37 @@ bool TranslateShaderClass::SetShaderParameters(ID3D11DeviceContext * deviceConte
}
// Get a pointer to the data in the texture translation constant buffer.
dataPtr2 = (TranslateBufferType*)mappedResource.pData;
dataPtr2 = (translate_buffer_type*)mappedResource.pData;
// Copy the translation value into the texture translation constant buffer.
dataPtr2->translation = translation;
// Unlock the buffer.
deviceContext->Unmap(m_translateBuffer, 0);
deviceContext->Unmap(translate_buffer_, 0);
// Set the position of the texture translation constant buffer in the pixel shader.
bufferNumber = 0;
// Now set the texture translation constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_translateBuffer);
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &translate_buffer_);
return true;
}
void TranslateShaderClass::RenderShader(ID3D11DeviceContext * deviceContext, int indexCount)
void translate_shader_class::render_shader(ID3D11DeviceContext * deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the geometry.
// render the geometry.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@ -1,30 +1,30 @@
#include "transparentshaderclass.h"
#include "transparent_shader_class.h"
TransparentShaderClass::TransparentShaderClass()
transparent_shader_class::transparent_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_matrixBuffer = 0;
m_sampleState = 0;
m_transparentBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
matrix_buffer_ = 0;
sample_state_ = 0;
transparent_buffer_ = 0;
}
TransparentShaderClass::TransparentShaderClass(const TransparentShaderClass& other)
transparent_shader_class::transparent_shader_class(const transparent_shader_class& other)
{
}
TransparentShaderClass::~TransparentShaderClass()
transparent_shader_class::~transparent_shader_class()
{
}
bool TransparentShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool transparent_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing TransparentShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Initializing transparent_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
wchar_t vsFilename[128];
@ -47,36 +47,36 @@ bool TransparentShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Failed to initialize shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("TransparentShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("transparent_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void TransparentShaderClass::Shutdown()
void transparent_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool TransparentShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool transparent_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, float blend)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, blend);
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, blend);
if (!result)
{
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -84,13 +84,13 @@ bool TransparentShaderClass::Render(ID3D11DeviceContext* deviceContext, int inde
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool transparent_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing transparent shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -105,7 +105,7 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
D3D11_BUFFER_DESC transparentBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@ -118,7 +118,7 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@ -137,7 +137,7 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@ -149,7 +149,7 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -157,7 +157,7 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -186,7 +186,7 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -202,14 +202,14 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -232,7 +232,7 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -241,14 +241,14 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
// Setup the description of the transparent dynamic constant buffer that is in the pixel shader.
transparentBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
transparentBufferDesc.ByteWidth = sizeof(TransparentBufferType);
transparentBufferDesc.ByteWidth = sizeof(transparent_buffer_type);
transparentBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
transparentBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
transparentBufferDesc.MiscFlags = 0;
transparentBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the pixel shader constant buffer from within this class.
result = device->CreateBuffer(&transparentBufferDesc, NULL, &m_transparentBuffer);
result = device->CreateBuffer(&transparentBufferDesc, NULL, &transparent_buffer_);
if (FAILED(result))
{
Logger::Get().Log("Failed to create transparent buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -261,50 +261,50 @@ bool TransparentShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, W
}
void TransparentShaderClass::ShutdownShader()
void transparent_shader_class::shutdown_shader()
{
Logger::Get().Log("Shutting down transparent shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the transparent constant buffer.
if (m_transparentBuffer)
if (transparent_buffer_)
{
m_transparentBuffer->Release();
m_transparentBuffer = 0;
transparent_buffer_->Release();
transparent_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
Logger::Get().Log("Transparent shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
@ -313,7 +313,7 @@ void TransparentShaderClass::ShutdownShader()
}
void TransparentShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void transparent_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@ -348,14 +348,14 @@ void TransparentShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage,
return;
}
bool TransparentShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
bool transparent_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, float blend)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
TransparentBufferType* dataPtr2;
transparent_buffer_type* dataPtr2;
// Transpose the matrices to prepare them for the shader.
@ -364,7 +364,7 @@ bool TransparentShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceCont
projectionMatrix = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -372,7 +372,7 @@ bool TransparentShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceCont
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@ -380,19 +380,19 @@ bool TransparentShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceCont
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
// Lock the transparent constant buffer so it can be written to.
result = deviceContext->Map(m_transparentBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(transparent_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map transparent buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
@ -400,37 +400,37 @@ bool TransparentShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceCont
}
// Get a pointer to the data in the transparent constant buffer.
dataPtr2 = (TransparentBufferType*)mappedResource.pData;
dataPtr2 = (transparent_buffer_type*)mappedResource.pData;
// Copy the alpha blending value into the transparent constant buffer.
dataPtr2->blendAmount = blend;
dataPtr2->blend_amount = blend;
// Unlock the buffer.
deviceContext->Unmap(m_transparentBuffer, 0);
deviceContext->Unmap(transparent_buffer_, 0);
// Set the position of the transparent constant buffer in the pixel shader.
bufferNumber = 0;
// Now set the transparent constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_transparentBuffer);
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &transparent_buffer_);
return true;
}
void TransparentShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void transparent_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render the geometry.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the geometry.
// render the geometry.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@ -1,29 +1,29 @@
#include "watershaderclass.h"
#include "water_shader_class.h"
WaterShaderClass::WaterShaderClass()
water_shader_class::water_shader_class()
{
m_vertexShader = 0;
m_pixelShader = 0;
m_layout = 0;
m_sampleState = 0;
m_matrixBuffer = 0;
m_reflectionBuffer = 0;
m_waterBuffer = 0;
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
sample_state_ = 0;
matrix_buffer_ = 0;
reflection_buffer_ = 0;
water_buffer_ = 0;
}
WaterShaderClass::WaterShaderClass(const WaterShaderClass& other)
water_shader_class::water_shader_class(const water_shader_class& other)
{
}
WaterShaderClass::~WaterShaderClass()
water_shader_class::~water_shader_class()
{
}
bool WaterShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool water_shader_class::initialize(ID3D11Device* device, HWND hwnd)
{
bool result;
wchar_t vsFilename[128];
@ -44,8 +44,8 @@ bool WaterShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
return false;
@ -55,15 +55,15 @@ bool WaterShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
}
void WaterShaderClass::Shutdown()
void water_shader_class::shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}
bool WaterShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
bool water_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
XMMATRIX reflectionMatrix, ID3D11ShaderResourceView* reflectionTexture, ID3D11ShaderResourceView* refractionTexture,
ID3D11ShaderResourceView* normalTexture, float waterTranslation, float reflectRefractScale)
{
@ -71,7 +71,7 @@ bool WaterShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, reflectionMatrix, reflectionTexture,
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, reflectionMatrix, reflectionTexture,
refractionTexture, normalTexture, waterTranslation, reflectRefractScale);
if (!result)
{
@ -79,13 +79,13 @@ bool WaterShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
render_shader(deviceContext, indexCount);
return true;
}
bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool water_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
HRESULT result;
ID3D10Blob* errorMessage;
@ -99,7 +99,7 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
D3D11_BUFFER_DESC waterBufferDesc;
// Initialize the pointers this function will use to null.
// initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
@ -112,7 +112,7 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
output_shader_error_message(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
@ -131,7 +131,7 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// If the shader failed to compile it should have writen something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
output_shader_error_message(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
@ -143,14 +143,14 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
if (FAILED(result))
{
return false;
}
// Create the pixel shader from the buffer.
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
if (FAILED(result))
{
return false;
@ -178,7 +178,7 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
vertexShaderBuffer->GetBufferSize(), &layout_);
if (FAILED(result))
{
return false;
@ -193,14 +193,14 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
if (FAILED(result))
{
return false;
@ -222,7 +222,7 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
if (FAILED(result))
{
return false;
@ -230,14 +230,14 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Setup the description of the reflection dynamic constant buffer that is in the vertex shader.
reflectionBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
reflectionBufferDesc.ByteWidth = sizeof(ReflectionBufferType);
reflectionBufferDesc.ByteWidth = sizeof(reflection_buffer_type);
reflectionBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
reflectionBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
reflectionBufferDesc.MiscFlags = 0;
reflectionBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = device->CreateBuffer(&reflectionBufferDesc, NULL, &m_reflectionBuffer);
result = device->CreateBuffer(&reflectionBufferDesc, NULL, &reflection_buffer_);
if (FAILED(result))
{
return false;
@ -245,14 +245,14 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
// Setup the description of the water dynamic constant buffer that is in the pixel shader.
waterBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
waterBufferDesc.ByteWidth = sizeof(WaterBufferType);
waterBufferDesc.ByteWidth = sizeof(water_buffer_type);
waterBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
waterBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
waterBufferDesc.MiscFlags = 0;
waterBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the pixel shader constant buffer from within this class.
result = device->CreateBuffer(&waterBufferDesc, NULL, &m_waterBuffer);
result = device->CreateBuffer(&waterBufferDesc, NULL, &water_buffer_);
if (FAILED(result))
{
return false;
@ -262,62 +262,62 @@ bool WaterShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
}
void WaterShaderClass::ShutdownShader()
void water_shader_class::shutdown_shader()
{
// Release the water constant buffer.
if (m_waterBuffer)
if (water_buffer_)
{
m_waterBuffer->Release();
m_waterBuffer = 0;
water_buffer_->Release();
water_buffer_ = 0;
}
// Release the reflection constant buffer.
if (m_reflectionBuffer)
if (reflection_buffer_)
{
m_reflectionBuffer->Release();
m_reflectionBuffer = 0;
reflection_buffer_->Release();
reflection_buffer_ = 0;
}
// Release the sampler state.
if (m_sampleState)
if (sample_state_)
{
m_sampleState->Release();
m_sampleState = 0;
sample_state_->Release();
sample_state_ = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
if (matrix_buffer_)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
matrix_buffer_->Release();
matrix_buffer_ = 0;
}
// Release the layout.
if (m_layout)
if (layout_)
{
m_layout->Release();
m_layout = 0;
layout_->Release();
layout_ = 0;
}
// Release the pixel shader.
if (m_pixelShader)
if (pixel_shader_)
{
m_pixelShader->Release();
m_pixelShader = 0;
pixel_shader_->Release();
pixel_shader_ = 0;
}
// Release the vertex shader.
if (m_vertexShader)
if (vertex_shader_)
{
m_vertexShader->Release();
m_vertexShader = 0;
vertex_shader_->Release();
vertex_shader_ = 0;
}
return;
}
void WaterShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void water_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned long long bufferSize, i;
@ -352,16 +352,16 @@ void WaterShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND h
return;
}
bool WaterShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, XMMATRIX reflectionMatrix,
bool water_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, XMMATRIX reflectionMatrix,
ID3D11ShaderResourceView* reflectionTexture, ID3D11ShaderResourceView* refractionTexture, ID3D11ShaderResourceView* normalTexture,
float waterTranslation, float reflectRefractScale)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
matrix_buffer_type* dataPtr;
unsigned int bufferNumber;
ReflectionBufferType* dataPtr2;
WaterBufferType* dataPtr3;
reflection_buffer_type* dataPtr2;
water_buffer_type* dataPtr3;
// Transpose the matrices to prepare them for the shader.
worldMatrix = XMMatrixTranspose(worldMatrix);
@ -370,14 +370,14 @@ bool WaterShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
reflectionMatrix = XMMatrixTranspose(reflectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr = (matrix_buffer_type*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
@ -385,35 +385,35 @@ bool WaterShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer, 0);
deviceContext->Unmap(matrix_buffer_, 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finanly set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
// Lock the reflection constant buffer so it can be written to.
result = deviceContext->Map(m_reflectionBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(reflection_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr2 = (ReflectionBufferType*)mappedResource.pData;
dataPtr2 = (reflection_buffer_type*)mappedResource.pData;
// Copy the reflection matrix into the constant buffer.
dataPtr2->reflection = reflectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_reflectionBuffer, 0);
deviceContext->Unmap(reflection_buffer_, 0);
// Set the position of the reflection constant buffer in the vertex shader.
bufferNumber = 1;
// Finally set the reflection constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_reflectionBuffer);
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &reflection_buffer_);
// Set the reflection texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &reflectionTexture);
@ -425,45 +425,45 @@ bool WaterShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
deviceContext->PSSetShaderResources(2, 1, &normalTexture);
// Lock the water constant buffer so it can be written to.
result = deviceContext->Map(m_waterBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
result = deviceContext->Map(water_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr3 = (WaterBufferType*)mappedResource.pData;
dataPtr3 = (water_buffer_type*)mappedResource.pData;
// Copy the water data into the constant buffer.
dataPtr3->waterTranslation = waterTranslation;
dataPtr3->reflectRefractScale = reflectRefractScale;
dataPtr3->water_translation = waterTranslation;
dataPtr3->reflect_refract_scale = reflectRefractScale;
dataPtr3->padding = XMFLOAT2(0.0f, 0.0f);
// Unlock the constant buffer.
deviceContext->Unmap(m_waterBuffer, 0);
deviceContext->Unmap(water_buffer_, 0);
// Set the position of the water constant buffer in the pixel shader.
bufferNumber = 0;
// Finally set the water constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_waterBuffer);
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &water_buffer_);
return true;
}
void WaterShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void water_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);
deviceContext->IASetInputLayout(layout_);
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
deviceContext->PSSetSamplers(0, 1, &sample_state_);
// Render the geometry.
// render the geometry.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;

View File

@ -1,9 +1,9 @@
#include "systemclass.h"
#include "system_class.h"
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow)
{
SystemClass* System;
system_class* System;
bool result;
wchar_t path[MAX_PATH];
@ -17,19 +17,19 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline,
std::filesystem::path WFolder = exePath.parent_path();
// Create the system object.
System = new SystemClass;
System = new system_class;
// Initialize and run the system object.
result = System->Initialize();
// initialize and run the system object.
result = System->initialize();
if (result)
{
Logger::Get().Log("System initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
System->SendPath(path,WFolder);
System->Run();
System->send_path(path,WFolder);
System->run();
}
// Shutdown and release the system object.
System->Shutdown();
// shutdown and release the system object.
System->shutdown();
delete System;
System = 0;

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