1 // Copyright (c) 2011 The Native Client Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef EXAMPLES_TUMBLER_TUMBLER_H_
6 #define EXAMPLES_TUMBLER_TUMBLER_H_
13 #include "opengl_context.h"
14 #include "opengl_context_ptrs.h"
15 #include "scripting_bridge.h"
16 #include "ppapi/cpp/instance.h"
20 class Tumbler : public pp::Instance {
22 explicit Tumbler(PP_Instance instance);
24 // The dtor makes the 3D context current before deleting the cube view, then
25 // destroys the 3D context both in the module and in the browser.
28 // Called by the browser when the NaCl module is loaded and all ready to go.
29 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]);
31 // Called whenever the in-browser window changes size.
32 virtual void DidChangeView(const pp::Rect& position, const pp::Rect& clip);
34 // Called by the browser to handle the postMessage() call in Javascript.
35 virtual void HandleMessage(const pp::Var& message);
37 // Bind and publish the module's methods to JavaScript.
38 void InitializeMethods(ScriptingBridge* bridge);
40 // Set the camera orientation to the quaternion in |args[0]|. |args| must
41 // have length at least 1; the first element is expeted to be an Array
42 // object containing 4 floating point number elements (the quaternion).
43 // This method is bound to the JavaScript "setCameraOrientation" method and
44 // is called like this:
45 // module.setCameraOrientation([0.0, 1.0, 0.0, 0.0]);
46 void SetCameraOrientation(
47 const tumbler::ScriptingBridge& bridge,
48 const tumbler::MethodParameter& parameters);
50 // Called to draw the contents of the module's browser area.
54 // Browser connectivity and scripting support.
55 ScriptingBridge scripting_bridge_;
57 SharedOpenGLContext opengl_context_;
58 // Wouldn't it be awesome if we had boost::scoped_ptr<>?
62 } // namespace tumbler
64 #endif // EXAMPLES_TUMBLER_TUMBLER_H_