Patch - Improves code and UI for better engine stability - V14.5.30

Addresses minor issues across the engine to improve stability and UI.

- Updates ImGui window size for better rendering
- Adds macro for boolean returns (R_TRUE and R_FALSE)
- Adds missing includes and removes unused code
- Updates shader code to use the new macros and improve readability
This commit is contained in:
2025-10-10 00:32:19 +02:00
parent 2b8e222d7c
commit 00339aa6c2
60 changed files with 1064 additions and 1022 deletions

View File

@@ -16,7 +16,7 @@ DockId=0x00000006,0
[Window][render Stats]
Pos=0,630
Size=1265,231
Size=1584,231
Collapsed=0
DockId=0x00000009,0

View File

@@ -63,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;

View File

@@ -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.

View File

@@ -77,7 +77,7 @@ public:
bool Load(const std::string& path) {
if (!m_system) {
Initialize();
if (!m_system) return false;
if (!m_system) R_FALSE
}
LOG_INFO("Loading audio file: " + path);
@@ -87,7 +87,7 @@ public:
if (!std::filesystem::exists(path)) {
m_lastError = "Fichier non trouv<75>: " + path;
LOG_ERROR(m_lastError);
return false;
R_FALSE
}
if (m_sound) {
@@ -110,10 +110,10 @@ public:
m_lastError = "<EFBFBD>chec du chargement du son: " + std::to_string(result) +
" (chemin: " + absolutePath.string() + ")";
LOG_ERROR(m_lastError);
return false;
R_FALSE
}
return true;
R_TRUE
}
/**
@@ -495,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;
@@ -525,7 +525,7 @@ public:
Load(m_soundPath);
}
return true;
R_TRUE
}
private:

View File

@@ -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 {

View File

@@ -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
}
};

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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
}
/**
@@ -245,12 +245,12 @@ 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
int diffuse_count = 0, normal_count = 0, specular_count = 0, alpha_count = 0;
@@ -258,14 +258,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,7 +278,7 @@ 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);
@@ -287,20 +287,20 @@ public:
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 +318,7 @@ public:
texture_container_buffer.specularPaths = std::move(paths_specular);
texture_container_buffer.alphaPaths = std::move(paths_alpha);
return true;
R_TRUE
}
/**

View File

@@ -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 {

View File

@@ -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
}
/**

View File

@@ -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();

View File

@@ -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];

View File

@@ -6,6 +6,7 @@
// INCLUDES //
//////////////
#include <directxmath.h>
#include "macro.h"
using namespace DirectX;

View File

@@ -45,12 +45,6 @@ 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);

View File

@@ -1,12 +1,162 @@
#pragma once
// Include //
#include "imgui.h"
#include "Logger.h"
#include <limits>
#include <DirectXMath.h>
// --------------------- //
// --- Global Macros --- //
// --------------------- //
#define R_FALSE return false;
#define R_TRUE return true;
// Macros //
#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)
#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)
// ---------------------------------------------------- //
// --- 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);

View File

@@ -1,6 +1,7 @@
#pragma once
#include <d3d11.h>
#include <directxmath.h>
#include "macro.h"
class shadow_map {
public:

View File

@@ -35,7 +35,7 @@ bool alpha_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Error copying string ");
return false;
R_FALSE
}
// Set the filename of the pixel shader.
@@ -43,7 +43,7 @@ bool alpha_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Error copying string");
return false;
R_FALSE
}
// initialize the vertex and pixel shaders.
@@ -51,10 +51,10 @@ bool alpha_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing shader");
return false;
R_FALSE
}
return true;
R_TRUE
}
@@ -78,13 +78,13 @@ bool alpha_map_shader_class::render(ID3D11DeviceContext* deviceContext, int inde
if (!result)
{
LOG_ERROR("Error setting shader parameters");
return false;
R_FALSE
}
// Now render the prepared buffers with the shader.
render_shader(deviceContext, indexCount);
return true;
R_TRUE
}
@@ -123,7 +123,7 @@ bool alpha_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
LOG_ERROR("Error compiling shader");
}
return false;
R_FALSE
}
// Compile the pixel shader code.
@@ -142,7 +142,7 @@ bool alpha_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
LOG_ERROR("Error compiling shader");
}
return false;
R_FALSE
}
// Create the vertex shader from the buffer.
@@ -150,7 +150,7 @@ bool alpha_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating vertex shader");
return false;
R_FALSE
}
// Create the pixel shader from the buffer.
@@ -158,7 +158,7 @@ bool alpha_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating pixel shader");
return false;
R_FALSE
}
// Create the vertex input layout description.
@@ -195,7 +195,7 @@ bool alpha_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating input layout");
return false;
R_FALSE
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
@@ -218,7 +218,7 @@ bool alpha_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating constant buffer");
return false;
R_FALSE
}
// Create a texture sampler state description.
@@ -241,12 +241,12 @@ bool alpha_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating sampler state");
return false;
R_FALSE
}
LOG_INIT("Shader initialized");
return true;
R_TRUE
}
@@ -361,7 +361,7 @@ bool alpha_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCo
if (FAILED(result))
{
LOG_ERROR("Error mapping constant buffer");
return false;
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
}

View File

@@ -42,7 +42,7 @@ bool celshade_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Failed to copy string");
return false;
R_FALSE
}
// Set the filename of the pixel shader.
@@ -50,19 +50,19 @@ bool celshade_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Failed to copy string");
return false;
R_FALSE
}
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
LOG_ERROR("Failed to initialize shader");
return false;
R_FALSE
}
LOG_INIT("SunLightShaderClass initialized");
return true;
R_TRUE
}
@@ -85,13 +85,13 @@ bool celshade_class::render(ID3D11DeviceContext* deviceContext, int index_count,
if (!result)
{
LOG_ERROR("Failed to set shader parameters");
return false;
R_FALSE
}
// Now render the prepared buffers with the shader.
render_shader(deviceContext, index_count);
return true;
R_TRUE
}
@@ -126,7 +126,7 @@ bool celshade_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* v
{
LOG_ERROR("Failed to compile shader");
}
return false;
R_FALSE
}
// Compile the pixel shader code.
@@ -141,7 +141,7 @@ bool celshade_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* v
{
LOG_ERROR("Failed to compile shader");
}
return false;
R_FALSE
}
// Create the vertex shader from the buffer.
@@ -149,7 +149,7 @@ bool celshade_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* v
if (FAILED(result))
{
LOG_ERROR("Failed to create vertex shader");
return false;
R_FALSE
}
// Create the pixel shader from the buffer.
@@ -157,7 +157,7 @@ bool celshade_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* v
if (FAILED(result))
{
LOG_ERROR("Failed to create pixel shader");
return false;
R_FALSE
}
// Create the vertex input layout description.
@@ -193,7 +193,7 @@ bool celshade_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* v
if (FAILED(result))
{
LOG_ERROR("Failed to create input layout");
return false;
R_FALSE
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
@@ -223,7 +223,7 @@ bool celshade_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* v
if (FAILED(result))
{
LOG_ERROR("Failed to create sampler state");
return false;
R_FALSE
}
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
@@ -239,7 +239,7 @@ bool celshade_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* v
if (FAILED(result))
{
LOG_ERROR("Failed to create matrix buffer");
return false;
R_FALSE
}
// Setup the description of the dynamic sunlight constant buffer that is in the pixel shader.
@@ -255,12 +255,12 @@ bool celshade_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* v
if (FAILED(result))
{
LOG_ERROR("Failed to create sunlight buffer");
return false;
R_FALSE
}
LOG_INIT("Shader initialized");
return true;
R_TRUE
}
@@ -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)

View File

@@ -36,7 +36,7 @@ bool color_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Error copying string");
return false;
R_FALSE
}
// Set the filename of the pixel shader.
@@ -44,7 +44,7 @@ bool color_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Error copying string");
return false;
R_FALSE
}
// initialize the vertex and pixel shaders.
@@ -52,12 +52,12 @@ bool color_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing shader");
return false;
R_FALSE
}
LOG_INIT("color_shader_class initialized");
return true;
R_TRUE
}
void color_shader_class::shutdown()
@@ -79,13 +79,13 @@ bool color_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCou
if (!result)
{
LOG_ERROR("Error setting shader parameters");
return false;
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)
@@ -122,7 +122,7 @@ bool color_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
LOG_ERROR("Error compiling shader");
}
return false;
R_FALSE
}
// Compile the pixel shader code.
@@ -141,7 +141,7 @@ bool color_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
LOG_ERROR("Error compiling shader");
}
return false;
R_FALSE
}
// Create the vertex shader from the buffer.
@@ -149,7 +149,7 @@ bool color_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Error creating vertex shader");
return false;
R_FALSE
}
// Create the pixel shader from the buffer.
@@ -157,7 +157,7 @@ bool color_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Error creating pixel shader");
return false;
R_FALSE
}
// Create the vertex input layout description.
@@ -187,7 +187,7 @@ bool color_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Error creating input layout");
return false;
R_FALSE
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
@@ -210,12 +210,12 @@ bool color_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Error creating constant buffer");
return false;
R_FALSE
}
LOG_INIT("Shader initialized");
return true;
R_TRUE
}
void color_shader_class::shutdown_shader()
@@ -318,7 +318,7 @@ bool color_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
if (FAILED(result))
{
LOG_ERROR("Error mapping constant buffer");
return false;
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)

View File

@@ -34,7 +34,7 @@ bool depth_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Error copying stirng");
return false;
R_FALSE
}
// Set the filename of the pixel shader.
@@ -42,7 +42,7 @@ bool depth_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Error copying stirng");
return false;
R_FALSE
}
// initialize the vertex and pixel shaders.
@@ -50,12 +50,12 @@ bool depth_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing shader");
return false;
R_FALSE
}
LOG_INIT("Texture shader initialized");
return true;
R_TRUE
}
void depth_shader_class::shutdown()
@@ -76,13 +76,13 @@ bool depth_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCou
if (!result)
{
LOG_ERROR("Error setting shader parameters");
return false;
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)
@@ -119,7 +119,7 @@ bool depth_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
LOG_ERROR("Error compiling shader");
}
return false;
R_FALSE
}
// Compile the pixel shader code.
@@ -138,7 +138,7 @@ bool depth_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
LOG_ERROR("Error compiling shader");
}
return false;
R_FALSE
}
// Create the vertex shader from the buffer.
@@ -146,7 +146,7 @@ bool depth_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Error creating vertex shader");
return false;
R_FALSE
}
// Create the pixel shader from the buffer.
@@ -154,7 +154,7 @@ bool depth_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Error creating pixel shader");
return false;
R_FALSE
}
// Create the vertex input layout description.
// This setup needs to match the VertexType stucture in the ModelClass and in the shader.
@@ -183,7 +183,7 @@ bool depth_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Error creating input layout");
return false;
R_FALSE
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
@@ -206,7 +206,7 @@ bool depth_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Error creating constant buffer");
return false;
R_FALSE
}
// Create a texture sampler state description.
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
@@ -228,12 +228,12 @@ bool depth_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Error creating sampler state");
return false;
R_FALSE
}
LOG_INIT("Shader initialized");
return true;
R_TRUE
}
void depth_shader_class::shutdown_shader()
@@ -334,7 +334,7 @@ bool depth_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
if (FAILED(result))
{
LOG_ERROR("Error mapping constant buffer");
return false;
R_FALSE
}
// Get a pointer to the data in the constant buffer.
@@ -356,7 +356,7 @@ bool depth_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
// 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)

View File

@@ -36,7 +36,7 @@ bool font_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Error copying string");
return false;
R_FALSE
}
// Set the filename of the pixel shader.
@@ -44,7 +44,7 @@ bool font_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Error copying string");
return false;
R_FALSE
}
// initialize the vertex and pixel shaders.
@@ -52,12 +52,12 @@ bool font_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing shader");
return false;
R_FALSE
}
LOG_INIT("font_shader_class initialized");
return true;
R_TRUE
}
void font_shader_class::shutdown()
@@ -79,13 +79,13 @@ bool font_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCoun
if (!result)
{
LOG_ERROR("Error setting shader parameters");
return false;
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)
@@ -124,7 +124,7 @@ bool font_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR
LOG_ERROR("Error compiling shader");
}
return false;
R_FALSE
}
// Compile the pixel shader code.
@@ -143,7 +143,7 @@ bool font_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR
LOG_ERROR("Error compiling shader");
}
return false;
R_FALSE
}
// Create the vertex shader from the buffer.
@@ -151,7 +151,7 @@ bool font_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR
if (FAILED(result))
{
LOG_ERROR("Error creating vertex shader");
return false;
R_FALSE
}
// Create the pixel shader from the buffer.
@@ -159,7 +159,7 @@ bool font_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR
if (FAILED(result))
{
LOG_ERROR("Error creating pixel shader");
return false;
R_FALSE
}
// Create the vertex input layout description.
@@ -189,7 +189,7 @@ bool font_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR
if (FAILED(result))
{
LOG_ERROR("Error creating input layout");
return false;
R_FALSE
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
@@ -212,7 +212,7 @@ bool font_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR
if (FAILED(result))
{
LOG_ERROR("Error creating constant buffer");
return false;
R_FALSE
}
// Create a texture sampler state description.
@@ -235,7 +235,7 @@ bool font_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR
if (FAILED(result))
{
LOG_ERROR("Error creating sampler state");
return false;
R_FALSE
}
// Setup the description of the dynamic pixel constant buffer that is in the pixel shader.
@@ -251,12 +251,12 @@ bool font_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR
if (FAILED(result))
{
LOG_ERROR("Error creating constant buffer");
return false;
R_FALSE
}
LOG_INIT("Shader initialized");
return true;
R_TRUE
}
void font_shader_class::shutdown_shader()
@@ -366,7 +366,7 @@ bool font_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext
if (FAILED(result))
{
LOG_ERROR("Error mapping constant buffer");
return false;
R_FALSE
}
// Get a pointer to the data in the constant buffer.
@@ -394,7 +394,7 @@ bool font_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext
if (FAILED(result))
{
LOG_ERROR("Error mapping constant buffer");
return false;
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)

View File

@@ -35,7 +35,7 @@ bool light_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Error copying string");
return false;
R_FALSE
}
// Set the filename of the pixel shader.
@@ -43,7 +43,7 @@ bool light_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Error copying string");
return false;
R_FALSE
}
// initialize the vertex and pixel shaders.
@@ -51,12 +51,12 @@ bool light_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing shader");
return false;
R_FALSE
}
LOG_INIT("light_map_shader_class initialized");
return true;
R_TRUE
}
@@ -79,13 +79,13 @@ bool light_map_shader_class::render(ID3D11DeviceContext* deviceContext, int inde
if (!result)
{
LOG_ERROR("Error setting shader parameters");
return false;
R_FALSE
}
// Now render the prepared buffers with the shader.
render_shader(deviceContext, indexCount);
return true;
R_TRUE
}
@@ -123,7 +123,7 @@ bool light_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
LOG_ERROR("Error compiling shader");
}
return false;
R_FALSE
}
// Compile the pixel shader code.
@@ -142,7 +142,7 @@ bool light_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
LOG_ERROR("Error compiling shader");
}
return false;
R_FALSE
}
// Create the vertex shader from the buffer.
@@ -150,7 +150,7 @@ bool light_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating vertex shader");
return false;
R_FALSE
}
// Create the pixel shader from the buffer.
@@ -158,7 +158,7 @@ bool light_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating pixel shader");
return false;
R_FALSE
}
// Create the vertex input layout description.
@@ -195,7 +195,7 @@ bool light_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating input layout");
return false;
R_FALSE
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
@@ -218,7 +218,7 @@ bool light_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating constant buffer");
return false;
R_FALSE
}
// Create a texture sampler state description.
@@ -241,12 +241,12 @@ bool light_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating sampler state");
return false;
R_FALSE
}
LOG_INIT("Shader initialized");
return true;
R_TRUE
}
@@ -350,7 +350,7 @@ bool light_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCo
if (FAILED(result))
{
LOG_ERROR("Error mapping constant buffer");
return false;
R_FALSE
}
// Get a pointer to the data in the constant buffer.
@@ -374,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
}

View File

@@ -42,7 +42,7 @@ bool light_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Failed to copy string");
return false;
R_FALSE
}
// Set the filename of the pixel shader.
@@ -50,19 +50,19 @@ bool light_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Failed to copy string");
return false;
R_FALSE
}
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
LOG_ERROR("Failed to initialize shader");
return false;
R_FALSE
}
LOG_INIT("light_shader_class initialized");
return true;
R_TRUE
}
@@ -85,13 +85,13 @@ bool light_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCou
if(!result)
{
LOG_ERROR("Failed to set shader parameters");
return false;
R_FALSE
}
// Now render the prepared buffers with the shader.
render_shader(deviceContext, indexCount);
return true;
R_TRUE
}
@@ -132,7 +132,7 @@ bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
LOG_ERROR("Failed to compile shader");
}
return false;
R_FALSE
}
// Compile the pixel shader code.
@@ -150,7 +150,7 @@ bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
LOG_ERROR("Failed to compile shader");
}
return false;
R_FALSE
}
// Create the vertex shader from the buffer.
@@ -158,7 +158,7 @@ bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Failed to create vertex shader");
return false;
R_FALSE
}
// Create the pixel shader from the buffer.
@@ -166,7 +166,7 @@ bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Failed to create pixel shader");
return false;
R_FALSE
}
// Create the vertex input layout description.
@@ -204,7 +204,7 @@ bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Failed to create input layout");
return false;
R_FALSE
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
@@ -234,7 +234,7 @@ bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Failed to create sampler state");
return false;
R_FALSE
}
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
@@ -250,7 +250,7 @@ bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Failed to create matrix buffer");
return false;
R_FALSE
}
@@ -268,7 +268,7 @@ bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Failed to create camera buffer");
return false;
R_FALSE
}
// Setup the description of the dynamic constant buffer that is in the pixel shader.
@@ -284,7 +284,7 @@ bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Failed to create light color buffer");
return false;
R_FALSE
}
// Setup the description of the dynamic constant buffer that is in the vertex shader.
@@ -300,12 +300,12 @@ bool light_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Failed to create light position buffer");
return false;
R_FALSE
}
LOG_INIT("Shader initialized");
return true;
R_TRUE
}
@@ -437,7 +437,7 @@ bool light_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
if (FAILED(result))
{
LOG_ERROR("Failed to map matrix buffer");
return false;
R_FALSE
}
// Get a pointer to the data in the constant buffer.
@@ -462,7 +462,7 @@ bool light_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
if (FAILED(result))
{
LOG_ERROR("Failed to map camera buffer");
return false;
R_FALSE
}
// Lock the light position constant buffer so it can be written to.
@@ -470,7 +470,7 @@ bool light_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
if (FAILED(result))
{
LOG_ERROR("Failed to map light position buffer");
return false;
R_FALSE
}
// Get a pointer to the data in the constant buffer.
@@ -499,7 +499,7 @@ bool light_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
if (FAILED(result))
{
LOG_ERROR("Failed to map light color buffer");
return false;
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
}

View File

@@ -19,5 +19,5 @@ bool master_shader::initialize(ID3D11Device* device, HWND hwnd)
bool success = false;
return true;
R_TRUE
}

View File

@@ -38,7 +38,7 @@ bool multi_texture_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Failed to set the filename of the vertex shader");
return false;
R_FALSE
}
// Set the filename of the pixel shader.
@@ -46,7 +46,7 @@ bool multi_texture_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Failed to set the filename of the pixel shader");
return false;
R_FALSE
}
// initialize the vertex and pixel shaders.
@@ -54,12 +54,12 @@ bool multi_texture_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Failed to initialize the vertex and pixel shaders");
return false;
R_FALSE
}
LOG_INIT("multi_texture_shader_class initialized");
return true;
R_TRUE
}
void multi_texture_shader_class::shutdown()
@@ -81,13 +81,13 @@ bool multi_texture_shader_class::render(ID3D11DeviceContext* deviceContext, int
if (!result)
{
LOG_ERROR("Failed to set the shader parameters that it will use for rendering");
return false;
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)
@@ -125,7 +125,7 @@ bool multi_texture_shader_class::initialize_shader(ID3D11Device* device, HWND hw
LOG_ERROR("Failed to compile the vertex shader code");
}
return false;
R_FALSE
}
// Compile the pixel shader code.
@@ -144,7 +144,7 @@ bool multi_texture_shader_class::initialize_shader(ID3D11Device* device, HWND hw
LOG_ERROR("Failed to compile the pixel shader code");
}
return false;
R_FALSE
}
// Create the vertex shader from the buffer.
@@ -152,7 +152,7 @@ bool multi_texture_shader_class::initialize_shader(ID3D11Device* device, HWND hw
if (FAILED(result))
{
LOG_ERROR("Failed to create the vertex shader from the buffer");
return false;
R_FALSE
}
// Create the pixel shader from the buffer.
@@ -160,7 +160,7 @@ bool multi_texture_shader_class::initialize_shader(ID3D11Device* device, HWND hw
if (FAILED(result))
{
LOG_ERROR("Failed to create the pixel shader from the buffer");
return false;
R_FALSE
}
// Create the vertex input layout description.
@@ -197,7 +197,7 @@ bool multi_texture_shader_class::initialize_shader(ID3D11Device* device, HWND hw
if (FAILED(result))
{
LOG_ERROR("Failed to create the vertex input layout");
return false;
R_FALSE
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
@@ -220,7 +220,7 @@ bool multi_texture_shader_class::initialize_shader(ID3D11Device* device, HWND hw
if (FAILED(result))
{
LOG_ERROR("Failed to create the constant buffer pointer");
return false;
R_FALSE
}
// Create a texture sampler state description.
@@ -243,12 +243,12 @@ bool multi_texture_shader_class::initialize_shader(ID3D11Device* device, HWND hw
if (FAILED(result))
{
LOG_ERROR("Failed to create the texture sampler state");
return false;
R_FALSE
}
LOG_INIT("Shader initialized");
return true;
R_TRUE
}
void multi_texture_shader_class::shutdown_shader()
@@ -349,7 +349,7 @@ bool multi_texture_shader_class::set_shader_parameters(ID3D11DeviceContext* devi
if (FAILED(result))
{
LOG_ERROR("Failed to lock the constant buffer");
return false;
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)

View File

@@ -36,7 +36,7 @@ bool normal_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Failed to set the filename of the vertex shader");
return false;
R_FALSE
}
// Set the filename of the pixel shader.
@@ -44,7 +44,7 @@ bool normal_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Failed to set the filename of the pixel shader");
return false;
R_FALSE
}
// initialize the vertex and pixel shaders.
@@ -52,12 +52,12 @@ bool normal_map_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Failed to initialize the vertex and pixel shaders");
return false;
R_FALSE
}
LOG_INIT("Successfully initialized normal map shader");
return true;
R_TRUE
}
@@ -80,13 +80,13 @@ bool normal_map_shader_class::render(ID3D11DeviceContext* deviceContext, int ind
if (!result)
{
LOG_ERROR("Failed to set the shader parameters that will be used for rendering");
return false;
R_FALSE
}
// Now render the prepared buffers with the shader.
render_shader(deviceContext, indexCount);
return true;
R_TRUE
}
@@ -126,7 +126,7 @@ bool normal_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
LOG_ERROR("Failed to compile the vertex shader code");
}
return false;
R_FALSE
}
// Compile the pixel shader code.
@@ -145,7 +145,7 @@ bool normal_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
LOG_ERROR("Failed to compile the pixel shader code");
}
return false;
R_FALSE
}
// Create the vertex shader from the buffer.
@@ -153,7 +153,7 @@ bool normal_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Failed to create the vertex shader from the buffer");
return false;
R_FALSE
}
// Create the pixel shader from the buffer.
@@ -161,7 +161,7 @@ bool normal_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Failed to create the pixel shader from the buffer");
return false;
R_FALSE
}
// Create the vertex input layout description.
@@ -214,7 +214,7 @@ bool normal_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Failed to create the vertex input layout");
return false;
R_FALSE
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
@@ -237,7 +237,7 @@ bool normal_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Failed to create the constant buffer pointer");
return false;
R_FALSE
}
// Create a texture sampler state description.
@@ -260,7 +260,7 @@ bool normal_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Failed to create the texture sampler state");
return false;
R_FALSE
}
// Setup the description of the light dynamic constant buffer that is in the pixel shader.
@@ -276,12 +276,12 @@ bool normal_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Failed to create the light constant buffer pointer");
return false;
R_FALSE
}
LOG_INIT("Successfully initialized normal map shader");
return true;
R_TRUE
}
@@ -393,7 +393,7 @@ bool normal_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceC
if (FAILED(result))
{
LOG_ERROR("Failed to lock the constant buffer so it can be written to");
return false;
R_FALSE
}
// Get a pointer to the data in the constant buffer.
@@ -422,7 +422,7 @@ bool normal_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceC
if (FAILED(result))
{
LOG_ERROR("Failed to lock the light constant buffer so it can be written to");
return false;
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
}

View File

@@ -33,7 +33,7 @@ bool reflection_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Error copying string");
return false;
R_FALSE
}
// Set the filename of the pixel shader.
@@ -41,7 +41,7 @@ bool reflection_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Error copying string");
return false;
R_FALSE
}
// initialize the vertex and pixel shaders.
@@ -49,12 +49,12 @@ bool reflection_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing shader");
return false;
R_FALSE
}
LOG_INIT("Reflection shader initialized");
return true;
R_TRUE
}
void reflection_shader_class::shutdown()
@@ -75,13 +75,13 @@ bool reflection_shader_class::render(ID3D11DeviceContext* deviceContext, int ind
if (!result)
{
LOG_ERROR("Error setting shader parameters");
return false;
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)
@@ -120,7 +120,7 @@ bool reflection_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
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,
@@ -138,7 +138,7 @@ bool reflection_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
LOG_ERROR("Error compiling shader");
}
return false;
R_FALSE
}
// Create the vertex shader from the buffer.
@@ -146,7 +146,7 @@ bool reflection_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating vertex shader");
return false;
R_FALSE
}
// Create the pixel shader from the buffer.
@@ -154,7 +154,7 @@ bool reflection_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating pixel shader");
return false;
R_FALSE
}
// Create the vertex input layout description.
@@ -183,7 +183,7 @@ bool reflection_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating input layout");
return false;
R_FALSE
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
@@ -206,7 +206,7 @@ bool reflection_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating constant buffer");
return false;
R_FALSE
}
// Create a texture sampler state description.
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
@@ -228,7 +228,7 @@ bool reflection_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating sampler state");
return false;
R_FALSE
}
// Setup the description of the reflection dynamic constant buffer that is in the vertex shader.
reflectionBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
@@ -243,12 +243,12 @@ bool reflection_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating constant buffer");
return false;
R_FALSE
}
LOG_INIT("Reflection shader initialized");
return true;
R_TRUE
}
void reflection_shader_class::shutdown_shader()
@@ -361,7 +361,7 @@ bool reflection_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceC
if (FAILED(result))
{
LOG_ERROR("Error mapping constant buffer");
return false;
R_FALSE
}
// Get a pointer to the data in the constant buffer.
@@ -386,7 +386,7 @@ bool reflection_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceC
if (FAILED(result))
{
LOG_ERROR("Error mapping constant buffer");
return false;
R_FALSE
}
// Get a pointer to the data in the matrix constant buffer.
@@ -410,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
}

View File

@@ -37,7 +37,7 @@ bool refraction_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Error copying vertex shader filename");
return false;
R_FALSE
}
// Set the filename of the pixel shader.
@@ -45,7 +45,7 @@ bool refraction_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Error copying pixel shader filename");
return false;
R_FALSE
}
// initialize the vertex and pixel shaders.
@@ -53,12 +53,12 @@ bool refraction_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing shader");
return false;
R_FALSE
}
LOG_INIT("Refraction shader initialized");
return true;
R_TRUE
}
@@ -80,13 +80,13 @@ bool refraction_shader_class::render(ID3D11DeviceContext* deviceContext, int ind
if (!result)
{
LOG_ERROR("Error setting shader parameters");
return false;
R_FALSE
}
// Now render the prepared buffers with the shader.
render_shader(deviceContext, indexCount);
return true;
R_TRUE
}
@@ -127,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.
@@ -147,7 +147,7 @@ bool refraction_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
MessageBox(hwnd, psFilename, L"Missing Shader File", MB_OK);
}
return false;
R_FALSE
}
// Create the vertex shader from the buffer.
@@ -155,7 +155,7 @@ bool refraction_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating vertex shader");
return false;
R_FALSE
}
// Create the pixel shader from the buffer.
@@ -163,7 +163,7 @@ bool refraction_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating pixel shader");
return false;
R_FALSE
}
// Create the vertex input layout description.
@@ -200,7 +200,7 @@ bool refraction_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating input layout");
return false;
R_FALSE
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
@@ -223,7 +223,7 @@ bool refraction_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating matrix buffer");
return false;
R_FALSE
}
// Create a texture sampler state description.
@@ -246,7 +246,7 @@ bool refraction_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating sampler state");
return false;
R_FALSE
}
// Setup the description of the light dynamic constant buffer that is in the pixel shader.
@@ -263,7 +263,7 @@ bool refraction_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating light buffer");
return false;
R_FALSE
}
// Setup the description of the clip plane dynamic constant buffer that is in the vertex shader.
@@ -279,12 +279,12 @@ bool refraction_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Error creating clip plane buffer");
return false;
R_FALSE
}
LOG_INIT("Refraction shader initialized");
return true;
R_TRUE
}
@@ -404,7 +404,7 @@ bool refraction_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceC
if (FAILED(result))
{
LOG_ERROR("Error mapping matrix buffer");
return false;
R_FALSE
}
// Get a pointer to the data in the constant buffer.
@@ -429,7 +429,7 @@ bool refraction_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceC
if(FAILED(result))
{
LOG_ERROR("Error mapping clip plane buffer");
return false;
R_FALSE
}
// Get a pointer to the data in the clip plane constant buffer.
@@ -455,7 +455,7 @@ bool refraction_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceC
if(FAILED(result))
{
LOG_ERROR("Error mapping light buffer");
return false;
R_FALSE
}
// Get a pointer to the data in the constant buffer.
@@ -476,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
}

View File

@@ -40,7 +40,7 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing texture_shader_class");
return false;
R_FALSE
}
// Create and initialize the normal map shader object.
@@ -49,7 +49,7 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing normal_map_shader_class");
return false;
R_FALSE
}
// Create and initialize the multitexture shader object.
@@ -58,7 +58,7 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing multi_texture_shader_class");
return false;
R_FALSE
}
// Create and initialize the translate shader object.
@@ -67,7 +67,7 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing translate_shader_class");
return false;
R_FALSE
}
// Create and initialize the alpha map shader object.
@@ -76,7 +76,7 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing alpha_map_shader_class");
return false;
R_FALSE
}
// Create and initialize the specular map shader object.
@@ -85,7 +85,7 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing spec_map_shader_class");
return false;
R_FALSE
}
// Create and initialize the transparent shader object.
@@ -94,7 +94,7 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing transparent_shader_class");
return false;
R_FALSE
}
// Create and initialize the light shader object.
@@ -103,7 +103,7 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing light_shader_class");
return false;
R_FALSE
}
// Create and initialize the light map shader object.
@@ -112,7 +112,7 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing light_map_shader_class");
return false;
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,21 +128,21 @@ 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;
@@ -150,7 +150,7 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing skybox_shader_class");
return false;
R_FALSE
}
depth_shader_ = new depth_shader_class;
@@ -158,12 +158,12 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing depth_shader_class");
return false;
R_FALSE
}
LOG_INIT("shader_manager_class initialized");
return true;
R_TRUE
}
void shader_manager_class::shutdown()
@@ -301,10 +301,10 @@ bool shader_manager_class::render_texture_shader(ID3D11DeviceContext* deviceCont
if (!result)
{
LOG_ERROR("Error rendering texture_shader_class");
return false;
R_FALSE
}
return true;
R_TRUE
}
bool shader_manager_class::render_normal_map_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
@@ -316,10 +316,10 @@ bool shader_manager_class::render_normal_map_shader(ID3D11DeviceContext* deviceC
if (!result)
{
LOG_ERROR("Error rendering normal_map_shader_class");
return false;
R_FALSE
}
return true;
R_TRUE
}
bool shader_manager_class::render_multitexture_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
@@ -331,10 +331,10 @@ bool shader_manager_class::render_multitexture_shader(ID3D11DeviceContext* devic
if (!result)
{
LOG_ERROR("Error rendering multi_texture_shader_class");
return false;
R_FALSE
}
return true;
R_TRUE
}
bool shader_manager_class::render_translate_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
@@ -346,10 +346,10 @@ bool shader_manager_class::render_translate_shader(ID3D11DeviceContext* deviceCo
if (!result)
{
LOG_ERROR("Error rendering translate_shader_class");
return false;
R_FALSE
}
return true;
R_TRUE
}
bool shader_manager_class::render_alpha_map_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
@@ -361,10 +361,10 @@ bool shader_manager_class::render_alpha_map_shader(ID3D11DeviceContext* deviceCo
if (!result)
{
LOG_ERROR("Error rendering alpha_map_shader_class");
return false;
R_FALSE
}
return true;
R_TRUE
}
bool shader_manager_class::render_spec_map_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
@@ -378,10 +378,10 @@ bool shader_manager_class::render_spec_map_shader(ID3D11DeviceContext* deviceCon
if (!result)
{
LOG_ERROR("Error rendering spec_map_shader_class");
return false;
R_FALSE
}
return true;
R_TRUE
}
bool shader_manager_class::render_transparent_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
@@ -393,10 +393,10 @@ bool shader_manager_class::render_transparent_shader(ID3D11DeviceContext* device
if (!result)
{
LOG_ERROR("Error rendering transparent_shader_class");
return false;
R_FALSE
}
return true;
R_TRUE
}
bool shader_manager_class::renderlight_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
@@ -408,10 +408,10 @@ bool shader_manager_class::renderlight_shader(ID3D11DeviceContext* deviceContext
if (!result)
{
LOG_ERROR("Error rendering light_shader_class");
return false;
R_FALSE
}
return true;
R_TRUE
}
bool shader_manager_class::renderlight_map_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
@@ -423,10 +423,10 @@ bool shader_manager_class::renderlight_map_shader(ID3D11DeviceContext* deviceCon
if (!result)
{
LOG_ERROR("Error rendering light_map_shader_class");
return false;
R_FALSE
}
return true;
R_TRUE
}
bool shader_manager_class::render_refraction_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
@@ -438,10 +438,10 @@ bool shader_manager_class::render_refraction_shader(ID3D11DeviceContext* deviceC
if (!result)
{
LOG_ERROR("Error rendering refraction_shader_class");
return false;
R_FALSE
}
return true;
R_TRUE
}
bool shader_manager_class::render_water_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
@@ -455,10 +455,10 @@ bool shader_manager_class::render_water_shader(ID3D11DeviceContext* deviceContex
if (!result)
{
LOG_ERROR("Error rendering water_shader_class");
return false;
R_FALSE
}
return true;
R_TRUE
}
bool shader_manager_class::render_cel_shading_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
@@ -470,10 +470,10 @@ bool shader_manager_class::render_cel_shading_shader(ID3D11DeviceContext* device
if (!result)
{
LOG_ERROR("Error rendering celshade_class");
return false;
R_FALSE
}
return true;
R_TRUE
}
bool shader_manager_class::render_sunlight_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
@@ -485,10 +485,10 @@ bool shader_manager_class::render_sunlight_shader(ID3D11DeviceContext* deviceCon
if (!result)
{
LOG_ERROR("Error rendering sunlight_shader_class");
return false;
R_FALSE
}
return true;
R_TRUE
}
bool shader_manager_class::render_skybox_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
@@ -500,10 +500,10 @@ bool shader_manager_class::render_skybox_shader(ID3D11DeviceContext* deviceConte
if (!result)
{
LOG_ERROR("Error rendering skybox_shader_class");
return false;
R_FALSE
}
return true;
R_TRUE
}
bool shader_manager_class::render_depth_shader(
@@ -521,8 +521,8 @@ bool shader_manager_class::render_depth_shader(
if (!result)
{
LOG_ERROR("Error rendering depth_shader_class");
return false;
R_FALSE
}
return true;
R_TRUE
}

View File

@@ -42,7 +42,7 @@ bool skybox_shader_class::Initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Failed to copy string");
return false;
R_FALSE
}
// Set the filename of the pixel shader.
@@ -50,19 +50,19 @@ bool skybox_shader_class::Initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Failed to copy string");
return false;
R_FALSE
}
// Initialize the vertex and pixel shaders.
result = InitializeShader(device, hwnd, vsFilename, psFilename);
if (!result)
{
LOG_ERROR("Failed to initialize shader");
return false;
R_FALSE
}
LOG_INIT("skybox_shader_class initialized");
return true;
R_TRUE
}
@@ -85,13 +85,13 @@ bool skybox_shader_class::Render(ID3D11DeviceContext* deviceContext, int indexCo
if (!result)
{
LOG_ERROR("Failed to set shader parameters");
return false;
R_FALSE
}
// Now render the prepared buffers with the shader.
RenderShader(deviceContext, indexCount);
return true;
R_TRUE
}
@@ -126,7 +126,7 @@ bool skybox_shader_class::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
{
LOG_ERROR("Failed to compile shader");
}
return false;
R_FALSE
}
// Compile the pixel shader code.
@@ -141,7 +141,7 @@ bool skybox_shader_class::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
{
LOG_ERROR("Failed to compile shader");
}
return false;
R_FALSE
}
// Create the vertex shader from the buffer.
@@ -149,7 +149,7 @@ bool skybox_shader_class::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Failed to create vertex shader");
return false;
R_FALSE
}
// Create the pixel shader from the buffer.
@@ -157,7 +157,7 @@ bool skybox_shader_class::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Failed to create pixel shader");
return false;
R_FALSE
}
// Create the vertex input layout description.
@@ -193,7 +193,7 @@ bool skybox_shader_class::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Failed to create input layout");
return false;
R_FALSE
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
@@ -223,7 +223,7 @@ bool skybox_shader_class::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Failed to create sampler state");
return false;
R_FALSE
}
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
@@ -239,7 +239,7 @@ bool skybox_shader_class::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Failed to create matrix buffer");
return false;
R_FALSE
}
// Setup the description of the dynamic sunlight constant buffer that is in the pixel shader.
@@ -255,12 +255,12 @@ bool skybox_shader_class::InitializeShader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Failed to create sunlight buffer");
return false;
R_FALSE
}
LOG_INIT("Shader initialized");
return true;
R_TRUE
}
@@ -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)

View File

@@ -37,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
}
@@ -79,13 +79,13 @@ bool spec_map_shader_class::render(ID3D11DeviceContext* deviceContext, int index
if (!result)
{
LOG_ERROR("Failed to set shader parameters in SpecMapShaderClass");
return false;
R_FALSE
}
// Now render the prepared buffers with the shader.
render_shader(deviceContext, indexCount);
return true;
R_TRUE
}
@@ -124,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.
@@ -143,7 +143,7 @@ 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.
@@ -151,7 +151,7 @@ bool spec_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
if (FAILED(result))
{
LOG_ERROR("Failed to create vertex shader in SpecMapShaderClass");
return false;
R_FALSE
}
// Create the pixel shader from the buffer.
@@ -159,7 +159,7 @@ bool spec_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
if (FAILED(result))
{
LOG_ERROR("Failed to create pixel shader in SpecMapShaderClass");
return false;
R_FALSE
}
// Create the vertex input layout description.
@@ -212,7 +212,7 @@ bool spec_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
if (FAILED(result))
{
LOG_ERROR("Failed to create input layout in SpecMapShaderClass");
return false;
R_FALSE
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
@@ -235,7 +235,7 @@ bool spec_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
if (FAILED(result))
{
LOG_ERROR("Failed to create uniform buffer in SpecMapShaderClass");
return false;
R_FALSE
}
// Create a texture sampler state description.
@@ -258,7 +258,7 @@ bool spec_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
if (FAILED(result))
{
LOG_ERROR("Failed to create sample state in SpecMapShaderClass");
return false;
R_FALSE
}
// Setup the description of the light dynamic constant buffer that is in the pixel shader.
@@ -274,7 +274,7 @@ bool spec_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
if (FAILED(result))
{
LOG_ERROR("Failed to create light buffer in SpecMapShaderClass");
return false;
R_FALSE
}
// Setup the description of the camera dynamic constant buffer that is in the vertex shader.
@@ -290,10 +290,10 @@ bool spec_map_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
if (FAILED(result))
{
LOG_ERROR("Failed to create camera buffer in SpecMapShaderClass");
return false;
R_FALSE
}
return true;
R_TRUE
}
@@ -411,7 +411,7 @@ bool spec_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCon
if (FAILED(result))
{
LOG_ERROR("Failed to map mapped buffer in SpecMapShaderClass");
return false;
R_FALSE
}
// Get a pointer to the data in the constant buffer.
@@ -441,7 +441,7 @@ bool spec_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCon
if (FAILED(result))
{
LOG_ERROR("Failed to map lighting buffer in SpecMapShaderClass");
return false;
R_FALSE
}
// Get a pointer to the data in the constant buffer.
@@ -467,7 +467,7 @@ bool spec_map_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCon
if (FAILED(result))
{
LOG_ERROR("Failed to map camera buffer in SpecMapShaderClass");
return false;
R_FALSE
}
// Get a pointer to the data in the constant buffer.
@@ -485,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
}

View File

@@ -42,7 +42,7 @@ bool sunlight_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Failed to copy string");
return false;
R_FALSE
}
// Set the filename of the pixel shader.
@@ -50,19 +50,19 @@ bool sunlight_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Failed to copy string");
return false;
R_FALSE
}
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
LOG_ERROR("Failed to initialize shader");
return false;
R_FALSE
}
LOG_INIT("SunLightShaderClass initialized");
return true;
R_TRUE
}
@@ -85,13 +85,13 @@ bool sunlight_shader_class::render(ID3D11DeviceContext* deviceContext, int index
if (!result)
{
LOG_ERROR("Failed to set shader parameters");
return false;
R_FALSE
}
// Now render the prepared buffers with the shader.
render_shader(deviceContext, indexCount);
return true;
R_TRUE
}
@@ -126,7 +126,7 @@ bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
{
LOG_ERROR("Failed to compile shader");
}
return false;
R_FALSE
}
// Compile the pixel shader code.
@@ -141,7 +141,7 @@ bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
{
LOG_ERROR("Failed to compile shader");
}
return false;
R_FALSE
}
// Create the vertex shader from the buffer.
@@ -149,7 +149,7 @@ bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
if (FAILED(result))
{
LOG_ERROR("Failed to create vertex shader");
return false;
R_FALSE
}
// Create the pixel shader from the buffer.
@@ -157,7 +157,7 @@ bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
if (FAILED(result))
{
LOG_ERROR("Failed to create pixel shader");
return false;
R_FALSE
}
// Create the vertex input layout description.
@@ -193,7 +193,7 @@ bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
if (FAILED(result))
{
LOG_ERROR("Failed to create input layout");
return false;
R_FALSE
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
@@ -223,7 +223,7 @@ bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
if (FAILED(result))
{
LOG_ERROR("Failed to create sampler state");
return false;
R_FALSE
}
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
@@ -239,7 +239,7 @@ bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
if (FAILED(result))
{
LOG_ERROR("Failed to create matrix buffer");
return false;
R_FALSE
}
// Setup the description of the dynamic sunlight constant buffer that is in the pixel shader.
@@ -255,12 +255,12 @@ bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, W
if (FAILED(result))
{
LOG_ERROR("Failed to create sunlight buffer");
return false;
R_FALSE
}
LOG_INIT("Shader initialized");
return true;
R_TRUE
}
@@ -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)

View File

@@ -34,7 +34,7 @@ bool texture_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Error copying stirng");
return false;
R_FALSE
}
// Set the filename of the pixel shader.
@@ -42,7 +42,7 @@ bool texture_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Error copying stirng");
return false;
R_FALSE
}
// initialize the vertex and pixel shaders.
@@ -50,12 +50,12 @@ bool texture_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Error initializing shader");
return false;
R_FALSE
}
LOG_INIT("Texture shader initialized");
return true;
R_TRUE
}
void texture_shader_class::shutdown()
@@ -77,13 +77,13 @@ bool texture_shader_class::render(ID3D11DeviceContext* deviceContext, int indexC
if (!result)
{
LOG_ERROR("Error setting shader parameters");
return false;
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)
@@ -120,7 +120,7 @@ bool texture_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WC
LOG_ERROR("Error compiling shader");
}
return false;
R_FALSE
}
// Compile the pixel shader code.
@@ -139,7 +139,7 @@ bool texture_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WC
LOG_ERROR("Error compiling shader");
}
return false;
R_FALSE
}
// Create the vertex shader from the buffer.
@@ -147,7 +147,7 @@ bool texture_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WC
if (FAILED(result))
{
LOG_ERROR("Error creating vertex shader");
return false;
R_FALSE
}
// Create the pixel shader from the buffer.
@@ -155,7 +155,7 @@ bool texture_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WC
if (FAILED(result))
{
LOG_ERROR("Error creating pixel shader");
return false;
R_FALSE
}
// Create the vertex input layout description.
// This setup needs to match the VertexType stucture in the ModelClass and in the shader.
@@ -184,7 +184,7 @@ bool texture_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WC
if (FAILED(result))
{
LOG_ERROR("Error creating input layout");
return false;
R_FALSE
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
@@ -207,7 +207,7 @@ bool texture_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WC
if (FAILED(result))
{
LOG_ERROR("Error creating constant buffer");
return false;
R_FALSE
}
// Create a texture sampler state description.
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
@@ -229,12 +229,12 @@ bool texture_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WC
if (FAILED(result))
{
LOG_ERROR("Error creating sampler state");
return false;
R_FALSE
}
LOG_INIT("Shader initialized");
return true;
R_TRUE
}
void texture_shader_class::shutdown_shader()
@@ -335,7 +335,7 @@ bool texture_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceCont
if (FAILED(result))
{
LOG_ERROR("Error mapping constant buffer");
return false;
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)

View File

@@ -36,7 +36,7 @@ bool translate_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Failed to copy vsFilename");
return false;
R_FALSE
}
// Set the filename of the pixel shader.
@@ -44,7 +44,7 @@ bool translate_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Failed to copy psFilename");
return false;
R_FALSE
}
// initialize the vertex and pixel shaders.
@@ -52,12 +52,12 @@ bool translate_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Failed to initialize shader");
return false;
R_FALSE
}
LOG_INIT("translate_shader_class initialized");
return true;
R_TRUE
}
@@ -80,13 +80,13 @@ bool translate_shader_class::render(ID3D11DeviceContext * deviceContext, int ind
if (!result)
{
LOG_ERROR("Failed to set shader parameters");
return false;
R_FALSE
}
// Now render the prepared buffers with the shader.
render_shader(deviceContext, indexCount);
return true;
R_TRUE
}
@@ -126,7 +126,7 @@ bool translate_shader_class::initialize_shader(ID3D11Device * device, HWND hwnd,
LOG_ERROR("Failed to compile shader");
}
return false;
R_FALSE
}
// Compile the pixel shader code.
@@ -145,7 +145,7 @@ bool translate_shader_class::initialize_shader(ID3D11Device * device, HWND hwnd,
LOG_ERROR("Failed to compile shader");
}
return false;
R_FALSE
}
// Create the vertex shader from the buffer.
@@ -153,7 +153,7 @@ bool translate_shader_class::initialize_shader(ID3D11Device * device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Failed to create vertex shader");
return false;
R_FALSE
}
// Create the pixel shader from the buffer.
@@ -161,7 +161,7 @@ bool translate_shader_class::initialize_shader(ID3D11Device * device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Failed to create pixel shader");
return false;
R_FALSE
}
// Create the vertex input layout description.
@@ -190,7 +190,7 @@ bool translate_shader_class::initialize_shader(ID3D11Device * device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Failed to create input layout");
return false;
R_FALSE
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
@@ -213,7 +213,7 @@ bool translate_shader_class::initialize_shader(ID3D11Device * device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Failed to create matrix buffer");
return false;
R_FALSE
}
// Create a texture sampler state description.
@@ -236,7 +236,7 @@ bool translate_shader_class::initialize_shader(ID3D11Device * device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Failed to create sampler state");
return false;
R_FALSE
}
// Setup the description of the texture translation dynamic constant buffer that is in the pixel shader.
@@ -252,12 +252,12 @@ bool translate_shader_class::initialize_shader(ID3D11Device * device, HWND hwnd,
if (FAILED(result))
{
LOG_ERROR("Failed to create translate buffer");
return false;
R_FALSE
}
LOG_INIT("Translate shader initialized");
return true;
R_TRUE
}
@@ -369,7 +369,7 @@ bool translate_shader_class::set_shader_parameters(ID3D11DeviceContext * deviceC
if (FAILED(result))
{
LOG_ERROR("Failed to map matrix buffer");
return false;
R_FALSE
}
// Get a pointer to the data in the constant buffer.
@@ -397,7 +397,7 @@ bool translate_shader_class::set_shader_parameters(ID3D11DeviceContext * deviceC
if (FAILED(result))
{
LOG_ERROR("Failed to map translate buffer");
return false;
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
}

View File

@@ -36,7 +36,7 @@ bool transparent_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Failed to copy vertex shader filename");
return false;
R_FALSE
}
// Set the filename of the pixel shader.
@@ -44,7 +44,7 @@ bool transparent_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (error != 0)
{
LOG_ERROR("Failed to copy pixel shader filename");
return false;
R_FALSE
}
// Initialize the vertex and pixel shaders.
@@ -52,12 +52,12 @@ bool transparent_shader_class::initialize(ID3D11Device* device, HWND hwnd)
if (!result)
{
LOG_ERROR("Failed to initialize shader");
return false;
R_FALSE
}
LOG_INIT("transparent_shader_class initialized");
return true;
R_TRUE
}
@@ -80,13 +80,13 @@ bool transparent_shader_class::render(ID3D11DeviceContext* deviceContext, int in
if (!result)
{
LOG_ERROR("Failed to set shader parameters");
return false;
R_FALSE
}
// Now render the prepared buffers with the shader.
render_shader(deviceContext, indexCount);
return true;
R_TRUE
}
@@ -126,7 +126,7 @@ bool transparent_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd
LOG_ERROR("Failed to compile vertex shader");
}
return false;
R_FALSE
}
// Compile the pixel shader code.
@@ -145,7 +145,7 @@ bool transparent_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd
LOG_ERROR("Failed to compile pixel shader");
}
return false;
R_FALSE
}
// Create the vertex shader from the buffer.
@@ -153,7 +153,7 @@ bool transparent_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd
if (FAILED(result))
{
LOG_ERROR("Failed to create vertex shader");
return false;
R_FALSE
}
// Create the pixel shader from the buffer.
@@ -161,7 +161,7 @@ bool transparent_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd
if (FAILED(result))
{
LOG_ERROR("Failed to create pixel shader");
return false;
R_FALSE
}
// Create the vertex input layout description.
@@ -190,7 +190,7 @@ bool transparent_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd
if (FAILED(result))
{
LOG_ERROR("Failed to create input layout");
return false;
R_FALSE
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
@@ -213,7 +213,7 @@ bool transparent_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd
if (FAILED(result))
{
LOG_ERROR("Failed to create matrix buffer");
return false;
R_FALSE
}
// Create a texture sampler state description.
@@ -236,7 +236,7 @@ bool transparent_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd
if (FAILED(result))
{
LOG_ERROR("Failed to create sampler state");
return false;
R_FALSE
}
// Setup the description of the transparent dynamic constant buffer that is in the pixel shader.
@@ -252,12 +252,12 @@ bool transparent_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd
if (FAILED(result))
{
LOG_ERROR("Failed to create transparent buffer");
return false;
R_FALSE
}
LOG_INIT("Transparent shader initialized");
return true;
R_TRUE
}
@@ -368,7 +368,7 @@ bool transparent_shader_class::set_shader_parameters(ID3D11DeviceContext* device
if (FAILED(result))
{
LOG_ERROR("Failed to map matrix buffer");
return false;
R_FALSE
}
// Get a pointer to the data in the constant buffer.
@@ -396,7 +396,7 @@ bool transparent_shader_class::set_shader_parameters(ID3D11DeviceContext* device
if (FAILED(result))
{
LOG_ERROR("Failed to map transparent buffer");
return false;
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
}

View File

@@ -37,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
}
@@ -79,13 +79,13 @@ bool water_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCou
if (!result)
{
LOG_ERROR("Failed to set shader parameters in water shader");
return false;
R_FALSE
}
// Now render the prepared buffers with the shader.
render_shader(deviceContext, indexCount);
return true;
R_TRUE
}
@@ -124,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.
@@ -143,7 +143,7 @@ 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.
@@ -151,7 +151,7 @@ bool water_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Error creating vertex shader in water shader");
return false;
R_FALSE
}
// Create the pixel shader from the buffer.
@@ -159,7 +159,7 @@ bool water_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Error creating pixel shader in water shader");
return false;
R_FALSE
}
// Create the vertex input layout description.
@@ -188,7 +188,7 @@ bool water_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Error creating input layout in water shader");
return false;
R_FALSE
}
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
@@ -211,7 +211,7 @@ bool water_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Error creating matrix buffer in water shader");
return false;
R_FALSE
}
// Create a texture sampler state description.
@@ -234,7 +234,7 @@ bool water_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Error creating sampler state in water shader");
return false;
R_FALSE
}
// Setup the description of the reflection dynamic constant buffer that is in the vertex shader.
@@ -250,7 +250,7 @@ bool water_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Error creating reflection buffer in water shader");
return false;
R_FALSE
}
// Setup the description of the water dynamic constant buffer that is in the pixel shader.
@@ -266,10 +266,10 @@ bool water_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHA
if (FAILED(result))
{
LOG_ERROR("Error creating water buffer in water shader");
return false;
R_FALSE
}
return true;
R_TRUE
}
@@ -388,7 +388,7 @@ bool water_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
if (FAILED(result))
{
LOG_ERROR("Error mapping matrix buffer in water shader");
return false;
R_FALSE
}
// Get a pointer to the data in the constant buffer.
@@ -413,7 +413,7 @@ bool water_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
if (FAILED(result))
{
LOG_ERROR("Error mapping reflection buffer in water shader");
return false;
R_FALSE
}
// Get a pointer to the data in the constant buffer.
@@ -445,7 +445,7 @@ bool water_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContex
if (FAILED(result))
{
LOG_ERROR("Error mapping water buffer in water shader");
return false;
R_FALSE
}
// Get a pointer to the data in the constant buffer.
@@ -465,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)

View File

@@ -98,14 +98,14 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!direct_3d_)
{
LOG_ERROR("Could not create the Direct3D object");
return false;
R_FALSE
}
result = direct_3d_->initialize(screen_width_, screen_height_, vsync_enabled_, hwnd, full_screen, screen_depth, screen_near);
if (!result)
{
LOG_ERROR("Could not initialize Direct3D");
return false;
R_FALSE
}
// Create the camera object.
@@ -113,14 +113,14 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!camera_)
{
LOG_ERROR("Could not create the camera object");
return false;
R_FALSE
}
sun_camera_ = new camera_class;
if (!sun_camera_)
{
LOG_ERROR("Could not create the sun camera object");
return false;
R_FALSE
}
sun_camera_->set_position(0.0f,0.0f,0.0f);
@@ -143,7 +143,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!result)
{
LOG_ERROR("Could not initialize the font shader object");
return false;
R_FALSE
}
// Create and initialize the font object.
@@ -153,7 +153,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!result)
{
LOG_ERROR("Could not initialize the font object");
return false;
R_FALSE
}
// Create and initialize the render to texture object.
@@ -163,7 +163,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!result)
{
LOG_ERROR("Could not initialize the render texture object");
return false;
R_FALSE
}
//ImVec2 availableSize = ImGui::GetContentRegionAvail();
@@ -174,7 +174,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!result)
{
LOG_ERROR("Could not initialize the render texture object");
return false;
R_FALSE
}
// Create and initialize the display plane object.
@@ -184,7 +184,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!result)
{
LOG_ERROR("Could not initialize the display plane object");
return false;
R_FALSE
}
@@ -199,7 +199,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!result)
{
LOG_ERROR("Could not initialize the sprite object");
return false;
R_FALSE
}
// Set the initial mouse strings.
@@ -217,7 +217,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!result)
{
LOG_ERROR("Could not initialize the mouse strings");
return false;
R_FALSE
}
}
@@ -231,7 +231,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!result)
{
LOG_ERROR("Could not initialize the bitmap object");
return false;
R_FALSE
}
// Set the file name of the model.
@@ -251,7 +251,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (FAILED(Hresult))
{
LOG_ERROR("Failed to load texture: " + std::string(textureFilename.begin(), textureFilename.end()));
return false;
R_FALSE
}
CubeTextures.diffuse.push_back(texture);
}
@@ -264,7 +264,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!result)
{
LOG_ERROR("Could not initialize the model object");
return false;
R_FALSE
}
// Create and initialize the light object.
@@ -335,7 +335,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!result)
{
LOG_ERROR("Could not initialize the shader manager object");
return false;
R_FALSE
}
// Set the initial render count string.
@@ -348,7 +348,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!result)
{
LOG_ERROR("Could not initialize the render count string");
return false;
R_FALSE
}
// Create and initialize the model list object.
@@ -370,7 +370,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (FAILED(Hresult))
{
LOG_ERROR("Failed to load texture: " + std::string(textureFilename.begin(), textureFilename.end()));
return false;
R_FALSE
}
BathTextures.diffuse.push_back(texture);
}
@@ -385,7 +385,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!result)
{
MessageBox(hwnd, L"Could not initialize the bath model object.", L"Error", MB_OK);
return false;
R_FALSE
}
// Set the file names of the water model.
@@ -405,7 +405,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (FAILED(Hresult))
{
LOG_ERROR("Failed to load texture: " + std::string(textureFilename.begin(), textureFilename.end()));
return false;
R_FALSE
}
WaterTextures.diffuse.push_back(texture);
}
@@ -417,7 +417,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!result)
{
MessageBox(hwnd, L"Could not initialize the water model object.", L"Error", MB_OK);
return false;
R_FALSE
}
// Create and initialize the refraction render to texture object.
@@ -427,7 +427,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!result)
{
MessageBox(hwnd, L"Could not initialize the refraction render texture object.", L"Error", MB_OK);
return false;
R_FALSE
}
// Create and initialize the reflection render to texture object.
@@ -437,7 +437,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!result)
{
MessageBox(hwnd, L"Could not initialize the reflection render texture object.", L"Error", MB_OK);
return false;
R_FALSE
}
// Set the height of the water.
@@ -453,7 +453,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!result)
{
LOG_ERROR("Could not initialize the timer object");
return false;
R_FALSE
}
// Create the position class object.
@@ -475,21 +475,21 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
if (!result)
{
LOG_ERROR("Could not initialize the fps string");
return false;
R_FALSE
}
shadow_map_ = new shadow_map();
if (!shadow_map_->initialize(direct_3d_->get_device(), 2048, 2048))
{
LOG_ERROR("Could not initialize the shadow map object");
return false;
R_FALSE
}
stats_ = new stats();
if (!stats_->initialize(this))
{
LOG_ERROR("Could not initialize the stats object");
return false;
R_FALSE
}
physics_ = new physics;
@@ -505,14 +505,17 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
std::string m_lastError;
if (FMOD_result != FMOD_OK) {
m_lastError = "<EFBFBD>chec de la cr<63>ation du syst<73>me FMOD: " + std::to_string(FMOD_result);
return false;
LOG_ERROR(m_lastError);
R_FALSE
}
FMOD_result = sound_system_->init(512, FMOD_INIT_NORMAL | FMOD_INIT_3D_RIGHTHANDED, nullptr);
if (FMOD_result != FMOD_OK) {
m_lastError = "<EFBFBD>chec de l'initialisation du syst<73>me FMOD: " + std::to_string(FMOD_result);
LOG_ERROR(m_lastError);
sound_system_->release();
sound_system_ = nullptr;
R_FALSE
}
entity_manager_->SetCamera(camera_);
@@ -526,13 +529,13 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
catch (const std::exception& e)
{
LOG_ERROR(std::string("Exception caught during initialization: ") + e.what() );
return false;
R_FALSE
}
LOG_INIT("Application class initialized");
return true;
R_TRUE
}
void application_class::shutdown()
@@ -835,12 +838,12 @@ bool application_class::frame(input_class* Input)
scrollDown = Input->IsScrollDown();
// Check if the a(q), d, w(z), s, q(a), e have been pressed, if so move the camera accordingly.
buttonQ = Input->IsAPressed();
buttonD = Input->IsDPressed();
buttonZ = Input->IsWPressed();
buttonS = Input->IsSPressed();
buttonA = Input->IsQPressed();
buttonE = Input->IsEPressed();
buttonQ = Input->is_key_pressed(DIK_A);
buttonD = Input->is_key_pressed(DIK_D);
buttonZ = Input->is_key_pressed(DIK_W);
buttonS = Input->is_key_pressed(DIK_S);
buttonA = Input->is_key_pressed(DIK_Q);
buttonE = Input->is_key_pressed(DIK_E);
position_->MoveCamera(buttonZ, buttonS, buttonQ, buttonD, buttonE, buttonA, scrollUp, scrollDown, rightMouseDown);
position_->GetPosition(positionX, positionY, positionZ);
@@ -883,7 +886,7 @@ bool application_class::frame(input_class* Input)
if (!result)
{
LOG_ERROR("Could not render the graphics scene");
return false;
R_FALSE
}
// Update the frames per second each frame.
@@ -891,7 +894,7 @@ bool application_class::frame(input_class* Input)
if (!result)
{
LOG_ERROR("Could not update the frames per second");
return false;
R_FALSE
}
// Update the rotation variable each frame.
@@ -912,14 +915,14 @@ bool application_class::frame(input_class* Input)
result = render_refraction_to_texture();
if (!result)
{
return false;
R_FALSE
}
// render the reflection of the scene to a texture.
result = render_reflection_to_texture();
if (!result)
{
return false;
R_FALSE
}
inputs_.key_left = Input->IsLeftArrowPressed();
@@ -932,7 +935,7 @@ bool application_class::frame(input_class* Input)
if (!result)
{
LOG_ERROR("Could not render the scene to the render texture");
return false;
R_FALSE
}
// Update the mouse strings each frame.
@@ -940,7 +943,7 @@ bool application_class::frame(input_class* Input)
if (!result)
{
LOG_ERROR("Could not update the mouse strings");
return false;
R_FALSE
}
// Update the sprite object using the frame time.
@@ -953,7 +956,7 @@ bool application_class::frame(input_class* Input)
textureTranslation -= 1.0f;
}
return true;
R_TRUE
}
bool application_class::render_refraction_to_texture()
@@ -999,14 +1002,14 @@ bool application_class::render_refraction_to_texture()
bath_model_->GetTexture(TextureType::Diffuse,0), lights_[0]->GetDirection(), ambientColor, diffuseColor, lightPosition, clipPlane);
if (!result)
{
return false;
R_FALSE
}
// Reset the render target back to the original back buffer and not the render to texture anymore. And reset the viewport back to the original.
direct_3d_->set_back_buffer_render_target();
direct_3d_->reset_viewport();
return true;
R_TRUE
}
bool application_class::render_reflection_to_texture()
@@ -1027,7 +1030,7 @@ bool application_class::render_reflection_to_texture()
direct_3d_->set_back_buffer_render_target();
direct_3d_->reset_viewport();
return true;
R_TRUE
}
bool application_class::render_scene_to_texture(float rotation)
@@ -1055,14 +1058,14 @@ bool application_class::render_scene_to_texture(float rotation)
model_->GetTexture(TextureType::Diffuse,0));
if (!result)
{
return false;
R_FALSE
}
// Reset the render target back to the original back buffer and not the render to texture anymore. And reset the viewport back to the original.
direct_3d_->set_back_buffer_render_target();
direct_3d_->reset_viewport();
return true;
R_TRUE
}
bool application_class::render(float rotation, float x, float y, float z, float textureTranslation)
@@ -1152,7 +1155,7 @@ bool application_class::render(float rotation, float x, float y, float z, float
if (!result)
{
LOG_ERROR("Could not render the model using any shader");
return false;
R_FALSE
}
// Reset the active camera to the main camera.
@@ -1165,7 +1168,7 @@ bool application_class::render(float rotation, float x, float y, float z, float
// if (!result)
// {
// LOG_ERROR("Could not render the model using any shader");
// return false;
// R_FALSE
// }
// stats_->update_geometric_stats();
@@ -1175,7 +1178,7 @@ bool application_class::render(float rotation, float x, float y, float z, float
if (!result)
{
LOG_ERROR("Could not update the render count string");
return false;
R_FALSE
}
@@ -1190,7 +1193,7 @@ bool application_class::render(float rotation, float x, float y, float z, float
bath_model_->GetTexture(TextureType::Diffuse,0), diffuseColor, lightPosition, ambientColor);
if (!result)
{
return false;
R_FALSE
}
// Reset the world matrix.
@@ -1211,7 +1214,7 @@ bool application_class::render(float rotation, float x, float y, float z, float
water_translation_, 0.01f);
if (!result)
{
return false;
R_FALSE
}
// Disable the Z buffer and enable alpha blending for 2D rendering.
@@ -1229,7 +1232,7 @@ bool application_class::render(float rotation, float x, float y, float z, float
if (!result)
{
LOG_ERROR("Could not render the render count text string using the font shader");
return false;
R_FALSE
}
// render the fps text string using the font shader.
@@ -1240,7 +1243,7 @@ bool application_class::render(float rotation, float x, float y, float z, float
if (!result)
{
LOG_ERROR("Could not render the fps text string using the font shader");
return false;
R_FALSE
}
// render the mouse text strings using the font shader.
@@ -1253,7 +1256,7 @@ bool application_class::render(float rotation, float x, float y, float z, float
if (!result)
{
LOG_ERROR("Could not render the mouse text strings using the font shader");
return false;
R_FALSE
}
}
@@ -1261,7 +1264,7 @@ bool application_class::render(float rotation, float x, float y, float z, float
result = sprite_->Render(direct_3d_->get_device_context());
if (!result)
{
return false;
R_FALSE
}
// render the sprite with the texture shader.
@@ -1270,7 +1273,7 @@ bool application_class::render(float rotation, float x, float y, float z, float
if (!result)
{
LOG_ERROR("Could not render the sprite using the texture shader");
return false;
R_FALSE
}
// Turn off alpha blending after rendering the 2D text.
@@ -1291,7 +1294,7 @@ bool application_class::render(float rotation, float x, float y, float z, float
// R<>initialiser la cible de rendu au back buffer.
direct_3d_->set_back_buffer_render_target();
return true;
R_TRUE
}
d_3d_class* application_class::get_direct_3d()
@@ -1364,7 +1367,7 @@ void application_class::generate_terrain()
for (int i = 0; i < gridSizeX; i++) {
for (int j = 0; j < gridSizeZ; j++) {
// Cr<43>er une entit<69>
auto entity = entity_manager_->CreateEntity();
auto entity = CREATE_ENTITY
// Ajouter un composant d'identit<69>
auto identity = entity->AddComponent<ecs::IdentityComponent>(object_id_++);
@@ -1383,7 +1386,7 @@ void application_class::generate_terrain()
// Ajouter un composant de shader
auto shader = entity->AddComponent<ecs::ShaderComponent>();
shader->SetActiveShader(ecs::ShaderType::SUNLIGHT);
shader->SetActiveShader(SHD_SUN);
}
}
}
@@ -1397,7 +1400,7 @@ void application_class::generate_terrain()
void application_class::add_kobject(std::wstring& filepath)
{
std::lock_guard<std::mutex> lock(objects_mutex_);
LOG_INFO("Adding object", __FILE__, __LINE__);
LOG_INFO("Adding object");
char modelFilename[128];
TextureContainer KobjectsTextures;
@@ -1428,7 +1431,7 @@ void application_class::add_kobject(std::wstring& filepath)
auto it = g_model_cache.find(modelKey);
if (it != g_model_cache.end()) {
// Utiliser le mod<6F>le existant du cache
LOG_INFO("Using cached model for " + modelKey, __FILE__, __LINE__);
LOG_INFO("Using cached model for " + modelKey);
sharedModel = it->second;
}
else {
@@ -1446,11 +1449,11 @@ void application_class::add_kobject(std::wstring& filepath)
// Ajouter le mod<6F>le au cache
g_model_cache[modelKey] = sharedModel;
LOG_INFO("Added model to cache: " + modelKey, __FILE__, __LINE__);
LOG_INFO("Added model to cache: " + modelKey);
}
// Cr<43>er une nouvelle entit<69>
auto entity = entity_manager_->CreateEntity();
auto entity = CREATE_ENTITY
// Ajouter un composant d'identit<69>
auto identity = entity->AddComponent<ecs::IdentityComponent>(object_id_++);
@@ -1469,13 +1472,13 @@ void application_class::add_kobject(std::wstring& filepath)
// Ajouter un composant de shader
auto shader = entity->AddComponent<ecs::ShaderComponent>();
shader->SetActiveShader(ecs::ShaderType::LIGHTING);
shader->SetActiveShader(SHD_LIGHT);
// Stocker le chemin du mod<6F>le
auto modelPath = entity->AddComponent<ecs::ModelPathComponent>();
modelPath->SetPath(filepath);
LOG_INFO("ECS entity created with ID: " + std::to_string(identity->GetId()), __FILE__, __LINE__);
LOG_INFO("ECS entity created with ID: " + std::to_string(identity->GetId()));
update_stats_after_modification();
}
@@ -1483,7 +1486,7 @@ void application_class::add_kobject(std::wstring& filepath)
void application_class::add_cube()
{
std::lock_guard<std::mutex> lock(objects_mutex_);
LOG_INFO("Adding cube", __FILE__, __LINE__);
LOG_INFO("Adding cube");
std::string model_name = "assets/Model/TXT/cube.txt";
std::shared_ptr<model_class> sharedModel;
@@ -1491,7 +1494,7 @@ void application_class::add_cube()
auto it = g_model_cache.find(model_name);
if (it != g_model_cache.end())
{
LOG_INFO("Using cached model: " + model_name, __FILE__, __LINE__);
LOG_INFO("Using cached model: " + model_name);
sharedModel = it->second;
}
else
@@ -1513,12 +1516,12 @@ void application_class::add_cube()
g_model_cache[model_name] = newModel;
sharedModel = newModel;
LOG_INFO("Added cube model to cache: " + model_name, __FILE__, __LINE__);
LOG_INFO("Added cube model to cache: " + model_name);
if (entity_manager_)
{
auto entity = entity_manager_->CreateEntity();
auto entity = CREATE_ENTITY
auto identity = entity->AddComponent<ecs::IdentityComponent>(object_id_++);
identity->SetName("Cube");
@@ -1533,7 +1536,7 @@ void application_class::add_cube()
render->InitializeWithModel(sharedModel);
auto shader = entity->AddComponent<ecs::ShaderComponent>();
shader->SetActiveShader(ecs::ShaderType::TEXTURE);
shader->SetActiveShader(SHD_TEX);
}
}
@@ -1601,7 +1604,7 @@ bool application_class::update_mouse_strings(int mouseX, int mouseY, bool mouseD
if (!result)
{
LOG_ERROR("Could not update the mouse X string");
return false;
R_FALSE
}
// Convert the mouse Y integer to string format.
@@ -1616,7 +1619,7 @@ bool application_class::update_mouse_strings(int mouseX, int mouseY, bool mouseD
if (!result)
{
LOG_ERROR("Could not update the mouse Y string");
return false;
R_FALSE
}
// Setup the mouse button string.
@@ -1635,10 +1638,10 @@ bool application_class::update_mouse_strings(int mouseX, int mouseY, bool mouseD
if (!result)
{
LOG_ERROR("Could not update the mouse button string");
return false;
R_FALSE
}
return true;
R_TRUE
}
bool application_class::update_fps()
@@ -1660,7 +1663,7 @@ bool application_class::update_fps()
// Check if the fps from the previous frame was the same, if so don't need to update the text string.
if (previous_fps_ == fps)
{
return true;
R_TRUE
}
// Store the fps for checking next frame.
@@ -1708,10 +1711,10 @@ bool application_class::update_fps()
if (!result)
{
LOG_ERROR("Could not update the fps string");
return false;
R_FALSE
}
return true;
R_TRUE
}
bool application_class::update_render_count_string(int renderCount)
@@ -1732,10 +1735,10 @@ bool application_class::update_render_count_string(int renderCount)
if (!result)
{
LOG_ERROR("Could not update the render count string");
return false;
R_FALSE
}
return true;
R_TRUE
}
XMVECTOR application_class::get_light_color(int index)
@@ -1777,14 +1780,14 @@ void application_class::set_light_position(int index, XMVECTOR position)
void application_class::set_screen_height(int height)
{
// log the new screen height
LOG_INFO("Setting screen height to " + std::to_string(height), __FILE__, __LINE__);
LOG_INFO("Setting screen height to " + std::to_string(height));
screen_height_ = height;
}
void application_class::set_screen_width(int width)
{
// log the new screen width
LOG_INFO("Setting screen width to " + std::to_string(width), __FILE__, __LINE__);
LOG_INFO("Setting screen width to " + std::to_string(width));
screen_width_ = width;
}
@@ -1846,11 +1849,8 @@ void application_class::culling_thread_function()
bool application_class::render_pass(XMFLOAT4* diffuse, XMFLOAT4* position, XMFLOAT4* ambient, XMMATRIX view, XMMATRIX projection)
{
std::lock_guard<std::mutex> lock(objects_mutex_);
XMMATRIX scaleMatrix, rotateMatrix, translateMatrix;
bool result;
int renderCount = 0;
int i;
// Rendu des entit<69>s du syst<73>me ECS s'il est disponible
if (entity_manager_) {
@@ -1896,7 +1896,7 @@ bool application_class::render_pass(XMFLOAT4* diffuse, XMFLOAT4* position, XMFLO
set_render_count(renderCount);
return true;
R_TRUE
}
void application_class::construct_frustum()
@@ -1937,7 +1937,7 @@ bool application_class::render_physics(float delta_time) {
}
}
return true;
R_TRUE
}
void application_class::physics_thread_function()
@@ -1989,7 +1989,7 @@ bool application_class::create_big_cube(int side_count)
newModel->PreloadTextures(direct_3d_->get_device(), direct_3d_->get_device_context(), textures);
if (!newModel->Initialize(direct_3d_->get_device(), direct_3d_->get_device_context(),model_file, textures)) {
LOG_ERROR("Impossible d'initialiser le mod<6F>le du gros cube");
return false;
R_FALSE
}
g_model_cache[modelName] = newModel;
sharedModel = newModel;
@@ -1999,7 +1999,7 @@ bool application_class::create_big_cube(int side_count)
for (int y = 0; y < side_count; y++) {
for (int z = 0; z < side_count; z++) {
// Cr<43>er une entit<69>
auto entity = entity_manager_->CreateEntity();
auto entity = CREATE_ENTITY
// Ajouter un composant d'identit<69>
auto identity = entity->AddComponent<ecs::IdentityComponent>(object_id_++);
@@ -2018,14 +2018,14 @@ bool application_class::create_big_cube(int side_count)
// Ajouter un composant de shader
auto shader = entity->AddComponent<ecs::ShaderComponent>();
shader->SetActiveShader(ecs::ShaderType::LIGHTING);
shader->SetActiveShader(SHD_LIGHT);
}
}
}
update_stats_after_modification();
return true;
R_TRUE
}
void application_class::update_stats_after_modification()
@@ -2077,7 +2077,7 @@ bool application_class::create_skysphere()
auto it = g_model_cache.find(modelKey);
if (it != g_model_cache.end())
{
LOG_INFO("Using cached model for sky sphere: " + modelKey, __FILE__, __LINE__);
LOG_INFO("Using cached model for sky sphere: " + modelKey);
sharedModel = it->second;
}
else
@@ -2087,18 +2087,18 @@ bool application_class::create_skysphere()
if (!sharedModel->Initialize(direct_3d_->get_device(), direct_3d_->get_device_context(), modelFilename, textures))
{
LOG_ERROR("Failed to initialize model for sky sphere");
return false;
R_FALSE
}
g_model_cache[modelKey] = sharedModel;
LOG_INFO("Added sky sphere model to cache: " + modelKey, __FILE__, __LINE__);
LOG_INFO("Added sky sphere model to cache: " + modelKey);
}
sky_entity_ = entity_manager_->CreateEntity();
sky_entity_ = CREATE_ENTITY
if (!sky_entity_)
{
LOG_ERROR("Failed to create sky entity");
return false;
R_FALSE
}
sky_id_ = sky_entity_->GetID();
@@ -2120,25 +2120,23 @@ bool application_class::create_skysphere()
modelpath->SetPath(L"assets/Model/OBJ/skysphere.obj");
auto shader = sky_entity_->AddComponent<ecs::ShaderComponent>();
shader->SetActiveShader(ecs::ShaderType::SKYBOX);
shader->SetActiveShader(SHD_SKYBOX);
return true;
R_TRUE
}
bool application_class::update_screen_depth(float new_screen_depth)
{
if (!direct_3d_) return false;
if (new_screen_depth <= screen_near) return false;
CHECK_2_CONDITION_INDEPENDENT_RETURN(direct_3d_,new_screen_depth <= screen_near);
screen_depth = new_screen_depth;
direct_3d_->set_projection_params(screen_width_, screen_height_, screen_depth, screen_near);
return true;
R_TRUE
}
bool application_class::update_screen_near(float new_screen_near)
{
if (!direct_3d_) return false;
if (new_screen_near <= 0.0f || new_screen_near >= screen_depth) return false;
CHECK_2_CONDITION_INDEPENDENT_RETURN(direct_3d_,new_screen_near <= 0.0f || new_screen_near >= screen_depth);
screen_near = new_screen_near;
direct_3d_->set_projection_params(screen_width_, screen_height_, screen_depth, screen_near);
return true;
R_TRUE
}

View File

@@ -37,7 +37,7 @@ bool bitmap_class::initialize(ID3D11Device* device, ID3D11DeviceContext* deviceC
if (!result)
{
LOG_ERROR("Failed to initialize buffers");
return false;
R_FALSE
}
// Load the texture for this bitmap.
@@ -45,12 +45,12 @@ bool bitmap_class::initialize(ID3D11Device* device, ID3D11DeviceContext* deviceC
if (!result)
{
LOG_ERROR("Failed to load texture");
return false;
R_FALSE
}
LOG_INIT("Bitmap class initialized");
return true;
R_TRUE
}
void bitmap_class::shutdown()
@@ -73,13 +73,13 @@ bool bitmap_class::render(ID3D11DeviceContext* deviceContext)
if (!result)
{
LOG_ERROR("Failed to update buffers");
return false;
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()
@@ -146,7 +146,7 @@ bool bitmap_class::initialize_buffers(ID3D11Device* device)
if (FAILED(result))
{
LOG_ERROR("Failed to create vertex buffer");
return false;
R_FALSE
}
// Set up the description of the index buffer.
@@ -167,7 +167,7 @@ bool bitmap_class::initialize_buffers(ID3D11Device* device)
if (FAILED(result))
{
LOG_ERROR("Failed to create index buffer");
return false;
R_FALSE
}
// Release the arrays now that the vertex and index buffers have been created and loaded.
@@ -179,7 +179,7 @@ bool bitmap_class::initialize_buffers(ID3D11Device* device)
LOG_INIT("Buffers initialized");
return true;
R_TRUE
}
void bitmap_class::shutdown_buffers()
@@ -220,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,7 +268,7 @@ bool bitmap_class::update_buffers(ID3D11DeviceContext* deviceContent)
if (FAILED(result))
{
LOG_ERROR("Failed to map vertex buffer");
return false;
R_FALSE
}
// Get a pointer to the data in the constant buffer.
@@ -287,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,14 +324,14 @@ bool bitmap_class::load_texture(ID3D11Device* device, ID3D11DeviceContext* devic
if (!result)
{
LOG_ERROR("Failed to initialize texture object");
return false;
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()

View File

@@ -65,7 +65,7 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
if (FAILED(result))
{
LOG_ERROR("Failed to create DXGIFactory");
return false;
R_FALSE
}
// Use the factory to create an adapter for the primary graphics interface (video card).
@@ -73,7 +73,7 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
if (FAILED(result))
{
LOG_ERROR("Failed to create adapter");
return false;
R_FALSE
}
// Enumerate the primary adapter output (monitor).
@@ -81,7 +81,7 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
if (FAILED(result))
{
LOG_ERROR("Failed to create adapter output");
return false;
R_FALSE
}
// Get the number of modes that fit the DXGI_FORMAT_R8G8B8A8_UNORM display format for the adapter output (monitor).
@@ -89,7 +89,7 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
if (FAILED(result))
{
LOG_ERROR("Failed to get display mode list");
return false;
R_FALSE
}
// Create a list to hold all the possible display modes for this monitor/video card combination.
@@ -97,7 +97,7 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
if (!displayModeList)
{
LOG_ERROR("Failed to create display mode list");
return false;
R_FALSE
}
// Now fill the display mode list structures.
@@ -105,7 +105,7 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
if (FAILED(result))
{
LOG_ERROR("Failed to fill display mode list");
return false;
R_FALSE
}
// Now go through all the display modes and find the one that matches the screen width and height.
@@ -127,7 +127,7 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
if (FAILED(result))
{
LOG_ERROR("Failed to get adapter description");
return false;
R_FALSE
}
// Store the dedicated video card memory in megabytes.
@@ -138,7 +138,7 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
if (error != 0)
{
LOG_ERROR("Failed to convert video card name to character array");
return false;
R_FALSE
}
// Release the display mode list.
@@ -221,7 +221,7 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
if (FAILED(result))
{
LOG_ERROR("Failed to create swap chain, device and device context");
return false;
R_FALSE
}
// Get the pointer to the back buffer.
@@ -229,7 +229,7 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
if (FAILED(result))
{
LOG_ERROR("Failed to get pointer to back buffer");
return false;
R_FALSE
}
// Create the render target view with the back buffer pointer.
@@ -237,7 +237,7 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
if (FAILED(result))
{
LOG_ERROR("Failed to create render target view");
return false;
R_FALSE
}
// Release pointer to the back buffer as we no longer need it.
@@ -265,7 +265,7 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
if (FAILED(result))
{
LOG_ERROR("Failed to create texture for depth buffer");
return false;
R_FALSE
}
// initialize the description of the stencil state.
@@ -297,7 +297,7 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
if (FAILED(result))
{
LOG_ERROR("Failed to create depth stencil state");
return false;
R_FALSE
}
// Set the depth stencil state.
@@ -316,7 +316,7 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
if (FAILED(result))
{
LOG_ERROR("Failed to create depth stencil view");
return false;
R_FALSE
}
// Bind the render target view and depth stencil buffer to the output render pipeline.
@@ -339,7 +339,7 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
if (FAILED(result))
{
LOG_ERROR("Failed to create rasterizer state");
return false;
R_FALSE
}
// Now set the rasterizer state.
@@ -394,7 +394,7 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
if (FAILED(result))
{
LOG_ERROR("Failed to create depth disabled stencil state");
return false;
R_FALSE
}
// Clear the blend state description.
@@ -415,7 +415,7 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
if (FAILED(result))
{
LOG_ERROR("Failed to create alpha enabled blend state");
return false;
R_FALSE
}
// Modify the description to create an alpha disabled blend state description.
@@ -426,10 +426,10 @@ bool d_3d_class::initialize(int screenWidth, int screenHeight, bool vsync, HWND
if (FAILED(result))
{
LOG_ERROR("Failed to create alpha disabled blend state");
return false;
R_FALSE
}
return true;
R_TRUE
}
@@ -787,5 +787,5 @@ bool d_3d_class::set_projection_params(int width, int height, float screenDepth,
// Create an orthographic projection matrix for 2D rendering.
ortho_matrix_ = XMMatrixOrthographicLH((float)width, (float)height, screenNear, screenDepth);
return true;
R_TRUE
}

View File

@@ -31,11 +31,11 @@ bool display_plane_class::Initialize(ID3D11Device* device, float width, float he
if (!result)
{
LOG_ERROR("Could not initialize buffers");
return false;
R_FALSE
}
LOG_INIT("Display_plane_class initialized");
return true;
R_TRUE
}
@@ -133,7 +133,7 @@ bool display_plane_class::InitializeBuffers(ID3D11Device* device, float width, f
if (FAILED(result))
{
LOG_ERROR("Could not create vertex buffer");
return false;
R_FALSE
}
// Set up the description of the index buffer.
@@ -154,7 +154,7 @@ bool display_plane_class::InitializeBuffers(ID3D11Device* device, float width, f
if (FAILED(result))
{
LOG_ERROR("Could not create index buffer");
return false;
R_FALSE
}
// Release the arrays now that the vertex and index buffers have been created and loaded.
@@ -166,7 +166,7 @@ bool display_plane_class::InitializeBuffers(ID3D11Device* device, float width, f
LOG_INIT("Buffers initialized");
return true;
R_TRUE
}

View File

@@ -53,7 +53,7 @@ bool font_class::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCon
if (!result)
{
LOG_ERROR("Failed to load font data");
return false;
R_FALSE
}
// Load the texture that has the font characters on it.
@@ -61,12 +61,12 @@ bool font_class::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCon
if (!result)
{
LOG_ERROR("Failed to load font texture");
return false;
R_FALSE
}
LOG_INIT("Font class initialized");
return true;
R_TRUE
}
void font_class::Shutdown()
@@ -98,7 +98,7 @@ bool font_class::LoadFontData(char* filename)
if (fin.fail())
{
LOG_ERROR("Failed to open font file");
return false;
R_FALSE
}
// Read in the 95 used ascii characters for text.
@@ -125,7 +125,7 @@ bool font_class::LoadFontData(char* filename)
LOG_INFO("Font data loaded");
return true;
R_TRUE
}
void font_class::ReleaseFontData()
@@ -159,12 +159,12 @@ bool font_class::LoadTexture(ID3D11Device* device, ID3D11DeviceContext* deviceCo
if (!result)
{
LOG_ERROR("Failed to initialize font texture");
return false;
R_FALSE
}
LOG_INFO("Font texture loaded");
return true;
R_TRUE
}
void font_class::ReleaseTexture()

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -49,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;
@@ -68,7 +68,7 @@ bool imguiManager::IncrementBuildVersionInConfig(const std::string& filepath) {
}
} catch (...) {
LOG_ERROR("Error converting VER to integer");
return false; // erreur conversion
R_FALSE // erreur conversion
}
}
lines.push_back(line);
@@ -86,14 +86,14 @@ bool imguiManager::IncrementBuildVersionInConfig(const std::string& filepath) {
if (!file_out)
{
LOG_ERROR("Error writing to file");
return false;
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)
@@ -120,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
@@ -150,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;
@@ -224,7 +224,7 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
scene_manager_ = new scene_manager;
if (!scene_manager_->initialize(app_.get())) {
LOG_ERROR("Failed to initialize scene manager");
return false;
R_FALSE
}
stats_ = app_->get_stats();
@@ -276,7 +276,7 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
LOG_INIT("imgui initialized");
return true;
R_TRUE
}
void imguiManager::Shutdown()
@@ -309,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();
@@ -340,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;
@@ -404,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;
@@ -514,18 +507,18 @@ void imguiManager::WidgetAddObject()
}
}
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;
@@ -604,14 +597,11 @@ void imguiManager::WidgetObjectWindow()
std::replace(relativePath.begin(), relativePath.end(), L'\\', L'/');
app_->add_kobject(relativePath);
}
}
}
ImGui::SameLine();
ImGui::Text("Number of objects: %d", entity_manager_->GetEntityCount());
ImGui::Separator();
S_LINE
TEXT_V("Number of cubes: %d", entity_manager_->GetEntityCount())
SEP
auto entities = entity_manager_->GetAllEntities();
@@ -626,7 +616,7 @@ void imguiManager::WidgetObjectWindow()
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))
if (SEL(name.c_str(), isSelected))
{
m_selected_entity_id = entity->GetID();
show_inspector_window_ = true;
@@ -634,13 +624,13 @@ void imguiManager::WidgetObjectWindow()
}
}
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)
@@ -650,14 +640,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();
@@ -666,27 +656,27 @@ 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;
}
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>(); }},
@@ -701,65 +691,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()
@@ -781,12 +769,12 @@ bool imguiManager::ImGuiWidgetRenderer()
//render imgui
Render();
return true;
R_TRUE
}
void imguiManager::WidgetLightWindow()
{
ImGui::Begin("Light", &showLightWindow);
BEGIN("Light", &showLightWindow)
// Sun light settings
@@ -813,7 +801,7 @@ void imguiManager::WidgetLightWindow()
}
ImGui::Separator();
SEP
int index = 0;
@@ -822,7 +810,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);
@@ -846,12 +834,12 @@ void imguiManager::WidgetLightWindow()
index++;
};
ImGui::End();
END
}
void imguiManager::WidgetEngineSettingsWindow()
{
ImGui::Begin("Engine Settings", &showEngineSettingsWindow);
BEGIN("Engine Settings", &showEngineSettingsWindow)
// Variables temporaires pour les settings
static bool temp_v_sync = app_->get_vsync();
@@ -954,7 +942,7 @@ void imguiManager::WidgetEngineSettingsWindow()
}
else
{
ImGui::Text("Sky entity not found.");
TEX("Sky entity not found.")
}
ImGui::EndTabItem();
@@ -974,7 +962,7 @@ void imguiManager::WidgetEngineSettingsWindow()
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));
}
ImGui::SameLine();
S_LINE
if (ImGui::Button("Reset Settings"))
{
temp_v_sync = app_->get_vsync();
@@ -988,18 +976,18 @@ void imguiManager::WidgetEngineSettingsWindow()
temp_gravity_values[2] = XMVectorGetZ(app_->get_physics()->GetGravity());
}
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"))
@@ -1008,7 +996,7 @@ 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"))
@@ -1021,12 +1009,12 @@ void imguiManager::WidgetLogWindow()
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");
@@ -1041,7 +1029,7 @@ void imguiManager::WidgetLogWindow()
if (logfiltered.size() == 0)
{
ImGui::Text("No logs to display.");
TEX("No logs to display.")
}
else
{
@@ -1069,7 +1057,7 @@ void imguiManager::WidgetLogWindow()
ImGui::EndChild();
ImGui::End();
END
}
void imguiManager::WidgetRenderWindow(ImVec2 availableSize)
@@ -1112,10 +1100,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()
@@ -1137,13 +1125,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;
@@ -1164,7 +1152,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,
@@ -1174,16 +1162,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();
@@ -1194,43 +1182,43 @@ 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
}

View File

@@ -45,7 +45,7 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
if (FAILED(result))
{
LOG_ERROR("Failed to create direct input interface");
return false;
R_FALSE
}
// Initialize the direct input interface for the keyboard.
@@ -53,7 +53,7 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
if (FAILED(result))
{
LOG_ERROR("Failed to create direct input interface for the keyboard");
return false;
R_FALSE
}
// Set the data format. In this case since it is a keyboard we can use the predefined data format.
@@ -61,7 +61,7 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
if (FAILED(result))
{
LOG_ERROR("Failed to set data format for the keyboard");
return false;
R_FALSE
}
// Set the cooperative level of the keyboard to share with other programs.
@@ -69,7 +69,7 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
if (FAILED(result))
{
LOG_ERROR("Failed to set cooperative level of the keyboard");
return false;
R_FALSE
}
// Now acquire the keyboard.
@@ -77,7 +77,7 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
if (FAILED(result))
{
LOG_ERROR("Failed to acquire the keyboard");
return false;
R_FALSE
}
// Initialize the direct input interface for the mouse.
@@ -85,7 +85,7 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
if (FAILED(result))
{
LOG_ERROR("Failed to create direct input interface for the mouse");
return false;
R_FALSE
}
// Set the data format for the mouse using the pre-defined mouse data format.
@@ -93,7 +93,7 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
if (FAILED(result))
{
LOG_ERROR("Failed to set data format for the mouse");
return false;
R_FALSE
}
// Set the cooperative level of the mouse to share with other programs.
@@ -101,7 +101,7 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
if (FAILED(result))
{
LOG_ERROR("Failed to set cooperative level of the mouse");
return false;
R_FALSE
}
// Acquire the mouse.
@@ -109,12 +109,12 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
if (FAILED(result))
{
LOG_ERROR("Failed to acquire the mouse");
return false;
R_FALSE
}
LOG_INIT("Input class initialized");
return true;
R_TRUE
}
@@ -182,7 +182,7 @@ bool input_class::Frame()
if (!result)
{
LOG_ERROR("Failed to read keyboard state");
return false;
R_FALSE
}
// Read the current state of the mouse.
@@ -190,13 +190,13 @@ bool input_class::Frame()
if (!result)
{
LOG_ERROR("Failed to read mouse state");
return false;
R_FALSE
}
// Process the changes in the mouse and keyboard.
ProcessInput();
return true;
R_TRUE
}
bool input_class::ReadKeyboard()
@@ -216,11 +216,11 @@ bool input_class::ReadKeyboard()
else
{
LOG_ERROR("Failed to get keyboard device state");
return false;
R_FALSE
}
}
return true;
R_TRUE
}
bool input_class::ReadMouse()
@@ -240,11 +240,11 @@ bool input_class::ReadMouse()
else
{
LOG_ERROR("Failed to get mouse device state");
return false;
R_FALSE
}
}
return true;
R_TRUE
}
void input_class::ProcessInput()
@@ -268,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
}
@@ -289,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
}
@@ -310,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;
@@ -395,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
@@ -406,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;
}

View File

@@ -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) {
@@ -45,7 +45,7 @@ bool model_class::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCo
result = LoadModel(modelFilename);
if (!result) {
LOG_ERROR("Failed to load model data");
return false;
R_FALSE
}
// Calculate the tangent and binormal vectors for the model.
@@ -55,10 +55,10 @@ bool model_class::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCo
result = InitializeBuffers(device);
if (!result) {
LOG_ERROR("Failed to initialize buffers");
return false;
R_FALSE
}
return true;
R_TRUE
}
void model_class::Shutdown()
@@ -140,7 +140,7 @@ bool model_class::InitializeBuffers(ID3D11Device* device)
if (FAILED(result))
{
LOG_ERROR("Failed to create vertex buffer");
return false;
R_FALSE
}
// Set up the description of the static index buffer.
@@ -161,7 +161,7 @@ bool model_class::InitializeBuffers(ID3D11Device* device)
if (FAILED(result))
{
LOG_ERROR("Failed to create index buffer");
return false;
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
}
@@ -228,7 +228,7 @@ bool model_class::LoadModel(char* filename)
else
{
LOG_ERROR("Unsupported file format");
return false;
R_FALSE
}
}
@@ -239,7 +239,7 @@ bool model_class::LoadObjModel(char* filename)
if (!fin)
{
LOG_ERROR("<EFBFBD>chec d'ouverture du fichier mod<6F>le");
return false;
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)
@@ -353,7 +353,7 @@ bool model_class::LoadTxtModel(char* filename)
if (fin.fail())
{
LOG_ERROR("Failed to open model file");
return false;
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()
@@ -536,7 +536,7 @@ bool model_class::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* dev
if (FAILED(hResult))
{
LOG_ERROR("<EFBFBD>chec du chargement de la texture diffuse: " + std::string(texturePath.begin(), texturePath.end()));
return false;
R_FALSE
}
textureContainer.diffuse.push_back(texture);
}
@@ -549,7 +549,7 @@ bool model_class::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* dev
if (FAILED(hResult))
{
LOG_ERROR("<EFBFBD>chec du chargement de la texture normale: " + std::string(texturePath.begin(), texturePath.end()));
return false;
R_FALSE
}
textureContainer.normal.push_back(texture);
}
@@ -562,7 +562,7 @@ bool model_class::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* dev
if (FAILED(hResult))
{
LOG_ERROR("<EFBFBD>chec du chargement de la texture sp<73>culaire: " + std::string(texturePath.begin(), texturePath.end()));
return false;
R_FALSE
}
textureContainer.specular.push_back(texture);
}
@@ -575,12 +575,12 @@ bool model_class::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* dev
if (FAILED(hResult))
{
LOG_ERROR("<EFBFBD>chec du chargement de la texture alpha: " + std::string(texturePath.begin(), texturePath.end()));
return false;
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) {
@@ -593,7 +593,7 @@ bool model_class::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* devic
result = DirectX::CreateWICTextureFromFile(device, deviceContext, filename.c_str(), nullptr, &newTexture);
if (FAILED(result)) {
LOG_ERROR("Failed to load texture: " + std::string(filename.begin(), filename.end()));
return false;
R_FALSE
}
// R<>cup<75>rer le vecteur correspondant au type de texture
@@ -641,7 +641,7 @@ bool model_class::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* devic
}
LOG_INIT("Texture changed successfully");
return true;
R_TRUE
}
bool model_class::AddTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, TextureType type) {
@@ -654,7 +654,7 @@ bool model_class::AddTexture(ID3D11Device* device, ID3D11DeviceContext* deviceCo
result = DirectX::CreateWICTextureFromFile(device, deviceContext, filename.c_str(), nullptr, &newTexture);
if (FAILED(result)) {
LOG_ERROR("Failed to load texture: " + std::string(filename.begin(), filename.end()));
return false;
R_FALSE
}
// Ajouter la texture au vecteur appropri<72> selon le type
@@ -678,13 +678,13 @@ bool model_class::AddTexture(ID3D11Device* device, ID3D11DeviceContext* deviceCo
}
LOG_INIT("Texture added successfully");
return true;
R_TRUE
}
bool model_class::AddTexture(ID3D11ShaderResourceView* texture, TextureType type) {
if (!texture) {
LOG_ERROR("Cannot add null texture");
return false;
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
}

View File

@@ -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;
@@ -424,12 +423,12 @@ bool object::LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, Textu
LOG_ERROR("Failed to load texture: " + std::string(texturePath.begin(), texturePath.end()) +
"\nError: " + std::to_string(result) +
"\nDescription: " + str);
return false; // Assurez-vous de retourner false ou de g<>rer l'erreur de mani<6E>re appropri<72>e
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
}

View File

@@ -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
}

View File

@@ -71,7 +71,7 @@ bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, i
if (FAILED(result))
{
LOG_ERROR("Failed to create render target texture");
return false;
R_FALSE
}
// Setup the description of the render target view.
@@ -84,7 +84,7 @@ bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, i
if (FAILED(result))
{
LOG_ERROR("Failed to create render target view");
return false;
R_FALSE
}
// Setup the description of the shader resource view.
@@ -98,7 +98,7 @@ bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, i
if (FAILED(result))
{
LOG_ERROR("Failed to create shader resource view");
return false;
R_FALSE
}
// Initialize the description of the depth buffer.
@@ -122,7 +122,7 @@ bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, i
if (FAILED(result))
{
LOG_ERROR("Failed to create depth buffer texture");
return false;
R_FALSE
}
// Initailze the depth stencil view description.
@@ -138,7 +138,7 @@ bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, i
if (FAILED(result))
{
LOG_ERROR("Failed to create depth stencil view");
return false;
R_FALSE
}
// Setup the viewport for rendering.
@@ -157,7 +157,7 @@ bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, i
LOG_INIT("render_texture_class initialized");
return true;
R_TRUE
}
void render_texture_class::Shutdown()

View File

@@ -14,29 +14,29 @@ bool scene_manager::initialize(application_class* app)
{
if (!app) {
LOG_ERROR("Application pointer is null");
return false;
R_FALSE
}
app_ = app;
if (app_ == nullptr) {
LOG_ERROR("Application pointer is null");
return false;
R_FALSE
}
direct_3d_ = app_->get_direct_3d();
if (!direct_3d_) {
LOG_ERROR("Direct3D pointer is null");
return false;
R_FALSE
}
return true;
R_TRUE
}
bool scene_manager::shutdown()
{
app_ = nullptr;
return true;
R_TRUE
}
bool scene_manager::save_scene_as() {
@@ -68,10 +68,10 @@ bool scene_manager::save_scene_as() {
// Sauvegarder la sc<73>ne avec le nouveau chemin
save_scene();
LOG_INFO("Scene saved as: " + scene_path_);
return false;
R_FALSE
}
return true;
R_TRUE
}
bool scene_manager::load_scene() {
@@ -93,13 +93,13 @@ bool scene_manager::load_scene() {
ofn.lpstrDefExt = L"ker";
if (GetOpenFileName(&ofn) != TRUE) {
LOG_WARNING("Load scene canceled or failed");
return false; // L'utilisateur a annul<75> la bo<62>te de dialogue
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()) {
LOG_ERROR("Invalid scene path");
return false;
R_FALSE
}
LOG_INFO("Loading scene from: " + scene_path_);
@@ -114,7 +114,7 @@ bool scene_manager::load_scene() {
std::ifstream inFile(scene_path_);
if (!inFile.is_open()) {
LOG_ERROR("<EFBFBD>chec de l'ouverture du fichier");
return false;
R_FALSE
}
auto entity_manager = app_->get_entity_manager();
@@ -220,7 +220,7 @@ bool scene_manager::load_scene() {
}
LOG_INFO("Sc<EFBFBD>ne charg<72>e avec succ<63>s");
return true;
R_TRUE
}
@@ -228,12 +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()) {
LOG_ERROR("<EFBFBD>chec de l'ouverture du fichier");
return false;
R_FALSE
}
for (const auto& entity : entity_) {
@@ -257,7 +257,7 @@ bool scene_manager::save_scene() {
outFile.close();
LOG_INFO("Sc<EFBFBD>ne sauvegard<72>e avec succ<63>s: " + scene_path_);
return true;
R_TRUE
}
std::wstring scene_manager::get_scene_path()

View File

@@ -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() {

View File

@@ -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()

View File

@@ -16,7 +16,7 @@ bool stats::initialize(application_class* app)
{
if (!app) {
LOG_ERROR("Application pointer is null");
return false;
R_FALSE
}
drawcalls_ = 0;
@@ -26,12 +26,12 @@ bool stats::initialize(application_class* app)
if (!fps_) {
LOG_ERROR("FPS object is null");
return false;
R_FALSE
}
LOG_INIT("Stats initialized successfully");
return true;
R_TRUE
}
void stats::update_geometric_stats()

View File

@@ -41,7 +41,7 @@ bool system_class::initialize()
if (!result)
{
LOG_ERROR("Failed to initialize input class");
return false;
R_FALSE
}
// Create and initialize the application class object. This object will handle rendering all the graphics for this application.
@@ -50,7 +50,7 @@ bool system_class::initialize()
result = application_->initialize(screenWidth, screenHeight, hwnd_, false);
if (!result)
{
return false;
R_FALSE
}
is_direct_3d_initialized_ = true;
@@ -69,7 +69,7 @@ bool system_class::initialize()
result = imgui_manager_->Initialize(hwnd_, application_->get_direct_3d()->get_device(), application_->get_direct_3d()->get_device_context());
if (!result)
{
return false;
R_FALSE
}
}
@@ -77,12 +77,12 @@ bool system_class::initialize()
catch (const std::exception& e)
{
LOG_ERROR(std::string("Exception caught during initialization: ") + e.what());
return false;
R_FALSE
}
LOG_INIT("System class initialized");
return true;
R_TRUE
}
void system_class::shutdown()
@@ -103,7 +103,7 @@ void system_class::run()
MSG msg;
bool done, result;
LOG_INFO("Running the system", __FILE__, __LINE__);
LOG_INFO("Running the system");
// initialize the message structure.
ZeroMemory(&msg, sizeof(MSG));
@@ -130,7 +130,7 @@ void system_class::run()
// If windows signals to end the application then exit out.
if (application_ != nullptr && application_->get_should_quit())
{
LOG_INFO("Received quit signal from application", __FILE__, __LINE__);
LOG_INFO("Received quit signal from application");
done = true;
}
else
@@ -144,7 +144,7 @@ void system_class::run()
LOG_ERROR("Failed to process frame");
done = true;
}
fps_limiter_->set_target_fps(application_->get_target_fps());
fps_limiter_->set_target_fps(int_to_float(application_->get_target_fps()));
}
}
@@ -166,7 +166,7 @@ bool system_class::frame()
if (!result)
{
LOG_ERROR("Failed to process input frame");
return false;
R_FALSE
}
// Do the frame processing for the application class object.
@@ -174,7 +174,7 @@ bool system_class::frame()
if (!result)
{
LOG_ERROR("Failed to process application frame");
return false;
R_FALSE
}
if(!input_->IsKeyDown(222))
@@ -196,13 +196,13 @@ bool system_class::frame()
if (!result)
{
LOG_ERROR("Failed to render ImGui widgets");
return false;
R_FALSE
}
}
application_->get_direct_3d()->end_scene();
return true;
R_TRUE
}
LRESULT CALLBACK system_class::message_handler(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam)
@@ -210,7 +210,7 @@ LRESULT CALLBACK system_class::message_handler(HWND hwnd, UINT umsg, WPARAM wpar
if (ImGui_ImplWin32_WndProcHandler(hwnd, umsg, wparam, lparam))
{
return true;
R_TRUE
}
switch (umsg)
@@ -291,7 +291,7 @@ LRESULT CALLBACK system_class::message_handler(HWND hwnd, UINT umsg, WPARAM wpar
}
case WM_CLOSE:
{
LOG_INFO("WM_CLOSE message received", __FILE__, __LINE__);
LOG_INFO("WM_CLOSE message received");
application_->set_should_quit(true);
return 0;
}

View File

@@ -34,10 +34,10 @@ bool text_class::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCon
result = InitializeBuffers(device, deviceContext, Font, text, positionX, positionY, red, green, blue);
if (!result)
{
return false;
R_FALSE
}
return true;
R_TRUE
}
void text_class::Shutdown()
@@ -106,7 +106,7 @@ bool text_class::InitializeBuffers(ID3D11Device* device, ID3D11DeviceContext* de
result = device->CreateBuffer(&vertexBufferDesc, &vertexData, &m_vertexBuffer);
if (FAILED(result))
{
return false;
R_FALSE
}
// Set up the description of the static index buffer.
@@ -126,7 +126,7 @@ bool text_class::InitializeBuffers(ID3D11Device* device, ID3D11DeviceContext* de
result = device->CreateBuffer(&indexBufferDesc, &indexData, &m_indexBuffer);
if (FAILED(result))
{
return false;
R_FALSE
}
// Release the vertex array as it is no longer needed.
@@ -141,10 +141,10 @@ bool text_class::InitializeBuffers(ID3D11Device* device, ID3D11DeviceContext* de
result = UpdateText(deviceContext, Font, text, positionX, positionY, red, green, blue);
if (!result)
{
return false;
R_FALSE
}
return true;
R_TRUE
}
void text_class::ShutdownBuffers()
@@ -184,7 +184,7 @@ bool text_class::UpdateText(ID3D11DeviceContext* deviceContext, font_class* Font
// Check for possible buffer overflow.
if (numLetters > m_maxLength)
{
return false;
R_FALSE
}
// Create the vertex array.
@@ -204,7 +204,7 @@ bool text_class::UpdateText(ID3D11DeviceContext* deviceContext, font_class* Font
result = deviceContext->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 vertex buffer.
@@ -220,7 +220,7 @@ bool text_class::UpdateText(ID3D11DeviceContext* deviceContext, font_class* Font
delete[] vertices;
vertices = 0;
return true;
R_TRUE
}
void text_class::RenderBuffers(ID3D11DeviceContext* deviceContext)

View File

@@ -31,7 +31,7 @@ bool texture_class::Initialize(ID3D11Device * device, ID3D11DeviceContext * devi
if (!result)
{
Logger::Get().Log("Failed to load targa data", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
R_FALSE
}
// Setup the description of the texture.
textureDesc.Height = m_height;
@@ -51,7 +51,7 @@ bool texture_class::Initialize(ID3D11Device * device, ID3D11DeviceContext * devi
if (FAILED(hResult))
{
LOG_ERROR("Failed to create texture");
return false;
R_FALSE
}
// Set the row pitch of the targa image data.
@@ -69,7 +69,7 @@ bool texture_class::Initialize(ID3D11Device * device, ID3D11DeviceContext * devi
if (FAILED(hResult))
{
LOG_ERROR("Failed to create shader resource view");
return false;
R_FALSE
}
// Generate mipmaps for this texture.
@@ -81,7 +81,7 @@ bool texture_class::Initialize(ID3D11Device * device, ID3D11DeviceContext * devi
LOG_INIT("Texture initialized");
return true;
R_TRUE
}
void texture_class::Shutdown()
@@ -133,7 +133,7 @@ bool texture_class::LoadTarga(std::string filename)
if (error != 0)
{
LOG_ERROR("Failed to open targa file. Working directory: " + std::filesystem::current_path().string());
return false;
R_FALSE
}
// Read in the file header.
@@ -141,7 +141,7 @@ bool texture_class::LoadTarga(std::string filename)
if (count != 1)
{
LOG_ERROR("Failed to read targa file header");
return false;
R_FALSE
}
// Get the important information from the header.
@@ -153,7 +153,7 @@ bool texture_class::LoadTarga(std::string filename)
if (bpp != 32 && bpp != 24)
{
LOG_ERROR("Targa file is not 32 or 24 bit");
return false;
R_FALSE
}
// Calculate the size of the 32 bit image data.
@@ -167,7 +167,7 @@ bool texture_class::LoadTarga(std::string filename)
if (count != imageSize)
{
LOG_ERROR("Failed to read targa image data");
return false;
R_FALSE
}
// Close the file.
@@ -175,7 +175,7 @@ bool texture_class::LoadTarga(std::string filename)
if (error != 0)
{
LOG_ERROR("Failed to close targa file");
return false;
R_FALSE
}
// Allocate memory for the targa destination data.
@@ -205,7 +205,7 @@ bool texture_class::LoadTarga(std::string filename)
else
{
LOG_ERROR("Index out of bounds");
return false;
R_FALSE
}
// Increment the indexes into the targa data.
@@ -224,7 +224,7 @@ bool texture_class::LoadTarga(std::string filename)
LOG_INFO("targa file " + filename + " loaded");
return true;
R_TRUE
}

View File

@@ -27,7 +27,7 @@ bool timer_class::Initialize()
if (frequency == 0)
{
LOG_ERROR("QueryPerformanceFrequency failed");
return false;
R_FALSE
}
// Store it in floating point.
@@ -38,7 +38,7 @@ bool timer_class::Initialize()
LOG_INIT("Timer class initialized");
return true;
R_TRUE
}
void timer_class::Frame()

BIN
x64/Debug/config.txt (Stored with Git LFS)

Binary file not shown.

BIN
x64/Release/config.txt (Stored with Git LFS)

Binary file not shown.