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

Vulkan compatibility #81

Open
jclc opened this issue May 3, 2019 · 4 comments
Open

Vulkan compatibility #81

jclc opened this issue May 3, 2019 · 4 comments

Comments

@jclc
Copy link

jclc commented May 3, 2019

It would make sense for this library to support both OpenGL and Vulkan coordinate systems. One difference that comes to mind is that screen coordinates in Vulkan range from 0 to 1 instead of -1 to 1 like in OpenGL.

@UserAB1236872
Copy link
Member

This is a bit tricky, not in execution but in design. Unfortunately, since Go doesn't have optional arguments or overloading, we can't make a version of each method where you can specify coordinate ranges without breaking compatibility.

To give context, this library was initially created when I was trying to follow some OpenGL tutorials in Go, and needed a math library. Vulkan hadn't even been announced yet IIRC (at the very least, it hadn't been released), so it's not a surprise it's not compatible.

I'm not hostile to the idea, but I'm not sure what a satisfying solution is. One is to add two new targets to the generation: mgl32_vk and mgl64_vk (mvk32/64?). The other is to add a matching method for each function that uses coordinates with a VK suffix, or at least a coordinate-agnostic one that lets you pass in your min/max (as well as testing to make sure a min of 0 doesn't divide by zero or something). I see drawbacks to both approaches.

@jclc
Copy link
Author

jclc commented May 10, 2019

As far as I know, only the screen coordinates are different in Vulkan. Texture coordinates are also flipped to be more in like with Direct3D, but that's unrelated to mathgl. All other functionality should be identical. I'll fork the library and make a pull request once I iron out the details.

@galsjel
Copy link

galsjel commented Oct 24, 2020

What about naming schemes like matrix_gl.go and matrix_vk.go with build constraints as described here?

https://golang.org/pkg/go/build/#hdr-Build_Constraints
https://stackoverflow.com/questions/36703867/golang-preprocessor-like-c-style-compile-switch

Then you could build the library specifically for Vulkan adding the -tag to the go build command with something like MGL_VK.

@jclc
Copy link
Author

jclc commented Oct 24, 2020

Hi, since making this issue, I've personally come to the conclusion that adding separate Vulkan functions isn't worth the effort when you can just multiply your transform matrix so that the coordinates match. For example, I'm transforming my matrices on every frame to change my game's coordinates to use Blender's coordinates and adding a matrix on top of that to change from GL coordinates to Vulkan coordinates doesn't cost anything.

At the very least having to build the whole library with a build tag just for that sounds like a bad idea, to be honest.

I'll leave the issue open in case the maintainers still want to consider this, but personally I don't think it's something this library really needs.

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

3 participants