1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 06:04:49 +01:00

merge opengl core and direct3d9on12 into renderer= setting

This commit is contained in:
FunkyFr3sh 2023-08-08 17:45:19 +02:00
parent 63c13d8a63
commit 54f23331e8
4 changed files with 234 additions and 218 deletions

View File

@ -597,7 +597,15 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender)
auto renderer = LowerCase(ini->ReadString("ddraw", "renderer", "auto"));
if (StartsStr("d", renderer)) {
if (renderer == "direct3d9on12") {
RendererCbx->AddItem(L"Direct3D 12 (9On12)", NULL);
RendererCbx->ItemIndex = 4;
}
else if (renderer == "openglcore") {
RendererCbx->AddItem(L"OpenGL Core", NULL);
RendererCbx->ItemIndex = 4;
}
else if (StartsStr("d", renderer)) {
RendererCbx->ItemIndex = 1;
}
else if (StartsStr("o", renderer)) {
@ -767,6 +775,14 @@ void TConfigForm::SaveSettings()
case 3:
ini->WriteString("ddraw", "renderer", "gdi");
break;
case 4:
if (RendererCbx->Text == "OpenGL Core") {
ini->WriteString("ddraw", "renderer", "openglcore");
}
else {
ini->WriteString("ddraw", "renderer", "direct3d9on12");
}
break;
default:
break;
}

View File

@ -2681,200 +2681,6 @@ object ConfigForm: TConfigForm
OnActivate = FormActivate
OnCreate = FormCreate
TextHeight = 13
object AdvancedPnl: TPanel
Left = 233
Top = 8
Width = 499
Height = 465
BevelOuter = bvNone
Color = clWhite
ParentBackground = False
ShowCaption = False
TabOrder = 2
Visible = False
StyleElements = [seFont, seBorder]
object RendererLbl: TLabel
Left = 40
Top = 28
Width = 64
Height = 21
Caption = 'Renderer'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object SavesettingsLbl: TLabel
Left = 40
Top = 386
Width = 256
Height = 21
Margins.Top = 18
Caption = 'Remember window position and size'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object ShaderLbl: TLabel
Left = 40
Top = 105
Width = 108
Height = 21
Margins.Top = 18
Caption = 'OpenGL shader'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object MaxfpsLbl: TLabel
Left = 40
Top = 182
Width = 111
Height = 21
Margins.Top = 18
Caption = 'Limit frame rate'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object BorderLbl: TLabel
Left = 40
Top = 318
Width = 293
Height = 21
Margins.Top = 18
Caption = 'Show window borders in windowed mode'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object BoxingLbl: TLabel
Left = 40
Top = 250
Width = 267
Height = 21
Margins.Top = 18
Caption = 'Enable windowboxing / integer scaling'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object RendererPbox: TPaintBox
Left = 40
Top = 54
Width = 207
Height = 31
OnPaint = PboxPaint
end
object ShaderPbox: TPaintBox
Left = 40
Top = 131
Width = 427
Height = 31
OnPaint = PboxPaint
end
object RendererCbx: TComboBox
Left = 41
Top = 55
Width = 205
Height = 29
BevelEdges = []
BevelInner = bvNone
BevelOuter = bvSpace
Style = csDropDownList
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
TabOrder = 0
OnChange = RendererCbxChange
Items.Strings = (
'Automatic'
'Direct3D 9'
'OpenGL'
'GDI')
end
object BorderChk: TToggleSwitch
Left = 40
Top = 345
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 1
OnClick = BorderChkClick
end
object SavesettingsChk: TToggleSwitch
Left = 40
Top = 413
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 2
OnClick = SavesettingsChkClick
end
object ShaderCbx: TComboBox
Left = 41
Top = 132
Width = 425
Height = 29
BevelEdges = []
BevelInner = bvNone
BevelOuter = bvSpace
Style = csDropDownList
DropDownCount = 10
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
TabOrder = 3
OnChange = ShaderCbxChange
end
object MaxfpsChk: TToggleSwitch
Left = 40
Top = 209
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 4
OnClick = MaxfpsChkClick
end
object BoxingChk: TToggleSwitch
Left = 40
Top = 277
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 5
OnClick = BoxingChkClick
end
end
object DisplayPnl: TPanel
Left = 233
Top = 8
@ -3245,6 +3051,200 @@ object ConfigForm: TConfigForm
OnClick = NonexclusiveChkClick
end
end
object AdvancedPnl: TPanel
Left = 233
Top = 8
Width = 499
Height = 465
BevelOuter = bvNone
Color = clWhite
ParentBackground = False
ShowCaption = False
TabOrder = 2
Visible = False
StyleElements = [seFont, seBorder]
object RendererLbl: TLabel
Left = 40
Top = 28
Width = 64
Height = 21
Caption = 'Renderer'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object SavesettingsLbl: TLabel
Left = 40
Top = 386
Width = 256
Height = 21
Margins.Top = 18
Caption = 'Remember window position and size'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object ShaderLbl: TLabel
Left = 40
Top = 105
Width = 108
Height = 21
Margins.Top = 18
Caption = 'OpenGL shader'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object MaxfpsLbl: TLabel
Left = 40
Top = 182
Width = 111
Height = 21
Margins.Top = 18
Caption = 'Limit frame rate'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object BorderLbl: TLabel
Left = 40
Top = 318
Width = 293
Height = 21
Margins.Top = 18
Caption = 'Show window borders in windowed mode'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object BoxingLbl: TLabel
Left = 40
Top = 250
Width = 267
Height = 21
Margins.Top = 18
Caption = 'Enable windowboxing / integer scaling'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object RendererPbox: TPaintBox
Left = 40
Top = 54
Width = 207
Height = 31
OnPaint = PboxPaint
end
object ShaderPbox: TPaintBox
Left = 40
Top = 131
Width = 427
Height = 31
OnPaint = PboxPaint
end
object RendererCbx: TComboBox
Left = 41
Top = 55
Width = 205
Height = 29
BevelEdges = []
BevelInner = bvNone
BevelOuter = bvSpace
Style = csDropDownList
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
TabOrder = 0
OnChange = RendererCbxChange
Items.Strings = (
'Automatic'
'Direct3D 9'
'OpenGL'
'GDI')
end
object BorderChk: TToggleSwitch
Left = 40
Top = 345
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 1
OnClick = BorderChkClick
end
object SavesettingsChk: TToggleSwitch
Left = 40
Top = 413
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 2
OnClick = SavesettingsChkClick
end
object ShaderCbx: TComboBox
Left = 41
Top = 132
Width = 425
Height = 29
BevelEdges = []
BevelInner = bvNone
BevelOuter = bvSpace
Style = csDropDownList
DropDownCount = 10
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
TabOrder = 3
OnChange = ShaderCbxChange
end
object MaxfpsChk: TToggleSwitch
Left = 40
Top = 209
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 4
OnClick = MaxfpsChkClick
end
object BoxingChk: TToggleSwitch
Left = 40
Top = 277
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 5
OnClick = BoxingChkClick
end
end
object MenuPnl: TPanel
Left = 0
Top = 8

View File

@ -19,12 +19,11 @@ CNCDDRAWCONFIG g_config =
void cfg_load()
{
char tmp[256];
cfg_init();
/* load settings from ini */
g_ddraw->windowed = cfg_get_bool("windowed", FALSE);
g_ddraw->fullscreen = cfg_get_bool("fullscreen", FALSE);
g_ddraw->border = cfg_get_bool("border", TRUE);
g_ddraw->boxing = cfg_get_bool("boxing", FALSE);
g_ddraw->maintas = cfg_get_bool("maintas", FALSE);
@ -42,13 +41,11 @@ void cfg_load()
g_ddraw->lock_surfaces = cfg_get_bool("lock_surfaces", FALSE);
g_ddraw->releasealt = cfg_get_bool("releasealt", FALSE);
g_ddraw->d3d9_filter = cfg_get_int("d3d9_filter", FILTER_CUBIC);
g_ddraw->d3d9on12 = cfg_get_bool("d3d9on12", FALSE);
g_ddraw->resolutions = cfg_get_int("resolutions", RESLIST_NORMAL);
g_ddraw->allow_wmactivate = cfg_get_bool("allow_wmactivate", FALSE);
g_ddraw->guard_lines = cfg_get_int("guard_lines", 200);
g_ddraw->max_resolutions = cfg_get_int("max_resolutions", 0);
g_ddraw->limit_bltfast = cfg_get_bool("limit_bltfast", FALSE);
g_ddraw->opengl_core = cfg_get_bool("opengl_core", FALSE);
g_ddraw->rgb555 = cfg_get_bool("rgb555", FALSE);
g_ddraw->hook_peekmessage = cfg_get_bool("hook_peekmessage", FALSE);
cfg_get_string("screenshotdir", ".\\Screenshots\\", g_ddraw->screenshot_dir, sizeof(g_ddraw->screenshot_dir));
@ -114,8 +111,6 @@ void cfg_load()
g_ddraw->flip_limiter.tick_length = (DWORD)(flip_len + 0.5f);
}
g_ddraw->fullscreen = cfg_get_bool("fullscreen", FALSE);
if (cfg_get_bool("singlecpu", TRUE))
{
SetProcessAffinityMask(GetCurrentProcess(), 1);
@ -133,18 +128,29 @@ void cfg_load()
/* to do: read .glslp config file instead of the shader and apply the correct settings */
cfg_get_string("shader", "Shaders\\cubic\\catmull-rom-bilinear.glsl", g_ddraw->shader, sizeof(g_ddraw->shader));
cfg_get_string("renderer", "auto", tmp, sizeof(tmp));
TRACE(" Using %s renderer\n", tmp);
char renderer[256] = {0};
cfg_get_string("renderer", "auto", renderer, sizeof(renderer));
if (tolower(tmp[0]) == 'd' || g_ddraw->d3d9on12) /* direct3d9 */
TRACE(" Using %s renderer\n", renderer);
if (_strcmpi(renderer, "direct3d9on12") == 0)
{
g_ddraw->d3d9on12 = TRUE;
}
else if (_strcmpi(renderer, "openglcore") == 0)
{
g_ddraw->opengl_core = TRUE;
}
if (tolower(renderer[0]) == 'd') /* direct3d9 or direct3d9on12*/
{
g_ddraw->renderer = d3d9_render_main;
}
else if (tolower(tmp[0]) == 's' || tolower(tmp[0]) == 'g') /* gdi */
else if (tolower(renderer[0]) == 's' || tolower(renderer[0]) == 'g') /* gdi */
{
g_ddraw->renderer = gdi_render_main;
}
else if (tolower(tmp[0]) == 'o') /* opengl */
else if (tolower(renderer[0]) == 'o') /* opengl or openglcore */
{
if (oglu_load_dll())
{
@ -251,7 +257,7 @@ static void cfg_create_ini()
"; Note: Does not have an impact on the game speed, to limit your game speed use 'maxgameticks='\n"
"maxfps=-1\n"
"\n"
"; Vertical synchronization, enable if you get tearing - (Requires 'renderer=auto/opengl/direct3d9')\n"
"; Vertical synchronization, enable if you get tearing - (Requires 'renderer=auto/opengl*/direct3d9*')\n"
"; Note: vsync=true can fix tearing but it will cause input lag\n"
"vsync=false\n"
"\n"
@ -259,7 +265,7 @@ static void cfg_create_ini()
"; Note: Only works if stretching is enabled. Sensitivity will be adjusted according to the size of the window\n"
"adjmouse=true\n"
"\n"
"; Preliminary libretro shader support - (Requires 'renderer=opengl') https://github.com/libretro/glsl-shaders\n"
"; Preliminary libretro shader support - (Requires 'renderer=opengl*') https://github.com/libretro/glsl-shaders\n"
"; 2x scaling example: https://imgur.com/a/kxsM1oY - 4x scaling example: https://imgur.com/a/wjrhpFV\n"
"shader=Shaders\\cubic\\catmull-rom-bilinear.glsl\n"
"\n"
@ -267,7 +273,7 @@ static void cfg_create_ini()
"posX=-32000\n"
"posY=-32000\n"
"\n"
"; Renderer, possible values: auto, opengl, gdi, direct3d9 (auto = try direct3d9/opengl, fallback = gdi)\n"
"; Renderer, possible values: auto, opengl, openglcore, gdi, direct3d9, direct3d9on12 (auto = try direct3d9/opengl, fallback = gdi)\n"
"renderer=auto\n"
"\n"
"; Developer mode (don't lock the cursor)\n"
@ -283,7 +289,7 @@ static void cfg_create_ini()
"; Should the window be resizable by the user in windowed mode?\n"
"resizable=true\n"
"\n"
"; Upscaling filter for the direct3d9 renderer\n"
"; Upscaling filter for the direct3d9* renderers\n"
"; Possible values: 0 = nearest-neighbor, 1 = bilinear, 2 = bicubic (16/32bit color depth games only)\n"
"d3d9_filter=2\n"
"\n"
@ -322,7 +328,7 @@ static void cfg_create_ini()
"; Note: Set this to a low value such as 5 or 10 if some parts of the game are not being displayed (e.g. menus or loading screens)\n"
"minfps=0\n"
"\n"
"; Disable fullscreen-exclusive mode for the direct3d9/opengl renderers\n"
"; Disable fullscreen-exclusive mode for the direct3d9*/opengl* renderers\n"
"; Note: Can be used in case some GUI elements like buttons/textboxes/videos/etc.. are invisible\n"
"nonexclusive=false\n"
"\n"
@ -339,8 +345,6 @@ static void cfg_create_ini()
"\n"
"\n"
"; Undocumented settings\n"
"opengl_core=false\n"
"d3d9on12=false\n"
"guard_lines=200\n"
"max_resolutions=0\n"
"limit_bltfast=false\n"

View File

@ -65,16 +65,12 @@ BOOL d3d9_create()
args.Enable9On12 = TRUE;
IDirect3D9* (WINAPI * d3d_create9on12)(INT, D3D9ON12_ARGS*, UINT) = NULL;
IDirect3D9* (WINAPI * d3d_create9)(UINT) = NULL;
IDirect3D9* (WINAPI * d3d_create9)(UINT) = (void*)real_GetProcAddress(g_d3d9.hmodule, "Direct3DCreate9");
if (g_ddraw->d3d9on12)
{
d3d_create9on12 = (void*)real_GetProcAddress(g_d3d9.hmodule, "Direct3DCreate9On12");
}
else
{
d3d_create9 = (void*)real_GetProcAddress(g_d3d9.hmodule, "Direct3DCreate9");
}
if ((d3d_create9on12 && (d3d9on12 = g_d3d9.instance = d3d_create9on12(D3D_SDK_VERSION, &args, 1))) ||
(d3d_create9 && (g_d3d9.instance = d3d_create9(D3D_SDK_VERSION))))