[英]D3D - GetSurfaceLevel unhandled exception
I'm creating D3D cursor, so first I made Surface & Texture. 我正在创建D3D光标,所以首先我制作了Surface&Texture。 and doing this, I met error on GetSurfaceLevel() Function. 这样做,我遇到了GetSurfaceLevel()函数的错误。
Unhandled exception at 0x5B494B11 0xC0000005: Access violation reading location 0x00000000. 0x5B494B11 0xC0000005处的未处理异常:访问冲突读取位置0x00000000。
code: 码:
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 );
What should I do? 我该怎么办?
Unhandled exception at 0x5B494B11 0xC0000005: Access violation reading location 0x00000000.
This kind of error was caused by dereference a NULL pointer, check whether you have create the texture successfully. 这种错误是由取消引用NULL指针引起的,检查是否已成功创建纹理。 Make sure g_cursortex not NULL before calling g_cursortex->GetSurfaceLevel( 0, &g_surfcursor );
在调用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.