jimy-byerley / pymadcad

Simple yet powerful CAD (Computer Aided Design) library, written with Python.
https://madcad.netlify.app/
GNU Lesser General Public License v3.0
211 stars 17 forks source link

Minimum fix for MacOS, possibly #82

Closed GenieTim closed 1 year ago

GenieTim commented 1 year ago

This is the reduced fix for MacOS, this time without also upgrading PyQt to 6.

This is what's required on my device. Without it, I still get the division by zero error. The change on line 767 is not strictly necessary.

It's possible that there are other ways to achieve what I do here, I am not particularly familiar with OpenGL or PyQt, just got to this answer thanks to this forum post: https://forum.qt.io/topic/75759/qopengl-on-mac-qcocoaglcontext-falling-back-to-unshared-context/3

jimy-byerley commented 1 year ago

That's an odd fix, but nice finding

Does it work for you to set the fix you set in show but to keep the QSurfaceFormat code in View, so using View as a widget in a Qt application still brings its own GL settings ?

jimy-byerley commented 1 year ago

If so, we should do the following:

# module level in rendering
def qt_surface_format():
    fmt = QSurfaceFormat()
    fmt.setVersion(*opengl_version)
    fmt.setProfile(QSurfaceFormat.OpenGLContextProfile.CoreProfile)
    fmt.setSamples(4)
    return fmt

# in show(), before QApplication init
QSurfaceFormat.setDefaultFormat(qt_surface_format())

# in View.__init__()
self.setFormat(qt_surface_format())
GenieTim commented 1 year ago

Yes, that absolutely works.

jimy-byerley commented 1 year ago

Hello @GenieTim We didn't received confirmations that this is working from other macos users, I'm not sure whether no one attempted it, or if some one with this problem found this PR and used that solution without subscribing to github to mention it.

I'm going to merge this anyway since it fixed the issue at least for you ;)

kzlar commented 1 year ago

Hi @jimy-byerley, I'm also seeing that issue and want to help test. I can't seem to get the branch to run locally. Would it be possible to publish a version that I could pip install and try? Thank you!

jimy-byerley commented 1 year ago

Sure I should publish a fix version however if the master branch doesn't run on your side, it will ikely be the same with the published version

What was the console output when you tried the master branch ?

kzlar commented 1 year ago

I wasnt able to build it. clang: error: no such file or directory: 'madcad/core.c' but admittedly a lot of this is far beyond my understanding :)

jimy-byerley commented 1 year ago

Ah, this is only because you didn't installed the build requirements: cython you can pip install it as well as the runtime dependencies and the compilation should proceed.

kzlar commented 1 year ago

Cool that indeed worked! The master branch works on my macbook m1 including the show function! Thank you!

jimy-byerley commented 1 year ago

Youre welcome ;)