From c4adc17d55feacc03c00f5a66f0e8412ef8982a9 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 12 Mar 2024 15:30:32 +0100 Subject: [PATCH] display: Fix assorted unreachable code warnings --- panda/metalibs/pandagl/pandagl.cxx | 15 +++++++------- panda/src/display/graphicsStateGuardian.cxx | 22 +++++++-------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/panda/metalibs/pandagl/pandagl.cxx b/panda/metalibs/pandagl/pandagl.cxx index 1a317fbdca..95c147c75e 100644 --- a/panda/metalibs/pandagl/pandagl.cxx +++ b/panda/metalibs/pandagl/pandagl.cxx @@ -70,25 +70,24 @@ init_libpandagl() { */ int get_pipe_type_pandagl() { -#ifdef HAVE_WGL +#if defined(HAVE_WGL) return wglGraphicsPipe::get_class_type().get_index(); -#endif -#if defined(HAVE_COCOA) +#elif defined(HAVE_COCOA) return CocoaGraphicsPipe::get_class_type().get_index(); + #elif defined(HAVE_CARBON) return osxGraphicsPipe::get_class_type().get_index(); -#endif -#ifdef HAVE_GLX +#elif defined(HAVE_GLX) return glxGraphicsPipe::get_class_type().get_index(); -#endif -#ifdef HAVE_EGL +#elif defined(HAVE_EGL) return eglGraphicsPipe::get_class_type().get_index(); -#endif +#else return 0; +#endif } #if defined(HAVE_EGL) && !defined(USE_X11) diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 7352afc85c..fb84f0cc96 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -1907,6 +1907,8 @@ fetch_specified_texture(Shader::ShaderTexSpec &spec, SamplerState &sampler, const LightAttrib *target_light; _target_rs->get_attrib_def(target_light); + PT(Texture) tex; + // We don't count ambient lights, which would be pretty silly to handle // via this mechanism. size_t num_lights = target_light->get_num_non_ambient_lights(); @@ -1916,28 +1918,21 @@ fetch_specified_texture(Shader::ShaderTexSpec &spec, SamplerState &sampler, Light *light_obj = light.node()->as_light(); nassertr(light_obj != nullptr, nullptr); - PT(Texture) tex; LightLensNode *lln = DCAST(LightLensNode, light.node()); if (lln != nullptr && lln->_shadow_caster) { tex = get_shadow_map(light); } else { tex = get_dummy_shadow_map((Texture::TextureType)spec._desired_type); } - - if (tex != nullptr) { - sampler = tex->get_default_sampler(); - } - return tex; } else { // There is no such light assigned. Bind a dummy shadow map. - PT(Texture) tex = get_dummy_shadow_map((Texture::TextureType)spec._desired_type); - if (tex != nullptr) { - sampler = tex->get_default_sampler(); - } - return tex; + tex = get_dummy_shadow_map((Texture::TextureType)spec._desired_type); } + if (tex != nullptr) { + sampler = tex->get_default_sampler(); + } + return tex; } - break; case Shader::STO_ff_stage_i: { @@ -2005,7 +2000,6 @@ fetch_specified_texture(Shader::ShaderTexSpec &spec, SamplerState &sampler, } return default_add_tex; } - break; case Shader::STO_stage_normal_i: { @@ -2035,7 +2029,6 @@ fetch_specified_texture(Shader::ShaderTexSpec &spec, SamplerState &sampler, } return default_normal_height_tex; } - break; case Shader::STO_stage_gloss_i: { @@ -2088,7 +2081,6 @@ fetch_specified_texture(Shader::ShaderTexSpec &spec, SamplerState &sampler, } return default_normal_height_tex; } - break; case Shader::STO_stage_selector_i: {