【问题标题】:D3D - GetSurfaceLevel unhandled exceptionD3D - GetSurfaceLevel 未处理的异常
【发布时间】:2014-04-20 16:18:34
【问题描述】:

我正在创建 D3D 光标,所以首先我制作了 Surface & Texture。 这样做,我在 GetSurfaceLevel() 函数上遇到了错误。

0x5B494B11 处未处理的异常 0xC0000005:访问冲突读取位置0x00000000。

代码:

D3DXCreateTextureFromFile( g_D3dDevice, L"cursor1.bmp", &g_cursortex );
g_cursortex->GetSurfaceLevel( 0, &g_surfcursor );
g_D3dDevice->SetCursorProperties( 0, 0, g_surfcursor );

g_D3dDevice->ShowCursor( TRUE );

我该怎么办?

【问题讨论】:

    标签: c++ direct3d


    【解决方案1】:
    Unhandled exception at 0x5B494B11 0xC0000005: Access violation reading location 0x00000000.
    

    这种错误是由于取消引用NULL指针引起的,请检查您是否已成功创建纹理。在调用g_cursortex->GetSurfaceLevel( 0, &g_surfcursor );之前确保g_cursortex不为NULL

    HRESULT hr = D3DXCreateTextureFromFile( g_D3dDevice, L"cursor1.bmp", &g_cursortex );
    if (SUCCEEDED(hr))
    {
        g_cursortex->GetSurfaceLevel( 0, &g_surfcursor );
        g_D3dDevice->SetCursorProperties( 0, 0, g_surfcursor );
    }
    

    【讨论】:

      猜你喜欢
      • 2011-11-19
      • 1970-01-01
      • 1970-01-01
      • 2011-01-16
      相关资源
      最近更新 更多