| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 5 |
| 6 #include <algorithm> | 6 #include <algorithm> |
| 7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
| 8 | 8 |
| 9 #include "ppapi/gles2/gl2ext_ppapi.h" | 9 #include "ppapi/gles2/gl2ext_ppapi.h" |
| 10 | 10 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 glBindBuffer(GL_ARRAY_BUFFER, 0); | 224 glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 225 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cube_vbos_[2]); | 225 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cube_vbos_[2]); |
| 226 glBufferData(GL_ELEMENT_ARRAY_BUFFER, | 226 glBufferData(GL_ELEMENT_ARRAY_BUFFER, |
| 227 kIndexCount * sizeof(GL_UNSIGNED_SHORT), | 227 kIndexCount * sizeof(GL_UNSIGNED_SHORT), |
| 228 cube_indices, | 228 cube_indices, |
| 229 GL_STATIC_DRAW); | 229 GL_STATIC_DRAW); |
| 230 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); | 230 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
| 231 } | 231 } |
| 232 | 232 |
| 233 void Cube::ComputeModelViewTransform(GLfloat* model_view) { | 233 void Cube::ComputeModelViewTransform(GLfloat* model_view) { |
| 234 // This method takes into account the possiblity that |orientation_| | 234 // This method takes into account the possibility that |orientation_| |
| 235 // might not be normalized. | 235 // might not be normalized. |
| 236 double sqrx = orientation_[0] * orientation_[0]; | 236 double sqrx = orientation_[0] * orientation_[0]; |
| 237 double sqry = orientation_[1] * orientation_[1]; | 237 double sqry = orientation_[1] * orientation_[1]; |
| 238 double sqrz = orientation_[2] * orientation_[2]; | 238 double sqrz = orientation_[2] * orientation_[2]; |
| 239 double sqrw = orientation_[3] * orientation_[3]; | 239 double sqrw = orientation_[3] * orientation_[3]; |
| 240 double sqrLength = 1.0 / (sqrx + sqry + sqrz + sqrw); | 240 double sqrLength = 1.0 / (sqrx + sqry + sqrz + sqrw); |
| 241 | 241 |
| 242 transform_4x4::LoadIdentity(model_view); | 242 transform_4x4::LoadIdentity(model_view); |
| 243 model_view[0] = (sqrx - sqry - sqrz + sqrw) * sqrLength; | 243 model_view[0] = (sqrx - sqry - sqrz + sqrw) * sqrLength; |
| 244 model_view[5] = (-sqrx + sqry - sqrz + sqrw) * sqrLength; | 244 model_view[5] = (-sqrx + sqry - sqrz + sqrw) * sqrLength; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 263 | 263 |
| 264 // Concatenate the translation to the eye point. | 264 // Concatenate the translation to the eye point. |
| 265 model_view[12] = -eye_[0]; | 265 model_view[12] = -eye_[0]; |
| 266 model_view[13] = -eye_[1]; | 266 model_view[13] = -eye_[1]; |
| 267 model_view[14] = -eye_[2]; | 267 model_view[14] = -eye_[2]; |
| 268 model_view[15] = 1.0; | 268 model_view[15] = 1.0; |
| 269 } | 269 } |
| 270 | 270 |
| 271 } // namespace tumbler | 271 } // namespace tumbler |
| 272 | 272 |
| OLD | NEW |