Skip to content

Commit ddd1fe7

Browse files
committed
no native VAOs
1 parent 77e2c66 commit ddd1fe7

File tree

3 files changed

+5
-55
lines changed

3 files changed

+5
-55
lines changed

src/ruis/render/opengl/shader_base.cpp

+1-15
Original file line numberDiff line numberDiff line change
@@ -183,25 +183,11 @@ void shader_base::render(const r4::matrix4<float>& m, const ruis::render::vertex
183183
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
184184
const auto& ogl_va = static_cast<const vertex_array&>(va);
185185

186-
if (GLEW_ARB_vertex_array_object) {
187-
glBindVertexArray(ogl_va.vao);
188-
assert_opengl_no_error();
189-
} else {
190-
ogl_va.bind_buffers();
191-
}
186+
ogl_va.bind_buffers();
192187

193188
// TRACE(<< "ivbo.elementsCount = " << ivbo.elementsCount << "
194189
// ivbo.elementType = " << ivbo.elementType << std::endl)
195190

196191
glDrawElements(mode_to_gl_mode(va.rendering_mode), ivbo.elements_count, ivbo.element_type, nullptr);
197192
assert_opengl_no_error();
198-
199-
if (GLEW_ARB_vertex_array_object) {
200-
// For some reason on linux when leaving bound vertex array after done with
201-
// rendering a frame, the vertex array can become corrupted in some
202-
// scenarios, like changing viewport size and possibly some other scenarios.
203-
// Because of that, unbind the vertex array after glDrawElements() call.
204-
glBindVertexArray(0);
205-
assert_opengl_no_error();
206-
}
207193
}

src/ruis/render/opengl/vertex_array.cpp

+2-38
Original file line numberDiff line numberDiff line change
@@ -38,44 +38,8 @@ vertex_array::vertex_array(
3838
std::move(buffers),
3939
std::move(indices),
4040
rendering_mode
41-
),
42-
vao([]() {
43-
if (GLEW_ARB_vertex_array_object) {
44-
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
45-
GLuint ret;
46-
glGenVertexArrays(1, &ret);
47-
assert_opengl_no_error();
48-
return ret;
49-
} else {
50-
return GLuint(0);
51-
}
52-
}())
53-
{
54-
if (GLEW_ARB_vertex_array_object) {
55-
glBindVertexArray(this->vao);
56-
assert_opengl_no_error();
57-
58-
this->bind_buffers();
59-
60-
glBindVertexArray(0);
61-
assert_opengl_no_error();
62-
63-
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
64-
assert_opengl_no_error();
65-
glBindBuffer(GL_ARRAY_BUFFER, 0);
66-
assert_opengl_no_error();
67-
}
68-
}
69-
70-
vertex_array::~vertex_array()
71-
{
72-
if (GLEW_ARB_vertex_array_object) {
73-
glBindVertexArray(0);
74-
assert_opengl_no_error();
75-
glDeleteVertexArrays(1, &this->vao);
76-
assert_opengl_no_error();
77-
}
78-
}
41+
)
42+
{}
7943

8044
void vertex_array::bind_buffers() const
8145
{

src/ruis/render/opengl/vertex_array.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace ruis::render::opengl {
2929
class vertex_array : public ruis::render::vertex_array
3030
{
3131
public:
32-
const GLuint vao;
32+
// NOTE: The native OpenGL Vertex Array Object is not used because it cannot be shared between OpenGL contexts.
3333

3434
vertex_array(
3535
utki::shared_ref<ruis::render::renderer> renderer, //
@@ -44,7 +44,7 @@ class vertex_array : public ruis::render::vertex_array
4444
vertex_array(vertex_array&&) = delete;
4545
vertex_array& operator=(vertex_array&&) = delete;
4646

47-
~vertex_array() override;
47+
~vertex_array() override = default;
4848

4949
void bind_buffers() const;
5050

0 commit comments

Comments
 (0)