Compare commits
48 Commits
V14.1.1
...
ImGui-Perf
| 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 |
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}
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
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
@@ -141,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" />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[Window][DockSpace]
|
||||
Pos=0,0
|
||||
Size=1584,861
|
||||
Size=1536,793
|
||||
Collapsed=0
|
||||
|
||||
[Window][Debug##Default]
|
||||
@@ -15,22 +15,22 @@ Collapsed=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
|
||||
|
||||
[Window][Inspector]
|
||||
Pos=1352,19
|
||||
Size=232,842
|
||||
Collapsed=0
|
||||
DockId=0x00000002,0
|
||||
|
||||
[Docking][Data]
|
||||
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1584,842 Split=X
|
||||
DockNode ID=0x00000005 Parent=0xCCBD8CF7 SizeRef=1265,842 Split=Y
|
||||
DockNode ID=0x00000003 Parent=0x00000005 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 Selected=0x9F035453
|
||||
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=0xCCBD8CF7 SizeRef=317,842 Selected=0x9F035453
|
||||
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
|
||||
|
||||
|
||||
@@ -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,7 @@ private :
|
||||
|
||||
input inputs_;
|
||||
bool tab_was_pressed_;
|
||||
std::shared_ptr<CameraInput> camera_input_;
|
||||
|
||||
// ------------------------------------------------- //
|
||||
// ------------------- SOUND ----------------------- //
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
@@ -120,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_;
|
||||
@@ -128,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
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <imgui.h>
|
||||
#include "entity.h"
|
||||
|
||||
#include "Logger.h"
|
||||
#include "macro.h"
|
||||
|
||||
/**
|
||||
* namespace for the Entity-Component-System (ECS)
|
||||
@@ -55,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.
|
||||
|
||||
@@ -77,17 +77,17 @@ public:
|
||||
bool Load(const std::string& path) {
|
||||
if (!m_system) {
|
||||
Initialize();
|
||||
if (!m_system) return false;
|
||||
if (!m_system) R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Loading audio file: " + path, __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
LOG_INFO("Loading audio file: " + path);
|
||||
|
||||
m_soundPath = path;
|
||||
|
||||
if (!std::filesystem::exists(path)) {
|
||||
m_lastError = "Fichier non trouv<75>: " + path;
|
||||
Logger::Get().Log(m_lastError, __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR(m_lastError);
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
if (m_sound) {
|
||||
@@ -109,10 +109,11 @@ 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
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,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());
|
||||
@@ -493,7 +495,7 @@ public:
|
||||
std::stringstream ss(data);
|
||||
std::string type;
|
||||
std::getline(ss, type, ':');
|
||||
if (type != "AudioComponent") return false;
|
||||
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;
|
||||
|
||||
@@ -507,8 +509,6 @@ public:
|
||||
std::getline(ss, s_priority, ':');
|
||||
std::getline(ss, s_spatialized, ':');
|
||||
std::getline(ss, s_use_velocity, ':');
|
||||
|
||||
Logger::Get().Log("Deserializing AudioComponent: path=" + m_soundPath, __FILE__, __LINE__, Logger::LogLevel::Warning);
|
||||
|
||||
m_volume = std::stof(s_volume);
|
||||
m_pan = std::stof(s_pan);
|
||||
@@ -525,7 +525,7 @@ public:
|
||||
Load(m_soundPath);
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -65,7 +65,7 @@ private:
|
||||
|
||||
bool CreateScriptFile() {
|
||||
if (strlen(scriptNameBuffer) == 0)
|
||||
return false;
|
||||
R_FALSE
|
||||
|
||||
scriptName = scriptNameBuffer;
|
||||
if (scriptName.length() < 4 || scriptName.substr(scriptName.length() - 4) != ".lua") {
|
||||
@@ -81,19 +81,19 @@ private:
|
||||
std::filesystem::create_directories(scriptFolder, ec);
|
||||
if (ec) {
|
||||
// Log erreur
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
std::string fullPath = scriptFolder + scriptName;
|
||||
|
||||
// Cr<43>er un fichier script vide ou template simple
|
||||
std::ofstream ofs(fullPath);
|
||||
if (!ofs) return false;
|
||||
if (!ofs) R_FALSE
|
||||
|
||||
ofs << "-- Script Lua vide pour ECS\n\nfunction on_update(dt)\n -- Code ici\nend\n";
|
||||
ofs.close();
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -48,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
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,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
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,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
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,6 +190,15 @@ 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.
|
||||
@@ -224,6 +233,7 @@ public:
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "RenderComponent:HasModel:"
|
||||
<< is_shadow_caster_ << ":"
|
||||
<< diffuse_count << ":" << diffuse_paths_ << ":"
|
||||
<< normal_count << ":" << normal_paths_ << ":"
|
||||
<< specular_count << ":" << specular_paths_ << ":"
|
||||
@@ -245,12 +255,15 @@ public:
|
||||
std::string type;
|
||||
|
||||
if (!std::getline(ss, type, ':') || type != "RenderComponent")
|
||||
return false;
|
||||
R_FALSE
|
||||
|
||||
std::string token;
|
||||
|
||||
if (!std::getline(ss, token, ':') || token != "HasModel")
|
||||
return false;
|
||||
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;
|
||||
|
||||
@@ -258,14 +271,14 @@ public:
|
||||
|
||||
auto read_count = [&](int& count) -> bool {
|
||||
if (!std::getline(ss, token, ':'))
|
||||
return false;
|
||||
R_FALSE
|
||||
try {
|
||||
count = std::stoi(token);
|
||||
}
|
||||
catch (...) {
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
return true;
|
||||
R_TRUE
|
||||
};
|
||||
|
||||
auto clean_token = [](std::string& str) {
|
||||
@@ -278,29 +291,29 @@ public:
|
||||
auto read_paths = [&](int count, std::vector<std::wstring>& paths) -> bool {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (!std::getline(ss, token, ':'))
|
||||
return false;
|
||||
R_FALSE
|
||||
|
||||
clean_token(token);
|
||||
|
||||
if (!token.empty()) {
|
||||
paths.emplace_back(token.begin(), token.end());
|
||||
Logger::Get().Log("Loaded path: " + std::string(token.begin(), token.end()), __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
LOG_INFO("Loaded path: " + std::string(token.begin(), token.end()));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
R_TRUE
|
||||
};
|
||||
|
||||
if (!read_count(diffuse_count)) return false;
|
||||
if (!read_paths(diffuse_count, paths_diffuse)) return false;
|
||||
if (!read_count(diffuse_count)) R_FALSE
|
||||
if (!read_paths(diffuse_count, paths_diffuse)) R_FALSE
|
||||
|
||||
if (!read_count(normal_count)) return false;
|
||||
if (!read_paths(normal_count, paths_normal)) return false;
|
||||
if (!read_count(normal_count)) R_FALSE
|
||||
if (!read_paths(normal_count, paths_normal)) R_FALSE
|
||||
|
||||
if (!read_count(specular_count)) return false;
|
||||
if (!read_paths(specular_count, paths_specular)) return false;
|
||||
if (!read_count(specular_count)) R_FALSE
|
||||
if (!read_paths(specular_count, paths_specular)) R_FALSE
|
||||
|
||||
if (!read_count(alpha_count)) return false;
|
||||
if (!read_paths(alpha_count, paths_alpha)) return 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; }
|
||||
@@ -318,7 +331,7 @@ public:
|
||||
texture_container_buffer.specularPaths = std::move(paths_specular);
|
||||
texture_container_buffer.alphaPaths = std::move(paths_alpha);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -328,6 +341,7 @@ public:
|
||||
*/
|
||||
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());
|
||||
@@ -453,6 +467,17 @@ public:
|
||||
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;
|
||||
@@ -460,6 +485,8 @@ private:
|
||||
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 {
|
||||
|
||||
@@ -186,7 +186,7 @@ public:
|
||||
std::string type;
|
||||
std::getline(ss, type, ':');
|
||||
|
||||
if (type != "TransformComponent") return false;
|
||||
if (type != "TransformComponent") R_FALSE
|
||||
|
||||
std::string token;
|
||||
XMFLOAT3 position, rotation, scale;
|
||||
@@ -206,7 +206,7 @@ public:
|
||||
SetPosition(XMLoadFloat3(&position));
|
||||
SetRotation(XMLoadFloat3(&rotation));
|
||||
SetScale(XMLoadFloat3(&scale));
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -178,6 +178,9 @@ public:
|
||||
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;
|
||||
@@ -186,6 +189,7 @@ private:
|
||||
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>
|
||||
@@ -38,6 +39,12 @@ struct ComponentEntry {
|
||||
std::function<void()> addFunc;
|
||||
};
|
||||
|
||||
struct CachedEntity
|
||||
{
|
||||
std::string name;
|
||||
int id;
|
||||
};
|
||||
|
||||
class imguiManager
|
||||
{
|
||||
public:
|
||||
@@ -174,6 +181,10 @@ private:
|
||||
// --------------------------------------------- //
|
||||
// ----------------- Functions ----------------- //
|
||||
// --------------------------------------------- //
|
||||
/**
|
||||
* Update the cached entity list if there is a new, delete or rename entity
|
||||
*/
|
||||
void UpdateCachedEntitiesIfNeeded();
|
||||
|
||||
// --------------------------------------------- //
|
||||
// ----------------- Variables ----------------- //
|
||||
@@ -185,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;
|
||||
@@ -229,6 +242,8 @@ 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;
|
||||
};
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
#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 1
|
||||
#define BUILD_VERSION_PATCH 1
|
||||
#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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -23,7 +23,7 @@ texture_shader_class::~texture_shader_class()
|
||||
|
||||
bool texture_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 +33,29 @@ bool texture_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/texture.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/texture.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 texture_shader_class::shutdown()
|
||||
@@ -76,19 +76,19 @@ bool texture_shader_class::render(ID3D11DeviceContext* deviceContext, int indexC
|
||||
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
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 texture_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;
|
||||
@@ -117,10 +117,10 @@ bool texture_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WC
|
||||
// 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 +136,26 @@ bool texture_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WC
|
||||
// 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 +183,8 @@ bool texture_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WC
|
||||
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 +206,8 @@ bool texture_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WC
|
||||
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,18 +228,18 @@ bool texture_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WC
|
||||
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 texture_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_)
|
||||
@@ -276,7 +276,7 @@ void 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;
|
||||
}
|
||||
@@ -334,8 +334,8 @@ bool texture_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCont
|
||||
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.
|
||||
@@ -357,7 +357,7 @@ bool texture_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCont
|
||||
// Set shader texture resource in the pixel shader.
|
||||
deviceContext->PSSetShaderResources(0, 1, &texture);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void texture_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
|
||||
|
||||
@@ -24,7 +24,7 @@ translate_shader_class::~translate_shader_class()
|
||||
|
||||
bool translate_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
Logger::Get().Log("Initilaizing translate_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initilaizing translate_shader_class");
|
||||
|
||||
bool result;
|
||||
wchar_t vsFilename[128];
|
||||
@@ -35,29 +35,29 @@ bool translate_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/translate.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to copy vsFilename", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to copy vsFilename");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/translate.ps");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to copy psFilename", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to copy psFilename");
|
||||
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("translate_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("translate_shader_class initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -79,20 +79,20 @@ bool translate_shader_class::render(ID3D11DeviceContext * deviceContext, int ind
|
||||
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, translation);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
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 translate_shader_class::initialize_shader(ID3D11Device * device, HWND hwnd, WCHAR * vsFilename, WCHAR * psFilename)
|
||||
{
|
||||
Logger::Get().Log("Initializing translate shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing translate shader");
|
||||
|
||||
HRESULT result;
|
||||
ID3D10Blob* errorMessage;
|
||||
@@ -123,10 +123,10 @@ bool translate_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 shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to compile shader");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Compile the pixel shader code.
|
||||
@@ -142,26 +142,26 @@ bool translate_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 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.
|
||||
@@ -189,8 +189,8 @@ bool translate_shader_class::initialize_shader(ID3D11Device * device, HWND hwnd,
|
||||
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.
|
||||
@@ -212,8 +212,8 @@ bool translate_shader_class::initialize_shader(ID3D11Device * device, HWND hwnd,
|
||||
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
|
||||
}
|
||||
|
||||
// Create a texture sampler state description.
|
||||
@@ -235,8 +235,8 @@ bool translate_shader_class::initialize_shader(ID3D11Device * device, HWND hwnd,
|
||||
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 texture translation dynamic constant buffer that is in the pixel shader.
|
||||
@@ -251,19 +251,19 @@ bool translate_shader_class::initialize_shader(ID3D11Device * device, HWND hwnd,
|
||||
result = device->CreateBuffer(&translateBufferDesc, NULL, &translate_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create translate buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create translate buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Translate shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Translate shader initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
void translate_shader_class::shutdown_shader()
|
||||
{
|
||||
Logger::Get().Log("Shutting down translate shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down translate shader");
|
||||
|
||||
// Release the texture translation constant buffer.
|
||||
if (translate_buffer_)
|
||||
@@ -307,7 +307,7 @@ void translate_shader_class::shutdown_shader()
|
||||
vertex_shader_ = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("Translate shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Translate shader shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -368,8 +368,8 @@ bool translate_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 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.
|
||||
@@ -396,8 +396,8 @@ bool translate_shader_class::set_shader_parameters(ID3D11DeviceContext * deviceC
|
||||
result = deviceContext->Map(translate_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to map translate buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to map translate buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the texture translation constant buffer.
|
||||
@@ -415,7 +415,7 @@ bool translate_shader_class::set_shader_parameters(ID3D11DeviceContext * deviceC
|
||||
// Now set the texture translation constant buffer in the pixel shader with the updated values.
|
||||
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &translate_buffer_);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ transparent_shader_class::~transparent_shader_class()
|
||||
|
||||
bool transparent_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
Logger::Get().Log("Initializing transparent_shader_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing transparent_shader_class");
|
||||
|
||||
bool result;
|
||||
wchar_t vsFilename[128];
|
||||
@@ -35,29 +35,29 @@ bool transparent_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/transparent.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to copy vertex shader filename", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to copy vertex shader filename");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/transparent.ps");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to copy pixel shader filename", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to copy pixel shader filename");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// initialize the vertex and pixel shaders.
|
||||
// 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("transparent_shader_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("transparent_shader_class initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -79,20 +79,20 @@ bool transparent_shader_class::render(ID3D11DeviceContext* deviceContext, int in
|
||||
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, blend);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
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 transparent_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
|
||||
{
|
||||
Logger::Get().Log("Initializing transparent shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing transparent shader");
|
||||
|
||||
HRESULT result;
|
||||
ID3D10Blob* errorMessage;
|
||||
@@ -123,10 +123,10 @@ bool transparent_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 vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to compile vertex shader");
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Compile the pixel shader code.
|
||||
@@ -142,26 +142,26 @@ bool transparent_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 pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to compile pixel 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.
|
||||
@@ -189,8 +189,8 @@ bool transparent_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd
|
||||
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.
|
||||
@@ -212,8 +212,8 @@ bool transparent_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd
|
||||
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
|
||||
}
|
||||
|
||||
// Create a texture sampler state description.
|
||||
@@ -235,8 +235,8 @@ bool transparent_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd
|
||||
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 transparent dynamic constant buffer that is in the pixel shader.
|
||||
@@ -251,19 +251,19 @@ bool transparent_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd
|
||||
result = device->CreateBuffer(&transparentBufferDesc, NULL, &transparent_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create transparent buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create transparent buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Transparent shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Transparent shader initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
void transparent_shader_class::shutdown_shader()
|
||||
{
|
||||
Logger::Get().Log("Shutting down transparent shader", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down transparent shader");
|
||||
|
||||
// Release the transparent constant buffer.
|
||||
if (transparent_buffer_)
|
||||
@@ -307,7 +307,7 @@ void transparent_shader_class::shutdown_shader()
|
||||
vertex_shader_ = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("Transparent shader shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Transparent shader shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -367,8 +367,8 @@ bool transparent_shader_class::set_shader_parameters(ID3D11DeviceContext* device
|
||||
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.
|
||||
@@ -395,8 +395,8 @@ bool transparent_shader_class::set_shader_parameters(ID3D11DeviceContext* device
|
||||
result = deviceContext->Map(transparent_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to map transparent buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to map transparent buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the transparent constant buffer.
|
||||
@@ -414,7 +414,7 @@ bool transparent_shader_class::set_shader_parameters(ID3D11DeviceContext* device
|
||||
// Now set the transparent constant buffer in the pixel shader with the updated values.
|
||||
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &transparent_buffer_);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@ water_shader_class::~water_shader_class()
|
||||
|
||||
bool water_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
|
||||
LOG_INIT("Initializing Water Shader");
|
||||
|
||||
bool result;
|
||||
wchar_t vsFilename[128];
|
||||
wchar_t psFilename[128];
|
||||
@@ -34,24 +37,24 @@ bool water_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/water.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/water.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 water_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCou
|
||||
refractionTexture, normalTexture, waterTranslation, reflectRefractScale);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Failed to set shader parameters in water shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now render the prepared buffers with the shader.
|
||||
render_shader(deviceContext, indexCount);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +124,7 @@ bool water_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
MessageBox(hwnd, vsFilename, L"Missing Shader File", MB_OK);
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Compile the pixel shader code.
|
||||
@@ -139,21 +143,23 @@ bool water_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
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 in water 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 in water shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the vertex input layout description.
|
||||
@@ -181,7 +187,8 @@ bool water_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
vertexShaderBuffer->GetBufferSize(), &layout_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error creating input layout in water shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
|
||||
@@ -203,7 +210,8 @@ bool water_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error creating matrix buffer in water shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create a texture sampler state description.
|
||||
@@ -225,7 +233,8 @@ bool water_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error creating sampler state in water shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the reflection dynamic constant buffer that is in the vertex shader.
|
||||
@@ -240,7 +249,8 @@ bool water_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
result = device->CreateBuffer(&reflectionBufferDesc, NULL, &reflection_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error creating reflection buffer in water shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the water dynamic constant buffer that is in the pixel shader.
|
||||
@@ -255,15 +265,19 @@ bool water_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
|
||||
result = device->CreateBuffer(&waterBufferDesc, NULL, &water_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error creating water buffer in water shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
void water_shader_class::shutdown_shader()
|
||||
{
|
||||
|
||||
LOG_SHUTDOWN("Shutting down Water Shader");
|
||||
|
||||
// Release the water constant buffer.
|
||||
if (water_buffer_)
|
||||
{
|
||||
@@ -373,7 +387,8 @@ bool water_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
|
||||
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error mapping matrix buffer in water shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -397,7 +412,8 @@ bool water_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
|
||||
result = deviceContext->Map(reflection_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error mapping reflection buffer in water shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -428,7 +444,8 @@ bool water_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
|
||||
result = deviceContext->Map(water_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
LOG_ERROR("Error mapping water buffer in water shader");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -448,7 +465,7 @@ bool water_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
|
||||
// Finally set the water constant buffer in the pixel shader with the updated values.
|
||||
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &water_buffer_);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void water_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "system_class.h"
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow)
|
||||
{
|
||||
@@ -23,7 +23,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline,
|
||||
result = System->initialize();
|
||||
if (result)
|
||||
{
|
||||
Logger::Get().Log("System initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("System initialized");
|
||||
System->send_path(path,WFolder);
|
||||
System->run();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ void Skybox::Initialize(d_3d_class* d3dClassRef)
|
||||
|
||||
object* Skybox::ConstructSkybox(application_class* app)
|
||||
{
|
||||
Logger::Get().Log("Construct skybox", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INFO("Construct skybox");
|
||||
|
||||
char modelFilename[128];
|
||||
strcpy_s(modelFilename, "assets/Model/OBJ/skysphere.obj");
|
||||
@@ -43,7 +43,7 @@ object* Skybox::ConstructSkybox(application_class* app)
|
||||
HRESULT result = DirectX::CreateWICTextureFromFile(m_d3dClassRef->get_device(), m_d3dClassRef->get_device_context(), textureFilename.c_str(), nullptr, &texture);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to load texture: " + std::string(textureFilename.begin(), textureFilename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to load texture: " + std::string(textureFilename.begin(), textureFilename.end()));
|
||||
return nullptr;
|
||||
}
|
||||
SkyboxTextures.diffuse.push_back(texture);
|
||||
@@ -55,7 +55,7 @@ object* Skybox::ConstructSkybox(application_class* app)
|
||||
HRESULT result = m_Skybox->Initialize(m_d3dClassRef->get_device(), m_d3dClassRef->get_device_context(), modelFilename, SkyboxTextures);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not initialize the skybox model object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Could not initialize the skybox model object");
|
||||
delete m_Skybox;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,7 @@ bitmap_class::~bitmap_class()
|
||||
|
||||
bool bitmap_class::initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, int screenWidth, int screenHeight, char* textureFilename, int renderX, int renderY)
|
||||
{
|
||||
Logger::Get().Log("Initializing bitmap class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing bitmap class");
|
||||
|
||||
bool result;
|
||||
|
||||
@@ -36,21 +36,21 @@ bool bitmap_class::initialize(ID3D11Device* device, ID3D11DeviceContext* deviceC
|
||||
result = initialize_buffers(device);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to initialize buffers", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to initialize buffers");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Load the texture for this bitmap.
|
||||
result = load_texture(device, deviceContext, textureFilename);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to load texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to load texture");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Bitmap class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Bitmap class initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void bitmap_class::shutdown()
|
||||
@@ -68,19 +68,18 @@ bool bitmap_class::render(ID3D11DeviceContext* deviceContext)
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
// Update the buffers if the position of the bitmap has changed from its original position.
|
||||
result = update_buffers(deviceContext);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to update buffers", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to update buffers");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Put the vertex and index buffers on the graphics pipeline to prepare them for drawing.
|
||||
render_buffers(deviceContext);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
int bitmap_class::get_index_count()
|
||||
@@ -95,7 +94,7 @@ ID3D11ShaderResourceView* bitmap_class::get_texture()
|
||||
|
||||
bool bitmap_class::initialize_buffers(ID3D11Device* device)
|
||||
{
|
||||
Logger::Get().Log("Initializing buffers", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing buffers");
|
||||
|
||||
vertex_type* vertices;
|
||||
unsigned long* indices;
|
||||
@@ -146,8 +145,8 @@ bool bitmap_class::initialize_buffers(ID3D11Device* device)
|
||||
result = device->CreateBuffer(&vertexBufferDesc, &vertexData, &vertex_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create vertex buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create vertex buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set up the description of the index buffer.
|
||||
@@ -167,8 +166,8 @@ bool bitmap_class::initialize_buffers(ID3D11Device* device)
|
||||
result = device->CreateBuffer(&indexBufferDesc, &indexData, &index_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create index buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create index buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the arrays now that the vertex and index buffers have been created and loaded.
|
||||
@@ -178,34 +177,34 @@ bool bitmap_class::initialize_buffers(ID3D11Device* device)
|
||||
delete[] indices;
|
||||
indices = 0;
|
||||
|
||||
Logger::Get().Log("Buffers initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Buffers initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void bitmap_class::shutdown_buffers()
|
||||
{
|
||||
Logger::Get().Log("Shutting down buffers", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down buffers");
|
||||
|
||||
// Release the index buffer.
|
||||
if (index_buffer_)
|
||||
{
|
||||
Logger::Get().Log("Releasing index buffer", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Releasing index buffer");
|
||||
index_buffer_->Release();
|
||||
index_buffer_ = 0;
|
||||
Logger::Get().Log("Index buffer released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Index buffer released");
|
||||
}
|
||||
|
||||
// Release the vertex buffer.
|
||||
if (vertex_buffer_)
|
||||
{
|
||||
Logger::Get().Log("Releasing vertex buffer", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Releasing vertex buffer");
|
||||
vertex_buffer_->Release();
|
||||
vertex_buffer_ = 0;
|
||||
Logger::Get().Log("Vertex buffer released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Vertex buffer released");
|
||||
}
|
||||
|
||||
Logger::Get().Log("Buffers shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Buffers shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -221,7 +220,7 @@ bool bitmap_class::update_buffers(ID3D11DeviceContext* deviceContent)
|
||||
// If the position we are rendering this bitmap to hasn't changed then don't update the vertex buffer.
|
||||
if ((prev_pos_x_ == render_x_) && (prev_pos_y_ == render_y_))
|
||||
{
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
// If the rendering location has changed then store the new position and update the vertex buffer.
|
||||
@@ -268,8 +267,8 @@ bool bitmap_class::update_buffers(ID3D11DeviceContext* deviceContent)
|
||||
result = deviceContent->Map(vertex_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to map vertex buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to map vertex buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -288,7 +287,7 @@ bool bitmap_class::update_buffers(ID3D11DeviceContext* deviceContent)
|
||||
delete[] vertices;
|
||||
vertices = 0;
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void bitmap_class::render_buffers(ID3D11DeviceContext* deviceContext)
|
||||
@@ -324,31 +323,31 @@ bool bitmap_class::load_texture(ID3D11Device* device, ID3D11DeviceContext* devic
|
||||
result = texture_->Initialize(device, deviceContext, filename);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to initialize texture object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to initialize texture object");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Store the size in pixels that this bitmap should be rendered at.
|
||||
bitmap_width_ = texture_->GetWidth();
|
||||
bitmap_height_ = texture_->GetHeight();
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void bitmap_class::release_texture()
|
||||
{
|
||||
Logger::Get().Log("Releasing texture", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Releasing texture");
|
||||
// Release the texture object.
|
||||
if (texture_)
|
||||
{
|
||||
Logger::Get().Log("Releasing texture object", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Releasing texture object");
|
||||
texture_->Shutdown();
|
||||
delete texture_;
|
||||
texture_ = 0;
|
||||
Logger::Get().Log("Texture object released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Texture object released");
|
||||
}
|
||||
|
||||
Logger::Get().Log("Texture released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Texture released");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
camera_class::camera_class()
|
||||
{
|
||||
LOG_INIT("Initializing camera class");
|
||||
position_x_ = 0.0f;
|
||||
position_y_ = 0.0f;
|
||||
position_z_ = 0.0f;
|
||||
@@ -12,6 +13,13 @@ camera_class::camera_class()
|
||||
rotation_x_ = 0.0f;
|
||||
rotation_y_ = 0.0f;
|
||||
rotation_z_ = 0.0f;
|
||||
|
||||
camera_speed_ = 4.0f;
|
||||
|
||||
view_matrix_ = XMMatrixIdentity();
|
||||
reflection_view_matrix_ = XMMatrixIdentity();
|
||||
|
||||
LOG_INIT("Camera class initialized");
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +30,7 @@ camera_class::camera_class(const camera_class& other)
|
||||
|
||||
camera_class::~camera_class()
|
||||
{
|
||||
LOG_SHUTDOWN("Camera class destructor called");
|
||||
}
|
||||
|
||||
void camera_class::set_position(float x, float y, float z)
|
||||
@@ -105,6 +114,8 @@ void camera_class::render()
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
XMMATRIX camera_class::get_view_matrix(XMMATRIX& view_matrix) const
|
||||
{
|
||||
view_matrix = view_matrix_;
|
||||
@@ -168,4 +179,130 @@ void camera_class::get_reflection_view_matrix(XMMATRIX& reflectionViewMatrix) co
|
||||
{
|
||||
reflectionViewMatrix = reflection_view_matrix_;
|
||||
return;
|
||||
}
|
||||
|
||||
void camera_class::move(float deltatime, float delta_x, float delta_y)
|
||||
{
|
||||
if (!inputs_) return;
|
||||
|
||||
float speed;
|
||||
float radiansY = rotation_y_ * TO_RAD;
|
||||
float radiansX = rotation_x_ * TO_RAD;
|
||||
|
||||
rotate(delta_x, delta_y);
|
||||
|
||||
if (inputs_->scroll_up && inputs_->right_click)
|
||||
{
|
||||
camera_speed_ *= 1.1f;
|
||||
}
|
||||
if (inputs_->scroll_down && inputs_->right_click)
|
||||
{
|
||||
camera_speed_ *= 0.9f;
|
||||
if (camera_speed_ < 0.25f) // Minimum speed.
|
||||
{
|
||||
camera_speed_ = 0.25f;
|
||||
}
|
||||
}
|
||||
|
||||
if (inputs_->scroll_up && !inputs_->right_click)
|
||||
{
|
||||
speed = camera_speed_ * 20 * deltatime;
|
||||
position_x_ += sinf(radiansY) * cosf(radiansX) * speed;
|
||||
position_z_ += cosf(radiansY) * cosf(radiansX) * speed;
|
||||
position_y_ -= sinf(radiansX) * speed;
|
||||
}
|
||||
|
||||
if (inputs_->scroll_up && !inputs_->right_click)
|
||||
{
|
||||
speed = camera_speed_ * 20 * deltatime;
|
||||
position_x_ -= sinf(radiansY) * cosf(radiansX) * speed;
|
||||
position_z_ -= cosf(radiansY) * cosf(radiansX) * speed;
|
||||
position_y_ += sinf(radiansX) * speed;
|
||||
}
|
||||
|
||||
speed = camera_speed_ * deltatime;
|
||||
|
||||
if (inputs_->move_forward)
|
||||
{
|
||||
position_x_ += sinf(radiansY) * cosf(radiansX) * speed;
|
||||
position_z_ += cosf(radiansY) * cosf(radiansX) * speed;
|
||||
position_y_ -= sinf(radiansX) * speed;
|
||||
}
|
||||
|
||||
if (inputs_->move_backward)
|
||||
{
|
||||
position_x_ -= sinf(radiansY) * cosf(radiansX) * speed;
|
||||
position_z_ -= cosf(radiansY) * cosf(radiansX) * speed;
|
||||
position_y_ += sinf(radiansX) * speed;
|
||||
}
|
||||
|
||||
if (inputs_->move_left)
|
||||
{
|
||||
position_x_ -= cosf(radiansY) * speed;
|
||||
position_z_ += sinf(radiansY) * speed;
|
||||
}
|
||||
|
||||
if (inputs_->move_right)
|
||||
{
|
||||
position_x_ += cosf(radiansY) * speed;
|
||||
position_z_ -= sinf(radiansY) * speed;
|
||||
}
|
||||
|
||||
if (inputs_->move_up)
|
||||
{
|
||||
position_y_ += speed;
|
||||
}
|
||||
|
||||
if (inputs_->move_down)
|
||||
{
|
||||
position_y_ -= speed;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void camera_class::rotate(float delta_x, float delta_y)
|
||||
{
|
||||
|
||||
if (inputs_ == nullptr) return;
|
||||
|
||||
float delta_yaw = delta_x * camera_sensitivity_;
|
||||
float delta_pitch = delta_y * camera_sensitivity_;
|
||||
if (inputs_->right_click)
|
||||
{
|
||||
rotation_y_ += delta_yaw;
|
||||
if (rotation_y_ < 0.0f)
|
||||
{
|
||||
rotation_y_ += 360.0f;
|
||||
}
|
||||
else if (rotation_y_ > 360.0f)
|
||||
{
|
||||
rotation_y_ -= 360.0f;
|
||||
}
|
||||
|
||||
rotation_x_ += delta_pitch;
|
||||
if (rotation_x_ < -90.0f)
|
||||
{
|
||||
rotation_x_ = -90.0f;
|
||||
}
|
||||
else if (rotation_x_ > 90.0f)
|
||||
{
|
||||
rotation_x_ = 90.0f;
|
||||
}
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void camera_class::update_camera_inputs_states(input_class* inputs)
|
||||
{
|
||||
inputs_->move_forward = inputs->is_key_pressed(DIK_W);
|
||||
inputs_->move_backward = inputs->is_key_pressed(DIK_S);
|
||||
inputs_->move_left = inputs->is_key_pressed(DIK_A);
|
||||
inputs_->move_right = inputs->is_key_pressed(DIK_D);
|
||||
inputs_->move_up = inputs->is_key_pressed(DIK_E);
|
||||
inputs_->move_down = inputs->is_key_pressed(DIK_Q);
|
||||
inputs_->scroll_up = inputs->IsScrollUp();
|
||||
inputs_->scroll_down = inputs->IsScrollDown();
|
||||
inputs_->right_click = inputs->IsRightMousePressed();
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
d_3d_class::d_3d_class()
|
||||
{
|
||||
LOG_INIT("Initializing D3D class constructor");
|
||||
swap_chain = 0;
|
||||
device_ = 0;
|
||||
device_context_ = 0;
|
||||
@@ -17,6 +18,7 @@ d_3d_class::d_3d_class()
|
||||
depth_disabled_stencil_state_ = 0;
|
||||
alpha_enable_blending_state_ = 0;
|
||||
alpha_disable_blending_state_ = 0;
|
||||
LOG_INIT("D3D class constructor initialized");
|
||||
}
|
||||
|
||||
|
||||
@@ -27,12 +29,13 @@ d_3d_class::d_3d_class(const d_3d_class& other)
|
||||
|
||||
d_3d_class::~d_3d_class()
|
||||
{
|
||||
LOG_SHUTDOWN("D3D class destructor called");
|
||||
}
|
||||
|
||||
|
||||
bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND hwnd, bool fullscreen, float screenDepth, float screenNear)
|
||||
{
|
||||
Logger::Get().Log("Initializing D3Dclass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing D3Dclass");
|
||||
|
||||
HRESULT result;
|
||||
IDXGIFactory* factory;
|
||||
@@ -61,48 +64,48 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
|
||||
result = CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&factory);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create DXGIFactory", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create DXGIFactory");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Use the factory to create an adapter for the primary graphics interface (video card).
|
||||
result = factory->EnumAdapters(0, &adapter);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create adapter", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create adapter");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Enumerate the primary adapter output (monitor).
|
||||
result = adapter->EnumOutputs(0, &adapterOutput);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create adapter output", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create adapter output");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get the number of modes that fit the DXGI_FORMAT_R8G8B8A8_UNORM display format for the adapter output (monitor).
|
||||
result = adapterOutput->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &numModes, NULL);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to get display mode list", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to get display mode list");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create a list to hold all the possible display modes for this monitor/video card combination.
|
||||
displayModeList = new DXGI_MODE_DESC[numModes];
|
||||
if (!displayModeList)
|
||||
{
|
||||
Logger::Get().Log("Failed to create display mode list", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create display mode list");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now fill the display mode list structures.
|
||||
result = adapterOutput->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &numModes, displayModeList);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to fill display mode list", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to fill display mode list");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now go through all the display modes and find the one that matches the screen width and height.
|
||||
@@ -123,8 +126,8 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
|
||||
result = adapter->GetDesc(&adapterDesc);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to get adapter description", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to get adapter description");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Store the dedicated video card memory in megabytes.
|
||||
@@ -134,8 +137,8 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
|
||||
error = wcstombs_s(&stringLength, video_card_description_, 128, adapterDesc.Description, 128);
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to convert video card name to character array", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to convert video card name to character array");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the display mode list.
|
||||
@@ -217,24 +220,24 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
|
||||
D3D11_SDK_VERSION, &swapChainDesc, &swap_chain, &device_, NULL, &device_context_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create swap chain, device and device context", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create swap chain, device and device context");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get the pointer to the back buffer.
|
||||
result = swap_chain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&backBufferPtr);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to get pointer to back buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to get pointer to back buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Create the render target view with the back buffer pointer.
|
||||
result = device_->CreateRenderTargetView(backBufferPtr, NULL, &render_target_view_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create render target view", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create render target view");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release pointer to the back buffer as we no longer need it.
|
||||
@@ -261,8 +264,8 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
|
||||
result = device_->CreateTexture2D(&depthBufferDesc, NULL, &depth_stencil_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create texture for depth buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create texture for depth buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// initialize the description of the stencil state.
|
||||
@@ -293,8 +296,8 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
|
||||
result = device_->CreateDepthStencilState(&depthStencilDesc, &depth_stencil_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create depth stencil state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create depth stencil state");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the depth stencil state.
|
||||
@@ -312,8 +315,8 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
|
||||
result = device_->CreateDepthStencilView(depth_stencil_buffer_, &depthStencilViewDesc, &depth_stencil_view_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create depth stencil view", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create depth stencil view");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Bind the render target view and depth stencil buffer to the output render pipeline.
|
||||
@@ -335,8 +338,8 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
|
||||
result = device_->CreateRasterizerState(&rasterDesc, &raster_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create rasterizer state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create rasterizer state");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now set the rasterizer state.
|
||||
@@ -390,8 +393,8 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
|
||||
result = device_->CreateDepthStencilState(&depthDisabledStencilDesc, &depth_disabled_stencil_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create depth disabled stencil state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create depth disabled stencil state");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Clear the blend state description.
|
||||
@@ -411,8 +414,8 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
|
||||
result = device_->CreateBlendState(&blendStateDescription, &alpha_enable_blending_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create alpha enabled blend state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create alpha enabled blend state");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Modify the description to create an alpha disabled blend state description.
|
||||
@@ -422,18 +425,17 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
|
||||
result = device_->CreateBlendState(&blendStateDescription, &alpha_disable_blending_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create alpha disabled blend state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create alpha disabled blend state");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
void d_3d_class::shutdown()
|
||||
{
|
||||
|
||||
Logger::Get().Log("Shutting down D3Dclass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down D3Dclass");
|
||||
|
||||
// Before shutting down set to windowed mode or when you release the swap chain it will throw an exception.
|
||||
if (swap_chain)
|
||||
@@ -507,7 +509,7 @@ void d_3d_class::shutdown()
|
||||
swap_chain = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("D3Dclass shutdown", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("D3Dclass shutdown");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -592,7 +594,7 @@ void d_3d_class::reset_viewport()
|
||||
|
||||
void d_3d_class::release_resources()
|
||||
{
|
||||
Logger::Get().Log("Releasing D3D resources", __FILE__, __LINE__);
|
||||
LOG_SHUTDOWN("Releasing D3D resources");
|
||||
|
||||
// libere la vue
|
||||
if (render_target_view_)
|
||||
@@ -615,13 +617,13 @@ void d_3d_class::release_resources()
|
||||
depth_stencil_view_ = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("D3D resources released", __FILE__, __LINE__);
|
||||
LOG_SHUTDOWN("D3D resources released");
|
||||
}
|
||||
|
||||
// Reset the resources for the swap chain
|
||||
void d_3d_class::reset_resources(int newWidth, int newHeight)
|
||||
{
|
||||
Logger::Get().Log("Resetting D3D resources", __FILE__, __LINE__);
|
||||
LOG_INIT("Resetting D3D resources");
|
||||
|
||||
HRESULT result;
|
||||
|
||||
@@ -629,21 +631,21 @@ void d_3d_class::reset_resources(int newWidth, int newHeight)
|
||||
result = swap_chain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&backBuffer);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to get back buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to get back buffer");
|
||||
return;
|
||||
}
|
||||
|
||||
result = device_->CreateRenderTargetView(backBuffer, NULL, &render_target_view_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create render target view", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to create render target view");
|
||||
return;
|
||||
}
|
||||
|
||||
result = backBuffer->Release();
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to release back buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to release back buffer");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -672,14 +674,14 @@ void d_3d_class::reset_resources(int newWidth, int newHeight)
|
||||
result = device_->CreateTexture2D(&depthBufferDesc, NULL, &depth_stencil_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create depth stencil buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to create depth stencil buffer");
|
||||
return;
|
||||
}
|
||||
|
||||
result = device_->CreateDepthStencilView(depth_stencil_buffer_, &depthStencilViewDesc, &depth_stencil_view_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create depth stencil view", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to create depth stencil view");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -694,9 +696,7 @@ IDXGISwapChain* d_3d_class::get_swap_chain()
|
||||
|
||||
void d_3d_class::resize_swap_chain(int newWidth, int newHeight)
|
||||
{
|
||||
|
||||
// log the new width and height
|
||||
Logger::Get().Log("Resizing swap chain to " + std::to_string(newWidth) + "x" + std::to_string(newHeight), __FILE__, __LINE__);
|
||||
LOG_INFO("Resizing swap chain to " + std::to_string(newWidth) + "x" + std::to_string(newHeight));
|
||||
|
||||
HRESULT result;
|
||||
|
||||
@@ -708,7 +708,7 @@ void d_3d_class::resize_swap_chain(int newWidth, int newHeight)
|
||||
result = swap_chain->ResizeBuffers(0, newWidth, newHeight, DXGI_FORMAT_UNKNOWN, 0);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to resize swap chain", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to resize swap chain");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -771,4 +771,21 @@ void d_3d_class::disable_alpha_blending()
|
||||
void d_3d_class::set_vsync(bool vsync)
|
||||
{
|
||||
vsync_enabled_ = vsync;
|
||||
}
|
||||
|
||||
bool d_3d_class::set_projection_params(int width, int height, float screenDepth, float screenNear)
|
||||
{
|
||||
float fieldOfView, screenAspect;
|
||||
|
||||
// Setup the projection matrix.
|
||||
fieldOfView = 3.141592654f / 4.0f;
|
||||
screenAspect = (float)width / (float)height;
|
||||
|
||||
// Create the projection matrix for 3D rendering.
|
||||
projection_matrix_ = XMMatrixPerspectiveFovLH(fieldOfView, screenAspect, screenNear, screenDepth);
|
||||
|
||||
// Create an orthographic projection matrix for 2D rendering.
|
||||
ortho_matrix_ = XMMatrixOrthographicLH((float)width, (float)height, screenNear, screenDepth);
|
||||
|
||||
R_TRUE
|
||||
}
|
||||
@@ -3,8 +3,10 @@
|
||||
|
||||
display_plane_class::display_plane_class()
|
||||
{
|
||||
LOG_INIT("Initializing display_plane_class constructor");
|
||||
m_vertexBuffer = 0;
|
||||
m_indexBuffer = 0;
|
||||
LOG_INIT("Display_plane_class constructor initialized");
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +17,12 @@ display_plane_class::display_plane_class(const display_plane_class& other)
|
||||
|
||||
display_plane_class::~display_plane_class()
|
||||
{
|
||||
LOG_SHUTDOWN("Display_plane_class destructor called");
|
||||
}
|
||||
|
||||
bool display_plane_class::Initialize(ID3D11Device* device, float width, float height)
|
||||
{
|
||||
Logger::Get().Log("Initializing display_plane_class, width: " + std::to_string(width) + ", height: " + std::to_string(height), __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing display_plane_class, width: " + std::to_string(width) + ", height: " + std::to_string(height));
|
||||
bool result;
|
||||
|
||||
|
||||
@@ -27,18 +30,21 @@ bool display_plane_class::Initialize(ID3D11Device* device, float width, float he
|
||||
result = InitializeBuffers(device, width, height);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not initialize buffers", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Could not initialize buffers");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
LOG_INIT("Display_plane_class initialized");
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
void display_plane_class::Shutdown()
|
||||
{
|
||||
LOG_SHUTDOWN("Shutting down display_plane_class");
|
||||
// Release the vertex and index buffers.
|
||||
ShutdownBuffers();
|
||||
LOG_SHUTDOWN("Display_plane_class shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -60,7 +66,7 @@ int display_plane_class::GetIndexCount()
|
||||
|
||||
bool display_plane_class::InitializeBuffers(ID3D11Device* device, float width, float height)
|
||||
{
|
||||
Logger::Get().Log("Initializing buffers", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing buffers");
|
||||
|
||||
VertexType* vertices;
|
||||
unsigned long* indices;
|
||||
@@ -126,8 +132,8 @@ bool display_plane_class::InitializeBuffers(ID3D11Device* device, float width, f
|
||||
result = device->CreateBuffer(&vertexBufferDesc, &vertexData, &m_vertexBuffer);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Could not create vertex buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Could not create vertex buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set up the description of the index buffer.
|
||||
@@ -147,8 +153,8 @@ bool display_plane_class::InitializeBuffers(ID3D11Device* device, float width, f
|
||||
result = device->CreateBuffer(&indexBufferDesc, &indexData, &m_indexBuffer);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Could not create index buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Could not create index buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the arrays now that the vertex and index buffers have been created and loaded.
|
||||
@@ -158,31 +164,35 @@ bool display_plane_class::InitializeBuffers(ID3D11Device* device, float width, f
|
||||
delete[] indices;
|
||||
indices = 0;
|
||||
|
||||
Logger::Get().Log("Buffers initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Buffers initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
void display_plane_class::ShutdownBuffers()
|
||||
{
|
||||
Logger::Get().Log("Shutting down Plane buffers", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down Plane buffers");
|
||||
|
||||
// Release the index buffer.
|
||||
if (m_indexBuffer)
|
||||
{
|
||||
LOG_SHUTDOWN("Releasing index buffer");
|
||||
m_indexBuffer->Release();
|
||||
m_indexBuffer = 0;
|
||||
LOG_SHUTDOWN("Index buffer released");
|
||||
}
|
||||
|
||||
// Release the vertex buffer.
|
||||
if (m_vertexBuffer)
|
||||
{
|
||||
LOG_SHUTDOWN("Releasing vertex buffer");
|
||||
m_vertexBuffer->Release();
|
||||
m_vertexBuffer = 0;
|
||||
LOG_SHUTDOWN("Vertex buffer released");
|
||||
}
|
||||
|
||||
Logger::Get().Log("Plane buffers shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Plane buffers shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
font_class::font_class()
|
||||
{
|
||||
LOG_INIT("Initializing font class constructor");
|
||||
m_Font = 0;
|
||||
m_Texture = 0;
|
||||
LOG_INIT("Font class constructor initialized");
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +16,12 @@ font_class::font_class(const font_class& other)
|
||||
|
||||
font_class::~font_class()
|
||||
{
|
||||
LOG_SHUTDOWN("Font class destructor called");
|
||||
}
|
||||
|
||||
bool font_class::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, int fontChoice)
|
||||
{
|
||||
Logger::Get().Log("Initializing font class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing font class");
|
||||
|
||||
char fontFilename[128];
|
||||
char fontTextureFilename[128];
|
||||
@@ -49,37 +52,39 @@ bool font_class::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCon
|
||||
result = LoadFontData(fontFilename);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to load font data", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to load font data");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Load the texture that has the font characters on it.
|
||||
result = LoadTexture(device, deviceContext, fontTextureFilename);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to load font texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to load font texture");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Font class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Font class initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void font_class::Shutdown()
|
||||
{
|
||||
LOG_SHUTDOWN("Shutting down font class");
|
||||
// Release the font texture.
|
||||
ReleaseTexture();
|
||||
|
||||
// Release the font data.
|
||||
ReleaseFontData();
|
||||
LOG_SHUTDOWN("Font class shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool font_class::LoadFontData(char* filename)
|
||||
{
|
||||
Logger::Get().Log(("Loading font data from %s", filename), __FILE__, __LINE__);
|
||||
LOG_INFO("Loading font data from " + std::string(filename));
|
||||
|
||||
std::ifstream fin;
|
||||
int i;
|
||||
@@ -92,8 +97,8 @@ bool font_class::LoadFontData(char* filename)
|
||||
fin.open(filename);
|
||||
if (fin.fail())
|
||||
{
|
||||
Logger::Get().Log("Failed to open font file", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to open font file");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Read in the 95 used ascii characters for text.
|
||||
@@ -118,26 +123,31 @@ bool font_class::LoadFontData(char* filename)
|
||||
// Close the file.
|
||||
fin.close();
|
||||
|
||||
Logger::Get().Log("Font data loaded", __FILE__, __LINE__);
|
||||
LOG_INFO("Font data loaded");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void font_class::ReleaseFontData()
|
||||
{
|
||||
LOG_SHUTDOWN("Releasing font data");
|
||||
// Release the font data array.
|
||||
if (m_Font)
|
||||
{
|
||||
LOG_SHUTDOWN("Releasing font array");
|
||||
delete[] m_Font;
|
||||
m_Font = 0;
|
||||
LOG_SHUTDOWN("Font array released");
|
||||
}
|
||||
|
||||
LOG_SHUTDOWN("Font data released");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool font_class::LoadTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* filename)
|
||||
{
|
||||
Logger::Get().Log(("Loading font texture from %s", filename), __FILE__, __LINE__);
|
||||
LOG_INFO("Loading font texture from " + std::string(filename));
|
||||
|
||||
bool result;
|
||||
|
||||
@@ -148,25 +158,30 @@ bool font_class::LoadTexture(ID3D11Device* device, ID3D11DeviceContext* deviceCo
|
||||
result = m_Texture->Initialize(device, deviceContext, filename);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to initialize font texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to initialize font texture");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Font texture loaded", __FILE__, __LINE__);
|
||||
LOG_INFO("Font texture loaded");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void font_class::ReleaseTexture()
|
||||
{
|
||||
LOG_SHUTDOWN("Releasing font texture");
|
||||
// Release the texture object.
|
||||
if (m_Texture)
|
||||
{
|
||||
LOG_SHUTDOWN("Releasing texture object");
|
||||
m_Texture->Shutdown();
|
||||
delete m_Texture;
|
||||
m_Texture = 0;
|
||||
LOG_SHUTDOWN("Texture object released");
|
||||
}
|
||||
|
||||
LOG_SHUTDOWN("Font texture released");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,33 +56,14 @@ void frustum::ConstructFrustum(float screenDepth, XMMATRIX projectionMatrix, XMM
|
||||
}
|
||||
}
|
||||
|
||||
bool frustum::CheckCube(float xCenter, float yCenter, float zCenter, float radius, float tolerance)
|
||||
bool frustum::CheckCube(const float x_center,const float y_center,const float z_center,const float radius,const float tolerance)
|
||||
{
|
||||
// V<>rifiez chaque plan du frustum pour voir si le cube est <20> l'int<6E>rieur
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
XMVECTOR plane = m_planes[i];
|
||||
if (XMVectorGetX(plane) * (xCenter - radius) + XMVectorGetY(plane) * (yCenter - radius) + XMVectorGetZ(plane) * (zCenter - radius) + XMVectorGetW(plane) > -tolerance)
|
||||
continue;
|
||||
if (XMVectorGetX(plane) * (xCenter + radius) + XMVectorGetY(plane) * (yCenter - radius) + XMVectorGetZ(plane) * (zCenter - radius) + XMVectorGetW(plane) > -tolerance)
|
||||
continue;
|
||||
if (XMVectorGetX(plane) * (xCenter - radius) + XMVectorGetY(plane) * (yCenter + radius) + XMVectorGetZ(plane) * (zCenter - radius) + XMVectorGetW(plane) > -tolerance)
|
||||
continue;
|
||||
if (XMVectorGetX(plane) * (xCenter + radius) + XMVectorGetY(plane) * (yCenter + radius) + XMVectorGetZ(plane) * (zCenter - radius) + XMVectorGetW(plane) > -tolerance)
|
||||
continue;
|
||||
if (XMVectorGetX(plane) * (xCenter - radius) + XMVectorGetY(plane) * (yCenter - radius) + XMVectorGetZ(plane) * (zCenter + radius) + XMVectorGetW(plane) > -tolerance)
|
||||
continue;
|
||||
if (XMVectorGetX(plane) * (xCenter + radius) + XMVectorGetY(plane) * (yCenter - radius) + XMVectorGetZ(plane) * (zCenter + radius) + XMVectorGetW(plane) > -tolerance)
|
||||
continue;
|
||||
if (XMVectorGetX(plane) * (xCenter - radius) + XMVectorGetY(plane) * (yCenter + radius) + XMVectorGetZ(plane) * (zCenter + radius) + XMVectorGetW(plane) > -tolerance)
|
||||
continue;
|
||||
if (XMVectorGetX(plane) * (xCenter + radius) + XMVectorGetY(plane) * (yCenter + radius) + XMVectorGetZ(plane) * (zCenter + radius) + XMVectorGetW(plane) > -tolerance)
|
||||
continue;
|
||||
|
||||
// Si le cube est en dehors de l'un des plans, il n'est pas dans le frustum
|
||||
return false;
|
||||
CHECK_FRUSTRUM_CUBE_CORNERS(plane, x_center, y_center, z_center, radius, tolerance)
|
||||
}
|
||||
|
||||
// Si le cube est <20> l'int<6E>rieur de tous les plans, il est dans le frustum
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
@@ -130,11 +130,11 @@ bool FrustumClass::CheckPoint(float x, float y, float z)
|
||||
{
|
||||
if (((m_planes[i].x * x) + (m_planes[i].y * y) + (m_planes[i].z * z) + m_planes[i].w) < 0.0f)
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool FrustumClass::CheckCube(float xCenter, float yCenter, float zCenter, float radius)
|
||||
@@ -201,10 +201,10 @@ bool FrustumClass::CheckCube(float xCenter, float yCenter, float zCenter, float
|
||||
continue;
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool FrustumClass::CheckSphere(float xCenter, float yCenter, float zCenter, float radius)
|
||||
@@ -217,11 +217,11 @@ bool FrustumClass::CheckSphere(float xCenter, float yCenter, float zCenter, floa
|
||||
{
|
||||
if (((m_planes[i].x * xCenter) + (m_planes[i].y * yCenter) + (m_planes[i].z * zCenter) + m_planes[i].w) < -radius)
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool FrustumClass::CheckRectangle(float xCenter, float yCenter, float zCenter, float xSize, float ySize, float zSize)
|
||||
@@ -288,9 +288,9 @@ bool FrustumClass::CheckRectangle(float xCenter, float yCenter, float zCenter, f
|
||||
continue;
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "application_class.h"
|
||||
#include "stats.h"
|
||||
|
||||
static fps_limiter fpsLimiter(60.0f);
|
||||
|
||||
imguiManager::imguiManager()
|
||||
{
|
||||
io = nullptr;
|
||||
@@ -51,7 +49,7 @@ imguiManager::~imguiManager()
|
||||
|
||||
bool imguiManager::IncrementBuildVersionInConfig(const std::string& filepath) {
|
||||
std::ifstream file_in(filepath);
|
||||
if (!file_in) return false; // fichier introuvable
|
||||
if (!file_in) R_FALSE // fichier introuvable
|
||||
|
||||
std::vector<std::string> lines;
|
||||
std::string line;
|
||||
@@ -69,7 +67,8 @@ bool imguiManager::IncrementBuildVersionInConfig(const std::string& filepath) {
|
||||
line = "VER=" + std::to_string(BUILD_VERSION_VER);
|
||||
}
|
||||
} catch (...) {
|
||||
return false; // erreur conversion
|
||||
LOG_ERROR("Error converting VER to integer");
|
||||
R_FALSE // erreur conversion
|
||||
}
|
||||
}
|
||||
lines.push_back(line);
|
||||
@@ -84,18 +83,22 @@ bool imguiManager::IncrementBuildVersionInConfig(const std::string& filepath) {
|
||||
|
||||
// Réécrire tout le fichier
|
||||
std::ofstream file_out(filepath, std::ios::trunc);
|
||||
if (!file_out) return false;
|
||||
if (!file_out)
|
||||
{
|
||||
LOG_ERROR("Error writing to file");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
for (const auto& l : lines) {
|
||||
file_out << l << "\n";
|
||||
}
|
||||
file_out.close();
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceContext* deviceContext)
|
||||
{
|
||||
Logger::Get().Log("Initializing imgui", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing imgui");
|
||||
|
||||
m_device = device;
|
||||
m_deviceContext = deviceContext;
|
||||
@@ -117,13 +120,13 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
|
||||
// Palette de couleurs sobres inspir<69>e des <20>diteurs modernes
|
||||
ImVec4 background_dark = ImVec4(0.10f, 0.10f, 0.10f, 1.00f); // Fond fonc<6E>
|
||||
ImVec4 background = ImVec4(0.15f, 0.15f, 0.15f, 1.00f); // Fond principal
|
||||
ImVec4 background_light = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); // Fond clair
|
||||
ImVec4 accent = ImVec4(0.14f, 0.44f, 0.80f, 0.50f); // Accent bleu
|
||||
ImVec4 accent_light = ImVec4(0.14f, 0.44f, 0.80f, 1.00f); // Accent bleu vif
|
||||
ImVec4 text = ImVec4(1.0f, 1.0f, 1.0f, 1.00f); // Texte plus blanc
|
||||
ImVec4 text_dim = ImVec4(0.70f, 0.70f, 0.70f, 1.00f);
|
||||
// ImVec4 background_dark = ImVec4(0.10f, 0.10f, 0.10f, 1.00f); // Fond fonc<6E>
|
||||
// ImVec4 background = ImVec4(0.15f, 0.15f, 0.15f, 1.00f); // Fond principal
|
||||
// ImVec4 background_light = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); // Fond clair
|
||||
// ImVec4 accent = ImVec4(0.14f, 0.44f, 0.80f, 0.50f); // Accent bleu
|
||||
// ImVec4 accent_light = ImVec4(0.14f, 0.44f, 0.80f, 1.00f); // Accent bleu vif
|
||||
// ImVec4 text = ImVec4(1.0f, 1.0f, 1.0f, 1.00f); // Texte plus blanc
|
||||
// ImVec4 text_dim = ImVec4(0.70f, 0.70f, 0.70f, 1.00f);
|
||||
|
||||
// Ajustements de style g<>n<EFBFBD>raux
|
||||
style.WindowPadding = ImVec2(4.0f, 4.0f); // Moins de padding dans les fen<65>tres
|
||||
@@ -147,57 +150,57 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
|
||||
style.TabRounding = 4.0f;
|
||||
|
||||
// Couleurs principales
|
||||
style.Colors[ImGuiCol_Text] = text;
|
||||
style.Colors[ImGuiCol_TextDisabled] = text_dim;
|
||||
style.Colors[ImGuiCol_WindowBg] = background;
|
||||
style.Colors[ImGuiCol_ChildBg] = background_dark;
|
||||
style.Colors[ImGuiCol_PopupBg] = background_dark;
|
||||
style.Colors[ImGuiCol_Border] = ImVec4(0.25f, 0.25f, 0.27f, 1.00f);
|
||||
style.Colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||
style.Colors[ImGuiCol_Text] = TEXT_COLOR;
|
||||
style.Colors[ImGuiCol_TextDisabled] = TEXT_DIM_COLOR;
|
||||
style.Colors[ImGuiCol_WindowBg] = BG_GRAY;
|
||||
style.Colors[ImGuiCol_ChildBg] = BG_DK_GRAY;
|
||||
style.Colors[ImGuiCol_PopupBg] = BG_DK_GRAY;
|
||||
style.Colors[ImGuiCol_Border] = BORDER_COLOR;
|
||||
style.Colors[ImGuiCol_BorderShadow] = BLK;
|
||||
|
||||
// Encadrements
|
||||
style.Colors[ImGuiCol_FrameBg] = background_light;
|
||||
style.Colors[ImGuiCol_FrameBg] = BG_LT_GRAY;
|
||||
style.Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f);
|
||||
style.Colors[ImGuiCol_FrameBgActive] = ImVec4(0.30f, 0.30f, 0.30f, 1.00f);
|
||||
|
||||
// Titres
|
||||
style.Colors[ImGuiCol_TitleBg] = background_dark;
|
||||
style.Colors[ImGuiCol_TitleBgActive] = accent;
|
||||
style.Colors[ImGuiCol_TitleBg] = BG_DK_GRAY;
|
||||
style.Colors[ImGuiCol_TitleBgActive] = ACCENT_COLOR;
|
||||
style.Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.12f, 0.12f, 0.12f, 0.90f);
|
||||
|
||||
// <20>l<EFBFBD>ments de menu
|
||||
style.Colors[ImGuiCol_MenuBarBg] = background_dark;
|
||||
style.Colors[ImGuiCol_ScrollbarBg] = background_dark;
|
||||
style.Colors[ImGuiCol_MenuBarBg] = BG_DK_GRAY;
|
||||
style.Colors[ImGuiCol_ScrollbarBg] = BG_DK_GRAY;
|
||||
style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.40f, 0.40f, 0.40f, 1.00f);
|
||||
style.Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
|
||||
style.Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
|
||||
|
||||
// Boutons et interactions
|
||||
style.Colors[ImGuiCol_CheckMark] = accent_light;
|
||||
style.Colors[ImGuiCol_SliderGrab] = accent;
|
||||
style.Colors[ImGuiCol_SliderGrabActive] = accent_light;
|
||||
style.Colors[ImGuiCol_Button] = background_light;
|
||||
style.Colors[ImGuiCol_CheckMark] = ACCENT_LT_COLOR;
|
||||
style.Colors[ImGuiCol_SliderGrab] = ACCENT_COLOR;
|
||||
style.Colors[ImGuiCol_SliderGrabActive] = ACCENT_LT_COLOR;
|
||||
style.Colors[ImGuiCol_Button] = BG_LT_GRAY;
|
||||
style.Colors[ImGuiCol_ButtonHovered] = ImVec4(0.30f, 0.30f, 0.30f, 1.00f);
|
||||
style.Colors[ImGuiCol_ButtonActive] = accent;
|
||||
style.Colors[ImGuiCol_ButtonActive] = ACCENT_COLOR;
|
||||
|
||||
// En-t<>tes et onglets
|
||||
style.Colors[ImGuiCol_Header] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
||||
style.Colors[ImGuiCol_HeaderHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f);
|
||||
style.Colors[ImGuiCol_HeaderActive] = accent;
|
||||
style.Colors[ImGuiCol_HeaderActive] = ACCENT_COLOR;
|
||||
|
||||
style.Colors[ImGuiCol_Separator] = ImVec4(0.28f, 0.28f, 0.28f, 1.00f);
|
||||
style.Colors[ImGuiCol_SeparatorHovered] = ImVec4(0.45f, 0.45f, 0.45f, 1.00f);
|
||||
style.Colors[ImGuiCol_SeparatorActive] = accent;
|
||||
style.Colors[ImGuiCol_SeparatorActive] = ACCENT_COLOR;
|
||||
|
||||
style.Colors[ImGuiCol_Tab] = background_dark;
|
||||
style.Colors[ImGuiCol_TabHovered] = accent;
|
||||
style.Colors[ImGuiCol_TabActive] = accent;
|
||||
style.Colors[ImGuiCol_TabUnfocused] = background_dark;
|
||||
style.Colors[ImGuiCol_TabUnfocusedActive] = background;
|
||||
style.Colors[ImGuiCol_Tab] = BG_DK_GRAY;
|
||||
style.Colors[ImGuiCol_TabHovered] = ACCENT_COLOR;
|
||||
style.Colors[ImGuiCol_TabActive] = ACCENT_COLOR;
|
||||
style.Colors[ImGuiCol_TabUnfocused] = BG_DK_GRAY;
|
||||
style.Colors[ImGuiCol_TabUnfocusedActive] = BG_GRAY;
|
||||
|
||||
// Autres <20>l<EFBFBD>ments
|
||||
style.Colors[ImGuiCol_DockingPreview] = accent;
|
||||
style.Colors[ImGuiCol_DockingEmptyBg] = background_light;
|
||||
style.Colors[ImGuiCol_DockingPreview] = ACCENT_COLOR;
|
||||
style.Colors[ImGuiCol_DockingEmptyBg] = BG_LT_GRAY;
|
||||
|
||||
// Charger une police avec une meilleure nettet<65>
|
||||
ImFontConfig fontConfig;
|
||||
@@ -220,8 +223,8 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
|
||||
// initialize the scene manager
|
||||
scene_manager_ = new scene_manager;
|
||||
if (!scene_manager_->initialize(app_.get())) {
|
||||
Logger::Get().Log("Failed to initialize scene manager", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to initialize scene manager");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
stats_ = app_->get_stats();
|
||||
@@ -254,29 +257,35 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
|
||||
std::string configPath = "config.txt"; // ou chemin complet
|
||||
configPath = exeDir + BUILD_VERSION_TYPE + "\\" + configPath;
|
||||
if (!IncrementBuildVersionInConfig(configPath)) {
|
||||
Logger::Get().Log("Failed to increment build version in config.txt", __FILE__, __LINE__, Logger::LogLevel::Warning);
|
||||
LOG_WARNING("Failed to increment build version in config.txt");
|
||||
}
|
||||
|
||||
// update the build version text in the inverse build type folder
|
||||
configPath = "config.txt";
|
||||
configPath = exeDir + BUILD_VERSION_INVERSE + "\\" + configPath;
|
||||
Logger::Get().Log("Inverse build type config path: " + configPath, __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
LOG_INFO("Inverse build type config path: " + configPath);
|
||||
if (!IncrementBuildVersionInConfig(configPath)) {
|
||||
Logger::Get().Log("Failed to increment build version in config.txt of inverse build type", __FILE__, __LINE__, Logger::LogLevel::Warning);
|
||||
LOG_WARNING("Failed to increment build version in config.txt of inverse build type");
|
||||
}
|
||||
|
||||
// get the sky entity shared ptr from the application
|
||||
sky_entity_shared_ptr_ = app_->get_sky_entity_shared_ptr();
|
||||
if (!sky_entity_shared_ptr_) {
|
||||
LOG_WARNING("Sky entity shared ptr is null");
|
||||
}
|
||||
|
||||
Logger::Get().Log("imgui initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("imgui initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void imguiManager::Shutdown()
|
||||
{
|
||||
Logger::Get().Log("Shutting down imgui", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down imgui");
|
||||
ImGui_ImplDX11_Shutdown();
|
||||
ImGui_ImplWin32_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
Logger::Get().Log("imgui shutdown", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("imgui shutdown");
|
||||
}
|
||||
|
||||
void imguiManager::Render()
|
||||
@@ -300,14 +309,7 @@ void imguiManager::NewFrame()
|
||||
}
|
||||
|
||||
void imguiManager::SetupDockspace() {
|
||||
// Configuration du style pour supprimer l'espace autour des fen<65>tres dock<63>es
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
|
||||
// Configuration du style pour les n<>uds de dock
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_DockingSeparatorSize, 1.0f); // R<>duit l'<27>paisseur des s<>parateurs
|
||||
|
||||
BASIC_DOCK_STYLE_1
|
||||
// Configuration de la fen<65>tre principale
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
|
||||
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||
@@ -331,27 +333,27 @@ void imguiManager::SetupDockspace() {
|
||||
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
|
||||
|
||||
if (ImGui::BeginMenuBar()) {
|
||||
if (ImGui::BeginMenu("Windows")) {
|
||||
ImGui::MenuItem("Object Window", NULL, &showObjectWindow);
|
||||
ImGui::MenuItem("Terrain Window", NULL, &showTerrainWindow);
|
||||
ImGui::MenuItem("Light Window", NULL, &showLightWindow);
|
||||
ImGui::MenuItem("Engine Settings Window", NULL, &showEngineSettingsWindow);
|
||||
ImGui::MenuItem("Log Window", NULL, &showLogWindow);
|
||||
ImGui::MenuItem("render Stats", NULL, &showStatsWindow);
|
||||
ImGui::EndMenu();
|
||||
if (B_MENU("Windows")) {
|
||||
M_ITEM_LP("Object Window", &showObjectWindow);
|
||||
M_ITEM_LP("Terrain Window", &showTerrainWindow);
|
||||
M_ITEM_LP("Light Window", &showLightWindow);
|
||||
M_ITEM_LP("Engine Settings Window", &showEngineSettingsWindow);
|
||||
M_ITEM_LP("Log Window", &showLogWindow);
|
||||
M_ITEM_LP("render Stats", &showStatsWindow);
|
||||
E_MENU
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("Scene")) {
|
||||
if (ImGui::MenuItem("Save Scene")) {
|
||||
if (B_MENU("Scene")) {
|
||||
if (M_ITEM_L("Save Scene")) {
|
||||
scene_manager_->save_scene();
|
||||
}
|
||||
if (ImGui::MenuItem("Save Scene As...")) {
|
||||
if (M_ITEM_L("Save Scene As...")) {
|
||||
scene_manager_->save_scene_as();
|
||||
}
|
||||
if (ImGui::MenuItem("Load Scene")) {
|
||||
if (M_ITEM_L("Load Scene")) {
|
||||
scene_manager_->load_scene();
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
E_MENU
|
||||
}
|
||||
|
||||
const float PAD_X = 14.0f;
|
||||
@@ -395,34 +397,34 @@ void imguiManager::SetupDockspace() {
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
END
|
||||
}
|
||||
|
||||
void imguiManager::WidgetSpeedSlider(float* speed)
|
||||
{
|
||||
ImGui::SliderFloat("Speed", speed, 0.0f, 100.0f);
|
||||
F_SLIDER("Speed", speed, 0.0f, 100.0f);
|
||||
}
|
||||
|
||||
void imguiManager::WidgetButton()
|
||||
{
|
||||
static int counter = 0;
|
||||
|
||||
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
||||
if (BUTTON("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
||||
counter++;
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("counter = %d", counter);
|
||||
S_LINE
|
||||
TEXT_V("counter = %d", counter)
|
||||
}
|
||||
|
||||
void imguiManager::WidgetAddObject()
|
||||
{
|
||||
if (ImGui::CollapsingHeader("Objects"))
|
||||
if (C_HEADER("Objects"))
|
||||
{
|
||||
if (ImGui::Button("Add Cube"))
|
||||
if (BUTTON("Add Cube"))
|
||||
{
|
||||
app_->add_cube();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Import Object"))
|
||||
S_LINE
|
||||
if (BUTTON("Import Object"))
|
||||
{
|
||||
// Open file dialog
|
||||
OPENFILENAME ofn;
|
||||
@@ -500,23 +502,25 @@ void imguiManager::WidgetAddObject()
|
||||
// Remplacer les antislashs par des slashs
|
||||
std::replace(relativePath.begin(), relativePath.end(), L'\\', L'/');
|
||||
app_->add_kobject(relativePath);
|
||||
// set entities list as dirty
|
||||
entityListDirty = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Number of cubes: %d", entity_manager_->GetEntityCount());
|
||||
S_LINE
|
||||
TEXT_V("Number of cubes: %d", entity_manager_->GetEntityCount());
|
||||
}
|
||||
}
|
||||
|
||||
void imguiManager::WidgetObjectWindow()
|
||||
{
|
||||
ImGui::Begin("Objects", &showObjectWindow);
|
||||
BEGIN("Objects", &showObjectWindow)
|
||||
|
||||
if (ImGui::Button("Add Cube")) { app_->add_cube(); }
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Import Object"))
|
||||
if (BUTTON("Add Cube")) { app_->add_cube(); }
|
||||
S_LINE
|
||||
if (BUTTON("Import Object"))
|
||||
{
|
||||
// Open file dialog
|
||||
OPENFILENAME ofn;
|
||||
@@ -594,44 +598,36 @@ void imguiManager::WidgetObjectWindow()
|
||||
// Remplacer les antislashs par des slashs
|
||||
std::replace(relativePath.begin(), relativePath.end(), L'\\', L'/');
|
||||
app_->add_kobject(relativePath);
|
||||
// set list as dirty since new entity has been added to the scene
|
||||
entityListDirty = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Number of objects: %d", entity_manager_->GetEntityCount());
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
auto entities = entity_manager_->GetAllEntities();
|
||||
S_LINE
|
||||
TEXT_V("Number of cubes: %d", entity_manager_->GetEntityCount())
|
||||
SEP
|
||||
|
||||
UpdateCachedEntitiesIfNeeded();
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,ImVec2(4,2));
|
||||
|
||||
for (auto& entity : entities)
|
||||
for (auto& cachedEntitie : cachedEntities_)
|
||||
{
|
||||
auto identity = entity->GetComponent<ecs::IdentityComponent>();
|
||||
if (identity)
|
||||
bool isSelected = (cachedEntitie.id == m_selected_entity_id);
|
||||
if (SEL(cachedEntitie.name.c_str(), isSelected))
|
||||
{
|
||||
std::string name = identity->GetName();
|
||||
if (name.empty()) name = "Entity #" + std::to_string(identity->GetId());
|
||||
|
||||
bool isSelected = (entity->GetID() == m_selected_entity_id);
|
||||
if (ImGui::Selectable(name.c_str(), isSelected))
|
||||
{
|
||||
m_selected_entity_id = entity->GetID();
|
||||
show_inspector_window_ = true;
|
||||
}
|
||||
m_selected_entity_id = cachedEntitie.id;
|
||||
show_inspector_window_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::End();
|
||||
PSV
|
||||
END
|
||||
}
|
||||
|
||||
void imguiManager::WidgetInspectorWindow()
|
||||
{
|
||||
ImGui::Begin("Inspector", &show_inspector_window_);
|
||||
BEGIN("Inspector", &show_inspector_window_)
|
||||
|
||||
auto entity = entity_manager_->GetEntityByID(m_selected_entity_id);
|
||||
if (entity)
|
||||
@@ -641,14 +637,14 @@ void imguiManager::WidgetInspectorWindow()
|
||||
{
|
||||
char name[256];
|
||||
strcpy_s(name, identity->GetName().c_str());
|
||||
if (ImGui::InputText("Name", name, sizeof(name)))
|
||||
if (I_TEX("Name",name,sizeof(name)))
|
||||
{
|
||||
identity->SetName(std::string(name));
|
||||
}
|
||||
ImGui::Text("ID: %d", identity->GetId());
|
||||
TEXT_V("ID: %d", identity->GetId())
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
SEP
|
||||
|
||||
// Lister et afficher les composants
|
||||
auto components = entity->GetAllComponents();
|
||||
@@ -657,27 +653,28 @@ void imguiManager::WidgetInspectorWindow()
|
||||
auto& comp = pair.second;
|
||||
// Utiliser le nom du type comme en-tete
|
||||
std::string compName = typeid(*comp).name();
|
||||
if (ImGui::CollapsingHeader(compName.c_str()))
|
||||
if (C_HEADER(compName.c_str()))
|
||||
{
|
||||
comp->OnImGuiRender();
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::Button("Delete Entity"))
|
||||
if (BUTTON("Delete Entity"))
|
||||
{
|
||||
entity_manager_->DestroyEntity(m_selected_entity_id);
|
||||
m_selected_entity_id = -1;
|
||||
show_inspector_window_ = false;
|
||||
entityListDirty = true;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
S_LINE
|
||||
|
||||
if (ImGui::Button("Add Component")) {
|
||||
ImGui::OpenPopup("AddComponentPopup");
|
||||
if (BUTTON("Add Component")) {
|
||||
O_POPUP("AddComponentPopup");
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopup("AddComponentPopup")) {
|
||||
ImGui::Text("Select Component to Add:");
|
||||
ImGui::Separator();
|
||||
if (B_POPUP("AddComponentPopup")) {
|
||||
TEX("Select Component to Add:")
|
||||
SEP;
|
||||
|
||||
ComponentEntry componentsEntry[] = {
|
||||
{"Transform Component", [&]() { if (!entity->HasComponent<ecs::TransformComponent>()) entity->AddComponent<ecs::TransformComponent>(); }},
|
||||
@@ -692,65 +689,63 @@ void imguiManager::WidgetInspectorWindow()
|
||||
};
|
||||
|
||||
for (auto& comp : componentsEntry) {
|
||||
if (ImGui::MenuItem(comp.name)) {
|
||||
if (M_ITEM_L(comp.name)) {
|
||||
comp.addFunc();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
E_POPUP
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::Text("No entity selected.");
|
||||
TEX("No entity selected.")
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
END
|
||||
}
|
||||
|
||||
void imguiManager::WidgetTerrainWindow()
|
||||
{
|
||||
ImGui::Begin("Terrain", &showTerrainWindow);
|
||||
BEGIN("Terrain", &showTerrainWindow)
|
||||
|
||||
ImGui::Text("Number of terrain cubes: %d", app_->get_terrain_entity_count());
|
||||
TEXT_V("Number of terrain cubes: %d", app_->get_terrain_entity_count())
|
||||
SEP
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Button("Generate Flat Terrain"))
|
||||
if (BUTTON("Generate Flat Terrain"))
|
||||
{
|
||||
app_->generate_terrain();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
SEP
|
||||
|
||||
// Input for the number of cubes on each side
|
||||
ImGui::Text("Number of cubes on each side: ");
|
||||
ImGui::SameLine();
|
||||
TEX("Number of cubes on each side: ")
|
||||
S_LINE
|
||||
ImGui::InputInt("##SideCount", &m_SideCount);
|
||||
if (m_SideCount < 1)
|
||||
{
|
||||
m_SideCount = 1;
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
SEP
|
||||
|
||||
if (ImGui::Button("Generate BigCube Terrain"))
|
||||
{
|
||||
app_->create_big_cube(m_SideCount);
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
|
||||
SEP
|
||||
|
||||
if (ImGui::Button("Delete All Terrain Cubes"))
|
||||
{
|
||||
app_->delete_terrain();
|
||||
}
|
||||
|
||||
|
||||
|
||||
ImGui::End();
|
||||
|
||||
END
|
||||
}
|
||||
|
||||
bool imguiManager::ImGuiWidgetRenderer()
|
||||
@@ -762,16 +757,6 @@ bool imguiManager::ImGuiWidgetRenderer()
|
||||
SetupDockspace();
|
||||
|
||||
//ImGui Widget
|
||||
ImGui::Begin("Khaotic Engine", NULL);
|
||||
|
||||
float speed = app_->get_speed();
|
||||
|
||||
WidgetSpeedSlider(&speed);
|
||||
app_->set_speed(speed);
|
||||
WidgetButton();
|
||||
WidgetAddObject();
|
||||
|
||||
ImGui::End();
|
||||
|
||||
// Read the widget list and call the function if the show variable is true
|
||||
for (const auto& entry : widgets_)
|
||||
@@ -782,12 +767,12 @@ bool imguiManager::ImGuiWidgetRenderer()
|
||||
//render imgui
|
||||
Render();
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void imguiManager::WidgetLightWindow()
|
||||
{
|
||||
ImGui::Begin("Light", &showLightWindow);
|
||||
BEGIN("Light", &showLightWindow)
|
||||
|
||||
|
||||
// Sun light settings
|
||||
@@ -814,7 +799,7 @@ void imguiManager::WidgetLightWindow()
|
||||
}
|
||||
|
||||
|
||||
ImGui::Separator();
|
||||
SEP
|
||||
|
||||
int index = 0;
|
||||
|
||||
@@ -823,7 +808,7 @@ void imguiManager::WidgetLightWindow()
|
||||
for(auto& light : app_->get_lights())
|
||||
{
|
||||
std::string headerName = "Light " + std::to_string(index);
|
||||
if (ImGui::CollapsingHeader(headerName.c_str()))
|
||||
if (C_HEADER(headerName.c_str()))
|
||||
{
|
||||
XMVECTOR position = app_->get_light_position(index);
|
||||
XMVECTOR color = app_->get_light_color(index);
|
||||
@@ -847,68 +832,160 @@ void imguiManager::WidgetLightWindow()
|
||||
index++;
|
||||
};
|
||||
|
||||
ImGui::End();
|
||||
END
|
||||
}
|
||||
|
||||
void imguiManager::WidgetEngineSettingsWindow()
|
||||
{
|
||||
ImGui::Begin("Engine Settings", &showEngineSettingsWindow);
|
||||
BEGIN("Engine Settings", &showEngineSettingsWindow)
|
||||
|
||||
// Begining Of General Setting
|
||||
ImGui::Text("General");
|
||||
// Variables temporaires pour les settings
|
||||
static bool temp_v_sync = app_->get_vsync();
|
||||
static int temp_target_fps = app_->get_target_fps();
|
||||
static float temp_screen_depth = app_->get_screen_depth();
|
||||
static float temp_screen_near = app_->get_screen_near();
|
||||
static float temp_frustum_tolerance = app_->get_frustum_tolerance();
|
||||
static int temp_physics_tick_rate = app_->get_physics_tick_rate();
|
||||
static float temp_gravity_values[3] = {
|
||||
XMVectorGetX(app_->get_physics()->GetGravity()),
|
||||
XMVectorGetY(app_->get_physics()->GetGravity()),
|
||||
XMVectorGetZ(app_->get_physics()->GetGravity())
|
||||
};
|
||||
|
||||
// Checkbox for toggling vsync globally in the application class by calling the set_vsync function in the application class when the checkbox state changes
|
||||
bool vsync = app_->get_vsync();
|
||||
if (ImGui::Checkbox("Vsync", &vsync))
|
||||
if (ImGui::BeginTabBar("Engine Settings"))
|
||||
{
|
||||
app_->set_vsync(vsync);
|
||||
if (ImGui::BeginTabItem("General"))
|
||||
{
|
||||
ImGui::Checkbox("Vsync", &temp_v_sync);
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Enable or disable Vsync");
|
||||
|
||||
ImGui::InputInt("Target FPS", &temp_target_fps);
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Set the target FPS for the engine");
|
||||
|
||||
// Drag float input for screen depth and near with min and max values and update the app values on change
|
||||
ImGui::DragFloat("Screen Depth", &temp_screen_depth, 1.f, 0.1f, 10000.0f);
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Set the screen depth");
|
||||
|
||||
ImGui::DragFloat("Screen Near", &temp_screen_near, 1.f, 0.1f, 10000.0f);
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Set the screen near");
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::BeginTabItem("Culling Settings"))
|
||||
{
|
||||
|
||||
ImGui::DragFloat("Frustum Tolerance", &temp_frustum_tolerance, 0.1f, 0.0f, 100.0f);
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Set the frustum tolerance for culling");
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::BeginTabItem("Physics Settings"))
|
||||
{
|
||||
|
||||
ImGui::InputInt("Physics Tick Rate", &temp_physics_tick_rate);
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Set the physics tick rate (Fixed Update Interval)");
|
||||
|
||||
ImGui::DragFloat3("Gravity", temp_gravity_values);
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Set the gravity vector for the physics engine");
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::BeginTabItem("Skysphere Settings"))
|
||||
{
|
||||
|
||||
if (sky_entity_shared_ptr_)
|
||||
{
|
||||
|
||||
// get the transform component
|
||||
auto transform = sky_entity_shared_ptr_->GetComponent<ecs::TransformComponent>();
|
||||
auto render = sky_entity_shared_ptr_->GetComponent<ecs::RenderComponent>();
|
||||
auto shader = sky_entity_shared_ptr_->GetComponent<ecs::ShaderComponent>();
|
||||
if (transform)
|
||||
{
|
||||
// get the scale and display it as a drag float3 input (need to convert from XMVECTOR to float[3])
|
||||
XMVECTOR scale = transform->GetScale();
|
||||
float scale_values[3] = { XMVectorGetX(scale), XMVectorGetY(scale), XMVectorGetZ(scale) };
|
||||
if (ImGui::DragFloat3("Skysphere Scale", scale_values, 0.1f, 1.0f, 1000.0f))
|
||||
{
|
||||
transform->SetScale(XMVectorSet(scale_values[0], scale_values[1], scale_values[2], 0.0f));
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::SetTooltip("Set the scale of the skysphere");
|
||||
}
|
||||
}
|
||||
|
||||
if (render)
|
||||
{
|
||||
// display the render component default imguirender
|
||||
render->OnImGuiRender();
|
||||
}
|
||||
|
||||
if (shader)
|
||||
{
|
||||
// display the render component default imguirender
|
||||
shader->OnImGuiRender();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
TEX("Sky entity not found.")
|
||||
}
|
||||
|
||||
ImGui::EndTabItem();
|
||||
|
||||
}
|
||||
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
|
||||
// End Of General Setting
|
||||
ImGui::Separator();
|
||||
// culling section
|
||||
ImGui::Text("Culling");
|
||||
|
||||
// float input for frustum tolerance
|
||||
float frustumTolerance = app_->get_frustum_tolerance();
|
||||
if (ImGui::DragFloat("Frustum Tolerance", &frustumTolerance, 0.1f, 0.0f, 100.0f))
|
||||
if (ImGui::Button("Apply Settings"))
|
||||
{
|
||||
app_->set_frustum_tolerance(frustumTolerance);
|
||||
app_->set_vsync(temp_v_sync);
|
||||
app_->set_target_fps(temp_target_fps);
|
||||
app_->update_screen_depth(temp_screen_depth);
|
||||
app_->update_screen_near(temp_screen_near);
|
||||
app_->set_frustum_tolerance(temp_frustum_tolerance);
|
||||
app_->set_physics_tick_rate(temp_physics_tick_rate);
|
||||
app_->get_physics()->SetGravity(XMVectorSet(temp_gravity_values[0], temp_gravity_values[1], temp_gravity_values[2], 0.0f));
|
||||
}
|
||||
S_LINE
|
||||
if (ImGui::Button("Reset Settings"))
|
||||
{
|
||||
temp_v_sync = app_->get_vsync();
|
||||
temp_target_fps = app_->get_target_fps();
|
||||
temp_screen_depth = app_->get_screen_depth();
|
||||
temp_screen_near = app_->get_screen_near();
|
||||
temp_frustum_tolerance = app_->get_frustum_tolerance();
|
||||
temp_physics_tick_rate = app_->get_physics_tick_rate();
|
||||
temp_gravity_values[0] = XMVectorGetX(app_->get_physics()->GetGravity());
|
||||
temp_gravity_values[1] = XMVectorGetY(app_->get_physics()->GetGravity());
|
||||
temp_gravity_values[2] = XMVectorGetZ(app_->get_physics()->GetGravity());
|
||||
}
|
||||
|
||||
// End Of Culling Setting
|
||||
ImGui::Separator();
|
||||
|
||||
// physics section
|
||||
ImGui::Text("physics");
|
||||
|
||||
// Input To set the Fixed Update Interval
|
||||
int physicsInterval = app_->get_physics_tick_rate();
|
||||
if (ImGui::InputInt("physics Tick Rate", &physicsInterval))
|
||||
{
|
||||
app_->set_physics_tick_rate(physicsInterval);
|
||||
}
|
||||
|
||||
// Input to change the gravity on same line
|
||||
XMVECTOR gravity = app_->get_physics()->GetGravity();
|
||||
float gravityValues[3] = { XMVectorGetX(gravity), XMVectorGetY(gravity), XMVectorGetZ(gravity) };
|
||||
if (ImGui::DragFloat3("Gravity", gravityValues))
|
||||
{
|
||||
app_->get_physics()->SetGravity(XMVectorSet(gravityValues[0], gravityValues[1], gravityValues[2], 0.0f));
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
END
|
||||
}
|
||||
|
||||
void imguiManager::WidgetLogWindow()
|
||||
{
|
||||
ImGui::Begin("Log Window" , &showLogWindow);
|
||||
BEGIN("Log Window" , &showLogWindow)
|
||||
|
||||
// Filtre de recherche
|
||||
static ImGuiTextFilter filter;
|
||||
filter.Draw("Filter ", 180);
|
||||
|
||||
ImGui::SameLine();
|
||||
S_LINE
|
||||
|
||||
// Bouton pour ouvrir le fichier de log
|
||||
if (ImGui::Button("Open Log File"))
|
||||
@@ -917,25 +994,25 @@ void imguiManager::WidgetLogWindow()
|
||||
}
|
||||
|
||||
// Place the menu on the same line as the filter
|
||||
ImGui::SameLine();
|
||||
S_LINE
|
||||
|
||||
// Menu d<>roulant pour les niveaux de log
|
||||
if (ImGui::BeginMenu("Log Levels"))
|
||||
if (B_MENU("Log Levels"))
|
||||
{
|
||||
for (size_t i = 0; i < Logger::LogLevelCount; ++i)
|
||||
{
|
||||
bool isVisible = !Logger::Get().m_disabledLogLevels[i];
|
||||
if (ImGui::Checkbox(Logger::Get().GetLogLevelInfo(static_cast<Logger::LogLevel>(i)).name, &isVisible))
|
||||
if (C_BOX(Logger::Get().GetLogLevelInfo(static_cast<Logger::LogLevel>(i)).name, &isVisible))
|
||||
{
|
||||
Logger::Get().m_disabledLogLevels[i] = !isVisible;
|
||||
}
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
E_MENU
|
||||
}
|
||||
|
||||
const auto& logBuffer = Logger::Get().GetLogBuffer();
|
||||
std::vector<Logger::LogEntry> logfiltered;
|
||||
int logCount = logBuffer.size();
|
||||
int logCount = ulli_to_int(logBuffer.size());
|
||||
|
||||
// Affichage des logs filtr<74>s
|
||||
ImGui::BeginChild("Log");
|
||||
@@ -950,7 +1027,7 @@ void imguiManager::WidgetLogWindow()
|
||||
|
||||
if (logfiltered.size() == 0)
|
||||
{
|
||||
ImGui::Text("No logs to display.");
|
||||
TEX("No logs to display.")
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -978,7 +1055,7 @@ void imguiManager::WidgetLogWindow()
|
||||
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::End();
|
||||
END
|
||||
}
|
||||
|
||||
void imguiManager::WidgetRenderWindow(ImVec2 availableSize)
|
||||
@@ -1021,10 +1098,10 @@ void imguiManager::WidgetRenderWindow(ImVec2 availableSize)
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::Text("render texture is not available.");
|
||||
TEX("render texture is not available.")
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
END
|
||||
}
|
||||
|
||||
void imguiManager::WidgetRenderStats()
|
||||
@@ -1046,13 +1123,13 @@ void imguiManager::WidgetRenderStats()
|
||||
m_frameTimeHistory[m_frameTimeHistoryIndex] = current_frame_time_;
|
||||
m_frameTimeHistoryIndex = (m_frameTimeHistoryIndex + 1) % FRAME_HISTORY_COUNT;
|
||||
|
||||
ImGui::Text("FPS: %d", current_fps_);
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Min Fps: %d", min_fps_);
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Max Fps: %d", max_fps_);
|
||||
TEXT_V("FPS: %d", current_fps_)
|
||||
S_LINE
|
||||
TEXT_V("Min Fps: %d", min_fps_)
|
||||
S_LINE
|
||||
TEXT_V("Max Fps: %d", max_fps_)
|
||||
|
||||
ImGui::Separator();
|
||||
SEP
|
||||
|
||||
// Trouver les valeurs min/max pour l'<27>chelle du graphique
|
||||
float frameTimeMin = FLT_MAX;
|
||||
@@ -1073,7 +1150,7 @@ void imguiManager::WidgetRenderStats()
|
||||
frameTimeMax += margin;
|
||||
|
||||
// Afficher le graphique
|
||||
ImGui::Text("Frame Time: %.3f ms", current_frame_time_ * 1000.0f);
|
||||
TEXT_V("Frame Time: %.3f ms", current_frame_time_ * 1000.0f)
|
||||
ImGui::PlotLines("FrameTimeGraph", // Au lieu de cha<68>ne vide ""
|
||||
m_frameTimeHistory,
|
||||
FRAME_HISTORY_COUNT,
|
||||
@@ -1083,16 +1160,16 @@ void imguiManager::WidgetRenderStats()
|
||||
frameTimeMax,
|
||||
ImVec2(0, 80));
|
||||
|
||||
ImGui::Text("Draw Calls: %d", draw_calls_);
|
||||
TEXT_V("Draw Calls: %d", draw_calls_)
|
||||
|
||||
ImGui::Separator();
|
||||
SEP
|
||||
|
||||
ImGui::Text("Statistiques de rendu:");
|
||||
ImGui::Text("Vertices total: %d", *total_vertex_count_);
|
||||
TEX("Statistiques de rendu:")
|
||||
TEXT_V("Vertices total: %d", *total_vertex_count_)
|
||||
|
||||
ImGui::Text("Triangles total: %d", *total_triangle_count_);
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Triangles visibles: %d", visible_triangle_count_);
|
||||
TEXT_V("Triangles total: %d", *total_triangle_count_)
|
||||
S_LINE
|
||||
TEXT_V("Triangles visibles: %d", visible_triangle_count_)
|
||||
|
||||
app_->get_direct_3d()->get_video_card_info(card_name_, video_memory_);
|
||||
cpu_name_ = stats_->get_cpu_name();
|
||||
@@ -1103,43 +1180,59 @@ void imguiManager::WidgetRenderStats()
|
||||
ImGui::SetColumnWidth(1, ImGui::GetWindowWidth() * 0.33f);
|
||||
|
||||
// Premier collapsing header pour les informations GPU
|
||||
if (ImGui::CollapsingHeader("Informations GPU"))
|
||||
if (C_HEADER("Informations GPU"))
|
||||
{
|
||||
ImGui::Text("Carte graphique: %s", card_name_);
|
||||
ImGui::Text("Memoire video: %d Mo", video_memory_);
|
||||
ImGui::Text("Pilote: %s", version_driver_.c_str());
|
||||
TEXT_V("Carte graphique: %s", card_name_)
|
||||
TEXT_V("Memoire video: %d Mo", video_memory_)
|
||||
TEXT_V("Pilote: %s", version_driver_.c_str())
|
||||
}
|
||||
|
||||
ImGui::NextColumn();
|
||||
|
||||
// Second collapsing header pour les informations CPU
|
||||
if (ImGui::CollapsingHeader("Informations CPU"))
|
||||
if (C_HEADER("Informations CPU"))
|
||||
{
|
||||
SYSTEM_INFO sysInfo;
|
||||
GetSystemInfo(&sysInfo);
|
||||
ImGui::Text("Processeur: %s", cpu_name_.c_str());
|
||||
ImGui::Text("Nombre de coeurs: %u", sysInfo.dwNumberOfProcessors);
|
||||
ImGui::Text("Architecture: %s", (sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) ? "x64" : "x86");
|
||||
ImGui::Text("Taille de la page: %u octets", sysInfo.dwPageSize);
|
||||
ImGui::Text("Taille du cache: %u octets", sysInfo.dwAllocationGranularity);
|
||||
ImGui::Text("Type de processeur: %u", sysInfo.wProcessorLevel);
|
||||
ImGui::Text("Version du processeur: %u", sysInfo.wProcessorRevision);
|
||||
TEXT_V("Processeur: %s", cpu_name_.c_str())
|
||||
TEXT_V("Nombre de coeurs: %u", sysInfo.dwNumberOfProcessors)
|
||||
TEXT_V("Architecture: %s", (sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) ? "x64" : "x86")
|
||||
TEXT_V("Taille de la page: %u octets", sysInfo.dwPageSize)
|
||||
TEXT_V("Taille du cache: %u octets", sysInfo.dwAllocationGranularity)
|
||||
TEXT_V("Type de processeur: %u", sysInfo.wProcessorLevel)
|
||||
TEXT_V("Version du processeur: %u", sysInfo.wProcessorRevision)
|
||||
}
|
||||
|
||||
ImGui::NextColumn();
|
||||
|
||||
if (ImGui::CollapsingHeader("Informations RAM"))
|
||||
if (C_HEADER("Informations RAM"))
|
||||
{
|
||||
MEMORYSTATUSEX mem_info;
|
||||
mem_info.dwLength = sizeof(MEMORYSTATUSEX);
|
||||
GlobalMemoryStatusEx(&mem_info);
|
||||
ImGui::Text("Memoire totale: %llu Mo", mem_info.ullTotalPhys / (1024 * 1024));
|
||||
ImGui::Text("Memoire disponible: %llu Mo", mem_info.ullAvailPhys / (1024 * 1024));
|
||||
ImGui::Text("Memoire utilisee: %llu Mo", (mem_info.ullTotalPhys - mem_info.ullAvailPhys) / (1024 * 1024));
|
||||
TEXT_V("Memoire totale: %llu Mo", mem_info.ullTotalPhys / (1024 * 1024))
|
||||
TEXT_V("Memoire disponible: %llu Mo", mem_info.ullAvailPhys / (1024 * 1024))
|
||||
TEXT_V("Memoire utilisee: %llu Mo", (mem_info.ullTotalPhys - mem_info.ullAvailPhys) / (1024 * 1024))
|
||||
}
|
||||
|
||||
ImGui::Columns(1);
|
||||
|
||||
ImGui::End();
|
||||
END
|
||||
}
|
||||
|
||||
void imguiManager::UpdateCachedEntitiesIfNeeded() {
|
||||
if (!entityListDirty) return;
|
||||
cachedEntities_.clear();
|
||||
auto entities = entity_manager_->GetAllEntities();
|
||||
for (auto& entity : entities) {
|
||||
auto identity = entity->GetComponent<ecs::IdentityComponent>();
|
||||
if (identity) {
|
||||
std::string name = identity->GetName();
|
||||
auto id = identity->GetId();
|
||||
if (name.empty())
|
||||
name = "Entity " + std::to_string(identity->GetId());
|
||||
cachedEntities_.push_back({name,id});
|
||||
}
|
||||
}
|
||||
entityListDirty = false;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ input_class::~input_class()
|
||||
|
||||
bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, int screenHeight)
|
||||
{
|
||||
Logger::Get().Log("Initializing input class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing input class");
|
||||
|
||||
HRESULT result;
|
||||
int i;
|
||||
@@ -44,84 +44,84 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
|
||||
result = DirectInput8Create(hinstance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&m_directInput, NULL);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create direct input interface", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create direct input interface");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Initialize the direct input interface for the keyboard.
|
||||
result = m_directInput->CreateDevice(GUID_SysKeyboard, &m_keyboard, NULL);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create direct input interface for the keyboard", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create direct input interface for the keyboard");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the data format. In this case since it is a keyboard we can use the predefined data format.
|
||||
result = m_keyboard->SetDataFormat(&c_dfDIKeyboard);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to set data format for the keyboard", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to set data format for the keyboard");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the cooperative level of the keyboard to share with other programs.
|
||||
result = m_keyboard->SetCooperativeLevel(hwnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to set cooperative level of the keyboard", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to set cooperative level of the keyboard");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Now acquire the keyboard.
|
||||
result = m_keyboard->Acquire();
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to acquire the keyboard", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to acquire the keyboard");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Initialize the direct input interface for the mouse.
|
||||
result = m_directInput->CreateDevice(GUID_SysMouse, &m_mouse, NULL);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create direct input interface for the mouse", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create direct input interface for the mouse");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the data format for the mouse using the pre-defined mouse data format.
|
||||
result = m_mouse->SetDataFormat(&c_dfDIMouse);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to set data format for the mouse", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to set data format for the mouse");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set the cooperative level of the mouse to share with other programs.
|
||||
result = m_mouse->SetCooperativeLevel(hwnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to set cooperative level of the mouse", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to set cooperative level of the mouse");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Acquire the mouse.
|
||||
result = m_mouse->Acquire();
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to acquire the mouse", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to acquire the mouse");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Input class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Input class initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
void input_class::KeyDown(unsigned int input)
|
||||
{
|
||||
// If a key is pressed then save that state in the key array.
|
||||
Logger::Get().Log("Key down: " + std::to_string(input), __FILE__, __LINE__, Logger::LogLevel::Input);
|
||||
LOG("Key down: " + std::to_string(input), Logger::LogLevel::Input);
|
||||
m_keys[input] = true;
|
||||
return;
|
||||
}
|
||||
@@ -143,7 +143,7 @@ bool input_class::IsKeyDown(unsigned int key) const
|
||||
|
||||
void input_class::Shutdown()
|
||||
{
|
||||
Logger::Get().Log("Shutting down input class", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down input class");
|
||||
|
||||
// Release the mouse.
|
||||
if (m_mouse)
|
||||
@@ -168,7 +168,7 @@ void input_class::Shutdown()
|
||||
m_directInput = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("Input class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Input class shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -177,27 +177,26 @@ bool input_class::Frame()
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
// Read the current state of the keyboard.
|
||||
result = ReadKeyboard();
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to read keyboard state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to read keyboard state");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Read the current state of the mouse.
|
||||
result = ReadMouse();
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to read mouse state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to read mouse state");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Process the changes in the mouse and keyboard.
|
||||
ProcessInput();
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool input_class::ReadKeyboard()
|
||||
@@ -216,12 +215,12 @@ bool input_class::ReadKeyboard()
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Failed to get keyboard device state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to get keyboard device state");
|
||||
R_FALSE
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool input_class::ReadMouse()
|
||||
@@ -240,12 +239,12 @@ bool input_class::ReadMouse()
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Failed to get mouse device state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to get mouse device state");
|
||||
R_FALSE
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void input_class::ProcessInput()
|
||||
@@ -269,20 +268,20 @@ bool input_class::IsEscapePressed() const
|
||||
// Do a bitwise and on the keyboard state to check if the escape key is currently being pressed.
|
||||
if (m_keyboardState[DIK_ESCAPE] & 0x80)
|
||||
{
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
bool input_class::IsLeftArrowPressed() const
|
||||
{
|
||||
if (m_keyboardState[DIK_LEFT] & 0x80)
|
||||
{
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
|
||||
@@ -290,20 +289,20 @@ bool input_class::IsRightArrowPressed() const
|
||||
{
|
||||
if (m_keyboardState[DIK_RIGHT] & 0x80)
|
||||
{
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
bool input_class::IsUpArrowPressed() const
|
||||
{
|
||||
if (m_keyboardState[DIK_UP] & 0x80)
|
||||
{
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
|
||||
@@ -311,79 +310,16 @@ bool input_class::IsDownArrowPressed() const
|
||||
{
|
||||
if (m_keyboardState[DIK_DOWN] & 0x80)
|
||||
{
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
// Les touches correspondent aux claviers QWERTY //
|
||||
///////////////////////////////////////////////////
|
||||
|
||||
bool input_class::IsAPressed() const
|
||||
{
|
||||
// Touche A sur QWERTY, Q sur AZERTY
|
||||
if (m_keyboardState[DIK_A] & 0x80)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool input_class::IsDPressed() const
|
||||
{
|
||||
if (m_keyboardState[DIK_D] & 0x80)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool input_class::IsWPressed() const
|
||||
{
|
||||
// Touche W sur QWERTY, Z sur AZERTY
|
||||
if (m_keyboardState[DIK_W] & 0x80)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool input_class::IsSPressed() const
|
||||
{
|
||||
if (m_keyboardState[DIK_S] & 0x80)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool input_class::IsQPressed() const
|
||||
{
|
||||
// Touche Q sur QWERTY, A sur AZERTY
|
||||
if (m_keyboardState[DIK_Q] & 0x80)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool input_class::IsEPressed() const
|
||||
{
|
||||
if (m_keyboardState[DIK_E] & 0x80)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void input_class::GetMouseLocation(int& mouseX, int& mouseY) const
|
||||
{
|
||||
mouseX = m_mouseX;
|
||||
@@ -396,10 +332,10 @@ bool input_class::IsLeftMousePressed() const
|
||||
// Check the left mouse button state.
|
||||
if (m_mouseState.rgbButtons[0] & 0x80)
|
||||
{
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
bool input_class::IsRightMousePressed() const
|
||||
@@ -407,38 +343,33 @@ bool input_class::IsRightMousePressed() const
|
||||
// Check the left mouse button state.
|
||||
if (m_mouseState.rgbButtons[1] & 0x80)
|
||||
{
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
bool input_class::IsScrollUp() const
|
||||
{
|
||||
if (m_mouseState.lZ > 0)
|
||||
{
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
bool input_class::IsScrollDown() const
|
||||
{
|
||||
if (m_mouseState.lZ < 0)
|
||||
{
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
bool input_class::is_key_pressed(const unsigned int key_code)
|
||||
{
|
||||
if (m_keyboardState[key_code] & 0x80)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return m_keyboardState[key_code] & 0x80;
|
||||
}
|
||||
|
||||
@@ -29,12 +29,12 @@ bool model_class::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCo
|
||||
|
||||
bool result = Initialize(device, deviceContext, modelFilename);
|
||||
if (!result) {
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
m_Textures = textures; // Copie de la structure de textures
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool model_class::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename) {
|
||||
@@ -44,8 +44,8 @@ bool model_class::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCo
|
||||
// Load in the model data.
|
||||
result = LoadModel(modelFilename);
|
||||
if (!result) {
|
||||
Logger::Get().Log("Failed to load model data", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to load model data");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Calculate the tangent and binormal vectors for the model.
|
||||
@@ -54,11 +54,11 @@ bool model_class::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCo
|
||||
// Initialize the vertex and index buffers.
|
||||
result = InitializeBuffers(device);
|
||||
if (!result) {
|
||||
Logger::Get().Log("Failed to initialize buffers", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to initialize buffers");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void model_class::Shutdown()
|
||||
@@ -139,8 +139,8 @@ bool model_class::InitializeBuffers(ID3D11Device* device)
|
||||
result = device->CreateBuffer(&vertexBufferDesc, &vertexData, &m_vertexBuffer);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create vertex buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create vertex buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set up the description of the static index buffer.
|
||||
@@ -160,8 +160,8 @@ bool model_class::InitializeBuffers(ID3D11Device* device)
|
||||
result = device->CreateBuffer(&indexBufferDesc, &indexData, &m_indexBuffer);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create index buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create index buffer");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the arrays now that the vertex and index buffers have been created and loaded.
|
||||
@@ -170,7 +170,7 @@ bool model_class::InitializeBuffers(ID3D11Device* device)
|
||||
|
||||
delete[] indices;
|
||||
indices = 0;
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -227,8 +227,8 @@ bool model_class::LoadModel(char* filename)
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Unsupported file format", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Unsupported file format");
|
||||
R_FALSE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,8 +238,8 @@ bool model_class::LoadObjModel(char* filename)
|
||||
std::ifstream fin(filename, std::ios::in | std::ios::binary);
|
||||
if (!fin)
|
||||
{
|
||||
Logger::Get().Log("<EFBFBD>chec d'ouverture du fichier mod<6F>le", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("<EFBFBD>chec d'ouverture du fichier mod<6F>le");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Lecture du fichier entier d'un coup (<28>vite la lecture ligne par ligne)
|
||||
@@ -309,9 +309,9 @@ bool model_class::LoadObjModel(char* filename)
|
||||
while (*linePtr && *linePtr != ' ') linePtr++;
|
||||
while (*linePtr == ' ') linePtr++;
|
||||
|
||||
if (posIndex[i] < 0) posIndex[i] += temp_positions.size() + 1;
|
||||
if (texIndex[i] < 0) texIndex[i] += temp_texcoords.size() + 1;
|
||||
if (normIndex[i] < 0) normIndex[i] += temp_normals.size() + 1;
|
||||
if (posIndex[i] < 0) posIndex[i] += size_t_to_int(temp_positions.size()) + 1;
|
||||
if (texIndex[i] < 0) texIndex[i] += size_t_to_int(temp_texcoords.size()) + 1;
|
||||
if (normIndex[i] < 0) normIndex[i] += size_t_to_int(temp_normals.size()) + 1;
|
||||
}
|
||||
|
||||
for (int i = 2; i >= 0; --i)
|
||||
@@ -331,12 +331,12 @@ bool model_class::LoadObjModel(char* filename)
|
||||
}
|
||||
|
||||
// Allocation et copie efficace du mod<6F>le final
|
||||
m_vertexCount = temp_model.size();
|
||||
m_indexCount = temp_model.size();
|
||||
m_vertexCount = size_t_to_int(temp_model.size());
|
||||
m_indexCount = size_t_to_int(temp_model.size());
|
||||
m_model = new ModelType[m_vertexCount];
|
||||
std::memcpy(m_model, temp_model.data(), m_vertexCount * sizeof(ModelType));
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool model_class::LoadTxtModel(char* filename)
|
||||
@@ -352,8 +352,8 @@ bool model_class::LoadTxtModel(char* filename)
|
||||
// If it could not open the file then exit.
|
||||
if (fin.fail())
|
||||
{
|
||||
Logger::Get().Log("Failed to open model file", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to open model file");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Read up to the value of vertex count.
|
||||
@@ -392,7 +392,7 @@ bool model_class::LoadTxtModel(char* filename)
|
||||
// Close the model file.
|
||||
fin.close();
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void model_class::CalculateModelVectors()
|
||||
@@ -535,8 +535,8 @@ bool model_class::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* dev
|
||||
hResult = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
|
||||
if (FAILED(hResult))
|
||||
{
|
||||
Logger::Get().Log("<EFBFBD>chec du chargement de la texture diffuse: " + std::string(texturePath.begin(), texturePath.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("<EFBFBD>chec du chargement de la texture diffuse: " + std::string(texturePath.begin(), texturePath.end()));
|
||||
R_FALSE
|
||||
}
|
||||
textureContainer.diffuse.push_back(texture);
|
||||
}
|
||||
@@ -548,8 +548,8 @@ bool model_class::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* dev
|
||||
hResult = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
|
||||
if (FAILED(hResult))
|
||||
{
|
||||
Logger::Get().Log("<EFBFBD>chec du chargement de la texture normale: " + std::string(texturePath.begin(), texturePath.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("<EFBFBD>chec du chargement de la texture normale: " + std::string(texturePath.begin(), texturePath.end()));
|
||||
R_FALSE
|
||||
}
|
||||
textureContainer.normal.push_back(texture);
|
||||
}
|
||||
@@ -561,8 +561,8 @@ bool model_class::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* dev
|
||||
hResult = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
|
||||
if (FAILED(hResult))
|
||||
{
|
||||
Logger::Get().Log("<EFBFBD>chec du chargement de la texture sp<73>culaire: " + std::string(texturePath.begin(), texturePath.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("<EFBFBD>chec du chargement de la texture sp<73>culaire: " + std::string(texturePath.begin(), texturePath.end()));
|
||||
R_FALSE
|
||||
}
|
||||
textureContainer.specular.push_back(texture);
|
||||
}
|
||||
@@ -574,17 +574,17 @@ bool model_class::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* dev
|
||||
hResult = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
|
||||
if (FAILED(hResult))
|
||||
{
|
||||
Logger::Get().Log("<EFBFBD>chec du chargement de la texture alpha: " + std::string(texturePath.begin(), texturePath.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("<EFBFBD>chec du chargement de la texture alpha: " + std::string(texturePath.begin(), texturePath.end()));
|
||||
R_FALSE
|
||||
}
|
||||
textureContainer.alpha.push_back(texture);
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool model_class::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, TextureType type, int index) {
|
||||
Logger::Get().Log("Changing texture", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Changing texture");
|
||||
|
||||
HRESULT result;
|
||||
ID3D11ShaderResourceView* newTexture = nullptr;
|
||||
@@ -592,8 +592,8 @@ bool model_class::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* devic
|
||||
// Charger la nouvelle texture
|
||||
result = DirectX::CreateWICTextureFromFile(device, deviceContext, filename.c_str(), nullptr, &newTexture);
|
||||
if (FAILED(result)) {
|
||||
Logger::Get().Log("Failed to load texture: " + std::string(filename.begin(), filename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to load texture: " + std::string(filename.begin(), filename.end()));
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// R<>cup<75>rer le vecteur correspondant au type de texture
|
||||
@@ -640,12 +640,12 @@ bool model_class::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* devic
|
||||
break;
|
||||
}
|
||||
|
||||
Logger::Get().Log("Texture changed successfully", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
return true;
|
||||
LOG_INIT("Texture changed successfully");
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool model_class::AddTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, TextureType type) {
|
||||
Logger::Get().Log("Adding texture", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Adding texture");
|
||||
|
||||
HRESULT result;
|
||||
ID3D11ShaderResourceView* newTexture = nullptr;
|
||||
@@ -653,8 +653,8 @@ bool model_class::AddTexture(ID3D11Device* device, ID3D11DeviceContext* deviceCo
|
||||
// Charger la nouvelle texture
|
||||
result = DirectX::CreateWICTextureFromFile(device, deviceContext, filename.c_str(), nullptr, &newTexture);
|
||||
if (FAILED(result)) {
|
||||
Logger::Get().Log("Failed to load texture: " + std::string(filename.begin(), filename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to load texture: " + std::string(filename.begin(), filename.end()));
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Ajouter la texture au vecteur appropri<72> selon le type
|
||||
@@ -677,14 +677,14 @@ bool model_class::AddTexture(ID3D11Device* device, ID3D11DeviceContext* deviceCo
|
||||
break;
|
||||
}
|
||||
|
||||
Logger::Get().Log("Texture added successfully", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
return true;
|
||||
LOG_INIT("Texture added successfully");
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool model_class::AddTexture(ID3D11ShaderResourceView* texture, TextureType type) {
|
||||
if (!texture) {
|
||||
Logger::Get().Log("Cannot add null texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Cannot add null texture");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Ajouter la texture au vecteur appropri<72>
|
||||
@@ -706,6 +706,6 @@ bool model_class::AddTexture(ID3D11ShaderResourceView* texture, TextureType type
|
||||
m_Textures.alphaPaths.push_back(L"[texture pr<70>charg<72>e]");
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -61,13 +61,13 @@ bool object::Initialize(
|
||||
auto new_model = std::make_shared<model_class>();
|
||||
if (!new_model->Initialize(device, deviceContext, modelFilename, texturesContainer))
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
g_model_cache[filename] = new_model;
|
||||
m_model_ = new_model;
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void object::SetScaleMatrix(XMMATRIX scaleMatrix)
|
||||
@@ -405,7 +405,6 @@ bool object::LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, Textu
|
||||
HRESULT result;
|
||||
|
||||
int i = 0;
|
||||
TextureType type;
|
||||
for (const auto& texturePath : texturePaths)
|
||||
{
|
||||
ID3D11ShaderResourceView* texture = nullptr;
|
||||
@@ -421,16 +420,15 @@ bool object::LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, Textu
|
||||
std::wstring ws(errMsg);
|
||||
std::string str(ws.begin(), ws.end());
|
||||
|
||||
Logger::Get().Log("Failed to load texture: " + std::string(texturePath.begin(), texturePath.end()) +
|
||||
LOG_ERROR("Failed to load texture: " + std::string(texturePath.begin(), texturePath.end()) +
|
||||
"\nError: " + std::to_string(result) +
|
||||
"\nDescription: " + str,
|
||||
__FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false; // Assurez-vous de retourner false ou de g<>rer l'erreur de mani<6E>re appropri<72>e
|
||||
"\nDescription: " + str);
|
||||
R_FALSE // Assurez-vous de retourner false ou de g<>rer l'erreur de mani<6E>re appropri<72>e
|
||||
}
|
||||
texturesContainer.AssignTexture(texturesContainer, texture,texturePath , i);
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
@@ -84,7 +84,7 @@ bool physics::IsColliding(object* object1, object* object2)
|
||||
|
||||
if (type1 == ObjectType::Unknown || type2 == ObjectType::Unknown)
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
if (type1 == ObjectType::Sphere && type2 == ObjectType::Sphere)
|
||||
@@ -108,7 +108,7 @@ bool physics::IsColliding(object* object1, object* object2)
|
||||
return CubesOverlap(object1, object2);
|
||||
}
|
||||
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,12 +8,6 @@ position_class::position_class()
|
||||
m_positionX = 0.0f;
|
||||
m_positionY = 0.0f;
|
||||
m_positionZ = 0.0f;
|
||||
m_leftTurnSpeed = 0.0f;
|
||||
m_rightTurnSpeed = 0.0f;
|
||||
m_horizontalTurnSpeed = 0.0f;
|
||||
m_verticalTurnSpeed = 0.0f;
|
||||
m_cameraSpeed = 4.0f;
|
||||
m_speed = m_cameraSpeed;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,197 +39,4 @@ void position_class::GetPosition(float& x, float& y, float& z) const
|
||||
y = m_positionY;
|
||||
z = m_positionZ;
|
||||
return;
|
||||
}
|
||||
|
||||
void position_class::TurnLeft(bool keydown)
|
||||
{
|
||||
// If the key is pressed increase the speed at which the camera turns left. If not slow down the turn speed.
|
||||
if (keydown)
|
||||
{
|
||||
m_leftTurnSpeed += m_frameTime * 1.5f;
|
||||
|
||||
if (m_leftTurnSpeed > (m_frameTime * 200.0f))
|
||||
{
|
||||
m_leftTurnSpeed = m_frameTime * 200.0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_leftTurnSpeed -= m_frameTime * 1.0f;
|
||||
|
||||
if (m_leftTurnSpeed < 0.0f)
|
||||
{
|
||||
m_leftTurnSpeed = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
// Update the rotation using the turning speed.
|
||||
m_rotationY -= m_leftTurnSpeed;
|
||||
if (m_rotationY < 0.0f)
|
||||
{
|
||||
m_rotationY += 360.0f;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void position_class::TurnRight(bool keydown)
|
||||
{
|
||||
// If the key is pressed increase the speed at which the camera turns right. If not slow down the turn speed.
|
||||
if (keydown)
|
||||
{
|
||||
m_rightTurnSpeed += m_frameTime * 1.5f;
|
||||
|
||||
if (m_rightTurnSpeed > (m_frameTime * 200.0f))
|
||||
{
|
||||
m_rightTurnSpeed = m_frameTime * 200.0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_rightTurnSpeed -= m_frameTime * 1.0f;
|
||||
|
||||
if (m_rightTurnSpeed < 0.0f)
|
||||
{
|
||||
m_rightTurnSpeed = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
// Update the rotation using the turning speed.
|
||||
m_rotationY += m_rightTurnSpeed;
|
||||
if (m_rotationY > 360.0f)
|
||||
{
|
||||
m_rotationY -= 360.0f;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void position_class::TurnMouse(float deltaX, float deltaY, float sensitivity, bool rightMouseDown)
|
||||
{
|
||||
// The turning speed is proportional to the horizontal mouse movement
|
||||
m_horizontalTurnSpeed = deltaX * sensitivity;
|
||||
|
||||
if (rightMouseDown)
|
||||
{
|
||||
// Update the rotation using the turning speed
|
||||
m_rotationY += m_horizontalTurnSpeed;
|
||||
if (m_rotationY < 0.0f)
|
||||
{
|
||||
m_rotationY += 360.0f;
|
||||
}
|
||||
else if (m_rotationY > 360.0f)
|
||||
{
|
||||
m_rotationY -= 360.0f;
|
||||
}
|
||||
|
||||
// The turning speed is proportional to the vertical mouse movement
|
||||
m_verticalTurnSpeed = deltaY * sensitivity;
|
||||
|
||||
// Update the rotation using the turning speed
|
||||
m_rotationX += m_verticalTurnSpeed;
|
||||
if (m_rotationX < -90.0f)
|
||||
{
|
||||
m_rotationX = -90.0f;
|
||||
}
|
||||
else if (m_rotationX > 90.0f)
|
||||
{
|
||||
m_rotationX = 90.0f;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void position_class::MoveCamera(bool forward, bool backward, bool left, bool right, bool up, bool down, bool scrollUp, bool scrollDown, bool rightClick)
|
||||
{
|
||||
float radiansY, radiansX, speed;
|
||||
|
||||
// Set the speed of the camera if the right click is down.
|
||||
if (scrollUp && rightClick)
|
||||
{
|
||||
m_cameraSpeed *= 1.1f;
|
||||
}
|
||||
if (scrollDown && rightClick)
|
||||
{
|
||||
m_cameraSpeed *= 0.9f;
|
||||
|
||||
if (m_cameraSpeed < 0.25f) // Minimum speed.
|
||||
{
|
||||
m_cameraSpeed = 0.25f;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert degrees to radians.
|
||||
radiansY = m_rotationY * 0.0174532925f;
|
||||
radiansX = m_rotationX * 0.0174532925f;
|
||||
|
||||
//////////////////////////
|
||||
// Update the position. //
|
||||
//////////////////////////
|
||||
|
||||
// Moves the camera forward on a greater scale than the arrows.
|
||||
if (scrollUp && !rightClick)
|
||||
{
|
||||
speed = m_speed * 20 * m_frameTime;
|
||||
m_positionX += sinf(radiansY) * cosf(radiansX) * speed;
|
||||
m_positionZ += cosf(radiansY) * cosf(radiansX) * speed;
|
||||
m_positionY -= sinf(radiansX) * speed;
|
||||
}
|
||||
|
||||
// Moves the camera backward on a greater scale than the arrows.
|
||||
if (scrollDown && !rightClick)
|
||||
{
|
||||
speed = m_speed * 20 * m_frameTime;
|
||||
m_positionX -= sinf(radiansY) * cosf(radiansX) * speed;
|
||||
m_positionZ -= cosf(radiansY) * cosf(radiansX) * speed;
|
||||
m_positionY += sinf(radiansX) * speed;
|
||||
}
|
||||
|
||||
// Set the speed of the camera.
|
||||
speed = m_cameraSpeed * m_frameTime;
|
||||
|
||||
// If moving forward, the position moves in the direction of the camera and accordingly to its angle.
|
||||
if (forward)
|
||||
{
|
||||
m_positionX += sinf(radiansY) * cosf(radiansX) * speed;
|
||||
m_positionZ += cosf(radiansY) * cosf(radiansX) * speed;
|
||||
m_positionY -= sinf(radiansX) * speed;
|
||||
}
|
||||
|
||||
// If moving backward, the position moves in the opposite direction of the camera and accordingly to its angle.
|
||||
if (backward)
|
||||
{
|
||||
m_positionX -= sinf(radiansY) * cosf(radiansX) * speed;
|
||||
m_positionZ -= cosf(radiansY) * cosf(radiansX) * speed;
|
||||
m_positionY += sinf(radiansX) * speed;
|
||||
}
|
||||
|
||||
// If moving left, the position moves to the left of the camera and accordingly to its angle.
|
||||
if (left)
|
||||
{
|
||||
m_positionX -= cosf(radiansY) * speed;
|
||||
m_positionZ += sinf(radiansY) * speed;
|
||||
}
|
||||
|
||||
// If moving right, the position moves to the right of the camera and accordingly to its angle.
|
||||
if (right)
|
||||
{
|
||||
m_positionX += cosf(radiansY) * speed;
|
||||
m_positionZ -= sinf(radiansY) * speed;
|
||||
}
|
||||
|
||||
// If moving up, the position moves up.
|
||||
if (up)
|
||||
{
|
||||
m_positionY += speed;
|
||||
}
|
||||
|
||||
// If moving down, the position moves down.
|
||||
if (down)
|
||||
{
|
||||
m_positionY -= speed;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ render_texture_class::~render_texture_class()
|
||||
|
||||
bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, int textureHeight, float screenDepth, float screenNear, int format)
|
||||
{
|
||||
Logger::Get().Log("Initializing render_texture_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing render_texture_class");
|
||||
|
||||
D3D11_TEXTURE2D_DESC textureDesc;
|
||||
HRESULT result;
|
||||
@@ -70,8 +70,8 @@ bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, i
|
||||
result = device->CreateTexture2D(&textureDesc, NULL, &m_renderTargetTexture);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create render target texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create render target texture");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the render target view.
|
||||
@@ -83,8 +83,8 @@ bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, i
|
||||
result = device->CreateRenderTargetView(m_renderTargetTexture, &renderTargetViewDesc, &m_renderTargetView);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create render target view", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create render target view");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the description of the shader resource view.
|
||||
@@ -97,8 +97,8 @@ bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, i
|
||||
result = device->CreateShaderResourceView(m_renderTargetTexture, &shaderResourceViewDesc, &m_shaderResourceView);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create shader resource view", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create shader resource view");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Initialize the description of the depth buffer.
|
||||
@@ -121,8 +121,8 @@ bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, i
|
||||
result = device->CreateTexture2D(&depthBufferDesc, NULL, &m_depthStencilBuffer);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create depth buffer texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create depth buffer texture");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Initailze the depth stencil view description.
|
||||
@@ -137,8 +137,8 @@ bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, i
|
||||
result = device->CreateDepthStencilView(m_depthStencilBuffer, &depthStencilViewDesc, &m_depthStencilView);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create depth stencil view", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Failed to create depth stencil view");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Setup the viewport for rendering.
|
||||
@@ -155,14 +155,14 @@ bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, i
|
||||
// Create an orthographic projection matrix for 2D rendering.
|
||||
m_orthoMatrix = XMMatrixOrthographicLH((float)textureWidth, (float)textureHeight, screenNear, screenDepth);
|
||||
|
||||
Logger::Get().Log("render_texture_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("render_texture_class initialized");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void render_texture_class::Shutdown()
|
||||
{
|
||||
Logger::Get().Log("Shutting down render_texture_class", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down render_texture_class");
|
||||
|
||||
if (m_depthStencilView)
|
||||
{
|
||||
@@ -194,7 +194,7 @@ void render_texture_class::Shutdown()
|
||||
m_renderTargetTexture = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("render_texture_class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("render_texture_class shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -13,35 +13,34 @@ scene_manager::~scene_manager()
|
||||
bool scene_manager::initialize(application_class* app)
|
||||
{
|
||||
if (!app) {
|
||||
Logger::Get().Log("Application pointer is null", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Application pointer is null");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
app_ = app;
|
||||
|
||||
if (app_ == nullptr) {
|
||||
Logger::Get().Log("Application pointer is null", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Application pointer is null");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
direct_3d_ = app_->get_direct_3d();
|
||||
if (!direct_3d_) {
|
||||
Logger::Get().Log("Direct3D pointer is null", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Direct3D pointer is null");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool scene_manager::shutdown()
|
||||
{
|
||||
app_ = nullptr;
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool scene_manager::save_scene_as() {
|
||||
|
||||
Logger::Get().Log("Saving scene as...", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
LOG_INFO("Saving scene as...");
|
||||
|
||||
OPENFILENAME ofn;
|
||||
wchar_t szFile[260] = { 0 };
|
||||
@@ -68,12 +67,11 @@ bool scene_manager::save_scene_as() {
|
||||
|
||||
// Sauvegarder la sc<73>ne avec le nouveau chemin
|
||||
save_scene();
|
||||
|
||||
Logger::Get().Log("Scene saved as: " + scene_path_, __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
return false;
|
||||
LOG_INFO("Scene saved as: " + scene_path_);
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
bool scene_manager::load_scene() {
|
||||
@@ -94,16 +92,16 @@ bool scene_manager::load_scene() {
|
||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
||||
ofn.lpstrDefExt = L"ker";
|
||||
if (GetOpenFileName(&ofn) != TRUE) {
|
||||
Logger::Get().Log("Load scene canceled or failed", __FILE__, __LINE__, Logger::LogLevel::Warning);
|
||||
return false; // L'utilisateur a annul<75> la bo<62>te de dialogue
|
||||
LOG_WARNING("Load scene canceled or failed");
|
||||
R_FALSE // L'utilisateur a annul<75> la bo<62>te de dialogue
|
||||
}
|
||||
std::filesystem::path filepath = ofn.lpstrFile;
|
||||
scene_path_ = convert_w_string_to_string(filepath.wstring());
|
||||
if (scene_path_.empty()) {
|
||||
Logger::Get().Log("Invalid scene path", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Invalid scene path");
|
||||
R_FALSE
|
||||
}
|
||||
Logger::Get().Log("Loading scene from: " + scene_path_, __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
LOG_INFO("Loading scene from: " + scene_path_);
|
||||
|
||||
|
||||
w_folder_ = app_->get_w_folder();
|
||||
@@ -115,8 +113,8 @@ bool scene_manager::load_scene() {
|
||||
|
||||
std::ifstream inFile(scene_path_);
|
||||
if (!inFile.is_open()) {
|
||||
Logger::Get().Log("<EFBFBD>chec de l'ouverture du fichier", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("<EFBFBD>chec de l'ouverture du fichier");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
auto entity_manager = app_->get_entity_manager();
|
||||
@@ -155,18 +153,18 @@ bool scene_manager::load_scene() {
|
||||
auto modelPathComponent = currentEntity->GetComponent<ecs::ModelPathComponent>();
|
||||
|
||||
if (!modelPathComponent) {
|
||||
Logger::Get().Log("ModelPathComponent missing for entity ID: " + std::to_string(currentEntity->GetID()), __FILE__, __LINE__, Logger::LogLevel::Warning);
|
||||
LOG_WARNING("ModelPathComponent missing for entity ID: " + std::to_string(currentEntity->GetID()));
|
||||
}
|
||||
|
||||
if (!modelPathComponent || modelPathComponent->GetPath().empty()) {
|
||||
Logger::Get().Log("No model path specified for entity ID: " + std::to_string(currentEntity->GetID()), __FILE__, __LINE__, Logger::LogLevel::Warning);
|
||||
LOG_WARNING("No model path specified for entity ID: " + std::to_string(currentEntity->GetID()));
|
||||
}
|
||||
|
||||
auto renderComponent = currentEntity->GetComponent<ecs::RenderComponent>();
|
||||
|
||||
if (!renderComponent)
|
||||
{
|
||||
Logger::Get().Log("RenderComponent missing for entity ID: " + std::to_string(currentEntity->GetID()), __FILE__, __LINE__, Logger::LogLevel::Warning);
|
||||
LOG_WARNING("RenderComponent missing for entity ID: " + std::to_string(currentEntity->GetID()));
|
||||
}
|
||||
|
||||
currentTextures = renderComponent->GetTextureContainerBuffer();
|
||||
@@ -185,7 +183,7 @@ bool scene_manager::load_scene() {
|
||||
|
||||
// Pr<50>charger les textures
|
||||
if (!model->PreloadTextures(direct_3d_->get_device(), direct_3d_->get_device_context(), currentTextures)) {
|
||||
Logger::Get().Log("<EFBFBD>chec du pr<70>chargement des textures", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("<EFBFBD>chec du pr<70>chargement des textures");
|
||||
}
|
||||
|
||||
char modelFilename[256];
|
||||
@@ -193,7 +191,7 @@ bool scene_manager::load_scene() {
|
||||
wcstombs_s(&convertedChars, modelFilename, sizeof(modelFilename), modelPath.c_str(), _TRUNCATE);
|
||||
|
||||
if (!model->Initialize(direct_3d_->get_device(), direct_3d_->get_device_context(), modelFilename, currentTextures)) {
|
||||
Logger::Get().Log("<EFBFBD>chec d'initialisation du mod<6F>le", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("<EFBFBD>chec d'initialisation du mod<6F>le");
|
||||
} else {
|
||||
// Ajouter au cache
|
||||
modelCache[modelKey] = model;
|
||||
@@ -221,8 +219,8 @@ bool scene_manager::load_scene() {
|
||||
}
|
||||
}
|
||||
|
||||
Logger::Get().Log("Sc<EFBFBD>ne charg<72>e avec succ<63>s", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
return true;
|
||||
LOG_INFO("Sc<EFBFBD>ne charg<72>e avec succ<63>s");
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -230,13 +228,12 @@ bool scene_manager::save_scene() {
|
||||
entity_ = app_->get_entity_manager()->GetAllEntities();
|
||||
|
||||
if (scene_path_.empty() && !save_scene_as()) {
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
std::ofstream outFile(scene_path_);
|
||||
if (!outFile.is_open()) {
|
||||
Logger::Get().Log("<EFBFBD>chec de l'ouverture du fichier", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("<EFBFBD>chec de l'ouverture du fichier");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
for (const auto& entity : entity_) {
|
||||
@@ -259,8 +256,8 @@ bool scene_manager::save_scene() {
|
||||
}
|
||||
|
||||
outFile.close();
|
||||
Logger::Get().Log("Sc<EFBFBD>ne sauvegard<72>e avec succ<63>s: " + scene_path_, __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
return true;
|
||||
LOG_INFO("Sc<EFBFBD>ne sauvegard<72>e avec succ<63>s: " + scene_path_);
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
std::wstring scene_manager::get_scene_path()
|
||||
@@ -298,4 +295,3 @@ std::string scene_manager::convert_w_string_to_string(const std::wstring& wstr)
|
||||
WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &str[0], size_needed, NULL, NULL);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ bool shadow_map::initialize(ID3D11Device* device, int width, int height) {
|
||||
texDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
|
||||
|
||||
if (FAILED(device->CreateTexture2D(&texDesc, nullptr, &depth_texture_)))
|
||||
return false;
|
||||
R_FALSE
|
||||
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc = {};
|
||||
dsvDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
|
||||
@@ -30,7 +30,7 @@ bool shadow_map::initialize(ID3D11Device* device, int width, int height) {
|
||||
dsvDesc.Texture2D.MipSlice = 0;
|
||||
|
||||
if (FAILED(device->CreateDepthStencilView(depth_texture_, &dsvDesc, &depth_stencil_view_)))
|
||||
return false;
|
||||
R_FALSE
|
||||
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
|
||||
srvDesc.Format = DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
|
||||
@@ -38,9 +38,9 @@ bool shadow_map::initialize(ID3D11Device* device, int width, int height) {
|
||||
srvDesc.Texture2D.MipLevels = 1;
|
||||
|
||||
if (FAILED(device->CreateShaderResourceView(depth_texture_, &srvDesc, &shader_resource_view_)))
|
||||
return false;
|
||||
R_FALSE
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void shadow_map::shutdown() {
|
||||
|
||||
@@ -38,17 +38,17 @@ bool sprite_class::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceC
|
||||
result = InitializeBuffers(device);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Load the textures for this sprite.
|
||||
result = LoadTextures(device, deviceContext, spriteFilename);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -73,13 +73,13 @@ bool sprite_class::Render(ID3D11DeviceContext* deviceContext)
|
||||
result = UpdateBuffers(deviceContext);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Put the vertex and index buffers on the graphics pipeline to prepare them for drawing.
|
||||
RenderBuffers(deviceContext);
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void sprite_class::Update(float frameTime)
|
||||
@@ -169,7 +169,7 @@ bool sprite_class::InitializeBuffers(ID3D11Device* device)
|
||||
result = device->CreateBuffer(&vertexBufferDesc, &vertexData, &m_vertexBuffer);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Set up the description of the index buffer.
|
||||
@@ -189,7 +189,7 @@ bool sprite_class::InitializeBuffers(ID3D11Device* device)
|
||||
result = device->CreateBuffer(&indexBufferDesc, &indexData, &m_indexBuffer);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Release the arrays now that the vertex and index buffers have been created and loaded.
|
||||
@@ -199,7 +199,7 @@ bool sprite_class::InitializeBuffers(ID3D11Device* device)
|
||||
delete[] indices;
|
||||
indices = 0;
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ bool sprite_class::UpdateBuffers(ID3D11DeviceContext* deviceContent)
|
||||
// If the position we are rendering this bitmap to hasn't changed then don't update the vertex buffer.
|
||||
if ((m_prevPosX == m_renderX) && (m_prevPosY == m_renderY))
|
||||
{
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
// If the rendering location has changed then store the new position and update the vertex buffer.
|
||||
@@ -282,7 +282,7 @@ bool sprite_class::UpdateBuffers(ID3D11DeviceContext* deviceContent)
|
||||
result = deviceContent->Map(m_vertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
@@ -301,7 +301,7 @@ bool sprite_class::UpdateBuffers(ID3D11DeviceContext* deviceContent)
|
||||
delete[] vertices;
|
||||
vertices = 0;
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
|
||||
@@ -340,7 +340,7 @@ bool sprite_class::LoadTextures(ID3D11Device* device, ID3D11DeviceContext* devic
|
||||
fin.open(filename);
|
||||
if (fin.fail())
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
// Read in the number of textures.
|
||||
@@ -369,7 +369,7 @@ bool sprite_class::LoadTextures(ID3D11Device* device, ID3D11DeviceContext* devic
|
||||
result = m_Textures[i].Initialize(device, deviceContext, textureFilename);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
R_FALSE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ bool sprite_class::LoadTextures(ID3D11Device* device, ID3D11DeviceContext* devic
|
||||
// Set the starting texture in the cycle to be the first one in the list.
|
||||
m_currentTexture = 0;
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void sprite_class::ReleaseTextures()
|
||||
|
||||
@@ -15,8 +15,8 @@ stats::~stats()
|
||||
bool stats::initialize(application_class* app)
|
||||
{
|
||||
if (!app) {
|
||||
Logger::Get().Log("Application pointer is null", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("Application pointer is null");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
drawcalls_ = 0;
|
||||
@@ -25,13 +25,13 @@ bool stats::initialize(application_class* app)
|
||||
fps_ = app_->get_fps();
|
||||
|
||||
if (!fps_) {
|
||||
Logger::Get().Log("FPS object is null", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
LOG_ERROR("FPS object is null");
|
||||
R_FALSE
|
||||
}
|
||||
|
||||
Logger::Get().Log("Stats initialized successfully", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Stats initialized successfully");
|
||||
|
||||
return true;
|
||||
R_TRUE
|
||||
}
|
||||
|
||||
void stats::update_geometric_stats()
|
||||
@@ -44,7 +44,7 @@ void stats::update_geometric_stats()
|
||||
|
||||
update_visible_count();
|
||||
|
||||
Logger::Get().Log("Statistics updated: " + std::to_string(*total_vertex_count_) + " vertices, " + std::to_string(*total_triangle_count_) + " triangles", __FILE__, __LINE__, Logger::LogLevel::Debug);
|
||||
LOG_DEBUG("Statistics updated: " + std::to_string(*total_vertex_count_) + " vertices, " + std::to_string(*total_triangle_count_) + " triangles");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user