[core] Redo approach to unsupported VAO extension
This commit is contained in:
@@ -122,17 +122,17 @@ UniqueTexture Context::createTexture() {
|
||||
return UniqueTexture{ std::move(id), { this } };
|
||||
}
|
||||
|
||||
bool Context::supportsVertexArrays() const {
|
||||
return gl::GenVertexArrays &&
|
||||
gl::BindVertexArray &&
|
||||
gl::DeleteVertexArrays &&
|
||||
!disableVAOExtension;
|
||||
}
|
||||
|
||||
UniqueVertexArray Context::createVertexArray() {
|
||||
assert(supportsVertexArrays());
|
||||
VertexArrayID id = 0;
|
||||
if (gl::GenVertexArrays && !disableVAOExtension) {
|
||||
MBGL_CHECK_ERROR(gl::GenVertexArrays(1, &id));
|
||||
} else {
|
||||
static bool reported = false;
|
||||
if (!reported) {
|
||||
Log::Warning(Event::OpenGL, "Not using Vertex Array Objects");
|
||||
reported = true;
|
||||
}
|
||||
}
|
||||
MBGL_CHECK_ERROR(gl::GenVertexArrays(1, &id));
|
||||
return UniqueVertexArray(std::move(id), { this });
|
||||
}
|
||||
|
||||
@@ -529,6 +529,7 @@ void Context::performCleanup() {
|
||||
}
|
||||
|
||||
if (!abandonedVertexArrays.empty()) {
|
||||
assert(supportsVertexArrays());
|
||||
for (const auto id : abandonedVertexArrays) {
|
||||
if (vertexArrayObject == id) {
|
||||
vertexArrayObject.setDirty();
|
||||
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
UniqueProgram createProgram(ShaderID vertexShader, ShaderID fragmentShader);
|
||||
void linkProgram(ProgramID);
|
||||
UniqueTexture createTexture();
|
||||
|
||||
bool supportsVertexArrays() const;
|
||||
UniqueVertexArray createVertexArray();
|
||||
|
||||
template <class Vertex, class DrawMode>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <mbgl/gl/context.hpp>
|
||||
#include <mbgl/gl/vertex_buffer.hpp>
|
||||
#include <mbgl/util/optional.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
@@ -32,12 +33,11 @@ public:
|
||||
BufferID indexBuffer_,
|
||||
const typename Attributes::Locations& attributeLocations,
|
||||
const typename Attributes::Bindings& attributeBindings_) const {
|
||||
if (!vao) {
|
||||
vao = context.createVertexArray();
|
||||
context.vertexBuffer.setDirty();
|
||||
}
|
||||
|
||||
if (*vao) {
|
||||
if (context.supportsVertexArrays()) {
|
||||
if (!vao) {
|
||||
vao = context.createVertexArray();
|
||||
context.vertexBuffer.setDirty();
|
||||
}
|
||||
context.vertexArrayObject = *vao;
|
||||
if (indexBuffer != indexBuffer_) {
|
||||
indexBuffer = indexBuffer_;
|
||||
@@ -46,6 +46,11 @@ public:
|
||||
}
|
||||
} else {
|
||||
// No VAO support. Force attributes to be rebound.
|
||||
static bool reported = false;
|
||||
if (!reported) {
|
||||
Log::Warning(Event::OpenGL, "Not using Vertex Array Objects");
|
||||
reported = true;
|
||||
}
|
||||
context.elementBuffer = indexBuffer_;
|
||||
variableBindings = {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user