mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-09 12:48:32 +09:00
[Feat] (...): Add BufferState and VertexBufferState while implementing these gl functions.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// Created by BZLZHH on 2025/5/1.
|
||||
//
|
||||
|
||||
#ifndef MOBILEGL_VERTEXARRAYSTATE_H
|
||||
#define MOBILEGL_VERTEXARRAYSTATE_H
|
||||
#define MOBILEGL_GLSTATE_H
|
||||
|
||||
#include "../../../Includes.h"
|
||||
|
||||
struct VertexAttribState {
|
||||
bool enabled = false;
|
||||
GLint size = 4;
|
||||
GLenum type = GL_FLOAT;
|
||||
GLboolean normalized = GL_FALSE;
|
||||
GLsizei stride = 0;
|
||||
const GLvoid* pointer = nullptr;
|
||||
GLuint buffer = 0;
|
||||
bool isInteger = false;
|
||||
};
|
||||
|
||||
struct VertexArrayObject {
|
||||
bool generated = false;
|
||||
GLuint elementBuffer = 0;
|
||||
std::unordered_map<GLuint, VertexAttribState> attribs;
|
||||
};
|
||||
|
||||
class VertexArrayState {
|
||||
public:
|
||||
VertexArrayState();
|
||||
|
||||
// Return: the validity of the operation, according to OpenGL 3 standard
|
||||
GLenum Create(GLuint* array);
|
||||
GLenum CreateN(GLsizei n, GLuint* arrays);
|
||||
GLenum Bind(GLuint array);
|
||||
GLenum EnableAttrib(GLuint index);
|
||||
GLenum DisableAttrib(GLuint index);
|
||||
GLenum SetAttribPointer(GLuint index, GLint size, GLenum type,
|
||||
GLboolean normalized, GLsizei stride,
|
||||
const void* pointer, bool isInteger,
|
||||
GLuint currentArrayBuffer);
|
||||
|
||||
GLuint GetBoundElementBuffer();
|
||||
VertexArrayObject* GetCurrentVAO();
|
||||
|
||||
private:
|
||||
std::unordered_map<GLuint, VertexArrayObject> vaos_;
|
||||
std::set<GLuint> freeIds_;
|
||||
GLuint lastId_ = 0;
|
||||
GLuint currentVao_ = 0;
|
||||
};
|
||||
|
||||
#endif //MOBILEGL_VERTEXARRAYSTATE_H
|
||||
Reference in New Issue
Block a user