Use 'nullptr' instead of 'NULL'

This commit is contained in:
Vittorio Romeo 2021-12-03 14:45:32 +00:00
parent bd12438916
commit c9f7cb3d52
99 changed files with 455 additions and 455 deletions

View File

@ -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);

View File

@ -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:

View File

@ -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 "";

View File

@ -66,7 +66,7 @@ protected:
static const sf::Font& getFont()
{
assert(s_font != NULL);
assert(s_font != nullptr);
return *s_font;
}

View File

@ -7,7 +7,7 @@
#include <cmath>
const sf::Font* Effect::s_font = NULL;
const sf::Font* Effect::s_font = nullptr;
////////////////////////////////////////////////////////////
// "Pixelate" fragment shader

View File

@ -29,7 +29,7 @@ std::string resourcesDir()
////////////////////////////////////////////////////////////
int main()
{
std::srand(static_cast<unsigned int>(std::time(NULL)));
std::srand(static_cast<unsigned int>(std::time(nullptr)));
// Define some constants
const float pi = 3.14159f;

View File

@ -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<HBRUSH>(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<UINT>(~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);

View File

@ -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;

View File

@ -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

View File

@ -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.
///

View File

@ -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.
///

View File

@ -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.
///

View File

@ -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

View File

@ -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
///

View File

@ -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
///

View File

@ -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);

View File

@ -66,7 +66,7 @@ struct ThreadMemberFunc : ThreadFunc
////////////////////////////////////////////////////////////
template <typename F>
Thread::Thread(F functor) :
m_impl (NULL),
m_impl (nullptr),
m_entryPoint(new priv::ThreadFunctor<F>(functor))
{
}
@ -75,7 +75,7 @@ m_entryPoint(new priv::ThreadFunctor<F>(functor))
////////////////////////////////////////////////////////////
template <typename F, typename A>
Thread::Thread(F function, A argument) :
m_impl (NULL),
m_impl (nullptr),
m_entryPoint(new priv::ThreadFunctorWithArg<F, A>(function, argument))
{
}
@ -84,7 +84,7 @@ m_entryPoint(new priv::ThreadFunctorWithArg<F, A>(function, argument))
////////////////////////////////////////////////////////////
template <typename C>
Thread::Thread(void(C::*function)(), C* object) :
m_impl (NULL),
m_impl (nullptr),
m_entryPoint(new priv::ThreadMemberFunc<C>(function, object))
{
}

View File

@ -54,7 +54,7 @@ public:
/// \param value Optional value to initialize the variable
///
////////////////////////////////////////////////////////////
ThreadLocal(void* value = NULL);
ThreadLocal(void* value = nullptr);
////////////////////////////////////////////////////////////
/// \brief Destructor

View File

@ -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 *

View File

@ -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();

View File

@ -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();

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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;
}
}

View File

@ -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];
}

View File

@ -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

View File

@ -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;
}
}

View File

@ -63,7 +63,7 @@ namespace
return static_cast<long>(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<int>(maxCount - count) * static_cast<int>(sizeof(Int16));
long bytesRead = ov_read(&m_vorbis, reinterpret_cast<char*>(samples), bytesToRead, 0, 2, 1, NULL);
long bytesRead = ov_read(&m_vorbis, reinterpret_cast<char*>(samples), bytesToRead, 0, 2, 1, nullptr);
if (bytesRead > 0)
{
long samplesRead = bytesRead / static_cast<long>(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;
}
}

View File

@ -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)

View File

@ -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;
}
}

View File

@ -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

View File

@ -40,7 +40,7 @@
namespace
{
ALCdevice* captureDevice = NULL;
ALCdevice* captureDevice = nullptr;
}
namespace sf
@ -148,7 +148,7 @@ std::vector<std::string> SoundRecorder::getAvailableDevices()
{
std::vector<std::string> 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<std::string> 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

View File

@ -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

View File

@ -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<unsigned long>(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<Uint8>().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<Row>::iterator it = page.rows.begin(); it != page.rows.end() && !row; ++it)
{

View File

@ -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<Uint8> 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<Uint8>().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<Uint8> 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<Uint8>().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;
}
}

View File

@ -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)
{
}

View File

@ -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;

View File

