sculpto
Public Member Functions | List of all members
scl::gl_index_buffer Class Reference

#include <gl_buffer.h>

Inheritance diagram for scl::gl_index_buffer:
scl::index_buffer

Public Member Functions

u32 GetCount () const override
 
render_primitive::handle GetHandle () const override
 
 gl_index_buffer (u32 *Indices, u32 Count)
 
 ~gl_index_buffer () override
 
void Bind () const override
 
void Unbind () const override
 
void Update (u32 *Indices, u32 Count) override
 
void Free () override
 
- Public Member Functions inherited from scl::index_buffer
virtual ~index_buffer ()=default
 
virtual void Bind () const =0
 
virtual void Unbind () const =0
 
virtual void Free ()=0
 
virtual void Update (u32 *Indices, u32 Count)=0
 
virtual u32 GetCount () const =0
 

Additional Inherited Members

- Static Public Member Functions inherited from scl::index_buffer
static shared< index_bufferCreate (u32 *Indices, u32 Count)
 

Detailed Description

Vertices indices buffer interface.

Definition at line 153 of file gl_buffer.h.

Constructor & Destructor Documentation

◆ gl_index_buffer()

scl::gl_index_buffer::gl_index_buffer ( u32 Indices,
u32  Count 
)
  • Create API specific vertex buffer by vertices count and data.
Parameters
Indices- indices array.
Count- indices in buffer count.

Definition at line 140 of file gl_buffer.cpp.

141{
142 this->IndicesCount = Count;
143
144 glCreateBuffers(1, &Id);
145 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, Id);
146 glBufferData(GL_ELEMENT_ARRAY_BUFFER, Count * sizeof(u32), Indices, GL_STATIC_DRAW);
147
148 SCL_CORE_SUCCES("OpenGL Index buffer with id {} and {} indices created.", Id, Count);
149}
#define SCL_CORE_SUCCES(...)
Definition: log.h:42
uint32_t u32
Definition: math_common.h:21

◆ ~gl_index_buffer()

scl::gl_index_buffer::~gl_index_buffer ( )
override

Index buffer default destructor.

Definition at line 151 of file gl_buffer.cpp.

152{
153 Free();
154}
void Free() override
Definition: gl_buffer.cpp:178

Member Function Documentation

◆ Bind()

void scl::gl_index_buffer::Bind ( ) const
overridevirtual
  • Bind buffer to current render stage function.
Parameters
None.
Returns
None.

Implements scl::index_buffer.

Definition at line 156 of file gl_buffer.cpp.

157{
158 if (Id != 0) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, Id);
159}

◆ Free()

void scl::gl_index_buffer::Free ( )
overridevirtual
  • Clear buffer from GPU memory function.
Parameters
None.
Returns
None.

Implements scl::index_buffer.

Definition at line 178 of file gl_buffer.cpp.

179{
180 if (Id != 0)
181 {
182 glDeleteBuffers(1, &Id);
183
184 SCL_CORE_INFO("OpenGL Index buffer with id {} freed.", Id);
185 Id = 0, IndicesCount = 0;
186 }
187}
#define SCL_CORE_INFO(...)
Definition: log.h:41

◆ GetCount()

u32 scl::gl_index_buffer::GetCount ( ) const
inlineoverridevirtual

Index buffer getter/setter functions.

Index buffer indices count getter function.

Implements scl::index_buffer.

Definition at line 161 of file gl_buffer.h.

161{ return IndicesCount; };

◆ GetHandle()

render_primitive::handle scl::gl_index_buffer::GetHandle ( ) const
inlineoverride

Backend api render primitive hadnle getter function.

Definition at line 164 of file gl_buffer.h.

164{ return Id; }

◆ Unbind()

void scl::gl_index_buffer::Unbind ( ) const
overridevirtual
  • Unbind buffer from current render stage function.
Parameters
None.
Returns
None.

Implements scl::index_buffer.

Definition at line 161 of file gl_buffer.cpp.

162{
163 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
164}

◆ Update()

void scl::gl_index_buffer::Update ( u32 Indices,
u32  Count 
)
overridevirtual
  • Update buffer function function.
Parameters
Indices- array of indices.
Count

Implements scl::index_buffer.

Definition at line 166 of file gl_buffer.cpp.

167{
168 if (Id != 0)
169 {
170 SCL_CORE_ASSERT(this->IndicesCount == Count, "Indices count cant'be changed.");
171
172 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, Id);
173 glBufferData(GL_ELEMENT_ARRAY_BUFFER, Count * sizeof(u32), Indices, GL_STATIC_DRAW);
174 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
175 }
176}
#define SCL_CORE_ASSERT(expr,...)
Definition: assert.h:69

The documentation for this class was generated from the following files: