簡體   English   中英

D3D - GetSurfaceLevel未處理的異常

[英]D3D - GetSurfaceLevel unhandled exception

我正在創建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 );

我該怎么辦?

Unhandled exception at 0x5B494B11 0xC0000005: Access violation reading location 0x00000000.

這種錯誤是由取消引用NULL指針引起的,檢查是否已成功創建紋理。 在調用g_cursortex->GetSurfaceLevel( 0, &g_surfcursor );之前,確保g_cursortex不為NULL g_cursortex->GetSurfaceLevel( 0, &g_surfcursor );

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 );
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM