[core] Use initializer list for Unique* objects

This commit is contained in:
Bruno de Oliveira Abinader
2016-06-06 16:15:29 +03:00
parent b761aad4e6
commit 5e6f8d4ce5

View File

@@ -20,27 +20,27 @@ class ObjectStore;
struct ProgramDeleter {
ObjectStore* store;
void operator()(GLuint id) const;
void operator()(GLuint) const;
};
struct ShaderDeleter {
ObjectStore* store;
void operator()(GLuint id) const;
void operator()(GLuint) const;
};
struct BufferDeleter {
ObjectStore* store;
void operator()(GLuint id) const;
void operator()(GLuint) const;
};
struct TextureDeleter {
ObjectStore* store;
void operator()(GLuint id) const;
void operator()(GLuint) const;
};
struct VAODeleter {
ObjectStore* store;
void operator()(GLuint id) const;
void operator()(GLuint) const;
};
using ObjectPool = std::array<GLuint, TextureMax>;
@@ -62,36 +62,36 @@ public:
~ObjectStore();
UniqueProgram createProgram() {
return UniqueProgram(MBGL_CHECK_ERROR(glCreateProgram()), { this });
return UniqueProgram { MBGL_CHECK_ERROR(glCreateProgram()), { this } };
}
UniqueShader createShader(GLenum type) {
return UniqueShader(MBGL_CHECK_ERROR(glCreateShader(type)), { this });
return UniqueShader { MBGL_CHECK_ERROR(glCreateShader(type)), { this } };
}
UniqueBuffer createBuffer() {
GLuint id = 0;
MBGL_CHECK_ERROR(glGenBuffers(1, &id));
return UniqueBuffer(std::move(id), { this });
return UniqueBuffer { std::move(id), { this } };
}
UniqueTexture createTexture() {
GLuint id = 0;
MBGL_CHECK_ERROR(glGenTextures(1, &id));
return UniqueTexture(std::move(id), { this });
return UniqueTexture { std::move(id), { this } };
}
UniqueVAO createVAO() {
GLuint id = 0;
MBGL_CHECK_ERROR(gl::GenVertexArrays(1, &id));
return UniqueVAO(std::move(id), { this });
return UniqueVAO { std::move(id), { this } };
}
UniqueTexturePool createTexturePool() {
ObjectPool ids;
MBGL_CHECK_ERROR(glGenTextures(TextureMax, ids.data()));
assert(ids.size() == size_t(TextureMax));
return UniqueTexturePool(std::move(ids), { this });
return UniqueTexturePool { std::move(ids), { this } };
}
// Actually remove the objects we marked as abandoned with the above methods.