Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GL.GL_MULTISAMPLE not supported on Windows and MacOS #399

Closed
ziyaointl opened this issue Sep 24, 2022 · 5 comments
Closed

GL.GL_MULTISAMPLE not supported on Windows and MacOS #399

ziyaointl opened this issue Sep 24, 2022 · 5 comments

Comments

@ziyaointl
Copy link
Member

Describe the bug
GL.glEnable(GL.GL_MULTISAMPLE) causes p5py to crash under the skia renderer in MacOS and Windows.

To Reproduce
Run the any p5 script with skia as renderer.

Expected behavior
p5py should not crash

Screenshots
N/A

System information:
MacOS

  • p5 release (version number or latest commit): 6f0d096
  • Python version: Python 3.9.13
  • Operating system: MacOS Montery 12.4

Windows

  • p5 release (version number or latest commit): 6f0d096
  • Python version: Python 3.10.7
  • Operating system: Windows 10 Pro 20H2

Additional context
Windows stack trace:

Traceback (most recent call last):
  File "test.py", line 22, in <module>
    run(renderer='skia')
  File "p5\sketch\userspace.py", line 231, in run
    p5.sketch.start()
  File "p5\sketch\Skia2DRenderer\base.py", line 159, in start
    self.window = self.glfw_window()
  File "p5\sketch\Skia2DRenderer\base.py", line 80, in glfw_window
    GL.glEnable(GL.GL_MULTISAMPLE)
  File "OpenGL\platform\baseplatform.py", line 415, in __call__
    return self( *args, **named )
  File "OpenGL\error.py", line 230, in glCheckError
    raise self._errorClass(
OpenGL.error.GLError: GLError(
        err = 1282,
        description = b'invalid operation',
        baseOperation = glEnable,
        cArguments = (GL_MULTISAMPLE,)
)

MacOS stack trace:

$ python -X faulthandler issue352.py
Fatal Python error: Segmentation fault

Current thread 0x0000000111041600 (most recent call first):
  File "OpenGL/platform/baseplatform.py", line 415 in __call__
  File "p5/sketch/Skia2DRenderer/base.py", line 80 in glfw_window
  File "p5/sketch/Skia2DRenderer/base.py", line 159 in start
  File "p5/sketch/userspace.py", line 231 in run
  File "issue352.py", line 40 in <module>
[1]    65875 segmentation fault  python -X faulthandler issue352.py

We may need to find another way to enable antialiasing in skia.

@tushar5526
Copy link
Member

tushar5526 commented Sep 24, 2022

I think I should try setting the settings after creating a context, and it might work fine.
https://stackoverflow.com/questions/68527174/invalid-operation-when-glenablegl-multisample-in-pyopengl
so glEnable should come after I create a context.

On researching further it seems that multisampling is enabled by default.
https://registry.khronos.org/OpenGL-Refpages/gl2.1/xhtml/glEnable.xml

@ziyaointl, can you try removing these 3 hints from line https://github.com/p5py/p5/blob/master/p5/sketch/Skia2DRenderer/base.py#L78 and test on windows again, when you have the time?

@ziyaointl
Copy link
Member Author

Thanks! I confirm that antialiasing works on windows if we removed the 3 lines:
Capture

@ziyaointl
Copy link
Member Author

On MacOS, removing the three lines also worked - though there seems to be a separate issue of the image not being the correct size.
Screen Shot 2022-09-27 at 8 05 20 PM

@tushar5526
Copy link
Member

tushar5526 commented Sep 28, 2022

The macos issue is due to the retina display. I will recheck the code to see if I am initialising values properly. In the sketch class framebuffers are not being configured properly

@ziyaointl
Copy link
Member Author

Closing issue since this was resolved in #400

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

No branches or pull requests

2 participants