Blender
V2.93
source
blender
gpu
opengl
gl_index_buffer.cc
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or
3
* modify it under the terms of the GNU General Public License
4
* as published by the Free Software Foundation; either version 2
5
* of the License, or (at your option) any later version.
6
*
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software Foundation,
14
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
*
16
* The Original Code is Copyright (C) 2020 Blender Foundation.
17
* All rights reserved.
18
*/
19
24
#include "
gl_context.hh
"
25
#include "
gl_debug.hh
"
26
27
#include "
gl_index_buffer.hh
"
28
29
namespace
blender::gpu
{
30
31
GLIndexBuf::~GLIndexBuf
()
32
{
33
GLContext::buf_free
(ibo_id_);
34
}
35
36
void
GLIndexBuf::bind
()
37
{
38
if
(
is_subrange_
) {
39
static_cast<
GLIndexBuf
*
>
(
src_
)->
bind
();
40
return
;
41
}
42
43
if
(ibo_id_ == 0) {
44
glGenBuffers(1, &ibo_id_);
45
46
if
(
data_
==
nullptr
) {
47
debug::raise_gl_error
(
"Trying to use Index Buffer but the buffer contains no data"
);
48
}
49
}
50
51
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id_);
52
53
if
(
data_
!=
nullptr
) {
54
size_t
size
= this->
size_get
();
55
/* Sends data to GPU. */
56
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
size
,
data_
, GL_STATIC_DRAW);
57
/* No need to keep copy of data in system memory. */
58
MEM_SAFE_FREE
(
data_
);
59
}
60
}
61
62
}
// namespace blender::gpu
MEM_SAFE_FREE
#define MEM_SAFE_FREE(v)
Definition:
MEM_guardedalloc.h:201
size
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition:
btDbvt.cpp:52
blender::gpu::GLContext::buf_free
static void buf_free(GLuint buf_id)
Definition:
gl_context.cc:257
blender::gpu::GLIndexBuf
Definition:
gl_index_buffer.hh:34
blender::gpu::GLIndexBuf::~GLIndexBuf
~GLIndexBuf()
Definition:
gl_index_buffer.cc:31
blender::gpu::GLIndexBuf::bind
void bind(void)
Definition:
gl_index_buffer.cc:36
blender::gpu::IndexBuf::src_
IndexBuf * src_
Definition:
gpu_index_buffer_private.hh:69
blender::gpu::IndexBuf::data_
void * data_
Definition:
gpu_index_buffer_private.hh:67
blender::gpu::IndexBuf::is_subrange_
bool is_subrange_
Definition:
gpu_index_buffer_private.hh:63
blender::gpu::IndexBuf::size_get
size_t size_get(void)
Definition:
gpu_index_buffer_private.hh:84
gl_context.hh
gl_debug.hh
gl_index_buffer.hh
blender::gpu::debug::raise_gl_error
void raise_gl_error(const char *info)
Definition:
gl_debug.cc:282
blender::gpu
Definition:
gpu_backend.hh:29
Generated on Tue Jan 31 2023 14:37:24 for Blender by
doxygen
1.9.1