mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-07 03:13:49 +00:00
Don't use macro to determine if GL_NUM_EXTENSIONS exists
This commit is contained in:
parent
3d95dbdb03
commit
874b410ee1
|
@ -404,7 +404,8 @@ struct FramebufferTextureFormatsGLES2 : public graphics::FramebufferTextureForma
|
||||||
return _glinfo.isGLES2;
|
return _glinfo.isGLES2;
|
||||||
}
|
}
|
||||||
|
|
||||||
FramebufferTextureFormatsGLES2()
|
FramebufferTextureFormatsGLES2(const GLInfo & _glinfo):
|
||||||
|
m_glinfo(_glinfo)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
@ -417,7 +418,7 @@ protected:
|
||||||
monochromeType = GL_UNSIGNED_SHORT_5_6_5;
|
monochromeType = GL_UNSIGNED_SHORT_5_6_5;
|
||||||
monochromeFormatBytes = 2;
|
monochromeFormatBytes = 2;
|
||||||
|
|
||||||
if (Utils::isExtensionSupported("GL_OES_depth_texture")) {
|
if (Utils::isExtensionSupported(m_glinfo, "GL_OES_depth_texture")) {
|
||||||
depthInternalFormat = GL_DEPTH_COMPONENT;
|
depthInternalFormat = GL_DEPTH_COMPONENT;
|
||||||
depthFormatBytes = 4;
|
depthFormatBytes = 4;
|
||||||
} else {
|
} else {
|
||||||
|
@ -428,7 +429,7 @@ protected:
|
||||||
depthFormat = GL_DEPTH_COMPONENT;
|
depthFormat = GL_DEPTH_COMPONENT;
|
||||||
depthType = GL_UNSIGNED_INT;
|
depthType = GL_UNSIGNED_INT;
|
||||||
|
|
||||||
if (Utils::isExtensionSupported("GL_OES_rgb8_rgba8")) {
|
if (Utils::isExtensionSupported(m_glinfo, "GL_OES_rgb8_rgba8")) {
|
||||||
colorInternalFormat = GL_RGBA;
|
colorInternalFormat = GL_RGBA;
|
||||||
colorFormat = GL_RGBA;
|
colorFormat = GL_RGBA;
|
||||||
colorType = GL_UNSIGNED_BYTE;
|
colorType = GL_UNSIGNED_BYTE;
|
||||||
|
@ -441,6 +442,9 @@ protected:
|
||||||
colorFormatBytes = 2;
|
colorFormatBytes = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const GLInfo & m_glinfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FramebufferTextureFormatsGLES3 : public graphics::FramebufferTextureFormats
|
struct FramebufferTextureFormatsGLES3 : public graphics::FramebufferTextureFormats
|
||||||
|
@ -602,7 +606,7 @@ graphics::FramebufferTextureFormats * BufferManipulationObjectFactory::getFrameb
|
||||||
return new FramebufferTextureFormatsGLES3;
|
return new FramebufferTextureFormatsGLES3;
|
||||||
|
|
||||||
if (FramebufferTextureFormatsGLES2::Check(m_glInfo))
|
if (FramebufferTextureFormatsGLES2::Check(m_glInfo))
|
||||||
return new FramebufferTextureFormatsGLES2;
|
return new FramebufferTextureFormatsGLES2(m_glInfo);
|
||||||
|
|
||||||
assert(false);
|
assert(false);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -406,12 +406,12 @@ bool ContextImpl::isSupported(graphics::SpecialFeatures _feature) const
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_glInfo.isGLESX)
|
if (m_glInfo.isGLESX)
|
||||||
return numBinaryFormats != 0 && Utils::isExtensionSupported("GL_OES_get_program_binary");
|
return numBinaryFormats != 0 && Utils::isExtensionSupported(m_glInfo, "GL_OES_get_program_binary");
|
||||||
|
|
||||||
return numBinaryFormats != 0 && Utils::isExtensionSupported("GL_ARB_get_program_binary");
|
return numBinaryFormats != 0 && Utils::isExtensionSupported(m_glInfo, "GL_ARB_get_program_binary");
|
||||||
}
|
}
|
||||||
case graphics::SpecialFeatures::DepthFramebufferTextures:
|
case graphics::SpecialFeatures::DepthFramebufferTextures:
|
||||||
if (!m_glInfo.isGLES2 || Utils::isExtensionSupported("GL_OES_depth_texture"))
|
if (!m_glInfo.isGLES2 || Utils::isExtensionSupported(m_glInfo, "GL_OES_depth_texture"))
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -12,8 +12,7 @@ void GLInfo::init() {
|
||||||
if (isGLES2) {
|
if (isGLES2) {
|
||||||
majorVersion = 2;
|
majorVersion = 2;
|
||||||
minorVersion = 0;
|
minorVersion = 0;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
glGetIntegerv(GL_MAJOR_VERSION, &majorVersion);
|
glGetIntegerv(GL_MAJOR_VERSION, &majorVersion);
|
||||||
glGetIntegerv(GL_MINOR_VERSION, &minorVersion);
|
glGetIntegerv(GL_MINOR_VERSION, &minorVersion);
|
||||||
}
|
}
|
||||||
|
@ -35,18 +34,22 @@ void GLInfo::init() {
|
||||||
imageTextures = (numericVersion >= 31) && (glBindImageTexture != nullptr);
|
imageTextures = (numericVersion >= 31) && (glBindImageTexture != nullptr);
|
||||||
msaa = numericVersion >= 31;
|
msaa = numericVersion >= 31;
|
||||||
} else {
|
} else {
|
||||||
imageTextures = ((numericVersion >= 43) || (Utils::isExtensionSupported("GL_ARB_shader_image_load_store") && Utils::isExtensionSupported("GL_ARB_compute_shader"))) && (glBindImageTexture != nullptr);
|
imageTextures = ((numericVersion >= 43) || (Utils::isExtensionSupported(*this, "GL_ARB_shader_image_load_store") &&
|
||||||
|
Utils::isExtensionSupported(*this, "GL_ARB_compute_shader"))) && (glBindImageTexture != nullptr);
|
||||||
msaa = true;
|
msaa = true;
|
||||||
}
|
}
|
||||||
bufferStorage = (!isGLESX && (numericVersion >= 44)) || Utils::isExtensionSupported("GL_ARB_buffer_storage") || Utils::isExtensionSupported("GL_EXT_buffer_storage");
|
bufferStorage = (!isGLESX && (numericVersion >= 44)) || Utils::isExtensionSupported(*this, "GL_ARB_buffer_storage") ||
|
||||||
texStorage = (isGLESX && (numericVersion >= 30)) || (!isGLESX && numericVersion >= 42) || Utils::isExtensionSupported("GL_ARB_texture_storage") || Utils::isExtensionSupported("GL_EXT_texture_storage");
|
Utils::isExtensionSupported(*this, "GL_EXT_buffer_storage");
|
||||||
|
texStorage = (isGLESX && (numericVersion >= 30)) || (!isGLESX && numericVersion >= 42) ||
|
||||||
|
Utils::isExtensionSupported(*this, "GL_ARB_texture_storage") ||
|
||||||
|
Utils::isExtensionSupported(*this, "GL_EXT_texture_storage");
|
||||||
|
|
||||||
shaderStorage = false;
|
shaderStorage = false;
|
||||||
if (config.generalEmulation.enableShadersStorage != 0) {
|
if (config.generalEmulation.enableShadersStorage != 0) {
|
||||||
const char * strGetProgramBinary = isGLESX
|
const char * strGetProgramBinary = isGLESX
|
||||||
? "GL_OES_get_program_binary"
|
? "GL_OES_get_program_binary"
|
||||||
: "GL_ARB_get_program_binary";
|
: "GL_ARB_get_program_binary";
|
||||||
if (Utils::isExtensionSupported(strGetProgramBinary)) {
|
if (Utils::isExtensionSupported(*this, strGetProgramBinary)) {
|
||||||
GLint numBinaryFormats = 0;
|
GLint numBinaryFormats = 0;
|
||||||
glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &numBinaryFormats);
|
glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &numBinaryFormats);
|
||||||
shaderStorage = numBinaryFormats > 0;
|
shaderStorage = numBinaryFormats > 0;
|
||||||
|
|
|
@ -7,21 +7,21 @@
|
||||||
|
|
||||||
using namespace opengl;
|
using namespace opengl;
|
||||||
|
|
||||||
bool Utils::isExtensionSupported(const char *extension)
|
bool Utils::isExtensionSupported(const opengl::GLInfo & _glinfo, const char *extension) {
|
||||||
{
|
if (!_glinfo.isGLES2 && !_glinfo.majorVersion >= 3) {
|
||||||
#ifdef GL_NUM_EXTENSIONS
|
GLint count = 0;
|
||||||
GLint count = 0;
|
glGetIntegerv(GL_NUM_EXTENSIONS, &count);
|
||||||
glGetIntegerv(GL_NUM_EXTENSIONS, &count);
|
assert(count >= 0);
|
||||||
assert(count >= 0);
|
for (GLuint i = 0; i < (GLuint)count; ++i) {
|
||||||
for (GLuint i = 0; i < (GLuint)count; ++i) {
|
const char* name = (const char*)glGetStringi(GL_EXTENSIONS, i);
|
||||||
const char* name = (const char*)glGetStringi(GL_EXTENSIONS, i);
|
if (name == nullptr)
|
||||||
if (name == nullptr)
|
continue;
|
||||||
continue;
|
if (strcmp(extension, name) == 0)
|
||||||
if (strcmp(extension, name) == 0)
|
return true;
|
||||||
return true;
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
GLubyte *where = (GLubyte *)strchr(extension, ' ');
|
GLubyte *where = (GLubyte *)strchr(extension, ' ');
|
||||||
if (where || *extension == '\0')
|
if (where || *extension == '\0')
|
||||||
return false;
|
return false;
|
||||||
|
@ -35,15 +35,13 @@ bool Utils::isExtensionSupported(const char *extension)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
GLubyte *terminator = where + strlen(extension);
|
GLubyte *terminator = where + strlen(extension);
|
||||||
if (where == start || *(where - 1) == ' ')
|
if (where == start || *(where - 1) == ' ') if (*terminator == ' ' || *terminator == '\0')
|
||||||
if (*terminator == ' ' || *terminator == '\0')
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
start = terminator;
|
start = terminator;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
#endif // GL_NUM_EXTENSIONS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,8 +89,7 @@ bool Utils::isGLError()
|
||||||
errString = GLErrorString(errCode);
|
errString = GLErrorString(errCode);
|
||||||
if (errString != nullptr) {
|
if (errString != nullptr) {
|
||||||
LOG(LOG_ERROR, "OpenGL Error: %s (%x)", errString, errCode);
|
LOG(LOG_ERROR, "OpenGL Error: %s (%x)", errString, errCode);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
LOG(LOG_ERROR, "OpenGL Error: %x", errCode);
|
LOG(LOG_ERROR, "OpenGL Error: %x", errCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "opengl_GLInfo.h"
|
||||||
|
|
||||||
namespace opengl {
|
namespace opengl {
|
||||||
|
|
||||||
struct Utils
|
struct Utils
|
||||||
{
|
{
|
||||||
static bool isExtensionSupported(const char * extension);
|
static bool isExtensionSupported(const opengl::GLInfo & _glinfo, const char * extension);
|
||||||
static bool isGLError();
|
static bool isGLError();
|
||||||
static bool isFramebufferError();
|
static bool isFramebufferError();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user