Cleanup fatal error enum.
This commit is contained in:
Родитель
6c6efd274e
Коммит
11a05e8cd7
|
@ -231,12 +231,9 @@ namespace bgfx
|
|||
{
|
||||
MinimumRequiredSpecs = 1,
|
||||
InvalidShader,
|
||||
D3D9_UnableToCreateInterface,
|
||||
D3D9_UnableToCreateDevice,
|
||||
D3D9_UnableToCreateRenderTarget,
|
||||
D3D9_UnableToCreateTexture,
|
||||
D3D11_UnableToInitialize,
|
||||
OPENGL_UnableToCreateContext,
|
||||
UnableToInitialize,
|
||||
UnableToCreateRenderTarget,
|
||||
UnableToCreateTexture,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -251,10 +251,10 @@ namespace bgfx
|
|||
void init()
|
||||
{
|
||||
m_d3d11dll = LoadLibrary("d3d11.dll");
|
||||
BGFX_FATAL(NULL != m_d3d11dll, Fatal::D3D11_UnableToInitialize, "Failed to load d3d11.dll.");
|
||||
BGFX_FATAL(NULL != m_d3d11dll, Fatal::UnableToInitialize, "Failed to load d3d11.dll.");
|
||||
|
||||
PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN d3D11CreateDeviceAndSwapChain = (PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN)GetProcAddress(m_d3d11dll, "D3D11CreateDeviceAndSwapChain");
|
||||
BGFX_FATAL(NULL != d3D11CreateDeviceAndSwapChain, Fatal::D3D11_UnableToInitialize, "Function D3D11CreateDeviceAndSwapChain not found.");
|
||||
BGFX_FATAL(NULL != d3D11CreateDeviceAndSwapChain, Fatal::UnableToInitialize, "Function D3D11CreateDeviceAndSwapChain not found.");
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
|
@ -297,7 +297,7 @@ namespace bgfx
|
|||
, &featureLevel
|
||||
, &m_deviceCtx
|
||||
);
|
||||
BGFX_FATAL(SUCCEEDED(hr), Fatal::D3D11_UnableToInitialize, "Unable to create Direct3D11 device.");
|
||||
BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to create Direct3D11 device.");
|
||||
|
||||
for (uint32_t ii = 0; ii < PredefinedUniform::Count; ++ii)
|
||||
{
|
||||
|
|
|
@ -232,7 +232,7 @@ namespace bgfx
|
|||
m_params.BackBufferHeight = rect.bottom-rect.top;
|
||||
|
||||
m_d3d9dll = LoadLibrary("d3d9.dll");
|
||||
BGFX_FATAL(NULL != m_d3d9dll, Fatal::D3D9_UnableToCreateInterface, "Failed to load d3d9.dll.");
|
||||
BGFX_FATAL(NULL != m_d3d9dll, Fatal::UnableToInitialize, "Failed to load d3d9.dll.");
|
||||
|
||||
m_D3DPERF_SetMarker = (D3DPERF_SetMarkerFunc)GetProcAddress(m_d3d9dll, "D3DPERF_SetMarker");
|
||||
m_D3DPERF_BeginEvent = (D3DPERF_BeginEventFunc)GetProcAddress(m_d3d9dll, "D3DPERF_BeginEvent");
|
||||
|
@ -240,15 +240,15 @@ namespace bgfx
|
|||
|
||||
#if BGFX_CONFIG_RENDERER_DIRECT3D9EX
|
||||
Direct3DCreate9ExFn direct3DCreate9Ex = (Direct3DCreate9ExFn)GetProcAddress(m_d3d9dll, "Direct3DCreate9Ex");
|
||||
BGFX_FATAL(NULL != direct3DCreate9Ex, Fatal::D3D9_UnableToCreateInterface, "Function Direct3DCreate9Ex not found.");
|
||||
BGFX_FATAL(NULL != direct3DCreate9Ex, Fatal::UnableToInitialize, "Function Direct3DCreate9Ex not found.");
|
||||
direct3DCreate9Ex(D3D_SDK_VERSION, &m_d3d9);
|
||||
#else
|
||||
Direct3DCreate9Fn direct3DCreate9 = (Direct3DCreate9Fn)GetProcAddress(m_d3d9dll, "Direct3DCreate9");
|
||||
BGFX_FATAL(NULL != direct3DCreate9, Fatal::D3D9_UnableToCreateInterface, "Function Direct3DCreate9 not found.");
|
||||
BGFX_FATAL(NULL != direct3DCreate9, Fatal::UnableToInitialize, "Function Direct3DCreate9 not found.");
|
||||
m_d3d9 = direct3DCreate9(D3D_SDK_VERSION);
|
||||
#endif // defined(D3D_DISABLE_9EX)
|
||||
|
||||
BGFX_FATAL(m_d3d9, Fatal::D3D9_UnableToCreateInterface, "Unable to create Direct3D.");
|
||||
BGFX_FATAL(m_d3d9, Fatal::UnableToInitialize, "Unable to create Direct3D.");
|
||||
|
||||
m_adapter = D3DADAPTER_DEFAULT;
|
||||
m_deviceType = D3DDEVTYPE_HAL;
|
||||
|
@ -313,7 +313,7 @@ namespace bgfx
|
|||
#endif // BGFX_CONFIG_RENDERER_DIRECT3D9EX
|
||||
}
|
||||
|
||||
BGFX_FATAL(m_device, Fatal::D3D9_UnableToCreateDevice, "Unable to create Direct3D9 device.");
|
||||
BGFX_FATAL(m_device, Fatal::UnableToInitialize, "Unable to create Direct3D9 device.");
|
||||
|
||||
DX_CHECK(m_device->GetDeviceCaps(&m_caps) );
|
||||
|
||||
|
@ -1100,7 +1100,7 @@ namespace bgfx
|
|||
, NULL
|
||||
) );
|
||||
|
||||
BGFX_FATAL(NULL != m_texture2d, Fatal::D3D9_UnableToCreateTexture, "Failed to create texture (size: %dx%d, mips: %d, fmt: 0x%08x)."
|
||||
BGFX_FATAL(NULL != m_texture2d, Fatal::UnableToCreateTexture, "Failed to create texture (size: %dx%d, mips: %d, fmt: 0x%08x)."
|
||||
, _width
|
||||
, _height
|
||||
, _numMips
|
||||
|
@ -1123,7 +1123,7 @@ namespace bgfx
|
|||
, NULL
|
||||
) );
|
||||
|
||||
BGFX_FATAL(NULL != m_texture3d, Fatal::D3D9_UnableToCreateTexture, "Failed to create volume texture (size: %dx%dx%d, mips: %d, fmt: 0x%08x)."
|
||||
BGFX_FATAL(NULL != m_texture3d, Fatal::UnableToCreateTexture, "Failed to create volume texture (size: %dx%dx%d, mips: %d, fmt: 0x%08x)."
|
||||
, _width
|
||||
, _height
|
||||
, _depth
|
||||
|
@ -1145,7 +1145,7 @@ namespace bgfx
|
|||
, NULL
|
||||
) );
|
||||
|
||||
BGFX_FATAL(NULL != m_textureCube, Fatal::D3D9_UnableToCreateTexture, "Failed to create cube texture (edge: %d, mips: %d, fmt: 0x%08x)."
|
||||
BGFX_FATAL(NULL != m_textureCube, Fatal::UnableToCreateTexture, "Failed to create cube texture (edge: %d, mips: %d, fmt: 0x%08x)."
|
||||
, _edge
|
||||
, _numMips
|
||||
, _fmt
|
||||
|
@ -1472,7 +1472,7 @@ namespace bgfx
|
|||
, NULL
|
||||
) );
|
||||
|
||||
BGFX_FATAL(m_rt, Fatal::D3D9_UnableToCreateRenderTarget, "Unable to create 1x1 render target.");
|
||||
BGFX_FATAL(m_rt, Fatal::UnableToCreateRenderTarget, "Unable to create 1x1 render target.");
|
||||
|
||||
DX_CHECK(s_renderCtx.m_device->CreateTexture(m_width
|
||||
, m_height
|
||||
|
@ -1484,7 +1484,7 @@ namespace bgfx
|
|||
, NULL
|
||||
) );
|
||||
|
||||
BGFX_FATAL(m_depthTexture, Fatal::D3D9_UnableToCreateRenderTarget, "Unable to create depth texture.");
|
||||
BGFX_FATAL(m_depthTexture, Fatal::UnableToCreateRenderTarget, "Unable to create depth texture.");
|
||||
|
||||
DX_CHECK(m_depthTexture->GetSurfaceLevel(0, &m_depth) );
|
||||
}
|
||||
|
@ -1502,7 +1502,7 @@ namespace bgfx
|
|||
, NULL
|
||||
) );
|
||||
|
||||
BGFX_FATAL(m_rt, Fatal::D3D9_UnableToCreateRenderTarget, "Unable to create MSAA render target.");
|
||||
BGFX_FATAL(m_rt, Fatal::UnableToCreateRenderTarget, "Unable to create MSAA render target.");
|
||||
}
|
||||
|
||||
if (0 < colorFormat)
|
||||
|
@ -1517,7 +1517,7 @@ namespace bgfx
|
|||
, NULL
|
||||
) );
|
||||
|
||||
BGFX_FATAL(m_colorTexture, Fatal::D3D9_UnableToCreateRenderTarget, "Unable to create color render target.");
|
||||
BGFX_FATAL(m_colorTexture, Fatal::UnableToCreateRenderTarget, "Unable to create color render target.");
|
||||
|
||||
DX_CHECK(m_colorTexture->GetSurfaceLevel(0, &m_color) );
|
||||
}
|
||||
|
@ -1534,7 +1534,7 @@ namespace bgfx
|
|||
, NULL
|
||||
) );
|
||||
|
||||
BGFX_FATAL(m_depth, Fatal::D3D9_UnableToCreateRenderTarget, "Unable to create depth stencil surface.");
|
||||
BGFX_FATAL(m_depth, Fatal::UnableToCreateRenderTarget, "Unable to create depth stencil surface.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ namespace bgfx
|
|||
# define GL_IMPORT(_optional, _proto, _func) \
|
||||
{ \
|
||||
_func = (_proto)eglGetProcAddress(#_func); \
|
||||
BGFX_FATAL(_optional || NULL != _func, Fatal::OPENGL_UnableToCreateContext, "Failed to create OpenGL context. eglGetProcAddress(\"%s\")", #_func); \
|
||||
BGFX_FATAL(_optional || NULL != _func, Fatal::UnableToInitialize, "Failed to create OpenGL context. eglGetProcAddress(\"%s\")", #_func); \
|
||||
}
|
||||
# include "glimports.h"
|
||||
# undef GL_IMPORT
|
||||
|
@ -164,22 +164,22 @@ namespace bgfx
|
|||
if (NULL == m_hdc)
|
||||
{
|
||||
m_opengl32dll = LoadLibrary("opengl32.dll");
|
||||
BGFX_FATAL(NULL != m_opengl32dll, Fatal::OPENGL_UnableToCreateContext, "Failed to load opengl32.dll.");
|
||||
BGFX_FATAL(NULL != m_opengl32dll, Fatal::UnableToInitialize, "Failed to load opengl32.dll.");
|
||||
|
||||
wglGetProcAddress = (PFNWGLGETPROCADDRESSPROC)GetProcAddress(m_opengl32dll, "wglGetProcAddress");
|
||||
BGFX_FATAL(NULL != wglGetProcAddress, Fatal::OPENGL_UnableToCreateContext, "Failed get wglGetProcAddress.");
|
||||
BGFX_FATAL(NULL != wglGetProcAddress, Fatal::UnableToInitialize, "Failed get wglGetProcAddress.");
|
||||
|
||||
wglMakeCurrent = (PFNWGLMAKECURRENTPROC)GetProcAddress(m_opengl32dll, "wglMakeCurrent");
|
||||
BGFX_FATAL(NULL != wglMakeCurrent, Fatal::OPENGL_UnableToCreateContext, "Failed get wglMakeCurrent.");
|
||||
BGFX_FATAL(NULL != wglMakeCurrent, Fatal::UnableToInitialize, "Failed get wglMakeCurrent.");
|
||||
|
||||
wglCreateContext = (PFNWGLCREATECONTEXTPROC)GetProcAddress(m_opengl32dll, "wglCreateContext");
|
||||
BGFX_FATAL(NULL != wglCreateContext, Fatal::OPENGL_UnableToCreateContext, "Failed get wglCreateContext.");
|
||||
BGFX_FATAL(NULL != wglCreateContext, Fatal::UnableToInitialize, "Failed get wglCreateContext.");
|
||||
|
||||
wglDeleteContext = (PFNWGLDELETECONTEXTPROC)GetProcAddress(m_opengl32dll, "wglDeleteContext");
|
||||
BGFX_FATAL(NULL != wglDeleteContext, Fatal::OPENGL_UnableToCreateContext, "Failed get wglDeleteContext.");
|
||||
BGFX_FATAL(NULL != wglDeleteContext, Fatal::UnableToInitialize, "Failed get wglDeleteContext.");
|
||||
|
||||
m_hdc = GetDC(g_bgfxHwnd);
|
||||
BGFX_FATAL(NULL != m_hdc, Fatal::OPENGL_UnableToCreateContext, "GetDC failed!");
|
||||
BGFX_FATAL(NULL != m_hdc, Fatal::UnableToInitialize, "GetDC failed!");
|
||||
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
memset(&pfd, 0, sizeof(pfd) );
|
||||
|
@ -193,19 +193,19 @@ namespace bgfx
|
|||
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||
|
||||
int pixelFormat = ChoosePixelFormat(m_hdc, &pfd);
|
||||
BGFX_FATAL(0 != pixelFormat, Fatal::OPENGL_UnableToCreateContext, "ChoosePixelFormat failed!");
|
||||
BGFX_FATAL(0 != pixelFormat, Fatal::UnableToInitialize, "ChoosePixelFormat failed!");
|
||||
|
||||
DescribePixelFormat(m_hdc, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
|
||||
|
||||
int result;
|
||||
result = SetPixelFormat(m_hdc, pixelFormat, &pfd);
|
||||
BGFX_FATAL(0 != result, Fatal::OPENGL_UnableToCreateContext, "SetPixelFormat failed!");
|
||||
BGFX_FATAL(0 != result, Fatal::UnableToInitialize, "SetPixelFormat failed!");
|
||||
|
||||
m_context = wglCreateContext(m_hdc);
|
||||
BGFX_FATAL(NULL != m_context, Fatal::OPENGL_UnableToCreateContext, "wglCreateContext failed!");
|
||||
BGFX_FATAL(NULL != m_context, Fatal::UnableToInitialize, "wglCreateContext failed!");
|
||||
|
||||
result = wglMakeCurrent(m_hdc, m_context);
|
||||
BGFX_FATAL(0 != result, Fatal::OPENGL_UnableToCreateContext, "wglMakeCurrent failed!");
|
||||
BGFX_FATAL(0 != result, Fatal::UnableToInitialize, "wglMakeCurrent failed!");
|
||||
|
||||
# define GL_IMPORT(_optional, _proto, _func) \
|
||||
{ \
|
||||
|
@ -214,7 +214,7 @@ namespace bgfx
|
|||
{ \
|
||||
_func = (_proto)GetProcAddress(m_opengl32dll, #_func); \
|
||||
} \
|
||||
BGFX_FATAL(_optional || NULL != _func, Fatal::OPENGL_UnableToCreateContext, "Failed to create OpenGL context. wglGetProcAddress(\"%s\")", #_func); \
|
||||
BGFX_FATAL(_optional || NULL != _func, Fatal::UnableToInitialize, "Failed to create OpenGL context. wglGetProcAddress(\"%s\")", #_func); \
|
||||
}
|
||||
# include "glimports.h"
|
||||
# undef GL_IMPORT
|
||||
|
@ -225,14 +225,14 @@ namespace bgfx
|
|||
{
|
||||
Display* display = XOpenDisplay(0);
|
||||
XLockDisplay(display);
|
||||
BGFX_FATAL(display, Fatal::OPENGL_UnableToCreateContext, "Failed to open X display (0).");
|
||||
BGFX_FATAL(display, Fatal::UnableToInitialize, "Failed to open X display (0).");
|
||||
|
||||
int glxMajor, glxMinor;
|
||||
if (!glXQueryVersion(display, &glxMajor, &glxMinor) )
|
||||
{
|
||||
BGFX_FATAL(false, Fatal::OPENGL_UnableToCreateContext, "Failed to query GLX version");
|
||||
BGFX_FATAL(false, Fatal::UnableToInitialize, "Failed to query GLX version");
|
||||
}
|
||||
BGFX_FATAL((glxMajor == 1 && glxMinor >= 3) || glxMajor > 1, Fatal::OPENGL_UnableToCreateContext, "GLX version is not >=1.3 (%d.%d).", glxMajor, glxMinor);
|
||||
BGFX_FATAL((glxMajor == 1 && glxMinor >= 3) || glxMajor > 1, Fatal::UnableToInitialize, "GLX version is not >=1.3 (%d.%d).", glxMajor, glxMinor);
|
||||
|
||||
const int glxAttribs[] =
|
||||
{
|
||||
|
@ -287,7 +287,7 @@ namespace bgfx
|
|||
}
|
||||
|
||||
XFree(configs);
|
||||
BGFX_FATAL(visualInfo, Fatal::OPENGL_UnableToCreateContext, "Failed to find a suitable X11 display configuration.");
|
||||
BGFX_FATAL(visualInfo, Fatal::UnableToInitialize, "Failed to find a suitable X11 display configuration.");
|
||||
|
||||
// Generate colormaps
|
||||
XSetWindowAttributes windowAttrs;
|
||||
|
@ -305,7 +305,7 @@ namespace bgfx
|
|||
, CWBorderPixel|CWColormap
|
||||
, &windowAttrs
|
||||
);
|
||||
BGFX_FATAL(window, Fatal::OPENGL_UnableToCreateContext, "Failed to create X11 window.");
|
||||
BGFX_FATAL(window, Fatal::UnableToInitialize, "Failed to create X11 window.");
|
||||
|
||||
XMapRaised(display, window);
|
||||
XFlush(display);
|
||||
|
@ -315,7 +315,7 @@ namespace bgfx
|
|||
|
||||
typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
|
||||
glXCreateContextAttribsARBProc glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc)glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB");
|
||||
BGFX_FATAL(glXCreateContextAttribsARB, Fatal::OPENGL_UnableToCreateContext, "Failed to get glXCreateContextAttribsARB.");
|
||||
BGFX_FATAL(glXCreateContextAttribsARB, Fatal::UnableToInitialize, "Failed to get glXCreateContextAttribsARB.");
|
||||
|
||||
const int contextArrib[] =
|
||||
{
|
||||
|
@ -325,14 +325,14 @@ namespace bgfx
|
|||
};
|
||||
|
||||
m_context = glXCreateContextAttribsARB(display, bestconfig, 0, True, contextArrib);
|
||||
BGFX_FATAL(m_context, Fatal::OPENGL_UnableToCreateContext, "Failed to create GLX context.");
|
||||
BGFX_FATAL(m_context, Fatal::UnableToInitialize, "Failed to create GLX context.");
|
||||
|
||||
glXMakeCurrent(display, window, m_context);
|
||||
|
||||
# define GL_IMPORT(_optional, _proto, _func) \
|
||||
{ \
|
||||
_func = (_proto)glXGetProcAddress((const GLubyte*)#_func); \
|
||||
BGFX_FATAL(_optional || NULL != _func, Fatal::OPENGL_UnableToCreateContext, "Failed to create OpenGL context. glXGetProcAddress %s", #_func); \
|
||||
BGFX_FATAL(_optional || NULL != _func, Fatal::UnableToInitialize, "Failed to create OpenGL context. glXGetProcAddress %s", #_func); \
|
||||
}
|
||||
# include "glimports.h"
|
||||
# undef GL_IMPORT
|
||||
|
@ -358,12 +358,12 @@ namespace bgfx
|
|||
nwt = g_bgfxHwnd;
|
||||
# endif // BX_PLATFORM_
|
||||
m_display = eglGetDisplay(ndt);
|
||||
BGFX_FATAL(m_display != EGL_NO_DISPLAY, Fatal::OPENGL_UnableToCreateContext, "Failed to create display 0x%08x", m_display);
|
||||
BGFX_FATAL(m_display != EGL_NO_DISPLAY, Fatal::UnableToInitialize, "Failed to create display 0x%08x", m_display);
|
||||
|
||||
EGLint major = 0;
|
||||
EGLint minor = 0;
|
||||
EGLBoolean success = eglInitialize(m_display, &major, &minor);
|
||||
BGFX_FATAL(success && major >= 1 && minor >= 3, Fatal::OPENGL_UnableToCreateContext, "Failed to initialize %d.%d", major, minor);
|
||||
BGFX_FATAL(success && major >= 1 && minor >= 3, Fatal::UnableToInitialize, "Failed to initialize %d.%d", major, minor);
|
||||
|
||||
EGLint attrs[] =
|
||||
{
|
||||
|
@ -392,16 +392,16 @@ namespace bgfx
|
|||
EGLint numConfig = 0;
|
||||
EGLConfig config = 0;
|
||||
success = eglChooseConfig(m_display, attrs, &config, 1, &numConfig);
|
||||
BGFX_FATAL(success, Fatal::OPENGL_UnableToCreateContext, "eglChooseConfig");
|
||||
BGFX_FATAL(success, Fatal::UnableToInitialize, "eglChooseConfig");
|
||||
|
||||
m_surface = eglCreateWindowSurface(m_display, config, nwt, NULL);
|
||||
BGFX_FATAL(m_surface != EGL_NO_SURFACE, Fatal::OPENGL_UnableToCreateContext, "Failed to create surface.");
|
||||
BGFX_FATAL(m_surface != EGL_NO_SURFACE, Fatal::UnableToInitialize, "Failed to create surface.");
|
||||
|
||||
m_context = eglCreateContext(m_display, config, EGL_NO_CONTEXT, contextAttrs);
|
||||
BGFX_FATAL(m_context != EGL_NO_CONTEXT, Fatal::OPENGL_UnableToCreateContext, "Failed to create context.");
|
||||
BGFX_FATAL(m_context != EGL_NO_CONTEXT, Fatal::UnableToInitialize, "Failed to create context.");
|
||||
|
||||
success = eglMakeCurrent(m_display, m_surface, m_surface, m_context);
|
||||
BGFX_FATAL(success, Fatal::OPENGL_UnableToCreateContext, "Failed to set context.");
|
||||
BGFX_FATAL(success, Fatal::UnableToInitialize, "Failed to set context.");
|
||||
|
||||
# if BX_PLATFORM_EMSCRIPTEN
|
||||
emscripten_set_canvas_size(_width, _height);
|
||||
|
@ -410,7 +410,7 @@ namespace bgfx
|
|||
{ \
|
||||
_func = (_proto)eglGetProcAddress(#_func); \
|
||||
BX_TRACE(#_func " 0x%08x", _func); \
|
||||
BGFX_FATAL(_optional || NULL != _func, Fatal::OPENGL_UnableToCreateContext, "Failed to create OpenGLES context. eglGetProcAddress(\"%s\")", #_func); \
|
||||
BGFX_FATAL(_optional || NULL != _func, Fatal::UnableToInitialize, "Failed to create OpenGLES context. eglGetProcAddress(\"%s\")", #_func); \
|
||||
}
|
||||
# include "glimports.h"
|
||||
# undef GL_IMPORT
|
||||
|
|
Загрузка…
Ссылка в новой задаче