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

SDL_GetWindowWMInfo is inaccessible (again?) #744

Closed
acmcarther opened this issue Jan 19, 2018 · 6 comments
Closed

SDL_GetWindowWMInfo is inaccessible (again?) #744

acmcarther opened this issue Jan 19, 2018 · 6 comments
Labels

Comments

@acmcarther
Copy link

I'm attempting to hook together vk-sys and a window produced by this library from scratch. For lack of the newest SDL2 vulkan features, which has these methods:

SDL_Vulkan_LoadLibrary()
SDL_Vulkan_GetVkGetInstanceProcAddr()
SDL_Vulkan_GetInstanceExtensions()
SDL_Vulkan_CreateSurface()
SDL_Vulkan_GetDrawableSize()
SDL_Vulkan_UnloadLibrary()

I went the route of trying to get the raw platform-specific window from the SDL_Window object. To do this, you need the method SDL_GetWindowWMInfo, but it appears to have briefly popped into existence in rust-sdl2 (7623bd5) before popping back out of existence when bindgen usage started.

Is there a mechanism I'm missing to access SDL_GetWindowWMInfo? I sort-of suspect that these might just be getting missed during the bindgen pass since they live in separate header files, but I'm not well informed about bindgen.

@Cobrand
Copy link
Member

Cobrand commented Jan 19, 2018

Woops, that was not expected. I don't understand how every C function was generated by bindgen, but not this one... It would help to know when SDL_GetWindowWMInfo was added so that we can pinpoint why GetWindowWM was not in the included headers in sdl2-sys.

@Cobrand Cobrand added the bug label Jan 19, 2018
@acmcarther
Copy link
Author

In that case, I'll take a look and see if I can understand how bindgen is locating these.

From this git blame of a mirror of the repository, it seems to be a pretty old function from the SDL1 days: https://github.com/spurious/SDL-mirror/blame/master/include/SDL_syswm.h#L312.

@Cobrand
Copy link
Member

Cobrand commented Jan 19, 2018 via email

@acmcarther
Copy link
Author

I believe this was an issue on my end. I'm now performing the bindgen manually on my SDL includes, using nearly the same wrapper.h as in the repo:

#include "SDL.h"
#include "SDL_syswm.h"
// Might as well bring in vulkan while I'm at it.
#include "SDL_vulkan.h"

I'm not using cargo, so the process is roughly:

1) Pass the bespoke wrapper.h to bindgen 
(with the SDL2 includes near enough by to be #included)
2) Generate a surrogate sdl2-sys crate using that new .rs file
3) Replace all sdl2-sys deps globally with the surrogate crate

As a side note, this required an additional flag to bindgen: --rustified-enum ".*", as there was a breaking change in bindgen-0.31.0 that changes enums from being "rust like", into being simple constants. See the patch notes for full details. Upgrading this crate without using the back-compat flag is something I'm not well equipped to understand the implications of, but it probably needs to get done at some point.

@Cobrand
Copy link
Member

Cobrand commented Jan 23, 2018

Since those two header files are going to be needed by other people as well, we could maybe add the option to add them a features in sdl2-sys. e.g. feature "include-syswm" adds the SDL_syswm.h header in bindgen, and another feature for vulkan as well...

The question is: are those functions included in SDL but "hidden" from the headers, or do you have to build a custom fork of SDL2, or even link another dynamic library, ...?

@acmcarther
Copy link
Author

I don't believe these functions are hidden -- I think I was performing bindgen incorrectly when trying to use the default sdl2-sys. The existing file includes "<SDL_syswm>", so it should be good to go. That said, it would probably be a good idea to regenerate the pre-generated bindings, as they appear at first glance to have been generated from a wrapper.h that did not include <SDL_syswm>. I can try to do this and submit a PR here but my environment is super weird so I'd be relying on the CI to catch anything anomalous.

In any case, it so happens that I am building a custom fork of SDL2, but I don't believe it was related to the issue at hand.

@Cobrand Cobrand closed this as completed in 3e22653 Jul 8, 2018
sypwex pushed a commit to sypwex/rust-sdl2 that referenced this issue Jun 2, 2024
Closes Rust-SDL2#744

Defines were not set correctly as target matching was wrong.
Removed hide_type deprecated binding builder method use, in favor of
blacklist_type.
Added rustified_enum call, since newer bindgen versions will make
constants instead of enums breaking the sdl2-sys crate.

Bindings were regenerated using the following command:
cargo build --features bindgen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants