mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +09:00
[Refactor] (All): Restructure include system.
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
#include "../../../Includes.h"
|
||||
#include <Includes.h>
|
||||
#include "../Temporary/TemporaryEGLImpl.h"
|
||||
|
||||
MOBILEGL_EGL_API EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window,
|
||||
const EGLint* attrib_list) {
|
||||
const EGLint* attrib_list) {
|
||||
return MobileGL::MG_Impl::EGLImpl::CreateWindowSurface(dpy, config, window, attrib_list);
|
||||
}
|
||||
|
||||
MOBILEGL_EGL_API EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs,
|
||||
EGLint config_size, EGLint* num_config) {
|
||||
EGLint config_size, EGLint* num_config) {
|
||||
return MobileGL::MG_Impl::EGLImpl::ChooseConfig(dpy, attrib_list, configs, config_size, num_config);
|
||||
}
|
||||
|
||||
MOBILEGL_EGL_API EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx,
|
||||
const EGLint* attrib_list) {
|
||||
const EGLint* attrib_list) {
|
||||
return MobileGL::MG_Impl::EGLImpl::CreateContext(dpy, config, shareCtx, attrib_list);
|
||||
}
|
||||
|
||||
@@ -82,4 +83,3 @@ MOBILEGL_EGL_API EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig co
|
||||
MOBILEGL_EGL_API __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char* name) {
|
||||
return MobileGL::MG_Impl::EGLImpl::GetProcAddress(name);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "TemporaryEGLImpl.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::EGLImpl {
|
||||
// TODO: Implement complete EGL functionality
|
||||
// TODO: Implement complete EGL functionality
|
||||
|
||||
EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window,
|
||||
const EGLint* attrib_list) {
|
||||
const EGLint* attrib_list) {
|
||||
return (EGLSurface)1;
|
||||
}
|
||||
|
||||
EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs,
|
||||
EGLint config_size, EGLint* num_config) {
|
||||
EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size,
|
||||
EGLint* num_config) {
|
||||
*num_config = 1;
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx,
|
||||
const EGLint* attrib_list) {
|
||||
EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx, const EGLint* attrib_list) {
|
||||
return (EGLContext)1;
|
||||
}
|
||||
|
||||
@@ -59,8 +58,21 @@ namespace MobileGL {
|
||||
}
|
||||
|
||||
EGLBoolean GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value) {
|
||||
if (attribute == EGL_NATIVE_VISUAL_ID)
|
||||
if (attribute == EGL_NATIVE_VISUAL_ID) {
|
||||
#if defined(ANDROID)
|
||||
*value = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
|
||||
return EGL_TRUE;
|
||||
#elif defined(__linux__)
|
||||
*value = 0;
|
||||
return EGL_TRUE;
|
||||
#elif defined(_WIN32)
|
||||
*value = 0;
|
||||
return EGL_TRUE;
|
||||
#else
|
||||
*value = 0;
|
||||
return EGL_FALSE;
|
||||
#endif
|
||||
}
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
@@ -95,7 +107,7 @@ namespace MobileGL {
|
||||
MGLOG_W("Failed to get function: %s", (const char*)name);
|
||||
return nullptr;
|
||||
}
|
||||
return (__eglMustCastToProperFunctionPointerType)proc;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (__eglMustCastToProperFunctionPointerType)proc;
|
||||
}
|
||||
} // namespace MG_Impl::EGLImpl
|
||||
} // namespace MobileGL
|
||||
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::EGLImpl {
|
||||
EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window,
|
||||
const EGLint* attrib_list);
|
||||
EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs,
|
||||
EGLint config_size, EGLint* num_config);
|
||||
EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx,
|
||||
const EGLint* attrib_list);
|
||||
const EGLint* attrib_list);
|
||||
EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size,
|
||||
EGLint* num_config);
|
||||
EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx, const EGLint* attrib_list);
|
||||
EGLBoolean Initialize(EGLDisplay dpy, EGLint* major, EGLint* minor);
|
||||
EGLDisplay GetDisplay(NativeDisplayType display);
|
||||
EGLint GetError();
|
||||
@@ -25,5 +25,5 @@ namespace MobileGL {
|
||||
EGLBoolean SwapBuffers(EGLDisplay dpy, EGLSurface draw);
|
||||
EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list);
|
||||
__eglMustCastToProperFunctionPointerType GetProcAddress(const char* name);
|
||||
}
|
||||
}
|
||||
} // namespace MG_Impl::EGLImpl
|
||||
} // namespace MobileGL
|
||||
@@ -1,457 +1,497 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "GL_Buffer.h"
|
||||
#include "Validators.h"
|
||||
#include <MG_State/GLState/Core.h>
|
||||
#include <MG_State/GLState/ErrorState/Error.h>
|
||||
#include <MG_Util/Converters/GLToMG/BufferEnumConverter.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
void DeleteBuffers_State(GLsizei n, const GLuint* buffers) {
|
||||
if (n < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteBuffers_State",
|
||||
"n must be non-negative."));
|
||||
return;
|
||||
}
|
||||
namespace MG_Impl::GLImpl {
|
||||
void DeleteBuffers_State(GLsizei n, const GLuint* buffers) {
|
||||
if (n < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteBuffers_State", "n must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!buffers) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteBuffers_State",
|
||||
"Buffer names array cannot be null."));
|
||||
return;
|
||||
}
|
||||
if (!buffers) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteBuffers_State",
|
||||
"Buffer names array cannot be null."));
|
||||
return;
|
||||
}
|
||||
|
||||
for (SizeT i = 0; i < static_cast<SizeT>(n); ++i) {
|
||||
Uint bufferName = buffers[i];
|
||||
if (bufferName == 0) continue;
|
||||
if (!BufferImpl::ValidateBufferName(bufferName)) continue;
|
||||
MG_State::pGLContext->MarkBufferObjectForDeletion(bufferName);
|
||||
}
|
||||
for (SizeT i = 0; i < static_cast<SizeT>(n); ++i) {
|
||||
Uint bufferName = buffers[i];
|
||||
if (bufferName == 0) continue;
|
||||
if (!BufferImpl::ValidateBufferName(bufferName)) continue;
|
||||
MG_State::pGLContext->MarkBufferObjectForDeletion(bufferName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FlushMappedBufferRange_State(GLenum target, GLintptr offset, GLsizeiptr length) {
|
||||
if (length < 0 || offset < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Offset and length must be non-negative."));
|
||||
return;
|
||||
}
|
||||
void FlushMappedBufferRange_State(GLenum target, GLintptr offset, GLsizeiptr length) {
|
||||
if (length < 0 || offset < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Offset and length must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return;
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return;
|
||||
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return;
|
||||
}
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bufferObject->IsMapped()) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Cannot flush a buffer object that is not mapped."));
|
||||
return;
|
||||
}
|
||||
if (!bufferObject->IsMapped()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Cannot flush a buffer object that is not mapped."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (offset + length > bufferObject->GetSize()) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Offset and length exceed buffer size."));
|
||||
return;
|
||||
}
|
||||
if (offset + length > bufferObject->GetSize()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Offset and length exceed buffer size."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto mappingAccess = bufferObject->GetMappingAccess();
|
||||
if(!(mappingAccess & BufferMappingAccessBit::FlushExplicit)) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Cannot flush a buffer object that is not mapped with GL_MAP_FLUSH_EXPLICIT_BIT."));
|
||||
return;
|
||||
}
|
||||
auto mappingAccess = bufferObject->GetMappingAccess();
|
||||
if (!(mappingAccess & BufferMappingAccessBit::FlushExplicit)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Cannot flush a buffer object that is not mapped with GL_MAP_FLUSH_EXPLICIT_BIT."));
|
||||
return;
|
||||
}
|
||||
|
||||
bufferObject->FlushMemoryRange(static_cast<SizeT>(offset), static_cast<SizeT>(length));
|
||||
}
|
||||
|
||||
GLboolean UnmapBuffer_State(GLenum target) {
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return GL_FALSE;
|
||||
bufferObject->FlushMemoryRange(static_cast<SizeT>(offset), static_cast<SizeT>(length));
|
||||
}
|
||||
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
GLboolean UnmapBuffer_State(GLenum target) {
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return GL_FALSE;
|
||||
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "UnmapBuffer_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return GL_FALSE;
|
||||
}
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
|
||||
if (!bufferObject->IsMapped()) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "UnmapBuffer_State",
|
||||
"Cannot unmap a buffer object that is not mapped."));
|
||||
return GL_FALSE;
|
||||
}
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "UnmapBuffer_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
bufferObject->ReleaseMemory();
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
void* MapBufferRange_State(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) {
|
||||
if (length < 0 || offset < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Offset and length must be non-negative."));
|
||||
return nullptr;
|
||||
}
|
||||
if (!bufferObject->IsMapped()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "UnmapBuffer_State",
|
||||
"Cannot unmap a buffer object that is not mapped."));
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (length == 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Length must be greater than zero."));
|
||||
return nullptr;
|
||||
}
|
||||
bufferObject->ReleaseMemory();
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return nullptr;
|
||||
void* MapBufferRange_State(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) {
|
||||
if (length < 0 || offset < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Offset and length must be non-negative."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return nullptr;
|
||||
}
|
||||
if (length == 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Length must be greater than zero."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (offset + length > bufferObject->GetSize()) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Offset and length exceed buffer size."));
|
||||
return nullptr;
|
||||
}
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return nullptr;
|
||||
|
||||
auto accessBits = MG_Util::ConvertGLEnumToBufferMappingAccess(access);
|
||||
if (!BufferImpl::ValidateBufferMappingAccess(accessBits)) return nullptr;
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!(accessBits & (BufferMappingAccessBit::Read | BufferMappingAccessBit::Write))) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"At least one of GL_MAP_READ_BIT or GL_MAP_WRITE_BIT must be set."));
|
||||
return nullptr;
|
||||
}
|
||||
if (offset + length > bufferObject->GetSize()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Offset and length exceed buffer size."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (accessBits & BufferMappingAccessBit::Read) {
|
||||
const auto invalidFlags = BufferMappingAccessBit::InvalidateRange |
|
||||
BufferMappingAccessBit::InvalidateBuffer |
|
||||
BufferMappingAccessBit::Unsynchronized;
|
||||
auto accessBits = MG_Util::ConvertGLEnumToBufferMappingAccess(access);
|
||||
if (!BufferImpl::ValidateBufferMappingAccess(accessBits)) return nullptr;
|
||||
|
||||
if (accessBits & invalidFlags) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"GL_MAP_READ_BIT cannot be combined with invalidation or unsynchronized flags."));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
if (!(accessBits & (BufferMappingAccessBit::Read | BufferMappingAccessBit::Write))) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"At least one of GL_MAP_READ_BIT or GL_MAP_WRITE_BIT must be set."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (accessBits & BufferMappingAccessBit::FlushExplicit) {
|
||||
if (!(accessBits & BufferMappingAccessBit::Write)) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"GL_MAP_FLUSH_EXPLICIT_BIT requires GL_MAP_WRITE_BIT."));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
if (accessBits & BufferMappingAccessBit::Read) {
|
||||
const auto invalidFlags = BufferMappingAccessBit::InvalidateRange |
|
||||
BufferMappingAccessBit::InvalidateBuffer |
|
||||
BufferMappingAccessBit::Unsynchronized;
|
||||
|
||||
const auto storageFlags =
|
||||
BufferMappingAccessBit::Persistent | BufferMappingAccessBit::Coherent;
|
||||
auto requiredFlags = accessBits & storageFlags;
|
||||
if (requiredFlags) {
|
||||
// TODO: check if the buffer data is created by BufferStorage and its flags after its implementation
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Access flags require matching storage flags in buffer."));
|
||||
return nullptr;
|
||||
}
|
||||
if (accessBits & invalidFlags) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"GL_MAP_READ_BIT cannot be combined with invalidation or unsynchronized flags."));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (bufferObject->IsMapped()) {
|
||||
const auto invalidateFlags = BufferMappingAccessBit::InvalidateRange |
|
||||
BufferMappingAccessBit::InvalidateBuffer;
|
||||
if (accessBits & BufferMappingAccessBit::FlushExplicit) {
|
||||
if (!(accessBits & BufferMappingAccessBit::Write)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"GL_MAP_FLUSH_EXPLICIT_BIT requires GL_MAP_WRITE_BIT."));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(accessBits & invalidateFlags)) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Cannot map a buffer object that is already mapped."));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
const auto storageFlags = BufferMappingAccessBit::Persistent | BufferMappingAccessBit::Coherent;
|
||||
auto requiredFlags = accessBits & storageFlags;
|
||||
if (requiredFlags) {
|
||||
// TODO: check if the buffer data is created by BufferStorage and its flags after its implementation
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Access flags require matching storage flags in buffer."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* result = bufferObject->AcquireMemoryRange(
|
||||
{ static_cast<SizeT>(offset), static_cast<SizeT>(offset + length) },
|
||||
accessBits
|
||||
);
|
||||
if (!result) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::OutOfMemory,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Failed to map buffer due to insufficient memory."));
|
||||
return nullptr;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void* MapBuffer_State(GLenum target, GLenum access) {
|
||||
bool readable = access == GL_READ_ONLY || access == GL_READ_WRITE;
|
||||
bool writable = access == GL_WRITE_ONLY || access == GL_READ_WRITE;
|
||||
if (access != GL_READ_ONLY && access != GL_WRITE_ONLY && access != GL_READ_WRITE) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBuffer_State",
|
||||
"Access must be one of GL_READ_ONLY, GL_WRITE_ONLY, or GL_READ_WRITE."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return nullptr;
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBuffer_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (bufferObject->IsMapped()) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBuffer_State",
|
||||
"Cannot map a buffer object that is already mapped."));
|
||||
return nullptr;
|
||||
}
|
||||
if (bufferObject->IsMapped()) {
|
||||
const auto invalidateFlags =
|
||||
BufferMappingAccessBit::InvalidateRange | BufferMappingAccessBit::InvalidateBuffer;
|
||||
|
||||
void* result = bufferObject->AcquireMemory(true, readable, writable);
|
||||
if (!result) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::OutOfMemory,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBuffer_State",
|
||||
"Failed to map buffer due to insufficient memory."));
|
||||
return nullptr;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CopyBufferSubData_State(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) {
|
||||
if (size < 0 || readOffset < 0 || writeOffset < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"Offset and size must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
BufferTarget readBufferTarget = MG_Util::ConvertGLEnumToBufferTarget(readTarget);
|
||||
BufferTarget writeBufferTarget = MG_Util::ConvertGLEnumToBufferTarget(writeTarget);
|
||||
if (!BufferImpl::ValidateBufferTarget(readBufferTarget) || !BufferImpl::ValidateBufferTarget(writeBufferTarget)) return;
|
||||
|
||||
auto& readBindingSlot = MG_State::pGLContext->GetBufferBindingSlot(readBufferTarget);
|
||||
auto& writeBindingSlot = MG_State::pGLContext->GetBufferBindingSlot(writeBufferTarget);
|
||||
auto readBufferObject = readBindingSlot.GetBoundObject();
|
||||
auto writeBufferObject = writeBindingSlot.GetBoundObject();
|
||||
if (!(accessBits & invalidateFlags)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Cannot map a buffer object that is already mapped."));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (!readBufferObject || !writeBufferObject) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"One of the buffer targets is bound to no buffer object."));
|
||||
return;
|
||||
}
|
||||
void* result = bufferObject->AcquireMemoryRange(
|
||||
{static_cast<SizeT>(offset), static_cast<SizeT>(offset + length)}, accessBits);
|
||||
if (!result) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::OutOfMemory,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Failed to map buffer due to insufficient memory."));
|
||||
return nullptr;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
if (readOffset + size > readBufferObject->GetSize() || writeOffset + size > writeBufferObject->GetSize()) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"Offset and size must be within the bounds of the buffer objects."));
|
||||
return;
|
||||
}
|
||||
void* MapBuffer_State(GLenum target, GLenum access) {
|
||||
bool readable = access == GL_READ_ONLY || access == GL_READ_WRITE;
|
||||
bool writable = access == GL_WRITE_ONLY || access == GL_READ_WRITE;
|
||||
if (access != GL_READ_ONLY && access != GL_WRITE_ONLY && access != GL_READ_WRITE) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "MapBuffer_State",
|
||||
"Access must be one of GL_READ_ONLY, GL_WRITE_ONLY, or GL_READ_WRITE."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (readBufferObject == writeBufferObject) {
|
||||
if ((readOffset <= writeOffset && readOffset + size > writeOffset) ||
|
||||
(writeOffset <= readOffset && writeOffset + size > readOffset)) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"Source and destination buffers overlap in the specified ranges."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return nullptr;
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
|
||||
auto isIllegallyMapped = [](const SharedPtr<MG_State::GLState::BufferObject>& buffer) {
|
||||
return buffer->IsMapped() && !(buffer->GetMappingAccess() & BufferMappingAccessBit::Persistent);
|
||||
};
|
||||
if (isIllegallyMapped(readBufferObject) || isIllegallyMapped(writeBufferObject)) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"Cannot copy data from/to a mapped buffer object unless it was mapped with GL_MAP_PERSISTENT_BIT."));
|
||||
return;
|
||||
}
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBuffer_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
writeBufferObject->CopyDataFrom(readBufferObject, readOffset, writeOffset, size);
|
||||
}
|
||||
|
||||
void BufferSubData_State(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) {
|
||||
if (!data) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::NoError, // somehow OpenGL does not generate an error for this
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Data pointer cannot be null."));
|
||||
return;
|
||||
}
|
||||
if (bufferObject->IsMapped()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBuffer_State",
|
||||
"Cannot map a buffer object that is already mapped."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (size < 0 || offset < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Offset and size must be non-negative."));
|
||||
return;
|
||||
}
|
||||
void* result = bufferObject->AcquireMemory(true, readable, writable);
|
||||
if (!result) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::OutOfMemory,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBuffer_State",
|
||||
"Failed to map buffer due to insufficient memory."));
|
||||
return nullptr;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return;
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
void CopyBufferSubData_State(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset,
|
||||
GLsizeiptr size) {
|
||||
if (size < 0 || readOffset < 0 || writeOffset < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"Offset and size must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return;
|
||||
}
|
||||
BufferTarget readBufferTarget = MG_Util::ConvertGLEnumToBufferTarget(readTarget);
|
||||
BufferTarget writeBufferTarget = MG_Util::ConvertGLEnumToBufferTarget(writeTarget);
|
||||
if (!BufferImpl::ValidateBufferTarget(readBufferTarget) ||
|
||||
!BufferImpl::ValidateBufferTarget(writeBufferTarget))
|
||||
return;
|
||||
|
||||
SizeT bufferSize = bufferObject->GetSize();
|
||||
Range1D mappedRange = bufferObject->GetMappedRange();
|
||||
if ((offset < mappedRange.end) && (offset + size > mappedRange.start)) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Offset and size must not overlap with the mapped range of the buffer object."));
|
||||
return;
|
||||
}
|
||||
auto& readBindingSlot = MG_State::pGLContext->GetBufferBindingSlot(readBufferTarget);
|
||||
auto& writeBindingSlot = MG_State::pGLContext->GetBufferBindingSlot(writeBufferTarget);
|
||||
auto readBufferObject = readBindingSlot.GetBoundObject();
|
||||
auto writeBufferObject = writeBindingSlot.GetBoundObject();
|
||||
|
||||
auto mappingAccess = bufferObject->GetMappingAccess();
|
||||
if (bufferObject->IsMapped() && !(mappingAccess & BufferMappingAccessBit::Persistent)) {
|
||||
Range1D mappedRange = bufferObject->GetMappedRange();
|
||||
if (offset + size >= mappedRange.start) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Cannot modify a mapped buffer object unless it was mapped with GL_MAP_PERSISTENT_BIT."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!readBufferObject || !writeBufferObject) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"One of the buffer targets is bound to no buffer object."));
|
||||
return;
|
||||
}
|
||||
|
||||
bufferObject->UploadSubData({ (void*)data, (SizeT)size }, offset);
|
||||
}
|
||||
|
||||
void BufferData_State(GLenum target, GLsizeiptr size, const void* data, GLenum usage) {
|
||||
if (size < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferData_State",
|
||||
"Size must be non-negative."));
|
||||
return;
|
||||
}
|
||||
if (readOffset + size > readBufferObject->GetSize() || writeOffset + size > writeBufferObject->GetSize()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"Offset and size must be within the bounds of the buffer objects."));
|
||||
return;
|
||||
}
|
||||
|
||||
BufferUsage bufferUsage = MG_Util::ConvertGLEnumToBufferUsage(usage);
|
||||
if (!BufferImpl::ValidateBufferUsage(bufferUsage)) return;
|
||||
if (readBufferObject == writeBufferObject) {
|
||||
if ((readOffset <= writeOffset && readOffset + size > writeOffset) ||
|
||||
(writeOffset <= readOffset && writeOffset + size > readOffset)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"Source and destination buffers overlap in the specified ranges."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return;
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
auto isIllegallyMapped = [](const SharedPtr<MG_State::GLState::BufferObject>& buffer) {
|
||||
return buffer->IsMapped() && !(buffer->GetMappingAccess() & BufferMappingAccessBit::Persistent);
|
||||
};
|
||||
if (isIllegallyMapped(readBufferObject) || isIllegallyMapped(writeBufferObject)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"Cannot copy data from/to a mapped buffer object unless it was mapped "
|
||||
"with GL_MAP_PERSISTENT_BIT."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferData_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return;
|
||||
}
|
||||
writeBufferObject->CopyDataFrom(readBufferObject, readOffset, writeOffset, size);
|
||||
}
|
||||
|
||||
bufferObject->SetUsage(bufferUsage);
|
||||
bufferObject->Resize(size);
|
||||
if (data) {
|
||||
bufferObject->UploadData({ (void*)data, (SizeT)size }, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void BindBuffer_State(GLenum target, GLuint buffer) {
|
||||
if (buffer != 0 && !BufferImpl::ValidateBufferName(buffer)) return;
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return;
|
||||
void BufferSubData_State(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) {
|
||||
if (!data) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::NoError, // somehow OpenGL does not generate an error for this
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Data pointer cannot be null."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto bufferObject = MG_State::pGLContext->GetBufferObject(buffer);
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->CreateBufferObject(buffer);
|
||||
bufferObject = MG_State::pGLContext->GetBufferObject(buffer);
|
||||
}
|
||||
if (size < 0 || offset < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Offset and size must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
bindingSlot.Bind(bufferObject);
|
||||
}
|
||||
|
||||
void GenBuffers_State(GLsizei n, GLuint* buffers) {
|
||||
if (n < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GenBuffers_State", "n must be non-negative"));
|
||||
return;
|
||||
}
|
||||
auto bufferNames = MG_State::pGLContext->GenBufferNames(n);
|
||||
Copy(bufferNames.data(), buffers, bufferNames.size());
|
||||
}
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return;
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
|
||||
GLboolean IsBuffer_State(GLuint buffer) {
|
||||
if (buffer == 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "IsBuffer_State",
|
||||
"Buffer name 0 is not a valid buffer object."));
|
||||
return GL_FALSE;
|
||||
}
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!BufferImpl::ValidateBufferName(buffer)) return GL_FALSE;
|
||||
return MG_State::pGLContext->ValidateBufferObject(buffer) ? GL_TRUE : GL_FALSE;
|
||||
}
|
||||
SizeT bufferSize = bufferObject->GetSize();
|
||||
Range1D mappedRange = bufferObject->GetMappedRange();
|
||||
if ((offset < mappedRange.end) && (offset + size > mappedRange.start)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Offset and size must not overlap with the mapped range of the buffer object."));
|
||||
return;
|
||||
}
|
||||
|
||||
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
|
||||
GLboolean IsBuffer(GLuint buffer) {
|
||||
return IsBuffer_State(buffer);
|
||||
}
|
||||
|
||||
void DeleteBuffers(GLsizei n, const GLuint* buffers) {
|
||||
DeleteBuffers_State(n, buffers);
|
||||
}
|
||||
|
||||
void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) {
|
||||
FlushMappedBufferRange_State(target, offset, length);
|
||||
}
|
||||
|
||||
GLboolean UnmapBuffer(GLenum target) {
|
||||
return UnmapBuffer_State(target);
|
||||
}
|
||||
|
||||
void* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) {
|
||||
return MapBufferRange_State(target, offset, length, access);
|
||||
}
|
||||
|
||||
void* MapBuffer(GLenum target, GLenum access) {
|
||||
return MapBuffer_State(target, access);
|
||||
}
|
||||
|
||||
void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) {
|
||||
CopyBufferSubData_State(readTarget, writeTarget, readOffset, writeOffset, size);
|
||||
}
|
||||
|
||||
void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) {
|
||||
BufferSubData_State(target, offset, size, data);
|
||||
}
|
||||
|
||||
void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage) {
|
||||
BufferData_State(target, size, data, usage);
|
||||
}
|
||||
|
||||
void BindBuffer(GLenum target, GLuint buffer) {
|
||||
BindBuffer_State(target, buffer);
|
||||
}
|
||||
|
||||
void GenBuffers(GLsizei n, GLuint* buffers) {
|
||||
GenBuffers_State(n, buffers);
|
||||
}
|
||||
}
|
||||
}
|
||||
auto mappingAccess = bufferObject->GetMappingAccess();
|
||||
if (bufferObject->IsMapped() && !(mappingAccess & BufferMappingAccessBit::Persistent)) {
|
||||
Range1D mappedRange = bufferObject->GetMappedRange();
|
||||
if (offset + size >= mappedRange.start) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Cannot modify a mapped buffer object unless it was mapped with GL_MAP_PERSISTENT_BIT."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bufferObject->UploadSubData({(void*)data, (SizeT)size}, offset);
|
||||
}
|
||||
|
||||
void BufferData_State(GLenum target, GLsizeiptr size, const void* data, GLenum usage) {
|
||||
if (size < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferData_State", "Size must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
BufferUsage bufferUsage = MG_Util::ConvertGLEnumToBufferUsage(usage);
|
||||
if (!BufferImpl::ValidateBufferUsage(bufferUsage)) return;
|
||||
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return;
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferData_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return;
|
||||
}
|
||||
|
||||
bufferObject->SetUsage(bufferUsage);
|
||||
bufferObject->Resize(size);
|
||||
if (data) {
|
||||
bufferObject->UploadData({(void*)data, (SizeT)size}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void BindBuffer_State(GLenum target, GLuint buffer) {
|
||||
if (buffer != 0 && !BufferImpl::ValidateBufferName(buffer)) return;
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return;
|
||||
|
||||
auto bufferObject = MG_State::pGLContext->GetBufferObject(buffer);
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->CreateBufferObject(buffer);
|
||||
bufferObject = MG_State::pGLContext->GetBufferObject(buffer);
|
||||
}
|
||||
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
bindingSlot.Bind(bufferObject);
|
||||
}
|
||||
|
||||
void GenBuffers_State(GLsizei n, GLuint* buffers) {
|
||||
if (n < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GenBuffers_State", "n must be non-negative"));
|
||||
return;
|
||||
}
|
||||
auto bufferNames = MG_State::pGLContext->GenBufferNames(n);
|
||||
Copy(bufferNames.data(), buffers, bufferNames.size());
|
||||
}
|
||||
|
||||
GLboolean IsBuffer_State(GLuint buffer) {
|
||||
if (buffer == 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "IsBuffer_State",
|
||||
"Buffer name 0 is not a valid buffer object."));
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (!BufferImpl::ValidateBufferName(buffer)) return GL_FALSE;
|
||||
return MG_State::pGLContext->ValidateBufferObject(buffer) ? GL_TRUE : GL_FALSE;
|
||||
}
|
||||
|
||||
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
|
||||
GLboolean IsBuffer(GLuint buffer) {
|
||||
return IsBuffer_State(buffer);
|
||||
}
|
||||
|
||||
void DeleteBuffers(GLsizei n, const GLuint* buffers) {
|
||||
DeleteBuffers_State(n, buffers);
|
||||
}
|
||||
|
||||
void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) {
|
||||
FlushMappedBufferRange_State(target, offset, length);
|
||||
}
|
||||
|
||||
GLboolean UnmapBuffer(GLenum target) {
|
||||
return UnmapBuffer_State(target);
|
||||
}
|
||||
|
||||
void* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) {
|
||||
return MapBufferRange_State(target, offset, length, access);
|
||||
}
|
||||
|
||||
void* MapBuffer(GLenum target, GLenum access) {
|
||||
return MapBuffer_State(target, access);
|
||||
}
|
||||
|
||||
void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset,
|
||||
GLsizeiptr size) {
|
||||
CopyBufferSubData_State(readTarget, writeTarget, readOffset, writeOffset, size);
|
||||
}
|
||||
|
||||
void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) {
|
||||
BufferSubData_State(target, offset, size, data);
|
||||
}
|
||||
|
||||
void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage) {
|
||||
BufferData_State(target, size, data, usage);
|
||||
}
|
||||
|
||||
void BindBuffer(GLenum target, GLuint buffer) {
|
||||
BindBuffer_State(target, buffer);
|
||||
}
|
||||
|
||||
void GenBuffers(GLsizei n, GLuint* buffers) {
|
||||
GenBuffers_State(n, buffers);
|
||||
}
|
||||
} // namespace MG_Impl::GLImpl
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
/* @INSERTION_POINT:FUNCTION_DECLARATION@ */
|
||||
GLboolean IsBuffer(GLuint buffer);
|
||||
void DeleteBuffers(GLsizei n, const GLuint* buffers);
|
||||
void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length);
|
||||
GLboolean UnmapBuffer(GLenum target);
|
||||
void* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
|
||||
void* MapBuffer(GLenum target, GLenum access);
|
||||
void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
|
||||
void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data);
|
||||
void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage);
|
||||
void BindBuffer(GLenum target, GLuint buffer);
|
||||
void GenBuffers(GLsizei n, GLuint* buffers);
|
||||
}
|
||||
}
|
||||
namespace MG_Impl::GLImpl {
|
||||
/* @INSERTION_POINT:FUNCTION_DECLARATION@ */
|
||||
GLboolean IsBuffer(GLuint buffer);
|
||||
void DeleteBuffers(GLsizei n, const GLuint* buffers);
|
||||
void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length);
|
||||
GLboolean UnmapBuffer(GLenum target);
|
||||
void* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
|
||||
void* MapBuffer(GLenum target, GLenum access);
|
||||
void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset,
|
||||
GLsizeiptr size);
|
||||
void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data);
|
||||
void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage);
|
||||
void BindBuffer(GLenum target, GLuint buffer);
|
||||
void GenBuffers(GLsizei n, GLuint* buffers);
|
||||
} // namespace MG_Impl::GLImpl
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,79 +1,84 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "Validators.h"
|
||||
#include <MG_State/GLState/Core.h>
|
||||
#include <MG_State/GLState/ErrorState/Error.h>
|
||||
#include <MG_Util/Converters/GLToStr/GLEnumConverter.h>
|
||||
#include <MG_Util/Converters/MGToGL/BufferEnumConverter.h>
|
||||
#include <MG_Util/Converters/MGToStr/BufferEnumConverter.h>
|
||||
|
||||
namespace MobileGL::MG_Impl::GLImpl {
|
||||
namespace BufferImpl {
|
||||
bool ValidateBufferTarget(BufferTarget target) {
|
||||
if (target == BufferTarget::Unknown) {
|
||||
using namespace MG_Util;
|
||||
String bufferTargetStr = ConvertBufferTargetToString(target);
|
||||
String glTargetStr = ConvertGLEnumToString(ConvertBufferTargetToGLEnum(target));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferTarget",
|
||||
std::format("Target {} ({}) is not valid.",
|
||||
bufferTargetStr, glTargetStr)));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (target == BufferTarget::Index && MG_State::pGLContext->GetBoundVertexArray() == nullptr) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferTarget",
|
||||
"No vertex array object is bound."));
|
||||
return false;
|
||||
}
|
||||
namespace BufferImpl {
|
||||
bool ValidateBufferTarget(BufferTarget target) {
|
||||
if (target == BufferTarget::Unknown) {
|
||||
using namespace MG_Util;
|
||||
String bufferTargetStr = ConvertBufferTargetToString(target);
|
||||
String glTargetStr = ConvertGLEnumToString(ConvertBufferTargetToGLEnum(target));
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl/BufferImpl", "ValidateBufferTarget",
|
||||
std::format("Target {} ({}) is not valid.", bufferTargetStr, glTargetStr)));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
if (target == BufferTarget::Index && MG_State::pGLContext->GetBoundVertexArray() == nullptr) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl",
|
||||
"ValidateBufferTarget",
|
||||
"No vertex array object is bound."));
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ValidateBufferName(Uint index) {
|
||||
bool isValid = MG_State::pGLContext->ValidateBufferName(index);
|
||||
if (isValid)
|
||||
return true;
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferName",
|
||||
std::format("Buffer name {} is not valid.", index)));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ValidateBufferUsage(BufferUsage usage) {
|
||||
if (usage != BufferUsage::Unknown) {
|
||||
return true;
|
||||
}
|
||||
using namespace MG_Util;
|
||||
String bufferUsageStr = ConvertBufferUsageToString(usage);
|
||||
String glUsageStr = ConvertGLEnumToString(ConvertBufferUsageToGLEnum(usage));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferUsage",
|
||||
std::format("Usage {} ({}) is not one of the allowable values.",
|
||||
bufferUsageStr, glUsageStr)));
|
||||
return false;
|
||||
}
|
||||
bool ValidateBufferName(Uint index) {
|
||||
bool isValid = MG_State::pGLContext->ValidateBufferName(index);
|
||||
if (isValid) return true;
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferName",
|
||||
std::format("Buffer name {} is not valid.", index)));
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ValidateBufferMappingAccess(Flags<BufferMappingAccessBit> accessBits) {
|
||||
if (accessBits == BufferMappingAccessBit::Null) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferMappingAccess",
|
||||
"Access bits cannot be null."));
|
||||
return false;
|
||||
}
|
||||
bool ValidateBufferUsage(BufferUsage usage) {
|
||||
if (usage != BufferUsage::Unknown) {
|
||||
return true;
|
||||
}
|
||||
using namespace MG_Util;
|
||||
String bufferUsageStr = ConvertBufferUsageToString(usage);
|
||||
String glUsageStr = ConvertGLEnumToString(ConvertBufferUsageToGLEnum(usage));
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl/BufferImpl", "ValidateBufferUsage",
|
||||
std::format("Usage {} ({}) is not one of the allowable values.", bufferUsageStr, glUsageStr)));
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto validBits =
|
||||
BufferMappingAccessBit::Read |
|
||||
BufferMappingAccessBit::Write |
|
||||
BufferMappingAccessBit::InvalidateRange |
|
||||
BufferMappingAccessBit::InvalidateBuffer |
|
||||
BufferMappingAccessBit::FlushExplicit |
|
||||
BufferMappingAccessBit::Unsynchronized |
|
||||
BufferMappingAccessBit::Persistent |
|
||||
BufferMappingAccessBit::Coherent;
|
||||
bool ValidateBufferMappingAccess(Flags<BufferMappingAccessBit> accessBits) {
|
||||
if (accessBits == BufferMappingAccessBit::Null) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl",
|
||||
"ValidateBufferMappingAccess",
|
||||
"Access bits cannot be null."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((accessBits & validBits) != accessBits) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferMappingAccess",
|
||||
"Access bits cannot contain invalid flags."));
|
||||
return false;
|
||||
}
|
||||
const auto validBits = BufferMappingAccessBit::Read | BufferMappingAccessBit::Write |
|
||||
BufferMappingAccessBit::InvalidateRange | BufferMappingAccessBit::InvalidateBuffer |
|
||||
BufferMappingAccessBit::FlushExplicit | BufferMappingAccessBit::Unsynchronized |
|
||||
BufferMappingAccessBit::Persistent | BufferMappingAccessBit::Coherent;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((accessBits & validBits) != accessBits) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferMappingAccess",
|
||||
"Access bits cannot contain invalid flags."));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace BufferImpl
|
||||
} // namespace MobileGL::MG_Impl::GLImpl
|
||||
@@ -1,10 +1,12 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
#include <MG_State/GLState/BufferState/BufferObject.h>
|
||||
|
||||
namespace MobileGL::MG_Impl::GLImpl {
|
||||
namespace BufferImpl {
|
||||
bool ValidateBufferTarget(BufferTarget target);
|
||||
bool ValidateBufferName(Uint index);
|
||||
bool ValidateBufferUsage(BufferUsage usage);
|
||||
bool ValidateBufferMappingAccess(Flags<BufferMappingAccessBit> accessBits);
|
||||
}
|
||||
}
|
||||
namespace BufferImpl {
|
||||
bool ValidateBufferTarget(BufferTarget target);
|
||||
bool ValidateBufferName(Uint index);
|
||||
bool ValidateBufferUsage(BufferUsage usage);
|
||||
bool ValidateBufferMappingAccess(Flags<BufferMappingAccessBit> accessBits);
|
||||
} // namespace BufferImpl
|
||||
} // namespace MobileGL::MG_Impl::GLImpl
|
||||
@@ -1,4 +1,8 @@
|
||||
#include "../../../Includes.h"
|
||||
#include <Includes.h>
|
||||
#include "../Buffer/GL_Buffer.h"
|
||||
#include "../VertexArray/GL_VertexArray.h"
|
||||
#include "../Getter/GL_Getter.h"
|
||||
#include "../Program/GL_Program.h"
|
||||
|
||||
#define DECLARE_GL_FUNCTION_STUB_HEAD(type,name,...) \
|
||||
MOBILEGL_GL_API type gl##name(__VA_ARGS__) {
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "GL_Getter.h"
|
||||
#include <Config.h>
|
||||
#include <MG_State/GLState/Core.h>
|
||||
#include <MG_Util/Converters/MGToGL/ErrorCodeConverter.h>
|
||||
#include <MG_Util/Converters/GLToStr/GLEnumConverter.h>
|
||||
#include <MG_Util/Converters/MGToStr/GLExtensionConverter.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
namespace MG_Impl::GLImpl {
|
||||
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
|
||||
const GLubyte* GetString(GLenum name) {
|
||||
static String vendorString;
|
||||
@@ -14,40 +19,37 @@ namespace MobileGL {
|
||||
case GL_VENDOR:
|
||||
if (vendorString.empty()) {
|
||||
if (MG_Config::RendererInfoPtr->ExtraVendor.has_value()) {
|
||||
vendorString = std::format("{}{}",
|
||||
MG_Config::CoreVendor, MG_Config::RendererInfoPtr->ExtraVendor.value());
|
||||
vendorString =
|
||||
std::format("{}{}", MG_Config::CoreVendor, MG_Config::RendererInfoPtr->ExtraVendor.value());
|
||||
} else {
|
||||
vendorString = MG_Config::CoreVendor;
|
||||
vendorString = MG_Config::CoreVendor;
|
||||
}
|
||||
}
|
||||
return (const GLubyte*)vendorString.c_str();
|
||||
case GL_VERSION: {
|
||||
if (versionStr.empty()) {
|
||||
versionStr = std::format("{} {}, {} Backend, Version {}",
|
||||
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.toString().c_str(),
|
||||
MG_Config::ProjectName.c_str(),
|
||||
MG_Config::RendererInfoPtr->BackendName.c_str(),
|
||||
MG_Config::CoreVersion.toString().c_str());
|
||||
versionStr =
|
||||
std::format("{} {}, {} Backend, Version {}",
|
||||
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.toString().c_str(),
|
||||
MG_Config::ProjectName.c_str(), MG_Config::RendererInfoPtr->BackendName.c_str(),
|
||||
MG_Config::CoreVersion.toString().c_str());
|
||||
}
|
||||
return (const GLubyte*)versionStr.c_str();
|
||||
}
|
||||
|
||||
case GL_RENDERER:
|
||||
{
|
||||
case GL_RENDERER: {
|
||||
if (rendererString.empty()) {
|
||||
String deviceInfo;
|
||||
rendererString = std::format("{} ({}) ({})",
|
||||
MG_Config::RendererInfoPtr->RendererName.c_str(),
|
||||
MG_Config::CoreName.c_str(),
|
||||
deviceInfo);
|
||||
rendererString = std::format("{} ({}) ({})", MG_Config::RendererInfoPtr->RendererName.c_str(),
|
||||
MG_Config::CoreName.c_str(), deviceInfo);
|
||||
}
|
||||
return (const GLubyte*)rendererString.c_str();
|
||||
}
|
||||
case GL_SHADING_LANGUAGE_VERSION:
|
||||
if (shadingLanguageVersion.empty()) {
|
||||
shadingLanguageVersion = std::format("{} MobileGL",
|
||||
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLSLVersion.toString(
|
||||
{ true, false }).c_str());
|
||||
shadingLanguageVersion = std::format(
|
||||
"{} MobileGL",
|
||||
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLSLVersion.toString({true, false}).c_str());
|
||||
}
|
||||
return (const GLubyte*)shadingLanguageVersion.c_str();
|
||||
case GL_EXTENSIONS:
|
||||
@@ -55,10 +57,10 @@ namespace MobileGL {
|
||||
for (auto& ext : MG_Config::RendererInfoPtr->RendererGLInfo.Extensions) {
|
||||
extensionsString += MG_Util::ConvertetGLExtToString(ext);
|
||||
extensionsString += " ";
|
||||
}
|
||||
}
|
||||
extensionsString.pop_back();
|
||||
}
|
||||
return (const GLubyte*)extensionsString.c_str();
|
||||
return (const GLubyte*)extensionsString.c_str();
|
||||
default:
|
||||
return (const GLubyte*)"Unknown enum";
|
||||
}
|
||||
@@ -88,7 +90,6 @@ namespace MobileGL {
|
||||
return (const GLubyte*)extStrings[index].c_str();
|
||||
}
|
||||
|
||||
|
||||
void GetIntegerv(GLenum pname, GLint* params) {
|
||||
MGLOG_D("glGetIntegerv, pname: %s", MG_Util::ConvertGLEnumToString(pname).c_str());
|
||||
if (!params) {
|
||||
@@ -101,8 +102,9 @@ namespace MobileGL {
|
||||
case GL_CONTEXT_FLAGS:
|
||||
params[0] = 0;
|
||||
case GL_CONTEXT_PROFILE_MASK:
|
||||
params[0] = MG_Config::RendererInfoPtr->RendererGLInfo.IsCompatibilityProfile ?
|
||||
GL_CONTEXT_COMPATIBILITY_PROFILE_BIT : GL_CONTEXT_CORE_PROFILE_BIT;
|
||||
params[0] = MG_Config::RendererInfoPtr->RendererGLInfo.IsCompatibilityProfile
|
||||
? GL_CONTEXT_COMPATIBILITY_PROFILE_BIT
|
||||
: GL_CONTEXT_CORE_PROFILE_BIT;
|
||||
break;
|
||||
case GL_NUM_EXTENSIONS:
|
||||
params[0] = MG_Config::RendererInfoPtr->RendererGLInfo.Extensions.size();
|
||||
@@ -113,22 +115,21 @@ namespace MobileGL {
|
||||
case GL_MINOR_VERSION:
|
||||
params[0] = MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.Minor;
|
||||
break;
|
||||
|
||||
|
||||
// State
|
||||
// TODO
|
||||
|
||||
|
||||
// Others...
|
||||
default:
|
||||
MGLOG_E("glGetIntegerv: Invalid enum %s (0x%X)",
|
||||
MG_Util::ConvertGLEnumToString(pname).c_str(), pname);
|
||||
// TODO: Report GL_INVALID_ENUM.
|
||||
MGLOG_E("glGetIntegerv: Invalid enum %s (0x%X)", MG_Util::ConvertGLEnumToString(pname).c_str(), pname);
|
||||
// TODO: Report GL_INVALID_ENUM.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GLenum GetError() {
|
||||
ErrorCode errorCode = MG_State::pGLContext->PopGLError().value_or(Error{ ErrorCode::NoError, nullptr }).code;
|
||||
ErrorCode errorCode = MG_State::pGLContext->PopGLError().value_or(Error{ErrorCode::NoError, nullptr}).code;
|
||||
return MG_Util::ConvertErrorCodeToGLEnum(errorCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace MG_Impl::GLImpl
|
||||
} // namespace MobileGL
|
||||
@@ -1,11 +1,12 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
/* @INSERTION_POINT:FUNCTION_DECLARATION@ */
|
||||
const GLubyte* GetString(GLenum name);
|
||||
const GLubyte* GetStringi(GLenum name, GLuint index);
|
||||
void GetIntegerv(GLenum pname, GLint* params);
|
||||
GLenum GetError();
|
||||
}
|
||||
}
|
||||
namespace MG_Impl::GLImpl {
|
||||
/* @INSERTION_POINT:FUNCTION_DECLARATION@ */
|
||||
const GLubyte* GetString(GLenum name);
|
||||
const GLubyte* GetStringi(GLenum name, GLuint index);
|
||||
void GetIntegerv(GLenum pname, GLint* params);
|
||||
GLenum GetError();
|
||||
} // namespace MG_Impl::GLImpl
|
||||
} // namespace MobileGL
|
||||
@@ -1,260 +1,363 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "GL_Program.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
void AttachShader_State(GLuint program, GLuint shader) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void BindAttribLocation_State(GLuint program, GLuint index, const GLchar *name) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void BindAttribLocation_State(GLuint program, GLuint index, const GLchar* name) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void CompileShader_State(GLuint shader) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
GLuint CreateProgram_State(void) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
GLuint CreateShader_State(GLenum type) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void DeleteProgram_State(GLuint program) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void DeleteShader_State(GLuint shader) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void DetachShader_State(GLuint program, GLuint shader) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetActiveAttrib_State(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetActiveAttrib_State(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size,
|
||||
GLenum* type, GLchar* name) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetActiveUniform_State(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetActiveUniform_State(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size,
|
||||
GLenum* type, GLchar* name) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetAttachedShaders_State(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetAttachedShaders_State(GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
GLint GetAttribLocation_State(GLuint program, const GLchar *name) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
GLint GetAttribLocation_State(GLuint program, const GLchar* name) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetProgramiv_State(GLuint program, GLenum pname, GLint *params) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetProgramiv_State(GLuint program, GLenum pname, GLint* params) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetProgramInfoLog_State(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetProgramInfoLog_State(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetShaderiv_State(GLuint shader, GLenum pname, GLint *params) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetShaderiv_State(GLuint shader, GLenum pname, GLint* params) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetShaderInfoLog_State(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetShaderInfoLog_State(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetShaderSource_State(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetShaderSource_State(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* source) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
GLint GetUniformLocation_State(GLuint program, const GLchar *name) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
GLint GetUniformLocation_State(GLuint program, const GLchar* name) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetUniformfv_State(GLuint program, GLint location, GLfloat *params) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetUniformfv_State(GLuint program, GLint location, GLfloat* params) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetUniformiv_State(GLuint program, GLint location, GLint *params) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetUniformiv_State(GLuint program, GLint location, GLint* params) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
GLboolean IsProgram_State(GLuint program) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
GLboolean IsShader_State(GLuint shader) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void LinkProgram_State(GLuint program) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void ShaderSource_State(GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void ShaderSource_State(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void UseProgram_State(GLuint program) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform1f_State(GLint location, GLfloat v0) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform2f_State(GLint location, GLfloat v0, GLfloat v1) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform3f_State(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform4f_State(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform1i_State(GLint location, GLint v0) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform2i_State(GLint location, GLint v0, GLint v1) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform3i_State(GLint location, GLint v0, GLint v1, GLint v2) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform4i_State(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform1fv_State(GLint location, GLsizei count, const GLfloat *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void Uniform1fv_State(GLint location, GLsizei count, const GLfloat* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform2fv_State(GLint location, GLsizei count, const GLfloat *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void Uniform2fv_State(GLint location, GLsizei count, const GLfloat* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform3fv_State(GLint location, GLsizei count, const GLfloat *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void Uniform3fv_State(GLint location, GLsizei count, const GLfloat* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform4fv_State(GLint location, GLsizei count, const GLfloat *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void Uniform4fv_State(GLint location, GLsizei count, const GLfloat* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform1iv_State(GLint location, GLsizei count, const GLint *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void Uniform1iv_State(GLint location, GLsizei count, const GLint* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform2iv_State(GLint location, GLsizei count, const GLint *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void Uniform2iv_State(GLint location, GLsizei count, const GLint* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform3iv_State(GLint location, GLsizei count, const GLint *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void Uniform3iv_State(GLint location, GLsizei count, const GLint* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform4iv_State(GLint location, GLsizei count, const GLint *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void Uniform4iv_State(GLint location, GLsizei count, const GLint* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void UniformMatrix2fv_State(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void UniformMatrix2fv_State(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void UniformMatrix3fv_State(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void UniformMatrix3fv_State(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void UniformMatrix4fv_State(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void UniformMatrix4fv_State(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void ValidateProgram_State(GLuint program) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void AttachShader(GLuint program, GLuint shader) {
|
||||
AttachShader_State(program, shader);
|
||||
}
|
||||
|
||||
void AttachShader(GLuint program, GLuint shader) { AttachShader_State(program, shader); }
|
||||
void BindAttribLocation(GLuint program, GLuint index, const GLchar *name) {
|
||||
void BindAttribLocation(GLuint program, GLuint index, const GLchar* name) {
|
||||
BindAttribLocation_State(program, index, name);
|
||||
}
|
||||
void CompileShader(GLuint shader) { CompileShader_State(shader); }
|
||||
GLuint CreateProgram(void) { return CreateProgram_State(); }
|
||||
GLuint CreateShader(GLenum type) { return CreateShader_State(type); }
|
||||
void DeleteProgram(GLuint program) { DeleteProgram_State(program); }
|
||||
void DeleteShader(GLuint shader) { DeleteShader_State(shader); }
|
||||
void DetachShader(GLuint program, GLuint shader) { DetachShader_State(program, shader); }
|
||||
void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) {
|
||||
|
||||
void CompileShader(GLuint shader) {
|
||||
CompileShader_State(shader);
|
||||
}
|
||||
GLuint CreateProgram(void) {
|
||||
return CreateProgram_State();
|
||||
}
|
||||
GLuint CreateShader(GLenum type) {
|
||||
return CreateShader_State(type);
|
||||
}
|
||||
|
||||
void DeleteProgram(GLuint program) {
|
||||
DeleteProgram_State(program);
|
||||
}
|
||||
|
||||
void DeleteShader(GLuint shader) {
|
||||
DeleteShader_State(shader);
|
||||
}
|
||||
|
||||
void DetachShader(GLuint program, GLuint shader) {
|
||||
DetachShader_State(program, shader);
|
||||
}
|
||||
|
||||
void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type,
|
||||
GLchar* name) {
|
||||
GetActiveAttrib_State(program, index, bufSize, length, size, type, name);
|
||||
}
|
||||
void GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) {
|
||||
|
||||
void GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type,
|
||||
GLchar* name) {
|
||||
GetActiveUniform_State(program, index, bufSize, length, size, type, name);
|
||||
}
|
||||
void GetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders) {
|
||||
|
||||
void GetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders) {
|
||||
GetAttachedShaders_State(program, maxCount, count, shaders);
|
||||
}
|
||||
GLint GetAttribLocation(GLuint program, const GLchar *name) {
|
||||
GLint GetAttribLocation(GLuint program, const GLchar* name) {
|
||||
GetAttribLocation_State(program, name);
|
||||
}
|
||||
void GetProgramiv(GLuint program, GLenum pname, GLint *params) {
|
||||
|
||||
void GetProgramiv(GLuint program, GLenum pname, GLint* params) {
|
||||
GetProgramiv_State(program, pname, params);
|
||||
}
|
||||
void GetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog) {
|
||||
|
||||
void GetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog) {
|
||||
GetProgramInfoLog_State(program, bufSize, length, infoLog);
|
||||
}
|
||||
void GetShaderiv(GLuint shader, GLenum pname, GLint *params) {
|
||||
|
||||
void GetShaderiv(GLuint shader, GLenum pname, GLint* params) {
|
||||
GetShaderiv_State(shader, pname, params);
|
||||
}
|
||||
void GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) {
|
||||
|
||||
void GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog) {
|
||||
GetShaderInfoLog_State(shader, bufSize, length, infoLog);
|
||||
}
|
||||
void GetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source) {
|
||||
|
||||
void GetShaderSource(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* source) {
|
||||
GetShaderSource_State(shader, bufSize, length, source);
|
||||
}
|
||||
GLint GetUniformLocation(GLuint program, const GLchar *name) {
|
||||
GLint GetUniformLocation(GLuint program, const GLchar* name) {
|
||||
GetUniformLocation_State(program, name);
|
||||
}
|
||||
void GetUniformfv(GLuint program, GLint location, GLfloat *params) {
|
||||
|
||||
void GetUniformfv(GLuint program, GLint location, GLfloat* params) {
|
||||
GetUniformfv_State(program, location, params);
|
||||
}
|
||||
void GetUniformiv(GLuint program, GLint location, GLint *params) {
|
||||
|
||||
void GetUniformiv(GLuint program, GLint location, GLint* params) {
|
||||
GetUniformiv_State(program, location, params);
|
||||
}
|
||||
GLboolean IsProgram(GLuint program) { return IsProgram_State(program); }
|
||||
GLboolean IsShader(GLuint shader) { return IsShader_State(shader); }
|
||||
void LinkProgram(GLuint program) { LinkProgram_State(program); }
|
||||
void ShaderSource(GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length) {
|
||||
GLboolean IsProgram(GLuint program) {
|
||||
return IsProgram_State(program);
|
||||
}
|
||||
GLboolean IsShader(GLuint shader) {
|
||||
return IsShader_State(shader);
|
||||
}
|
||||
|
||||
void LinkProgram(GLuint program) {
|
||||
LinkProgram_State(program);
|
||||
}
|
||||
|
||||
void ShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length) {
|
||||
ShaderSource_State(shader, count, string, length);
|
||||
}
|
||||
void UseProgram(GLuint program) { UseProgram_State(program); }
|
||||
void Uniform1f(GLint location, GLfloat v0) { Uniform1f_State(location, v0); }
|
||||
void Uniform2f(GLint location, GLfloat v0, GLfloat v1) { Uniform2f_State(location, v0, v1); }
|
||||
void Uniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) { Uniform3f_State(location, v0, v1, v2); }
|
||||
void Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
|
||||
void Uniform1i(GLint location, GLint v0) { Uniform1i_State(location, v0); }
|
||||
void Uniform2i(GLint location, GLint v0, GLint v1) { Uniform2i_State(location, v0, v1); }
|
||||
void Uniform3i(GLint location, GLint v0, GLint v1, GLint v2) { Uniform3i_State(location, v0, v1, v2); }
|
||||
void Uniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) { Uniform4i_State(location, v0, v1, v2, v3); }
|
||||
void Uniform1fv(GLint location, GLsizei count, const GLfloat *value) { Uniform1fv_State(location, count, value); }
|
||||
void Uniform2fv(GLint location, GLsizei count, const GLfloat *value) { Uniform2fv_State(location, count, value); }
|
||||
void Uniform3fv(GLint location, GLsizei count, const GLfloat *value) { Uniform3fv_State(location, count, value); }
|
||||
void Uniform4fv(GLint location, GLsizei count, const GLfloat *value) { Uniform4fv_State(location, count, value); }
|
||||
void Uniform1iv(GLint location, GLsizei count, const GLint *value) { Uniform1iv_State(location, count, value); }
|
||||
void Uniform2iv(GLint location, GLsizei count, const GLint *value) { Uniform2iv_State(location, count, value); }
|
||||
void Uniform3iv(GLint location, GLsizei count, const GLint *value) { Uniform3iv_State(location, count, value); }
|
||||
void Uniform4iv(GLint location, GLsizei count, const GLint *value) { Uniform4iv_State(location, count, value); }
|
||||
void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { UniformMatrix2fv_State(location, count, transpose, value); }
|
||||
void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { UniformMatrix3fv_State(location, count, transpose, value); }
|
||||
void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { UniformMatrix4fv_State(location, count, transpose, value); }
|
||||
void ValidateProgram(GLuint program) { ValidateProgram_State(program); }
|
||||
}
|
||||
}
|
||||
|
||||
void UseProgram(GLuint program) {
|
||||
UseProgram_State(program);
|
||||
}
|
||||
|
||||
void Uniform1f(GLint location, GLfloat v0) {
|
||||
Uniform1f_State(location, v0);
|
||||
}
|
||||
|
||||
void Uniform2f(GLint location, GLfloat v0, GLfloat v1) {
|
||||
Uniform2f_State(location, v0, v1);
|
||||
}
|
||||
|
||||
void Uniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {
|
||||
Uniform3f_State(location, v0, v1, v2);
|
||||
}
|
||||
|
||||
void Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {
|
||||
Uniform4f_State(location, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
void Uniform1i(GLint location, GLint v0) {
|
||||
Uniform1i_State(location, v0);
|
||||
}
|
||||
|
||||
void Uniform2i(GLint location, GLint v0, GLint v1) {
|
||||
Uniform2i_State(location, v0, v1);
|
||||
}
|
||||
|
||||
void Uniform3i(GLint location, GLint v0, GLint v1, GLint v2) {
|
||||
Uniform3i_State(location, v0, v1, v2);
|
||||
}
|
||||
|
||||
void Uniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) {
|
||||
Uniform4i_State(location, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
void Uniform1fv(GLint location, GLsizei count, const GLfloat* value) {
|
||||
Uniform1fv_State(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform2fv(GLint location, GLsizei count, const GLfloat* value) {
|
||||
Uniform2fv_State(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform3fv(GLint location, GLsizei count, const GLfloat* value) {
|
||||
Uniform3fv_State(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform4fv(GLint location, GLsizei count, const GLfloat* value) {
|
||||
Uniform4fv_State(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform1iv(GLint location, GLsizei count, const GLint* value) {
|
||||
Uniform1iv_State(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform2iv(GLint location, GLsizei count, const GLint* value) {
|
||||
Uniform2iv_State(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform3iv(GLint location, GLsizei count, const GLint* value) {
|
||||
Uniform3iv_State(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform4iv(GLint location, GLsizei count, const GLint* value) {
|
||||
Uniform4iv_State(location, count, value);
|
||||
}
|
||||
|
||||
void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
UniformMatrix2fv_State(location, count, transpose, value);
|
||||
}
|
||||
|
||||
void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
UniformMatrix3fv_State(location, count, transpose, value);
|
||||
}
|
||||
|
||||
void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
UniformMatrix4fv_State(location, count, transpose, value);
|
||||
}
|
||||
|
||||
void ValidateProgram(GLuint program) {
|
||||
ValidateProgram_State(program);
|
||||
}
|
||||
} // namespace MG_Impl::GLImpl
|
||||
} // namespace MobileGL
|
||||
@@ -1,31 +1,34 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
void AttachShader(GLuint program, GLuint shader);
|
||||
void BindAttribLocation(GLuint program, GLuint index, const GLchar *name);
|
||||
void BindAttribLocation(GLuint program, GLuint index, const GLchar* name);
|
||||
void CompileShader(GLuint shader);
|
||||
GLuint CreateProgram(void);
|
||||
GLuint CreateShader(GLenum type);
|
||||
void DeleteProgram(GLuint program);
|
||||
void DeleteShader(GLuint shader);
|
||||
void DetachShader(GLuint program, GLuint shader);
|
||||
void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
|
||||
void GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
|
||||
void GetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders);
|
||||
GLint GetAttribLocation(GLuint program, const GLchar *name);
|
||||
void GetProgramiv(GLuint program, GLenum pname, GLint *params);
|
||||
void GetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
|
||||
void GetShaderiv(GLuint shader, GLenum pname, GLint *params);
|
||||
void GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
|
||||
void GetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
|
||||
GLint GetUniformLocation(GLuint program, const GLchar *name);
|
||||
void GetUniformfv(GLuint program, GLint location, GLfloat *params);
|
||||
void GetUniformiv(GLuint program, GLint location, GLint *params);
|
||||
void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type,
|
||||
GLchar* name);
|
||||
void GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type,
|
||||
GLchar* name);
|
||||
void GetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders);
|
||||
GLint GetAttribLocation(GLuint program, const GLchar* name);
|
||||
void GetProgramiv(GLuint program, GLenum pname, GLint* params);
|
||||
void GetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog);
|
||||
void GetShaderiv(GLuint shader, GLenum pname, GLint* params);
|
||||
void GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog);
|
||||
void GetShaderSource(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* source);
|
||||
GLint GetUniformLocation(GLuint program, const GLchar* name);
|
||||
void GetUniformfv(GLuint program, GLint location, GLfloat* params);
|
||||
void GetUniformiv(GLuint program, GLint location, GLint* params);
|
||||
GLboolean IsProgram(GLuint program);
|
||||
GLboolean IsShader(GLuint shader);
|
||||
void LinkProgram(GLuint program);
|
||||
void ShaderSource(GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
|
||||
void ShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
|
||||
void UseProgram(GLuint program);
|
||||
void Uniform1f(GLint location, GLfloat v0);
|
||||
void Uniform2f(GLint location, GLfloat v0, GLfloat v1);
|
||||
@@ -35,17 +38,17 @@ namespace MobileGL {
|
||||
void Uniform2i(GLint location, GLint v0, GLint v1);
|
||||
void Uniform3i(GLint location, GLint v0, GLint v1, GLint v2);
|
||||
void Uniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
|
||||
void Uniform1fv(GLint location, GLsizei count, const GLfloat *value);
|
||||
void Uniform2fv(GLint location, GLsizei count, const GLfloat *value);
|
||||
void Uniform3fv(GLint location, GLsizei count, const GLfloat *value);
|
||||
void Uniform4fv(GLint location, GLsizei count, const GLfloat *value);
|
||||
void Uniform1iv(GLint location, GLsizei count, const GLint *value);
|
||||
void Uniform2iv(GLint location, GLsizei count, const GLint *value);
|
||||
void Uniform3iv(GLint location, GLsizei count, const GLint *value);
|
||||
void Uniform4iv(GLint location, GLsizei count, const GLint *value);
|
||||
void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
|
||||
void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
|
||||
void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
|
||||
void Uniform1fv(GLint location, GLsizei count, const GLfloat* value);
|
||||
void Uniform2fv(GLint location, GLsizei count, const GLfloat* value);
|
||||
void Uniform3fv(GLint location, GLsizei count, const GLfloat* value);
|
||||
void Uniform4fv(GLint location, GLsizei count, const GLfloat* value);
|
||||
void Uniform1iv(GLint location, GLsizei count, const GLint* value);
|
||||
void Uniform2iv(GLint location, GLsizei count, const GLint* value);
|
||||
void Uniform3iv(GLint location, GLsizei count, const GLint* value);
|
||||
void Uniform4iv(GLint location, GLsizei count, const GLint* value);
|
||||
void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
void ValidateProgram(GLuint program);
|
||||
}
|
||||
}
|
||||
} // namespace MG_Impl::GLImpl
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "GL_VertexArray.h"
|
||||
#include "Validators.h"
|
||||
#include <MG_State/GLState/Core.h>
|
||||
#include <MG_State/GLState/ErrorState/Error.h>
|
||||
#include <MG_Util/Converters/GLToMG/DataTypeConverter.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
namespace MG_Impl::GLImpl {
|
||||
void DisableVertexAttribArray_State(GLuint index) {
|
||||
if (!VertexArrayImpl::ValidateVertexAttributeIndex(index)) return;
|
||||
|
||||
auto vao = MG_State::pGLContext->GetBoundVertexArray();
|
||||
if (!vao) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "EnableVertexAttribArray_State",
|
||||
"No vertex array object is bound."));
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl",
|
||||
"EnableVertexAttribArray_State",
|
||||
"No vertex array object is bound."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,8 +27,9 @@ namespace MobileGL {
|
||||
auto vao = MG_State::pGLContext->GetBoundVertexArray();
|
||||
if (!vao) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "EnableVertexAttribArray_State",
|
||||
"No vertex array object is bound."));
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl",
|
||||
"EnableVertexAttribArray_State",
|
||||
"No vertex array object is bound."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,17 +46,19 @@ namespace MobileGL {
|
||||
auto vao = MG_State::pGLContext->GetBoundVertexArray();
|
||||
if (!vao) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "VertexAttribPointer_State",
|
||||
"No vertex array object is bound."));
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl",
|
||||
"VertexAttribPointer_State",
|
||||
"No vertex array object is bound."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto& vboSlot = MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::Vertex);
|
||||
auto vbo = vboSlot.GetBoundObject();
|
||||
if (!vbo) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "VertexAttribPointer_State",
|
||||
"No buffer is bound to GL_ARRAY_BUFFER."));
|
||||
"No buffer is bound to GL_ARRAY_BUFFER."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -60,27 +68,30 @@ namespace MobileGL {
|
||||
vao->BindAttributeBuffer(index, vbo);
|
||||
}
|
||||
|
||||
// TODO: Implement GL_BGRA support
|
||||
void VertexAttribPointer_State(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer) {
|
||||
// TODO: Implement GL_BGRA support
|
||||
void VertexAttribPointer_State(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride,
|
||||
const void* pointer) {
|
||||
if (!VertexArrayImpl::ValidateVertexAttributeIndex(index)) return;
|
||||
|
||||
DataType dataType = MG_Util::ConvertGLEnumToDataType(type);
|
||||
DataType dataType = MG_Util::ConvertGLEnumToDataType(type);
|
||||
if (!VertexArrayImpl::ValidateVertexAttribPointerParams(index, size, dataType, stride)) return;
|
||||
|
||||
auto vao = MG_State::pGLContext->GetBoundVertexArray();
|
||||
if (!vao) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "VertexAttribPointer_State",
|
||||
"No vertex array object is bound."));
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl",
|
||||
"VertexAttribPointer_State",
|
||||
"No vertex array object is bound."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto& vboSlot = MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::Vertex);
|
||||
auto vbo = vboSlot.GetBoundObject();
|
||||
if (!vbo) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "VertexAttribPointer_State",
|
||||
"No buffer is bound to GL_ARRAY_BUFFER."));
|
||||
"No buffer is bound to GL_ARRAY_BUFFER."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -107,9 +118,9 @@ namespace MobileGL {
|
||||
|
||||
void DeleteVertexArrays_State(GLsizei n, const GLuint* arrays) {
|
||||
if (n < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteVertexArrays_State",
|
||||
"n must be non-negative."));
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteVertexArrays_State",
|
||||
"n must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -120,8 +131,7 @@ namespace MobileGL {
|
||||
if (!VertexArrayImpl::ValidateVertexArrayName(vao)) continue;
|
||||
|
||||
if (MG_State::pGLContext->GetBoundVertexArray() &&
|
||||
MG_State::pGLContext->GetBoundVertexArray() ==
|
||||
MG_State::pGLContext->GetVertexArrayObject(vao)) {
|
||||
MG_State::pGLContext->GetBoundVertexArray() == MG_State::pGLContext->GetVertexArrayObject(vao)) {
|
||||
MG_State::pGLContext->BindVertexArray(0);
|
||||
}
|
||||
|
||||
@@ -131,64 +141,66 @@ namespace MobileGL {
|
||||
|
||||
void GenVertexArrays_State(GLsizei n, GLuint* arrays) {
|
||||
if (n < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GenVertexArrays_State",
|
||||
"n must be non-negative."));
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GenVertexArrays_State", "n must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto vaoNames = MG_State::pGLContext->GenVertexArrayNames(n);
|
||||
Copy(vaoNames.data(), arrays, vaoNames.size());
|
||||
}
|
||||
|
||||
|
||||
GLboolean IsVertexArray_State(GLuint array) {
|
||||
if (array == 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "IsVertexArray_State",
|
||||
"Vertex array name 0 is not supported."));
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "IsVertexArray_State",
|
||||
"Vertex array name 0 is not supported."));
|
||||
return GL_FALSE;
|
||||
}
|
||||
if (!VertexArrayImpl::ValidateVertexArrayName(array)) return GL_FALSE;
|
||||
if (!MG_State::pGLContext->ValidateVertexArrayObject(array)) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "IsVertexArray_State",
|
||||
std::format("Vertex array object {} does not exist.", array)));
|
||||
std::format("Vertex array object {} does not exist.", array)));
|
||||
return GL_FALSE;
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
|
||||
GLboolean IsVertexArray(GLuint array) {
|
||||
return IsVertexArray_State(array);
|
||||
}
|
||||
|
||||
|
||||
void DisableVertexAttribArray(GLuint index) {
|
||||
DisableVertexAttribArray_State(index);
|
||||
DisableVertexAttribArray_State(index);
|
||||
}
|
||||
|
||||
|
||||
void EnableVertexAttribArray(GLuint index) {
|
||||
EnableVertexAttribArray_State(index);
|
||||
EnableVertexAttribArray_State(index);
|
||||
}
|
||||
|
||||
|
||||
void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer) {
|
||||
VertexAttribIPointer_State(index, size, type, stride, pointer);
|
||||
VertexAttribIPointer_State(index, size, type, stride, pointer);
|
||||
}
|
||||
|
||||
void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer) {
|
||||
VertexAttribPointer_State(index, size, type, normalized, stride, pointer);
|
||||
|
||||
void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride,
|
||||
const void* pointer) {
|
||||
VertexAttribPointer_State(index, size, type, normalized, stride, pointer);
|
||||
}
|
||||
|
||||
|
||||
void BindVertexArray(GLuint array) {
|
||||
BindVertexArray_State(array);
|
||||
BindVertexArray_State(array);
|
||||
}
|
||||
|
||||
|
||||
void DeleteVertexArrays(GLsizei n, const GLuint* arrays) {
|
||||
DeleteVertexArrays_State(n, arrays);
|
||||
DeleteVertexArrays_State(n, arrays);
|
||||
}
|
||||
|
||||
|
||||
void GenVertexArrays(GLsizei n, GLuint* arrays) {
|
||||
GenVertexArrays_State(n, arrays);
|
||||
GenVertexArrays_State(n, arrays);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace MG_Impl::GLImpl
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
namespace MG_Impl::GLImpl {
|
||||
/* @INSERTION_POINT:FUNCTION_DECLARATION@ */
|
||||
GLboolean IsVertexArray(GLuint array);
|
||||
void DisableVertexAttribArray(GLuint index);
|
||||
void EnableVertexAttribArray(GLuint index);
|
||||
void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer);
|
||||
void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer);
|
||||
void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride,
|
||||
const void* pointer);
|
||||
void BindVertexArray(GLuint array);
|
||||
void DeleteVertexArrays(GLsizei n, const GLuint* arrays);
|
||||
void GenVertexArrays(GLsizei n, GLuint* arrays);
|
||||
}
|
||||
}
|
||||
} // namespace MG_Impl::GLImpl
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,31 +1,37 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "Validators.h"
|
||||
#include <MG_State/GLState/Core.h>
|
||||
#include <MG_State/GLState/ErrorState/Error.h>
|
||||
#include <MG_Util/Converters/MGToGL/DataTypeConverter.h>
|
||||
#include <MG_Util/Converters/MGToStr/DataTypeConverter.h>
|
||||
|
||||
namespace MobileGL::MG_Impl::GLImpl {
|
||||
namespace VertexArrayImpl {
|
||||
namespace VertexArrayImpl {
|
||||
|
||||
bool ValidateVertexArrayName(Uint index) {
|
||||
if (index == 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexArrayName",
|
||||
"Vertex array name 0 is not supported."));
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexArrayName",
|
||||
"Vertex array name 0 is not supported."));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool isValid = MG_State::pGLContext->ValidateVertexArrayName(index);
|
||||
if (!isValid) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
if (!isValid) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexArrayName",
|
||||
std::format("Vertex array name {} is not valid.", index)));
|
||||
std::format("Vertex array name {} is not valid.", index)));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ValidateVertexArrayObject(Uint index) {
|
||||
if (!MG_State::pGLContext->ValidateVertexArrayObject(index)) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexArrayObject",
|
||||
std::format("Vertex array object {} does not exist.", index)));
|
||||
std::format("Vertex array object {} does not exist.", index)));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -33,10 +39,12 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
bool ValidateVertexAttributeIndex(Uint index) {
|
||||
if (index >= MG_State::GLState::VertexArrayObject::MAX_VERTEX_ATTRIBS) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexAttributeIndex",
|
||||
std::format("Attribute index {} exceeds maximum of {}.",
|
||||
index, MG_State::GLState::VertexArrayObject::MAX_VERTEX_ATTRIBS - 1)));
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "ValidateVertexAttributeIndex",
|
||||
std::format("Attribute index {} exceeds maximum of {}.", index,
|
||||
MG_State::GLState::VertexArrayObject::MAX_VERTEX_ATTRIBS - 1)));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -44,27 +52,33 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
bool ValidateVertexAttribPointerParams(Uint index, SizeT size, DataType type, Int stride) {
|
||||
if (size < 1 || size > 4) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexAttribPointerParams",
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "ValidateVertexAttribPointerParams",
|
||||
std::format("Invalid size {} for attribute {}. Must be 1-4.", size, index)));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (type == DataType::Unknown) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexAttribPointerParams",
|
||||
std::format("Invalid type {} for attribute {}.", MG_Util::ConvertDataTypeToString(type).c_str(), index)));
|
||||
std::format("Invalid type {} for attribute {}.",
|
||||
MG_Util::ConvertDataTypeToString(type).c_str(), index)));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (stride < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexAttribPointerParams",
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "ValidateVertexAttribPointerParams",
|
||||
std::format("Negative stride {} is not allowed for attribute {}.", stride, index)));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace VertexArrayImpl
|
||||
} // namespace MobileGL::MG_Impl::GLImpl
|
||||
@@ -1,10 +1,12 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
#include <MG_State/GLState/VertexArrayState/VertexArrayObject.h>
|
||||
|
||||
namespace MobileGL::MG_Impl::GLImpl {
|
||||
namespace VertexArrayImpl {
|
||||
namespace VertexArrayImpl {
|
||||
bool ValidateVertexArrayName(Uint index);
|
||||
bool ValidateVertexArrayObject(Uint index);
|
||||
bool ValidateVertexAttributeIndex(Uint index);
|
||||
bool ValidateVertexAttribPointerParams(Uint index, SizeT size, DataType type, Int stride);
|
||||
}
|
||||
}
|
||||
} // namespace VertexArrayImpl
|
||||
} // namespace MobileGL::MG_Impl::GLImpl
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "../../../Includes.h"
|
||||
#include <Includes.h>
|
||||
#include "../LookUp/LookUp.h"
|
||||
|
||||
MOBILEGL_GLX_API void* glXGetProcAddress(const char* name) {
|
||||
return MG_Impl::GLXImpl::GetProcAddress(name);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "LookUp.h"
|
||||
|
||||
namespace MG_Impl::GLXImpl {
|
||||
// TODO: Implement complete glx functionality
|
||||
// TODO: Implement complete GLX functionality
|
||||
|
||||
void* GetProcAddress(const char* name) {
|
||||
MGLOG_D("glXGetProcAddress(\"%s\")", name);
|
||||
@@ -18,4 +18,4 @@ namespace MG_Impl::GLXImpl {
|
||||
void* GetProcAddressARB(const char* name) {
|
||||
return GetProcAddress(name);
|
||||
}
|
||||
}
|
||||
} // namespace MG_Impl::GLXImpl
|
||||
@@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MG_Impl {
|
||||
namespace GLXImpl {
|
||||
void* GetProcAddress(const char* name);
|
||||
void* GetProcAddressARB(const char* name);
|
||||
}
|
||||
}
|
||||
} // namespace GLXImpl
|
||||
} // namespace MG_Impl
|
||||
Reference in New Issue
Block a user