From 9e97a2c4a1852f11335f4c2104093fe654d32c0c Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 7 Jul 2022 11:07:41 +0200 Subject: [PATCH] ADDED: example: `core_window_should_close` --- examples/core/core_window_should_close.c | 75 ++++ examples/core/core_window_should_close.png | Bin 0 -> 15199 bytes .../examples/core_window_should_close.vcxproj | 390 ++++++++++++++++++ projects/VS2022/raylib.sln | 19 + 4 files changed, 484 insertions(+) create mode 100644 examples/core/core_window_should_close.c create mode 100644 examples/core/core_window_should_close.png create mode 100644 projects/VS2022/examples/core_window_should_close.vcxproj diff --git a/examples/core/core_window_should_close.c b/examples/core/core_window_should_close.c new file mode 100644 index 00000000..3bf902d6 --- /dev/null +++ b/examples/core/core_window_should_close.c @@ -0,0 +1,75 @@ +/******************************************************************************************* +* +* raylib [core] example - Window should close +* +* This example has been created using raylib 1.0 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include "raylib.h" + +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + const int screenWidth = 800; + const int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib [core] example - window should close"); + + SetExitKey(KEY_NULL); // Disable KEY_ESCAPE to close window, X-button still works + + bool exitWindowRequested = false; // Flag to request window to exit + bool exitWindow = false; // Flag to set window to exit + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!exitWindow) + { + // Update + //---------------------------------------------------------------------------------- + // Detect if X-button or KEY_ESCAPE have been presssed to close window + if (WindowShouldClose() || IsKeyPressed(KEY_ESCAPE)) exitWindowRequested = true; + + if (exitWindowRequested) + { + // A request for close window has been issued, we can save data before closing + // or just show a message asking for confirmation + + if (IsKeyPressed(KEY_Y)) exitWindow = true; + else if (IsKeyPressed(KEY_N)) exitWindowRequested = false; + } + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + if (exitWindowRequested) + { + DrawRectangle(0, 100, screenWidth, 200, BLACK); + DrawText("Are you sure you want to exit program? [Y/N]", 40, 180, 30, WHITE); + } + else DrawText("Try to close the window to get confirmation message!", 120, 200, 20, LIGHTGRAY); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file diff --git a/examples/core/core_window_should_close.png b/examples/core/core_window_should_close.png new file mode 100644 index 0000000000000000000000000000000000000000..4ef088ac5a0a84f5edfca40229fafb33b3eb2704 GIT binary patch literal 15199 zcmeAS@N?(olHy`uVBq!ia0y~yU{+vYU_8XZ1{4ubUVDOp!CKAJ#WAEJF8R-|udnOd z0u7{?7AxW)N;nvoT?~-pZM-NTft6saYCVv_o?^1Lx9va%M-LXlpr_2iP52;oNuY)e z+>I9{CtP%~#pMi#?E(^S8+z2X;dH|;h#NNIbOXoaZp#Vyb zqoFVw3Zvx$xX>Og9YOWlXef+^0<3v6nifXW!f0ARZtD+<9KqLPu8W|iH zlv&)SC-g4cOnzVDf-Z}jwZh`gToV>I=LBrT7G|SaY&hghSlZ$_dd@ZUEPFNTgwaqK zO$)#rG@2to<;Z9#jD`ZNIvGt1qiJC@Eg-k8=#e8D@)QpkNnOJ+7#`vD;Q#;s5pxfn zIAI~>nW1P9ayYAmEyYB$AGsln-1a2cQUqFP@M3zx!&y;ErY&yE-?|lF1?%_VV|=n{ z%C)D8wr{1@6?SR!xF0UtBD1)ZgJ)Zr__|MBllC~gu5s!9(|y|K$%lnucP=VV?*%p~ zr={X>x)f6haDCFe4xW|48$4po45lnwSg<+3VEKViiR&I zT>EHoz47AENmN;Dwc#vEeqQvrB&H=EtS>qrGVv`!kz76xdvHRPk$+q*8QZv z^^A>qvpsM-8htP63g2!;(cYZ5e z=xm0SnjQ;Vairm;SBo1@E#EOMnRmO5i50U^lvW=_S!@?ex0j=Bz;c7Y*I#-LrtukG zbn2e$%yv6d1(dLa*tFsbZhD{O)M{Q>r+n=1mWZ~N)9-h@k;?h#*YkVg-Ja9&SFAp! zZ8)lId-+?yn$2vh;*u9QTBjT69A8u_onY{z&_e&X)Lcf%w{IzO<^hf^FaKv$@V^&O zNb@|9Atk}f7zC^ZV|$m)1ZJ_d)^1Kx61uNn$e-RZExdQj4&mRz~o`l3MtfD1b|ku)$8=@ZB?@CYs-oN6*Je&apogp zikY5yO{N4=EznN`*}bOuY$3R?0Y)&cS=Bm417NbBwaOjT3c{AZL0MaN!o?$IxaLd^ zZZS&wGUJS=!}=_4z`{HDEBOfrGzOB1!+Ag_|7bn%g6BlWDx6ctzzPR{`2n6*=0z^@ zP$qDB_6tY=Go9~MoSr0@7(uhj%W%a3Z{tI8CQ$BLS%p0g+?+wxHz=HQa5@1LNhUa^ z)`6P-0P9s?3nG;K76dqV({!w9G&2xU)sAL{(aZoWsVE->AFUa{U6Ik6VYFrdHIIN@ z*3o7XrI{h&Cvcr##vYuV6JTF57MR>PuVpw<)Y~J_)1Y}BNw`Nm>I86yg4Qkf(TE^! zfMzr~jwVNV4|+6Hf`Vc+6h=b + + + + Debug.DLL + Win32 + + + Debug.DLL + x64 + + + Debug + Win32 + + + Debug + x64 + + + Release.DLL + Win32 + + + Release.DLL + x64 + + + Release + Win32 + + + Release + x64 + + + + {3FE7E9B6-49AC-4246-A789-28DB4644567B} + Win32Proj + core_window_should_close + 10.0 + core_window_should_close + + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + $(SolutionDir)..\..\examples\core + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\core + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\core + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\core + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\core + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\core + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\core + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\core + WindowsLocalDebugger + + + + + + Level3 + Disabled + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + /FS %(AdditionalOptions) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + Copy Debug DLL to output directory + + + + + + + Level3 + Disabled + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + Copy Debug DLL to output directory + + + + + Level3 + + + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + + + Level3 + + + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + + + Level3 + + + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + + + Copy Release DLL to output directory + + + + + Level3 + + + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + + + Copy Release DLL to output directory + + + + + + + + + + + {e89d61ac-55de-4482-afd4-df7242ebc859} + + + + + + \ No newline at end of file diff --git a/projects/VS2022/raylib.sln b/projects/VS2022/raylib.sln index 97967ff6..66830ce1 100644 --- a/projects/VS2022/raylib.sln +++ b/projects/VS2022/raylib.sln @@ -247,6 +247,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "models_loading_gltf", "exam EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "text_codepoints_loading", "examples\text_codepoints_loading.vcxproj", "{F2DB2E59-76BF-4D81-859A-AFC289C046C0}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core_window_should_close", "examples\core_window_should_close.vcxproj", "{3FE7E9B6-49AC-4246-A789-28DB4644567B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug.DLL|x64 = Debug.DLL|x64 @@ -2063,6 +2065,22 @@ Global {F2DB2E59-76BF-4D81-859A-AFC289C046C0}.Release|x64.Build.0 = Release|x64 {F2DB2E59-76BF-4D81-859A-AFC289C046C0}.Release|x86.ActiveCfg = Release|Win32 {F2DB2E59-76BF-4D81-859A-AFC289C046C0}.Release|x86.Build.0 = Release|Win32 + {3FE7E9B6-49AC-4246-A789-28DB4644567B}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64 + {3FE7E9B6-49AC-4246-A789-28DB4644567B}.Debug.DLL|x64.Build.0 = Debug.DLL|x64 + {3FE7E9B6-49AC-4246-A789-28DB4644567B}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32 + {3FE7E9B6-49AC-4246-A789-28DB4644567B}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32 + {3FE7E9B6-49AC-4246-A789-28DB4644567B}.Debug|x64.ActiveCfg = Debug|x64 + {3FE7E9B6-49AC-4246-A789-28DB4644567B}.Debug|x64.Build.0 = Debug|x64 + {3FE7E9B6-49AC-4246-A789-28DB4644567B}.Debug|x86.ActiveCfg = Debug|Win32 + {3FE7E9B6-49AC-4246-A789-28DB4644567B}.Debug|x86.Build.0 = Debug|Win32 + {3FE7E9B6-49AC-4246-A789-28DB4644567B}.Release.DLL|x64.ActiveCfg = Release.DLL|x64 + {3FE7E9B6-49AC-4246-A789-28DB4644567B}.Release.DLL|x64.Build.0 = Release.DLL|x64 + {3FE7E9B6-49AC-4246-A789-28DB4644567B}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32 + {3FE7E9B6-49AC-4246-A789-28DB4644567B}.Release.DLL|x86.Build.0 = Release.DLL|Win32 + {3FE7E9B6-49AC-4246-A789-28DB4644567B}.Release|x64.ActiveCfg = Release|x64 + {3FE7E9B6-49AC-4246-A789-28DB4644567B}.Release|x64.Build.0 = Release|x64 + {3FE7E9B6-49AC-4246-A789-28DB4644567B}.Release|x86.ActiveCfg = Release|Win32 + {3FE7E9B6-49AC-4246-A789-28DB4644567B}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2188,6 +2206,7 @@ Global {2F1B955B-275E-4D8E-8864-06FEC44D7912} = {AF5BEC5C-1F2B-4DA8-B12D-D09FE569237C} {F5FC9279-DE63-4EF3-B31F-CFCEF9B11F71} = {AF5BEC5C-1F2B-4DA8-B12D-D09FE569237C} {F2DB2E59-76BF-4D81-859A-AFC289C046C0} = {8D3C83B7-F1E0-4C2E-9E34-EE5F6AB2502A} + {3FE7E9B6-49AC-4246-A789-28DB4644567B} = {6C82BAAE-BDDF-457D-8FA8-7E2490B07035} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E926C768-6307-4423-A1EC-57E95B1FAB29}