diff options
author | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-26 02:53:54 +0000 |
---|---|---|
committer | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-26 02:53:54 +0000 |
commit | 326975bc6d456cf9fd4a6d944ce1f9f5f834e7e4 (patch) | |
tree | 544760f0e2efb3a6e81ab024ea51adc4b7c0dddd /gpu/demos/framework/demo.h | |
parent | a651b74d09d8f96d6dbb488dde3c494d97544886 (diff) | |
download | chromium_src-326975bc6d456cf9fd4a6d944ce1f9f5f834e7e4.zip chromium_src-326975bc6d456cf9fd4a6d944ce1f9f5f834e7e4.tar.gz chromium_src-326975bc6d456cf9fd4a6d944ce1f9f5f834e7e4.tar.bz2 |
Added infrastructure to run gpu demos under Pepper3D. Created a Demo class that can be run as both standalone apps (exe) or pepper plugins (dll). Created entry points and framework classes for both platforms - exe and pepper. A demo application has three layers:
1. Entry point
- standalone (main_exe.cc): Contains the main function for console applications. Instantiates and runs a window.
- pepper (main_pepper.cc): Contains NPAPI entry points. Instantiates pepper plugin object.
2. Framework that hosts demo
- standalone: Window
- pepper: Plugin
3. Demo - One demo class for all platforms. This does all the rendering and event handling.
BUG=26099
Review URL: http://codereview.chromium.org/554053
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37082 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/demos/framework/demo.h')
-rw-r--r-- | gpu/demos/framework/demo.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/gpu/demos/framework/demo.h b/gpu/demos/framework/demo.h new file mode 100644 index 0000000..801609b --- /dev/null +++ b/gpu/demos/framework/demo.h @@ -0,0 +1,67 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Base class for gles2 demos. + +#ifndef GPU_DEMOS_FRAMEWORK_DEMO_H_ +#define GPU_DEMOS_FRAMEWORK_DEMO_H_ + +#include "base/time.h" + +namespace gpu { +namespace demos { + +// Base class for GLES2 demos. The same demo class is supposed to be run as +// standalone apps (exe), pepper plugin (dll), and nacl module (nexe). This is +// accomplished by creating framework for each platfom and hosting the demo +// class object. +class Demo { + public: + Demo(); + virtual ~Demo(); + + // Returns the title of demo. This title is used to name the window or + // html page where demo is running. + virtual const wchar_t* Title() const = 0; + + // Initializes the size of the window on which this demo object will render. + void InitWindowSize(int width, int height); + + // This function is called by the framework to initialize the OpenGL state + // required by this demo. When this function is called, it is assumed that + // a rendering context has already been created and made current. + virtual bool InitGL() = 0; + + // This function is called by the framework to perform OpenGL rendering. + // When this function is called, it is assumed that the rendering context + // has been made current. + void Draw(); + + protected: + // Returns the width of window. + int width() const { return width_; } + // Returns the height of window. + int height() const { return height_; } + + // The framework calls this function for the derived classes to do custom + // rendering. There is no default implementation. It must be defined by the + // derived classes. The elapsed_sec param represents the time elapsed + // (in seconds) after Render was called the last time. It can be used to + // make the application frame-rate independent. It is 0.0f for the + // first render call. + virtual void Render(float elapsed_sec) = 0; + + private: + int width_; // Window width. + int height_; // Window height. + + // Time at which draw was called last. + base::Time last_draw_time_; + + DISALLOW_COPY_AND_ASSIGN(Demo); +}; + +} // namespace demos +} // namespace gpu +#endif // GPU_DEMOS_FRAMEWORK_DEMO_H_ |