mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Remove macros checking for GL version and use runtime checks instead.
This commit is contained in:
parent
9c16d1e75c
commit
c53dc0a6c0
|
@ -40,16 +40,14 @@ void Config::resetToDefaults()
|
|||
generalEmulation.enableNativeResTexrects = 0;
|
||||
generalEmulation.enableLegacyBlending = 0;
|
||||
generalEmulation.hacks = 0;
|
||||
#ifdef GLES2
|
||||
generalEmulation.enableFragmentDepthWrite = 0;
|
||||
#else
|
||||
generalEmulation.enableFragmentDepthWrite = 1;
|
||||
#endif
|
||||
generalEmulation.enableBlitScreenWorkaround = 0;
|
||||
#ifdef ANDROID
|
||||
generalEmulation.enableFragmentDepthWrite = 0;
|
||||
generalEmulation.enableBlitScreenWorkaround = 0;
|
||||
generalEmulation.forcePolygonOffset = 0;
|
||||
generalEmulation.polygonOffsetFactor = 0.0f;
|
||||
generalEmulation.polygonOffsetUnits = 0.0f;
|
||||
#else
|
||||
generalEmulation.enableFragmentDepthWrite = 1;
|
||||
#endif
|
||||
|
||||
frameBufferEmulation.enable = 1;
|
||||
|
|
42
src/GBI.cpp
42
src/GBI.cpp
|
@ -190,30 +190,30 @@ void GBIInfo::_makeCurrent(MicrocodeInfo * _pCurrent)
|
|||
case F3DEX2MM: F3DEX2MM_Init(); break;
|
||||
}
|
||||
|
||||
#ifndef GLESX
|
||||
if (m_pCurrent->NoN) {
|
||||
// Disable near and far plane clipping
|
||||
gfxContext.enable(graphics::enable::DEPTH_CLAMP, true);
|
||||
// Enable Far clipping plane in vertex shader
|
||||
gfxContext.enable(graphics::enable::CLIP_DISTANCE0, true);
|
||||
} else {
|
||||
gfxContext.enable(graphics::enable::DEPTH_CLAMP, false);
|
||||
gfxContext.enable(graphics::enable::CLIP_DISTANCE0, false);
|
||||
if (gfxContext.isSupported(graphics::SpecialFeatures::NearPlaneClipping)) {
|
||||
if (m_pCurrent->NoN) {
|
||||
// Disable near and far plane clipping
|
||||
gfxContext.enable(graphics::enable::DEPTH_CLAMP, true);
|
||||
// Enable Far clipping plane in vertex shader
|
||||
gfxContext.enable(graphics::enable::CLIP_DISTANCE0, true);
|
||||
} else {
|
||||
gfxContext.enable(graphics::enable::DEPTH_CLAMP, false);
|
||||
gfxContext.enable(graphics::enable::CLIP_DISTANCE0, false);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else if (m_pCurrent->NoN != _pCurrent->NoN) {
|
||||
#ifndef GLESX
|
||||
if (_pCurrent->NoN) {
|
||||
// Disable near and far plane clipping
|
||||
gfxContext.enable(graphics::enable::DEPTH_CLAMP, true);
|
||||
// Enable Far clipping plane in vertex shader
|
||||
gfxContext.enable(graphics::enable::CLIP_DISTANCE0, true);
|
||||
if (gfxContext.isSupported(graphics::SpecialFeatures::NearPlaneClipping)) {
|
||||
if (_pCurrent->NoN) {
|
||||
// Disable near and far plane clipping
|
||||
gfxContext.enable(graphics::enable::DEPTH_CLAMP, true);
|
||||
// Enable Far clipping plane in vertex shader
|
||||
gfxContext.enable(graphics::enable::CLIP_DISTANCE0, true);
|
||||
}
|
||||
else {
|
||||
gfxContext.enable(graphics::enable::DEPTH_CLAMP, false);
|
||||
gfxContext.enable(graphics::enable::CLIP_DISTANCE0, false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
gfxContext.enable(graphics::enable::DEPTH_CLAMP, false);
|
||||
gfxContext.enable(graphics::enable::CLIP_DISTANCE0, false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
m_pCurrent = _pCurrent;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ using namespace glsl;
|
|||
#define SHADER_STORAGE_FOLDER_NAME L"shaders"
|
||||
|
||||
static
|
||||
void getStorageFileName(wchar_t * _fileName)
|
||||
void getStorageFileName(const opengl::GLInfo & _glinfo, wchar_t * _fileName)
|
||||
{
|
||||
wchar_t strCacheFolderPath[PLUGIN_PATH_SIZE];
|
||||
api().GetUserCachePath(strCacheFolderPath);
|
||||
|
@ -30,15 +30,15 @@ void getStorageFileName(wchar_t * _fileName)
|
|||
pPath = strCacheFolderPath;
|
||||
}
|
||||
|
||||
#ifdef GLES3
|
||||
const wchar_t* strOpenGLType = L"GLES3";
|
||||
#elif GLES3_1
|
||||
const wchar_t* strOpenGLType = L"GLES3_1";
|
||||
#else
|
||||
const wchar_t* strOpenGLType = L"OpenGL";
|
||||
#endif
|
||||
std::wstring strOpenGLType;
|
||||
|
||||
swprintf(_fileName, PLUGIN_PATH_SIZE, L"%ls/GLideN64.%08lx.%ls.shaders", pPath, std::hash<std::string>()(RSP.romname), strOpenGLType);
|
||||
if(_glinfo.isGLESX) {
|
||||
strOpenGLType = L"GLES";
|
||||
} else {
|
||||
strOpenGLType = L"OpenGL";
|
||||
}
|
||||
|
||||
swprintf(_fileName, PLUGIN_PATH_SIZE, L"%ls/GLideN64.%08lx.%ls.shaders", pPath, std::hash<std::string>()(RSP.romname), strOpenGLType.c_str());
|
||||
}
|
||||
|
||||
static
|
||||
|
@ -67,7 +67,7 @@ static const u32 ShaderStorageFormatVersion = 0x0DU;
|
|||
bool ShaderStorage::saveShadersStorage(const graphics::Combiners & _combiners) const
|
||||
{
|
||||
wchar_t fileName[PLUGIN_PATH_SIZE];
|
||||
getStorageFileName(fileName);
|
||||
getStorageFileName(m_glinfo, fileName);
|
||||
|
||||
#if defined(OS_WINDOWS) && !defined(MINGW)
|
||||
std::ofstream fout(fileName, std::ofstream::binary | std::ofstream::trunc);
|
||||
|
@ -162,7 +162,7 @@ CombinerProgramImpl * _readCominerProgramFromStream(std::istream & _is,
|
|||
bool ShaderStorage::loadShadersStorage(graphics::Combiners & _combiners)
|
||||
{
|
||||
wchar_t fileName[PLUGIN_PATH_SIZE];
|
||||
getStorageFileName(fileName);
|
||||
getStorageFileName(m_glinfo, fileName);
|
||||
const u32 configOptionsBitSet = _getConfigOptionsBitSet();
|
||||
|
||||
#if defined(OS_WINDOWS) && !defined(MINGW)
|
||||
|
|
|
@ -44,29 +44,11 @@ DisplayWindow & DisplayWindow::get()
|
|||
|
||||
void DisplayWindowMupen64plus::_setAttributes()
|
||||
{
|
||||
|
||||
#ifdef GLES2
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 2);
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MINOR_VERSION, 0);
|
||||
LOG(LOG_VERBOSE, "[gles2GlideN64]: _setAttributes\n");
|
||||
#elif defined(GLES3)
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MINOR_VERSION, 0);
|
||||
#elif defined(GLES3_1)
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MINOR_VERSION, 1);
|
||||
#else
|
||||
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_PROFILE_MASK, M64P_GL_CONTEXT_PROFILE_CORE);
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MINOR_VERSION, 3);
|
||||
#endif
|
||||
|
||||
#ifndef GLES2
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_RED_SIZE, 8);
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_GREEN_SIZE, 8);
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_BLUE_SIZE, 8);
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_ALPHA_SIZE, 8);
|
||||
#endif
|
||||
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_DOUBLEBUFFER, 1);
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_SWAP_CONTROL, config.video.verticalSync);
|
||||
|
@ -196,7 +178,7 @@ void DisplayWindowMupen64plus::_readScreen2(void * _dest, int * _width, int * _h
|
|||
u8 *pBufferData = (u8*)malloc((*_width)*(*_height) * 4);
|
||||
u8 *pDest = (u8*)_dest;
|
||||
|
||||
#ifndef GLES2
|
||||
#ifndef ANDROID
|
||||
GLint oldMode;
|
||||
glGetIntegerv(GL_READ_BUFFER, &oldMode);
|
||||
if (_front != 0)
|
||||
|
|
|
@ -134,46 +134,11 @@ else ifeq ($(TARGET_ARCH_ABI), x86)
|
|||
MY_LOCAL_SRC_FILES += $(SRCDIR)/3DMath.cpp
|
||||
endif
|
||||
|
||||
|
||||
###########
|
||||
# gles 2.0
|
||||
# Build library
|
||||
###########
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := $(MY_LOCAL_MODULE)-gles20
|
||||
LOCAL_SHARED_LIBRARIES := $(MY_LOCAL_SHARED_LIBRARIES)
|
||||
LOCAL_STATIC_LIBRARIES := $(MY_LOCAL_STATIC_LIBRARIES)
|
||||
LOCAL_ARM_MODE := $(MY_LOCAL_ARM_MODE)
|
||||
LOCAL_C_INCLUDES := $(MY_LOCAL_C_INCLUDES) $(LOCAL_PATH)/GL/
|
||||
LOCAL_SRC_FILES := $(MY_LOCAL_SRC_FILES)
|
||||
LOCAL_CFLAGS := $(MY_LOCAL_CFLAGS) -DEGL -DGLES2 -DGLESX
|
||||
LOCAL_CPPFLAGS := $(MY_LOCAL_CPPFLAGS)
|
||||
LOCAL_LDFLAGS := $(MY_LOCAL_LDFLAGS)
|
||||
LOCAL_LDLIBS := $(MY_LOCAL_LDLIBS) -lEGL
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
###########
|
||||
# gles 3.x
|
||||
###########
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := $(MY_LOCAL_MODULE)-gles3x
|
||||
LOCAL_SHARED_LIBRARIES := $(MY_LOCAL_SHARED_LIBRARIES)
|
||||
LOCAL_STATIC_LIBRARIES := $(MY_LOCAL_STATIC_LIBRARIES)
|
||||
LOCAL_ARM_MODE := $(MY_LOCAL_ARM_MODE)
|
||||
LOCAL_C_INCLUDES := $(MY_LOCAL_C_INCLUDES) $(LOCAL_PATH)/GL/
|
||||
LOCAL_SRC_FILES := $(MY_LOCAL_SRC_FILES)
|
||||
LOCAL_CFLAGS := $(MY_LOCAL_CFLAGS) -DEGL -DGLES3_1 -DGLESX
|
||||
LOCAL_CPPFLAGS := $(MY_LOCAL_CPPFLAGS)
|
||||
LOCAL_LDFLAGS := $(MY_LOCAL_LDFLAGS)
|
||||
LOCAL_LDLIBS := $(MY_LOCAL_LDLIBS) -lEGL
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
###########
|
||||
# EGL
|
||||
###########
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := $(MY_LOCAL_MODULE)-egl
|
||||
LOCAL_MODULE := $(MY_LOCAL_MODULE)
|
||||
LOCAL_SHARED_LIBRARIES := $(MY_LOCAL_SHARED_LIBRARIES)
|
||||
LOCAL_STATIC_LIBRARIES := $(MY_LOCAL_STATIC_LIBRARIES)
|
||||
LOCAL_ARM_MODE := $(MY_LOCAL_ARM_MODE)
|
||||
|
|
|
@ -82,15 +82,11 @@ bool Config_SetDefault()
|
|||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableLegacyBlending", config.generalEmulation.enableLegacyBlending, "Do not use shaders to emulate N64 blending modes. Works faster on slow GPU. Can cause glitches.");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
#ifndef GLES2
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableFragmentDepthWrite", config.generalEmulation.enableFragmentDepthWrite, "Enable writing of fragment depth. Some mobile GPUs do not support it, thus it made optional. Leave enabled.");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
#ifdef GLESX
|
||||
#ifdef ANDROID
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableBlitScreenWorkaround", config.generalEmulation.enableBlitScreenWorkaround, "Enable to render everything upside down");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
#endif //GLESX
|
||||
#endif //GLES2
|
||||
#ifdef ANDROID
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "ForcePolygonOffset", config.generalEmulation.forcePolygonOffset, "If true, use polygon offset values specified below");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultFloat(g_configVideoGliden64, "PolygonOffsetFactor", config.generalEmulation.polygonOffsetFactor, "Specifies a scale factor that is used to create a variable depth offset for each polygon");
|
||||
|
@ -237,13 +233,9 @@ void Config_LoadConfig()
|
|||
config.generalEmulation.correctTexrectCoords = ConfigGetParamInt(g_configVideoGliden64, "CorrectTexrectCoords");
|
||||
config.generalEmulation.enableNativeResTexrects = ConfigGetParamBool(g_configVideoGliden64, "EnableNativeResTexrects");
|
||||
config.generalEmulation.enableLegacyBlending = ConfigGetParamBool(g_configVideoGliden64, "EnableLegacyBlending");
|
||||
#ifndef GLES2
|
||||
config.generalEmulation.enableFragmentDepthWrite = ConfigGetParamBool(g_configVideoGliden64, "EnableFragmentDepthWrite");
|
||||
#ifdef GLESX
|
||||
config.generalEmulation.enableBlitScreenWorkaround = ConfigGetParamBool(g_configVideoGliden64, "EnableBlitScreenWorkaround");
|
||||
#endif //GLESX
|
||||
#endif //GLES2
|
||||
#ifdef ANDROID
|
||||
config.generalEmulation.enableBlitScreenWorkaround = ConfigGetParamBool(g_configVideoGliden64, "EnableBlitScreenWorkaround");
|
||||
config.generalEmulation.forcePolygonOffset = ConfigGetParamBool(g_configVideoGliden64, "ForcePolygonOffset");
|
||||
config.generalEmulation.polygonOffsetFactor = ConfigGetParamFloat(g_configVideoGliden64, "PolygonOffsetFactor");
|
||||
config.generalEmulation.polygonOffsetUnits = ConfigGetParamFloat(g_configVideoGliden64, "PolygonOffsetUnits");
|
||||
|
|
Loading…
Reference in New Issue
Block a user