Easy3D 2.6.1
Loading...
Searching...
No Matches
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:
58 static bool is_supported();
68
73 GLuint id() const { return id_; }
74
79 void bind();
84 void release() const;
85
86 //------------------------- buffer management -------------------
87
98 bool create_array_buffer(GLuint& buffer, GLuint index, const void* data, std::size_t size, std::size_t dim, bool dynamic = false);
107 bool create_element_buffer(GLuint& buffer, const void* data, std::size_t size, bool dynamic = false);
108
117 bool create_storage_buffer(GLuint& buffer, GLuint index, const void* data, std::size_t size);
126 bool update_storage_buffer(GLuint& buffer, GLintptr offset, GLsizeiptr size, const void* data);
127
132 static void release_buffer(GLuint& buffer);
133
134 // ------------------------- read/write buffer--------------------
135
144 static void get_buffer_data(GLenum target, GLuint buffer, GLintptr offset, GLsizeiptr size, void* data);
145
153 static void* map_buffer(GLenum target, GLuint buffer, GLenum access);
159 static void unmap_buffer(GLenum target, GLuint buffer);
160
161 private:
162 GLuint id_;
163
164 private:
165 //copying disabled
167 VertexArrayObject& operator=(const VertexArrayObject&);
168 };
169
170}
171
172
173#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 uploads data to the buffer.
Definition vertex_array_object.cpp:100
GLuint id() const
Get the OpenGL ID of the VAO.
Definition vertex_array_object.h:73
static void * map_buffer(GLenum target, GLuint buffer, GLenum access)
Maps a buffer object's data store.
Definition vertex_array_object.cpp:174
void release() const
Release the VAO.
Definition vertex_array_object.cpp:85
bool update_storage_buffer(GLuint &buffer, GLintptr offset, GLsizeiptr size, const void *data)
Updates an OpenGL shader storage buffer with new data.
Definition vertex_array_object.cpp:164
void bind()
Bind the VAO.
Definition vertex_array_object.cpp:72
~VertexArrayObject()
Destructor.
Definition vertex_array_object.cpp:64
bool create_element_buffer(GLuint &buffer, const void *data, std::size_t size, bool dynamic=false)
Creates an OpenGL element buffer and uploads data to the buffer.
Definition vertex_array_object.cpp:121
static bool is_supported()
Check if VAOs are supported by the current OpenGL context.
Definition vertex_array_object.cpp:39
static void release_buffer(GLuint &buffer)
Frees the GPU memory of the buffer specified by 'buffer'.
Definition vertex_array_object.cpp:91
VertexArrayObject()
Constructor.
Definition vertex_array_object.cpp:46
static void get_buffer_data(GLenum target, GLuint buffer, GLintptr offset, GLsizeiptr size, void *data)
Returns a subset of a buffer object's data store.
Definition vertex_array_object.cpp:194
bool create_storage_buffer(GLuint &buffer, GLuint index, const void *data, std::size_t size)
Creates an OpenGL shader storage buffer and uploads data to the buffer.
Definition vertex_array_object.cpp:140
static void unmap_buffer(GLenum target, GLuint buffer)
Unmaps a buffer object's data store.
Definition vertex_array_object.cpp:186
Functions for updating render buffers.
Definition buffer.cpp:45
Definition collider.cpp:182