SDL on IOS with input and rendering on seperate threads

Anyone any idea how to solve this?------------------------
Ronimo Games, Awesomenauts, Proun, Swords & Soldiers, De Blob

You can always handle input on its own thread. SDL’s event queue is, quite literally, a thread-safe queue of "SDL_Event"s. However, on most systems (Windows included), SDL must fill this event queue from the main thread.

So, if this concurrency is demanded by the unique needs of your application, what you will need to do is to reverse the way you have the program split up: render on the main thread, handle events in a new thread. However, you will want to actually call SDL_PumpEvents() from your main thread loop.------------------------
Nate Fries

Hi Oogst,

I believe there already have been several answers to this. Simply put most people suggest

  1. Keep the rendering on the main thread
  2. Call SDL_PumpEvents on the main thread as well
  3. SDL_PollEvent on the input thread

If this does not work, then you have to do what I have done, which is to also call SDL_PollEvent on the main thread as well, and put it into a thread safe data structure, that you can then read from your input thread. As I have later discovered, this should not be necessary, as the SDL_event queue is already thread safe.On Thursday, March 14, 2013 at 8:29 AM, Oogst wrote:

Anyone any idea how to solve this?

Ronimo Games, Awesomenauts, Proun, Swords & Soldiers, De Blob


SDL mailing list
SDL at lists.libsdl.org (mailto:SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

The main question here is whether it is possible to switch the OpenGL context on iOS to another thread. This works fine on other platforms: our engine already runs fine in the current structure on PC/Mac/Linux using SDL, so this question is specific to the iOS implementation of SDL. Can SDL_GL_MakeCurrent() be used on iOS, and if so, how?

gormlai wrote:


I believe there already have been several answers to this.

I couldn’t find any other topics about this, maybe I am searching with the wrong keywords? Do you have links to those other discussions?------------------------
Ronimo Games, Awesomenauts, Proun, Swords & Soldiers, De Blob

Aha, sorry, I did not get your topic from the question. My experience with running OpenGL multi-threaded is that it performs badly on OSX. For iOS no idea.On Friday, March 15, 2013 at 11:06 AM, Oogst wrote:

The main question here is whether it is possible to switch the OpenGL context on iOS to another thread. This works fine on other platforms: our engine already runs fine in the current structure on PC/Mac/Linux using SDL, so this question is specific to the iOS implementation of SDL. Can SDL_GL_MakeCurrent() be used on iOS, and if so, how?

gormlai wrote:

I believe there already have been several answers to this.

I couldn’t find any other topics about this, maybe I am searching with the wrong keywords? Do you have links to those other discussions?

Ronimo Games, Awesomenauts, Proun, Swords & Soldiers, De Blob


SDL mailing list
SDL at lists.libsdl.org (mailto:SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

threads
Message-ID: <1363345570.m2f.36069 at forums.libsdl.org>
Content-Type: text/plain; charset=“iso-8859-1”

The main question here is whether it is possible to switch the OpenGL
context on iOS to another thread. This works fine on other platforms: our
engine already runs fine in the current structure on PC/Mac/Linux using SDL,
so this question is specific to the iOS implementation of SDL. Can
SDL_GL_MakeCurrent() be used on iOS, and if so, how?

gormlai wrote:


I believe there already have been several answers to this.

I couldn’t find any other topics about this, maybe I am searching with the
wrong keywords? Do you have links to those other discussions?

The answer to your question has nothing to do with SDL, and everything
to do with iOS. As I best recall, the last time that I looked this up,
Mac OS would only execute graphics operations on the main thread
(which involved pausing the caller thread, and waiting for a chance to
tell the main thread to do the job), and iOS simply didn’t support it
at all. You want to look up the documentation for iOS, that’s where
you’ll find this information.

You should understand that most graphics code supposedly goes through
a single-threaded driver stage at some point or another, so unless
you’re doing software rendering (in which case your graphics calls
degrade to just “display this image”) having multiple graphics threads
will do little good, and may even reduce your framerate. Thus, the
only REAL question multi-threaded graphical programs is “which thread
is the right thread to render in?”. The only thread that you can
more-or-less count on supporting graphics system calls is the thread
that’s running when your program first starts, so that’s the thread
that you should ALWAYS do your graphics calls from.

Every single time, regardless of OS.

That having been said, if you’re fine with writing a glue layer, then
there’s nothing to stop you from transferring graphics calls from your
rendering thread to the initial thread with a custom library. You
could even use SDL’s event queue and user-defined events for the
actual transfer stage, if you wanted to.> Date: Fri, 15 Mar 2013 04:06:11 -0700

From: “Oogst”
To: sdl at lists.libsdl.org
Subject: Re: [SDL] SDL on IOS with input and rendering on seperate

Oogst wrote:

The main question here is whether it is possible to switch the OpenGL context on iOS to another thread. This works fine on other platforms: our engine already runs fine in the current structure on PC/Mac/Linux using SDL, so this question is specific to the iOS implementation of SDL. Can SDL_GL_MakeCurrent() be used on iOS, and if so, how?

Has to be on the main thread.
Actually, I was under the impression that OS X had this limitation too, but apparently I remember the documentation incorrectly.------------------------
Nate Fries