sdl multiple view support

Member
Posts: 27
Joined: 2010.01
Post: #1
I'm I the only one that finds sdl's single window limitation annoying?

If I wanted to hack ah mod sdl to allow multiple windows support, does any one have any idea what's a good starting point.



The keyboard is handled here, this seems the obvious spot for our hook.

Code:
#if SDL_IPHONE_KEYBOARD

/* Is the iPhone virtual keyboard visible onscreen? */
- (BOOL)keyboardVisible {
return keyboardVisible;
}

/* Set ourselves up as a UITextFieldDelegate */
- (void)initializeKeyboard {




Obviously this needs to change too.

Code:
int UIKit_CreateWindow(_THIS, SDL_Window *window) {

/* We currently only handle single window applications on iPhone */
if (nil != [SDLUIKitDelegate sharedAppDelegate].window) {
SDL_SetError("Window already exists, no multi-window support.");
return -1;
}

/* ignore the size user requested, and make a fullscreen window */
UIWindow *uiwindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

if (SetupWindowData(_this, window, uiwindow, SDL_TRUE) < 0) {
[uiwindow release];
return -1;
}

// This saves the main window in the app delegate so event callbacks can do stuff on the window.
// This assumes a single window application design and needs to be fixed for multiple windows.
[SDLUIKitDelegate sharedAppDelegate].window = window;
[SDLUIKitDelegate sharedAppDelegate].uiwindow = uiwindow;
[uiwindow release]; /* release the window (the app delegate has retained it) */

return 1;

}


The question is why does sdl have this limitation.

I'm thinking if I try to use a navigation controller model or the like I will short circuit sdl's event handling.

But what about opening a uiwebView, to me that seems like it could be done with little damage.

I'm interested in hearing anyone's thoughts or ideas.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
Supporting multiple windows really isn't the sort of thing SDL is designed to do.

libsdl.org Wrote:Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.

Also, "multiple windows" doesn't make sense on the iPhone. Is there a reason you're trying to do whatever it is you're doing with SDL instead of going straight to UIKit?
Quote this message in a reply
Member
Posts: 27
Joined: 2010.01
Post: #3
ThemsAllTook Wrote:Supporting multiple windows really isn't the sort of thing SDL is designed to do.



Also, "multiple windows" doesn't make sense on the iPhone. Is there a reason you're trying to do whatever it is you're doing with SDL instead of going straight to UIKit?


I may of stated the intention wrong. sorry.

It is not easy to get to the uikit with sdl.

No nav views, no uiwebviews, no imagepickers, all you have a single opengl window full screen and sdl takes complete utter control over your applicationmain.

Posting on the sdl forum, you get hundreds of line of useless baber about how sdl is designed for portablity and there are 3rd party libraries you can use.

But my point is simple, if I am using SDL and I want to display an imagepicker or a tableview I should not have to go off to some linux style 3rd party library.

Maybe I am alone on this, but if thats the case porting straight to the sdk and opengles makes a lot more sense.
Quote this message in a reply
Member
Posts: 27
Joined: 2010.01
Post: #4
notice this phrase.

Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.

library implies a usable collection of methods that let you perform the function, not a library that thinks its an enviroment and literally takes over the runloop.

On the other hand , it is fairly easy to port a linux app to the iphone. ie. some video apps.

Fine but than what can you do, without a lot of effort you can't pass data to it, it can't interact with its environment except for the few states the library support. Come on that may fly on other platforms linux, xbox, nes but really is any iphone developer going to embrace that.

I set up a thread on the official forum for suggestions how we can provide some hooks to normal sdk functions, like gps etc. only get tons of stuff back from fanboys how that would break with the philosophy behind the environment. this girl doesn't care about design philosophy , I just want a product that actually has some potential for sale.

In its current state SDL is DOA.
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #5
michelleC Wrote:In its current state SDL is DOA.

Well, certainly if it is fighting with you about what you're trying to accomplish on iPhone, then yes, I'd say you should go your own way. It's not hard to set up the environment on iPhone anyway. As much as I like what SDL has to offer, I personally see no benefit to using it on iPhone.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #6
I don't really see the benefit of it on the iPhone either. It's really not well suited to the iPhone's inputs, and it doesn't have much else to offer that makes it useful like it is on the desktop.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 27
Joined: 2010.01
Post: #7
Skorche Wrote:I don't really see the benefit of it on the iPhone either. It's really not well suited to the iPhone's inputs, and it doesn't have much else to offer that makes it useful like it is on the desktop.

came up with an iphone specfic solution, Not sure if there is a way to make it generic.

The iphone actually DOES let you create multiple windows, there are a few apps I know of in the app store that take advantage of this fact but not sdl, there are one or two apps that would like to get appstore approval that use this fact to display tv out, ie. display an image on the screen with overlays and everything but another to the tv out cable. Alas, they use undocumented api's so the authors just have to sit an wait.

But the the fact that the iphone can have several uiwindows but can only have one window as keywindow is an advantage.

You can create the sdl window and the coaca window, complete with tabbars , navigation anything you want . You have to do some notifications and set some keys to try to make it generic but basically each window just takes turns becoming the key window.

There is a game api that uses a similar method,UNITY what it does it when it launches it shows the users a menu system, after the user does the initial setup and is ready to play the game the menu relinquishes control to Unity . When the player is within the unity system and decides to return to the menu system clicking a button sends a notification and sets a key . The notification is handled and the menu frontend once again becomes the key window.

My solution is quite similar to this, but SDL is not quite the black box Unity is, so I have more control over when to swap windows.
Quote this message in a reply
Member
Posts: 27
Joined: 2010.01
Post: #8
of course once you have your windows created you can do cool things, like interate through the windows and views adding overlays etc.

look at apple's movie player sample code for an example of what I am talking about that.

I don't see any reason to have to go to any third parties linux api's , there may be good reason. but I don't see any right now.
Quote this message in a reply
Member
Posts: 27
Joined: 2010.01
Post: #9
Ok so its not much to look at, but I'll be expanding on this in the next few days and
publish the complete proof of concept with all the demos on the tabbar.

http://web.me.com/cannonwc/Site/Photos_7.html#grid
Quote this message in a reply
Member
Posts: 27
Joined: 2010.01
Post: #10
And as promised here is the POC.

[http://sol3.typepad.com/tagalong_develop...isted.html
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #11
I still don't really understand why you'd want to do this. Using SDL on the iPhone really only saves you a couple hundred lines of code that you can grab from the OpenGL template. I especially don't understand it when you are trying so hard to work around SDL's shortcomings.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 27
Joined: 2010.01
Post: #12
Skorche Wrote:I still don't really understand why you'd want to do this. Using SDL on the iPhone really only saves you a couple hundred lines of code that you can grab from the OpenGL template. I especially don't understand it when you are trying so hard to work around SDL's shortcomings.

We are porting programs already written in sdl.

Aside from that in theory we should be able to take the code and run it on an Android device.

And giving developers one more option doesn't hurt, I don't see much of a performance lost or gain either way.
Quote this message in a reply
Member
Posts: 27
Joined: 2010.01
Post: #13
Skorche Wrote:I still don't really understand why you'd want to do this. Using SDL on the iPhone really only saves you a couple hundred lines of code that you can grab from the OpenGL template. I especially don't understand it when you are trying so hard to work around SDL's shortcomings.

to put this is a little more perspective.

Lets say I wanted to model for a game for instance the effects of time dialation as you approach the outer event horizon of a Schwarzschild blackhole.

I could start by building the code from stratch. But its well possible something like this already exists on another system , maybe linux based.

If its written in SDL than in theory I should be able to take the SDL code and move it to the iphone. Only taking into account the differences in some of the methods for that particular environment. (most common sdl methods get mapped to audio, video and pthreads just fine).

My problem with SDL was its lack of direct support of the iphone ui, but it turns out that the problem is only in how the library is packaged. They tried to hide the entire implementation. Once I got around that it wasn't an issue.

Anyway, Now I should be able to take this simulation and again with only marginal changes move it to a supported platform android (sdl 1.2, almost works ok), psp , xbox etc..

trades time for a slight decrease in performance, sometimes made up by optimizing the code.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Logic Based Multiple View Game sum2cubes 1 2,844 Jul 2, 2009 08:30 AM
Last Post: bruss14
  Tutorial on Multiple View swapping? dragagon 1 5,515 Oct 28, 2008 12:03 PM
Last Post: dragagon