[nostalgia/core/userland] Cleanup
This commit is contained in:
parent
f5ff700bf3
commit
fefe8bacc7
@ -30,10 +30,10 @@ constexpr auto BgVertexVboLength = BgVertexVboRows * BgVertexVboRowLength;
|
||||
constexpr auto BgVertexEboLength = 6;
|
||||
|
||||
struct Background {
|
||||
VertexArray vao;
|
||||
Buffer vbo;
|
||||
Buffer ebo;
|
||||
Texture tex;
|
||||
GLVertexArray vao;
|
||||
GLBuffer vbo;
|
||||
GLBuffer ebo;
|
||||
GLTexture tex;
|
||||
bool enabled = false;
|
||||
bool updated = false;
|
||||
std::array<float, TileCount * BgVertexVboLength> bgVertices = {};
|
||||
@ -41,7 +41,7 @@ struct Background {
|
||||
};
|
||||
|
||||
struct GlImplData {
|
||||
Program bgShader;
|
||||
GLProgram bgShader;
|
||||
int64_t prevFpsCheckTime = 0;
|
||||
uint64_t draws = 0;
|
||||
std::array<Background, 4> backgrounds;
|
||||
@ -119,16 +119,16 @@ static void initBackgroundBufferObjects(Context *ctx, Background *bg) noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
static VertexArray genVertexArrayObject() noexcept {
|
||||
static GLVertexArray genVertexArrayObject() noexcept {
|
||||
GLuint vao = 0;
|
||||
glGenVertexArrays(1, &vao);
|
||||
return VertexArray(vao);
|
||||
return GLVertexArray(vao);
|
||||
}
|
||||
|
||||
static Buffer genBuffer() noexcept {
|
||||
static GLBuffer genBuffer() noexcept {
|
||||
GLuint buff = 0;
|
||||
glGenBuffers(1, &buff);
|
||||
return Buffer(buff);
|
||||
return GLBuffer(buff);
|
||||
}
|
||||
|
||||
static void initBackgroundBufferset(Context *ctx, GLuint shader, Background *bg) noexcept {
|
||||
@ -151,10 +151,10 @@ static void initBackgroundBufferset(Context *ctx, GLuint shader, Background *bg)
|
||||
ox::bit_cast<void*>(2 * sizeof(float)));
|
||||
}
|
||||
|
||||
static Texture loadTexture(GLsizei w, GLsizei h, void *pixels) noexcept {
|
||||
static GLTexture loadTexture(GLsizei w, GLsizei h, void *pixels) noexcept {
|
||||
GLuint texId = 0;
|
||||
glGenTextures(1, &texId);
|
||||
Texture tex(texId);
|
||||
GLTexture tex(texId);
|
||||
tex.width = w;
|
||||
tex.height = h;
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
@ -28,15 +28,15 @@ void deleteVertexArray(GLuint v) noexcept {
|
||||
glDeleteVertexArrays(1, &v);
|
||||
}
|
||||
|
||||
template struct GLobject<deleteBuffer>;
|
||||
template struct GLobject<deleteTexture, TextureBase>;
|
||||
template struct GLobject<deleteVertexArray>;
|
||||
template struct GLobject<glDeleteProgram>;
|
||||
template struct GLobject<glDeleteShader>;
|
||||
template struct GLObject<deleteBuffer>;
|
||||
template struct GLObject<deleteTexture, TextureBase>;
|
||||
template struct GLObject<deleteVertexArray>;
|
||||
template struct GLObject<glDeleteProgram>;
|
||||
template struct GLObject<glDeleteShader>;
|
||||
|
||||
[[nodiscard]]
|
||||
static ox::Result<Shader> buildShader(GLuint shaderType, const GLchar *src, const char *shaderName) noexcept {
|
||||
Shader shader(glCreateShader(shaderType));
|
||||
static ox::Result<GLShader> buildShader(GLuint shaderType, const GLchar *src, const char *shaderName) noexcept {
|
||||
GLShader shader(glCreateShader(shaderType));
|
||||
glShaderSource(shader, 1, &src, nullptr);
|
||||
glCompileShader(shader);
|
||||
GLint status;
|
||||
@ -51,10 +51,10 @@ static ox::Result<Shader> buildShader(GLuint shaderType, const GLchar *src, cons
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
ox::Result<Program> buildShaderProgram(const GLchar *vert, const GLchar *frag) noexcept {
|
||||
ox::Result<GLProgram> buildShaderProgram(const GLchar *vert, const GLchar *frag) noexcept {
|
||||
oxRequire(vs, buildShader(GL_VERTEX_SHADER, vert, "vshad"));
|
||||
oxRequire(fs, buildShader(GL_FRAGMENT_SHADER, frag, "fshad"));
|
||||
Program prgm(glCreateProgram());
|
||||
GLProgram prgm(glCreateProgram());
|
||||
glAttachShader(prgm, vs);
|
||||
glAttachShader(prgm, fs);
|
||||
glLinkProgram(prgm);
|
||||
|
@ -47,26 +47,26 @@ struct TextureBase {
|
||||
|
||||
|
||||
template<auto del, typename Base = Empty>
|
||||
struct GLobject: public Base {
|
||||
struct GLObject: public Base {
|
||||
|
||||
GLuint id = 0;
|
||||
|
||||
constexpr GLobject() noexcept = default;
|
||||
constexpr GLObject() noexcept = default;
|
||||
|
||||
explicit constexpr GLobject(GLuint id) noexcept {
|
||||
explicit constexpr GLObject(GLuint id) noexcept {
|
||||
this->id = id;
|
||||
}
|
||||
|
||||
constexpr GLobject(GLobject &&o) noexcept: Base(ox::move(o)) {
|
||||
constexpr GLObject(GLObject &&o) noexcept: Base(ox::move(o)) {
|
||||
id = o.id;
|
||||
o.id = 0;
|
||||
}
|
||||
|
||||
~GLobject() {
|
||||
~GLObject() {
|
||||
del(id);
|
||||
}
|
||||
|
||||
GLobject &operator=(GLobject &&o) noexcept {
|
||||
GLObject &operator=(GLObject &&o) noexcept {
|
||||
if (this != &o) {
|
||||
del(id);
|
||||
Base::operator=(ox::move(o));
|
||||
@ -96,19 +96,19 @@ void deleteBuffer(GLuint b) noexcept;
|
||||
void deleteTexture(GLuint t) noexcept;
|
||||
void deleteVertexArray(GLuint v) noexcept;
|
||||
|
||||
extern template struct GLobject<deleteBuffer>;
|
||||
extern template struct GLobject<deleteTexture, TextureBase>;
|
||||
extern template struct GLobject<deleteVertexArray>;
|
||||
extern template struct GLobject<glDeleteProgram>;
|
||||
extern template struct GLobject<glDeleteShader>;
|
||||
extern template struct GLObject<deleteBuffer>;
|
||||
extern template struct GLObject<deleteTexture, TextureBase>;
|
||||
extern template struct GLObject<deleteVertexArray>;
|
||||
extern template struct GLObject<glDeleteProgram>;
|
||||
extern template struct GLObject<glDeleteShader>;
|
||||
|
||||
using Buffer = GLobject<deleteBuffer>;
|
||||
using Shader = GLobject<glDeleteShader>;
|
||||
using Program = GLobject<glDeleteProgram>;
|
||||
using Texture = GLobject<deleteTexture, TextureBase>;
|
||||
using VertexArray = GLobject<deleteVertexArray>;
|
||||
using GLBuffer = GLObject<deleteBuffer>;
|
||||
using GLShader = GLObject<glDeleteShader>;
|
||||
using GLProgram = GLObject<glDeleteProgram>;
|
||||
using GLTexture = GLObject<deleteTexture, TextureBase>;
|
||||
using GLVertexArray = GLObject<deleteVertexArray>;
|
||||
|
||||
[[nodiscard]]
|
||||
ox::Result<Program> buildShaderProgram(const GLchar *vert, const GLchar *frag) noexcept;
|
||||
ox::Result<GLProgram> buildShaderProgram(const GLchar *vert, const GLchar *frag) noexcept;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user