cocos2d-1.0.1-x-0.11.0 – with PlayBook Support

A bit later than initially expected, but it happened a week ago (announcement):  cocos2d-1.0.1-x-0.11.0.zip is available with PlayBook support.

The release includes a Wiki page that shows How to run HelloWorld and Tests on BlackBerry Tablet OS.

Our goal is to upstream as many of our ports as possible.

Posted in Native | Tagged , | 1 Comment

NDK 2.0 Beta 3 Available with Additional Code Samples

As Tim announced at DevBlog, the NDK 2.0 beta 3 is now available.  This beta includes new tooling, API, samples, and documentation as well as the Scoreloop™ SDK beta3.  Tim’s post has a list of the changes; also see the Release Notes.

The NDK samples have been updated, and two templates used in the IDE are now also available directly: ScreenTemplate (Hello World using Native Graphics) and OpenGLES11Template (OpenGL Window 3D Graphics).  There is also a new sample that shows how to use Neutrino Channels (*) so two different threads can communicate sending events (see ZIP file).

The samples are available in the NDK-Samples repository – the master branch (default) corresponds to PlayBook 1.0 while the next branch corresponds to PlayBook 2.0.

(*)
Added – Turns out they are not exactly Neutrino Channels; I will post more information when I get it.
Added – the BPS channel functions are here.

Posted in Native | Tagged | 1 Comment

OpenGL ES 2.0 Programming Guide Samples

The sample code for the book OpenGL ES 2.0 Programming Guide has been ported to BlackBerry Native SDK. The source code is available on github at github.com/blackberry/OpenGLES-Samples.

For those unfamiliar with OpenGL ES 2.0, it differs from OpenGL ES 1.1 by eliminating most of the fixed function pipeline in favor of a programmable pipeline. Basically you write small programs called “shaders” that get executed per vertex or per pixel in the pipeline. This makes OpenGL ES 2.0 more powerful but also more difficult to learn compared to OpenGL ES 1.1.

The book covers the entire OpenGL ES 2.0 API, including the Khronos-ratified extensions. I found it very helpful when I learned OpenGL ES 2.0 and I keep it at my desk as a reference.

Other ports of the source code are available on the author’s Google Code project for Windows, Linux, iPhone, Android and WebGL. Thank you, Dan Ginsburg!

Posted in Native | Tagged , | 5 Comments

CouchDB on the PlayBook

We’re excited to add a port of Apache CouchDB (home site, Wikipedia), the most widely deployed document-oriented database, to complement the data persistence APIs on the PlayBook. CouchDB is a NoSQL database featuring a RESTful JSON API, ACID semantics and a distributed architecture with replication.

CouchDB 1.1.0 and its dependencies (Erlang-OTP R14B03 and SpiderMonkey 1.8.0) have been ported to the PlayBook and are publicly available on GitHub. Below are the details for all the components. We pass most of the Futon test suite but we have a few failures, and we invite the CouchDB community to assist in resolving these remaining issues. Drop a note to Cliff (@CliffordHung) if you are interested.

The following sections outline the steps that are necessary to obtain the source, build, run and test CouchDB on the PlayBook. Ubuntu 11.10 was used as the development environment but any Linux variant should work. The compilation process also works on Mac OS X .

Obtaining the source

CouchDB has a number of dependencies, some of which have been ported to compile and run for the PlayBook and others that can be cross-compiled as-is. They are available at the following locations; ensure that all of these repos/projects are at the same directory level as each other so that the build scripts work.

CouchDBhttp://github.com/blackberry/CouchDB
This repo was forked from the apache/couchdb GitHub repo. Development is being done on a branch of the 1.1.0 tag, please switch to this branch using git checkout branch_1.1.0.

Erlang-OTPhttp://github.com/blackberry/Erlang-OTP
As described on the Apache CouchDB project page, CouchDB is written in Erlang-OTP, a robust functional programming language ideal for building concurrent distributed systems. This repo was forked from the erlang/otp GitHub repo. Development is being done on a branch of the OTP_R14B03 tag, please switch to this branch using git checkout branch_OTP_R14B03.

SpiderMonkeyhttp://github.com/blackberry/SpiderMonkey
SpiderMonkey is the JavaScript engine used by CouchDB. The repo is based on a 1.8.0 tarball; development is being done on the master branch.

GetOpthttp://github.com/blackberry/GetOpt
Needed to run the couchdb shell script.

GetTexthttp://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.tar.gz
Gettext is needed to compile GetOpt; the source does not require changes to compile for the PlayBook.

On your build machine, extract the tarball and move the source directory to gettext:

tar zxf gettext-0.18.tar.gz
mv gettext-0.18 gettext

BlackBerry Tablet OS Native SDK for Linuxhttp://developer.blackberry.com/native/download/linux/.
Required to compile the projects.

Compiling CouchDB

Install the Native SDK if necessary. Ensure that the bbndk-env.sh script is sourced in your shell (e.g. Add this to your shell’s login script: source ~/bbndk/bbndk-env.sh).

Update to the latest versions of autoconf, automake and libtool using Mac Ports on Mac OS X or a suitable package manager on Linux systems, such as apt-get on Ubuntu.

Run the top level build script build.sh, located in CouchDB/PlayBook-build.

cd CouchDB/PlayBook-build
./build.sh

This script sets the necessary environment variables and builds Erlang, SpiderMonkey and other dependencies in addition to CouchDB. It will create a file named couchdb-installer.zip in the CouchDB/PlayBook-build directory that contains all the files needed to install and run CouchDB on the PlayBook.

Installing CouchDB

Connect to the PlayBook through a USB or Wi-Fi connection for the remaining steps. For a USB connection, connect your PlayBook to a USB port on your build machine. Enable development mode on the Playbook (Tap the gear icon, select “Security”, tap “Development Mode” and set “Use Development Mode” to “ON”). Follow the instructions in the “Where is that Log? DevUser and Account 1000 on PlayBook” post under the section “Enable SSH Access” to set up SSH access to the PlayBook.

Transfer the installer to the PlayBook:

scp couchdb-installer.zip devuser@<PlayBook's IP address>:

Log-in to the PlayBook as devuser:

ssh devuser@<PlayBook's IP address>

Create a directory for the installer and extract it:

mkdir couchdb-install
unzip couchdb-installer.zip -d couchdb-install

Run install.sh which will set up CouchDB, Erlang, SpiderMonkey and getopt:

cd couchdb-install
./install.sh

To allow the Futon test suite to be run on a desktop box connected to the PlayBook, in the httpd section, modify CouchDB/etc/couchdb/default.ini to listen on the USB or Wi-Fi interface:

cat default.ini | sed -e 's|^\(bind_address =\) .\+|\1 <PlayBook's IP address>|' > default.ini.new
mv default.ini.new default.ini

Source the couchdb-env.sh to set some environment variables:

. ./couchdb-env.sh

Running CouchDB

Follow the instructions to run CouchDB in the installed directory, as prompted by the install script:

cd CouchDB/bin
./couchdb

You should see the following:

Apache CouchDB 1.1.0 (LogLevel=info) is starting.
Apache CouchDB has started. Time to relax.
[info] [<0.30.0>] Apache CouchDB has started on http://<PlayBook's IP address>:5984/

Running the Futon test suite

From the computer connected to the PlayBook, navigate in FireFox to the following URL to view the web interface for CouchDB, Futon:  http://<PlayBook’s IP address>:5984/_utils

Select the “Test Suite” from the right-hand menu. Click the “Run All” button to run the tests. You should see the HTTP requests being logged from the CouchDB server.

Known test issues:

The oauth, replication and security_validation tests report errors similar to the following:

{"error":"db_not_found","reason":"could not open http://<PlayBook's IP address>/test_suite_db_b/"}

This has been traced to a networking bug in the OS that is being investigated.

Some of the other tests report exceptions or assertion failures; these need investigation.

Posted in Native, PlayBook | Tagged , | 4 Comments

logging4bb – a Logging Framework for BlackBerry OS

[Ekke is an independent software developer and a BlackBerry fan. He recently open-sourced logging4bb and graciously accepted my invitation to write a post on the framework – Eduardo]

logging4bb

I’ve been a big fan of logging for many years, and this was one of the main things I missed in BlackBerry OS.  Debugging on mobile devices sometimes is a challenge – for instance, testing Location-based Services out in the field or applications with many async tasks, where debugging changes the behaviour of the application – and logging is an invaluable aid.

During these last two years I have developed a logging framework and now you can get it as Open Source.

Overview

logging4bb is a background app and will be started automatically as a system module.
logging4bb logs events to a remote socket logger (Lilith) and/or to a local SQLite database.

My goal for logging4bb was to have an easy to use logging framework for BBOS.  The general structure is as follows:

logging4bb registers some remote commands using BlackBerry OS Command Framework. This means that the logger is not hard bundled with other Applications and can serve as many APPs as you like.

To use logging4bb you only need to copy 5 classes into your application…

… change same parameters in the LoggerFactory class (marked as TODO) and it works.

The logging from BlackBerry OS Applications works similar to Logging in Java SE, each class gets a logger:

// the logger
 private static final ILogger logger =
         LoggerFactory.getLogger(HelloLoggingApp.class);

and you can log as usual:

logger.debug("HelloLoggerScreen successfully initialized");

If the background app isn’t installed on the BlackBerry there’s a fallback to sys-out logging. So it is possible to install the logger only if you need it or while testing.

For additional details, please take a look at my presentation at BlackBerry DevCon 2011 in San Francisco:

or download the pdf: Logging: Esay and Flexible

OSS as GIT repository at Bitbucket

logging4bb is hosted at Bitbucket.  Why? because Bitbucket offers Unlimited Private Repositories for free.

There are two projects: logging4bb, and a “Hello Logging” example that shows how to use the framework.

Branches

logging4bb uses Git branches to manage different platforms in one single repository.  The default master branch only has a readme file, while the other two branches have the code that is needed for each platform – please checkout the branch you need:

  • dev-public is always the newest one – at the moment BB OS 7
  • os6/dev-public is based on BB OS 6

Please take a look at this blog I wrote about Git and mobile development describing the structure of my GIT repositories to understand how it works.

BIS Connection

logging4bb isn’t running out of the box because BIS is used to communicate with the logging server and you have to replace the secret connection string.

If you don’t want to use BIS,  you can set deviceside=true to use a direct socket connection, customize the transport protocol, and do it your way.

BlackBerry Forums will help if you have questions about BlackBerry Connections.

License

logging4bb uses the Eclipse Public License (EPL). EPL gives the licensor much freedom and can be combined easy with Apache Licenses used by BlackBerry OSS projects at Github.

All documentation and content is licensed under Creative Commons License 3.0 (BY-NC-SA).

Lilith is dual-licensed for Apache 2.0, LGPL and GPL – so its always compatible.

HowTo start

There are two ways to get the sources:

  1. Use Eclipse and download the ready-to-use Eclipse Projects, or
  2. Clone from GIT Repositories

Once all is installed and running you will be able to log to Lilith or SQLite on the device.

Logging to Server (Lilith Logmonitor)

Please download Lilith from Sourceforge.

Lilith is available as APP for OSX and also for Windows and Linux.

Originally Lilith was used as a LogMonitor for SLF4J / LogBack but, as you probably know, LogBack doesn’t run on BlackBerry OS.  Instead logging4bb uses a trick and sends Log Messages in the same format to Lilith as this would be done using an Appender for Lilith from Java SE applications.

This is really great if you’re testing Client / Server applications – you can monitor the Logging using Lilith and watch server-logs side-by-side with logs from BlackBerry devices or Simulator.

Logging to DB (local SQLite)

logging4bb uses a local SQLite database for two use-cases:

  • Storing preferences
  • Storing log messages

The first time logging4bb is started, the SQLite will be created automatically and the preferences will be initialized.

Here’s an example with some log events stored into SQLite (opened with Firefox PlugIn SQLite Manager):

Problems ? Questions ? More Info ?

logging4bb requires BlackBerry OS 6+ and needs a SDCard.  Documentation for the framework can be found here.

If you encounter bugs or want to request new features, please open an issue at Bitbucket here.

Thanks

Thanks that I was allowed to present logging4bb as part of the OpenBBNews. I will publish additional Open Source Projects in the next months.

I work as an Independent Software Architect in Germany and I blog about my work at ekkes-corner.  You can follow me at @ekkescorner.

Posted in Java | Tagged , , | Leave a comment

DosBox – From GitHub to Your PlayBook

DosBox is one of the Open Source ports we announced at DevCon America 2011.  The port (by Jeremy’s team) reinforces the richness of the PlayBook platform and made it to Engadget.  Below are updated instructions on how to build and install DosBox from GitHub to your PlayBook.

Disclaimer – questions on specific games belong elsewhere.  CrackBerry has two active threads on the topic: DosBox and DosBox Games.

SetUp

The host for these instructions is a Mac laptop running MacOS and I deployed on a consumer (i.e. secure) PlayBook Tablet, running a recent build of PlayBook OS 2.0.  I used the latest NDK 2 SDK beta 2.  I believe the instructions apply equally well to a 1.0 release, except for the libbps.so issue mentioned below.

I used a debug-token to avoid having to sign the applications during the “development” cycle.

Building DosBox

DosBox requires a number of dependencies.  For the most part the build steps are pretty easy, but there are a couple of places that Jeremy indicated he wanted to improve.

We will end-up creating and building 5 projects, with DosBox being the top one, and the one we will deploy:

Let’s get started

Downloading Sources

Download DosBox, SDL, TouchControlOverlay and OggVorbis from GitHub.  You can either git clone them, or download a ZIP and unzip them.  Use the default (master) branches.

Rename SDL into SDL12.  This is because some of the projects have a dependency on that name; Jeremy says he will remove the need for this.

Download SDL_sound from http://icculus.org/SDL_sound/downloads/.  I used version 1.0.3.  Unzip it into DosBox/3rdparty/SDL_sound/src.  The SDL_sound directory should look like:

bash-3.2$ pwd
.../DosBox/3rdparty/SDL_sound
bash-3.2$ ls -p -a -1 . src
.:
./
../
.cproject
.project
README
src/

src:
./
../
CHANGELOG
COPYING
CREDITS
CWProject.sit
Doxyfile
INSTALL
Makefile.am
....

As shown by the .cproject and .project files, this project will be imported into the IDE.

Build OggVorbis

Currently OggVorbis needs to be build from the command line.  Instructions are at OggVorbis/vorbis/README, but you just need to set the environment variables from the NDK (via bbndk-env), then go to vorbis/qnx and execute a make.

Import Projects into Momentics

Import the 5 projects into your IDE workspace.  DosBox, SDL and TouchControlOverlay are top projects.  Vorbis is at OggVorbis/vorbis and SDL_sound is at DosBox/3rdparty/SDL_sound.

You cannot copy the vorbis sources – same reason why it needs to be compiled via make.

You need to adjust one property of SDL_sound.  Open the properties dialog

Now go to C/C++Build > Settings > QCC Compiler > PreProcessor.  Select “All Configurations” and change the include path ${workspace_log:/vorbis/ogg/include} to ${workspace_loc:/vorbis}/../ogg/include.

Almost ready.  Now just make sure all the projects have set the same build configuration.  Since I’m using an actual PlayBook, it is a Device-* configuration; I used Device-Debug.

Finally, right-click on DosBox and Build Project.  There will be some warnings that you can ignore for now (we will encounter libbps shortly).

Package and Deploy DosBox

As part of package and deploying we will need to specify the target and ensure that the debug token is deployed appropriately.  The target can be Window->Show View->Target Navigator.  Momentics will also ask you for details if necessary; for example, it asks how to configure the debug-token via a popup:

I selected the second option because I had previously created a debug token – already uploaded to my PlayBook.

Libbps.So and PlayBook 2

Trying to package DosBox generates the following error:

The problem is that blackberry-tablet.xml descriptor is designed for PlayBook 1, and requires the bundling of a (new, 1.0) copy of libbps.so that is not present in 1.0. Incidentally, this is the same message you get if you try to run the Samples from NDK1.0 on a PlayBook 2.0 build. The solution is to remove that line in blackberry-tablet.xml, rebuild, and redeploy, this time successfully.

