April 12, 2016 2:00 pm

Marmalade makes it easy to create games that run cross-platform

At //build 2016, developers were shown how to create cross-platform games for iOS, Android, and Windows 10 using Visual Studio and the Marmalade Platform, the leading cross-platform solution for game developers.

Developers can write code once and deploy it to many types of devices using Marmalade Core, a cross-platform C++ SDK, leveraging a platform abstraction API that hides much of the complexity of native platforms.

Accessing a device’s accelerometer, for instance, reuses the same code across platforms:



// Start the accelerometer
accelAvailable = s3eAccelerometerStart() == S3E_RESULT_SUCCESS;
 
// Read the accelerometer
if (accelAvailable)
{
   int32 x = s3eAccelerometerGetX();
   int32 y = s3eAccelerometerGetY();
   int32 z = s3eAccelerometerGetZ();
}


Projects can be opened in Visual Studio 2015 using the Marmalade Hub, the go-to tool for organizing and working within Marmalade Core.

Marmalade Core: Project ready to Open in IDE with a click

Marmalade Core: Project ready to Open in IDE with a click

Visual Studio cross-platform technology

By default, Marmalade Core projects produce a Visual Studio solution capable of generating an app binary that can be deployed to several target platforms without recompiling.

The new cross-platform features of Visual Studio 2015 allow native debugging of Marmalade Core apps running on either the Visual Studio Emulator for Android (x86) or an attached Android device (ARM).

Marmalade can easily allow game devs to, for instance, target iOS and Android from a Windows machine using this “single-binary” approach. This type of Visual Studio solution is ideal for generating a binary for distribution or for debugging on the Marmalade Desktop Simulator.

Marmalade Core: Project being debugged as a native Android app in Visual Studio

Marmalade Core: Project being debugged as a native Android app in Visual Studio

For on-device native debugging, Marmalade Core projects can also generate a special Visual Studio solution that allows for debugging on Windows Phone, Windows 10, and now Android. All it takes is a single click in the Marmalade Hub and Visual Studio will open, ready to build and debug your Android app.

Hands-on with Marmalade 2D Kit and Marmalade 3D Kit

As part of showcasing how Marmalade Core and Visual Studio combine to help create great cross-platform games, we also went hands-on at //build with 2D Kit and 3D Kit.

2D Kit offers a set of tools and APIs to make creating 2D content easier than ever before. With a focus on user interfaces, 2D Kit’s editor can dramatically reduce the time and cost of creating a rich, dynamic, and engaging UI experience for your game.

Marmalade 2D Kit: Editor in action

Marmalade 2D Kit: Editor in action

With the help of a dedicated 2D Kit runtime, integrating the content you create in the editor with your existing pipeline and game code in Visual Studio is quick and straightforward. The code outline below illustrates how to go about integrating the runtime with your code.



m_SceneContainer.RegisterTextureLoadCallback(...);
m_SceneContainer.RegisterTextureUnloadCallback(...);
m_SceneContainer.RegisterFontLoadCallback(...);
m_SceneContainer.RegisterFontUnloadCallback(...);
m_SceneContainer.RegisterStringLoadCallback(...);
m_SceneContainer.RegisterStringUnloadCallback(...);
...
m_SceneContainer = new CSceneContainer();
...
m_SceneContainer.LoadScene(...);
...
m_SceneContainer.DrawScene(...);


3D Kit brings together a suite of tools and APIs to simplify the creation of 3D games built using Marmalade Core.

Projects in Marmalade Core can seamlessly import and use resources created in modeling tools with FBX support, such as Maya, 3ds Max, and many more. Previewing your FBX files is easy thanks to Visual Studio’s integrated Model Editor.

As a simple example of how 3D Kit can be used within a Marmalade Core project, here’s how you can load and render a 3D model.



// Load the 3D board model and materials
CIwResGroup* pGroup = IwGetResManager()->LoadGroup("Board.group");
 
// Get a reference to the model resource
CIwModel* board = (CIwModel*)pGroup->GetResNamed("board", IW_GRAPHICS_RESTYPE_MODEL);
 
// Build model’s 3D transform
CIwFMat Transform
Transform.SetRotY(Rotation.y);
Transform.ScaleRot(Scale);
Transform.SetTrans(Position);
IwGxSetModelMatrix(&Transform);
 
// Render the model
board->Render();


There’s lots of useful information on 2D Kit to be found in the Marmalade developer documentation here. To find out all about 3D Kit, take a look the developer documentation here.

At //build, we also offered a look ahead to the future of 3D Kit, including an all-new editor for improved workflow efficiency and a next-generation graphics architecture, leveraging leading industry technology, such as DirectX 12.

Want to know more? Download the Marmalade Platform for free at the Marmalade Developer site.

Posted by Patrick Stanton, Director for Post Sales Monetization, on behalf of Marmalade