This page lists all of the examples available in the most recent Native Client SDK bundle. Each example is designed to teach a few specific Native Client programming concepts.
- Hello World in C
- The Hello World In C example demonstrates the basic structure of all Native Client applications. This example loads a Native Client module and responds to button click events by showing alert panels.
Teaching focus: Basic HTML, JavaScript, and module architecture; Messaging API.
- Hello World in C++
- The Hello World C++ example demonstrates the basic structure of all Native Client applications. This example loads a Native Client module and responds to button click events by showing alert panels.
Teaching focus: Basic HTML, JavaScript, and module architecture; Messaging API.
- Load Progress
- The Load Progress example demonstrates how to listen for and handle events that occur while a
NaCl module loads. This example listens for different load event types and dispatches different events to their respective handler. This example also checks for valid browser
version and shows how to calculate and display loading progress.
Teaching focus: Progress event handling.
- Pi Generator
- The Pi Generator example demonstrates creating a helper thread that estimate pi using the Monte Carlo
method while randomly putting 1,000,000,000 points inside a 2D square that shares two
sides with a quarter circle.
Teaching focus: Thread creation, 2D graphics, view change events.
- Input Events
- The Input Events example demonstrates how to handle events triggered by the user. This example allows a user
to interact with a square representing a module instance. Events are displayed on the screen as the user clicks, scrolls, types, inside or outside
of the square.
Teaching focus: Keyboard and mouse input, view change, and focus events.
- Sine Wave Synthesizer
- The Sine Wave Synthesizer example demonstrates playing sound (a sine wave).
Teaching focus: Audio.
- Pong
- The Pong example demonstrates how to create a basic 2D video game and how to store application
information in a local persistent file. This game uses up and
down arrow keyboard input events to move the paddle.
Teaching focus: File I/O, 2D graphics, input events.
- Get URL
- The Get URL example demonstrates fetching an URL and then displaying its contents.
Teaching focus: URL loading.
- Multi-threaded Input Events
- The Multithreaded Input Events example combines HTML, Javascript,
and C++ (the C++ is compiled to create a .nexe file).
The C++ shows how to handle input events in a multi-threaded application.
The main thread converts input events to non-pepper events and puts them on
a queue. The worker thread pulls them off of the queue, converts them to a
string, and then uses CallOnMainThread so that PostMessage can be send the
result of the worker thread to the browser.
- Tumbler
- The Tumbler example demonstrates how to create a 3D cube that you can rotate with your mouse while pressing the
left mouse button. This example creates a 3D context and draws to it using
OpenGL ES. The JavaScript implements a virtual trackball interface to
map mouse movements into 3D rotations using simple 3D vector math and
quaternions.
Teaching focus: 3D graphics
- Full-screen Tumbler
- This is a modified version of the Tumbler example above that supports
full-screen display. It is in every way identical to Tumbler in
functionality, except that it adds the ability to switch to/from
full-screen display by pressing the Enter key.
Teaching focus: Full-screen
- Mouse Locker
- The Mouselock example demonstrates how to use the MouseLock API to hide
the mouse cursor. Mouse lock is only available in full-screen mode. You can
lock and unlock the mouse while in full-screen mode by pressing the Enter key.
Teaching focus: Mouse lock, Full-screen