Skip to content

Commit d168bdf

Browse files
committed
Create vertex arrays using DSA (refs #394)
1 parent ff2eb5a commit d168bdf

8 files changed

+60
-2
lines changed

source/globjects/source/Resource.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "implementations/AbstractBufferImplementation.h"
99
#include "implementations/AbstractFramebufferImplementation.h"
1010
#include "implementations/AbstractTextureImplementation.h"
11+
#include "implementations/AbstractVertexAttributeBindingImplementation.h"
1112

1213

1314
using namespace gl;
@@ -231,13 +232,16 @@ TransformFeedbackResource::~TransformFeedbackResource()
231232

232233

233234
VertexArrayObjectResource::VertexArrayObjectResource()
234-
: IDResource(createObject(glGenVertexArrays))
235+
: IDResource(ImplementationRegistry::current().attributeImplementation().create())
235236
{
236237
}
237238

238239
VertexArrayObjectResource::~VertexArrayObjectResource()
239240
{
240-
deleteObject(glDeleteVertexArrays, id(), hasOwnership());
241+
if (hasOwnership())
242+
{
243+
ImplementationRegistry::current().attributeImplementation().destroy(id());
244+
}
241245
}
242246

243247

source/globjects/source/implementations/AbstractVertexAttributeBindingImplementation.h

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class AbstractVertexAttributeBindingImplementation
2727
static AbstractVertexAttributeBindingImplementation * get(VertexArray::AttributeImplementation impl =
2828
VertexArray::AttributeImplementation::VertexAttribBindingARB);
2929

30+
virtual gl::GLuint create() const = 0;
31+
virtual void destroy(gl::GLuint id) const = 0;
32+
3033
virtual void enable(const VertexArray * vertexArray, gl::GLint attributeIndex) const = 0;
3134
virtual void disable(const VertexArray * vertexArray, gl::GLint attributeIndex) const = 0;
3235

source/globjects/source/implementations/VertexAttributeBindingImplementation_DirectStateAccessARB.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ VertexAttributeBindingImplementation_DirectStateAccessARB::~VertexAttributeBindi
2525

2626
}
2727

28+
gl::GLuint VertexAttributeBindingImplementation_DirectStateAccessARB::create() const
29+
{
30+
gl::GLuint result = 0;
31+
32+
gl::glCreateVertexArrays(1, &result);
33+
34+
return result;
35+
}
36+
37+
void VertexAttributeBindingImplementation_DirectStateAccessARB::destroy(gl::GLuint id) const
38+
{
39+
gl::glDeleteVertexArrays(1, &id);
40+
}
41+
2842
void VertexAttributeBindingImplementation_DirectStateAccessARB::enable(const VertexArray * vertexArray, GLint attributeIndex) const
2943
{
3044
glEnableVertexArrayAttrib(vertexArray->id(), attributeIndex);

source/globjects/source/implementations/VertexAttributeBindingImplementation_DirectStateAccessARB.h

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class VertexAttributeBindingImplementation_DirectStateAccessARB : public Abstrac
2222
VertexAttributeBindingImplementation_DirectStateAccessARB();
2323
virtual ~VertexAttributeBindingImplementation_DirectStateAccessARB();
2424

25+
virtual gl::GLuint create() const override;
26+
virtual void destroy(gl::GLuint id) const override;
27+
2528
virtual void enable(const VertexArray * vertexArray, gl::GLint attributeIndex) const override;
2629
virtual void disable(const VertexArray * vertexArray, gl::GLint attributeIndex) const override;
2730

source/globjects/source/implementations/VertexAttributeBindingImplementation_Legacy.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ VertexAttributeBindingImplementation_Legacy::BindingData::BindingData()
4646
{
4747
}
4848

49+
gl::GLuint VertexAttributeBindingImplementation_Legacy::create() const
50+
{
51+
gl::GLuint result = 0;
52+
53+
gl::glGenVertexArrays(1, &result);
54+
55+
return result;
56+
}
57+
58+
void VertexAttributeBindingImplementation_Legacy::destroy(gl::GLuint id) const
59+
{
60+
gl::glDeleteVertexArrays(1, &id);
61+
}
62+
4963
VertexAttributeBindingImplementation_Legacy::VertexAttributeBindingImplementation_Legacy()
5064
{
5165
}

source/globjects/source/implementations/VertexAttributeBindingImplementation_Legacy.h

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class VertexAttributeBindingImplementation_Legacy : public AbstractVertexAttribu
2222
VertexAttributeBindingImplementation_Legacy();
2323
virtual ~VertexAttributeBindingImplementation_Legacy();
2424

25+
virtual gl::GLuint create() const override;
26+
virtual void destroy(gl::GLuint id) const override;
27+
2528
virtual void enable(const VertexArray * vertexArray, gl::GLint attributeIndex) const override;
2629
virtual void disable(const VertexArray * vertexArray, gl::GLint attributeIndex) const override;
2730

source/globjects/source/implementations/VertexAttributeBindingImplementation_VertexAttribBindingARB.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ VertexAttributeBindingImplementation_VertexAttribBindingARB::~VertexAttributeBin
2727
{
2828
}
2929

30+
gl::GLuint VertexAttributeBindingImplementation_VertexAttribBindingARB::create() const
31+
{
32+
gl::GLuint result = 0;
33+
34+
gl::glGenVertexArrays(1, &result);
35+
36+
return result;
37+
}
38+
39+
void VertexAttributeBindingImplementation_VertexAttribBindingARB::destroy(gl::GLuint id) const
40+
{
41+
gl::glDeleteVertexArrays(1, &id);
42+
}
43+
3044
void VertexAttributeBindingImplementation_VertexAttribBindingARB::enable(const VertexArray * vertexArray, GLint attributeIndex) const
3145
{
3246
VertexAttributeBindingImplementation_Legacy::instance()->enable(vertexArray, attributeIndex);

source/globjects/source/implementations/VertexAttributeBindingImplementation_VertexAttribBindingARB.h

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class VertexAttributeBindingImplementation_VertexAttribBindingARB : public Abstr
2222
VertexAttributeBindingImplementation_VertexAttribBindingARB();
2323
virtual ~VertexAttributeBindingImplementation_VertexAttribBindingARB();
2424

25+
virtual gl::GLuint create() const override;
26+
virtual void destroy(gl::GLuint id) const override;
27+
2528
virtual void enable(const VertexArray * vertexArray, gl::GLint attributeIndex) const override;
2629
virtual void disable(const VertexArray * vertexArray, gl::GLint attributeIndex) const override;
2730

0 commit comments

Comments
 (0)