1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/output/geometry_binding.h"
7 #include "gpu/command_buffer/client/gles2_interface.h"
8 #include "ui/gfx/geometry/rect_f.h"
12 void SetupGLContext(gpu::gles2::GLES2Interface
* gl
,
13 GLuint quad_elements_vbo
,
14 GLuint quad_vertices_vbo
) {
15 gl
->BindBuffer(GL_ELEMENT_ARRAY_BUFFER
, quad_elements_vbo
);
17 gl
->BindBuffer(GL_ARRAY_BUFFER
, quad_vertices_vbo
);
18 // OpenGL defines the last parameter to VertexAttribPointer as type
19 // "const GLvoid*" even though it is actually an offset into the buffer
20 // object's data store and not a pointer to the client's address space.
21 const void* offsets
[3] = {
23 reinterpret_cast<const void*>(3 * sizeof(float)),
24 reinterpret_cast<const void*>(5 * sizeof(float)),
27 gl
->VertexAttribPointer(GeometryBinding::PositionAttribLocation(), 3,
28 GL_FLOAT
, false, 6 * sizeof(float), offsets
[0]);
29 gl
->VertexAttribPointer(GeometryBinding::TexCoordAttribLocation(), 2,
30 GL_FLOAT
, false, 6 * sizeof(float), offsets
[1]);
31 gl
->VertexAttribPointer(GeometryBinding::TriangleIndexAttribLocation(), 1,
32 GL_FLOAT
, false, 6 * sizeof(float), offsets
[2]);
33 gl
->EnableVertexAttribArray(GeometryBinding::PositionAttribLocation());
34 gl
->EnableVertexAttribArray(GeometryBinding::TexCoordAttribLocation());
35 gl
->EnableVertexAttribArray(GeometryBinding::TriangleIndexAttribLocation());
38 GeometryBindingQuad::GeometryBindingQuad() {
39 v0
= {{0, 0, 0}, {0, 0}, 0};
40 v1
= {{0, 0, 0}, {0, 0}, 0};
41 v2
= {{0, 0, 0}, {0, 0}, 0};
42 v3
= {{0, 0, 0}, {0, 0}, 0};
45 GeometryBindingQuad::GeometryBindingQuad(const GeometryBindingVertex
& vert0
,
46 const GeometryBindingVertex
& vert1
,
47 const GeometryBindingVertex
& vert2
,
48 const GeometryBindingVertex
& vert3
) {
55 GeometryBindingQuadIndex::GeometryBindingQuadIndex() {
56 memset(data
, 0x0, sizeof(data
));
59 GeometryBindingQuadIndex::GeometryBindingQuadIndex(uint16 index0
,