OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This is an example that demonstrates the three texture |
| 6 // wrap modes available on 2D textures. |
| 7 |
| 8 #include "gpu/demos/app_framework/application.h" |
| 9 #include "third_party/gles2_book/Chapter_9/TextureWrap/TextureWrap.h" |
| 10 |
| 11 namespace gpu_demos { |
| 12 class TextureWrap : public Application { |
| 13 public: |
| 14 TextureWrap(); |
| 15 ~TextureWrap(); |
| 16 |
| 17 bool Init(); |
| 18 |
| 19 protected: |
| 20 virtual void Draw(float elapsed_sec); |
| 21 |
| 22 private: |
| 23 ESContext context_; |
| 24 TWUserData user_data_; |
| 25 |
| 26 DISALLOW_COPY_AND_ASSIGN(TextureWrap); |
| 27 }; |
| 28 |
| 29 TextureWrap::TextureWrap() { |
| 30 esInitContext(&context_); |
| 31 |
| 32 memset(&user_data_, 0, sizeof(TWUserData)); |
| 33 context_.userData = &user_data_; |
| 34 } |
| 35 |
| 36 TextureWrap::~TextureWrap() { |
| 37 twShutDown(&context_); |
| 38 } |
| 39 |
| 40 bool TextureWrap::Init() { |
| 41 if (!Application::InitRenderContext()) return false; |
| 42 |
| 43 context_.width = width(); |
| 44 context_.height = height(); |
| 45 if (!twInit(&context_)) return false; |
| 46 |
| 47 return true; |
| 48 } |
| 49 |
| 50 void TextureWrap::Draw(float /*elapsed_sec*/) { |
| 51 twDraw(&context_); |
| 52 } |
| 53 } // namespace gpu_demos |
| 54 |
| 55 int main(int argc, char *argv[]) { |
| 56 gpu_demos::TextureWrap app; |
| 57 if (!app.Init()) { |
| 58 printf("Could not init.\n"); |
| 59 return EXIT_FAILURE; |
| 60 } |
| 61 |
| 62 app.MainLoop(); |
| 63 return EXIT_SUCCESS; |
| 64 } |
OLD | NEW |