Skip to content

Cockpit mesh invisible in cockpit camera mode (F10) due to GL_CULL_FACE state leak #29

Description

@mido3ds

Bug

Cockpit mesh is invisible in cockpit camera mode (F10). HUD elements render fine.

Root Cause

aircrafts_prepare_render (aircraft.cpp:639) calls glDisable(GL_CULL_FACE) before pushing cockpit meshes to the canvas, then glEnable(GL_CULL_FACE) at line 653. No GL draws happen between those calls — only canvas_add pushes to a Vec. The actual glDrawArrays happens later in canvas_render_meshes, at which point GL_CULL_FACE is enabled (leaked from line 653). The cockpit interior faces (back-facing from camera POV inside the cockpit) are culled → cockpit invisible.

The original analysis blamed GL_DEPTH_TEST, but the depth test is irrelevant here — the HUD renders correctly on top of the scene because it runs after the scene draw and uses its own orthographic projection. The real issue is face culling.

Fix

  1. Add a separate list_cockpit mesh list to Canvas::meshes
  2. Push cockpit meshes there instead of list_regular
  3. Render list_cockpit in canvas_render_meshes wrapped in glDisable(GL_CULL_FACE) / glEnable(GL_CULL_FACE)
  4. Remove the dead glDisable/glEnable(GL_CULL_FACE) from the push site in aircraft.cpp

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions