1 Commits

Author SHA1 Message Date
cabf9b39d8 Load Texture Rework Needed 2024-09-27 17:06:02 +02:00
1411 changed files with 805438 additions and 769223 deletions

2
.gitattributes vendored
View File

@@ -1,2 +0,0 @@
enginecustom/assets/Model/OBJ/*.obj filter=lfs diff=lfs merge=lfs -text
enginecustom/assets/Model/OBJ/*.mtl filter=lfs diff=lfs merge=lfs -text

8
.gitignore vendored
View File

@@ -9,6 +9,14 @@
*.slo
*.lo
*.o
*.obj
# Don't ignore 3d model in OBJ
!enginecustom/monke.obj
!enginecustom/isosphere.obj
!enginecustom/cone.obj
!enginecustom/vaisseau.obj
!enginecustom/86.obj
# Precompiled Headers
*.gch

View File

@@ -1 +0,0 @@
KhaoticEngineReborn

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidProjectSystem">
<option name="providerId" value="RiderAndroidProjectSystem" />
</component>
</project>

View File

@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="PROJECT_FILES" />
<option name="description" value="" />
<option name="applicationTheme" value="default" />
<option name="iconsTheme" value="default" />
<option name="button1Title" value="" />
<option name="button1Url" value="" />
<option name="button2Title" value="" />
<option name="button2Url" value="" />
<option name="customApplicationId" value="" />
</component>
</project>

View File

@@ -1,8 +0,0 @@
<?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/imguiManager.cpp" charset="windows-1252" />
<file url="PROJECT" charset="windows-1252" />
</component>
</project>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxBlameSettings">
<option name="version" value="2" />
</component>
</project>

View File

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxProjectSettings">
<option name="commitMessageIssueKeyValidationOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
<option name="commitMessageValidationEnabledOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
</component>
</project>

View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View File

@@ -1,6 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="ReassignedToPlainText" enabled="false" level="WARNING" enabled_by_default="false" />
</profile>
</component>

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MaterialThemeProjectNewConfig">
<option name="metadata">
<MTProjectMetadataState>
<option name="migrated" value="true" />
<option name="pristineConfig" value="false" />
<option name="userId" value="4025287c:194ad69ad19:-7ff7" />
</MTProjectMetadataState>
</option>
</component>
</project>

View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RiderProjectSettingsUpdater">
<option name="singleClickDiffPreview" value="1" />
<option name="unhandledExceptionsIgnoreList" value="1" />
<option name="vcsConfiguration" value="3" />
</component>
</project>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@@ -1,386 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="">
<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/inc/system/imguiManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/imguiManager.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/modelclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/modelclass.h" 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/src/src/system/modelclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/modelclass.cpp" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="DpaMonitoringSettings">
<option name="firstShow" value="false" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="HighlightingSettingsPerFile">
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="file://C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um/d3d11.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="MetaFilesCheckinStateConfiguration" checkMetaFiles="true" />
<component name="ProblemsViewState">
<option name="selectedTabId" value="CurrentFile" />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 6
}</component>
<component name="ProjectId" id="2sGIWDeT5ixyzDQ0he4A3RFpG9W" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;ASKED_SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;C++ Project.enginecustom.executor&quot;: &quot;Run&quot;,
&quot;C/C++ Project.enginecustom.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&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;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}</component>
<component name="RunManager" selected="C/C++ Project.enginecustom">
<configuration name="KhaoticDemo" type="CppProject" factoryName="C++ Project">
<configuration_1 setup="1">
<option name="CONFIGURATION" value="Debug" />
<option name="PLATFORM" value="x64" />
<option name="CURRENT_LAUNCH_PROFILE" value="Local" />
<option name="EXE_PATH" value="$(LocalDebuggerCommand)" />
<option name="PROGRAM_PARAMETERS" value="$(LocalDebuggerCommandArguments)" />
<option name="WORKING_DIRECTORY" value="$(LocalDebuggerWorkingDirectory)" />
<option name="PASS_PARENT_ENVS" value="1" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<option name="TERMINAL_INTERACTION_BEHAVIOR" value="AUTO_DETECT" />
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/KhaoticDemo/KhaoticDemo.vcxproj" />
</configuration_1>
<option name="DEFAULT_PROJECT_PATH" value="$PROJECT_DIR$/KhaoticDemo/KhaoticDemo.vcxproj" />
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/KhaoticDemo/KhaoticDemo.vcxproj" />
<option name="AUTO_SELECT_PRIORITY" value="0" />
<method v="2">
<option name="Build" />
</method>
</configuration>
<configuration name="enginecustom" type="CppProject" factoryName="C++ Project">
<configuration_1 setup="1">
<option name="CONFIGURATION" value="Debug" />
<option name="PLATFORM" value="x64" />
<option name="CURRENT_LAUNCH_PROFILE" value="Local" />
<option name="EXE_PATH" value="$(LocalDebuggerCommand)" />
<option name="PROGRAM_PARAMETERS" value="$(LocalDebuggerCommandArguments)" />
<option name="WORKING_DIRECTORY" value="$(LocalDebuggerWorkingDirectory)" />
<option name="PASS_PARENT_ENVS" value="1" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<option name="TERMINAL_INTERACTION_BEHAVIOR" value="AUTO_DETECT" />
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
</configuration_1>
<configuration_2 setup="1">
<option name="CONFIGURATION" value="Release" />
<option name="PLATFORM" value="x64" />
<option name="CURRENT_LAUNCH_PROFILE" value="Local" />
<option name="EXE_PATH" value="$(TargetPath)" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="$(ProjectDir)" />
<option name="PASS_PARENT_ENVS" value="1" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<option name="TERMINAL_INTERACTION_BEHAVIOR" value="AUTO_DETECT" />
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
</configuration_2>
<option name="DEFAULT_PROJECT_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
<option name="AUTO_SELECT_PRIORITY" value="0" />
<method v="2">
<option name="Build" />
</method>
</configuration>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="" />
<created>1738075515913</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1738075515913</updated>
<workItem from="1738075517746" duration="553000" />
<workItem from="1738076088229" duration="80000" />
<workItem from="1738076192788" duration="19000" />
<workItem from="1738076222547" duration="6131000" />
<workItem from="1738171504772" duration="876000" />
<workItem from="1738172392786" duration="67000" />
<workItem from="1738173151768" duration="2361000" />
<workItem from="1738175535254" duration="279000" />
<workItem from="1738178991872" duration="2736000" />
<workItem from="1738244577624" duration="3000" />
<workItem from="1738321399968" duration="689000" />
<workItem from="1738358054789" duration="9000" />
<workItem from="1738358091089" duration="6675000" />
<workItem from="1738364887298" duration="2275000" />
<workItem from="1738515031789" duration="14018000" />
<workItem from="1741705445392" duration="138000" />
<workItem from="1741706018301" duration="5499000" />
<workItem from="1742198713923" duration="31000" />
<workItem from="1742198792655" duration="4618000" />
<workItem from="1742203643675" duration="600000" />
<workItem from="1742206836574" duration="258000" />
<workItem from="1742207107802" duration="5340000" />
<workItem from="1742228751298" duration="38000" />
<workItem from="1742228870107" duration="1198000" />
<workItem from="1742314944369" duration="79000" />
<workItem from="1742318452773" duration="2258000" />
<workItem from="1742331065936" duration="3030000" />
<workItem from="1742371397157" duration="13355000" />
<workItem from="1742425863119" duration="231000" />
<workItem from="1742474596806" duration="67000" />
<workItem from="1742474683111" duration="689000" />
<workItem from="1742574318953" duration="552000" />
<workItem from="1742581210996" duration="681000" />
<workItem from="1742651501885" duration="47000" />
<workItem from="1742664377329" duration="746000" />
<workItem from="1742665243312" duration="310000" />
<workItem from="1742667326806" duration="95000" />
<workItem from="1743185728805" duration="15000" />
<workItem from="1743185754182" duration="815000" />
<workItem from="1743355100472" duration="708000" />
<workItem from="1743355837694" duration="1514000" />
<workItem from="1743370106270" duration="901000" />
<workItem from="1743505399891" duration="2361000" />
<workItem from="1746106963725" duration="5888000" />
<workItem from="1746112904421" duration="75000" />
<workItem from="1746113092234" duration="1477000" />
<workItem from="1746117455914" duration="5976000" />
<workItem from="1746126812110" duration="180000" />
<workItem from="1746188920194" duration="1870000" />
<workItem from="1746274246641" duration="89000" />
<workItem from="1746274352144" duration="8039000" />
<workItem from="1746444660572" duration="7742000" />
<workItem from="1746456965664" duration="13000" />
<workItem from="1746469494034" duration="799000" />
<workItem from="1746526901276" duration="2023000" />
<workItem from="1746536290167" duration="1908000" />
<workItem from="1746538260893" duration="5781000" />
<workItem from="1746546014271" duration="1814000" />
<workItem from="1746619988287" duration="12282000" />
<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" />
</task>
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
<option name="closed" value="true" />
<created>1738175474520</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1738175474520</updated>
</task>
<task id="LOCAL-00002" summary="Patch update - add menu button">
<option name="closed" value="true" />
<created>1738181617050</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1738181617050</updated>
</task>
<option name="localTasksCounter" value="3" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="UnityCheckinConfiguration" checkUnsavedScenes="true" />
<component name="UnityProjectConfiguration" hasMinimizedUI="false" />
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
<MESSAGE value="Minor update - viewport window tweak" />
<MESSAGE value="Patch update - add menu button" />
<option name="LAST_COMMIT_MESSAGE" value="Patch update - add menu button" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
<properties exception="System.OperationCanceledException" breakIfHandledByOtherCode="false" displayValue="System.OperationCanceledException" />
<option name="timeStamp" value="1" />
</breakpoint>
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
<properties exception="System.Threading.Tasks.TaskCanceledException" breakIfHandledByOtherCode="false" displayValue="System.Threading.Tasks.TaskCanceledException" />
<option name="timeStamp" value="2" />
</breakpoint>
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
<properties exception="System.Threading.ThreadAbortException" breakIfHandledByOtherCode="false" displayValue="System.Threading.ThreadAbortException" />
<option name="timeStamp" value="3" />
</breakpoint>
</breakpoints>
</breakpoint-manager>
<watches-manager>
<configuration name="CppProject">
<watch expression="((class ModelClass &amp;) (*(*(*this).m_Application).m_object[0]))" />
</configuration>
</watches-manager>
</component>
<component name="XSLT-Support.FileAssociations.UIState">
<expand />
<select />
</component>
</project>

2970
Doxyfile

File diff suppressed because it is too large Load Diff

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** et utilise **ImGui** pour son interface graphique.
Ce moteur est basé sur **DirectX11** utilise **ImGui** avec une couche d'abstraction pour permetre son usage avec d'autres API.
---
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** for the user interface.
This **DirectX11** based engine uses **ImGui** with an abstraction layer to enable its use with other APIs.
## Installation
@@ -35,36 +35,15 @@ This **DirectX11** based engine uses **ImGui** for the user interface.
**SHADER** :
+ Sunlight shader
+ Cel Shading
+ Skysphere
- Cel Shading
**Interface Graphique** :
+ Console link to the Logger object
+ Shader Manager
+ Engine Settings
+ Sunlight Settings
**Save And Load of a Scene** :
+ Save All Custom object
+ Save All Custom Texture for Custom Object
**Texture File** :
+ All the format supported by Windows Imaging Component (WIC)
**Optimization** :
- Shader rendering
- Frustum culling
- Object rendering
- Terrain Instancing
- Shader Manager
## Demo :
[![Demo Video](https://img.youtube.com/vi/qCOCTyB_97c/0.jpg)](https://youtu.be/DYgT1Nu7B4c)
[![Demo Video](https://img.youtube.com/vi/qCOCTyB_97c/0.jpg)](https://www.youtube.com/watch?v=qCOCTyB_97c)
## Engine Build by :

View File

@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "windows-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "gcc",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "windows-gcc-x64",
"compilerArgs": [
""
]
}
],
"version": 4
}

724122
enginecustom/86.obj Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,90 +1,77 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: lightshaderclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "sunlightshaderclass.h"
#include "CelShadingShader.h"
#include <iostream>
SunlightShaderClass::SunlightShaderClass()
CelShadingShader::CelShadingShader()
{
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;
m_sampleState = 0;
m_lightBuffer = 0;
}
SunlightShaderClass::SunlightShaderClass(const SunlightShaderClass& other)
CelShadingShader::CelShadingShader(const CelShadingShader& other)
{
}
SunlightShaderClass::~SunlightShaderClass()
CelShadingShader::~CelShadingShader()
{
}
bool SunlightShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
bool CelShadingShader::Initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Initializing CelShadingShader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
bool result;
wchar_t vsFilename[128];
wchar_t psFilename[128];
int error;
bool result;
// Set the filename of the vertex shader.
error = wcscpy_s(vsFilename, 128, L"src/hlsl/sunlight.vs");
error = wcscpy_s(vsFilename, 128, L"celshading.vs");
if (error != 0)
{
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to set the filename of the vertex shader", __FILE__, __LINE__);
return false;
}
// Set the filename of the pixel shader.
error = wcscpy_s(psFilename, 128, L"src/hlsl/sunlight.ps");
error = wcscpy_s(psFilename, 128, L"celshading.ps");
if (error != 0)
{
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to set the filename of the pixel shader", __FILE__, __LINE__);
return false;
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Failed to initialize shader", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to initialize the vertex and pixel shaders", __FILE__, __LINE__);
return false;
}
Logger::Get().Log("SunLightShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("Successfully initialized CelShadingShader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void SunlightShaderClass::Shutdown()
void CelShadingShader::Shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
return;
}
bool SunlightShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
bool CelShadingShader::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor, XMFLOAT3 lightPosition)
{
bool result;
// Set the shader parameters that it will use for rendering.
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, lightDirection, diffuseColor, lightPosition);
if (!result)
{
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("CelShading Error", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
@@ -94,92 +81,89 @@ bool SunlightShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCo
return true;
}
bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool CelShadingShader::InitializeShader(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;
ID3D10Blob* errorMessage = nullptr;
ID3D10Blob* vertexShaderBuffer = nullptr;
ID3D10Blob* pixelShaderBuffer = nullptr;
D3D11_INPUT_ELEMENT_DESC polygonLayout[3];
unsigned int numElements;
D3D11_SAMPLER_DESC samplerDesc;
D3D11_BUFFER_DESC matrixBufferDesc;
D3D11_BUFFER_DESC sunlightBufferDesc;
// Initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
D3D11_SAMPLER_DESC samplerDesc;
D3D11_BUFFER_DESC lightBufferDesc;
// Compile the vertex shader code.
result = D3DCompileFromFile(vsFilename, NULL, NULL, "SunLightVertexShader", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, &vertexShaderBuffer, &errorMessage);
result = D3DCompileFromFile(vsFilename, nullptr, nullptr, "CelShadingVertexShader", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, &vertexShaderBuffer, &errorMessage);
if (FAILED(result))
{
// If the shader failed to compile it should have written something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(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("Failed to compile shader", __FILE__, __LINE__, Logger::LogLevel::Error);
MessageBox(hwnd, vsFilename, L"Missing Shader File", MB_OK);
}
return false;
}
// Compile the pixel shader code.
result = D3DCompileFromFile(psFilename, NULL, NULL, "SunLightPixelShader", "ps_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, &pixelShaderBuffer, &errorMessage);
result = D3DCompileFromFile(psFilename, nullptr, nullptr, "CelShadingPixelShader", "ps_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, &pixelShaderBuffer, &errorMessage);
if (FAILED(result))
{
// If the shader failed to compile it should have written something to the error message.
if (errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
{
Logger::Get().Log("Failed to compile shader", __FILE__, __LINE__, Logger::LogLevel::Error);
MessageBox(hwnd, psFilename, L"Missing Shader File", MB_OK);
}
return false;
}
// Create the vertex shader from the buffer.
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), nullptr, &m_vertexShader);
if (FAILED(result))
{
Logger::Get().Log("Failed to create vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
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(), nullptr, &m_pixelShader);
if (FAILED(result))
{
Logger::Get().Log("Failed to create pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Create the vertex input layout description.
// This setup needs to match the VertexType structure in the ModelClass and in the shader.
polygonLayout[0].SemanticName = "POSITION";
polygonLayout[0].SemanticIndex = 0;
polygonLayout[0].Format = DXGI_FORMAT_R32G32B32_FLOAT;
polygonLayout[0].Format = DXGI_FORMAT_R32G32B32A32_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].SemanticName = "NORMAL";
polygonLayout[1].SemanticIndex = 0;
polygonLayout[1].Format = DXGI_FORMAT_R32G32_FLOAT;
polygonLayout[1].Format = DXGI_FORMAT_R32G32B32_FLOAT;
polygonLayout[1].InputSlot = 0;
polygonLayout[1].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
polygonLayout[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
polygonLayout[1].InstanceDataStepRate = 0;
polygonLayout[2].SemanticName = "NORMAL";
polygonLayout[2].SemanticName = "TEXCOORD";
polygonLayout[2].SemanticIndex = 0;
polygonLayout[2].Format = DXGI_FORMAT_R32G32B32_FLOAT;
polygonLayout[2].Format = DXGI_FORMAT_R32G32_FLOAT;
polygonLayout[2].InputSlot = 0;
polygonLayout[2].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
polygonLayout[2].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
@@ -192,16 +176,30 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &m_layout);
if (FAILED(result))
{
Logger::Get().Log("Failed to create 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;
vertexShaderBuffer = nullptr;
pixelShaderBuffer->Release();
pixelShaderBuffer = 0;
pixelShaderBuffer = nullptr;
// 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.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, nullptr, &m_matrixBuffer);
if (FAILED(result))
{
return false;
}
// Create a texture sampler state description.
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
@@ -222,128 +220,78 @@ bool SunlightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
if (FAILED(result))
{
Logger::Get().Log("Failed to create sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// 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.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);
if (FAILED(result))
{
Logger::Get().Log("Failed to create matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// 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.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
sunlightBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
sunlightBufferDesc.MiscFlags = 0;
sunlightBufferDesc.StructureByteStride = 0;
// 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.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 pixel shader constant buffer from within this class.
result = device->CreateBuffer(&sunlightBufferDesc, NULL, &m_sunlightBuffer);
result = device->CreateBuffer(&lightBufferDesc, nullptr, &m_lightBuffer);
if (FAILED(result))
{
Logger::Get().Log("Failed to create sunlight buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("Shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void SunlightShaderClass::ShutdownShader()
void CelShadingShader::ShutdownShader()
{
Logger::Get().Log("Shutting down SunLightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the light constant buffers.
if (m_sunlightColorBuffer)
{
m_sunlightColorBuffer->Release();
m_sunlightColorBuffer = 0;
}
if (m_sunlightPositionBuffer)
{
m_sunlightPositionBuffer->Release();
m_sunlightPositionBuffer = 0;
}
// Release the light constant buffer.
if (m_sunlightBuffer)
if (m_lightBuffer)
{
m_sunlightBuffer->Release();
m_sunlightBuffer = 0;
}
// Release the camera constant buffer.
if (m_cameraBuffer)
{
m_cameraBuffer->Release();
m_cameraBuffer = 0;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
{
m_matrixBuffer->Release();
m_matrixBuffer = 0;
m_lightBuffer->Release();
m_lightBuffer = nullptr;
}
// Release the sampler state.
if (m_sampleState)
{
m_sampleState->Release();
m_sampleState = 0;
m_sampleState = nullptr;
}
// Release the matrix constant buffer.
if (m_matrixBuffer)
{
m_matrixBuffer->Release();
m_matrixBuffer = nullptr;
}
// Release the layout.
if (m_layout)
{
m_layout->Release();
m_layout = 0;
m_layout = nullptr;
}
// Release the pixel shader.
if (m_pixelShader)
{
m_pixelShader->Release();
m_pixelShader = 0;
m_pixelShader = nullptr;
}
// Release the vertex shader.
if (m_vertexShader)
{
m_vertexShader->Release();
m_vertexShader = 0;
m_vertexShader = nullptr;
}
}
Logger::Get().Log("SunLightShaderClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
return;
}
void SunlightShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void CelShadingShader::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned __int64 bufferSize, i;
ofstream fout;
unsigned long bufferSize, i;
std::ofstream fout;
// Get a pointer to the error message text buffer.
compileErrors = (char*)(errorMessage->GetBufferPointer());
@@ -365,22 +313,20 @@ void SunlightShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWN
// Release the error message.
errorMessage->Release();
errorMessage = 0;
errorMessage = nullptr;
// 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 SunlightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 ambientColor, XMFLOAT4 diffuseColor, XMFLOAT3 lightDirection, float sunIntensity)
bool CelShadingShader::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor, XMFLOAT3 lightPosition)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
CameraBufferType* dataPtr2;
SunLightBufferType* dataPtr3;
LightBufferType* dataPtr2;
unsigned int bufferNumber;
// Transpose the matrices to prepare them for the shader.
@@ -412,30 +358,32 @@ bool SunlightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
// Lock the sunlight constant buffer so it can be written to.
result = deviceContext->Map(m_sunlightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
// Lock the light constant buffer so it can be written to.
result = deviceContext->Map(m_lightBuffer, 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;
dataPtr2 = (LightBufferType*)mappedResource.pData;
// Copy the lighting variables into the constant buffer.
dataPtr3->ambientColor = ambientColor;
dataPtr3->diffuseColor = diffuseColor;
dataPtr3->sunDirection = lightDirection;
dataPtr3->intensity = sunIntensity;
dataPtr2->diffuseColor = diffuseColor;
dataPtr2->lightDirection = lightDirection;
dataPtr2->lightPosition = lightPosition;
dataPtr2->constantAttenuation = 0.5f; // Set your attenuation values here
dataPtr2->linearAttenuation = 0.1f;
dataPtr2->quadraticAttenuation = 0.01f;
// Unlock the constant buffer.
deviceContext->Unmap(m_sunlightBuffer, 0);
deviceContext->Unmap(m_lightBuffer, 0);
// Set the position of the sunlight constant buffer in the pixel shader.
// Set the position of the light 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);
// Finally set the light constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_lightBuffer);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
@@ -443,20 +391,20 @@ bool SunlightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext
return true;
}
void SunlightShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void CelShadingShader::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_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(m_vertexShader, nullptr, 0);
deviceContext->PSSetShader(m_pixelShader, nullptr, 0);
// Set the sampler state in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
// Render the triangle.
deviceContext->DrawIndexed(indexCount, 0, 0);
return;
}

View File

@@ -0,0 +1,68 @@
#ifndef _CELSHADINGSHADER_H_
#define _CELSHADINGSHADER_H_
//////////////
// INCLUDES //
//////////////
#include "Logger.h"
#include <d3d11.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <fstream>
using namespace DirectX;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
// Class name: CelShadingShader
////////////////////////////////////////////////////////////////////////////////
class CelShadingShader
{
private:
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
};
struct LightBufferType
{
XMFLOAT4 diffuseColor;
XMFLOAT3 lightDirection;
float padding; // Padding to ensure the structure is a multiple of 16 bytes.
XMFLOAT3 lightPosition; // Add light position
float padding2; // Padding to ensure the structure is a multiple of 16 bytes.
float constantAttenuation;
float linearAttenuation;
float quadraticAttenuation;
float padding3; // Padding to ensure the structure is a multiple of 16 bytes.
};
public:
CelShadingShader();
CelShadingShader(const CelShadingShader&);
~CelShadingShader();
bool Initialize(ID3D11Device*, HWND);
void Shutdown();
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4, XMFLOAT3);
private:
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
void ShutdownShader();
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4, XMFLOAT3);
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

@@ -32,7 +32,7 @@ bool ColorShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
// Set the filename of the vertex shader.
error = wcscpy_s(vsFilename, 128, L"src/hlsl/Color.vs");
error = wcscpy_s(vsFilename, 128, L"../enginecustom/Color.vs");
if (error != 0)
{
Logger::Get().Log("Error copying string", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -40,7 +40,7 @@ bool ColorShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
}
// Set the filename of the pixel shader.
error = wcscpy_s(psFilename, 128, L"src/hlsl/Color.ps");
error = wcscpy_s(psFilename, 128, L"../enginecustom/Color.ps");
if (error != 0)
{
Logger::Get().Log("Error copying string", __FILE__, __LINE__, Logger::LogLevel::Error);

49
enginecustom/Lightclass.h Normal file
View File

@@ -0,0 +1,49 @@
#pragma once
////////////////////////////////////////////////////////////////////////////////
// Filename: lightclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _LIGHTCLASS_H_
#define _LIGHTCLASS_H_
//////////////
// INCLUDES //
//////////////
#include <directxmath.h>
using namespace DirectX;
////////////////////////////////////////////////////////////////////////////////
// Class name: LightClass
////////////////////////////////////////////////////////////////////////////////
class LightClass
{
public:
LightClass();
LightClass(const LightClass&);
~LightClass();
void SetAmbientColor(float, float, float, float);
void SetDiffuseColor(float, float, float, float);
void SetDirection(float, float, float);
void SetSpecularColor(float, float, float, float);
void SetSpecularPower(float);
void SetPosition(float, float, float);
XMFLOAT4 GetAmbientColor();
XMFLOAT4 GetDiffuseColor();
XMFLOAT3 GetDirection();
XMFLOAT4 GetSpecularColor();
float GetSpecularPower();
XMFLOAT4 GetPosition();
private:
XMFLOAT4 m_ambientColor;
XMFLOAT4 m_diffuseColor;
XMFLOAT3 m_direction;
XMFLOAT4 m_specularColor;
float m_specularPower;
XMFLOAT4 m_position;
};
#endif

View File

@@ -1,10 +1,10 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: lightshaderclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "CelShadingShader.h"
#include "lightshaderclass.h"
CelshadeClass::CelshadeClass()
LightShaderClass::LightShaderClass()
{
m_vertexShader = 0;
m_pixelShader = 0;
@@ -12,23 +12,23 @@ CelshadeClass::CelshadeClass()
m_sampleState = 0;
m_matrixBuffer = 0;
m_cameraBuffer = 0;
m_sunlightBuffer = 0;
m_sunlightColorBuffer = 0;
m_sunlightPositionBuffer = 0;
m_lightBuffer = 0;
m_lightColorBuffer = 0;
m_lightPositionBuffer = 0;
}
CelshadeClass::CelshadeClass(const CelshadeClass& other)
LightShaderClass::LightShaderClass(const LightShaderClass& other)
{
}
CelshadeClass::~CelshadeClass()
LightShaderClass::~LightShaderClass()
{
}
bool CelshadeClass::Initialize(ID3D11Device* device, HWND hwnd)
bool LightShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
{
Logger::Get().Log("Initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -38,7 +38,7 @@ bool CelshadeClass::Initialize(ID3D11Device* device, HWND hwnd)
bool result;
// Set the filename of the vertex shader.
error = wcscpy_s(vsFilename, 128, L"src/hlsl/celshading.vs");
error = wcscpy_s(vsFilename, 128, L"light.vs");
if (error != 0)
{
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -46,7 +46,7 @@ bool CelshadeClass::Initialize(ID3D11Device* device, HWND hwnd)
}
// Set the filename of the pixel shader.
error = wcscpy_s(psFilename, 128, L"src/hlsl/celshading.ps");
error = wcscpy_s(psFilename, 128, L"light.ps");
if (error != 0)
{
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -60,13 +60,13 @@ bool CelshadeClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
Logger::Get().Log("SunLightShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
Logger::Get().Log("LightShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
void CelshadeClass::Shutdown()
void LightShaderClass::Shutdown()
{
// Shutdown the vertex and pixel shaders as well as the related objects.
ShutdownShader();
@@ -74,14 +74,14 @@ void CelshadeClass::Shutdown()
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 LightShaderClass::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, ambientColor, sunDirection, sunIntensity);
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, lightPosition, ambientClor);
if(!result)
{
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -95,7 +95,7 @@ bool CelshadeClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, X
}
bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -107,7 +107,10 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
unsigned int numElements;
D3D11_SAMPLER_DESC samplerDesc;
D3D11_BUFFER_DESC matrixBufferDesc;
D3D11_BUFFER_DESC sunlightBufferDesc;
D3D11_BUFFER_DESC cameraBufferDesc;
D3D11_BUFFER_DESC lightColorBufferDesc;
D3D11_BUFFER_DESC lightPositionBufferDesc;
// Initialize the pointers this function will use to null.
errorMessage = 0;
@@ -115,32 +118,38 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
pixelShaderBuffer = 0;
// Compile the vertex shader code.
result = D3DCompileFromFile(vsFilename, NULL, NULL, "SunLightVertexShader", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, &vertexShaderBuffer, &errorMessage);
result = D3DCompileFromFile(vsFilename, NULL, NULL, "LightVertexShader", "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)
{
OutputShaderErrorMessage(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("Failed to compile shader", __FILE__, __LINE__, Logger::LogLevel::Error);
}
return false;
}
// Compile the pixel shader code.
result = D3DCompileFromFile(psFilename, NULL, NULL, "SunLightPixelShader", "ps_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, &pixelShaderBuffer, &errorMessage);
result = D3DCompileFromFile(psFilename, NULL, NULL, "LightPixelShader", "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)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
{
Logger::Get().Log("Failed to compile shader", __FILE__, __LINE__, Logger::LogLevel::Error);
}
return false;
}
@@ -161,6 +170,7 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
}
// 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;
@@ -189,7 +199,8 @@ 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(),
&m_layout);
if (FAILED(result))
{
Logger::Get().Log("Failed to create input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -242,19 +253,53 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
return false;
}
// 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.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);
// 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.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);
if (FAILED(result))
{
Logger::Get().Log("Failed to create sunlight buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to create camera buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Setup the description of the dynamic constant buffer that is in the pixel shader.
lightColorBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
lightColorBufferDesc.ByteWidth = sizeof(LightColorBufferType);
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);
if (FAILED(result))
{
Logger::Get().Log("Failed to create light color buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Setup the description of the dynamic constant buffer that is in the vertex shader.
lightPositionBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
lightPositionBufferDesc.ByteWidth = sizeof(LightPositionBufferType);
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);
if (FAILED(result))
{
Logger::Get().Log("Failed to create light position buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
@@ -264,30 +309,28 @@ bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsF
}
void CelshadeClass::ShutdownShader()
void LightShaderClass::ShutdownShader()
{
Logger::Get().Log("Shutting down SunLightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
Logger::Get().Log("Shutting down LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
// Release the light constant buffers.
if (m_sunlightColorBuffer)
if (m_lightColorBuffer)
{
m_sunlightColorBuffer->Release();
m_sunlightColorBuffer = 0;
m_lightColorBuffer->Release();
m_lightColorBuffer = 0;
}
if (m_sunlightPositionBuffer)
if (m_lightPositionBuffer)
{
m_sunlightPositionBuffer->Release();
m_sunlightPositionBuffer = 0;
m_lightPositionBuffer->Release();
m_lightPositionBuffer = 0;
}
// Release the light constant buffer.
if (m_sunlightBuffer)
if (m_lightBuffer)
{
m_sunlightBuffer->Release();
m_sunlightBuffer = 0;
m_lightBuffer->Release();
m_lightBuffer = 0;
}
// Release the camera constant buffer.
@@ -332,13 +375,13 @@ void CelshadeClass::ShutdownShader()
m_vertexShader = 0;
}
Logger::Get().Log("SunLightShaderClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
Logger::Get().Log("LightShaderClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
return;
}
void CelshadeClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
void LightShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
{
char* compileErrors;
unsigned __int64 bufferSize, i;
@@ -374,24 +417,15 @@ void CelshadeClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd
}
bool CelshadeClass::SetShaderParameters(
ID3D11DeviceContext* deviceContext,
XMMATRIX worldMatrix,
XMMATRIX viewMatrix,
XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture,
XMFLOAT4 ambientColor,
XMFLOAT4 diffuseColor,
XMFLOAT3 lightDirection,
float sunIntensity
)
bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[], XMFLOAT4 ambientColor[])
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
CameraBufferType* dataPtr2;
SunLightBufferType* dataPtr3;
unsigned int bufferNumber;
MatrixBufferType* dataPtr;
LightPositionBufferType* dataPtr2;
LightColorBufferType* dataPtr3;
// Transpose the matrices to prepare them for the shader.
worldMatrix = XMMatrixTranspose(worldMatrix);
@@ -402,6 +436,7 @@ bool CelshadeClass::SetShaderParameters(
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
@@ -419,41 +454,78 @@ bool CelshadeClass::SetShaderParameters(
// 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.
// Now set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
// Lock the sunlight constant buffer so it can be written to.
result = deviceContext->Map(m_sunlightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
// Lock the camera constant buffer so it can be written to.
result = deviceContext->Map(m_cameraBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map camera buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Lock the light position constant buffer so it can be written to.
result = deviceContext->Map(m_lightPositionBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
Logger::Get().Log("Failed to map light position buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr3 = (SunLightBufferType*)mappedResource.pData;
dataPtr2 = (LightPositionBufferType*)mappedResource.pData;
// Copy the lighting variables into the constant buffer.
dataPtr3->ambientColor = ambientColor;
dataPtr3->diffuseColor = diffuseColor;
dataPtr3->sunDirection = lightDirection;
dataPtr3->intensity = sunIntensity;
// Copy the light position variables into the constant buffer.
for (int i = 0; i < NUM_LIGHTS; i++)
{
dataPtr2->lightPosition[i] = lightPosition[i];
}
// Unlock the constant buffer.
deviceContext->Unmap(m_sunlightBuffer, 0);
deviceContext->Unmap(m_lightPositionBuffer, 0);
// Set the position of the sunlight constant buffer in the pixel shader.
bufferNumber = 0;
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 1;
// Finally set the sunlight constant buffer in the pixel shader with the updated values.
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_sunlightBuffer);
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_lightPositionBuffer);
// 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);
if (FAILED(result))
{
Logger::Get().Log("Failed to map light color buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr3 = (LightColorBufferType*)mappedResource.pData;
// Copy the light color variables into the constant buffer.
for (int i = 0; i < NUM_LIGHTS; i++)
{
dataPtr3->diffuseColor[i] = diffuseColor[i];
}
// Unlock the constant buffer.
deviceContext->Unmap(m_lightColorBuffer, 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);
return true;
}
void CelshadeClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
void LightShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
{
// Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout);

View File

@@ -0,0 +1,92 @@
////////////////////////////////////////////////////////////////////////////////
// Filename: lightshaderclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _LIGHTSHADERCLASS_H_
#define _LIGHTSHADERCLASS_H_
/////////////
// 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

@@ -6,9 +6,6 @@
#include <iomanip>
#include <sstream>
#include <filesystem>
#include <deque>
#include <unordered_set>
#include <imgui.h>
class Logger
{
@@ -40,50 +37,9 @@ public:
AI,
Resource,
Memory,
Debug,
Count // Do not use this, it's just to get the number of log levels it must at the end
Debug
};
// Return the size of the enum class LogLevel as a constant integer
static constexpr int LogLevelCount = static_cast<int>(LogLevel::Count);
struct LogEntry
{
std::string message;
LogLevel level;
};
struct LogLevelInfo
{
const char* name;
int value;
ImVec4 color;
};
static const LogLevelInfo GetLogLevelInfo(LogLevel level)
{
switch (level)
{
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::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::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::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) };
case LogLevel::AI: return LogLevelInfo{ "AI", 12, ImVec4(0.5f, 0.5f, 0.5f, 1.0f) };
case LogLevel::Resource: return LogLevelInfo{ "Resource", 13, ImVec4(0.5f, 0.5f, 0.5f, 1.0f) };
case LogLevel::Memory: return LogLevelInfo{ "Memory", 14, ImVec4(0.5f, 0.5f, 0.5f, 1.0f) };
case LogLevel::Debug: return LogLevelInfo{ "Debug", 15, ImVec4(0.5f, 0.5f, 0.5f, 1.0f) };
default: return LogLevelInfo{ "Unknown", 16, ImVec4(1.0f, 1.0f, 1.0f, 1.0f) };
}
}
Logger()
{
char* appdata = nullptr;
@@ -104,25 +60,10 @@ public:
ManageLogFiles(directoryPath);
m_logFilePath = directoryPath + "\\" + m_logFileName;
// Enable only the Error warning and shutdown log levels
for (int i = 0; i < LogLevelCount; i++)
{
m_disabledLogLevels[i] = true;
if (i == static_cast<int>(LogLevel::Error) || i == static_cast<int>(LogLevel::Warning) || i == static_cast<int>(LogLevel::Shutdown))
{
m_disabledLogLevels[i] = false;
}
}
}
// ecrit un message dans le fichier de log et le stocke dans le buffer
void Log(const std::string& message, const std::string& fileName, int lineNumber, LogLevel level = LogLevel::Info)
{
auto now = std::chrono::system_clock::now();
auto in_time_t = std::chrono::system_clock::to_time_t(now);
@@ -132,8 +73,59 @@ public:
// Obtenez les millisecondes à partir de maintenant
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()) % 1000;
// Utilisez LogLevelToString pour obtenir la chaîne de caractères du niveau de log
std::string levelStr = GetLogLevelInfo(level).name;
std::string levelStr;
switch (level)
{
case LogLevel::Error:
levelStr = "ERROR";
break;
case LogLevel::Warning:
levelStr = "WARNING";
break;
case LogLevel::Info:
levelStr = "INFO";
break;
case LogLevel::Shutdown:
levelStr = "SHUTDOWN";
break;
case LogLevel::Initialize:
levelStr = "INITIALIZE";
break;
case LogLevel::Update:
levelStr = "UPDATE";
break;
case LogLevel::Render:
levelStr = "RENDER";
break;
case LogLevel::Input:
levelStr = "INPUT";
break;
case LogLevel::Physics:
levelStr = "PHYSICS";
break;
case LogLevel::Audio:
levelStr = "AUDIO";
break;
case LogLevel::Network:
levelStr = "NETWORK";
break;
case LogLevel::Scripting:
levelStr = "SCRIPTING";
break;
case LogLevel::AI:
levelStr = "AI";
break;
case LogLevel::Resource:
levelStr = "RESOURCE";
break;
case LogLevel::Memory:
levelStr = "MEMORY";
break;
case LogLevel::Debug:
levelStr = "DEBUG";
break;
}
std::stringstream ss;
ss << "[" << std::put_time(&buf, "%Y-%m-%d") << "] "
@@ -142,8 +134,6 @@ public:
<< "[" << fileName << ":" << lineNumber << "] "
<< message;
Log(ss.str(), level);
std::ofstream file(m_logFilePath, std::ios::app);
if (file.is_open())
{
@@ -152,25 +142,6 @@ public:
}
}
// ecrit un message dans la console
void Log(const std::string& message, LogLevel level)
{
// Si le niveau de log est désactivé, ne faites rien
if (m_disabledLogLevels[GetLogLevelInfo(level).value])
{
return;
}
if (logBuffer.size() >= logBufferSize)
{
logBuffer.pop_front();
}
logBuffer.push_back({ message, level });
}
const std::deque<LogEntry>& GetLogBuffer() const { return logBuffer; }
void ManageLogFiles(const std::string& directoryPath)
{
std::vector<std::filesystem::path> logFiles;
@@ -210,17 +181,12 @@ public:
std::stringstream ss;
ss << "Khaotic_log_" << std::put_time(&buf, "%Y_%m_%d_%Hh%Mm%Ss") << ".log";
m_logFileName = ss.str();
}
bool m_disabledLogLevels[LogLevelCount];
std::string m_logFilePath;
}
private:
std::string m_filename;
std::string m_appdataPath;
std::string m_logFileName;
std::deque<LogEntry> logBuffer;
const size_t logBufferSize = 100;
std::string m_logFilePath;
};

View File

@@ -6,16 +6,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline,
SystemClass* System;
bool result;
wchar_t path[MAX_PATH];
HMODULE hmodule = GetModuleHandle(NULL);
if (hmodule != NULL)
{
GetModuleFileName(hmodule, path, (sizeof(path) / sizeof(wchar_t)));
}
std::filesystem::path exePath(path);
std::filesystem::path WFolder = exePath.parent_path();
// Create the system object.
System = new SystemClass;
@@ -24,7 +14,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline,
if (result)
{
Logger::Get().Log("System initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
System->SendPath(path,WFolder);
System->Run();
}

View File

@@ -34,7 +34,7 @@ bool MultiTextureShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
int error;
// Set the filename of the vertex shader.
error = wcscpy_s(vsFilename, 128, L"src/hlsl/multitexture.vs");
error = wcscpy_s(vsFilename, 128, L"multitexture.vs");
if (error != 0)
{
Logger::Get().Log("Failed to set the filename of the vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -42,7 +42,7 @@ bool MultiTextureShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
}
// Set the filename of the pixel shader.
error = wcscpy_s(psFilename, 128, L"src/hlsl/multitexture.ps");
error = wcscpy_s(psFilename, 128, L"multitexture.ps");
if (error != 0)
{
Logger::Get().Log("Failed to set the filename of the pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);

View File

@@ -12,6 +12,7 @@ PositionClass::PositionClass()
m_rightTurnSpeed = 0.0f;
m_horizontalTurnSpeed = 0.0f;
m_verticalTurnSpeed = 0.0f;
m_verticalTurnSpeed = 0.0f;
m_cameraSpeed = 4.0f;
m_speed = m_cameraSpeed;
}

View File

@@ -9,28 +9,34 @@ SystemClass::SystemClass()
m_Input = 0;
m_Application = 0;
m_imguiManager = 0;
m_applicationName = 0;
m_hinstance = 0;
m_hwnd = 0;
m_initialWindowWidth = 0;
m_initialWindowHeight = 0;
m_isDirect3DInitialized = false;
}
SystemClass::SystemClass(const SystemClass& other)
{
}
SystemClass::~SystemClass()
{
}
bool SystemClass::Initialize()
{
int screenHeight, screenWidth = 0;
int screenWidth, screenHeight;
bool result;
Logger::Get().Log("Initializing system class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
try
{
// Initialize the width and height of the screen to zero before sending the variables into the function.
screenWidth = 0;
screenHeight = 0;
m_initialWindowWidth = 0;
m_initialWindowHeight = 0;
m_isDirect3DInitialized = false;
// Initialize the windows api.
InitializeWindows(screenWidth, screenHeight);
@@ -47,7 +53,7 @@ bool SystemClass::Initialize()
// Create and initialize the application class object. This object will handle rendering all the graphics for this application.
m_Application = new ApplicationClass;
result = m_Application->Initialize(screenWidth, screenHeight, m_hwnd, false);
result = m_Application->Initialize(screenWidth, screenHeight, m_hwnd);
if (!result)
{
return false;
@@ -62,8 +68,6 @@ bool SystemClass::Initialize()
}
// Initialize imgui
if(DEBUG_MODE)
{
m_imguiManager = new imguiManager;
result = m_imguiManager->Initialize(m_hwnd, m_Application->GetDirect3D()->GetDevice(), m_Application->GetDirect3D()->GetDeviceContext());
if (!result)
@@ -71,8 +75,6 @@ bool SystemClass::Initialize()
return false;
}
}
}
catch (const std::exception& e)
{
Logger::Get().Log(std::string("Exception caught during initialization: ") + e.what(), __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -147,65 +149,6 @@ void SystemClass::Run()
// Loop until there is a quit message from the window or the user.
done = false;
// Ask if the user wants to load a scene or create a new one
int result_scene = MessageBox(NULL, L"Do you want to load a saved scene?", L"Load Scene", MB_YESNO | MB_ICONQUESTION);
if (result_scene == IDYES)
{
m_Application->LoadScene();
}
else
{
OPENFILENAME ofn;
wchar_t szFile[260] = L"";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = m_hwnd;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
// Allow multiple extensions
ofn.lpstrFilter = L"Ker Scene (*.ker)\0*.ker\0All Files (*.*)\0*.*\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
if (GetSaveFileName(&ofn) == TRUE)
{
std::filesystem::path filepath = ofn.lpstrFile;
std::string path = filepath.string();
// Add the selected extension if not already present
switch (ofn.nFilterIndex)
{
case 1:
if (filepath.extension() != L".ker")
path += ".ker";
break;
case 2:
if (filepath.extension() != L".txt")
path += ".txt";
break;
}
m_Application->SetScenePath(path);
// Create a new scene file
std::ofstream outFile(path);
if (outFile.is_open())
{
// Initialize the new scene file with default content if needed
outFile.close();
Logger::Get().Log("New scene file created successfully", __FILE__, __LINE__, Logger::LogLevel::Info);
}
else
{
Logger::Get().Log("Failed to create new scene file", __FILE__, __LINE__, Logger::LogLevel::Error);
}
}
}
while (!done)
{
// Handle the windows messages.
@@ -268,21 +211,6 @@ bool SystemClass::Frame()
return false;
}
if(!m_Input->IsKeyDown(222))
{
//log the key press
m_IsDebugKeyPressed = false;
}
else if (m_Input->IsKeyDown(222) && !m_IsDebugKeyPressed)
{
// Log the key release state
m_IsDebugKeyPressed = true;
DEBUG_MODE = !DEBUG_MODE;
}
if (DEBUG_MODE)
{
// Render ImGui
result = m_imguiManager->ImGuiWidgetRenderer(m_Application);
if (!result)
@@ -290,8 +218,6 @@ bool SystemClass::Frame()
Logger::Get().Log("Failed to render ImGui widgets", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
}
m_Application->GetDirect3D()->EndScene();
@@ -331,8 +257,6 @@ LRESULT CALLBACK SystemClass::MessageHandler(HWND hwnd, UINT umsg, WPARAM wparam
// If Direct3D is initialized, update the swap chain. Otherwise, store the window dimensions
if (m_isDirect3DInitialized && m_Application && m_Application->GetDirect3D())
{
m_Application->SetScreenWidth(newWidth);
m_Application->SetScreenHeight(newHeight);
m_Application->GetDirect3D()->ResizeSwapChain(newWidth, newHeight);
}
else
@@ -340,7 +264,6 @@ LRESULT CALLBACK SystemClass::MessageHandler(HWND hwnd, UINT umsg, WPARAM wparam
m_initialWindowWidth = newWidth;
m_initialWindowHeight = newHeight;
}
return 0;
}
case WM_ENTERSIZEMOVE:
{
@@ -370,7 +293,7 @@ LRESULT CALLBACK SystemClass::MessageHandler(HWND hwnd, UINT umsg, WPARAM wparam
if (extension == L"txt" || extension == L"kobj") {
// Handle dropped files with valid extensions
std::wcout << L"File dropped: " << filePath << std::endl;
m_Application->AddKobject(fileName);
m_Application->AddKobject(filePath);
}
else {
// Handle files with invalid extensions (optional)
@@ -540,9 +463,3 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT umessage, WPARAM wparam, LPARAM lparam)
}
}
}
void SystemClass::SendPath(wchar_t* path, std::filesystem::path WFolder)
{
m_Application->SetPath(path);
m_Application->SetWFolder(WFolder);
}

View File

@@ -1,8 +0,0 @@
- Scene Manager :
TODO : Save and Load Scene
- ImguiManager :
TODO : Add Save and Load Scene Button in the bar menu
TODO : Add a preview of the game in a new window

BIN
enginecustom/alpha01.tga Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

View File

@@ -31,7 +31,7 @@ bool AlphaMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
int error;
// Set the filename of the vertex shader.
error = wcscpy_s(vsFilename, 128, L"src/hlsl/alphamap.vs");
error = wcscpy_s(vsFilename, 128, L"alphamap.vs");
if (error != 0)
{
Logger::Get().Log("Error copying string ", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -39,7 +39,7 @@ bool AlphaMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
}
// Set the filename of the pixel shader.
error = wcscpy_s(psFilename, 128, L"src/hlsl/alphamap.ps");
error = wcscpy_s(psFilename, 128, L"alphamap.ps");
if (error != 0)
{
Logger::Get().Log("Error copying string", __FILE__, __LINE__, Logger::LogLevel::Error);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,183 @@
#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"
/////////////
// GLOBALS //
/////////////
const bool FULL_SCREEN = false;
const bool VSYNC_ENABLED = true;
const float SCREEN_DEPTH = 1000.0f;
const float SCREEN_NEAR = 0.3f;
////////////////////////////////////////////////////////////////////////////////
// Class name: ApplicationClass
////////////////////////////////////////////////////////////////////////////////
class ApplicationClass
{
public:
ApplicationClass();
ApplicationClass(const ApplicationClass&);
~ApplicationClass();
D3DClass* GetDirect3D();
bool Initialize(int, int, HWND);
void Shutdown();
bool Frame(InputClass*);
int GetScreenWidth() const;
int GetScreenHeight() const;
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(WCHAR* filepath);
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; };
bool GetShouldQuit() const { return m_ShouldQuit; };
void SetShouldQuit(bool shouldQuit) { m_ShouldQuit = shouldQuit; };
void SetCelShading(bool enable) { m_enableCelShading = enable; };
private:
bool Render(float, float, float, float, float);
bool UpdateMouseStrings(int, int, bool);
bool UpdateFps();
bool UpdateRenderCountString(int);
bool RenderSceneToTexture(float);
bool RenderRefractionToTexture();
bool RenderReflectionToTexture();
ID3D11ShaderResourceView* LoadTexture(const std::string* filename);
private :
// ------------------------------------- //
// ------------- DIRECT3D -------------- //
// ------------------------------------- //
D3DClass* m_Direct3D;
IDXGISwapChain* m_swapChain;
ModelClass* m_Model,* m_GroundModel, * m_WallModel, * m_BathModel, * m_WaterModel;
ModelListClass* m_ModelList;
// ------------------------------------- //
// ------------- RENDERING ------------- //
// ------------------------------------- //
XMMATRIX m_baseViewMatrix;
RenderTextureClass* m_RenderTexture, * m_RefractionTexture, * m_ReflectionTexture;
DisplayPlaneClass* m_DisplayPlane;
int m_screenWidth, m_screenHeight;
CameraClass* m_Camera;
PositionClass* m_Position;
FrustumClass* m_Frustum;
// ------------------------------------ //
// ------------- 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;
int m_ObjectId = 0;
// ----------------------------------- //
// ------------- LIGHTS -------------- //
// ----------------------------------- //
LightClass* m_Light;
std::vector<LightClass*> m_Lights;
int m_numLights;
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;
// ------------------------------------------------- //
// ------------- 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;
};
#endif

BIN
enginecustom/assets/Model/OBJ/86.obj (Stored with Git LFS)

Binary file not shown.

BIN
enginecustom/assets/Model/OBJ/cone.obj (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
enginecustom/assets/Model/OBJ/monke.obj (Stored with Git LFS)

Binary file not shown.

BIN
enginecustom/assets/Model/OBJ/plane.obj (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

BIN
enginecustom/assets/Model/OBJ/vaisseau.obj (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,24 +0,0 @@
[Window][Debug##Default]
Pos=60,60
Size=400,400
[Window][Khaotic Engine]
Pos=1120,51
Size=392,273
[Window][Objects]
Pos=930,39
Size=457,294
[Window][Terrain]
Pos=60,60
Size=342,82
[Window][Light]
Pos=1551,17
Size=358,535
[Window][Shader Manager]
Pos=30,255
Size=172,284

View File

@@ -1,91 +0,0 @@
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0
[Window][Khaotic Engine]
Pos=1180,27
Size=396,826
Collapsed=0
DockId=0x00000005,0
[Window][Objects]
Pos=8,442
Size=290,411
Collapsed=0
DockId=0x0000000A,0
[Window][Terrain]
Pos=8,27
Size=290,413
Collapsed=0
DockId=0x00000009,0
[Window][Light]
Pos=8,27
Size=330,487
Collapsed=0
DockId=0x00000004,1
[Window][Shader Manager]
Pos=8,27
Size=330,487
Collapsed=0
DockId=0x00000004,2
[Window][Engine Settings]
Pos=1180,27
Size=396,826
Collapsed=0
DockId=0x00000005,1
[Window][DockSpace Demo]
Size=1584,861
Collapsed=0
[Window][Render Window]
Pos=300,27
Size=878,826
Collapsed=0
DockId=0x00000002,0
[Window][DockSpace]
Pos=0,0
Size=1584,861
Collapsed=0
[Window][Add Object]
Pos=1188,0
Size=396,430
Collapsed=0
[Window][Log]
Pos=8,518
Size=1568,335
Collapsed=0
DockId=0x0000000C,0
[Window][Log Window]
Pos=8,627
Size=1568,226
Collapsed=0
DockId=0x0000000E,0
[Docking][Data]
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Split=Y Selected=0x393905AB
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=330,487 Selected=0x393905AB
DockNode ID=0x00000006 Parent=0x00000001 SizeRef=330,485 Selected=0x031DC75C
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=1568,826 Split=Y
DockNode ID=0x0000000D Parent=0xCCBD8CF7 SizeRef=1568,598 Split=Y
DockNode ID=0x0000000B Parent=0x0000000D SizeRef=1568,637 Split=X
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=290,826 Split=Y Selected=0x393905AB
DockNode ID=0x00000009 Parent=0x00000007 SizeRef=395,413 Selected=0x393905AB
DockNode ID=0x0000000A Parent=0x00000007 SizeRef=395,411 Selected=0x031DC75C
DockNode ID=0x00000008 Parent=0x0000000B SizeRef=1276,826 Split=X
DockNode ID=0x00000002 Parent=0x00000008 SizeRef=878,826 CentralNode=1 Selected=0x9204953B
DockNode ID=0x00000005 Parent=0x00000008 SizeRef=396,826 Selected=0x9F035453
DockNode ID=0x0000000C Parent=0x0000000D SizeRef=1568,335 Selected=0x139FDA3F
DockNode ID=0x0000000E Parent=0xCCBD8CF7 SizeRef=1568,226 Selected=0xAB74BEE9

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 331 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 493 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 510 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 498 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 422 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 588 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 MiB

View File

@@ -1,89 +0,0 @@
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0
[Window][Khaotic Engine]
Pos=1697,27
Size=343,1094
Collapsed=0
DockId=0x00000005,0
[Window][Objects]
Pos=8,27
Size=289,547
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
Collapsed=0
DockId=0x0000000B,1
[Window][Shader Manager]
Pos=8,27
Size=330,487
Collapsed=0
DockId=0x00000001,2
[Window][Engine Settings]
Pos=8,27
Size=289,547
Collapsed=0
DockId=0x00000007,1
[Window][DockSpace Demo]
Size=1584,861
Collapsed=0
[Window][Render Window]
Pos=8,27
Size=1559,974
Collapsed=0
DockId=0x00000007,0
[Window][DockSpace]
Pos=0,0
Size=2048,1129
Collapsed=0
[Window][Add Object]
Pos=1188,0
Size=396,430
Collapsed=0
[Window][Log]
Pos=8,518
Size=1568,335
Collapsed=0
DockId=0x0000000C,0
[Window][Log Window]
Pos=8,37
Size=16,19
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 599 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 917 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 934 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 KiB

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