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 draws a sphere with a cubemap image applied. | 5 // This is a simple example that draws a sphere with a cubemap image applied. |
6 | 6 |
7 #include "gpu/demos/app_framework/application.h" | 7 #include "gpu/demos/gles2_book/example.h" |
8 #include "third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureC
ubemap.h" | 8 #include "third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureC
ubemap.h" |
9 | 9 |
10 namespace gpu_demos { | 10 namespace gpu { |
11 class SimpleTextureCubemap : public Application { | 11 namespace demos { |
12 public: | 12 namespace gles2_book { |
13 SimpleTextureCubemap(); | 13 typedef Example<STCUserData, |
14 ~SimpleTextureCubemap(); | 14 stcInit, |
15 | 15 NoOpUpdateFunc, |
16 bool Init(); | 16 stcDraw, |
17 | 17 stcShutDown> SimpleTextureCubemap; |
18 protected: | 18 } // namespace gles2_book |
19 virtual void Draw(float elapsed_sec); | 19 } // namespace demos |
20 | 20 } // namespace gpu |
21 private: | |
22 ESContext context_; | |
23 STCUserData user_data_; | |
24 | |
25 DISALLOW_COPY_AND_ASSIGN(SimpleTextureCubemap); | |
26 }; | |
27 | |
28 SimpleTextureCubemap::SimpleTextureCubemap() { | |
29 esInitContext(&context_); | |
30 | |
31 memset(&user_data_, 0, sizeof(STCUserData)); | |
32 context_.userData = &user_data_; | |
33 } | |
34 | |
35 SimpleTextureCubemap::~SimpleTextureCubemap() { | |
36 stcShutDown(&context_); | |
37 } | |
38 | |
39 bool SimpleTextureCubemap::Init() { | |
40 if (!Application::InitRenderContext()) return false; | |
41 | |
42 context_.width = width(); | |
43 context_.height = height(); | |
44 if (!stcInit(&context_)) return false; | |
45 | |
46 return true; | |
47 } | |
48 | |
49 void SimpleTextureCubemap::Draw(float /*elapsed_sec*/) { | |
50 stcDraw(&context_); | |
51 } | |
52 } // namespace gpu_demos | |
53 | 21 |
54 int main(int argc, char *argv[]) { | 22 int main(int argc, char *argv[]) { |
55 gpu_demos::SimpleTextureCubemap app; | 23 gpu::demos::gles2_book::SimpleTextureCubemap demo; |
56 if (!app.Init()) { | 24 CHECK(demo.Init()); |
57 printf("Could not init.\n"); | |
58 return EXIT_FAILURE; | |
59 } | |
60 | 25 |
61 app.MainLoop(); | 26 demo.MainLoop(); |
62 return EXIT_SUCCESS; | 27 return EXIT_SUCCESS; |
63 } | 28 } |
OLD | NEW |