Introduction to the Native Client technology, implemented in Samsung Smart TV.
The NaCl unique build system lets the developer target all three current major system architectures (x86_32, x86_64 and ARM) and is future compatible with platforms that are yet to come. This way when the support for a new platform is added, the developer can translate (no need to recompile) the application for the new architecture without worrying about compatibility issues. However C/C++ native code compiled by the NaCl toolchain has some restrictions in order to ensure the safety of executed code, e.g.:
Some of NaCl features are:
NaCl can be used for many purposes and in many ways. It may be used for standalone CPU-heavy web applications like 3D games, easy porting of existing C++ applications to the web, or embedding a NaCl plugin on a webpage to support it’s heavy computational tasks or extend it’s functionality. Especially on SmartTV and TizenTV NaCl can be used to enchance TV experience as it can be used to implement fast and highly responsive applications with great connectivity possibilities.
In order to run a NaCl application on the TizenTV (or any other supported web browser) you have to compile the native code first. Compilation of the NaCl application is similar to the compilation of normal C/C++ code. NaCl toolchain provides a set of tools specially prepared for NaCl compilation like: GCC, Clang, ar, make, etc. Compilation of NaCl application can take two different courses. One way to compile NaCl app is the direct compilation to .nexe using the provided GCC, which is almost identical to normal C/C++ compilation. The other way is using an LLVM compiler - Clang. Clang compiles the source code to a .pexe file which is an intermediate form of bytecode called Portable NativeClient or PNaCl for short. These .pexe files are then translated to the desired architecture’s bytecode format resulting in .nexe file for every coresponding architecture. Google Chrome supports just-in-time translation mechanism which allows the .pexe files to be loaded directly by the web browser. On TizenTV the process of translation is performed by the developer after the compilation to .pexe. Advantages of the second approach include:
With the NaCl module compiled everything is ready to go. Loading of the NaCl application is done in several steps:
This covers the basic knowledge about the NativeClient technology. If you want to start creating apps in NaCl for TizenTV it’s recommended to read How to create a sample NaCl application and Hello World in C++ articles. Also please consider using the specially prepared IDE for NaCl TizenTV developement which makes the process of compilation, testing and debugging the application very easy.
This is an example game written in NaCl that takes advantage of OpenGL ES 2.0. It’s called Futuracer and can be downloaded on supported SmartTV platforms from the SmartHub.