summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-12-22 14:10:34 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-12-22 14:10:34 +0000
commit20646758939562c0fbad4d52774efcfacf7e22fc (patch)
tree9bd582b749640206a5e38389117d6c931dcf1f5f /ui
parentInitial commit with some basic UI (diff)
downloadilt-20646758939562c0fbad4d52774efcfacf7e22fc.tar.bz2
ilt-20646758939562c0fbad4d52774efcfacf7e22fc.tar.xz
ilt-20646758939562c0fbad4d52774efcfacf7e22fc.zip
RAII for glVertex and glBuffer
Diffstat (limited to 'ui')
-rw-r--r--ui/iconButton.cpp9
-rw-r--r--ui/iconButton.h6
2 files changed, 8 insertions, 7 deletions
diff --git a/ui/iconButton.cpp b/ui/iconButton.cpp
index c35303f..c97896f 100644
--- a/ui/iconButton.cpp
+++ b/ui/iconButton.cpp
@@ -1,6 +1,9 @@
#include "iconButton.h"
+#include "glBuffers.h"
+#include "glVertexArrays.h"
#include "ui/icon.h"
#include "ui/uiComponent.h"
+#include <GL/glew.h>
#include <SDL2/SDL.h>
#include <array>
#include <filesystem>
@@ -9,14 +12,10 @@
#include <utility>
IconButton::IconButton(const std::string & icon_, glm::vec2 position_, UIEvent click_) :
- UIComponent {{position_, ICON_SIZE}}, icon {icon_}, click {std::move(click_)}, m_vertexArrayObject {},
- m_vertexArrayBuffer {}
+ UIComponent {{position_, ICON_SIZE}}, icon {icon_}, click {std::move(click_)}
{
- glGenVertexArrays(1, &m_vertexArrayObject);
glBindVertexArray(m_vertexArrayObject);
- glGenBuffers(1, &m_vertexArrayBuffer);
-
glBindBuffer(GL_ARRAY_BUFFER, m_vertexArrayBuffer);
glBufferData(GL_ARRAY_BUFFER, static_cast<GLsizeiptr>(sizeof(glm::vec4) * 4), nullptr, GL_DYNAMIC_DRAW);
diff --git a/ui/iconButton.h b/ui/iconButton.h
index ec3f357..76e3f1b 100644
--- a/ui/iconButton.h
+++ b/ui/iconButton.h
@@ -3,7 +3,8 @@
#include "icon.h"
#include "uiComponent.h"
-#include <GL/glew.h>
+#include <glBuffers.h>
+#include <glVertexArrays.h>
#include <glm/glm.hpp>
#include <string>
@@ -21,7 +22,8 @@ public:
Icon icon;
UIEvent click;
- GLuint m_vertexArrayObject, m_vertexArrayBuffer;
+ glVertexArray m_vertexArrayObject;
+ glBuffer m_vertexArrayBuffer;
};
#endif