summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authoralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-19 21:23:59 +0000
committeralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-19 21:23:59 +0000
commit0192d0455dadef14e37ac526bf9902f142f3f592 (patch)
treed87dc175df20a3809eee15b9c7d0aeb9b0a5cd12 /gpu
parentfd2a9927ec151327e710f1fca66f5620e24f98dd (diff)
downloadchromium_src-0192d0455dadef14e37ac526bf9902f142f3f592.zip
chromium_src-0192d0455dadef14e37ac526bf9902f142f3f592.tar.gz
chromium_src-0192d0455dadef14e37ac526bf9902f142f3f592.tar.bz2
Converted all demos to use gpu::demos::Example base class.
Review URL: http://codereview.chromium.org/542120 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36551 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/demos/mip_map_2d/main.cc65
-rw-r--r--gpu/demos/simple_texture_2d/main.cc65
-rw-r--r--gpu/demos/simple_texture_cubemap/main.cc65
-rw-r--r--gpu/demos/simple_vertex_shader/main.cc67
-rw-r--r--gpu/demos/stencil_test/main.cc65
-rw-r--r--gpu/demos/texture_wrap/main.cc65
6 files changed, 90 insertions, 302 deletions
diff --git a/gpu/demos/mip_map_2d/main.cc b/gpu/demos/mip_map_2d/main.cc
index c201367..72818d0e 100644
--- a/gpu/demos/mip_map_2d/main.cc
+++ b/gpu/demos/mip_map_2d/main.cc
@@ -5,60 +5,25 @@
// This is a simple example that demonstrates generating a mipmap chain
// and rendering with it.
-#include "gpu/demos/app_framework/application.h"
+#include "gpu/demos/gles2_book/example.h"
#include "third_party/gles2_book/Chapter_9/MipMap2D/MipMap2D.h"
-namespace gpu_demos {
-class MipMap2D : public Application {
- public:
- MipMap2D();
- ~MipMap2D();
-
- bool Init();
-
- protected:
- virtual void Draw(float elapsed_sec);
-
- private:
- ESContext context_;
- MMUserData user_data_;
-
- DISALLOW_COPY_AND_ASSIGN(MipMap2D);
-};
-
-MipMap2D::MipMap2D() {
- esInitContext(&context_);
-
- memset(&user_data_, 0, sizeof(MMUserData));
- context_.userData = &user_data_;
-}
-
-MipMap2D::~MipMap2D() {
- mmShutDown(&context_);
-}
-
-bool MipMap2D::Init() {
- if (!Application::InitRenderContext()) return false;
-
- context_.width = width();
- context_.height = height();
- if (!mmInit(&context_)) return false;
-
- return true;
-}
-
-void MipMap2D::Draw(float /*elapsed_sec*/) {
- mmDraw(&context_);
-}
-} // namespace gpu_demos
+namespace gpu {
+namespace demos {
+namespace gles2_book {
+typedef Example<MMUserData,
+ mmInit,
+ NoOpUpdateFunc,
+ mmDraw,
+ mmShutDown> MipMap2D;
+} // namespace gles2_book
+} // namespace demos
+} // namespace gpu
int main(int argc, char *argv[]) {
- gpu_demos::MipMap2D app;
- if (!app.Init()) {
- printf("Could not init.\n");
- return EXIT_FAILURE;
- }
+ gpu::demos::gles2_book::MipMap2D demo;
+ CHECK(demo.Init());
- app.MainLoop();
+ demo.MainLoop();
return EXIT_SUCCESS;
}
diff --git a/gpu/demos/simple_texture_2d/main.cc b/gpu/demos/simple_texture_2d/main.cc
index e122f03..116f298 100644
--- a/gpu/demos/simple_texture_2d/main.cc
+++ b/gpu/demos/simple_texture_2d/main.cc
@@ -6,60 +6,25 @@
// texture image. The purpose of this example is to demonstrate
// the basics of 2D texturing
-#include "gpu/demos/app_framework/application.h"
+#include "gpu/demos/gles2_book/example.h"
#include "third_party/gles2_book/Chapter_9/Simple_Texture2D/Simple_Texture2D.h"
-namespace gpu_demos {
-class SimpleTexture2D : public Application {
- public:
- SimpleTexture2D();
- ~SimpleTexture2D();
-
- bool Init();
-
- protected:
- virtual void Draw(float elapsed_sec);
-
- private:
- ESContext context_;
- STUserData user_data_;
-
- DISALLOW_COPY_AND_ASSIGN(SimpleTexture2D);
-};
-
-SimpleTexture2D::SimpleTexture2D() {
- esInitContext(&context_);
-
- memset(&user_data_, 0, sizeof(STUserData));
- context_.userData = &user_data_;
-}
-
-SimpleTexture2D::~SimpleTexture2D() {
- stShutDown(&context_);
-}
-
-bool SimpleTexture2D::Init() {
- if (!Application::InitRenderContext()) return false;
-
- context_.width = width();
- context_.height = height();
- if (!stInit(&context_)) return false;
-
- return true;
-}
-
-void SimpleTexture2D::Draw(float /*elapsed_sec*/) {
- stDraw(&context_);
-}
-} // namespace gpu_demos
+namespace gpu {
+namespace demos {
+namespace gles2_book {
+typedef Example<STUserData,
+ stInit,
+ NoOpUpdateFunc,
+ stDraw,
+ stShutDown> SimpleTexture2D;
+} // namespace gles2_book
+} // namespace demos
+} // namespace gpu
int main(int argc, char *argv[]) {
- gpu_demos::SimpleTexture2D app;
- if (!app.Init()) {
- printf("Could not init.\n");
- return EXIT_FAILURE;
- }
+ gpu::demos::gles2_book::SimpleTexture2D demo;
+ CHECK(demo.Init());
- app.MainLoop();
+ demo.MainLoop();
return EXIT_SUCCESS;
}
diff --git a/gpu/demos/simple_texture_cubemap/main.cc b/gpu/demos/simple_texture_cubemap/main.cc
index d42f003..6317a2d 100644
--- a/gpu/demos/simple_texture_cubemap/main.cc
+++ b/gpu/demos/simple_texture_cubemap/main.cc
@@ -4,60 +4,25 @@
// This is a simple example that draws a sphere with a cubemap image applied.
-#include "gpu/demos/app_framework/application.h"
+#include "gpu/demos/gles2_book/example.h"
#include "third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.h"
-namespace gpu_demos {
-class SimpleTextureCubemap : public Application {
- public:
- SimpleTextureCubemap();
- ~SimpleTextureCubemap();
-
- bool Init();
-
- protected:
- virtual void Draw(float elapsed_sec);
-
- private:
- ESContext context_;
- STCUserData user_data_;
-
- DISALLOW_COPY_AND_ASSIGN(SimpleTextureCubemap);
-};
-
-SimpleTextureCubemap::SimpleTextureCubemap() {
- esInitContext(&context_);
-
- memset(&user_data_, 0, sizeof(STCUserData));
- context_.userData = &user_data_;
-}
-
-SimpleTextureCubemap::~SimpleTextureCubemap() {
- stcShutDown(&context_);
-}
-
-bool SimpleTextureCubemap::Init() {
- if (!Application::InitRenderContext()) return false;
-
- context_.width = width();
- context_.height = height();
- if (!stcInit(&context_)) return false;
-
- return true;
-}
-
-void SimpleTextureCubemap::Draw(float /*elapsed_sec*/) {
- stcDraw(&context_);
-}
-} // namespace gpu_demos
+namespace gpu {
+namespace demos {
+namespace gles2_book {
+typedef Example<STCUserData,
+ stcInit,
+ NoOpUpdateFunc,
+ stcDraw,
+ stcShutDown> SimpleTextureCubemap;
+} // namespace gles2_book
+} // namespace demos
+} // namespace gpu
int main(int argc, char *argv[]) {
- gpu_demos::SimpleTextureCubemap app;
- if (!app.Init()) {
- printf("Could not init.\n");
- return EXIT_FAILURE;
- }
+ gpu::demos::gles2_book::SimpleTextureCubemap demo;
+ CHECK(demo.Init());
- app.MainLoop();
+ demo.MainLoop();
return EXIT_SUCCESS;
}
diff --git a/gpu/demos/simple_vertex_shader/main.cc b/gpu/demos/simple_vertex_shader/main.cc
index 350c5d7..87978fc 100644
--- a/gpu/demos/simple_vertex_shader/main.cc
+++ b/gpu/demos/simple_vertex_shader/main.cc
@@ -7,62 +7,25 @@
// example is to demonstrate the basic concepts of
// OpenGL ES 2.0 rendering.
-#include "gpu/demos/app_framework/application.h"
+#include "gpu/demos/gles2_book/example.h"
#include "third_party/gles2_book/Chapter_8/Simple_VertexShader/Simple_VertexShader.h"
-namespace gpu_demos {
-class SimpleVertexShader : public Application {
- public:
- SimpleVertexShader();
- ~SimpleVertexShader();
-
- bool Init();
-
- protected:
- virtual void Draw(float elapsed_sec);
-
- private:
- ESContext context_;
- SVSUserData user_data_;
-
- DISALLOW_COPY_AND_ASSIGN(SimpleVertexShader);
-};
-
-SimpleVertexShader::SimpleVertexShader() {
- esInitContext(&context_);
-
- memset(&user_data_, 0, sizeof(SVSUserData));
- context_.userData = &user_data_;
-}
-
-SimpleVertexShader::~SimpleVertexShader() {
- svsShutDown(&context_);
-}
-
-bool SimpleVertexShader::Init() {
- if (!Application::InitRenderContext()) return false;
-
- context_.width = width();
- context_.height = height();
- if (!svsInit(&context_)) return false;
-
- return true;
-}
-
-void SimpleVertexShader::Draw(float elapsed_sec) {
- svsUpdate(&context_, elapsed_sec);
-
- svsDraw(&context_);
-}
-} // namespace gpu_demos
+namespace gpu {
+namespace demos {
+namespace gles2_book {
+typedef Example<SVSUserData,
+ svsInit,
+ svsUpdate,
+ svsDraw,
+ svsShutDown> SimpleVertexShader;
+} // namespace gles2_book
+} // namespace demos
+} // namespace gpu
int main(int argc, char *argv[]) {
- gpu_demos::SimpleVertexShader app;
- if (!app.Init()) {
- printf("Could not init.\n");
- return EXIT_FAILURE;
- }
+ gpu::demos::gles2_book::SimpleVertexShader demo;
+ CHECK(demo.Init());
- app.MainLoop();
+ demo.MainLoop();
return EXIT_SUCCESS;
}
diff --git a/gpu/demos/stencil_test/main.cc b/gpu/demos/stencil_test/main.cc
index a0009cc..9489fee 100644
--- a/gpu/demos/stencil_test/main.cc
+++ b/gpu/demos/stencil_test/main.cc
@@ -4,60 +4,25 @@
// This example shows various stencil buffer operations.
-#include "gpu/demos/app_framework/application.h"
+#include "gpu/demos/gles2_book/example.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
+namespace gpu {
+namespace demos {
+namespace gles2_book {
+typedef Example<STUserData,
+ stInit,
+ NoOpUpdateFunc,
+ stDraw,
+ stShutDown> StencilTest;
+} // namespace gles2_book
+} // namespace demos
+} // namespace gpu
int main(int argc, char *argv[]) {
- gpu_demos::StencilTest app;
- if (!app.Init()) {
- printf("Could not init.\n");
- return EXIT_FAILURE;
- }
+ gpu::demos::gles2_book::StencilTest demo;
+ CHECK(demo.Init());
- app.MainLoop();
+ demo.MainLoop();
return EXIT_SUCCESS;
}
diff --git a/gpu/demos/texture_wrap/main.cc b/gpu/demos/texture_wrap/main.cc
index 8f240ed..4c2a86e 100644
--- a/gpu/demos/texture_wrap/main.cc
+++ b/gpu/demos/texture_wrap/main.cc
@@ -5,60 +5,25 @@
// This is an example that demonstrates the three texture
// wrap modes available on 2D textures.
-#include "gpu/demos/app_framework/application.h"
+#include "gpu/demos/gles2_book/example.h"
#include "third_party/gles2_book/Chapter_9/TextureWrap/TextureWrap.h"
-namespace gpu_demos {
-class TextureWrap : public Application {
- public:
- TextureWrap();
- ~TextureWrap();
-
- bool Init();
-
- protected:
- virtual void Draw(float elapsed_sec);
-
- private:
- ESContext context_;
- TWUserData user_data_;
-
- DISALLOW_COPY_AND_ASSIGN(TextureWrap);
-};
-
-TextureWrap::TextureWrap() {
- esInitContext(&context_);
-
- memset(&user_data_, 0, sizeof(TWUserData));
- context_.userData = &user_data_;
-}
-
-TextureWrap::~TextureWrap() {
- twShutDown(&context_);
-}
-
-bool TextureWrap::Init() {
- if (!Application::InitRenderContext()) return false;
-
- context_.width = width();
- context_.height = height();
- if (!twInit(&context_)) return false;
-
- return true;
-}
-
-void TextureWrap::Draw(float /*elapsed_sec*/) {
- twDraw(&context_);
-}
-} // namespace gpu_demos
+namespace gpu {
+namespace demos {
+namespace gles2_book {
+typedef Example<TWUserData,
+ twInit,
+ NoOpUpdateFunc,
+ twDraw,
+ twShutDown> TextureWrap;
+} // namespace gles2_book
+} // namespace demos
+} // namespace gpu
int main(int argc, char *argv[]) {
- gpu_demos::TextureWrap app;
- if (!app.Init()) {
- printf("Could not init.\n");
- return EXIT_FAILURE;
- }
+ gpu::demos::gles2_book::TextureWrap demo;
+ CHECK(demo.Init());
- app.MainLoop();
+ demo.MainLoop();
return EXIT_SUCCESS;
}