Skip to content

fix: isnan is not available in OpenGL 2.1 nor OpenGL ES 2.0#3248

Merged
j9ac9k merged 2 commits intopyqtgraph:masterfrom
pijyoi:fix-pcmi-no-isnan
Feb 21, 2025
Merged

fix: isnan is not available in OpenGL 2.1 nor OpenGL ES 2.0#3248
j9ac9k merged 2 commits intopyqtgraph:masterfrom
pijyoi:fix-pcmi-no-isnan

Conversation

@pijyoi
Copy link
Copy Markdown
Contributor

@pijyoi pijyoi commented Feb 16, 2025

#3170 added checks for nan in the shader code.
The "COMPAT" shader code is intended for running on OpenGL 2.1 and OpenGL ES 2.0, and in those versions, isnan is not defined. Fix by replacing isnan with a self comparison.

Notes:

  1. On my system, even when forcing it to use the "COMPAT" shader code, the use of isnan doesn't trigger an error. An error is only triggered if the GLSL version is explicitly specified as #version 120. i.e. the shader compiler can be permissive and support functions that appear in newer GLSL versions.
  2. It was not possible to test the shader errors on the CI, because even if illegal keywords were put into the shader code, the CI did not detect that there was a shader compilation error.
  3. Windows and Linux are not going to be affected by this bug because they will take the modern shader code path.
  4. macOS is possibly affected by this bug as its default OpenGL version is 2.1.

A simple script to exercise the shader code.

import numpy as np
import pyqtgraph as pg

pg.setConfigOptions(useOpenGL=True, enableExperimental=True, background='w')

Z = np.linspace(0, 1, 12).reshape((3, 4))
Z[1,1] = np.nan

pg.mkQApp()
win = pg.PlotWidget()
pcmi = pg.PColorMeshItem(Z)
win.addItem(pcmi)
win.show()
pg.exec()

it is available in OpenGL 3.0 (GLSL 130) and OpenGL ES 3.0
@j9ac9k j9ac9k merged commit 205f29f into pyqtgraph:master Feb 21, 2025
30 checks passed
@pijyoi pijyoi deleted the fix-pcmi-no-isnan branch February 21, 2025 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants