Wiley.Games.on.Symbian.OS.A.Handbook.for.Mobile.Development.Apr.2008 (779888), страница 51
Текст из файла (страница 51)
Note that native Symbian OS C++ DLLs and EXEs will not supportlookup by name – this is specific to the new target types.Again, you’ll need to add runtime libraries on actual phones; to thisend, the Open C plug-in comes with four SIS packages for use onhardware as described in Table 7.2.Table 7.2 Open C SIS packagesPackageUIDInclusionNotespips s60 wp.sis0x20009A80MandatoryContains libc, libm,libdl and libpthreadopenc ssl.sis0x10281F35OptionalContains libcrypt,libcrypto, libssland libzopenc glib.sis0x10281F2COptionalContains libglibstdioserver.sis0x20009AA2OptionalSupports a console to beused only for testingWhen your game is built and ready to be deployed onto hardware,you embed the relevant SIS files into your own package, as shown below,and away you go.Notice that, while the SIS file is named differently to that supplied withP.I.P.S.
(pips_s60_1_1.sis), the UID remains the same.@"pips_s60_wp.sis", (0x20009A80)Open C has already met with some success, even though it was onlyreleased in January 2007. Oracle recently ported Berkley DB across to S60in less than 10 person-days, requiring changes to only about 1000 linesOPEN C223of code,1 and a quick browse through the discussion groups at ForumNokia shows that C programmers are already trying out a wide variety ofporting projects across many domains.
This isn’t really surprising whenyou consider that, for the first time, C programmers can now have avaluable part to play in the development of mobile applications andgames – particularly considering the huge volume of OpenGL ES librarieswritten in C out there, which can now run almost unchanged under S60!So the skills of all these game developers working on C can befocused – they can write or port AI libraries, graphics libraries, or evenservers for local clients, all very easily using Open C.
These are simplylinked against and used just like any other library. The advantages togame ports here should be obvious as this mixture allows each set ofexperts to do what they do best. However, a developer will still need tohave at least a nodding acquaintance with core Symbian OS conceptssuch as descriptors, leaves and the cleanup stack, and the Symbian OStool chain when working on the platform. This isn’t a particularly easylearning curve; it’s often by-passed as questions on the developer forumswould seem to indicate.2 More than one person has jumped straight inand lost days trying to port across software that uses sockets over WLANor GPRS without assigning the LocalServices or NetworkServicescapabilities in their MMP file.
Data caging seems to be another thingcausing issues, as developers attempt to access file system locations thatare protected and require certain capabilities.In addition, when it comes to porting games using Open C there aresome things that need to be kept in mind:• there are no UI libraries available to date• Open C doesn’t provide access to telephony, messaging, Bluetoothtechnology or location-based services, or other APIs specific to Symbian OS• as already mentioned, there is no support for signal, fork or exec,which is likely to be the biggest hurdle• Open C libraries are still subject to the platform security restrictions,so games will still need to be assigned the relevant capabilities wherethey are required• if you mix C and C++ code, you need to be careful to specify C APIsas such (using extern "C") or their names will get mangled by theC++ compiler1More information can be found at www.nokia.com/NOKIA COM 1/Developers/Success Stories/Enablers & infrastructure/Dev succ Oracle.pdf.2A good place to ask questions about Open C is on the discussion board at discussion.forum.nokia.com/forum.
The P.I.P.S. forum at developer.symbian.com/forum isanother good place to find information.224 C/C++ STANDARDS SUPPORT FOR GAMES DEVELOPERS ON SYMBIAN OS• while you can mix C code and Symbian OS C++ code, it’s a goodidea to keep this separate as much as possible because C does nothave any concept of leaves or the cleanup stack. Allocating memoryusing C functions and then calling functions that may leave is askingfor a memory leak (although you can use TCleanupItem for this,you’d have to ask why you’re coding in this manner in the first place)• Open C is called that for a reason – it doesn’t help porting overof C++ games or applications.
Currently, there’s no official STLimplementation.So the take home message here is that Open C allows C programmersto port applications and games onto S60, but you’ll more than likely needexpertise in both Symbian OS and the C programming language to effecta truly successful transition.Open C demonstrates Nokia’s continuing commitment to workingwith Symbian to keep the world’s leading smartphone platform as thebest of breed. By providing support for industry standards such as POSIXcompliance, we should see a large influx of game titles over the next yearor so as the potential of this technology is realized in the market.7.3 OpenKODEAs Aleks explained in Chapter 4, Symbian and Nokia are both membersof the Khronos Group (www.khronos.org) which is ‘‘a member-fundedindustry consortium focused on the creation of open standard, royaltyfree APIs to enable the authoring and accelerated playback of dynamicmedia on a wide variety of platforms and devices.’’Some of their more relevant standards for games include COLLADA (an XML based standard for content authoring), glFX (a visualeffects abstraction framework) and, of course, our current subjectOpenKODE.To quote directly from Khronos group’s presentation material,‘‘OpenKODE is a set of native APIs [that aims] to provide sourceportability.’’This initiative is specifically aimed at resource-constrained devicessuch as mobile phones.
The obvious driving force here is the proliferationof hardware platforms and operating systems in the mobile space, ofwhich Symbian OS is just one.Consumer demand and game development economics are pushingthe consolidation of standards in many areas. Enter OpenKODE, whichis actually comprised of a suite of other open standards managed by theKhronos Group along with definitions to tie it all together. It includes hardware acceleration requirements for the following four standard mediacentric APIs: OpenGL ES (OpenGL for embedded systems), OpenVGOPENKODE225(vector graphics), OpenMAX (streaming media portability) and OpenSLES (embedded audio).It’s often referred to as being just ‘like DirectX for mobile phones’ –except for the obvious caveats that it’s royalty-free, cross-platform,designed for handheld devices and is an open standard (so really it’sprobably more accurate to say that it’s not at all like Microsoft DirectX,other than the fact that they’re both media-related umbrella technologies).The main point about OpenKODE is that it defines two key features aspart of its standard.
First, it defines a set of APIs that serve as core operatingsystem abstractions, which is clearly necessary for cross-platform support.This includes the following:• core OS libraries based on the POSIX standard as far as possible• thread creation and synchronization• an event system with key OS abstractions (window resize, pause,quit, etc.)• mathematical functions – mainly standard C analogs• utility functions – assertions, logging, string conversion, memory allocation, random number generators (RNG) and so on.• C time function analogs and some more accurate OpenKODE-specifictime keeping functions for better accuracy, as well as event raisingtimers• a virtual file system based on C and POSIX file I/O• networking based on BSD (POSIX) sockets• cryptographic support• user input abstractions for key strokes (similar to the game keys usedin Java MIDP) and access to outputs in a standard manner• window support for multiple non-full screen windows, resize, minimizing, maximizing and so on.Secondly, OpenKODE defines in no uncertain terms exactly how awide variety of media APIs can interact with each other in a meaningfulway to allow the creation of media-rich content and advanced UIs formobile phone applications and games.
This is done using EGL 1.0 as akind of communication API; it is actually an abstraction of the underlyingoperating system. EGL is described later in section 7.7.At the time of writing, the current version of the OpenKODE standard isthe 1.0 Provisional Release, which contains OpenGL ES 1.1 and OpenVG.The first half of 2008 should see version 1.1 of the specification, whichwill also include the OpenSL ES and OpenMAX standard APIs.226 C/C++ STANDARDS SUPPORT FOR GAMES DEVELOPERS ON SYMBIAN OSAs game developers, you may be asking why you care, but the truthis that on small screen devices, hardware accelerated media can addup to dramatic power savings (of about an order of magnitude whencompared to software emulation).