From 507fa60f32bd3f64840a2cdd1be5d68478432b55 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 27 Nov 2022 14:01:01 +0200 Subject: [PATCH] Use nullptr in place of 0 or NULL --- source/graphics/android/display_platform.h | 4 +-- source/graphics/android/window.cpp | 2 +- source/graphics/android/window_platform.h | 2 +- source/graphics/cgl/glcontext.cpp | 2 +- source/graphics/cocoa/display.cpp | 2 +- source/graphics/display.cpp | 6 ++-- source/graphics/display.h | 8 ++--- source/graphics/display_private.h | 2 +- source/graphics/egl_android/glcontext.cpp | 6 ++-- source/graphics/errordialog.h | 2 +- source/graphics/glcontext.h | 2 +- source/graphics/glx/glcontext.cpp | 18 +++++----- source/graphics/image.cpp | 4 +-- source/graphics/image.h | 4 +-- source/graphics/imageloader.cpp | 2 +- source/graphics/imageloader.h | 2 +- source/graphics/jpeg/jpegloader.h | 2 +- source/graphics/monitor.h | 6 ++-- source/graphics/png/pngloader.cpp | 19 +++++----- source/graphics/png/pngloader.h | 2 +- source/graphics/quartz/quartzloader.h | 2 +- source/graphics/videomode.h | 2 +- source/graphics/vkxlib/vulkancontext.cpp | 28 +++++++-------- .../graphics/vkxlib/vulkancontext_platform.h | 36 +++++++++---------- source/graphics/vulkancontext.h | 2 +- source/graphics/wgl/glcontext.cpp | 6 ++-- source/graphics/window.h | 4 +-- source/graphics/windows/display.cpp | 6 ++-- source/graphics/windows/window.cpp | 20 +++++------ source/graphics/x11/display.cpp | 14 ++++---- source/graphics/x11/window.cpp | 2 +- source/input/bindings.cpp | 4 +-- source/input/control.cpp | 6 ++-- source/input/control.h | 6 ++-- source/input/device.cpp | 4 +-- source/input/gamecontroller.h | 4 +-- source/input/hub.cpp | 4 +-- source/input/linux/gamecontroller_platform.h | 2 +- source/input/smoothcontrol.cpp | 6 ++-- source/input/smoothcontrol.h | 2 +- source/input/windows/gamecontroller.cpp | 10 +++--- .../input/windows/gamecontroller_platform.h | 4 +-- source/input/x11/keyboard.cpp | 2 +- 43 files changed, 136 insertions(+), 137 deletions(-) diff --git a/source/graphics/android/display_platform.h b/source/graphics/android/display_platform.h index 207f6ef..e07cb2e 100644 --- a/source/graphics/android/display_platform.h +++ b/source/graphics/android/display_platform.h @@ -14,10 +14,10 @@ typedef void *DisplayHandle; struct PlatformDisplayPrivate: public sigc::trackable { - AInputQueue *input_queue = 0; + AInputQueue *input_queue = nullptr; std::list events; Mutex event_mutex; - WindowHandle native_window = 0; + WindowHandle native_window = nullptr; Mutex window_mutex; void push_event(AndroidEventType); diff --git a/source/graphics/android/window.cpp b/source/graphics/android/window.cpp index d3260ca..ec632aa 100644 --- a/source/graphics/android/window.cpp +++ b/source/graphics/android/window.cpp @@ -66,7 +66,7 @@ bool Window::event(const Event &evnt) case WINDOW_DESTROYED: signal_lost_focus.emit(); priv->signal_window_lost.emit(); - priv->window = 0; + priv->window = nullptr; display.remove_window(*this); display.add_window(*this); break; diff --git a/source/graphics/android/window_platform.h b/source/graphics/android/window_platform.h index 633444b..faa9f16 100644 --- a/source/graphics/android/window_platform.h +++ b/source/graphics/android/window_platform.h @@ -26,7 +26,7 @@ struct PlatformWindowPrivate struct PlatformEvent { AndroidEventType type; - AInputEvent *aevent = 0; + AInputEvent *aevent = nullptr; }; } // namespace Graphics diff --git a/source/graphics/cgl/glcontext.cpp b/source/graphics/cgl/glcontext.cpp index c1a3a0e..9cddf38 100644 --- a/source/graphics/cgl/glcontext.cpp +++ b/source/graphics/cgl/glcontext.cpp @@ -14,7 +14,7 @@ typedef CocoaGLContext *ContextHandle; struct GLContext::Private { - ContextHandle context = 0; + ContextHandle context = nullptr; }; void GLContext::platform_init(const GLOptions &opts) diff --git a/source/graphics/cocoa/display.cpp b/source/graphics/cocoa/display.cpp index bf0c562..2f8d66c 100644 --- a/source/graphics/cocoa/display.cpp +++ b/source/graphics/cocoa/display.cpp @@ -11,7 +11,7 @@ namespace Graphics { Display::Display(const string &): priv(new Private) { - static ErrorDialog err_dlg(0); + static ErrorDialog err_dlg(nullptr); priv->display = create_display(); } diff --git a/source/graphics/display.cpp b/source/graphics/display.cpp index 92e341a..8c3813d 100644 --- a/source/graphics/display.cpp +++ b/source/graphics/display.cpp @@ -20,7 +20,7 @@ void Display::remove_window(Window &wnd) { priv->windows.erase(wnd.get_private().window); if(&wnd==focus_window) - focus_window = 0; + focus_window = nullptr; } const VideoMode &Display::get_desktop_mode() const @@ -39,7 +39,7 @@ void Display::restore_mode() const VideoMode *Display::find_mode(const VideoMode &mode, float rate_tolerance) const { - const VideoMode *closest = 0; + const VideoMode *closest = nullptr; float rate_diff = 0.0f; float target_rate = mode.rate; @@ -85,7 +85,7 @@ void Display::window_got_focus(Window &w) void Display::window_lost_focus() { - focus_window = 0; + focus_window = nullptr; } void Display::tick() diff --git a/source/graphics/display.h b/source/graphics/display.h index da3eafa..f78aaff 100644 --- a/source/graphics/display.h +++ b/source/graphics/display.h @@ -24,11 +24,11 @@ public: private: std::list monitors; - Monitor *primary_monitor = 0; + Monitor *primary_monitor = nullptr; std::list modes; - Private *priv = 0; - ErrorDialog *err_dialog = 0; - Window *focus_window = 0; + Private *priv = nullptr; + ErrorDialog *err_dialog = nullptr; + Window *focus_window = nullptr; public: Display(const std::string &disp_name = std::string()); diff --git a/source/graphics/display_private.h b/source/graphics/display_private.h index 71fc094..db67512 100644 --- a/source/graphics/display_private.h +++ b/source/graphics/display_private.h @@ -12,7 +12,7 @@ namespace Graphics { struct Display::Private: PlatformDisplayPrivate { - DisplayHandle display = 0; + DisplayHandle display = nullptr; std::map windows; }; diff --git a/source/graphics/egl_android/glcontext.cpp b/source/graphics/egl_android/glcontext.cpp index ebdb801..809ed04 100644 --- a/source/graphics/egl_android/glcontext.cpp +++ b/source/graphics/egl_android/glcontext.cpp @@ -29,7 +29,7 @@ void GLContext::platform_init(const GLOptions &opts) if(egl_display==EGL_NO_DISPLAY) throw runtime_error("no egl display"); - if(!eglInitialize(egl_display, 0, 0)) + if(!eglInitialize(egl_display, nullptr, nullptr)) throw runtime_error("could not initialize egl"); vector attribs; @@ -88,11 +88,11 @@ void GLContext::platform_init(const GLOptions &opts) eglGetConfigAttrib(priv->display, config, EGL_NATIVE_VISUAL_ID, &format); ANativeWindow_setBuffersGeometry(native_window, 0, 0, format); - priv->surface = eglCreateWindowSurface(priv->display, config, native_window, 0); + priv->surface = eglCreateWindowSurface(priv->display, config, native_window, nullptr); eglBindAPI(EGL_OPENGL_ES_API); int context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; - priv->context = eglCreateContext(priv->display, config, 0, context_attribs); + priv->context = eglCreateContext(priv->display, config, nullptr, context_attribs); eglMakeCurrent(priv->display, priv->surface, priv->surface, priv->context); diff --git a/source/graphics/errordialog.h b/source/graphics/errordialog.h index e0c423c..6885834 100644 --- a/source/graphics/errordialog.h +++ b/source/graphics/errordialog.h @@ -11,7 +11,7 @@ class Display; class ErrorDialog: public Debug::ErrorReporter { private: - Display *display = 0; + Display *display = nullptr; public: ErrorDialog(Display *d): display(d) { } diff --git a/source/graphics/glcontext.h b/source/graphics/glcontext.h index c637b39..ef374c1 100644 --- a/source/graphics/glcontext.h +++ b/source/graphics/glcontext.h @@ -42,7 +42,7 @@ private: Display &display; Window &window; - Private *priv = 0; + Private *priv = nullptr; public: GLContext(Window &wnd, const GLOptions &opts = GLOptions()); diff --git a/source/graphics/glx/glcontext.cpp b/source/graphics/glx/glcontext.cpp index 699f856..ad63350 100644 --- a/source/graphics/glx/glcontext.cpp +++ b/source/graphics/glx/glcontext.cpp @@ -17,7 +17,7 @@ typedef GLXContext ContextHandle; struct GLContext::Private { - ContextHandle context = 0; + ContextHandle context = nullptr; // We need to create a window with the chosen visual WindowHandle subwnd = None; GLXWindow glxwnd = None; @@ -97,7 +97,7 @@ void GLContext::platform_init(const GLOptions &opts) priv->subwnd = XCreateWindow(dpy, window.get_private().window, 0, 0, window.get_width(), window.get_height(), 0, vi->depth, InputOutput, vi->visual, CWColormap, &attr); XMapWindow(dpy, priv->subwnd); - priv->glxwnd = glXCreateWindow(dpy, fb_configs[0], priv->subwnd, 0); + priv->glxwnd = glXCreateWindow(dpy, fb_configs[0], priv->subwnd, nullptr); if(opts.forward_compatible || opts.gl_version_major!=GLOptions::DEFAULT_VERSION) { @@ -108,7 +108,7 @@ void GLContext::platform_init(const GLOptions &opts) unsigned gl_version_minor = opts.gl_version_minor; if(opts.gl_version_major==GLOptions::LATEST_VERSION) { - ContextHandle probe_context = glXCreateNewContext(dpy, fb_configs[0], GLX_RGBA_TYPE, 0, true); + ContextHandle probe_context = glXCreateNewContext(dpy, fb_configs[0], GLX_RGBA_TYPE, nullptr, true); glXMakeContextCurrent(dpy, priv->glxwnd, priv->glxwnd, probe_context); const char *gl_ver_ptr = reinterpret_cast(glGetString(GL_VERSION)); @@ -121,7 +121,7 @@ void GLContext::platform_init(const GLOptions &opts) gl_version_major = lexical_cast(parts[0]); gl_version_minor = lexical_cast(parts[1]); - glXMakeContextCurrent(dpy, 0, 0, 0); + glXMakeContextCurrent(dpy, None, None, nullptr); glXDestroyContext(dpy, probe_context); } @@ -154,10 +154,10 @@ void GLContext::platform_init(const GLOptions &opts) const GLubyte *name = reinterpret_cast("glXCreateContextAttribsARB"); PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = reinterpret_cast(glXGetProcAddressARB(name)); - priv->context = glXCreateContextAttribs(dpy, fb_configs[0], 0, true, &ctx_attribs[0]); + priv->context = glXCreateContextAttribs(dpy, fb_configs[0], nullptr, true, &ctx_attribs[0]); } else - priv->context = glXCreateNewContext(dpy, fb_configs[0], GLX_RGBA_TYPE, 0, true); + priv->context = glXCreateNewContext(dpy, fb_configs[0], GLX_RGBA_TYPE, nullptr, true); XFree(vi); XFree(fb_configs); @@ -205,7 +205,7 @@ void GLContext::platform_init(const GLOptions &opts) priv = new Private; priv->glxwnd = 0; - priv->context = glXCreateContext(dpy, vi, 0, true); + priv->context = glXCreateContext(dpy, vi, nullptr, true); XSetWindowAttributes attr; attr.colormap = XCreateColormap(dpy, DefaultRootWindow(dpy), vi->visual, AllocNone); @@ -225,11 +225,11 @@ GLContext::~GLContext() if(priv->glxwnd) { - glXMakeContextCurrent(dpy, 0, 0, 0); + glXMakeContextCurrent(dpy, None, None, nullptr); glXDestroyWindow(dpy, priv->glxwnd); } else - glXMakeCurrent(dpy, 0, 0); + glXMakeCurrent(dpy, None, nullptr); glXDestroyContext(dpy, priv->context); XDestroyWindow(dpy, priv->subwnd); diff --git a/source/graphics/image.cpp b/source/graphics/image.cpp index 5b2eb1a..813672b 100644 --- a/source/graphics/image.cpp +++ b/source/graphics/image.cpp @@ -15,7 +15,7 @@ Image::Data::Data(const Data &other): width(other.width), height(other.height), stride(other.stride), - owned_pixels(other.pixels ? new char[stride*height] : 0), + owned_pixels(other.pixels ? new char[stride*height] : nullptr), pixels(owned_pixels) { if(pixels) @@ -25,7 +25,7 @@ Image::Data::Data(const Data &other): Image::Data &Image::Data::operator=(const Data &other) { delete[] owned_pixels; - pixels = owned_pixels = 0; + pixels = owned_pixels = nullptr; fmt = other.fmt; width = other.width; diff --git a/source/graphics/image.h b/source/graphics/image.h index d9f5870..3f8f556 100644 --- a/source/graphics/image.h +++ b/source/graphics/image.h @@ -20,8 +20,8 @@ public: unsigned width = 0; unsigned height = 0; unsigned stride = 0; - char *owned_pixels = 0; - char *pixels = 0; + char *owned_pixels = nullptr; + char *pixels = nullptr; Data() = default; Data(const Data &); diff --git a/source/graphics/imageloader.cpp b/source/graphics/imageloader.cpp index 6a3196c..a938340 100644 --- a/source/graphics/imageloader.cpp +++ b/source/graphics/imageloader.cpp @@ -66,7 +66,7 @@ ImageLoader *ImageLoader::open_io(IO::Seekable &io) string signature(registry.loaders.back()->get_signature_size(), 0); unsigned sig_len = io.read(&signature[0], signature.size()); - ImageLoader *loader = 0; + ImageLoader *loader = nullptr; for(auto i=registry.loaders.begin(); (!loader && i!=registry.loaders.end()); ++i) if((*i)->detect(signature)) loader = (*i)->create(io); diff --git a/source/graphics/imageloader.h b/source/graphics/imageloader.h index 65f3c56..ca69459 100644 --- a/source/graphics/imageloader.h +++ b/source/graphics/imageloader.h @@ -60,7 +60,7 @@ protected: }; private: - IO::Base *source = 0; + IO::Base *source = nullptr; State state = INITIAL; protected: diff --git a/source/graphics/jpeg/jpegloader.h b/source/graphics/jpeg/jpegloader.h index 4773168..88dc00c 100644 --- a/source/graphics/jpeg/jpegloader.h +++ b/source/graphics/jpeg/jpegloader.h @@ -11,7 +11,7 @@ class JpegLoader: public ImageLoader private: struct Private; - Private *priv = 0; + Private *priv = nullptr; public: JpegLoader(IO::Seekable &); diff --git a/source/graphics/monitor.h b/source/graphics/monitor.h index 0fc9798..b74cea8 100644 --- a/source/graphics/monitor.h +++ b/source/graphics/monitor.h @@ -12,7 +12,7 @@ struct Monitor { struct Settings { - const VideoMode *mode = 0; + const VideoMode *mode = nullptr; VideoRotation rotation = ROTATE_NORMAL; int x = 0; int y = 0; @@ -23,8 +23,8 @@ struct Monitor std::list video_modes; Settings desktop_settings; Settings current_settings; - const Monitor *next_left = 0; - const Monitor *next_right = 0; + const Monitor *next_left = nullptr; + const Monitor *next_right = nullptr; }; } // namespace Graphics diff --git a/source/graphics/png/pngloader.cpp b/source/graphics/png/pngloader.cpp index 7842c18..9c2e1ae 100644 --- a/source/graphics/png/pngloader.cpp +++ b/source/graphics/png/pngloader.cpp @@ -27,8 +27,8 @@ namespace Graphics { struct PngLoader::Private { string message; - png_struct *png = 0; - png_info *info = 0; + png_struct *png = nullptr; + png_info *info = nullptr; int interlace = PNG_INTERLACE_NONE; }; @@ -36,7 +36,7 @@ struct PngLoader::Private PngLoader::PngLoader(IO::Base &io, unsigned sig_bytes): priv(new Private) { - priv->png = png_create_read_struct(PNG_LIBPNG_VER_STRING, &priv->message, error, 0); + priv->png = png_create_read_struct(PNG_LIBPNG_VER_STRING, &priv->message, error, nullptr); priv->info = png_create_info_struct(priv->png); // These probably won't give any errors @@ -46,7 +46,7 @@ PngLoader::PngLoader(IO::Base &io, unsigned sig_bytes): PngLoader::~PngLoader() { - png_destroy_read_struct(&priv->png, &priv->info, 0); + png_destroy_read_struct(&priv->png, &priv->info, nullptr); delete priv; } @@ -67,7 +67,7 @@ void PngLoader::load_headers_(Image::Data &data) png_uint_32 height; int depth; int color; - png_get_IHDR(priv->png, priv->info, &width, &height, &depth, &color, &priv->interlace, 0, 0); + png_get_IHDR(priv->png, priv->info, &width, &height, &depth, &color, &priv->interlace, nullptr, nullptr); unsigned nchans = png_get_channels(priv->png, priv->info); if(depth!=8) @@ -90,7 +90,7 @@ void PngLoader::load_headers_(Image::Data &data) void PngLoader::load_pixels_(Image::Data &data) { - png_byte **rows = 0; + png_byte **rows = nullptr; if(setjmp(png_jmpbuf(priv->png))) { @@ -107,18 +107,17 @@ void PngLoader::load_pixels_(Image::Data &data) rows[y] = reinterpret_cast(data.pixels+data.stride*(data.height-1-y)); for(unsigned i=0; ipng, rows, 0, data.height); + png_read_rows(priv->png, rows, nullptr, data.height); delete[] rows; - rows = 0; } else { for(unsigned y=0; ypng, reinterpret_cast(data.pixels+data.stride*(data.height-1-y)), 0); + png_read_row(priv->png, reinterpret_cast(data.pixels+data.stride*(data.height-1-y)), nullptr); } - png_read_end(priv->png, 0); + png_read_end(priv->png, nullptr); } } // namespace Graphics diff --git a/source/graphics/png/pngloader.h b/source/graphics/png/pngloader.h index c21cc5a..f334d82 100644 --- a/source/graphics/png/pngloader.h +++ b/source/graphics/png/pngloader.h @@ -11,7 +11,7 @@ class PngLoader: public ImageLoader private: struct Private; - Private *priv = 0; + Private *priv = nullptr; public: PngLoader(IO::Base &, unsigned = 0); diff --git a/source/graphics/quartz/quartzloader.h b/source/graphics/quartz/quartzloader.h index c4517ec..73c74c0 100644 --- a/source/graphics/quartz/quartzloader.h +++ b/source/graphics/quartz/quartzloader.h @@ -11,7 +11,7 @@ class QuartzLoader: public ImageLoader private: struct Private; - Private *priv = 0; + Private *priv = nullptr; public: QuartzLoader(IO::Seekable &); diff --git a/source/graphics/videomode.h b/source/graphics/videomode.h index 6c83d94..c527ed7 100644 --- a/source/graphics/videomode.h +++ b/source/graphics/videomode.h @@ -28,7 +28,7 @@ enum VideoRotation struct VideoMode { unsigned index = 0; - const Monitor *monitor = 0; + const Monitor *monitor = nullptr; unsigned width = 0; unsigned height = 0; float rate = 0.0f; diff --git a/source/graphics/vkxlib/vulkancontext.cpp b/source/graphics/vkxlib/vulkancontext.cpp index 7026e30..c3a7d76 100644 --- a/source/graphics/vkxlib/vulkancontext.cpp +++ b/source/graphics/vkxlib/vulkancontext.cpp @@ -96,7 +96,7 @@ void VulkanContext::platform_init(const VulkanOptions &opts) instance_create_info.enabledExtensionCount = extensions.size(); instance_create_info.ppEnabledExtensionNames = extensions.data(); - VkResult result = f.vkCreateInstance(&instance_create_info, 0, &priv->instance); + VkResult result = f.vkCreateInstance(&instance_create_info, nullptr, &priv->instance); if(result!=VK_SUCCESS) throw vulkan_error(result, "vkCreateInstance"); @@ -120,7 +120,7 @@ void VulkanContext::platform_init(const VulkanOptions &opts) debug_report_create_info.pfnCallback = &Private::debug_report_func; debug_report_create_info.pUserData = this; - result = f.vkCreateDebugReportCallback(priv->instance, &debug_report_create_info, 0, &priv->debug_report_callback); + result = f.vkCreateDebugReportCallback(priv->instance, &debug_report_create_info, nullptr, &priv->debug_report_callback); if(result!=VK_SUCCESS) throw vulkan_error(result, "vkCreateDebugReportCallback"); } @@ -130,12 +130,12 @@ void VulkanContext::platform_init(const VulkanOptions &opts) surface_create_info.dpy = display.get_private().display; surface_create_info.window = window.get_private().window; - result = f.vkCreateXlibSurface(priv->instance, &surface_create_info, 0, &priv->surface); + result = f.vkCreateXlibSurface(priv->instance, &surface_create_info, nullptr, &priv->surface); if(result!=VK_SUCCESS) throw vulkan_error(result, "vkCreateXlibSurface"); unsigned n_phys_devices = 0; - result = f.vkEnumeratePhysicalDevices(priv->instance, &n_phys_devices, 0); + result = f.vkEnumeratePhysicalDevices(priv->instance, &n_phys_devices, nullptr); if(result!=VK_SUCCESS) throw vulkan_error(result, "vkEnumeratePhysicalDevices"); else if(!n_phys_devices) @@ -151,7 +151,7 @@ void VulkanContext::platform_init(const VulkanOptions &opts) VkPhysicalDevice phys_device = phys_devices[i]; unsigned n_queue_families = 0; - f.vkGetPhysicalDeviceQueueFamilyProperties(phys_device, &n_queue_families, 0); + f.vkGetPhysicalDeviceQueueFamilyProperties(phys_device, &n_queue_families, nullptr); vector queue_family_props(n_queue_families); f.vkGetPhysicalDeviceQueueFamilyProperties(phys_device, &n_queue_families, queue_family_props.data()); @@ -201,7 +201,7 @@ void VulkanContext::platform_init(const VulkanOptions &opts) device_create_info.ppEnabledExtensionNames = extensions.data(); device_create_info.pEnabledFeatures = &features; - result = f.vkCreateDevice(priv->physical_device, &device_create_info, 0, &priv->device); + result = f.vkCreateDevice(priv->physical_device, &device_create_info, nullptr, &priv->device); if(result!=VK_SUCCESS) throw vulkan_error(result, "vkCreateDevice"); @@ -210,13 +210,13 @@ void VulkanContext::platform_init(const VulkanOptions &opts) catch(...) { if(priv->device) - f.vkDestroyDevice(priv->device, 0); + f.vkDestroyDevice(priv->device, nullptr); if(priv->surface) - f.vkDestroySurface(priv->instance, priv->surface, 0); + f.vkDestroySurface(priv->instance, priv->surface, nullptr); if(priv->debug_report_callback) - f.vkDestroyDebugReportCallback(priv->instance, priv->debug_report_callback, 0); + f.vkDestroyDebugReportCallback(priv->instance, priv->debug_report_callback, nullptr); if(priv->instance) - f.vkDestroyInstance(priv->instance, 0); + f.vkDestroyInstance(priv->instance, nullptr); delete priv; throw; } @@ -225,11 +225,11 @@ void VulkanContext::platform_init(const VulkanOptions &opts) VulkanContext::~VulkanContext() { const VulkanFunctions &f = priv->functions; - f.vkDestroyDevice(priv->device, 0); - f.vkDestroySurface(priv->instance, priv->surface, 0); + f.vkDestroyDevice(priv->device, nullptr); + f.vkDestroySurface(priv->instance, priv->surface, nullptr); if(priv->debug_report_callback) - f.vkDestroyDebugReportCallback(priv->instance, priv->debug_report_callback, 0); - f.vkDestroyInstance(priv->instance, 0); + f.vkDestroyDebugReportCallback(priv->instance, priv->debug_report_callback, nullptr); + f.vkDestroyInstance(priv->instance, nullptr); delete priv; } diff --git a/source/graphics/vkxlib/vulkancontext_platform.h b/source/graphics/vkxlib/vulkancontext_platform.h index aa82880..888557e 100644 --- a/source/graphics/vkxlib/vulkancontext_platform.h +++ b/source/graphics/vkxlib/vulkancontext_platform.h @@ -10,30 +10,30 @@ namespace Graphics { struct VulkanFunctions { - PFN_vkCreateInstance vkCreateInstance = 0; - PFN_vkDestroyInstance vkDestroyInstance = 0; - PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices = 0; - PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties = 0; - PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupport = 0; - PFN_vkCreateDevice vkCreateDevice = 0; - PFN_vkDestroyDevice vkDestroyDevice = 0; - PFN_vkGetDeviceQueue vkGetDeviceQueue = 0; - PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurface = 0; - PFN_vkDestroySurfaceKHR vkDestroySurface = 0; - PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallback = 0; - PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallback = 0; + PFN_vkCreateInstance vkCreateInstance = nullptr; + PFN_vkDestroyInstance vkDestroyInstance = nullptr; + PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices = nullptr; + PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties = nullptr; + PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupport = nullptr; + PFN_vkCreateDevice vkCreateDevice = nullptr; + PFN_vkDestroyDevice vkDestroyDevice = nullptr; + PFN_vkGetDeviceQueue vkGetDeviceQueue = nullptr; + PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurface = nullptr; + PFN_vkDestroySurfaceKHR vkDestroySurface = nullptr; + PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallback = nullptr; + PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallback = nullptr; }; struct VulkanContext::Private { VulkanFunctions functions; - VkInstance instance = 0; - VkPhysicalDevice physical_device = 0; - VkDevice device = 0; + VkInstance instance = nullptr; + VkPhysicalDevice physical_device = nullptr; + VkDevice device = nullptr; unsigned graphics_queue_family = 0; - VkQueue graphics_queue = 0; - VkSurfaceKHR surface = 0; - VkDebugReportCallbackEXT debug_report_callback = 0; + VkQueue graphics_queue = nullptr; + VkSurfaceKHR surface = nullptr; + VkDebugReportCallbackEXT debug_report_callback = nullptr; static VkBool32 debug_report_func(VkDebugReportFlagsEXT, VkDebugReportObjectTypeEXT, uint64_t, size_t, int32_t, const char *, const char *, void *); }; diff --git a/source/graphics/vulkancontext.h b/source/graphics/vulkancontext.h index c590079..211f86a 100644 --- a/source/graphics/vulkancontext.h +++ b/source/graphics/vulkancontext.h @@ -34,7 +34,7 @@ private: Display &display; Window &window; - Private *priv = 0; + Private *priv = nullptr; public: VulkanContext(Window &, const VulkanOptions & = VulkanOptions()); diff --git a/source/graphics/wgl/glcontext.cpp b/source/graphics/wgl/glcontext.cpp index 2791fed..3627a17 100644 --- a/source/graphics/wgl/glcontext.cpp +++ b/source/graphics/wgl/glcontext.cpp @@ -26,7 +26,7 @@ typedef HGLRC ContextHandle; struct GLContext::Private { - ContextHandle context = 0; + ContextHandle context = nullptr; }; @@ -107,7 +107,7 @@ void GLContext::platform_init(const GLOptions &opts) if(!priv->context) throw unsupported_gl_mode(opts); - wglMakeCurrent(0, 0); + wglMakeCurrent(nullptr, nullptr); wglDeleteContext(fake_context); } else @@ -119,7 +119,7 @@ void GLContext::platform_init(const GLOptions &opts) GLContext::~GLContext() { - wglMakeCurrent(0, 0); + wglMakeCurrent(nullptr, nullptr); wglDeleteContext(priv->context); delete priv; diff --git a/source/graphics/window.h b/source/graphics/window.h index 09ab25b..de8a3d0 100644 --- a/source/graphics/window.h +++ b/source/graphics/window.h @@ -18,7 +18,7 @@ struct WindowOptions unsigned width = 640; unsigned height = 480; bool fullscreen = false; - const Monitor *fullscreen_monitor = 0; + const Monitor *fullscreen_monitor = nullptr; bool fullscreen_exclusive = true; bool resizable = false; }; @@ -50,7 +50,7 @@ protected: bool touch_input = false; bool resizing = false; bool moving = false; - Private *priv = 0; + Private *priv = nullptr; public: Window(Display &, unsigned w, unsigned h, bool fs = false); diff --git a/source/graphics/windows/display.cpp b/source/graphics/windows/display.cpp index ee08395..bea18a6 100644 --- a/source/graphics/windows/display.cpp +++ b/source/graphics/windows/display.cpp @@ -10,13 +10,13 @@ namespace Graphics { Display::Display(const string &): priv(new Private) { - static ErrorDialog err_dlg(0); + static ErrorDialog err_dlg(nullptr); for(unsigned i=0;; ++i) { DISPLAY_DEVICE adapter_dev; adapter_dev.cb = sizeof(adapter_dev); - if(!EnumDisplayDevices(0, i, &adapter_dev, 0)) + if(!EnumDisplayDevices(nullptr, i, &adapter_dev, 0)) break; if(adapter_dev.StateFlags&DISPLAY_DEVICE_MIRRORING_DRIVER) @@ -96,7 +96,7 @@ void Display::set_mode(const VideoMode &requested_mode, bool) bool Display::process_events() { MSG msg; - if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) + if(PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); diff --git a/source/graphics/windows/window.cpp b/source/graphics/windows/window.cpp index b90498b..e7ec910 100644 --- a/source/graphics/windows/window.cpp +++ b/source/graphics/windows/window.cpp @@ -50,12 +50,12 @@ void Window::platform_init() wndcl.cbClsExtra = 0; wndcl.cbWndExtra = sizeof(Window *); wndcl.hInstance = reinterpret_cast(Application::get_data()); - wndcl.hIcon = 0; - wndcl.hCursor = LoadCursor(0, IDC_ARROW); - wndcl.hbrBackground = 0; - wndcl.lpszMenuName = 0; + wndcl.hIcon = nullptr; + wndcl.hCursor = LoadCursor(nullptr, IDC_ARROW); + wndcl.hbrBackground = nullptr; + wndcl.lpszMenuName = nullptr; wndcl.lpszClassName = "mspgui"; - wndcl.hIconSm = 0; + wndcl.hIconSm = nullptr; if(!RegisterClassEx(&wndcl)) throw system_error("RegisterClassEx"); @@ -121,18 +121,18 @@ void Window::platform_reconfigure(bool fullscreen_changed) } if(options.fullscreen) - SetWindowPos(priv->window, 0, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER); + SetWindowPos(priv->window, nullptr, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER); else if(options.user_position) - SetWindowPos(priv->window, 0, options.x, options.y, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER); + SetWindowPos(priv->window, nullptr, options.x, options.y, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER); else - SetWindowPos(priv->window, 0, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOMOVE|SWP_NOZORDER); + SetWindowPos(priv->window, nullptr, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOMOVE|SWP_NOZORDER); } void Window::show_cursor(bool s) { priv->cursor_visible = s; if(priv->cursor_in_client_area && !s) - SetCursor(NULL); + SetCursor(nullptr); } void Window::warp_pointer(int, int) @@ -222,7 +222,7 @@ bool Window::event(const Event &evnt) case WM_SETCURSOR: priv->cursor_in_client_area = (LOWORD(evnt.lparam)==HTCLIENT); if(priv->cursor_in_client_area && !priv->cursor_visible) - SetCursor(NULL); + SetCursor(nullptr); else return false; break; diff --git a/source/graphics/x11/display.cpp b/source/graphics/x11/display.cpp index edc6a12..fd60485 100644 --- a/source/graphics/x11/display.cpp +++ b/source/graphics/x11/display.cpp @@ -87,7 +87,7 @@ Display::Display(const string &disp_name): priv(new Private) { if(disp_name.empty()) - priv->display = XOpenDisplay(0); + priv->display = XOpenDisplay(nullptr); else priv->display = XOpenDisplay(disp_name.c_str()); if(!priv->display) @@ -119,7 +119,7 @@ Display::Display(const string &disp_name): for(int i=0; inoutput; ++i) { XRROutputInfo *output = XRRGetOutputInfo(priv->display, res, res->outputs[i]); - XRRCrtcInfo *crtc = (output->crtc ? XRRGetCrtcInfo(priv->display, res, output->crtc) : 0); + XRRCrtcInfo *crtc = (output->crtc ? XRRGetCrtcInfo(priv->display, res, output->crtc) : nullptr); monitors.push_back(Monitor()); Monitor &monitor = monitors.back(); @@ -133,7 +133,7 @@ Display::Display(const string &disp_name): int prop_format; unsigned long length; unsigned long overflow; - unsigned char *edid = 0; + unsigned char *edid = nullptr; XRRGetOutputProperty(priv->display, res->outputs[i], edid_prop, 0, 32, false, false, XA_INTEGER, &prop_type, &prop_format, &length, &overflow, &edid); if(prop_type==XA_INTEGER && prop_format==8) { @@ -194,7 +194,7 @@ Display::Display(const string &disp_name): XRRFreeScreenResources(res); monitors.sort(monitor_x_compare); - Monitor *prev_enabled = 0; + Monitor *prev_enabled = nullptr; for(Monitor &m: monitors) if(m.desktop_settings.mode) { @@ -248,7 +248,7 @@ void Display::set_mode(const VideoMode &requested_mode, bool exclusive) // Check if the output already has a CRTC and find a free one if it doesn't RRCrtc crtc = output_info->crtc; - XRRCrtcInfo *crtc_info = 0; + XRRCrtcInfo *crtc_info = nullptr; if(crtc) crtc_info = XRRGetCrtcInfo(priv->display, res, crtc); else @@ -288,10 +288,10 @@ void Display::set_mode(const VideoMode &requested_mode, bool exclusive) { XRROutputInfo *o = XRRGetOutputInfo(priv->display, res, priv->monitors[m.index]); if(o->crtc) - XRRSetCrtcConfig(priv->display, res, o->crtc, CurrentTime, 0, 0, 0, RR_Rotate_0, 0, 0); + XRRSetCrtcConfig(priv->display, res, o->crtc, CurrentTime, 0, 0, 0, RR_Rotate_0, nullptr, 0); XRRFreeOutputInfo(o); - m.current_settings.mode = 0; + m.current_settings.mode = nullptr; m.current_settings.rotation = ROTATE_NORMAL; m.current_settings.x = 0; m.current_settings.y = 0; diff --git a/source/graphics/x11/window.cpp b/source/graphics/x11/window.cpp index e33511e..96d0985 100644 --- a/source/graphics/x11/window.cpp +++ b/source/graphics/x11/window.cpp @@ -148,7 +148,7 @@ void Window::show_cursor(bool s) int screen = DefaultScreen(dpy); Pixmap pm = XCreatePixmap(dpy, priv->window, 1, 1, 1); - GC gc = XCreateGC(dpy, pm, 0, 0); + GC gc = XCreateGC(dpy, pm, 0, nullptr); XSetFunction(dpy, gc, GXclear); XDrawPoint(dpy, pm, gc, 0, 0); XFreeGC(dpy, gc); diff --git a/source/input/bindings.cpp b/source/input/bindings.cpp index 1c58816..291c8f1 100644 --- a/source/input/bindings.cpp +++ b/source/input/bindings.cpp @@ -19,7 +19,7 @@ vector Bindings::resolve_devices(Device &dev) const else if(!d.name.empty()) resolved_devs.push_back(dev.find_subdevice(d.name)); else - resolved_devs.push_back(0); + resolved_devs.push_back(nullptr); } return resolved_devs; } @@ -37,7 +37,7 @@ bool Bindings::apply_to(ControlScheme &control_scheme, Device &dev) for(const Binding &b: bindings) { Control *ctrl = control_scheme.find(b.control); - Device *bdev = (b.deviceset_source(*bdev, b.type, b.index); diff --git a/source/input/control.cpp b/source/input/control.cpp index 2bb4104..4f09357 100644 --- a/source/input/control.cpp +++ b/source/input/control.cpp @@ -54,7 +54,7 @@ void Control::capture(Device &d) void Control::cancel_capture() { notify_callbacks(); - capture_dev = 0; + capture_dev = nullptr; connect_signals(); } @@ -112,7 +112,7 @@ void Control::button_press(unsigned i) src.index = i; notify_callbacks(); - capture_dev = 0; + capture_dev = nullptr; connect_signals(); signal_capture_complete.emit(); } @@ -143,7 +143,7 @@ void Control::axis_motion(unsigned i, float v, float r) src.index = i; notify_callbacks(); - capture_dev = 0; + capture_dev = nullptr; connect_signals(); signal_capture_complete.emit(); } diff --git a/source/input/control.h b/source/input/control.h index b71c818..f9c7003 100644 --- a/source/input/control.h +++ b/source/input/control.h @@ -25,7 +25,7 @@ different types of controls in a uniform way. */ struct ControlSource { - Device *dev = 0; + Device *dev = nullptr; ControlSrcType type = NO_SOURCE; unsigned index = 0; @@ -55,8 +55,8 @@ public: protected: ControlSource src; - Device *capture_dev = 0; - BinaryControl *activator = 0; + Device *capture_dev = nullptr; + BinaryControl *activator = nullptr; float origin = 0.0f; bool rising_edge = false; bool falling_edge = false; diff --git a/source/input/device.cpp b/source/input/device.cpp index 4aa8ce6..b615cb7 100644 --- a/source/input/device.cpp +++ b/source/input/device.cpp @@ -15,12 +15,12 @@ Device::~Device() Device *Device::find_subdevice(const string &n) { - return (n==name ? this : 0); + return (n==name ? this : nullptr); } Device *Device::find_subdevice(DeviceType t, unsigned i) { - return (t==type && i==0 ? this : 0); + return (t==type && i==0 ? this : nullptr); } bool Device::get_button_state(unsigned btn) const diff --git a/source/input/gamecontroller.h b/source/input/gamecontroller.h index 6393ac0..baf94cb 100644 --- a/source/input/gamecontroller.h +++ b/source/input/gamecontroller.h @@ -13,8 +13,8 @@ class GameController: public Device private: struct Private; - Private *priv = 0; - IO::EventDispatcher *event_disp = 0; + Private *priv = nullptr; + IO::EventDispatcher *event_disp = nullptr; static bool detect_done; static unsigned n_detected_controllers; diff --git a/source/input/hub.cpp b/source/input/hub.cpp index e7eb0fc..1916126 100644 --- a/source/input/hub.cpp +++ b/source/input/hub.cpp @@ -34,7 +34,7 @@ Device *Hub::find_subdevice(DeviceType t, unsigned n) return dev; --n; } - return 0; + return nullptr; } Device *Hub::find_subdevice(const string &n) @@ -44,7 +44,7 @@ Device *Hub::find_subdevice(const string &n) for(Device *d: devices) if(Device *dev = d->find_subdevice(n)) return dev; - return 0; + return nullptr; } string Hub::get_button_name(unsigned btn) const diff --git a/source/input/linux/gamecontroller_platform.h b/source/input/linux/gamecontroller_platform.h index 8676875..224450e 100644 --- a/source/input/linux/gamecontroller_platform.h +++ b/source/input/linux/gamecontroller_platform.h @@ -33,7 +33,7 @@ public: struct GameController::Private { - JsDevice *dev = 0; + JsDevice *dev = nullptr; static std::vector detected_controllers; }; diff --git a/source/input/smoothcontrol.cpp b/source/input/smoothcontrol.cpp index 988509b..0532aef 100644 --- a/source/input/smoothcontrol.cpp +++ b/source/input/smoothcontrol.cpp @@ -16,7 +16,7 @@ SmoothControl::SmoothControl(Device &d, ControlSrcType t, unsigned i): SmoothControl::~SmoothControl() { - pair(0); + pair(nullptr); } void SmoothControl::set_dead_zone(float d) @@ -49,8 +49,8 @@ void SmoothControl::pair(SmoothControl *ctrl) if(paired_ctrl) { SmoothControl *old_pair = paired_ctrl; - paired_ctrl = 0; - old_pair->pair(0); + paired_ctrl = nullptr; + old_pair->pair(nullptr); } paired_ctrl = ctrl; diff --git a/source/input/smoothcontrol.h b/source/input/smoothcontrol.h index 5f71824..b5eb9aa 100644 --- a/source/input/smoothcontrol.h +++ b/source/input/smoothcontrol.h @@ -21,7 +21,7 @@ public: private: float value = 0.0f; - SmoothControl *paired_ctrl = 0; + SmoothControl *paired_ctrl = nullptr; float dead_zone = 0.1f; float threshold = 0.9f; diff --git a/source/input/windows/gamecontroller.cpp b/source/input/windows/gamecontroller.cpp index df29666..46536b3 100644 --- a/source/input/windows/gamecontroller.cpp +++ b/source/input/windows/gamecontroller.cpp @@ -34,7 +34,7 @@ GameController::GameController(unsigned index): GameController::~GameController() { - use_event_dispatcher(0); + use_event_dispatcher(nullptr); delete priv; } @@ -75,9 +75,9 @@ void GameController::use_event_dispatcher(IO::EventDispatcher *ed) else if(priv->event_pipe) { GameControllerTimerThread::remove_slot(*priv->timer_slot); - priv->timer_slot = 0; + priv->timer_slot = nullptr; delete priv->event_pipe; - priv->event_pipe = 0; + priv->event_pipe = nullptr; } } @@ -134,7 +134,7 @@ void GameController::Private::update_state(GameController &ctrl, const XINPUT_ST } -GameControllerTimerThread *GameControllerTimerThread::thread = 0; +GameControllerTimerThread *GameControllerTimerThread::thread = nullptr; GameControllerTimerThread::GameControllerTimerThread(): Thread("GameController") @@ -163,7 +163,7 @@ void GameControllerTimerThread::remove_slot(Time::Timer::Slot &slot) { thread->timer.add(Time::zero); delete thread; - thread = 0; + thread = nullptr; } } diff --git a/source/input/windows/gamecontroller_platform.h b/source/input/windows/gamecontroller_platform.h index d6ee6c2..1541ae7 100644 --- a/source/input/windows/gamecontroller_platform.h +++ b/source/input/windows/gamecontroller_platform.h @@ -33,8 +33,8 @@ struct GameController::Private { unsigned index = 0; unsigned last_packet_number = 0; - IO::Pipe *event_pipe = 0; - Time::Timer::Slot *timer_slot = 0; + IO::Pipe *event_pipe = nullptr; + Time::Timer::Slot *timer_slot = nullptr; static std::vector detected_controllers; diff --git a/source/input/x11/keyboard.cpp b/source/input/x11/keyboard.cpp index ed959da..00b6448 100644 --- a/source/input/x11/keyboard.cpp +++ b/source/input/x11/keyboard.cpp @@ -33,7 +33,7 @@ void Keyboard::input_event(const Graphics::Window::Event &event) if(event.xevent.type==KeyPress) { char ch; - if(XLookupString(const_cast(&event.xevent.xkey), &ch, 1, 0, 0)) + if(XLookupString(const_cast(&event.xevent.xkey), &ch, 1, nullptr, nullptr)) // XLookupString always returns Latin-1 signal_character.emit(static_cast(ch)); } -- 2.45.2