From 6b9dea3e3069c3ef05b26c3db9cc0863c125e312 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 9 Mar 2022 10:46:02 +0100 Subject: [PATCH] cleanup: Fix comparison between pointer and 0 (instead of nullptr) --- panda/src/dxgsg9/dxShaderContext9.cxx | 2 +- panda/src/dxgsg9/wdxGraphicsBuffer9.cxx | 4 ++-- panda/src/dxgsg9/wdxGraphicsWindow9.cxx | 2 +- panda/src/glstuff/glCgShaderContext_src.cxx | 6 +++--- panda/src/glstuff/glGraphicsBuffer_src.cxx | 6 +++--- panda/src/gobj/material.I | 2 +- panda/src/wgldisplay/wglGraphicsBuffer.cxx | 14 +++++++------- panda/src/wgldisplay/wglGraphicsWindow.cxx | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/panda/src/dxgsg9/dxShaderContext9.cxx b/panda/src/dxgsg9/dxShaderContext9.cxx index 6c7a15d313..dd9b8f8233 100644 --- a/panda/src/dxgsg9/dxShaderContext9.cxx +++ b/panda/src/dxgsg9/dxShaderContext9.cxx @@ -693,7 +693,7 @@ update_shader_texture_bindings(DXShaderContext9 *prev, GSG *gsg) { continue; } - if (spec._suffix != 0) { + if (spec._suffix != nullptr) { // The suffix feature is inefficient. It is a temporary hack. tex = tex->load_related(spec._suffix); } diff --git a/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx b/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx index 81fce0c90b..86a8c9ee41 100644 --- a/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx @@ -266,7 +266,7 @@ rebuild_bitplanes() { // Decide how big the bitplanes should be. - if ((_host != 0)&&(_creation_flags & GraphicsPipe::BF_size_track_host)) { + if (_host != nullptr && (_creation_flags & GraphicsPipe::BF_size_track_host) != 0) { if (_host->get_size() != _size) { set_size_and_recalc(_host->get_x_size(), _host->get_y_size()); @@ -739,7 +739,7 @@ bool wdxGraphicsBuffer9:: open_buffer() { // GSG creationinitialization. - if (_gsg == 0) { + if (_gsg == nullptr) { // The code below doesn't support creating a GSG on the fly. Just error // out for now. _dxgsg = new DXGraphicsStateGuardian9(_engine, _pipe); // _gsg = _dxgsg; diff --git a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx index ef70d24879..b1694b5613 100644 --- a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx @@ -261,7 +261,7 @@ open_window() { static ConfigVariableBool always_discard_device("always-discard-device", true); bool discard_device = always_discard_device; - if (_gsg == 0) { + if (_gsg == nullptr) { _dxgsg = new DXGraphicsStateGuardian9(_engine, _pipe); _gsg = _dxgsg; } else { diff --git a/panda/src/glstuff/glCgShaderContext_src.cxx b/panda/src/glstuff/glCgShaderContext_src.cxx index 7d65fdd976..e4c3aedf36 100644 --- a/panda/src/glstuff/glCgShaderContext_src.cxx +++ b/panda/src/glstuff/glCgShaderContext_src.cxx @@ -1113,14 +1113,14 @@ update_shader_texture_bindings(ShaderContext *prev) { continue; } - if (spec._suffix != 0) { + if (spec._suffix != nullptr) { // The suffix feature is inefficient. It is a temporary hack. - if (tex == 0) { + if (tex == nullptr) { continue; } tex = tex->load_related(spec._suffix); } - if ((tex == 0) || (tex->get_texture_type() != spec._desired_type)) { + if (tex == nullptr || tex->get_texture_type() != spec._desired_type) { continue; } diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index c8641ebe6e..dbaf610d5a 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -360,7 +360,7 @@ check_fbo() { void CLP(GraphicsBuffer):: rebuild_bitplanes() { check_host_valid(); - if (_gsg == 0) { + if (_gsg == nullptr) { return; } @@ -1661,7 +1661,7 @@ close_buffer() { check_host_valid(); - if (_gsg == 0) { + if (_gsg == nullptr) { return; } @@ -1824,7 +1824,7 @@ unregister_shared_depth_buffer(GraphicsOutput *graphics_output) { */ void CLP(GraphicsBuffer):: report_my_errors(int line, const char *file) { - if (_gsg == 0) { + if (_gsg == nullptr) { GLenum error_code = glGetError(); if (error_code != GL_NO_ERROR) { GLCAT.error() << file << ", line " << line << ": GL error " << (int)error_code << "\n"; diff --git a/panda/src/gobj/material.I b/panda/src/gobj/material.I index dcaef86980..bd717f835c 100644 --- a/panda/src/gobj/material.I +++ b/panda/src/gobj/material.I @@ -58,7 +58,7 @@ INLINE Material:: */ INLINE Material *Material:: get_default() { - if (_default == 0) { + if (_default == nullptr) { _default = new Material("default"); } return _default; diff --git a/panda/src/wgldisplay/wglGraphicsBuffer.cxx b/panda/src/wgldisplay/wglGraphicsBuffer.cxx index aacedf0ae3..207fa7eeaf 100644 --- a/panda/src/wgldisplay/wglGraphicsBuffer.cxx +++ b/panda/src/wgldisplay/wglGraphicsBuffer.cxx @@ -157,7 +157,7 @@ bind_texture_to_pbuffer() { if (tex_index >= 0) { const RenderTexture &rt = cdata->_textures[tex_index]; Texture *tex = rt._texture; - if ((_pbuffer_bound != 0)&&(_pbuffer_bound != tex)) { + if (_pbuffer_bound != nullptr && _pbuffer_bound != tex) { _pbuffer_bound->release(wglgsg->get_prepared_objects()); _pbuffer_bound = 0; } @@ -188,7 +188,7 @@ bind_texture_to_pbuffer() { } _pbuffer_bound = tex; } else { - if (_pbuffer_bound != 0) { + if (_pbuffer_bound != nullptr) { _pbuffer_bound->release(wglgsg->get_prepared_objects()); _pbuffer_bound = 0; } @@ -292,7 +292,7 @@ open_buffer() { // GSG creationinitialization. wglGraphicsStateGuardian *wglgsg; - if (_gsg == 0) { + if (_gsg == nullptr) { // There is no old gsg. Create a new one. wglgsg = new wglGraphicsStateGuardian(_engine, _pipe, nullptr); wglgsg->choose_pixel_format(_fb_properties, true); @@ -355,16 +355,16 @@ open_buffer() { */ void wglGraphicsBuffer:: release_pbuffer() { - if (_gsg == 0) { + if (_gsg == nullptr) { return; } wglGraphicsStateGuardian *wglgsg; DCAST_INTO_V(wglgsg, _gsg); - if (_pbuffer_bound != 0) { + if (_pbuffer_bound != nullptr) { _pbuffer_bound->release(wglgsg->get_prepared_objects()); - _pbuffer_bound = 0; + _pbuffer_bound.clear(); } wglGraphicsPipe::wgl_make_current(0, 0, nullptr); if (_pbuffer_dc) { @@ -420,7 +420,7 @@ rebuild_bitplanes() { // Determine what pbuffer attributes are needed for currently-applicable // textures. - if ((_host != 0)&&(_creation_flags & GraphicsPipe::BF_size_track_host)) { + if (_host != nullptr && (_creation_flags & GraphicsPipe::BF_size_track_host) != 0) { if (_host->get_size() != _size) { set_size_and_recalc(_host->get_x_size(), _host->get_y_size()); diff --git a/panda/src/wgldisplay/wglGraphicsWindow.cxx b/panda/src/wgldisplay/wglGraphicsWindow.cxx index 1af86c6b95..c79ea4eb9f 100644 --- a/panda/src/wgldisplay/wglGraphicsWindow.cxx +++ b/panda/src/wgldisplay/wglGraphicsWindow.cxx @@ -200,7 +200,7 @@ open_window() { // GSG creationinitialization. wglGraphicsStateGuardian *wglgsg; - if (_gsg == 0) { + if (_gsg == nullptr) { // There is no old gsg. Create a new one. wglgsg = new wglGraphicsStateGuardian(_engine, _pipe, nullptr); wglgsg->choose_pixel_format(_fb_properties, false);