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

Instructions of usage and setup #94

Open
Flecart opened this issue Sep 16, 2023 · 2 comments
Open

Instructions of usage and setup #94

Flecart opened this issue Sep 16, 2023 · 2 comments

Comments

@Flecart
Copy link

Flecart commented Sep 16, 2023

currently this repo is not clear nor informative on how to include and use it.

Things that I think should be specified:

  1. How to link openGL with the bindings?
  2. further usage examples

For example on point 1, I'm getting segment fault because probably the function pointers are undefined (point to 0).

@KnockerPulsar
Copy link

I agree that at least a basic example should be included to help new users since there isn't a ton of projects out there using zgl yet. I managed to brute-force my way to a bit of working code in a few hours. I'm using SDL but the code should be similar with whatever libarary you're using, it just needs a GetProcAddress counterpart:

pub const c = @cImport({
    @cInclude("SDL2/SDL.h");
});

const zgl = @import("zgl");

fn getProcAddressWrapper(comptime _: type, symbolName: [:0]const u8) ?*const anyopaque {
    return c.SDL_GL_GetProcAddress(symbolName);
}

fn init_opengl() {
  // Init SDL

  try zgl.loadExtensions(void, getProcAddressWrapper);
  
  // Use zgl with zig bindings or C-API bindings
}

This isn't the same exact code I use in my application, but it should get you going with zgl. Feel free to reply if something is not working correctly.

@Flecart
Copy link
Author

Flecart commented Oct 25, 2023

Hi @KnockerPulsar, at the end I was able to make it work using mach-glfw, you can see an example here: https://github.com/Flecart/zig-learnopengl/blob/main/src/chapter-1/1.2.zig#L41

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