From 726b8486c7a115768000d1776a04dd4dc818b976 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sun, 4 Oct 2020 17:22:16 +0300 Subject: [PATCH] Add explicit bool cast for OpenGL objects --- libs/gfx/include/psemek/gfx/buffer.hpp | 2 ++ libs/gfx/include/psemek/gfx/framebuffer.hpp | 2 ++ libs/gfx/include/psemek/gfx/renderbuffer.hpp | 2 ++ libs/gfx/include/psemek/gfx/texture.hpp | 4 ++-- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/gfx/include/psemek/gfx/buffer.hpp b/libs/gfx/include/psemek/gfx/buffer.hpp index 3cb3d273..eb25949e 100644 --- a/libs/gfx/include/psemek/gfx/buffer.hpp +++ b/libs/gfx/include/psemek/gfx/buffer.hpp @@ -21,6 +21,8 @@ namespace psemek::gfx GLuint id() const { return id_; } + explicit operator bool() const { return id() != 0; } + void bind() const; void reset(); diff --git a/libs/gfx/include/psemek/gfx/framebuffer.hpp b/libs/gfx/include/psemek/gfx/framebuffer.hpp index e291a6a3..e5797ffe 100644 --- a/libs/gfx/include/psemek/gfx/framebuffer.hpp +++ b/libs/gfx/include/psemek/gfx/framebuffer.hpp @@ -21,6 +21,8 @@ namespace psemek::gfx GLuint id() const { return id_; } + explicit operator bool() const { return id() != 0; } + void bind() const; void reset(); diff --git a/libs/gfx/include/psemek/gfx/renderbuffer.hpp b/libs/gfx/include/psemek/gfx/renderbuffer.hpp index ccef0dbf..0d11c192 100644 --- a/libs/gfx/include/psemek/gfx/renderbuffer.hpp +++ b/libs/gfx/include/psemek/gfx/renderbuffer.hpp @@ -21,6 +21,8 @@ namespace psemek::gfx GLuint id() const { return id_; } + explicit operator bool() const { return id() != 0; } + void bind() const; void reset(); diff --git a/libs/gfx/include/psemek/gfx/texture.hpp b/libs/gfx/include/psemek/gfx/texture.hpp index 9681a713..f32e3586 100644 --- a/libs/gfx/include/psemek/gfx/texture.hpp +++ b/libs/gfx/include/psemek/gfx/texture.hpp @@ -27,12 +27,12 @@ namespace psemek::gfx GLuint id() const { return id_; } + explicit operator bool() const { return id() != 0; } + void reset(); void bind() const; - explicit operator bool() const { return id() != 0; } - geom::vector size() const { return size_; } std::size_t width() const;