Compare commits
58 Commits
V13.3.0
...
2e33adf4a9
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e33adf4a9 | |||
| c67a805bd7 | |||
| cb234f64f0 | |||
| 5ab98c9a0a | |||
| 37bba7866c | |||
| ebbbd181e3 | |||
| ba7d0ca27e | |||
| 13fc189ee8 | |||
| af5473f6e3 | |||
| 526b38eb4f | |||
| 295b7354d9 | |||
| b31b242775 | |||
| 7c6562719f | |||
| 00339aa6c2 | |||
| 2b8e222d7c | |||
| 7c5a6435bb | |||
| fe77100612 | |||
| 985e4de77d | |||
| b1ba23f9c0 | |||
| 884db4877e | |||
| 38569b18a7 | |||
| aa8e5c0782 | |||
| 6680e4689b | |||
| a2dc31f49c | |||
| fc9a4bdc47 | |||
| 4922305921 | |||
| 14c07f8750 | |||
| 2f5a970a4e | |||
| 6667a57585 | |||
| 9da4a5e852 | |||
| 871d7c8265 | |||
| 3352f2afa7 | |||
| 715955ef6a | |||
| 90a43254f3 | |||
| f1db564fb3 | |||
| 97b5483cc9 | |||
| ad056fa2a8 | |||
| 1bdcd5cd1b | |||
| 467b357620 | |||
| 0368276fbf | |||
| 9515b18d1e | |||
| d131c78a59 | |||
| 56389b5dee | |||
| 389cde97c2 | |||
| 0e41fb0ec9 | |||
| e4836174b4 | |||
| 284e282679 | |||
| 4b47346208 | |||
| a3d80256f5 | |||
| 29db39910c | |||
| 2346625afb | |||
| e9d906ce72 | |||
| aee0704fe7 | |||
| f3039f22ed | |||
| 76fdd3c76e | |||
| 7fc4b08808 | |||
| de05631608 | |||
| f875580197 |
7
.gitattributes
vendored
7
.gitattributes
vendored
@@ -1,3 +1,10 @@
|
||||
enginecustom/assets/Model/OBJ/*.obj filter=lfs diff=lfs merge=lfs -text
|
||||
enginecustom/assets/Model/OBJ/*.mtl filter=lfs diff=lfs merge=lfs -text
|
||||
doxygen_docs/** filter=lfs diff=lfs merge=lfs -text
|
||||
enginecustom/include/Lua/Lib/lua54.lib filter=lfs diff=lfs merge=lfs -text
|
||||
enginecustom/x64/Debug/lua54.dll filter=lfs diff=lfs merge=lfs -text
|
||||
enginecustom/x64/Release/lua54.dll filter=lfs diff=lfs merge=lfs -text
|
||||
x64/Debug/lua54.dll filter=lfs diff=lfs merge=lfs -text
|
||||
x64/Release/lua54.dll filter=lfs diff=lfs merge=lfs -text
|
||||
x64/Debug/config.txt filter=lfs diff=lfs merge=lfs -text
|
||||
x64/Release/config.txt filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -434,3 +434,5 @@ FodyWeavers.xsd
|
||||
# Additional files built by Visual Studio
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/visualstudio,c++
|
||||
|
||||
.idea/
|
||||
|
||||
1
.idea/.idea.KhaoticEngineReborn/.idea/.name
generated
1
.idea/.idea.KhaoticEngineReborn/.idea/.name
generated
@@ -1 +0,0 @@
|
||||
KhaoticEngineReborn
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AndroidProjectSystem">
|
||||
<option name="providerId" value="RiderAndroidProjectSystem" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AgentMigrationStateService">
|
||||
<option name="migrationStatus" value="COMPLETED" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EditMigrationStateService">
|
||||
<option name="migrationStatus" value="COMPLETED" />
|
||||
</component>
|
||||
</project>
|
||||
14
.idea/.idea.KhaoticEngineReborn/.idea/discord.xml
generated
14
.idea/.idea.KhaoticEngineReborn/.idea/discord.xml
generated
@@ -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>
|
||||
@@ -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/application_class.cpp" charset="windows-1252" />
|
||||
<file url="file://$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" charset="windows-1252" />
|
||||
<file url="PROJECT" charset="windows-1252" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GitToolBoxBlameSettings">
|
||||
<option name="version" value="2" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -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>
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,7 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="LanguageDetectionInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="ReassignedToPlainText" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
</profile>
|
||||
</component>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
6
.idea/.idea.KhaoticEngineReborn/.idea/vcs.xml
generated
6
.idea/.idea.KhaoticEngineReborn/.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
332
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
332
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
@@ -1,332 +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/src/inc/system/camera_class.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/camera_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/component.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/component.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/audio_component.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/audio_component.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/transform_component.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/transform_component.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/entity.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/entity.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/entity_manager.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/entity_manager.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/application_class.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/application_class.cpp" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<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="file://C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um/d3d11.h" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um/dinput.h" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/include/memory" 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/inc/system/ecs/ComponentFactory.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/identity_component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/model_path_component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/physics_component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/render_component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/shader_component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/transform_component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/entity.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/entity_manager.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/systems/render_system.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/systems/types.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/../../IDE_VS/VC/Tools/MSVC/14.38.33130/include/type_traits" root0="SKIP_HIGHLIGHTING" />
|
||||
</component>
|
||||
<component name="KubernetesApiPersistence">{}</component>
|
||||
<component name="KubernetesApiProvider">{
|
||||
"isMigrated": true
|
||||
}</component>
|
||||
<component name="MetaFilesCheckinStateConfiguration" checkMetaFiles="true" />
|
||||
<component name="ProblemsViewState">
|
||||
<option name="selectedTabId" value="CurrentFile" />
|
||||
</component>
|
||||
<component name="ProjectColorInfo">{
|
||||
"associatedIndex": 6
|
||||
}</component>
|
||||
<component name="ProjectId" id="2sGIWDeT5ixyzDQ0he4A3RFpG9W" />
|
||||
<component name="ProjectLevelVcsManager">
|
||||
<ConfirmationsSetting value="2" id="Add" />
|
||||
</component>
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"C++ Project.enginecustom.executor": "Run",
|
||||
"C/C++ Project.KhaoticDemo.executor": "Run",
|
||||
"C/C++ Project.enginecustom.executor": "Run",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.git.unshallow": "true",
|
||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"git-widget-placeholder": "main",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}</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" />
|
||||
<workItem from="1747258663152" duration="835000" />
|
||||
<workItem from="1747826758888" duration="3587000" />
|
||||
<workItem from="1747830379222" duration="7954000" />
|
||||
<workItem from="1748254142068" duration="10499000" />
|
||||
<workItem from="1748267553700" duration="654000" />
|
||||
<workItem from="1748429087202" duration="7421000" />
|
||||
<workItem from="1748521606678" duration="5300000" />
|
||||
<workItem from="1748859894056" duration="1431000" />
|
||||
<workItem from="1748861785837" duration="357000" />
|
||||
<workItem from="1748865625274" duration="797000" />
|
||||
<workItem from="1748869642637" duration="3049000" />
|
||||
<workItem from="1748954607174" duration="14202000" />
|
||||
<workItem from="1748969487337" duration="402000" />
|
||||
<workItem from="1750187491423" duration="4397000" />
|
||||
<workItem from="1750191969842" duration="162000" />
|
||||
<workItem from="1750248915365" duration="442000" />
|
||||
<workItem from="1750335650897" duration="2051000" />
|
||||
<workItem from="1750344288223" duration="1751000" />
|
||||
<workItem from="1750351735497" duration="9648000" />
|
||||
<workItem from="1750417484899" duration="2384000" />
|
||||
<workItem from="1750420267631" duration="148000" />
|
||||
<workItem from="1750592598277" duration="332000" />
|
||||
<workItem from="1750699146323" duration="10385000" />
|
||||
<workItem from="1750763086646" duration="4874000" />
|
||||
<workItem from="1750770680795" duration="13425000" />
|
||||
<workItem from="1750964683511" duration="27000" />
|
||||
<workItem from="1750964770914" duration="2126000" />
|
||||
<workItem from="1753700140931" duration="918000" />
|
||||
<workItem from="1753701507863" duration="7153000" />
|
||||
<workItem from="1753713925469" duration="1739000" />
|
||||
<workItem from="1754572996727" duration="224000" />
|
||||
<workItem from="1755617169013" duration="222000" />
|
||||
<workItem from="1757101936080" duration="185000" />
|
||||
<workItem from="1757158576637" duration="2501000" />
|
||||
<workItem from="1757167799006" duration="45000" />
|
||||
<workItem from="1757167889796" duration="7081000" />
|
||||
<workItem from="1757175031271" duration="2289000" />
|
||||
<workItem from="1757177353935" duration="676000" />
|
||||
<workItem from="1757182479393" duration="1386000" />
|
||||
<workItem from="1757427950015" duration="2864000" />
|
||||
<workItem from="1757431548883" duration="986000" />
|
||||
<workItem from="1757449929378" duration="1107000" />
|
||||
<workItem from="1757456559331" duration="2094000" />
|
||||
<workItem from="1757458683204" duration="3628000" />
|
||||
<workItem from="1757938327874" duration="2045000" />
|
||||
<workItem from="1757952605657" duration="117000" />
|
||||
<workItem from="1757952791669" duration="4499000" />
|
||||
<workItem from="1757959923169" duration="1930000" />
|
||||
<workItem from="1757961888820" duration="8937000" />
|
||||
</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 &) (*(*(*this).m_Application).m_object[0]))" />
|
||||
</configuration>
|
||||
</watches-manager>
|
||||
</component>
|
||||
<component name="XSLT-Support.FileAssociations.UIState">
|
||||
<expand />
|
||||
<select />
|
||||
</component>
|
||||
</project>
|
||||
136
Jenkinsfile
vendored
Normal file
136
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
pipeline {
|
||||
agent { label 'windows' }
|
||||
|
||||
parameters {
|
||||
string(name: 'DISCORD_USER_ID', defaultValue: '378262266723696651', description: 'ID Discord pour recevoir le DM')
|
||||
choice(name: 'BUILD_TYPE', choices: ['Both', 'Debug', 'Release'], description: 'Type de build à exécuter')
|
||||
}
|
||||
|
||||
options {
|
||||
timestamps()
|
||||
disableConcurrentBuilds()
|
||||
timeout(time: 30, unit: 'MINUTES')
|
||||
}
|
||||
|
||||
triggers {
|
||||
pollSCM('')
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
checkout scm
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build') {
|
||||
parallel {
|
||||
stage('Build Debug') {
|
||||
when { expression { params.BUILD_TYPE in ['Both', 'Debug'] } }
|
||||
steps {
|
||||
echo 'Building Debug...'
|
||||
bat """
|
||||
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe" ^
|
||||
"%WORKSPACE%\\KhaoticEngineReborn.sln" ^
|
||||
/p:Configuration=Debug ^
|
||||
/p:Platform=x64 ^
|
||||
/m ^
|
||||
/verbosity:minimal
|
||||
"""
|
||||
}
|
||||
}
|
||||
stage('Build Release') {
|
||||
when { expression { params.BUILD_TYPE in ['Both', 'Release'] } }
|
||||
steps {
|
||||
echo 'Building Release...'
|
||||
bat """
|
||||
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe" ^
|
||||
"%WORKSPACE%\\KhaoticEngineReborn.sln" ^
|
||||
/p:Configuration=Release ^
|
||||
/p:Platform=x64 ^
|
||||
/m ^
|
||||
/verbosity:minimal
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Package') {
|
||||
parallel {
|
||||
stage('Package Debug') {
|
||||
when { expression { params.BUILD_TYPE in ['Both', 'Debug'] } }
|
||||
steps {
|
||||
echo 'Packaging Debug into ZIP'
|
||||
bat 'if not exist "%WORKSPACE%\\builds" mkdir "%WORKSPACE%\\builds"'
|
||||
bat """
|
||||
powershell -Command "Compress-Archive -Path '%WORKSPACE%\\**\\Debug\\*' -DestinationPath '%WORKSPACE%\\builds\\KhaoticEngineReborn_Debug.zip' -Force"
|
||||
"""
|
||||
}
|
||||
}
|
||||
stage('Package Release') {
|
||||
when { expression { params.BUILD_TYPE in ['Both', 'Release'] } }
|
||||
steps {
|
||||
echo 'Packaging Release into ZIP'
|
||||
bat 'if not exist "%WORKSPACE%\\builds" mkdir "%WORKSPACE%\\builds"'
|
||||
bat """
|
||||
powershell -Command "Compress-Archive -Path '%WORKSPACE%\\**\\Release\\*' -DestinationPath '%WORKSPACE%\\builds\\KhaoticEngineReborn_Release.zip' -Force"
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Archive Artifacts') {
|
||||
steps {
|
||||
archiveArtifacts artifacts: 'builds/*.zip', fingerprint: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
success {
|
||||
script {
|
||||
def urlsList = []
|
||||
if (params.BUILD_TYPE in ['Both', 'Debug']) {
|
||||
urlsList << "${env.BUILD_URL}artifact/builds/KhaoticEngineReborn_Debug.zip"
|
||||
}
|
||||
if (params.BUILD_TYPE in ['Both', 'Release']) {
|
||||
urlsList << "${env.BUILD_URL}artifact/builds/KhaoticEngineReborn_Release.zip"
|
||||
}
|
||||
|
||||
def data = [
|
||||
userId: params.DISCORD_USER_ID,
|
||||
status: 'success',
|
||||
urls: urlsList
|
||||
]
|
||||
def jsonFile = "${env.WORKSPACE}\\payload.json"
|
||||
writeFile file: jsonFile, text: groovy.json.JsonOutput.toJson(data)
|
||||
|
||||
bat """
|
||||
curl -X POST http://192.168.1.131:2500/ci-notify ^
|
||||
-H "Content-Type: application/json" ^
|
||||
--data @${jsonFile}
|
||||
"""
|
||||
}
|
||||
}
|
||||
failure {
|
||||
script {
|
||||
def data = [
|
||||
userId: params.DISCORD_USER_ID,
|
||||
status: 'failure',
|
||||
urls: []
|
||||
]
|
||||
def jsonFile = "${env.WORKSPACE}\\payload-fail.json"
|
||||
writeFile file: jsonFile, text: groovy.json.JsonOutput.toJson(data)
|
||||
|
||||
bat """
|
||||
curl -X POST http://192.168.1.131:2500/ci-notify ^
|
||||
-H "Content-Type: application/json" ^
|
||||
--data @${jsonFile}
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
8
enginecustom/DemoScene_V13.6.0.ker
Normal file
8
enginecustom/DemoScene_V13.6.0.ker
Normal file
@@ -0,0 +1,8 @@
|
||||
Entity:0:86
|
||||
IdentityComponent:0:86:Unknown
|
||||
TransformComponent:0:50:0:0:-0:0:1:1:1
|
||||
RenderComponent:HasModel:1:assets/Texture/Bricks2K.png:1:assets/Texture/BricksNRM2K.png:1:assets/Texture/BricksGLOSS2K.png:0:
|
||||
ShaderComponent:LIGHTING
|
||||
ModelPathComponent:Content/Assets/Kobject/86.obj
|
||||
AudioComponent:F:\Github_Repo\khaotic-engine-Reborn\x64\Release\assets\sounds\default.mp3;1:0:1:1:0:0:128:1:0
|
||||
EndEntity
|
||||
6014
enginecustom/DemoScene_V14.7.0.ker
Normal file
6014
enginecustom/DemoScene_V14.7.0.ker
Normal file
File diff suppressed because it is too large
Load Diff
@@ -123,6 +123,7 @@
|
||||
<ClInclude Include="src\inc\system\ecs\ComponentFactory.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\components\audio_component.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\components\identity_component.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\components\lua_script_component.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\components\model_path_component.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\components\physics_component.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\components\render_component.h" />
|
||||
@@ -140,6 +141,7 @@
|
||||
<ClInclude Include="src\inc\system\input_class.h" />
|
||||
<ClInclude Include="src\inc\system\light_class.h" />
|
||||
<ClInclude Include="src\inc\system\Logger.h" />
|
||||
<ClInclude Include="src\inc\system\macro.h" />
|
||||
<ClInclude Include="src\inc\system\model_class.h" />
|
||||
<ClInclude Include="src\inc\system\Modellistclass.h" />
|
||||
<ClInclude Include="src\inc\system\object.h" />
|
||||
@@ -155,6 +157,7 @@
|
||||
<ClInclude Include="src\inc\system\text_class.h" />
|
||||
<ClInclude Include="src\inc\system\texture_class.h" />
|
||||
<ClInclude Include="src\inc\system\timer_class.h" />
|
||||
<ClInclude Include="src\inc\system\version.h" />
|
||||
<ClInclude Include="src\inc\system\vulkan.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -682,14 +685,14 @@
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)enginecustom\include\backends;$(SolutionDir)enginecustom\include\Inc;$(SolutionDir)enginecustom\include;$(SolutionDir)enginecustom\src\inc\shader;$(SolutionDir)enginecustom\src\inc\system;$(SolutionDir)enginecustom\include\Vulkan\Include;$(SolutionDir)enginecustom\include\Fmod;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)enginecustom\include\backends;$(SolutionDir)enginecustom\include\Inc;$(SolutionDir)enginecustom\include;$(SolutionDir)enginecustom\src\inc\shader;$(SolutionDir)enginecustom\src\inc\system;$(SolutionDir)enginecustom\include\Vulkan\Include;$(SolutionDir)enginecustom\include\Lua;$(SolutionDir)enginecustom\include\Fmod;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)enginecustom\include\Vulkan\Lib;$(SolutionDir)enginecustom\include\GLFW\lib-vc2022;$(SolutionDir)enginecustom\include\Fmod\core\lib\x64\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>fmodL_vc.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)enginecustom\include\Vulkan\Lib;$(SolutionDir)enginecustom\include\GLFW\lib-vc2022;$(SolutionDir)enginecustom\include\Lua\Lib;$(SolutionDir)enginecustom\include\Fmod\core\lib\x64\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>fmodL_vc.lib;lua54.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -701,15 +704,15 @@
|
||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)enginecustom\include\backends;$(SolutionDir)enginecustom\include\Inc;$(SolutionDir)enginecustom\include;$(SolutionDir)enginecustom\src\inc\shader;$(SolutionDir)enginecustom\src\inc\system;$(SolutionDir)enginecustom\include\Vulkan\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)enginecustom\include\backends;$(SolutionDir)enginecustom\include\Inc;$(SolutionDir)enginecustom\include;$(SolutionDir)enginecustom\src\inc\shader;$(SolutionDir)enginecustom\src\inc\system;$(SolutionDir)enginecustom\include\Vulkan\Include;$(SolutionDir)enginecustom\include\Lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)enginecustom\include\Vulkan\Lib;$(SolutionDir)enginecustom\include\GLFW\lib-vc2022;$(SolutionDir)enginecustom\include\Fmod\core\lib\x64\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>fmod_vc.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)enginecustom\include\Vulkan\Lib;$(SolutionDir)enginecustom\include\GLFW\lib-vc2022;$(SolutionDir)enginecustom\include\Lua\Lib;$(SolutionDir)enginecustom\include\Fmod\core\lib\x64\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>fmod_vc.lib;lua54.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[Window][DockSpace]
|
||||
Pos=0,0
|
||||
Size=1584,861
|
||||
Size=1536,793
|
||||
Collapsed=0
|
||||
|
||||
[Window][Debug##Default]
|
||||
@@ -12,25 +12,25 @@ Collapsed=0
|
||||
Pos=1267,19
|
||||
Size=317,842
|
||||
Collapsed=0
|
||||
DockId=0x00000005,0
|
||||
DockId=0x00000006,0
|
||||
|
||||
[Window][render Stats]
|
||||
Pos=0,630
|
||||
Size=1584,231
|
||||
Pos=0,562
|
||||
Size=1217,231
|
||||
Collapsed=0
|
||||
DockId=0x00000009,0
|
||||
|
||||
[Window][Objects]
|
||||
Pos=0,19
|
||||
Size=234,842
|
||||
Size=15,22
|
||||
Collapsed=0
|
||||
DockId=0x0000000B,0
|
||||
|
||||
[Window][Terrain]
|
||||
Pos=0,19
|
||||
Size=266,842
|
||||
Size=15,22
|
||||
Collapsed=0
|
||||
DockId=0x00000007,0
|
||||
DockId=0x0000000B,1
|
||||
|
||||
[Window][Log Window]
|
||||
Pos=0,630
|
||||
@@ -45,23 +45,27 @@ Collapsed=0
|
||||
DockId=0x0000000B,0
|
||||
|
||||
[Window][Engine Settings]
|
||||
Pos=1267,462
|
||||
Size=317,166
|
||||
Pos=1219,19
|
||||
Size=317,774
|
||||
Collapsed=0
|
||||
DockId=0x00000006,0
|
||||
|
||||
[Docking][Data]
|
||||
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1584,842 Split=Y
|
||||
DockNode ID=0x00000003 Parent=0xCCBD8CF7 SizeRef=1584,609 Split=X
|
||||
DockNode ID=0x0000000B Parent=0x00000003 SizeRef=234,842 Selected=0x031DC75C
|
||||
DockNode ID=0x0000000C Parent=0x00000003 SizeRef=1348,842 Split=X
|
||||
DockNode ID=0x00000007 Parent=0x0000000C SizeRef=266,842 Selected=0x393905AB
|
||||
DockNode ID=0x00000008 Parent=0x0000000C SizeRef=1316,842 Split=X
|
||||
DockNode ID=0x00000001 Parent=0x00000008 SizeRef=1265,842 CentralNode=1
|
||||
DockNode ID=0x00000002 Parent=0x00000008 SizeRef=317,842 Split=Y Selected=0x9F035453
|
||||
DockNode ID=0x00000005 Parent=0x00000002 SizeRef=317,441 Selected=0x9F035453
|
||||
DockNode ID=0x00000006 Parent=0x00000002 SizeRef=317,166 Selected=0x0B098C4B
|
||||
DockNode ID=0x00000004 Parent=0xCCBD8CF7 SizeRef=1584,231 Split=X Selected=0xF5D1BB37
|
||||
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=792,231 Selected=0xF5D1BB37
|
||||
DockNode ID=0x0000000A Parent=0x00000004 SizeRef=790,231 Selected=0xAB74BEE9
|
||||
[Window][Inspector]
|
||||
Pos=1352,19
|
||||
Size=232,842
|
||||
Collapsed=0
|
||||
DockId=0x00000002,0
|
||||
|
||||
[Docking][Data]
|
||||
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1536,774 Split=X
|
||||
DockNode ID=0x00000001 Parent=0xCCBD8CF7 SizeRef=1350,842 Split=X
|
||||
DockNode ID=0x00000005 Parent=0x00000001 SizeRef=1265,842 Split=Y
|
||||
DockNode ID=0x00000003 Parent=0x00000005 SizeRef=1584,609 Split=X
|
||||
DockNode ID=0x0000000B Parent=0x00000003 SizeRef=251,842 Selected=0x031DC75C
|
||||
DockNode ID=0x0000000C Parent=0x00000003 SizeRef=964,842 CentralNode=1
|
||||
DockNode ID=0x00000004 Parent=0x00000005 SizeRef=1584,231 Split=X Selected=0xF5D1BB37
|
||||
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=792,231 Selected=0xF5D1BB37
|
||||
DockNode ID=0x0000000A Parent=0x00000004 SizeRef=790,231 Selected=0xAB74BEE9
|
||||
DockNode ID=0x00000006 Parent=0x00000001 SizeRef=317,842 Selected=0x0B098C4B
|
||||
DockNode ID=0x00000002 Parent=0xCCBD8CF7 SizeRef=232,842 Selected=0x36DC96AB
|
||||
|
||||
|
||||
BIN
enginecustom/include/Lua/Lib/lua54.lib
(Stored with Git LFS)
Normal file
BIN
enginecustom/include/Lua/Lib/lua54.lib
(Stored with Git LFS)
Normal file
Binary file not shown.
276
enginecustom/include/Lua/lauxlib.h
Normal file
276
enginecustom/include/Lua/lauxlib.h
Normal file
@@ -0,0 +1,276 @@
|
||||
/*
|
||||
** $Id: lauxlib.h $
|
||||
** Auxiliary functions for building Lua libraries
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef lauxlib_h
|
||||
#define lauxlib_h
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lua.h"
|
||||
|
||||
|
||||
/* global table */
|
||||
#define LUA_GNAME "_G"
|
||||
|
||||
|
||||
typedef struct luaL_Buffer luaL_Buffer;
|
||||
|
||||
|
||||
/* extra error code for 'luaL_loadfilex' */
|
||||
#define LUA_ERRFILE (LUA_ERRERR+1)
|
||||
|
||||
|
||||
/* key, in the registry, for table of loaded modules */
|
||||
#define LUA_LOADED_TABLE "_LOADED"
|
||||
|
||||
|
||||
/* key, in the registry, for table of preloaded loaders */
|
||||
#define LUA_PRELOAD_TABLE "_PRELOAD"
|
||||
|
||||
|
||||
typedef struct luaL_Reg {
|
||||
const char *name;
|
||||
lua_CFunction func;
|
||||
} luaL_Reg;
|
||||
|
||||
|
||||
#define LUAL_NUMSIZES (sizeof(lua_Integer)*16 + sizeof(lua_Number))
|
||||
|
||||
LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver, size_t sz);
|
||||
#define luaL_checkversion(L) \
|
||||
luaL_checkversion_(L, LUA_VERSION_NUM, LUAL_NUMSIZES)
|
||||
|
||||
LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
|
||||
LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
|
||||
LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len);
|
||||
LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg);
|
||||
LUALIB_API int (luaL_typeerror) (lua_State *L, int arg, const char *tname);
|
||||
LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg,
|
||||
size_t *l);
|
||||
LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg,
|
||||
const char *def, size_t *l);
|
||||
LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int arg);
|
||||
LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int arg, lua_Number def);
|
||||
|
||||
LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg);
|
||||
LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg,
|
||||
lua_Integer def);
|
||||
|
||||
LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
|
||||
LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t);
|
||||
LUALIB_API void (luaL_checkany) (lua_State *L, int arg);
|
||||
|
||||
LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname);
|
||||
LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname);
|
||||
LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname);
|
||||
LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
|
||||
|
||||
LUALIB_API void (luaL_where) (lua_State *L, int lvl);
|
||||
LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
|
||||
|
||||
LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def,
|
||||
const char *const lst[]);
|
||||
|
||||
LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname);
|
||||
LUALIB_API int (luaL_execresult) (lua_State *L, int stat);
|
||||
|
||||
|
||||
/* predefined references */
|
||||
#define LUA_NOREF (-2)
|
||||
#define LUA_REFNIL (-1)
|
||||
|
||||
LUALIB_API int (luaL_ref) (lua_State *L, int t);
|
||||
LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
|
||||
|
||||
LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename,
|
||||
const char *mode);
|
||||
|
||||
#define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL)
|
||||
|
||||
LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz,
|
||||
const char *name, const char *mode);
|
||||
LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
|
||||
|
||||
LUALIB_API lua_State *(luaL_newstate) (void);
|
||||
|
||||
LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx);
|
||||
|
||||
LUALIB_API void luaL_addgsub (luaL_Buffer *b, const char *s,
|
||||
const char *p, const char *r);
|
||||
LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s,
|
||||
const char *p, const char *r);
|
||||
|
||||
LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup);
|
||||
|
||||
LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname);
|
||||
|
||||
LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1,
|
||||
const char *msg, int level);
|
||||
|
||||
LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
|
||||
lua_CFunction openf, int glb);
|
||||
|
||||
/*
|
||||
** ===============================================================
|
||||
** some useful macros
|
||||
** ===============================================================
|
||||
*/
|
||||
|
||||
|
||||
#define luaL_newlibtable(L,l) \
|
||||
lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)
|
||||
|
||||
#define luaL_newlib(L,l) \
|
||||
(luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
|
||||
|
||||
#define luaL_argcheck(L, cond,arg,extramsg) \
|
||||
((void)((cond) || luaL_argerror(L, (arg), (extramsg))))
|
||||
|
||||
#define luaL_argexpected(L,cond,arg,tname) \
|
||||
((void)((cond) || luaL_typeerror(L, (arg), (tname))))
|
||||
|
||||
#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
|
||||
#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
|
||||
|
||||
#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))
|
||||
|
||||
#define luaL_dofile(L, fn) \
|
||||
(luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
|
||||
|
||||
#define luaL_dostring(L, s) \
|
||||
(luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
|
||||
|
||||
#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n)))
|
||||
|
||||
#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
|
||||
|
||||
#define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL)
|
||||
|
||||
|
||||
/* push the value used to represent failure/error */
|
||||
#define luaL_pushfail(L) lua_pushnil(L)
|
||||
|
||||
|
||||
/*
|
||||
** {======================================================
|
||||
** Generic Buffer manipulation
|
||||
** =======================================================
|
||||
*/
|
||||
|
||||
struct luaL_Buffer {
|
||||
char *b; /* buffer address */
|
||||
size_t size; /* buffer size */
|
||||
size_t n; /* number of characters in buffer */
|
||||
lua_State *L;
|
||||
union {
|
||||
LUAI_MAXALIGN; /* ensure maximum alignment for buffer */
|
||||
char b[LUAL_BUFFERSIZE]; /* initial buffer */
|
||||
} init;
|
||||
};
|
||||
|
||||
|
||||
#define luaL_bufflen(bf) ((bf)->n)
|
||||
#define luaL_buffaddr(bf) ((bf)->b)
|
||||
|
||||
|
||||
#define luaL_addchar(B,c) \
|
||||
((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \
|
||||
((B)->b[(B)->n++] = (c)))
|
||||
|
||||
#define luaL_addsize(B,s) ((B)->n += (s))
|
||||
|
||||
#define luaL_buffsub(B,s) ((B)->n -= (s))
|
||||
|
||||
LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
|
||||
LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz);
|
||||
LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
|
||||
LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
|
||||
LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
|
||||
LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
|
||||
LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz);
|
||||
LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz);
|
||||
|
||||
#define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE)
|
||||
|
||||
/* }====================================================== */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** {======================================================
|
||||
** File handles for IO library
|
||||
** =======================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and
|
||||
** initial structure 'luaL_Stream' (it may contain other fields
|
||||
** after that initial structure).
|
||||
*/
|
||||
|
||||
#define LUA_FILEHANDLE "FILE*"
|
||||
|
||||
|
||||
typedef struct luaL_Stream {
|
||||
FILE *f; /* stream (NULL for incompletely created streams) */
|
||||
lua_CFunction closef; /* to close stream (NULL for closed streams) */
|
||||
} luaL_Stream;
|
||||
|
||||
/* }====================================================== */
|
||||
|
||||
/*
|
||||
** {==================================================================
|
||||
** "Abstraction Layer" for basic report of messages and errors
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
/* print a string */
|
||||
#if !defined(lua_writestring)
|
||||
#define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout)
|
||||
#endif
|
||||
|
||||
/* print a newline and flush the output */
|
||||
#if !defined(lua_writeline)
|
||||
#define lua_writeline() (lua_writestring("\n", 1), fflush(stdout))
|
||||
#endif
|
||||
|
||||
/* print an error message */
|
||||
#if !defined(lua_writestringerror)
|
||||
#define lua_writestringerror(s,p) \
|
||||
(fprintf(stderr, (s), (p)), fflush(stderr))
|
||||
#endif
|
||||
|
||||
/* }================================================================== */
|
||||
|
||||
|
||||
/*
|
||||
** {============================================================
|
||||
** Compatibility with deprecated conversions
|
||||
** =============================================================
|
||||
*/
|
||||
#if defined(LUA_COMPAT_APIINTCASTS)
|
||||
|
||||
#define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a))
|
||||
#define luaL_optunsigned(L,a,d) \
|
||||
((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d)))
|
||||
|
||||
#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
|
||||
#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
|
||||
|
||||
#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
|
||||
#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
|
||||
|
||||
#endif
|
||||
/* }============================================================ */
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
517
enginecustom/include/Lua/lua.h
Normal file
517
enginecustom/include/Lua/lua.h
Normal file
@@ -0,0 +1,517 @@
|
||||
/*
|
||||
** $Id: lua.h $
|
||||
** Lua - A Scripting Language
|
||||
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
|
||||
** See Copyright Notice at the end of this file
|
||||
*/
|
||||
|
||||
|
||||
#ifndef lua_h
|
||||
#define lua_h
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
#include "luaconf.h"
|
||||
|
||||
|
||||
#define LUA_VERSION_MAJOR "5"
|
||||
#define LUA_VERSION_MINOR "4"
|
||||
#define LUA_VERSION_RELEASE "2"
|
||||
|
||||
#define LUA_VERSION_NUM 504
|
||||
#define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + 0)
|
||||
|
||||
#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
|
||||
#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
|
||||
#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2020 Lua.org, PUC-Rio"
|
||||
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
|
||||
|
||||
|
||||
/* mark for precompiled code ('<esc>Lua') */
|
||||
#define LUA_SIGNATURE "\x1bLua"
|
||||
|
||||
/* option for multiple returns in 'lua_pcall' and 'lua_call' */
|
||||
#define LUA_MULTRET (-1)
|
||||
|
||||
|
||||
/*
|
||||
** Pseudo-indices
|
||||
** (-LUAI_MAXSTACK is the minimum valid index; we keep some free empty
|
||||
** space after that to help overflow detection)
|
||||
*/
|
||||
#define LUA_REGISTRYINDEX (-LUAI_MAXSTACK - 1000)
|
||||
#define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i))
|
||||
|
||||
|
||||
/* thread status */
|
||||
#define LUA_OK 0
|
||||
#define LUA_YIELD 1
|
||||
#define LUA_ERRRUN 2
|
||||
#define LUA_ERRSYNTAX 3
|
||||
#define LUA_ERRMEM 4
|
||||
#define LUA_ERRERR 5
|
||||
|
||||
|
||||
typedef struct lua_State lua_State;
|
||||
|
||||
|
||||
/*
|
||||
** basic types
|
||||
*/
|
||||
#define LUA_TNONE (-1)
|
||||
|
||||
#define LUA_TNIL 0
|
||||
#define LUA_TBOOLEAN 1
|
||||
#define LUA_TLIGHTUSERDATA 2
|
||||
#define LUA_TNUMBER 3
|
||||
#define LUA_TSTRING 4
|
||||
#define LUA_TTABLE 5
|
||||
#define LUA_TFUNCTION 6
|
||||
#define LUA_TUSERDATA 7
|
||||
#define LUA_TTHREAD 8
|
||||
|
||||
#define LUA_NUMTYPES 9
|
||||
|
||||
|
||||
|
||||
/* minimum Lua stack available to a C function */
|
||||
#define LUA_MINSTACK 20
|
||||
|
||||
|
||||
/* predefined values in the registry */
|
||||
#define LUA_RIDX_MAINTHREAD 1
|
||||
#define LUA_RIDX_GLOBALS 2
|
||||
#define LUA_RIDX_LAST LUA_RIDX_GLOBALS
|
||||
|
||||
|
||||
/* type of numbers in Lua */
|
||||
typedef LUA_NUMBER lua_Number;
|
||||
|
||||
|
||||
/* type for integer functions */
|
||||
typedef LUA_INTEGER lua_Integer;
|
||||
|
||||
/* unsigned integer type */
|
||||
typedef LUA_UNSIGNED lua_Unsigned;
|
||||
|
||||
/* type for continuation-function contexts */
|
||||
typedef LUA_KCONTEXT lua_KContext;
|
||||
|
||||
|
||||
/*
|
||||
** Type for C functions registered with Lua
|
||||
*/
|
||||
typedef int (*lua_CFunction) (lua_State *L);
|
||||
|
||||
/*
|
||||
** Type for continuation functions
|
||||
*/
|
||||
typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx);
|
||||
|
||||
|
||||
/*
|
||||
** Type for functions that read/write blocks when loading/dumping Lua chunks
|
||||
*/
|
||||
typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
|
||||
|
||||
typedef int (*lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud);
|
||||
|
||||
|
||||
/*
|
||||
** Type for memory-allocation functions
|
||||
*/
|
||||
typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
|
||||
|
||||
|
||||
/*
|
||||
** Type for warning functions
|
||||
*/
|
||||
typedef void (*lua_WarnFunction) (void *ud, const char *msg, int tocont);
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** generic extra include file
|
||||
*/
|
||||
#if defined(LUA_USER_H)
|
||||
#include LUA_USER_H
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
** RCS ident string
|
||||
*/
|
||||
extern const char lua_ident[];
|
||||
|
||||
|
||||
/*
|
||||
** state manipulation
|
||||
*/
|
||||
LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
|
||||
LUA_API void (lua_close) (lua_State *L);
|
||||
LUA_API lua_State *(lua_newthread) (lua_State *L);
|
||||
LUA_API int (lua_resetthread) (lua_State *L);
|
||||
|
||||
LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
|
||||
|
||||
|
||||
LUA_API lua_Number (lua_version) (lua_State *L);
|
||||
|
||||
|
||||
/*
|
||||
** basic stack manipulation
|
||||
*/
|
||||
LUA_API int (lua_absindex) (lua_State *L, int idx);
|
||||
LUA_API int (lua_gettop) (lua_State *L);
|
||||
LUA_API void (lua_settop) (lua_State *L, int idx);
|
||||
LUA_API void (lua_pushvalue) (lua_State *L, int idx);
|
||||
LUA_API void (lua_rotate) (lua_State *L, int idx, int n);
|
||||
LUA_API void (lua_copy) (lua_State *L, int fromidx, int toidx);
|
||||
LUA_API int (lua_checkstack) (lua_State *L, int n);
|
||||
|
||||
LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n);
|
||||
|
||||
|
||||
/*
|
||||
** access functions (stack -> C)
|
||||
*/
|
||||
|
||||
LUA_API int (lua_isnumber) (lua_State *L, int idx);
|
||||
LUA_API int (lua_isstring) (lua_State *L, int idx);
|
||||
LUA_API int (lua_iscfunction) (lua_State *L, int idx);
|
||||
LUA_API int (lua_isinteger) (lua_State *L, int idx);
|
||||
LUA_API int (lua_isuserdata) (lua_State *L, int idx);
|
||||
LUA_API int (lua_type) (lua_State *L, int idx);
|
||||
LUA_API const char *(lua_typename) (lua_State *L, int tp);
|
||||
|
||||
LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum);
|
||||
LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum);
|
||||
LUA_API int (lua_toboolean) (lua_State *L, int idx);
|
||||
LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len);
|
||||
LUA_API lua_Unsigned (lua_rawlen) (lua_State *L, int idx);
|
||||
LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx);
|
||||
LUA_API void *(lua_touserdata) (lua_State *L, int idx);
|
||||
LUA_API lua_State *(lua_tothread) (lua_State *L, int idx);
|
||||
LUA_API const void *(lua_topointer) (lua_State *L, int idx);
|
||||
|
||||
|
||||
/*
|
||||
** Comparison and arithmetic functions
|
||||
*/
|
||||
|
||||
#define LUA_OPADD 0 /* ORDER TM, ORDER OP */
|
||||
#define LUA_OPSUB 1
|
||||
#define LUA_OPMUL 2
|
||||
#define LUA_OPMOD 3
|
||||
#define LUA_OPPOW 4
|
||||
#define LUA_OPDIV 5
|
||||
#define LUA_OPIDIV 6
|
||||
#define LUA_OPBAND 7
|
||||
#define LUA_OPBOR 8
|
||||
#define LUA_OPBXOR 9
|
||||
#define LUA_OPSHL 10
|
||||
#define LUA_OPSHR 11
|
||||
#define LUA_OPUNM 12
|
||||
#define LUA_OPBNOT 13
|
||||
|
||||
LUA_API void (lua_arith) (lua_State *L, int op);
|
||||
|
||||
#define LUA_OPEQ 0
|
||||
#define LUA_OPLT 1
|
||||
#define LUA_OPLE 2
|
||||
|
||||
LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);
|
||||
LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op);
|
||||
|
||||
|
||||
/*
|
||||
** push functions (C -> stack)
|
||||
*/
|
||||
LUA_API void (lua_pushnil) (lua_State *L);
|
||||
LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n);
|
||||
LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n);
|
||||
LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t len);
|
||||
LUA_API const char *(lua_pushstring) (lua_State *L, const char *s);
|
||||
LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
|
||||
va_list argp);
|
||||
LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
|
||||
LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
|
||||
LUA_API void (lua_pushboolean) (lua_State *L, int b);
|
||||
LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p);
|
||||
LUA_API int (lua_pushthread) (lua_State *L);
|
||||
|
||||
|
||||
/*
|
||||
** get functions (Lua -> stack)
|
||||
*/
|
||||
LUA_API int (lua_getglobal) (lua_State *L, const char *name);
|
||||
LUA_API int (lua_gettable) (lua_State *L, int idx);
|
||||
LUA_API int (lua_getfield) (lua_State *L, int idx, const char *k);
|
||||
LUA_API int (lua_geti) (lua_State *L, int idx, lua_Integer n);
|
||||
LUA_API int (lua_rawget) (lua_State *L, int idx);
|
||||
LUA_API int (lua_rawgeti) (lua_State *L, int idx, lua_Integer n);
|
||||
LUA_API int (lua_rawgetp) (lua_State *L, int idx, const void *p);
|
||||
|
||||
LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec);
|
||||
LUA_API void *(lua_newuserdatauv) (lua_State *L, size_t sz, int nuvalue);
|
||||
LUA_API int (lua_getmetatable) (lua_State *L, int objindex);
|
||||
LUA_API int (lua_getiuservalue) (lua_State *L, int idx, int n);
|
||||
|
||||
|
||||
/*
|
||||
** set functions (stack -> Lua)
|
||||
*/
|
||||
LUA_API void (lua_setglobal) (lua_State *L, const char *name);
|
||||
LUA_API void (lua_settable) (lua_State *L, int idx);
|
||||
LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k);
|
||||
LUA_API void (lua_seti) (lua_State *L, int idx, lua_Integer n);
|
||||
LUA_API void (lua_rawset) (lua_State *L, int idx);
|
||||
LUA_API void (lua_rawseti) (lua_State *L, int idx, lua_Integer n);
|
||||
LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p);
|
||||
LUA_API int (lua_setmetatable) (lua_State *L, int objindex);
|
||||
LUA_API int (lua_setiuservalue) (lua_State *L, int idx, int n);
|
||||
|
||||
|
||||
/*
|
||||
** 'load' and 'call' functions (load and run Lua code)
|
||||
*/
|
||||
LUA_API void (lua_callk) (lua_State *L, int nargs, int nresults,
|
||||
lua_KContext ctx, lua_KFunction k);
|
||||
#define lua_call(L,n,r) lua_callk(L, (n), (r), 0, NULL)
|
||||
|
||||
LUA_API int (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc,
|
||||
lua_KContext ctx, lua_KFunction k);
|
||||
#define lua_pcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL)
|
||||
|
||||
LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt,
|
||||
const char *chunkname, const char *mode);
|
||||
|
||||
LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data, int strip);
|
||||
|
||||
|
||||
/*
|
||||
** coroutine functions
|
||||
*/
|
||||
LUA_API int (lua_yieldk) (lua_State *L, int nresults, lua_KContext ctx,
|
||||
lua_KFunction k);
|
||||
LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg,
|
||||
int *nres);
|
||||
LUA_API int (lua_status) (lua_State *L);
|
||||
LUA_API int (lua_isyieldable) (lua_State *L);
|
||||
|
||||
#define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL)
|
||||
|
||||
|
||||
/*
|
||||
** Warning-related functions
|
||||
*/
|
||||
LUA_API void (lua_setwarnf) (lua_State *L, lua_WarnFunction f, void *ud);
|
||||
LUA_API void (lua_warning) (lua_State *L, const char *msg, int tocont);
|
||||
|
||||
|
||||
/*
|
||||
** garbage-collection function and options
|
||||
*/
|
||||
|
||||
#define LUA_GCSTOP 0
|
||||
#define LUA_GCRESTART 1
|
||||
#define LUA_GCCOLLECT 2
|
||||
#define LUA_GCCOUNT 3
|
||||
#define LUA_GCCOUNTB 4
|
||||
#define LUA_GCSTEP 5
|
||||
#define LUA_GCSETPAUSE 6
|
||||
#define LUA_GCSETSTEPMUL 7
|
||||
#define LUA_GCISRUNNING 9
|
||||
#define LUA_GCGEN 10
|
||||
#define LUA_GCINC 11
|
||||
|
||||
LUA_API int (lua_gc) (lua_State *L, int what, ...);
|
||||
|
||||
|
||||
/*
|
||||
** miscellaneous functions
|
||||
*/
|
||||
|
||||
LUA_API int (lua_error) (lua_State *L);
|
||||
|
||||
LUA_API int (lua_next) (lua_State *L, int idx);
|
||||
|
||||
LUA_API void (lua_concat) (lua_State *L, int n);
|
||||
LUA_API void (lua_len) (lua_State *L, int idx);
|
||||
|
||||
LUA_API size_t (lua_stringtonumber) (lua_State *L, const char *s);
|
||||
|
||||
LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
|
||||
LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud);
|
||||
|
||||
LUA_API void (lua_toclose) (lua_State *L, int idx);
|
||||
|
||||
|
||||
/*
|
||||
** {==============================================================
|
||||
** some useful macros
|
||||
** ===============================================================
|
||||
*/
|
||||
|
||||
#define lua_getextraspace(L) ((void *)((char *)(L) - LUA_EXTRASPACE))
|
||||
|
||||
#define lua_tonumber(L,i) lua_tonumberx(L,(i),NULL)
|
||||
#define lua_tointeger(L,i) lua_tointegerx(L,(i),NULL)
|
||||
|
||||
#define lua_pop(L,n) lua_settop(L, -(n)-1)
|
||||
|
||||
#define lua_newtable(L) lua_createtable(L, 0, 0)
|
||||
|
||||
#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
|
||||
|
||||
#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
|
||||
|
||||
#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)
|
||||
#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE)
|
||||
#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
|
||||
#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL)
|
||||
#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)
|
||||
#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)
|
||||
#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)
|
||||
#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
|
||||
|
||||
#define lua_pushliteral(L, s) lua_pushstring(L, "" s)
|
||||
|
||||
#define lua_pushglobaltable(L) \
|
||||
((void)lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS))
|
||||
|
||||
#define lua_tostring(L,i) lua_tolstring(L, (i), NULL)
|
||||
|
||||
|
||||
#define lua_insert(L,idx) lua_rotate(L, (idx), 1)
|
||||
|
||||
#define lua_remove(L,idx) (lua_rotate(L, (idx), -1), lua_pop(L, 1))
|
||||
|
||||
#define lua_replace(L,idx) (lua_copy(L, -1, (idx)), lua_pop(L, 1))
|
||||
|
||||
/* }============================================================== */
|
||||
|
||||
|
||||
/*
|
||||
** {==============================================================
|
||||
** compatibility macros
|
||||
** ===============================================================
|
||||
*/
|
||||
#if defined(LUA_COMPAT_APIINTCASTS)
|
||||
|
||||
#define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n))
|
||||
#define lua_tounsignedx(L,i,is) ((lua_Unsigned)lua_tointegerx(L,i,is))
|
||||
#define lua_tounsigned(L,i) lua_tounsignedx(L,(i),NULL)
|
||||
|
||||
#endif
|
||||
|
||||
#define lua_newuserdata(L,s) lua_newuserdatauv(L,s,1)
|
||||
#define lua_getuservalue(L,idx) lua_getiuservalue(L,idx,1)
|
||||
#define lua_setuservalue(L,idx) lua_setiuservalue(L,idx,1)
|
||||
|
||||
#define LUA_NUMTAGS LUA_NUMTYPES
|
||||
|
||||
/* }============================================================== */
|
||||
|
||||
/*
|
||||
** {======================================================================
|
||||
** Debug API
|
||||
** =======================================================================
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
** Event codes
|
||||
*/
|
||||
#define LUA_HOOKCALL 0
|
||||
#define LUA_HOOKRET 1
|
||||
#define LUA_HOOKLINE 2
|
||||
#define LUA_HOOKCOUNT 3
|
||||
#define LUA_HOOKTAILCALL 4
|
||||
|
||||
|
||||
/*
|
||||
** Event masks
|
||||
*/
|
||||
#define LUA_MASKCALL (1 << LUA_HOOKCALL)
|
||||
#define LUA_MASKRET (1 << LUA_HOOKRET)
|
||||
#define LUA_MASKLINE (1 << LUA_HOOKLINE)
|
||||
#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT)
|
||||
|
||||
typedef struct lua_Debug lua_Debug; /* activation record */
|
||||
|
||||
|
||||
/* Functions to be called by the debugger in specific events */
|
||||
typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
|
||||
|
||||
|
||||
LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar);
|
||||
LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar);
|
||||
LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n);
|
||||
LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n);
|
||||
LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n);
|
||||
LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n);
|
||||
|
||||
LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n);
|
||||
LUA_API void (lua_upvaluejoin) (lua_State *L, int fidx1, int n1,
|
||||
int fidx2, int n2);
|
||||
|
||||
LUA_API void (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count);
|
||||
LUA_API lua_Hook (lua_gethook) (lua_State *L);
|
||||
LUA_API int (lua_gethookmask) (lua_State *L);
|
||||
LUA_API int (lua_gethookcount) (lua_State *L);
|
||||
|
||||
LUA_API int (lua_setcstacklimit) (lua_State *L, unsigned int limit);
|
||||
|
||||
struct lua_Debug {
|
||||
int event;
|
||||
const char *name; /* (n) */
|
||||
const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */
|
||||
const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */
|
||||
const char *source; /* (S) */
|
||||
size_t srclen; /* (S) */
|
||||
int currentline; /* (l) */
|
||||
int linedefined; /* (S) */
|
||||
int lastlinedefined; /* (S) */
|
||||
unsigned char nups; /* (u) number of upvalues */
|
||||
unsigned char nparams;/* (u) number of parameters */
|
||||
char isvararg; /* (u) */
|
||||
char istailcall; /* (t) */
|
||||
unsigned short ftransfer; /* (r) index of first value transferred */
|
||||
unsigned short ntransfer; /* (r) number of transferred values */
|
||||
char short_src[LUA_IDSIZE]; /* (S) */
|
||||
/* private part */
|
||||
struct CallInfo *i_ci; /* active function */
|
||||
};
|
||||
|
||||
/* }====================================================================== */
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright (C) 1994-2020 Lua.org, PUC-Rio.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#endif
|
||||
9
enginecustom/include/Lua/lua.hpp
Normal file
9
enginecustom/include/Lua/lua.hpp
Normal file
@@ -0,0 +1,9 @@
|
||||
// lua.hpp
|
||||
// Lua header files for C++
|
||||
// <<extern "C">> not supplied automatically because Lua also compiles as C++
|
||||
|
||||
extern "C" {
|
||||
#include "lua.h"
|
||||
#include "lualib.h"
|
||||
#include "lauxlib.h"
|
||||
}
|
||||
763
enginecustom/include/Lua/luaconf.h
Normal file
763
enginecustom/include/Lua/luaconf.h
Normal file
@@ -0,0 +1,763 @@
|
||||
/*
|
||||
** $Id: luaconf.h $
|
||||
** Configuration file for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef luaconf_h
|
||||
#define luaconf_h
|
||||
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** General Configuration File for Lua
|
||||
**
|
||||
** Some definitions here can be changed externally, through the
|
||||
** compiler (e.g., with '-D' options). Those are protected by
|
||||
** '#if !defined' guards. However, several other definitions should
|
||||
** be changed directly here, either because they affect the Lua
|
||||
** ABI (by making the changes here, you ensure that all software
|
||||
** connected to Lua, such as C libraries, will be compiled with the
|
||||
** same configuration); or because they are seldom changed.
|
||||
**
|
||||
** Search for "@@" to find all configurable definitions.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
** {====================================================================
|
||||
** System Configuration: macros to adapt (if needed) Lua to some
|
||||
** particular platform, for instance restricting it to C89.
|
||||
** =====================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ LUA_USE_C89 controls the use of non-ISO-C89 features.
|
||||
** Define it if you want Lua to avoid the use of a few C99 features
|
||||
** or Windows-specific features on Windows.
|
||||
*/
|
||||
/* #define LUA_USE_C89 */
|
||||
|
||||
|
||||
/*
|
||||
** By default, Lua on Windows use (some) specific Windows features
|
||||
*/
|
||||
#if !defined(LUA_USE_C89) && defined(_WIN32) && !defined(_WIN32_WCE)
|
||||
#define LUA_USE_WINDOWS /* enable goodies for regular Windows */
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(LUA_USE_WINDOWS)
|
||||
#define LUA_DL_DLL /* enable support for DLL */
|
||||
#define LUA_USE_C89 /* broadly, Windows is C89 */
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(LUA_USE_LINUX)
|
||||
#define LUA_USE_POSIX
|
||||
#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(LUA_USE_MACOSX)
|
||||
#define LUA_USE_POSIX
|
||||
#define LUA_USE_DLOPEN /* MacOS does not need -ldl */
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits.
|
||||
*/
|
||||
#define LUAI_IS32INT ((UINT_MAX >> 30) >= 3)
|
||||
|
||||
/* }================================================================== */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** {==================================================================
|
||||
** Configuration for Number types.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats.
|
||||
*/
|
||||
/* #define LUA_32BITS */
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for
|
||||
** C89 ('long' and 'double'); Windows always has '__int64', so it does
|
||||
** not need to use this case.
|
||||
*/
|
||||
#if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS)
|
||||
#define LUA_C89_NUMBERS
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_INT_TYPE defines the type for Lua integers.
|
||||
@@ LUA_FLOAT_TYPE defines the type for Lua floats.
|
||||
** Lua should work fine with any mix of these options supported
|
||||
** by your C compiler. The usual configurations are 64-bit integers
|
||||
** and 'double' (the default), 32-bit integers and 'float' (for
|
||||
** restricted platforms), and 'long'/'double' (for C compilers not
|
||||
** compliant with C99, which may not have support for 'long long').
|
||||
*/
|
||||
|
||||
/* predefined options for LUA_INT_TYPE */
|
||||
#define LUA_INT_INT 1
|
||||
#define LUA_INT_LONG 2
|
||||
#define LUA_INT_LONGLONG 3
|
||||
|
||||
/* predefined options for LUA_FLOAT_TYPE */
|
||||
#define LUA_FLOAT_FLOAT 1
|
||||
#define LUA_FLOAT_DOUBLE 2
|
||||
#define LUA_FLOAT_LONGDOUBLE 3
|
||||
|
||||
#if defined(LUA_32BITS) /* { */
|
||||
/*
|
||||
** 32-bit integers and 'float'
|
||||
*/
|
||||
#if LUAI_IS32INT /* use 'int' if big enough */
|
||||
#define LUA_INT_TYPE LUA_INT_INT
|
||||
#else /* otherwise use 'long' */
|
||||
#define LUA_INT_TYPE LUA_INT_LONG
|
||||
#endif
|
||||
#define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT
|
||||
|
||||
#elif defined(LUA_C89_NUMBERS) /* }{ */
|
||||
/*
|
||||
** largest types available for C89 ('long' and 'double')
|
||||
*/
|
||||
#define LUA_INT_TYPE LUA_INT_LONG
|
||||
#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE
|
||||
|
||||
#endif /* } */
|
||||
|
||||
|
||||
/*
|
||||
** default configuration for 64-bit Lua ('long long' and 'double')
|
||||
*/
|
||||
#if !defined(LUA_INT_TYPE)
|
||||
#define LUA_INT_TYPE LUA_INT_LONGLONG
|
||||
#endif
|
||||
|
||||
#if !defined(LUA_FLOAT_TYPE)
|
||||
#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE
|
||||
#endif
|
||||
|
||||
/* }================================================================== */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** {==================================================================
|
||||
** Configuration for Paths.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
** LUA_PATH_SEP is the character that separates templates in a path.
|
||||
** LUA_PATH_MARK is the string that marks the substitution points in a
|
||||
** template.
|
||||
** LUA_EXEC_DIR in a Windows path is replaced by the executable's
|
||||
** directory.
|
||||
*/
|
||||
#define LUA_PATH_SEP ";"
|
||||
#define LUA_PATH_MARK "?"
|
||||
#define LUA_EXEC_DIR "!"
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
|
||||
** Lua libraries.
|
||||
@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
|
||||
** C libraries.
|
||||
** CHANGE them if your machine has a non-conventional directory
|
||||
** hierarchy or if you want to install your libraries in
|
||||
** non-conventional directories.
|
||||
*/
|
||||
|
||||
#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
|
||||
#if defined(_WIN32) /* { */
|
||||
/*
|
||||
** In Windows, any exclamation mark ('!') in the path is replaced by the
|
||||
** path of the directory of the executable file of the current process.
|
||||
*/
|
||||
#define LUA_LDIR "!\\lua\\"
|
||||
#define LUA_CDIR "!\\"
|
||||
#define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\"
|
||||
|
||||
#if !defined(LUA_PATH_DEFAULT)
|
||||
#define LUA_PATH_DEFAULT \
|
||||
LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
|
||||
LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \
|
||||
LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \
|
||||
".\\?.lua;" ".\\?\\init.lua"
|
||||
#endif
|
||||
|
||||
#if !defined(LUA_CPATH_DEFAULT)
|
||||
#define LUA_CPATH_DEFAULT \
|
||||
LUA_CDIR"?.dll;" \
|
||||
LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \
|
||||
LUA_CDIR"loadall.dll;" ".\\?.dll;" \
|
||||
LUA_CDIR"?54.dll;" ".\\?54.dll"
|
||||
#endif
|
||||
|
||||
#else /* }{ */
|
||||
|
||||
#define LUA_ROOT "/usr/local/"
|
||||
#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/"
|
||||
#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/"
|
||||
|
||||
#if !defined(LUA_PATH_DEFAULT)
|
||||
#define LUA_PATH_DEFAULT \
|
||||
LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
|
||||
LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \
|
||||
"./?.lua;" "./?/init.lua"
|
||||
#endif
|
||||
|
||||
#if !defined(LUA_CPATH_DEFAULT)
|
||||
#define LUA_CPATH_DEFAULT \
|
||||
LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so;" \
|
||||
LUA_CDIR"lib?54.so;" "./lib?54.so"
|
||||
#endif
|
||||
|
||||
#endif /* } */
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_DIRSEP is the directory separator (for submodules).
|
||||
** CHANGE it if your machine does not use "/" as the directory separator
|
||||
** and is not Windows. (On Windows Lua automatically uses "\".)
|
||||
*/
|
||||
#if !defined(LUA_DIRSEP)
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define LUA_DIRSEP "\\"
|
||||
#else
|
||||
#define LUA_DIRSEP "/"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* }================================================================== */
|
||||
|
||||
|
||||
/*
|
||||
** {==================================================================
|
||||
** Marks for exported symbols in the C code
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ LUA_API is a mark for all core API functions.
|
||||
@@ LUALIB_API is a mark for all auxiliary library functions.
|
||||
@@ LUAMOD_API is a mark for all standard library opening functions.
|
||||
** CHANGE them if you need to define those functions in some special way.
|
||||
** For instance, if you want to create one Windows DLL with the core and
|
||||
** the libraries, you may want to use the following definition (define
|
||||
** LUA_BUILD_AS_DLL to get it).
|
||||
*/
|
||||
#if defined(LUA_BUILD_AS_DLL) /* { */
|
||||
|
||||
#if defined(LUA_CORE) || defined(LUA_LIB) /* { */
|
||||
#define LUA_API __declspec(dllexport)
|
||||
#else /* }{ */
|
||||
#define LUA_API __declspec(dllimport)
|
||||
#endif /* } */
|
||||
|
||||
#else /* }{ */
|
||||
|
||||
#define LUA_API extern
|
||||
|
||||
#endif /* } */
|
||||
|
||||
|
||||
/*
|
||||
** More often than not the libs go together with the core.
|
||||
*/
|
||||
#define LUALIB_API LUA_API
|
||||
#define LUAMOD_API LUA_API
|
||||
|
||||
|
||||
/*
|
||||
@@ LUAI_FUNC is a mark for all extern functions that are not to be
|
||||
** exported to outside modules.
|
||||
@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables,
|
||||
** none of which to be exported to outside modules (LUAI_DDEF for
|
||||
** definitions and LUAI_DDEC for declarations).
|
||||
** CHANGE them if you need to mark them in some special way. Elf/gcc
|
||||
** (versions 3.2 and later) mark them as "hidden" to optimize access
|
||||
** when Lua is compiled as a shared library. Not all elf targets support
|
||||
** this attribute. Unfortunately, gcc does not offer a way to check
|
||||
** whether the target offers that support, and those without support
|
||||
** give a warning about it. To avoid these warnings, change to the
|
||||
** default definition.
|
||||
*/
|
||||
#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
|
||||
defined(__ELF__) /* { */
|
||||
#define LUAI_FUNC __attribute__((visibility("internal"))) extern
|
||||
#else /* }{ */
|
||||
#define LUAI_FUNC extern
|
||||
#endif /* } */
|
||||
|
||||
#define LUAI_DDEC(dec) LUAI_FUNC dec
|
||||
#define LUAI_DDEF /* empty */
|
||||
|
||||
/* }================================================================== */
|
||||
|
||||
|
||||
/*
|
||||
** {==================================================================
|
||||
** Compatibility with previous versions
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ LUA_COMPAT_5_3 controls other macros for compatibility with Lua 5.3.
|
||||
** You can define it to get all options, or change specific options
|
||||
** to fit your specific needs.
|
||||
*/
|
||||
#if defined(LUA_COMPAT_5_3) /* { */
|
||||
|
||||
/*
|
||||
@@ LUA_COMPAT_MATHLIB controls the presence of several deprecated
|
||||
** functions in the mathematical library.
|
||||
** (These functions were already officially removed in 5.3;
|
||||
** nevertheless they are still available here.)
|
||||
*/
|
||||
#define LUA_COMPAT_MATHLIB
|
||||
|
||||
/*
|
||||
@@ LUA_COMPAT_APIINTCASTS controls the presence of macros for
|
||||
** manipulating other integer types (lua_pushunsigned, lua_tounsigned,
|
||||
** luaL_checkint, luaL_checklong, etc.)
|
||||
** (These macros were also officially removed in 5.3, but they are still
|
||||
** available here.)
|
||||
*/
|
||||
#define LUA_COMPAT_APIINTCASTS
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_COMPAT_LT_LE controls the emulation of the '__le' metamethod
|
||||
** using '__lt'.
|
||||
*/
|
||||
#define LUA_COMPAT_LT_LE
|
||||
|
||||
|
||||
/*
|
||||
@@ The following macros supply trivial compatibility for some
|
||||
** changes in the API. The macros themselves document how to
|
||||
** change your code to avoid using them.
|
||||
** (Once more, these macros were officially removed in 5.3, but they are
|
||||
** still available here.)
|
||||
*/
|
||||
#define lua_strlen(L,i) lua_rawlen(L, (i))
|
||||
|
||||
#define lua_objlen(L,i) lua_rawlen(L, (i))
|
||||
|
||||
#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)
|
||||
#define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT)
|
||||
|
||||
#endif /* } */
|
||||
|
||||
/* }================================================================== */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** {==================================================================
|
||||
** Configuration for Numbers.
|
||||
** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_*
|
||||
** satisfy your needs.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ LUA_NUMBER is the floating-point type used by Lua.
|
||||
@@ LUAI_UACNUMBER is the result of a 'default argument promotion'
|
||||
@@ over a floating number.
|
||||
@@ l_floatatt(x) corrects float attribute 'x' to the proper float type
|
||||
** by prefixing it with one of FLT/DBL/LDBL.
|
||||
@@ LUA_NUMBER_FRMLEN is the length modifier for writing floats.
|
||||
@@ LUA_NUMBER_FMT is the format for writing floats.
|
||||
@@ lua_number2str converts a float to a string.
|
||||
@@ l_mathop allows the addition of an 'l' or 'f' to all math operations.
|
||||
@@ l_floor takes the floor of a float.
|
||||
@@ lua_str2number converts a decimal numeral to a number.
|
||||
*/
|
||||
|
||||
|
||||
/* The following definitions are good for most cases here */
|
||||
|
||||
#define l_floor(x) (l_mathop(floor)(x))
|
||||
|
||||
#define lua_number2str(s,sz,n) \
|
||||
l_sprintf((s), sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)(n))
|
||||
|
||||
/*
|
||||
@@ lua_numbertointeger converts a float number with an integral value
|
||||
** to an integer, or returns 0 if float is not within the range of
|
||||
** a lua_Integer. (The range comparisons are tricky because of
|
||||
** rounding. The tests here assume a two-complement representation,
|
||||
** where MININTEGER always has an exact representation as a float;
|
||||
** MAXINTEGER may not have one, and therefore its conversion to float
|
||||
** may have an ill-defined value.)
|
||||
*/
|
||||
#define lua_numbertointeger(n,p) \
|
||||
((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \
|
||||
(n) < -(LUA_NUMBER)(LUA_MININTEGER) && \
|
||||
(*(p) = (LUA_INTEGER)(n), 1))
|
||||
|
||||
|
||||
/* now the variable definitions */
|
||||
|
||||
#if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT /* { single float */
|
||||
|
||||
#define LUA_NUMBER float
|
||||
|
||||
#define l_floatatt(n) (FLT_##n)
|
||||
|
||||
#define LUAI_UACNUMBER double
|
||||
|
||||
#define LUA_NUMBER_FRMLEN ""
|
||||
#define LUA_NUMBER_FMT "%.7g"
|
||||
|
||||
#define l_mathop(op) op##f
|
||||
|
||||
#define lua_str2number(s,p) strtof((s), (p))
|
||||
|
||||
|
||||
#elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE /* }{ long double */
|
||||
|
||||
#define LUA_NUMBER long double
|
||||
|
||||
#define l_floatatt(n) (LDBL_##n)
|
||||
|
||||
#define LUAI_UACNUMBER long double
|
||||
|
||||
#define LUA_NUMBER_FRMLEN "L"
|
||||
#define LUA_NUMBER_FMT "%.19Lg"
|
||||
|
||||
#define l_mathop(op) op##l
|
||||
|
||||
#define lua_str2number(s,p) strtold((s), (p))
|
||||
|
||||
#elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE /* }{ double */
|
||||
|
||||
#define LUA_NUMBER double
|
||||
|
||||
#define l_floatatt(n) (DBL_##n)
|
||||
|
||||
#define LUAI_UACNUMBER double
|
||||
|
||||
#define LUA_NUMBER_FRMLEN ""
|
||||
#define LUA_NUMBER_FMT "%.14g"
|
||||
|
||||
#define l_mathop(op) op
|
||||
|
||||
#define lua_str2number(s,p) strtod((s), (p))
|
||||
|
||||
#else /* }{ */
|
||||
|
||||
#error "numeric float type not defined"
|
||||
|
||||
#endif /* } */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_INTEGER is the integer type used by Lua.
|
||||
**
|
||||
@@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER.
|
||||
**
|
||||
@@ LUAI_UACINT is the result of a 'default argument promotion'
|
||||
@@ over a LUA_INTEGER.
|
||||
@@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers.
|
||||
@@ LUA_INTEGER_FMT is the format for writing integers.
|
||||
@@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER.
|
||||
@@ LUA_MININTEGER is the minimum value for a LUA_INTEGER.
|
||||
@@ LUA_MAXUNSIGNED is the maximum value for a LUA_UNSIGNED.
|
||||
@@ LUA_UNSIGNEDBITS is the number of bits in a LUA_UNSIGNED.
|
||||
@@ lua_integer2str converts an integer to a string.
|
||||
*/
|
||||
|
||||
|
||||
/* The following definitions are good for most cases here */
|
||||
|
||||
#define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d"
|
||||
|
||||
#define LUAI_UACINT LUA_INTEGER
|
||||
|
||||
#define lua_integer2str(s,sz,n) \
|
||||
l_sprintf((s), sz, LUA_INTEGER_FMT, (LUAI_UACINT)(n))
|
||||
|
||||
/*
|
||||
** use LUAI_UACINT here to avoid problems with promotions (which
|
||||
** can turn a comparison between unsigneds into a signed comparison)
|
||||
*/
|
||||
#define LUA_UNSIGNED unsigned LUAI_UACINT
|
||||
|
||||
|
||||
#define LUA_UNSIGNEDBITS (sizeof(LUA_UNSIGNED) * CHAR_BIT)
|
||||
|
||||
|
||||
/* now the variable definitions */
|
||||
|
||||
#if LUA_INT_TYPE == LUA_INT_INT /* { int */
|
||||
|
||||
#define LUA_INTEGER int
|
||||
#define LUA_INTEGER_FRMLEN ""
|
||||
|
||||
#define LUA_MAXINTEGER INT_MAX
|
||||
#define LUA_MININTEGER INT_MIN
|
||||
|
||||
#define LUA_MAXUNSIGNED UINT_MAX
|
||||
|
||||
#elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */
|
||||
|
||||
#define LUA_INTEGER long
|
||||
#define LUA_INTEGER_FRMLEN "l"
|
||||
|
||||
#define LUA_MAXINTEGER LONG_MAX
|
||||
#define LUA_MININTEGER LONG_MIN
|
||||
|
||||
#define LUA_MAXUNSIGNED ULONG_MAX
|
||||
|
||||
#elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */
|
||||
|
||||
/* use presence of macro LLONG_MAX as proxy for C99 compliance */
|
||||
#if defined(LLONG_MAX) /* { */
|
||||
/* use ISO C99 stuff */
|
||||
|
||||
#define LUA_INTEGER long long
|
||||
#define LUA_INTEGER_FRMLEN "ll"
|
||||
|
||||
#define LUA_MAXINTEGER LLONG_MAX
|
||||
#define LUA_MININTEGER LLONG_MIN
|
||||
|
||||
#define LUA_MAXUNSIGNED ULLONG_MAX
|
||||
|
||||
#elif defined(LUA_USE_WINDOWS) /* }{ */
|
||||
/* in Windows, can use specific Windows types */
|
||||
|
||||
#define LUA_INTEGER __int64
|
||||
#define LUA_INTEGER_FRMLEN "I64"
|
||||
|
||||
#define LUA_MAXINTEGER _I64_MAX
|
||||
#define LUA_MININTEGER _I64_MIN
|
||||
|
||||
#define LUA_MAXUNSIGNED _UI64_MAX
|
||||
|
||||
#else /* }{ */
|
||||
|
||||
#error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \
|
||||
or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)"
|
||||
|
||||
#endif /* } */
|
||||
|
||||
#else /* }{ */
|
||||
|
||||
#error "numeric integer type not defined"
|
||||
|
||||
#endif /* } */
|
||||
|
||||
/* }================================================================== */
|
||||
|
||||
|
||||
/*
|
||||
** {==================================================================
|
||||
** Dependencies with C99 and other C details
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ l_sprintf is equivalent to 'snprintf' or 'sprintf' in C89.
|
||||
** (All uses in Lua have only one format item.)
|
||||
*/
|
||||
#if !defined(LUA_USE_C89)
|
||||
#define l_sprintf(s,sz,f,i) snprintf(s,sz,f,i)
|
||||
#else
|
||||
#define l_sprintf(s,sz,f,i) ((void)(sz), sprintf(s,f,i))
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ lua_strx2number converts a hexadecimal numeral to a number.
|
||||
** In C99, 'strtod' does that conversion. Otherwise, you can
|
||||
** leave 'lua_strx2number' undefined and Lua will provide its own
|
||||
** implementation.
|
||||
*/
|
||||
#if !defined(LUA_USE_C89)
|
||||
#define lua_strx2number(s,p) lua_str2number(s,p)
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ lua_pointer2str converts a pointer to a readable string in a
|
||||
** non-specified way.
|
||||
*/
|
||||
#define lua_pointer2str(buff,sz,p) l_sprintf(buff,sz,"%p",p)
|
||||
|
||||
|
||||
/*
|
||||
@@ lua_number2strx converts a float to a hexadecimal numeral.
|
||||
** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that.
|
||||
** Otherwise, you can leave 'lua_number2strx' undefined and Lua will
|
||||
** provide its own implementation.
|
||||
*/
|
||||
#if !defined(LUA_USE_C89)
|
||||
#define lua_number2strx(L,b,sz,f,n) \
|
||||
((void)L, l_sprintf(b,sz,f,(LUAI_UACNUMBER)(n)))
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
** 'strtof' and 'opf' variants for math functions are not valid in
|
||||
** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the
|
||||
** availability of these variants. ('math.h' is already included in
|
||||
** all files that use these macros.)
|
||||
*/
|
||||
#if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF))
|
||||
#undef l_mathop /* variants not available */
|
||||
#undef lua_str2number
|
||||
#define l_mathop(op) (lua_Number)op /* no variant */
|
||||
#define lua_str2number(s,p) ((lua_Number)strtod((s), (p)))
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_KCONTEXT is the type of the context ('ctx') for continuation
|
||||
** functions. It must be a numerical type; Lua will use 'intptr_t' if
|
||||
** available, otherwise it will use 'ptrdiff_t' (the nearest thing to
|
||||
** 'intptr_t' in C89)
|
||||
*/
|
||||
#define LUA_KCONTEXT ptrdiff_t
|
||||
|
||||
#if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \
|
||||
__STDC_VERSION__ >= 199901L
|
||||
#include <stdint.h>
|
||||
#if defined(INTPTR_MAX) /* even in C99 this type is optional */
|
||||
#undef LUA_KCONTEXT
|
||||
#define LUA_KCONTEXT intptr_t
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ lua_getlocaledecpoint gets the locale "radix character" (decimal point).
|
||||
** Change that if you do not want to use C locales. (Code using this
|
||||
** macro must include the header 'locale.h'.)
|
||||
*/
|
||||
#if !defined(lua_getlocaledecpoint)
|
||||
#define lua_getlocaledecpoint() (localeconv()->decimal_point[0])
|
||||
#endif
|
||||
|
||||
/* }================================================================== */
|
||||
|
||||
|
||||
/*
|
||||
** {==================================================================
|
||||
** Language Variations
|
||||
** =====================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ LUA_NOCVTN2S/LUA_NOCVTS2N control how Lua performs some
|
||||
** coercions. Define LUA_NOCVTN2S to turn off automatic coercion from
|
||||
** numbers to strings. Define LUA_NOCVTS2N to turn off automatic
|
||||
** coercion from strings to numbers.
|
||||
*/
|
||||
/* #define LUA_NOCVTN2S */
|
||||
/* #define LUA_NOCVTS2N */
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_USE_APICHECK turns on several consistency checks on the C API.
|
||||
** Define it as a help when debugging C code.
|
||||
*/
|
||||
#if defined(LUA_USE_APICHECK)
|
||||
#include <assert.h>
|
||||
#define luai_apicheck(l,e) assert(e)
|
||||
#endif
|
||||
|
||||
/* }================================================================== */
|
||||
|
||||
|
||||
/*
|
||||
** {==================================================================
|
||||
** Macros that affect the API and must be stable (that is, must be the
|
||||
** same when you compile Lua and when you compile code that links to
|
||||
** Lua).
|
||||
** =====================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ LUAI_MAXSTACK limits the size of the Lua stack.
|
||||
** CHANGE it if you need a different limit. This limit is arbitrary;
|
||||
** its only purpose is to stop Lua from consuming unlimited stack
|
||||
** space (and to reserve some numbers for pseudo-indices).
|
||||
** (It must fit into max(size_t)/32.)
|
||||
*/
|
||||
#if LUAI_IS32INT
|
||||
#define LUAI_MAXSTACK 1000000
|
||||
#else
|
||||
#define LUAI_MAXSTACK 15000
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_EXTRASPACE defines the size of a raw memory area associated with
|
||||
** a Lua state with very fast access.
|
||||
** CHANGE it if you need a different size.
|
||||
*/
|
||||
#define LUA_EXTRASPACE (sizeof(void *))
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_IDSIZE gives the maximum size for the description of the source
|
||||
@@ of a function in debug information.
|
||||
** CHANGE it if you want a different size.
|
||||
*/
|
||||
#define LUA_IDSIZE 60
|
||||
|
||||
|
||||
/*
|
||||
@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
|
||||
*/
|
||||
#define LUAL_BUFFERSIZE ((int)(16 * sizeof(void*) * sizeof(lua_Number)))
|
||||
|
||||
|
||||
/*
|
||||
@@ LUAI_MAXALIGN defines fields that, when used in a union, ensure
|
||||
** maximum alignment for the other items in that union.
|
||||
*/
|
||||
#define LUAI_MAXALIGN lua_Number n; double u; void *s; lua_Integer i; long l
|
||||
|
||||
/* }================================================================== */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* =================================================================== */
|
||||
|
||||
/*
|
||||
** Local configuration. You can use this space to add your redefinitions
|
||||
** without modifying the main part of the file.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
58
enginecustom/include/Lua/lualib.h
Normal file
58
enginecustom/include/Lua/lualib.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
** $Id: lualib.h $
|
||||
** Lua standard libraries
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef lualib_h
|
||||
#define lualib_h
|
||||
|
||||
#include "lua.h"
|
||||
|
||||
|
||||
/* version suffix for environment variable names */
|
||||
#define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
|
||||
|
||||
|
||||
LUAMOD_API int (luaopen_base) (lua_State *L);
|
||||
|
||||
#define LUA_COLIBNAME "coroutine"
|
||||
LUAMOD_API int (luaopen_coroutine) (lua_State *L);
|
||||
|
||||
#define LUA_TABLIBNAME "table"
|
||||
LUAMOD_API int (luaopen_table) (lua_State *L);
|
||||
|
||||
#define LUA_IOLIBNAME "io"
|
||||
LUAMOD_API int (luaopen_io) (lua_State *L);
|
||||
|
||||
#define LUA_OSLIBNAME "os"
|
||||
LUAMOD_API int (luaopen_os) (lua_State *L);
|
||||
|
||||
#define LUA_STRLIBNAME "string"
|
||||
LUAMOD_API int (luaopen_string) (lua_State *L);
|
||||
|
||||
#define LUA_UTF8LIBNAME "utf8"
|
||||
LUAMOD_API int (luaopen_utf8) (lua_State *L);
|
||||
|
||||
#define LUA_MATHLIBNAME "math"
|
||||
LUAMOD_API int (luaopen_math) (lua_State *L);
|
||||
|
||||
#define LUA_DBLIBNAME "debug"
|
||||
LUAMOD_API int (luaopen_debug) (lua_State *L);
|
||||
|
||||
#define LUA_LOADLIBNAME "package"
|
||||
LUAMOD_API int (luaopen_package) (lua_State *L);
|
||||
|
||||
|
||||
/* open all previous libraries */
|
||||
LUALIB_API void (luaL_openlibs) (lua_State *L);
|
||||
|
||||
|
||||
|
||||
#if !defined(lua_assert)
|
||||
#define lua_assert(x) ((void)0)
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,8 +1,6 @@
|
||||
/////////////
|
||||
// GLOBALS //
|
||||
/////////////
|
||||
Texture2D shaderTexture : register(t0);
|
||||
SamplerState SampleType : register(s0);
|
||||
|
||||
//////////////
|
||||
// TYPEDEFS //
|
||||
@@ -10,7 +8,6 @@ SamplerState SampleType : register(s0);
|
||||
struct PixelInputType
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float2 tex : TEXCOORD0;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -14,13 +14,11 @@ cbuffer MatrixBuffer
|
||||
struct VertexInputType
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float2 tex : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PixelInputType
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float2 tex : TEXCOORD0;
|
||||
};
|
||||
|
||||
|
||||
@@ -40,8 +38,5 @@ PixelInputType DepthVertexShader(VertexInputType input)
|
||||
output.position = mul(output.position, viewMatrix);
|
||||
output.position = mul(output.position, projectionMatrix);
|
||||
|
||||
// Store the texture coordinates for the pixel shader.
|
||||
output.tex = input.tex;
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <d3dcompiler.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <d3dcompiler.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <d3dcompiler.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <d3dcompiler.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
using namespace std;
|
||||
|
||||
@@ -34,14 +35,14 @@ public:
|
||||
|
||||
bool initialize(ID3D11Device*, HWND);
|
||||
void shutdown();
|
||||
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*);
|
||||
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX);
|
||||
|
||||
private:
|
||||
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
|
||||
void shutdown_shader();
|
||||
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
|
||||
|
||||
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*);
|
||||
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX);
|
||||
void render_shader(ID3D11DeviceContext*, int);
|
||||
|
||||
private:
|
||||
@@ -49,7 +50,6 @@ private:
|
||||
ID3D11PixelShader* pixel_shader_;
|
||||
ID3D11InputLayout* layout_;
|
||||
ID3D11Buffer* matrix_buffer_;
|
||||
ID3D11SamplerState* sample_state_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <d3dcompiler.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <d3dcompiler.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ constexpr int num_lights = 4;
|
||||
#include <d3dcompiler.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <d3d11.h>
|
||||
#include <DirectXMath.h>
|
||||
#include <string>
|
||||
#include "macro.h"
|
||||
|
||||
|
||||
class master_shader
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <d3dcompiler.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <d3dcompiler.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <d3dcompiler.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <d3dcompiler.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "skybox_shader_class.h"
|
||||
#include "sunlight_shader_class.h"
|
||||
#include "depth_shader_class.h"
|
||||
#include "macro.h"
|
||||
|
||||
using namespace DirectX;
|
||||
|
||||
@@ -53,8 +54,7 @@ public:
|
||||
int indexCount,
|
||||
XMMATRIX worldMatrix,
|
||||
XMMATRIX viewMatrix,
|
||||
XMMATRIX projectionMatrix,
|
||||
ID3D11ShaderResourceView* texture
|
||||
XMMATRIX projectionMatrix
|
||||
);
|
||||
|
||||
private:
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <d3dcompiler.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <d3dcompiler.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <d3dcompiler.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <d3dcompiler.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <d3dcompiler.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <d3dcompiler.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <d3dcompiler.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "camera_class.h"
|
||||
#include "light_class.h"
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
#include "Fmod/core/inc/fmod.hpp"
|
||||
|
||||
#include "bitmap_class.h"
|
||||
@@ -61,8 +63,6 @@
|
||||
// GLOBALS //
|
||||
/////////////
|
||||
constexpr bool full_screen = false;
|
||||
constexpr float screen_depth = 1000.0f;
|
||||
constexpr float screen_near = 0.3f;
|
||||
|
||||
static std::map<std::string, std::shared_ptr<model_class>> g_model_cache;
|
||||
|
||||
@@ -381,7 +381,7 @@ public:
|
||||
* Construct the frustum for culling.
|
||||
* This function will calculate the frustum based on the current camera view and projection matrices.
|
||||
*/
|
||||
void construct_frustum();
|
||||
void construct_frustum(frustum& frustum, float screen_depth, XMMATRIX projectionMatrix, XMMATRIX viewMatrix);
|
||||
|
||||
/**
|
||||
* Get the number of objects rendered in the current frame.
|
||||
@@ -450,6 +450,50 @@ public:
|
||||
* @return A reference to the global model cache as a map of strings to shared pointers of model_class.
|
||||
*/
|
||||
std::map<std::string, std::shared_ptr<model_class>>& get_model_cache() { return g_model_cache; }
|
||||
|
||||
/**
|
||||
* Get the sky entity ID.
|
||||
* @return The sky entity ID as an integer.
|
||||
*/
|
||||
int get_sky_id() const { return sky_id_; }
|
||||
|
||||
/** Get the Sky entity as a shared pointer.
|
||||
* @return A shared pointer to the sky entity.
|
||||
*/
|
||||
std::shared_ptr<ecs::Entity> get_sky_entity_shared_ptr() const { return sky_entity_; }
|
||||
|
||||
/**
|
||||
* Update the screen depth.
|
||||
*/
|
||||
bool update_screen_depth(float new_screen_depth);
|
||||
|
||||
/**
|
||||
* Update the screen near.
|
||||
*/
|
||||
bool update_screen_near(float new_screen_near);
|
||||
|
||||
/**
|
||||
* Get the screen depth.
|
||||
* @return The screen depth as a float.
|
||||
*/
|
||||
float get_screen_depth() const { return screen_depth; }
|
||||
/**
|
||||
* Get the screen near.
|
||||
* @return The screen near as a float.
|
||||
*/
|
||||
float get_screen_near() const { return screen_near; }
|
||||
|
||||
/**
|
||||
* Get the target fps for the application.
|
||||
* @return The target fps as an integer.
|
||||
*/
|
||||
int get_target_fps() const { return target_fps_; };
|
||||
/**
|
||||
* Set the target fps for the application.
|
||||
* @param target_fps The new target fps as an integer.
|
||||
*/
|
||||
void set_target_fps(int target_fps) { target_fps_ = target_fps; };
|
||||
|
||||
|
||||
private:
|
||||
/**
|
||||
@@ -500,6 +544,13 @@ private:
|
||||
* @return True if the refraction was rendered to the texture successfully, false otherwise.
|
||||
*/
|
||||
bool render_refraction_to_texture();
|
||||
|
||||
/**
|
||||
* Render the shadow map texture for the scene.
|
||||
* @return True if the shadow map was rendered successfully, false otherwise.
|
||||
*/
|
||||
bool render_shadow_map();
|
||||
|
||||
/**
|
||||
* Render the reflection of the scene to a texture.
|
||||
* This function will render the reflection effects, such as water or mirrors, to a texture.
|
||||
@@ -530,6 +581,16 @@ private:
|
||||
* The thread function for culling objects in the scene.
|
||||
*/
|
||||
void culling_thread_function();
|
||||
|
||||
/**
|
||||
* A thread function to handle culling of objects no visible by sun light.
|
||||
*/
|
||||
void sun_culling_thread_function();
|
||||
|
||||
/**
|
||||
* Create the skysphere entity.
|
||||
*/
|
||||
bool create_skysphere();
|
||||
|
||||
public :
|
||||
std::vector<ID3D11ShaderResourceView*> textures;
|
||||
@@ -540,6 +601,11 @@ private :
|
||||
std::thread culling_thread_;
|
||||
std::atomic<bool> culling_active_;
|
||||
std::mutex objects_mutex_;
|
||||
|
||||
// Thread de culling pour les shadows
|
||||
std::thread culling_sun_thread_;
|
||||
std::atomic<bool> culling_sun_active_;
|
||||
std::mutex objects_sun_mutex_;
|
||||
|
||||
std::mutex terrain_mutex_;
|
||||
std::vector<std::tuple<float, float, float, std::string, int>> terrain_generation_data_;
|
||||
@@ -559,12 +625,15 @@ private :
|
||||
HWND hwnd_;
|
||||
bool windowed_;
|
||||
|
||||
float screen_depth = 1000.0f;
|
||||
float screen_near = 0.3f;
|
||||
|
||||
// ------------------------------------- //
|
||||
// ------------- RENDERING ------------- //
|
||||
// ------------------------------------- //
|
||||
|
||||
XMMATRIX base_view_matrix_;
|
||||
render_texture_class* render_texture_, * refraction_texture_, * reflection_texture_;
|
||||
render_texture_class* render_texture_, * refraction_texture_, * reflection_texture_,* shadow_texture_ ;
|
||||
render_texture_class* scene_texture_;
|
||||
display_plane_class* display_plane_;
|
||||
int screen_width_, screen_height_;
|
||||
@@ -587,7 +656,9 @@ private :
|
||||
float speed_ = 0.1f; // speed for the demo spinning object
|
||||
std::vector<object*> imported_object_;
|
||||
int object_id_ = 0;
|
||||
std::vector<object*> skybox_;
|
||||
|
||||
int sky_id_ = -1;
|
||||
std::shared_ptr<ecs::Entity> sky_entity_;
|
||||
|
||||
// ----------------------------------- //
|
||||
// ------------- LIGHTS -------------- //
|
||||
@@ -647,12 +718,14 @@ private :
|
||||
ID3D11ShaderResourceView* back_buffer_srv_;
|
||||
|
||||
stats* stats_;
|
||||
int target_fps_ = 60;
|
||||
|
||||
// ------------------------------------------------- //
|
||||
// ------------------- Culling --------------------- //
|
||||
// ------------------------------------------------- //
|
||||
|
||||
frustum frustum_culling_;
|
||||
frustum sun_culling_;
|
||||
int render_count_;
|
||||
float frustum_culling_tolerance_ = 5.f;
|
||||
|
||||
@@ -662,6 +735,14 @@ private :
|
||||
|
||||
input inputs_;
|
||||
bool tab_was_pressed_;
|
||||
std::shared_ptr<CameraInput> camera_input_;
|
||||
|
||||
// ------------------------------------------------- //
|
||||
// ------------------- SOUND ----------------------- //
|
||||
// ------------------------------------------------- //
|
||||
|
||||
// shared pointer to the FMOD system
|
||||
FMOD::System* sound_system_;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -13,6 +13,7 @@ using namespace DirectX;
|
||||
// MY CLASS INCLUDES //
|
||||
///////////////////////
|
||||
#include "texture_class.h"
|
||||
#include "macro.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
// INCLUDES //
|
||||
//////////////
|
||||
#include <directxmath.h>
|
||||
|
||||
#include "input_class.h"
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
|
||||
|
||||
@@ -69,6 +72,10 @@ public:
|
||||
*/
|
||||
XMMATRIX get_view_matrix(XMMATRIX& view_matrix) const;
|
||||
|
||||
/**
|
||||
* Update the camera's view matrix without
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Renders the reflection of the scene from the camera's perspective.
|
||||
*
|
||||
@@ -82,6 +89,12 @@ public:
|
||||
*/
|
||||
void get_reflection_view_matrix(XMMATRIX&) const;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Calculates and returns the forward direction vector of the camera based on its rotation.
|
||||
* This vector points in the direction the camera is facing.
|
||||
* @return A normalized 3D vector representing the camera's forward direction.
|
||||
*/
|
||||
XMFLOAT3 get_forward() const {
|
||||
float pitch = XMConvertToRadians(rotation_x_);
|
||||
float yaw = XMConvertToRadians(rotation_y_);
|
||||
@@ -93,7 +106,11 @@ public:
|
||||
return forwardVec;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Calculates and returns the right direction vector of the camera based on its rotation.
|
||||
* This vector points to the right side of the camera.
|
||||
* @return A normalized 3D vector representing the camera's right direction.
|
||||
*/
|
||||
XMFLOAT3 get_up() const {
|
||||
// Construire matrice rotation <20> partir des angles
|
||||
XMMATRIX rot = XMMatrixRotationRollPitchYaw(
|
||||
@@ -110,7 +127,40 @@ public:
|
||||
return upF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the camera
|
||||
* @param std::vector<bool> inputs : forward, backward, left, right, up, down, scrollUp, scrollDown, rightClick
|
||||
* @param float deltaTime : time since last frame
|
||||
* @return void
|
||||
*/
|
||||
void move(float deltatime, float delta_x, float delta_y);
|
||||
|
||||
/**
|
||||
* Rotate the camera
|
||||
* @param float delta_x : mouse delta x
|
||||
* @param float delta_y : mouse delta y
|
||||
* @return void
|
||||
*/
|
||||
void rotate(float delta_x, float delta_y);
|
||||
|
||||
/**
|
||||
* Update the camera input states based on the provided input_class instance.
|
||||
* This method updates the internal state of the camera's input handling.
|
||||
* @param imputs A pointer to an input_class instance containing the current input states.
|
||||
*/
|
||||
void update_camera_inputs_states(input_class* imputs);
|
||||
|
||||
/**
|
||||
* Set the camera inputs structure.
|
||||
* @param inputs A shared pointer to a CameraInput structure containing the input states.
|
||||
*/
|
||||
void set_camera_inputs(std::shared_ptr<CameraInput> inputs) { inputs_ = inputs; }
|
||||
|
||||
/**
|
||||
* Get the camera inputs structure.
|
||||
* @return A shared pointer to the CameraInput structure containing the input states.
|
||||
*/
|
||||
std::shared_ptr<CameraInput> get_camera_inputs() { return inputs_; }
|
||||
|
||||
private:
|
||||
float position_x_, position_y_, position_z_;
|
||||
@@ -118,6 +168,9 @@ private:
|
||||
XMMATRIX view_matrix_;
|
||||
XMMATRIX reflection_view_matrix_;
|
||||
|
||||
float camera_speed_;
|
||||
std::shared_ptr<CameraInput> inputs_;
|
||||
float camera_sensitivity_ = 0.1f;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "font_shader_class.h"
|
||||
#include "font_class.h"
|
||||
#include "text_class.h"
|
||||
#include "macro.h"
|
||||
|
||||
using namespace DirectX;
|
||||
|
||||
@@ -165,6 +166,16 @@ public:
|
||||
*/
|
||||
void disable_alpha_blending();
|
||||
|
||||
/**
|
||||
* Set new projection parameters.
|
||||
* @param width The new width for the projection matrix.
|
||||
* @param height The new height for the projection matrix.
|
||||
* @param screenDepth The new screen depth.
|
||||
* @param screenNear The new near clipping plane distance.
|
||||
* @return True if the projection parameters were set successfully, false otherwise.
|
||||
*/
|
||||
bool set_projection_params(int width,int height,float screenDepth, float screenNear);
|
||||
|
||||
private:
|
||||
bool vsync_enabled_;
|
||||
int video_card_memory_;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// MY CLASS INCLUDES //
|
||||
///////////////////////
|
||||
#include "d_3d_class.h"
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Class name: display_plane_class
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "component.h"
|
||||
#include "components/audio_component.h"
|
||||
#include "components/identity_component.h"
|
||||
#include "components/lua_script_component.h"
|
||||
#include "components/render_component.h"
|
||||
#include "components/transform_component.h"
|
||||
#include "components/physics_component.h"
|
||||
@@ -52,5 +53,6 @@ inline void EnregistrerTousLesComposants() {
|
||||
factory.EnregistrerComposant<ecs::IdentityComponent>("IdentityComponent");
|
||||
factory.EnregistrerComposant<ecs::RenderComponent>("RenderComponent");
|
||||
factory.EnregistrerComposant<ecs::AudioComponent>("AudioComponent");
|
||||
factory.EnregistrerComposant<ecs::LuaScriptComponent>("LuaScriptComponent");
|
||||
// Ajouter d'autres composants ici
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <imgui.h>
|
||||
#include "entity.h"
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
/**
|
||||
* namespace for the Entity-Component-System (ECS)
|
||||
*/
|
||||
@@ -30,6 +32,11 @@ public:
|
||||
*/
|
||||
virtual void Initialize() {}
|
||||
|
||||
/**
|
||||
*Virtual function to shutdown the component.
|
||||
*/
|
||||
virtual void Shutdown() {}
|
||||
|
||||
/**
|
||||
* Virtual function to update the component.
|
||||
* @param deltaTime Time since the last update.
|
||||
@@ -48,7 +55,7 @@ public:
|
||||
* @param data The string data to deserialize from.
|
||||
* @return True if deserialization was successful, otherwise false.
|
||||
*/
|
||||
virtual bool Deserialize(const std::string& data) { return false;}
|
||||
virtual bool Deserialize(const std::string& data) { R_FALSE}
|
||||
|
||||
/**
|
||||
* Virtual function to render ImGui controls for the component.
|
||||
|
||||
@@ -16,50 +16,78 @@
|
||||
namespace ecs {
|
||||
class AudioComponent : public Component {
|
||||
public:
|
||||
AudioComponent() : m_system(nullptr), m_sound(nullptr), m_channel(nullptr) {}
|
||||
AudioComponent() : m_sound(nullptr), m_channel(nullptr) {}
|
||||
~AudioComponent() override {
|
||||
// stop the sound if it's playing
|
||||
if (m_channel) {
|
||||
bool isPlaying = false;
|
||||
m_channel->isPlaying(&isPlaying);
|
||||
if (isPlaying) {
|
||||
m_channel->stop();
|
||||
}
|
||||
}
|
||||
if (m_sound) m_sound->release();
|
||||
// Ne pas lib<69>rer m_system ici car il peut <20>tre partag<61>
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown the audio component by releasing the sound and channel.
|
||||
* This method is called when the component is removed from an entity or when the entity is destroyed.
|
||||
*/
|
||||
void Shutdown() override {
|
||||
if (m_channel) {
|
||||
bool isPlaying = false;
|
||||
m_channel->isPlaying(&isPlaying);
|
||||
if (isPlaying) {
|
||||
m_channel->stop();
|
||||
}
|
||||
m_channel = nullptr;
|
||||
}
|
||||
if (m_sound) {
|
||||
m_sound->release();
|
||||
m_sound = nullptr;
|
||||
}
|
||||
m_system = nullptr; // Ne pas lib<69>rer m_system ici car il peut <20>tre partag<61>
|
||||
m_camera = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the audio component by setting up the FMOD system and camera from the parent entity.
|
||||
* This method is called when the component is added to an entity.
|
||||
*/
|
||||
void Initialize() override
|
||||
{
|
||||
// create FMOD system if not already created
|
||||
if (!m_system)
|
||||
{
|
||||
FMOD_RESULT result = FMOD::System_Create(&m_system);
|
||||
if (result != FMOD_OK) {
|
||||
m_lastError = "<EFBFBD>chec de la cr<63>ation du syst<73>me FMOD: " + std::to_string(result);
|
||||
return;
|
||||
}
|
||||
|
||||
result = m_system->init(512, FMOD_INIT_NORMAL | FMOD_INIT_3D_RIGHTHANDED, nullptr);
|
||||
if (result != FMOD_OK) {
|
||||
m_lastError = "<EFBFBD>chec de l'initialisation du syst<73>me FMOD: " + std::to_string(result);
|
||||
m_system->release();
|
||||
m_system = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
auto parent = GetParent();
|
||||
if (parent && parent->GetCamera())
|
||||
{
|
||||
SetCamera(parent->GetCamera());
|
||||
SetSoundSystem(parent->GetSoundSystem());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an audio file from the specified path.
|
||||
* If the FMOD system is not initialized, it will be initialized first.
|
||||
* Creates a sound object with appropriate settings based on the component's properties.
|
||||
* @param path The file path to load the audio from.
|
||||
* @return True if the audio file was loaded successfully, otherwise false.
|
||||
*/
|
||||
bool Load(const std::string& path) {
|
||||
if (!m_system) {
|
||||
Initialize();
|
||||
if (!m_system) return false;
|
||||
if (!m_system) R_FALSE
|
||||
}
|
||||
|
||||
LOG_INFO("Loading audio file: " + path);
|
||||
|
||||
m_soundPath = path;
|
||||
|
||||
if (!std::filesystem::exists(path)) {
|
||||
m_lastError = "Fichier non trouv<75>: " + path;
|
||||
return false;
|
||||
LOG_ERROR(m_lastError);
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
if (m_sound) {
|
||||
@@ -81,12 +109,18 @@ public:
|
||||
if (result != FMOD_OK) {
|
||||
m_lastError = "<EFBFBD>chec du chargement du son: " + std::to_string(result) +
|
||||
" (chemin: " + absolutePath.string() + ")";
|
||||
return false;
|
||||
LOG_ERROR(m_lastError);
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
/**
|
||||
* Play the loaded audio sound.
|
||||
* If the sound is already playing, it will be stopped and restarted.
|
||||
* The channel properties such as volume, pan, pitch, mute, priority, and paused state are applied.
|
||||
*/
|
||||
void Play() {
|
||||
if (m_system && m_sound) {
|
||||
bool isPlaying = false;
|
||||
@@ -111,6 +145,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause the currently playing audio sound.
|
||||
* If the sound is not playing, this method has no effect.
|
||||
*/
|
||||
void Pause() {
|
||||
if (m_channel) {
|
||||
m_paused = true;
|
||||
@@ -118,6 +156,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume the paused audio sound.
|
||||
* If the sound is not paused, this method has no effect.
|
||||
*/
|
||||
void Resume() {
|
||||
if (m_channel) {
|
||||
m_paused = false;
|
||||
@@ -125,13 +167,26 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the currently playing audio sound.
|
||||
* If the sound is not playing, this method has no effect.
|
||||
*/
|
||||
void Stop() {
|
||||
if (m_channel)
|
||||
m_channel->stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the camera to be used for 3D audio spatialization.
|
||||
* This camera is used to update the listener attributes in FMOD.
|
||||
* @param camera Pointer to the camera_class instance.
|
||||
*/
|
||||
void SetCamera(camera_class* camera) {m_camera = camera; }
|
||||
|
||||
/**
|
||||
* Update the audio component.
|
||||
* @param deltaTime Time since the last update.
|
||||
*/
|
||||
void Update(float deltaTime) override {
|
||||
if (!m_spatialized) return;
|
||||
|
||||
@@ -186,7 +241,12 @@ public:
|
||||
m_system->update();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ImGui Widget to control the audio component properties.
|
||||
* Allows loading/changing/removing audio files, and adjusting properties like volume, pan, pitch, looping, spatialization, etc.
|
||||
* Displays error messages if loading fails.
|
||||
* This method is called during the ImGui rendering phase.
|
||||
*/
|
||||
void OnImGuiRender() override {
|
||||
if (!m_sound) {
|
||||
ImGui::Text("No audio file loaded");
|
||||
@@ -238,6 +298,7 @@ public:
|
||||
|
||||
if (!m_lastError.empty()) {
|
||||
ImGui::TextColored(ImVec4(1, 0, 0, 1), "Error: %s", m_lastError.c_str());
|
||||
LOG_ERROR(m_lastError);
|
||||
}
|
||||
} else {
|
||||
ImGui::Text("Loaded: %s", m_soundPath.c_str());
|
||||
@@ -392,7 +453,80 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the FMOD system to be used by this audio component.
|
||||
* This method allows sharing the FMOD system instance across multiple audio components.
|
||||
* @param system Pointer to the FMOD::System instance.
|
||||
*/
|
||||
void SetSoundSystem(FMOD::System* system) {
|
||||
m_system = system;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the audio component's state to a string.
|
||||
* This includes properties like sound path, volume, pan, pitch, looping, muted, paused, priority, spatialization, and use of velocity.
|
||||
* This method is useful for saving the component's state or debugging.
|
||||
* @return A string representation of the audio component's state.
|
||||
*/
|
||||
std::string Serialize() const override {
|
||||
std::stringstream ss;
|
||||
ss << "AudioComponent:"
|
||||
<< m_soundPath << ";"
|
||||
<< m_volume << ":"
|
||||
<< m_pan << ":"
|
||||
<< m_pitch << ":"
|
||||
<< m_looping << ":"
|
||||
<< m_muted << ":"
|
||||
<< m_paused << ":"
|
||||
<< m_priority << ":"
|
||||
<< m_spatialized << ":"
|
||||
<< m_use_velocity;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize the audio component's state from a string.
|
||||
* This method parses the string and sets the component's properties accordingly.
|
||||
* If the sound path is valid, it attempts to load the audio file.
|
||||
* @param data The string representation of the audio component's state.
|
||||
* @return True if deserialization was successful, otherwise false.
|
||||
*/
|
||||
bool Deserialize(const std::string& data) override {
|
||||
std::stringstream ss(data);
|
||||
std::string type;
|
||||
std::getline(ss, type, ':');
|
||||
if (type != "AudioComponent") R_FALSE
|
||||
|
||||
std::string s_volume, s_pan, s_pitch, s_looping, s_muted, s_paused, s_priority, s_spatialized, s_use_velocity;
|
||||
|
||||
std::getline(ss, m_soundPath, ';');
|
||||
std::getline(ss, s_volume, ':');
|
||||
std::getline(ss, s_pan, ':');
|
||||
std::getline(ss, s_pitch, ':');
|
||||
std::getline(ss, s_looping, ':');
|
||||
std::getline(ss, s_muted, ':');
|
||||
std::getline(ss, s_paused, ':');
|
||||
std::getline(ss, s_priority, ':');
|
||||
std::getline(ss, s_spatialized, ':');
|
||||
std::getline(ss, s_use_velocity, ':');
|
||||
|
||||
m_volume = std::stof(s_volume);
|
||||
m_pan = std::stof(s_pan);
|
||||
m_pitch = std::stof(s_pitch);
|
||||
m_looping = (s_looping == "1");
|
||||
m_muted = (s_muted == "1");
|
||||
m_paused = (s_paused == "1");
|
||||
m_priority = std::stoi(s_priority);
|
||||
m_spatialized = (s_spatialized == "1");
|
||||
m_use_velocity = (s_use_velocity == "1");
|
||||
|
||||
// Recharger le son si le chemin existe (optional: ou laisser le chargement manuel)
|
||||
if (!m_soundPath.empty() && m_system) {
|
||||
Load(m_soundPath);
|
||||
}
|
||||
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
private:
|
||||
FMOD::System* m_system;
|
||||
|
||||
@@ -119,7 +119,7 @@ public:
|
||||
std::string type;
|
||||
std::getline(ss, type, ':');
|
||||
|
||||
if (type != "IdentityComponent") return false;
|
||||
if (type != "IdentityComponent") R_FALSE
|
||||
|
||||
std::string token, name, objectTypeStr;
|
||||
int id;
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
SetId(id);
|
||||
SetName(name);
|
||||
SetType(StringToObjectType(objectTypeStr));
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void OnImGuiRender() override {
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
#pragma once
|
||||
#include "../component.h"
|
||||
#include "Lua/lua.hpp"
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <imgui.h>
|
||||
#include <filesystem>
|
||||
|
||||
namespace ecs {
|
||||
|
||||
class LuaScriptComponent : public Component {
|
||||
public:
|
||||
LuaScriptComponent() : scriptCreated(false), popupOpen(true) {
|
||||
L = luaL_newstate();
|
||||
luaL_openlibs(L);
|
||||
}
|
||||
|
||||
~LuaScriptComponent() override {
|
||||
if (L) {
|
||||
lua_close(L);
|
||||
L = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void OnImGuiRender() override {
|
||||
if (popupOpen) {
|
||||
ImGui::OpenPopup("Nouveau Script Lua");
|
||||
if (ImGui::BeginPopupModal("Nouveau Script Lua", NULL, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
|
||||
ImGui::InputText("Nom du Script", scriptNameBuffer, sizeof(scriptNameBuffer));
|
||||
|
||||
if (ImGui::Button("Annuler")) {
|
||||
scriptCreated = false;
|
||||
popupOpen = false;
|
||||
// Signal pour retirer ce component (<28> g<>rer par l'entity)
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Valider")) {
|
||||
if (CreateScriptFile()) {
|
||||
scriptCreated = true;
|
||||
popupOpen = false;
|
||||
} else {
|
||||
// Gestion d'erreur possible (imprimer popup message)
|
||||
}
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
if (scriptCreated) {
|
||||
ImGui::TextWrapped("Script associe: %s", scriptName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
bool HasScript() const { return scriptCreated; }
|
||||
const std::string& GetScriptName() const { return scriptName; }
|
||||
|
||||
private:
|
||||
lua_State* L = nullptr;
|
||||
char scriptNameBuffer[128] = {0};
|
||||
std::string scriptName;
|
||||
bool scriptCreated = false;
|
||||
bool popupOpen = false;
|
||||
|
||||
bool CreateScriptFile() {
|
||||
if (strlen(scriptNameBuffer) == 0)
|
||||
R_FALSE
|
||||
|
||||
scriptName = scriptNameBuffer;
|
||||
if (scriptName.length() < 4 || scriptName.substr(scriptName.length() - 4) != ".lua") {
|
||||
scriptName += ".lua";
|
||||
}
|
||||
|
||||
// Dossier standard des scripts
|
||||
std::string execFolder = std::filesystem::current_path().string();
|
||||
std::string scriptFolder = execFolder + "/assets/Script/";
|
||||
|
||||
// Cr<43>er dossiers s'ils manquent
|
||||
std::error_code ec;
|
||||
std::filesystem::create_directories(scriptFolder, ec);
|
||||
if (ec) {
|
||||
// Log erreur
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
std::string fullPath = scriptFolder + scriptName;
|
||||
|
||||
// Cr<43>er un fichier script vide ou template simple
|
||||
std::ofstream ofs(fullPath);
|
||||
if (!ofs) R_FALSE
|
||||
|
||||
ofs << "-- Script Lua vide pour ECS\n\nfunction on_update(dt)\n -- Code ici\nend\n";
|
||||
ofs.close();
|
||||
|
||||
R_TRUE
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ecs
|
||||
@@ -46,13 +46,13 @@ public:
|
||||
std::string type;
|
||||
std::getline(ss, type, ':');
|
||||
|
||||
if (type != "ModelPathComponent") return false;
|
||||
if (type != "ModelPathComponent") R_FALSE
|
||||
|
||||
std::string modelPath;
|
||||
std::getline(ss, modelPath);
|
||||
|
||||
SetPath(std::wstring(modelPath.begin(), modelPath.end()));
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void OnImGuiRender() override {
|
||||
|
||||
@@ -213,7 +213,7 @@ public:
|
||||
std::string type;
|
||||
std::getline(ss, type, ':');
|
||||
|
||||
if (type != "PhysicsComponent") return false;
|
||||
if (type != "PhysicsComponent") R_FALSE
|
||||
|
||||
std::string token;
|
||||
float mass, boundingRadius;
|
||||
@@ -230,7 +230,7 @@ public:
|
||||
SetPhysicsEnabled(physicsEnabled);
|
||||
SetGravityEnabled(gravityEnabled);
|
||||
SetGrounded(isGrounded);
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void OnImGuiRender() override {
|
||||
|
||||
@@ -14,17 +14,7 @@
|
||||
extern std::map<std::string, std::shared_ptr<model_class>> g_model_cache;
|
||||
|
||||
namespace ecs {
|
||||
/**
|
||||
* Enum for different types of textures used in rendering.
|
||||
*/
|
||||
enum class TextureType
|
||||
{
|
||||
Diffuse,
|
||||
Normal,
|
||||
Specular,
|
||||
Alpha,
|
||||
Reflection
|
||||
};
|
||||
|
||||
|
||||
class RenderComponent : public Component {
|
||||
public:
|
||||
@@ -34,7 +24,21 @@ public:
|
||||
RenderComponent() : m_model(nullptr), m_isVisible(true) {}
|
||||
~RenderComponent() = default;
|
||||
|
||||
void Initialize() override {}
|
||||
|
||||
/**
|
||||
* Initialize the component by setting up the Direct3D device and context from the parent entity.
|
||||
* This method is called when the component is added to an entity.
|
||||
*/
|
||||
void Initialize() override
|
||||
{
|
||||
if (auto parent = GetParent()) {
|
||||
SetDevice(parent->GetDevice());
|
||||
SetContext(parent->GetContext());
|
||||
}
|
||||
|
||||
texture_container_buffer = TextureContainer();
|
||||
|
||||
}
|
||||
void Update(float deltaTime) override {}
|
||||
|
||||
/**
|
||||
@@ -44,9 +48,9 @@ public:
|
||||
* @return True if initialization was successful, false otherwise.
|
||||
*/
|
||||
bool InitializeWithModel(std::shared_ptr<model_class> model) {
|
||||
if (!model) return false;
|
||||
if (!model) R_FALSE
|
||||
m_model = model;
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,14 +73,14 @@ public:
|
||||
// Cr<43>er un nouveau mod<6F>le
|
||||
auto new_model = std::make_shared<model_class>();
|
||||
if (!new_model->Initialize(device, deviceContext, const_cast<char*>(modelFilename), textureContainer)) {
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
g_model_cache[filename] = new_model;
|
||||
m_model = new_model;
|
||||
}
|
||||
|
||||
m_modelFilePath = modelFilename;
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,13 +101,13 @@ public:
|
||||
ID3D11ShaderResourceView* texture = nullptr;
|
||||
result = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
|
||||
if (FAILED(result)) {
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
texturesContainer.AssignTexture(texturesContainer, texture, texturePath, i);
|
||||
i++;
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,42 +190,303 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void RenderOnlyGeometryFromSun(ID3D11DeviceContext* ctx)
|
||||
{
|
||||
if (m_model && m_is_in_sun_pov) m_model->Render(ctx);
|
||||
|
||||
}
|
||||
|
||||
void set_is_sun_visible(bool v) { m_is_in_sun_pov = v; }
|
||||
bool is_in_sun_pov() const { return m_is_in_sun_pov; }
|
||||
|
||||
/**
|
||||
* Serialize the RenderComponent's state to a string.
|
||||
* This method is useful for saving the component's state or debugging.
|
||||
* @return A string representation of the RenderComponent's state.
|
||||
*/
|
||||
std::string Serialize() const override {
|
||||
if (!m_model) return "RenderComponent:NoModel";
|
||||
|
||||
|
||||
TextureContainer texture_container_buffer = m_model->GetTextureContainer();
|
||||
|
||||
auto serializePaths = [](const std::vector<std::wstring> &paths) -> std::string {
|
||||
std::string result;
|
||||
for (size_t i = 0; i < paths.size(); ++i) {
|
||||
std::string p = std::string(paths[i].begin(), paths[i].end());
|
||||
result += p;
|
||||
if (i + 1 < paths.size()) {
|
||||
result += ","; // virgule entre chemins mais pas apr<70>s dernier
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
int diffuse_count = (int)texture_container_buffer.diffuse.size();
|
||||
int normal_count = (int)texture_container_buffer.normal.size();
|
||||
int specular_count = (int)texture_container_buffer.specular.size();
|
||||
int alpha_count = (int)texture_container_buffer.alpha.size();
|
||||
|
||||
std::string diffuse_paths_ = serializePaths(texture_container_buffer.diffusePaths);
|
||||
std::string normal_paths_ = serializePaths(texture_container_buffer.normalPaths);
|
||||
std::string specular_paths_ = serializePaths(texture_container_buffer.specularPaths);
|
||||
std::string alpha_paths_ = serializePaths(texture_container_buffer.alphaPaths);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "RenderComponent:HasModel";
|
||||
ss << "RenderComponent:HasModel:"
|
||||
<< is_shadow_caster_ << ":"
|
||||
<< diffuse_count << ":" << diffuse_paths_ << ":"
|
||||
<< normal_count << ":" << normal_paths_ << ":"
|
||||
<< specular_count << ":" << specular_paths_ << ":"
|
||||
<< alpha_count << ":" << alpha_paths_;
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deserialize the RenderComponent's state from a string.
|
||||
* This method parses the string and sets the component's properties accordingly.
|
||||
* Note: The model will be loaded separately based on the model file path.
|
||||
* @param data The string representation of the RenderComponent's state.
|
||||
* @return True if deserialization was successful, otherwise false.
|
||||
*/
|
||||
bool Deserialize(const std::string& data) override {
|
||||
std::stringstream ss(data);
|
||||
std::string type;
|
||||
std::getline(ss, type, ':');
|
||||
|
||||
if (type != "RenderComponent") return false;
|
||||
|
||||
std::string hasModel;
|
||||
std::getline(ss, hasModel);
|
||||
|
||||
// Le mod<6F>le sera charg<72> s<>par<61>ment
|
||||
return true;
|
||||
|
||||
if (!std::getline(ss, type, ':') || type != "RenderComponent")
|
||||
R_FALSE
|
||||
|
||||
std::string token;
|
||||
|
||||
if (!std::getline(ss, token, ':') || token != "HasModel")
|
||||
R_FALSE
|
||||
|
||||
std::getline(ss,token, ':');
|
||||
is_shadow_caster_ = std::stoi(token);
|
||||
|
||||
int diffuse_count = 0, normal_count = 0, specular_count = 0, alpha_count = 0;
|
||||
|
||||
std::vector<std::wstring> paths_diffuse, paths_normal, paths_specular, paths_alpha;
|
||||
|
||||
auto read_count = [&](int& count) -> bool {
|
||||
if (!std::getline(ss, token, ':'))
|
||||
R_FALSE
|
||||
try {
|
||||
count = std::stoi(token);
|
||||
}
|
||||
catch (...) {
|
||||
R_FALSE
|
||||
}
|
||||
R_TRUE
|
||||
};
|
||||
|
||||
auto clean_token = [](std::string& str) {
|
||||
// Retirer virgules et espaces
|
||||
str.erase(std::remove(str.begin(), str.end(), ','), str.end());
|
||||
str.erase(0, str.find_first_not_of(" \t\n\r"));
|
||||
str.erase(str.find_last_not_of(" \t\n\r") + 1);
|
||||
};
|
||||
|
||||
auto read_paths = [&](int count, std::vector<std::wstring>& paths) -> bool {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (!std::getline(ss, token, ':'))
|
||||
R_FALSE
|
||||
|
||||
clean_token(token);
|
||||
|
||||
if (!token.empty()) {
|
||||
paths.emplace_back(token.begin(), token.end());
|
||||
LOG_INFO("Loaded path: " + std::string(token.begin(), token.end()));
|
||||
}
|
||||
}
|
||||
R_TRUE
|
||||
};
|
||||
|
||||
if (!read_count(diffuse_count)) R_FALSE
|
||||
if (!read_paths(diffuse_count, paths_diffuse)) R_FALSE
|
||||
|
||||
if (!read_count(normal_count)) R_FALSE
|
||||
if (!read_paths(normal_count, paths_normal)) R_FALSE
|
||||
|
||||
if (!read_count(specular_count)) R_FALSE
|
||||
if (!read_paths(specular_count, paths_specular)) R_FALSE
|
||||
|
||||
if (!read_count(alpha_count)) R_FALSE
|
||||
if (!read_paths(alpha_count, paths_alpha)) R_FALSE
|
||||
|
||||
// Lib<69>rer textures existantes
|
||||
for (auto& tex : texture_container_buffer.diffuse) if (tex) { tex->Release(); tex = nullptr; }
|
||||
for (auto& tex : texture_container_buffer.normal) if (tex) { tex->Release(); tex = nullptr; }
|
||||
for (auto& tex : texture_container_buffer.specular) if (tex) { tex->Release(); tex = nullptr; }
|
||||
for (auto& tex : texture_container_buffer.alpha) if (tex) { tex->Release(); tex = nullptr; }
|
||||
|
||||
texture_container_buffer.diffuse.clear();
|
||||
texture_container_buffer.normal.clear();
|
||||
texture_container_buffer.specular.clear();
|
||||
texture_container_buffer.alpha.clear();
|
||||
|
||||
texture_container_buffer.diffusePaths = std::move(paths_diffuse);
|
||||
texture_container_buffer.normalPaths = std::move(paths_normal);
|
||||
texture_container_buffer.specularPaths = std::move(paths_specular);
|
||||
texture_container_buffer.alphaPaths = std::move(paths_alpha);
|
||||
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the ImGui interface for the RenderComponent.
|
||||
* This method provides a user interface for inspecting and modifying the component's properties.
|
||||
* It includes options to toggle visibility, display model information, and manage textures.
|
||||
*/
|
||||
void OnImGuiRender() override {
|
||||
ImGui::Checkbox("Visible", &m_isVisible);
|
||||
C_BOX("Is shadow caster" , &is_shadow_caster_);
|
||||
ImGui::Text("Model File Path: %s", m_modelFilePath.c_str());
|
||||
if (m_model) {
|
||||
ImGui::Text("Index Count: %d", m_model->GetIndexCount());
|
||||
} else {
|
||||
ImGui::Text("No model loaded.");
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// D<>finir les types de textures_
|
||||
std::vector<std::string> textureCategories = {
|
||||
"Diffuse", "Normal", "Specular", "Alpha"
|
||||
};
|
||||
|
||||
std::vector<TextureType> textureTypes = {
|
||||
TextureType::Diffuse, TextureType::Normal,
|
||||
TextureType::Specular, TextureType::Alpha
|
||||
};
|
||||
|
||||
// Cr<43>er un espace pour afficher les textures_ avec d<>filement
|
||||
ImGui::BeginChild("TextureChild", ImVec2(0, 200), true, ImGuiWindowFlags_HorizontalScrollbar);
|
||||
|
||||
// Pour chaque type de texture
|
||||
for (int typeIndex = 0; typeIndex < textureCategories.size(); typeIndex++)
|
||||
{
|
||||
TextureType type = textureTypes[typeIndex];
|
||||
std::string typeName = textureCategories[typeIndex];
|
||||
|
||||
// Afficher le titre de la cat<61>gorie
|
||||
ImGui::Text("%s:", typeName.c_str());
|
||||
ImGui::SameLine();
|
||||
|
||||
// Compter combien de textures_ de ce type existent
|
||||
int textureCount = 0;
|
||||
while (GetTexture(type, textureCount) != nullptr)
|
||||
{
|
||||
textureCount++;
|
||||
}
|
||||
|
||||
// Afficher toutes les textures_ existantes
|
||||
ImGui::BeginGroup();
|
||||
for (int texIndex = 0; texIndex < textureCount; texIndex++)
|
||||
{
|
||||
ID3D11ShaderResourceView* texture = GetTexture(type, texIndex);
|
||||
if (texture)
|
||||
{
|
||||
// ID unique pour chaque bouton de texture
|
||||
std::string buttonId = "tex##" +
|
||||
std::to_string(typeIndex) + "_" +
|
||||
std::to_string(texIndex);
|
||||
|
||||
if (ImGui::ImageButton(buttonId.c_str(), (ImTextureID)texture, ImVec2(48, 48)))
|
||||
{
|
||||
// Ouvrir une bo<62>te de dialogue pour changer la texture
|
||||
OPENFILENAME ofn;
|
||||
WCHAR szFile[260];
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = NULL;
|
||||
ofn.lpstrFile = szFile;
|
||||
szFile[0] = '\0';
|
||||
ofn.nMaxFile = sizeof(szFile);
|
||||
ofn.lpstrFilter = L"Texture\0*.png;*.jpg;*.dds\0";
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrInitialDir = NULL;
|
||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
||||
|
||||
if (GetOpenFileName(&ofn))
|
||||
{
|
||||
// Changer la texture existante
|
||||
m_model->ChangeTexture(device, context, ofn.lpstrFile, type, texIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// Afficher l'indice de texture et pr<70>visualisation au survol
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text("%s %d", typeName.c_str(), texIndex);
|
||||
ImGui::Image((ImTextureID)texture, ImVec2(192, 192));
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
}
|
||||
}
|
||||
|
||||
// Bouton pour ajouter une nouvelle texture
|
||||
std::string addButtonLabel = "+##" + std::to_string(typeIndex);
|
||||
if (ImGui::Button(addButtonLabel.c_str(), ImVec2(48, 48)))
|
||||
{
|
||||
// Ouvrir une bo<62>te de dialogue pour ajouter une texture
|
||||
OPENFILENAME ofn;
|
||||
WCHAR szFile[260];
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = NULL;
|
||||
ofn.lpstrFile = szFile;
|
||||
szFile[0] = '\0';
|
||||
ofn.nMaxFile = sizeof(szFile);
|
||||
ofn.lpstrFilter = L"Texture\0*.png;*.jpg;*.dds\0";
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrInitialDir = NULL;
|
||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
||||
|
||||
if (GetOpenFileName(&ofn))
|
||||
{
|
||||
// Ajouter une nouvelle texture
|
||||
m_model->AddTexture(device, context, ofn.lpstrFile, type);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndGroup();
|
||||
ImGui::Separator();
|
||||
}
|
||||
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
void SetDevice (ID3D11Device* dev) { device = dev; }
|
||||
void SetContext(ID3D11DeviceContext* ctx) { context = ctx; }
|
||||
|
||||
void SetTextureContainer(const TextureContainer& texContainer) { texture_container_buffer = texContainer; }
|
||||
const TextureContainer& GetTextureContainerBuffer() const { return texture_container_buffer; }
|
||||
|
||||
/**
|
||||
* Get whether the model casts shadows.
|
||||
* @return True if the model casts shadows, false otherwise.
|
||||
*/
|
||||
bool IsShadowCaster() const { return is_shadow_caster_; }
|
||||
/**
|
||||
* Set whether the model casts shadows.
|
||||
* @param isCaster True to make the model cast shadows, false otherwise.
|
||||
*/
|
||||
void SetShadowCaster(bool isCaster) { is_shadow_caster_ = isCaster; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<model_class> m_model;
|
||||
std::string m_modelFilePath;
|
||||
bool m_isVisible;
|
||||
ID3D11Device* device;
|
||||
ID3D11DeviceContext* context;
|
||||
TextureContainer texture_container_buffer;
|
||||
bool is_shadow_caster_ = true;
|
||||
bool m_is_in_sun_pov;
|
||||
};
|
||||
|
||||
} // namespace ecs
|
||||
|
||||
@@ -53,17 +53,17 @@ public:
|
||||
* @return The ShaderType enum corresponding to the provided string.
|
||||
*/
|
||||
static ShaderType StringToShaderType(const std::string& str) {
|
||||
if (str == "ALPHA_MAPPING") return ShaderType::ALPHA_MAPPING;
|
||||
if (str == "CEL_SHADING") return ShaderType::CEL_SHADING;
|
||||
if (str == "NORMAL_MAPPING") return ShaderType::NORMAL_MAPPING;
|
||||
if (str == "SPECULAR_MAPPING") return ShaderType::SPECULAR_MAPPING;
|
||||
if (str == "TEXTURE") return ShaderType::TEXTURE;
|
||||
if (str == "LIGHTING") return ShaderType::LIGHTING;
|
||||
if (str == "SUNLIGHT") return ShaderType::SUNLIGHT;
|
||||
if (str == "SKYBOX") return ShaderType::SKYBOX;
|
||||
if (str == "REFLECTION") return ShaderType::REFLECTION;
|
||||
if (str == "REFRACTION") return ShaderType::REFRACTION;
|
||||
return ShaderType::TEXTURE;
|
||||
if (str == "ALPHA_MAPPING") return SHD_ALPHA;
|
||||
if (str == "CEL_SHADING") return SHD_CEL;
|
||||
if (str == "NORMAL_MAPPING") return SHD_NORM;
|
||||
if (str == "SPECULAR_MAPPING") return SHD_SPEC;
|
||||
if (str == "TEXTURE") return SHD_TEX;
|
||||
if (str == "LIGHTING") return SHD_LIGHT;
|
||||
if (str == "SUNLIGHT") return SHD_SUN;
|
||||
if (str == "SKYBOX") return SHD_SKYBOX;
|
||||
if (str == "REFLECTION") return SHD_REFL;
|
||||
if (str == "REFRACTION") return SHD_REFR;
|
||||
return SHD_TEX;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,17 +74,17 @@ public:
|
||||
*/
|
||||
static std::string ShaderTypeToString(ShaderType type) {
|
||||
switch (type) {
|
||||
case ShaderType::ALPHA_MAPPING: return "ALPHA_MAPPING";
|
||||
case ShaderType::CEL_SHADING: return "CEL_SHADING";
|
||||
case ShaderType::NORMAL_MAPPING: return "NORMAL_MAPPING";
|
||||
case ShaderType::SPECULAR_MAPPING: return "SPECULAR_MAPPING";
|
||||
case ShaderType::TEXTURE: return "TEXTURE";
|
||||
case ShaderType::LIGHTING: return "LIGHTING";
|
||||
case ShaderType::SUNLIGHT: return "SUNLIGHT";
|
||||
case ShaderType::SKYBOX: return "SKYBOX";
|
||||
case ShaderType::REFLECTION: return "REFLECTION";
|
||||
case ShaderType::REFRACTION: return "REFRACTION";
|
||||
default: return "TEXTURE";
|
||||
case SHD_ALPHA: return "ALPHA_MAPPING";
|
||||
case SHD_CEL: return "CEL_SHADING";
|
||||
case SHD_NORM: return "NORMAL_MAPPING";
|
||||
case SHD_SPEC: return "SPECULAR_MAPPING";
|
||||
case SHD_TEX: return "TEXTURE";
|
||||
case SHD_LIGHT: return "LIGHTING";
|
||||
case SHD_SUN: return "SUNLIGHT";
|
||||
case SHD_SKYBOX: return "SKYBOX";
|
||||
case SHD_REFL: return "REFLECTION";
|
||||
case SHD_REFR: return "REFRACTION";
|
||||
default: return "TEXTURE";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,13 +101,13 @@ public:
|
||||
std::string type;
|
||||
std::getline(ss, type, ':');
|
||||
|
||||
if (type != "ShaderComponent") return false;
|
||||
if (type != "ShaderComponent") R_FALSE
|
||||
|
||||
std::string shaderTypeStr;
|
||||
std::getline(ss, shaderTypeStr);
|
||||
|
||||
SetActiveShader(StringToShaderType(shaderTypeStr));
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void OnImGuiRender() override {
|
||||
|
||||
@@ -154,6 +154,11 @@ public:
|
||||
*/
|
||||
void SetTranslateMatrix(XMMATRIX matrix) { m_TranslateMatrix = matrix; UpdateWorldMatrix(); }
|
||||
|
||||
/**
|
||||
* Serialize the transform component's state to a string.
|
||||
* The format is: "TransformComponent:posX:posY:posZ:rotX:rotY:rotZ:scaleX:scaleY:scaleZ"
|
||||
* @return A string representation of the transform component's state.
|
||||
*/
|
||||
std::string Serialize() const override
|
||||
{
|
||||
XMFLOAT3 position, rotation, scale;
|
||||
@@ -169,13 +174,19 @@ public:
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize the transform component's state from a string.
|
||||
* The expected format is: "TransformComponent:posX:posY:posZ:rotX:rotY:rotZ:scaleX:scaleY:scaleZ"
|
||||
* @param data The string representation of the transform component's state.
|
||||
* @return True if deserialization was successful, otherwise false.
|
||||
*/
|
||||
bool Deserialize(const std::string& data) override
|
||||
{
|
||||
std::stringstream ss(data);
|
||||
std::string type;
|
||||
std::getline(ss, type, ':');
|
||||
|
||||
if (type != "TransformComponent") return false;
|
||||
if (type != "TransformComponent") R_FALSE
|
||||
|
||||
std::string token;
|
||||
XMFLOAT3 position, rotation, scale;
|
||||
@@ -195,9 +206,13 @@ public:
|
||||
SetPosition(XMLoadFloat3(&position));
|
||||
SetRotation(XMLoadFloat3(&rotation));
|
||||
SetScale(XMLoadFloat3(&scale));
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the ImGui interface for editing the transform component.
|
||||
* This method provides draggable controls for position, rotation, and scale.
|
||||
*/
|
||||
void OnImGuiRender() override {
|
||||
XMFLOAT3 position, rotation, scale;
|
||||
XMStoreFloat3(&position, GetPosition());
|
||||
|
||||
@@ -5,8 +5,11 @@
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <WICTextureLoader.h>
|
||||
#include <d3d11.h>
|
||||
|
||||
#include "camera_class.h"
|
||||
#include <Fmod/core/inc/fmod.hpp>
|
||||
|
||||
namespace ecs {
|
||||
/**
|
||||
@@ -137,9 +140,50 @@ public:
|
||||
return m_Components;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the main camera of the scene to be used by components like AudioComponent.
|
||||
* @param camera
|
||||
*/
|
||||
void SetCamera(camera_class* camera) {m_camera = camera; }
|
||||
|
||||
/**
|
||||
* Get the main camera of the scene.
|
||||
* @return A pointer to the main camera.
|
||||
*/
|
||||
camera_class* GetCamera() const { return m_camera; }
|
||||
|
||||
/**
|
||||
* Set the FMOD sound system to be used by components like AudioComponent.
|
||||
* @param soundSystem
|
||||
*/
|
||||
void SetSoundSystem(FMOD::System* soundSystem) {m_soundSystem = soundSystem; }
|
||||
/**
|
||||
* Get the FMOD sound system.
|
||||
* @return A pointer to the FMOD sound system.
|
||||
*/
|
||||
FMOD::System* GetSoundSystem() const { return m_soundSystem; }
|
||||
|
||||
/**
|
||||
* Release all data associated with the entity.
|
||||
* This includes clearing all components and resetting the camera and sound system pointers.
|
||||
*/
|
||||
void release()
|
||||
{
|
||||
// call shutdown on all components if needed
|
||||
for (auto& [typeID, component] : m_Components) {
|
||||
// If components had a shutdown method, we would call it here
|
||||
component->Shutdown();
|
||||
}
|
||||
m_Components.clear();
|
||||
m_camera = nullptr;
|
||||
m_soundSystem = nullptr;
|
||||
}
|
||||
|
||||
void SetDevice (ID3D11Device* dev) { device = dev; }
|
||||
void SetContext(ID3D11DeviceContext* ctx) { context = ctx; }
|
||||
ID3D11Device* GetDevice() const { return device; }
|
||||
ID3D11DeviceContext* GetContext() const { return context; }
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@@ -154,6 +198,12 @@ private:
|
||||
|
||||
// camera
|
||||
camera_class* m_camera = nullptr;
|
||||
|
||||
// FMOD sound system
|
||||
FMOD::System* m_soundSystem = nullptr;
|
||||
|
||||
ID3D11Device* device;
|
||||
ID3D11DeviceContext* context;
|
||||
};
|
||||
|
||||
} // namespace ecs
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <queue>
|
||||
#include <d3d11.h>
|
||||
|
||||
namespace ecs {
|
||||
|
||||
@@ -32,6 +33,9 @@ public:
|
||||
|
||||
auto entity = std::make_shared<Entity>(id);
|
||||
entity->SetCamera(camera_);
|
||||
entity->SetSoundSystem(sound_system_);
|
||||
entity->SetDevice(device);
|
||||
entity->SetContext(context);
|
||||
m_Entities[id] = entity;
|
||||
|
||||
return entity;
|
||||
@@ -44,6 +48,7 @@ public:
|
||||
void DestroyEntity(EntityID id) {
|
||||
auto it = m_Entities.find(id);
|
||||
if (it != m_Entities.end()) {
|
||||
it->second->release();
|
||||
m_Entities.erase(it);
|
||||
m_FreeIDs.push(id); // Recycler l'ID
|
||||
}
|
||||
@@ -145,14 +150,46 @@ public:
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the main camera that will be propagate to the entity when creating a new entity.
|
||||
* @param camera Pointer to the camera_class instance.
|
||||
*/
|
||||
void SetCamera(camera_class* camera) { camera_ = camera; }
|
||||
|
||||
/**
|
||||
* Get the main camera used by entities.
|
||||
* @return Pointer to the camera_class instance.
|
||||
*/
|
||||
camera_class* GetCamera() const { return camera_; }
|
||||
|
||||
/**
|
||||
* Set the FMOD sound system that will be propagate to the entity when creating a new entity.
|
||||
* @param sound_system Pointer to the FMOD::System instance.
|
||||
*/
|
||||
void SetSoundSystem(FMOD::System* sound_system) { sound_system_ = sound_system; }
|
||||
/**
|
||||
* Get the FMOD sound system used by entities.
|
||||
* @return Pointer to the FMOD::System instance.
|
||||
*/
|
||||
FMOD::System* GetSoundSystem() const { return sound_system_; }
|
||||
|
||||
void SetDevice (ID3D11Device* dev) { device = dev; }
|
||||
void SetContext(ID3D11DeviceContext* ctx) { context = ctx; }
|
||||
ID3D11Device* GetDevice() const { return device; }
|
||||
ID3D11DeviceContext* GetContext() const { return context; }
|
||||
|
||||
int GetSkyID() const { return sky_id_; }
|
||||
void SetSkyID(int id) { sky_id_ = id; }
|
||||
|
||||
private:
|
||||
EntityID m_NextEntityID;
|
||||
std::unordered_map<EntityID, std::shared_ptr<Entity>> m_Entities;
|
||||
std::queue<EntityID> m_FreeIDs; // IDs <20> r<>utiliser
|
||||
camera_class* camera_ = nullptr;
|
||||
FMOD::System* sound_system_ = nullptr;
|
||||
ID3D11Device* device;
|
||||
ID3D11DeviceContext* context;
|
||||
int sky_id_ = -1;
|
||||
};
|
||||
|
||||
} // namespace ecs
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
auto shader = entity->GetComponent<ShaderComponent>();
|
||||
|
||||
if (!transform || !render || !shader || !render->GetModel())
|
||||
return false;
|
||||
R_FALSE
|
||||
|
||||
// Calculer la matrice monde
|
||||
XMMATRIX scaleMatrix = transform->GetScaleMatrix();
|
||||
@@ -238,6 +238,16 @@ public:
|
||||
// V<>rifier si le mod<6F>le est visible
|
||||
if (!render->IsVisible()) continue;
|
||||
|
||||
// check if the id the sky id to disabled the z buffer
|
||||
if (entity->GetID() == entityManager->GetSkyID())
|
||||
{
|
||||
// D<>sactiver le Z-buffer pour le skysphere
|
||||
m_deviceContext->OMSetDepthStencilState(nullptr, 0);
|
||||
} else {
|
||||
// Activer le Z-buffer pour les autres entit<69>s
|
||||
m_deviceContext->OMSetDepthStencilState(nullptr, 1);
|
||||
}
|
||||
|
||||
// Effectuer le rendu
|
||||
if (RenderEntity(entity, viewMatrix, projectionMatrix,
|
||||
diffuseColors, lightPositions, ambientColors,cameraPos,
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//////////////
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
|
||||
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
|
||||
class fps_limiter {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Builder for fps_limiter class
|
||||
* This class is used to limit the execution rate of a loop based on a target frames per second (FPS).
|
||||
* @param target_fps Target frames per second for the limiter. The default is 60.0f FPS.
|
||||
* Constructor for fps_limiter class
|
||||
* @param target_fps Target frames per second for the limiter. Default is 60.0f FPS.
|
||||
*/
|
||||
explicit fps_limiter(const float target_fps = 60.0f)
|
||||
: min_delta_(1.0f / target_fps), last_time_(std::chrono::high_resolution_clock::now()) {}
|
||||
@@ -25,7 +23,17 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically set the target FPS limit.
|
||||
* @param target_fps New target frames per second.
|
||||
*/
|
||||
void set_target_fps(float target_fps) {
|
||||
if (target_fps > 0.0f) {
|
||||
min_delta_ = 1.0f / target_fps;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
float min_delta_;
|
||||
std::chrono::high_resolution_clock::time_point last_time_;
|
||||
};
|
||||
float min_delta_; // Minimum time in seconds between frames
|
||||
std::chrono::high_resolution_clock::time_point last_time_; // Time point of last allowed execution
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <DirectXMath.h>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
|
||||
class frustum
|
||||
@@ -13,12 +14,14 @@ public:
|
||||
void ConstructFrustum(float screenDepth, XMMATRIX projectionMatrix, XMMATRIX viewMatrix);
|
||||
/**
|
||||
* Check if a point is inside the frustum.
|
||||
* @param x X coordinate of the point.
|
||||
* @param y Y coordinate of the point.
|
||||
* @param z Z coordinate of the point.
|
||||
* @param x_center X coordinate of the point.
|
||||
* @param y_center Y coordinate of the point.
|
||||
* @param z_center Z coordinate of the point.
|
||||
* @param radius Radius of the point (for bounding sphere).
|
||||
* @param tolerance Tolerance value for the check.
|
||||
* @return True if the point is inside the frustum, otherwise false.
|
||||
*/
|
||||
bool CheckCube(float xCenter, float yCenter, float zCenter, float radius, float tolerance);
|
||||
bool CheckCube(float x_center, float y_center, float z_center, float radius, float tolerance);
|
||||
|
||||
private:
|
||||
XMVECTOR m_planes[6];
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// INCLUDES //
|
||||
//////////////
|
||||
#include <directxmath.h>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "Logger.h"
|
||||
#include "sceneManager.h"
|
||||
#include "fps_limiter.h"
|
||||
#include "macro.h"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_dx11.h>
|
||||
@@ -17,6 +18,8 @@
|
||||
#include "scene_manager.h"
|
||||
#include "ecs/entity_manager.h"
|
||||
|
||||
#include "version.h"
|
||||
|
||||
class application_class;
|
||||
class stats;
|
||||
|
||||
@@ -31,6 +34,17 @@ struct widget_entry
|
||||
std::function<void()> func;
|
||||
};
|
||||
|
||||
struct ComponentEntry {
|
||||
const char* name;
|
||||
std::function<void()> addFunc;
|
||||
};
|
||||
|
||||
struct CachedEntity
|
||||
{
|
||||
std::string name;
|
||||
int id;
|
||||
};
|
||||
|
||||
class imguiManager
|
||||
{
|
||||
public:
|
||||
@@ -42,6 +56,16 @@ public:
|
||||
imguiManager();
|
||||
~imguiManager();
|
||||
|
||||
/**
|
||||
* Load the build version from a configuration file.
|
||||
* The configuration file should contain a line with the build version in the format "VER=XXX...".
|
||||
* If the line is not found, it will be added with a version of 0.
|
||||
* The build version will be incremented by 1 each time this function is called.
|
||||
* @param filepath The path to the configuration file.
|
||||
* @return True if the build version was loaded successfully, otherwise false.
|
||||
*/
|
||||
bool IncrementBuildVersionInConfig(const std::string& filepath);
|
||||
|
||||
/**
|
||||
* Initializes the ImGui manager.
|
||||
* @param hwnd Handle to the window where ImGui will be rendered.
|
||||
@@ -157,6 +181,10 @@ private:
|
||||
// --------------------------------------------- //
|
||||
// ----------------- Functions ----------------- //
|
||||
// --------------------------------------------- //
|
||||
/**
|
||||
* Update the cached entity list if there is a new, delete or rename entity
|
||||
*/
|
||||
void UpdateCachedEntitiesIfNeeded();
|
||||
|
||||
// --------------------------------------------- //
|
||||
// ----------------- Variables ----------------- //
|
||||
@@ -168,6 +196,8 @@ private:
|
||||
scene_manager* scene_manager_;
|
||||
stats* stats_;
|
||||
ecs::EntityManager* entity_manager_;
|
||||
|
||||
std::shared_ptr<ecs::Entity> sky_entity_shared_ptr_;
|
||||
|
||||
bool showObjectWindow;
|
||||
bool showTerrainWindow;
|
||||
@@ -212,6 +242,10 @@ private:
|
||||
std::string version_driver_;
|
||||
|
||||
ecs::EntityID m_selected_entity_id = 0; // ID of the currently selected entity
|
||||
std::vector<CachedEntity> cachedEntities_;
|
||||
bool entityListDirty = true;
|
||||
|
||||
int BUILD_VERSION_VER = -1;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -17,6 +17,7 @@
|
||||
//////////////
|
||||
#include "Logger.h"
|
||||
#include <dinput.h>
|
||||
#include "macro.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Class name: input_class
|
||||
@@ -24,6 +25,17 @@
|
||||
class input_class
|
||||
{
|
||||
public:
|
||||
|
||||
template<typename Container>
|
||||
std::vector<bool> get_key_states(const Container& key) const
|
||||
{
|
||||
std::vector<bool> key_states;
|
||||
key_states.reserve(key.size());
|
||||
for (auto k : key)
|
||||
key_states.push_back(this->is_key_pressed(k));
|
||||
return key_states;
|
||||
}
|
||||
|
||||
input_class();
|
||||
input_class(const input_class&);
|
||||
~input_class();
|
||||
@@ -44,15 +56,11 @@ public:
|
||||
bool IsScrollDown() const;
|
||||
bool IsUpArrowPressed() const;
|
||||
bool IsDownArrowPressed() const;
|
||||
bool IsAPressed() const;
|
||||
bool IsDPressed() const;
|
||||
bool IsWPressed() const;
|
||||
bool IsSPressed() const;
|
||||
bool IsQPressed() const;
|
||||
bool IsEPressed()const;
|
||||
bool IsKeyDown(unsigned int) const;
|
||||
bool is_key_pressed(const unsigned int);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
bool m_keys[256];
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
// INCLUDES //
|
||||
//////////////
|
||||
#include <directxmath.h>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
|
||||
|
||||
|
||||
185
enginecustom/src/inc/system/macro.h
Normal file
185
enginecustom/src/inc/system/macro.h
Normal file
@@ -0,0 +1,185 @@
|
||||
#pragma once
|
||||
#include "imgui.h"
|
||||
#include "Logger.h"
|
||||
#include <limits>
|
||||
#include <DirectXMath.h>
|
||||
// --------------------- //
|
||||
// --- Global Macros --- //
|
||||
// --------------------- //
|
||||
#define R_FALSE return false;
|
||||
#define R_TRUE return true;
|
||||
#define TO_RAD 0.0174532925f
|
||||
#define TO_DEG (180.0f/3.141593f)
|
||||
|
||||
#ifdef max
|
||||
#pragma push_macro("max")
|
||||
#undef max
|
||||
#define PUSHED_MAX_DEFINED
|
||||
#endif
|
||||
|
||||
|
||||
// convert unsigned long long int to int safely
|
||||
inline int ulli_to_int(unsigned long long x)
|
||||
{
|
||||
return (x > static_cast<unsigned long long>(std::numeric_limits<int>::max())) ? std::numeric_limits<int>::max() : static_cast<int>(x);
|
||||
}
|
||||
|
||||
// convert int to float safely
|
||||
inline float int_to_float(int x)
|
||||
{
|
||||
return (x > static_cast<int>(std::numeric_limits<float>::max())) ? std::numeric_limits<float>::max() : static_cast<float>(x);
|
||||
}
|
||||
|
||||
// convert size_t to int safely
|
||||
inline int size_t_to_int(size_t x)
|
||||
{
|
||||
return (x > static_cast<size_t>(std::numeric_limits<int>::max())) ? std::numeric_limits<int>::max() : static_cast<int>(x);
|
||||
}
|
||||
|
||||
#ifdef PUSHED_MAX_DEFINED
|
||||
#pragma pop_macro("max")
|
||||
#undef PUSHED_MAX_DEFINED
|
||||
#endif
|
||||
// --------------------------------------------------------- //
|
||||
// --- Macros for logging with different severity levels --- //
|
||||
// --------------------------------------------------------- //
|
||||
|
||||
#define LOG(msg, level) Logger::Get().Log(msg, __FILE__, __LINE__, level)
|
||||
#define LOG_INFO(msg) Logger::Get().Log(msg, __FILE__, __LINE__, Logger::LogLevel::Info)
|
||||
#define LOG_WARNING(msg) Logger::Get().Log(msg, __FILE__, __LINE__, Logger::LogLevel::Warning)
|
||||
#define LOG_ERROR(msg) Logger::Get().Log(msg, __FILE__, __LINE__, Logger::LogLevel::Error)
|
||||
#define LOG_DEBUG(msg) Logger::Get().Log(msg, __FILE__, __LINE__, Logger::LogLevel::Debug)
|
||||
#define LOG_SHUTDOWN(msg) Logger::Get().Log(msg, __FILE__, __LINE__, Logger::LogLevel::Shutdown)
|
||||
#define LOG_INIT(msg) Logger::Get().Log(msg, __FILE__, __LINE__, Logger::LogLevel::Initialize)
|
||||
|
||||
#define R_LOG_ERROR(result,msg) \
|
||||
if(!(result)) { \
|
||||
LOG_ERROR(msg); \
|
||||
return false; \
|
||||
}
|
||||
|
||||
// ---------------------------------------------------- //
|
||||
// --- Macros for the Entity Component System (ECS) --- //
|
||||
// ---------------------------------------------------- //
|
||||
#define CREATE_ENTITY entity_manager_->CreateEntity();
|
||||
|
||||
#define SHD_ALPHA ecs::ShaderType::ALPHA_MAPPING
|
||||
#define SHD_CEL ecs::ShaderType::CEL_SHADING
|
||||
#define SHD_LIGHT ecs::ShaderType::LIGHTING
|
||||
#define SHD_NORM ecs::ShaderType::NORMAL_MAPPING
|
||||
#define SHD_REFL ecs::ShaderType::REFLECTION
|
||||
#define SHD_REFR ecs::ShaderType::REFRACTION
|
||||
#define SHD_SKYBOX ecs::ShaderType::SKYBOX
|
||||
#define SHD_SPEC ecs::ShaderType::SPECULAR_MAPPING
|
||||
#define SHD_SUN ecs::ShaderType::SUNLIGHT
|
||||
#define SHD_TEX ecs::ShaderType::TEXTURE
|
||||
|
||||
// ---------------------------------------- //
|
||||
// --- Macros for the application class --- //
|
||||
// ---------------------------------------- //
|
||||
#define CHECK_2_CONDITION_INDEPENDENT_RETURN(cond1, cond2) \
|
||||
if(!(cond1)) { \
|
||||
LOG_ERROR("Condition 1 failed: " #cond1); \
|
||||
return false; \
|
||||
} \
|
||||
if (!(cond2)) { \
|
||||
LOG_ERROR("Condition 2 failed: " #cond2); \
|
||||
return false; \
|
||||
}
|
||||
|
||||
#define CHECK_CONDITION_RETURN(cond) \
|
||||
if(!(cond)) { \
|
||||
LOG_ERROR("Condition failed: " #cond); \
|
||||
return false; \
|
||||
}
|
||||
|
||||
// ------------------------------------------------ //
|
||||
// --- Macros and constexpr for the ImGUI class --- //
|
||||
// ------------------------------------------------ //
|
||||
constexpr ImVec4 BG_DK_GRAY = ImVec4(0.1f, 0.1f, 0.1f, 1.0f);
|
||||
constexpr ImVec4 BG_GRAY = ImVec4(0.2f, 0.2f, 0.2f, 1.0f);
|
||||
constexpr ImVec4 BG_LT_GRAY = ImVec4(0.3f, 0.3f, 0.3f, 1.0f);
|
||||
constexpr ImVec4 ACCENT_COLOR = ImVec4(0.14f, 0.5f, 0.8f, 0.5f);
|
||||
constexpr ImVec4 ACCENT_LT_COLOR= ImVec4(0.14f, 0.5f, 0.8f, 1.0f);
|
||||
constexpr ImVec4 TEXT_COLOR = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
constexpr ImVec4 TEXT_DIM_COLOR = ImVec4(0.6f, 0.6f, 0.6f, 1.0f);
|
||||
constexpr ImVec4 BORDER_COLOR = ImVec4(0.25f, 0.25f, 0.27f, 1.00f);
|
||||
constexpr ImVec4 BLK = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
#define BASIC_DOCK_STYLE_1 \
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); \
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); \
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); \
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_DockingSeparatorSize, 1.0f);
|
||||
|
||||
#define BEGIN(name, p_open) ImGui::Begin(name, p_open);
|
||||
#define S_LINE ImGui::SameLine();
|
||||
#define E_MENU ImGui::EndMenu();
|
||||
#define END ImGui::End();
|
||||
#define TEXT_V(label,var) ImGui::Text(label, var);
|
||||
#define SEP ImGui::Separator();
|
||||
#define PSV ImGui::PopStyleVar();
|
||||
#define O_POPUP(str) ImGui::OpenPopup(str);
|
||||
#define E_POPUP ImGui::EndPopup();
|
||||
#define TEX(label) ImGui::Text(label);
|
||||
|
||||
#define BUTTON(label) ImGui::Button(label)
|
||||
#define B_MENU(label) ImGui::BeginMenu(label)
|
||||
#define M_ITEM_LP(label, p_open) ImGui::MenuItem(label, NULL, p_open)
|
||||
#define M_ITEM_L(label) ImGui::MenuItem(label)
|
||||
#define F_SLIDER(label, value, min, max) ImGui::SliderFloat(label, value, min, max)
|
||||
#define I_SLIDER(label, value, min, max) ImGui::SliderInt(label, value, min, max)
|
||||
#define C_HEADER(label) ImGui::CollapsingHeader(label)
|
||||
#define SEL(label, isSelected) ImGui::Selectable(label, isSelected)
|
||||
#define I_TEX(label, buf, buf_size) ImGui::InputText(label, buf, buf_size)
|
||||
#define C_BOX(label, v) ImGui::Checkbox(label, v)
|
||||
#define B_POPUP(str) ImGui::BeginPopup(str)
|
||||
|
||||
// ------------------------------------ //
|
||||
// --- Macros for the frustum class --- //
|
||||
// ------------------------------------ //
|
||||
inline bool TestPlaneCorner(
|
||||
const DirectX::XMVECTOR& plane,
|
||||
float xPos, float yPos, float zPos,
|
||||
float tolerance)
|
||||
{
|
||||
float val =
|
||||
DirectX::XMVectorGetX(plane) * xPos +
|
||||
DirectX::XMVectorGetY(plane) * yPos +
|
||||
DirectX::XMVectorGetZ(plane) * zPos +
|
||||
DirectX::XMVectorGetW(plane);
|
||||
return val > -tolerance;
|
||||
}
|
||||
|
||||
#define CHECK_FRUSTRUM_CUBE_CORNERS(plane, xCenter, yCenter, zCenter, radius, tolerance) \
|
||||
do { \
|
||||
const float offsets[2] = { -radius, radius }; \
|
||||
bool inside = false; \
|
||||
for (int xi = 0; xi < 2 && !inside; ++xi) { \
|
||||
for (int yi = 0; yi < 2 && !inside; ++yi) { \
|
||||
for (int zi = 0; zi < 2 && !inside; ++zi) { \
|
||||
if (TestPlaneCorner(plane, xCenter + offsets[xi], yCenter + offsets[yi], zCenter + offsets[zi], tolerance)) { \
|
||||
inside = true; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
if (!inside) { \
|
||||
R_FALSE; \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
// ---------------------------------------------- //
|
||||
// --- Macros for the camera input processing --- //
|
||||
// ---------------------------------------------- //
|
||||
struct CameraInput {
|
||||
bool move_forward = false;
|
||||
bool move_backward = false;
|
||||
bool move_left = false;
|
||||
bool move_right = false;
|
||||
bool move_up = false;
|
||||
bool move_down = false;
|
||||
bool scroll_up = false;
|
||||
bool scroll_down = false;
|
||||
bool right_click = false;
|
||||
};
|
||||
@@ -6,6 +6,7 @@
|
||||
// INCLUDES //
|
||||
//////////////
|
||||
#include "Logger.h"
|
||||
#include "macro.h"
|
||||
|
||||
#include <d3d11.h>
|
||||
#include <directxmath.h>
|
||||
|
||||
@@ -22,16 +22,10 @@ public:
|
||||
void GetRotation(float&, float&) const;
|
||||
void GetPosition(float&, float&, float&) const;
|
||||
|
||||
void TurnLeft(bool);
|
||||
void TurnRight(bool);
|
||||
void TurnMouse(float, float, float, bool);
|
||||
void MoveCamera(bool, bool, bool, bool, bool, bool, bool, bool, bool);
|
||||
|
||||
private:
|
||||
float m_frameTime;
|
||||
float m_rotationY, m_rotationX;
|
||||
float m_positionX, m_positionY, m_positionZ;
|
||||
float m_leftTurnSpeed, m_rightTurnSpeed, m_horizontalTurnSpeed, m_verticalTurnSpeed, m_cameraSpeed, m_speed;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "Logger.h"
|
||||
#include <d3d11.h>
|
||||
#include <directxmath.h>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "macro.h"
|
||||
|
||||
#include "ecs/entity.h"
|
||||
#include "ecs/ComponentFactory.h"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <d3d11.h>
|
||||
#include <directxmath.h>
|
||||
#include "macro.h"
|
||||
|
||||
class shadow_map {
|
||||
public:
|
||||
|
||||
@@ -64,6 +64,8 @@ private:
|
||||
bool is_debug_key_pressed_ = false;
|
||||
|
||||
std::mutex render_mutex_;
|
||||
|
||||
std::unique_ptr<fps_limiter> fps_limiter_ = std::make_unique<fps_limiter>(60);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "Logger.h"
|
||||
#include <d3d11.h>
|
||||
#include <stdio.h>
|
||||
#include "macro.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//////////////
|
||||
#include "Logger.h"
|
||||
#include <windows.h>
|
||||
#include "macro.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
34
enginecustom/src/inc/system/version.h
Normal file
34
enginecustom/src/inc/system/version.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include "imgui.h"
|
||||
/**
|
||||
* Definitions for build versioning.
|
||||
* The build version is composed of:
|
||||
* - Major version (BUILD_VERSION_MAJOR)
|
||||
* - Minor version (BUILD_VERSION_MINOR)
|
||||
* - Patch version (BUILD_VERSION_PATCH)
|
||||
* - Build number (BUILD_VERSION_VER) which is incremented at each build.
|
||||
* - Build type (BUILD_VERSION_TYPE) which can be "Debug" or "Release"
|
||||
* - Build state (BUILD_VERSION_STATE) which can be "Dev" or "Stable"
|
||||
*/
|
||||
#define BUILD_VERSION_MAJOR 14
|
||||
#define BUILD_VERSION_MINOR 5
|
||||
#define BUILD_VERSION_PATCH 27
|
||||
|
||||
// BUILD_VERSION_VER est un int persist<73> dans un fichier, <20> charger au lancement et incr<63>menter <20> chaque build (voir point 3)
|
||||
extern int BUILD_VERSION_VER;
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define BUILD_VERSION_TYPE "Debug"
|
||||
#define BUILD_VERSION_INVERSE "Release"
|
||||
// define a color for debug mode (dark yellow)
|
||||
#define DEBUG_MODE_COLOR IM_COL32(204, 153, 0, 255)
|
||||
#else
|
||||
#define BUILD_VERSION_TYPE "Release"
|
||||
#define BUILD_VERSION_INVERSE "Debug"
|
||||
// define a color for release mode (rouge bordeau)
|
||||
#define DEBUG_MODE_COLOR IM_COL32(128, 0, 32, 255)
|
||||
#endif
|
||||
|
||||
// BUILD_VERSION_STATE est d<>fini manuellement (ex "Dev" ou "Stable")
|
||||
#define BUILD_VERSION_STATE "Dev"
|
||||
//#define BUILD_VERSION_STATE "Stable"
|
||||
@@ -23,7 +23,7 @@ alpha_map_shader_class::~alpha_map_shader_class()
|
||||
|
||||
bool alpha_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
Logger::Get().Log("Initializing alpha_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing alpha_map_shader_class");
|
||||
|
||||
bool result;
|
||||
wchar_t vsFilename[128];
|
||||
@@ -34,27 +34,27 @@ bool alpha_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/alphamap.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Error copying string ", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error copying string ");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/alphamap.ps");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Error copying string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error copying string");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// initialize the vertex and pixel shaders.
|
||||
result = initialize_shader(device, hwnd, vsFilename, psFilename);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error initializing shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -77,20 +77,20 @@ bool alpha_map_shader_class::render(ID3D11DeviceContext* deviceContext, int inde
|
||||
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error setting shader parameters");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now render the prepared buffers with the shader.
|
||||
render_shader(deviceContext, indexCount);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
bool alpha_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
|
||||
{
|
||||
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing shader");
|
||||
|
||||
HRESULT result;
|
||||
ID3D10Blob* errorMessage;
|
||||
@@ -120,10 +120,10 @@ bool alpha_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
// If there was nothing in the error message then it simply could not find the shader file itself.
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Error compiling shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Error compiling shader");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Compile the pixel shader code.
|
||||
@@ -139,26 +139,26 @@ bool alpha_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
// If there was nothing in the error message then it simply could not find the file itself.
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Error compiling shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Error compiling shader");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex shader from the buffer.
|
||||
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating vertex shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the pixel shader from the buffer.
|
||||
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating pixel shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex input layout description.
|
||||
@@ -194,8 +194,8 @@ bool alpha_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
vertexShaderBuffer->GetBufferSize(), &layout_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating input layout");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
|
||||
@@ -217,8 +217,8 @@ bool alpha_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating constant buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create a texture sampler state description.
|
||||
@@ -240,67 +240,67 @@ bool alpha_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating sampler state");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Shader initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
void alpha_map_shader_class::shutdown_shader()
|
||||
{
|
||||
|
||||
Logger::Get().Log("Shutting down shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down shader");
|
||||
|
||||
// Release the sampler state.
|
||||
if (sample_state_)
|
||||
{
|
||||
Logger::Get().Log("Releasing sampler state", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Releasing sampler state");
|
||||
sample_state_->Release();
|
||||
sample_state_ = 0;
|
||||
Logger::Get().Log("Sampler state released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Sampler state released");
|
||||
}
|
||||
|
||||
// Release the matrix constant buffer.
|
||||
if (matrix_buffer_)
|
||||
{
|
||||
Logger::Get().Log("Releasing constant buffer", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Releasing constant buffer");
|
||||
matrix_buffer_->Release();
|
||||
matrix_buffer_ = 0;
|
||||
Logger::Get().Log("Constant buffer released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Constant buffer released");
|
||||
}
|
||||
|
||||
// Release the layout.
|
||||
if (layout_)
|
||||
{
|
||||
Logger::Get().Log("Releasing layout", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Releasing layout");
|
||||
layout_->Release();
|
||||
layout_ = 0;
|
||||
Logger::Get().Log("Layout released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Layout released");
|
||||
}
|
||||
|
||||
// Release the pixel shader.
|
||||
if (pixel_shader_)
|
||||
{
|
||||
Logger::Get().Log("Releasing pixel shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Releasing pixel shader");
|
||||
pixel_shader_->Release();
|
||||
pixel_shader_ = 0;
|
||||
Logger::Get().Log("Pixel shader released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Pixel shader released");
|
||||
}
|
||||
|
||||
// Release the vertex shader.
|
||||
if (vertex_shader_)
|
||||
{
|
||||
Logger::Get().Log("Releasing vertex shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Releasing vertex shader");
|
||||
vertex_shader_->Release();
|
||||
vertex_shader_ = 0;
|
||||
Logger::Get().Log("Vertex shader released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Vertex shader released");
|
||||
}
|
||||
|
||||
Logger::Get().Log("Shader shutdown complete", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shader shutdown complete");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -360,8 +360,8 @@ bool alpha_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCo
|
||||
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error mapping constant buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -386,7 +386,7 @@ bool alpha_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCo
|
||||
deviceContext->PSSetShaderResources(1, 1, &texture2);
|
||||
deviceContext->PSSetShaderResources(2, 1, &texture3);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ celshade_class::~celshade_class()
|
||||
|
||||
bool celshade_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
Logger::Get().Log("Initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing LightShaderClass");
|
||||
|
||||
wchar_t vsFilename[128];
|
||||
wchar_t psFilename[128];
|
||||
@@ -41,28 +41,28 @@ bool celshade_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/celshading.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to copy string");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/celshading.ps");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to copy string");
|
||||
R_FALSE
|
||||
}
|
||||
// initialize the vertex and pixel shaders.
|
||||
result = initialize_shader(device, hwnd, vsFilename, psFilename);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to initialize shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to initialize shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("SunLightShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("SunLightShaderClass initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -84,20 +84,20 @@ bool celshade_class::render(ID3D11DeviceContext* deviceContext, int index_count,
|
||||
result = set_shader_parameters(deviceContext, world_matrix, view_matrix, projection_matrix, texture, diffuse_color, ambient_color, sun_direction, sunIntensity);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to set shader parameters");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now render the prepared buffers with the shader.
|
||||
render_shader(deviceContext, index_count);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
bool celshade_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
|
||||
{
|
||||
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing shader");
|
||||
|
||||
HRESULT result;
|
||||
ID3D10Blob* errorMessage;
|
||||
@@ -124,9 +124,9 @@ bool celshade_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* v
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Failed to compile shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to compile shader");
|
||||
}
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Compile the pixel shader code.
|
||||
@@ -139,25 +139,25 @@ bool celshade_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* v
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Failed to compile shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to compile shader");
|
||||
}
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex shader from the buffer.
|
||||
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create vertex shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the pixel shader from the buffer.
|
||||
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create pixel shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex input layout description.
|
||||
@@ -192,8 +192,8 @@ bool celshade_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* v
|
||||
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &layout_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create input layout");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
|
||||
@@ -222,8 +222,8 @@ bool celshade_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* v
|
||||
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create sampler state");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
|
||||
@@ -238,8 +238,8 @@ bool celshade_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* v
|
||||
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create matrix buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the dynamic sunlight constant buffer that is in the pixel shader.
|
||||
@@ -254,13 +254,13 @@ bool celshade_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* v
|
||||
result = device->CreateBuffer(&sunlightBufferDesc, NULL, &sunlight_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create sunlight buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create sunlight buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Shader initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -268,7 +268,7 @@ bool celshade_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* v
|
||||
|
||||
void celshade_class::shutdown_shader()
|
||||
{
|
||||
Logger::Get().Log("Shutting down SunLightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down SunLightShaderClass");
|
||||
|
||||
// Release the light constant buffers.
|
||||
if (sunlight_color_buffer_)
|
||||
@@ -332,7 +332,7 @@ void celshade_class::shutdown_shader()
|
||||
vertex_shader_ = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("SunLightShaderClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("SunLightShaderClass shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -389,7 +389,6 @@ bool celshade_class::set_shader_parameters(
|
||||
HRESULT result;
|
||||
D3D11_MAPPED_SUBRESOURCE mappedResource;
|
||||
matrix_buffer_type* dataPtr;
|
||||
camera_buffer_type* dataPtr2;
|
||||
sun_light_buffer_type* dataPtr3;
|
||||
unsigned int bufferNumber;
|
||||
|
||||
@@ -402,7 +401,7 @@ bool celshade_class::set_shader_parameters(
|
||||
result = device_context->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -426,7 +425,7 @@ bool celshade_class::set_shader_parameters(
|
||||
result = device_context->Map(sunlight_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -450,7 +449,7 @@ bool celshade_class::set_shader_parameters(
|
||||
// Set shader texture resource in the pixel shader.
|
||||
device_context->PSSetShaderResources(0, 1, &texture);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void celshade_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
|
||||
|
||||
@@ -23,7 +23,7 @@ color_shader_class::~color_shader_class()
|
||||
|
||||
bool color_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
Logger::Get().Log("Initializing color_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing color_shader_class");
|
||||
|
||||
bool result;
|
||||
wchar_t vsFilename[128];
|
||||
@@ -35,29 +35,29 @@ bool color_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/Color.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Error copying string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error copying string");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/Color.ps");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Error copying string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error copying string");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// initialize the vertex and pixel shaders.
|
||||
result = initialize_shader(device, hwnd, vsFilename, psFilename);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error initializing shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("color_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("color_shader_class initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void color_shader_class::shutdown()
|
||||
@@ -78,19 +78,19 @@ bool color_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCou
|
||||
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error setting shader parameters");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now render the prepared buffers with the shader.
|
||||
render_shader(deviceContext, indexCount);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool color_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
|
||||
{
|
||||
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing shader");
|
||||
|
||||
HRESULT result;
|
||||
ID3D10Blob* errorMessage;
|
||||
@@ -119,10 +119,10 @@ bool color_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
// If there was nothing in the error message then it simply could not find the shader file itself.
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Error compiling shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Error compiling shader");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Compile the pixel shader code.
|
||||
@@ -138,26 +138,26 @@ bool color_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
// If there was nothing in the error message then it simply could not find the file itself.
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Error compiling shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Error compiling shader");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex shader from the buffer.
|
||||
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating vertex shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the pixel shader from the buffer.
|
||||
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating pixel shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex input layout description.
|
||||
@@ -186,8 +186,8 @@ bool color_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
vertexShaderBuffer->GetBufferSize(), &layout_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating input layout");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
|
||||
@@ -209,56 +209,56 @@ bool color_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating constant buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Shader initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void color_shader_class::shutdown_shader()
|
||||
{
|
||||
Logger::Get().Log("Shutting down shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down shader");
|
||||
|
||||
// Release the matrix constant buffer.
|
||||
if (matrix_buffer_)
|
||||
{
|
||||
Logger::Get().Log("Releasing matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Releasing matrix buffer");
|
||||
matrix_buffer_->Release();
|
||||
matrix_buffer_ = 0;
|
||||
Logger::Get().Log("Matrix buffer released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Matrix buffer released");
|
||||
}
|
||||
|
||||
// Release the layout.
|
||||
if (layout_)
|
||||
{
|
||||
Logger::Get().Log("Releasing layout", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Releasing layout");
|
||||
layout_->Release();
|
||||
layout_ = 0;
|
||||
Logger::Get().Log("Layout released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Layout released");
|
||||
}
|
||||
|
||||
// Release the pixel shader.
|
||||
if (pixel_shader_)
|
||||
{
|
||||
Logger::Get().Log("Releasing pixel shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Releasing pixel shader");
|
||||
pixel_shader_->Release();
|
||||
pixel_shader_ = 0;
|
||||
Logger::Get().Log("Pixel shader released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Pixel shader released");
|
||||
}
|
||||
|
||||
// Release the vertex shader.
|
||||
if (vertex_shader_)
|
||||
{
|
||||
Logger::Get().Log("Releasing vertex shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Releasing vertex shader");
|
||||
vertex_shader_->Release();
|
||||
vertex_shader_ = 0;
|
||||
Logger::Get().Log("Vertex shader released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Vertex shader released");
|
||||
}
|
||||
|
||||
Logger::Get().Log("Shader shut down", __FILE__, __LINE__);
|
||||
LOG_SHUTDOWN("Shader shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -301,7 +301,7 @@ void color_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, H
|
||||
bool color_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
|
||||
XMMATRIX projectionMatrix)
|
||||
{
|
||||
Logger::Get().Log("Setting shader parameters", __FILE__, __LINE__);
|
||||
LOG_DEBUG("Setting shader parameters");
|
||||
|
||||
HRESULT result;
|
||||
D3D11_MAPPED_SUBRESOURCE mappedResource;
|
||||
@@ -317,8 +317,8 @@ bool color_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
|
||||
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error mapping constant buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -338,7 +338,7 @@ bool color_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
|
||||
// Finanly set the constant buffer in the vertex shader with the updated values.
|
||||
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void color_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
|
||||
|
||||
@@ -7,7 +7,6 @@ depth_shader_class::depth_shader_class()
|
||||
pixel_shader_ = 0;
|
||||
layout_ = 0;
|
||||
matrix_buffer_ = 0;
|
||||
sample_state_ = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +22,7 @@ depth_shader_class::~depth_shader_class()
|
||||
|
||||
bool depth_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
Logger::Get().Log("Initializing texture shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing texture shader");
|
||||
|
||||
bool result;
|
||||
wchar_t vsFilename[128];
|
||||
@@ -33,29 +32,29 @@ bool depth_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/depth.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Error copying stirng", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error copying stirng");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/depth.ps");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Error copying stirng", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error copying stirng");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// initialize the vertex and pixel shaders.
|
||||
result = initialize_shader(device, hwnd, vsFilename, psFilename);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error initializing shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Texture shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Texture shader initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void depth_shader_class::shutdown()
|
||||
@@ -67,28 +66,27 @@ void depth_shader_class::shutdown()
|
||||
}
|
||||
|
||||
bool depth_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
|
||||
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture)
|
||||
XMMATRIX projectionMatrix)
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
// Set the shader parameters that it will use for rendering.
|
||||
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture);
|
||||
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error setting shader parameters");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now render the prepared buffers with the shader.
|
||||
render_shader(deviceContext, indexCount);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool depth_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
|
||||
{
|
||||
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing shader");
|
||||
|
||||
HRESULT result;
|
||||
ID3D10Blob* errorMessage;
|
||||
@@ -97,7 +95,6 @@ bool depth_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
D3D11_INPUT_ELEMENT_DESC polygonLayout[2];
|
||||
unsigned int numElements;
|
||||
D3D11_BUFFER_DESC matrixBufferDesc;
|
||||
D3D11_SAMPLER_DESC samplerDesc;
|
||||
|
||||
|
||||
// initialize the pointers this function will use to null.
|
||||
@@ -117,10 +114,10 @@ bool depth_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
// If there was nothing in the error message then it simply could not find the shader file itself.
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Error compiling shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Error compiling shader");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Compile the pixel shader code.
|
||||
@@ -136,26 +133,26 @@ bool depth_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
// If there was nothing in the error message then it simply could not find the file itself.
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Error compiling shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Error compiling shader");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex shader from the buffer.
|
||||
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating vertex shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the pixel shader from the buffer.
|
||||
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating pixel shader");
|
||||
R_FALSE
|
||||
}
|
||||
// Create the vertex input layout description.
|
||||
// This setup needs to match the VertexType stucture in the ModelClass and in the shader.
|
||||
@@ -183,8 +180,8 @@ bool depth_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
vertexShaderBuffer->GetBufferSize(), &layout_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating input layout");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
|
||||
@@ -206,47 +203,18 @@ bool depth_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Create a texture sampler state description.
|
||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 1;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
|
||||
// Create the texture sampler state.
|
||||
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating constant buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Shader initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void depth_shader_class::shutdown_shader()
|
||||
{
|
||||
Logger::Get().Log("Shutting down shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
|
||||
// Release the sampler state.
|
||||
if (sample_state_)
|
||||
{
|
||||
sample_state_->Release();
|
||||
sample_state_ = 0;
|
||||
}
|
||||
LOG_SHUTDOWN("Shutting down shader");
|
||||
|
||||
// Release the matrix constant buffer.
|
||||
if (matrix_buffer_)
|
||||
@@ -276,7 +244,7 @@ void depth_shader_class::shutdown_shader()
|
||||
vertex_shader_ = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("Shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shader shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -317,7 +285,7 @@ void depth_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, H
|
||||
}
|
||||
|
||||
bool depth_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
|
||||
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture)
|
||||
XMMATRIX projectionMatrix)
|
||||
{
|
||||
HRESULT result;
|
||||
D3D11_MAPPED_SUBRESOURCE mappedResource;
|
||||
@@ -334,8 +302,8 @@ bool depth_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
|
||||
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error mapping constant buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -354,10 +322,8 @@ bool depth_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
|
||||
|
||||
// Finanly set the constant buffer in the vertex shader with the updated values.
|
||||
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
|
||||
// Set shader texture resource in the pixel shader.
|
||||
deviceContext->PSSetShaderResources(0, 1, &texture);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void depth_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
|
||||
@@ -368,8 +334,6 @@ void depth_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int i
|
||||
// Set the vertex and pixel shaders that will be used to render this triangle.
|
||||
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
|
||||
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
|
||||
// Set the sampler state in the pixel shader.
|
||||
deviceContext->PSSetSamplers(0, 1, &sample_state_);
|
||||
|
||||
// render the triangle.
|
||||
deviceContext->DrawIndexed(indexCount, 0, 0);
|
||||
|
||||
@@ -24,7 +24,7 @@ font_shader_class::~font_shader_class()
|
||||
|
||||
bool font_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
Logger::Get().Log("Initializing font_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing font_shader_class");
|
||||
|
||||
bool result;
|
||||
wchar_t vsFilename[128];
|
||||
@@ -35,29 +35,29 @@ bool font_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/font.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Error copying string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error copying string");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/font.ps");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Error copying string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error copying string");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// initialize the vertex and pixel shaders.
|
||||
result = initialize_shader(device, hwnd, vsFilename, psFilename);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error initializing shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("font_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
return true;
|
||||
LOG_INIT("font_shader_class initialized");
|
||||
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void font_shader_class::shutdown()
|
||||
@@ -78,19 +78,19 @@ bool font_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCoun
|
||||
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, pixelColor);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error setting shader parameters");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now render the prepared buffers with the shader.
|
||||
render_shader(deviceContext, indexCount);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool font_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
|
||||
{
|
||||
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing shader");
|
||||
|
||||
HRESULT result;
|
||||
ID3D10Blob* errorMessage;
|
||||
@@ -121,10 +121,10 @@ bool font_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR
|
||||
// If there was nothing in the error message then it simply could not find the shader file itself.
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Error compiling shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Error compiling shader");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Compile the pixel shader code.
|
||||
@@ -140,26 +140,26 @@ bool font_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR
|
||||
// If there was nothing in the error message then it simply could not find the file itself.
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Error compiling shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Error compiling shader");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex shader from the buffer.
|
||||
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating vertex shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the pixel shader from the buffer.
|
||||
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating pixel shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex input layout description.
|
||||
@@ -188,8 +188,8 @@ bool font_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR
|
||||
vertexShaderBuffer->GetBufferSize(), &layout_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating input layout");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
|
||||
@@ -211,8 +211,8 @@ bool font_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR
|
||||
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating constant buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create a texture sampler state description.
|
||||
@@ -234,8 +234,8 @@ bool font_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR
|
||||
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating sampler state");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the dynamic pixel constant buffer that is in the pixel shader.
|
||||
@@ -250,18 +250,18 @@ bool font_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR
|
||||
result = device->CreateBuffer(&pixelBufferDesc, NULL, &pixel_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating constant buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Shader initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void font_shader_class::shutdown_shader()
|
||||
{
|
||||
Logger::Get().Log("Shutting down shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down shader");
|
||||
|
||||
// Release the pixel constant buffer.
|
||||
if (pixel_buffer_)
|
||||
@@ -305,7 +305,7 @@ void font_shader_class::shutdown_shader()
|
||||
vertex_shader_ = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("Shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shader shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -365,8 +365,8 @@ bool font_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext
|
||||
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error mapping constant buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -393,8 +393,8 @@ bool font_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext
|
||||
result = deviceContext->Map(pixel_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error mapping constant buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the pixel constant buffer.
|
||||
@@ -412,7 +412,7 @@ bool font_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext
|
||||
// Now set the pixel constant buffer in the pixel shader with the updated value.
|
||||
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &pixel_buffer_);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void font_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
|
||||
|
||||
@@ -23,7 +23,7 @@ light_map_shader_class::~light_map_shader_class()
|
||||
|
||||
bool light_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
Logger::Get().Log("Initializing light_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing light_map_shader_class");
|
||||
|
||||
bool result;
|
||||
wchar_t vsFilename[128];
|
||||
@@ -34,29 +34,29 @@ bool light_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/lightmap.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Error copying string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error copying string");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/lightmap.ps");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Error copying string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error copying string");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// initialize the vertex and pixel shaders.
|
||||
result = initialize_shader(device, hwnd, vsFilename, psFilename);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error initializing shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("light_map_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("light_map_shader_class initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -74,25 +74,24 @@ bool light_map_shader_class::render(ID3D11DeviceContext* deviceContext, int inde
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
// Set the shader parameters that it will use for rendering.
|
||||
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error setting shader parameters");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now render the prepared buffers with the shader.
|
||||
render_shader(deviceContext, indexCount);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
bool light_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
|
||||
{
|
||||
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing shader");
|
||||
HRESULT result;
|
||||
ID3D10Blob* errorMessage;
|
||||
ID3D10Blob* vertexShaderBuffer;
|
||||
@@ -121,10 +120,10 @@ bool light_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
// If there was nothing in the error message then it simply could not find the shader file itself.
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Error compiling shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Error compiling shader");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Compile the pixel shader code.
|
||||
@@ -140,26 +139,26 @@ bool light_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
// If there was nothing in the error message then it simply could not find the file itself.
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Error compiling shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Error compiling shader");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex shader from the buffer.
|
||||
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating vertex shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the pixel shader from the buffer.
|
||||
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating pixel shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex input layout description.
|
||||
@@ -195,8 +194,8 @@ bool light_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
vertexShaderBuffer->GetBufferSize(), &layout_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating input layout");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
|
||||
@@ -218,8 +217,8 @@ bool light_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating constant buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create a texture sampler state description.
|
||||
@@ -241,19 +240,19 @@ bool light_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating sampler state");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Shader initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
void light_map_shader_class::shutdown_shader()
|
||||
{
|
||||
Logger::Get().Log("Shutting down light_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down light_map_shader_class");
|
||||
|
||||
// Release the sampler state.
|
||||
if (sample_state_)
|
||||
@@ -290,7 +289,7 @@ void light_map_shader_class::shutdown_shader()
|
||||
vertex_shader_ = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("light_map_shader_class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("light_map_shader_class shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -350,8 +349,8 @@ bool light_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCo
|
||||
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error mapping constant buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -375,7 +374,7 @@ bool light_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCo
|
||||
deviceContext->PSSetShaderResources(0, 1, &texture1);
|
||||
deviceContext->PSSetShaderResources(1, 1, &texture2);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ light_shader_class::~light_shader_class()
|
||||
|
||||
bool light_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
Logger::Get().Log("Initializing light_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing light_shader_class");
|
||||
|
||||
wchar_t vsFilename[128];
|
||||
wchar_t psFilename[128];
|
||||
@@ -41,28 +41,28 @@ bool light_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/light.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to copy string");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/light.ps");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to copy string");
|
||||
R_FALSE
|
||||
}
|
||||
// initialize the vertex and pixel shaders.
|
||||
result = initialize_shader(device, hwnd, vsFilename, psFilename);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to initialize shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to initialize shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("light_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("light_shader_class initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -84,20 +84,20 @@ bool light_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCou
|
||||
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, lightPosition, ambientClor);
|
||||
if(!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to set shader parameters");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now render the prepared buffers with the shader.
|
||||
render_shader(deviceContext, indexCount);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
|
||||
{
|
||||
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing shader");
|
||||
|
||||
HRESULT result;
|
||||
ID3D10Blob* errorMessage;
|
||||
@@ -129,10 +129,10 @@ bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
// 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);
|
||||
LOG_ERROR("Failed to compile shader");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Compile the pixel shader code.
|
||||
@@ -147,26 +147,26 @@ bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
// 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);
|
||||
LOG_ERROR("Failed to compile shader");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex shader from the buffer.
|
||||
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create vertex shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the pixel shader from the buffer.
|
||||
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create pixel shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex input layout description.
|
||||
@@ -203,8 +203,8 @@ bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
&layout_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create input layout");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
|
||||
@@ -233,8 +233,8 @@ bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create sampler state");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
|
||||
@@ -249,8 +249,8 @@ bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create matrix buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
|
||||
@@ -267,8 +267,8 @@ bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
result = device->CreateBuffer(&cameraBufferDesc, NULL, &camera_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create camera buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create camera buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the dynamic constant buffer that is in the pixel shader.
|
||||
@@ -283,8 +283,8 @@ bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
result = device->CreateBuffer(&lightColorBufferDesc, NULL, &light_color_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create light color buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create light color buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the dynamic constant buffer that is in the vertex shader.
|
||||
@@ -299,19 +299,19 @@ bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
result = device->CreateBuffer(&lightPositionBufferDesc, NULL, &light_position_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create light position buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create light position buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Shader initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
void light_shader_class::shutdown_shader()
|
||||
{
|
||||
Logger::Get().Log("Shutting down light_shader_class", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down light_shader_class");
|
||||
|
||||
// Release the light constant buffers.
|
||||
if (light_color_buffer_)
|
||||
@@ -375,7 +375,7 @@ void light_shader_class::shutdown_shader()
|
||||
vertex_shader_ = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("light_shader_class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("light_shader_class shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -436,8 +436,8 @@ bool light_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
|
||||
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to map matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to map matrix buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -461,16 +461,16 @@ bool light_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
|
||||
result = deviceContext->Map(camera_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to map camera buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to map camera buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Lock the light position constant buffer so it can be written to.
|
||||
result = deviceContext->Map(light_position_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to map light position buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to map light position buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -498,8 +498,8 @@ bool light_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
|
||||
result = deviceContext->Map(light_color_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to map light color buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to map light color buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -521,7 +521,7 @@ bool light_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
|
||||
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &light_color_buffer_);
|
||||
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "master_shader.h"
|
||||
#include "Logger.h"
|
||||
|
||||
master_shader::master_shader()
|
||||
{
|
||||
@@ -16,9 +15,9 @@ master_shader::~master_shader()
|
||||
|
||||
bool master_shader::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
Logger::Get().Log("Initializing master_shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing master_shader");
|
||||
|
||||
bool success = false;
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
@@ -26,7 +26,7 @@ multi_texture_shader_class::~multi_texture_shader_class()
|
||||
|
||||
bool multi_texture_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
Logger::Get().Log("Initializing multi_texture_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing multi_texture_shader_class");
|
||||
|
||||
bool result;
|
||||
wchar_t vsFilename[128];
|
||||
@@ -37,29 +37,29 @@ bool multi_texture_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/multitexture.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to set the filename of the vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to set the filename of the vertex shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/multitexture.ps");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to set the filename of the pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to set the filename of the pixel shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// initialize the vertex and pixel shaders.
|
||||
result = initialize_shader(device, hwnd, vsFilename, psFilename);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to initialize the vertex and pixel shaders", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to initialize the vertex and pixel shaders");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("multi_texture_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("multi_texture_shader_class initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void multi_texture_shader_class::shutdown()
|
||||
@@ -80,19 +80,19 @@ bool multi_texture_shader_class::render(ID3D11DeviceContext* deviceContext, int
|
||||
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to set the shader parameters that it will use for rendering", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to set the shader parameters that it will use for rendering");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now render the prepared buffers with the shader.
|
||||
render_shader(deviceContext, indexCount);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool multi_texture_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
|
||||
{
|
||||
Logger::Get().Log("Initializing the shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing the shader");
|
||||
|
||||
HRESULT result;
|
||||
ID3D10Blob* errorMessage;
|
||||
@@ -122,10 +122,10 @@ bool multi_texture_shader_class::initialize_shader(ID3D11Device* device, HWND hw
|
||||
// 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 the vertex shader code", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to compile the vertex shader code");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Compile the pixel shader code.
|
||||
@@ -141,26 +141,26 @@ bool multi_texture_shader_class::initialize_shader(ID3D11Device* device, HWND hw
|
||||
// If there was nothing in the error message then it simply could not find the file itself.
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Failed to compile the pixel shader code", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to compile the pixel shader code");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex shader from the buffer.
|
||||
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create the vertex shader from the buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create the vertex shader from the buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the pixel shader from the buffer.
|
||||
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create the pixel shader from the buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create the pixel shader from the buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex input layout description.
|
||||
@@ -196,8 +196,8 @@ bool multi_texture_shader_class::initialize_shader(ID3D11Device* device, HWND hw
|
||||
vertexShaderBuffer->GetBufferSize(), &layout_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create the vertex input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create the vertex input layout");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
|
||||
@@ -219,8 +219,8 @@ bool multi_texture_shader_class::initialize_shader(ID3D11Device* device, HWND hw
|
||||
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create the constant buffer pointer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create the constant buffer pointer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create a texture sampler state description.
|
||||
@@ -242,18 +242,18 @@ bool multi_texture_shader_class::initialize_shader(ID3D11Device* device, HWND hw
|
||||
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create the texture sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create the texture sampler state");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Shader initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void multi_texture_shader_class::shutdown_shader()
|
||||
{
|
||||
Logger::Get().Log("Shutting down the shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down the shader");
|
||||
|
||||
// Release the sampler state.
|
||||
if (sample_state_)
|
||||
@@ -290,7 +290,7 @@ void multi_texture_shader_class::shutdown_shader()
|
||||
vertex_shader_ = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("Shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shader shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -348,8 +348,8 @@ bool multi_texture_shader_class::set_shader_parameters(ID3D11DeviceContext* devi
|
||||
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to lock the constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to lock the constant buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -373,7 +373,7 @@ bool multi_texture_shader_class::set_shader_parameters(ID3D11DeviceContext* devi
|
||||
deviceContext->PSSetShaderResources(0, 1, &texture1);
|
||||
deviceContext->PSSetShaderResources(1, 1, &texture2);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void multi_texture_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
|
||||
|
||||
@@ -24,7 +24,7 @@ normal_map_shader_class::~normal_map_shader_class()
|
||||
|
||||
bool normal_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
Logger::Get().Log("Initializing normal map shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing normal map shader");
|
||||
|
||||
bool result;
|
||||
wchar_t vsFilename[128];
|
||||
@@ -35,29 +35,29 @@ bool normal_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/normalmap.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to set the filename of the vertex shader", __FILE__, __LINE__);
|
||||
return false;
|
||||
LOG_ERROR("Failed to set the filename of the vertex shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/normalmap.ps");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to set the filename of the pixel shader", __FILE__, __LINE__);
|
||||
return false;
|
||||
LOG_ERROR("Failed to set the filename of the pixel shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// initialize the vertex and pixel shaders.
|
||||
result = initialize_shader(device, hwnd, vsFilename, psFilename);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to initialize the vertex and pixel shaders", __FILE__, __LINE__);
|
||||
return false;
|
||||
LOG_ERROR("Failed to initialize the vertex and pixel shaders");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Successfully initialized normal map shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Successfully initialized normal map shader");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -79,20 +79,20 @@ bool normal_map_shader_class::render(ID3D11DeviceContext* deviceContext, int ind
|
||||
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, lightDirection, diffuseColor);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to set the shader parameters that will be used for rendering", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to set the shader parameters that will be used for rendering");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now render the prepared buffers with the shader.
|
||||
render_shader(deviceContext, indexCount);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
bool normal_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
|
||||
{
|
||||
Logger::Get().Log("Initializing normal map shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing normal map shader");
|
||||
|
||||
HRESULT result;
|
||||
ID3D10Blob* errorMessage;
|
||||
@@ -123,10 +123,10 @@ bool normal_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
// 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 the vertex shader code", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to compile the vertex shader code");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Compile the pixel shader code.
|
||||
@@ -142,26 +142,26 @@ bool normal_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
// If there was nothing in the error message then it simply could not find the file itself.
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Failed to compile the pixel shader code", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to compile the pixel shader code");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex shader from the buffer.
|
||||
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create the vertex shader from the buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create the vertex shader from the buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the pixel shader from the buffer.
|
||||
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create the pixel shader from the buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create the pixel shader from the buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex input layout description.
|
||||
@@ -213,8 +213,8 @@ bool normal_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
vertexShaderBuffer->GetBufferSize(), &layout_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create the vertex input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create the vertex input layout");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
|
||||
@@ -236,8 +236,8 @@ bool normal_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create the constant buffer pointer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create the constant buffer pointer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create a texture sampler state description.
|
||||
@@ -259,8 +259,8 @@ bool normal_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create the texture sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create the texture sampler state");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the light dynamic constant buffer that is in the pixel shader.
|
||||
@@ -275,19 +275,19 @@ bool normal_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
result = device->CreateBuffer(&lightBufferDesc, NULL, &light_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create the light constant buffer pointer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create the light constant buffer pointer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Successfully initialized normal map shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Successfully initialized normal map shader");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
void normal_map_shader_class::shutdown_shader()
|
||||
{
|
||||
Logger::Get().Log("Shutting down normal map shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down normal map shader");
|
||||
|
||||
// Release the light constant buffer.
|
||||
if (light_buffer_)
|
||||
@@ -331,7 +331,7 @@ void normal_map_shader_class::shutdown_shader()
|
||||
vertex_shader_ = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("Successfully shut down normal map shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Successfully shut down normal map shader");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -392,8 +392,8 @@ bool normal_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceC
|
||||
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to lock the constant buffer so it can be written to", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to lock the constant buffer so it can be written to");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -421,8 +421,8 @@ bool normal_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceC
|
||||
result = deviceContext->Map(light_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to lock the light constant buffer so it can be written to", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to lock the light constant buffer so it can be written to");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -446,7 +446,7 @@ bool normal_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceC
|
||||
deviceContext->PSSetShaderResources(0, 1, &texture1);
|
||||
deviceContext->PSSetShaderResources(1, 1, &texture2);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ reflection_shader_class::~reflection_shader_class()
|
||||
|
||||
bool reflection_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
Logger::Get().Log("Initializing reflection shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing reflection shader");
|
||||
|
||||
bool result;
|
||||
wchar_t vsFilename[128];
|
||||
@@ -32,29 +32,29 @@ bool reflection_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/reflection.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Error copying string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error copying string");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/reflection.ps");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Error copying string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error copying string");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// initialize the vertex and pixel shaders.
|
||||
result = initialize_shader(device, hwnd, vsFilename, psFilename);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error initializing shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Reflection shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Reflection shader initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void reflection_shader_class::shutdown()
|
||||
@@ -70,24 +70,23 @@ bool reflection_shader_class::render(ID3D11DeviceContext* deviceContext, int ind
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
// Set the shader parameters that it will use for rendering.
|
||||
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, reflectionTexture, reflectionMatrix);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error setting shader parameters");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now render the prepared buffers with the shader.
|
||||
render_shader(deviceContext, indexCount);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool reflection_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
|
||||
{
|
||||
Logger::Get().Log("Initializing reflection shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing reflection shader");
|
||||
|
||||
HRESULT result;
|
||||
ID3D10Blob* errorMessage;
|
||||
@@ -118,10 +117,10 @@ bool reflection_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
// If there was nothing in the error message then it simply could not find the shader file itself.
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Error compiling shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Error compiling shader");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
// Compile the pixel shader code.
|
||||
result = D3DCompileFromFile(psFilename, NULL, NULL, "ReflectionPixelShader", "ps_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0,
|
||||
@@ -136,26 +135,26 @@ bool reflection_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
// If there was nothing in the error message then it simply could not find the file itself.
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Error compiling shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Error compiling shader");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex shader from the buffer.
|
||||
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating vertex shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the pixel shader from the buffer.
|
||||
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating pixel shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex input layout description.
|
||||
@@ -183,8 +182,8 @@ bool reflection_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
vertexShaderBuffer->GetBufferSize(), &layout_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating input layout");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
|
||||
@@ -206,8 +205,8 @@ bool reflection_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating constant buffer");
|
||||
R_FALSE
|
||||
}
|
||||
// Create a texture sampler state description.
|
||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
@@ -228,8 +227,8 @@ bool reflection_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating sampler state");
|
||||
R_FALSE
|
||||
}
|
||||
// Setup the description of the reflection dynamic constant buffer that is in the vertex shader.
|
||||
reflectionBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
@@ -243,18 +242,18 @@ bool reflection_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
result = device->CreateBuffer(&reflectionBufferDesc, NULL, &reflection_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error creating constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error creating constant buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Reflection shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Reflection shader initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void reflection_shader_class::shutdown_shader()
|
||||
{
|
||||
Logger::Get().Log("Shutting down reflection shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down reflection shader");
|
||||
|
||||
// Release the reflection constant buffer.
|
||||
if (reflection_buffer_)
|
||||
@@ -298,7 +297,7 @@ void reflection_shader_class::shutdown_shader()
|
||||
vertex_shader_ = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("Reflection shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Reflection shader shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -361,8 +360,8 @@ bool reflection_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceC
|
||||
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error mapping constant buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -386,8 +385,8 @@ bool reflection_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceC
|
||||
result = deviceContext->Map(reflection_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Error mapping constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error mapping constant buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the matrix constant buffer.
|
||||
@@ -411,7 +410,7 @@ bool reflection_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceC
|
||||
// Set the reflection texture resource in the pixel shader.
|
||||
deviceContext->PSSetShaderResources(1, 1, &reflectionTexture);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ refraction_shader_class::~refraction_shader_class()
|
||||
|
||||
bool refraction_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
LOG_INIT("Initializing refraction shader");
|
||||
|
||||
bool result;
|
||||
wchar_t vsFilename[128];
|
||||
wchar_t psFilename[128];
|
||||
@@ -34,24 +36,29 @@ bool refraction_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/refraction.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error copying vertex shader filename");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/refraction.ps");
|
||||
if (error != 0)
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error copying pixel shader filename");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// initialize the vertex and pixel shaders.
|
||||
result = initialize_shader(device, hwnd, vsFilename, psFilename);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error initializing shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
LOG_INIT("Refraction shader initialized");
|
||||
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -68,23 +75,25 @@ bool refraction_shader_class::render(ID3D11DeviceContext* deviceContext, int ind
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
// Set the shader parameters that it will use for rendering.
|
||||
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, lightDirection, ambientColor, diffuseColor, lightPosition, clipPlane);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error setting shader parameters");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now render the prepared buffers with the shader.
|
||||
render_shader(deviceContext, indexCount);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
bool refraction_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
|
||||
{
|
||||
LOG_INIT("Initializing refraction shader");
|
||||
|
||||
HRESULT result;
|
||||
ID3D10Blob* errorMessage;
|
||||
ID3D10Blob* vertexShaderBuffer;
|
||||
@@ -118,7 +127,7 @@ bool refraction_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
MessageBox(hwnd, vsFilename, L"Missing Shader File", MB_OK);
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Compile the pixel shader code.
|
||||
@@ -134,24 +143,27 @@ bool refraction_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
// If there was nothing in the error message then it simply could not find the file itself.
|
||||
else
|
||||
{
|
||||
LOG_ERROR("Missing pixel shader file");
|
||||
MessageBox(hwnd, psFilename, L"Missing Shader File", MB_OK);
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex shader from the buffer.
|
||||
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error creating vertex shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the pixel shader from the buffer.
|
||||
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error creating pixel shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex input layout description.
|
||||
@@ -187,7 +199,8 @@ bool refraction_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
vertexShaderBuffer->GetBufferSize(), &layout_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error creating input layout");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
|
||||
@@ -209,7 +222,8 @@ bool refraction_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error creating matrix buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create a texture sampler state description.
|
||||
@@ -231,7 +245,8 @@ bool refraction_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error creating sampler state");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the light dynamic constant buffer that is in the pixel shader.
|
||||
@@ -247,7 +262,8 @@ bool refraction_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
result = device->CreateBuffer(&lightBufferDesc, NULL, &light_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error creating light buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the clip plane dynamic constant buffer that is in the vertex shader.
|
||||
@@ -262,15 +278,20 @@ bool refraction_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
|
||||
result = device->CreateBuffer(&clipPlaneBufferDesc, NULL, &clip_plane_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error creating clip plane buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
LOG_INIT("Refraction shader initialized");
|
||||
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
void refraction_shader_class::shutdown_shader()
|
||||
{
|
||||
LOG_SHUTDOWN("Shutting down refraction shader");
|
||||
|
||||
// Release the clip plane constant buffer.
|
||||
if (clip_plane_buffer_)
|
||||
{
|
||||
@@ -320,6 +341,8 @@ void refraction_shader_class::shutdown_shader()
|
||||
vertex_shader_ = 0;
|
||||
}
|
||||
|
||||
LOG_SHUTDOWN("Refraction shader shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -380,7 +403,8 @@ bool refraction_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceC
|
||||
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error mapping matrix buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -404,7 +428,8 @@ bool refraction_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceC
|
||||
result = deviceContext->Map(clip_plane_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if(FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error mapping clip plane buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the clip plane constant buffer.
|
||||
@@ -429,7 +454,8 @@ bool refraction_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceC
|
||||
result = deviceContext->Map(light_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if(FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error mapping light buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -450,7 +476,7 @@ bool refraction_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceC
|
||||
// Finally set the light constant buffer in the pixel shader with the updated values.
|
||||
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &light_buffer_);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ shader_manager_class::~shader_manager_class()
|
||||
|
||||
bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
Logger::Get().Log("Initializing shader_manager_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing shader_manager_class");
|
||||
|
||||
bool result;
|
||||
|
||||
@@ -39,8 +39,8 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
result = texture_shader_->initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error initializing texture_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error initializing texture_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create and initialize the normal map shader object.
|
||||
@@ -48,8 +48,8 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
result = normal_map_shader_->initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error initializing normal_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error initializing normal_map_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create and initialize the multitexture shader object.
|
||||
@@ -57,8 +57,8 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
result = multitexture_shader_->initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error initializing multi_texture_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error initializing multi_texture_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create and initialize the translate shader object.
|
||||
@@ -66,8 +66,8 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
result = translate_shader_->initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error initializing translate_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error initializing translate_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create and initialize the alpha map shader object.
|
||||
@@ -75,8 +75,8 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
result = alpha_map_shader_->initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error initializing alpha_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error initializing alpha_map_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create and initialize the specular map shader object.
|
||||
@@ -84,8 +84,8 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
result = spec_map_shader_->initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error initializing spec_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error initializing spec_map_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create and initialize the transparent shader object.
|
||||
@@ -93,8 +93,8 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
result = transparent_shader_->initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error initializing transparent_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error initializing transparent_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create and initialize the light shader object.
|
||||
@@ -102,8 +102,8 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
result = light_shader_->initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error initializing light_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error initializing light_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create and initialize the light map shader object.
|
||||
@@ -111,8 +111,8 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
result = light_map_shader_->initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error initializing light_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error initializing light_map_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create and initialize the refraction shader object.
|
||||
@@ -120,7 +120,7 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
result = refraction_shader_->initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create and initialize the water shader object.
|
||||
@@ -128,47 +128,47 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
result = water_shader_->initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
cel_shading_shader_ = new celshade_class;
|
||||
result = cel_shading_shader_->initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
sunlight_shader_ = new sunlight_shader_class;
|
||||
result = sunlight_shader_->initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
skybox_shader_ = new skybox_shader_class;
|
||||
result = skybox_shader_->Initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error initializing skybox_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error initializing skybox_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
depth_shader_ = new depth_shader_class;
|
||||
result = depth_shader_->initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error initializing depth_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error initializing depth_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("shader_manager_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("shader_manager_class initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void shader_manager_class::shutdown()
|
||||
{
|
||||
Logger::Get().Log("Shutting down shader_manager_class", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down shader_manager_class");
|
||||
|
||||
// Release the normal map shader object.
|
||||
if (normal_map_shader_)
|
||||
@@ -287,7 +287,9 @@ void shader_manager_class::shutdown()
|
||||
depth_shader_ = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("shader_manager_class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("shader_manager_class shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool shader_manager_class::render_texture_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
@@ -298,11 +300,11 @@ bool shader_manager_class::render_texture_shader(ID3D11DeviceContext* deviceCont
|
||||
result = texture_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error rendering texture_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error rendering texture_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool shader_manager_class::render_normal_map_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
@@ -313,11 +315,11 @@ bool shader_manager_class::render_normal_map_shader(ID3D11DeviceContext* deviceC
|
||||
result = normal_map_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, colorTexture, normalTexture, lightDirection, diffuseColor);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error rendering normal_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error rendering normal_map_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool shader_manager_class::render_multitexture_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
@@ -328,11 +330,11 @@ bool shader_manager_class::render_multitexture_shader(ID3D11DeviceContext* devic
|
||||
result = multitexture_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error rendering multi_texture_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error rendering multi_texture_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool shader_manager_class::render_translate_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
@@ -343,11 +345,11 @@ bool shader_manager_class::render_translate_shader(ID3D11DeviceContext* deviceCo
|
||||
result = translate_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, valeur);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error rendering translate_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error rendering translate_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool shader_manager_class::render_alpha_map_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
@@ -358,11 +360,11 @@ bool shader_manager_class::render_alpha_map_shader(ID3D11DeviceContext* deviceCo
|
||||
result = alpha_map_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error rendering alpha_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error rendering alpha_map_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool shader_manager_class::render_spec_map_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
@@ -375,11 +377,11 @@ bool shader_manager_class::render_spec_map_shader(ID3D11DeviceContext* deviceCon
|
||||
diffuseColor, cameraPosition, specularColor, specularPower);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error rendering spec_map_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error rendering spec_map_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool shader_manager_class::render_transparent_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
@@ -390,11 +392,11 @@ bool shader_manager_class::render_transparent_shader(ID3D11DeviceContext* device
|
||||
result = transparent_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, blendAmount);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error rendering transparent_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Error rendering transparent_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool shader_manager_class::renderlight_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
@@ -405,10 +407,11 @@ bool shader_manager_class::renderlight_shader(ID3D11DeviceContext* deviceContext
|
||||
result = light_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, lightPosition, ambientColor);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error rendering light_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool shader_manager_class::renderlight_map_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
|
||||
@@ -419,10 +422,11 @@ bool shader_manager_class::renderlight_map_shader(ID3D11DeviceContext* deviceCon
|
||||
result = light_map_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error rendering light_map_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool shader_manager_class::render_refraction_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
@@ -433,10 +437,11 @@ bool shader_manager_class::render_refraction_shader(ID3D11DeviceContext* deviceC
|
||||
result = refraction_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, lightDirection, ambientColor, diffuseColor, lightPosition, clipPlane);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error rendering refraction_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool shader_manager_class::render_water_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
@@ -449,10 +454,11 @@ bool shader_manager_class::render_water_shader(ID3D11DeviceContext* deviceContex
|
||||
refractionTexture, normalTexture, waterTranslation, reflectRefractScale);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error rendering water_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool shader_manager_class::render_cel_shading_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
@@ -463,10 +469,11 @@ bool shader_manager_class::render_cel_shading_shader(ID3D11DeviceContext* device
|
||||
result = cel_shading_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error rendering celshade_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool shader_manager_class::render_sunlight_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
@@ -477,10 +484,11 @@ bool shader_manager_class::render_sunlight_shader(ID3D11DeviceContext* deviceCon
|
||||
result = sunlight_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error rendering sunlight_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool shader_manager_class::render_skybox_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
@@ -491,10 +499,11 @@ bool shader_manager_class::render_skybox_shader(ID3D11DeviceContext* deviceConte
|
||||
result = skybox_shader_->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error rendering skybox_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool shader_manager_class::render_depth_shader(
|
||||
@@ -502,17 +511,17 @@ bool shader_manager_class::render_depth_shader(
|
||||
int indexCount,
|
||||
XMMATRIX worldMatrix,
|
||||
XMMATRIX viewMatrix,
|
||||
XMMATRIX projectionMatrix,
|
||||
ID3D11ShaderResourceView* texture
|
||||
XMMATRIX projectionMatrix
|
||||
)
|
||||
{
|
||||
bool result;
|
||||
|
||||
result = depth_shader_->render(context, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture);
|
||||
result = depth_shader_->render(context, indexCount, worldMatrix, viewMatrix, projectionMatrix);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error rendering depth_shader_class");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
@@ -30,7 +30,7 @@ skybox_shader_class::~skybox_shader_class()
|
||||
|
||||
bool skybox_shader_class::Initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
Logger::Get().Log("Initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing LightShaderClass");
|
||||
|
||||
wchar_t vsFilename[128];
|
||||
wchar_t psFilename[128];
|
||||
@@ -41,28 +41,28 @@ bool skybox_shader_class::Initialize(ID3D11Device* device, HWND hwnd)
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/skybox.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to copy string");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/skybox.ps");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to copy string");
|
||||
R_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);
|
||||
return false;
|
||||
LOG_ERROR("Failed to initialize shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("skybox_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("skybox_shader_class initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -84,20 +84,20 @@ bool skybox_shader_class::Render(ID3D11DeviceContext* deviceContext, int indexCo
|
||||
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to set shader parameters");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now render the prepared buffers with the shader.
|
||||
RenderShader(deviceContext, indexCount);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
bool skybox_shader_class::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
|
||||
{
|
||||
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing shader");
|
||||
|
||||
HRESULT result;
|
||||
ID3D10Blob* errorMessage;
|
||||
@@ -124,9 +124,9 @@ bool skybox_shader_class::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Failed to compile shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to compile shader");
|
||||
}
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Compile the pixel shader code.
|
||||
@@ -139,25 +139,25 @@ bool skybox_shader_class::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Failed to compile shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to compile shader");
|
||||
}
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex shader from the buffer.
|
||||
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create vertex shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the pixel shader from the buffer.
|
||||
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create pixel shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex input layout description.
|
||||
@@ -192,8 +192,8 @@ bool skybox_shader_class::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;
|
||||
LOG_ERROR("Failed to create input layout");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
|
||||
@@ -222,8 +222,8 @@ bool skybox_shader_class::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;
|
||||
LOG_ERROR("Failed to create sampler state");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
|
||||
@@ -238,8 +238,8 @@ bool skybox_shader_class::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
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;
|
||||
LOG_ERROR("Failed to create matrix buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the dynamic sunlight constant buffer that is in the pixel shader.
|
||||
@@ -254,13 +254,13 @@ bool skybox_shader_class::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
result = device->CreateBuffer(&sunlightBufferDesc, NULL, &m_sunlightBuffer);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create sunlight buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create sunlight buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Shader initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -268,7 +268,7 @@ bool skybox_shader_class::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
|
||||
void skybox_shader_class::ShutdownShader()
|
||||
{
|
||||
Logger::Get().Log("Shutting down SunLightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down SunLightShaderClass");
|
||||
|
||||
// Release the light constant buffers.
|
||||
if (m_sunlightColorBuffer)
|
||||
@@ -332,7 +332,7 @@ void skybox_shader_class::ShutdownShader()
|
||||
m_vertexShader = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("SunLightShaderClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("SunLightShaderClass shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -379,7 +379,6 @@ bool skybox_shader_class::SetShaderParameters(ID3D11DeviceContext* deviceContext
|
||||
HRESULT result;
|
||||
D3D11_MAPPED_SUBRESOURCE mappedResource;
|
||||
MatrixBufferType* dataPtr;
|
||||
CameraBufferType* dataPtr2;
|
||||
SkyboxBufferType* dataPtr3;
|
||||
unsigned int bufferNumber;
|
||||
|
||||
@@ -392,7 +391,7 @@ bool skybox_shader_class::SetShaderParameters(ID3D11DeviceContext* deviceContext
|
||||
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -416,7 +415,7 @@ bool skybox_shader_class::SetShaderParameters(ID3D11DeviceContext* deviceContext
|
||||
result = deviceContext->Map(m_sunlightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -440,7 +439,7 @@ bool skybox_shader_class::SetShaderParameters(ID3D11DeviceContext* deviceContext
|
||||
// Set shader texture resource in the pixel shader.
|
||||
deviceContext->PSSetShaderResources(0, 1, &texture);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void skybox_shader_class::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
|
||||
|
||||
@@ -25,6 +25,9 @@ spec_map_shader_class::~spec_map_shader_class()
|
||||
|
||||
bool spec_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
|
||||
LOG_INIT("Initializing SpecMapShaderClass");
|
||||
|
||||
bool result;
|
||||
wchar_t vsFilename[128];
|
||||
wchar_t psFilename[128];
|
||||
@@ -34,24 +37,24 @@ bool spec_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/specmap.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/specmap.ps");
|
||||
if (error != 0)
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// initialize the vertex and pixel shaders.
|
||||
result = initialize_shader(device, hwnd, vsFilename, psFilename);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -75,13 +78,14 @@ bool spec_map_shader_class::render(ID3D11DeviceContext* deviceContext, int index
|
||||
cameraPosition, specularColor, specularPower);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Failed to set shader parameters in SpecMapShaderClass");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now render the prepared buffers with the shader.
|
||||
render_shader(deviceContext, indexCount);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +124,7 @@ bool spec_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
|
||||
MessageBox(hwnd, vsFilename, L"Missing Shader File", MB_OK);
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Compile the pixel shader code.
|
||||
@@ -139,21 +143,23 @@ bool spec_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
|
||||
MessageBox(hwnd, psFilename, L"Missing Shader File", MB_OK);
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex shader from the buffer.
|
||||
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Failed to create vertex shader in SpecMapShaderClass");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the pixel shader from the buffer.
|
||||
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Failed to create pixel shader in SpecMapShaderClass");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex input layout description.
|
||||
@@ -205,7 +211,8 @@ bool spec_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
|
||||
vertexShaderBuffer->GetBufferSize(), &layout_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Failed to create input layout in SpecMapShaderClass");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
|
||||
@@ -227,7 +234,8 @@ bool spec_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
|
||||
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Failed to create uniform buffer in SpecMapShaderClass");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create a texture sampler state description.
|
||||
@@ -249,7 +257,8 @@ bool spec_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
|
||||
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Failed to create sample state in SpecMapShaderClass");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the light dynamic constant buffer that is in the pixel shader.
|
||||
@@ -264,7 +273,8 @@ bool spec_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
|
||||
result = device->CreateBuffer(&lightBufferDesc, NULL, &light_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Failed to create light buffer in SpecMapShaderClass");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the camera dynamic constant buffer that is in the vertex shader.
|
||||
@@ -279,15 +289,18 @@ bool spec_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
|
||||
result = device->CreateBuffer(&cameraBufferDesc, NULL, &camera_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Failed to create camera buffer in SpecMapShaderClass");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
void spec_map_shader_class::shutdown_shader()
|
||||
{
|
||||
LOG_SHUTDOWN("Shutting down SpecMapShaderClass");
|
||||
|
||||
// Release the camera constant buffer.
|
||||
if (camera_buffer_)
|
||||
{
|
||||
@@ -397,7 +410,8 @@ bool spec_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCon
|
||||
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Failed to map mapped buffer in SpecMapShaderClass");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -426,7 +440,8 @@ bool spec_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCon
|
||||
result = deviceContext->Map(light_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Failed to map lighting buffer in SpecMapShaderClass");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -451,7 +466,8 @@ bool spec_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCon
|
||||
result = deviceContext->Map(camera_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Failed to map camera buffer in SpecMapShaderClass");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -469,7 +485,7 @@ bool spec_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCon
|
||||
// Now set the camera constant buffer in the vertex shader with the updated values.
|
||||
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &camera_buffer_);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ sunlight_shader_class::~sunlight_shader_class()
|
||||
|
||||
bool sunlight_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
Logger::Get().Log("Initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing LightShaderClass");
|
||||
|
||||
wchar_t vsFilename[128];
|
||||
wchar_t psFilename[128];
|
||||
@@ -41,28 +41,28 @@ bool sunlight_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/sunlight.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to copy string");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/sunlight.ps");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to copy string");
|
||||
R_FALSE
|
||||
}
|
||||
// initialize the vertex and pixel shaders.
|
||||
result = initialize_shader(device, hwnd, vsFilename, psFilename);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to initialize shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to initialize shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("SunLightShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("SunLightShaderClass initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -84,20 +84,20 @@ bool sunlight_shader_class::render(ID3D11DeviceContext* deviceContext, int index
|
||||
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to set shader parameters");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now render the prepared buffers with the shader.
|
||||
render_shader(deviceContext, indexCount);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
|
||||
{
|
||||
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing shader");
|
||||
|
||||
HRESULT result;
|
||||
ID3D10Blob* errorMessage;
|
||||
@@ -124,9 +124,9 @@ bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Failed to compile shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to compile shader");
|
||||
}
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Compile the pixel shader code.
|
||||
@@ -139,25 +139,25 @@ bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Failed to compile shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to compile shader");
|
||||
}
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex shader from the buffer.
|
||||
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create vertex shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the pixel shader from the buffer.
|
||||
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create pixel shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex input layout description.
|
||||
@@ -192,8 +192,8 @@ bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
|
||||
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &layout_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create input layout");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
|
||||
@@ -222,8 +222,8 @@ bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
|
||||
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create sampler state");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
|
||||
@@ -238,8 +238,8 @@ bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
|
||||
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create matrix buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the dynamic sunlight constant buffer that is in the pixel shader.
|
||||
@@ -254,13 +254,13 @@ bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
|
||||
result = device->CreateBuffer(&sunlightBufferDesc, NULL, &sunlight_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create sunlight buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create sunlight buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Shader initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -268,7 +268,7 @@ bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
|
||||
|
||||
void sunlight_shader_class::shutdown_shader()
|
||||
{
|
||||
Logger::Get().Log("Shutting down SunLightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down SunLightShaderClass");
|
||||
|
||||
// Release the light constant buffers.
|
||||
if (sunlight_color_buffer_)
|
||||
@@ -332,7 +332,7 @@ void sunlight_shader_class::shutdown_shader()
|
||||
vertex_shader_ = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("SunLightShaderClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("SunLightShaderClass shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -379,7 +379,6 @@ bool sunlight_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCon
|
||||
HRESULT result;
|
||||
D3D11_MAPPED_SUBRESOURCE mappedResource;
|
||||
matrix_buffer_type* dataPtr;
|
||||
camera_buffer_type* dataPtr2;
|
||||
sun_light_buffer_type* dataPtr3;
|
||||
unsigned int bufferNumber;
|
||||
|
||||
@@ -392,7 +391,7 @@ bool sunlight_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCon
|
||||
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -416,7 +415,7 @@ bool sunlight_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCon
|
||||
result = deviceContext->Map(sunlight_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -440,7 +439,7 @@ bool sunlight_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCon
|
||||
// Set shader texture resource in the pixel shader.
|
||||
deviceContext->PSSetShaderResources(0, 1, &texture);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void sunlight_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user