diff options
author | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-15 21:32:20 +0000 |
---|---|---|
committer | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-15 21:32:20 +0000 |
commit | cb79b334b49795a96034749007d3104e3b7740aa (patch) | |
tree | 28ccf42ac462bc22c3ebc494c175e6385d9515fa /gpu | |
parent | eb003245da4a579090d1e9bdee891587db451d4c (diff) | |
download | chromium_src-cb79b334b49795a96034749007d3104e3b7740aa.zip chromium_src-cb79b334b49795a96034749007d3104e3b7740aa.tar.gz chromium_src-cb79b334b49795a96034749007d3104e3b7740aa.tar.bz2 |
Added stencil-test demo.
PS: I have not moved the repeated code to the base class for this demo because this is the last one I intend to submit before starting to port the demos to pepper. I will refactor all the demos to eliminate repeating code in light of pepper framework.
BUG=26099
TEST=Run stencil_test executable. You should see four different-colored quads.
Review URL: http://codereview.chromium.org/545092
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36410 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/demos/demos.gyp | 11 | ||||
-rw-r--r-- | gpu/demos/stencil_test/main.cc | 63 |
2 files changed, 74 insertions, 0 deletions
diff --git a/gpu/demos/demos.gyp b/gpu/demos/demos.gyp index 5aeaade..99aa697 100644 --- a/gpu/demos/demos.gyp +++ b/gpu/demos/demos.gyp @@ -79,6 +79,17 @@ ], }, { + 'target_name': 'stencil_test', + 'type': 'executable', + 'dependencies': [ + 'app_framework', + '../../third_party/gles2_book/gles2_book.gyp:stencil_test', + ], + 'sources': [ + 'stencil_test/main.cc', + ], + }, + { 'target_name': 'texture_wrap', 'type': 'executable', 'dependencies': [ diff --git a/gpu/demos/stencil_test/main.cc b/gpu/demos/stencil_test/main.cc new file mode 100644 index 0000000..a0009cc --- /dev/null +++ b/gpu/demos/stencil_test/main.cc @@ -0,0 +1,63 @@ +// 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. + +// This example shows various stencil buffer operations. + +#include "gpu/demos/app_framework/application.h" +#include "third_party/gles2_book/Chapter_11/Stencil_Test/Stencil_Test.h" + +namespace gpu_demos { +class StencilTest : public Application { + public: + StencilTest(); + ~StencilTest(); + + bool Init(); + + protected: + virtual void Draw(float elapsed_sec); + + private: + ESContext context_; + STUserData user_data_; + + DISALLOW_COPY_AND_ASSIGN(StencilTest); +}; + +StencilTest::StencilTest() { + esInitContext(&context_); + + memset(&user_data_, 0, sizeof(STUserData)); + context_.userData = &user_data_; +} + +StencilTest::~StencilTest() { + stShutDown(&context_); +} + +bool StencilTest::Init() { + if (!Application::InitRenderContext()) return false; + + context_.width = width(); + context_.height = height(); + if (!stInit(&context_)) return false; + + return true; +} + +void StencilTest::Draw(float /*elapsed_sec*/) { + stDraw(&context_); +} +} // namespace gpu_demos + +int main(int argc, char *argv[]) { + gpu_demos::StencilTest app; + if (!app.Init()) { + printf("Could not init.\n"); + return EXIT_FAILURE; + } + + app.MainLoop(); + return EXIT_SUCCESS; +} |