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

add a tag to the sdl view on iphone #282

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

add a tag to the sdl view on iphone #282

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Labels
enhancement New feature or request invalid This doesn't seem right

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.0
Reported for operating system, platform: iOS (All), Other

Comments on the original bug report:

On 2010-05-01 05:52:00 +0000, Vittorio Giovara wrote:

it would be nice to have a way to get the pointer of the sdl generated view for various reasons, such as applying objc functions on it, modify its size at run time and so on.

the way i currently do this is by adding a tag to the sdl view and then use the viewWithTag method on the uiwindow.
my 'patch' consists of two lines of code added

  • adding a symbol in SDL_config_iphoneos.h like
    #define c 12345

  • add a tag in SDL_uikitopengles.m in UIKit_GL_CreateContext()
    view.tag = SDL_VIEW_TAG;

in this way we could call just
[[SDLUIKitDelegate sharedAppDelegate].uiwindow viewWithTag:SDL_VIEW_TAG]
to get the pointer to view and apply some nice objc api to it

would it be possible to include this feature in mainstream?

On 2010-07-16 19:31:13 +0000, Vittorio Giovara wrote:

Created attachment 519
patch that implements this feature

i'm submitting a patch that implements this feature;
note that even if the uiwindow cannot be retrieved from the appdelegate, it would be still possible to apply this method by calling

[[[UIApplication sharedApplication] keyWindow] viewWithTag:SDL_VIEW_TAG]

On 2011-01-20 00:01:55 +0000, Sam Lantinga wrote:

I'd actually rather expose the uiwindow through the "standard" cross-platform APIs in SDL_syswm.h

On 2011-01-20 01:03:07 +0000, Vittorio Giovara wrote:

well the uiwindow can always be fetched by [[UIApplication sharedApplication] keyWindow] which returns the topmost window of the application.

My feature request would be a method to fetch the uiview that contains the sdl context.

On 2011-01-20 09:47:30 +0000, Sam Lantinga wrote:

Can't you just grab the first view from that window?

On 2011-01-21 03:24:19 +0000, Vittorio Giovara wrote:

Not really, as the user might add/remove views from the uikit window and in that case the order is not predictable.
I reckon that adding a tag is not a very elegant solution and that this is not a 'standard use' by any means but it'd be nice to have more hooks to tinker with the library as much as possible.

On 2011-04-27 02:22:56 +0000, Vittorio Giovara wrote:

i found a way to avoid adding a tag to the sdl view just by doing

UIView *sdlView = nil;
for (UIView *oneView in [[[UIApplication sharedApplication] keyWindow] subviews])
    if ([oneView isMemberOfClass:[SDL_uikitopenglview class]]) {
        sdlView = (UIView *)oneView;
        break;
    }

so i would say that the bug can be marked as invalid as adding a tag is not a clean procedure at all, expecially for a library

On 2011-04-27 15:04:49 +0000, Sam Lantinga wrote:

Great, I'm glad you found a better way to do this. :)

It might be worth posting this trick on the mailing list if you haven't already.

@SDLBugzilla SDLBugzilla added enhancement New feature or request invalid This doesn't seem right labels Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant