[Feat] (...): Implement glDrawArrays.

This commit is contained in:
BZLZHH
2025-11-01 13:06:18 +08:00
parent 0ae69cfe9e
commit e8d6cd4b31
6 changed files with 21 additions and 3 deletions
+1 -1
View File
@@ -31,7 +31,7 @@
#define MOBILEGL_BACKEND_TYPE_DIRECT_GLES 3
// ====================== MobileGL configurations ======================= //
#define MOBILEGL_LOG_ACTIVE_LEVEL MOBILEGL_LOG_LEVEL_DEBUG
#define MOBILEGL_LOG_ACTIVE_LEVEL MOBILEGL_LOG_LEVEL_WARN
#define MOBILEGL_LOG_ENABLE_CONSOLE 0
#define MOBILEGL_LOG_ENABLE_FILE 1
@@ -348,6 +348,11 @@ namespace MobileGL::MG_Backend::DirectGLES {
}
}
void DrawArrays(GLenum mode, GLint first, GLsizei count) {
PrepareForDraw();
MG_External::GLES::glDrawArrays(mode, first, count);
}
void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) {
PrepareForDraw();
MG_External::GLES::glDrawElements(mode, count, type, indices);
@@ -35,7 +35,17 @@ namespace MobileGL {
#endif
}
void DrawArrays_Backend(GLenum mode, GLint first, GLsizei count) {
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
MG_Backend::DirectGLES::DrawArrays(mode, first, count);
#endif
}
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
void DrawArrays(GLenum mode, GLint first, GLsizei count) {
DrawArrays_Backend(mode, first, count);
}
void MultiDrawElements(GLenum mode, const GLsizei* count, GLenum type, const void* const* indices,
GLsizei drawcount) {
MultiDrawElements_Backend(mode, count, type, indices, drawcount);
@@ -4,6 +4,7 @@
namespace MobileGL {
namespace MG_Impl::GLImpl {
/* @INSERTION_POINT:FUNCTION_DECLARATION@ */
void DrawArrays(GLenum mode, GLint first, GLsizei count);
void MultiDrawElements(GLenum mode, const GLsizei* count, GLenum type, const void* const* indices,
GLsizei drawcount);
void MultiDrawElementsBaseVertex(GLenum mode, const GLsizei* count, GLenum type, const void* const* indices,
@@ -77,7 +77,7 @@ DECLARE_GL_FUNCTION_STUB_HEAD(void, DepthRangef, GLfloat n, GLfloat f) DECLARE_G
DECLARE_GL_FUNCTION_HEAD(void, DetachShader, GLuint program, GLuint shader) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DetachShader, program, shader)
DECLARE_GL_FUNCTION_HEAD(void, Disable, GLenum cap) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Disable, cap)
DECLARE_GL_FUNCTION_HEAD(void, DisableVertexAttribArray, GLuint index) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DisableVertexAttribArray, index)
DECLARE_GL_FUNCTION_STUB_HEAD(void, DrawArrays, GLenum mode, GLint first, GLsizei count) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DrawArrays, mode, first, count)
DECLARE_GL_FUNCTION_HEAD(void, DrawArrays, GLenum mode, GLint first, GLsizei count) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DrawArrays, mode, first, count)
DECLARE_GL_FUNCTION_HEAD(void, DrawElements, GLenum mode, GLsizei count, GLenum type, const void* indices) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DrawElements, mode, count, type, indices)
DECLARE_GL_FUNCTION_HEAD(void, Enable, GLenum cap) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Enable, cap)
DECLARE_GL_FUNCTION_HEAD(void, EnableVertexAttribArray, GLuint index) DECLARE_GL_FUNCTION_END_NO_RETURN(void, EnableVertexAttribArray, index)
@@ -788,7 +788,9 @@ namespace MobileGL {
ErrorCode::InvalidEnum,
MakeShared<GenericErrorInfo>(
"MG_Impl/GLImpl", "ActiveTexture_State",
"Texture must be one of GL_TEXTUREi, where i is in the range 0 to 31."));
std::format("Texture must be one of GL_TEXTUREi, where i is in the range 0 to 31, but got "
"invalid enum: 0x{:X}, which may stand for unit {}.",
texture, texture - GL_TEXTURE0)));
return;
}