[Feat] (GL_State/RenderState): implement glDrawArrays (command only)

This commit is contained in:
2026-02-17 08:50:34 +08:00
parent 3ce7a2fd46
commit 5412d1c165
5 changed files with 82 additions and 9 deletions
@@ -1,4 +1,4 @@
// MobileGL - MobileGL/MG_Backend/DirectVulkan/DirectVulkan.cpp
// MobileGL - MobileGL/MG_Backend/DirectVulkan/DirectVulkan.cpp
// Copyright (c) 2025-2026 MobileGL-Dev
// Licensed under the GNU Lesser General Public License v3.0:
// https://www.gnu.org/licenses/gpl-3.0.txt
@@ -13,9 +13,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
UniquePtr<VulkanRenderer> pVulkanRenderer = nullptr;
void Clear(GLbitfield mask) {
if (!pVulkanRenderer || !MG_State::pGLContext) {
return;
}
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::Clear called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_State::pGLContext, "DirectVulkan::Clear called with null GL context");
const auto& clearColor = MG_State::pGLContext->GetClearColor();
const auto clearDepth = MG_State::pGLContext->GetClearDepth();
@@ -24,13 +23,52 @@ namespace MobileGL::MG_Backend::DirectVulkan {
}
void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) {
if (pVulkanRenderer) {
pVulkanRenderer->EnsureFrameRecordingStarted();
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::DrawElements called with null VulkanRenderer");
if (count < 0) {
MGLOG_W("DrawElements skipped: count (%d) must be non-negative", count);
return;
}
if (count == 0) {
return;
}
if (mode != GL_TRIANGLES) {
MGLOG_W("DrawElements skipped: primitive mode %u is not supported yet", mode);
return;
}
pVulkanRenderer->EnsureFrameRecordingStarted();
(void)mode;
(void)count;
(void)type;
(void)indices;
}
void DrawArrays(GLenum mode, GLint first, GLsizei count) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::DrawArrays called with null VulkanRenderer");
if (first < 0) {
MGLOG_W("DrawArrays skipped: first (%d) must be non-negative", first);
return;
}
if (count < 0) {
MGLOG_W("DrawArrays skipped: count (%d) must be non-negative", count);
return;
}
if (count == 0) {
return;
}
if (mode != GL_TRIANGLES) {
MGLOG_W("DrawArrays skipped: primitive mode %u is not supported yet", mode);
return;
}
pVulkanRenderer->DrawArrays(mode, first, count);
}
} // namespace MobileGL::MG_Backend::DirectVulkan