summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-05 21:26:39 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-05 21:26:39 +0000
commit1819ba241b4e6d1143e54f161d738caf5cbdabd4 (patch)
treed6955150efc67815087ed74191da3daab2175081
parent434c8fbb60314945b5f3474d2867adbf96c2b184 (diff)
downloadchromium_src-1819ba241b4e6d1143e54f161d738caf5cbdabd4.zip
chromium_src-1819ba241b4e6d1143e54f161d738caf5cbdabd4.tar.gz
chromium_src-1819ba241b4e6d1143e54f161d738caf5cbdabd4.tar.bz2
bring back deleted folder
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215689 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--gpu/demos/gles2_book/demo_hello_triangle.cc35
-rw-r--r--gpu/demos/gles2_book/demo_mip_map_2d.cc33
-rw-r--r--gpu/demos/gles2_book/demo_simple_texture_2d.cc34
-rw-r--r--gpu/demos/gles2_book/demo_simple_texture_cubemap.cc32
-rw-r--r--gpu/demos/gles2_book/demo_simple_vertex_shader.cc37
-rw-r--r--gpu/demos/gles2_book/demo_stencil_test.cc32
-rw-r--r--gpu/demos/gles2_book/demo_texture_wrap.cc33
-rw-r--r--gpu/demos/gles2_book/example.h91
8 files changed, 327 insertions, 0 deletions
diff --git a/gpu/demos/gles2_book/demo_hello_triangle.cc b/gpu/demos/gles2_book/demo_hello_triangle.cc
new file mode 100644
index 0000000..806a0dd
--- /dev/null
+++ b/gpu/demos/gles2_book/demo_hello_triangle.cc
@@ -0,0 +1,35 @@
+// 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 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/framework/demo_factory.h"
+#include "gpu/demos/gles2_book/example.h"
+#include "third_party/gles2_book/Chapter_2/Hello_Triangle/Hello_Triangle.h"
+
+namespace gpu {
+namespace demos {
+
+namespace gles2_book {
+class HelloTriangle : public Example<HTUserData> {
+ public:
+ HelloTriangle() {
+ RegisterCallbacks(htInit, NULL, htDraw, htShutDown);
+ }
+
+ const wchar_t* Title() const {
+ return L"Hello Triangle";
+ }
+};
+} // namespace gles2_book
+
+Demo* CreateDemo() {
+ return new gles2_book::HelloTriangle();
+}
+
+} // namespace demos
+} // namespace gpu
diff --git a/gpu/demos/gles2_book/demo_mip_map_2d.cc b/gpu/demos/gles2_book/demo_mip_map_2d.cc
new file mode 100644
index 0000000..fcb5c3b
--- /dev/null
+++ b/gpu/demos/gles2_book/demo_mip_map_2d.cc
@@ -0,0 +1,33 @@
+// 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 is a simple example that demonstrates generating a mipmap chain
+// and rendering with it.
+
+#include "gpu/demos/framework/demo_factory.h"
+#include "gpu/demos/gles2_book/example.h"
+#include "third_party/gles2_book/Chapter_9/MipMap2D/MipMap2D.h"
+
+namespace gpu {
+namespace demos {
+
+namespace gles2_book {
+class MipMap2D : public Example<MMUserData> {
+ public:
+ MipMap2D() {
+ RegisterCallbacks(mmInit, NULL, mmDraw, mmShutDown);
+ }
+
+ const wchar_t* Title() const {
+ return L"Mip-Map 2D";
+ }
+};
+} // namespace gles2_book
+
+Demo* CreateDemo() {
+ return new gles2_book::MipMap2D();
+}
+
+} // namespace demos
+} // namespace gpu
diff --git a/gpu/demos/gles2_book/demo_simple_texture_2d.cc b/gpu/demos/gles2_book/demo_simple_texture_2d.cc
new file mode 100644
index 0000000..3f4eff6
--- /dev/null
+++ b/gpu/demos/gles2_book/demo_simple_texture_2d.cc
@@ -0,0 +1,34 @@
+// 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 is a simple example that draws a quad with a 2D
+// texture image. The purpose of this example is to demonstrate
+// the basics of 2D texturing.
+
+#include "gpu/demos/framework/demo_factory.h"
+#include "gpu/demos/gles2_book/example.h"
+#include "third_party/gles2_book/Chapter_9/Simple_Texture2D/Simple_Texture2D.h"
+
+namespace gpu {
+namespace demos {
+
+namespace gles2_book {
+class SimpleTexture2D : public Example<STUserData> {
+ public:
+ SimpleTexture2D() {
+ RegisterCallbacks(stInit, NULL, stDraw, stShutDown);
+ }
+
+ const wchar_t* Title() const {
+ return L"Simple Texture 2D";
+ }
+};
+} // namespace gles2_book
+
+Demo* CreateDemo() {
+ return new gles2_book::SimpleTexture2D();
+}
+
+} // namespace demos
+} // namespace gpu
diff --git a/gpu/demos/gles2_book/demo_simple_texture_cubemap.cc b/gpu/demos/gles2_book/demo_simple_texture_cubemap.cc
new file mode 100644
index 0000000..6db525b
--- /dev/null
+++ b/gpu/demos/gles2_book/demo_simple_texture_cubemap.cc
@@ -0,0 +1,32 @@
+// 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 is a simple example that draws a sphere with a cubemap image applied.
+
+#include "gpu/demos/framework/demo_factory.h"
+#include "gpu/demos/gles2_book/example.h"
+#include "third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.h"
+
+namespace gpu {
+namespace demos {
+
+namespace gles2_book {
+class SimpleTextureCubemap : public Example<STCUserData> {
+ public:
+ SimpleTextureCubemap() {
+ RegisterCallbacks(stcInit, NULL, stcDraw, stcShutDown);
+ }
+
+ const wchar_t* Title() const {
+ return L"Simple Texture Cubemap";
+ }
+};
+} // namespace gles2_book
+
+Demo* CreateDemo() {
+ return new gles2_book::SimpleTextureCubemap();
+}
+
+} // namespace demos
+} // namespace gpu
diff --git a/gpu/demos/gles2_book/demo_simple_vertex_shader.cc b/gpu/demos/gles2_book/demo_simple_vertex_shader.cc
new file mode 100644
index 0000000..0f8b72e
--- /dev/null
+++ b/gpu/demos/gles2_book/demo_simple_vertex_shader.cc
@@ -0,0 +1,37 @@
+// 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 is a simple example that draws a rotating cube in perspective
+// using a vertex shader to transform the object.
+
+#include "gpu/demos/framework/demo_factory.h"
+#include "gpu/demos/gles2_book/example.h"
+#include "third_party/gles2_book/Chapter_8/Simple_VertexShader/Simple_VertexShader.h"
+
+namespace gpu {
+namespace demos {
+
+namespace gles2_book {
+class SimpleVertexShader : public Example<SVSUserData> {
+ public:
+ SimpleVertexShader() {
+ RegisterCallbacks(svsInit, svsUpdate, svsDraw, svsShutDown);
+ }
+
+ const wchar_t* Title() const {
+ return L"Simple Vertex Shader";
+ }
+
+ virtual bool IsAnimated() {
+ return true;
+ }
+};
+} // namespace gles2_book
+
+Demo* CreateDemo() {
+ return new gles2_book::SimpleVertexShader();
+}
+
+} // namespace demos
+} // namespace gpu
diff --git a/gpu/demos/gles2_book/demo_stencil_test.cc b/gpu/demos/gles2_book/demo_stencil_test.cc
new file mode 100644
index 0000000..66be791
--- /dev/null
+++ b/gpu/demos/gles2_book/demo_stencil_test.cc
@@ -0,0 +1,32 @@
+// 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/framework/demo_factory.h"
+#include "gpu/demos/gles2_book/example.h"
+#include "third_party/gles2_book/Chapter_11/Stencil_Test/Stencil_Test.h"
+
+namespace gpu {
+namespace demos {
+
+namespace gles2_book {
+class StencilTest : public Example<STUserData> {
+ public:
+ StencilTest() {
+ RegisterCallbacks(stInit, NULL, stDraw, stShutDown);
+ }
+
+ const wchar_t* Title() const {
+ return L"Stencil Test";
+ }
+};
+} // namespace gles2_book
+
+Demo* CreateDemo() {
+ return new gles2_book::StencilTest();
+}
+
+} // namespace demos
+} // namespace gpu
diff --git a/gpu/demos/gles2_book/demo_texture_wrap.cc b/gpu/demos/gles2_book/demo_texture_wrap.cc
new file mode 100644
index 0000000..a3fb3ba
--- /dev/null
+++ b/gpu/demos/gles2_book/demo_texture_wrap.cc
@@ -0,0 +1,33 @@
+// 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 is an example that demonstrates the three texture
+// wrap modes available on 2D textures.
+
+#include "gpu/demos/framework/demo_factory.h"
+#include "gpu/demos/gles2_book/example.h"
+#include "third_party/gles2_book/Chapter_9/TextureWrap/TextureWrap.h"
+
+namespace gpu {
+namespace demos {
+
+namespace gles2_book {
+class TextureWrap : public Example<TWUserData> {
+ public:
+ TextureWrap() {
+ RegisterCallbacks(twInit, NULL, twDraw, twShutDown);
+ }
+
+ const wchar_t* Title() const {
+ return L"Texture Wrap";
+ }
+};
+} // namespace gles2_book
+
+Demo* CreateDemo() {
+ return new gles2_book::TextureWrap();
+}
+
+} // namespace demos
+} // namespace gpu
diff --git a/gpu/demos/gles2_book/example.h b/gpu/demos/gles2_book/example.h
new file mode 100644
index 0000000..0eaf1a4
--- /dev/null
+++ b/gpu/demos/gles2_book/example.h
@@ -0,0 +1,91 @@
+// Copyright (c) 2006-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.
+
+// Base class for OpenGL ES 2.0 book examples.
+
+#ifndef GPU_DEMOS_GLES2_BOOK_EXAMPLE_H_
+#define GPU_DEMOS_GLES2_BOOK_EXAMPLE_H_
+
+#include <cassert>
+#include <cstring>
+
+#include "gpu/demos/framework/demo.h"
+#include "third_party/gles2_book/Common/Include/esUtil.h"
+
+namespace gpu {
+namespace demos {
+namespace gles2_book {
+
+typedef int InitFunc(ESContext* context);
+typedef void UpdateFunc(ESContext* context, float elapsed_sec);
+typedef void DrawFunc(ESContext* context);
+typedef void ShutDownFunc(ESContext* context);
+
+// The examples taken from OpenGL 2.0 ES book follow a well-defined pattern.
+// They all use one ESContext that holds a reference to a custom UserData.
+// Each example provides four functions:
+// 1. InitFunc to initialize OpenGL state and custom UserData
+// 2. UpdateFunc is called before drawing each frame to update animation etc.
+// 3. DrawFunc is called to do the actual frame rendering
+// 4. ShutDownFunc is called when program terminates
+// This class encapsulates this pattern to make it easier to write classes
+// for each example.
+template <typename UserData>
+class Example : public gpu::demos::Demo {
+ public:
+ Example()
+ : init_func_(NULL),
+ update_func_(NULL),
+ draw_func_(NULL),
+ shut_down_func_(NULL) {
+ esInitContext(&context_);
+ memset(&user_data_, 0, sizeof(UserData));
+ context_.userData = &user_data_;
+ }
+ virtual ~Example() {
+ shut_down_func_(&context_);
+ }
+
+ virtual bool InitGL() {
+ // Note that update_func is optional.
+ assert(init_func_ && draw_func_ && shut_down_func_);
+
+ if (!init_func_(&context_)) return false;
+ return true;
+ }
+
+ protected:
+ void RegisterCallbacks(InitFunc* init_func,
+ UpdateFunc* update_func,
+ DrawFunc* draw_func,
+ ShutDownFunc* shut_down_func) {
+ init_func_ = init_func;
+ update_func_ = update_func;
+ draw_func_ = draw_func;
+ shut_down_func_ = shut_down_func;
+ }
+
+ virtual void Render(float elapsed_sec) {
+ context_.width = width();
+ context_.height = height();
+
+ if (update_func_) update_func_(&context_, elapsed_sec);
+ draw_func_(&context_);
+ }
+
+ private:
+ ESContext context_;
+ UserData user_data_;
+
+ // Callback functions.
+ InitFunc* init_func_;
+ UpdateFunc* update_func_;
+ DrawFunc* draw_func_;
+ ShutDownFunc* shut_down_func_;
+};
+
+} // namespace gles2_book
+} // namespace demos
+} // namespace gpu
+#endif // GPU_DEMOS_GLES2_BOOK_EXAMPLE_H_