Minor Update - Stats Widget + BigCube Generation WIP - V10.2.0

This commit is contained in:
2025-05-07 17:15:11 +02:00
parent 2744c809d3
commit 94fd900ce8
13 changed files with 552 additions and 66 deletions

View File

@@ -41,6 +41,7 @@
#include <map>
#include <algorithm>
#include <DirectXMath.h>
#include <mutex>
/////////////
@@ -67,12 +68,17 @@ public:
ApplicationClass();
~ApplicationClass();
D3DClass* GetDirect3D();
RenderTextureClass* GetSceneTexture() const { return m_SceneTexture; };
RenderTextureClass* GetRenderTexture() const { return m_RenderTexture; };
RenderTextureClass* GetRefractionTexture() const { return m_RefractionTexture; };
RenderTextureClass* GetReflectionTexture() const { return m_ReflectionTexture; };
int GetTotalVertexCount() const;
int GetTotalTriangleCount() const;
int GetVisibleTriangleCount() const;
void CreateBigCube(int sideCount);
bool Initialize(int, int, HWND, bool IsVulkan);
void Shutdown();
bool Frame(InputClass*);
@@ -131,6 +137,19 @@ public:
Physics* GetPhysics() const { return m_Physics; };
// ------------------------------------- //
// --------------- Stats --------------- //
// ------------------------------------- //
int GetCurrentFps() const;
int GetMinFps() const;
int GetMaxFps() const;
float GetFrameTime() const;
int GetDrawCalls() const;
void ResetFpsStats();
void IncrementDrawCallCount();
void ResetDrawCallCount();
// ----------------------------------- //
// ------------- Culling ------------- //
// ----------------------------------- //
@@ -202,6 +221,7 @@ private :
int m_screenWidth, m_screenHeight;
CameraClass* m_Camera;
PositionClass* m_Position;
int m_drawcalls;
// ------------------------------------ //
// ------------- OBJECTS -------------- //

View File

@@ -28,9 +28,19 @@ public:
void Frame();
int GetFps();
int GetMinFps() const;
int GetMaxFps() const;
float GetFrameTime() const;
void ResetStats();
private:
int m_fps, m_count;
unsigned long m_startTime;
int m_minFps;
int m_maxFps;
float m_frameTime;
unsigned long m_previousTime;
};
#endif

View File

@@ -38,6 +38,7 @@ public:
void WidgetEngineSettingsWindow(ApplicationClass* app);
void WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSize);
void WidgetLogWindow(ApplicationClass* app);
void WidgetRenderStats(ApplicationClass* app);
bool ImGuiWidgetRenderer(ApplicationClass* app);
@@ -65,6 +66,11 @@ private:
bool showOldSceneWindow;
bool showEngineSettingsWindow;
bool showLogWindow;
bool showStatsWindow;
static const int FRAME_HISTORY_COUNT = 3600; // 1min secondes <20> 60 FPS
float m_frameTimeHistory[FRAME_HISTORY_COUNT] = {};
int m_frameTimeHistoryIndex = 0;
bool m_isPhyiscsEnabled = false;
bool m_isGravityEnabled = false;

View File

@@ -213,9 +213,13 @@ public:
void Render(ID3D11DeviceContext*);
int GetIndexCount();
int GetVertexCount() const { return m_vertexCount; }
// TEXTURE //
//ID3D11ShaderResourceView* GetTexture(int index) const;
ID3D11ShaderResourceView* GetTexture(TextureType type, int index) const;
//bool ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, int index);
bool ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext,std::wstring filename, TextureType type, int index);
@@ -227,7 +231,11 @@ public:
TextureContainer GetTextureContainer() const { return m_Textures; }
bool PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, TextureContainer& textureContainer);
protected:
int m_vertexCount, m_indexCount;
ID3D11Buffer* m_vertexBuffer, * m_indexBuffer;
private:
bool InitializeBuffers(ID3D11Device*);
void ShutdownBuffers();
@@ -243,8 +251,6 @@ private:
void CalculateModelVectors();
void CalculateTangentBinormal(TempVertexType, TempVertexType, TempVertexType, VectorType&, VectorType&);
ID3D11Buffer* m_vertexBuffer, * m_indexBuffer;
int m_vertexCount, m_indexCount;
TextureContainer m_Textures;
ModelType* m_model;
};

View File

@@ -50,6 +50,7 @@ public:
XMVECTOR GetPosition();
XMVECTOR GetRotation();
void Render(ID3D11DeviceContext* deviceContext);
XMVECTOR GetScale();
void SetVelocity(XMVECTOR);
@@ -63,7 +64,8 @@ public:
bool IsGrounded() const;
bool IsPhysicsEnabled() const;
void SetPhysicsEnabled(bool state);
void SetVisible (bool state) { m_isVisible = state; }
bool IsVisible() const { return m_isVisible; }
void UpdateWorldMatrix();
void UpdateSRMatrix();
@@ -100,6 +102,12 @@ public:
void LaunchObject();
bool LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, TextureContainer& texturesContainer,
D3DClass* m_Direct3D);
bool SetupInstancing(ID3D11Device* device, const std::vector<XMMATRIX>& instanceTransforms);
void EnableInstancing(bool enabled);
void SetInstanceCount(int count);
bool IsInstancingEnabled() const;
int GetInstanceCount() const;
ID3D11Buffer* GetInstanceBuffer() const;
void SetAlpha(float alpha) { m_alpha = alpha; }
float GetAlpha() const { return m_alpha; }
void SetInitialStretch(float initialStretch) { m_initialStretch = initialStretch; }
@@ -128,6 +136,7 @@ private:
float m_mass;
bool m_isGrounded;
bool m_isPhysicsEnabled;
bool m_isVisible;
std::string m_name;
ObjectType m_type = ObjectType::Unknown;
@@ -140,5 +149,9 @@ private:
float m_initialStretch = 0.0f;
float m_springConstant = 10.0f;
bool m_instancingEnabled;
int m_instanceCount;
ID3D11Buffer* m_instanceBuffer;
std::vector<XMMATRIX> m_instanceTransforms;
};