]> git.tdb.fi Git - libs/gui.git/commitdiff
Use nullptr in place of 0 or NULL
authorMikko Rasa <tdb@tdb.fi>
Sun, 27 Nov 2022 12:01:01 +0000 (14:01 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 27 Nov 2022 14:20:18 +0000 (16:20 +0200)
43 files changed:
source/graphics/android/display_platform.h
source/graphics/android/window.cpp
source/graphics/android/window_platform.h
source/graphics/cgl/glcontext.cpp
source/graphics/cocoa/display.cpp
source/graphics/display.cpp
source/graphics/display.h
source/graphics/display_private.h
source/graphics/egl_android/glcontext.cpp
source/graphics/errordialog.h
source/graphics/glcontext.h
source/graphics/glx/glcontext.cpp
source/graphics/image.cpp
source/graphics/image.h
source/graphics/imageloader.cpp
source/graphics/imageloader.h
source/graphics/jpeg/jpegloader.h
source/graphics/monitor.h
source/graphics/png/pngloader.cpp
source/graphics/png/pngloader.h
source/graphics/quartz/quartzloader.h
source/graphics/videomode.h
source/graphics/vkxlib/vulkancontext.cpp
source/graphics/vkxlib/vulkancontext_platform.h
source/graphics/vulkancontext.h
source/graphics/wgl/glcontext.cpp
source/graphics/window.h
source/graphics/windows/display.cpp
source/graphics/windows/window.cpp
source/graphics/x11/display.cpp
source/graphics/x11/window.cpp
source/input/bindings.cpp
source/input/control.cpp
source/input/control.h
source/input/device.cpp
source/input/gamecontroller.h
source/input/hub.cpp
source/input/linux/gamecontroller_platform.h
source/input/smoothcontrol.cpp
source/input/smoothcontrol.h
source/input/windows/gamecontroller.cpp
source/input/windows/gamecontroller_platform.h
source/input/x11/keyboard.cpp

index 207f6ef6722606bd7198c6b17052fe212ac1b290..e07cb2ebeacaa76a7962a35bc5a7d7db6ff31efc 100644 (file)
@@ -14,10 +14,10 @@ typedef void *DisplayHandle;
 
 struct PlatformDisplayPrivate: public sigc::trackable
 {
-       AInputQueue *input_queue = 0;
+       AInputQueue *input_queue = nullptr;
        std::list<Window::Event> events;
        Mutex event_mutex;
-       WindowHandle native_window = 0;
+       WindowHandle native_window = nullptr;
        Mutex window_mutex;
 
        void push_event(AndroidEventType);
index d3260ca830402cc1cd583e4e94ef8812b391c20b..ec632aaeafd96b5948e72fe5812b18cc3937249f 100644 (file)
@@ -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;
index 633444b147a98b49b825073585c8b7c5648c96af..faa9f16c526120ff09733e02b8f2f88bb399f363 100644 (file)
@@ -26,7 +26,7 @@ struct PlatformWindowPrivate
 struct PlatformEvent
 {
        AndroidEventType type;
-       AInputEvent *aevent = 0;
+       AInputEvent *aevent = nullptr;
 };
 
 } // namespace Graphics
index c1a3a0e7bc451224a2c54b056d8b691256dc3ed4..9cddf38795cbe378961ba3f5c3f542b00b7d6e25 100644 (file)
@@ -14,7 +14,7 @@ typedef CocoaGLContext *ContextHandle;
 
 struct GLContext::Private
 {
-       ContextHandle context = 0;
+       ContextHandle context = nullptr;
 };
 
 void GLContext::platform_init(const GLOptions &opts)
index bf0c562721f0ccaac525c1daee71fc4822431f3c..2f8d66c9dd4a72fa07057c11dcc676a279774667 100644 (file)
@@ -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();
 }
index 92e341aed334b25fa283197d39e2e20dc3766f1e..8c3813d16cd8d19321fddcd6609a9dfc5748da3c 100644 (file)
@@ -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()
index da3eafa65ca8c462c754ccfe168e26abb699076c..f78aaff48448a67cd5532945a187e181ca72cc17 100644 (file)
@@ -24,11 +24,11 @@ public:
 
 private:
        std::list<Monitor> monitors;
-       Monitor *primary_monitor = 0;
+       Monitor *primary_monitor = nullptr;
        std::list<VideoMode> 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());
index 71fc0941438d061a592ed064f07c4793e850495c..db67512781c430b295bb7b84065dc93cc5308946 100644 (file)
@@ -12,7 +12,7 @@ namespace Graphics {
 
 struct Display::Private: PlatformDisplayPrivate
 {
-       DisplayHandle display = 0;
+       DisplayHandle display = nullptr;
        std::map<WindowHandle, Window *> windows;
 };
 
index ebdb8015dd5413868b2b8895aac8c456537fb7d0..809ed0499591587c299e8c8cae018d4608e1dc20 100644 (file)
@@ -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<int> 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);
 
