Skip to content

Is it possible to pass ProcAddress into a ktx library? #33

@Logickin-Lambda

Description

@Logickin-Lambda

I am currently trying to figure out how to use ktx library provided by the KhronosGroup, and seem I have faced an issue on initialize the library.

The library is written in C, so I have used a C import:

const c = @cImport({
    @cInclude("ktx.h");
});

To build the project, I have pointed the header file in in build.zig as shown:

exe.addIncludePath(.{ .cwd_relative = "C:\\Program Files\\KTX-Software\\include" });

In the official documentation, before running any the load function, I need to run function ktxLoadOpenGL( PFNGLGETPROCADDRESS pfnGLGetProcAddress) to initialize the library before using the load function, and seems that the input parameter PFNGLGETPROCADDRESS pfnGLGetProcAddress is a kind of GLGetProcAddress function. For that reason, I decided to past the function glfw.getProcAddress because this is the only function with the same name.

However, this function is not matched to the input of ktxLoadOpenGL because the following error:

error: expected type 
  '*const fn ([*c]const u8) callconv(.c) ?*const fn () callconv(.c) void', 
found 
  '*const fn ([*:0]const u8) callconv(.c) ?*const anyopaque'

Seems like the ktx library accepts a precise return type instead of anyopaque, so here are the questions:

  • Did I pass the wrong ProcAddress into the KTX library?
  • If so, what is the equivalent? If not, is there a way to convert the return type such that I can initialize the function?
  • Have you worked on KTX texture with zig before? If you did, I wish to see if you could have some better ideas on handling those textures.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions