PeriDyno 1.0.0
Loading...
Searching...
No Matches
VertexArray.cpp
Go to the documentation of this file.
1#include "VertexArray.h"
2
3#include <glad/glad.h>
4#include <vector>
5
6namespace dyno
7{
9 {
10 glGenVertexArrays(1, &id);
11 }
12
14 {
15 glDeleteVertexArrays(1, &id);
16
17 // reset object id
18 id = GL_INVALID_INDEX;
19 }
20
22 {
23 glBindVertexArray(id);
24 }
25
27 {
28 glBindVertexArray(0);
29 }
30
32 {
33 this->bind();
34 if (buffer == 0)
35 {
36 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
37 }
38 else
39 {
40 buffer->bind();
41 }
42 this->unbind();
43 }
44
45
46 void VertexArray::bindVertexBuffer(Buffer* buffer, int index,
47 int size, int type, int stride, int offset, int divisor)
48 {
49 this->bind();
50 if (buffer == 0)
51 {
52 glDisableVertexAttribArray(index);
53 }
54 else
55 {
56 buffer->bind();
57 glEnableVertexAttribArray(index);
58 glVertexAttribPointer(index, size, type, GL_FALSE, stride, (void*)offset);
59 glVertexAttribDivisor(index, divisor);
60 }
61 this->unbind();
62 }
63
64}
void bind()
Definition Buffer.cpp:31
virtual void unbind()
virtual void bindIndexBuffer(Buffer *buffer)
virtual void release() override
virtual void bind()
virtual void bindVertexBuffer(Buffer *buffer, int index, int size, int type, int stride, int offset, int divisor)
virtual void create() override
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25