| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/android/vr_shell/vr_shell_renderer.h" | 5 #include "chrome/browser/android/vr_shell/vr_shell_renderer.h" |
| 6 | 6 |
| 7 #include "chrome/browser/android/vr_shell/vr_gl_util.h" | 7 #include "chrome/browser/android/vr_shell/vr_gl_util.h" |
| 8 #include "ui/gl/gl_bindings.h" | 8 #include "ui/gl/gl_bindings.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_); | 290 glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_); |
| 291 | 291 |
| 292 glEnableVertexAttribArray(position_handle_); | 292 glEnableVertexAttribArray(position_handle_); |
| 293 glEnableVertexAttribArray(tex_coord_handle_); | 293 glEnableVertexAttribArray(tex_coord_handle_); |
| 294 | 294 |
| 295 glVertexAttribPointer(position_handle_, POSITION_ELEMENTS, GL_FLOAT, false, | 295 glVertexAttribPointer(position_handle_, POSITION_ELEMENTS, GL_FLOAT, false, |
| 296 VERTEX_STRIDE, VOID_OFFSET(POSITION_OFFSET)); | 296 VERTEX_STRIDE, VOID_OFFSET(POSITION_OFFSET)); |
| 297 glVertexAttribPointer(tex_coord_handle_, TEXCOORD_ELEMENTS, GL_FLOAT, false, | 297 glVertexAttribPointer(tex_coord_handle_, TEXCOORD_ELEMENTS, GL_FLOAT, false, |
| 298 VERTEX_STRIDE, VOID_OFFSET(TEXCOORD_OFFSET)); | 298 VERTEX_STRIDE, VOID_OFFSET(TEXCOORD_OFFSET)); |
| 299 | 299 |
| 300 // Bind texture. | 300 // Bind texture. Ideally this should be a 1:1 pixel copy. (Or even more |
| 301 // ideally, a zero copy reuse of the texture.) For now, we're using an |
| 302 // undersized render target for WebVR, so GL_LINEAR makes it look slightly |
| 303 // less chunky. TODO(klausw): change this to GL_NEAREST once we're doing |
| 304 // a 1:1 copy since that should be more efficient. |
| 301 glActiveTexture(GL_TEXTURE0); | 305 glActiveTexture(GL_TEXTURE0); |
| 302 glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_handle); | 306 glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_handle); |
| 307 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 308 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 309 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 310 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 303 glUniform1i(tex_uniform_handle_, 0); | 311 glUniform1i(tex_uniform_handle_, 0); |
| 304 | 312 |
| 305 // TODO(bajones): Should be able handle both eyes in a single draw call. | 313 // TODO(bajones): Should be able handle both eyes in a single draw call. |
| 306 // Left eye | 314 // Left eye |
| 307 glUniform4fv(src_rect_uniform_handle_, 1, (float*)(&left_bounds_)); | 315 glUniform4fv(src_rect_uniform_handle_, 1, (float*)(&left_bounds_)); |
| 308 glDrawArrays(GL_TRIANGLE_FAN, 0, 4); | 316 glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
| 309 | 317 |
| 310 // Right eye | 318 // Right eye |
| 311 glUniform4fv(src_rect_uniform_handle_, 1, (float*)(&right_bounds_)); | 319 glUniform4fv(src_rect_uniform_handle_, 1, (float*)(&right_bounds_)); |
| 312 glDrawArrays(GL_TRIANGLE_FAN, 4, 4); | 320 glDrawArrays(GL_TRIANGLE_FAN, 4, 4); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 | 449 |
| 442 VrShellRenderer::VrShellRenderer() | 450 VrShellRenderer::VrShellRenderer() |
| 443 : textured_quad_renderer_(new TexturedQuadRenderer), | 451 : textured_quad_renderer_(new TexturedQuadRenderer), |
| 444 webvr_renderer_(new WebVrRenderer), | 452 webvr_renderer_(new WebVrRenderer), |
| 445 reticle_renderer_(new ReticleRenderer), | 453 reticle_renderer_(new ReticleRenderer), |
| 446 laser_renderer_(new LaserRenderer) {} | 454 laser_renderer_(new LaserRenderer) {} |
| 447 | 455 |
| 448 VrShellRenderer::~VrShellRenderer() = default; | 456 VrShellRenderer::~VrShellRenderer() = default; |
| 449 | 457 |
| 450 } // namespace vr_shell | 458 } // namespace vr_shell |
| OLD | NEW |