{"record":{"id":"e58ee7cc43c787b0","repo":"a-b-street/abstreet","slug":"error-compiling-shader","errorCode":null,"errorMessage":"error compiling shader: {}","messagePattern":"error compiling shader: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"critical","filePath":"widgetry/src/backend_glow.rs","lineNumber":67,"sourceCode":"        glow::ONE,\n        glow::ONE_MINUS_SRC_ALPHA,\n        glow::ONE_MINUS_DST_ALPHA,\n        glow::ONE,\n    );\n\n    Ok(program)\n}\n\nunsafe fn compile_shader(\n    gl: &glow::Context,\n    shader_type: u32,\n    shader_source: &str,\n) -> anyhow::Result<glow::Shader> {\n    let shader = gl.create_shader(shader_type).map_err(|e| anyhow!(e))?;\n    gl.shader_source(shader, shader_source);\n    gl.compile_shader(shader);\n    if !gl.get_shader_compile_status(shader) {\n        bail!(\"error compiling shader: {}\", gl.get_shader_info_log(shader));\n    }\n\n    Ok(shader)\n}\n\n// Represents one frame that's gonna be drawn\npub struct GfxCtxInnards<'a> {\n    gl: &'a glow::Context,\n    current_clip: Option<[i32; 4]>,\n    transform_location: <glow::Context as glow::HasContext>::UniformLocation,\n    window_location: <glow::Context as glow::HasContext>::UniformLocation,\n}\n\nimpl<'a> GfxCtxInnards<'a> {\n    pub fn new(\n        gl: &'a glow::Context,\n        program: &'a <glow::Context as glow::HasContext>::Program,\n    ) -> Self {","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/widgetry/src/backend_glow.rs#L49-L85","documentation":"compile_shader in widgetry's glow backend wraps OpenGL shader compilation: it uploads the shader source, compiles it, and if the driver reports a compile failure it bails with the driver's info log. The message is a low-level rendering backend error surfacing a GLSL problem.","triggerScenarios":"Any widgetry program whose GLSL source fails to compile on the current GPU/driver, e.g. shader syntax errors, unsupported GLSL version directives, or features the driver rejects.","commonSituations":"Running on machines with old/limited GPU drivers, missing OpenGL version support (e.g. VMs or software renderers), recently modified shader code with a typo, driver-specific GLSL strictness.","solutions":["Read the info log appended to the error message and fix the GLSL syntax/feature it points to","Update GPU drivers or run on hardware supporting the required OpenGL version","Check the GLSL version header (#version) matches the context's supported version","If the shader was recently changed, revert and re-apply the change carefully"],"exampleFix":"// before\n#version 410 core\n// after\n#version 150 core // match the driver's supported GLSL version","handlingStrategy":"try-catch","validationCode":"if !gl.get_shader_compile_status(shader) {\n    eprintln!(\"shader log: {}\", gl.get_shader_info_log(shader));\n}","typeGuard":null,"tryCatchPattern":"match widgetry_app::run(settings) {\n    Ok(()) => {},\n    Err(e) if e.to_string().starts_with(\"error compiling shader\") => {\n        eprintln!(\"GPU/driver rejected shader: {}\\ntry updating drivers or another machine\", e);\n        std::process::exit(1);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Verify the target machine's OpenGL/GPU driver supports the required GLSL version","Avoid editing shipped shaders without testing on the lowest-spec supported machine","Pin a supported GLSL #version header and keep shader code under review","Test on software renderers/VMs early if deploying to constrained environments"],"tags":["opengl","shaders","graphics","glow"],"backgroundTag":"shader-compilation-failed","analyzedSha":"0964f29315820c91b171b585eb51e300164e9197","analyzedAt":"2026-09-13T18:02:03.421Z","contentChangedAt":"2026-09-13T18:02:03.421Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}