cosmoharrigan / rl-glue

Automatically exported from code.google.com/p/rl-glue
0 stars 0 forks source link

RL-glue defining its own main function in the C codec #96

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

Sorry about classifying this as a defect. I wanted to label it as an
enhancement suggestion, but didn't see how.

The issue is RL-glue defining the main method. This can sometimes cause
issues when developers want to combine existing applications with RL-glue.
The problem I had was when I wanted to make an RL-glue domain out of the
game megamario. Megamario uses SDL, which is very insistent on being run in
the application's primary thread. I have no idea why this is, but if it
isn't, things bomb out immediately.

When I used RL-glue 2.0 to do this, I had to rename main to glue_main, and
in my own method, spawn a thread to run glue_main. Then the primary thread
is able to do whatever SDL needs it for.

Another reason to do this is exception catching. I like to put a try/catch
around the contents of my main method, so when my code throws an exception,
I can catch it, see its type, and identify where it happened easily by
examining the stack.

So, the change required to "fix" this is simple, rename main to glue_main.
Obviously, it's not so simple to implement this, because it would break
every existing RL-glue library out there. But adding a simple main function
that immediately calls glue_main is not an unreasonable burden to place on
the developer, and doing this with the new version of RL-glue would catch
it at a time when people might be rewriting some code anyway.

Thanks!

- John Asmuth, Rutgers University, RL^3

Original issue reported on code.google.com by jasm...@gmail.com on 3 Oct 2008 at 2:05

GoogleCodeExporter commented 9 years ago
After some conversation about this on the mailing list, I think we've come (I've
pushed) a concensus that a customized codec can be integrated with these sorts 
of
projects.  

See the section in the C-Codec Manual called: Customize the Codec for Flexible
Integration:
http://rl-glue-ext.googlecode.com/svn/trunk/projects/codecs/C/docs/html/C-Codec.
html#SECTION00082000000000000000

I've even included an example :)

Original comment by brian.ta...@gmail.com on 6 Oct 2008 at 5:41