We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 996 - add a tag to the sdl view on iphone
Summary: add a tag to the sdl view on iphone
Status: RESOLVED INVALID
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: Other iOS (All)
: P2 enhancement
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-01 05:52 UTC by Vittorio Giovara
Modified: 2011-04-27 15:04 UTC (History)
0 users

See Also:


Attachments
patch that implements this feature (850 bytes, patch)
2010-07-16 19:31 UTC, Vittorio Giovara
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vittorio Giovara 2010-05-01 05:52:00 UTC
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?
Comment 1 Vittorio Giovara 2010-07-16 19:31:13 UTC
Created attachment 519 [details]
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]
Comment 2 Sam Lantinga 2011-01-20 00:01:55 UTC
I'd actually rather expose the uiwindow through the "standard" cross-platform APIs in SDL_syswm.h
Comment 3 Vittorio Giovara 2011-01-20 01:03:07 UTC
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.
Comment 4 Sam Lantinga 2011-01-20 09:47:30 UTC
Can't you just grab the first view from that window?
Comment 5 Vittorio Giovara 2011-01-21 03:24:19 UTC
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.
Comment 6 Vittorio Giovara 2011-04-27 02:22:56 UTC
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
Comment 7 Sam Lantinga 2011-04-27 15:04:49 UTC
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.