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

kgl-opengl on macOS creates 2.1 context instead of 4.1 context by default #20

Closed
nlbuescher opened this issue Feb 8, 2020 · 5 comments

Comments

@nlbuescher
Copy link
Collaborator

nlbuescher commented Feb 8, 2020

kgl-opengl currently can only create an OpenGL context up version 2.1, because Apple. Platform lib only supports up to 3.2+ (no 4), but there's nothing to be done about that. Calling gl functions from 4+ throws NullPointerException because the function loader can't find them.

@Dominaezzz
Copy link
Owner

kgl-opengl can load functions from 3.2. I've tested this on at least three macs. Are you experiencing any specific issues with function loading?

@nlbuescher
Copy link
Collaborator Author

nlbuescher commented Feb 8, 2020

It can load the functions, but the context version returned from glGetString(GL_VERSION) is 2.1 when using GLFW (ie initializing context without specifying version). This may affect shader compilation, although I'm not sure about that. Would need to test.

Relevant stack overflow link: https://stackoverflow.com/a/26982694

@nlbuescher nlbuescher changed the title kgs-opengl on macOS should use platform libs since macOS doesn't support modern OpenGL kgl-opengl on macOS should use platform libs since macOS doesn't support modern OpenGL Feb 9, 2020
@nlbuescher
Copy link
Collaborator Author

Update after a bit more research:

  1. The latest version on OpenGL supported by Apple seems to be 4.1 (link), which is better than I thought.
  2. Despite that, if the context is initialized as 2.1, my #version 330 shader does not compile because version 330 is not supported.

Calling glutInitDisplayMode(GLUT_3_2_CORE_PROFILE) from the OpenGL3 platform lib get a glGetString(GL_VERSION) result of 4.1, otherwise the context version is similarly defaulted to 2.1. Not sure what the implications of that are.

@nlbuescher nlbuescher changed the title kgl-opengl on macOS should use platform libs since macOS doesn't support modern OpenGL kgl-opengl on macOS creates 2.1 context instead of 4.1 context by default Feb 9, 2020
@Dominaezzz
Copy link
Owner

I'll try and also look into this but without a Mac it'll take me a while. It should just mean updating the Loader class for the macosMain sourceSet.

@nlbuescher
Copy link
Collaborator Author

nlbuescher commented Feb 10, 2020

This is actually documented behavior of GLFW on macOS (link)

Might be helpful to link to the GLFW FAQ in the README so issue reports like this don't happen again 😅

EDIT: Forgot to mention that I tested the instructions in the FAQ and they successfully create a 4.1 context (although my textures don't seem to load, but that's a different thing entirely because of the API differences)

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