| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Base class for gles2 demos. | 5 // Base class for gles2 demos. |
| 6 | 6 |
| 7 #ifndef GPU_DEMOS_FRAMEWORK_DEMO_H_ | 7 #ifndef GPU_DEMOS_FRAMEWORK_DEMO_H_ |
| 8 #define GPU_DEMOS_FRAMEWORK_DEMO_H_ | 8 #define GPU_DEMOS_FRAMEWORK_DEMO_H_ |
| 9 | 9 |
| 10 #include <ctime> | 10 #include <ctime> |
| 11 | 11 |
| 12 namespace gpu { | 12 namespace gpu { |
| 13 namespace demos { | 13 namespace demos { |
| 14 | 14 |
| 15 // Base class for GLES2 demos. The same demo class is supposed to be run as | 15 // Base class for GLES2 demos. The same demo class is supposed to be run as |
| 16 // standalone apps (exe), pepper plugin (dll), and nacl module (nexe). This is | 16 // standalone apps (exe), pepper plugin (dll), and nacl module (nexe). This is |
| 17 // accomplished by creating framework for each platfom and hosting the demo | 17 // accomplished by creating framework for each platfom and hosting the demo |
| 18 // class object. | 18 // class object. |
| 19 class Demo { | 19 class Demo { |
| 20 public: | 20 public: |
| 21 Demo(); | 21 Demo(); |
| 22 virtual ~Demo(); | 22 virtual ~Demo(); |
| 23 | 23 |
| 24 // Returns the title of demo. This title is used to name the window or | 24 // Returns the title of demo. This title is used to name the window or |
| 25 // html page where demo is running. | 25 // html page where demo is running. |
| 26 virtual const wchar_t* Title() const = 0; | 26 virtual const wchar_t* Title() const = 0; |
| 27 | 27 |
| 28 // Initializes the size of the window on which this demo object will render. | |
| 29 void InitWindowSize(int width, int height); | |
| 30 | |
| 31 // This function is called by the framework to initialize the OpenGL state | 28 // This function is called by the framework to initialize the OpenGL state |
| 32 // required by this demo. When this function is called, it is assumed that | 29 // required by this demo. When this function is called, it is assumed that |
| 33 // a rendering context has already been created and made current. | 30 // a rendering context has already been created and made current. |
| 34 virtual bool InitGL() = 0; | 31 virtual bool InitGL() = 0; |
| 35 | 32 |
| 36 // Returns whether the demo is animated. Animated demos are drawn | 33 // Returns whether the demo is animated. Animated demos are drawn |
| 37 // continuously. Unanimated demos are only drawn when the window is invalid. | 34 // continuously. Unanimated demos are only drawn when the window is invalid. |
| 38 virtual bool IsAnimated(); | 35 virtual bool IsAnimated(); |
| 39 | 36 |
| 37 // This function is called by the network to notify demo that window |
| 38 // surface has been resized. |
| 39 void Resize(int width, int height); |
| 40 |
| 40 // This function is called by the framework to perform OpenGL rendering. | 41 // This function is called by the framework to perform OpenGL rendering. |
| 41 // When this function is called, it is assumed that the rendering context | 42 // When this function is called, it is assumed that the rendering context |
| 42 // has been made current. | 43 // has been made current. |
| 43 void Draw(); | 44 void Draw(); |
| 44 | 45 |
| 45 protected: | 46 protected: |
| 46 // Returns the width of window. | 47 // Returns the width of window. |
| 47 int width() const { return width_; } | 48 int width() const { return width_; } |
| 48 // Returns the height of window. | 49 // Returns the height of window. |
| 49 int height() const { return height_; } | 50 int height() const { return height_; } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 60 int width_; // Window width. | 61 int width_; // Window width. |
| 61 int height_; // Window height. | 62 int height_; // Window height. |
| 62 | 63 |
| 63 // Time at which draw was called last. | 64 // Time at which draw was called last. |
| 64 clock_t last_draw_time_; | 65 clock_t last_draw_time_; |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 } // namespace demos | 68 } // namespace demos |
| 68 } // namespace gpu | 69 } // namespace gpu |
| 69 #endif // GPU_DEMOS_FRAMEWORK_DEMO_H_ | 70 #endif // GPU_DEMOS_FRAMEWORK_DEMO_H_ |
| OLD | NEW |