diff options
author | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-09 13:40:59 +0000 |
---|---|---|
committer | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-09 13:40:59 +0000 |
commit | 714be33609c9405f197c61339d8a77a91b3353da (patch) | |
tree | c9b13a41e4292c1a0b7676e9d4b745a4a679e730 /gpu | |
parent | 0ca038ddae59aab258705d47a866f93cdeaa9ad9 (diff) | |
download | chromium_src-714be33609c9405f197c61339d8a77a91b3353da.zip chromium_src-714be33609c9405f197c61339d8a77a91b3353da.tar.gz chromium_src-714be33609c9405f197c61339d8a77a91b3353da.tar.bz2 |
Added hello-triangle demo.
BUG=26099
TEST=Try running hello_triangle executable, you should see a red triangle
Review URL: http://codereview.chromium.org/539001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35873 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/demos/DEPS | 3 | ||||
-rw-r--r-- | gpu/demos/demos.gyp | 11 | ||||
-rw-r--r-- | gpu/demos/hello_triangle/main.cc | 66 |
3 files changed, 80 insertions, 0 deletions
diff --git a/gpu/demos/DEPS b/gpu/demos/DEPS new file mode 100644 index 0000000..74c3f98 --- /dev/null +++ b/gpu/demos/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + "+third_party/gles_book_examples", +] diff --git a/gpu/demos/demos.gyp b/gpu/demos/demos.gyp index addfa0a..9bf55d6 100644 --- a/gpu/demos/demos.gyp +++ b/gpu/demos/demos.gyp @@ -23,6 +23,17 @@ 'app_framework/platform.h', ], }, + { + 'target_name': 'hello_triangle', + 'type': 'executable', + 'dependencies': [ + 'app_framework', + '../../third_party/gles_book_examples/gles_book_examples.gyp:hello_triangle', + ], + 'sources': [ + 'hello_triangle/main.cc', + ], + }, ] } diff --git a/gpu/demos/hello_triangle/main.cc b/gpu/demos/hello_triangle/main.cc new file mode 100644 index 0000000..ef22208 --- /dev/null +++ b/gpu/demos/hello_triangle/main.cc @@ -0,0 +1,66 @@ +// Copyright (c) 2009 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. + +// This is a simple example that draws a single triangle with +// a minimal vertex/fragment shader. The purpose of this +// example is to demonstrate the basic concepts of +// OpenGL ES 2.0 rendering. + +#include "gpu/demos/app_framework/application.h" +#include "third_party/gles_book_examples/Chapter_2/Hello_Triangle/Hello_Triangle.h" + +namespace gpu_demos { +class HelloTriangle : public Application { + public: + HelloTriangle(); + ~HelloTriangle(); + + bool Init(); + + protected: + virtual void Draw(); + + private: + ESContext context_; + HTUserData user_data_; + + DISALLOW_COPY_AND_ASSIGN(HelloTriangle); +}; + +HelloTriangle::HelloTriangle() { + esInitContext(&context_); + + memset(&user_data_, 0, sizeof(HTUserData)); + context_.userData = &user_data_; +} + +HelloTriangle::~HelloTriangle() { + htShutDown(&context_); +} + +bool HelloTriangle::Init() { + if (!Application::InitRenderContext()) return false; + + context_.width = width(); + context_.height = height(); + if (!htInit(&context_)) return false; + + return true; +} + +void HelloTriangle::Draw() { + htDraw(&context_); +} +} // namespace gpu_demos + +int main(int argc, char *argv[]) { + gpu_demos::HelloTriangle app; + if (!app.Init()) { + printf("Could not init.\n"); + return EXIT_FAILURE; + } + + app.MainLoop(); + return EXIT_SUCCESS; +} |