瀏覽代碼

always report directx errors that are not out_of_memory

ncannasse 7 年之前
父節點
當前提交
3829e5d3a8
共有 1 個文件被更改,包括 5 次插入5 次删除
  1. 5 5
      libs/directx/directx.cpp

+ 5 - 5
libs/directx/directx.cpp

@@ -6,11 +6,7 @@
 #include <d3d11.h>
 #include <D3Dcompiler.h>
 
-#ifdef HL_DEBUG
-#	define DXERR(cmd)	{ HRESULT __ret = cmd; if( __ret != S_OK ) hl_error_msg(USTR("DXERROR %X line %d"),(DWORD)__ret,__LINE__); }
-#else
-#	define DXERR(cmd)	if( (cmd) != S_OK ) return NULL;
-#endif
+#define DXERR(cmd)	{ HRESULT __ret = cmd; if( __ret == E_OUTOFMEMORY ) return NULL; if( __ret != S_OK ) ReportDxError(__ret,__LINE__); }
 
 typedef struct {
 	ID3D11Device *device;
@@ -39,6 +35,10 @@ static IDXGIFactory *GetDXGI() {
 	return factory;
 }
 
+static void ReportDxError( HRESULT err, int line ) {
+	hl_error_msg(USTR("DXERROR %X line %d"),(DWORD)err,line);
+}
+
 HL_PRIM dx_driver *HL_NAME(create)( HWND window, int format, int flags, int restrictLevel ) {
 	static D3D_FEATURE_LEVEL levels[] = {
 		D3D_FEATURE_LEVEL_11_1,