diff --git a/bettergln.vcxproj b/bettergln.vcxproj
index 829474d..4aea897 100644
--- a/bettergln.vcxproj
+++ b/bettergln.vcxproj
@@ -26,9 +26,9 @@
-
+
DynamicLibrary
- MultiByte
+ Unicode
v143
@@ -106,7 +106,7 @@
Disabled
- WIN32;GLEW_STATIC;CORE_PLUGIN_WITH_CALLBACKS
+ WIN32;GLEW_STATIC;CORE_PLUGIN_WITH_CALLBACKS;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebug
Level3
@@ -124,7 +124,7 @@
true
Speed
true
- WIN32;GLEW_STATIC;CORE_PLUGIN_WITH_CALLBACKS
+ WIN32;GLEW_STATIC;CORE_PLUGIN_WITH_CALLBACKS;%(PreprocessorDefinitions)
MultiThreaded
true
Level3
@@ -140,7 +140,7 @@
Disabled
- WIN32;GLEW_STATIC;CORE_PLUGIN_WITH_CALLBACKS
+ WIN32;GLEW_STATIC;CORE_PLUGIN_WITH_CALLBACKS;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebug
Level3
@@ -158,7 +158,7 @@
true
Speed
true
- WIN32;GLEW_STATIC;CORE_PLUGIN_WITH_CALLBACKS
+ WIN32;GLEW_STATIC;CORE_PLUGIN_WITH_CALLBACKS;%(PreprocessorDefinitions)
MultiThreaded
true
Level3
@@ -229,6 +229,7 @@
+
diff --git a/src/Config.cpp b/src/Config.cpp
index 092ffaf..f03321d 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -14,20 +14,20 @@ struct
{
WORD width{};
WORD height{};
- std::string description{};
+ std::wstring description{};
} windowedModes[numWindowedModes] = {
-{320, 240, "320 x 240"},
-{400, 300, "400 x 300"},
-{480, 360, "480 x 360"},
-{640, 480, "640 x 480"},
-{800, 600, "800 x 600"},
-{960, 720, "960 x 720"},
-{1024, 768, "1024 x 768"},
-{1152, 864, "1152 x 864"},
-{1280, 960, "1280 x 960"},
-{1280, 1024, "1280 x 1024"},
-{1440, 1080, "1440 x 1080"},
-{1600, 1200, "1600 x 1200"}};
+{320, 240, L"320 x 240"},
+{400, 300, L"400 x 300"},
+{480, 360, L"480 x 360"},
+{640, 480, L"640 x 480"},
+{800, 600, L"800 x 600"},
+{960, 720, L"960 x 720"},
+{1024, 768, L"1024 x 768"},
+{1152, 864, L"1152 x 864"},
+{1280, 960, L"1280 x 960"},
+{1280, 1024, L"1280 x 1024"},
+{1440, 1080, L"1440 x 1080"},
+{1600, 1200, L"1600 x 1200"}};
void EnableCustom(HWND hWndDlg, BOOL enable)
{
@@ -41,38 +41,38 @@ void Config_LoadConfig()
HKEY hKey;
- RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\N64 Emulation\\DLL\\glN64", 0, KEY_READ, &hKey);
+ RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\N64 Emulation\\DLL\\glN64", 0, KEY_READ, &hKey);
if (hKey)
{
- 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, "Force Bilinear", 0, NULL, (BYTE*)&value, &size);
+ RegQueryValueEx(hKey, L"Windowed Width", 0, NULL, (BYTE*)&OGL.windowedWidth, &size);
+ RegQueryValueEx(hKey, L"Windowed Height", 0, NULL, (BYTE*)&OGL.windowedHeight, &size);
+ RegQueryValueEx(hKey, L"Windowed Width", 0, NULL, (BYTE*)&OGL.windowedWidth, &size);
+ RegQueryValueEx(hKey, L"Force Bilinear", 0, NULL, (BYTE*)&value, &size);
OGL.forceBilinear = value ? TRUE : FALSE;
- RegQueryValueEx(hKey, "Texture Filter", 0, NULL, (BYTE*)&value, &size);
+ RegQueryValueEx(hKey, L"Texture Filter", 0, NULL, (BYTE*)&value, &size);
OGL.textureFilter = (TextureFilter)value;
- RegQueryValueEx(hKey, "Filter Scale", 0, NULL, (BYTE*)&value, &size);
+ RegQueryValueEx(hKey, L"Filter Scale", 0, NULL, (BYTE*)&value, &size);
OGL.filterScale = value;
- RegQueryValueEx(hKey, "Enable Fog", 0, NULL, (BYTE*)&value, &size);
+ RegQueryValueEx(hKey, L"Enable Fog", 0, NULL, (BYTE*)&value, &size);
OGL.fog = value ? TRUE : FALSE;
- RegQueryValueEx(hKey, "Texture Cache Size", 0, NULL, (BYTE*)&value, &size);
+ RegQueryValueEx(hKey, L"Texture Cache Size", 0, NULL, (BYTE*)&value, &size);
cache.maxBytes = value * 1048576;
- RegQueryValueEx(hKey, "Dithered Alpha Testing", 0, NULL, (BYTE*)&value, &size);
+ RegQueryValueEx(hKey, L"Dithered Alpha Testing", 0, NULL, (BYTE*)&value, &size);
OGL.usePolygonStipple = value ? TRUE : FALSE;
- RegQueryValueEx(hKey, "Ignore Scissor", 0, NULL, (BYTE*)&value, &size);
+ RegQueryValueEx(hKey, L"Ignore Scissor", 0, NULL, (BYTE*)&value, &size);
OGL.ignoreScissor = value ? TRUE : FALSE;
- RegQueryValueEx(hKey, "Clear Override", 0, NULL, (BYTE*)&value, &size);
+ RegQueryValueEx(hKey, L"Clear Override", 0, NULL, (BYTE*)&value, &size);
OGL.clear_override = value ? TRUE : FALSE;
- RegQueryValueEx(hKey, "Combiner", 0, NULL, (BYTE*)&value, &size);
+ RegQueryValueEx(hKey, L"Combiner", 0, NULL, (BYTE*)&value, &size);
OGL.combiner = value;
if (OGL.textureFilter == TextureFilter::SaI)
@@ -106,37 +106,37 @@ void Config_SaveConfig()
DWORD value;
HKEY hKey;
- RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\N64 Emulation\\DLL\\glN64", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL);
+ RegCreateKeyEx(HKEY_CURRENT_USER, L"Software\\N64 Emulation\\DLL\\glN64", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL);
- RegSetValueEx(hKey, "Windowed Width", 0, REG_DWORD, (BYTE*)&OGL.windowedWidth, 4);
- RegSetValueEx(hKey, "Windowed Height", 0, REG_DWORD, (BYTE*)&OGL.windowedHeight, 4);
+ RegSetValueEx(hKey, L"Windowed Width", 0, REG_DWORD, (BYTE*)&OGL.windowedWidth, 4);
+ RegSetValueEx(hKey, L"Windowed Height", 0, REG_DWORD, (BYTE*)&OGL.windowedHeight, 4);
value = OGL.forceBilinear ? 1 : 0;
- RegSetValueEx(hKey, "Force Bilinear", 0, REG_DWORD, (BYTE*)&value, 4);
+ RegSetValueEx(hKey, L"Force Bilinear", 0, REG_DWORD, (BYTE*)&value, 4);
value = (DWORD)OGL.textureFilter;
- RegSetValueEx(hKey, "Texture Filter", 0, REG_DWORD, (BYTE*)&value, 4);
+ RegSetValueEx(hKey, L"Texture Filter", 0, REG_DWORD, (BYTE*)&value, 4);
value = OGL.filterScale;
- RegSetValueEx(hKey, "Filter Scale", 0, REG_DWORD, (BYTE*)&value, 4);
+ RegSetValueEx(hKey, L"Filter Scale", 0, REG_DWORD, (BYTE*)&value, 4);
value = OGL.fog ? 1 : 0;
- RegSetValueEx(hKey, "Enable Fog", 0, REG_DWORD, (BYTE*)&value, 4);
+ RegSetValueEx(hKey, L"Enable Fog", 0, REG_DWORD, (BYTE*)&value, 4);
value = cache.maxBytes / 1048576;
- RegSetValueEx(hKey, "Texture Cache Size", 0, REG_DWORD, (BYTE*)&value, 4);
+ RegSetValueEx(hKey, L"Texture Cache Size", 0, REG_DWORD, (BYTE*)&value, 4);
value = OGL.usePolygonStipple ? 1 : 0;
- RegSetValueEx(hKey, "Dithered Alpha Testing", 0, REG_DWORD, (BYTE*)&value, 4);
+ RegSetValueEx(hKey, L"Dithered Alpha Testing", 0, REG_DWORD, (BYTE*)&value, 4);
value = OGL.ignoreScissor ? 1 : 0;
- RegSetValueEx(hKey, "Ignore Scissor", 0, REG_DWORD, (BYTE*)&value, 4);
+ RegSetValueEx(hKey, L"Ignore Scissor", 0, REG_DWORD, (BYTE*)&value, 4);
value = OGL.clear_override ? 1 : 0;
- RegSetValueEx(hKey, "Clear Override", 0, REG_DWORD, (BYTE*)&value, 4);
+ RegSetValueEx(hKey, L"Clear Override", 0, REG_DWORD, (BYTE*)&value, 4);
value = OGL.combiner;
- RegSetValueEx(hKey, "Combiner", 0, REG_DWORD, (BYTE*)&value, 4);
+ RegSetValueEx(hKey, L"Combiner", 0, REG_DWORD, (BYTE*)&value, 4);
RegCloseKey(hKey);
}
@@ -190,72 +190,69 @@ void Config_ApplyDlgConfig(HWND hWndDlg)
BOOL CALLBACK ConfigDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
- char text[256]{};
bool custom = true;
switch (message)
{
case WM_INITDIALOG:
- hConfigDlg = hWndDlg;
-
-
- // Fill windowed mode resolution
- for (int i = 0; i < numWindowedModes; i++)
{
- ComboBox_AddString(GetDlgItem(hWndDlg, IDC_WINDOWEDRES), windowedModes[i].description.c_str());
- if ((OGL.windowedWidth == windowedModes[i].width) &&
- (OGL.windowedHeight == windowedModes[i].height))
+ hConfigDlg = hWndDlg;
+
+ // Fill windowed mode resolution
+ for (int i = 0; i < numWindowedModes; i++)
{
- SendDlgItemMessage(hWndDlg, IDC_WINDOWEDRES, CB_SETCURSEL, i, 0);
- custom = false;
+ ComboBox_AddString(GetDlgItem(hWndDlg, IDC_WINDOWEDRES), windowedModes[i].description.c_str());
+ if ((OGL.windowedWidth == windowedModes[i].width) &&
+ (OGL.windowedHeight == windowedModes[i].height))
+ {
+ SendDlgItemMessage(hWndDlg, IDC_WINDOWEDRES, CB_SETCURSEL, i, 0);
+ custom = false;
+ }
}
- }
-
- SendDlgItemMessage(hWndDlg, IDC_WINDOWEDRES, CB_ADDSTRING, 0, (LPARAM) "Custom...");
- char val[32];
- sprintf(val, "%d", OGL.windowedWidth);
- SendDlgItemMessage(hWndDlg, IDC_WINDOWED_X, WM_SETTEXT, 0, (LPARAM)val);
- sprintf(val, "%d", OGL.windowedHeight);
- SendDlgItemMessage(hWndDlg, IDC_WINDOWED_Y, WM_SETTEXT, 0, (LPARAM)val);
- if (custom)
- {
- int num = SendDlgItemMessage(hWndDlg, IDC_WINDOWEDRES, CB_GETCOUNT, 0, 0) - 1;
- EnableCustom(hWndDlg, TRUE);
- SendDlgItemMessage(hWndDlg, IDC_WINDOWEDRES, CB_SETCURSEL, num, 0);
- }
+ SendDlgItemMessage(hWndDlg, IDC_WINDOWEDRES, CB_ADDSTRING, 0, (LPARAM)L"Custom...");
- SendDlgItemMessage(hWndDlg, IDC_TEXTUREFILTER, CB_ADDSTRING, 0, (LPARAM) "None");
- SendDlgItemMessage(hWndDlg, IDC_TEXTUREFILTER, CB_ADDSTRING, 0, (LPARAM) "2xSaI");
- SendDlgItemMessage(hWndDlg, IDC_TEXTUREFILTER, CB_ADDSTRING, 0, (LPARAM) "xBRZ");
- SendDlgItemMessage(hWndDlg, IDC_TEXTUREFILTER, CB_ADDSTRING, 0, (LPARAM) "Hqx");
- SendDlgItemMessage(hWndDlg, IDC_TEXTUREFILTER, CB_SETCURSEL, (int)OGL.textureFilter, 0);
- SendMessage(GetDlgItem(hWndDlg, IDC_FSCALE), TBM_SETPOS, TRUE, OGL.filterScale);
+ SendDlgItemMessage(hWndDlg, IDC_WINDOWED_X, WM_SETTEXT, 0, (LPARAM)std::to_wstring(OGL.windowedWidth).c_str());
+ SendDlgItemMessage(hWndDlg, IDC_WINDOWED_Y, WM_SETTEXT, 0, (LPARAM)std::to_wstring(OGL.windowedHeight).c_str());
+
+ if (custom)
+ {
+ int num = SendDlgItemMessage(hWndDlg, IDC_WINDOWEDRES, CB_GETCOUNT, 0, 0) - 1;
+ EnableCustom(hWndDlg, TRUE);
+ SendDlgItemMessage(hWndDlg, IDC_WINDOWEDRES, CB_SETCURSEL, num, 0);
+ }
- SendDlgItemMessage(hWndDlg, IDC_FORCEBILINEAR, BM_SETCHECK, OGL.forceBilinear ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL);
- SendDlgItemMessage(hWndDlg, IDC_SCISSOR, BM_SETCHECK, OGL.ignoreScissor ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL);
- SendDlgItemMessage(hWndDlg, IDC_CLEAR, BM_SETCHECK, OGL.clear_override ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL);
+ SendDlgItemMessage(hWndDlg, IDC_TEXTUREFILTER, CB_ADDSTRING, 0, (LPARAM)L"None");
+ SendDlgItemMessage(hWndDlg, IDC_TEXTUREFILTER, CB_ADDSTRING, 0, (LPARAM)L"2xSaI");
+ SendDlgItemMessage(hWndDlg, IDC_TEXTUREFILTER, CB_ADDSTRING, 0, (LPARAM)L"xBRZ");
+ SendDlgItemMessage(hWndDlg, IDC_TEXTUREFILTER, CB_ADDSTRING, 0, (LPARAM)L"Hqx");
+ SendDlgItemMessage(hWndDlg, IDC_TEXTUREFILTER, CB_SETCURSEL, (int)OGL.textureFilter, 0);
+ SendMessage(GetDlgItem(hWndDlg, IDC_FSCALE), TBM_SETPOS, TRUE, OGL.filterScale);
- ComboBox_AddString(GetDlgItem(hWndDlg, IDC_COMBINER), "Autodetect");
- ComboBox_AddString(GetDlgItem(hWndDlg, IDC_COMBINER), "TEXTURE_ENV");
- ComboBox_AddString(GetDlgItem(hWndDlg, IDC_COMBINER), "TEXTURE_ENV_COMBINE");
- ComboBox_AddString(GetDlgItem(hWndDlg, IDC_COMBINER), "NV_REGISTER_COMBINERS");
- ComboBox_SetCurSel(GetDlgItem(hWndDlg, IDC_COMBINER), OGL.combiner);
+ SendDlgItemMessage(hWndDlg, IDC_FORCEBILINEAR, BM_SETCHECK, OGL.forceBilinear ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL);
+ SendDlgItemMessage(hWndDlg, IDC_SCISSOR, BM_SETCHECK, OGL.ignoreScissor ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL);
+ SendDlgItemMessage(hWndDlg, IDC_CLEAR, BM_SETCHECK, OGL.clear_override ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL);
- // Enable/disable fog
- SendDlgItemMessage(hWndDlg, IDC_FOG, BM_SETCHECK, OGL.fog ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL);
+ ComboBox_AddString(GetDlgItem(hWndDlg, IDC_COMBINER), L"Autodetect");
+ ComboBox_AddString(GetDlgItem(hWndDlg, IDC_COMBINER), L"TEXTURE_ENV");
+ ComboBox_AddString(GetDlgItem(hWndDlg, IDC_COMBINER), L"TEXTURE_ENV_COMBINE");
+ ComboBox_AddString(GetDlgItem(hWndDlg, IDC_COMBINER), L"NV_REGISTER_COMBINERS");
+ ComboBox_SetCurSel(GetDlgItem(hWndDlg, IDC_COMBINER), OGL.combiner);
- SendDlgItemMessage(hWndDlg, IDC_DITHEREDALPHATEST, BM_SETCHECK, OGL.usePolygonStipple ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL);
+ // Enable/disable fog
+ SendDlgItemMessage(hWndDlg, IDC_FOG, BM_SETCHECK, OGL.fog ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL);
- _ltoa(cache.maxBytes / 1048576, text, 10);
- SendDlgItemMessage(hWndDlg, IDC_CACHEMEGS, WM_SETTEXT, NULL, (LPARAM)text);
+ SendDlgItemMessage(hWndDlg, IDC_DITHEREDALPHATEST, BM_SETCHECK, OGL.usePolygonStipple ? (LPARAM)BST_CHECKED : (LPARAM)BST_UNCHECKED, NULL);
- SendMessage(hWndDlg, WM_COMMAND,
- MAKEWPARAM(IDC_TEXTUREFILTER, CBN_SELCHANGE),
- (LPARAM)GetDlgItem(hWndDlg, IDC_TEXTUREFILTER));
+ const auto cache_size = std::to_wstring(cache.maxBytes / 1048576);
+ SendDlgItemMessage(hWndDlg, IDC_CACHEMEGS, WM_SETTEXT, NULL, (LPARAM)cache_size.c_str());
- return TRUE;
+ SendMessage(hWndDlg, WM_COMMAND,
+ MAKEWPARAM(IDC_TEXTUREFILTER, CBN_SELCHANGE),
+ (LPARAM)GetDlgItem(hWndDlg, IDC_TEXTUREFILTER));
+ return TRUE;
+ }
case WM_COMMAND:
switch (LOWORD(wParam))
{
diff --git a/src/Debug.cpp b/src/Debug.cpp
index f996225..122e607 100644
--- a/src/Debug.cpp
+++ b/src/Debug.cpp
@@ -18,7 +18,7 @@ NULL,
RGB(0, 0, 0),
NULL,
NULL,
-"Courier New"};
+L"Courier New"};
CHARFORMAT unknownFormat =
{
@@ -30,7 +30,7 @@ NULL,
RGB(128, 128, 0),
NULL,
NULL,
-"Courier New"};
+L"Courier New"};
CHARFORMAT errorFormat =
{
@@ -42,7 +42,7 @@ NULL,
RGB(128, 0, 0),
NULL,
NULL,
-"Courier New"};
+L"Courier New"};
CHARFORMAT detailFormat =
{
@@ -54,7 +54,7 @@ NULL,
RGB(0, 128, 0),
NULL,
NULL,
-"Courier New"};
+L"Courier New"};
HWND hDebugDlg;
BOOL DumpMessages;
@@ -177,7 +177,7 @@ INT_PTR CALLBACK DebugDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
void DebugDlgThreadFunc(void*)
{
- LoadLibrary("RichEd20.dll");
+ LoadLibrary(L"RichEd20.dll");
hDebugDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DEBUGDLG), hWnd, DebugDlgProc);
MSG msg;
diff --git a/src/MiscHelpers.h b/src/MiscHelpers.h
new file mode 100644
index 0000000..b7eaf50
--- /dev/null
+++ b/src/MiscHelpers.h
@@ -0,0 +1,32 @@
+#pragma once
+
+namespace MiscHelpers
+{
+ inline std::wstring string_to_wstring(const std::string& str)
+ {
+#ifdef _WIN32
+ int size_needed = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, nullptr, 0);
+ if (size_needed <= 0)
+ return L"";
+
+ std::wstring wstr(size_needed, 0);
+ MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, &wstr[0], size_needed);
+ wstr.pop_back();
+ return wstr;
+#endif
+ }
+
+ inline std::string wstring_to_string(const std::wstring& wstr)
+ {
+#ifdef _WIN32
+ int size_needed = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, nullptr, 0, nullptr, nullptr);
+ if (size_needed <= 0)
+ return "";
+
+ std::string str(size_needed, 0);
+ WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &str[0], size_needed, nullptr, nullptr);
+ str.pop_back();
+ return str;
+#endif
+ }
+}; // namespace MiscHelpers
diff --git a/src/OpenGL.cpp b/src/OpenGL.cpp
index 1ebfbb1..400c1aa 100644
--- a/src/OpenGL.cpp
+++ b/src/OpenGL.cpp
@@ -9,6 +9,8 @@
#include "Combiner.h"
#include "VI.h"
+#include
+
GLInfo OGL{};
void* gCapturedPixels; // pointer to buffer to fill
@@ -186,33 +188,33 @@ bool OGL_InitContext()
if ((OGL.hDC = GetDC(hWnd)) == NULL)
{
- MessageBox(hWnd, "Error while getting a device context!", PLUGIN_NAME, MB_ICONERROR | MB_OK);
+ MessageBox(hWnd, L"Error while getting a device context!", PLUGIN_NAME, MB_ICONERROR | MB_OK);
return FALSE;
}
if ((pixelFormat = ChoosePixelFormat(OGL.hDC, &pfd)) == 0)
{
- MessageBox(hWnd, "Unable to find a suitable pixel format!", PLUGIN_NAME, MB_ICONERROR | MB_OK);
+ MessageBox(hWnd, L"Unable to find a suitable pixel format!", PLUGIN_NAME, MB_ICONERROR | MB_OK);
OGL_Stop();
return FALSE;
}
if ((SetPixelFormat(OGL.hDC, pixelFormat, &pfd)) == FALSE)
{
- MessageBox(hWnd, "Error while setting pixel format!", PLUGIN_NAME, MB_ICONERROR | MB_OK);
+ MessageBox(hWnd, L"Error while setting pixel format!", PLUGIN_NAME, MB_ICONERROR | MB_OK);
OGL_Stop();
return FALSE;
}
if ((OGL.hRC = wglCreateContext(OGL.hDC)) == NULL)
{
- MessageBox(hWnd, "Error while creating OpenGL context!", PLUGIN_NAME, MB_ICONERROR | MB_OK);
+ MessageBox(hWnd, L"Error while creating OpenGL context!", PLUGIN_NAME, MB_ICONERROR | MB_OK);
OGL_Stop();
return FALSE;
}
if ((wglMakeCurrent(OGL.hDC, OGL.hRC)) == FALSE)
{
- MessageBox(hWnd, "Error while making OpenGL context current!", PLUGIN_NAME, MB_ICONERROR | MB_OK);
+ MessageBox(hWnd, L"Error while making OpenGL context current!", PLUGIN_NAME, MB_ICONERROR | MB_OK);
OGL_Stop();
return FALSE;
}
@@ -870,23 +872,11 @@ void OGL_SaveScreenshot()
fileHeader.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + infoHeader.biSizeImage;
fileHeader.bfReserved1 = fileHeader.bfReserved2 = 0;
fileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
+
+ CreateDirectory(screenDirectory.c_str(), NULL);
- char filename[256];
-
- CreateDirectory(screenDirectory, NULL);
-
- int i = 0;
- do
- {
- sprintf(filename, "%sscreen%02i.bmp", screenDirectory, i);
- i++;
-
- if (i > 99)
- return;
-
- hBitmapFile = CreateFile(filename, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
- }
- while (hBitmapFile == INVALID_HANDLE_VALUE);
+ const auto filename = std::format(L"{}screen{}.bmp", screenDirectory.wstring(), time(nullptr));
+ hBitmapFile = CreateFile(filename.c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
DWORD written;
diff --git a/src/glN64.cpp b/src/glN64.cpp
index 5ba4b98..a736882 100644
--- a/src/glN64.cpp
+++ b/src/glN64.cpp
@@ -4,13 +4,14 @@
#include "N64.h"
#include "RSP.h"
#include "Config.h"
+#include "MiscHelpers.h"
HWND hWnd;
HWND hStatusBar;
HWND hToolBar;
HINSTANCE hInstance;
-char* screenDirectory;
+std::filesystem::path screenDirectory;
void (*CheckInterrupts)(void);
@@ -33,7 +34,7 @@ bool init_rsp_thread()
i = CreateEvent(NULL, FALSE, FALSE, NULL);
if (i == nullptr)
{
- MessageBox(hWnd, "Error creating video thread message events.", PLUGIN_NAME, MB_OK | MB_ICONERROR);
+ MessageBox(hWnd, L"Error creating video thread message events.", PLUGIN_NAME, MB_OK | MB_ICONERROR);
return false;
}
}
@@ -41,7 +42,7 @@ bool init_rsp_thread()
RSP.threadFinished = CreateEvent(NULL, FALSE, FALSE, NULL);
if (RSP.threadFinished == NULL)
{
- MessageBox(hWnd, "Error creating video thread finished event.", PLUGIN_NAME, MB_OK | MB_ICONERROR);
+ MessageBox(hWnd, L"Error creating video thread finished event.", PLUGIN_NAME, MB_OK | MB_ICONERROR);
return false;
}
@@ -98,7 +99,7 @@ EXPORT void CALL GetDllInfo(core_plugin_info* PluginInfo)
{
PluginInfo->ver = 0x100;
PluginInfo->type = plugin_video;
- strcpy(PluginInfo->name, PLUGIN_NAME);
+ strcpy(PluginInfo->name, MiscHelpers::wstring_to_string(PLUGIN_NAME).c_str());
PluginInfo->unused_normal_memory = FALSE;
PluginInfo->unused_byteswapped = TRUE;
}
diff --git a/src/glN64.h b/src/glN64.h
index ce0840c..4612a57 100644
--- a/src/glN64.h
+++ b/src/glN64.h
@@ -1,5 +1,6 @@
#ifndef GLN64_H
#define GLN64_H
+#include
extern HWND hWnd;
extern HWND hStatusBar;
@@ -7,22 +8,22 @@ extern HWND hToolBar;
extern HINSTANCE hInstance;
extern void (*CheckInterrupts)(void);
-extern char* screenDirectory;
+extern std::filesystem::path screenDirectory;
-#define PLUGIN_VERSION "1.4-rc2"
+#define PLUGIN_VERSION L"1.4-rc2"
#ifdef _M_X64
-#define PLUGIN_ARCH "-x64"
+#define PLUGIN_ARCH L"-x64"
#else
-#define PLUGIN_ARCH "-x86"
+#define PLUGIN_ARCH L"-x86"
#endif
#ifdef _DEBUG
-#define PLUGIN_TARGET "-debug"
+#define PLUGIN_TARGET L"-debug"
#else
-#define PLUGIN_TARGET "-release"
+#define PLUGIN_TARGET L"-release"
#endif
-#define PLUGIN_NAME "bettergln " PLUGIN_VERSION PLUGIN_ARCH PLUGIN_TARGET
+#define PLUGIN_NAME L"bettergln " PLUGIN_VERSION PLUGIN_ARCH PLUGIN_TARGET
#endif