@ -35,7 +35,7 @@ namespace sf
{
////////////////////////////////////////////////////////////
RenderTexture::RenderTexture() :
m_impl(NULL)
m_impl(nullptr)
{
}

View File

@ -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<Uint64, unsigned int>::iterator iter;
if (m_multisample)
{
iter = m_multisampleFrameBuffers.find(contextId);

View File

@ -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

View File

@ -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);
}
}

View File

@ -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

View File

@ -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),

View File

@ -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<GLsizei>(m_actualSize.x), static_cast<GLsizei>(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<GLsizei>(m_actualSize.x), static_cast<GLsizei>(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));

View File

@ -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);

View File

@ -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<jstring>(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);

View File

@ -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)
{

View File

@ -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;
}

View File

@ -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;
}

View File

@ -178,7 +178,7 @@ Socket::Status TcpSocket::connect(const IpAddress& remoteAddress, unsigned short
time.tv_usec = static_cast<long>(timeout.asMicroseconds() % 1000000);
// Wait for something to write on our socket (which means that the connection request has returned)
if (select(static_cast<int>(getHandle() + 1), NULL, &selector, NULL, &time) > 0)
if (select(static_cast<int>(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

View File

@ -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;
}

View File

@ -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);

View File

@ -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
}

View File

@ -33,7 +33,7 @@ namespace sf
{
////////////////////////////////////////////////////////////
MemoryInputStream::MemoryInputStream() :
m_data (NULL),
m_data (nullptr),
m_size (0),
m_offset(0)
{

View File

@ -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;
}
}

View File

@ -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

View File

@ -36,7 +36,7 @@ namespace priv
ThreadLocalImpl::ThreadLocalImpl() :
m_key(0)
{
pthread_key_create(&m_key, NULL);
pthread_key_create(&m_key, nullptr);
}

View File

@ -39,7 +39,7 @@ namespace priv
////////////////////////////////////////////////////////////
ThreadImpl::ThreadImpl(Thread* owner)
{
m_thread = reinterpret_cast<HANDLE>(_beginthreadex(NULL, 0, &ThreadImpl::entryPoint, owner, 0, &m_threadId));
m_thread = reinterpret_cast<HANDLE>(_beginthreadex(nullptr, 0, &ThreadImpl::entryPoint, owner, 0, &m_threadId));
if (!m_thread)
err() << "Failed to create thread" << std::endl;

View File

@ -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);

View File

@ -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];
}

View File

@ -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);

View File

@ -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);

View File

@ -36,7 +36,7 @@ namespace
namespace ContextImpl
{
// This per-thread variable holds the current context for each thread
sf::ThreadLocalPtr<sf::Context> currentContext(NULL);
sf::ThreadLocalPtr<sf::Context> 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;
}

View File

@ -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));
}

View File

@ -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
///

View File

@ -162,7 +162,7 @@ namespace priv
////////////////////////////////////////////////////////////
void JoystickImpl::initialize()
{
hid_init(NULL);
hid_init(nullptr);
// Do an initial scan
updatePluggedList();

View File

@ -164,10 +164,10 @@ namespace
unsigned int resourceCount = 0;
// This per-thread variable holds the current context for each thread
sf::ThreadLocalPtr<sf::priv::GlContext> currentContext(NULL);
sf::ThreadLocalPtr<sf::priv::GlContext> 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> transientContext(NULL);
sf::ThreadLocalPtr<TransientContext> transientContext(nullptr);
// Supported OpenGL extensions
std::vector<std::string> 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);

View File

@ -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();

View File

@ -163,7 +163,7 @@ namespace priv
////////////////////////////////////////////////////////////
void JoystickImpl::initialize()
{
hid_init(NULL);
hid_init(nullptr);
// Do an initial scan
updatePluggedList();

View File

@ -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);

View File

@ -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

View File

@ -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);
}

View File

@ -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();

View File

@ -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);

View File

@ -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);

View File

@ -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
///

View File

@ -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)
{

View File

@ -42,9 +42,9 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
std::vector<VideoMode> 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;

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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<unsigned int>(std::strtoul(attribute, NULL, 16));
value = static_cast<unsigned int>(std::strtoul(attribute, nullptr, 16));
return value;
}
@ -304,7 +304,7 @@ namespace
unsigned int value = 0;
if (attribute)
value = static_cast<unsigned int>(std::strtoul(attribute, NULL, 16));
value = static_cast<unsigned int>(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)

