mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 06:08:30 +09:00
[Feat] (Diligent, MG_Backend): wire Clear/Draw/Present into GLFunctionsTable
BackendObject_Diligent now exposes real function-table entries backed by the DiligentRenderer: Clear reads the current GL clear color from MG_State, and DrawArrays/DrawElements currently render the built-in triangle as a placeholder until buffer/VAO/program state is connected. Present flushes the immediate context. Local Diligent tests still pass on Turnip Adreno 750.
This commit is contained in:
@@ -9,6 +9,8 @@
|
|||||||
#include "DiligentVulkan.h"
|
#include "DiligentVulkan.h"
|
||||||
#include "Renderer/DiligentRenderer.h"
|
#include "Renderer/DiligentRenderer.h"
|
||||||
#include <MG_Backend/BackendObject.h>
|
#include <MG_Backend/BackendObject.h>
|
||||||
|
#include <MG_Backend/BackendObjects.h>
|
||||||
|
#include <MG_State/GLState/Core.h>
|
||||||
|
|
||||||
#include <EngineFactoryVk.h>
|
#include <EngineFactoryVk.h>
|
||||||
#include <RenderDevice.h>
|
#include <RenderDevice.h>
|
||||||
@@ -27,6 +29,52 @@ namespace MobileGL::MG_Backend::DiligentBackend {
|
|||||||
info.RendererGLInfo.IsCompatibilityProfile = false;
|
info.RendererGLInfo.IsCompatibilityProfile = false;
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DiligentRenderer* GetActiveRenderer() {
|
||||||
|
auto* backend = dynamic_cast<BackendObject_Diligent*>(pActiveBackendObject.get());
|
||||||
|
return backend != nullptr ? backend->GetRenderer() : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clear(GLbitfield mask) {
|
||||||
|
auto* renderer = GetActiveRenderer();
|
||||||
|
if (renderer == nullptr || MG_State::pGLContext == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((mask & GL_COLOR_BUFFER_BIT) != 0) {
|
||||||
|
const auto& color = MG_State::pGLContext->GetClearColor();
|
||||||
|
renderer->Clear(color.x(), color.y(), color.z(), color.w());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawArrays(GLenum mode, GLint first, GLsizei count) {
|
||||||
|
(void)mode;
|
||||||
|
(void)first;
|
||||||
|
(void)count;
|
||||||
|
auto* renderer = GetActiveRenderer();
|
||||||
|
if (renderer != nullptr) {
|
||||||
|
// Placeholder: draw the built-in triangle until the real
|
||||||
|
// buffer/VAO/program state is wired into the renderer.
|
||||||
|
renderer->DrawTriangle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) {
|
||||||
|
(void)mode;
|
||||||
|
(void)count;
|
||||||
|
(void)type;
|
||||||
|
(void)indices;
|
||||||
|
auto* renderer = GetActiveRenderer();
|
||||||
|
if (renderer != nullptr) {
|
||||||
|
renderer->DrawTriangle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Present() {
|
||||||
|
auto* renderer = GetActiveRenderer();
|
||||||
|
if (renderer != nullptr) {
|
||||||
|
renderer->Present();
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
BackendObject_Diligent::BackendObject_Diligent()
|
BackendObject_Diligent::BackendObject_Diligent()
|
||||||
@@ -105,6 +153,12 @@ namespace MobileGL::MG_Backend::DiligentBackend {
|
|||||||
m_pRenderer.reset();
|
m_pRenderer.reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_functions.GL.Clear = Clear;
|
||||||
|
m_functions.GL.DrawArrays = DrawArrays;
|
||||||
|
m_functions.GL.DrawElements = DrawElements;
|
||||||
|
m_functions.Present = Present;
|
||||||
|
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user