blob: e50c471b6d0dd62c638c45cbe9ec7cd41a77c710 [file] [log] [blame]
Lucas Dupinad663372020-03-19 12:44:36 -07001/*
2 * Copyright 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define ATRACE_TAG ATRACE_TAG_GRAPHICS
18
19#include "GLVertexBuffer.h"
20
21#include <GLES/gl.h>
22#include <GLES2/gl2.h>
23#include <nativebase/nativebase.h>
24#include <utils/Trace.h>
25
26namespace android {
27namespace renderengine {
28namespace gl {
29
30GLVertexBuffer::GLVertexBuffer() {
31 glGenBuffers(1, &mBufferName);
32}
33
34GLVertexBuffer::~GLVertexBuffer() {
35 glDeleteBuffers(1, &mBufferName);
36}
37
38void GLVertexBuffer::allocateBuffers(const GLfloat data[], const GLuint size) {
39 ATRACE_CALL();
40 bind();
41 glBufferData(GL_ARRAY_BUFFER, size * sizeof(GLfloat), data, GL_STATIC_DRAW);
42 unbind();
43}
44
45void GLVertexBuffer::bind() const {
46 glBindBuffer(GL_ARRAY_BUFFER, mBufferName);
47}
48
49void GLVertexBuffer::unbind() const {
50 glBindBuffer(GL_ARRAY_BUFFER, 0);
51}
52
53} // namespace gl
54} // namespace renderengine
55} // namespace android