forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgeometry_binding.cc
75 lines (63 loc) · 2.77 KB
/
geometry_binding.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/output/geometry_binding.h"
#include <stdint.h>
#include "gpu/command_buffer/client/gles2_interface.h"
#include "ui/gfx/geometry/rect_f.h"
namespace cc {
void SetupGLContext(gpu::gles2::GLES2Interface* gl,
GLuint quad_elements_vbo,
GLuint quad_vertices_vbo) {
gl->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_elements_vbo);
gl->BindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo);
// OpenGL defines the last parameter to VertexAttribPointer as type
// "const GLvoid*" even though it is actually an offset into the buffer
// object's data store and not a pointer to the client's address space.
const void* offsets[3] = {
0,
reinterpret_cast<const void*>(3 * sizeof(float)),
reinterpret_cast<const void*>(5 * sizeof(float)),
};
gl->VertexAttribPointer(GeometryBinding::PositionAttribLocation(), 3,
GL_FLOAT, false, 6 * sizeof(float), offsets[0]);
gl->VertexAttribPointer(GeometryBinding::TexCoordAttribLocation(), 2,
GL_FLOAT, false, 6 * sizeof(float), offsets[1]);
gl->VertexAttribPointer(GeometryBinding::TriangleIndexAttribLocation(), 1,
GL_FLOAT, false, 6 * sizeof(float), offsets[2]);
gl->EnableVertexAttribArray(GeometryBinding::PositionAttribLocation());
gl->EnableVertexAttribArray(GeometryBinding::TexCoordAttribLocation());
gl->EnableVertexAttribArray(GeometryBinding::TriangleIndexAttribLocation());
}
GeometryBindingQuad::GeometryBindingQuad() {
v0 = {{0, 0, 0}, {0, 0}, 0};
v1 = {{0, 0, 0}, {0, 0}, 0};
v2 = {{0, 0, 0}, {0, 0}, 0};
v3 = {{0, 0, 0}, {0, 0}, 0};
}
GeometryBindingQuad::GeometryBindingQuad(const GeometryBindingVertex& vert0,
const GeometryBindingVertex& vert1,
const GeometryBindingVertex& vert2,
const GeometryBindingVertex& vert3) {
v0 = vert0;
v1 = vert1;
v2 = vert2;
v3 = vert3;
}
GeometryBindingQuadIndex::GeometryBindingQuadIndex() {
memset(data, 0x0, sizeof(data));
}
GeometryBindingQuadIndex::GeometryBindingQuadIndex(uint16_t index0,
uint16_t index1,
uint16_t index2,
uint16_t index3,
uint16_t index4,
uint16_t index5) {
data[0] = index0;
data[1] = index1;
data[2] = index2;
data[3] = index3;
data[4] = index4;
data[5] = index5;
}
} // namespace cc