Marmalade SDK Bitesize Tutorial – How to Determine Device Operating System

Just though that I would sneak this quick bite sized tutorial in whilst taking a breather from documenting IwGame. Tell you something, I never realised just what a big beast IwGame has become.

Ok, I’m going to quickly cover how to determine which device operating system we are running on using the Marmalade SDK.

The Marmalade SDK has two neat little functions called s3eDeviceGetInt(s3eDeviceProperty property) and s3eDeviceGetString(s3eDeviceProperty property) which allow us to query details about the device that we are running our apps on. As the names suggest, one returns an integer value, whilst the other returns a human readable string value.

Using the property parameter you can query all sorts of things such as:

  • Device operating system (S3E_DEVICE_OS)
  • Device phone number (S3E_DEVICE_PHONE_NUMBER)
  • Device language (S3E_DEVICE_LANGUAGE)
  • Battery level (S3E_DEVICE_BATTERY_LEVEL)
  • Operating system version (S3E_DEVICE_OS_VERSION)
  • Floating point unit support (S3E_DEVICE_FPU)
  • Language- country code pair, e.g. en-us (S3E_DEVICE_LOCALE)

And all sorts of other useful info. Check 3seDevice.h for a comprehensive list of all properties that you can retrieve.

To find out which operating system you are running on you call:

int os = s3eDeviceGetInt(S3E_DEVICE_OS);

You can then test for which OS is running using a simple switch statement like this:

switch (os) { case S3E_OS_ID_SYMBIAN: break; case S3E_OS_ID_WINMOBILE: break; case S3E_OS_ID_WINCE: break; case S3E_OS_ID_QNX: break; case S3E_OS_ID_BADA: break; case S3E_OS_ID_ANDROID: break; case S3E_OS_ID_IPHONE: break; case S3E_OS_ID_WEBOS: break; case S3E_OS_ID_WINDOWS: break; case S3E_OS_ID_LINUX: break; case S3E_OS_ID_OSX: break; }

Marmalade SDK Bitesize Tutorial – How to force a CIw2DImage texture to upload

Welcome to another bite size Marmalade SDK tutorial. I’ve seen this question pop up a few times in the Marmalade SDk forums so I thought that I would cover it here as a bite size tutorial.

You are using the Iw2D module to render handle 2D images, but you need to force the images to be uploaded to texture RAM before the game begins. You took a quick look at CIw2DImage to discover that it is in fact an abstract class with not a lot of info in there, except a few pure virtual methods  for retrieving width, height and the material associated with the CIw2DImage.

You can call GetMaterial() to return the material that makes up your CIw2DImage() and then in turn, call GetTexture() on the returned material to locate its texture. Finally you can call Upload() on the texture to tell Marmalade to upload it. Here’s a quick example code to show what I mean:

CIwMaterial* mat = your_iw2d_image->GetMaterial();
CIwTexture* texture = mat->GetTexture();

Don’t forget that unless you mark the texture as modifiable using texture->SetModifiable(true), the system will delete your pixel / palette data to free up memory.