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