• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 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 #ifndef MOJO_EXAMPLES_SAMPLE_APP_SPINNING_CUBE_H_
6 #define MOJO_EXAMPLES_SAMPLE_APP_SPINNING_CUBE_H_
7 
8 #include <stdint.h>
9 
10 #include "base/memory/scoped_ptr.h"
11 
12 namespace mojo {
13 namespace examples {
14 
15 class SpinningCube {
16  public:
17   SpinningCube();
18   ~SpinningCube();
19 
20   void Init(uint32_t width, uint32_t height);
set_direction(int direction)21   void set_direction(int direction) { direction_ = direction; }
set_color(float r,float g,float b)22   void set_color(float r, float g, float b) {
23     color_[0] = r;
24     color_[1] = g;
25     color_[2] = b;
26   }
27   void SetFlingMultiplier(float drag_distance, float drag_time);
28   void UpdateForTimeDelta(float delta_time);
29   void UpdateForDragDistance(float distance);
30   void Draw();
31 
32   void OnGLContextLost();
33 
34  private:
35   class GLState;
36 
37   void Update();
38 
39   bool initialized_;
40   uint32_t width_;
41   uint32_t height_;
42   scoped_ptr<GLState> state_;
43   float fling_multiplier_;
44   int direction_;
45   float color_[3];
46 };
47 
48 }  // namespace examples
49 }  // namespace mojo
50 
51 #endif  // MOJO_EXAMPLES_SAMPLE_APP_SPINNING_CUBE_H_
52