mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-05 10:33:37 +00:00
Rewrite config load for MupenPlus. Store parameters in main config file.
Add new video config parameters: fullscreen, verticalSync, multisampling.
This commit is contained in:
parent
6bf0302f19
commit
79bf9d9910
2
Config.h
2
Config.h
|
@ -9,8 +9,10 @@ struct Config
|
|||
|
||||
struct
|
||||
{
|
||||
u32 fullscreen;
|
||||
u32 fullscreenWidth, fullscreenHeight, windowedWidth, windowedHeight;
|
||||
u32 fullscreenBits, fullscreenRefresh;
|
||||
u32 multisampling, verticalSync;
|
||||
} video;
|
||||
|
||||
struct
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "GLideN64_MupenPlus.h"
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -13,6 +14,97 @@ Config config;
|
|||
|
||||
const u32 uMegabyte = 1024U*1024U;
|
||||
|
||||
static m64p_handle g_configVideoGeneral = NULL;
|
||||
static m64p_handle g_configVideoGliden64 = NULL;
|
||||
|
||||
static
|
||||
bool Config_SetDefault()
|
||||
{
|
||||
if (ConfigOpenSection("Video-General", &g_configVideoGeneral) != M64ERR_SUCCESS) {
|
||||
LOG(LOG_ERROR, "Unable to open Video-General configuration section");
|
||||
return false;
|
||||
}
|
||||
if (ConfigOpenSection("Video-GLideN64", &g_configVideoGliden64) != M64ERR_SUCCESS) {
|
||||
LOG(LOG_ERROR, "Unable to open GLideN64 configuration section");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set default values for "Video-General" section, if they are not set yet. Taken from RiceVideo
|
||||
m64p_error res = ConfigSetDefaultBool(g_configVideoGeneral, "Fullscreen", 0, "Use fullscreen mode if True, or windowed mode if False ");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultInt(g_configVideoGeneral, "ScreenWidth", 640, "Width of output window or fullscreen width");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultInt(g_configVideoGeneral, "ScreenHeight", 480, "Height of output window or fullscreen height");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultBool(g_configVideoGeneral, "VerticalSync", 0, "If true, activate the SDL_GL_SWAP_CONTROL attribute");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
|
||||
res = ConfigSetDefaultInt(g_configVideoGliden64, "MultiSampling", 0, "Enable/Disable MultiSampling (0=off, 2,4,8,16=quality)");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
|
||||
//#Texture Settings
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "ForceBilinear", 0, "Force bilinear texture filter");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultInt(g_configVideoGliden64, "CacheSize", 192, "Size of texture cache in megabytes. Good value is VRAM*3/4");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultInt(g_configVideoGliden64, "TextureBitDepth", 1, "Texture bit depth (0=16bit only, 1=16 and 32 bit, 2=32bit only)");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
//#Emulation Settings
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableFog", 1, "Enable fog emulation.");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableNoise", 1, "Enable color noise emulation.");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableLOD", 1, "Enable LOD emulation.");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableHWLighting", 1, "Enable hardware per-pixel lighting.");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
//#Frame Buffer Settings:"
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableFBEmulation", 1, "Enable frame and|or depth buffer emulation.");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableCopyColorToRDRAM", 0, "Enable color buffer copy to RDRAM.");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableCopyDepthToRDRAM", 0, "Enable depth buffer copy to RDRAM.");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableCopyColorFromRDRAM", 0, "Enable color buffer copy from RDRAM.");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableIgnoreCFB", 1, "Ignore CPU writes to frame buffer.");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableN64DepthCompare", 0, "Enable N64 depth compare instead of OpenGL standard one. Experimental.");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
|
||||
return res == M64ERR_SUCCESS;
|
||||
}
|
||||
|
||||
void Config_LoadConfig()
|
||||
{
|
||||
Config_SetDefault();
|
||||
|
||||
config.video.fullscreen = ConfigGetParamBool(g_configVideoGeneral, "Fullscreen");
|
||||
config.video.windowedWidth = ConfigGetParamInt(g_configVideoGeneral, "ScreenWidth");
|
||||
config.video.windowedHeight = ConfigGetParamInt(g_configVideoGeneral, "ScreenHeight");
|
||||
config.video.verticalSync = ConfigGetParamBool(g_configVideoGeneral, "VerticalSync");
|
||||
|
||||
config.video.multisampling = ConfigGetParamInt(g_configVideoGliden64, "MultiSampling");
|
||||
|
||||
//#Texture Settings
|
||||
config.texture.forceBilinear = ConfigGetParamBool(g_configVideoGliden64, "ForceBilinear");
|
||||
config.texture.maxBytes = ConfigGetParamInt(g_configVideoGliden64, "CacheSize") * uMegabyte;
|
||||
config.texture.textureBitDepth = ConfigGetParamInt(g_configVideoGliden64, "TextureBitDepth");
|
||||
//#Emulation Settings
|
||||
config.enableFog = ConfigGetParamBool(g_configVideoGliden64, "EnableFog");
|
||||
config.enableNoise = ConfigGetParamBool(g_configVideoGliden64, "EnableNoise");
|
||||
config.enableLOD = ConfigGetParamBool(g_configVideoGliden64, "EnableLOD");
|
||||
config.enableHWLighting = ConfigGetParamBool(g_configVideoGliden64, "EnableHWLighting");
|
||||
//#Frame Buffer Settings:"
|
||||
config.frameBufferEmulation.enable = ConfigGetParamBool(g_configVideoGliden64, "EnableFBEmulation");
|
||||
config.frameBufferEmulation.copyToRDRAM = ConfigGetParamBool(g_configVideoGliden64, "EnableCopyColorToRDRAM");
|
||||
config.frameBufferEmulation.copyDepthToRDRAM = ConfigGetParamBool(g_configVideoGliden64, "EnableCopyDepthToRDRAM");
|
||||
config.frameBufferEmulation.copyFromRDRAM = ConfigGetParamBool(g_configVideoGliden64, "EnableCopyColorFromRDRAM");
|
||||
config.frameBufferEmulation.ignoreCFB = ConfigGetParamBool(g_configVideoGliden64, "EnableIgnoreCFB");
|
||||
config.frameBufferEmulation.N64DepthCompare = ConfigGetParamBool(g_configVideoGliden64, "EnableN64DepthCompare");
|
||||
}
|
||||
|
||||
#if 0
|
||||
struct Option
|
||||
{
|
||||
const char* name;
|
||||
|
@ -26,12 +118,9 @@ Option configOptions[] =
|
|||
{"config version", &config.version, 0},
|
||||
{"", NULL, 0},
|
||||
|
||||
{"#Window Settings:", NULL, 0},
|
||||
{"window width", &config.video.windowedWidth, 640},
|
||||
{"window height", &config.video.windowedHeight, 480},
|
||||
{"#Texture Settings:", NULL, 0},
|
||||
{"force bilinear", &config.texture.forceBilinear, 0},
|
||||
{"cache size", &config.texture.maxBytes, 64*uMegabyte},
|
||||
{"cache size", &config.texture.maxBytes, 64 * uMegabyte},
|
||||
{"texture bit depth", &config.texture.textureBitDepth, 1},
|
||||
{"#Emulation Settings:", NULL, 0},
|
||||
{"enable fog", &config.enableFog, 1},
|
||||
|
@ -54,15 +143,15 @@ void Config_WriteConfig(const char *filename)
|
|||
//config.version = CONFIG_VERSION;
|
||||
FILE* f = fopen(filename, "w");
|
||||
if (!f) {
|
||||
fprintf( stderr, "[GLideN64]: Could Not Open %s for writing\n", filename);
|
||||
fprintf(stderr, "[GLideN64]: Could Not Open %s for writing\n", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i=0; i<configOptionsSize; i++) {
|
||||
for (int i = 0; i<configOptionsSize; i++) {
|
||||
Option *o = &configOptions[i];
|
||||
fprintf(f, "%s", o->name);
|
||||
if (o->data)
|
||||
fprintf(f,"=%i", *(o->data));
|
||||
fprintf(f, "=%i", *(o->data));
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
|
||||
|
@ -71,7 +160,7 @@ void Config_WriteConfig(const char *filename)
|
|||
|
||||
void Config_SetDefault()
|
||||
{
|
||||
for(int i=0; i < configOptionsSize; i++) {
|
||||
for (int i = 0; i < configOptionsSize; i++) {
|
||||
Option *o = &configOptions[i];
|
||||
if (o->data) *(o->data) = o->initial;
|
||||
}
|
||||
|
@ -81,12 +170,12 @@ void Config_SetDefault()
|
|||
|
||||
void Config_SetOption(char* line, char* val)
|
||||
{
|
||||
for(int i=0; i< configOptionsSize; i++) {
|
||||
for (int i = 0; i< configOptionsSize; i++) {
|
||||
Option *o = &configOptions[i];
|
||||
#ifndef _WINDOWS
|
||||
if (strcasecmp(line, o->name) == 0) {
|
||||
if (strcasecmp(line, o->name) == 0) {
|
||||
#else
|
||||
if (_stricmp(line, o->name) == 0) {
|
||||
if (_stricmp(line, o->name) == 0) {
|
||||
#endif
|
||||
if (o->data) {
|
||||
int v = atoi(val);
|
||||
|
@ -112,20 +201,19 @@ void Config_LoadConfig()
|
|||
|
||||
// read configuration
|
||||
#ifndef GLES2
|
||||
const char *filename = ConfigGetSharedDataFilepath("GLideN64.cfg");
|
||||
const char * pConfigName = "GLideN64.cfg";
|
||||
const char * pConfigPath = ConfigGetUserConfigPath();
|
||||
const size_t nPathLen = strlen(pConfigPath);
|
||||
const size_t configNameLen = nPathLen + strlen(pConfigName) + 2;
|
||||
char * pConfigFullName = new char[configNameLen];
|
||||
strcpy(pConfigFullName, pConfigPath);
|
||||
if (pConfigPath[nPathLen-1] != '/')
|
||||
if (pConfigPath[nPathLen - 1] != '/')
|
||||
strcat(pConfigFullName, "/");
|
||||
strcat(pConfigFullName, pConfigName);
|
||||
f = fopen(pConfigFullName, "r");
|
||||
if (!f) {
|
||||
fprintf( stderr, "[GLideN64]: (WW) Couldn't open config file '%s' for reading: %s\n", pConfigFullName, strerror( errno ) );
|
||||
fprintf( stderr, "[GLideN64]: Attempting to write new Config \n");
|
||||
fprintf(stderr, "[GLideN64]: (WW) Couldn't open config file '%s' for reading: %s\n", pConfigFullName, strerror(errno));
|
||||
fprintf(stderr, "[GLideN64]: Attempting to write new Config \n");
|
||||
Config_WriteConfig(pConfigFullName);
|
||||
delete[] pConfigFullName;
|
||||
return;
|
||||
|
@ -135,34 +223,37 @@ void Config_LoadConfig()
|
|||
const char *filename = ConfigGetSharedDataFilepath("gles2gliden64.conf");
|
||||
f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
LOG(LOG_MINIMAL, "[gles2GlideN64]: Couldn't open config file '%s' for reading: %s\n", filename, strerror( errno ) );
|
||||
LOG(LOG_MINIMAL, "[gles2GlideN64]: Couldn't open config file '%s' for reading: %s\n", filename, strerror(errno));
|
||||
LOG(LOG_MINIMAL, "[gles2GlideN64]: Attempting to write new Config \n");
|
||||
Config_WriteConfig(filename);
|
||||
return;
|
||||
}
|
||||
LOG(LOG_MINIMAL, "[gles2GlideN64]: Loading Config from %s \n", filename);
|
||||
#endif
|
||||
while (!feof( f )) {
|
||||
while (!feof(f)) {
|
||||
char *val;
|
||||
fgets( line, 4096, f );
|
||||
fgets(line, 4096, f);
|
||||
|
||||
if (line[0] == '#' || line[0] == '\n')
|
||||
continue;
|
||||
|
||||
val = strchr( line, '=' );
|
||||
val = strchr(line, '=');
|
||||
if (!val) continue;
|
||||
|
||||
*val++ = '\0';
|
||||
|
||||
Config_SetOption(line,val);
|
||||
Config_SetOption(line, val);
|
||||
}
|
||||
/*
|
||||
/*
|
||||
if (config.version < CONFIG_VERSION)
|
||||
{
|
||||
LOG(LOG_WARNING, "[gles2N64]: Wrong config version, rewriting config with defaults\n");
|
||||
Config_SetDefault();
|
||||
Config_WriteConfig(filename);
|
||||
LOG(LOG_WARNING, "[gles2N64]: Wrong config version, rewriting config with defaults\n");
|
||||
Config_SetDefault();
|
||||
Config_WriteConfig(filename);
|
||||
}
|
||||
*/
|
||||
*/
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -11,6 +11,11 @@
|
|||
|
||||
ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath = NULL;
|
||||
ptr_ConfigGetUserConfigPath ConfigGetUserConfigPath = NULL;
|
||||
ptr_ConfigOpenSection ConfigOpenSection = NULL;
|
||||
ptr_ConfigSetDefaultInt ConfigSetDefaultInt = NULL;
|
||||
ptr_ConfigSetDefaultBool ConfigSetDefaultBool = NULL;
|
||||
ptr_ConfigGetParamInt ConfigGetParamInt = NULL;
|
||||
ptr_ConfigGetParamBool ConfigGetParamBool = NULL;
|
||||
|
||||
/* definitions of pointers to Core video extension functions */
|
||||
ptr_VidExt_Init CoreVideo_Init = NULL;
|
||||
|
@ -31,6 +36,11 @@ m64p_error PluginAPI::PluginStartup(m64p_dynlib_handle _CoreLibHandle)
|
|||
{
|
||||
ConfigGetSharedDataFilepath = (ptr_ConfigGetSharedDataFilepath) DLSYM(_CoreLibHandle, "ConfigGetSharedDataFilepath");
|
||||
ConfigGetUserConfigPath = (ptr_ConfigGetUserConfigPath) DLSYM(_CoreLibHandle, "ConfigGetUserConfigPath");
|
||||
ConfigOpenSection = (ptr_ConfigOpenSection)DLSYM(_CoreLibHandle, "ConfigOpenSection");
|
||||
ConfigSetDefaultInt = (ptr_ConfigSetDefaultInt)DLSYM(_CoreLibHandle, "ConfigSetDefaultInt");
|
||||
ConfigSetDefaultBool = (ptr_ConfigSetDefaultBool)DLSYM(_CoreLibHandle, "ConfigSetDefaultBool");
|
||||
ConfigGetParamInt = (ptr_ConfigGetParamInt)DLSYM(_CoreLibHandle, "ConfigGetParamInt");
|
||||
ConfigGetParamBool = (ptr_ConfigGetParamBool)DLSYM(_CoreLibHandle, "ConfigGetParamBool");
|
||||
|
||||
/* Get the core Video Extension function pointers from the library handle */
|
||||
CoreVideo_Init = (ptr_VidExt_Init) DLSYM(_CoreLibHandle, "VidExt_Init");
|
||||
|
|
|
@ -33,20 +33,28 @@ OGLVideo & OGLVideo::get()
|
|||
|
||||
bool OGLVideoMupenPlus::_start()
|
||||
{
|
||||
if (m_bFullscreen){
|
||||
m_width = config.video.fullscreenWidth;
|
||||
m_height = config.video.fullscreenHeight;
|
||||
} else {
|
||||
m_width = config.video.windowedWidth;
|
||||
m_height = config.video.windowedHeight;
|
||||
}
|
||||
m_bFullscreen = config.video.fullscreen > 0;
|
||||
m_width = config.video.windowedWidth;
|
||||
m_height = config.video.windowedHeight;
|
||||
|
||||
CoreVideo_Init();
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_DOUBLEBUFFER, 1);
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_SWAP_CONTROL, 1);
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_BUFFER_SIZE, 16);
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_SWAP_CONTROL, config.video.verticalSync);
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_BUFFER_SIZE, 32);
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_DEPTH_SIZE, 16);
|
||||
|
||||
if (config.video.multisampling > 0) {
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLEBUFFERS, 1);
|
||||
if (config.video.multisampling <= 2)
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 2);
|
||||
else if (config.video.multisampling <= 4)
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 4);
|
||||
else if (config.video.multisampling <= 8)
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 8);
|
||||
else
|
||||
CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 16);
|
||||
}
|
||||
|
||||
printf("(II) Setting video mode %dx%d...\n", m_width, m_height);
|
||||
if (CoreVideo_SetVideoMode(m_width, m_height, 0, m_bFullscreen ? M64VIDEO_FULLSCREEN : M64VIDEO_WINDOWED, (m64p_video_flags)0) != M64ERR_SUCCESS) {
|
||||
printf("(EE) Error setting videomode %dx%d\n", m_width, m_height);
|
||||
|
@ -82,13 +90,8 @@ void OGLVideoMupenPlus::_saveScreenshot()
|
|||
void OGLVideoMupenPlus::_resizeWindow()
|
||||
{
|
||||
u32 newWidth, newHeight;
|
||||
if (m_bFullscreen) {
|
||||
newWidth = config.video.fullscreenWidth;
|
||||
newHeight = config.video.fullscreenHeight;
|
||||
} else {
|
||||
newWidth = config.video.windowedWidth;
|
||||
newHeight = config.video.windowedHeight;
|
||||
}
|
||||
newWidth = config.video.windowedWidth;
|
||||
newHeight = config.video.windowedHeight;
|
||||
if (m_width != newWidth || m_height != newHeight) {
|
||||
m_width = newWidth;
|
||||
m_height = newHeight;
|
||||
|
|
Loading…
Reference in New Issue
Block a user