OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef GL_GLEXT_PROTOTYPES | |
6 #define GL_GLEXT_PROTOTYPES | |
7 #endif | |
8 | |
5 #include "examples/spinning_cube/gles2_client_impl.h" | 9 #include "examples/spinning_cube/gles2_client_impl.h" |
6 | 10 |
7 #include <GLES2/gl2.h> | 11 #include <GLES2/gl2.h> |
8 #include <GLES2/gl2ext.h> | 12 #include <GLES2/gl2ext.h> |
13 #include <GLES2/gl2extchromium.h> | |
9 #include <math.h> | 14 #include <math.h> |
10 #include <stdlib.h> | 15 #include <stdlib.h> |
11 | 16 |
12 #include "gpu/command_buffer/client/gles2_interface.h" | |
13 #include "mojo/public/c/gles2/gles2.h" | 17 #include "mojo/public/c/gles2/gles2.h" |
14 #include "mojo/public/cpp/environment/environment.h" | 18 #include "mojo/public/cpp/environment/environment.h" |
15 #include "mojo/public/cpp/utility/run_loop.h" | 19 #include "mojo/public/cpp/utility/run_loop.h" |
16 | 20 |
17 namespace examples { | 21 namespace examples { |
18 namespace { | 22 namespace { |
19 | 23 |
20 float CalculateDragDistance(const mojo::PointF& start, | 24 float CalculateDragDistance(const mojo::PointF& start, |
21 const mojo::PointF& end) { | 25 const mojo::PointF& end) { |
22 return hypot(start.x - end.x, start.y - end.y); | 26 return hypot(start.x - end.x, start.y - end.y); |
(...skipping 18 matching lines...) Expand all Loading... | |
41 | 45 |
42 GLES2ClientImpl::~GLES2ClientImpl() { | 46 GLES2ClientImpl::~GLES2ClientImpl() { |
43 MojoGLES2DestroyContext(context_); | 47 MojoGLES2DestroyContext(context_); |
44 } | 48 } |
45 | 49 |
46 void GLES2ClientImpl::SetSize(const mojo::Size& size) { | 50 void GLES2ClientImpl::SetSize(const mojo::Size& size) { |
47 size_ = size; | 51 size_ = size; |
48 cube_.set_size(size_.width, size_.height); | 52 cube_.set_size(size_.width, size_.height); |
49 if (size_.width == 0 || size_.height == 0 || !context_) | 53 if (size_.width == 0 || size_.height == 0 || !context_) |
50 return; | 54 return; |
51 static_cast<gpu::gles2::GLES2Interface*>( | 55 glResizeCHROMIUM(size_.width, size_.height, 1); |
jamesr
2015/07/27 23:16:44
i think the last parameter is a float, so you shou
viettrungluu
2015/07/28 16:49:42
Done (good to be explicit I guess, even if int ->
| |
52 MojoGLES2GetGLES2Interface(context_))->ResizeCHROMIUM(size_.width, | |
53 size_.height, | |
54 1); | |
55 WantToDraw(); | 56 WantToDraw(); |
56 } | 57 } |
57 | 58 |
58 void GLES2ClientImpl::HandleInputEvent(const mojo::Event& event) { | 59 void GLES2ClientImpl::HandleInputEvent(const mojo::Event& event) { |
59 switch (event.action) { | 60 switch (event.action) { |
60 case mojo::EVENT_TYPE_POINTER_DOWN: | 61 case mojo::EVENT_TYPE_POINTER_DOWN: |
61 if (event.flags & mojo::EVENT_FLAGS_RIGHT_MOUSE_BUTTON) | 62 if (event.flags & mojo::EVENT_FLAGS_RIGHT_MOUSE_BUTTON) |
62 break; | 63 break; |
63 capture_point_.x = event.pointer_data->x; | 64 capture_point_.x = event.pointer_data->x; |
64 capture_point_.y = event.pointer_data->y; | 65 capture_point_.y = event.pointer_data->y; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 float delta = static_cast<float>(offset) / 1000000.; | 146 float delta = static_cast<float>(offset) / 1000000.; |
146 last_time_ = now; | 147 last_time_ = now; |
147 cube_.UpdateForTimeDelta(delta); | 148 cube_.UpdateForTimeDelta(delta); |
148 cube_.Draw(); | 149 cube_.Draw(); |
149 | 150 |
150 MojoGLES2SwapBuffers(); | 151 MojoGLES2SwapBuffers(); |
151 WantToDraw(); | 152 WantToDraw(); |
152 } | 153 } |
153 | 154 |
154 } // namespace examples | 155 } // namespace examples |
OLD | NEW |