Jump to content
  • entries
    941
  • comments
    5,894
  • views
    866,359

Leadwerks on the iPhone


Josh

3,181 views

 Share

So here's what it took to get Leadwerks running on the iPhone:

 

Let's start at the point we had the C++ code building and running with an OpenGL 1 renderer on OSX. I was worried OpenGLES might be a dramatically different API that required a whole new learning curve, but I was pleasantly surprised. It's just a stripped-down version of OpenGL, more like OpenGL 3.3 than anything else. Making the OpenGL2ES renderer was mostly just a copy and paste operation, and then I had to comment out a few unsupported commands.

 

Building for the iPhone simulator was a bit harder. The first problem I ran into was that file paths on iOS are case-sensitive. (They aren't on OSX.) This was problematic, because my asset management code stored file paths in lowercase, so that had to be changed.

 

Then there was the matter of setting the application's file path. A special function had to be written to set this at application startup.

 

The hardest part was the context handling. The flow of an iOS app all revolves around Objective-C events, and this doesn't mix well with a C++ program. What I ended up doing was creating an App class like this:

class App {
public:
bool Start();
bool Continue();
int Finish();
};

Objective-C calls these class functions to keep the program loop running. Once the Continue() function returns false, the application calls Finish() and exits.

 

I'm okay with using this same design across all platforms, if it means your C++ code will run on everything. of course, this is just a convention in the generated project files, and if you want you can code the engine with any program structure you want. This is just the best way to ensure your code runs on everything.

 

The last challenge was setting up the provisioning profiles, certificate, and some other stuff I don't even remember. This was pretty tricky, and took most of the day to figure out. In the end, I just ran through the instructions a second time, and it magically worked. :)

 

At the end of all that, it was nice to see Leadwerks running on the iPhone. iOS was the hardest platform to add support for, and I don't expect the same difficulty when we add support for Android:

 

Thanks to Ed Upton and Simon Armstrong for their help and advice.

 Share

11 Comments


Recommended Comments

Guest Red Ocktober

Posted

super impressive!!! can't wait...

 

and as far as the code design.. the approach is similar to the object oriented gameobjects thing i did for Leadwerks and MiniB3d...

 

i have absolutely no problem with it...

 

--Mike

Link to comment
Oh my Oh my.... Besides buying a MAC I now must by a IPhone ;)
Don't forget the iPad. ;)

 

The only reason I do not already own a Mac and an iPad is because Leadwerks 3 is not out yet. Can you imagine?

Link to comment

I'm not allowed to use my Mac anymore, the kids took it over to play World of Warcraft :/

 

I too had a heck of a time sorting out the provisioning on the device and getting the certificate accepted. I aim to put together a simple 3rd person on-rails tank shooter for LE3 mobile, have the assets ready to roll out for that one. Little bit more complex than a spinning cube. I put together a little test in Unity that allows you to change play styles (weapon mode) by changing the screen orientation, hopefully this event will be available to LE3 but it's not a big deal.

 

A cool thing to do with your cube is to get some audio sampling done and blow to spin it.

Link to comment

It's a challenge to handle user input on mobile devices, because they are so different from a computer. The iPhone version considers screen touches to be mouse hits and movements, so by default you get a reasonably consistent control scheme. Of course, on a PC you can move the mouse position, and on a touch device you cannot forcibly move the user's finger to a given position (yet ;)).

 

I found an event queue was necessary for more advanced input like screen rotation and multitouch input, so if you need to get that info, the events are available to you.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...