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 a simple example that draws a sphere with a cubemap image applied. |
| 6 |
| 7 #include "gpu/demos/app_framework/application.h" |
| 8 #include "third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureC
ubemap.h" |
| 9 |
| 10 namespace gpu_demos { |
| 11 class SimpleTextureCubemap : public Application { |
| 12 public: |
| 13 SimpleTextureCubemap(); |
| 14 ~SimpleTextureCubemap(); |
| 15 |
| 16 bool Init(); |
| 17 |
| 18 protected: |
| 19 virtual void Draw(float); |
| 20 |
| 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) { |
| 50 stcDraw(&context_); |
| 51 } |
| 52 } // namespace gpu_demos |
| 53 |
| 54 int main(int argc, char *argv[]) { |
| 55 gpu_demos::SimpleTextureCubemap app; |
| 56 if (!app.Init()) { |
| 57 printf("Could not init.\n"); |
| 58 return EXIT_FAILURE; |
| 59 } |
| 60 |
| 61 app.MainLoop(); |
| 62 return EXIT_SUCCESS; |
| 63 } |
OLD | NEW |