mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 06:08:30 +09:00
[Misc] (MG_Impl/Getter): GL_MAX_COLOR_ATTACHMENTS in GetIntegerv.
This commit is contained in:
@@ -136,12 +136,13 @@ namespace MobileGL {
|
|||||||
void DrawBuffers_State(GLsizei n, const GLenum* bufs) {
|
void DrawBuffers_State(GLsizei n, const GLenum* bufs) {
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
ErrorCode::InvalidValue,
|
||||||
"`n` is less than 0."));
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__, "`n` is less than 0."));
|
||||||
return;
|
return;
|
||||||
} else if (n > MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS) {
|
} else if (n > MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
ErrorCode::InvalidValue,
|
||||||
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||||
"`n` is greater than `GL_MAX_DRAW_BUFFERS`."));
|
"`n` is greater than `GL_MAX_DRAW_BUFFERS`."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -151,10 +152,9 @@ namespace MobileGL {
|
|||||||
auto fbo = bindingSlot.GetBoundObject();
|
auto fbo = bindingSlot.GetBoundObject();
|
||||||
bool isDefaultFBO = (fbo == FramebufferImpl::pDefaultFramebufferInfo->defaultFBO);
|
bool isDefaultFBO = (fbo == FramebufferImpl::pDefaultFramebufferInfo->defaultFBO);
|
||||||
|
|
||||||
static int existenceMap[(SizeT)FramebufferAttachmentType::FramebufferAttachmentTypeCount] = {
|
static int existenceMap[(SizeT)FramebufferAttachmentType::FramebufferAttachmentTypeCount] = {-1};
|
||||||
-1
|
std::fill(existenceMap, existenceMap + (SizeT)FramebufferAttachmentType::FramebufferAttachmentTypeCount,
|
||||||
};
|
-1);
|
||||||
std::fill(existenceMap, existenceMap + (SizeT)FramebufferAttachmentType::FramebufferAttachmentTypeCount, -1);
|
|
||||||
|
|
||||||
for (GLsizei i = 0; i < n; ++i) {
|
for (GLsizei i = 0; i < n; ++i) {
|
||||||
auto attType = MG_Util::ConvertGLEnumToFramebufferAttachmentType(bufs[i]);
|
auto attType = MG_Util::ConvertGLEnumToFramebufferAttachmentType(bufs[i]);
|
||||||
@@ -162,40 +162,58 @@ namespace MobileGL {
|
|||||||
// ------------------- Check validity begin ------------------------
|
// ------------------- Check validity begin ------------------------
|
||||||
if (attType == FramebufferAttachmentType::Unknown) {
|
if (attType == FramebufferAttachmentType::Unknown) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidEnum, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
ErrorCode::InvalidEnum,
|
||||||
std::format("bufs[{}] = %s is not an accepted value.", i, MG_Util::ConvertGLEnumToString(bufs[i]))));
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||||
|
std::format("bufs[{}] = %s is not an accepted value.", i,
|
||||||
|
MG_Util::ConvertGLEnumToString(bufs[i]))));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDefaultFBO &&
|
if (isDefaultFBO && attType >= FramebufferAttachmentType::Color0 &&
|
||||||
attType >= FramebufferAttachmentType::Color0 && attType <= FramebufferAttachmentType::Color31) {
|
attType <= FramebufferAttachmentType::Color31) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidEnum, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
ErrorCode::InvalidEnum,
|
||||||
std::format("FBO is default FBO, but bufs[{}] = {} is one of the `GL_COLOR_ATTACHMENTn` tokens.", i, MG_Util::ConvertGLEnumToString(bufs[i]))));
|
MakeShared<GenericErrorInfo>(
|
||||||
|
"MG_Impl/GLImpl", __func__,
|
||||||
|
std::format(
|
||||||
|
"FBO is default FBO, but bufs[{}] = {} is one of the `GL_COLOR_ATTACHMENTn` tokens.", i,
|
||||||
|
MG_Util::ConvertGLEnumToString(bufs[i]))));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isDefaultFBO &&
|
if (!isDefaultFBO && attType >= FramebufferAttachmentType::FrontLeft &&
|
||||||
attType >= FramebufferAttachmentType::FrontLeft && attType <= FramebufferAttachmentType::BackRight) {
|
attType <= FramebufferAttachmentType::BackRight) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidEnum, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
ErrorCode::InvalidEnum,
|
||||||
std::format("FBO is not default FBO, but bufs[{}] = {} is anything other than `GL_NONE` or one of the `GL_COLOR_ATTACHMENTn` tokens.", i, MG_Util::ConvertGLEnumToString(bufs[i]))));
|
MakeShared<GenericErrorInfo>(
|
||||||
|
"MG_Impl/GLImpl", __func__,
|
||||||
|
std::format("FBO is not default FBO, but bufs[{}] = {} is anything other than `GL_NONE` or "
|
||||||
|
"one of the `GL_COLOR_ATTACHMENTn` tokens.",
|
||||||
|
i, MG_Util::ConvertGLEnumToString(bufs[i]))));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attType != FramebufferAttachmentType::None && existenceMap[(SizeT)attType] >= 0) {
|
if (attType != FramebufferAttachmentType::None && existenceMap[(SizeT)attType] >= 0) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidOperation, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
ErrorCode::InvalidOperation,
|
||||||
std::format("a symbolic constant other than `GL_NONE` appears more than once in bufs. bufs[{}] == bufs[{}] == {}.", i, existenceMap[(SizeT)attType], MG_Util::ConvertGLEnumToString(bufs[i]))));
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||||
|
std::format("a symbolic constant other than `GL_NONE` appears "
|
||||||
|
"more than once in bufs. bufs[{}] == bufs[{}] == {}.",
|
||||||
|
i, existenceMap[(SizeT)attType],
|
||||||
|
MG_Util::ConvertGLEnumToString(bufs[i]))));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
existenceMap[(SizeT)attType] = i;
|
existenceMap[(SizeT)attType] = i;
|
||||||
|
|
||||||
if ((SizeT)attType > (SizeT)FramebufferAttachmentType::Color0 + MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS) {
|
if ((SizeT)attType >
|
||||||
|
(SizeT)FramebufferAttachmentType::Color0 + MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidOperation, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
ErrorCode::InvalidOperation,
|
||||||
std::format("bufs[{}] == {} indicates a color buffer that does not exist in the current GL context.", i, MG_Util::ConvertGLEnumToString(bufs[i]))));
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||||
|
std::format("bufs[{}] == {} indicates a color buffer that does "
|
||||||
|
"not exist in the current GL context.",
|
||||||
|
i, MG_Util::ConvertGLEnumToString(bufs[i]))));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// ------------------------- Check validity end ----------------------------------
|
// ------------------------- Check validity end ----------------------------------
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#include "GL_Getter.h"
|
#include "GL_Getter.h"
|
||||||
#include "GL/gl.h"
|
#include "GL/gl.h"
|
||||||
|
#include "GL/glext.h"
|
||||||
#include "MG_State/GLState/ErrorState/ErrorInfo.h"
|
#include "MG_State/GLState/ErrorState/ErrorInfo.h"
|
||||||
|
#include "MG_State/GLState/FramebufferState/FramebufferObject.h"
|
||||||
#include <Config.h>
|
#include <Config.h>
|
||||||
#include <MG_State/GLState/Core.h>
|
#include <MG_State/GLState/Core.h>
|
||||||
#include <MG_Util/Converters/GLToStr/GLEnumConverter.h>
|
#include <MG_Util/Converters/GLToStr/GLEnumConverter.h>
|
||||||
@@ -341,9 +343,6 @@ namespace MobileGL {
|
|||||||
case GL_MAX_DEPTH_TEXTURE_SAMPLES:
|
case GL_MAX_DEPTH_TEXTURE_SAMPLES:
|
||||||
*params = 16; // TODO
|
*params = 16; // TODO
|
||||||
break;
|
break;
|
||||||
case GL_MAX_DRAW_BUFFERS:
|
|
||||||
*params = 8; // TODO
|
|
||||||
break;
|
|
||||||
case GL_MAX_DUAL_SOURCE_DRAW_BUFFERS:
|
case GL_MAX_DUAL_SOURCE_DRAW_BUFFERS:
|
||||||
*params = 1; // TODO
|
*params = 1; // TODO
|
||||||
break;
|
break;
|
||||||
@@ -854,6 +853,9 @@ namespace MobileGL {
|
|||||||
case GL_CONTEXT_PROFILE_MASK:
|
case GL_CONTEXT_PROFILE_MASK:
|
||||||
*params = GL_CONTEXT_CORE_PROFILE_BIT;
|
*params = GL_CONTEXT_CORE_PROFILE_BIT;
|
||||||
break;
|
break;
|
||||||
|
case GL_MAX_COLOR_ATTACHMENTS:
|
||||||
|
case GL_MAX_DRAW_BUFFERS:
|
||||||
|
*params = MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS; // TODO: use backend value
|
||||||
default:
|
default:
|
||||||
MGLOG_E("glGetIntegerv: Invalid enum %s (0x%X)", MG_Util::ConvertGLEnumToString(pname).c_str(), pname);
|
MGLOG_E("glGetIntegerv: Invalid enum %s (0x%X)", MG_Util::ConvertGLEnumToString(pname).c_str(), pname);
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
|
|||||||
Reference in New Issue
Block a user