Perl-GPU / OpenGL-Modern

Perl OpenGL bindings for modern OpenGL 3.1-4.x
7 stars 5 forks source link

glewCreateContext fails on MacOSX on Travis #34

Closed wchristian closed 2 months ago

wchristian commented 7 years ago

Right now the tests only skip and mention they failed. They don't try to inspect the return values to see why they failed. Tests should try and give more feedback about that.

wchristian commented 7 years ago
GLenum err = glewInit();
if (GLEW_OK != err)
{
  /* Problem: glewInit failed, something is seriously wrong. */
  fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
  ...
}
wchristian commented 7 years ago

This is also misleading:

skip "glewInit not successful, skipping tests", 2 if glewCreateContext() or glewInit(); # GLEW_OK == 0

Should be separate lines. Also i'm curious to see if glewInit gives useful feedback if it's called before glewCreateContext. Maybe try this in a separate branch.

wchristian commented 7 years ago

Where did the idea to use glewCreateContext come from anyhow? As far as i can see it is only declared for glewinfo, which is a specific commandline tool.

devel-chm commented 7 years ago

The line-by-line check for the glewCreateContext and glewInit are in test 01context.t The usage in 02* etc is for skipping runtime tests if real contexts are not available. I think Max used this approach first but it is is good in the sense of being lightweight.

wchristian commented 7 years ago

Alright, so neither of us knows why it's there. Checking to see if it's actually necessary.

As for 02, the line is misleading as it only says glewInit in the skip message, it should at least mention both, i think?

wchristian commented 7 years ago

Err, results on this:

If i don't run glewCreateContext (using master) it crashes as soon as it tries to use a GL function:

glGenBuffers not available on this machine at C:/strawberry/perl/site/lib/OpenGL/Modern/Helpers.pm line 267.

If i don't run glewInit, Microidium works, but runs at 3.6 fps?

wchristian commented 7 years ago

Ok, on further inspection, without create context glewinit errors out with "Missing GL version" if glCreateContext wasn't called.

Do you think you can get some more details out of glCreateContext if it fails? Maybe by making some of the internally called functions available in Perl? ( https://github.com/nigels-com/glew/blob/master/auto/src/glewinfo_tail.c#L176-L598 )

devel-chm commented 7 years ago

I thought you were asking about why glewCreateContext specifically. In order for GLEW to load the needed extensions, there has to be an OpenGL context. glewCreateContext is good because it comes with the GLEW distribution.

wchristian commented 7 years ago

Alright, so if that's not strictly necessary, can you throw together a different context creation process we can bash against mac?

devel-chm commented 7 years ago

You can use GLUT from OpenGL. Once the window+context is created, you can call glewInit. If you use the just fixed for the transparent glewInit calls, it should just work. (Famous last words...)

wchristian commented 7 years ago

Right, so you probably want to add -framework GLUT to MFpl so it can link and then special-case macosx in the test. Also, i'm asking you to write the test code because you know better what you're doing there. :x

devel-chm commented 7 years ago

That is the problem. If the MacOSX code built and linked correctly, then glewCreateContext should work as well. I put out a call for someone with MacOSX to help debug. Here's hoping....

--Chris

devel-chm commented 7 years ago

Oh, I didn't realize this was in the Travis-CI thread. There is definitely something needed to allow glutCreateContext to work. I vaguely recall something about Xvfb or some such from a search... HTH.

wchristian commented 7 years ago

If i understand this correctly, xvfb won't run on osx anymore without considerable effort to get quartz installed and set up:

http://stackoverflow.com/questions/25451133/xvfb-run-on-os-x/32786365#32786365

Please read and tell me what you get from it.

wchristian commented 7 years ago

Ok, turns out there is xvfb on those machines:

https://github.com/travis-ci/travis-ci/issues/2351#issuecomment-49422274

And i actually got somewhat close to making things happen, but now i'm quite stuck:

$ if [ "${TRAVIS_OS_NAME}" = "osx" ]; then Xvfb :99 -ac -screen 0 1024x768x8 -extension GLX; fi
[mi] Extension "GLX" is not recognized
[mi] Only the following extensions can be run-time disabled:
[mi]    Generic Events
[mi]    Composite
[mi]    DAMAGE
[mi]    DOUBLE-BUFFER
[mi]    DPMS
[mi]    MIT-SCREEN-SAVER
[mi]    MIT-SHM
[mi]    RANDR
[mi]    RENDER
[mi]    X-Resource
[mi]    XFIXES
[mi]    XINERAMA
[mi]    XTEST
[mi]    XVideo
_XSERVTransmkdir: ERROR: euid != 0,directory /tmp/.X11-unix will not be created.
_XSERVTransSocketUNIXCreateListener: mkdir(/tmp/.X11-unix) failed, errno = 2
_XSERVTransMakeAllCOTSServerListeners: failed to create listener for local
(EE) 
Fatal server error:
(EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE) 
The command "if [ "${TRAVIS_OS_NAME}" = "osx" ]; then Xvfb :99 -ac -screen 0 1024x768x8 -extension GLX; fi" failed and exited with 1 during .
wchristian commented 7 years ago

Asked in the Travis issues: https://github.com/travis-ci/travis-ci/issues/7313

mohawk2 commented 2 months ago

@zmughal made xvfb routinely work with PDL's TriD CI. The GitHub Actions CI for this org works on MacOS. Together with the croaking auto-glewInit, I am confident this distro works on MacOS, so am closing this.