[nostalgia] Move much of the OpenGL code to glutils

This commit is contained in:
2021-10-29 00:57:59 -05:00
parent 51f3c01c4e
commit 45d79e99e8
6 changed files with 99 additions and 66 deletions
+26 -2
View File
@@ -9,6 +9,7 @@
#pragma once
#include <ox/std/defines.hpp>
#include <ox/std/string.hpp>
#define GL_GLEXT_PROTOTYPES 1
#ifdef OX_OS_Darwin
@@ -21,9 +22,12 @@
#endif
#include <ox/std/error.hpp>
#include <ox/std/vector.hpp>
namespace nostalgia::glutils {
constexpr auto GlslVersion = "#version 150";
struct Empty {};
struct TextureBase {
@@ -125,6 +129,8 @@ using GLVertexArray = GLObject<deleteVertexArray>;
* and not its dependencies.
*/
struct FrameBuffer {
int width = 0;
int height = 0;
GLFrameBuffer fbo;
GLTexture color;
GLRenderBuffer depth;
@@ -139,10 +145,28 @@ struct FrameBuffer {
};
[[nodiscard]]
ox::Result<GLProgram> buildShaderProgram(const GLchar *vert, const GLchar *frag) noexcept;
ox::Result<GLProgram> buildShaderProgram(const ox::String &vert, const ox::String &frag) noexcept;
glutils::GLVertexArray generateVertexArrayObject() noexcept;
glutils::GLBuffer generateBuffer() noexcept;
[[nodiscard]]
FrameBuffer generateFrameBuffer(int width, int height) noexcept;
}
struct BufferSet {
glutils::GLVertexArray vao;
glutils::GLBuffer vbo;
glutils::GLBuffer ebo;
glutils::GLTexture tex;
ox::Vector<float> vertices;
ox::Vector<GLuint> elements;
};
void sendVbo(const BufferSet &bg) noexcept;
void sendEbo(const BufferSet &bg) noexcept;
}