FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Derelict on Mac OS X - another solution
Goto page Previous  1, 2, 3, 4, 5, 6
 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Thu Nov 13, 2008 6:30 pm    Post subject: Reply with quote

The special initialization for Mac that was recently checked in is, unfortunately, not yet handled automatically. You need to handle it explicitly. Modify your code to look like this (based on a sample doob gave me):


Code:

module sdltest;

import tango.io.Stdout;
import derelict.sdl.sdl;

import derelict.sdl.macinit.SDLMain;

void main()
{
   macInit(1, ["main".ptr]);

   DerelictSDL.load();
   
   if (SDL_Init(SDL_INIT_VIDEO) < 0)
   {
      Stdout("error: SDL_Init").newline;
       
      return;
   }

   if (pool)
       pool.release;
   
    if (sdlMain)
       sdlMain.release;
}



This is a hack for now. I want to automate it so that it's handled from within DerelictSDL.load, but it will require some changes in doob's code. Without a Mac for me to test on, it makes the code-test cycle a bit cumbersome as I need to rely on others to test it (unless, of course, someone with a Mac wants to volunteer). I hope it will be taken care of in the near future. I'll be sure to post an announcement here when it is so that you can drop the hack and go back to the original version of your code.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Fri Nov 14, 2008 5:59 am    Post subject: Reply with quote

"macInit" should take the arguments that is recived as the arguments to "main", c style. I don't know how to do this automatically without hijacking the "main" function, perhaps there are API functions to get the argumetns. I guess that the calls to the release functions can be moved to "DerelictSDL.unload" or something like that.

Please let me know if there is something specific I can do or test to help out.
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Fri Nov 14, 2008 7:45 am    Post subject: Reply with quote

doob wrote:
"macInit" should take the arguments that is recived as the arguments to "main", c style. I don't know how to do this automatically without hijacking the "main" function, perhaps there are API functions to get the argumetns.


Realistically, I don't see that the command line is necessary at all. It's not used by any of the Cocoa initialization, that I can see. The only use that's made of it is in the 'application' function, where the filenames of double-clicked or dragged-&-dropped documents are appended. This is a convenience, only.

For now, that can all be removed, hence removing the dependency on passing a command line arg at all. Then things should just work without any intervention from the client.. However, if someone wants support for dragged-&-dropped or double-clicked files in the future, that can easily be added in with a special global.

Quote:
I guess that the calls to the release functions can be moved to "DerelictSDL.unload" or something like that.


Absolutely. Should be the last thing that happens. As such, the sdlMain and pool variables should be private to the SDLMain module.

Quote:
Please let me know if there is something specific I can do or test to help out.


I'm going to give a shot at removing the uneeded cruft. But I can't test it. So if you don't mind, once I've got something I think should work, I'll hand it off to you for testing. Then if anything's broken, you can tweak it until it works as it should.

Sound OK to you?
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Fri Nov 14, 2008 9:03 am    Post subject: Reply with quote

Yeah sounds good.
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Fri Nov 14, 2008 6:52 pm    Post subject: Reply with quote

For the benefit of anyone following this thread, we've made some progress. Cleanup is now handled automatically, so you don't need to make calls to sdlMain.release or pool.release in your own code. And while macinit no longer accepts any arguments (so you don't have to pass it a command line), you still need to call it manually. There were some errors when calling it from DerelictSDL.load. Hopefully, we'll be able to get around that shortly.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Sat Nov 15, 2008 6:54 am    Post subject: Reply with quote

I've fixed the problem now, everything is handle automatically. No need to call any extra mac specific functions.
Back to top
View user's profile Send private message
michael



Joined: 23 Aug 2006
Posts: 13

PostPosted: Sat Nov 15, 2008 11:03 am    Post subject: Reply with quote

Just wanted to say that it's working fine here now without the mac specific stuff.

Thank you guys for the nice work!

~Michael
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4, 5, 6
Page 6 of 6

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group