#Load OpenGL with ZGL and SDL.Zig

1 messages · Page 1 of 1 (latest)

vale torrent
#

I'm trying to use ZGL + SDL.Zig to run OpenGL, but I can't seem to load OpenGL correctly. The ZGL function to load OpenGl is zgl.loadExtensions. However this function requires a function that takes in 'fn(gl.Context, [:0]const u8) ?*const anyopaque', but the SDL get proc address function only takes in 'fn([:0]const u8) ?*const anyopaque'. How can I get the function that takes in the correct number of parameters?

umbral frigate
#

You declare a new function with the correct signature that forwards the call to getProcAddress?

loadExtensions is defined like this:
https://github.com/ziglibs/zgl/blob/a52715ea11cc435ad4598369d3fd2ae1e4570c3d/zgl.zig#L2640-L2642

It calls binding.load, which in turn is implemented like this:
https://github.com/ziglibs/zgl/blob/a52715ea11cc435ad4598369d3fd2ae1e4570c3d/binding.zig#L4033-L4040

So looking at how those work, you want to declare a function like fn (ctx: T, name: [:0]const u8) where T can be literally anything you want, then call loadExtensions passing a value of type T as the first parameter and your custom loader function as the second.

vale torrent
#

thank you