OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Base class for gles2 demos. |
| 6 |
| 7 #ifndef GPU_DEMOS_FRAMEWORK_DEMO_H_ |
| 8 #define GPU_DEMOS_FRAMEWORK_DEMO_H_ |
| 9 |
| 10 #include "base/time.h" |
| 11 |
| 12 namespace gpu { |
| 13 namespace demos { |
| 14 |
| 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 |
| 17 // accomplished by creating framework for each platfom and hosting the demo |
| 18 // class object. |
| 19 class Demo { |
| 20 public: |
| 21 Demo(); |
| 22 virtual ~Demo(); |
| 23 |
| 24 // Returns the title of demo. This title is used to name the window or |
| 25 // html page where demo is running. |
| 26 virtual const wchar_t* Title() const = 0; |
| 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 |
| 32 // required by this demo. When this function is called, it is assumed that |
| 33 // a rendering context has already been created and made current. |
| 34 virtual bool InitGL() = 0; |
| 35 |
| 36 // This function is called by the framework to perform OpenGL rendering. |
| 37 // When this function is called, it is assumed that the rendering context |
| 38 // has been made current. |
| 39 void Draw(); |
| 40 |
| 41 protected: |
| 42 // Returns the width of window. |
| 43 int width() const { return width_; } |
| 44 // Returns the height of window. |
| 45 int height() const { return height_; } |
| 46 |
| 47 // The framework calls this function for the derived classes to do custom |
| 48 // rendering. There is no default implementation. It must be defined by the |
| 49 // derived classes. The elapsed_sec param represents the time elapsed |
| 50 // (in seconds) after Render was called the last time. It can be used to |
| 51 // make the application frame-rate independent. It is 0.0f for the |
| 52 // first render call. |
| 53 virtual void Render(float elapsed_sec) = 0; |
| 54 |
| 55 private: |
| 56 int width_; // Window width. |
| 57 int height_; // Window height. |
| 58 |
| 59 // Time at which draw was called last. |
| 60 base::Time last_draw_time_; |
| 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(Demo); |
| 63 }; |
| 64 |
| 65 } // namespace demos |
| 66 } // namespace gpu |
| 67 #endif // GPU_DEMOS_FRAMEWORK_DEMO_H_ |
OLD | NEW |