Easy3D 2.5.3
vertex_array_object.h
1/********************************************************************
2 * Copyright (C) 2015 Liangliang Nan <liangliang.nan@gmail.com>
3 * https://3d.bk.tudelft.nl/liangliang/
4 *
5 * This file is part of Easy3D. If it is useful in your research/work,
6 * I would be grateful if you show your appreciation by citing it:
7 * ------------------------------------------------------------------
8 * Liangliang Nan.
9 * Easy3D: a lightweight, easy-to-use, and efficient C++ library
10 * for processing and rendering 3D data.
11 * Journal of Open Source Software, 6(64), 3255, 2021.
12 * ------------------------------------------------------------------
13 *
14 * Easy3D is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License Version 3
16 * as published by the Free Software Foundation.
17 *
18 * Easy3D is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ********************************************************************/
26
27#ifndef EASY_RENDERER_VERTEX_ARRAY_OBJECT_H
28#define EASY_RENDERER_VERTEX_ARRAY_OBJECT_H
29
30#include <easy3d/renderer/opengl.h>
31
32#include <string>
33
34
35namespace easy3d {
36
52 {
53 public:
54 static bool is_supported();
55
58
59 GLuint id() const { return id_; }
60
61 void bind();
62 void release() const;
63
64 //------------------------- buffer management -------------------
65
76 bool create_array_buffer(GLuint& buffer, GLuint index, const void* data, std::size_t size, std::size_t dim, bool dynamic = false);
77 bool create_element_buffer(GLuint& buffer, const void* data, std::size_t size, bool dynamic = false);
78
79 // @param index: the index of the binding point.
80 bool create_storage_buffer(GLuint& buffer, GLuint index, const void* data, std::size_t size);
81 bool update_storage_buffer(GLuint& buffer, GLintptr offset, GLsizeiptr size, const void* data);
82
84 static void release_buffer(GLuint& buffer);
85
86 // ------------------------- read/write buffer--------------------
87
97 static void get_buffer_data(GLenum target, GLuint buffer, GLintptr offset, GLsizeiptr size, void* data);
98
99 // \param target: can be GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, GL_SHADER_STORAGE_BUFFER, etc.
100 // \param handle: the name of the buffer object for the mapping.
101 // \param access: must be GL_READ_ONLY, GL_WRITE_ONLY, or GL_READ_WRITE.
102 static void* map_buffer(GLenum target, GLuint buffer, GLenum access);
103 static void unmap_buffer(GLenum target, GLuint buffer);
104
105 private:
106 GLuint id_;
107
108 private:
109 //copying disabled
111 VertexArrayObject& operator=(const VertexArrayObject&);
112 };
113
114}
115
116
117#endif // EASY_RENDERER_VERTEX_ARRAY_OBJECT_H
A thin wrapper around an OpenGL Vertex Array Object (VAO).
Definition: vertex_array_object.h:52
bool create_array_buffer(GLuint &buffer, GLuint index, const void *data, std::size_t size, std::size_t dim, bool dynamic=false)
Creates an OpenGL array buffer and upload data to the buffer.
Definition: vertex_array_object.cpp:100
static void release_buffer(GLuint &buffer)
Frees the GPU memory of the buffer specified by 'handle'.
Definition: vertex_array_object.cpp:91
static void get_buffer_data(GLenum target, GLuint buffer, GLintptr offset, GLsizeiptr size, void *data)
Definition: vertex_array_object.cpp:194
Definition: collider.cpp:182