OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/gl/gl_helper.h" | 5 #include "ui/gl/gl_helper.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/gl/scoped_binders.h" | 10 #include "ui/gl/scoped_binders.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 glDeleteProgram(program); | 66 glDeleteProgram(program); |
67 program = 0; | 67 program = 0; |
68 } | 68 } |
69 return program; | 69 return program; |
70 } | 70 } |
71 | 71 |
72 // static | 72 // static |
73 GLuint GLHelper::SetupQuadVertexBuffer() { | 73 GLuint GLHelper::SetupQuadVertexBuffer() { |
74 GLuint vertex_buffer = 0; | 74 GLuint vertex_buffer = 0; |
75 glGenBuffersARB(1, &vertex_buffer); | 75 glGenBuffersARB(1, &vertex_buffer); |
76 gl::ScopedBufferBinder buffer_binder(GL_ARRAY_BUFFER, vertex_buffer); | 76 ScopedBufferBinder buffer_binder(GL_ARRAY_BUFFER, vertex_buffer); |
77 GLfloat data[] = {-1.f, -1.f, 1.f, -1.f, -1.f, 1.f, 1.f, 1.f}; | 77 GLfloat data[] = {-1.f, -1.f, 1.f, -1.f, -1.f, 1.f, 1.f, 1.f}; |
78 glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW); | 78 glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW); |
79 return vertex_buffer; | 79 return vertex_buffer; |
80 } | 80 } |
81 | 81 |
82 // static | 82 // static |
83 void GLHelper::DrawQuad(GLuint vertex_buffer) { | 83 void GLHelper::DrawQuad(GLuint vertex_buffer) { |
84 gl::ScopedBufferBinder buffer_binder(GL_ARRAY_BUFFER, vertex_buffer); | 84 ScopedBufferBinder buffer_binder(GL_ARRAY_BUFFER, vertex_buffer); |
85 gl::ScopedVertexAttribArray vertex_attrib_array(0, 2, GL_FLOAT, GL_FALSE, | 85 ScopedVertexAttribArray vertex_attrib_array(0, 2, GL_FLOAT, GL_FALSE, |
86 sizeof(GLfloat) * 2, 0); | 86 sizeof(GLfloat) * 2, 0); |
87 gl::ScopedCapability disable_blending(GL_BLEND, GL_FALSE); | 87 ScopedCapability disable_blending(GL_BLEND, GL_FALSE); |
88 gl::ScopedCapability disable_culling(GL_CULL_FACE, GL_FALSE); | 88 ScopedCapability disable_culling(GL_CULL_FACE, GL_FALSE); |
89 gl::ScopedCapability disable_dithering(GL_DITHER, GL_FALSE); | 89 ScopedCapability disable_dithering(GL_DITHER, GL_FALSE); |
90 gl::ScopedCapability disable_depth_test(GL_DEPTH_TEST, GL_FALSE); | 90 ScopedCapability disable_depth_test(GL_DEPTH_TEST, GL_FALSE); |
91 gl::ScopedCapability disable_scissor_test(GL_SCISSOR_TEST, GL_FALSE); | 91 ScopedCapability disable_scissor_test(GL_SCISSOR_TEST, GL_FALSE); |
92 gl::ScopedColorMask color_mask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 92 ScopedColorMask color_mask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
93 | 93 |
94 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); | 94 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
95 } | 95 } |
96 | 96 |
97 } // namespace gl | 97 } // namespace gl |
OLD | NEW |