OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This is a simple example that demonstrates generating a mipmap chain | 5 // This is a simple example that demonstrates generating a mipmap chain |
6 // and rendering with it. | 6 // and rendering with it. |
7 | 7 |
8 #include "gpu/demos/app_framework/application.h" | 8 #include "gpu/demos/gles2_book/example.h" |
9 #include "third_party/gles2_book/Chapter_9/MipMap2D/MipMap2D.h" | 9 #include "third_party/gles2_book/Chapter_9/MipMap2D/MipMap2D.h" |
10 | 10 |
11 namespace gpu_demos { | 11 namespace gpu { |
12 class MipMap2D : public Application { | 12 namespace demos { |
13 public: | 13 namespace gles2_book { |
14 MipMap2D(); | 14 typedef Example<MMUserData, |
15 ~MipMap2D(); | 15 mmInit, |
16 | 16 NoOpUpdateFunc, |
17 bool Init(); | 17 mmDraw, |
18 | 18 mmShutDown> MipMap2D; |
19 protected: | 19 } // namespace gles2_book |
20 virtual void Draw(float elapsed_sec); | 20 } // namespace demos |
21 | 21 } // namespace gpu |
22 private: | |
23 ESContext context_; | |
24 MMUserData user_data_; | |
25 | |
26 DISALLOW_COPY_AND_ASSIGN(MipMap2D); | |
27 }; | |
28 | |
29 MipMap2D::MipMap2D() { | |
30 esInitContext(&context_); | |
31 | |
32 memset(&user_data_, 0, sizeof(MMUserData)); | |
33 context_.userData = &user_data_; | |
34 } | |
35 | |
36 MipMap2D::~MipMap2D() { | |
37 mmShutDown(&context_); | |
38 } | |
39 | |
40 bool MipMap2D::Init() { | |
41 if (!Application::InitRenderContext()) return false; | |
42 | |
43 context_.width = width(); | |
44 context_.height = height(); | |
45 if (!mmInit(&context_)) return false; | |
46 | |
47 return true; | |
48 } | |
49 | |
50 void MipMap2D::Draw(float /*elapsed_sec*/) { | |
51 mmDraw(&context_); | |
52 } | |
53 } // namespace gpu_demos | |
54 | 22 |
55 int main(int argc, char *argv[]) { | 23 int main(int argc, char *argv[]) { |
56 gpu_demos::MipMap2D app; | 24 gpu::demos::gles2_book::MipMap2D demo; |
57 if (!app.Init()) { | 25 CHECK(demo.Init()); |
58 printf("Could not init.\n"); | |
59 return EXIT_FAILURE; | |
60 } | |
61 | 26 |
62 app.MainLoop(); | 27 demo.MainLoop(); |
63 return EXIT_SUCCESS; | 28 return EXIT_SUCCESS; |
64 } | 29 } |
OLD | NEW |