index e0c423cc04005f3aec1a08bd278fc5f965db6dd2..6885834b4cbc37e55592044e326d653d62d31356 100644 (file)
@@ -11,7 +11,7 @@ class Display;
 class ErrorDialog: public Debug::ErrorReporter
 {
 private:
-       Display *display = 0;
+       Display *display = nullptr;
 
 public:
        ErrorDialog(Display *d): display(d) { }
index c637b39e95308bdf6913e7c3dbbfc52de5f9839d..ef374c1038efc6da274d5b62b370656a4b3fe2f7 100644 (file)
@@ -42,7 +42,7 @@ private:
 
        Display &display;
        Window &window;
-       Private *priv = 0;
+       Private *priv = nullptr;
 
 public:
        GLContext(Window &wnd, const GLOptions &opts = GLOptions());
index 699f856f35d06ce239f7576e7b499500f3b6fc6a..ad63350283c223cc3a92aec699f316e5b8ad471c 100644 (file)
@@ -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<const char *>(glGetString(GL_VERSION));
@@ -121,7 +121,7 @@ void GLContext::platform_init(const GLOptions &opts)
                                gl_version_major = lexical_cast<unsigned>(parts[0]);
                                gl_version_minor = lexical_cast<unsigned>(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<const GLubyte *>("glXCreateContextAttribsARB");
                        PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = reinterpret_cast<PFNGLXCREATECONTEXTATTRIBSARBPROC>(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);
 
index 5b2eb1ac3f6decbe74b5c774c246a9e58c6c0aa1..813672bca52d8fdec846629e53845af9c3a6dd17 100644 (file)
@@ -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;
index d9f5870bdea53aea092be5c4d5a7e4ca5c90b4d8..3f8f556e85a42fa88e5f7f886918037b3143434e 100644 (file)
@@ -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 &);
index 6a3196c91c94071850663b0522a830e24026dd05..a9383401a6f46c10a5f58fcfa0ef55369ff006b3 100644 (file)
@@ -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);
index 65f3c5679e2b41b66fd4d964a7a5f9a4aa2762b9..ca69459f22601dcd2ee520f419b3881c279c42dc 100644 (file)
@@ -60,7 +60,7 @@ protected:
        };
 
 private:
-       IO::Base *source = 0;
+       IO::Base *source = nullptr;
        State state = INITIAL;
 
 protected:
index 4773168aace6848f7e26605c4fb716418acf2d24..88dc00c85e519d9b7c2c69e16ec774a956c18e8f 100644 (file)
@@ -11,7 +11,7 @@ class JpegLoader: public ImageLoader
 private:
        struct Private;
 
-       Private *priv = 0;
+       Private *priv = nullptr;
 
 public:
        JpegLoader(IO::Seekable &);
index 0fc9798568348e1eedd745eac9c8212e3f41fd4e..b74cea898a6398390cce90d21ad20bcea06fb000 100644 (file)
@@ -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<const VideoMode *> 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
index 7842c1864a60c69072906be62f3957c19a6171cb..9c2e1ae339213c2f3cc5a2ad5965ecebb759bf33 100644 (file)
@@ -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<png_byte *>(data.pixels+data.stride*(data.height-1-y));
 
                for(unsigned i=0; i<n_passes; ++i)
-                       png_read_rows(priv->png, rows, 0, data.height);
+                       png_read_rows(priv->png, rows, nullptr, data.height);
 
                delete[] rows;
-               rows = 0;
        }
        else
        {
                for(unsigned y=0; y<data.height; ++y)
-                       png_read_row(priv->png, reinterpret_cast<png_byte *>(data.pixels+data.stride*(data.height-1-y)), 0);
+                       png_read_row(priv->png, reinterpret_cast<png_byte *>(data.pixels+data.stride*(data.height-1-y)), nullptr);
        }
 
-       png_read_end(priv->png, 0);
+       png_read_end(priv->png, nullptr);
 }
 
 } // namespace Graphics
index c21cc5a4474945100a91aa9cfb4f18634fe462cc..f334d82231f760489113667469abdd32e87f2a35 100644 (file)
@@ -11,7 +11,7 @@ class PngLoader: public ImageLoader
 private:
        struct Private;
 
-       Private *priv = 0;
+       Private *priv = nullptr;
 
 public:
        PngLoader(IO::Base &, unsigned = 0);
index c4517ec3b61520a49e7c312449a34b2a14ba4c0b..73c74c00fc6e58eea38c675b94fe17a2a94781ce 100644 (file)
@@ -11,7 +11,7 @@ class QuartzLoader: public ImageLoader
 private:
        struct Private;
 
-       Private *priv = 0;
+       Private *priv = nullptr;
 
 public:
        QuartzLoader(IO::Seekable &);
index 6c83d945185123a055fd967082875f32b9aa484c..c527ed75de9d75b2d42b45a8635f87ee7c854be9 100644 (file)
@@ -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;
index 7026e3007aa738fb3284b418fed75002f43959c6..c3a7d761a1969601e8fe9ddfdf213b5c158de901 100644 (file)
@@ -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<VkQueueFamilyProperties> 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;
 }
 
