summaryrefslogtreecommitdiff
path: root/Runtime/Graphics/GfxDevice.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-27 23:37:24 +0800
committerchai <chaifix@163.com>2021-10-27 23:37:24 +0800
commit305ca0a09d4e750186b5190432de47f3493e806a (patch)
treed82f9ef73191abc2acbcbfdca4b184a28e6c381b /Runtime/Graphics/GfxDevice.h
parent51ced5a191078ce4ef08d57e343e91db007f556f (diff)
*GfxDevice
Diffstat (limited to 'Runtime/Graphics/GfxDevice.h')
-rw-r--r--Runtime/Graphics/GfxDevice.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/Runtime/Graphics/GfxDevice.h b/Runtime/Graphics/GfxDevice.h
new file mode 100644
index 0000000..70ce8e6
--- /dev/null
+++ b/Runtime/Graphics/GfxDevice.h
@@ -0,0 +1,76 @@
+#ifndef DEVICE_H
+#define DEVICE_H
+
+#include "../Utilities/NonCopyable.h"
+#include "../Utilities/Type.h"
+#include "../Utilities/Assert.h"
+
+#include "Texture.h"
+#include "DeviceDefine.h"
+#include "VertexBuffer.h"
+#include "Color.h"
+
+struct GfxDeviceSetting
+{
+ ETextureFilterMode filterMode; // 默认的贴图过滤模式
+ ETextureWrapMode wrapMode; // 默认的贴图平铺模式
+};
+
+// 对渲染相关API的封装
+class GfxDevice : public NonCopyable
+{
+public:
+ GfxDevice();
+ ~GfxDevice();
+
+ void Initialize(GfxDeviceSetting setting);
+
+ void Enable(EDeviceEnable enabled);
+ void Disable(EDeviceEnable enabled);
+ void IsEnable(uint flag);
+
+ void SetDepthTest(EDepthTest testing);
+ void SetCullFace(ECullFace face);
+ void SetStencilMask(byte stencilMask);
+ void SetStencilOp(EStencilOp op);
+
+ void SetAntiAliasing(int level = 0);
+
+ void Clear(int clearFlag);
+
+ void BeginFrame();
+ void EndFrame();
+ void PresentFrame();
+
+ bool IsInsideFrame();
+
+ SharedVertexBuffer* GetSharedVBO() { return &m_SharedVBO; }
+
+ GET_SET(Color, ClearColor, m_ClearColor);
+ GET_SET(ETextureFilterMode, DefaultFilterMode, m_DefaultFilterMode);
+ GET_SET(ETextureWrapMode, DefaultWrapMode, m_DefaultWrapMode);
+
+private:
+ bool m_IsInsideFrame;
+
+ // 渲染状态
+ uint m_EnableFlag;
+ Color m_ClearColor;
+ EDepthTest m_DepthTest;
+ EStencilTest m_StencilTest;
+ EStencilOp m_StencilOp;
+ byte m_StencilMask;
+
+ // 贴图默认设置
+ ETextureFilterMode m_DefaultFilterMode;
+ ETextureWrapMode m_DefaultWrapMode;
+
+ SharedVertexBuffer m_SharedVBO; // 共享的VBO,用来做立即渲染
+
+};
+
+extern GfxDevice g_GfxDevice;
+
+#define g_SharedVBO (*g_GfxDevice.GetSharedVBO())
+
+#endif \ No newline at end of file