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/gles2_client_impl.h" |
| 6 |
| 7 #include <GLES2/gl2.h> |
| 8 #include <GLES2/gl2ext.h> |
| 9 |
| 10 #include "mojo/public/gles2/gles2.h" |
| 11 |
| 12 namespace mojo { |
| 13 namespace examples { |
| 14 |
| 15 GLES2ClientImpl::GLES2ClientImpl(ScopedMessagePipeHandle pipe) |
| 16 : service_(pipe.Pass()) { |
| 17 service_.SetPeer(this); |
| 18 } |
| 19 |
| 20 GLES2ClientImpl::~GLES2ClientImpl() { |
| 21 service_->Destroy(); |
| 22 } |
| 23 |
| 24 void GLES2ClientImpl::DidCreateContext(uint64_t encoded, |
| 25 uint32_t width, |
| 26 uint32_t height) { |
| 27 MojoGLES2MakeCurrent(encoded); |
| 28 |
| 29 cube_.Init(width, height); |
| 30 last_time_ = base::Time::Now(); |
| 31 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(16), |
| 32 this, &GLES2ClientImpl::Draw); |
| 33 } |
| 34 |
| 35 void GLES2ClientImpl::Draw() { |
| 36 base::Time now = base::Time::Now(); |
| 37 base::TimeDelta offset = now - last_time_; |
| 38 last_time_ = now; |
| 39 cube_.Update(offset.InSecondsF()); |
| 40 cube_.Draw(); |
| 41 |
| 42 MojoGLES2SwapBuffers(); |
| 43 } |
| 44 |
| 45 void GLES2ClientImpl::ContextLost() { |
| 46 timer_.Stop(); |
| 47 } |
| 48 |
| 49 } // namespace examples |
| 50 } // namespace mojo |
OLD | NEW |