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

Unified Diff: mojo/examples/sample_app/gles2_client_impl.cc

Issue 297113002: Change the color of the spinning cube on click. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mojo/examples/sample_app/spinning_cube.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/examples/sample_app/gles2_client_impl.cc
diff --git a/mojo/examples/sample_app/gles2_client_impl.cc b/mojo/examples/sample_app/gles2_client_impl.cc
index ca26b2d4f3dc4da0daec730e874bb297ef05f0db..1913b486e6690a8602ea34bf817adb31aa4b6f0e 100644
--- a/mojo/examples/sample_app/gles2_client_impl.cc
+++ b/mojo/examples/sample_app/gles2_client_impl.cc
@@ -7,6 +7,7 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <math.h>
+#include <stdlib.h>
#include "mojo/public/c/gles2/gles2.h"
#include "ui/events/event_constants.h"
@@ -19,6 +20,10 @@ float CalculateDragDistance(const gfx::PointF& start, const Point& end) {
return hypot(start.x() - end.x(), start.y() - end.y());
}
+float GetRandomColor() {
+ return static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
+}
+
}
GLES2ClientImpl::GLES2ClientImpl(ScopedMessagePipeHandle pipe)
@@ -74,6 +79,8 @@ void GLES2ClientImpl::HandleInputEvent(const Event& event) {
CalculateDragDistance(capture_point_, event.location()),
delta);
+ cube_.set_color(GetRandomColor(), GetRandomColor(), GetRandomColor());
+
capture_point_ = last_drag_point_ = gfx::PointF();
RequestAnimationFrames();
}
« no previous file with comments | « no previous file | mojo/examples/sample_app/spinning_cube.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698