<commit_before>#pragma once
#include <Internal/Manager/DirectXManagerImpl.hpp>
#include <GraphicModuleContext.hpp>
#include <d3d11_1.h>
#include <SDL2/SDL.h>

#include <iostream>
namespace DoremiEngine
{
    namespace Graphic
    {
        DirectXManagerImpl::DirectXManagerImpl(const GraphicModuleContext& p_graphicContext) : m_graphicContext(p_graphicContext) {}
        DirectXManagerImpl::~DirectXManagerImpl() {}

        void InitializeSDL()
        {
            if(!SDL_WasInit(SDL_INIT_VIDEO))
            {
                if(SDL_Init(SDL_INIT_VIDEO) != 0)
                {
                    std::cout << "SDL_Ubut Error: " << SDL_GetError() << std::endl;
                    SDL_QUIT;
                }
                else
                {
                    // TODO logger maybe
                }
            }
        }

        void DirectXManagerImpl::InitializeDirectX()
        {

            InitializeSDL();

            SDL_Window* m_win = SDL_CreateWindow("Do-Re-Mi by Let Him Be: Interactive", 1200, 200, 800, 800,
                                                 SDL_WINDOW_SHOWN); // TODOKO Get height and width form reliable source
            if(!m_win)
            {
                std::cout << "SDL_CreateWindow Error: " << SDL_GetError() << std::endl;
                SDL_QUIT;
            }
            DXGI_SWAP_CHAIN_DESC scd;

            // clear out the struct for use
            ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC));

            // fill the swap chain description struct
            scd.BufferCount = 1; // one back buffer
            scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; // use 32-bit color
            scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // how swap chain is to be used
            scd.OutputWindow = GetActiveWindow(); // the window to be used
            if(scd.OutputWindow == nullptr)
            {
                InitializeSDL();
                SDL_Window* m_win = SDL_CreateWindow("Do-Re-Mi by Let Him Be: Interactive", 1200, 200, 800, 800,
                                                     SDL_WINDOW_SHOWN); // TODOKO Get height and width form reliable source
                if(!m_win)
                {
                    std::cout << "SDL_CreateWindow Error: " << SDL_GetError() << std::endl;
                    SDL_QUIT;
                }
            }
            scd.OutputWindow = GetActiveWindow();
            scd.SampleDesc.Count = 4; // how many multisamples
            scd.Windowed = TRUE; // windowed/full-screen mode

            HRESULT res = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, D3D11_CREATE_DEVICE_DEBUG, NULL, NULL,
                                                        D3D11_SDK_VERSION, &scd, &m_swapChain, &m_device, NULL, &m_deviceContext);

            ID3D11Texture2D* t_BackBuffer;
            m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&t_BackBuffer);
            m_device->CreateRenderTargetView(t_BackBuffer, NULL, &m_backBuffer);
            t_BackBuffer->Release();

            // Rasterizer info, here you can change from backface culling mm
            // We might want this as a class or something to enable easy switching between rasterizers
            D3D11_RASTERIZER_DESC rastDesc;
            ZeroMemory(&rastDesc, sizeof(rastDesc));
            rastDesc.FillMode = D3D11_FILL_SOLID;
            rastDesc.CullMode = D3D11_CULL_NONE;
            rastDesc.FrontCounterClockwise = false;
            rastDesc.DepthBias = 0;
            rastDesc.DepthBiasClamp = 0.0f;
            rastDesc.SlopeScaledDepthBias = 0.0f;
            rastDesc.DepthClipEnable = false;
            rastDesc.ScissorEnable = false;
            rastDesc.MultisampleEnable = true;
            rastDesc.AntialiasedLineEnable = false;
            ID3D11RasterizerState* tRastHandle;
            res = m_device->CreateRasterizerState(&rastDesc, &tRastHandle);
            m_deviceContext->RSSetState(tRastHandle);

            // Depth buffer
            // Might want this in a class for readability and easy changing between states<commit_msg>Added todo for graphics module<commit_after>#pragma once
#include <Internal/Manager/DirectXManagerImpl.hpp>
#include <GraphicModuleContext.hpp>
#include <d3d11_1.h>
#include <SDL2/SDL.h>

