OLD | NEW |
| (Empty) |
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 #include "mojo/examples/sample_app/sample_gles2_delegate.h" | |
6 | |
7 #include <stdio.h> | |
8 #include <GLES2/gl2.h> | |
9 #include <GLES2/gl2ext.h> | |
10 | |
11 namespace mojo { | |
12 namespace examples { | |
13 | |
14 SampleGLES2Delegate::SampleGLES2Delegate() | |
15 : gl_(NULL) { | |
16 } | |
17 | |
18 SampleGLES2Delegate::~SampleGLES2Delegate() { | |
19 } | |
20 | |
21 void SampleGLES2Delegate::DidCreateContext( | |
22 GLES2ClientImpl* gl, uint32_t width, uint32_t height) { | |
23 gl_ = gl; | |
24 cube_.Init(width, height); | |
25 last_time_ = base::Time::Now(); | |
26 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(16), | |
27 this, &SampleGLES2Delegate::Draw); | |
28 } | |
29 | |
30 void SampleGLES2Delegate::Draw() { | |
31 base::Time now = base::Time::Now(); | |
32 base::TimeDelta offset = now - last_time_; | |
33 last_time_ = now; | |
34 cube_.Update(offset.InSecondsF()); | |
35 cube_.Draw(); | |
36 gl_->SwapBuffers(); | |
37 } | |
38 | |
39 void SampleGLES2Delegate::ContextLost(GLES2ClientImpl* gl) { | |
40 gl_ = NULL; | |
41 timer_.Stop(); | |
42 } | |
43 | |
44 } // namespace examples | |
45 } // namespace mojo | |
OLD | NEW |