| 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/app_framework/application.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_demos { |
| 12 class MipMap2D : public Application { | 12 class MipMap2D : public Application { |
| 13 public: | 13 public: |
| 14 MipMap2D(); | 14 MipMap2D(); |
| 15 ~MipMap2D(); | 15 ~MipMap2D(); |
| 16 | 16 |
| 17 bool Init(); | 17 bool Init(); |
| 18 | 18 |
| 19 protected: | 19 protected: |
| 20 virtual void Draw(float); | 20 virtual void Draw(float elapsed_sec); |
| 21 | 21 |
| 22 private: | 22 private: |
| 23 ESContext context_; | 23 ESContext context_; |
| 24 MMUserData user_data_; | 24 MMUserData user_data_; |
| 25 | 25 |
| 26 DISALLOW_COPY_AND_ASSIGN(MipMap2D); | 26 DISALLOW_COPY_AND_ASSIGN(MipMap2D); |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 MipMap2D::MipMap2D() { | 29 MipMap2D::MipMap2D() { |
| 30 esInitContext(&context_); | 30 esInitContext(&context_); |
| 31 | 31 |
| 32 memset(&user_data_, 0, sizeof(MMUserData)); | 32 memset(&user_data_, 0, sizeof(MMUserData)); |
| 33 context_.userData = &user_data_; | 33 context_.userData = &user_data_; |
| 34 } | 34 } |
| 35 | 35 |
| 36 MipMap2D::~MipMap2D() { | 36 MipMap2D::~MipMap2D() { |
| 37 mmShutDown(&context_); | 37 mmShutDown(&context_); |
| 38 } | 38 } |
| 39 | 39 |
| 40 bool MipMap2D::Init() { | 40 bool MipMap2D::Init() { |
| 41 if (!Application::InitRenderContext()) return false; | 41 if (!Application::InitRenderContext()) return false; |
| 42 | 42 |
| 43 context_.width = width(); | 43 context_.width = width(); |
| 44 context_.height = height(); | 44 context_.height = height(); |
| 45 if (!mmInit(&context_)) return false; | 45 if (!mmInit(&context_)) return false; |
| 46 | 46 |
| 47 return true; | 47 return true; |
| 48 } | 48 } |
| 49 | 49 |
| 50 void MipMap2D::Draw(float) { | 50 void MipMap2D::Draw(float /*elapsed_sec*/) { |
| 51 mmDraw(&context_); | 51 mmDraw(&context_); |
| 52 } | 52 } |
| 53 } // namespace gpu_demos | 53 } // namespace gpu_demos |
| 54 | 54 |
| 55 int main(int argc, char *argv[]) { | 55 int main(int argc, char *argv[]) { |
| 56 gpu_demos::MipMap2D app; | 56 gpu_demos::MipMap2D app; |
| 57 if (!app.Init()) { | 57 if (!app.Init()) { |
| 58 printf("Could not init.\n"); | 58 printf("Could not init.\n"); |
| 59 return EXIT_FAILURE; | 59 return EXIT_FAILURE; |
| 60 } | 60 } |
| 61 | 61 |
| 62 app.MainLoop(); | 62 app.MainLoop(); |
| 63 return EXIT_SUCCESS; | 63 return EXIT_SUCCESS; |
| 64 } | 64 } |
| OLD | NEW |