#include <iostream>
namespace DoremiEngine
{
    namespace Graphic
    {
        DirectXManagerImpl::DirectXManagerImpl(const GraphicModuleContext& p_graphicContext) : m_graphicContext(p_graphicContext) {}
        DirectXManagerImpl::~DirectXManagerImpl() {}

        void InitializeSDL()
        {
            if(!SDL_WasInit(SDL_INIT_VIDEO))
            {
                if(SDL_Init(SDL_INIT_VIDEO) != 0)
                {
                    std::cout << "SDL_Ubut Error: " << SDL_GetError() << std::endl;
                    SDL_QUIT;
                }
                else
                {
                    // TODO logger maybe
                }
            }
        }

        void DirectXManagerImpl::InitializeDirectX()
        {

            InitializeSDL();

            SDL_Window* m_win = SDL_CreateWindow("Do-Re-Mi by Let Him Be: Interactive", 1200, 200, 800, 800,
                                                 SDL_WINDOW_SHOWN); // TODOKO Get height and width form reliable source
            if(!m_win)
            {
                std::cout << "SDL_CreateWindow Error: " << SDL_GetError() << std::endl;
                SDL_QUIT;
            }
            DXGI_SWAP_CHAIN_DESC scd;

            // clear out the struct for use
            ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC));

            // fill the swap chain description struct
            scd.BufferCount = 1; // one back buffer
            scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; // use 32-bit color
            scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // how swap chain is to be used
            scd.OutputWindow = GetActiveWindow(); // the window to be used
            if(scd.OutputWindow == nullptr)
            {
                InitializeSDL();
                SDL_Window* m_win = SDL_CreateWindow("Do-Re-Mi by Let Him Be: Interactive", 1200, 200, 800, 800,
                                                     SDL_WINDOW_SHOWN); // TODOKO Get height and width form reliable source
                if(!m_win)
                {
                    std::cout << "SDL_CreateWindow Error: " << SDL_GetError() << std::endl;
                    SDL_QUIT;
                }
            }
            scd.OutputWindow = GetActiveWindow();
            scd.SampleDesc.Count = 4; // how many multisamples
            scd.Windowed = TRUE; // windowed/full-screen mode

            // TODOKO CHECK THIS pls :)
            HRESULT res = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, D3D11_CREATE_DEVICE_DEBUG, NULL, NULL,
                                                        D3D11_SDK_VERSION, &scd, &m_swapChain, &m_device, NULL, &m_deviceContext);

            ID3D11Texture2D* t_BackBuffer;
            m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&t_BackBuffer);
            m_device->CreateRenderTargetView(t_BackBuffer, NULL, &m_backBuffer);
            t_BackBuffer->Release();

            // Rasterizer info, here you can change from backface culling mm
            // We might want this as a class or something to enable easy switching between rasterizers
            D3D11_RASTERIZER_DESC rastDesc;
            ZeroMemory(&rastDesc, sizeof(rastDesc));
            rastDesc.FillMode = D3D11_FILL_SOLID;
            rastDesc.CullMode = D3D11_CULL_NONE;
            rastDesc.FrontCounterClockwise = false;
            rastDesc.DepthBias = 0;
            rastDesc.DepthBiasClamp = 0.0f;
            rastDesc.SlopeScaledDepthBias = 0.0f;
            rastDesc.DepthClipEnable = false;
            rastDesc.ScissorEnable = false;
            rastDesc.MultisampleEnable = true;
            rastDesc.AntialiasedLineEnable = false;
            ID3D11RasterizerState* tRastHandle;
            res = m_device->CreateRasterizerState(&rastDesc, &tRastHandle);
            m_deviceContext->RSSetState(tRastHandle);

            // Depth buffer
            // Might want this in a class for readability and easy changing between states
{'fraction_non_alphanumeric': 0.08437084491720054, 'fraction_numerical': 0.018373020669648254, 'mean_word_length': 1.7774420946626384, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3630073', 'n_tokens_mistral': 2539, 'n_tokens_neox': 2303, 'n_words': 495}