Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: native_client_sdk/src/examples/api/graphics_3d/graphics_3d.cc

Issue 398943003: NaCl SDK: Demonstrate use of pp::View::GetDeviceScale for 3D (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add comment. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include <GLES2/gl2.h> 5 #include <GLES2/gl2.h>
6 #include <math.h> 6 #include <math.h>
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 mvp_loc_(0), 240 mvp_loc_(0),
241 x_angle_(0), 241 x_angle_(0),
242 y_angle_(0), 242 y_angle_(0),
243 animating_(true) {} 243 animating_(true) {}
244 244
245 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { 245 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) {
246 return true; 246 return true;
247 } 247 }
248 248
249 virtual void DidChangeView(const pp::View& view) { 249 virtual void DidChangeView(const pp::View& view) {
250 int32_t new_width = view.GetRect().width(); 250 // Pepper specifies dimensions in DIPs (device-independent pixels). To
251 int32_t new_height = view.GetRect().height(); 251 // generate a context that is at device-pixel resolution on HiDPI devices,
252 // scale the dimensions by view.GetDeviceScale().
253 int32_t new_width = view.GetRect().width() * view.GetDeviceScale();
254 int32_t new_height = view.GetRect().height() * view.GetDeviceScale();
252 255
253 if (context_.is_null()) { 256 if (context_.is_null()) {
254 if (!InitGL(new_width, new_height)) { 257 if (!InitGL(new_width, new_height)) {
255 // failed. 258 // failed.
256 return; 259 return;
257 } 260 }
258 261
259 InitShaders(); 262 InitShaders();
260 InitBuffers(); 263 InitBuffers();
261 InitTexture(); 264 InitTexture();
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 virtual ~Graphics3DModule() {} 500 virtual ~Graphics3DModule() {}
498 501
499 virtual pp::Instance* CreateInstance(PP_Instance instance) { 502 virtual pp::Instance* CreateInstance(PP_Instance instance) {
500 return new Graphics3DInstance(instance); 503 return new Graphics3DInstance(instance);
501 } 504 }
502 }; 505 };
503 506
504 namespace pp { 507 namespace pp {
505 Module* CreateModule() { return new Graphics3DModule(); } 508 Module* CreateModule() { return new Graphics3DModule(); }
506 } // namespace pp 509 } // namespace pp
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698