index aa82880d05c229555c64f54c05b6256e9cf8e36f..888557e1fe2e39b92ac786d07bd3fc0d7939dfc4 100644 (file)
@@ -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 *);
 };
index c59007900a847c7583237f318f4ab8a5482d18a8..211f86a8af47a305ba0c8bc7bb515aafdc3dda03 100644 (file)
@@ -34,7 +34,7 @@ private:
 
        Display &display;
        Window &window;
-       Private *priv = 0;
+       Private *priv = nullptr;
 
 public:
        VulkanContext(Window &, const VulkanOptions & = VulkanOptions());
index 2791fed5e7cc8e01444cbbdccd6c2dec1f62cc0a..3627a17ff286ca6494c2e81cdf7e6f2051208d25 100644 (file)
@@ -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;
index 09ab25b1b42e3d9bebb86e659bbe62228a0b74f2..de8a3d0beaccf79c2bc7bf9e42c3535840636fbf 100644 (file)
@@ -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);
index ee08395659a4aef8701d1dcf5162e00d8f1b3508..bea18a64d0f8b05d372e8e900f2e89c4f7d1608f 100644 (file)
@@ -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);
index b90498bc53dbcf650b6ae1f6c5c31ee3a83bec69..e7ec9109c5fa16f1f19db2f5930359cd77a39d17 100644 (file)
@@ -50,12 +50,12 @@ void Window::platform_init()
                wndcl.cbClsExtra = 0;
                wndcl.cbWndExtra = sizeof(Window *);
                wndcl.hInstance = reinterpret_cast<HINSTANCE>(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;
index edc6a12a0d48e2bd433e467a084b7c4ff689cdc6..fd6048566d3faec09b0108440e7b4f008a985a33 100644 (file)
@@ -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; i<res->noutput; ++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;
index e33511e888b17f57a82646416239841f9a8bc26c..96d098551b561861254e65c2d1a59d6ba8ee0cdf 100644 (file)
@@ -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);
index 1c58816ea82a8d636f65d50e21591476c130a561..291c8f152584b552acbf7228053fcb1ed765ee6b 100644 (file)
@@ -19,7 +19,7 @@ vector<Device *> 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.device<resolved_devs.size() ? resolved_devs[b.device] : 0);
+               Device *bdev = (b.device<resolved_devs.size() ? resolved_devs[b.device] : nullptr);
                if(ctrl && bdev)
                {
                        ctrl->set_source(*bdev, b.type, b.index);
index 2bb4104cbc83539352039fec982aff163c0c98ff..4f093573baeaf2418a2faf25ca881934b94aecae 100644 (file)
@@ -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();
                }
index b71c81871e94ca67b95433d91b679a2e9234751a..f9c7003b4290ea17b8f57dfb43249b03f8489288 100644 (file)
@@ -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;
index 4aa8ce6b20fb0910d5d15e144de8d0d33a03b336..b615cb7fb92fe870ede98effec9ed505db4ed848 100644 (file)
@@ -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
index 6393ac09358a6b297cc2f0b261e5c94dccd8a5cd..baf94cb6c9e437f05422636787111c2b1d57d985 100644 (file)
@@ -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;
index e7eb0fc115581a1400e603640103e57b620c5d0c..1916126c9ff3f3be420de975bb3b93ea03ad9f55 100644 (file)
@@ -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
index 86768751af3e185dd548e21162e41c07720ab039..224450e0cccf6aec8421770c7eb41f1329a737f8 100644 (file)
@@ -33,7 +33,7 @@ public:
 
 struct GameController::Private
 {
-       JsDevice *dev = 0;
+       JsDevice *dev = nullptr;
 
        static std::vector<std::string> detected_controllers;
 };
index 988509bf99a4990a3972381c33d2734d1447f275..0532aef68ca66d62dc6d38808da0a08c07529eb9 100644 (file)
@@ -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;
index 5f7182404bc5cb11bf12bdebd5cb3b1dc7259ef1..b5eb9aa2fd9dea6c56d81a38d40ed88755893671 100644 (file)
@@ -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;
 
index df29666cc73904d9dd83d437e50d58d94a6aa97d..46536b39d37acba729c300c02a748a7a825bd18f 100644 (file)
@@ -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;
        }
 }
 
index d6ee6c27d4bc2f252acf3bc26d1fb4187f37d30b..1541ae7edb5aad809728682149a6daa3690041be 100644 (file)
@@ -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<unsigned> detected_controllers;
 
index ed959dafe40e9fb643202a2fc7eea0bb9b9b4e2d..00b6448e316bf84232fc64e0245e3c4010abe209 100644 (file)
@@ -33,7 +33,7 @@ void Keyboard::input_event(const Graphics::Window::Event &event)
                        if(event.xevent.type==KeyPress)
                        {
                                char ch;
-                               if(XLookupString(const_cast<XKeyEvent *>(&event.xevent.xkey), &ch, 1, 0, 0))
+                               if(XLookupString(const_cast<XKeyEvent *>(&event.xevent.xkey), &ch, 1, nullptr, nullptr))
                                        // XLookupString always returns Latin-1
                                        signal_character.emit(static_cast<unsigned char>(ch));
                        }