diff --git a/Config.cpp b/Config.cpp index e78225d9..29237a33 100644 --- a/Config.cpp +++ b/Config.cpp @@ -8,6 +8,7 @@ #include "OpenGL.h" #include +Config config; HWND hConfigDlg; struct @@ -62,51 +63,51 @@ void Config_LoadConfig() if (hKey) { - RegQueryValueEx( hKey, "Fullscreen Bit Depth", 0, NULL, (BYTE*)&OGL.fullscreenBits, &size ); - RegQueryValueEx( hKey, "Fullscreen Width", 0, NULL, (BYTE*)&OGL.fullscreenWidth, &size ); - RegQueryValueEx( hKey, "Fullscreen Height", 0, NULL, (BYTE*)&OGL.fullscreenHeight, &size ); - RegQueryValueEx( hKey, "Fullscreen Refresh", 0, NULL, (BYTE*)&OGL.fullscreenRefresh, &size ); - RegQueryValueEx( hKey, "Windowed Width", 0, NULL, (BYTE*)&OGL.windowedWidth, &size ); - RegQueryValueEx( hKey, "Windowed Height", 0, NULL, (BYTE*)&OGL.windowedHeight, &size ); - RegQueryValueEx( hKey, "Windowed Width", 0, NULL, (BYTE*)&OGL.windowedWidth, &size ); + RegQueryValueEx( hKey, "Fullscreen Bit Depth", 0, NULL, (BYTE*)&config.video.fullscreenBits, &size ); + RegQueryValueEx( hKey, "Fullscreen Width", 0, NULL, (BYTE*)&config.video.fullscreenWidth, &size ); + RegQueryValueEx( hKey, "Fullscreen Height", 0, NULL, (BYTE*)&config.video.fullscreenHeight, &size ); + RegQueryValueEx( hKey, "Fullscreen Refresh", 0, NULL, (BYTE*)&config.video.fullscreenRefresh, &size ); + RegQueryValueEx( hKey, "Windowed Width", 0, NULL, (BYTE*)&config.video.windowedWidth, &size ); + RegQueryValueEx( hKey, "Windowed Height", 0, NULL, (BYTE*)&config.video.windowedHeight, &size ); + RegQueryValueEx( hKey, "Windowed Width", 0, NULL, (BYTE*)&config.video.windowedWidth, &size ); RegQueryValueEx( hKey, "Force Bilinear", 0, NULL, (BYTE*)&value, &size ); - OGL.forceBilinear = value ? TRUE : FALSE; + config.texture.forceBilinear = value ? TRUE : FALSE; RegQueryValueEx( hKey, "Enable 2xSaI", 0, NULL, (BYTE*)&value, &size ); - OGL.enable2xSaI = value ? TRUE : FALSE; + config.texture.enable2xSaI = value ? TRUE : FALSE; RegQueryValueEx( hKey, "Enable Fog", 0, NULL, (BYTE*)&value, &size ); - OGL.fog = value ? TRUE : FALSE; + config.enableFog = value ? TRUE : FALSE; RegQueryValueEx( hKey, "Texture Cache Size", 0, NULL, (BYTE*)&value, &size ); cache.maxBytes = value * 1048576; RegQueryValueEx( hKey, "Hardware Frame Buffer Textures", 0, NULL, (BYTE*)&value, &size ); - OGL.frameBufferTextures = value ? TRUE : FALSE; + config.frameBufferEmulation = value ? TRUE : FALSE; RegQueryValueEx( hKey, "Hardware lighting", 0, NULL, (BYTE*)&value, &size ); - OGL.bHWLighting = value ? TRUE : FALSE; + config.enableHWLighting = value ? TRUE : FALSE; RegQueryValueEx( hKey, "Texture Bit Depth", 0, NULL, (BYTE*)&value, &size ); - OGL.textureBitDepth = value; + config.texture.textureBitDepth = value; RegCloseKey( hKey ); } else { - OGL.fog = TRUE; - OGL.windowedWidth = 640; - OGL.windowedHeight = 480; - OGL.fullscreenWidth = 640; - OGL.fullscreenHeight = 480; - OGL.fullscreenBits = 16; - OGL.fullscreenRefresh = 60; - OGL.forceBilinear = FALSE; + config.enableFog = TRUE; + config.video.windowedWidth = 640; + config.video.windowedHeight = 480; + config.video.fullscreenWidth = 640; + config.video.fullscreenHeight = 480; + config.video.fullscreenBits = 16; + config.video.fullscreenRefresh = 60; + config.texture.forceBilinear = FALSE; cache.maxBytes = 32 * 1048576; - OGL.frameBufferTextures = FALSE; - OGL.enable2xSaI = FALSE; - OGL.textureBitDepth = 1; - OGL.bHWLighting = FALSE; + config.frameBufferEmulation = FALSE; + config.texture.enable2xSaI = FALSE; + config.texture.textureBitDepth = 1; + config.enableHWLighting = FALSE; } } @@ -117,32 +118,32 @@ void Config_SaveConfig() RegCreateKeyEx( HKEY_CURRENT_USER, "Software\\N64 Emulation\\DLL\\glN64", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL ); - RegSetValueEx( hKey, "Fullscreen Bit Depth", 0, REG_DWORD, (BYTE*)&OGL.fullscreenBits, 4 ); - RegSetValueEx( hKey, "Fullscreen Width", 0, REG_DWORD, (BYTE*)&OGL.fullscreenWidth, 4 ); - RegSetValueEx( hKey, "Fullscreen Height", 0, REG_DWORD, (BYTE*)&OGL.fullscreenHeight, 4 ); - RegSetValueEx( hKey, "Fullscreen Refresh", 0, REG_DWORD, (BYTE*)&OGL.fullscreenRefresh, 4 ); - RegSetValueEx( hKey, "Windowed Width", 0, REG_DWORD, (BYTE*)&OGL.windowedWidth, 4 ); - RegSetValueEx( hKey, "Windowed Height", 0, REG_DWORD, (BYTE*)&OGL.windowedHeight, 4 ); + RegSetValueEx( hKey, "Fullscreen Bit Depth", 0, REG_DWORD, (BYTE*)&config.video.fullscreenBits, 4 ); + RegSetValueEx( hKey, "Fullscreen Width", 0, REG_DWORD, (BYTE*)&config.video.fullscreenWidth, 4 ); + RegSetValueEx( hKey, "Fullscreen Height", 0, REG_DWORD, (BYTE*)&config.video.fullscreenHeight, 4 ); + RegSetValueEx( hKey, "Fullscreen Refresh", 0, REG_DWORD, (BYTE*)&config.video.fullscreenRefresh, 4 ); + RegSetValueEx( hKey, "Windowed Width", 0, REG_DWORD, (BYTE*)&config.video.windowedWidth, 4 ); + RegSetValueEx( hKey, "Windowed Height", 0, REG_DWORD, (BYTE*)&config.video.windowedHeight, 4 ); - value = OGL.forceBilinear ? 1 : 0; + value = config.texture.forceBilinear ? 1 : 0; RegSetValueEx( hKey, "Force Bilinear", 0, REG_DWORD, (BYTE*)&value, 4 ); - value = OGL.enable2xSaI ? 1 : 0; + value = config.texture.enable2xSaI ? 1 : 0; RegSetValueEx( hKey, "Enable 2xSaI", 0, REG_DWORD, (BYTE*)&value, 4 ); - value = OGL.fog ? 1 : 0; + value = config.enableFog ? 1 : 0; RegSetValueEx( hKey, "Enable Fog", 0, REG_DWORD, (BYTE*)&value, 4 ); value = cache.maxBytes / 1048576; RegSetValueEx( hKey, "Texture Cache Size", 0, REG_DWORD, (BYTE*)&value, 4 ); - value = OGL.frameBufferTextures ? 1 : 0; + value = config.frameBufferEmulation ? 1 : 0; RegSetValueEx( hKey, "Hardware Frame Buffer Textures", 0, REG_DWORD, (BYTE*)&value, 4 ); - value = OGL.bHWLighting ? 1 : 0; + value = config.enableHWLighting ? 1 : 0; RegSetValueEx( hKey, "Hardware lighting", 0, REG_DWORD, (BYTE*)&value, 4 ); - value = OGL.textureBitDepth; + value = config.texture.textureBitDepth; RegSetValueEx( hKey, "Texture Bit Depth", 0, REG_DWORD, (BYTE*)&value, 4 ); RegCloseKey( hKey ); @@ -156,26 +157,26 @@ void Config_ApplyDlgConfig( HWND hWndDlg ) SendDlgItemMessage( hWndDlg, IDC_CACHEMEGS, WM_GETTEXT, 4, (LPARAM)text ); cache.maxBytes = atol( text ) * 1048576; - OGL.forceBilinear = (SendDlgItemMessage( hWndDlg, IDC_FORCEBILINEAR, BM_GETCHECK, NULL, NULL ) == BST_CHECKED); - OGL.enable2xSaI = (SendDlgItemMessage( hWndDlg, IDC_ENABLE2XSAI, BM_GETCHECK, NULL, NULL ) == BST_CHECKED); - OGL.fog = (SendDlgItemMessage( hWndDlg, IDC_FOG, BM_GETCHECK, NULL, NULL ) == BST_CHECKED); - OGL.originAdjust = (OGL.enable2xSaI ? 0.25f : 0.50f); + config.texture.forceBilinear = (SendDlgItemMessage( hWndDlg, IDC_FORCEBILINEAR, BM_GETCHECK, NULL, NULL ) == BST_CHECKED); + config.texture.enable2xSaI = (SendDlgItemMessage( hWndDlg, IDC_ENABLE2XSAI, BM_GETCHECK, NULL, NULL ) == BST_CHECKED); + config.enableFog = (SendDlgItemMessage( hWndDlg, IDC_FOG, BM_GETCHECK, NULL, NULL ) == BST_CHECKED); + //OGL.originAdjust = (OGL.enable2xSaI ? 0.25f : 0.50f); - OGL.fullscreenBits = fullscreen.bitDepth[SendDlgItemMessage( hWndDlg, IDC_FULLSCREENBITDEPTH, CB_GETCURSEL, 0, 0 )]; + config.video.fullscreenBits = fullscreen.bitDepth[SendDlgItemMessage( hWndDlg, IDC_FULLSCREENBITDEPTH, CB_GETCURSEL, 0, 0 )]; i = SendDlgItemMessage( hWndDlg, IDC_FULLSCREENRES, CB_GETCURSEL, 0, 0 ); - OGL.fullscreenWidth = fullscreen.resolution[i].width; - OGL.fullscreenHeight = fullscreen.resolution[i].height; - OGL.fullscreenRefresh = fullscreen.refreshRate[SendDlgItemMessage( hWndDlg, IDC_FULLSCREENREFRESH, CB_GETCURSEL, 0, 0 )]; + config.video.fullscreenWidth = fullscreen.resolution[i].width; + config.video.fullscreenHeight = fullscreen.resolution[i].height; + config.video.fullscreenRefresh = fullscreen.refreshRate[SendDlgItemMessage( hWndDlg, IDC_FULLSCREENREFRESH, CB_GETCURSEL, 0, 0 )]; i = SendDlgItemMessage( hWndDlg, IDC_TEXTUREBPP, CB_GETCURSEL, 0, 0 ); - OGL.textureBitDepth = (int)i; + config.texture.textureBitDepth = (int)i; i = SendDlgItemMessage( hWndDlg, IDC_WINDOWEDRES, CB_GETCURSEL, 0, 0 ); - OGL.windowedWidth = windowedModes[i].width; - OGL.windowedHeight = windowedModes[i].height; + config.video.windowedWidth = windowedModes[i].width; + config.video.windowedHeight = windowedModes[i].height; - OGL.frameBufferTextures = (SendDlgItemMessage( hWndDlg, IDC_FRAMEBUFFER, BM_GETCHECK, NULL, NULL ) == BST_CHECKED); - OGL.bHWLighting = (SendDlgItemMessage( hWndDlg, IDC_HWLIGHT, BM_GETCHECK, NULL, NULL ) == BST_CHECKED); + config.frameBufferEmulation = (SendDlgItemMessage( hWndDlg, IDC_FRAMEBUFFER, BM_GETCHECK, NULL, NULL ) == BST_CHECKED); + config.enableHWLighting = (SendDlgItemMessage( hWndDlg, IDC_HWLIGHT, BM_GETCHECK, NULL, NULL ) == BST_CHECKED); if (!OGL.fullscreen) OGL_ResizeWindow(); @@ -299,10 +300,10 @@ BOOL CALLBACK ConfigDlgProc( HWND hWndDlg, UINT message, WPARAM wParam, LPARAM l case WM_INITDIALOG: hConfigDlg = hWndDlg; - fullscreen.selected.width = OGL.fullscreenWidth; - fullscreen.selected.height = OGL.fullscreenHeight; - fullscreen.selected.bitDepth = OGL.fullscreenBits; - fullscreen.selected.refreshRate = OGL.fullscreenRefresh; + fullscreen.selected.width = config.video.fullscreenWidth; + fullscreen.selected.height = config.video.fullscreenHeight; + fullscreen.selected.bitDepth = config.video.fullscreenBits; + fullscreen.selected.refreshRate = config.video.fullscreenRefresh; UpdateFullscreenConfig( hWndDlg ); EnumDisplaySettings( NULL, ENUM_CURRENT_SETTINGS, &deviceMode ); @@ -314,23 +315,23 @@ BOOL CALLBACK ConfigDlgProc( HWND hWndDlg, UINT message, WPARAM wParam, LPARAM l (deviceMode.dmPelsHeight > windowedModes[i].height)) { SendDlgItemMessage( hWndDlg, IDC_WINDOWEDRES, CB_ADDSTRING, 0, (LPARAM)windowedModes[i].description ); - if ((OGL.windowedWidth == windowedModes[i].width) && - (OGL.windowedHeight == windowedModes[i].height)) + if ((config.video.windowedWidth == windowedModes[i].width) && + (config.video.windowedHeight == windowedModes[i].height)) SendDlgItemMessage( hWndDlg, IDC_WINDOWEDRES, CB_SETCURSEL, i, 0 ); } } - SendDlgItemMessage( hWndDlg, IDC_ENABLE2XSAI, BM_SETCHECK, OGL.enable2xSaI ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL ); + SendDlgItemMessage( hWndDlg, IDC_ENABLE2XSAI, BM_SETCHECK, config.texture.enable2xSaI ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL ); // Set forced bilinear check box - SendDlgItemMessage( hWndDlg, IDC_FORCEBILINEAR, BM_SETCHECK, OGL.forceBilinear ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL ); + SendDlgItemMessage( hWndDlg, IDC_FORCEBILINEAR, BM_SETCHECK, config.texture.forceBilinear ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL ); SendDlgItemMessage( hWndDlg, IDC_TEXTUREBPP, CB_ADDSTRING, 0, (LPARAM)"16-bit only (faster)" ); SendDlgItemMessage( hWndDlg, IDC_TEXTUREBPP, CB_ADDSTRING, 0, (LPARAM)"16-bit and 32-bit (normal)" ); SendDlgItemMessage( hWndDlg, IDC_TEXTUREBPP, CB_ADDSTRING, 0, (LPARAM)"32-bit only (best for 2xSaI)" ); - SendDlgItemMessage( hWndDlg, IDC_TEXTUREBPP, CB_SETCURSEL, OGL.textureBitDepth, 0 ); + SendDlgItemMessage( hWndDlg, IDC_TEXTUREBPP, CB_SETCURSEL, config.texture.textureBitDepth, 0 ); // Enable/disable fog - SendDlgItemMessage( hWndDlg, IDC_FOG, BM_SETCHECK, OGL.fog ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL ); - SendDlgItemMessage( hWndDlg, IDC_FRAMEBUFFER, BM_SETCHECK, OGL.frameBufferTextures ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL ); + SendDlgItemMessage( hWndDlg, IDC_FOG, BM_SETCHECK, config.enableFog ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL ); + SendDlgItemMessage( hWndDlg, IDC_FRAMEBUFFER, BM_SETCHECK, config.frameBufferEmulation ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL ); - SendDlgItemMessage( hWndDlg, IDC_HWLIGHT, BM_SETCHECK, OGL.bHWLighting ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL ); + SendDlgItemMessage( hWndDlg, IDC_HWLIGHT, BM_SETCHECK, config.enableHWLighting ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL ); _ltoa( cache.maxBytes / 1048576, text, 10 ); SendDlgItemMessage( hWndDlg, IDC_CACHEMEGS, WM_SETTEXT, NULL, (LPARAM)text ); diff --git a/Config.h b/Config.h index e0e45ba7..489fdba7 100644 --- a/Config.h +++ b/Config.h @@ -1,5 +1,36 @@ #ifndef CONFIG_H #define CONFIG_H + +#include "Types.h" + +struct Config +{ + u32 version; + + struct + { + u32 fullscreenWidth, fullscreenHeight, windowedWidth, windowedHeight; + u32 fullscreenBits, fullscreenRefresh; + } video; + + struct + { + u32 maxAnisotropy; + u32 textureBitDepth; + u32 enableLOD; + u32 forceBilinear; + u32 enable2xSaI; + u32 pow2; + } texture; + + u32 frameBufferEmulation; + u32 enableFog; + u32 enableNoise; + u32 enableHWLighting; +}; + +extern Config config; + void Config_LoadConfig(); void Config_DoConfig(); #endif diff --git a/Config_linux.cpp b/Config_linux.cpp index 5a335f24..014fe277 100644 --- a/Config_linux.cpp +++ b/Config_linux.cpp @@ -10,6 +10,8 @@ #include "Textures.h" #include "OpenGL.h" +Config config; + static GtkWidget *configWindow = NULL; //static GtkWidget *bitdepthCombo[2], *resolutionCombo[2]; static GtkWidget *resolutionCombo; @@ -70,20 +72,20 @@ static void okButton_clicked( GtkWidget *widget, void *data ) i1 = 640; i2 = 480; } - OGL.fullscreenWidth = OGL.windowedWidth = i1; - OGL.fullscreenHeight = OGL.windowedHeight = i2; + config.video.fullscreenWidth = config.video.windowedWidth = i1; + config.video.fullscreenHeight = config.video.windowedHeight = i2; - OGL.forceBilinear = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(forceBilinearCheck) ); - OGL.enable2xSaI = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(enable2xSAICheck) ); - OGL.fog = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(enableFogCheck) ); - OGL.frameBufferTextures = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(enableHardwareFBCheck) ); - OGL.bHWLighting = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(enableHardwareLighting) ); + config.texture.forceBilinear = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(forceBilinearCheck) ); + config.texture.enable2xSaI = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(enable2xSAICheck) ); + config.enableFog = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(enableFogCheck) ); + config.frameBufferEmulation = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(enableHardwareFBCheck) ); + config.enableHWLighting = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(enableHardwareLighting) ); const char *depth = gtk_entry_get_text( GTK_ENTRY(GTK_COMBO(textureDepthCombo)->entry) ); - OGL.textureBitDepth = 1; + config.texture.textureBitDepth = 1; for (i = 0; textureBitDepth[i] != 0; i++) { if (!strcmp( depth, textureBitDepth[i] )) - OGL.textureBitDepth = i; + config.texture.textureBitDepth = i; } cache.maxBytes = atoi( gtk_entry_get_text( GTK_ENTRY(textureCacheEntry) ) ) * 1048576; @@ -103,17 +105,17 @@ static void okButton_clicked( GtkWidget *widget, void *data ) /* fprintf( f, "fullscreen width=%d\n", OGL.fullscreenWidth ); fprintf( f, "fullscreen height=%d\n", OGL.fullscreenHeight ); fprintf( f, "fullscreen depth=%d\n", OGL.fullscreenBits );*/ - fprintf( f, "width=%d\n", OGL.windowedWidth ); - fprintf( f, "height=%d\n", OGL.windowedHeight ); + fprintf( f, "width=%d\n", config.video.windowedWidth ); + fprintf( f, "height=%d\n", config.video.windowedHeight ); // fprintf( f, "windowed depth=%d\n", OGL.windowedBits );*/ /* fprintf( f, "width=%d\n", OGL.width ); fprintf( f, "height=%d\n", OGL.height );*/ - fprintf( f, "force bilinear=%d\n", OGL.forceBilinear ); - fprintf( f, "enable 2xSAI=%d\n", OGL.enable2xSaI ); - fprintf( f, "enable fog=%d\n", OGL.fog ); - fprintf( f, "enable HardwareFB=%d\n", OGL.frameBufferTextures ); - fprintf( f, "enable hardware lighting=%d\n", OGL.bHWLighting ); - fprintf( f, "texture depth=%d\n", OGL.textureBitDepth ); + fprintf( f, "force bilinear=%d\n", config.texture.forceBilinear ); + fprintf( f, "enable 2xSAI=%d\n", config.texture.enable2xSaI ); + fprintf( f, "enable fog=%d\n", config.enableFog ); + fprintf( f, "enable HardwareFB=%d\n", config.frameBufferEmulation ); + fprintf( f, "enable hardware lighting=%d\n", config.enableHWLighting ); + fprintf( f, "texture depth=%d\n", config.texture.textureBitDepth ); fprintf( f, "cache size=%d\n", cache.maxBytes / 1048576 ); fclose( f ); @@ -144,17 +146,17 @@ static void configWindow_show( GtkWidget *widget, void *data ) sprintf( text, "%d x %d", OGL.windowedWidth, OGL.windowedHeight ); gtk_entry_set_text( GTK_ENTRY(GTK_COMBO(resolutionCombo[1])->entry), text );*/ - sprintf( text, "%d x %d", OGL.windowedWidth, OGL.windowedHeight ); + sprintf( text, "%d x %d", config.video.windowedWidth, config.video.windowedHeight ); gtk_entry_set_text( GTK_ENTRY(GTK_COMBO(resolutionCombo)->entry), text ); - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(enable2xSAICheck), (OGL.enable2xSaI) ); - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(forceBilinearCheck), (OGL.forceBilinear) ); - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(enableFogCheck), (OGL.fog) ); - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(enableHardwareLighting), (OGL.bHWLighting) ); + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(enable2xSAICheck), (config.texture.enable2xSaI) ); + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(forceBilinearCheck), (config.texture.forceBilinear) ); + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(enableFogCheck), (config.enableFog) ); + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(enableHardwareLighting), (config.enableHWLighting) ); // textures - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(enableHardwareFBCheck), (OGL.frameBufferTextures) ); - gtk_entry_set_text( GTK_ENTRY(GTK_COMBO(textureDepthCombo)->entry), textureBitDepth[OGL.textureBitDepth] ); + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(enableHardwareFBCheck), (config.frameBufferEmulation) ); + gtk_entry_set_text( GTK_ENTRY(GTK_COMBO(textureDepthCombo)->entry), textureBitDepth[config.texture.textureBitDepth] ); sprintf( text, "%d", cache.maxBytes / 1048576 ); gtk_entry_set_text( GTK_ENTRY(textureCacheEntry), text ); } @@ -362,18 +364,18 @@ void Config_LoadConfig() pluginDir = GetPluginDir(); // default configuration - OGL.fullscreenWidth = 640; - OGL.fullscreenHeight = 480; + config.video.fullscreenWidth = 640; + config.video.fullscreenHeight = 480; // OGL.fullscreenBits = 0; - OGL.windowedWidth = 640; - OGL.windowedHeight = 480; + config.video.windowedWidth = 640; + config.video.windowedHeight = 480; // OGL.windowedBits = 0; - OGL.forceBilinear = 0; - OGL.enable2xSaI = 0; - OGL.fog = 1; - OGL.textureBitDepth = 1; // normal (16 & 32 bits) - OGL.frameBufferTextures = 0; - OGL.bHWLighting = 0; + config.texture.forceBilinear = 0; + config.texture.enable2xSaI = 0; + config.enableFog = 1; + config.texture.textureBitDepth = 1; // normal (16 & 32 bits) + config.frameBufferEmulation = 0; + config.enableHWLighting = 0; cache.maxBytes = 32 * 1048576; // read configuration @@ -423,24 +425,24 @@ void Config_LoadConfig() if (!strcasecmp( line, "width" )) { int w = atoi( val ); - OGL.fullscreenWidth = OGL.windowedWidth = (w == 0) ? (640) : (w); + config.video.fullscreenWidth = config.video.windowedWidth = (w == 0) ? (640) : (w); } else if (!strcasecmp( line, "height" )) { int h = atoi( val ); - OGL.fullscreenHeight = OGL.windowedHeight = (h == 0) ? (480) : (h); + config.video.fullscreenHeight = config.video.windowedHeight = (h == 0) ? (480) : (h); } else if (!strcasecmp( line, "force bilinear" )) { - OGL.forceBilinear = atoi( val ); + config.texture.forceBilinear = atoi( val ); } else if (!strcasecmp( line, "enable 2xSAI" )) { - OGL.enable2xSaI = atoi( val ); + config.texture.enable2xSaI = atoi( val ); } else if (!strcasecmp( line, "enable fog" )) { - OGL.fog = atoi( val ); + config.enableFog = atoi( val ); } else if (!strcasecmp( line, "cache size" )) { @@ -448,15 +450,15 @@ void Config_LoadConfig() } else if (!strcasecmp( line, "enable HardwareFB" )) { - OGL.frameBufferTextures = atoi( val ); + config.frameBufferEmulation = atoi( val ); } else if (!strcasecmp( line, "enable hardware lighting" )) { - OGL.bHWLighting = atoi( val ); + config.enableHWLighting = atoi( val ); } else if (!strcasecmp( line, "texture depth" )) { - OGL.textureBitDepth = atoi( val ); + config.texture.textureBitDepth = atoi( val ); } else { diff --git a/Config_mupen.cpp b/Config_mupen.cpp index 96c06a5d..38bcb3d7 100644 --- a/Config_mupen.cpp +++ b/Config_mupen.cpp @@ -9,28 +9,32 @@ #include "Textures.h" #include "OpenGL.h" +Config config; + struct Option { const char* name; - unsigned int* data; + u32* data; const int initial; }; Option configOptions[] = { {"#GLideN64 Graphics Plugin for N64", NULL, 0}, -// {"config version", &config.version, 0}, + {"config version", &config.version, 0}, {"", NULL, 0}, -// {"#Window Settings:", NULL, 0}, - {"window width", &OGL.windowedWidth, 640}, - {"window height", &OGL.windowedHeight, 480}, - {"force bilinear", &OGL.forceBilinear, 0}, - {"enable 2xSAI", &OGL.enable2xSaI, 0}, - {"enable fog", &OGL.fog, 1}, + {"#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}, + {"enable 2xSAI", &config.texture.enable2xSaI, 0}, {"cache size", &cache.maxBytes, 64*1048576}, - {"enable HardwareFB", &OGL.frameBufferTextures, 0}, - {"texture depth", &OGL.textureBitDepth, 1} + {"texture depth", &config.texture.textureBitDepth, 1}, + {"#Emulation Settings:", NULL, 0}, + {"enable fog", &config.enableFog, 1}, + {"enable HardwareFB", &config.frameBufferEmulation, 0} }; const int configOptionsSize = sizeof(configOptions) / sizeof(Option); @@ -61,8 +65,8 @@ void Config_SetDefault() Option *o = &configOptions[i]; if (o->data) *(o->data) = o->initial; } - OGL.fullscreenWidth = 640; - OGL.fullscreenHeight = 480; + config.video.fullscreenWidth = 640; + config.video.fullscreenHeight = 480; } void Config_SetOption(char* line, char* val) diff --git a/DepthBuffer.cpp b/DepthBuffer.cpp index 70f3498b..f005ec1b 100644 --- a/DepthBuffer.cpp +++ b/DepthBuffer.cpp @@ -5,6 +5,7 @@ #include "FrameBuffer.h" #include "DepthBuffer.h" #include "VI.h" +#include "Config.h" #include "Debug.h" DepthBufferInfo depthBuffer; @@ -179,7 +180,7 @@ void DepthBuffer_SetBuffer( u32 address ) current->address = address; current->width = pFrameBuffer != NULL ? pFrameBuffer->width : VI.width; current->depth_texture = NULL; - if (OGL.frameBufferTextures) { + if (config.frameBufferEmulation) { glGenRenderbuffers(1, ¤t->renderbuf); glBindRenderbuffer(GL_RENDERBUFFER, current->renderbuf); if (pFrameBuffer != NULL) @@ -189,7 +190,7 @@ void DepthBuffer_SetBuffer( u32 address ) } } - if (OGL.frameBufferTextures) { + if (config.frameBufferEmulation) { FrameBuffer_AttachDepthBuffer(); #ifdef DEBUG diff --git a/FrameBuffer.cpp b/FrameBuffer.cpp index a1d728a4..99c4cd41 100644 --- a/FrameBuffer.cpp +++ b/FrameBuffer.cpp @@ -10,6 +10,7 @@ #include "Textures.h" #include "Combiner.h" #include "Types.h" +#include "Config.h" #include "Debug.h" bool g_bCopyToRDRAM = false; @@ -526,7 +527,7 @@ void FrameBuffer_RenderBuffer( u32 address ) glMatrixMode( GL_PROJECTION ); glLoadIdentity(); - glOrtho( 0, OGL.width, 0, OGL.height, -1.0f, 1.0f ); + glOrtho( 0, OGL.width, 0, OGL.height, -1.0f, 1.0f ); glViewport( 0, OGL.heightOffset, OGL.width, OGL.height ); glDisable( GL_SCISSOR_TEST ); diff --git a/GLSLCombiner.cpp b/GLSLCombiner.cpp index 087de87e..0b6b39ba 100644 --- a/GLSLCombiner.cpp +++ b/GLSLCombiner.cpp @@ -2,6 +2,7 @@ #include #include "N64.h" #include "OpenGL.h" +#include "Config.h" #include "Combiner.h" #include "GLSLCombiner.h" #include "Shaders.h" @@ -399,7 +400,7 @@ GLSLCombiner::GLSLCombiner(Combiner *_color, Combiner *_alpha) { } else { assert(strstr(strCombiner, "readtex") == 0); } - if (OGL.bHWLighting) + if (config.enableHWLighting) strcat(fragment_shader, " float intensity = calc_light(int(vNumLights), vShadeColor.rgb, input_color); \n"); else strcat(fragment_shader, " input_color = vShadeColor.rgb;\n"); @@ -442,7 +443,7 @@ GLSLCombiner::GLSLCombiner(Combiner *_color, Combiner *_alpha) { m_aShaders[uShaderIdx++] = g_vertex_shader_object; glAttachShader(m_program, fragmentShader); m_aShaders[uShaderIdx++] = fragmentShader; - if (OGL.bHWLighting) { + if (config.enableHWLighting) { glAttachShader(m_program, g_calc_light_shader_object); m_aShaders[uShaderIdx++] = g_calc_light_shader_object; } @@ -571,7 +572,7 @@ void GLSLCombiner::UpdateColors(bool _bForce) { _setV4Uniform(m_uniforms.uFogColor, &gDP.fogColor.r, _bForce); _setV4Uniform(m_uniforms.uCenterColor, &gDP.key.center.r, _bForce); _setV4Uniform(m_uniforms.uScaleColor, &gDP.key.scale.r, _bForce); - _setIUniform(m_uniforms.uEnableFog, (OGL.fog && (gSP.geometryMode & G_FOG) != 0), _bForce); + _setIUniform(m_uniforms.uEnableFog, (config.enableFog && (gSP.geometryMode & G_FOG) != 0), _bForce); _setFUniform(m_uniforms.uFogMultiplier, (float)gSP.fog.multiplier / 255.0f, _bForce); _setFUniform(m_uniforms.uFogOffset, (float)gSP.fog.offset / 255.0f, _bForce); _setFUniform(m_uniforms.uK4, gDP.convert.k4, _bForce); @@ -721,7 +722,7 @@ void GLSL_RenderDepth() { glMatrixMode( GL_PROJECTION ); glLoadIdentity(); - glOrtho( 0, OGL.width, 0, OGL.height, -1.0f, 1.0f ); + glOrtho( 0, OGL.width, 0, OGL.height, -1.0f, 1.0f ); glViewport( 0, OGL.heightOffset, OGL.width, OGL.height ); glDisable( GL_SCISSOR_TEST ); diff --git a/OpenGL.cpp b/OpenGL.cpp index 04d43a14..cbc62fa0 100644 --- a/OpenGL.cpp +++ b/OpenGL.cpp @@ -12,6 +12,7 @@ #include "FrameBuffer.h" #include "DepthBuffer.h" #include "VI.h" +#include "Config.h" GLInfo OGL; @@ -222,16 +223,16 @@ void OGL_ResizeWindow() if (OGL.fullscreen) { - OGL.width = OGL.fullscreenWidth; - OGL.height = OGL.fullscreenHeight; + OGL.width = config.video.fullscreenWidth; + OGL.height = config.video.fullscreenHeight; OGL.heightOffset = 0; SetWindowPos( hWnd, NULL, 0, 0, OGL.width, OGL.height, SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW ); } else { - OGL.width = OGL.windowedWidth; - OGL.height = OGL.windowedHeight; + OGL.width = config.video.windowedWidth; + OGL.height = config.video.windowedHeight; GetClientRect( hWnd, &windowRect ); GetWindowRect( hStatusBar, &statusRect ); @@ -242,8 +243,8 @@ void OGL_ResizeWindow() toolRect.bottom = toolRect.top = 0; OGL.heightOffset = (statusRect.bottom - statusRect.top); - windowRect.right = windowRect.left + OGL.windowedWidth - 1; - windowRect.bottom = windowRect.top + OGL.windowedHeight - 1 + OGL.heightOffset; + windowRect.right = windowRect.left + config.video.windowedWidth - 1; + windowRect.bottom = windowRect.top + config.video.windowedHeight - 1 + OGL.heightOffset; AdjustWindowRect( &windowRect, GetWindowLong( hWnd, GWL_STYLE ), GetMenu( hWnd ) != NULL ); @@ -318,13 +319,13 @@ bool OGL_Start() if (OGL.fullscreen) { - OGL.width = OGL.fullscreenWidth; - OGL.height = OGL.fullscreenHeight; + OGL.width = config.video.fullscreenWidth; + OGL.height = config.video.fullscreenHeight; } else { - OGL.width = OGL.windowedWidth; - OGL.height = OGL.windowedHeight; + OGL.width = config.video.windowedWidth; + OGL.height = config.video.windowedHeight; } @@ -792,7 +793,7 @@ void OGL_DrawTriangles() glVertexAttribPointer(SC_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(SPVertex), &OGL.triangles.vertices[0].r); glVertexAttribPointer(SC_TEXCOORD0, 2, GL_FLOAT, GL_FALSE, sizeof(SPVertex), &OGL.triangles.vertices[0].s); glVertexAttribPointer(SC_STSCALED, 1, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(SPVertex), &OGL.triangles.vertices[0].st_scaled); - if (OGL.bHWLighting) { + if (config.enableHWLighting) { glEnableVertexAttribArray(SC_NUMLIGHTS); glVertexAttribPointer(SC_NUMLIGHTS, 1, GL_BYTE, GL_FALSE, sizeof(SPVertex), &OGL.triangles.vertices[0].HWLight); } @@ -1004,7 +1005,7 @@ void OGL_DrawTexturedRect( float ulx, float uly, float lrx, float lry, float uls OGL.rect[3].t1 *= cache.current[1]->scaleT; } - if ((gDP.otherMode.cycleType == G_CYC_COPY) && !OGL.forceBilinear) + if ((gDP.otherMode.cycleType == G_CYC_COPY) && !config.texture.forceBilinear) { glActiveTexture( GL_TEXTURE0 ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); @@ -1040,7 +1041,7 @@ void OGL_DrawTexturedRect( float ulx, float uly, float lrx, float lry, float uls void OGL_ClearDepthBuffer() { - if (OGL.frameBufferTextures && frameBuffer.top == NULL) + if (config.frameBufferEmulation && frameBuffer.top == NULL) return; DepthBuffer_ClearBuffer(); diff --git a/OpenGL.h b/OpenGL.h index 7e4df829..690c20f5 100644 --- a/OpenGL.h +++ b/OpenGL.h @@ -41,10 +41,8 @@ struct GLInfo SDL_Surface *hScreen; #endif // _WINDOWS - DWORD fullscreenWidth, fullscreenHeight, fullscreenBits, fullscreenRefresh; - DWORD width, height, windowedWidth, windowedHeight, heightOffset; - - BOOL fullscreen, forceBilinear, fog; + BOOL fullscreen; + unsigned int width, height, heightOffset; float scaleX, scaleY; @@ -87,13 +85,6 @@ struct GLInfo } renderState; bool bImageTexture; bool captureScreen; - - // Settings. TODO: Move to Settings class - BOOL bHWLighting; - BOOL enable2xSaI; - BOOL frameBufferTextures; - u32 textureBitDepth; - float originAdjust; }; extern GLInfo OGL; diff --git a/Textures.cpp b/Textures.cpp index 0ce9c720..60ed4023 100644 --- a/Textures.cpp +++ b/Textures.cpp @@ -10,6 +10,7 @@ #include "convert.h" #include "2xSAI.h" #include "FrameBuffer.h" +#include "Config.h" #include TextureCache cache; @@ -226,8 +227,8 @@ void TextureCache_Init() cache.bottom = NULL; cache.numCached = 0; cache.cachedBytes = 0; - cache.enable2xSaI = OGL.enable2xSaI; - cache.bitDepth = OGL.textureBitDepth; + cache.enable2xSaI = config.texture.enable2xSaI; + cache.bitDepth = config.texture.textureBitDepth; glGenTextures( 32, cache.glNoiseNames ); @@ -738,7 +739,7 @@ void TextureCache_ActivateTexture( u32 t, CachedTexture *texture ) glBindTexture( GL_TEXTURE_2D, texture->glName ); // Set filter mode. Almost always bilinear, but check anyways - if ((gDP.otherMode.textureFilter == G_TF_BILERP) || (gDP.otherMode.textureFilter == G_TF_AVERAGE) || (OGL.forceBilinear)) + if ((gDP.otherMode.textureFilter == G_TF_BILERP) || (gDP.otherMode.textureFilter == G_TF_AVERAGE) || (config.texture.forceBilinear)) { glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); @@ -857,13 +858,13 @@ void TextureCache_Update( u32 t ) u32 tileWidth, maskWidth, loadWidth, lineWidth, clampWidth, height; u32 tileHeight, maskHeight, loadHeight, lineHeight, clampHeight, width; - if (cache.enable2xSaI != OGL.enable2xSaI) + if (cache.enable2xSaI != config.texture.enable2xSaI) { TextureCache_Destroy(); TextureCache_Init(); } - if (cache.bitDepth != OGL.textureBitDepth) + if (cache.bitDepth != config.texture.textureBitDepth) { TextureCache_Destroy(); TextureCache_Init(); @@ -1102,8 +1103,8 @@ void TextureCache_Update( u32 t ) cache.current[t]->shiftScaleS = 1.0f; cache.current[t]->shiftScaleT = 1.0f; - cache.current[t]->offsetS = OGL.enable2xSaI ? 0.25f : 0.5f; - cache.current[t]->offsetT = OGL.enable2xSaI ? 0.25f : 0.5f; + cache.current[t]->offsetS = config.texture.enable2xSaI ? 0.25f : 0.5f; + cache.current[t]->offsetT = config.texture.enable2xSaI ? 0.25f : 0.5f; if (gSP.textureTile[t]->shifts > 10) cache.current[t]->shiftScaleS = (f32)(1 << (16 - gSP.textureTile[t]->shifts)); diff --git a/VI.cpp b/VI.cpp index 7a36bb64..79f369f2 100644 --- a/VI.cpp +++ b/VI.cpp @@ -7,6 +7,7 @@ #include "gDP.h" #include "RSP.h" #include "FrameBuffer.h" +#include "Config.h" #include "Debug.h" VIInfo VI; @@ -55,7 +56,7 @@ void VI_UpdateScreen() if (((*REG.VI_STATUS)&3) == 0) VI.vStart = VI.vEnd = 0; - if (OGL.frameBufferTextures) { + if (config.frameBufferEmulation) { const bool bCFB = !g_bIgnoreCFB && (gSP.changed&CHANGED_CPU_FB_WRITE) == CHANGED_CPU_FB_WRITE; const bool bNeedUpdate = bCFB ? true : (*REG.VI_ORIGIN != VI.lastOrigin);// && gDP.colorImage.changed; diff --git a/gDP.cpp b/gDP.cpp index 43cc7b53..ae12a37a 100644 --- a/gDP.cpp +++ b/gDP.cpp @@ -13,6 +13,7 @@ #include "FrameBuffer.h" #include "DepthBuffer.h" #include "VI.h" +#include "Config.h" gDPInfo gDP; @@ -268,7 +269,7 @@ void gDPSetColorImage( u32 format, u32 size, u32 width, u32 address ) else height = gSP.viewport.height; - if (OGL.frameBufferTextures)// && address != gDP.depthImageAddress) + if (config.frameBufferEmulation)// && address != gDP.depthImageAddress) { //if (gDP.colorImage.changed) FrameBuffer_SaveBuffer( address, (u16)format, (u16)size, (u16)width, height ); @@ -496,7 +497,7 @@ bool CheckForFrameBufferTexture(u32 _address, u32 _bytes) gDP.loadTile->textureMode = TEXTUREMODE_NORMAL; gDP.loadTile->frameBuffer = NULL; gDP.changed |= CHANGED_TMEM; - if (!OGL.frameBufferTextures) + if (!config.frameBufferEmulation) return false; FrameBuffer *pBuffer = FrameBuffer_FindBuffer( _address ); diff --git a/gSP.cpp b/gSP.cpp index f594c1bb..2c01eca0 100644 --- a/gSP.cpp +++ b/gSP.cpp @@ -17,6 +17,7 @@ #include "VI.h" #include "FrameBuffer.h" #include "DepthBuffer.h" +#include "Config.h" #include "Log.h" #ifdef DEBUG @@ -446,7 +447,7 @@ static void gSPLightVertex_default(u32 v) { TransformVectorNormalize( &OGL.triangles.vertices[v].nx, gSP.matrix.modelView[gSP.matrix.modelViewi] ); - if (!OGL.bHWLighting) { + if (!config.enableHWLighting) { f32 r = gSP.lights[gSP.numLights].r; f32 g = gSP.lights[gSP.numLights].g; f32 b = gSP.lights[gSP.numLights].b; @@ -756,7 +757,7 @@ void gSPLight( u32 l, s32 n ) Normalize( &gSP.lights[n].x ); } - if (OGL.bHWLighting) { + if (config.enableHWLighting) { float fLightPos[4] = {gSP.lights[n].x, gSP.lights[n].y, gSP.lights[n].z, 0.0}; glLightfv(GL_LIGHT0+n, GL_POSITION, fLightPos); float fLightColor[4] = {gSP.lights[n].r, gSP.lights[n].g, gSP.lights[n].b, 1.0}; @@ -1728,7 +1729,7 @@ void loadBGImage(const uObjScaleBg * _bgInfo, bool _loadScale) } else gSP.bgImage.scaleW = gSP.bgImage.scaleH = 1.0f; - if (OGL.frameBufferTextures) + if (config.frameBufferEmulation) { FrameBuffer *buffer; if (((buffer = FrameBuffer_FindBuffer( gSP.bgImage.address )) != NULL) &&