From c9f7cb3d525a995912fc62507802f3f265de2728 Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Fri, 3 Dec 2021 14:45:32 +0000 Subject: [PATCH] Use 'nullptr' instead of 'NULL' --- examples/X11/X11.cpp | 6 +- examples/android/app/src/main/jni/main.cpp | 20 +++---- examples/cocoa/NSString+stdstring.mm | 2 +- examples/shader/Effect.hpp | 2 +- examples/shader/Shader.cpp | 2 +- examples/tennis/Tennis.cpp | 2 +- examples/win32/Win32.cpp | 16 +++--- include/SFML/Audio/Sound.hpp | 2 +- include/SFML/Graphics/Shader.hpp | 6 +- include/SFML/Graphics/Shape.hpp | 4 +- include/SFML/Graphics/Sprite.hpp | 2 +- include/SFML/Graphics/Text.hpp | 2 +- include/SFML/Graphics/Texture.hpp | 4 +- include/SFML/Graphics/VertexBuffer.hpp | 2 +- include/SFML/Network/Packet.hpp | 2 +- include/SFML/System/Err.hpp | 2 +- include/SFML/System/Thread.inl | 6 +- include/SFML/System/ThreadLocal.hpp | 2 +- include/SFML/System/ThreadLocalPtr.hpp | 2 +- include/SFML/Window/Context.hpp | 2 +- include/SFML/Window/WindowBase.hpp | 2 +- src/SFML/Audio/AudioDevice.cpp | 10 ++-- src/SFML/Audio/InputSoundFile.cpp | 8 +-- src/SFML/Audio/OutputSoundFile.cpp | 4 +- src/SFML/Audio/Sound.cpp | 10 ++-- src/SFML/Audio/SoundBuffer.cpp | 2 +- src/SFML/Audio/SoundFileFactory.cpp | 10 ++-- src/SFML/Audio/SoundFileReaderFlac.cpp | 8 +-- src/SFML/Audio/SoundFileReaderOgg.cpp | 12 ++-- src/SFML/Audio/SoundFileReaderWav.cpp | 2 +- src/SFML/Audio/SoundFileWriterFlac.cpp | 6 +- src/SFML/Audio/SoundFileWriterOgg.cpp | 2 +- src/SFML/Audio/SoundRecorder.cpp | 8 +-- src/SFML/Audio/SoundStream.cpp | 6 +- src/SFML/Graphics/Font.cpp | 28 +++++----- src/SFML/Graphics/Image.cpp | 16 +++--- src/SFML/Graphics/RenderStates.cpp | 16 +++--- src/SFML/Graphics/RenderTarget.cpp | 14 ++--- src/SFML/Graphics/RenderTexture.cpp | 2 +- src/SFML/Graphics/RenderTextureImplFBO.cpp | 4 +- src/SFML/Graphics/Shader.cpp | 30 +++++----- src/SFML/Graphics/Shape.cpp | 4 +- src/SFML/Graphics/Sprite.cpp | 6 +- src/SFML/Graphics/Text.cpp | 2 +- src/SFML/Graphics/Texture.cpp | 2 +- src/SFML/Main/MainAndroid.cpp | 38 ++++++------- src/SFML/Main/SFMLActivity.cpp | 6 +- src/SFML/Network/IpAddress.cpp | 4 +- src/SFML/Network/Packet.cpp | 4 +- src/SFML/Network/SocketSelector.cpp | 2 +- src/SFML/Network/TcpSocket.cpp | 2 +- src/SFML/System/Android/Activity.cpp | 4 +- src/SFML/System/Android/ResourceStream.cpp | 2 +- src/SFML/System/FileInputStream.cpp | 4 +- src/SFML/System/MemoryInputStream.cpp | 2 +- src/SFML/System/Thread.cpp | 4 +- src/SFML/System/Unix/ThreadImpl.cpp | 8 +-- src/SFML/System/Unix/ThreadLocalImpl.cpp | 2 +- src/SFML/System/Win32/ThreadImpl.cpp | 2 +- src/SFML/Window/Android/InputImpl.cpp | 10 ++-- src/SFML/Window/Android/SensorImpl.cpp | 4 +- src/SFML/Window/Android/SensorImpl.hpp | 2 +- src/SFML/Window/Android/WindowImplAndroid.cpp | 14 ++--- src/SFML/Window/Context.cpp | 6 +- src/SFML/Window/EglContext.cpp | 12 ++-- src/SFML/Window/EglContext.hpp | 4 +- src/SFML/Window/FreeBSD/JoystickImpl.cpp | 2 +- src/SFML/Window/GlContext.cpp | 34 +++++------ src/SFML/Window/GlContext.hpp | 2 +- src/SFML/Window/NetBSD/JoystickImpl.cpp | 2 +- src/SFML/Window/OSX/HIDInputManager.hpp | 2 +- src/SFML/Window/OSX/HIDInputManager.mm | 14 ++--- src/SFML/Window/OSX/HIDJoystickManager.cpp | 6 +- src/SFML/Window/OSX/HIDJoystickManager.hpp | 2 +- src/SFML/Window/OSX/InputImpl.mm | 2 +- src/SFML/Window/OSX/JoystickImpl.cpp | 22 ++++---- src/SFML/Window/OSX/SFContext.hpp | 4 +- src/SFML/Window/OSX/SFContext.mm | 4 +- src/SFML/Window/OSX/VideoModeImpl.cpp | 4 +- src/SFML/Window/Unix/Display.cpp | 4 +- src/SFML/Window/Unix/GlxContext.cpp | 34 +++++------ src/SFML/Window/Unix/GlxContext.hpp | 6 +- src/SFML/Window/Unix/JoystickImpl.cpp | 14 ++--- src/SFML/Window/Unix/VulkanImplX11.cpp | 12 ++-- src/SFML/Window/Unix/WindowImplX11.cpp | 56 +++++++++---------- src/SFML/Window/Vulkan.cpp | 2 +- src/SFML/Window/Win32/ClipboardImpl.cpp | 4 +- src/SFML/Window/Win32/CursorImpl.cpp | 18 +++--- src/SFML/Window/Win32/JoystickImpl.cpp | 50 ++++++++--------- src/SFML/Window/Win32/VideoModeImpl.cpp | 4 +- src/SFML/Window/Win32/VulkanImplWin32.cpp | 14 ++--- src/SFML/Window/Win32/WglContext.cpp | 56 +++++++++---------- src/SFML/Window/Win32/WglContext.hpp | 6 +- src/SFML/Window/Win32/WindowImplWin32.cpp | 52 ++++++++--------- src/SFML/Window/Window.cpp | 8 +-- src/SFML/Window/WindowBase.cpp | 14 ++--- src/SFML/Window/iOS/EaglContext.hpp | 6 +- src/SFML/Window/iOS/SFAppDelegate.mm | 10 ++-- src/SFML/Window/iOS/SFView.mm | 2 +- 99 files changed, 455 insertions(+), 455 deletions(-) diff --git a/examples/X11/X11.cpp b/examples/X11/X11.cpp index 76d52d37a..b4365fb20 100644 --- a/examples/X11/X11.cpp +++ b/examples/X11/X11.cpp @@ -142,7 +142,7 @@ void draw(sf::Window& window, float elapsedTime) int main() { // Open a connection with the X server - Display* display = XOpenDisplay(NULL); + Display* display = XOpenDisplay(nullptr); if (!display) return EXIT_FAILURE; @@ -171,13 +171,13 @@ int main() DefaultDepth(display, screen), InputOutput, DefaultVisual(display, screen), - 0, NULL); + 0, nullptr); Window view2 = XCreateWindow(display, window, 330, 10, 310, 310, 0, DefaultDepth(display, screen), InputOutput, DefaultVisual(display, screen), - 0, NULL); + 0, nullptr); // Show our windows XMapWindow(display, window); diff --git a/examples/android/app/src/main/jni/main.cpp b/examples/android/app/src/main/jni/main.cpp index 10240e37d..b9934e0ee 100644 --- a/examples/android/app/src/main/jni/main.cpp +++ b/examples/android/app/src/main/jni/main.cpp @@ -23,7 +23,7 @@ int vibrate(sf::Time duration) { // First we'll need the native activity handle ANativeActivity *activity = sf::getNativeActivity(); - + // Retrieve the JVM and JNI environment JavaVM* vm = activity->vm; JNIEnv* env = activity->env; @@ -32,7 +32,7 @@ int vibrate(sf::Time duration) JavaVMAttachArgs attachargs; attachargs.version = JNI_VERSION_1_6; attachargs.name = "NativeThread"; - attachargs.group = NULL; + attachargs.group = nullptr; jint res = vm->AttachCurrentThread(&env, &attachargs); if (res == JNI_ERR) @@ -41,22 +41,22 @@ int vibrate(sf::Time duration) // Retrieve class information jclass natact = env->FindClass("android/app/NativeActivity"); jclass context = env->FindClass("android/content/Context"); - + // Get the value of a constant jfieldID fid = env->GetStaticFieldID(context, "VIBRATOR_SERVICE", "Ljava/lang/String;"); jobject svcstr = env->GetStaticObjectField(context, fid); - + // Get the method 'getSystemService' and call it jmethodID getss = env->GetMethodID(natact, "getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;"); jobject vib_obj = env->CallObjectMethod(activity->clazz, getss, svcstr); - + // Get the object's class and retrieve the member name jclass vib_cls = env->GetObjectClass(vib_obj); - jmethodID vibrate = env->GetMethodID(vib_cls, "vibrate", "(J)V"); - + jmethodID vibrate = env->GetMethodID(vib_cls, "vibrate", "(J)V"); + // Determine the timeframe jlong length = duration.asMilliseconds(); - + // Bzzz! env->CallVoidMethod(vib_obj, vibrate, length); @@ -66,7 +66,7 @@ int vibrate(sf::Time duration) env->DeleteLocalRef(svcstr); env->DeleteLocalRef(context); env->DeleteLocalRef(natact); - + // Detach thread again vm->DetachCurrentThread(); } @@ -133,7 +133,7 @@ int main(int argc, char *argv[]) case sf::Event::GainedFocus: background = sf::Color::White; break; - + // On Android MouseLeft/MouseEntered are (for now) triggered, // whenever the app loses or gains focus. case sf::Event::MouseLeft: diff --git a/examples/cocoa/NSString+stdstring.mm b/examples/cocoa/NSString+stdstring.mm index 36a2f4dff..bb074fb39 100644 --- a/examples/cocoa/NSString+stdstring.mm +++ b/examples/cocoa/NSString+stdstring.mm @@ -56,7 +56,7 @@ // work for characters like é or à. const char *cstr = [self cStringUsingEncoding:NSISOLatin1StringEncoding]; - if (cstr != NULL) + if (cstr != nullptr) return std::string(cstr); else return ""; diff --git a/examples/shader/Effect.hpp b/examples/shader/Effect.hpp index 0ff65b433..f6065dfe0 100644 --- a/examples/shader/Effect.hpp +++ b/examples/shader/Effect.hpp @@ -66,7 +66,7 @@ protected: static const sf::Font& getFont() { - assert(s_font != NULL); + assert(s_font != nullptr); return *s_font; } diff --git a/examples/shader/Shader.cpp b/examples/shader/Shader.cpp index 3e885fd3e..7ded53299 100644 --- a/examples/shader/Shader.cpp +++ b/examples/shader/Shader.cpp @@ -7,7 +7,7 @@ #include -const sf::Font* Effect::s_font = NULL; +const sf::Font* Effect::s_font = nullptr; //////////////////////////////////////////////////////////// // "Pixelate" fragment shader diff --git a/examples/tennis/Tennis.cpp b/examples/tennis/Tennis.cpp index bc80bf5ed..c598b641f 100644 --- a/examples/tennis/Tennis.cpp +++ b/examples/tennis/Tennis.cpp @@ -29,7 +29,7 @@ std::string resourcesDir() //////////////////////////////////////////////////////////// int main() { - std::srand(static_cast(std::time(NULL))); + std::srand(static_cast(std::time(nullptr))); // Define some constants const float pi = 3.14159f; diff --git a/examples/win32/Win32.cpp b/examples/win32/Win32.cpp index 9b696c2c1..ccf32b8a8 100644 --- a/examples/win32/Win32.cpp +++ b/examples/win32/Win32.cpp @@ -49,7 +49,7 @@ LRESULT CALLBACK onEvent(HWND handle, UINT message, WPARAM wParam, LPARAM lParam //////////////////////////////////////////////////////////// int main() { - HINSTANCE instance = GetModuleHandle(NULL); + HINSTANCE instance = GetModuleHandle(nullptr); // Define a class for our main window WNDCLASS windowClass; @@ -58,22 +58,22 @@ int main() windowClass.cbClsExtra = 0; windowClass.cbWndExtra = 0; windowClass.hInstance = instance; - windowClass.hIcon = NULL; + windowClass.hIcon = nullptr; windowClass.hCursor = 0; windowClass.hbrBackground = reinterpret_cast(COLOR_BACKGROUND); - windowClass.lpszMenuName = NULL; + windowClass.lpszMenuName = nullptr; windowClass.lpszClassName = TEXT("SFML App"); RegisterClass(&windowClass); // Let's create the main window - HWND window = CreateWindow(TEXT("SFML App"), TEXT("SFML Win32"), WS_SYSMENU | WS_VISIBLE, 200, 200, 660, 520, NULL, NULL, instance, NULL); + HWND window = CreateWindow(TEXT("SFML App"), TEXT("SFML Win32"), WS_SYSMENU | WS_VISIBLE, 200, 200, 660, 520, nullptr, nullptr, instance, nullptr); // Add a button for exiting - button = CreateWindow(TEXT("BUTTON"), TEXT("Quit"), WS_CHILD | WS_VISIBLE, 560, 440, 80, 40, window, NULL, instance, NULL); + button = CreateWindow(TEXT("BUTTON"), TEXT("Quit"), WS_CHILD | WS_VISIBLE, 560, 440, 80, 40, window, nullptr, instance, nullptr); // Let's create two SFML views - HWND view1 = CreateWindow(TEXT("STATIC"), NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, 20, 20, 300, 400, window, NULL, instance, NULL); - HWND view2 = CreateWindow(TEXT("STATIC"), NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, 340, 20, 300, 400, window, NULL, instance, NULL); + HWND view1 = CreateWindow(TEXT("STATIC"), nullptr, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, 20, 20, 300, 400, window, nullptr, instance, nullptr); + HWND view2 = CreateWindow(TEXT("STATIC"), nullptr, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, 340, 20, 300, 400, window, nullptr, instance, nullptr); sf::RenderWindow SFMLView1(view1); sf::RenderWindow SFMLView2(view2); @@ -94,7 +94,7 @@ int main() message.message = static_cast(~WM_QUIT); while (message.message != WM_QUIT) { - if (PeekMessage(&message, NULL, 0, 0, PM_REMOVE)) + if (PeekMessage(&message, nullptr, 0, 0, PM_REMOVE)) { // If a message was waiting in the message queue, process it TranslateMessage(&message); diff --git a/include/SFML/Audio/Sound.hpp b/include/SFML/Audio/Sound.hpp index 513379f45..4891a568b 100644 --- a/include/SFML/Audio/Sound.hpp +++ b/include/SFML/Audio/Sound.hpp @@ -158,7 +158,7 @@ public: //////////////////////////////////////////////////////////// /// \brief Get the audio buffer attached to the sound /// - /// \return Sound buffer attached to the sound (can be NULL) + /// \return Sound buffer attached to the sound (can be a null pointer) /// //////////////////////////////////////////////////////////// const SoundBuffer* getBuffer() const; diff --git a/include/SFML/Graphics/Shader.hpp b/include/SFML/Graphics/Shader.hpp index 00673b8c4..87531dd0e 100644 --- a/include/SFML/Graphics/Shader.hpp +++ b/include/SFML/Graphics/Shader.hpp @@ -651,7 +651,7 @@ public: /// // draw OpenGL stuff that use s1... /// sf::Shader::bind(&s2); /// // draw OpenGL stuff that use s2... - /// sf::Shader::bind(NULL); + /// sf::Shader::bind(nullptr); /// // draw OpenGL stuff that use no shader... /// \endcode /// @@ -696,7 +696,7 @@ private: //////////////////////////////////////////////////////////// /// \brief Compile the shader(s) and create the program /// - /// If one of the arguments is NULL, the corresponding shader + /// If one of the arguments is a null pointer, the corresponding shader /// is not created. /// /// \param vertexShaderCode Source code of the vertex shader @@ -867,7 +867,7 @@ private: /// \code /// sf::Shader::bind(&shader); /// ... render OpenGL geometry ... -/// sf::Shader::bind(NULL); +/// sf::Shader::bind(nullptr); /// \endcode /// /// \see sf::Glsl diff --git a/include/SFML/Graphics/Shape.hpp b/include/SFML/Graphics/Shape.hpp index 251b3cd41..1fc91f48e 100644 --- a/include/SFML/Graphics/Shape.hpp +++ b/include/SFML/Graphics/Shape.hpp @@ -60,7 +60,7 @@ public: /// a pointer to the one that you passed to this function. /// If the source texture is destroyed and the shape tries to /// use it, the behavior is undefined. - /// \a texture can be NULL to disable texturing. + /// \a texture can be a null pointer to disable texturing. /// If \a resetRect is true, the TextureRect property of /// the shape is automatically adjusted to the size of the new /// texture. If it is false, the texture rect is left unchanged. @@ -134,7 +134,7 @@ public: //////////////////////////////////////////////////////////// /// \brief Get the source texture of the shape /// - /// If the shape has no source texture, a NULL pointer is returned. + /// If the shape has no source texture, a null pointer is returned. /// The returned pointer is const, which means that you can't /// modify the texture when you retrieve it with this function. /// diff --git a/include/SFML/Graphics/Sprite.hpp b/include/SFML/Graphics/Sprite.hpp index 872020221..571f1d4ba 100644 --- a/include/SFML/Graphics/Sprite.hpp +++ b/include/SFML/Graphics/Sprite.hpp @@ -130,7 +130,7 @@ public: //////////////////////////////////////////////////////////// /// \brief Get the source texture of the sprite /// - /// If the sprite has no source texture, a NULL pointer is returned. + /// If the sprite has no source texture, a null pointer is returned. /// The returned pointer is const, which means that you can't /// modify the texture when you retrieve it with this function. /// diff --git a/include/SFML/Graphics/Text.hpp b/include/SFML/Graphics/Text.hpp index c3285371a..69b439acc 100644 --- a/include/SFML/Graphics/Text.hpp +++ b/include/SFML/Graphics/Text.hpp @@ -272,7 +272,7 @@ public: //////////////////////////////////////////////////////////// /// \brief Get the text's font /// - /// If the text has no font attached, a NULL pointer is returned. + /// If the text has no font attached, a null pointer is returned. /// The returned pointer is const, which means that you /// cannot modify the font when you get it from this function. /// diff --git a/include/SFML/Graphics/Texture.hpp b/include/SFML/Graphics/Texture.hpp index ddd5e3a7d..8214f3f0b 100644 --- a/include/SFML/Graphics/Texture.hpp +++ b/include/SFML/Graphics/Texture.hpp @@ -552,7 +552,7 @@ public: /// // draw OpenGL stuff that use t1... /// sf::Texture::bind(&t2); /// // draw OpenGL stuff that use t2... - /// sf::Texture::bind(NULL); + /// sf::Texture::bind(nullptr); /// // draw OpenGL stuff that use no texture... /// \endcode /// @@ -725,7 +725,7 @@ private: /// \code /// sf::Texture::bind(&texture); /// ... render OpenGL geometry ... -/// sf::Texture::bind(NULL); +/// sf::Texture::bind(nullptr); /// \endcode /// /// \see sf::Sprite, sf::Image, sf::RenderTexture diff --git a/include/SFML/Graphics/VertexBuffer.hpp b/include/SFML/Graphics/VertexBuffer.hpp index 3615ca8dc..38979841f 100644 --- a/include/SFML/Graphics/VertexBuffer.hpp +++ b/include/SFML/Graphics/VertexBuffer.hpp @@ -297,7 +297,7 @@ public: /// // draw OpenGL stuff that use vb1... /// sf::VertexBuffer::bind(&vb2); /// // draw OpenGL stuff that use vb2... - /// sf::VertexBuffer::bind(NULL); + /// sf::VertexBuffer::bind(nullptr); /// // draw OpenGL stuff that use no vertex buffer... /// \endcode /// diff --git a/include/SFML/Network/Packet.hpp b/include/SFML/Network/Packet.hpp index 9128c2fa8..7056009a4 100644 --- a/include/SFML/Network/Packet.hpp +++ b/include/SFML/Network/Packet.hpp @@ -105,7 +105,7 @@ public: /// Warning: the returned pointer may become invalid after /// you append data to the packet, therefore it should never /// be stored. - /// The return pointer is NULL if the packet is empty. + /// The return pointer is a null pointer if the packet is empty. /// /// \return Pointer to the data /// diff --git a/include/SFML/System/Err.hpp b/include/SFML/System/Err.hpp index babc6c155..a6c926baf 100644 --- a/include/SFML/System/Err.hpp +++ b/include/SFML/System/Err.hpp @@ -69,7 +69,7 @@ SFML_SYSTEM_API std::ostream& err(); /// std::streambuf* previous = sf::err().rdbuf(file.rdbuf()); /// /// // Redirect to nothing -/// sf::err().rdbuf(NULL); +/// sf::err().rdbuf(nullptr); /// /// // Restore the original output /// sf::err().rdbuf(previous); diff --git a/include/SFML/System/Thread.inl b/include/SFML/System/Thread.inl index 3b42c2cef..4d8eb00fe 100644 --- a/include/SFML/System/Thread.inl +++ b/include/SFML/System/Thread.inl @@ -66,7 +66,7 @@ struct ThreadMemberFunc : ThreadFunc //////////////////////////////////////////////////////////// template Thread::Thread(F functor) : -m_impl (NULL), +m_impl (nullptr), m_entryPoint(new priv::ThreadFunctor(functor)) { } @@ -75,7 +75,7 @@ m_entryPoint(new priv::ThreadFunctor(functor)) //////////////////////////////////////////////////////////// template Thread::Thread(F function, A argument) : -m_impl (NULL), +m_impl (nullptr), m_entryPoint(new priv::ThreadFunctorWithArg(function, argument)) { } @@ -84,7 +84,7 @@ m_entryPoint(new priv::ThreadFunctorWithArg(function, argument)) //////////////////////////////////////////////////////////// template Thread::Thread(void(C::*function)(), C* object) : -m_impl (NULL), +m_impl (nullptr), m_entryPoint(new priv::ThreadMemberFunc(function, object)) { } diff --git a/include/SFML/System/ThreadLocal.hpp b/include/SFML/System/ThreadLocal.hpp index 7b4012eb5..6bed2c7ff 100644 --- a/include/SFML/System/ThreadLocal.hpp +++ b/include/SFML/System/ThreadLocal.hpp @@ -54,7 +54,7 @@ public: /// \param value Optional value to initialize the variable /// //////////////////////////////////////////////////////////// - ThreadLocal(void* value = NULL); + ThreadLocal(void* value = nullptr); //////////////////////////////////////////////////////////// /// \brief Destructor diff --git a/include/SFML/System/ThreadLocalPtr.hpp b/include/SFML/System/ThreadLocalPtr.hpp index fb4a62882..af864ffea 100644 --- a/include/SFML/System/ThreadLocalPtr.hpp +++ b/include/SFML/System/ThreadLocalPtr.hpp @@ -48,7 +48,7 @@ public: /// \param value Optional value to initialize the variable /// //////////////////////////////////////////////////////////// - ThreadLocalPtr(T* value = NULL); + ThreadLocalPtr(T* value = nullptr); //////////////////////////////////////////////////////////// /// \brief Overload of unary operator * diff --git a/include/SFML/Window/Context.hpp b/include/SFML/Window/Context.hpp index b834b09ec..73dc2cd41 100644 --- a/include/SFML/Window/Context.hpp +++ b/include/SFML/Window/Context.hpp @@ -116,7 +116,7 @@ public: /// Contexts created e.g. by RenderTargets or for internal /// use will not be returned by this function. /// - /// \return The currently active context or NULL if none is active + /// \return The currently active context or a null pointer if none is active /// //////////////////////////////////////////////////////////// static const Context* getActiveContext(); diff --git a/include/SFML/Window/WindowBase.hpp b/include/SFML/Window/WindowBase.hpp index 2984528f8..e3eaf6fec 100644 --- a/include/SFML/Window/WindowBase.hpp +++ b/include/SFML/Window/WindowBase.hpp @@ -454,7 +454,7 @@ private: //////////////////////////////////////////////////////////// /// \brief Get the fullscreen window /// - /// \return The fullscreen window or NULL if there is none + /// \return The fullscreen window or a null pointer if there is none /// //////////////////////////////////////////////////////////// const WindowBase* getFullscreenWindow(); diff --git a/src/SFML/Audio/AudioDevice.cpp b/src/SFML/Audio/AudioDevice.cpp index 25c86d997..87315c5c2 100644 --- a/src/SFML/Audio/AudioDevice.cpp +++ b/src/SFML/Audio/AudioDevice.cpp @@ -34,8 +34,8 @@ namespace { - ALCdevice* audioDevice = NULL; - ALCcontext* audioContext = NULL; + ALCdevice* audioDevice = nullptr; + ALCcontext* audioContext = nullptr; float listenerVolume = 100.f; sf::Vector3f listenerPosition (0.f, 0.f, 0.f); @@ -51,12 +51,12 @@ namespace priv AudioDevice::AudioDevice() { // Create the device - audioDevice = alcOpenDevice(NULL); + audioDevice = alcOpenDevice(nullptr); if (audioDevice) { // Create the context - audioContext = alcCreateContext(audioDevice, NULL); + audioContext = alcCreateContext(audioDevice, nullptr); if (audioContext) { @@ -90,7 +90,7 @@ AudioDevice::AudioDevice() AudioDevice::~AudioDevice() { // Destroy the context - alcMakeContextCurrent(NULL); + alcMakeContextCurrent(nullptr); if (audioContext) alcDestroyContext(audioContext); diff --git a/src/SFML/Audio/InputSoundFile.cpp b/src/SFML/Audio/InputSoundFile.cpp index 5f30f6186..115dc3054 100644 --- a/src/SFML/Audio/InputSoundFile.cpp +++ b/src/SFML/Audio/InputSoundFile.cpp @@ -40,8 +40,8 @@ namespace sf { //////////////////////////////////////////////////////////// InputSoundFile::InputSoundFile() : -m_reader (NULL), -m_stream (NULL), +m_reader (nullptr), +m_stream (nullptr), m_streamOwned (false), m_sampleOffset (0), m_sampleCount (0), @@ -260,7 +260,7 @@ void InputSoundFile::close() { // Destroy the reader delete m_reader; - m_reader = NULL; + m_reader = nullptr; // Destroy the stream if we own it if (m_streamOwned) @@ -268,7 +268,7 @@ void InputSoundFile::close() delete m_stream; m_streamOwned = false; } - m_stream = NULL; + m_stream = nullptr; m_sampleOffset = 0; // Reset the sound file attributes diff --git a/src/SFML/Audio/OutputSoundFile.cpp b/src/SFML/Audio/OutputSoundFile.cpp index cc94c319a..6771b0efe 100644 --- a/src/SFML/Audio/OutputSoundFile.cpp +++ b/src/SFML/Audio/OutputSoundFile.cpp @@ -34,7 +34,7 @@ namespace sf { //////////////////////////////////////////////////////////// OutputSoundFile::OutputSoundFile() : -m_writer(NULL) +m_writer(nullptr) { } @@ -82,7 +82,7 @@ void OutputSoundFile::close() { // Destroy the reader delete m_writer; - m_writer = NULL; + m_writer = nullptr; } } // namespace sf diff --git a/src/SFML/Audio/Sound.cpp b/src/SFML/Audio/Sound.cpp index bb5b9fabe..f1e509ea3 100644 --- a/src/SFML/Audio/Sound.cpp +++ b/src/SFML/Audio/Sound.cpp @@ -34,14 +34,14 @@ namespace sf { //////////////////////////////////////////////////////////// Sound::Sound() : -m_buffer(NULL) +m_buffer(nullptr) { } //////////////////////////////////////////////////////////// Sound::Sound(const SoundBuffer& buffer) : -m_buffer(NULL) +m_buffer(nullptr) { setBuffer(buffer); } @@ -50,7 +50,7 @@ m_buffer(NULL) //////////////////////////////////////////////////////////// Sound::Sound(const Sound& copy) : SoundSource(copy), -m_buffer (NULL) +m_buffer (nullptr) { if (copy.m_buffer) setBuffer(*copy.m_buffer); @@ -172,7 +172,7 @@ Sound& Sound::operator =(const Sound& right) { stop(); m_buffer->detachSound(this); - m_buffer = NULL; + m_buffer = nullptr; } // Copy the remaining sound attributes @@ -195,7 +195,7 @@ void Sound::resetBuffer() { alCheck(alSourcei(m_source, AL_BUFFER, 0)); m_buffer->detachSound(this); - m_buffer = NULL; + m_buffer = nullptr; } } diff --git a/src/SFML/Audio/SoundBuffer.cpp b/src/SFML/Audio/SoundBuffer.cpp index cd88145b1..764c8e87e 100644 --- a/src/SFML/Audio/SoundBuffer.cpp +++ b/src/SFML/Audio/SoundBuffer.cpp @@ -162,7 +162,7 @@ bool SoundBuffer::saveToFile(const std::string& filename) const //////////////////////////////////////////////////////////// const Int16* SoundBuffer::getSamples() const { - return m_samples.empty() ? NULL : &m_samples[0]; + return m_samples.empty() ? nullptr : &m_samples[0]; } diff --git a/src/SFML/Audio/SoundFileFactory.cpp b/src/SFML/Audio/SoundFileFactory.cpp index 58c9edd51..7b9c70ed0 100644 --- a/src/SFML/Audio/SoundFileFactory.cpp +++ b/src/SFML/Audio/SoundFileFactory.cpp @@ -72,7 +72,7 @@ SoundFileReader* SoundFileFactory::createReaderFromFilename(const std::string& f FileInputStream stream; if (!stream.open(filename)) { err() << "Failed to open sound file \"" << filename << "\" (couldn't open stream)" << std::endl; - return NULL; + return nullptr; } // Test the filename in all the registered factories @@ -85,7 +85,7 @@ SoundFileReader* SoundFileFactory::createReaderFromFilename(const std::string& f // No suitable reader found err() << "Failed to open sound file \"" << filename << "\" (format not supported)" << std::endl; - return NULL; + return nullptr; } @@ -109,7 +109,7 @@ SoundFileReader* SoundFileFactory::createReaderFromMemory(const void* data, std: // No suitable reader found err() << "Failed to open sound file from memory (format not supported)" << std::endl; - return NULL; + return nullptr; } @@ -129,7 +129,7 @@ SoundFileReader* SoundFileFactory::createReaderFromStream(InputStream& stream) // No suitable reader found err() << "Failed to open sound file from stream (format not supported)" << std::endl; - return NULL; + return nullptr; } @@ -148,7 +148,7 @@ SoundFileWriter* SoundFileFactory::createWriterFromFilename(const std::string& f // No suitable writer found err() << "Failed to open sound file \"" << filename << "\" (format not supported)" << std::endl; - return NULL; + return nullptr; } } // namespace sf diff --git a/src/SFML/Audio/SoundFileReaderFlac.cpp b/src/SFML/Audio/SoundFileReaderFlac.cpp index 371cf5d1d..702346065 100644 --- a/src/SFML/Audio/SoundFileReaderFlac.cpp +++ b/src/SFML/Audio/SoundFileReaderFlac.cpp @@ -191,7 +191,7 @@ bool SoundFileReaderFlac::check(InputStream& stream) ClientData data; data.stream = &stream; data.error = false; - FLAC__stream_decoder_init_stream(decoder, &streamRead, &streamSeek, &streamTell, &streamLength, &streamEof, &streamWrite, NULL, &streamError, &data); + FLAC__stream_decoder_init_stream(decoder, &streamRead, &streamSeek, &streamTell, &streamLength, &streamEof, &streamWrite, nullptr, &streamError, &data); // Read the header bool valid = FLAC__stream_decoder_process_until_end_of_metadata(decoder) != 0; @@ -206,7 +206,7 @@ bool SoundFileReaderFlac::check(InputStream& stream) //////////////////////////////////////////////////////////// SoundFileReaderFlac::SoundFileReaderFlac() : -m_decoder(NULL), +m_decoder(nullptr), m_clientData() { } @@ -255,7 +255,7 @@ void SoundFileReaderFlac::seek(Uint64 sampleOffset) assert(m_decoder); // Reset the callback data (the "write" callback will be called) - m_clientData.buffer = NULL; + m_clientData.buffer = nullptr; m_clientData.remaining = 0; m_clientData.leftovers.clear(); @@ -331,7 +331,7 @@ void SoundFileReaderFlac::close() { FLAC__stream_decoder_finish(m_decoder); FLAC__stream_decoder_delete(m_decoder); - m_decoder = NULL; + m_decoder = nullptr; } } diff --git a/src/SFML/Audio/SoundFileReaderOgg.cpp b/src/SFML/Audio/SoundFileReaderOgg.cpp index 056a3e5c3..adf9c9e20 100644 --- a/src/SFML/Audio/SoundFileReaderOgg.cpp +++ b/src/SFML/Audio/SoundFileReaderOgg.cpp @@ -63,7 +63,7 @@ namespace return static_cast(stream->tell()); } - static ov_callbacks callbacks = {&read, &seek, NULL, &tell}; + static ov_callbacks callbacks = {&read, &seek, nullptr, &tell}; } namespace sf @@ -74,7 +74,7 @@ namespace priv bool SoundFileReaderOgg::check(InputStream& stream) { OggVorbis_File file; - if (ov_test_callbacks(&stream, &file, NULL, 0, callbacks) == 0) + if (ov_test_callbacks(&stream, &file, nullptr, 0, callbacks) == 0) { ov_clear(&file); return true; @@ -91,7 +91,7 @@ SoundFileReaderOgg::SoundFileReaderOgg() : m_vorbis (), m_channelCount(0) { - m_vorbis.datasource = NULL; + m_vorbis.datasource = nullptr; } @@ -106,7 +106,7 @@ SoundFileReaderOgg::~SoundFileReaderOgg() bool SoundFileReaderOgg::open(InputStream& stream, Info& info) { // Open the Vorbis stream - int status = ov_open_callbacks(&stream, &m_vorbis, NULL, 0, callbacks); + int status = ov_open_callbacks(&stream, &m_vorbis, nullptr, 0, callbacks); if (status < 0) { err() << "Failed to open Vorbis file for reading" << std::endl; @@ -145,7 +145,7 @@ Uint64 SoundFileReaderOgg::read(Int16* samples, Uint64 maxCount) while (count < maxCount) { int bytesToRead = static_cast(maxCount - count) * static_cast(sizeof(Int16)); - long bytesRead = ov_read(&m_vorbis, reinterpret_cast(samples), bytesToRead, 0, 2, 1, NULL); + long bytesRead = ov_read(&m_vorbis, reinterpret_cast(samples), bytesToRead, 0, 2, 1, nullptr); if (bytesRead > 0) { long samplesRead = bytesRead / static_cast(sizeof(Int16)); @@ -169,7 +169,7 @@ void SoundFileReaderOgg::close() if (m_vorbis.datasource) { ov_clear(&m_vorbis); - m_vorbis.datasource = NULL; + m_vorbis.datasource = nullptr; m_channelCount = 0; } } diff --git a/src/SFML/Audio/SoundFileReaderWav.cpp b/src/SFML/Audio/SoundFileReaderWav.cpp index 28dfc4e4a..4590cb1ba 100644 --- a/src/SFML/Audio/SoundFileReaderWav.cpp +++ b/src/SFML/Audio/SoundFileReaderWav.cpp @@ -117,7 +117,7 @@ bool SoundFileReaderWav::check(InputStream& stream) //////////////////////////////////////////////////////////// SoundFileReaderWav::SoundFileReaderWav() : -m_stream (NULL), +m_stream (nullptr), m_bytesPerSample(0), m_dataStart (0), m_dataEnd (0) diff --git a/src/SFML/Audio/SoundFileWriterFlac.cpp b/src/SFML/Audio/SoundFileWriterFlac.cpp index e857f47d0..a7d50fcd9 100644 --- a/src/SFML/Audio/SoundFileWriterFlac.cpp +++ b/src/SFML/Audio/SoundFileWriterFlac.cpp @@ -56,7 +56,7 @@ bool SoundFileWriterFlac::check(const std::string& filename) //////////////////////////////////////////////////////////// SoundFileWriterFlac::SoundFileWriterFlac() : -m_encoder (NULL), +m_encoder (nullptr), m_channelCount(0), m_samples32 () { @@ -87,7 +87,7 @@ bool SoundFileWriterFlac::open(const std::string& filename, unsigned int sampleR FLAC__stream_encoder_set_sample_rate(m_encoder, sampleRate); // Initialize the output stream - if (FLAC__stream_encoder_init_file(m_encoder, filename.c_str(), NULL, NULL) != FLAC__STREAM_ENCODER_INIT_STATUS_OK) + if (FLAC__stream_encoder_init_file(m_encoder, filename.c_str(), nullptr, nullptr) != FLAC__STREAM_ENCODER_INIT_STATUS_OK) { err() << "Failed to write flac file \"" << filename << "\" (failed to open the file)" << std::endl; close(); @@ -132,7 +132,7 @@ void SoundFileWriterFlac::close() // Destroy the encoder FLAC__stream_encoder_delete(m_encoder); - m_encoder = NULL; + m_encoder = nullptr; } } diff --git a/src/SFML/Audio/SoundFileWriterOgg.cpp b/src/SFML/Audio/SoundFileWriterOgg.cpp index 4ecc46562..73e2ddc17 100644 --- a/src/SFML/Audio/SoundFileWriterOgg.cpp +++ b/src/SFML/Audio/SoundFileWriterOgg.cpp @@ -175,7 +175,7 @@ void SoundFileWriterOgg::flushBlocks() while (vorbis_analysis_blockout(&m_state, &block) == 1) { // Let the automatic bitrate management do its job - vorbis_analysis(&block, NULL); + vorbis_analysis(&block, nullptr); vorbis_bitrate_addblock(&block); // Get new packets from the bitrate management engine diff --git a/src/SFML/Audio/SoundRecorder.cpp b/src/SFML/Audio/SoundRecorder.cpp index d80182ce0..72416878e 100644 --- a/src/SFML/Audio/SoundRecorder.cpp +++ b/src/SFML/Audio/SoundRecorder.cpp @@ -40,7 +40,7 @@ namespace { - ALCdevice* captureDevice = NULL; + ALCdevice* captureDevice = nullptr; } namespace sf @@ -148,7 +148,7 @@ std::vector SoundRecorder::getAvailableDevices() { std::vector deviceNameList; - const ALchar* deviceList = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER); + const ALchar* deviceList = alcGetString(nullptr, ALC_CAPTURE_DEVICE_SPECIFIER); if (deviceList) { while (*deviceList) @@ -165,7 +165,7 @@ std::vector SoundRecorder::getAvailableDevices() //////////////////////////////////////////////////////////// std::string SoundRecorder::getDefaultDevice() { - return alcGetString(NULL, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER); + return alcGetString(nullptr, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER); } @@ -324,7 +324,7 @@ void SoundRecorder::cleanup() // Close the device alcCaptureCloseDevice(captureDevice); - captureDevice = NULL; + captureDevice = nullptr; } } // namespace sf diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp index df5eb6bd4..6c88e04db 100644 --- a/src/SFML/Audio/SoundStream.cpp +++ b/src/SFML/Audio/SoundStream.cpp @@ -414,14 +414,14 @@ bool SoundStream::fillAndPushBuffer(unsigned int bufferNum, bool immediateLoop) bool requestStop = false; // Acquire audio data, also address EOF and error cases if they occur - Chunk data = {NULL, 0}; + Chunk data = {nullptr, 0}; for (Uint32 retryCount = 0; !onGetData(data) && (retryCount < BufferRetries); ++retryCount) { // Check if the stream must loop or stop if (!m_loop) { // Not looping: Mark this buffer as ending with 0 and request stop - if (data.samples != NULL && data.sampleCount != 0) + if (data.samples != nullptr && data.sampleCount != 0) m_bufferSeeks[bufferNum] = 0; requestStop = true; break; @@ -432,7 +432,7 @@ bool SoundStream::fillAndPushBuffer(unsigned int bufferNum, bool immediateLoop) m_bufferSeeks[bufferNum] = onLoop(); // If we got data, break and process it, else try to fill the buffer once again - if (data.samples != NULL && data.sampleCount != 0) + if (data.samples != nullptr && data.sampleCount != 0) break; // If immediateLoop is specified, we have to immediately adjust the sample count diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 40c17a3ce..bcc7791bf 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -85,16 +85,16 @@ namespace sf { //////////////////////////////////////////////////////////// Font::Font() : -m_library (NULL), -m_face (NULL), -m_streamRec(NULL), -m_stroker (NULL), -m_refCount (NULL), +m_library (nullptr), +m_face (nullptr), +m_streamRec(nullptr), +m_stroker (nullptr), +m_refCount (nullptr), m_isSmooth (true), m_info () { #ifdef SFML_SYSTEM_ANDROID - m_stream = NULL; + m_stream = nullptr; #endif } @@ -112,7 +112,7 @@ m_pages (copy.m_pages), m_pixelBuffer(copy.m_pixelBuffer) { #ifdef SFML_SYSTEM_ANDROID - m_stream = NULL; + m_stream = nullptr; #endif // Note: as FreeType doesn't provide functions for copying/cloning, @@ -283,7 +283,7 @@ bool Font::loadFromStream(InputStream& stream) // Prepare a wrapper for our stream, that we'll pass to FreeType callbacks FT_StreamRec* rec = new FT_StreamRec; std::memset(rec, 0, sizeof(*rec)); - rec->base = NULL; + rec->base = nullptr; rec->size = static_cast(stream.getSize()); rec->pos = 0; rec->descriptor.pointer = &stream; @@ -557,11 +557,11 @@ void Font::cleanup() } // Reset members - m_library = NULL; - m_face = NULL; - m_stroker = NULL; - m_streamRec = NULL; - m_refCount = NULL; + m_library = nullptr; + m_face = nullptr; + m_stroker = nullptr; + m_streamRec = nullptr; + m_refCount = nullptr; m_pages.clear(); std::vector().swap(m_pixelBuffer); } @@ -735,7 +735,7 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f IntRect Font::findGlyphRect(Page& page, unsigned int width, unsigned int height) const { // Find the line that fits well the glyph - Row* row = NULL; + Row* row = nullptr; float bestRatio = 0; for (std::vector::iterator it = page.rows.begin(); it != page.rows.end() && !row; ++it) { diff --git a/src/SFML/Graphics/Image.cpp b/src/SFML/Graphics/Image.cpp index 606fd6648..f27db7265 100644 --- a/src/SFML/Graphics/Image.cpp +++ b/src/SFML/Graphics/Image.cpp @@ -59,7 +59,7 @@ void Image::create(unsigned int width, unsigned int height, const Color& color) { // Create a new pixel buffer first for exception safety's sake std::vector newPixels(width * height * 4); - + // Fill it with the specified color Uint8* ptr = &newPixels[0]; Uint8* end = ptr + newPixels.size(); @@ -70,10 +70,10 @@ void Image::create(unsigned int width, unsigned int height, const Color& color) *ptr++ = color.b; *ptr++ = color.a; } - + // Commit the new pixel buffer m_pixels.swap(newPixels); - + // Assign the new size m_size.x = width; m_size.y = height; @@ -82,7 +82,7 @@ void Image::create(unsigned int width, unsigned int height, const Color& color) { // Dump the pixel buffer std::vector().swap(m_pixels); - + // Assign the new size m_size.x = 0; m_size.y = 0; @@ -97,10 +97,10 @@ void Image::create(unsigned int width, unsigned int height, const Uint8* pixels) { // Create a new pixel buffer first for exception safety's sake std::vector newPixels(pixels, pixels + width * height * 4); - + // Commit the new pixel buffer m_pixels.swap(newPixels); - + // Assign the new size m_size.x = width; m_size.y = height; @@ -109,7 +109,7 @@ void Image::create(unsigned int width, unsigned int height, const Uint8* pixels) { // Dump the pixel buffer std::vector().swap(m_pixels); - + // Assign the new size m_size.x = 0; m_size.y = 0; @@ -294,7 +294,7 @@ const Uint8* Image::getPixelsPtr() const else { err() << "Trying to access the pixels of an empty image" << std::endl; - return NULL; + return nullptr; } } diff --git a/src/SFML/Graphics/RenderStates.cpp b/src/SFML/Graphics/RenderStates.cpp index ae4a56d28..0158a03b1 100644 --- a/src/SFML/Graphics/RenderStates.cpp +++ b/src/SFML/Graphics/RenderStates.cpp @@ -43,8 +43,8 @@ const RenderStates RenderStates::Default(BlendMode( RenderStates::RenderStates() : blendMode(BlendAlpha), transform(), -texture (NULL), -shader (NULL) +texture (nullptr), +shader (nullptr) { } @@ -53,8 +53,8 @@ shader (NULL) RenderStates::RenderStates(const Transform& theTransform) : blendMode(BlendAlpha), transform(theTransform), -texture (NULL), -shader (NULL) +texture (nullptr), +shader (nullptr) { } @@ -63,8 +63,8 @@ shader (NULL) RenderStates::RenderStates(const BlendMode& theBlendMode) : blendMode(theBlendMode), transform(), -texture (NULL), -shader (NULL) +texture (nullptr), +shader (nullptr) { } @@ -74,7 +74,7 @@ RenderStates::RenderStates(const Texture* theTexture) : blendMode(BlendAlpha), transform(), texture (theTexture), -shader (NULL) +shader (nullptr) { } @@ -83,7 +83,7 @@ shader (NULL) RenderStates::RenderStates(const Shader* theShader) : blendMode(BlendAlpha), transform(), -texture (NULL), +texture (nullptr), shader (theShader) { } diff --git a/src/SFML/Graphics/RenderTarget.cpp b/src/SFML/Graphics/RenderTarget.cpp index 5110b4776..586039a1d 100644 --- a/src/SFML/Graphics/RenderTarget.cpp +++ b/src/SFML/Graphics/RenderTarget.cpp @@ -174,7 +174,7 @@ void RenderTarget::clear(const Color& color) if (RenderTargetImpl::isActive(m_id) || setActive(true)) { // Unbind texture to fix RenderTexture preventing clear - applyTexture(NULL); + applyTexture(nullptr); glCheck(glClearColor(color.r / 255.f, color.g / 255.f, color.b / 255.f, color.a / 255.f)); glCheck(glClear(GL_COLOR_BUFFER_BIT)); @@ -404,7 +404,7 @@ void RenderTarget::draw(const VertexBuffer& vertexBuffer, std::size_t firstVerte drawPrimitives(vertexBuffer.getPrimitiveType(), firstVertex, vertexCount); // Unbind vertex buffer - VertexBuffer::bind(NULL); + VertexBuffer::bind(nullptr); cleanupDraw(states); @@ -556,12 +556,12 @@ void RenderTarget::resetGLStates() // Apply the default SFML states applyBlendMode(BlendAlpha); - applyTexture(NULL); + applyTexture(nullptr); if (shaderAvailable) - applyShader(NULL); + applyShader(nullptr); if (vertexBufferAvailable) - glCheck(VertexBuffer::bind(NULL)); + glCheck(VertexBuffer::bind(nullptr)); m_cache.texCoordsArrayEnabled = true; @@ -771,12 +771,12 @@ void RenderTarget::cleanupDraw(const RenderStates& states) { // Unbind the shader, if any if (states.shader) - applyShader(NULL); + applyShader(nullptr); // If the texture we used to draw belonged to a RenderTexture, then forcibly unbind that texture. // This prevents a bug where some drivers do not clear RenderTextures properly. if (states.texture && states.texture->m_fboAttachment) - applyTexture(NULL); + applyTexture(nullptr); // Re-enable the cache at the end of the draw if it was disabled m_cache.enable = true; diff --git a/src/SFML/Graphics/RenderTexture.cpp b/src/SFML/Graphics/RenderTexture.cpp index e6783b3e6..cdb7b2808 100644 --- a/src/SFML/Graphics/RenderTexture.cpp +++ b/src/SFML/Graphics/RenderTexture.cpp @@ -35,7 +35,7 @@ namespace sf { //////////////////////////////////////////////////////////// RenderTexture::RenderTexture() : -m_impl(NULL) +m_impl(nullptr) { } diff --git a/src/SFML/Graphics/RenderTextureImplFBO.cpp b/src/SFML/Graphics/RenderTextureImplFBO.cpp index ba8c1f65a..1b0c92629 100644 --- a/src/SFML/Graphics/RenderTextureImplFBO.cpp +++ b/src/SFML/Graphics/RenderTextureImplFBO.cpp @@ -117,7 +117,7 @@ m_depthStencilBuffer(0), m_colorBuffer (0), m_width (0), m_height (0), -m_context (NULL), +m_context (nullptr), m_textureId (0), m_multisample (false), m_stencil (false), @@ -541,7 +541,7 @@ bool RenderTextureImplFBO::activate(bool active) Lock lock(mutex); std::map::iterator iter; - + if (m_multisample) { iter = m_multisampleFrameBuffers.find(contextId); diff --git a/src/SFML/Graphics/Shader.cpp b/src/SFML/Graphics/Shader.cpp index 90856b008..65e72ee08 100644 --- a/src/SFML/Graphics/Shader.cpp +++ b/src/SFML/Graphics/Shader.cpp @@ -252,11 +252,11 @@ bool Shader::loadFromFile(const std::string& filename, Type type) // Compile the shader program if (type == Vertex) - return compile(&shader[0], NULL, NULL); + return compile(&shader[0], nullptr, nullptr); else if (type == Geometry) - return compile(NULL, &shader[0], NULL); + return compile(nullptr, &shader[0], nullptr); else - return compile(NULL, NULL, &shader[0]); + return compile(nullptr, nullptr, &shader[0]); } @@ -280,7 +280,7 @@ bool Shader::loadFromFile(const std::string& vertexShaderFilename, const std::st } // Compile the shader program - return compile(&vertexShader[0], NULL, &fragmentShader[0]); + return compile(&vertexShader[0], nullptr, &fragmentShader[0]); } @@ -321,11 +321,11 @@ bool Shader::loadFromMemory(const std::string& shader, Type type) { // Compile the shader program if (type == Vertex) - return compile(shader.c_str(), NULL, NULL); + return compile(shader.c_str(), nullptr, nullptr); else if (type == Geometry) - return compile(NULL, shader.c_str(), NULL); + return compile(nullptr, shader.c_str(), nullptr); else - return compile(NULL, NULL, shader.c_str()); + return compile(nullptr, nullptr, shader.c_str()); } @@ -333,7 +333,7 @@ bool Shader::loadFromMemory(const std::string& shader, Type type) bool Shader::loadFromMemory(const std::string& vertexShader, const std::string& fragmentShader) { // Compile the shader program - return compile(vertexShader.c_str(), NULL, fragmentShader.c_str()); + return compile(vertexShader.c_str(), nullptr, fragmentShader.c_str()); } @@ -358,11 +358,11 @@ bool Shader::loadFromStream(InputStream& stream, Type type) // Compile the shader program if (type == Vertex) - return compile(&shader[0], NULL, NULL); + return compile(&shader[0], nullptr, nullptr); else if (type == Geometry) - return compile(NULL, &shader[0], NULL); + return compile(nullptr, &shader[0], nullptr); else - return compile(NULL, NULL, &shader[0]); + return compile(nullptr, nullptr, &shader[0]); } @@ -386,7 +386,7 @@ bool Shader::loadFromStream(InputStream& vertexShaderStream, InputStream& fragme } // Compile the shader program - return compile(&vertexShader[0], NULL, &fragmentShader[0]); + return compile(&vertexShader[0], nullptr, &fragmentShader[0]); } @@ -864,7 +864,7 @@ bool Shader::compile(const char* vertexShaderCode, const char* geometryShaderCod // Create and compile the shader GLEXT_GLhandle vertexShader; glCheck(vertexShader = GLEXT_glCreateShaderObject(GLEXT_GL_VERTEX_SHADER)); - glCheck(GLEXT_glShaderSource(vertexShader, 1, &vertexShaderCode, NULL)); + glCheck(GLEXT_glShaderSource(vertexShader, 1, &vertexShaderCode, nullptr)); glCheck(GLEXT_glCompileShader(vertexShader)); // Check the compile log @@ -891,7 +891,7 @@ bool Shader::compile(const char* vertexShaderCode, const char* geometryShaderCod { // Create and compile the shader GLEXT_GLhandle geometryShader = GLEXT_glCreateShaderObject(GLEXT_GL_GEOMETRY_SHADER); - glCheck(GLEXT_glShaderSource(geometryShader, 1, &geometryShaderCode, NULL)); + glCheck(GLEXT_glShaderSource(geometryShader, 1, &geometryShaderCode, nullptr)); glCheck(GLEXT_glCompileShader(geometryShader)); // Check the compile log @@ -919,7 +919,7 @@ bool Shader::compile(const char* vertexShaderCode, const char* geometryShaderCod // Create and compile the shader GLEXT_GLhandle fragmentShader; glCheck(fragmentShader = GLEXT_glCreateShaderObject(GLEXT_GL_FRAGMENT_SHADER)); - glCheck(GLEXT_glShaderSource(fragmentShader, 1, &fragmentShaderCode, NULL)); + glCheck(GLEXT_glShaderSource(fragmentShader, 1, &fragmentShaderCode, nullptr)); glCheck(GLEXT_glCompileShader(fragmentShader)); // Check the compile log diff --git a/src/SFML/Graphics/Shape.cpp b/src/SFML/Graphics/Shape.cpp index 8acc286d2..96e5fe97c 100644 --- a/src/SFML/Graphics/Shape.cpp +++ b/src/SFML/Graphics/Shape.cpp @@ -157,7 +157,7 @@ FloatRect Shape::getGlobalBounds() const //////////////////////////////////////////////////////////// Shape::Shape() : -m_texture (NULL), +m_texture (nullptr), m_textureRect (), m_fillColor (255, 255, 255), m_outlineColor (255, 255, 255), @@ -220,7 +220,7 @@ void Shape::draw(RenderTarget& target, RenderStates states) const // Render the outline if (m_outlineThickness != 0) { - states.texture = NULL; + states.texture = nullptr; target.draw(m_outlineVertices, states); } } diff --git a/src/SFML/Graphics/Sprite.cpp b/src/SFML/Graphics/Sprite.cpp index 100ac6734..37d69bcad 100644 --- a/src/SFML/Graphics/Sprite.cpp +++ b/src/SFML/Graphics/Sprite.cpp @@ -35,7 +35,7 @@ namespace sf { //////////////////////////////////////////////////////////// Sprite::Sprite() : -m_texture (NULL), +m_texture (nullptr), m_textureRect() { } @@ -43,7 +43,7 @@ m_textureRect() //////////////////////////////////////////////////////////// Sprite::Sprite(const Texture& texture) : -m_texture (NULL), +m_texture (nullptr), m_textureRect() { setTexture(texture, true); @@ -52,7 +52,7 @@ m_textureRect() //////////////////////////////////////////////////////////// Sprite::Sprite(const Texture& texture, const IntRect& rectangle) : -m_texture (NULL), +m_texture (nullptr), m_textureRect() { // Compute the texture area diff --git a/src/SFML/Graphics/Text.cpp b/src/SFML/Graphics/Text.cpp index a32c4439e..f6abfdf36 100644 --- a/src/SFML/Graphics/Text.cpp +++ b/src/SFML/Graphics/Text.cpp @@ -77,7 +77,7 @@ namespace sf //////////////////////////////////////////////////////////// Text::Text() : m_string (), -m_font (NULL), +m_font (nullptr), m_characterSize (30), m_letterSpacingFactor(1.f), m_lineSpacingFactor (1.f), diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index f462f2632..28b9439bb 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -206,7 +206,7 @@ bool Texture::create(unsigned int width, unsigned int height) // Initialize the texture glCheck(glBindTexture(GL_TEXTURE_2D, m_texture)); - glCheck(glTexImage2D(GL_TEXTURE_2D, 0, (m_sRgb ? GLEXT_GL_SRGB8_ALPHA8 : GL_RGBA), static_cast(m_actualSize.x), static_cast(m_actualSize.y), 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL)); + glCheck(glTexImage2D(GL_TEXTURE_2D, 0, (m_sRgb ? GLEXT_GL_SRGB8_ALPHA8 : GL_RGBA), static_cast(m_actualSize.x), static_cast(m_actualSize.y), 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr)); glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, m_isRepeated ? GL_REPEAT : (textureEdgeClamp ? GLEXT_GL_CLAMP_TO_EDGE : GLEXT_GL_CLAMP))); glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, m_isRepeated ? GL_REPEAT : (textureEdgeClamp ? GLEXT_GL_CLAMP_TO_EDGE : GLEXT_GL_CLAMP))); glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST)); diff --git a/src/SFML/Main/MainAndroid.cpp b/src/SFML/Main/MainAndroid.cpp index 9fbd586a8..d5edb60eb 100644 --- a/src/SFML/Main/MainAndroid.cpp +++ b/src/SFML/Main/MainAndroid.cpp @@ -65,11 +65,11 @@ int getAndroidApiLevel(ANativeActivity* activity) JNIEnv* lJNIEnv = activity->env; jclass versionClass = lJNIEnv->FindClass("android/os/Build$VERSION"); - if (versionClass == NULL) + if (versionClass == nullptr) return 0; jfieldID sdkIntFieldID = lJNIEnv->GetStaticFieldID(versionClass, "SDK_INT", "I"); - if (sdkIntFieldID == NULL) + if (sdkIntFieldID == nullptr) return 0; jint sdkInt = 0; @@ -82,7 +82,7 @@ int getAndroidApiLevel(ANativeActivity* activity) //////////////////////////////////////////////////////////// ActivityStates* retrieveStates(ANativeActivity* activity) { - assert(activity != NULL); + assert(activity != nullptr); // Hide the ugly cast we find in each callback function return (ActivityStates*)activity->instance; @@ -132,7 +132,7 @@ void* main(ActivityStates* states) initializeMain(states); sleep(seconds(0.5)); - ::main(0, NULL); + ::main(0, nullptr); // Terminate properly the main thread and wait until it's done terminateMain(states); @@ -143,7 +143,7 @@ void* main(ActivityStates* states) states->terminated = true; } - return NULL; + return nullptr; } } // namespace priv @@ -330,7 +330,7 @@ static void onDestroy(ANativeActivity* activity) delete states; // Reset the activity pointer for all modules - sf::priv::resetActivity(NULL); + sf::priv::resetActivity(nullptr); // The application should now terminate } @@ -372,7 +372,7 @@ static void onNativeWindowDestroyed(ANativeActivity* activity, ANativeWindow* wi sf::Lock lock(states->mutex); // Update the activity states - states->window = NULL; + states->window = nullptr; // Notify SFML mechanism sf::Event event; @@ -416,7 +416,7 @@ static void onInputQueueCreated(ANativeActivity* activity, AInputQueue* queue) { sf::Lock lock(states->mutex); - AInputQueue_attachLooper(queue, states->looper, 1, states->processEvent, NULL); + AInputQueue_attachLooper(queue, states->looper, 1, states->processEvent, nullptr); states->inputQueue = queue; } } @@ -433,7 +433,7 @@ static void onInputQueueDestroyed(ANativeActivity* activity, AInputQueue* queue) sf::Lock lock(states->mutex); AInputQueue_detachLooper(queue); - states->inputQueue = NULL; + states->inputQueue = nullptr; ALooper_release(states->looper); } @@ -458,7 +458,7 @@ static void onContentRectChanged(ANativeActivity* activity, const ARect* rect) sf::Lock lock(states->mutex); // Make sure the window still exists before we access the dimensions on it - if (states->window != NULL) { + if (states->window != nullptr) { // Send an event to warn people about the window move/resize sf::Event event; event.type = sf::Event::Resized; @@ -483,7 +483,7 @@ static void* onSaveInstanceState(ANativeActivity* activity, size_t* outLen) (void) activity; *outLen = 0; - return NULL; + return nullptr; } @@ -498,15 +498,15 @@ static void onLowMemory(ANativeActivity* activity) JNIEXPORT void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_t savedStateSize) { // Create an activity states (will keep us in the know, about events we care) - sf::priv::ActivityStates* states = NULL; + sf::priv::ActivityStates* states = nullptr; states = new sf::priv::ActivityStates; // Initialize the states value - states->activity = NULL; - states->window = NULL; - states->looper = NULL; - states->inputQueue = NULL; - states->config = NULL; + states->activity = nullptr; + states->window = nullptr; + states->looper = nullptr; + states->inputQueue = nullptr; + states->config = nullptr; for (unsigned int i = 0; i < sf::Mouse::ButtonCount; i++) states->isButtonPressed[i] = false; @@ -514,7 +514,7 @@ JNIEXPORT void ANativeActivity_onCreate(ANativeActivity* activity, void* savedSt gladLoaderLoadEGL(EGL_DEFAULT_DISPLAY); states->display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (savedState != NULL) + if (savedState != nullptr) { states->savedState = malloc(savedStateSize); states->savedStateSize = savedStateSize; @@ -560,7 +560,7 @@ JNIEXPORT void ANativeActivity_onCreate(ANativeActivity* activity, void* savedSt AWINDOW_FLAG_KEEP_SCREEN_ON); // Initialize the display - eglInitialize(states->display, NULL, NULL); + eglInitialize(states->display, nullptr, nullptr); getScreenSizeInPixels(activity, &states->screenSize.x, &states->screenSize.y); diff --git a/src/SFML/Main/SFMLActivity.cpp b/src/SFML/Main/SFMLActivity.cpp index caf191b28..fb3a21053 100644 --- a/src/SFML/Main/SFMLActivity.cpp +++ b/src/SFML/Main/SFMLActivity.cpp @@ -61,7 +61,7 @@ const char *getLibraryName(JNIEnv* lJNIEnv, jobject& objectActivityInfo) jstring valueString = (jstring)lJNIEnv->CallObjectMethod(objectMetaData, methodGetString, objectName); // No meta-data "sfml.app.lib_name" was found so we abort and inform the user - if (valueString == NULL) + if (valueString == nullptr) { LOGE("No meta-data 'sfml.app.lib_name' found in AndroidManifest.xml file"); exit(1); @@ -69,7 +69,7 @@ const char *getLibraryName(JNIEnv* lJNIEnv, jobject& objectActivityInfo) // Convert the application name to a C++ string and return it const jsize applicationNameLength = lJNIEnv->GetStringUTFLength(valueString); - const char* applicationName = lJNIEnv->GetStringUTFChars(valueString, NULL); + const char* applicationName = lJNIEnv->GetStringUTFChars(valueString, nullptr); if (applicationNameLength >= 256) { @@ -109,7 +109,7 @@ void* loadLibrary(const char* libraryName, JNIEnv* lJNIEnv, jobject& ObjectActiv // Get the library absolute path and convert it jmethodID MethodGetPath = lJNIEnv->GetMethodID(ClassFile, "getPath", "()Ljava/lang/String;"); jstring javaLibraryPath = static_cast(lJNIEnv->CallObjectMethod(ObjectFile, MethodGetPath)); - const char* libraryPath = lJNIEnv->GetStringUTFChars(javaLibraryPath, NULL); + const char* libraryPath = lJNIEnv->GetStringUTFChars(javaLibraryPath, nullptr); // Manually load the library void * handle = dlopen(libraryPath, RTLD_NOW | RTLD_GLOBAL); diff --git a/src/SFML/Network/IpAddress.cpp b/src/SFML/Network/IpAddress.cpp index 0130c6376..90d9e24d9 100644 --- a/src/SFML/Network/IpAddress.cpp +++ b/src/SFML/Network/IpAddress.cpp @@ -193,8 +193,8 @@ void IpAddress::resolve(const std::string& address) addrinfo hints; std::memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; - addrinfo* result = NULL; - if (getaddrinfo(address.c_str(), NULL, &hints, &result) == 0) + addrinfo* result = nullptr; + if (getaddrinfo(address.c_str(), nullptr, &hints, &result) == 0) { if (result) { diff --git a/src/SFML/Network/Packet.cpp b/src/SFML/Network/Packet.cpp index 22315d8b7..d1cd52abd 100644 --- a/src/SFML/Network/Packet.cpp +++ b/src/SFML/Network/Packet.cpp @@ -82,7 +82,7 @@ void Packet::clear() //////////////////////////////////////////////////////////// const void* Packet::getData() const { - return !m_data.empty() ? &m_data[0] : NULL; + return !m_data.empty() ? &m_data[0] : nullptr; } @@ -103,7 +103,7 @@ bool Packet::endOfPacket() const //////////////////////////////////////////////////////////// Packet::operator BoolType() const { - return m_isValid ? &Packet::checkSize : NULL; + return m_isValid ? &Packet::checkSize : nullptr; } diff --git a/src/SFML/Network/SocketSelector.cpp b/src/SFML/Network/SocketSelector.cpp index 47fe597ca..fa1786588 100644 --- a/src/SFML/Network/SocketSelector.cpp +++ b/src/SFML/Network/SocketSelector.cpp @@ -165,7 +165,7 @@ bool SocketSelector::wait(Time timeout) // Wait until one of the sockets is ready for reading, or timeout is reached // The first parameter is ignored on Windows - int count = select(m_impl->maxSocket + 1, &m_impl->socketsReady, NULL, NULL, timeout != Time::Zero ? &time : NULL); + int count = select(m_impl->maxSocket + 1, &m_impl->socketsReady, nullptr, nullptr, timeout != Time::Zero ? &time : nullptr); return count > 0; } diff --git a/src/SFML/Network/TcpSocket.cpp b/src/SFML/Network/TcpSocket.cpp index 02ed063b4..3381ccb97 100644 --- a/src/SFML/Network/TcpSocket.cpp +++ b/src/SFML/Network/TcpSocket.cpp @@ -178,7 +178,7 @@ Socket::Status TcpSocket::connect(const IpAddress& remoteAddress, unsigned short time.tv_usec = static_cast(timeout.asMicroseconds() % 1000000); // Wait for something to write on our socket (which means that the connection request has returned) - if (select(static_cast(getHandle() + 1), NULL, &selector, NULL, &time) > 0) + if (select(static_cast(getHandle() + 1), nullptr, &selector, nullptr, &time) > 0) { // At this point the connection may have been either accepted or refused. // To know whether it's a success or a failure, we must check the address of the connected peer diff --git a/src/SFML/System/Android/Activity.cpp b/src/SFML/System/Android/Activity.cpp index 3e32ccdeb..cd8c327a3 100644 --- a/src/SFML/System/Android/Activity.cpp +++ b/src/SFML/System/Android/Activity.cpp @@ -60,7 +60,7 @@ namespace priv ActivityStates*& getActivityStatesPtr() { - static ActivityStates* states = NULL; + static ActivityStates* states = nullptr; return states; } @@ -72,7 +72,7 @@ void resetActivity(ActivityStates* initializedStates) ActivityStates& getActivity() { ActivityStates* const states = getActivityStatesPtr(); - assert(states != NULL); + assert(states != nullptr); return *states; } diff --git a/src/SFML/System/Android/ResourceStream.cpp b/src/SFML/System/Android/ResourceStream.cpp index adfde8526..32f254a2a 100644 --- a/src/SFML/System/Android/ResourceStream.cpp +++ b/src/SFML/System/Android/ResourceStream.cpp @@ -38,7 +38,7 @@ namespace priv //////////////////////////////////////////////////////////// ResourceStream::ResourceStream(const std::string& filename) : -m_file (NULL) +m_file (nullptr) { ActivityStates& states = getActivity(); Lock lock(states.mutex); diff --git a/src/SFML/System/FileInputStream.cpp b/src/SFML/System/FileInputStream.cpp index 8ef1c573c..e54c4e0e0 100644 --- a/src/SFML/System/FileInputStream.cpp +++ b/src/SFML/System/FileInputStream.cpp @@ -35,7 +35,7 @@ namespace sf { //////////////////////////////////////////////////////////// FileInputStream::FileInputStream() -: m_file(NULL) +: m_file(nullptr) { } @@ -68,7 +68,7 @@ bool FileInputStream::open(const std::string& filename) m_file = std::fopen(filename.c_str(), "rb"); - return m_file != NULL; + return m_file != nullptr; #endif } diff --git a/src/SFML/System/MemoryInputStream.cpp b/src/SFML/System/MemoryInputStream.cpp index 6aa8f4973..3b1403f64 100644 --- a/src/SFML/System/MemoryInputStream.cpp +++ b/src/SFML/System/MemoryInputStream.cpp @@ -33,7 +33,7 @@ namespace sf { //////////////////////////////////////////////////////////// MemoryInputStream::MemoryInputStream() : -m_data (NULL), +m_data (nullptr), m_size (0), m_offset(0) { diff --git a/src/SFML/System/Thread.cpp b/src/SFML/System/Thread.cpp index 6c17cec1f..cc966e68a 100644 --- a/src/SFML/System/Thread.cpp +++ b/src/SFML/System/Thread.cpp @@ -60,7 +60,7 @@ void Thread::wait() { m_impl->wait(); delete m_impl; - m_impl = NULL; + m_impl = nullptr; } } @@ -72,7 +72,7 @@ void Thread::terminate() { m_impl->terminate(); delete m_impl; - m_impl = NULL; + m_impl = nullptr; } } diff --git a/src/SFML/System/Unix/ThreadImpl.cpp b/src/SFML/System/Unix/ThreadImpl.cpp index 3b8234cef..a169f3740 100644 --- a/src/SFML/System/Unix/ThreadImpl.cpp +++ b/src/SFML/System/Unix/ThreadImpl.cpp @@ -39,7 +39,7 @@ namespace priv ThreadImpl::ThreadImpl(Thread* owner) : m_isActive(true) { - m_isActive = pthread_create(&m_thread, NULL, &ThreadImpl::entryPoint, owner) == 0; + m_isActive = pthread_create(&m_thread, nullptr, &ThreadImpl::entryPoint, owner) == 0; if (!m_isActive) std::cerr << "Failed to create thread" << std::endl; @@ -52,7 +52,7 @@ void ThreadImpl::wait() if (m_isActive) { assert(pthread_equal(pthread_self(), m_thread) == 0); // A thread cannot wait for itself! - pthread_join(m_thread, NULL); + pthread_join(m_thread, nullptr); } } @@ -80,13 +80,13 @@ void* ThreadImpl::entryPoint(void* userData) #ifndef SFML_SYSTEM_ANDROID // Tell the thread to handle cancel requests immediately - pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); + pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, nullptr); #endif // Forward to the owner owner->run(); - return NULL; + return nullptr; } } // namespace priv diff --git a/src/SFML/System/Unix/ThreadLocalImpl.cpp b/src/SFML/System/Unix/ThreadLocalImpl.cpp index 35df0931e..53a228ec7 100644 --- a/src/SFML/System/Unix/ThreadLocalImpl.cpp +++ b/src/SFML/System/Unix/ThreadLocalImpl.cpp @@ -36,7 +36,7 @@ namespace priv ThreadLocalImpl::ThreadLocalImpl() : m_key(0) { - pthread_key_create(&m_key, NULL); + pthread_key_create(&m_key, nullptr); } diff --git a/src/SFML/System/Win32/ThreadImpl.cpp b/src/SFML/System/Win32/ThreadImpl.cpp index 0a80ec5e2..01b051436 100644 --- a/src/SFML/System/Win32/ThreadImpl.cpp +++ b/src/SFML/System/Win32/ThreadImpl.cpp @@ -39,7 +39,7 @@ namespace priv //////////////////////////////////////////////////////////// ThreadImpl::ThreadImpl(Thread* owner) { - m_thread = reinterpret_cast(_beginthreadex(NULL, 0, &ThreadImpl::entryPoint, owner, 0, &m_threadId)); + m_thread = reinterpret_cast(_beginthreadex(nullptr, 0, &ThreadImpl::entryPoint, owner, 0, &m_threadId)); if (!m_thread) err() << "Failed to create thread" << std::endl; diff --git a/src/SFML/Window/Android/InputImpl.cpp b/src/SFML/Window/Android/InputImpl.cpp index 6c19f7791..90ed8023b 100644 --- a/src/SFML/Window/Android/InputImpl.cpp +++ b/src/SFML/Window/Android/InputImpl.cpp @@ -61,7 +61,7 @@ void InputImpl::setVirtualKeyboardVisible(bool visible) JavaVMAttachArgs lJavaVMAttachArgs; lJavaVMAttachArgs.version = JNI_VERSION_1_6; lJavaVMAttachArgs.name = "NativeThread"; - lJavaVMAttachArgs.group = NULL; + lJavaVMAttachArgs.group = nullptr; lResult=lJavaVM->AttachCurrentThread(&lJNIEnv, &lJavaVMAttachArgs); @@ -136,7 +136,7 @@ void InputImpl::setVirtualKeyboardVisible(bool visible) //////////////////////////////////////////////////////////// bool InputImpl::isMouseButtonPressed(Mouse::Button button) { - ALooper_pollAll(0, NULL, NULL, NULL); + ALooper_pollAll(0, nullptr, nullptr, nullptr); priv::ActivityStates& states = priv::getActivity(); Lock lock(states.mutex); @@ -148,7 +148,7 @@ bool InputImpl::isMouseButtonPressed(Mouse::Button button) //////////////////////////////////////////////////////////// Vector2i InputImpl::getMousePosition() { - ALooper_pollAll(0, NULL, NULL, NULL); + ALooper_pollAll(0, nullptr, nullptr, nullptr); priv::ActivityStates& states = priv::getActivity(); Lock lock(states.mutex); @@ -181,7 +181,7 @@ void InputImpl::setMousePosition(const Vector2i& position, const WindowBase& rel //////////////////////////////////////////////////////////// bool InputImpl::isTouchDown(unsigned int finger) { - ALooper_pollAll(0, NULL, NULL, NULL); + ALooper_pollAll(0, nullptr, nullptr, nullptr); priv::ActivityStates& states = priv::getActivity(); Lock lock(states.mutex); @@ -193,7 +193,7 @@ bool InputImpl::isTouchDown(unsigned int finger) //////////////////////////////////////////////////////////// Vector2i InputImpl::getTouchPosition(unsigned int finger) { - ALooper_pollAll(0, NULL, NULL, NULL); + ALooper_pollAll(0, nullptr, nullptr, nullptr); priv::ActivityStates& states = priv::getActivity(); Lock lock(states.mutex); diff --git a/src/SFML/Window/Android/SensorImpl.cpp b/src/SFML/Window/Android/SensorImpl.cpp index 7142e1d9b..c1dd9ddf8 100644 --- a/src/SFML/Window/Android/SensorImpl.cpp +++ b/src/SFML/Window/Android/SensorImpl.cpp @@ -58,7 +58,7 @@ void SensorImpl::initialize() // Create the sensor events queue and attach it to the looper sensorEventQueue = ASensorManager_createEventQueue(sensorManager, looper, - 1, &processSensorEvents, NULL); + 1, &processSensorEvents, nullptr); } @@ -113,7 +113,7 @@ void SensorImpl::close() Vector3f SensorImpl::update() { // Update our sensor data list - ALooper_pollAll(0, NULL, NULL, NULL); + ALooper_pollAll(0, nullptr, nullptr, nullptr); return sensorData[m_index]; } diff --git a/src/SFML/Window/Android/SensorImpl.hpp b/src/SFML/Window/Android/SensorImpl.hpp index f212db859..13c90f222 100644 --- a/src/SFML/Window/Android/SensorImpl.hpp +++ b/src/SFML/Window/Android/SensorImpl.hpp @@ -105,7 +105,7 @@ private: /// /// \param type Type of the sensor /// - /// \return The default Android sensor, NULL otherwise + /// \return The default Android sensor, a null pointer otherwise /// //////////////////////////////////////////////////////////// static ASensor const* getDefaultSensor(Sensor::Type sensor); diff --git a/src/SFML/Window/Android/WindowImplAndroid.cpp b/src/SFML/Window/Android/WindowImplAndroid.cpp index ba36524f8..b44199588 100644 --- a/src/SFML/Window/Android/WindowImplAndroid.cpp +++ b/src/SFML/Window/Android/WindowImplAndroid.cpp @@ -46,7 +46,7 @@ namespace sf { namespace priv { -WindowImplAndroid* WindowImplAndroid::singleInstance = NULL; +WindowImplAndroid* WindowImplAndroid::singleInstance = nullptr; //////////////////////////////////////////////////////////// WindowImplAndroid::WindowImplAndroid(WindowHandle handle) @@ -84,7 +84,7 @@ WindowImplAndroid::WindowImplAndroid(VideoMode mode, const String& title, unsign //////////////////////////////////////////////////////////// WindowImplAndroid::~WindowImplAndroid() { - WindowImplAndroid::singleInstance = NULL; + WindowImplAndroid::singleInstance = nullptr; } @@ -102,7 +102,7 @@ WindowHandle WindowImplAndroid::getSystemHandle() const void WindowImplAndroid::processEvents() { // Process incoming OS events - ALooper_pollAll(0, NULL, NULL, NULL); + ALooper_pollAll(0, nullptr, nullptr, nullptr); ActivityStates& states = getActivity(); Lock lock(states.mutex); @@ -217,7 +217,7 @@ bool WindowImplAndroid::hasFocus() const //////////////////////////////////////////////////////////// void WindowImplAndroid::forwardEvent(const Event& event) { - if (WindowImplAndroid::singleInstance != NULL) + if (WindowImplAndroid::singleInstance != nullptr) { ActivityStates& states = getActivity(); @@ -245,7 +245,7 @@ int WindowImplAndroid::processEvent(int fd, int events, void* data) ActivityStates& states = getActivity(); Lock lock(states.mutex); - AInputEvent* _event = NULL; + AInputEvent* _event = nullptr; if (AInputQueue_getEvent(states.inputQueue, &_event) >= 0) { @@ -326,7 +326,7 @@ int WindowImplAndroid::processScrollEvent(AInputEvent* _event, ActivityStates& s JavaVMAttachArgs lJavaVMAttachArgs; lJavaVMAttachArgs.version = JNI_VERSION_1_6; lJavaVMAttachArgs.name = "NativeThread"; - lJavaVMAttachArgs.group = NULL; + lJavaVMAttachArgs.group = nullptr; lResult=lJavaVM->AttachCurrentThread(&lJNIEnv, &lJavaVMAttachArgs); @@ -691,7 +691,7 @@ int WindowImplAndroid::getUnicode(AInputEvent* event) JavaVMAttachArgs lJavaVMAttachArgs; lJavaVMAttachArgs.version = JNI_VERSION_1_6; lJavaVMAttachArgs.name = "NativeThread"; - lJavaVMAttachArgs.group = NULL; + lJavaVMAttachArgs.group = nullptr; lResult=lJavaVM->AttachCurrentThread(&lJNIEnv, &lJavaVMAttachArgs); diff --git a/src/SFML/Window/Context.cpp b/src/SFML/Window/Context.cpp index dd74ced48..1e326380a 100644 --- a/src/SFML/Window/Context.cpp +++ b/src/SFML/Window/Context.cpp @@ -36,7 +36,7 @@ namespace namespace ContextImpl { // This per-thread variable holds the current context for each thread - sf::ThreadLocalPtr currentContext(NULL); + sf::ThreadLocalPtr currentContext(nullptr); } } @@ -64,7 +64,7 @@ bool Context::setActive(bool active) bool result = m_context->setActive(active); if (result) - ContextImpl::currentContext = (active ? this : NULL); + ContextImpl::currentContext = (active ? this : nullptr); return result; } @@ -86,7 +86,7 @@ const Context* Context::getActiveContext() if (currentContext && currentContext->m_context == priv::GlContext::getActiveContext()) return currentContext; else - return NULL; + return nullptr; } diff --git a/src/SFML/Window/EglContext.cpp b/src/SFML/Window/EglContext.cpp index f9b50c8fb..d5845c5d9 100644 --- a/src/SFML/Window/EglContext.cpp +++ b/src/SFML/Window/EglContext.cpp @@ -69,7 +69,7 @@ namespace if (display == EGL_NO_DISPLAY) { eglCheck(display = eglGetDisplay(EGL_DEFAULT_DISPLAY)); - eglCheck(eglInitialize(display, NULL, NULL)); + eglCheck(eglInitialize(display, nullptr, nullptr)); } return display; @@ -105,7 +105,7 @@ EglContext::EglContext(EglContext* shared) : m_display (EGL_NO_DISPLAY), m_context (EGL_NO_CONTEXT), m_surface (EGL_NO_SURFACE), -m_config (NULL) +m_config (nullptr) { EglContextImpl::ensureInit(); @@ -116,7 +116,7 @@ m_config (NULL) m_config = getBestConfig(m_display, VideoMode::getDesktopMode().bitsPerPixel, ContextSettings()); updateSettings(); - // Note: The EGL specs say that attrib_list can be NULL when passed to eglCreatePbufferSurface, + // Note: The EGL specs say that attrib_list can be a null pointer when passed to eglCreatePbufferSurface, // but this is resulting in a segfault. Bug in Android? EGLint attrib_list[] = { EGL_WIDTH, 1, @@ -136,7 +136,7 @@ EglContext::EglContext(EglContext* shared, const ContextSettings& settings, cons m_display (EGL_NO_DISPLAY), m_context (EGL_NO_CONTEXT), m_surface (EGL_NO_SURFACE), -m_config (NULL) +m_config (nullptr) { EglContextImpl::ensureInit(); @@ -173,7 +173,7 @@ EglContext::EglContext(EglContext* /*shared*/, const ContextSettings& /*settings m_display (EGL_NO_DISPLAY), m_context (EGL_NO_CONTEXT), m_surface (EGL_NO_SURFACE), -m_config (NULL) +m_config (nullptr) { EglContextImpl::ensureInit(); @@ -281,7 +281,7 @@ void EglContext::createContext(EglContext* shared) //////////////////////////////////////////////////////////// void EglContext::createSurface(EGLNativeWindowType window) { - eglCheck(m_surface = eglCreateWindowSurface(m_display, m_config, window, NULL)); + eglCheck(m_surface = eglCreateWindowSurface(m_display, m_config, window, nullptr)); } diff --git a/src/SFML/Window/EglContext.hpp b/src/SFML/Window/EglContext.hpp index 824648e82..e1fdf46a5 100644 --- a/src/SFML/Window/EglContext.hpp +++ b/src/SFML/Window/EglContext.hpp @@ -49,7 +49,7 @@ public: //////////////////////////////////////////////////////////// /// \brief Create a new context, not associated to a window /// - /// \param shared Context to share the new one with (can be NULL) + /// \param shared Context to share the new one with (can be a null pointer) /// //////////////////////////////////////////////////////////// EglContext(EglContext* shared); @@ -126,7 +126,7 @@ public: //////////////////////////////////////////////////////////// /// \brief Create the context /// - /// \param shared Context to share the new one with (can be NULL) + /// \param shared Context to share the new one with (can be a null pointer) /// \param bitsPerPixel Pixel depth, in bits per pixel /// \param settings Creation parameters /// diff --git a/src/SFML/Window/FreeBSD/JoystickImpl.cpp b/src/SFML/Window/FreeBSD/JoystickImpl.cpp index 22c78eac7..845e8dd60 100644 --- a/src/SFML/Window/FreeBSD/JoystickImpl.cpp +++ b/src/SFML/Window/FreeBSD/JoystickImpl.cpp @@ -162,7 +162,7 @@ namespace priv //////////////////////////////////////////////////////////// void JoystickImpl::initialize() { - hid_init(NULL); + hid_init(nullptr); // Do an initial scan updatePluggedList(); diff --git a/src/SFML/Window/GlContext.cpp b/src/SFML/Window/GlContext.cpp index 9074d31a7..9ec625ad1 100644 --- a/src/SFML/Window/GlContext.cpp +++ b/src/SFML/Window/GlContext.cpp @@ -164,10 +164,10 @@ namespace unsigned int resourceCount = 0; // This per-thread variable holds the current context for each thread - sf::ThreadLocalPtr currentContext(NULL); + sf::ThreadLocalPtr currentContext(nullptr); // The hidden, inactive context that will be shared with all other contexts - ContextType* sharedContext = NULL; + ContextType* sharedContext = nullptr; // Unique identifier, used for identifying contexts when managing unshareable OpenGL resources sf::Uint64 id = 1; // start at 1, zero is "no context" @@ -229,7 +229,7 @@ namespace // This per-thread variable tracks if and how a transient // context is currently being used on the current thread - sf::ThreadLocalPtr transientContext(NULL); + sf::ThreadLocalPtr transientContext(nullptr); // Supported OpenGL extensions std::vector extensions; @@ -337,7 +337,7 @@ void GlContext::initResource() } // Create the shared context - sharedContext = new ContextType(NULL); + sharedContext = new ContextType(nullptr); sharedContext->initialize(ContextSettings()); // Load our extensions vector @@ -373,7 +373,7 @@ void GlContext::cleanupResource() // Destroy the shared context delete sharedContext; - sharedContext = NULL; + sharedContext = nullptr; } } @@ -425,7 +425,7 @@ void GlContext::releaseTransientContext() if (transientContext->referenceCount == 0) { delete transientContext; - transientContext = NULL; + transientContext = nullptr; } } @@ -437,11 +437,11 @@ GlContext* GlContext::create() using GlContextImpl::sharedContext; // Make sure that there's an active context (context creation may need extensions, and thus a valid context) - assert(sharedContext != NULL); + assert(sharedContext != nullptr); Lock lock(mutex); - GlContext* context = NULL; + GlContext* context = nullptr; // We don't use acquireTransientContext here since we have // to ensure we have exclusive access to the shared context @@ -470,7 +470,7 @@ GlContext* GlContext::create(const ContextSettings& settings, const WindowImpl* using GlContextImpl::loadExtensions; // Make sure that there's an active context (context creation may need extensions, and thus a valid context) - assert(sharedContext != NULL); + assert(sharedContext != nullptr); Lock lock(mutex); @@ -486,14 +486,14 @@ GlContext* GlContext::create(const ContextSettings& settings, const WindowImpl* ContextSettings sharedSettings(0, 0, 0, settings.majorVersion, settings.minorVersion, settings.attributeFlags); delete sharedContext; - sharedContext = new ContextType(NULL, sharedSettings, 1, 1); + sharedContext = new ContextType(nullptr, sharedSettings, 1, 1); sharedContext->initialize(sharedSettings); // Reload our extensions vector loadExtensions(); } - GlContext* context = NULL; + GlContext* context = nullptr; // We don't use acquireTransientContext here since we have // to ensure we have exclusive access to the shared context @@ -523,7 +523,7 @@ GlContext* GlContext::create(const ContextSettings& settings, unsigned int width using GlContextImpl::loadExtensions; // Make sure that there's an active context (context creation may need extensions, and thus a valid context) - assert(sharedContext != NULL); + assert(sharedContext != nullptr); Lock lock(mutex); @@ -539,14 +539,14 @@ GlContext* GlContext::create(const ContextSettings& settings, unsigned int width ContextSettings sharedSettings(0, 0, 0, settings.majorVersion, settings.minorVersion, settings.attributeFlags); delete sharedContext; - sharedContext = new ContextType(NULL, sharedSettings, 1, 1); + sharedContext = new ContextType(nullptr, sharedSettings, 1, 1); sharedContext->initialize(sharedSettings); // Reload our extensions vector loadExtensions(); } - GlContext* context = NULL; + GlContext* context = nullptr; // We don't use acquireTransientContext here since we have // to ensure we have exclusive access to the shared context @@ -610,7 +610,7 @@ GlContext::~GlContext() if (sharedContext) { if (this == currentContext) - currentContext = NULL; + currentContext = nullptr; } } @@ -662,7 +662,7 @@ bool GlContext::setActive(bool active) // Deactivate the context if (makeCurrent(false)) { - currentContext = NULL; + currentContext = nullptr; return true; } else @@ -728,7 +728,7 @@ void GlContext::cleanupUnsharedResources() // If this context is already active there is no need to save it if (contextToRestore == this) - contextToRestore = NULL; + contextToRestore = nullptr; // Make this context active so resources can be freed setActive(true); diff --git a/src/SFML/Window/GlContext.hpp b/src/SFML/Window/GlContext.hpp index 5ca8134f0..5ca45312f 100644 --- a/src/SFML/Window/GlContext.hpp +++ b/src/SFML/Window/GlContext.hpp @@ -160,7 +160,7 @@ public: //////////////////////////////////////////////////////////// /// \brief Get the currently active context /// - /// \return The currently active context or NULL if none is active + /// \return The currently active context or a null pointer if none is active /// //////////////////////////////////////////////////////////// static const GlContext* getActiveContext(); diff --git a/src/SFML/Window/NetBSD/JoystickImpl.cpp b/src/SFML/Window/NetBSD/JoystickImpl.cpp index b9b389949..96d35f268 100644 --- a/src/SFML/Window/NetBSD/JoystickImpl.cpp +++ b/src/SFML/Window/NetBSD/JoystickImpl.cpp @@ -163,7 +163,7 @@ namespace priv //////////////////////////////////////////////////////////// void JoystickImpl::initialize() { - hid_init(NULL); + hid_init(nullptr); // Do an initial scan updatePluggedList(); diff --git a/src/SFML/Window/OSX/HIDInputManager.hpp b/src/SFML/Window/OSX/HIDInputManager.hpp index f935bf4c7..2d0b001f9 100644 --- a/src/SFML/Window/OSX/HIDInputManager.hpp +++ b/src/SFML/Window/OSX/HIDInputManager.hpp @@ -178,7 +178,7 @@ private: /// /// \param page HID page like kHIDPage_GenericDesktop /// \param usage HID usage page like kHIDUsage_GD_Keyboard or kHIDUsage_GD_Mouse - /// \return a retained CFSetRef of IOHIDDeviceRef or NULL + /// \return a retained CFSetRef of IOHIDDeviceRef or a null pointer /// //////////////////////////////////////////////////////////// CFSetRef copyDevices(UInt32 page, UInt32 usage); diff --git a/src/SFML/Window/OSX/HIDInputManager.mm b/src/SFML/Window/OSX/HIDInputManager.mm index 8868d3e03..2df085deb 100644 --- a/src/SFML/Window/OSX/HIDInputManager.mm +++ b/src/SFML/Window/OSX/HIDInputManager.mm @@ -150,7 +150,7 @@ void HIDInputManager::initializeKeyboard() // Get only keyboards CFSetRef keyboards = copyDevices(kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard); - if (keyboards == NULL) + if (keyboards == nullptr) { sf::err() << "No keyboard detected by the HID manager!" << std::endl; freeUp(); @@ -181,9 +181,9 @@ void HIDInputManager::initializeKeyboard() void HIDInputManager::loadKeyboard(IOHIDDeviceRef keyboard) { CFArrayRef keys = IOHIDDeviceCopyMatchingElements(keyboard, - NULL, + nullptr, kIOHIDOptionsTypeNone); - if (keys == NULL) + if (keys == nullptr) { sf::err() << "We got a keyboard without any keys (1)" << std::endl; return; @@ -342,15 +342,15 @@ CFSetRef HIDInputManager::copyDevices(UInt32 page, UInt32 usage) mask = 0; CFSetRef devices = IOHIDManagerCopyDevices(m_manager); - if (devices == NULL) - return NULL; + if (devices == nullptr) + return nullptr; // Is there at least one device? CFIndex deviceCount = CFSetGetCount(devices); if (deviceCount < 1) { CFRelease(devices); - return NULL; + return nullptr; } return devices; @@ -358,7 +358,7 @@ CFSetRef HIDInputManager::copyDevices(UInt32 page, UInt32 usage) bool HIDInputManager::isPressed(IOHIDElements& elements) { - if (!m_isValid) + if (!m_isValid) return false; // state = true if at least one corresponding HID button is pressed diff --git a/src/SFML/Window/OSX/HIDJoystickManager.cpp b/src/SFML/Window/OSX/HIDJoystickManager.cpp index edcb5a4c7..f5505617b 100644 --- a/src/SFML/Window/OSX/HIDJoystickManager.cpp +++ b/src/SFML/Window/OSX/HIDJoystickManager.cpp @@ -85,7 +85,7 @@ m_joystickCount(0) maskArray[0] = mask0; maskArray[1] = mask1; - CFArrayRef mask = CFArrayCreate(NULL, (const void**)maskArray, 2, NULL); + CFArrayRef mask = CFArrayCreate(nullptr, (const void**)maskArray, 2, nullptr); IOHIDManagerSetDeviceMatchingMultiple(m_manager, mask); CFRelease(mask); @@ -111,8 +111,8 @@ HIDJoystickManager::~HIDJoystickManager() CFRunLoopGetCurrent(), RunLoopMode); - IOHIDManagerRegisterDeviceMatchingCallback(m_manager, NULL, 0); - IOHIDManagerRegisterDeviceRemovalCallback(m_manager, NULL, 0); + IOHIDManagerRegisterDeviceMatchingCallback(m_manager, nullptr, 0); + IOHIDManagerRegisterDeviceRemovalCallback(m_manager, nullptr, 0); IOHIDManagerClose(m_manager, kIOHIDOptionsTypeNone); } diff --git a/src/SFML/Window/OSX/HIDJoystickManager.hpp b/src/SFML/Window/OSX/HIDJoystickManager.hpp index 3a8305bef..b0edceca4 100644 --- a/src/SFML/Window/OSX/HIDJoystickManager.hpp +++ b/src/SFML/Window/OSX/HIDJoystickManager.hpp @@ -69,7 +69,7 @@ public: //////////////////////////////////////////////////////////// /// \brief Copy the devices associated with this HID manager /// - /// \return a retained CFSetRef of IOHIDDeviceRef or NULL + /// \return a retained CFSetRef of IOHIDDeviceRef or a null pointer /// //////////////////////////////////////////////////////////// CFSetRef copyJoysticks(); diff --git a/src/SFML/Window/OSX/InputImpl.mm b/src/SFML/Window/OSX/InputImpl.mm index a5c200a13..4dcebfae3 100644 --- a/src/SFML/Window/OSX/InputImpl.mm +++ b/src/SFML/Window/OSX/InputImpl.mm @@ -188,7 +188,7 @@ void InputImpl::setMousePosition(const Vector2i& position) CGPoint pos = CGPointMake(position.x / scale, position.y / scale); // Place the cursor. - CGEventRef event = CGEventCreateMouseEvent(NULL, + CGEventRef event = CGEventCreateMouseEvent(nullptr, kCGEventMouseMoved, pos, /* we don't care about this: */ kCGMouseButtonLeft); diff --git a/src/SFML/Window/OSX/JoystickImpl.cpp b/src/SFML/Window/OSX/JoystickImpl.cpp index f2a159a25..041d175da 100644 --- a/src/SFML/Window/OSX/JoystickImpl.cpp +++ b/src/SFML/Window/OSX/JoystickImpl.cpp @@ -138,7 +138,7 @@ bool JoystickImpl::isConnected(unsigned int index) // Get all devices CFSetRef devices = HIDJoystickManager::getInstance().copyJoysticks(); - if (devices != NULL) + if (devices != nullptr) { CFIndex size = CFSetGetCount(devices); if (size > 0) @@ -184,12 +184,12 @@ bool JoystickImpl::open(unsigned int index) { AutoreleasePool pool; m_index = index; - m_hat = NULL; + m_hat = nullptr; Location deviceLoc = m_locationIDs[index]; // The device we need to load // Get all devices CFSetRef devices = HIDJoystickManager::getInstance().copyJoysticks(); - if (devices == NULL) + if (devices == nullptr) return false; // Get a usable copy of the joysticks devices. @@ -217,9 +217,9 @@ bool JoystickImpl::open(unsigned int index) m_identification.productId = getDeviceUint(self, CFSTR(kIOHIDProductIDKey), m_index); // Get a list of all elements attached to the device. - CFArrayRef elements = IOHIDDeviceCopyMatchingElements(self, NULL, kIOHIDOptionsTypeNone); + CFArrayRef elements = IOHIDDeviceCopyMatchingElements(self, nullptr, kIOHIDOptionsTypeNone); - if (elements == NULL) + if (elements == nullptr) { CFRelease(devices); return false; @@ -311,7 +311,7 @@ bool JoystickImpl::open(unsigned int index) CFRetain(*it); for (AxisMap::iterator it(m_axis.begin()); it != m_axis.end(); ++it) CFRetain(it->second); - if (m_hat != NULL) + if (m_hat != nullptr) CFRetain(m_hat); // Note: we didn't retain element in the switch because we might have multiple @@ -337,9 +337,9 @@ void JoystickImpl::close() CFRelease(it->second); m_axis.clear(); - if (m_hat != NULL) + if (m_hat != nullptr) CFRelease(m_hat); - m_hat = NULL; + m_hat = nullptr; // And we unregister this joystick m_locationIDs[m_index] = 0; @@ -359,7 +359,7 @@ JoystickCaps JoystickImpl::getCapabilities() const for (AxisMap::const_iterator it(m_axis.begin()); it != m_axis.end(); ++it) caps.axes[it->first] = true; - if (m_hat != NULL) + if (m_hat != nullptr) caps.axes[Joystick::PovX] = caps.axes[Joystick::PovY] = true; return caps; @@ -390,7 +390,7 @@ JoystickState JoystickImpl::update() // Get all devices CFSetRef devices = HIDJoystickManager::getInstance().copyJoysticks(); - if (devices == NULL) + if (devices == nullptr) return disconnectedState; // Get a usable copy of the joysticks devices. @@ -468,7 +468,7 @@ JoystickState JoystickImpl::update() // West / 6 Null / 8 East / 2 // South-West / 5 South / 4 South-East / 3 // - if (m_hat != NULL) + if (m_hat != nullptr) { IOHIDValueRef value = 0; IOHIDDeviceGetValue(IOHIDElementGetDevice(m_hat), m_hat, &value); diff --git a/src/SFML/Window/OSX/SFContext.hpp b/src/SFML/Window/OSX/SFContext.hpp index 950a47079..5d231358a 100644 --- a/src/SFML/Window/OSX/SFContext.hpp +++ b/src/SFML/Window/OSX/SFContext.hpp @@ -68,7 +68,7 @@ public: //////////////////////////////////////////////////////////// /// \brief Create a new context, not associated to a window /// - /// \param shared Context to share the new one with (can be NULL) + /// \param shared Context to share the new one with (can be a null pointer) /// //////////////////////////////////////////////////////////// SFContext(SFContext* shared); @@ -149,7 +149,7 @@ private: /// \brief Create the context /// \note Must only be called from Ctor. /// - /// \param shared Context to share the new one with (can be NULL) + /// \param shared Context to share the new one with (can be a null pointer) /// \param bitsPerPixel bpp /// \param settings Creation parameters /// diff --git a/src/SFML/Window/OSX/SFContext.mm b/src/SFML/Window/OSX/SFContext.mm index 358172afd..5dec79f9c 100644 --- a/src/SFML/Window/OSX/SFContext.mm +++ b/src/SFML/Window/OSX/SFContext.mm @@ -119,7 +119,7 @@ SFContext::~SFContext() GlFunctionPointer SFContext::getFunction(const char* name) { AutoreleasePool pool; - static void* image = NULL; + static void* image = nullptr; if (!image) image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY); @@ -272,7 +272,7 @@ void SFContext::createContext(SFContext* shared, } // Use the shared context if one is given. - NSOpenGLContext* sharedContext = shared != NULL ? shared->m_context : nil; + NSOpenGLContext* sharedContext = shared != nullptr ? shared->m_context : nil; if (sharedContext != nil) { diff --git a/src/SFML/Window/OSX/VideoModeImpl.cpp b/src/SFML/Window/OSX/VideoModeImpl.cpp index 7df01a5a9..92cf46c88 100644 --- a/src/SFML/Window/OSX/VideoModeImpl.cpp +++ b/src/SFML/Window/OSX/VideoModeImpl.cpp @@ -42,9 +42,9 @@ std::vector VideoModeImpl::getFullscreenModes() std::vector modes; // Retrieve all modes available for main screen only. - CFArrayRef cgmodes = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), NULL); + CFArrayRef cgmodes = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), nullptr); - if (cgmodes == NULL) + if (cgmodes == nullptr) { sf::err() << "Couldn't get VideoMode for main display." << std::endl; return modes; diff --git a/src/SFML/Window/Unix/Display.cpp b/src/SFML/Window/Unix/Display.cpp index 144fe7822..3bfd7f969 100644 --- a/src/SFML/Window/Unix/Display.cpp +++ b/src/SFML/Window/Unix/Display.cpp @@ -38,7 +38,7 @@ namespace { // The shared display and its reference counter - Display* sharedDisplay = NULL; + Display* sharedDisplay = nullptr; unsigned int referenceCount = 0; sf::Mutex mutex; @@ -57,7 +57,7 @@ Display* OpenDisplay() if (referenceCount == 0) { - sharedDisplay = XOpenDisplay(NULL); + sharedDisplay = XOpenDisplay(nullptr); // Opening display failed: The best we can do at the moment is to output a meaningful error message // and cause an abnormal program termination diff --git a/src/SFML/Window/Unix/GlxContext.cpp b/src/SFML/Window/Unix/GlxContext.cpp index e422b6b52..c401d1814 100644 --- a/src/SFML/Window/Unix/GlxContext.cpp +++ b/src/SFML/Window/Unix/GlxContext.cpp @@ -108,9 +108,9 @@ namespace priv { //////////////////////////////////////////////////////////// GlxContext::GlxContext(GlxContext* shared) : -m_display (NULL), +m_display (nullptr), m_window (0), -m_context (NULL), +m_context (nullptr), m_pbuffer (0), m_ownsWindow(false) { @@ -133,9 +133,9 @@ m_ownsWindow(false) //////////////////////////////////////////////////////////// GlxContext::GlxContext(GlxContext* shared, const ContextSettings& settings, const WindowImpl* owner, unsigned int /*bitsPerPixel*/) : -m_display (NULL), +m_display (nullptr), m_window (0), -m_context (NULL), +m_context (nullptr), m_pbuffer (0), m_ownsWindow(false) { @@ -158,9 +158,9 @@ m_ownsWindow(false) //////////////////////////////////////////////////////////// GlxContext::GlxContext(GlxContext* shared, const ContextSettings& settings, unsigned int width, unsigned int height) : -m_display (NULL), +m_display (nullptr), m_window (0), -m_context (NULL), +m_context (nullptr), m_pbuffer (0), m_ownsWindow(false) { @@ -195,7 +195,7 @@ GlxContext::~GlxContext() #endif if (glXGetCurrentContext() == m_context) - glXMakeCurrent(m_display, None, NULL); + glXMakeCurrent(m_display, None, nullptr); glXDestroyContext(m_display, m_context); #if defined(GLX_DEBUGGING) @@ -253,7 +253,7 @@ bool GlxContext::makeCurrent(bool current) } else { - result = glXMakeCurrent(m_display, None, NULL); + result = glXMakeCurrent(m_display, None, nullptr); } #if defined(GLX_DEBUGGING) @@ -332,7 +332,7 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe // Retrieve all the visuals int count; - XVisualInfo* visuals = XGetVisualInfo(display, 0, NULL, &count); + XVisualInfo* visuals = XGetVisualInfo(display, 0, nullptr, &count); if (visuals) { // Evaluate all the returned visuals, and pick the best one @@ -492,13 +492,13 @@ void GlxContext::createSurface(GlxContext* shared, unsigned int width, unsigned if (hasCreatePbuffer) { // Get a GLXFBConfig that matches the visual - GLXFBConfig* config = NULL; + GLXFBConfig* config = nullptr; // We don't supply attributes to match against, since // the visual we are matching against was already // deemed suitable in selectBestVisual() int nbConfigs = 0; - GLXFBConfig* configs = glXChooseFBConfig(m_display, DefaultScreen(m_display), NULL, &nbConfigs); + GLXFBConfig* configs = glXChooseFBConfig(m_display, DefaultScreen(m_display), nullptr, &nbConfigs); for (int i = 0; configs && (i < nbConfigs); ++i) { @@ -583,7 +583,7 @@ void GlxContext::createContext(GlxContext* shared) // Get a working copy of the context settings ContextSettings settings = m_settings; - XVisualInfo* visualInfo = NULL; + XVisualInfo* visualInfo = nullptr; if (m_pbuffer) { @@ -631,7 +631,7 @@ void GlxContext::createContext(GlxContext* shared) } // Get the context to share display lists with - GLXContext toShare = shared ? shared->m_context : NULL; + GLXContext toShare = shared ? shared->m_context : nullptr; // There are no GLX versions prior to 1.0 int major = 0; @@ -647,13 +647,13 @@ void GlxContext::createContext(GlxContext* shared) if (hasCreateContextArb) { // Get a GLXFBConfig that matches the window's visual, for glXCreateContextAttribsARB - GLXFBConfig* config = NULL; + GLXFBConfig* config = nullptr; // We don't supply attributes to match against, since // the visual we are matching against was already // deemed suitable in selectBestVisual() int nbConfigs = 0; - GLXFBConfig* configs = glXChooseFBConfig(m_display, DefaultScreen(m_display), NULL, &nbConfigs); + GLXFBConfig* configs = glXChooseFBConfig(m_display, DefaultScreen(m_display), nullptr, &nbConfigs); for (int i = 0; configs && (i < nbConfigs); ++i) { @@ -718,7 +718,7 @@ void GlxContext::createContext(GlxContext* shared) if (toShare) { - if (!glXMakeCurrent(m_display, None, NULL)) + if (!glXMakeCurrent(m_display, None, nullptr)) { err() << "Failed to deactivate shared context before sharing" << std::endl; return; @@ -773,7 +773,7 @@ void GlxContext::createContext(GlxContext* shared) if (toShare) { - if (!glXMakeCurrent(m_display, None, NULL)) + if (!glXMakeCurrent(m_display, None, nullptr)) { err() << "Failed to deactivate shared context before sharing" << std::endl; return; diff --git a/src/SFML/Window/Unix/GlxContext.hpp b/src/SFML/Window/Unix/GlxContext.hpp index 9df902417..6d1971ce0 100644 --- a/src/SFML/Window/Unix/GlxContext.hpp +++ b/src/SFML/Window/Unix/GlxContext.hpp @@ -48,7 +48,7 @@ public: //////////////////////////////////////////////////////////// /// \brief Create a new default context /// - /// \param shared Context to share the new one with (can be NULL) + /// \param shared Context to share the new one with (can be a null pointer) /// //////////////////////////////////////////////////////////// GlxContext(GlxContext* shared); @@ -151,7 +151,7 @@ private: //////////////////////////////////////////////////////////// /// \brief Create the context's drawing surface /// - /// \param shared Context to share the new one with (can be NULL) + /// \param shared Context to share the new one with (can be a null pointer) /// \param width Back buffer width, in pixels /// \param height Back buffer height, in pixels /// \param bitsPerPixel Pixel depth, in bits per pixel @@ -170,7 +170,7 @@ private: //////////////////////////////////////////////////////////// /// \brief Create the context /// - /// \param shared Context to share the new one with (can be NULL) + /// \param shared Context to share the new one with (can be a null pointer) /// //////////////////////////////////////////////////////////// void createContext(GlxContext* shared); diff --git a/src/SFML/Window/Unix/JoystickImpl.cpp b/src/SFML/Window/Unix/JoystickImpl.cpp index 99ce355bb..1af2ef259 100644 --- a/src/SFML/Window/Unix/JoystickImpl.cpp +++ b/src/SFML/Window/Unix/JoystickImpl.cpp @@ -112,7 +112,7 @@ namespace return true; } - void updatePluggedList(udev_device* udevDevice = NULL) + void updatePluggedList(udev_device* udevDevice = nullptr) { if (udevDevice) { @@ -258,7 +258,7 @@ namespace FD_SET(monitorFd, &descriptorSet); timeval timeout = {0, 0}; - return (select(monitorFd + 1, &descriptorSet, NULL, NULL, &timeout) > 0) && + return (select(monitorFd + 1, &descriptorSet, nullptr, nullptr, &timeout) > 0) && FD_ISSET(monitorFd, &descriptorSet); } @@ -274,7 +274,7 @@ namespace udev_device* udevDeviceParent = udev_device_get_parent_with_subsystem_devtype(udevDevice, "usb", "usb_device"); if (!udevDeviceParent) - return NULL; + return nullptr; return udev_device_get_sysattr_value(udevDeviceParent, attributeName.c_str()); } @@ -289,7 +289,7 @@ namespace unsigned int value = 0; if (attribute) - value = static_cast(std::strtoul(attribute, NULL, 16)); + value = static_cast(std::strtoul(attribute, nullptr, 16)); return value; } @@ -304,7 +304,7 @@ namespace unsigned int value = 0; if (attribute) - value = static_cast(std::strtoul(attribute, NULL, 16)); + value = static_cast(std::strtoul(attribute, nullptr, 16)); return value; } @@ -466,7 +466,7 @@ void JoystickImpl::initialize() } else { - int error = udev_monitor_filter_add_match_subsystem_devtype(udevMonitor, "input", NULL); + int error = udev_monitor_filter_add_match_subsystem_devtype(udevMonitor, "input", nullptr); if (error < 0) { @@ -528,7 +528,7 @@ bool JoystickImpl::isConnected(unsigned int index) udev_device* udevDevice = udev_monitor_receive_device(udevMonitor); // If we can get the specific device, we check that, - // otherwise just do a full scan if udevDevice == NULL + // otherwise just do a full scan if udevDevice == nullptr updatePluggedList(udevDevice); if (udevDevice) diff --git a/src/SFML/Window/Unix/VulkanImplX11.cpp b/src/SFML/Window/Unix/VulkanImplX11.cpp index b4c06bc1b..4ad12e9cb 100644 --- a/src/SFML/Window/Unix/VulkanImplX11.cpp +++ b/src/SFML/Window/Unix/VulkanImplX11.cpp @@ -41,7 +41,7 @@ namespace struct VulkanLibraryWrapper { VulkanLibraryWrapper() : - library(NULL) + library(nullptr) { } @@ -65,21 +65,21 @@ namespace if (!loadEntryPoint(vkGetInstanceProcAddr, "vkGetInstanceProcAddr")) { dlclose(library); - library = NULL; + library = nullptr; return false; } if (!loadEntryPoint(vkEnumerateInstanceLayerProperties, "vkEnumerateInstanceLayerProperties")) { dlclose(library); - library = NULL; + library = nullptr; return false; } if (!loadEntryPoint(vkEnumerateInstanceExtensionProperties, "vkEnumerateInstanceExtensionProperties")) { dlclose(library); - library = NULL; + library = nullptr; return false; } @@ -91,7 +91,7 @@ namespace { entryPoint = reinterpret_cast(dlsym(library, name)); - return (entryPoint != NULL); + return (entryPoint != nullptr); } void* library; @@ -133,7 +133,7 @@ bool VulkanImplX11::isAvailable(bool requireGraphics) uint32_t extensionCount = 0; - wrapper.vkEnumerateInstanceExtensionProperties(0, &extensionCount, NULL); + wrapper.vkEnumerateInstanceExtensionProperties(0, &extensionCount, nullptr); extensionProperties.resize(extensionCount); diff --git a/src/SFML/Window/Unix/WindowImplX11.cpp b/src/SFML/Window/Unix/WindowImplX11.cpp index 569f5f15c..514a8e683 100644 --- a/src/SFML/Window/Unix/WindowImplX11.cpp +++ b/src/SFML/Window/Unix/WindowImplX11.cpp @@ -66,7 +66,7 @@ namespace // A nested named namespace is used here to allow unity builds of SFML. namespace WindowsImplX11Impl { - sf::priv::WindowImplX11* fullscreenWindow = NULL; + sf::priv::WindowImplX11* fullscreenWindow = nullptr; std::vector allWindows; sf::Mutex allWindowsMutex; sf::String windowManagerName; @@ -292,13 +292,13 @@ namespace ::Window getParentWindow(::Display* disp, ::Window win) { ::Window root, parent; - ::Window* children = NULL; + ::Window* children = nullptr; unsigned int numChildren; XQueryTree(disp, win, &root, &parent, &children, &numChildren); // Children information is not used, so must be freed. - if (children != NULL) + if (children != nullptr) XFree(children); return parent; @@ -321,7 +321,7 @@ namespace int actualFormat; unsigned long numItems; unsigned long numBytesLeft; - unsigned char* data = NULL; + unsigned char* data = nullptr; int result = XGetWindowProperty(disp, win, @@ -338,7 +338,7 @@ namespace if ((result == Success) && (actualType == XA_CARDINAL) && (actualFormat == 32) && (numItems == 4) && (numBytesLeft == 0) && - (data != NULL)) + (data != nullptr)) { gotFrameExtents = true; @@ -352,7 +352,7 @@ namespace } // Always free data. - if (data != NULL) + if (data != nullptr) XFree(data); return gotFrameExtents; @@ -497,8 +497,8 @@ namespace priv WindowImplX11::WindowImplX11(WindowHandle handle) : m_window (0), m_screen (0), -m_inputMethod (NULL), -m_inputContext (NULL), +m_inputMethod (nullptr), +m_inputContext (nullptr), m_isExternal (true), m_oldVideoMode (0), m_oldRRCrtc (0), @@ -548,8 +548,8 @@ m_lastInputTime (0) WindowImplX11::WindowImplX11(VideoMode mode, const String& title, unsigned long style, const ContextSettings& settings) : m_window (0), m_screen (0), -m_inputMethod (NULL), -m_inputContext (NULL), +m_inputMethod (nullptr), +m_inputContext (nullptr), m_isExternal (false), m_oldVideoMode (0), m_oldRRCrtc (0), @@ -590,7 +590,7 @@ m_lastInputTime (0) unsigned int width = mode.width; unsigned int height = mode.height; - Visual* visual = NULL; + Visual* visual = nullptr; int depth = 0; // Check if the user chose to not create an OpenGL context (settings.attributeFlags will be 0xFFFFFFFF) @@ -978,21 +978,21 @@ void WindowImplX11::setTitle(const String& title) m_window, title.toAnsiString().c_str(), title.toAnsiString().c_str(), - NULL, + nullptr, 0, - NULL, - NULL, - NULL); + nullptr, + nullptr, + nullptr); #else XmbSetWMProperties(m_display, m_window, title.toAnsiString().c_str(), title.toAnsiString().c_str(), - NULL, + nullptr, 0, - NULL, - NULL, - NULL); + nullptr, + nullptr, + nullptr); #endif } @@ -1232,7 +1232,7 @@ void WindowImplX11::requestFocus() // Otherwise: display urgency hint (flashing application logo) // Ensure WM hints exist, allocate if necessary XWMHints* hints = XGetWMHints(m_display, m_window); - if (hints == NULL) + if (hints == nullptr) hints = XAllocWMHints(); // Add urgency (notification) flag to hints @@ -1470,7 +1470,7 @@ void WindowImplX11::resetVideoMode() } // Reset the fullscreen window - fullscreenWindow = NULL; + fullscreenWindow = nullptr; } } @@ -1607,7 +1607,7 @@ void WindowImplX11::initialize() using namespace WindowsImplX11Impl; // Create the input context - m_inputMethod = XOpenIM(m_display, NULL, NULL, NULL); + m_inputMethod = XOpenIM(m_display, nullptr, nullptr, nullptr); if (m_inputMethod) { @@ -1618,11 +1618,11 @@ void WindowImplX11::initialize() m_window, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, - NULL); + nullptr); } else { - m_inputContext = NULL; + m_inputContext = nullptr; } if (!m_inputContext) @@ -1690,7 +1690,7 @@ void WindowImplX11::createHiddenCursor() { // Create the cursor's pixmap (1x1 pixels) Pixmap cursorPixmap = XCreatePixmap(m_display, m_window, 1, 1, 1); - GC graphicsContext = XCreateGC(m_display, cursorPixmap, 0, NULL); + GC graphicsContext = XCreateGC(m_display, cursorPixmap, 0, nullptr); XDrawPoint(m_display, cursorPixmap, graphicsContext, 0, 0); XFreeGC(m_display, graphicsContext); @@ -1796,7 +1796,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent) // If the window has been previously marked urgent (notification) as a result of a focus request, undo that XWMHints* hints = XGetWMHints(m_display, m_window); - if (hints != NULL) + if (hints != nullptr) { // Remove urgency (notification) flag from hints hints->flags &= ~XUrgencyHint; @@ -1911,7 +1911,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent) &windowEvent.xkey, reinterpret_cast(keyBuffer), sizeof(keyBuffer), - NULL, + nullptr, &status ); @@ -1933,7 +1933,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent) { static XComposeStatus status; char keyBuffer[16]; - if (XLookupString(&windowEvent.xkey, keyBuffer, sizeof(keyBuffer), NULL, &status)) + if (XLookupString(&windowEvent.xkey, keyBuffer, sizeof(keyBuffer), nullptr, &status)) { Event textEvent; textEvent.type = Event::TextEntered; diff --git a/src/SFML/Window/Vulkan.cpp b/src/SFML/Window/Vulkan.cpp index 39958f88a..255339654 100644 --- a/src/SFML/Window/Vulkan.cpp +++ b/src/SFML/Window/Vulkan.cpp @@ -66,7 +66,7 @@ VulkanFunctionPointer Vulkan::getFunction(const char* name) { #if defined(SFML_VULKAN_IMPLEMENTATION_NOT_AVAILABLE) - return NULL; + return nullptr; #else diff --git a/src/SFML/Window/Win32/ClipboardImpl.cpp b/src/SFML/Window/Win32/ClipboardImpl.cpp index 21120faf0..4a678bf40 100644 --- a/src/SFML/Window/Win32/ClipboardImpl.cpp +++ b/src/SFML/Window/Win32/ClipboardImpl.cpp @@ -46,7 +46,7 @@ String ClipboardImpl::getString() return text; } - if (!OpenClipboard(NULL)) + if (!OpenClipboard(nullptr)) { std::cerr << "Failed to open the Win32 clipboard." << std::endl; return text; @@ -72,7 +72,7 @@ String ClipboardImpl::getString() //////////////////////////////////////////////////////////// void ClipboardImpl::setString(const String& text) { - if (!OpenClipboard(NULL)) + if (!OpenClipboard(nullptr)) { std::cerr << "Failed to open the Win32 clipboard." << std::endl; return; diff --git a/src/SFML/Window/Win32/CursorImpl.cpp b/src/SFML/Window/Win32/CursorImpl.cpp index 725447d65..b2711e49e 100755 --- a/src/SFML/Window/Win32/CursorImpl.cpp +++ b/src/SFML/Window/Win32/CursorImpl.cpp @@ -36,7 +36,7 @@ namespace priv //////////////////////////////////////////////////////////// CursorImpl::CursorImpl() : -m_cursor(NULL), +m_cursor(nullptr), m_systemCursor(false) { // That's it. @@ -70,18 +70,18 @@ bool CursorImpl::loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hot bitmapHeader.bV5BlueMask = 0x000000ff; bitmapHeader.bV5AlphaMask = 0xff000000; - Uint32* bitmapData = NULL; + Uint32* bitmapData = nullptr; - HDC screenDC = GetDC(NULL); + HDC screenDC = GetDC(nullptr); HBITMAP color = CreateDIBSection( screenDC, reinterpret_cast(&bitmapHeader), DIB_RGB_COLORS, reinterpret_cast(&bitmapData), - NULL, + nullptr, 0 ); - ReleaseDC(NULL, screenDC); + ReleaseDC(nullptr, screenDC); if (!color) { @@ -98,7 +98,7 @@ bool CursorImpl::loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hot } // Create a dummy mask bitmap (it won't be used) - HBITMAP mask = CreateBitmap(static_cast(size.x), static_cast(size.y), 1, 1, NULL); + HBITMAP mask = CreateBitmap(static_cast(size.x), static_cast(size.y), 1, 1, nullptr); if (!mask) { @@ -142,7 +142,7 @@ bool CursorImpl::loadFromSystem(Cursor::Type type) { release(); - LPCTSTR shape = NULL; + LPCTSTR shape = nullptr; switch (type) { case Cursor::Arrow: shape = IDC_ARROW; break; @@ -169,7 +169,7 @@ bool CursorImpl::loadFromSystem(Cursor::Type type) } // Get the shared system cursor and make sure not to destroy it - m_cursor = LoadCursor(NULL, shape); + m_cursor = LoadCursor(nullptr, shape); m_systemCursor = true; if (m_cursor) @@ -189,7 +189,7 @@ void CursorImpl::release() { if (m_cursor && !m_systemCursor) { DestroyCursor(m_cursor); - m_cursor = NULL; + m_cursor = nullptr; } } diff --git a/src/SFML/Window/Win32/JoystickImpl.cpp b/src/SFML/Window/Win32/JoystickImpl.cpp index 8918cc9b4..78879ca4b 100644 --- a/src/SFML/Window/Win32/JoystickImpl.cpp +++ b/src/SFML/Window/Win32/JoystickImpl.cpp @@ -68,8 +68,8 @@ namespace const GUID GUID_RyAxis = {0xa36d02f5, 0xc9f3, 0x11cf, {0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}; } - HMODULE dinput8dll = NULL; - IDirectInput8W* directInput = NULL; + HMODULE dinput8dll = nullptr; + IDirectInput8W* directInput = nullptr; struct JoystickRecord { @@ -117,7 +117,7 @@ namespace { PTCHAR buffer; - if (FormatMessage(FORMAT_MESSAGE_MAX_WIDTH_MASK | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, reinterpret_cast(&buffer), 0, NULL) == 0) + if (FormatMessage(FORMAT_MESSAGE_MAX_WIDTH_MASK | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr, error, 0, reinterpret_cast(&buffer), 0, nullptr) == 0) return "Unknown error."; sf::String message = buffer; @@ -167,7 +167,7 @@ namespace TCHAR keyData[256]; DWORD keyDataSize = sizeof(keyData); - result = RegQueryValueEx(currentKey, subkey.c_str(), NULL, NULL, reinterpret_cast(keyData), &keyDataSize); + result = RegQueryValueEx(currentKey, subkey.c_str(), nullptr, nullptr, reinterpret_cast(keyData), &keyDataSize); RegCloseKey(currentKey); if (result != ERROR_SUCCESS) @@ -190,7 +190,7 @@ namespace keyDataSize = sizeof(keyData); - result = RegQueryValueEx(currentKey, REGSTR_VAL_JOYOEMNAME, NULL, NULL, reinterpret_cast(keyData), &keyDataSize); + result = RegQueryValueEx(currentKey, REGSTR_VAL_JOYOEMNAME, nullptr, nullptr, reinterpret_cast(keyData), &keyDataSize); RegCloseKey(currentKey); if (result != ERROR_SUCCESS) @@ -409,14 +409,14 @@ void JoystickImpl::initializeDInput() if (directInput8Create) { // Try to acquire a DirectInput 8.x interface - HRESULT result = directInput8Create(GetModuleHandleW(NULL), 0x0800, guids::IID_IDirectInput8W, reinterpret_cast(&directInput), NULL); + HRESULT result = directInput8Create(GetModuleHandleW(nullptr), 0x0800, guids::IID_IDirectInput8W, reinterpret_cast(&directInput), nullptr); if (FAILED(result)) { // De-initialize everything - directInput = NULL; + directInput = nullptr; FreeLibrary(dinput8dll); - dinput8dll = NULL; + dinput8dll = nullptr; err() << "Failed to initialize DirectInput: " << result << std::endl; } @@ -425,7 +425,7 @@ void JoystickImpl::initializeDInput() { // Unload dinput8.dll FreeLibrary(dinput8dll); - dinput8dll = NULL; + dinput8dll = nullptr; } } } @@ -438,7 +438,7 @@ void JoystickImpl::cleanupDInput() if (directInput) { directInput->Release(); - directInput = NULL; + directInput = nullptr; } // Unload dinput8.dll @@ -469,7 +469,7 @@ void JoystickImpl::updateConnectionsDInput() joystickList[i].plugged = false; // Enumerate devices - HRESULT result = directInput->EnumDevices(DI8DEVCLASS_GAMECTRL, &JoystickImpl::deviceEnumerationCallback, NULL, DIEDFL_ATTACHEDONLY); + HRESULT result = directInput->EnumDevices(DI8DEVCLASS_GAMECTRL, &JoystickImpl::deviceEnumerationCallback, nullptr, DIEDFL_ATTACHEDONLY); // Remove devices that were not connected during the enumeration for (std::vector::iterator i = joystickList.begin(); i != joystickList.end();) @@ -509,7 +509,7 @@ void JoystickImpl::updateConnectionsDInput() bool JoystickImpl::openDInput(unsigned int index) { // Initialize DirectInput members - m_device = NULL; + m_device = nullptr; for (int i = 0; i < Joystick::AxisCount; ++i) m_axes[i] = -1; @@ -528,7 +528,7 @@ bool JoystickImpl::openDInput(unsigned int index) if (it->index == index) { // Create device - HRESULT result = directInput->CreateDevice(it->guid, &m_device, NULL); + HRESULT result = directInput->CreateDevice(it->guid, &m_device, nullptr); if (FAILED(result)) { @@ -559,7 +559,7 @@ bool JoystickImpl::openDInput(unsigned int index) { // Device is blacklisted m_device->Release(); - m_device = NULL; + m_device = nullptr; return false; } @@ -650,7 +650,7 @@ bool JoystickImpl::openDInput(unsigned int index) for (int i = 0; i < sf::Joystick::ButtonCount; ++i) { - data[8 * 4 + 4 + i].pguid = NULL; + data[8 * 4 + 4 + i].pguid = nullptr; data[8 * 4 + 4 + i].dwOfs = static_cast(DIJOFS_BUTTON(i)); data[8 * 4 + 4 + i].dwType = buttonType; data[8 * 4 + 4 + i].dwFlags = 0; @@ -674,7 +674,7 @@ bool JoystickImpl::openDInput(unsigned int index) err() << "Failed to set DirectInput device data format: " << result << std::endl; m_device->Release(); - m_device = NULL; + m_device = nullptr; return false; } @@ -687,7 +687,7 @@ bool JoystickImpl::openDInput(unsigned int index) err() << "Failed to get DirectInput device capabilities: " << result << std::endl; m_device->Release(); - m_device = NULL; + m_device = nullptr; return false; } @@ -700,7 +700,7 @@ bool JoystickImpl::openDInput(unsigned int index) err() << "Failed to enumerate DirectInput device objects: " << result << std::endl; m_device->Release(); - m_device = NULL; + m_device = nullptr; return false; } @@ -724,7 +724,7 @@ bool JoystickImpl::openDInput(unsigned int index) << m_identification.name.toAnsiString() << "\": " << result << std::endl; m_device->Release(); - m_device = NULL; + m_device = nullptr; return false; } @@ -756,7 +756,7 @@ bool JoystickImpl::openDInput(unsigned int index) << m_identification.name.toAnsiString() << "\": " << result << std::endl; m_device->Release(); - m_device = NULL; + m_device = nullptr; return false; } @@ -778,7 +778,7 @@ bool JoystickImpl::openDInput(unsigned int index) } m_device->Release(); - m_device = NULL; + m_device = nullptr; return false; } @@ -812,7 +812,7 @@ bool JoystickImpl::openDInput(unsigned int index) << m_identification.name.toAnsiString() << "\": " << result << std::endl; m_device->Release(); - m_device = NULL; + m_device = nullptr; return false; } @@ -832,7 +832,7 @@ void JoystickImpl::closeDInput() { // Release the device m_device->Release(); - m_device = NULL; + m_device = nullptr; } } @@ -885,7 +885,7 @@ JoystickState JoystickImpl::updateDInputBuffered() if ((result == DIERR_NOTACQUIRED) || (result == DIERR_INPUTLOST)) { m_device->Release(); - m_device = NULL; + m_device = nullptr; return m_state; } @@ -979,7 +979,7 @@ JoystickState JoystickImpl::updateDInputPolled() if ((result == DIERR_NOTACQUIRED) || (result == DIERR_INPUTLOST)) { m_device->Release(); - m_device = NULL; + m_device = nullptr; return state; } diff --git a/src/SFML/Window/Win32/VideoModeImpl.cpp b/src/SFML/Window/Win32/VideoModeImpl.cpp index 2facb871a..1fd5bc000 100644 --- a/src/SFML/Window/Win32/VideoModeImpl.cpp +++ b/src/SFML/Window/Win32/VideoModeImpl.cpp @@ -43,7 +43,7 @@ std::vector VideoModeImpl::getFullscreenModes() DEVMODE win32Mode; win32Mode.dmSize = sizeof(win32Mode); win32Mode.dmDriverExtra = 0; - for (int count = 0; EnumDisplaySettings(NULL, static_cast(count), &win32Mode); ++count) + for (int count = 0; EnumDisplaySettings(nullptr, static_cast(count), &win32Mode); ++count) { // Convert to sf::VideoMode VideoMode mode(win32Mode.dmPelsWidth, win32Mode.dmPelsHeight, win32Mode.dmBitsPerPel); @@ -63,7 +63,7 @@ VideoMode VideoModeImpl::getDesktopMode() DEVMODE win32Mode; win32Mode.dmSize = sizeof(win32Mode); win32Mode.dmDriverExtra = 0; - EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &win32Mode); + EnumDisplaySettings(nullptr, ENUM_CURRENT_SETTINGS, &win32Mode); return VideoMode(win32Mode.dmPelsWidth, win32Mode.dmPelsHeight, win32Mode.dmBitsPerPel); } diff --git a/src/SFML/Window/Win32/VulkanImplWin32.cpp b/src/SFML/Window/Win32/VulkanImplWin32.cpp index d2eb2a409..5d675592f 100644 --- a/src/SFML/Window/Win32/VulkanImplWin32.cpp +++ b/src/SFML/Window/Win32/VulkanImplWin32.cpp @@ -43,7 +43,7 @@ namespace struct VulkanLibraryWrapper { VulkanLibraryWrapper() : - library(NULL) + library(nullptr) { } @@ -67,21 +67,21 @@ namespace if (!loadEntryPoint(vkGetInstanceProcAddr, "vkGetInstanceProcAddr")) { FreeLibrary(library); - library = NULL; + library = nullptr; return false; } if (!loadEntryPoint(vkEnumerateInstanceLayerProperties, "vkEnumerateInstanceLayerProperties")) { FreeLibrary(library); - library = NULL; + library = nullptr; return false; } if (!loadEntryPoint(vkEnumerateInstanceExtensionProperties, "vkEnumerateInstanceExtensionProperties")) { FreeLibrary(library); - library = NULL; + library = nullptr; return false; } @@ -93,7 +93,7 @@ namespace { entryPoint = reinterpret_cast(reinterpret_cast(GetProcAddress(library, name))); - return (entryPoint != NULL); + return (entryPoint != nullptr); } HMODULE library; @@ -135,7 +135,7 @@ bool VulkanImplWin32::isAvailable(bool requireGraphics) uint32_t extensionCount = 0; - wrapper.vkEnumerateInstanceExtensionProperties(0, &extensionCount, NULL); + wrapper.vkEnumerateInstanceExtensionProperties(0, &extensionCount, nullptr); extensionProperties.resize(extensionCount); @@ -210,7 +210,7 @@ bool VulkanImplWin32::createVulkanSurface(const VkInstance& instance, WindowHand VkWin32SurfaceCreateInfoKHR surfaceCreateInfo = VkWin32SurfaceCreateInfoKHR(); surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; - surfaceCreateInfo.hinstance = GetModuleHandleA(NULL); + surfaceCreateInfo.hinstance = GetModuleHandleA(nullptr); surfaceCreateInfo.hwnd = windowHandle; return (vkCreateWin32SurfaceKHR(instance, &surfaceCreateInfo, allocator, &surface) == VK_SUCCESS); diff --git a/src/SFML/Window/Win32/WglContext.cpp b/src/SFML/Window/Win32/WglContext.cpp index 9191503ce..2f09320a8 100644 --- a/src/SFML/Window/Win32/WglContext.cpp +++ b/src/SFML/Window/Win32/WglContext.cpp @@ -48,7 +48,7 @@ namespace { // Some drivers are bugged and don't track the current HDC/HGLRC properly // In order to deactivate successfully, we need to track it ourselves as well - sf::ThreadLocalPtr currentContext(NULL); + sf::ThreadLocalPtr currentContext(nullptr); //////////////////////////////////////////////////////////// @@ -59,7 +59,7 @@ namespace { initialized = true; - gladLoadWGL(NULL, sf::priv::WglContext::getFunction); + gladLoadWGL(nullptr, sf::priv::WglContext::getFunction); } } @@ -89,7 +89,7 @@ namespace priv String getErrorString(DWORD errorCode) { PTCHAR buffer; - if (FormatMessage(FORMAT_MESSAGE_MAX_WIDTH_MASK | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorCode, 0, reinterpret_cast(&buffer), 256, NULL) != 0) + if (FormatMessage(FORMAT_MESSAGE_MAX_WIDTH_MASK | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, errorCode, 0, reinterpret_cast(&buffer), 256, nullptr) != 0) { String errMsg(buffer); LocalFree(buffer); @@ -104,10 +104,10 @@ String getErrorString(DWORD errorCode) //////////////////////////////////////////////////////////// WglContext::WglContext(WglContext* shared) : -m_window (NULL), -m_pbuffer (NULL), -m_deviceContext(NULL), -m_context (NULL), +m_window (nullptr), +m_pbuffer (nullptr), +m_deviceContext(nullptr), +m_context (nullptr), m_ownsWindow (false) { WglContextImpl::ensureInit(); @@ -127,10 +127,10 @@ m_ownsWindow (false) //////////////////////////////////////////////////////////// WglContext::WglContext(WglContext* shared, const ContextSettings& settings, const WindowImpl* owner, unsigned int bitsPerPixel) : -m_window (NULL), -m_pbuffer (NULL), -m_deviceContext(NULL), -m_context (NULL), +m_window (nullptr), +m_pbuffer (nullptr), +m_deviceContext(nullptr), +m_context (nullptr), m_ownsWindow (false) { WglContextImpl::ensureInit(); @@ -148,10 +148,10 @@ m_ownsWindow (false) //////////////////////////////////////////////////////////// WglContext::WglContext(WglContext* shared, const ContextSettings& settings, unsigned int width, unsigned int height) : -m_window (NULL), -m_pbuffer (NULL), -m_deviceContext(NULL), -m_context (NULL), +m_window (nullptr), +m_pbuffer (nullptr), +m_deviceContext(nullptr), +m_context (nullptr), m_ownsWindow (false) { WglContextImpl::ensureInit(); @@ -178,8 +178,8 @@ WglContext::~WglContext() { if (WglContextImpl::currentContext == this) { - if (wglMakeCurrent(m_deviceContext, NULL) == TRUE) - WglContextImpl::currentContext = NULL; + if (wglMakeCurrent(m_deviceContext, nullptr) == TRUE) + WglContextImpl::currentContext = nullptr; } wglDeleteContext(m_context); @@ -219,7 +219,7 @@ GlFunctionPointer WglContext::getFunction(const char* name) return address; } - static HMODULE module = NULL; + static HMODULE module = nullptr; if (!module) module = GetModuleHandleA("OpenGL32.dll"); @@ -237,13 +237,13 @@ bool WglContext::makeCurrent(bool current) if (!m_deviceContext || !m_context) return false; - if (wglMakeCurrent(m_deviceContext, current ? m_context : NULL) == FALSE) + if (wglMakeCurrent(m_deviceContext, current ? m_context : nullptr) == FALSE) { err() << "Failed to " << (current ? "activate" : "deactivate") << " OpenGL context: " << getErrorString(GetLastError()).toAnsiString() << std::endl; return false; } - WglContextImpl::currentContext = (current ? this : NULL); + WglContextImpl::currentContext = (current ? this : nullptr); return true; } @@ -305,7 +305,7 @@ int WglContext::selectBestPixelFormat(HDC deviceContext, unsigned int bitsPerPix // Let's check how many formats are supporting our requirements int formats[512]; UINT nbFormats = 0; // We must initialize to 0 otherwise broken drivers might fill with garbage in the following call - bool isValid = wglChoosePixelFormatARB(deviceContext, intAttributes, NULL, 512, formats, &nbFormats) != FALSE; + bool isValid = wglChoosePixelFormatARB(deviceContext, intAttributes, nullptr, 512, formats, &nbFormats) != FALSE; if (!isValid) err() << "Failed to enumerate pixel formats: " << getErrorString(GetLastError()).toAnsiString() << std::endl; @@ -563,7 +563,7 @@ void WglContext::createSurface(WglContext* shared, unsigned int width, unsigned err() << "Failed to retrieve pixel buffer device context: " << getErrorString(GetLastError()).toAnsiString() << std::endl; wglDestroyPbufferARB(m_pbuffer); - m_pbuffer = NULL; + m_pbuffer = nullptr; } } else @@ -580,7 +580,7 @@ void WglContext::createSurface(WglContext* shared, unsigned int width, unsigned // with other contexts and thus wglShareLists would always fail // Create the hidden window - m_window = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, static_cast(width), static_cast(height), NULL, NULL, GetModuleHandle(NULL), NULL); + m_window = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, static_cast(width), static_cast(height), nullptr, nullptr, GetModuleHandle(nullptr), nullptr); ShowWindow(m_window, SW_HIDE); m_deviceContext = GetDC(m_window); @@ -620,7 +620,7 @@ void WglContext::createContext(WglContext* shared) ContextSettings settings = m_settings; // Get the context to share display lists with - HGLRC sharedContext = shared ? shared->m_context : NULL; + HGLRC sharedContext = shared ? shared->m_context : nullptr; // Create the OpenGL context -- first try using wglCreateContextAttribsARB while (!m_context && m_settings.majorVersion) @@ -669,13 +669,13 @@ void WglContext::createContext(WglContext* shared) if (WglContextImpl::currentContext == shared) { - if (wglMakeCurrent(shared->m_deviceContext, NULL) == FALSE) + if (wglMakeCurrent(shared->m_deviceContext, nullptr) == FALSE) { err() << "Failed to deactivate shared context before sharing: " << getErrorString(GetLastError()).toAnsiString() << std::endl; return; } - WglContextImpl::currentContext = NULL; + WglContextImpl::currentContext = nullptr; } } @@ -739,13 +739,13 @@ void WglContext::createContext(WglContext* shared) if (WglContextImpl::currentContext == shared) { - if (wglMakeCurrent(shared->m_deviceContext, NULL) == FALSE) + if (wglMakeCurrent(shared->m_deviceContext, nullptr) == FALSE) { err() << "Failed to deactivate shared context before sharing: " << getErrorString(GetLastError()).toAnsiString() << std::endl; return; } - WglContextImpl::currentContext = NULL; + WglContextImpl::currentContext = nullptr; } if (wglShareLists(sharedContext, m_context) == FALSE) diff --git a/src/SFML/Window/Win32/WglContext.hpp b/src/SFML/Window/Win32/WglContext.hpp index d31d7f1a8..63106e7d3 100644 --- a/src/SFML/Window/Win32/WglContext.hpp +++ b/src/SFML/Window/Win32/WglContext.hpp @@ -47,7 +47,7 @@ public: //////////////////////////////////////////////////////////// /// \brief Create a new default context /// - /// \param shared Context to share the new one with (can be NULL) + /// \param shared Context to share the new one with (can be a null pointer) /// //////////////////////////////////////////////////////////// WglContext(WglContext* shared); @@ -151,7 +151,7 @@ private: //////////////////////////////////////////////////////////// /// \brief Create the context's drawing surface /// - /// \param shared Shared context (can be NULL) + /// \param shared Shared context (can be a null pointer) /// \param width Back buffer width, in pixels /// \param height Back buffer height, in pixels /// \param bitsPerPixel Pixel depth, in bits per pixel @@ -171,7 +171,7 @@ private: //////////////////////////////////////////////////////////// /// \brief Create the context /// - /// \param shared Context to share the new one with (can be NULL) + /// \param shared Context to share the new one with (can be a null pointer) /// //////////////////////////////////////////////////////////// void createContext(WglContext* shared); diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index b2815c857..e030e5a28 100755 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -67,7 +67,7 @@ namespace unsigned int windowCount = 0; // Windows owned by SFML unsigned int handleCount = 0; // All window handles const wchar_t* className = L"SFML_Window"; - sf::priv::WindowImplWin32* fullscreenWindow = NULL; + sf::priv::WindowImplWin32* fullscreenWindow = nullptr; const GUID GUID_DEVINTERFACE_HID = {0x4d1e55b2, 0xf16f, 0x11cf, {0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30}}; @@ -136,8 +136,8 @@ WindowImplWin32::WindowImplWin32(WindowHandle handle) : m_handle (handle), m_callback (0), m_cursorVisible (true), // might need to call GetCursorInfo -m_lastCursor (LoadCursor(NULL, IDC_ARROW)), -m_icon (NULL), +m_lastCursor (LoadCursor(nullptr, IDC_ARROW)), +m_icon (nullptr), m_keyRepeatEnabled(true), m_lastSize (0, 0), m_resizing (false), @@ -166,11 +166,11 @@ m_cursorGrabbed (false) //////////////////////////////////////////////////////////// WindowImplWin32::WindowImplWin32(VideoMode mode, const String& title, Uint32 style, const ContextSettings& /*settings*/) : -m_handle (NULL), +m_handle (nullptr), m_callback (0), m_cursorVisible (true), // might need to call GetCursorInfo -m_lastCursor (LoadCursor(NULL, IDC_ARROW)), -m_icon (NULL), +m_lastCursor (LoadCursor(nullptr, IDC_ARROW)), +m_icon (nullptr), m_keyRepeatEnabled(true), m_lastSize (mode.width, mode.height), m_resizing (false), @@ -187,12 +187,12 @@ m_cursorGrabbed (m_fullscreen) registerWindowClass(); // Compute position and size - HDC screenDC = GetDC(NULL); + HDC screenDC = GetDC(nullptr); int left = (GetDeviceCaps(screenDC, HORZRES) - static_cast(mode.width)) / 2; int top = (GetDeviceCaps(screenDC, VERTRES) - static_cast(mode.height)) / 2; int width = static_cast(mode.width); int height = static_cast(mode.height); - ReleaseDC(NULL, screenDC); + ReleaseDC(nullptr, screenDC); // Choose the window style according to the Style parameter DWORD win32Style = WS_VISIBLE; @@ -217,7 +217,7 @@ m_cursorGrabbed (m_fullscreen) } // Create the window - m_handle = CreateWindowW(className, title.toWideString().c_str(), win32Style, left, top, width, height, NULL, NULL, GetModuleHandle(NULL), this); + m_handle = CreateWindowW(className, title.toWideString().c_str(), win32Style, left, top, width, height, nullptr, nullptr, GetModuleHandle(nullptr), this); // Register to receive device interface change notifications (used for joystick connection handling) DEV_BROADCAST_DEVICEINTERFACE deviceInterface = {sizeof(DEV_BROADCAST_DEVICEINTERFACE), DBT_DEVTYP_DEVICEINTERFACE, 0, GUID_DEVINTERFACE_HID, 0}; @@ -274,7 +274,7 @@ WindowImplWin32::~WindowImplWin32() // Unregister window class if we were the last window if (windowCount == 0) - UnregisterClassW(className, GetModuleHandleW(NULL)); + UnregisterClassW(className, GetModuleHandleW(nullptr)); } else { @@ -298,7 +298,7 @@ void WindowImplWin32::processEvents() if (!m_callback) { MSG message; - while (PeekMessageW(&message, NULL, 0, 0, PM_REMOVE)) + while (PeekMessageW(&message, nullptr, 0, 0, PM_REMOVE)) { TranslateMessage(&message); DispatchMessageW(&message); @@ -320,7 +320,7 @@ Vector2i WindowImplWin32::getPosition() const //////////////////////////////////////////////////////////// void WindowImplWin32::setPosition(const Vector2i& position) { - SetWindowPos(m_handle, NULL, position.x, position.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER); + SetWindowPos(m_handle, nullptr, position.x, position.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER); if(m_cursorGrabbed) grabCursor(true); @@ -347,7 +347,7 @@ void WindowImplWin32::setSize(const Vector2u& size) int width = rectangle.right - rectangle.left; int height = rectangle.bottom - rectangle.top; - SetWindowPos(m_handle, NULL, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER); + SetWindowPos(m_handle, nullptr, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER); } @@ -376,7 +376,7 @@ void WindowImplWin32::setIcon(unsigned int width, unsigned int height, const Uin } // Create the icon from the pixel array - m_icon = CreateIcon(GetModuleHandleW(NULL), static_cast(width), static_cast(height), 1, 32, NULL, &iconPixels[0]); + m_icon = CreateIcon(GetModuleHandleW(nullptr), static_cast(width), static_cast(height), 1, 32, nullptr, &iconPixels[0]); // Set it as both big and small icon of the window if (m_icon) @@ -402,7 +402,7 @@ void WindowImplWin32::setVisible(bool visible) void WindowImplWin32::setMouseCursorVisible(bool visible) { m_cursorVisible = visible; - SetCursor(m_cursorVisible ? m_lastCursor : NULL); + SetCursor(m_cursorVisible ? m_lastCursor : nullptr); } @@ -418,7 +418,7 @@ void WindowImplWin32::setMouseCursorGrabbed(bool grabbed) void WindowImplWin32::setMouseCursor(const CursorImpl& cursor) { m_lastCursor = cursor.m_cursor; - SetCursor(m_cursorVisible ? m_lastCursor : NULL); + SetCursor(m_cursorVisible ? m_lastCursor : nullptr); } @@ -472,11 +472,11 @@ void WindowImplWin32::registerWindowClass() windowClass.lpfnWndProc = &WindowImplWin32::globalOnEvent; windowClass.cbClsExtra = 0; windowClass.cbWndExtra = 0; - windowClass.hInstance = GetModuleHandleW(NULL); - windowClass.hIcon = NULL; + windowClass.hInstance = GetModuleHandleW(nullptr); + windowClass.hIcon = nullptr; windowClass.hCursor = 0; windowClass.hbrBackground = 0; - windowClass.lpszMenuName = NULL; + windowClass.lpszMenuName = nullptr; windowClass.lpszClassName = className; RegisterClassW(&windowClass); } @@ -518,8 +518,8 @@ void WindowImplWin32::cleanup() // Restore the previous video mode (in case we were running in fullscreen) if (fullscreenWindow == this) { - ChangeDisplaySettingsW(NULL, 0); - fullscreenWindow = NULL; + ChangeDisplaySettingsW(nullptr, 0); + fullscreenWindow = nullptr; } // Unhide the mouse cursor (in case it was hidden) @@ -552,12 +552,12 @@ void WindowImplWin32::grabCursor(bool grabbed) { RECT rect; GetClientRect(m_handle, &rect); - MapWindowPoints(m_handle, NULL, reinterpret_cast(&rect), 2); + MapWindowPoints(m_handle, nullptr, reinterpret_cast(&rect), 2); ClipCursor(&rect); } else { - ClipCursor(NULL); + ClipCursor(nullptr); } } @@ -566,7 +566,7 @@ void WindowImplWin32::grabCursor(bool grabbed) void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam) { // Don't process any message until window is created - if (m_handle == NULL) + if (m_handle == nullptr) return; switch (message) @@ -584,7 +584,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam) { // The mouse has moved, if the cursor is in our window we must refresh the cursor if (LOWORD(lParam) == HTCLIENT) { - SetCursor(m_cursorVisible ? m_lastCursor : NULL); + SetCursor(m_cursorVisible ? m_lastCursor : nullptr); } break; @@ -1138,7 +1138,7 @@ LRESULT CALLBACK WindowImplWin32::globalOnEvent(HWND handle, UINT message, WPARA } // Get the WindowImpl instance corresponding to the window handle - WindowImplWin32* window = handle ? reinterpret_cast(GetWindowLongPtr(handle, GWLP_USERDATA)) : NULL; + WindowImplWin32* window = handle ? reinterpret_cast(GetWindowLongPtr(handle, GWLP_USERDATA)) : nullptr; // Forward the event to the appropriate function if (window) diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index 1c2cf65e1..30ae0bd73 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -36,7 +36,7 @@ namespace sf { //////////////////////////////////////////////////////////// Window::Window() : -m_context (NULL), +m_context (nullptr), m_frameTimeLimit(Time::Zero) { @@ -45,7 +45,7 @@ m_frameTimeLimit(Time::Zero) //////////////////////////////////////////////////////////// Window::Window(VideoMode mode, const String& title, Uint32 style, const ContextSettings& settings) : -m_context (NULL), +m_context (nullptr), m_frameTimeLimit(Time::Zero) { Window::create(mode, title, style, settings); @@ -54,7 +54,7 @@ m_frameTimeLimit(Time::Zero) //////////////////////////////////////////////////////////// Window::Window(WindowHandle handle, const ContextSettings& settings) : -m_context (NULL), +m_context (nullptr), m_frameTimeLimit(Time::Zero) { Window::create(handle, settings); @@ -155,7 +155,7 @@ void Window::close() { // Delete the context delete m_context; - m_context = NULL; + m_context = nullptr; // Close the base window WindowBase::close(); diff --git a/src/SFML/Window/WindowBase.cpp b/src/SFML/Window/WindowBase.cpp index 1b6c94865..6303526e0 100644 --- a/src/SFML/Window/WindowBase.cpp +++ b/src/SFML/Window/WindowBase.cpp @@ -36,7 +36,7 @@ namespace // A nested named namespace is used here to allow unity builds of SFML. namespace WindowsBaseImpl { - const sf::WindowBase* fullscreenWindow = NULL; + const sf::WindowBase* fullscreenWindow = nullptr; } } @@ -45,7 +45,7 @@ namespace sf { //////////////////////////////////////////////////////////// WindowBase::WindowBase() : -m_impl (NULL), +m_impl (nullptr), m_size (0, 0) { @@ -54,7 +54,7 @@ m_size (0, 0) //////////////////////////////////////////////////////////// WindowBase::WindowBase(VideoMode mode, const String& title, Uint32 style) : -m_impl (NULL), +m_impl (nullptr), m_size (0, 0) { WindowBase::create(mode, title, style); @@ -63,7 +63,7 @@ m_size (0, 0) //////////////////////////////////////////////////////////// WindowBase::WindowBase(WindowHandle handle) : -m_impl (NULL), +m_impl (nullptr), m_size (0, 0) { WindowBase::create(handle); @@ -144,18 +144,18 @@ void WindowBase::close() { // Delete the window implementation delete m_impl; - m_impl = NULL; + m_impl = nullptr; // Update the fullscreen window if (this == getFullscreenWindow()) - setFullscreenWindow(NULL); + setFullscreenWindow(nullptr); } //////////////////////////////////////////////////////////// bool WindowBase::isOpen() const { - return m_impl != NULL; + return m_impl != nullptr; } diff --git a/src/SFML/Window/iOS/EaglContext.hpp b/src/SFML/Window/iOS/EaglContext.hpp index 79931ef18..0c392907e 100644 --- a/src/SFML/Window/iOS/EaglContext.hpp +++ b/src/SFML/Window/iOS/EaglContext.hpp @@ -55,7 +55,7 @@ public: //////////////////////////////////////////////////////////// /// \brief Create a new context, not associated to a window /// - /// \param shared Context to share the new one with (can be NULL) + /// \param shared Context to share the new one with (can be a null pointer) /// //////////////////////////////////////////////////////////// EaglContext(EaglContext* shared); @@ -148,8 +148,8 @@ private: //////////////////////////////////////////////////////////// /// \brief Create the context /// - /// \param shared Context to share the new one with (can be NULL) - /// \param window Window to attach the context to (can be NULL) + /// \param shared Context to share the new one with (can be a null pointer) + /// \param window Window to attach the context to (can be a null pointer) /// \param bitsPerPixel Pixel depth, in bits per pixel /// \param settings Creation parameters /// diff --git a/src/SFML/Window/iOS/SFAppDelegate.mm b/src/SFML/Window/iOS/SFAppDelegate.mm index 309f42a8e..90f17ff89 100644 --- a/src/SFML/Window/iOS/SFAppDelegate.mm +++ b/src/SFML/Window/iOS/SFAppDelegate.mm @@ -33,7 +33,7 @@ namespace { // Save the global instance of the delegate - SFAppDelegate* delegateInstance = NULL; + SFAppDelegate* delegateInstance = nullptr; // Current touches positions std::vector touchPositions; @@ -59,7 +59,7 @@ namespace NSAssert(delegateInstance, @"SFAppDelegate instance is nil, this means SFML was not properly initialized. " "Make sure that the file defining your main() function includes "); - + return delegateInstance; } @@ -68,7 +68,7 @@ namespace - (void)runUserMain { // Arguments intentionally dropped, see comments in main in sfml-main - sfmlMain(0, NULL); + sfmlMain(0, nullptr); } @@ -248,7 +248,7 @@ namespace { position.x *= backingScaleFactor; position.y *= backingScaleFactor; - + // save the touch position if (index >= touchPositions.size()) touchPositions.resize(index + 1, sf::Vector2i(-1, -1)); @@ -272,7 +272,7 @@ namespace { position.x *= backingScaleFactor; position.y *= backingScaleFactor; - + // save the touch position if (index >= touchPositions.size()) touchPositions.resize(index + 1, sf::Vector2i(-1, -1)); diff --git a/src/SFML/Window/iOS/SFView.mm b/src/SFML/Window/iOS/SFView.mm index 9b38bbf30..2fff25c4a 100644 --- a/src/SFML/Window/iOS/SFView.mm +++ b/src/SFML/Window/iOS/SFView.mm @@ -183,7 +183,7 @@ if (self) { - self.context = NULL; + self.context = nullptr; self.touches = [NSMutableArray array]; // Configure the EAGL layer