Run DosBox

Next is to try to mount a PlayBook directory as a DOS disk so we can run applications (like Games) from there. The first thought would be to use the shared download directory, at /accounts/1000/shared, but PlayBook OS does not give default access to this directory to applications:

Rather, what’s needed is to request this access via the application description.  You can manually edit the blackberry-tablet.xml file, or you can use the IDE to do so.  Using the IDE you request the permission and the IDE will insert the correct XML element:

Rebuild DosBox and redeploy and rerun, and this time around the mount will succeed.

Running a Game

I further tested DosBox with one of the games from BestOldGames.netPrince of Persia.

The IDE includes a File Explorer that can be used to explore and manipulate the Target.  I copied the ZIP for PoP in a /accounts/1000/shared/downloads/DOS/ directory, and later unzipped it using unzip natively via an ssh connection.

To run the game, I just mounted the above directory in a DOS disk (C:), navigated on directory down and ran the main command (Prince):

If you want to use DosBox for actual game playing you may want to adjust some of its settings – they are at /accounts/1000/appdata/<DOSBOXAPP>/data/.dosbox/dosbox-0.74.conf; I changed none as I just wanted to test the application.

Enjoy!  An internet search quickly finds instructions for other games ([1], [2])

Posted in Native | Tagged , | 8 Comments

Building and Deploying WebWorks Samples

We now have 5 samples at WebWorks-Samples (TunnelTilt, is a sixth one but it is at WebGL-Samples):

Aura, Payment and SketchPad were designed specifically for the PlayBook.  I believe KitchenSink and UIExamples started for the smartphones but they work equally well on the PlayBook, although the layout of UIExamples is better in portrait rather than landscape mode.

Setup

The instructions are the same for all the samples.  They are similar to those for TunnelTilt, except that you don’t need to bundle any extra WebWorks extensions.

The usual setup for debug mode – see Install the Developers Beta and Install a Debug Token.  Set your PlayBook in Development Mode, and write down the DEVICEIP and the DEVICEPASS.

Download

