OLD | NEW |
| (Empty) |
1 // Copyright 2010 The Native Client Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can | |
3 // be found in the LICENSE file. | |
4 | |
5 #ifndef C_SALT_BROWSER_3D_DEVICE_H_ | |
6 #define C_SALT_BROWSER_3D_DEVICE_H_ | |
7 | |
8 /// | |
9 /// @file | |
10 /// Browser3DContext provides the browser-specific support for managing an | |
11 /// 3D context in the browser. Currently, all 3D browser contexts support | |
12 /// OpenGL ES 2.0. | |
13 /// @see c_salt/opengl_context.h | |
14 /// | |
15 | |
16 #include <pgl/pgl.h> | |
17 | |
18 namespace c_salt { | |
19 class Instance; | |
20 class OpenGLContext; | |
21 | |
22 /// | |
23 /// @class Browser3DContext | |
24 /// @a Browser3DContext manages access to the 3D device in the browser and a 3D | |
25 /// rendering context on that device. A newly constructed @a Browser3DContext | |
26 /// is invalid until @a AcquireBrowser3DDevice() is called. After acquiring | |
27 /// the 3D device in the browser, you then have to create a context by calling | |
28 /// @a CreateBrowser3DContext(). | |
29 /// @see AcquireBrowser3DDevice() | |
30 /// @see CreateBrowser3DContext() | |
31 /// | |
32 class Browser3DDevice { | |
33 public: | |
34 /// Deletes all active in-browser 3D contexts and releases the 3D device. | |
35 virtual ~Browser3DDevice() {} | |
36 | |
37 /// Acquire the 3D device in the browser that is associated with the | |
38 /// @a Instance instance passed into the ctor. | |
39 /// @return success. | |
40 virtual bool AcquireBrowser3DDevice() = 0; | |
41 | |
42 /// Create a 3D rendering context in the browser, and bind to @a context. | |
43 /// This can be called more than once to create many 3D rendering contexts | |
44 /// associated with the browser's 3D device. | |
45 virtual PGLContext CreateBrowser3DContext(OpenGLContext* context) = 0; | |
46 | |
47 /// Delete the in-browser 3D context and release the 3D device. After calling | |
48 /// this method, the context is no longer valid. | |
49 virtual void DeleteBrowser3DContext() = 0; | |
50 | |
51 /// The browser context is considered valid when the 3D device has been | |
52 /// succesfully acquired, and a 3D context has been initialized. | |
53 /// @return true if the 3D device is aquired. | |
54 virtual bool is_valid() const = 0; | |
55 }; | |
56 | |
57 /// Browser-specific subclasses must implement this factory method. The caller | |
58 /// takes ownership of the returned object. | |
59 /// @param instance The Instance instance associated with the in-browser | |
60 /// 3D device and context. | |
61 /// @return A newly-created Browser3DDevice instance. | |
62 Browser3DDevice* CreateBrowser3DDevice(const Instance& instance); | |
63 | |
64 } // namespace c_salt | |
65 #endif // C_SALT_BROWSER_3D_DEVICE_H_ | |
OLD | NEW |