#ifndef RENDER_GRAPHIC_H
#define RENDER_GRAPHIC_H
#include <d3d11.h>
#include <dxgi.h>
#include <wrl/client.h>
#include <render_type_def.h>
#include "shader.h"

class RenderObject;
class Graphic {
public:
    template<typename T>
    using cp = Microsoft::WRL::ComPtr<T>;
public:
    bool Init(HWND outputWnd);
    bool ResizeTheWinodw(UINT w, UINT h);

    // DRAW PER FRAME
    // void PreDraw();

    //获取资源
    [[nodiscard]] ID3D11Device *GetDevice() const noexcept { return m_device.Get(); }
    [[nodiscard]] ID3D11DeviceContext *GetDeviceContext() const noexcept {
        return m_device_ctx.Get();
    }

    // renderer pipeline
    void BeginMainPass();
    void EndMainPass();
    void Present() const; // 被wnd_render的Update函数call

private:
    // 设备相关
    bool CreateBackBufferResources();
    void DestroyBackBufferResources();
    bool CreateRasterizerState();
private:
    static constexpr float m_clearColor[4]{0.2f, 0.4f, 0.6f, 1.0f};
    D3D11_VIEWPORT m_viewPorts[1]{};
    // devices ----
    D3D_FEATURE_LEVEL m_featureLevel{};
    cp<ID3D11Device> m_device{};
    cp<IDXGISwapChain> m_swapchain{};
    cp<ID3D11Texture2D> m_back_buffer{};
    cp<ID3D11RenderTargetView> m_rtv{};

    cp<ID3D11Texture2D> m_ds_buffer{};
    cp<ID3D11DepthStencilView> m_dsv{};
    cp<ID3D11DepthStencilState> m_ds_state{};

    cp<ID3D11DeviceContext> m_device_ctx{};
    cp<ID3D11RasterizerState> m_rasterizer_state{};

    // constant buffers ----



};


















#endif //RENDER_GRAPHIC_H