Download the samples from GitHub.  Pay some attention to the branch you are using – you want master because gh-pages is missing sketchpad (issue #18).

You can download via a git clone, or just a plain zip download.

If you choose a ZIP, GitHub will create a ZIP file for you that corresponds to the state of the repository right now.  Something like blackberry-WebWorks-Samples-6c853cb.zip.  Unzip it and, if you want, rename the directory to something like blackberry-WebWorks-Samples.

The result will look something like:

bash-3.2$ /bin/ls -1 -p blackberry-WebWorks-Samples/
Aura/
LICENSE
README.md
UIExamples/
kitchenSink/
payment/
sketchPad/

We will now build and deploy each sample.  All samples are built and deployed using the same instructions.

Build and Deploy

Each sample directory has the HTML, CSS, JS and other resource files needed (locally) by the application.  Each sample also has a widget configuration file config.xml that describes what features will be needed by the application, the icon to use on the home screen, the name, the description, and other resources.

You just need 3 commands per sample: zip your WebWorks application, then package that ZIP into a BAR, then deploy. The zip command is most likely bundled in your platform, the packager comes from the WebWorks SDK, the deployer is also included in the WebWorks SDK although that is a copy of that in the NDK.

bash-3.2$ which zip
/usr/bin/zip
bash-3.2$ which bbwp
/Developer/SDKs/wwsdk-2.2.0.5/bbwp/bbwp
bash-3.2$ which blackberry-deploy
/Developer/SDKs/bbndk-2.0.0-beta2/host/macosx/x86/usr/bin/blackberry-deploy

If you wonder about that wwsdk directory, it is really a symlink to the standard installation directory to give it a sensible name:

bash-3.2$ ls -l /Developer/SDKs/wwsdk-2.2.0.5
lrwxr-xr-x  1 root  wheel  64 Dec 28 17:40 /Developer/SDKs/wwsdk-2.2.0.5@ -> Research In Motion/BlackBerry WebWorks SDK for TabletOS 2.2.0.5/

And that’s pretty much all. If we save the ZIPs and BARs in the top directory for simplicity, the commands for each application are of the form:

bash-3.2$ cd Aura
bash-3.2$ zip -r ../Aura.zip *
bash-3.2$ bbwp ../Aura.zip -d -v -o ..
bash-3.2$ blackberry-deploy -installApp \
-password DEVICEPASS -device DEVICEIP \
-package ../Aura.bar
bash-3.2$ cd ..

At the end you will have 5 new applications in your PlayBook:

Posted in HTML5 | Tagged , | 2 Comments

GamePlay 1.1 – New Features and Samples

GamePlay 1.1 is now available at GitHub. This release includes a significant number of new features, including physics support using Bullet,  OggVorbis audio support, and XCode 4 support, in addition to PlayBook and Windows 7 support – a complete list of feature is at Milestone Page.

The release also includes 4 ready-to-go samples: Mesh, LongBoard, SpaceShip, and Character.  There are fairly complete Tutorial documents for both LongBoard (pdf, 16 pages) and SpaceShip (pdf, 27 pages).

The release includes Doxygen-generated documentation.  After you download (or clone) the sources, point your browser to <root>/gameplay-api/html/index.html.

Building the samples with the IDE is pretty straight-forward.  The Getting Started page at the micro-site provides good instructions: Install the IDE, then load gameplay’s project and the 4 games projects (File->Import->General->Existing Projects into Workspace).  Configure the targets Using the Deployment Wizard.

First build the GamePlay and the samples, and then deploy them.  I had previously uploaded a debug token to my PlayBook (used in the tunneltilt and other posts), so I did not generate a new debug token but rather adjusted the target to reuse the  debug token already in my PB.

Everything worked smoothly and the 4 apps showed up on my PlayBook (running a recent 2.0.0.* release).

GamePlay is a multi-platform framework.  In addition to PlayBook (1.0 and 2.0) it also supports the Mac and Windows.  Specific details::

  • BlackBerry PlayBook 1.0/2.0 (using BlackBerry Native SDK 1.0/2.0)
  • Apple MacOS X (using Apple XCode 4.0)
  • Microsoft Windows 7 (using Microsoft Visual Studio 2010 Pro/Express)

Drop us a comment if you write about your experiences with the framework in any of these platforms.  I am specially interested in Applications submitted to the BlackBerry App World.

The next release is Milestone 1.2.  Features currently planned for it include:

  • UI Forms with Themed Overlays.
  • Improvements to Lighting.
  • Developer Guide.
  • More Samples and Tutorials.
  • Apple iOS 5 Support.
Posted in Native | Tagged , | Leave a comment

Next release of cocos2d-x to include PlayBook support

Cocos2d-x was one of the Open Source components ported to the PlayBook and announced as part of DevCon America.  The intention was always to upstream the changes, and Dale just mentioned that this has indeed been the case.

This integration is targeted for cocos2d-1.0.1-x-0.11.0, due end of the month.  The beauty of transparent Open Source development is that all the details are there: the feature request is #907, and you can track all the changes in the community roadmap.

There is a brand-new platform-blackberry-qnx forum at cocos2d-x.org; I’d encourage you to use it.  Drop us a comment if you use the component in a PlayBook game and we will highlight it here or at DevBlog; we are always interested in your experiences.

We have not yet decided on exactly how to handle the upstreaming of the ported components.  My current thinking is to record this in the new Wiki pages I mentioned in the OSS forum.

Posted in Native | Tagged , | 1 Comment

SketchPad WebWorks sample now open source

Happy to share that we have moved the sketchPad sample application into Github to make this code more easily available for developers to discover, download and use:

https://github.com/blackberry/WebWorks-Samples/tree/master/sketchPad

As described in our Developer Resource center:

Sketchpad is a sample application provided to developers as a learning resource.  This application is created using the BlackBerry® WebWorks™ App Platform and demonstrates how HTML5 and Touch Events can be used to draw an image on the screen using either the touch screen or the trackpad.

SketchPad is supported on BlackBerry® 6 and higher, as well as the BlackBerry Tablet OS®.

Hope you enjoy this sample!

Posted in HTML5 | Tagged , | 1 Comment