View File

@ -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<T>(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);

View File

@ -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<sf::priv::WindowImplX11*> 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<char*>(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;

View File

@ -66,7 +66,7 @@ VulkanFunctionPointer Vulkan::getFunction(const char* name)
{
#if defined(SFML_VULKAN_IMPLEMENTATION_NOT_AVAILABLE)
return NULL;
return nullptr;
#else

View File

@ -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;

View File

@ -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<const BITMAPINFO*>(&bitmapHeader),
DIB_RGB_COLORS,
reinterpret_cast<void**>(&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<int>(size.x), static_cast<int>(size.y), 1, 1, NULL);
HBITMAP mask = CreateBitmap(static_cast<int>(size.x), static_cast<int>(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;
}
}

View File

@ -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<PTCHAR>(&buffer), 0, NULL) == 0)
if (FormatMessage(FORMAT_MESSAGE_MAX_WIDTH_MASK | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr, error, 0, reinterpret_cast<PTCHAR>(&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<LPBYTE>(keyData), &keyDataSize);
result = RegQueryValueEx(currentKey, subkey.c_str(), nullptr, nullptr, reinterpret_cast<LPBYTE>(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<LPBYTE>(keyData), &keyDataSize);
result = RegQueryValueEx(currentKey, REGSTR_VAL_JOYOEMNAME, nullptr, nullptr, reinterpret_cast<LPBYTE>(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<void**>(&directInput), NULL);
HRESULT result = directInput8Create(GetModuleHandleW(nullptr), 0x0800, guids::IID_IDirectInput8W, reinterpret_cast<void**>(&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<JoystickRecord>::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<DWORD>(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;
}

View File

@ -43,7 +43,7 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
DEVMODE win32Mode;
win32Mode.dmSize = sizeof(win32Mode);
win32Mode.dmDriverExtra = 0;
for (int count = 0; EnumDisplaySettings(NULL, static_cast<DWORD>(count), &win32Mode); ++count)
for (int count = 0; EnumDisplaySettings(nullptr, static_cast<DWORD>(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);
}

View File

@ -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<T>(reinterpret_cast<void*>(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);

View File

@ -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<sf::priv::WglContext> currentContext(NULL);
sf::ThreadLocalPtr<sf::priv::WglContext> 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<LPTSTR>(&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<LPTSTR>(&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<int>(width), static_cast<int>(height), NULL, NULL, GetModuleHandle(NULL), NULL);
m_window = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, static_cast<int>(width), static_cast<int>(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)

View File

@ -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);

View File

@ -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<int>(mode.width)) / 2;
int top = (GetDeviceCaps(screenDC, VERTRES) - static_cast<int>(mode.height)) / 2;
int width = static_cast<int>(mode.width);
int height = static_cast<int>(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<int>(width), static_cast<int>(height), 1, 32, NULL, &iconPixels[0]);
m_icon = CreateIcon(GetModuleHandleW(nullptr), static_cast<int>(width), static_cast<int>(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<LPPOINT>(&rect), 2);
MapWindowPoints(m_handle, nullptr, reinterpret_cast<LPPOINT>(&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<WindowImplWin32*>(GetWindowLongPtr(handle, GWLP_USERDATA)) : NULL;
WindowImplWin32* window = handle ? reinterpret_cast<WindowImplWin32*>(GetWindowLongPtr(handle, GWLP_USERDATA)) : nullptr;
// Forward the event to the appropriate function
if (window)

View File

@ -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();

View File

@ -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;
}

View File

@ -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
///

View File

@ -33,7 +33,7 @@
namespace
{
// Save the global instance of the delegate
SFAppDelegate* delegateInstance = NULL;
SFAppDelegate* delegateInstance = nullptr;
// Current touches positions
std::vector<sf::Vector2i> 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 <SFML/Main.hpp>");
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));

View File

@ -183,7 +183,7 @@
if (self)
{
self.context = NULL;
self.context = nullptr;
self.touches = [NSMutableArray array];
// Configure the EAGL layer