Blender  V2.93
gl_index_buffer.hh
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 #pragma once
25 
26 #include "MEM_guardedalloc.h"
27 
29 
30 #include "glew-mx.h"
31 
32 namespace blender::gpu {
33 
34 class GLIndexBuf : public IndexBuf {
35  friend class GLBatch;
36  friend class GLDrawList;
37 
38  private:
39  GLuint ibo_id_ = 0;
40 
41  public:
42  ~GLIndexBuf();
43 
44  void bind(void);
45 
46  void *offset_ptr(uint additional_vertex_offset) const
47  {
48  additional_vertex_offset += index_start_;
49  if (index_type_ == GPU_INDEX_U32) {
50  return (GLuint *)0 + additional_vertex_offset;
51  }
52  return (GLushort *)0 + additional_vertex_offset;
53  }
54 
55  GLuint restart_index(void) const
56  {
57  return (index_type_ == GPU_INDEX_U16) ? 0xFFFFu : 0xFFFFFFFFu;
58  }
59 
60  MEM_CXX_CLASS_ALLOC_FUNCS("GLIndexBuf")
61 };
62 
63 static inline GLenum to_gl(GPUIndexBufType type)
64 {
65  return (type == GPU_INDEX_U32) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT;
66 }
67 
68 } // namespace blender::gpu
unsigned int uint
Definition: BLI_sys_types.h:83
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Read Guarded memory(de)allocation.
GLuint restart_index(void) const
void * offset_ptr(uint additional_vertex_offset) const
static GLenum to_gl(const GPUAttachmentType type)