g3n / g3nd

G3N Game Engine Demo
BSD 2-Clause "Simplified" License
279 stars 32 forks source link

Runtime panic on OS X complaining about OpenGL version #7

Closed dobegor closed 6 years ago

dobegor commented 7 years ago
$ hellog3n
panic: VersionUnavailable: NSGL: The targeted version of OS X only supports forward-compatible contexts for OpenGL 3.2 and above

OS X supports opengl 4.1 at least. Could you please help me with fixing this problem? I'll also provide a PR fixing build with OpenAL and Vorbis a bit later, I'm still fixing it.

If you are willing to test the engine on OS X, I may help you.

leonsal commented 7 years ago

Unfortunately we don't have an OS X machine for testing, but we can give you some hints on where to search for problems. G3N engine currently uses two external Go package dependencies for OpenGL access: glfw and go-gl.

GLFW is responsible for creating and managing an OpenGL window and GL is a Go binding to OpenGL C functions. The problem reported seems to be returned by GLFW when G3N tries to create a window. When the G3N engine creates a window using GLFW it specifically requests an OpenGL context for version 3.3 and Core profile You can try to change HERE these parameters to other values. You can also try to run a minimum GLFW test program which is presented in the project page.

dobegor commented 7 years ago

Yeah, after some searches I've found that calling glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE) right after initialization to flag that forward compatibility is in effect fixes the issue.

However, there are some other places where engine is currently crashing on OS X, and I'll look further this month to fix them and submit a patch.

I truly believe this engine may have a great potential to become a fully-featured cross-platform game engine with ability to code it in Go. Perhaps, it's worth to set up a website / some kind of roadmap / community. Maybe, start with a channel in gophers Slack?

Thanks.

danaugrs commented 6 years ago

The engine macOS issues were addressed by https://github.com/g3n/engine/commit/1929d6070113634d2d0ac653b6c3bcf67bf4033a. @dobegor Do you see any remaining macOS issues with g3nd?

dobegor commented 6 years ago

@danaugrs yes, there are still issues with current version. This is how it looks right after launch: screen1

Moving the window helps. This is because for defining viewport one should use framebuffer size instead of a window size as I mentioned in pull request.

But the demos are rendered a bit off for me: http://jmp.sh/2EM1X2f Perhaps, due to the same viewport/framebuffer size stuff.

dobegor commented 6 years ago

BTW, audio works beautifully on macOS and I honestly don't know how I did it. We'll probably try later to build openal and vorbis statically into the binaries so that end user won't need to install anything.

dobegor commented 6 years ago

Now it's good except scaling issues on hidpi screens. I'll close this one and open a new in the engine repo.

danaugrs commented 6 years ago

The correct macOS linker paths for the audio libraries were suggested in https://github.com/g3n/engine/pull/35 and added in https://github.com/g3n/engine/commit/1929d6070113634d2d0ac653b6c3bcf67bf4033a so that's probably why the audio is working for you 😉.

The issue in the GIF where the 3D portion of the screen is clipped to the "small" version is due to the scissor test using the exact panel3D coordinates and size here: https://github.com/g3n/engine/blob/master/renderer/renderer.go#L339

If you apply the scaling there it should resolve it.

dobegor commented 6 years ago

@danaugrs updated screenshot: img

the 3d portion (the demo itself) is scaled OK, the gui is small

danaugrs commented 6 years ago

Oh I see - the GIF was taken before https://github.com/g3n/engine/pull/39 was merged and the merge resolved it. Nice!