C ++ wcstomb_s错误重载

时间:2015-11-03 22:04:56

标签: c++ directx-11

大家好我一直关注youtube上的Direct x 11教程[视频2] :( https://www.youtube.com/watch?v=IyWdWclIX7I

但是我遇到了[第168行]一个"没有重载函数的实例" wcstombs_s"匹配参数列表" 现在我已经加倍检查错误,并没有找到任何错误。 谁能告诉我哪里出错了? 我不得不使用智能指针[ - >]而不是点来评估adapterdesc属性,这让我觉得参数有变化,但无法确定。

      #include "DXManager.h"



     DXManager::DXManager()
     {
     m_swapChain = 0;
     m_device = 0;
     m_deviceContext = 0;
     m_renderTargetView = 0;
     m_depthStencilBuffer = 0;
     m_depthStencilState = 0;
     m_depthStencilView = 0;
     m_rasterState = 0;
     m_alphaEnableBlendingState = 0;
     m_alphaDisabledBlendingState = 0;
     m_depthDisabledStencilState = 0;

    }


    DXManager::~DXManager()
    {
    if (m_swapChain)
    {
        m_swapChain->SetFullscreenState(false, NULL);
    }

    if (m_swapChain)
    {
        m_swapChain->Release();
        m_swapChain = 0;
    }

    if (m_device)
    {
        m_device->Release();
        m_device = 0;
    }

    if (m_deviceContext)
    {
        m_deviceContext->Release();
        m_deviceContext = 0;
    }

    if (m_renderTargetView)
    {
        m_renderTargetView->Release();
        m_renderTargetView = 0;
    }

    if (m_depthStencilBuffer)
    {
        m_depthStencilBuffer->Release();
        m_depthStencilBuffer = 0;
    }

    if (m_depthStencilState)
    {
        m_depthStencilState->Release();
        m_depthStencilState = 0;
    }

    if (m_depthStencilView)
    {
        m_depthStencilView->Release();
        m_depthStencilView = 0;
    }

    if (m_rasterState)
    {
        m_rasterState->Release();
        m_rasterState = 0;
    }

    if (m_alphaEnableBlendingState)
    {
        m_alphaEnableBlendingState->Release();
        m_alphaEnableBlendingState = 0;
    }

    if (m_alphaDisabledBlendingState)
    {
        m_alphaDisabledBlendingState->Release();
        m_alphaDisabledBlendingState = 0;
    }

    if (m_depthDisabledStencilState)
    {
        m_depthDisabledStencilState->Release();
        m_depthDisabledStencilState = 0;
    }
}

    bool DXManager::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hwnd, bool fullscreen)
    {
        HRESULT result;
        IDXGIFactory* factory;
        IDXGIAdapter* adapter;
        IDXGIOutput* adapterOutput;
        unsigned int numModes, numerator = 0, denuminator = 0,stringLength;
        DXGI_MODE_DESC* displayModeList;
        DXGI_ADAPTER_DESC* adapterDesc;
        int error;
        ID3D11Texture2D* backBufferPtr;
    m_vsync_enabled = vsync;

    result = CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&factory);
    if (FAILED(result))
    {
        return false;
    }

    result = factory->EnumAdapters(0, &adapter);
    if (FAILED(result))
    {
        return false;
    }

    result = adapter->EnumOutputs(0, &adapterOutput);
    if (FAILED(result))
    {
        return false;
    }

    result = adapterOutput->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &numModes, NULL);
    if (FAILED(result))
    {
        return false;
    }

    displayModeList = new DXGI_MODE_DESC[numModes];

    result = adapterOutput->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &numModes,displayModeList);
    if (FAILED(result))
    {
        return false;
    }

    for (int i = 0; i < numModes; ++i)
    {
        if(displayModeList[i].Width == (unsigned int)screenWidth)
        { 
            if (displayModeList[i].Height == (unsigned int)screenHeight)
            {
                numerator = displayModeList[i].RefreshRate.Numerator;
                denuminator = displayModeList[i].RefreshRate.Denominator;
            }
        }

    }

    if (numerator = 0 && denuminator == 0)
    {
        return false;
    }

    result = adapter->GetDesc(adapterDesc);
    if (FAILED(result))
    {
        return false;
    }

    m_videoCardMemory = (int)(adapterDesc -> DedicatedVideoMemory / 1024 / 1024);

    error = wcstombs_s(&stringLength, m_videoCardDiscription, 128, adapterDesc->Description, 128);
    if (error != 0)
    {
        return false;
    }

    delete[] displayModeList;
    displayModeList = 0;

    adapterOutput->Release();
    adapterOutput = 0;

    adapter->Release();
    adapter = 0;

    factory->Release();
    factory = 0;
}

void DXManager::BeginScene(float r, float g, float b, float a)
{
}

void DXManager::EndScene()
{
}

void DXManager::EnableAlphaBlending(bool enable)
{
}

void DXManager::EnableZBffer(bool enable)
{
}

ID3D11Device * DXManager::GetDevice()
{
    return nullptr;
}

ID3D11DeviceContext * DXManager::GetDevicecontext()
{
    return nullptr;
}

bool DXManager::InitializeSwapChain(HWND hwnd, bool fullscreen, int screenWidth, int screenHeight, unsigned int numerator, unsigned int denomerator)
{
    return false;
}

bool DXManager::InitializeDepthBuffer(int screenWidth, int screenHeight)
{
    return false;
}

bool DXManager::InitializeDepthStencilBufer()
{
    return false;
}

bool DXManager::InitializeStencilView()
{
    return false;
}

bool DXManager::InitializeRasterState()
{
    return false;
}

void DXManager::InitializeViewport(int screenWidth, int screenHeight)
{
}

bool DXManager::InitializeAlphaBlending()
{
    return false;
}

bool DXManager::InitializeZBuffer()
{
    return false;
}

视频声明

private:
    bool InitializeSwapChain(HWND hwnd, bool fullscreen, int screenWidth, int screenHeight, unsigned int numerator, unsigned int denomerator);
    bool InitializeDepthBuffer(int screenWidth, int screenHeight);
    bool InitializeDepthStencilBufer();
    bool InitializeStencilView();
    bool InitializeRasterState();
    void InitializeViewport(int screenWidth, int screenHeight);
    bool InitializeAlphaBlending();
    bool InitializeZBuffer();

    bool m_vsync_enabled;
    int m_videoCardMemory;
    char*m_videoCardDiscription[128];
    IDXGISwapChain* m_swapChain;
    IDXGIDevice* m_device;
    ID3D11DeviceContext* m_deviceContext;
    ID3D11RenderTargetView* m_renderTargetView;
    ID3D11Texture2D* m_depthStencilBuffer;
    ID3D11DepthStencilState* m_depthStencilState;
    ID3D11DepthStencilView* m_depthStencilView;
    ID3D11RasterizerState* m_rasterState;
    ID3D11BlendState* m_alphaEnableBlendingState;
    ID3D11BlendState* m_alphaDisabledBlendingState;
    ID3D11DepthStencilState* m_depthDisabledStencilState;

    };

0 个答案:

没有答案