Skip to content

Error creating OpenGL context on Windows ARM64 builds #999

@trevorsandy

Description

@trevorsandy

Describe the bug
I am able to successfully build LeoCAD on Windows ARM64 but on execution, QOpenGLContext is consistently failing on create() in lcContext::CreateOffscreenContext().

To Reproduce
Steps to reproduce the behavior:

  1. set LEOCAD_LIB=<path to your LDraw library>
  2. copy <path to your Demo.mpd file> .
  3. leocad.exe -i Demo.png -l %LEOCAD_LIB% Demo.mpd
  4. See error

Expected behavior
Application should run and produce Demo.png.

Version:

Additional context
I inserted trace statements in lcContext::CreateOffscreenContext() to track at which function the failure occurs. See details:

Details

While the build log is available, you can see the full GitHub build process at https://github.com/trevorsandy/leocad/actions/runs/18812958719/job/53677245473

Error creating OpenGL context.
DEBUG Shared Context - Obtained OpenGL context:
    Version: 2.0
    Profile: NoProfile
    IsOpenGLES: No

DEBUG Shared Context 1 of 6 - [OK] Construct new OpenGLContext OffscreenContext.
DEBUG Shared Context 2 of 6 - [FAIL] Set globalShareContext and create OffscreenContext.
DEBUG Shared Context 3 of 6 - [FAIL] OffscreenContext is valid.
DEBUG Shared Context 4 of 6 - [OK] Construct new OffscreenSurface.
DEBUG Shared Context 5 of 6 - [OK] Create OffscreenSurface is valid.
DEBUG Shared Context 6 of 6 - [FAIL] Make current OffscreenContext - get OffscreenSurface.
Error: Process completed with exit code 1.

I removed QOpenGLFunctions_3_2_Core from lc_context.cpp and lc_glexensions.cpp with no change.

#ifndef LC_WIN_ARM64
#include <QOpenGLFunctions_3_2_Core>
#endif

I've also tried setting the QSurfaceFormat to both OpenGL and OpenGLES with no change.

static void lcInitializeSurfaceFormat(int argc, char* argv[])
{
	QCoreApplication Application(argc, argv);
	const lcCommandLineOptions Options = lcApplication::ParseCommandLineOptions();

    QSurfaceFormat Format = QSurfaceFormat::defaultFormat();
#ifdef LC_WIN_ARM64 
    Format.setRenderableType(QSurfaceFormat::OpenGLES); 
    /*Format.setRenderableType(QSurfaceFormat::OpenGL);*/ 
    Format.setVersion(3, 0); 
    /*Format.setVersion(4, 5);*/ 
    Format.setProfile(QSurfaceFormat::CoreProfile); 
    QSurfaceFormat::setDefaultFormat(Format); 
#endif
	if (Options.ParseOK && Options.AASamples > 1)
	{
		Format.setSamples(Options.AASamples);
		QSurfaceFormat::setDefaultFormat(Format);
	}
}

To perform the build and check, I added a build-windows job for Windows AMD64 and ARM64 distributions to continuous.yml. See details:

Details
jobs:
  build-windows:
    # if: ${{ false }} # uncomment to disable this job
    name: 'Build ${{ matrix.name }}'
    runs-on: ${{ matrix.runner-os }}
    continue-on-error: true
    strategy:
      fail-fast: false
      matrix:
        runner-os: [ windows-2025, windows-11-arm ]
        platform: [ AMD64, ARM64 ]
        exclude:
          - runner-os: windows-2025
            platform: ARM64
          - runner-os: windows-11-arm
            platform: AMD64
        include:
          - runner-os: windows-2025
          - runner-os: windows-11-arm
          - platform: AMD64
            name: Windows 2025 AMD64
            host: ''
            arch: _64
            vca: X64
          - platform: ARM64
            name: Windows 11 ARM64
            host: _arm64
            arch: _arm64
            vca: ARM64
    steps:
    - name: Checkout Source
      uses: actions/checkout@v5
      with:
        fetch-depth: 0
    - name: Work Paths
      run: |
        Echo "LC_BUILD_BASE=$(resolve-path ..\)" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
        Echo "LC_BUILD_APPDIR=$(Join-Path (resolve-path ..\) 'appdir')" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
        New-Item -Path ..\ -Name 'appdir' -ItemType 'directory'
    - name: Qt MSVC 2022 ${{ matrix.platform }} # path: ..\Qt\6.10.0\msvc2022_arm64\bin
      uses: jurplel/install-qt-action@v4
      with:
        version: 6.10.0
        host: windows${{ matrix.host }}
        target: desktop
        modules: qt5compat
        arch: win64_msvc2022${{ matrix.arch }}
        dir: ${{ env.LC_BUILD_BASE }}
        cache: 'true'
        cache-key-prefix: install-qt
    - name: Cache Parts Library
      uses: actions/cache@v3
      id: cache-library
      with:
        path: ${{ env.LC_BUILD_APPDIR }}\library.bin
        key: library-25.08
    - name: Download Parts Library
      if: steps.cache-library.outputs.cache-hit != 'true'
      shell: cmd
      run: |
        curl https://github.com/leozide/leocad/releases/download/v23.03/Library-25.08.zip -Lo library.zip
        unzip library.zip -d ${{ env.LC_BUILD_APPDIR }}
    - name: Cache POV-Ray
      uses: actions/cache@v3
      id: cache-povray
      with:
        path: ${{ env.LC_BUILD_APPDIR }}\povconsole32-sse2.exe
        key: povray-20.03
    - name: Download POV-Ray
      if: steps.cache-povray.outputs.cache-hit != 'true'
      shell: cmd
      run: |
        :: the x86 version of POVRay will work on ARM64 in emulation mode but will be less efficient.
        curl https://github.com/leozide/povray/releases/download/continuous/povconsole32-sse2.exe -Lo ${{ env.LC_BUILD_APPDIR }}\povconsole32-sse2.exe
    - name: Install NSIS with EnVar plugin # missing in Windows 2025 but pre-installed in windows-11-arm
      if: ${{ matrix.runner-os == 'windows-2025' && matrix.platform == 'AMD64' }}
      uses: repolevedavaj/install-nsis@v1.0.3
      with:
        nsis-version: 3.11
    - name: Build ${{ matrix.name }}
      shell: cmd
      run: |
        call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.platform }}
        set "CONFIG_ARGS=CONFIG+=Release CONFIG-=debug_and_release"
        set "MAKE_ARGS=-c -f Makefile"
        qmake -v
        qmake %CONFIG_ARGS%
        nmake %MAKE_ARGS%
    - name: Stage ${{ matrix.name }}
      shell: cmd
      run: |
        call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.platform }}
        copy docs\readme.md ${{ env.LC_BUILD_APPDIR }}\readme.txt
        copy build\release\leocad.exe ${{ env.LC_BUILD_APPDIR }}
        windeployqt ${{ env.LC_BUILD_APPDIR }}\leocad.exe
    - name: Check ${{ matrix.name }}
      if: ${{ matrix.runner-os == 'windows-11-arm' }}
      id: check
      shell: cmd
      run: |
        copy resources\8464.ldr ${{ env.LC_BUILD_BASE }}\8464.mpd
        cd ${{ env.LC_BUILD_BASE }}
        ${{ env.LC_BUILD_APPDIR }}\leocad.exe -i 8464.png -l ${{ env.LC_BUILD_APPDIR }}\library.bin 8464.mpd
    - name: Package ${{ matrix.name }}
      if: success() || ( failure() && steps.check.outcome == 'failure' )
      shell: cmd
      run: |
        copy tools\setup\leocad.nsi ${{ env.LC_BUILD_BASE }}
        copy tools\setup\setup.ico ${{ env.LC_BUILD_BASE }}
        git rev-parse --short HEAD > version.txt
        set /p VERSION= < version.txt
        tar.exe -a -c -f ${{ env.LC_BUILD_BASE }}\symbols-${{ matrix.platform }}-%VERSION%.zip build\release\leocad.exe build\release\leocad.pdb
        cd ${{ env.LC_BUILD_BASE }}
        "C:\Program Files (x86)\NSIS\makensis.exe" /V4 /D${{ matrix.vca }} "/XOutFile LeoCAD-Windows-${{ matrix.platform }}-%VERSION%.exe" leocad.nsi
    - name: Deploy ${{ matrix.name }}
      if: success() || ( failure() && steps.check.outcome == 'failure' )
      shell: cmd
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      run: |
        curl https://github.com/probonopd/uploadtool/raw/master/upload.sh -Lo upload.sh
        set UPLOADTOOL_ISPRERELEASE=1
        if not defined GITHUB_HEAD_REF (bash upload.sh ${{ env.LC_BUILD_BASE }}/LeoCAD*.exe ${{ env.LC_BUILD_BASE }}/symbols*.zip)

An ARM64 version of povconsole32-sse2.exe (see my POVRay ARM64 build) is best but the existing x86 version should work using emulation.

Cheers,

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions