diff --git a/VisualC-WinRT/SDL-UWP.sln b/VisualC-WinRT/SDL-UWP.sln index 62f9f0417..bb6346c73 100644 --- a/VisualC-WinRT/SDL-UWP.sln +++ b/VisualC-WinRT/SDL-UWP.sln @@ -1,10 +1,12 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.33027.164 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL3-UWP", "SDL-UWP.vcxproj", "{89E9B32E-A86A-47C3-A948-D2B1622925CE}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestDraw2", "TestDraw2\TestDraw2.vcxproj", "{95943BBE-F378-4068-A3FD-DAE1B8309B6E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM @@ -33,8 +35,35 @@ Global {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x64.Build.0 = Release|x64 {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x86.ActiveCfg = Release|Win32 {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x86.Build.0 = Release|Win32 + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|ARM.ActiveCfg = Debug|ARM + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|ARM.Build.0 = Debug|ARM + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|ARM.Deploy.0 = Debug|ARM + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|ARM64.Build.0 = Debug|ARM64 + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|x64.ActiveCfg = Debug|x64 + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|x64.Build.0 = Debug|x64 + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|x64.Deploy.0 = Debug|x64 + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|x86.ActiveCfg = Debug|Win32 + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|x86.Build.0 = Debug|Win32 + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|x86.Deploy.0 = Debug|Win32 + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|ARM.ActiveCfg = Release|ARM + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|ARM.Build.0 = Release|ARM + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|ARM.Deploy.0 = Release|ARM + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|ARM64.ActiveCfg = Release|ARM64 + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|ARM64.Build.0 = Release|ARM64 + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|ARM64.Deploy.0 = Release|ARM64 + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|x64.ActiveCfg = Release|x64 + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|x64.Build.0 = Release|x64 + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|x64.Deploy.0 = Release|x64 + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|x86.ActiveCfg = Release|Win32 + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|x86.Build.0 = Release|Win32 + {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|x86.Deploy.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {30680F51-7BB9-41D0-A0D6-BC44A1557D87} + EndGlobalSection EndGlobal diff --git a/VisualC-WinRT/SDL-UWP.vcxproj b/VisualC-WinRT/SDL-UWP.vcxproj index dd18fe91e..09e22b53a 100644 --- a/VisualC-WinRT/SDL-UWP.vcxproj +++ b/VisualC-WinRT/SDL-UWP.vcxproj @@ -62,6 +62,7 @@ + diff --git a/VisualC-WinRT/SDL-UWP.vcxproj.filters b/VisualC-WinRT/SDL-UWP.vcxproj.filters index 6efea895e..65dd7e2f2 100644 --- a/VisualC-WinRT/SDL-UWP.vcxproj.filters +++ b/VisualC-WinRT/SDL-UWP.vcxproj.filters @@ -822,6 +822,9 @@ Source Files + + Header Files + diff --git a/VisualC-WinRT/TestDraw2/Assets/LockScreenLogo.scale-200.png b/VisualC-WinRT/TestDraw2/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 000000000..735f57adb Binary files /dev/null and b/VisualC-WinRT/TestDraw2/Assets/LockScreenLogo.scale-200.png differ diff --git a/VisualC-WinRT/TestDraw2/Assets/SplashScreen.scale-200.png b/VisualC-WinRT/TestDraw2/Assets/SplashScreen.scale-200.png new file mode 100644 index 000000000..023e7f1fe Binary files /dev/null and b/VisualC-WinRT/TestDraw2/Assets/SplashScreen.scale-200.png differ diff --git a/VisualC-WinRT/TestDraw2/Assets/Square150x150Logo.scale-200.png b/VisualC-WinRT/TestDraw2/Assets/Square150x150Logo.scale-200.png new file mode 100644 index 000000000..af49fec1a Binary files /dev/null and b/VisualC-WinRT/TestDraw2/Assets/Square150x150Logo.scale-200.png differ diff --git a/VisualC-WinRT/TestDraw2/Assets/Square44x44Logo.scale-200.png b/VisualC-WinRT/TestDraw2/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 000000000..ce342a2ec Binary files /dev/null and b/VisualC-WinRT/TestDraw2/Assets/Square44x44Logo.scale-200.png differ diff --git a/VisualC-WinRT/TestDraw2/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/VisualC-WinRT/TestDraw2/Assets/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 000000000..f6c02ce97 Binary files /dev/null and b/VisualC-WinRT/TestDraw2/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/VisualC-WinRT/TestDraw2/Assets/StoreLogo.png b/VisualC-WinRT/TestDraw2/Assets/StoreLogo.png new file mode 100644 index 000000000..7385b56c0 Binary files /dev/null and b/VisualC-WinRT/TestDraw2/Assets/StoreLogo.png differ diff --git a/VisualC-WinRT/TestDraw2/Assets/Wide310x150Logo.scale-200.png b/VisualC-WinRT/TestDraw2/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 000000000..288995b39 Binary files /dev/null and b/VisualC-WinRT/TestDraw2/Assets/Wide310x150Logo.scale-200.png differ diff --git a/VisualC-WinRT/TestDraw2/Package.appxmanifest b/VisualC-WinRT/TestDraw2/Package.appxmanifest new file mode 100644 index 000000000..f04c9ffc4 --- /dev/null +++ b/VisualC-WinRT/TestDraw2/Package.appxmanifest @@ -0,0 +1,49 @@ + + + + + + + + + + TestDraw2 + Daniel + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VisualC-WinRT/TestDraw2/TestDraw2.vcxproj b/VisualC-WinRT/TestDraw2/TestDraw2.vcxproj new file mode 100644 index 000000000..9de6beae4 --- /dev/null +++ b/VisualC-WinRT/TestDraw2/TestDraw2.vcxproj @@ -0,0 +1,336 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + + {95943bbe-f378-4068-a3fd-dae1b8309b6e} + DirectXApp + TestDraw2 + en-US + 14.0 + true + Windows Store + 10.0.19041.0 + 10.0.17763.0 + 10.0 + false + + + + Application + true + v142 + + + Application + true + v142 + + + Application + true + v142 + true + + + Application + true + v142 + + + Application + false + true + v142 + true + + + Application + false + true + v142 + true + + + Application + false + true + v142 + true + + + Application + false + true + v142 + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\arm; $(VCInstallDir)\lib\arm + /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) + + + pch.h + $(IntDir)pch.pch + $(ProjectDir);$(IntermediateOutputPath);..\..\include + /bigobj %(AdditionalOptions) + 4453;28204 + _DEBUG;%(PreprocessorDefinitions) + false + NotUsing + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\arm; $(VCInstallDir)\lib\arm + /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) + + + pch.h + $(IntDir)pch.pch + $(ProjectDir);$(IntermediateOutputPath);..\..\include + /bigobj %(AdditionalOptions) + 4453;28204 + NDEBUG;%(PreprocessorDefinitions) + false + NotUsing + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\arm64; $(VCInstallDir)\lib\arm64 + /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) + + + pch.h + $(IntDir)pch.pch + $(ProjectDir);$(IntermediateOutputPath);..\..\include + /bigobj %(AdditionalOptions) + 4453;28204 + _DEBUG;%(PreprocessorDefinitions) + false + NotUsing + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\arm64; $(VCInstallDir)\lib\arm64 + /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) + + + pch.h + $(IntDir)pch.pch + $(ProjectDir);$(IntermediateOutputPath);..\..\include + /bigobj %(AdditionalOptions) + 4453;28204 + NDEBUG;%(PreprocessorDefinitions) + false + NotUsing + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store; $(VCInstallDir)\lib + /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) + + + pch.h + $(IntDir)pch.pch + $(ProjectDir);$(IntermediateOutputPath);..\..\include + /bigobj %(AdditionalOptions) + 4453;28204 + _DEBUG;%(PreprocessorDefinitions) + false + NotUsing + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store; $(VCInstallDir)\lib + /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) + + + pch.h + $(IntDir)pch.pch + $(ProjectDir);$(IntermediateOutputPath);..\..\include + /bigobj %(AdditionalOptions) + 4453;28204 + NDEBUG;%(PreprocessorDefinitions) + false + NotUsing + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\amd64; $(VCInstallDir)\lib\amd64 + /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) + + + pch.h + $(IntDir)pch.pch + $(ProjectDir);$(IntermediateOutputPath);..\..\include + /bigobj %(AdditionalOptions) + 4453;28204 + _DEBUG;%(PreprocessorDefinitions) + false + NotUsing + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\amd64; $(VCInstallDir)\lib\amd64 + /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) + + + pch.h + $(IntDir)pch.pch + $(ProjectDir);$(IntermediateOutputPath);..\..\include + /bigobj %(AdditionalOptions) + 4453;28204 + NDEBUG;%(PreprocessorDefinitions) + false + NotUsing + + + + + + + + + + + + + + Designer + + + + + {89e9b32e-a86a-47c3-a948-d2b1622925ce} + + + + + + + + + + + + + + + + + + + + + true + true + true + true + true + true + true + true + + + false + false + false + false + false + false + false + false + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VisualC-WinRT/TestDraw2/TestDraw2.vcxproj.filters b/VisualC-WinRT/TestDraw2/TestDraw2.vcxproj.filters new file mode 100644 index 000000000..841b7e832 --- /dev/null +++ b/VisualC-WinRT/TestDraw2/TestDraw2.vcxproj.filters @@ -0,0 +1,103 @@ + + + + + 95943bbe-f378-4068-a3fd-dae1b8309b6e + + + dad3d573-ab33-428d-ae70-6098066c27e7 + bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png + + + e4caa635-e149-44c2-8915-48ffa6ac48f7 + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + + + Assets + + + + + + + + Content + + + Content + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + + + + + + + \ No newline at end of file diff --git a/docs/README-winrt.md b/docs/README-winrt.md index 3d7cfea03..6f9d49d13 100644 --- a/docs/README-winrt.md +++ b/docs/README-winrt.md @@ -71,10 +71,9 @@ Here is a rough list of what works, and what doesn't: well as many keys with documented hardware scancodes. Converting SDL_Scancodes to or from SDL_Keycodes may not work, due to missing APIs (MapVirtualKey()) in Microsoft's Windows Store / UWP APIs. - * SDL_main. WinRT uses a different signature for each app's main() function. - SDL-based apps that use this port must compile in SDL_winrt_main_NonXAML.cpp - (in `SDL\src\main\winrt\`) directly in order for their C-style main() - functions to be called. + * SDL_main. WinRT uses a different signature for each app's main() function + and requires it to be implemented in C++, so SDL_main.h must be #include'd + in a C++ source file, that also must be compiled with /ZW. * What doesn't work: * compilation with anything other than Visual C++ @@ -240,7 +239,9 @@ To change these settings: 2. choose "Properties" 3. in the drop-down box next to "Configuration", choose, "All Configurations" 4. in the drop-down box next to "Platform", choose, "All Platforms" -5. in the left-hand list, expand the "C/C++" section +5. in the left-hand list, expand the "C/C++" section + **Note:** If you don't see this section, you may have to add a .c or .cpp + Source file to the Project first. 6. select "General" 7. edit the "Additional Include Directories" setting, and add a path to SDL's "include" directory @@ -271,16 +272,21 @@ To include these files for C/C++ projects: navigate to "Add", then choose "Existing Item...". 2. navigate to the directory containing SDL's source code, then into its subdirectory, 'src/main/winrt/'. Select, then add, the following files: - - `SDL_winrt_main_NonXAML.cpp` - `SDL3-WinRTResources.rc` - `SDL3-WinRTResource_BlankCursor.cur` -3. right-click on the file `SDL_winrt_main_NonXAML.cpp` (as listed in your - project), then click on "Properties...". -4. in the drop-down box next to "Configuration", choose, "All Configurations" -5. in the drop-down box next to "Platform", choose, "All Platforms" -6. in the left-hand list, click on "C/C++" -7. change the setting for "Consume Windows Runtime Extension" to "Yes (/ZW)". -8. click the OK button. This will close the dialog. +3. For the next step you need a C++ source file. + - If your standard main() function is implemented in a **C++** source file, + use that file. + - If your standard main() function is implemented in a **plain C** source file, + create an empty .cpp source file (e.g. `main.cpp`) that only contains the line + `#include ` and use that file instead. +4. Right click on the C++ source file from step 3 (as listed in your project), + then click on "Properties...". +5. in the drop-down box next to "Configuration", choose, "All Configurations" +6. in the drop-down box next to "Platform", choose, "All Platforms" +7. in the left-hand list, click on "C/C++" +8. change the setting for "Consume Windows Runtime Extension" to "Yes (/ZW)". +9. click the OK button. This will close the dialog. **NOTE: C++/CX compilation is currently required in at least one file of your app's project. This is to make sure that Visual C++'s linker builds a 'Windows @@ -322,7 +328,8 @@ your project, and open the file in Visual C++'s text editor. 7. Copy and paste the following code into the new file, then save it. ```c -#include +#include +#include int main(int argc, char **argv) { diff --git a/include/SDL3/SDL_main.h b/include/SDL3/SDL_main.h index d26b866de..f22903cac 100644 --- a/include/SDL3/SDL_main.h +++ b/include/SDL3/SDL_main.h @@ -284,11 +284,25 @@ extern DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void); #include -#if !defined(SDL_MAIN_HANDLED) && !defined(_SDL_MAIN_NOIMPL) +#if !defined(SDL_MAIN_HANDLED) && !defined(SDL_MAIN_NOIMPL) /* include header-only SDL_main implementations */ #if defined(__WIN32__) || defined(__GDK__) || defined(__IOS__) || defined(__TVOS__) /* TODO: other platforms */ #include -#endif +#elif defined(__WINRT__) /* TODO: other C++ platforms */ + +#ifdef __cplusplus +#include +#else +/* Note: to get rid of the following warning, you can #define SDL_MAIN_NOIMPL before including SDL_main.h + * in your C sourcefile that contains the standard main. Do *not* use SDL_MAIN_HANDLED for that, then SDL_main won't find your main()! + */ +#ifdef _MSC_VER +#pragma message("Note: Your platform needs the SDL_main implementation in a C++ source file. You can keep your main() in plain C (then continue including SDL_main.h there!) and create a fresh .cpp file that only contains #include ") +#elif defined(__GNUC__) /* gcc, clang, mingw and compatible are matched by this and have #warning */ +#warning "Note: Your platform needs the SDL_main implementation in a C++ source file. You can keep your main() in plain C and create a fresh .cpp file that only contains #include " +#endif /* __GNUC__ */ +#endif /* __cplusplus */ +#endif /* __WINRT__ etc */ #endif /* SDL_MAIN_HANDLED */ diff --git a/include/SDL3/SDL_main_impl.h b/include/SDL3/SDL_main_impl.h index c4646887f..11acf2e85 100644 --- a/include/SDL3/SDL_main_impl.h +++ b/include/SDL3/SDL_main_impl.h @@ -28,9 +28,12 @@ /* if someone wants to include SDL_main.h but doesn't want the main handing magic, (maybe to call SDL_RegisterApp()) they can #define SDL_MAIN_HANDLED first - _SDL_MAIN_NOIMPL is for SDL-internal usage (only affects implementation, - not definition of SDL_MAIN_AVAILABLE etc in SDL_main.h) */ -#if !defined(SDL_MAIN_HANDLED) && !defined(_SDL_MAIN_NOIMPL) + SDL_MAIN_NOIMPL is for SDL-internal usage (only affects implementation, + not definition of SDL_MAIN_AVAILABLE etc in SDL_main.h) and if the user wants + to have the SDL_main implementation (from this header) in another source file + than their main() function, for example if SDL_main requires C++ + and main() is implemented in plain C */ +#if !defined(SDL_MAIN_HANDLED) && !defined(SDL_MAIN_NOIMPL) #if defined(__WIN32__) || defined(__GDK__) @@ -103,6 +106,61 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) #define main SDL_main /* end of __WIN32__ and __GDK__ impls */ +#elif defined(__WINRT__) + +/* WinRT main based on SDL_winrt_main_NonXAML.cpp, placed in the public domain by David Ludwig 3/13/14 */ + +#include + +/* At least one file in any SDL/WinRT app appears to require compilation + with C++/CX, otherwise a Windows Metadata file won't get created, and + an APPX0702 build error can appear shortly after linking. + + The following set of preprocessor code forces this file to be compiled + as C++/CX, which appears to cause Visual C++ 2012's build tools to + create this .winmd file, and will help allow builds of SDL/WinRT apps + to proceed without error. + + If other files in an app's project enable C++/CX compilation, then it might + be possible for the .cpp file including SDL_main.h to be compiled without /ZW, + for Visual C++'s build tools to create a winmd file, and for the app to + build without APPX0702 errors. In this case, if + SDL_WINRT_METADATA_FILE_AVAILABLE is defined as a C/C++ macro, then + the #error (to force C++/CX compilation) will be disabled. + + Please note that /ZW can be specified on a file-by-file basis. To do this, + right click on the file in Visual C++, click Properties, then change the + setting through the dialog that comes up. +*/ +#ifndef SDL_WINRT_METADATA_FILE_AVAILABLE +#if !defined(__cplusplus) || !defined(__cplusplus_winrt) +#error The C++ file that includes SDL_main.h must be compiled as C++ code with /ZW, otherwise build errors due to missing .winmd files can occur. +#endif +#endif + +/* Prevent MSVC++ from warning about threading models when defining our + custom WinMain. The threading model will instead be set via a direct + call to Windows::Foundation::Initialize (rather than via an attributed + function). + + To note, this warning (C4447) does not seem to come up unless this file + is compiled with C++/CX enabled (via the /ZW compiler flag). +*/ +#ifdef _MSC_VER +#pragma warning(disable : 4447) +#endif + +/* Make sure the function to initialize the Windows Runtime gets linked in. */ +#ifdef _MSC_VER +#pragma comment(lib, "runtimeobject.lib") +#endif + +int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int) +{ + return SDL_WinRTRunApp(SDL_main, NULL); +} + +/* end of WinRT impl */ #elif defined(__IOS__) || defined(__TVOS__) #ifdef main diff --git a/src/SDL_internal.h b/src/SDL_internal.h index 855aa0c03..4ee473f5a 100644 --- a/src/SDL_internal.h +++ b/src/SDL_internal.h @@ -181,7 +181,7 @@ #endif #include -#define _SDL_MAIN_NOIMPL /* don't drag in header-only implementation of SDL_main */ +#define SDL_MAIN_NOIMPL /* don't drag in header-only implementation of SDL_main */ #include /* The internal implementations of these functions have up to nanosecond precision. diff --git a/src/dynapi/SDL_dynapi.c b/src/dynapi/SDL_dynapi.c index d1f627b59..2a21457ac 100644 --- a/src/dynapi/SDL_dynapi.c +++ b/src/dynapi/SDL_dynapi.c @@ -31,7 +31,7 @@ #endif #include -#define _SDL_MAIN_NOIMPL /* don't drag in header-only implementation of SDL_main */ +#define SDL_MAIN_NOIMPL /* don't drag in header-only implementation of SDL_main */ #include diff --git a/src/main/winrt/SDL_winrt_main_NonXAML.cpp b/src/main/winrt/SDL_winrt_main_NonXAML.cpp deleted file mode 100644 index 5fc3c4a41..000000000 --- a/src/main/winrt/SDL_winrt_main_NonXAML.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - SDL_winrt_main_NonXAML.cpp, placed in the public domain by David Ludwig 3/13/14 -*/ -#include -#include /* until this SDL_main impl is converted to header-only.. */ - -#include - -/* At least one file in any SDL/WinRT app appears to require compilation - with C++/CX, otherwise a Windows Metadata file won't get created, and - an APPX0702 build error can appear shortly after linking. - - The following set of preprocessor code forces this file to be compiled - as C++/CX, which appears to cause Visual C++ 2012's build tools to - create this .winmd file, and will help allow builds of SDL/WinRT apps - to proceed without error. - - If other files in an app's project enable C++/CX compilation, then it might - be possible for SDL_winrt_main_NonXAML.cpp to be compiled without /ZW, - for Visual C++'s build tools to create a winmd file, and for the app to - build without APPX0702 errors. In this case, if - SDL_WINRT_METADATA_FILE_AVAILABLE is defined as a C/C++ macro, then - the #error (to force C++/CX compilation) will be disabled. - - Please note that /ZW can be specified on a file-by-file basis. To do this, - right click on the file in Visual C++, click Properties, then change the - setting through the dialog that comes up. -*/ -#ifndef SDL_WINRT_METADATA_FILE_AVAILABLE -#ifndef __cplusplus_winrt -#error SDL_winrt_main_NonXAML.cpp must be compiled with /ZW, otherwise build errors due to missing .winmd files can occur. -#endif -#endif - -/* Prevent MSVC++ from warning about threading models when defining our - custom WinMain. The threading model will instead be set via a direct - call to Windows::Foundation::Initialize (rather than via an attributed - function). - - To note, this warning (C4447) does not seem to come up unless this file - is compiled with C++/CX enabled (via the /ZW compiler flag). -*/ -#ifdef _MSC_VER -#pragma warning(disable : 4447) -#endif - -/* Make sure the function to initialize the Windows Runtime gets linked in. */ -#ifdef _MSC_VER -#pragma comment(lib, "runtimeobject.lib") -#endif - -int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int) -{ - return SDL_WinRTRunApp(SDL_main, NULL); -} diff --git a/test/main.cpp b/test/main.cpp new file mode 100644 index 000000000..8e2fcbabb --- /dev/null +++ b/test/main.cpp @@ -0,0 +1,11 @@ +/* + * This file is supposed to be used to build tests on platforms that require + * the main function to be implemented in C++, which means that SDL_main's + * implementation needs C++ and thus can't be included in test*.c + * + * Placed in the public domain by Daniel Gibson, 2022-12-12 + */ + +#include + +// that's all, folks!